From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796172823; b=S+UB1EyVjkBlluzJZk0zjjiobtSNdbtxBkEumwosUINb4hgDANQFE3uxARaB3Si+vaDR YJqsKMQIyWKo8FrNKoFjADDeujyjdevFkBVGE+0781OTCp64SymDZdEUFdJZcuzjmfs6T cnwoNDvymbsWDHy8upt7vkK22XGCsRgqQGsRYzu27xkC3+0cWKeLSKkX4xG4czV/9NGvy nJuGZBhTiz8qM9qFf+vWCxu9/9XYePAzHnGQwquKrmF+EOyMcGgLSzB/5/qKvRHq3frUi i+REsjwE3Ke6bi534cEbnEFGyW14iLhtkqHWQQXO7eLdJTUfXYSV+kxQCQIh/QphQFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796172823; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=sIRhQPXWqKp4+Vaq6JQv7ghTsxO0XXWSTDt5W7QR1wE=; b=LbgybGCTIo0Nlbz890jsAdAutIex7tE+R03iPZOQAlHFhJ9OGo5QY8Uf134ibEHpctAF enhxtUpE3K2t4wm4b9Z2iunEL/nF6/duGoEoQGbrfzGe4LwcN6gGuS94rdcsyyAJ97nGh C1I4Qnpi2iLZqFOz09WN88rfQqyTPZzaliKwzmCT14NHH3y9PMt+G98Zzg21u4pFrR2Cw PyOxWO/j1kCmKWx/M3loLhi3RXP1UUV8pmcPVlit1SXAACcAXeIgS/ov6NVAZX/9sEUtu WUQcH/5P7CAHKPVxxeNsrCHfSuxAEuk9u+kkpu/chRYfEph5vFBzmT7iVYp0bCrthHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BTGUgk3H; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09EAC606A31A; Wed, 2 Dec 2026 00:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BTGUgk3H Received: by smtp.kernel.org (Postfix) with ESMTPSA id A944E1F00893; Wed, 2 Dec 2026 00:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796172822; bh=sIRhQPXWqKp4+Vaq6JQv7ghTsxO0XXWSTDt5W7QR1wE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BTGUgk3HW2Pve8Lh/AMJWT2uKAREu/t8x9S+SMtrkMrieK2g9ABUGmBrNezY/o5Tv tHuyWJtECjxf4OJROdXhwU9TGH2+1zEQn4grH54YWo6Bui2/gKERsjM3V6T4I7YLVs 7H1r2jQmzIU+ADjdFV1CZbmx2Q9dFJKHHegwVXzv8fRtlF2P/NKkqakSecWxTVljE/ rl2YvILy8jlEUR0tL83JjEgV9GgLzWmXOIdfyvQYnrQ8Y7AGf3mDKyKsCR99fTygEJ hf+gxDTdnzrbJIth8gWGEwawEgQb7ZAkGIEfuKO2fGqP00mJsnJJzFL4DKyzx0mY8A tPQZRvX621npg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 7/7] Input: novatek-nvt-ts - add no-flash firmware download Reply-To: sashiko-reviews@lists.linux.dev To: "Qianhui Xu" Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com In-Reply-To: <20261202003159.1321846-7-xiaqinghuan@mail.ustc.edu.cn> References: <20261202003159.1321846-1-xiaqinghuan@mail.ustc.edu.cn> <20261202003159.1321846-7-xiaqinghuan@mail.ustc.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 00:53:42 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] Input: novatek-nvt-ts - DMA from stack in nvt_ts_spi_write() callers - [Medium] Input: novatek-nvt-ts - unbalanced IRQ/regulators if nvt_ts_start() fails -- commit ba7ffce013641ae13b88a77b35356567c7d1fd3e Author: Qianhui Xu Input: novatek-nvt-ts - add no-flash firmware download This commit adds firmware download support for flashless Novatek touchscreen controllers, uploading partitioned firmware images to SRAM when the controller powers up. > diff --git a/drivers/input/touchscreen/novatek-nvt-ts-core.c b/drivers/in= put/touchscreen/novatek-nvt-ts-core.c > index 4303d0901c91d..4d374235b2bfb 100644 > --- a/drivers/input/touchscreen/novatek-nvt-ts-core.c > +++ b/drivers/input/touchscreen/novatek-nvt-ts-core.c [ ... ] > @@ -169,9 +676,23 @@ static int nvt_ts_start(struct input_dev *dev) > return error; > } > =20 > - enable_irq(data->irq); > gpiod_set_value_cansleep(data->reset_gpio, 0); > =20 > + /* > + * A controller without on-board flash only starts reporting touches > + * once its firmware has been uploaded, and it loses the firmware when > + * it is powered down again. > + */ > + error =3D nvt_ts_load_firmware(data); > + if (error) { > + gpiod_set_value_cansleep(data->reset_gpio, 1); > + regulator_bulk_disable(ARRAY_SIZE(data->regulators), > + data->regulators); > + return error; > + } > + > + enable_irq(data->irq); > + > return 0; > } [Severity: Medium] Can a failure in nvt_ts_load_firmware() during nvt_ts_resume() unbalance data->irq and data->regulators? When the device is open, nvt_ts_suspend() calls nvt_ts_stop() to disable the IRQ and regulators, and nvt_ts_resume() calls nvt_ts_start(): drivers/input/touchscreen/novatek-nvt-ts-core.c:nvt_ts_stop() { disable_irq(data->irq); gpiod_set_value_cansleep(data->reset_gpio, 1); regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); } If nvt_ts_load_firmware() fails on resume, nvt_ts_start() disables the regulators and returns before calling enable_irq(data->irq), while input_device_enabled(data->input) remains true. When the input device is later closed or suspended again, nvt_ts_stop() runs a second time, calling regulator_bulk_disable() on already-disabled regulators and incrementing the IRQ disable depth to 2 so future opens can no longer re-enable data->irq. [ ... ] > diff --git a/drivers/input/touchscreen/novatek-nvt-ts-spi.c b/drivers/inp= ut/touchscreen/novatek-nvt-ts-spi.c > index c7b36e29cb983..5b878695f5ac7 100644 > --- a/drivers/input/touchscreen/novatek-nvt-ts-spi.c > +++ b/drivers/input/touchscreen/novatek-nvt-ts-spi.c > @@ -28,8 +28,17 @@ static int nvt_ts_spi_read(struct nvt_ts_data *data, u= 8 reg, u8 *buf, > return spi_write_then_read(spi, cmd, sizeof(cmd), buf, count); > } > =20 > +static int nvt_ts_spi_write(struct nvt_ts_data *data, const u8 *buf, > + size_t count) > +{ > + struct spi_device *spi =3D to_spi_device(data->dev); > + > + return spi_write(spi, buf, count); > +} [Severity: High] Does nvt_ts_spi_write() pass stack-allocated buffers directly to spi_write()? Unlike spi_write_then_read() in nvt_ts_spi_read(), spi_write() does not bounce tx_buf and requires DMA-safe memory. Callers in the firmware loader such as nvt_ts_fw_set_page(), nvt_ts_fw_write_byte(), nvt_ts_fw_write_value(), nvt_ts_fw_identify() and nvt_ts_fw_upload() pass stack arrays (buf, trim, reset_done and host_cmd) to nvt_ts_write_data(), which will fail DMA mapping with VMAP_STACK or corrupt stack memory on SPI controllers that use DMA. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202003159.1321= 846-1-xiaqinghuan@mail.ustc.edu.cn?part=3D7