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=1796443089; b=Vd18WYcn7HKa181yCKLOeAtwsrg8d6Ga16GMuuEZ/ol+uRnHiUUqD1XraObtjiheP3dq 9BG1JNBuLPwza49Mju0FRrJk5ynVv33We45vWAYtri/gih2hNuSyq4ukA1MythjNbyCL/ zGv9maXjfmOCrzmUfUac+PkN5sKDlZn2Q7Pt+iphENgNSewaywKPGezeEdfOAuiOFKaNE ywKfSjRAlh9bbmKpK0iMJBm73wKQ9cBkki8fIdCUUhWpmqZMT4Kgy5ByEicvC7ort5NQE NQi31zx3d/ZToG3Ap3DugKNkMsDB4vvxqH1oeV8sm50M06xX9HdP3Y/yMQKuLWfDfEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443089; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=326rfzyn5aYnzYbjSeh7zrL2iX3fLZVqw0Iy00vuXgQ=; b=iymFqlctR/xChMZJv0zn3yVhbRnzn8dlPbrnJgbYneRqc6hmWBvRumnQhNBqjYWqDL3x mlB+HyJbUsO2DiTD40igCFUZE/QdCiYH1S4Kmj3ZddrWOuO72dp6U3lXUPU7OJ3dsSXzm bbNiUtwbfLlMsOJ79uHSYdlyC8iBYIVIOAMAonSW2LVjSMMzmRvUa6xtlZRQtvaco1ZkA NXxurdJwT//BbdXiTa5VqP+ZR/U05TbuhJSPhS1lLRTeuODv0dQTa4XXuWppWLQ6jaV3r tXUi93kQ4eXovw6MEgbybi9HtKw6tqNLCqsy6oPqf3JxjG+1xiWJyhxwVUJsnYZ3XiA== 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=EEuuKCPH; 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 69652606A322 for ; Sat, 5 Dec 2026 03:58:09 +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=EEuuKCPH Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB6F71F00A07; Sat, 5 Dec 2026 03:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443089; bh=326rfzyn5aYnzYbjSeh7zrL2iX3fLZVqw0Iy00vuXgQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=EEuuKCPHbjAXCarpt2VKHxgf1WUpuPj1i5ZglreS52VIwUSdsZloUfriT4jIkDW2q vJDXxvHB1ujGbHJe/pDWhHug1UQTe07/PVq/VewTiAejZzoa+iLPVikoUzD2l9rWiI sHZIh9cY+lw24dwsqIc7QMd/Gdq4kckPpSaMZMq9O5rzk9vDIzNF/WJHvegqJK2m9W FUxkka7VBL40QDTTD0qJ2Vf2lGKgG/RqR0/XC0Hob85JqXm/z0bR2PHoKY5yhwJH3t vM58FcsYs/ZN0hdHQDMfsyLJkcQmZArTenRgdxHfXFMc1NPYUqStIKiXJV4F/y9p9F c7Vj85YuI1Jiw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?QWRpbCBIw7xzcmV2IFRlcGU=?= Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261205-isg5320a-v4-2-a9bb8573c064@gmail.com> References: <20261205-isg5320a-v4-0-a9bb8573c064@gmail.com> <20261205-isg5320a-v4-2-a9bb8573c064@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 03:58:08 +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 8 potential issues to consider: - [Medium] iio: proximity: isg5320a_events_off() clears state and PM ref on write error - [Medium] iio: proximity: isg5320a_probe() skips client->irq validation before request - [Medium] iio: proximity: isg5320a IRQ thread races with system suspend and events_off - [Medium] iio: proximity: isg5320a leaves data->close stale after system resume - [Medium] iio: proximity: isg5320a_irq_thread() races with events disable and sleep - [Medium] iio: proximity: isg5320a unconditionally sleeps on suspend despite wakeup-source - [Medium] iio: isg5320a: isg5320a_read_irq_status() skips IRQSRC on sample error - [Low] iio: proximity: isg5320a_read_irq_status() skips IRQ ack on sample error -- commit 73f01735ba874407aefe2dc455ca4c17ad756481 Author: Adil H=C3=BCsrev Tepe iio: proximity: add Imagis ISG5320A SAR sensor driver This commit adds an IIO driver for the Imagis ISG5320A capacitive SAR/grip sensor over I2C, exposing a single proximity channel and rising/falling threshold events with runtime PM support. > diff --git a/drivers/iio/proximity/isg5320a.c b/drivers/iio/proximity/isg= 5320a.c > new file mode 100644 > index 0000000000000..407f2c7e2d8ab > --- /dev/null > +++ b/drivers/iio/proximity/isg5320a.c [ ... ] > +static int isg5320a_read_irq_status(struct isg5320a_data *data, bool *cl= ose) > +{ > + unsigned int val; > + int ret; > + > + lockdep_assert_held(&data->lock); > + > + ret =3D isg5320a_read_sample(data); > + if (ret) > + return ret; > + > + ret =3D regmap_read(data->regmap, ISG5320A_REG_IRQSRC, &val); > + if (ret) > + return ret; > + > + ret =3D regmap_read(data->regmap, ISG5320A_REG_IRQSTS, &val); > + if (ret) > + return ret; > + > + *close =3D val & ISG5320A_IRQSTS_PROX; > + > + return 0; > +} [Severity: Medium] Can an I2C error in isg5320a_read_sample() leave the active-low INT line stuck asserted? If the 4-byte bulk read fails, isg5320a_read_irq_status() returns early without reading ISG5320A_REG_IRQSRC to release INT, and isg5320a_irq_thread() then returns IRQ_HANDLED. Because isg5320a_events_on() keeps runtime PM active, nothing else reads ISG5320A_REG_IRQSRC, so falling-edge interrupts wedge until events are toggled or the system suspends, and level-low interrupts re-trigger immediately. [Severity: Low] Does isg5320a_read_irq_status() need to read the sample before acknowledging the interrupt at all? Neither isg5320a_read_irq_status() nor isg5320a_irq_thread() uses data->cdc or data->base, and isg5320a_read_raw() calls isg5320a_read_sample() itself. Reading ISG5320A_REG_IRQSRC and ISG5320A_REG_IRQSTS first (or dropping the unused sample read here) avoids gating interrupt acknowledgment on an unrelated bulk transfer. > +static irqreturn_t isg5320a_irq_thread(int irq, void *private) > +{ > + struct iio_dev *indio_dev =3D private; > + struct isg5320a_data *data =3D iio_priv(indio_dev); > + s64 timestamp =3D iio_get_time_ns(indio_dev); > + enum iio_event_direction dir; > + bool close; > + int ret; > + > + guard(mutex)(&data->lock); > + > + ret =3D isg5320a_read_irq_status(data, &close); > + if (ret) { > + dev_err_ratelimited(regmap_get_device(data->regmap), > + "irq status read failed: %d\n", ret); > + return IRQ_HANDLED; > + } > + > + if (close =3D=3D data->close) > + return IRQ_HANDLED; > + > + data->close =3D close; > + > + dir =3D close ? IIO_EV_DIR_RISING : IIO_EV_DIR_FALLING; > + iio_push_event(indio_dev, > + IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, > + IIO_EV_TYPE_THRESH, dir), > + timestamp); > + > + return IRQ_HANDLED; > +} [Severity: Medium] Can isg5320a_irq_thread() access a runtime-suspended chip or push events after userspace disables them? isg5320a_events_off() writes ISG5320A_IRQFUNC_DISABLE and drops the runtime PM reference without calling synchronize_irq(), and isg5320a_irq_thread() neither takes a runtime PM reference nor checks data->ev_enabled: CPU0 CPU1 isg5320a_events_off() lock(&data->lock) isg5320a_irq_thread() lock(&data->lock) (blocks) regmap_write(IRQFUNC_DISABLE) data->ev_enabled =3D false pm_runtime_put_autosuspend() unlock(&data->lock) ... isg5320a_runtime_suspend() isg5320a_mode_sleep() isg5320a_read_irq_status() <-- sleeping iio_push_event() <-- after disable If an interrupt fires just before ISG5320A_IRQFUNC_DISABLE takes effect, the pending thread can push a spurious event after write_event_config() returns, or read registers after autosuspend has put the sensor to sleep (for instance if autosuspend_delay_ms is set to 0). [ ... ] > +static int isg5320a_events_off(struct isg5320a_data *data) > +{ > + struct device *dev =3D regmap_get_device(data->regmap); > + int ret; > + > + guard(mutex)(&data->lock); > + > + ret =3D regmap_write(data->regmap, ISG5320A_REG_IRQFUNC, > + ISG5320A_IRQFUNC_DISABLE); > + > + data->ev_enabled =3D false; > + > + /* Drop the reference kept by isg5320a_events_on(). */ > + pm_runtime_put_autosuspend(dev); > + > + return ret; > +} [Severity: Medium] Should data->ev_enabled and the runtime PM reference stay intact when regmap_write() fails here? Clearing data->ev_enabled unconditionally causes a retry from isg5320a_write_event_config() to hit the state =3D=3D data->ev_enabled shortcut and return 0 without disabling ISG5320A_REG_IRQFUNC, and isg5320a_events_off_action() will also skip disabling it on unbind. Meanwhile, dropping the runtime PM reference lets the sensor autosuspend with hardware interrupts still enabled. Keeping the sysfs disable path from clearing state or dropping the PM reference on error (while still letting the unbind action drop the PM reference unconditionally) avoids leaving hardware and driver state out of sync. [ ... ] > + ret =3D devm_request_threaded_irq(dev, client->irq, NULL, > + isg5320a_irq_thread, IRQF_ONESHOT, > + "isg5320a", indio_dev); > + if (ret) > + return ret; [Severity: Medium] What happens if the I2C device is instantiated without an interrupt? Because the driver has an i2c_device_id table, a device created via sysfs new_device or incomplete firmware gets client->irq =3D=3D 0 from i2c_device_probe(). request_threaded_irq() only rejects IRQ_NOTCONNECTED and otherwise passes 0 to irq_to_desc(0), which on architectures with a legacy IRQ 0 either fails with a misleading -EBUSY or binds the handler to IRQ 0 after powering on and calibrating the sensor. Checking client->irq <=3D 0 early in isg5320a_probe() avoids both the invalid IRQ request and the unnecessary hardware startup. [ ... ] > +static int isg5320a_runtime_resume(struct device *dev) > +{ > + struct iio_dev *indio_dev =3D dev_get_drvdata(dev); > + struct isg5320a_data *data =3D iio_priv(indio_dev); > + > + return isg5320a_mode_normal(data); > +} [Severity: Medium] Can data->close become stale across system suspend and resume? When proximity events are enabled, pm_runtime_force_suspend() puts the sensor to sleep and pm_runtime_force_resume() restarts and recalibrates it via isg5320a_mode_normal(), without refreshing data->close from ISG5320A_REG_IRQSTS as isg5320a_events_on() does. If the device was gripped before suspend and released while suspended, the recalibrated chip starts in the far state while data->close is still true, so isg5320a_irq_thread() suppresses the next rising proximity event. > +static DEFINE_RUNTIME_DEV_PM_OPS(isg5320a_pm_ops, isg5320a_runtime_suspe= nd, > + isg5320a_runtime_resume, NULL); [Severity: Medium] Does DEFINE_RUNTIME_DEV_PM_OPS() allow isg5320a_irq_thread() to race with system suspend and resume? pm_runtime_force_suspend() runs isg5320a_mode_sleep() during dpm_suspend(), before dpm_suspend_noirq() calls suspend_device_irqs(), and isg5320a_mode_sleep() does not disable ISG5320A_REG_IRQFUNC or client->irq: CPU0 CPU1 dpm_suspend() pm_runtime_force_suspend() isg5320a_mode_sleep() lock(&data->lock) isg5320a_irq_thread() lock(&data->lock) (blocks) regmap_multi_reg_write(sleep) unlock(&data->lock) isg5320a_read_irq_status() <-- bus/chip suspended Symmetrically, on resume dpm_resume_noirq() re-enables client->irq before pm_runtime_force_resume() wakes and recalibrates the chip with IRQFUNC still enabled. Using explicit system sleep callbacks that disable/enable client->irq around sleep would close both windows. [Severity: Medium] Does putting the sensor to sleep unconditionally on system suspend break the wakeup-source property in the DT binding? Documentation/devicetree/bindings/iio/proximity/imagis,isg5320a.yaml documents wakeup-source, which causes the I2C core to call device_init_wakeup() and dev_pm_set_wake_irq() automatically. Because pm_runtime_force_suspend() always calls isg5320a_mode_sleep() without checking device_may_wakeup(dev), the chip stops scanning during suspend and can never wake the system. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-isg5320a-v= 4-0-a9bb8573c064@gmail.com?part=3D2