linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Oliver Neukum <oneukum@suse.com>, Ye Xiang <xiang.ye@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Matthias Kaehlcke <mka@chromium.org>, Lee Jones <lee@kernel.org>,
	Wolfram Sang <wsa@kernel.org>, Tyrone Ting <kfting@nuvoton.com>,
	Mark Brown <broonie@kernel.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-usb@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
	linux-gpio@vger.kernel.org, srinivas.pandruvada@intel.com,
	heikki.krogerus@linux.intel.com, sakari.ailus@linux.intel.com,
	zhifeng.wang@intel.com, wentong.wu@intel.com,
	lixu.zhang@intel.com
Subject: Re: [PATCH v4 2/5] gpio: Add support for Intel LJCA USB GPIO driver
Date: Thu, 9 Mar 2023 15:36:44 +0100	[thread overview]
Message-ID: <ZAnu/GlpS32BgmqG@kroah.com> (raw)
In-Reply-To: <CACRpkdYQfT=JXvmjKR_9O74H2dmwx1EF4QjCHM6fKAetpbrMOg@mail.gmail.com>

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@linux.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

  reply	other threads:[~2023-03-09 14:37 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  7:10 [PATCH v4 0/5] Add Intel LJCA device driver Ye Xiang
2023-03-09  7:10 ` [PATCH v4 1/5] mfd: Add support for Intel LJCA device Ye Xiang
2023-03-09  7:49   ` Greg Kroah-Hartman
2023-03-09  9:10     ` Ye, Xiang
2023-03-09  9:26       ` Greg Kroah-Hartman
2023-03-09 10:16         ` Ye, Xiang
2023-03-09  7:52   ` Greg Kroah-Hartman
2023-03-09  9:31     ` Ye, Xiang
2023-03-09  9:41       ` Greg Kroah-Hartman
2023-03-09 10:06         ` Andi Shyti
2023-03-09 15:45           ` Ye, Xiang
2023-03-09 15:58             ` Greg Kroah-Hartman
2023-03-09 17:42               ` Ye, Xiang
2023-03-09  7:56   ` Arnd Bergmann
2023-03-09 10:00     ` Ye, Xiang
2023-03-09 11:03     ` Mark Brown
2023-03-09 11:30       ` Arnd Bergmann
2023-03-09 12:53   ` Oliver Neukum
2023-03-10  4:14     ` Ye, Xiang
2023-03-13 13:27       ` Oliver Neukum
2023-03-14  7:15         ` Ye, Xiang
2023-03-09  7:10 ` [PATCH v4 2/5] gpio: Add support for Intel LJCA USB GPIO driver Ye Xiang
2023-03-09 13:40   ` Oliver Neukum
2023-03-09 13:52     ` Andy Shevchenko
2023-03-09 14:06       ` Greg Kroah-Hartman
2023-03-09 14:18       ` Linus Walleij
2023-03-09 14:36         ` Greg Kroah-Hartman [this message]
2023-03-09 14:48         ` Arnd Bergmann
2023-03-09 17:37           ` Oliver Neukum
2023-03-09 17:30       ` Oliver Neukum
2023-03-10  5:01     ` Ye, Xiang
2023-03-10  7:11       ` Greg Kroah-Hartman
2023-03-10  7:39         ` Ye, Xiang
2023-03-10  7:53           ` Greg Kroah-Hartman
2023-03-10  8:59             ` Ye, Xiang
2023-03-11 12:13   ` Krzysztof Kozlowski
2023-03-12 15:40     ` Ye, Xiang
2023-03-09  7:10 ` [PATCH v4 3/5] i2c: Add support for Intel LJCA USB I2C driver Ye Xiang
2023-03-09  7:10 ` [PATCH v4 4/5] spi: Add support for Intel LJCA USB SPI driver Ye Xiang
2023-03-09  7:11 ` [PATCH v4 5/5] Documentation: Add ABI doc for attributes of LJCA device Ye Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAnu/GlpS32BgmqG@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kfting@nuvoton.com \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lixu.zhang@intel.com \
    --cc=mka@chromium.org \
    --cc=oneukum@suse.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=srinivas.pandruvada@intel.com \
    --cc=wentong.wu@intel.com \
    --cc=wsa@kernel.org \
    --cc=xiang.ye@intel.com \
    --cc=zhifeng.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).