[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZAnu/GlpS32BgmqG@kroah.com>
Date: Thu, 9 Mar 2023 15:36:44 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Oliver Neukum <oneukum@...e.com>,
Ye Xiang <xiang.ye@...el.com>, Arnd Bergmann <arnd@...db.de>,
Matthias Kaehlcke <mka@...omium.org>,
Lee Jones <lee@...nel.org>, Wolfram Sang <wsa@...nel.org>,
Tyrone Ting <kfting@...oton.com>,
Mark Brown <broonie@...nel.org>,
Bartosz Golaszewski <brgl@...ev.pl>, linux-usb@...r.kernel.org,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-spi@...r.kernel.org, linux-gpio@...r.kernel.org,
srinivas.pandruvada@...el.com, heikki.krogerus@...ux.intel.com,
sakari.ailus@...ux.intel.com, zhifeng.wang@...el.com,
wentong.wu@...el.com, lixu.zhang@...el.com
Subject: Re: [PATCH v4 2/5] gpio: Add support for Intel LJCA USB GPIO driver
On Thu, Mar 09, 2023 at 03:18:53PM +0100, Linus Walleij wrote:
> On Thu, Mar 9, 2023 at 2:53 PM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > On Thu, Mar 09, 2023 at 02:40:10PM +0100, Oliver Neukum wrote:
> > > On 09.03.23 08:10, Ye Xiang wrote:
> > >
> > > > +#define LJCA_GPIO_BUF_SIZE 60
> > > > +struct ljca_gpio_dev {
> > > > + struct platform_device *pdev;
> > > > + struct gpio_chip gc;
> > > > + struct ljca_gpio_info *gpio_info;
> > > > + DECLARE_BITMAP(unmasked_irqs, LJCA_MAX_GPIO_NUM);
> > > > + DECLARE_BITMAP(enabled_irqs, LJCA_MAX_GPIO_NUM);
> > > > + DECLARE_BITMAP(reenable_irqs, LJCA_MAX_GPIO_NUM);
> > > > + u8 *connect_mode;
> > > > + /* mutex to protect irq bus */
> > > > + struct mutex irq_lock;
> > > > + struct work_struct work;
> > > > + /* lock to protect package transfer to Hardware */
> > > > + struct mutex trans_lock;
> > > > +
> > > > + u8 obuf[LJCA_GPIO_BUF_SIZE];
> > > > + u8 ibuf[LJCA_GPIO_BUF_SIZE];
> > >
> > > And here we have a violation of DMA coherency rules.
> > > Basically you cannot embed buffers into other data structures
> > > if they can be subject to DMA.
> >
> > Huh?!
> >
> > The problem here is alignment. But other than that I can't see the issue with
> > embedding into structures the instances of which will be allocated on the heap.
>
> Yups. And I think the solution looks something like this:
>
> u8 obuf[LJCA_GPIO_BUF_SIZE] __aligned(8);
> u8 ibuf[LJCA_GPIO_BUF_SIZE] __aligned(8);
>
> __aligned(4) if it's 32bit DMA I guess? 8 always works that's
> why we use it all over the IIO subsystem.
To make it all simple, just make obuf and ibuf pointers to the data you
allocate with a call to kmalloc().
thanks,
greg k-h
Powered by blists - more mailing lists