From patchwork Sun Jun 13 15:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E8F0C48BE8 for ; Sun, 13 Jun 2021 15:21:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39ECC61358 for ; Sun, 13 Jun 2021 15:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbhFMPXO (ORCPT ); Sun, 13 Jun 2021 11:23:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:60962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbhFMPXO (ORCPT ); Sun, 13 Jun 2021 11:23:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C31E661285; Sun, 13 Jun 2021 15:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597672; bh=A2mZSbX/BRRKhma5z072BPclMFGaJIcuWPhmZbCWk0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D56jp3mmGxdduPvRmaq57RD/8/G5qNZX1IP+KGA65yhprOCzxoDJrrlAAPc82xZr2 czb66l2ZuYzBHcuE/43XZfxu9TXfrFHaLcu7aPfhx20Zzfn6f4SL1p8UsFRkFtNoY3 2x9YxB43feBD3GPPdD38FQjXiibUFzAyMKF9CJgNDWnUwvJNMALUslYG2WBfAct7Vj yWAP6J9pAVSIVoBon06WbnmjnnMLP2rRn9kKLW5/pn2yZRrUJEv+49+do3CENUNEK4 myt4F/jRFMyfoHVrG0+GiWLIJOpZ/JUr1hNKo0E+1hwx/JKYRSYZBNM2k3PYkeyIqQ X5eeqO2DQEAIg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Eugen Hristev Subject: [PATCH RESEND 1/8] iio: adc: at91-sama5d2: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:54 +0100 Message-Id: <20210613152301.571002-2-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: 5e1a1da0f8c9 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support") Signed-off-by: Jonathan Cameron Cc: Eugen Hristev --- drivers/iio/adc/at91-sama5d2_adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 6e8c28675947..ea5ca163d879 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -403,7 +403,8 @@ struct at91_adc_state { struct at91_adc_dma dma_st; struct at91_adc_touch touch_st; struct iio_dev *indio_dev; - u16 buffer[AT91_BUFFER_MAX_HWORDS]; + /* Ensure naturally aligned timestamp */ + u16 buffer[AT91_BUFFER_MAX_HWORDS] __aligned(8); /* * lock to prevent concurrent 'single conversion' requests through * sysfs. From patchwork Sun Jun 13 15:22:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D6C7C48BDF for ; Sun, 13 Jun 2021 15:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72A6C61357 for ; Sun, 13 Jun 2021 15:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbhFMPXQ (ORCPT ); Sun, 13 Jun 2021 11:23:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:60970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhFMPXP (ORCPT ); Sun, 13 Jun 2021 11:23:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C77261354; Sun, 13 Jun 2021 15:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597674; bh=QZLhUp1m0enuZlXvp/rqP4Zt2pi7nHEB4ftK9+HGlBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AE9CLkXtDRHi+PNQjL/FlZTVgQIwxdZ9/rqzZRxidJKTj6Xwvwxtrc4T8qXJGBmIA Ek7jiREl4X1ol/igpGzXcEYSP9OFXqqBtazf5h7qvA/5NKktCp+55108DZPf/X+QV4 0ZG8vXhKayiT7Spdu6hxwpXwvAGnpWMWG2RPldLqoqxi7xCG6ZOl7dLESnCwg7OpAv Yb1q8F+1iFJf57G8+Crpo7wy43QX25tEGmn+cYa+PWDbnSPlOqarDmFPjprfLSr2dr A4BQ703VRIY8KcHKnaSYcvtxk05vtNIKbCd/Q66eQbDUMu8MHXWSX2oI5rfXoKBbNM 08fbDPZLtGpEg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Andreas Klinger Subject: [PATCH RESEND 2/8] iio: adc: hx711: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:55 +0100 Message-Id: <20210613152301.571002-3-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: d3bf60450d47 ("iio: hx711: add triggered buffer support") Signed-off-by: Jonathan Cameron Cc: Andreas Klinger --- drivers/iio/adc/hx711.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 6a173531d355..f7ee856a6b8b 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -86,9 +86,9 @@ struct hx711_data { struct mutex lock; /* * triggered buffer - * 2x32-bit channel + 64-bit timestamp + * 2x32-bit channel + 64-bit naturally aligned timestamp */ - u32 buffer[4]; + u32 buffer[4] __aligned(8); /* * delay after a rising edge on SCK until the data is ready DOUT * this is dependent on the hx711 where the datasheet tells a From patchwork Sun Jun 13 15:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABB33C48BCF for ; Sun, 13 Jun 2021 15:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91EB361357 for ; Sun, 13 Jun 2021 15:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231931AbhFMPXR (ORCPT ); Sun, 13 Jun 2021 11:23:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:60976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhFMPXR (ORCPT ); Sun, 13 Jun 2021 11:23:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1282D61358; Sun, 13 Jun 2021 15:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597676; bh=iyAIIOgOWfYUCbhWSZ72K4nDwPr+DNsjgnbf+4mU8gU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rw/0/ExVS/1EPzwuG8mPt1y+T823j8ghIYR97bWEF7Nn4Yi6N1dE1yEZWwLsu8Fg5 jzvBBFSkYLI6UH7K0AXvN3W6dPyj5xht8+VmwffPrq03WO7vJR/nKKly6XpjgF15Gn atzZvAMLeKr6ZwSoHfQCM0Tg2KOLtAR9Lde0l0ad3+y1d1CyO4nrHqyhyl5rMRof6X edGHB3U5IOr8dd5bEQ39fpyJeWZD/zkxxdlDo12CcOqma2TyV8LHp6e2IceE0Byj1m AD3F/6EsSty/oQyBlHXl75yrMWpZbDkJsJC8lOTH/hTjG63x1NsM1PTkcF5bI94tpO OZ5kEa9Pb2q8w== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Andreas Klinger Subject: [PATCH RESEND 3/8] iio: adc: mxs-lradc: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:56 +0100 Message-Id: <20210613152301.571002-4-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Add a comment on why the buffer is the size it is as not immediately obvious. Found during an audit of all calls of this function. Fixes: 6dd112b9f85e ("iio: adc: mxs-lradc: Add support for ADC driver") Signed-off-by: Jonathan Cameron Cc: Andreas Klinger --- drivers/iio/adc/mxs-lradc-adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c index 1d99170d3328..bca79a93cbe4 100644 --- a/drivers/iio/adc/mxs-lradc-adc.c +++ b/drivers/iio/adc/mxs-lradc-adc.c @@ -115,7 +115,8 @@ struct mxs_lradc_adc { struct device *dev; void __iomem *base; - u32 buffer[10]; + /* Maximum of 8 channels + 8 byte ts */ + u32 buffer[10] __aligned(8); struct iio_trigger *trig; struct completion completion; spinlock_t lock; From patchwork Sun Jun 13 15:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39E26C48BCF for ; Sun, 13 Jun 2021 15:21:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2594761040 for ; Sun, 13 Jun 2021 15:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231947AbhFMPXV (ORCPT ); Sun, 13 Jun 2021 11:23:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:60996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhFMPXT (ORCPT ); Sun, 13 Jun 2021 11:23:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 956436135A; Sun, 13 Jun 2021 15:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597677; bh=2YrdloDFiGofABSM2biMcXE1AyP4jOJacY4rXJGqyQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ak+sx10dZOgY+D3kyx4pmFITqq6k/9Jy3GuURq5v8TsxnU8f2gSejp4o4/oTnp4q4 iVh3490d/ectTWCQw12biWY18g9NMUoi3v/X8JHIBDf6UHIzZt9XfrH+Ig+p6Ar1Ma 67SAQwgOhkESXCAqPv9nB7l//qR5AWGliE/PLy0PtUPqZ0pbJE2zojTP8SGfVwMljy zXC7RwwIAgztry7xks8kxLo44q5OCkTgAyizPcgp9DMCl87UlKabNdLapuNcx4/nuY CfDj5+byh0l4zj9Sf7G9ecZdqek8DvW8GYbc6O8OuIYTrYQBWtbiHLXaybkQ0iV6Av MciJNsVF9/Nlw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron Subject: [PATCH RESEND 4/8] iio: adc: ti-ads8688: Fix alignment of buffer in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:57 +0100 Message-Id: <20210613152301.571002-5-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Fixes: f214ff521fb1 ("iio: ti-ads8688: Update buffer allocation for timestamps") Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads8688.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c index 16bcb37eebb7..79c803537dc4 100644 --- a/drivers/iio/adc/ti-ads8688.c +++ b/drivers/iio/adc/ti-ads8688.c @@ -383,7 +383,8 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; - u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)]; + /* Ensure naturally aligned timestamp */ + u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8); int i, j = 0; for (i = 0; i < indio_dev->masklength; i++) { From patchwork Sun Jun 13 15:22:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D00C48BE8 for ; Sun, 13 Jun 2021 15:21:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 965D661040 for ; Sun, 13 Jun 2021 15:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231940AbhFMPXW (ORCPT ); Sun, 13 Jun 2021 11:23:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:32772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbhFMPXU (ORCPT ); Sun, 13 Jun 2021 11:23:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8934F61285; Sun, 13 Jun 2021 15:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597679; bh=EmaCDSVuN2EoRAgJ0f5x0SnwmyPJnN+RJlYUj4Gez84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApSagRJ7Rhhqq2ed2xs6eSsMeRoO9pL5r+A7DbGs/kMuxoaL47jK8uVi9rPeMwZKr si4VXiyHelaE6P8TxkJU/tHEjFloSZd/m9NI+5dbpUrXd++0SSSu4qLMA/vs7IFNlO pEOxotJyXlgUp6YR+4XBY1EzzGlXWlQoLp1355y1wle7JA4U8+YrI3r+cYP/8nfMkY uf2RucmVcdWGa9HWdR2hFm5FY6EolkaUUAwTWGqTZvierOAgogMYOSEamQMnoDPrRH Evu2B6bpPG17AqEJrCsGEC+LRTdZeHnHW6o6jbdNrqitE51KXP9luZZM5fu0To4qcf 91YXGVPa3INFg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Song Qiang Subject: [PATCH RESEND 5/8] iio: magn: rm3100: Fix alignment of buffer in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:58 +0100 Message-Id: <20210613152301.571002-6-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Here an explicit structure is not used, because this buffer is used in a non-trivial way for data repacking. Fixes: 121354b2eceb ("iio: magnetometer: Add driver support for PNI RM3100") Signed-off-by: Jonathan Cameron Cc: Song Qiang --- drivers/iio/magnetometer/rm3100-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index 4df5887fd04c..13914273c999 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -78,7 +78,8 @@ struct rm3100_data { bool use_interrupt; int conversion_time; int scale; - u8 buffer[RM3100_SCAN_BYTES]; + /* Ensure naturally aligned timestamp */ + u8 buffer[RM3100_SCAN_BYTES] __aligned(8); struct iio_trigger *drdy_trig; /* From patchwork Sun Jun 13 15:22:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4299C48BDF for ; Sun, 13 Jun 2021 15:21:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8324061040 for ; Sun, 13 Jun 2021 15:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231941AbhFMPXX (ORCPT ); Sun, 13 Jun 2021 11:23:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:32782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhFMPXW (ORCPT ); Sun, 13 Jun 2021 11:23:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61A116120E; Sun, 13 Jun 2021 15:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597681; bh=3/7ZH7g1j1rFfoo5SRi/tmpWpYw4Vi9sb+xRO6Uci58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JoOJrOew9U83dlBDsQTytPuU/9pm33vp0uZaq8DSBjW3Sz8WGTd6B7V/QwBAyOEFv 48vjvUOEy1kRGE70gjasUnwJmEXwwncHplZIvZ8/01HxqFglnJHNw/tt/eZYzUCvNO 0/iL/0FGTg78csNVjCfRB22wEOul0zO8pP6j1yU8FQ5bAlqVttSsGmaZH5/uls6yqR XzmTc/9H4l8x7sJzVEqsyFdkH+YCP3T8K0UZlP79BKiYrIY00+iomv7twlTQ2qD78C yHmEb36xwYwbQeaUjqZOO/4M7P/W+A+BE2dtxoYYWmxkL/BEaGRGs/TjKS7vlS0hf0 fCJB3lbNycvug== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Mathieu Othacehe Subject: [PATCH RESEND 6/8] iio: light: vcnl4000: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:22:59 +0100 Message-Id: <20210613152301.571002-7-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Here an explicit structure is not used, because the holes would necessitate the addition of an explict memset(), to avoid a kernel data leak, making for a less minimal fix. Found during an audit of all callers of iio_push_to_buffers_with_timestamp() Fixes: 8fe78d5261e7 ("iio: vcnl4000: Add buffer support for VCNL4010/20.") Signed-off-by: Jonathan Cameron Cc: Mathieu Othacehe --- drivers/iio/light/vcnl4000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 01772327a947..e02e92bc2928 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -908,7 +908,7 @@ static irqreturn_t vcnl4010_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct vcnl4000_data *data = iio_priv(indio_dev); const unsigned long *active_scan_mask = indio_dev->active_scan_mask; - u16 buffer[8] = {0}; /* 1x16-bit + ts */ + u16 buffer[8] __aligned(8) = {0}; /* 1x16-bit + naturally aligned ts */ bool data_read = false; unsigned long isr; int val = 0; From patchwork Sun Jun 13 15:23:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DA62C48BE8 for ; Sun, 13 Jun 2021 15:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0612161285 for ; Sun, 13 Jun 2021 15:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231948AbhFMPXY (ORCPT ); Sun, 13 Jun 2021 11:23:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:32790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbhFMPXY (ORCPT ); Sun, 13 Jun 2021 11:23:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 096C061357; Sun, 13 Jun 2021 15:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597683; bh=PF1US0c7Wsh9C/4TzIRkm0l7hg4wgena7Kc0Y2kWV9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkGfo7UeO0Q6FlseiBRAcnxlQ3JLo7/8pOAxuAk8zSOoKCf7AVcojoAOGNnTblDkZ G9pqrFx9R7NUlyd3YHICuTJEWqfwAWMPEChvZ9oMBPYXsDFSOYQ/5omDnq4lqjpM5+ zEl/rdiT9Rpphh00m845iJXk59O+aaDSP31zXCqnnc89hNiJsi6Kcm2uIMAwN4ByD2 a3WTismLKlpwU+DzHVUgOknqlkc21RBNNSgD8M+e6fgUWno2ZF85crGw5HbRTY4pAN LgtouDx52gpbWpbFsmELHl2fNA+v5k6xD0vIA8maVu5mlLivCX37E9l3KTorHZ6PAP etx4W1xNboFjw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Parthiban Nallathambi Subject: [PATCH RESEND 7/8] iio: light: vcnl4035: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:23:00 +0100 Message-Id: <20210613152301.571002-8-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Here an explicit structure is not used, because the holes would necessitate the addition of an explict memset(), to avoid a potential kernel data leak, making for a less minimal fix. Fixes: 55707294c4eb ("iio: light: Add support for vishay vcnl40352") Signed-off-by: Jonathan Cameron Cc: Parthiban Nallathambi --- drivers/iio/light/vcnl4035.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c index fd2f181b16db..0db306ee910e 100644 --- a/drivers/iio/light/vcnl4035.c +++ b/drivers/iio/light/vcnl4035.c @@ -102,7 +102,8 @@ static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct vcnl4035_data *data = iio_priv(indio_dev); - u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)]; + /* Ensure naturally aligned timestamp */ + u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8); int ret; ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer); From patchwork Sun Jun 13 15:23:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12317765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3580DC48BCF for ; Sun, 13 Jun 2021 15:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10D9C6120E for ; Sun, 13 Jun 2021 15:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbhFMPX0 (ORCPT ); Sun, 13 Jun 2021 11:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:32798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhFMPX0 (ORCPT ); Sun, 13 Jun 2021 11:23:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE63E61358; Sun, 13 Jun 2021 15:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623597685; bh=OsP7Jyl45mX+TaPWmlosk3K0gqYWkdCUU08UScKj36s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O+Ekdxn0PVUVWVWnbUNxc1++APw0a+dVOoogrN/H392WFqXceAdC5BA2BX6QnHSvy G4MIFx7nJ7I0ST5spjEkohFzOdIRemPO78NlgtrHopcGWpSmeWZFGZj1eqEUU3hs4W 64Zb1NS4flStvvpHmuLttQRlC+cVm7wynIhiw6BW9eshuBbtqIcXDqilHnrud3zQUQ FLfetqsP4KgP3IjamEvyNeaKL3CVedIbJ3UUhW0RVBj0BAdSkBAUWjdNg6/rLfb1HX iBRWXfqMOArkhsyGYv8z2aubaMar3qffjSTSftMS89QPrKVKaYDjaODnvD/8Hhc8IK qHH7ARXsN5YcA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Mathieu Othacehe Subject: [PATCH RESEND 8/8] iio: prox: isl29501: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Sun, 13 Jun 2021 16:23:01 +0100 Message-Id: <20210613152301.571002-9-jic23@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613152301.571002-1-jic23@kernel.org> References: <20210613152301.571002-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Add __aligned(8) to ensure the buffer passed to iio_push_to_buffers_with_timestamp() is suitable for the naturally aligned timestamp that will be inserted. Here an explicit structure is not used, because the holes would necessitate the addition of an explict memset(), to avoid a kernel data leak, making for a less minimal fix. Fixes: 1c28799257bc ("iio: light: isl29501: Add support for the ISL29501 ToF sensor.") Signed-off-by: Jonathan Cameron Cc: Mathieu Othacehe --- drivers/iio/proximity/isl29501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c index 90e76451c972..5b6ea783795d 100644 --- a/drivers/iio/proximity/isl29501.c +++ b/drivers/iio/proximity/isl29501.c @@ -938,7 +938,7 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct isl29501_private *isl29501 = iio_priv(indio_dev); const unsigned long *active_mask = indio_dev->active_scan_mask; - u32 buffer[4] = {}; /* 1x16-bit + ts */ + u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */ if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) isl29501_register_read(isl29501, REG_DISTANCE, buffer);