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 F2E27C433F5 for ; Wed, 4 May 2022 20:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234572AbiEDVC0 (ORCPT ); Wed, 4 May 2022 17:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232621AbiEDVCZ (ORCPT ); Wed, 4 May 2022 17:02:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E61640E40 for ; Wed, 4 May 2022 13:58:48 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id C4FCDB8298D for ; Wed, 4 May 2022 20:58:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68907C385A4; Wed, 4 May 2022 20:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651697925; bh=l1WJwsWLYz+ulbb8iY+KLKyiPv4eYktWOD8/eK71reE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Cx+Ooitoubx7NC80Q6JDmQwhS769Eu2v5aytOKGszOljSNae07pri5h3r/7ihguyS YMGZe2d5dgxRE2+lrEPm/CxheBkOzNcIXTneKO84GN49dXdZDvqnHNZ8z7RyDHJZ5l w4KueZ+EY+/Kz35XIVNF1FkdTXd+ffdxaLrCryhtuPL3o33VGrvh1JEoN4Kl4Msa2C I0yMS71zMf0KEkLdnEJHsztDO7LzFZbx0FsX44KB6W0pu2aaeNe0is21UZjBhtJd/4 TP3WmHZ0VXjOVZBhTP7Hg83f5ljS2wdk3j5v1lLBA519CUg+3w07gWxQ03lGrZzhWw XpDxxFzN9Iq3g== Date: Wed, 4 May 2022 22:06:57 +0100 From: Jonathan Cameron To: "Sa, Nuno" Cc: "linux-iio@vger.kernel.org" , Akinobu Mita , Alexandru Lazar , "Tachici, Alexandru" , "Miclaus, Antoniu" , Charles-Antoine Couret , "Tanislav, Cosmin" , Cristian Pop , David Lechner , Ivan Mikhaylov , Jacopo Mondi , Jean-Baptiste Maneyrol , Lars-Peter Clausen , Marcelo Schmitt , =?UTF-8?B?TcOlcnRlbg==?= Lindahl , Matt Ranostay , "Hennerich, Michael" , Michael Welling , Mugilraj Dhavachelvan , Navin Sankar Velliangiri , Paul Cercueil , Phil Reid , Puranjay Mohan , Ricardo Ribalda , Robert Jones , Rui Miguel Silva , Sean Nyekjaer , Tomas Melin , Tomislav Denis , Uwe =?UTF-8?B?S2xlaW5lLUvDtm5p?= =?UTF-8?B?Zw==?= , Jonathan Cameron , "catalin.marinas@arm.com" Subject: Re: [PATCH 00/92] IIO: Fix alignment of buffers for DMA Message-ID: <20220504220657.6f9f3f69@jic23-huawei> In-Reply-To: References: <20220503085935.1533814-1-jic23@kernel.org> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Wed, 4 May 2022 13:00:58 +0000 "Sa, Nuno" wrote: > Hi Jonathan, >=20 > > From: Jonathan Cameron > > Sent: Tuesday, May 3, 2022 10:58 AM > > To: linux-iio@vger.kernel.org > > Cc: Akinobu Mita ; Alexandru Lazar > > ; Tachici, Alexandru > > ; Miclaus, Antoniu > > ; Charles-Antoine Couret > antoine.couret@essensium.com>; Tanislav, Cosmin =20 > > ; Cristian Pop > > ; David Lechner ; > > Ivan Mikhaylov ; Jacopo Mondi > > ; Jean-Baptiste Maneyrol > > ; Lars-Peter Clausen > > ; Marcelo Schmitt ; > > M=C3=A5rten Lindahl ; Matt Ranostay > > ; Hennerich, Michael > > ; Michael Welling > > ; Mugilraj Dhavachelvan > > ; Navin Sankar Velliangiri > > ; Sa, Nuno ; Paul > > Cercueil ; Phil Reid > > ; Puranjay Mohan > > ; Ricardo Ribalda ; > > Robert Jones ; Rui Miguel Silva > > ; Sean Nyekjaer ; > > Tomas Melin ; Tomislav Denis > > ; Uwe Kleine-K=C3=B6nig > koenig@pengutronix.de>; Jonathan Cameron =20 > > ; catalin.marinas@arm.com > > Subject: [PATCH 00/92] IIO: Fix alignment of buffers for DMA > >=20 > > [External] > >=20 > > From: Jonathan Cameron > >=20 > > Many years ago, IIO started using ____cacheline_aligned to ensure > > that buffers that might be used for DMA were not sharing a cacheline > > with other data that might lead to DMA safety issues. > >=20 > > As it turns out, that was fine at the time, but not based on the > > correct alignment requirement (though I believe it was a conservative > > choice at the time). Note that on many architectures this was > > introducing > > unecessary padding. We should have been using > > ARCH_KMALLOC_MINALIGN > > as other subsystems such as crypto have done for a long time. > >=20 > > Patch 1 discription contains more information but in short, there are > > ARM64 SoCs out their that have a larger cachline size for caches > > beyond > > L1. In many cases they maintain coherency for all DMA devices > > attached > > and so this isn't a problem, but there are exceptions that do not. > >=20 > > So, this is a rather large patch set and just covers those drivers > > that are in the last kernel release and in drivers/iio. > >=20 > > Many of these drivers are somewhat old so I haven't specifically > > cc'd anyone so will be relying on those kind enough to sanity check > > patches on drivers that are beyond their own. > >=20 > > Given there is ongoing discussion around reducing the alignment > > requirements where possible, I've adopted the existing IIO_ALIGN > > define througout. That way we have a single point to update if > > that becomes relevant in future. > > =20 >=20 > Nice to see this in... Since we are here, I guess in a couple of patches = where we have: >=20 > struct { > ... > u8 rx[] __aligned(); > u8 tx[] __aligned(); > }; >=20 > we could make it such that only the first member is aligned. But bah, I g= et that this > is already a huge patchset to diverge from it. Anyhow, Yup. I thought about tidying those up but decided it would just make things harder to explain so could be done as a follow up. I should have said so in the cover letter though! I particularly like the case where (a long time ago) I added a question on whether there was a need for separate alignment and left that question in the final code. Oops. >=20 > Acked-by: Nuno S=C3=A1 Thanks for looking through all these. We haven't yet concluded on the questions of naming and possible additional define for __aligned(XXX) but if we do make such a change it should be purely mechanical hence I'll keep all the tags people have given and not bother them again :) Thanks, Jonathan