From patchwork Sun Aug 7 15:12:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12938175 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 44286C3F6B0 for ; Sun, 7 Aug 2022 15:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbiHGPCK (ORCPT ); Sun, 7 Aug 2022 11:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234067AbiHGPCJ (ORCPT ); Sun, 7 Aug 2022 11:02:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0846263 for ; Sun, 7 Aug 2022 08:02:07 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 50D9460F67 for ; Sun, 7 Aug 2022 15:02:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8915DC433C1; Sun, 7 Aug 2022 15:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659884526; bh=mtfiBmCMLT5hsnF7pu5nJeA4tweQ5srfRQmvOfHKkJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ooB/MCY4EaLcq9DrOjxFpaSwPGniLjhPTGk6lHAXwQnGJXzcr77x8TXCjSnsTZKUd jtSaIJ2HwgsCOWPHQPF9nhAAKxrfj6Xjpwt07qU1rrUzdkKmQ6CB5TcKBwmD1o3VBo OIMiWBh3e83+4ge7ixEEeZtOiC/Olxv9Og+VzkFnJn6nV41sIbrUj6RzifmxFw6J3D KGIfAzADR5z3+mvd1I14FYMsfoJihC9cCKtaaPpmZXHkGFss1YIxYUGctqU0kUXEr5 nsdX/WTmX4iC4b0syHBfwdu8chCg96FJI8l2ABxfaLdCn93AHuGCzJMG3130cRorX/ zTsyCFrD6pBDQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron Subject: [PATCH 1/4] staging: iio: frequency: ad9832: Fix alignment for DMA safety Date: Sun, 7 Aug 2022 16:12:15 +0100 Message-Id: <20220807151218.656881-2-jic23@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220807151218.656881-1-jic23@kernel.org> References: <20220807151218.656881-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron ____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/frequency/ad9832.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index f43464db618a..ce9fcba6bc5c 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -112,7 +112,7 @@ struct ad9832_state { * transfer buffers to live in their own cache lines. */ union { - __be16 freq_data[4]____cacheline_aligned; + __be16 freq_data[4] __aligned(IIO_DMA_MINALIGN); __be16 phase_data[2]; __be16 data; }; From patchwork Sun Aug 7 15:12:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12938176 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 D4256C19F2A for ; Sun, 7 Aug 2022 15:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234067AbiHGPCM (ORCPT ); Sun, 7 Aug 2022 11:02:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbiHGPCL (ORCPT ); Sun, 7 Aug 2022 11:02:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB046261 for ; Sun, 7 Aug 2022 08:02:10 -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 79CBCB80B88 for ; Sun, 7 Aug 2022 15:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49B96C433D6; Sun, 7 Aug 2022 15:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659884528; bh=jczaYgwshWH1gPBR59OPG7NoLtPIIA1Ja3a29qnXd7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tbgl6x4h1AuJLkphGzKa7riabPJPI5FOUNKkfEsAe2n7hMaStjSg7uuubg2X204nr 1TVwvryJzkYoqJn4nc8hLv9uZT5xQ0mL/Uqvo05PEQF+OHi177y8ORVTLdEWN9m6Kl A6d5dxVc4b0PwKQPOMeOQ78eOhIyNzZdFSKCApnfiQbZ2cm3QXt7T40NyfSRbhBp3E /nvfdjKldEhVhPjzqESV/X4rg1/habWJiPvPqUt1KiiRW0rdfGoR81mOZp+X5W+ImR GFHh1ku7z1VgOL5yEVOKVhLWja/08GFpOjxLjqvH96T00Q+2deSc4pb9bcJ4lnQ93p p8ZmbRovslL5w== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron Subject: [PATCH 2/4] staging: iio: frequency: ad9834: Fix alignment for DMA safety Date: Sun, 7 Aug 2022 16:12:16 +0100 Message-Id: <20220807151218.656881-3-jic23@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220807151218.656881-1-jic23@kernel.org> References: <20220807151218.656881-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron ____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/frequency/ad9834.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 94b131ef8a22..2b4267a87e65 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -83,7 +83,7 @@ struct ad9834_state { * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. */ - __be16 data ____cacheline_aligned; + __be16 data __aligned(IIO_DMA_MINALIGN); __be16 freq_data[2]; }; From patchwork Sun Aug 7 15:12:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12938177 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 1B74DC19F2A for ; Sun, 7 Aug 2022 15:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234126AbiHGPCQ (ORCPT ); Sun, 7 Aug 2022 11:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbiHGPCP (ORCPT ); Sun, 7 Aug 2022 11:02:15 -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 D72C96261 for ; Sun, 7 Aug 2022 08:02:12 -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 8CAABB80CC7 for ; Sun, 7 Aug 2022 15:02:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8EDC433D7; Sun, 7 Aug 2022 15:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659884530; bh=PFoyiJf5SuRaVq5+C1txhCA7YyWswLSlz/r+vGYOoTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZSy8gJ1dwwwov6lpg3jojEl5Y+MO6Da+nvyydpSxhAatU/qeSf5aoxIWMKlpzK6Ld /yOskJ9jgAeI7/k0Hl8dEG+XrYXQDzvv6vdWXurX+HBCe0rlum+M8JT70ekdG6JjGa 5rYYfqflUoXNaRWalWLk0YoB81cT/HD6cTtZGT7Fan2/IGvXIzYbMIjolDLoCsLgIF Se3Onw93iMu2Zifn5HCCbyeBBKE3ZMpKLCV5zs+2KwlPZJAcUK188TZGKHQa158zeH bGyfo0ArxviASGte3CDoh5wPkZkgDqPupu1E0wBO9f1W+eHYfYB7XdhwkXqDBb+Ipg WcEcA0+H56XSA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Rodrigo Siqueira Subject: [PATCH 3/4] staging: iio: meter: ade7854: Fix alignment for DMA safety Date: Sun, 7 Aug 2022 16:12:17 +0100 Message-Id: <20220807151218.656881-4-jic23@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220807151218.656881-1-jic23@kernel.org> References: <20220807151218.656881-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron ____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. Signed-off-by: Jonathan Cameron Cc: Rodrigo Siqueira --- drivers/staging/iio/meter/ade7854.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/meter/ade7854.h b/drivers/staging/iio/meter/ade7854.h index a51e6e3183d3..7a49f8f1016f 100644 --- a/drivers/staging/iio/meter/ade7854.h +++ b/drivers/staging/iio/meter/ade7854.h @@ -162,7 +162,7 @@ struct ade7854_state { int bits); int irq; struct mutex buf_lock; - u8 tx[ADE7854_MAX_TX] ____cacheline_aligned; + u8 tx[ADE7854_MAX_TX] __aligned(IIO_DMA_MINALIGN); u8 rx[ADE7854_MAX_RX]; }; From patchwork Sun Aug 7 15:12:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12938178 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 C7433C25B0D for ; Sun, 7 Aug 2022 15:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234376AbiHGPCQ (ORCPT ); Sun, 7 Aug 2022 11:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbiHGPCP (ORCPT ); Sun, 7 Aug 2022 11:02:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3256F6263 for ; Sun, 7 Aug 2022 08:02:13 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B6AF960F6C for ; Sun, 7 Aug 2022 15:02:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF26CC433C1; Sun, 7 Aug 2022 15:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659884532; bh=FP/be31CKfNeC0fXGZqpIrfbAK+dYnAz9pdbY8yUWn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSjliznFdUcN71hp1cABc8XkUHaGuW/MA+GdE6v4LaWmsXa77GAzWKGrrzfILnplg 1lJ92W3keznuk5rSZDue2QIKYq4oqGOCUl5yjddpi0WmJ0yAqly3DjaxEPOZl7r6of Z6EypzL6OYWO6aO/BtMSl5i5/WG8+gftHeSGAxMT/LJh7D82lcQ8SPD/AbvlmcjkUW S4kLnUaUPPgoKMZENmyxZ/UJE8WQP3ChGq2p6w4Vdq6YBxoVqezQ+YsciihgMVPyZo VMdZGNP9BV52JmJmBn5oR2rPZDMsZi77F47eiRDx39YsW214SG5+6uZBDVh07dA/og 6aGLZmoGnRErw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron Subject: [PATCH 4/4] staging: iio: resolver: ad2s1210: Fix alignment for DMA safety Date: Sun, 7 Aug 2022 16:12:18 +0100 Message-Id: <20220807151218.656881-5-jic23@kernel.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220807151218.656881-1-jic23@kernel.org> References: <20220807151218.656881-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron ____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. As the tx[] an rx[] buffers are only used in the same SPI exchanges, we should be safe with them on the same cacheline. Hence only mark the first one __aligned(IIO_DMA_MINALIGN). Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index c0b2716d0511..e4cf42438487 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -94,8 +94,8 @@ struct ad2s1210_state { bool hysteresis; u8 resolution; enum ad2s1210_mode mode; - u8 rx[2] ____cacheline_aligned; - u8 tx[2] ____cacheline_aligned; + u8 rx[2] __aligned(IIO_DMA_MINALIGN); + u8 tx[2]; }; static const int ad2s1210_mode_vals[4][2] = {