From nobody Thu Apr 9 14:18:40 2026 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED8C6AD5A for ; Sat, 7 Mar 2026 21:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772918169; cv=none; b=oPl6dFasV6fjxzvtkXkBmb8cgd3Q3FkGSi7NNIYFcWFtNbngBRMJCR35Ny4OBaxN79LMJn0xNlL5RxOfbltOd0oJDDHj5oDIqTkwp4r6tdO0K7Ayj6lWi1Hx3CTgRgsncmst/R/0nayy058pOyjjGkuYKCoMjldsM5uSj8oCVh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772918169; c=relaxed/simple; bh=WrqL3yauu3lnqQOwYJcaBtVmyiMULhjAZfpSSlokRfk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=p+LmrOUwwLKzdp7to0CgdBUXNlQqIZ3+7Ay4obhaOglUBmQIyUXvsqNzobpN+PlTLFK3pgxAt24nco7ku3Oh1YtluPr+PHN7XvrXC6Ad7wR1pGjjzOPKrCipLqm0So6pWbaSfBbdMPIpKcooaI+aPrfCveZ2/In8GJq9VzGiErw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=eTXDVB8E; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="eTXDVB8E" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7d741f61ee5so189703a34.1 for ; Sat, 07 Mar 2026 13:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772918167; x=1773522967; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=iBhICo6K0vCDwfk5k1LFwGSmR+AACWQpZvfAyNHAL5o=; b=eTXDVB8EBn/D9oLg04HSY7pM0UEbg8IVS2sKv5LM+GLMsz6r7eU31bCEE/s5yUr5vB /kEBaAwe+E8hwFZY6Efy2o0Ya84B+3Ijm+ZqNzEQa+RRddh3dxD8NxrnWyQ8pAIDL/lM JwDmZXGyvl5qV5FOVb5Lfk2cRsi2so0qiZtJpdI8/jKfI/9/AXtNwRNdrsHyowiz/UbK RzzTyIEcmO6y8FDsnvGeL3u03KFJH/kyaQo+r7Oxo8jmqIjgZM32r/5xVRI1AGkdHuEW 0dzGeU13SueKz//sagLBacj0hJzAgkq27y32giQyGGq8UW8M7cR04jjCuQEMwWa8DTp2 +GLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772918167; x=1773522967; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iBhICo6K0vCDwfk5k1LFwGSmR+AACWQpZvfAyNHAL5o=; b=FVblf9RQmg/anUyMKioYKNyxNxD3rh+nufF7HR0COn+OEokrGs5dghMslJcUY93Ud3 ZEAjeK1esZxPv+kyhKcsGtxgo8wZDOX+73gxpcEpjJWN2Uu4JnG29mDr9S5Ygmv/5Rem 7HAjiPabWbSgrFUA/vj0GxRyXTa306fsWeoGLM6ugC8x0YXvgkD5IqeoRE+v+kPAkmwP ojHTw661UEvOxMVFxWdaK3xSEtNipWXPGulBsKRHws0KeoMF9QZgHteoSywCh32XrrRt FzWjCMagXdk/N2HzB8A+7cYlN3sLoM+Ss1uA1o/wdGsAi5UMKcUl57j5halM7r8i8nnN B6/w== X-Forwarded-Encrypted: i=1; AJvYcCXAIsXXZZrPzSCmBQE92gwQLmXvax5P0pvguWrBqPKo5/nElroYDmkvn7tYWnz9dT7YZsdi551hSd9bT2o=@vger.kernel.org X-Gm-Message-State: AOJu0YxinfY6EYq11R3737+96DqmwQFQz1BI4hKN2GlUNdb+p8juAysT eFINZm3ngy3wHKvoSBTkzXGyeuuc43kBppcZw58bVS4rGtDfKGTr0BFAvQe2uxsxFtg= X-Gm-Gg: ATEYQzzVpaNItSspaGRCDZoseX3uDL45azAgYi0GDDZ+EJWZNJGtV2z447kTjrSf2HO rjRGvWpcgvVVBEk9UMPUWKTWrlqqgVwoMdosJZWVeIymtG/byEZzttzjuoorzoWBQ8GMxHvBwIS Uuuf54EspDf/kd3eEiwV5Iy+9ggucDu6M5p7HkYuYqskqn3QtzO/ZGtrWjHELlCb2QPZzMGk2fG b5eSlxNBlBzBuShqLjaFFjXUorCX5zXjXtr1IrqR1ZInyKIF/3n3h0mRdwbvAGFLHvNYRyE6izX IimXswe41XPxhfVPz+ttBYsuAOebtZ94c0xbyGFV2YRDeggcHcZfWAXmxVZl8NlNBynGXIAFdp+ ANHJmEOi6szzU7Uh0Pbpm47cyH30JQtMdv0ekIr2PuDEBYVeS3RNALB6Y7lht2bAB4NNerYULdN OSLA82a+VJ7T2soTJ5T8U6nrHn5nYI X-Received: by 2002:a05:6830:82cb:b0:7d1:90ae:bc16 with SMTP id 46e09a7af769-7d726f46099mr4612141a34.8.1772918166863; Sat, 07 Mar 2026 13:16:06 -0800 (PST) Received: from [127.0.1.1] ([2600:8803:e7e4:500:cccf:5174:fa72:c520]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d738e3f421sm1949310a34.25.2026.03.07.13.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 13:16:05 -0800 (PST) From: David Lechner Date: Sat, 07 Mar 2026 15:15:55 -0600 Subject: [PATCH] iio: adc: ti-ads7950: use iio_push_to_buffers_with_ts_unaligned() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260307-iio-adc-ti-ads7950-declare-dma-buffer-v1-1-79b1309338df@baylibre.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yXNQQrCMBCF4auUWTsQI22NV5EuJsmMjmgrk1aE0 rsbdfX4Nv9bobApFzg1Kxi/tOg0Vux3DaQrjRdGzdXgne/cwfWoOiHlhLPWKX1oHWZOdzLG/CC Miwgbhtz6LojQMUaoraex6Pv3cx7+Lku8cZq/cdi2Dxx8dbSJAAAA X-Change-ID: 20260307-iio-adc-ti-ads7950-declare-dma-buffer-9d5269ffa8bb To: Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Dmitry Torokhov , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2706; i=dlechner@baylibre.com; h=from:subject:message-id; bh=WrqL3yauu3lnqQOwYJcaBtVmyiMULhjAZfpSSlokRfk=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBprJWN4HnG8bBFned+R+PJCel5v86OS8sLgWD6O w0iwIgVTvGJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaayVjQAKCRDCzCAB/wGP wIFWB/4mt5sZnK3pnw4mb9D3hxLc8gwRj4rzI8qvE+S5/MSGRSjBkuYihQnZYH140bDTyuiZdUL TBt5t9hC3hAWzEE2bzuOdS6AnXZ0P4VETLh0Bjb5CkwZ7laCT0reHqXuuqccXP52exNmrqyiG0T nyHbEFbFWv2UElE/KAodUZKyvv4c+o5sEE8zHaGl+MVgJLQQPnTaF5eYgS3KrHFHLcxl+seiTQa cbUUmHlKJInOE2Xv7BaIEVSeyEUhzlOyHD6z9Owl28fKq70gOtjlWIyj9uEjklKtSnDiRmEEVdr gRK5EsAzWzxluJD1ybKCxYWG7qC9HnmbbUPswZgBg1g3KSZ1 X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use iio_push_to_buffers_with_ts_unaligned() to avoid unaligned access when writing the timestamp in the rx_buf. The previous implementation would have been fine on architectures that support 4-byte alignment of 64-bit integers but could cause issues on architectures that require 8-byte alignment. Fixes: 902c4b2446d4 ("iio: adc: New driver for TI ADS7950 chips") Signed-off-by: David Lechner --- Since we were looking at this driver, I was going to convert this to use IIO_DECLARE_DMA_BUFFER_WITH_TS() but then I noticed that we actually have an unaligned access problem with the timestamp since we are ignoring the first two elements in the rx_buf when pushing the data to the buffer. Unfortunately, this will cause a merge conflict with the series Dmitry is working on. I don't think there is any rush to get this backported since no one has reported a crash from unaligned access. Since fixes should go before improvements, we could apply this to iio/togreg then Dmitry can rebase his series on top of it. --- drivers/iio/adc/ti-ads7950.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index bbe1ce577789..53825c8b350a 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -47,8 +47,6 @@ #define TI_ADS7950_MAX_CHAN 16 #define TI_ADS7950_NUM_GPIOS 4 =20 -#define TI_ADS7950_TIMESTAMP_SIZE (sizeof(int64_t) / sizeof(__be16)) - /* val =3D value, dec =3D left shift, bits =3D number of bits of the mask = */ #define TI_ADS7950_EXTRACT(val, dec, bits) \ (((val) >> (dec)) & ((1 << (bits)) - 1)) @@ -105,8 +103,7 @@ struct ti_ads7950_state { * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. */ - u16 rx_buf[TI_ADS7950_MAX_CHAN + 2 + TI_ADS7950_TIMESTAMP_SIZE] - __aligned(IIO_DMA_MINALIGN); + u16 rx_buf[TI_ADS7950_MAX_CHAN + 2] __aligned(IIO_DMA_MINALIGN); u16 tx_buf[TI_ADS7950_MAX_CHAN + 2]; u16 single_tx; u16 single_rx; @@ -313,8 +310,9 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, = void *p) if (ret < 0) goto out; =20 - iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2], - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts_unaligned(indio_dev, &st->rx_buf[2], + sizeof(u16) * TI_ADS7950_MAX_CHAN, + iio_get_time_ns(indio_dev)); =20 out: mutex_unlock(&st->slock); --- base-commit: 6f25a6105c41a7d6b12986dbe80ded396a5667f8 change-id: 20260307-iio-adc-ti-ads7950-declare-dma-buffer-9d5269ffa8bb Best regards, -- =20 David Lechner