From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 041D070808 for ; Sun, 30 Aug 2026 20:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123179; cv=none; b=sP5xrsoZLVY8rIaQf/vDSysdkHxLRfsyHlxii1V4I/BQXLVgJGXMKo0l5jZB+KIax2wlI9cAfirEmbfa99KNUAtHcaXIBgfhGL1ugny8uLcNTW9TJMua94hB0Qe8paivGuwWBehuC9lJ+AP5lXV9HxFEluwXbBwJ2RGADcjHGuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123179; c=relaxed/simple; bh=acCrqg8IpFZBPKIGBafgy4kHQIbRWqxM2O/BWjgnWqs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CzT19DVBR6Lnfb12slumcmHc0AhdniyW6jr5antAfakkBg1T4xWls6nEotz64v6u8F97v53QeWJl1jBZ6W2ju/cN9RmwzgmcFFekaOaYa3dMahAZ2UT2oyFI+zKHDXpipmgsEWPteFJyVbbnablUjrAvsChOlZvpZ2AAhCsxP9c= 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=dPzKy9ME; arc=none smtp.client-ip=209.85.215.176 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="dPzKy9ME" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-ca766c1c9ccso1826291a12.0 for ; Sun, 30 Aug 2026 13:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123174; x=1788727974; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ChRQxZ6nhdb/L1XpAtq/GVRDJWbntfU/ug1ECOX+bsc=; b=dPzKy9MEnC0jeaONH4i0j0to4Ht5vNM2NxNv1T1I2s8FHTjpXGwmL8EkvxxK0DMOFt OJqq9OVdBoJEllEzSbNd3WLivUkEEDAhHY9I+bvvWdldVv4Q4VZ0G63TFLBpuaheQc4s 33tHbxqUhBCcADR8efj9OLzs9a9ov7c3z8Kg+7G9rPL3HHG0K28dE2qErrO7CHy/pVj+ 4Sglj/lwQg4+6wa/e61iMR4sF45ZifsQu57DsCrpxibkVwx/Km542yll3+8fV3aXMkr0 WLXVhQfrE/2w1qSYH4Ey8yBUrQ3MKDkXESexAaZ63DjiCr4XrmTodsmJOk3AX9QPv1xU AyIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123174; x=1788727974; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ChRQxZ6nhdb/L1XpAtq/GVRDJWbntfU/ug1ECOX+bsc=; b=QD5TTTOHr+Xmof9sGeboYZnNxjudoTkei62vptNfakYvnWt8jeewY+vmtvgbhiE5u8 1aaIUQ/bIwlTICDJ3w2PfVuDrNKf32E4gZDCrLiF4M4ZajmdMi0FJmsLpk2zX5RjyEgD APEsopBHAMx+LVtUByZ5AUyHEnuaPlbsizOP0v8SbL48wlWS9Trv6Njvx5rxlmSYaOzN FnGKGnlimvhy0qu3FVCwmoNzR8cqP4Hihq9jHnUwpt2kaRBNo4Sro4yWNqRgTQ2F9t4g alVi4yE4NT53eunPIoTQd+Hvbs31KAEMPRdBEJGMihnJNvngQBXAA7GouZJ3AzRhsxbT FwgA== X-Gm-Message-State: AFuF++nzPguY11QMzX88hX+vK8e/zzWCRwap8k2Z5GMbQXLpSiiYUOsc gwDYBDxouFvPGsENVNrhoxmpUl/67YZY+S6BMuGxl+8WuwI+kkG8nGGA1+dzsKRH X-Gm-Gg: AR+sD11YLXhWBo8oMjXqq5r2+51LupvqlEn18kXKNOyLBzQJlqldgl25u5j2K/Zmsys 0fQACOU2Bl8RAcUeLx0YPrFtQDJvZwcUqE4KXr6FnRAKscHhUqAGkWk1v0XHHVF1aF3UwdMrpma NCCUZGXvPQ+ApuB6Ho7AzSmNwaHwkCySrBApVqWI3LhJPBfAiYqunxA68Sj7hwBhdMqgMYFn+YH aWTWfeZ1OXm56WMxHk+mmk1Q+2EVoLLheg5paMfGRQK/wuj1jRqpMwE0ydMhk8g8iCFu+/PsiDd T6jfahVq1wyyml3EXd0IiCZKSiQ0cm3KNu5SsI9yA6nq2m+oMhYz7JiM+wLxs41A3wEAGSwIMJ1 FrrJIT7vhuNf0xQTYVT+fEaSHlmAJV+PmtKHdbM78iBJjSWoDJanzBEow4pb1SEVQTlJQht5eyW G0lpyWAFLQYiKCGKTpB0jNdEvjEG1bw/jxTau61zNc/dtyDeoaTeSP2PZHCOKUZAOGQReLyBMYZ ns9ugh98yz6j8UDqsTqNyeNgYxdteMPNhYLow24fh2HokJRVx8= X-Received: by 2002:a05:6a20:a108:b0:3cc:f280:ebc6 with SMTP id adf61e73a8af0-3d265c4270cmr33754961637.5.1788123174088; Sun, 30 Aug 2026 13:52:54 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:52:53 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:46 -0700 Subject: [PATCH 1/7] Input: gscps2 - clean up driver code style and structure 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: <20260830-gscps2-v1-1-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org X-Mailer: b4 0.16-dev-b242f Clean up code style issues and function ordering in the gscps2 driver: - Reorder functions to place gscps2_interrupt() before its callers, allowing removal of its forward declaration. - Change gscps2_enable() to accept a boolean parameter and remove the ENABLE and DISABLE macro definitions. - Convert printk() calls to dev_dbg() and dev_warn(). - Fix operator spacing and multi-variable assignment. - Add spinlock comment and use cpu_relax() in spin-wait loop. Assisted-by: LLM Signed-off-by: Dmitry Torokhov Acked-by: Helge Deller Tested-by: Helge Deller --- drivers/input/serio/gscps2.c | 208 +++++++++++++++++++--------------------= ---- 1 file changed, 91 insertions(+), 117 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 43453ec533b2..b82c56ba8ff7 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -1,6 +1,4 @@ /* - * drivers/input/serio/gscps2.c - * * Copyright (c) 2004-2006 Helge Deller * Copyright (c) 2002 Laurent Canet * Copyright (c) 2002 Thibaut Varene @@ -37,16 +35,10 @@ MODULE_AUTHOR("Laurent Canet , Thibaut= Varene addr) & GSC_STAT_RBNE) gscps2_readb_input(ps2port->addr); - ps2port->act =3D ps2port->append =3D 0; -} - -/* - * gscps2_writeb_output() - write a byte to the port - * - * returns 1 on success, 0 on error - */ - -static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data) -{ - char __iomem *addr =3D ps2port->addr; - - if (!wait_TBE(addr)) { - printk(KERN_DEBUG PFX "timeout - could not write byte %#x\n", data); - return 0; - } - - while (gscps2_readb_status(addr) & GSC_STAT_RBNE) - /* wait */; - - scoped_guard(spinlock_irqsave, &ps2port->lock) - writeb(data, addr+GSC_XMTDATA); - - /* this is ugly, but due to timing of the port it seems to be necessary. = */ - mdelay(6); - - /* make sure any received data is returned as fast as possible */ - /* this is important e.g. when we set the LEDs on the keyboard */ - gscps2_interrupt(0, NULL); - - return 1; -} - - -/* - * gscps2_enable() - enables or disables the port - */ - -static void gscps2_enable(struct gscps2port *ps2port, int enable) -{ - u8 data; - - /* now enable/disable the port */ - scoped_guard(spinlock_irqsave, &ps2port->lock) { - gscps2_flush(ps2port); - data =3D gscps2_readb_control(ps2port->addr); - if (enable) - data |=3D GSC_CTRL_ENBL; - else - data &=3D ~GSC_CTRL_ENBL; - gscps2_writeb_control(data, ps2port->addr); - } - - wait_TBE(ps2port->addr); - gscps2_flush(ps2port); -} - -/* - * gscps2_reset() - resets the PS/2 port - */ - -static void gscps2_reset(struct gscps2port *ps2port) -{ - /* reset the interface */ - guard(spinlock_irqsave)(&ps2port->lock); - gscps2_flush(ps2port); - writeb(0xff, ps2port->addr + GSC_RESET); - gscps2_flush(ps2port); + ps2port->act =3D 0; + ps2port->append =3D 0; } =20 -static LIST_HEAD(ps2port_list); - static void gscps2_read_data(struct gscps2port *ps2port) { u8 status; @@ -348,8 +266,8 @@ static bool gscps2_report_data(struct gscps2port *ps2po= rt) data =3D ps2port->buffer[ps2port->act].data; =20 ps2port->act =3D (ps2port->act + 1) & BUFFER_SIZE; - rxflags =3D ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0 ) | - ((status & GSC_STAT_PERR) ? SERIO_PARITY : 0 ); + rxflags =3D ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0) | + ((status & GSC_STAT_PERR) ? SERIO_PARITY : 0); =20 serio_interrupt(ps2port->port, data, rxflags); } @@ -370,7 +288,6 @@ static bool gscps2_report_data(struct gscps2port *ps2po= rt) * the data as fast as possible and handle the reporting to the upper layer * later. */ - static irqreturn_t gscps2_interrupt(int irq, void *dev) { struct gscps2port *ps2port; @@ -392,17 +309,79 @@ static irqreturn_t gscps2_interrupt(int irq, void *de= v) return IRQ_HANDLED; } =20 +/* + * gscps2_writeb_output() - write a byte to the port + * + * returns 1 on success, 0 on error + */ +static inline int gscps2_writeb_output(struct gscps2port *ps2port, u8 data) +{ + char __iomem *addr =3D ps2port->addr; + + if (!wait_TBE(addr)) { + dev_dbg(&ps2port->padev->dev, "timeout - could not write byte %#x\n", da= ta); + return 0; + } + + while (gscps2_readb_status(addr) & GSC_STAT_RBNE) + cpu_relax(); + + scoped_guard(spinlock_irqsave, &ps2port->lock) + writeb(data, addr + GSC_XMTDATA); + + /* this is ugly, but due to timing of the port it seems to be necessary. = */ + mdelay(6); + + /* make sure any received data is returned as fast as possible */ + /* this is important e.g. when we set the LEDs on the keyboard */ + gscps2_interrupt(0, NULL); + + return 1; +} =20 /* - * gscps2_write() - send a byte out through the aux interface. + * gscps2_enable() - enables or disables the port */ +static void gscps2_enable(struct gscps2port *ps2port, bool enable) +{ + u8 data; =20 + /* now enable/disable the port */ + scoped_guard(spinlock_irqsave, &ps2port->lock) { + gscps2_flush(ps2port); + data =3D gscps2_readb_control(ps2port->addr); + if (enable) + data |=3D GSC_CTRL_ENBL; + else + data &=3D ~GSC_CTRL_ENBL; + gscps2_writeb_control(data, ps2port->addr); + } + + wait_TBE(ps2port->addr); + gscps2_flush(ps2port); +} + +/* + * gscps2_reset() - resets the PS/2 port + */ +static void gscps2_reset(struct gscps2port *ps2port) +{ + /* reset the interface */ + guard(spinlock_irqsave)(&ps2port->lock); + gscps2_flush(ps2port); + writeb(0xff, ps2port->addr + GSC_RESET); + gscps2_flush(ps2port); +} + +/* + * gscps2_write() - send a byte out through the aux interface. + */ static int gscps2_write(struct serio *port, unsigned char data) { struct gscps2port *ps2port =3D port->port_data; =20 if (!gscps2_writeb_output(ps2port, data)) { - printk(KERN_DEBUG PFX "sending byte %#x failed.\n", data); + dev_dbg(&ps2port->padev->dev, "sending byte %#x failed.\n", data); return -1; } return 0; @@ -412,7 +391,6 @@ static int gscps2_write(struct serio *port, unsigned ch= ar data) * gscps2_open() is called when a port is opened by the higher layer. * It resets and enables the port. */ - static int gscps2_open(struct serio *port) { struct gscps2port *ps2port =3D port->port_data; @@ -420,7 +398,7 @@ static int gscps2_open(struct serio *port) gscps2_reset(ps2port); =20 /* enable it */ - gscps2_enable(ps2port, ENABLE); + gscps2_enable(ps2port, true); =20 gscps2_interrupt(0, NULL); =20 @@ -430,11 +408,11 @@ static int gscps2_open(struct serio *port) /* * gscps2_close() disables the port */ - static void gscps2_close(struct serio *port) { struct gscps2port *ps2port =3D port->port_data; - gscps2_enable(ps2port, DISABLE); + + gscps2_enable(ps2port, false); } =20 /** @@ -443,7 +421,6 @@ static void gscps2_close(struct serio *port) * * @return: success/error report */ - static int __init gscps2_probe(struct parisc_device *dev) { struct gscps2port *ps2port; @@ -494,8 +471,8 @@ static int __init gscps2_probe(struct parisc_device *de= v) goto fail_miserably; =20 if (ps2port->id !=3D GSC_ID_KEYBOARD && ps2port->id !=3D GSC_ID_MOUSE) { - printk(KERN_WARNING PFX "Unsupported PS/2 port at 0x%08lx (id=3D%d) igno= red\n", - hpa, ps2port->id); + dev_warn(&dev->dev, "Unsupported PS/2 port at 0x%08lx (id=3D%d) ignored\= n", + hpa, ps2port->id); ret =3D -ENODEV; goto fail; } @@ -552,7 +529,6 @@ static int __init gscps2_probe(struct parisc_device *de= v) * * @return: success/error report */ - static void __exit gscps2_remove(struct parisc_device *dev) { struct gscps2port *ps2port =3D dev_get_drvdata(&dev->dev); @@ -572,7 +548,6 @@ static void __exit gscps2_remove(struct parisc_device *= dev) kfree(ps2port); } =20 - static const struct parisc_device_id gscps2_device_tbl[] __initconst =3D { { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00084 }, /* LASI PS/2= */ #ifdef DINO_TESTED @@ -610,6 +585,5 @@ static void __exit gscps2_exit(void) software_node_unregister(&gscps2_keyboard_node); } =20 - module_init(gscps2_init); module_exit(gscps2_exit); --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 9E915324B33 for ; Sun, 30 Aug 2026 20:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123181; cv=none; b=J+w2bOYoni/Dy6FIun+OcPHWR0cVteQ87iTySNbwT5bnjSujVIQ0WhQuzxl4JteAo92LZqEBvgX+hFvk6yBV7RW40vl6iBLWm7r8Ml2jOT1eKgochsQRmV9eTogeC2xTo47ha+jOUtwM+p2Xi2EdrCM6ZCCdBpp2EXP8oy/iza4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123181; c=relaxed/simple; bh=GXnE++8ycCQ3Geyc1VEaJivw863kljbsemhtvc2XkW0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HFTDmcZMptJnN3nqhoxrs3stCDhliMDoYBHe6AJigRUHz+7W2pHQFg2FLS/CxUzgbsjt4g0GxJSccY0YSQG9TApn3hQq6BZe37df0YZJG8zEAF4Yy8bhsKvrdQLHrXuESuk19G/SomOh4MXjoKeIDrgJvvcC3hnPIIxt5EsH/hw= 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=LMIlAmQv; arc=none smtp.client-ip=209.85.215.181 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="LMIlAmQv" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cc1c7364550so2924012a12.1 for ; Sun, 30 Aug 2026 13:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123176; x=1788727976; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6Dq60Pyzo1OLSy7MU+OaidMLABdeC4LX97otWKe9Wa0=; b=LMIlAmQvTa8F1O3iDv4z56PI9Z8qth5rgwpOm6Het98hLwadf5fDHBEqJ5dgss9zLz 3OU7PZ7alooHd3aI5tx5ju1cNQkBKB1w8No5eV1K51x1egwwxWxkTfpeRGY8wEyZ/H9C V9iO9Xpn3U+J7Mh5TfSt5JjS6G99sdmUwjvkmSPVhz2sNzKZ6ECyKJO6lkLiyzCQ744t V+xuuIj734Jt91jZiTDb1b2TJo1TppDPuo6JpLRKUTnXzPO1kuG8/4+Gc5lvAv+olpMV WNCsqd5IgTq03vuSoGv1QgDxR+6AlkNTOOOHAs0eo3D6c8eTfZMqgyQXMg4ZNpTLL0WD EEhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123176; x=1788727976; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6Dq60Pyzo1OLSy7MU+OaidMLABdeC4LX97otWKe9Wa0=; b=E/2Awv/+TkizK/7uKZlNYEAZBFcmbl+74lChN9CfsKhl0ahM7VOyNjKoS8U+aZD+1v +H29Wfr+Gj73y9W1uxsDuOiAh+ZSLC0FBUJY6HWQF4qAZjeuJOuVju8BCrtBIerp1jXw SgjtDKxlilBMk24mIW6VKiLZhImG17Ql5f0AP6cX6GSq1x8D5bCgdtW6YBq+ApP+Xotu zC+IyG1A21Yx5l3XCLn2VbnbHx6a2b9ttiW2IY4Fc4y0kdEkxxPemT7J2+RRhiAf2QG1 /OUCbIMEI+L8t6xo3CxqAzSXCO/+6A024Ak5OjoLty5XmNaUJ8em7Cy+KoLd497O+RL5 ubgQ== X-Gm-Message-State: AFuF++kXR85lKT/twuum44fsRLvwQh8/TxmFUlULRgpzVWikgEoNLvdx GEvp/8D3UMG8B4kA90wITtxu2BPSMgkGXsyOtqhk8sy73CCGvvk/rlQpfFkzqE6X X-Gm-Gg: AYBFou3NyHCzTASbgwne5AzCe7vfInpilI+/bU7Z430zaYKEx21YQqaEbsooFeBsN7r tiEg4h+QmeTEpW3lC+UkVVAZXStFYBAcut+HoWrt6OsQ6WkVGMxESzCfDBib3jRilaxh9TQw0t/ pSqoVSOUs3FEcmPROpAyr6Aihk+PBRmqjrNaI+HuH3F2JdtK90U02Pp1tmmMMC0Yte4P61UFD6o diJEnXgMRMKgH8gcpC8dLoRv6YSncU+DF5Lua1vm6RGogB6sWc6+5V5FCnWEdMzhPfsH7NFOGiE 3GONifl6bnpfZE+7h8z9A93mcF+kiPK/xDt4ailLeA1Nt5/Q0/gfyGDTPqVsLagPgPbe+pVA2vD IcJlLEp4TGi2ZTjm4r5nZnP5Grcwd+vcdFgWB80I9Gc+96enTJnvPv6sp2E0BAnjrByu+S/upjB 5PouPEpuDHEYnUxmm6byv8b0rZMhNNEul2SQWfgN+7hJ1Egc2zljOZWsV6kRaQYfNxGFj9qas5D vb0i4RNnhUDVSwvM6bvcDvbHthhocsejba8HyFpTKaZd44pl6A= X-Received: by 2002:a17:90b:3812:b0:398:b71e:60c1 with SMTP id 98e67ed59e1d1-398b71e6250mr11845600a91.12.1788123176445; Sun, 30 Aug 2026 13:52:56 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:52:54 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:47 -0700 Subject: [PATCH 2/7] Input: gscps2 - use RCU for ps2port_list and manage it in open/close 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: <20260830-gscps2-v1-2-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f Managing ps2port_list in gscps2_probe() and gscps2_remove() had two issues: - in gscps2_remove(), serio_unregister_port() frees the serio port, but because the port remained in ps2port_list until later in remove, a shared interrupt firing on another CPU could traverse ps2port_list and dereference the freed serio port - ps2port_list additions and deletions in probe/remove raced locklessly against list traversals in gscps2_interrupt(). Convert ps2port_list traversal in gscps2_interrupt() to use RCU, and move list management to gscps2_open() and gscps2_close(). When serio_unregister_port() runs during device removal, serio_close() is invoked, cleanly taking the port out of ps2port_list before the serio structure is destroyed, while maintaining active hardware communication during child driver disconnect. Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index b82c56ba8ff7..5b6e311f8a02 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -26,6 +26,7 @@ #include #include #include +#include #include =20 #include @@ -195,6 +196,7 @@ struct gscps2port { int id; }; =20 +static DEFINE_SPINLOCK(ps2port_list_lock); static LIST_HEAD(ps2port_list); =20 /* @@ -292,14 +294,16 @@ static irqreturn_t gscps2_interrupt(int irq, void *de= v) { struct gscps2port *ps2port; =20 - list_for_each_entry(ps2port, &ps2port_list, node) { + guard(rcu)(); + + list_for_each_entry_rcu(ps2port, &ps2port_list, node) { guard(spinlock_irqsave)(&ps2port->lock); =20 gscps2_read_data(ps2port); - } /* list_for_each_entry */ + } =20 /* all data was read from the ports - now report the data to upper layer = */ - list_for_each_entry(ps2port, &ps2port_list, node) { + list_for_each_entry_rcu(ps2port, &ps2port_list, node) { if (gscps2_report_data(ps2port)) { /* More data ready - break early to restart interrupt */ break; @@ -397,6 +401,9 @@ static int gscps2_open(struct serio *port) =20 gscps2_reset(ps2port); =20 + scoped_guard(spinlock_irqsave, &ps2port_list_lock) + list_add_tail_rcu(&ps2port->node, &ps2port_list); + /* enable it */ gscps2_enable(ps2port, true); =20 @@ -413,6 +420,11 @@ static void gscps2_close(struct serio *port) struct gscps2port *ps2port =3D port->port_data; =20 gscps2_enable(ps2port, false); + + scoped_guard(spinlock_irqsave, &ps2port_list_lock) + list_del_rcu(&ps2port->node); + + synchronize_rcu(); } =20 /** @@ -446,6 +458,7 @@ static int __init gscps2_probe(struct parisc_device *de= v) =20 ps2port->port =3D serio; ps2port->padev =3D dev; + INIT_LIST_HEAD(&ps2port->node); ps2port->addr =3D ioremap(hpa, GSC_STATUS + 4); if (!ps2port->addr) { ret =3D -ENOMEM; @@ -501,8 +514,6 @@ static int __init gscps2_probe(struct parisc_device *de= v) =20 serio_register_port(ps2port->port); =20 - list_add_tail(&ps2port->node, &ps2port_list); - return 0; =20 fail: @@ -539,12 +550,10 @@ static void __exit gscps2_remove(struct parisc_device= *dev) serio_unregister_port(ps2port->port); free_irq(dev->irq, ps2port); gscps2_flush(ps2port); - list_del(&ps2port->node); iounmap(ps2port->addr); #if 0 release_mem_region(dev->hpa, GSC_STATUS + 4); #endif - dev_set_drvdata(&dev->dev, NULL); kfree(ps2port); } =20 --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 41D8731CA4E for ; Sun, 30 Aug 2026 20:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123182; cv=none; b=UwnwaXqvm5KrJQXgCC+eQ3iMjJbvWzKIt25stfZZo5/0Q8B0gP51QxnByyYBd4ThyF26mrNx6UC6Bv1E5aw+PSTEoULJ3ZXSE+JW9QFxQmo/MtTVkRvk/ItjDWlMMStSYhxO1xcicKDMOIeTgSMM0Cj1i529rtY2IeCSfbkLHsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123182; c=relaxed/simple; bh=dgRlrPA0xNRpVH6a2orSrjoVD6Nad1aDhCkhQHF7NZc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S0WbR8UDnod2gt3tkOip+cWNa8TZIehb0TFUZv8z9fvRHL8tmJbCXbQHIhe/TJezsTurw/orrp5cOOGXZ6npupFdWvnI/TbPFVXk0Q+ffQA24dQhZXC8An/EIpseBwgaSf8SkmTGVaFb7JZXWJYk7BstlPjBDSM8ETHX6/ghylA= 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=K4ulL8SM; arc=none smtp.client-ip=209.85.214.181 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="K4ulL8SM" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2cace91f112so22313815ad.0 for ; Sun, 30 Aug 2026 13:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123178; x=1788727978; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EUPfcFMxDXMk/XqBeY+4XwVjn+mvGP82psS7PbouEZI=; b=K4ulL8SMDxQGY9peYtUl96MNzOmlNI+cDtc9p4EoZ2NfPXPLblNsOnlFSu94jxZ9xf CwIjBZMSdGrzVsvZ+vg6/nJsXP9PkNXXnkBOX5hLcr5krzFtl9U9hV7ByhKZ5l+iFr+q 179zMzQ6kX6VRCBUQR6AlSOQWtfMnKS21QPt80xe6ATIY9+4/E4GV1DMcze92KtRigOl yHLgf8HKJvT4d24v8y10rTS0vukPHfzqjWiBGB0cr13v6HXNaxdXWgn1s3/xAmy7OQmd l3zK6yeP1DBfgwSbl3RcFzPvhFDjcKhKV+qufAsr4BHPruRstaj+1jq05xNJIxkwiJRE leJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123178; x=1788727978; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EUPfcFMxDXMk/XqBeY+4XwVjn+mvGP82psS7PbouEZI=; b=LAsFtxrwxXnP+/IebDj8Y+l7b1F53INHDtjv62BmyElAxyMlSoTqyykot1ejM2YeR0 ORYifD/M4S2KEFztLAjmLP0Nl9VjWE0+9MuoWCpj7yBffm289D3y8KeEgNav8Ojwrk0e QwtO731qQjP2Xh3H38RxKUnUid8mVas/ALIvLpEUkDb8JEiTSWgxq/9f6pNi+lUGLYOF 4lUiijGzQ/s05tLN9a+dicGXg78irbx66OCHf18j2g7wv3Y/oGACA434PIEvIIlG/4xc qnhoab1Go6m8zxSIJ1ZTmCymZRiT6D/UwjvU5Djwt8c79v6r9srGs9rDJga7OBaCyXxY wTuQ== X-Gm-Message-State: AFuF++nxd5Ey18cF/4//yJ+WPXlYakhFQ0yblIYwlq//h3HxXOJQ+OW2 46KiEjpF/Mlj5zli7hcxTX4A9AVy2G+3l/LqvXieyZAPn8VjJVogrRZEyQwnnNil X-Gm-Gg: AR+sD115bhBY+lO/Z6O1uN5QKPGEas4XEF/4m5DK9mFwKlnNcNEo6MLqfGOaS60b/kL V5Faz1nxOt/hmQZ+byYk0ePqo96RUI5H5ZwzFthxM7xrllmSB7mPeqy84anOvvbxVXhKEJCCgq9 FWjIEq4+imycgXfvkNJfPcOdYcT59AEwby6BSAN8QvR83m//mghMeUpsRF9dv62n1sFRc8hfBd6 GdKj1A+xhovGidTjRqQx4jMfuWr8WDMWGGcZVVkfk4s+wfoqmunA+I0BSXOzlfDjM4qB7KuBdPm yIyyX07i/eHUh0uZu7D2Zuco7blwhpiaNToGJc8iR9ckOeNyCkJz624rmwhH3BWRUGEiEbZaAJ0 n6TZ/0WRR3r3/2TJltqYKT0MfTGrXnYmBXsogjFutLCbvoCFQNv/3rZunfJQ0IMZQXRE4S6r+Rg aYgWR50v9MYRO2F4bD5H2ezwFths3GrgvvpQOISqQQtnodwF1JQah1cXVMCJqc+YO8COSUm/Sms EIIUCY0LQzIjF3UtsOvHZ2sUgiOhGIM4tAu6RRpceBTwNsbx7M= X-Received: by 2002:a05:6a20:a108:b0:3cc:f280:ebc6 with SMTP id adf61e73a8af0-3d265c4270cmr33755175637.5.1788123177680; Sun, 30 Aug 2026 13:52:57 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:52:57 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:48 -0700 Subject: [PATCH 3/7] Input: gscps2 - protect buffer access in read and report helpers 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: <20260830-gscps2-v1-3-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f In gscps2_report_data(), the ring buffer consumer index ps2port->act was read and updated locklessly. When gscps2_interrupt() was called from process context (such as during port write or open) concurrently with a hardware interrupt running on another CPU, two execution contexts could execute gscps2_report_data() simultaneously for the same port, racing on ps2port->act and leading to duplicate, skipped, or out-of-order bytes. Protect buffer access by taking ps2port->lock inside gscps2_read_data() and gscps2_report_data(). In gscps2_report_data(), acquire ps2port->lock only when popping entries from the ring buffer and release it before calling serio_interrupt() to avoid recursive deadlocks if the input driver synchronously sends a command back via serio_write(). Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 5b6e311f8a02..fef6fffb6f86 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -238,6 +238,8 @@ static void gscps2_read_data(struct gscps2port *ps2port) { u8 status; =20 + guard(spinlock_irqsave)(&ps2port->lock); + do { status =3D gscps2_readb_status(ps2port->addr); if (!(status & GSC_STAT_RBNE)) @@ -255,7 +257,7 @@ static bool gscps2_report_data(struct gscps2port *ps2po= rt) unsigned int rxflags; u8 data, status; =20 - while (ps2port->act !=3D ps2port->append) { + while (true) { /* * Did new data arrived while we read existing data ? * If yes, exit now and let the new irq handler start @@ -264,17 +266,20 @@ static bool gscps2_report_data(struct gscps2port *ps2= port) if (gscps2_readb_status(ps2port->addr) & GSC_STAT_CMPINTR) return true; =20 - status =3D ps2port->buffer[ps2port->act].str; - data =3D ps2port->buffer[ps2port->act].data; + scoped_guard(spinlock_irqsave, &ps2port->lock) { + if (ps2port->act =3D=3D ps2port->append) + return false; + + status =3D ps2port->buffer[ps2port->act].str; + data =3D ps2port->buffer[ps2port->act].data; + ps2port->act =3D (ps2port->act + 1) & BUFFER_SIZE; + } =20 - ps2port->act =3D (ps2port->act + 1) & BUFFER_SIZE; rxflags =3D ((status & GSC_STAT_TERR) ? SERIO_TIMEOUT : 0) | ((status & GSC_STAT_PERR) ? SERIO_PARITY : 0); =20 serio_interrupt(ps2port->port, data, rxflags); } - - return false; } =20 /** @@ -296,11 +301,8 @@ static irqreturn_t gscps2_interrupt(int irq, void *dev) =20 guard(rcu)(); =20 - list_for_each_entry_rcu(ps2port, &ps2port_list, node) { - guard(spinlock_irqsave)(&ps2port->lock); - + list_for_each_entry_rcu(ps2port, &ps2port_list, node) gscps2_read_data(ps2port); - } =20 /* all data was read from the ports - now report the data to upper layer = */ list_for_each_entry_rcu(ps2port, &ps2port_list, node) { --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 9963D325485 for ; Sun, 30 Aug 2026 20:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123183; cv=none; b=JpMMJ8ToyO5w5GcdNtZ8UCfv8o0+Kz1BIpjs2865QAUqGgt2YlD8qNg9zpROXCnt35vmsCOm+ShJ6BRacb2un0SGNWmIcq/RI5Bp3EUoJSuhwV8kw8tXCT0epXL1bmJEGcC25TzygpTtQUa/pI4bdIQZ8uImcYBDSoTH8IVeQTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123183; c=relaxed/simple; bh=EOnSXOVAAeXVYSqilMUhL2SUOzE8QoOUvM+prd9A1TM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ATxj/CDZm89pqwvt29FtmcsdYJh8dyaBGHr/9NeBEW0Lp7Xv0ru4QqTyH8pxdlzFVENAJPkcd9J3/nlbH1QKRw8ZtAXRSatgjUA9NE6H02uyRIh7+IIwUmtoWS+g1UqqIDKtej4wvJ4o55bAYf6y4mjYDF5+1TFJwzDhA3Wqbfg= 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=GjXVZdSd; arc=none smtp.client-ip=209.85.214.174 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="GjXVZdSd" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2d7195706f1so27098745ad.0 for ; Sun, 30 Aug 2026 13:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123179; x=1788727979; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AsQW+e9qFtWuEHb6msaYSCJD2h6v64jckrT0lnLqEOQ=; b=GjXVZdSdWxHhSfEhqJ8f4a51fhS4ThyTHXbGnhbNAG5wJt9Y3orej4TlIrgsnZcWxW E0s605c0keDlpf1+vdcR8rrPE9u+gFnSuNLwiRYuEuydLolOaAgrPjBiUAGU/O1JMtXo 7QxH4YvFAF6fod38gVg0R9n0eY7SfPhToTCWyXYDaasKr4pI6LLnTO7LZwRBIDiApFV0 mc4IYzuaRl7c28C0ron65xJ4zugSOjI1FRBBa/jTr6yOrvhudPqnpZOmY3j/p1zuT6k3 gYzUEFj6VBB+icdKFVdEQMiVPrQud6tLQ8ZvtIakaVVjCF0BXNM9VGVezNQjHHjRXxTK r4Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123179; x=1788727979; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AsQW+e9qFtWuEHb6msaYSCJD2h6v64jckrT0lnLqEOQ=; b=T58mYDCCZ6H6Pv9ke7r6dLVcfCZmQsQE15pamvMDkLy31ISZ+aWJV7mQdstWeL5cTe KB1fzjfj5t1jE147NW8TJZ7Bx6uUNY+sqXstDGiTA2ujm9kaE4aLdOBv5Z/xWR1YtM31 /I6QC7vAuNeG8VoPrRR7fBlSpwB+2Lw58pGr990sqVK4iT81jzsYz3LFC6fO0LoELnYi nvSVTdA1Mh8cqljG0UwNRYNWQn+Ko6O92kOpNHWubebLtfkcbnKfHX6SA/QDy4pbEkvC is+HJ71j01kfLHai2kwh4eJA6/T+n5iuHn5EL3So6lDGD/X/Gvs3wecd2O67tWNiC3FY /y4g== X-Gm-Message-State: AFuF++nZRD9VHOLfRjotiZgb4qNlXkNAvCKiK7ytdi8VOZkAYsKuIQF1 LgpUd9lDPAClMH3+K213Xd5stq/g+3fl+FPdzBQJdaWtQVIZNe/XOKM/ipgj2nZQ X-Gm-Gg: AYBFou3ofex+bg5wp+vDIjZIe2hURCKfSsZZRsFZbw3foCnLgeFyQuAvBAWYa1gOayD oeZ6TwDrvGNRhuc+0peIAPGITvMvDNCTyDQ/2Y3YxPbZH/iGDnDig0T2XfaQ+8+tkLVUom/IM2a 65oEwtI27X1T5L8OqMMipbHetC/TDOsTnqdYUzhFI0IfMHX6rf/PE731lyODTqN4HOkMHvQf1oY fWQk0nkMnb5A8KXfr4m80KUcQv6W/b7U8QHJrhOyeIEXcercH3jH07wBwh4i8jYfWiU8DzH3KhY IOMigZY1QQOzJoEZanW+abru7CmrgxpZyub4HnUMBeXrC4OZr121U2BBe3lsCSxVfWVuvMykU27 U8t5TlU5UpRuIOv9eE69Fjci+7jOTL/WMeMi1AndFeTXDlJO6cgSKhEJFwc+D5JeE2aSSVi10AB eyRV7HHTp8V6Xf2IijXS0OhzWDe+Ld/zSQlLOsLMtx5HRpi7LZYRD1qF2TgHef2d0o+ZOWKe0IZ DoDu+XOItDgoqmV7DXI6TUaG1GNH0PZFPK/dHyk88/WCT9Fd3Y= X-Received: by 2002:a17:903:1aa3:b0:2d0:cc92:f7a3 with SMTP id d9443c01a7336-2d74dc1065fmr279050945ad.2.1788123178954; Sun, 30 Aug 2026 13:52:58 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:52:58 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:49 -0700 Subject: [PATCH 4/7] Input: gscps2 - serialize hardware and buffer access in gscps2_flush() 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: <20260830-gscps2-v1-4-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f gscps2_flush() reads from hardware registers and resets the ring buffer indices ps2port->act and ps2port->append. In gscps2_enable(), the trailing gscps2_flush() was called without holding ps2port->lock, racing with concurrent hardware interrupts and buffer access. Assert that ps2port->lock is held in gscps2_flush() with lockdep_assert_held(), and ensure all callers acquire ps2port->lock so that multi-step hardware sequences remain fully serialized without unprotected windows. Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index fef6fffb6f86..36c25db9ff7f 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -228,6 +228,8 @@ static int wait_TBE(char __iomem *addr) */ static void gscps2_flush(struct gscps2port *ps2port) { + lockdep_assert_held(&ps2port->lock); + while (gscps2_readb_status(ps2port->addr) & GSC_STAT_RBNE) gscps2_readb_input(ps2port->addr); ps2port->act =3D 0; @@ -364,7 +366,8 @@ static void gscps2_enable(struct gscps2port *ps2port, b= ool enable) } =20 wait_TBE(ps2port->addr); - gscps2_flush(ps2port); + scoped_guard(spinlock_irqsave, &ps2port->lock) + gscps2_flush(ps2port); } =20 /* @@ -551,7 +554,8 @@ static void __exit gscps2_remove(struct parisc_device *= dev) =20 serio_unregister_port(ps2port->port); free_irq(dev->irq, ps2port); - gscps2_flush(ps2port); + scoped_guard(spinlock_irqsave, &ps2port->lock) + gscps2_flush(ps2port); iounmap(ps2port->addr); #if 0 release_mem_region(dev->hpa, GSC_STATUS + 4); --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 9A514326939 for ; Sun, 30 Aug 2026 20:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123183; cv=none; b=OIvlBSDsJmjhP98d7w4lgp7jneJBE0fxlJ/WggzIR+b1u3ORhHuC/iCb/bR2aczVBu0+2PWKVTeaGrmCkxXrFazTtW0mWrBti0cTeLu//IaIv7XgaUVhO0gar82lBpAINUkqGPWew0IxwMbGp/gp4Ea5mJ4SpPgWuA167GaFqb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123183; c=relaxed/simple; bh=/6qnuDkJ9Pht84ieqMDQcNLwfOfRm8nb+vO15yDAXbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ss5yVuGmW7rE9l6mIaeD9P/NE2ltjqMihFKgO/DpN8TnKpR3xLlrEoBx6fYX2HLQ8xCxEW4n0gwTjjQgraFD6FQ5z6SfL1EFXLWijL2+iSw3HByLa6LbV6xHeaRPzqndh/TrV7v8GdJT70BxV7cTYZWkwTJXYkclNjj1aaCNz7I= 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=ZUvPLYQ/; arc=none smtp.client-ip=209.85.214.171 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="ZUvPLYQ/" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2d710632717so22562515ad.0 for ; Sun, 30 Aug 2026 13:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123180; x=1788727980; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KhuHXF4zjm1wA7Hdsp9+NElntybJGb7Ekfxcvka1Z1s=; b=ZUvPLYQ/ZkFAolW5sswKw9z38UVckOFX5wfnEvt3ks4/JgadPo4EVky/2AviIsCRdU QTWtE76sc1wB/KwaxeXdprpVPUTt9mA7BjGaadkJEmbcUW0ZA/NbTfLjdmu9Sahv4u02 nD8LAe3qu6YO3ahLzbOz8mMa7robhkRtihjqPBKIYqWhhAo+V83vi9cpfuCG9G8Nn6Fn tgIShKE7vYazJWvysyUvSXyLgH/HVhwwrfYynhLO0txp/TDeq5ogZDp1X3xHsmOAjDoa EJEXNyElnk6KhcesOh3gdlu75eiWx7dmvUOI+suidQsuWc76MX07YTBTAqND3kLuJ94e vqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123180; x=1788727980; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KhuHXF4zjm1wA7Hdsp9+NElntybJGb7Ekfxcvka1Z1s=; b=Ss4p/9QWK6s/2jB1+ByiecrFfNBdbgth+XdjJ0ir3V+tdp0YeFu5YfNjyINofxY+4m 3jrDv9azbOmhCGj1+Hif5FwTwS1apQGR4bm9QxLoNhovaRXo2t55e8vHTi5PfTIggJ5E 0GBO+6vgMJuVafBYEOYbWGuAf0qIkeCa42MO0KDT1CjP5C2MxrFe+7Uzffwp5JapWmU2 i93GUNAp8bUko7RhUTPqk31DJZdzuFax3nqgP8RnyC1zNuwKkn6SgeuJe2Im7Gn17i8X iU73VfqaHIRCbY7S0LM3p7xPbpc4kjzYDhD4sxLZViqLj8IXgY5WAsi/C3INrYUMKmQT ZGiA== X-Gm-Message-State: AFuF++l9Ep4GFd+Hc6oReG+RssVBCQ6cm3rSb5I1rmeJBPV4t1g9XZ4t RNgayIHLJIZciyQfrL+meU1a6i7QJgsjHWZg1aBH31+EJTzee7L7f/BNwtXNDTe4 X-Gm-Gg: AYBFou040SdQnwa5i4zgcVaMZjD8cDdwLo03WWwsoXN3g8CLZM+T28eadNoKFVS0pew QDTUW8uefDr4/vxbfV9EUjB8nceoSAOPLu6JFf+cRU5kwgrzi+LKl2YPv9mjN/isW9RlnX594WO hfTS0FK6fwF1XhV+vUJFm0eFaTCOLzduR3Trqwjcwic7W+lg/bqGDRdiPxhuYraJkxPvfoU7WH1 BoepXlhz2OW81JKW8Pr+GMkqAszKBr/Pn7H4SrDrQC0KF+d9i5Zq5d5IjqObh8US6ZMlv6yG0kP JH04T8/ivOHbu/aWZY+iOHTJrhiOf0eWsm6nK+IelcBNAmHznLeTmmMc1rf7YRfPDjFCjJfRyp1 sKnY22HIcl5u/ep8HUFutyTZ9RGcOO6iEWfmJC+FV/BMur2Ix48lzExhDGxE6S2z43fXnBoS9Fi x1L4uGEjiidJ0Z/wMqJ4zNo3xvAtjJvfbqi6LLqBwtwaSjxTmtRRUrwIe5hDo6gXL1z5Q3GK7C/ gPSuIq6sht/DK82HT+upaaYTEVYB+vWzWTTM4/w6JNYgX9X+tB/c0SODlJXhg== X-Received: by 2002:a17:902:f546:b0:2ca:6c8:abd8 with SMTP id d9443c01a7336-2d74df45042mr327708175ad.12.1788123180207; Sun, 30 Aug 2026 13:53:00 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:52:59 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:50 -0700 Subject: [PATCH 5/7] Input: gscps2 - return IRQ_NONE when interrupt is not handled 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: <20260830-gscps2-v1-5-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f gscps2_interrupt() is registered with IRQF_SHARED. Unconditionally returning IRQ_HANDLED when no data was pending on any GSC PS/2 port masks unhandled interrupts on the shared interrupt line and prevents the kernel core spurious interrupt detector from identifying runaway interrupt storms. Have gscps2_read_data() return whether any bytes were read, accumulate the handled status in gscps2_interrupt(), and return IRQ_RETVAL(handled). Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 36c25db9ff7f..907fb1537595 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -236,8 +236,9 @@ static void gscps2_flush(struct gscps2port *ps2port) ps2port->append =3D 0; } =20 -static void gscps2_read_data(struct gscps2port *ps2port) +static bool gscps2_read_data(struct gscps2port *ps2port) { + bool read_any =3D false; u8 status; =20 guard(spinlock_irqsave)(&ps2port->lock); @@ -247,11 +248,14 @@ static void gscps2_read_data(struct gscps2port *ps2po= rt) if (!(status & GSC_STAT_RBNE)) break; =20 + read_any =3D true; ps2port->buffer[ps2port->append].str =3D status; ps2port->buffer[ps2port->append].data =3D gscps2_readb_input(ps2port->addr); ps2port->append =3D (ps2port->append + 1) & BUFFER_SIZE; } while (true); + + return read_any; } =20 static bool gscps2_report_data(struct gscps2port *ps2port) @@ -300,11 +304,14 @@ static bool gscps2_report_data(struct gscps2port *ps2= port) static irqreturn_t gscps2_interrupt(int irq, void *dev) { struct gscps2port *ps2port; + bool handled =3D false; =20 guard(rcu)(); =20 - list_for_each_entry_rcu(ps2port, &ps2port_list, node) - gscps2_read_data(ps2port); + list_for_each_entry_rcu(ps2port, &ps2port_list, node) { + if (gscps2_read_data(ps2port)) + handled =3D true; + } =20 /* all data was read from the ports - now report the data to upper layer = */ list_for_each_entry_rcu(ps2port, &ps2port_list, node) { @@ -314,7 +321,7 @@ static irqreturn_t gscps2_interrupt(int irq, void *dev) } } =20 - return IRQ_HANDLED; + return IRQ_RETVAL(handled); } =20 /* --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 6003632AAD6 for ; Sun, 30 Aug 2026 20:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123185; cv=none; b=pnrCnHa1Tl5UNWxnYUZ0EsEtC6hqVIknZ2iST+qJ6wu/yS48Ib88f0qNDfpWTVRKj4mUCg0cfDUUH8lA7l7arEXQjXglKD9PnQ8Xq8ZEqQDq/cTpegQUOeTGMfMoX0tzTVEDYUMEgZWF/Shs/KJAm75mU1a2AMZN4QGq7eRH0v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123185; c=relaxed/simple; bh=bs9mrsFzM//ZHvK7snT2+IBTMQyZXvEiQ5+GAtaAmBE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mNPJKBJw1B9P3VoodvpGc4SagArGkPx7X+6C3tNUWsmqHEem/2fi4ey2+FZoNFmj5aE3cF3toPchRjfa1w5qanW0dPpHgTFhcDFJWPe1ceE+Wr/j55Cm/BDgYfwFQXtqOTf6TTPEgVZ9zKm0urWRvadVfN61Qzypywm7Kl6MrRo= 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=mHef68uN; arc=none smtp.client-ip=209.85.215.182 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="mHef68uN" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-cc1bc88a20eso3602200a12.3 for ; Sun, 30 Aug 2026 13:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123181; x=1788727981; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gMm1bV3fk8RuJ0iH9m0xwNjD31eH6ofBYEV7LvqwZ1I=; b=mHef68uNPpJMJrLW6Y9KqF0Td3KB8RuJfcXUcd95VmE5yWkYJ6POHwKmL1ZapalBb8 XE92rnbY6FgkxmgW28eaE425O4pgrCixhs2f9vEyrzeIkzQRNi71XKeeQ6ZSUlDr7+Wx HWR3dW6+SEU+ektyeujJ9ACnBO/mqrSLKq+1V3mZBBOFXq2HjO4uORBSgUyCHyjiMDuZ C3FX/SkLkGrWJHqEbgg/UKaQXjC87IniWEKPpqJyaVSCVFwqkfGc3Fq4mKDYdRrUq8+Y afwkpQo8Bs2N8At77shiGq2+11HCK0RmOSKG/bbLjqxaLV1dZ3rxMQVbB4Tg1RzRVPOi 3/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123181; x=1788727981; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gMm1bV3fk8RuJ0iH9m0xwNjD31eH6ofBYEV7LvqwZ1I=; b=drLGQ0tDnDTMDBc7nC3Q4NLaLvvfyV7AR7h7UML5l/3u4tTFt0uI89iUF3GvH4FDmW m1q9FmQligSeJvqRY+++fjKodNAFFaZHc20/L0P729ADlvwk/BKqo34F0gRHC6UX6NKN F96q9B5QnENDIkW4uEriASNEtC5aE5Pxk8Zd5pq3+vDe90qTs2OIPcS/NgWUxAuTiT1W qYHH8Qo/2QqscJd1n9Avp/NqxIMAqcE58vX7YH2ctnsjNTbJl52/EfI6D4sy9zGNOjrX l9PKS9aIFJBbY/5fmD20XnADF6S4PD9U6iEPA76ZOJN3f0p1bWFvjLrQ4o75yTmjkZed CWjQ== X-Gm-Message-State: AFuF++lKxiecmSE5O9tBwtm7IeQZj/hhWVYY6a2W74CU+/spiCCpRtq/ nm2cJAoYHwwydeyqG40zZeP1s85E9GhlngQB1RhXF2MHrnvunD0IrhFUmhCX7pGA X-Gm-Gg: AR+sD11ayvhe+6KfRqVXFiciFeN2MQq0wXHuy3qRqOB6fl3/8JfcLa/Illxr/thtl5X qiBSqylc3K1IJqVpfjB9of4RJlnNWrjwZyP18kGAdbZPNKpdcT0XwtDX478ZckbMHbe8g4/gqQZ BmZicAp05sqXWeZQmdOef+z5MDbKa8Yp4l14YATGSMrxJe4LdUOXyrrb2vKDHzAMvhFaKdUiqKb a+Aw490wSzG2vmsC8rxw6sYT9Qjcrit/c09zcCsKd7U/TX6lBMFMFQ3TX9ArFlGlW9m5nX2Vq+5 HHIPHXehJ0GHyD4UI1IhurZFyLbHzwkp0uvNHWzuHcZM+gnRRVesT9G/kCfRdg3uomQ3GWyylJI 4M2Ghq4y1Lu5sUDCGMzqMWdxI6G4XjJJUVDKGlnHggIenoaThSwfthovpf72SCc0lM0uEijQRmB cIReVaSo9xWTq0m/7izvrhPjFfKKyysedkztRKfce7CnwgjFf2bXS477hcS05CjrHvrhG6607v6 T/E4+lVGg4hyGBQun/dl4R03MkyoM11hG7Iof29X3tOQqyZREU= X-Received: by 2002:a05:6a20:7345:b0:3d1:7238:33d9 with SMTP id adf61e73a8af0-3d26532756amr33302467637.3.1788123181468; Sun, 30 Aug 2026 13:53:01 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.53.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:53:00 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:51 -0700 Subject: [PATCH 6/7] Input: gscps2 - serialize concurrent interrupt handlers 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: <20260830-gscps2-v1-6-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f gscps2_interrupt() may be invoked concurrently from a hardware interrupt on one CPU and from process context via gscps2_writeb_output() on another CPU. In gscps2_report_data(), ps2port->lock is released before calling serio_interrupt() to avoid recursive deadlocks. However, if two execution contexts run gscps2_report_data() concurrently for the same port, they could race to acquire serio->lock inside serio_interrupt(), potentially delivering multi-byte scancodes out of order. Serialize execution of gscps2_interrupt() using gscps2_interrupt_lock with ACQUIRE(spinlock_irqsave_try). Using spin_trylock prevents overlapping executions and guarantees in-order packet delivery without risking recursive deadlocks if an input driver synchronously sends a command back via serio_write(). If the lock cannot be acquired, return IRQ_NONE to preserve spurious interrupt detection on shared IRQ lines. Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 907fb1537595..2afd53a163ff 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -288,6 +288,8 @@ static bool gscps2_report_data(struct gscps2port *ps2po= rt) } } =20 +static DEFINE_SPINLOCK(gscps2_interrupt_lock); + /** * gscps2_interrupt() - Interruption service routine * @irq: interrupt number which triggered (unused) @@ -305,21 +307,31 @@ static irqreturn_t gscps2_interrupt(int irq, void *de= v) { struct gscps2port *ps2port; bool handled =3D false; + bool more_data; + + ACQUIRE(spinlock_irqsave_try, lock)(&gscps2_interrupt_lock); + if (ACQUIRE_ERR(spinlock_irqsave_try, &lock)) + return IRQ_NONE; =20 guard(rcu)(); =20 - list_for_each_entry_rcu(ps2port, &ps2port_list, node) { - if (gscps2_read_data(ps2port)) - handled =3D true; - } + do { + more_data =3D false; =20 - /* all data was read from the ports - now report the data to upper layer = */ - list_for_each_entry_rcu(ps2port, &ps2port_list, node) { - if (gscps2_report_data(ps2port)) { - /* More data ready - break early to restart interrupt */ - break; + list_for_each_entry_rcu(ps2port, &ps2port_list, node) { + if (gscps2_read_data(ps2port)) + handled =3D true; } - } + + /* all data was read from the ports - now report the data to upper layer= */ + list_for_each_entry_rcu(ps2port, &ps2port_list, node) { + if (gscps2_report_data(ps2port)) { + /* More data ready - restart loop to read new data */ + more_data =3D true; + break; + } + } + } while (more_data); =20 return IRQ_RETVAL(handled); } --=20 2.55.0.897.gb25b4bd76c-goog From nobody Sat Sep 26 20:28:07 2026 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 A2B8C32860B for ; Sun, 30 Aug 2026 20:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123192; cv=none; b=mQ+gPY9Llcp6X95SdRm3ILN05Zs5vXr4tJj5VtPdQ75jHF/6NQqVy4wutPDv9ZHiL/wdXOYs3ite+gUAv+Z99HeNzXVgXCz3SGaaZFygf3pbKbHFYZonqsEPYWq0AjCuCLpSEyIkLV8lTnOw0p/SOW7jBIXWBeag9C0hj1yxd+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788123192; c=relaxed/simple; bh=23/J+3gDoDVZml6rrky5zUoFra+g0uhnHf6Qlc/3LG0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XnzztNyv/7IB8by/v0bfn9mLB9jkkltjEe3v/by79annywUZH3fpYqNetm4vJcbDGsMTNbs8NmuK7GR6rqdtTVfQ3ZzEKtWTBKDXGo+6w6DqtdC0Waf+1cWa21A2wmLc+zeQjXn3s7tQkhUqehbn3f71r59p2j1zzdx+DGlpHRk= 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=HLG90q1n; arc=none smtp.client-ip=209.85.215.174 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="HLG90q1n" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-cc147d86bebso3162183a12.0 for ; Sun, 30 Aug 2026 13:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788123184; x=1788727984; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UDmUbvUq5gus03tv1ZZ+Ru3jkSSxaXW9u1MMK1TfK1M=; b=HLG90q1n9NfiZ0jTc3uS8Bu24RQ401hDn1PEKJc4P4I+TZDxDTZsfN08Fm/GdTIYAw PFLVcVDkp1XjH16KQRkM9Wh/ke6D6mTWkMAgcSBxHBeJ6vKHL//ogA+gFDRgIjAkup/z ex7kPXIa8FMtdU52zuZgERfxD7vMyobTw5sF7jkF/QjYFyQFfl1zYiPhw52w00tl+JyG A3AYOFhDBd92cBNENjC+eWDzklw7MEZ4kREpxpw5gOBzc6nao52Z98B0MrmDJ/o6l+QM JhmLreb/7UtdxJF8vCPTj1TlRkgs5XMiqSw5vozcbxV5b51Z60fTtKZacb6DTTjv8vwR awvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788123184; x=1788727984; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UDmUbvUq5gus03tv1ZZ+Ru3jkSSxaXW9u1MMK1TfK1M=; b=LCV5Ih4AsHa/HyecAXl/K4YsXqpQiqwVXWeV1LzIGM9Hi2POnGzYIrOwlATGKj+GIc GYdnSdUIVkHy7KXBHug6e3T5PGA+T9/v7oWvTP+SEVxpBGxGMtt498gX8RRBedxoiaOc g/PYrijtiP0KrtvfShpefchgdyqDfLyVChzq/JfCe2eu2GErFUsT/KGL2395Xfcei+FO 5N9/b27sx0V6B9B4L2Y5yi57Q/az7/dzOG4ijemwG0NzS0AmqbCJ76Q4UBKBMSC+tlCK YNAeNyQGFOepL6w6XkKu5f3ccIxHIQ71KPxjt0xRoOcnUs5kpbW3FXUqb/bJr1k0J0ct yRBw== X-Gm-Message-State: AFuF++lQgAOytf+soSRXuaCc+8JpQPvn1RkyicdhVlXeemdDmc1gWH9n G5CjMpSUe7h0MaAMWlMOKMVlAKgJ/oueJLphJnqsvAI0tkun6LqPiPZCnlLP+VXh X-Gm-Gg: AR+sD10v7u3qgBkmQ6WhVof1z/5CYjKXr3fujJqk72cjMAocXYt+7ejia4nDqFbConE 1JmICuNBbPbGtUHNHqNxZ3ylN+zkVz1SFCODiEGqUOcNAGSjSSmI/w8owaToe20IPDzN1Gt3NoP JkUBTfYkTKplue9WO951Q8pGcpGAwNKToSQgkFv+mfzdLnR7O6k89iJ/jwJhNG6CpnRdyYkasfB K7eiq5h5lev1eHHBU74PHIvztgRjnQ8D96ufu+19xteWrd8SpuFOuZwc8ux5R0Qes7SutGPcCop eKrGFvI/0qGLDjpiIE617hMco8B4HhZ22QXHeP9xr6IUHUmW3p+SP/mNkrywFrzb/ar7pf/RJyX bOIrNPX0m1AwiL+iERJAbkucaOkudKTGS/i2TcgPtL83FufHttXi1mCQ3Yvp84IUul0HGMAp+e0 YjmUP3tqbmLyY7waFKHxrPBnWLFPQBpMVDY+P4sKWjrV06xB20iESv2yziA4PuHiHB6fDX4MTSM A0VDPOqcbd/qouOFjgxUVUXBnB2Ks5FyOny8stHi4pcsqxo4WJeFvL7ju6iCg== X-Received: by 2002:a05:6a21:7e84:b0:3d3:3dca:f0a3 with SMTP id adf61e73a8af0-3d5d787403dmr2821879637.8.1788123183999; Sun, 30 Aug 2026 13:53:03 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:c021:485f:75be:3c7]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3286f9e3cf8sm26849437eec.24.2026.08.30.13.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 13:53:03 -0700 (PDT) From: Dmitry Torokhov Date: Sun, 30 Aug 2026 13:52:52 -0700 Subject: [PATCH 7/7] Input: gscps2 - drop busy-wait and manual interrupt pump on transmit 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: <20260830-gscps2-v1-7-c733d4cae7f9@gmail.com> References: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> In-Reply-To: <20260830-gscps2-v1-0-c733d4cae7f9@gmail.com> To: "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-parisc@vger.kernel.org, sashiko-bot@kernel.org X-Mailer: b4 0.16-dev-b242f In gscps2_writeb_output(), after writing data to GSC_XMTDATA, the driver explicitly executed mdelay(6) and manually called gscps2_interrupt() as a polling mechanism to accelerate command responses (such as keyboard ACK or LED updates). On PA-RISC, the PS/2 controller asserts a level interrupt to the system ASIC whenever received data arrives in hardware, and the input/serio subsystem handles command responses asynchronously via completions. Busy-waiting for 6 ms on every transmitted byte introduces significant unnecessary latency during multi-byte command sequences and complicates interrupt handler locking. Remove mdelay(6) and the manual invocation of gscps2_interrupt() from gscps2_writeb_output(), relying on normal hardware interrupt delivery. Reported-by: sashiko-bot@kernel.org Assisted-by: LLM Signed-off-by: Dmitry Torokhov --- drivers/input/serio/gscps2.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c index 2afd53a163ff..985539f1d088 100644 --- a/drivers/input/serio/gscps2.c +++ b/drivers/input/serio/gscps2.c @@ -356,13 +356,6 @@ static inline int gscps2_writeb_output(struct gscps2po= rt *ps2port, u8 data) scoped_guard(spinlock_irqsave, &ps2port->lock) writeb(data, addr + GSC_XMTDATA); =20 - /* this is ugly, but due to timing of the port it seems to be necessary. = */ - mdelay(6); - - /* make sure any received data is returned as fast as possible */ - /* this is important e.g. when we set the LEDs on the keyboard */ - gscps2_interrupt(0, NULL); - return 1; } =20 --=20 2.55.0.897.gb25b4bd76c-goog