From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 6FC183B6347 for ; Sun, 3 May 2026 14:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777817837; cv=none; b=UmBWmEzPZdXK4Ef7sqtX6yXiPHVhbk/p6xy5QlBZ7VjcUEEqt9UBNIYm9XzSQtkUc682PBHlgha/7o6l1u7rEFn11ZJV+LwFk5XOn/kUxn3gzuRZoWDznHtlSEC040+9qgIgKspgcizYKO/HCPqIPNLVSEwPXXFsK5e2cQ8BjNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777817837; c=relaxed/simple; bh=yRozUyojZfZK0RqFIQxSQtMQHsJ16Kwd9wCnDsCZXRs=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=TxrIZyakxc7GFVG1WujtbFSj/RczkSs8f31ET6aUUgbnpBqXB4+g3umoZzQQOr96QV18y3wV9sww91f2Jbn4SzkT9lqA9K3J6yabRI9jL6ppWRiVWJYmQHzyN+U2pZ0BqpRiWVdrpWnmDJo3mpA55I0pRgwbRoMFYtIpbiHBwDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZA24N1Da; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZA24N1Da" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-365425c98c6so79534a91.0 for ; Sun, 03 May 2026 07:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777817836; x=1778422636; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=2IgW7hnthbt48/vAXh96SJ1gPwAAHh0EsYwYa2W+GNA=; b=ZA24N1DaWkb60XFX6f59HHVenfqWlK5tr/NrRR0wyaP9bdV3Y5st6sw1/hu42sncGw RrYBYx74CzKaqkGqGBnigwsicixo/66LV34GapXSby0Doe3lFyqixh6+CuEFk01qvIsM hedI25dNLMbfyXE9v4sGEMdYxe6Wt8mxBZE2ulWYCcxwHvX0SIu0d3xRhDM9juphzd9a IzWbZvnsdSgVvjHaNnngK6nzbE2AF4Q2jNmEOTJEdQTniWly7B7iqWti4P36ZzyDv7t/ DRgzYopTNyROhXywplh8VQK3Ta2uRFOhBgmPbxGgZouBdhuzrVlH7VRFp7LSIUiQPBWJ iSRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777817836; x=1778422636; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2IgW7hnthbt48/vAXh96SJ1gPwAAHh0EsYwYa2W+GNA=; b=Qk/RisXMG+Ghrd6B4RHrjjQS41N0PMmchLicKR1ppkLVgiiws+bT+mLv6LO8f+w4Tx zJlnTcOUbOZXuVFBtSCvmvpOvG+5tOw/QDYi7nr/8toLxHYSSOLfcLcs3jB+KWbSlUQS NlhO3/Nyzn+Paec241pErQZS866M+j/9st+m/bBVfp+VI80p/U0PLgTcpEguR7N07do/ D00ohVjKE9vP0MWfp+N14LHTYxmccUVOsmtw2yqAeB5Q8a87yN/FehI9y98t/p4tor8p yZfmo5pufnJXiJ+ALwAxIFsYAdGKh7dzClICLKi51YttwnH6F9RYY40O3Uwv91XqoUJg 9Xsg== X-Forwarded-Encrypted: i=1; AFNElJ9uZn6th08AIQzXn5xpxdDg+LGly47WyO1V1W6+7oEzXEWMV4eMfVZVH8IZOAChjMQgFSnQqy8+3bCOYUs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywem4yriii46oQSSQaSgeEBQZizc6nBMvKHdiYnin2VitqBCPI/ ZvVoMoXTsP6ywE+TH2ukmlYl6wTUm4PolP/UfqLZ5ox205JsRnGMrr0W X-Gm-Gg: AeBDieukvP0gSCIdg88q79FqKU4Wqy8bTBrYIGBPVIlCkRCsgLU7eLFT6VooEQetndg 414Y0mseaWhMTCysg3AxLZLIPmm+ONCdmTNsAsLmeH99zgO8meDnBON4hRMf8BW4YlCwmD/LlRI eJkWtPvL5JK2G6SzYjX69gXq0CD097xTR/DDa+bzmneSlyYMSVULBbCUuiRy93ibHkMiXLpjsyl seOODqTcdvtQzjk0bbxj4TQUc9c2+UlRFwjnyOwrm0LVylN3UJyGlHonLpTjpBWvtp/dzgVCXpK z9Zq1RNKYDj+zthmY3ZcAfGCtfR2XIIGMSI6OcWdFWtIUc9C8ZIpAVv6vWj2gLrWAxtSlCvYcvh n1GS0oIGHi8RVhEAM6b6l/e0/x2/aSB/z731+tADRDwlkiJfDsmlBSS0eF2cV0enZucSD6vfh9s lU9y0iAbvsRZnIrkb19UVI+4fA7fNyE6j/fQbbpV4hMm5UQNZx5M0c01Y= X-Received: by 2002:a17:90b:48cb:b0:364:b4e7:729b with SMTP id 98e67ed59e1d1-3650ce47351mr7394878a91.21.1777817835587; Sun, 03 May 2026 07:17:15 -0700 (PDT) Received: from ehlo.thunderbird.net ([2401:4900:c032:ba9d:4953:28:24e7:1e48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ebec736dsm8335235a91.3.2026.05.03.07.17.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 May 2026 07:17:15 -0700 (PDT) Date: Sun, 03 May 2026 19:47:03 +0530 From: Sanjay Chitroda To: Jonathan Cameron CC: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, mingo@kernel.org, christophe.jaillet@wanadoo.fr, nabijaczleweli@nabijaczleweli.xyz, kees@kernel.org, kyungmin.park@samsung.com, k.wrona@samsung.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v7_9/9=5D_iio=3A_ssp=5Fsensors=3A_re?= =?US-ASCII?Q?use_embedded_RX_buffer_for_SPI_transfers?= User-Agent: Thunderbird for Android In-Reply-To: <20260426153540.3d43a085@jic23-huawei> References: <20260426091710.3722035-1-sanjayembedded@gmail.com> <20260426091710.3722035-10-sanjayembedded@gmail.com> <20260426153540.3d43a085@jic23-huawei> Message-ID: 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 On 26 April 2026 8:05:40=E2=80=AFpm IST, Jonathan Cameron wrote: >On Sun, 26 Apr 2026 14:47:10 +0530 >Sanjay Chitroda wrote: > >> From: Sanjay Chitroda >>=20 >> Avoid allocating a temporary DMA buffer in the interrupt context when >> handling hub-to-AP and AP-to-hub SPI write messages=2E >>=20 >> Replace the dynamically allocated RX buffer with a fixed-size, >> preallocated buffer embedded in the driver structure and reused for all >> SPI receive operations=2E This removes memory allocation from the >> IRQ path, simplifies lifetime management=2E >>=20 >> Signed-off-by: Sanjay Chitroda > >> diff --git a/drivers/iio/common/ssp_sensors/ssp_spi=2Ec b/drivers/iio/c= ommon/ssp_sensors/ssp_spi=2Ec >> index 870214551f0b=2E=2Ee41da88bf96d 100644 >> --- a/drivers/iio/common/ssp_sensors/ssp_spi=2Ec >> +++ b/drivers/iio/common/ssp_sensors/ssp_spi=2Ec >> @@ -339,7 +339,7 @@ static int ssp_parse_dataframe(struct ssp_data *dat= a, char *dataframe, int len) >> /* threaded irq */ >> int ssp_irq_msg(struct ssp_data *data) >> { >> - char *buffer; >> + char *buffer =3D data->rx_buf; >> u8 msg_type; >> int ret; >> u16 length, msg_options; >> @@ -383,19 +383,12 @@ int ssp_irq_msg(struct ssp_data *data) >> * but the slave should not send such ones - it is to >> * check but let's handle this >> */ >> - buffer =3D kmalloc(length, GFP_KERNEL | GFP_DMA); >As bellow=2E > >> - if (!buffer) { >> - ret =3D -ENOMEM; >> - goto _unlock; >> - } >> =20 >> /* got dead packet so it is always an error */ >> ret =3D spi_read(data->spi, buffer, length); >> if (ret >=3D 0) >> ret =3D -EPROTO; >> =20 >> - kfree(buffer); >> - >> dev_err(SSP_DEV, "No match error %x\n", >> msg_options); >> =20 >> @@ -428,22 +421,13 @@ int ssp_irq_msg(struct ssp_data *data) >> mutex_unlock(&data->pending_lock); >> break; >> case SSP_HUB2AP_WRITE: >> - buffer =3D kzalloc(length, GFP_KERNEL | GFP_DMA); >Is there any chance that GFP_DMA marking is needed? > As per my understanding, this must be legacy flag as there is no direct us= e of any dma_* API=2E marking should be redundant and safe to drop=2E >> - if (!buffer) >> - return -ENOMEM;