Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E06DC61DA4 for ; Thu, 9 Mar 2023 14:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbjCIOHs (ORCPT ); Thu, 9 Mar 2023 09:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbjCIOHI (ORCPT ); Thu, 9 Mar 2023 09:07:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F02E05D747; Thu, 9 Mar 2023 06:06:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7584C61B5C; Thu, 9 Mar 2023 14:06:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5766AC433EF; Thu, 9 Mar 2023 14:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678370774; bh=HukZ+ILxzTnCQfpiikli+vpJ+j7QZXr1rOExU9Cd028=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A7w0BiKmJDFqnf6FXNmD0HW/rcBRaXuGdvtl/atJt2ssNfdcEieJ5YyfIALm53wLC cgIMAHNHnbHvWfY9g6zZcHICQFsiHvDJNq2sx9TcWl8DAjgCrjnWA/G/jIKMfspZiI PrIOXv6CaBrI25isoxOuosC+ZtG82vx0B9SKkWpM= Date: Thu, 9 Mar 2023 15:06:11 +0100 From: Greg Kroah-Hartman To: Andy Shevchenko Cc: Oliver Neukum , Ye Xiang , Arnd Bergmann , Matthias Kaehlcke , Lee Jones , Wolfram Sang , Tyrone Ting , Mark Brown , Linus Walleij , Bartosz Golaszewski , 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 Message-ID: References: <20230309071100.2856899-1-xiang.ye@intel.com> <20230309071100.2856899-3-xiang.ye@intel.com> <2865f3d0-428b-0df1-fc50-f6af3cb9dac3@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 09, 2023 at 03:52:59PM +0200, Andy Shevchenko 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. As you said, the problem is alignment.