From nobody Sun Feb 8 04:17:41 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E23BE4C957F for ; Thu, 8 Jan 2026 13:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767879575; cv=none; b=mn0NmgvJEKZIp2yeoTEdvWs2fs4XQKBHEf2lhExoeW9/zdCleVJetSbxInoCwqzMQer1TFVXdaw+tqleJ5XPr/1cIkRy8Y6I5yN/kaH1CuolNI2aeZWEjAwB6ygWHc5gRMLETXpqYQzGn9Mt4SSyEWK2MeVy7xBHYB3OpOWhmxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767879575; c=relaxed/simple; bh=nCRiDCaT8yK5ye8iHjJw9IcWUflG3KmvYZ4eH9WPKZA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=F32FbmbG19HrzzC2tyDmkHLCW1nUujlUFEAyFPvjvkYXHiA3w1zOjzHJJ1AxTqzuXUDPUaadCUo9r1MMzrEsoAUcdzBJPP4XLvIh29aLgLiV5z/wu3hnSUntUyHF+z1zSEqzEL8m7FUKuh0gacx5LCzB+AVXGCfBRdcxJ+h5dwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=eNNC1cFD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=erbcmGIp; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="eNNC1cFD"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="erbcmGIp" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6089FwuN878063 for ; Thu, 8 Jan 2026 13:39:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=733x5L3JU69gmVDQP6/lL4 XGh5m0v/GcKMZkPc8vrcU=; b=eNNC1cFDUxHoAq43NxigMO7fZ5xnZYD+I2Wifp 6mChEOZgJuB1LKjQln3cJyPjV06Z4fzRfe/fKDf7p4ut6sg8qocEoTO0W95MvSbe 2a8FuL4r2aNjzWc9KwIa0xwRTNao4w+v7oszJjMG635o0JH52al8l3e0zBuhFYd+ RvfS+LLRfKNyIe9/Qvr66dGw0ZzWpxiREKiZRQn2EAoKciKhV7YcMgAXQ1Uo/zQ0 31fnhJeqqV4IXfQHmddWqOfluKNR7CuigxlZUaBUkmbZTKNtqKc81blQ2P7nQJwj JQs+QOc/NS940o0mlcLxe9K70nfEaFvnxnY4+diR/AK3ULVw== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bj2r3236b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 08 Jan 2026 13:39:31 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-8bb6a7fea4dso760636985a.0 for ; Thu, 08 Jan 2026 05:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767879571; x=1768484371; 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=733x5L3JU69gmVDQP6/lL4XGh5m0v/GcKMZkPc8vrcU=; b=erbcmGIpKguiCpiuqWq5CXwx4YKyrIjyZmnzmp2C5fpUOCgOmHQ55sJEuvv0yuAm46 O9SaHfOmpW/TyuIPWXKaLx6+2hJ5ukGq2iM/etJ90F0/qZ+WkApljG887QuaIq5j058+ 7CWsS2cIznxLhPOGEu/tqm1eqcB0k1LTWUm1F+Ah/KGqH7wcXwfpodcdcmJFUwbFdB5s hxtqLvNlbjrq3WJLMPZcnc17ARllPs3yrH1Y/eTqtTJIYo9wgI9oqheji0+CFben/BW1 18S90xOtcCRW6/fC2TJYfGOBDn7uZi6/is7BfZSQm/svmMNukc7cW1IXGeMNxquyNZXE rDjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767879571; x=1768484371; 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=733x5L3JU69gmVDQP6/lL4XGh5m0v/GcKMZkPc8vrcU=; b=IrAUQh0iTLcTj3CfmX6z7O0Vhd1t1YAEy6lidgAOJtTamVj0O1wycmRsWU1izsGnOU c6dckh1CBAJCDciQd1THgY8zR3zNYV63HZUiW4dXLEVXFZVTl7UBYedreil/bnYDlk3O kO6p3UobTeVz/7vAtRNESG3IVCs8lUuLeMENg/EuYtW2GEDZXEf+2Ci0JVfiHFdGPUJT EqV2wxHkdoCvghMNKFLGC3xuKNMUdhU/4FGLYmJio2RnA2zkzBIPJRz87l8kBla7qncZ 0WZjSrH972tnA2A9UVd8F6RjaqFRlunY/q0cJLDRmQP2/2Sx17AGNPbE+MRFPwMnuLC4 Zyyg== X-Forwarded-Encrypted: i=1; AJvYcCVxczsjXfpAXdkNdvwplU6w/IbGkKgoqBrfETff9ZcfaCqvS0nbznfrr/3b437ZcMtp13SHKDFr6+GyjGY=@vger.kernel.org X-Gm-Message-State: AOJu0YxjvWMj+r9xEZfQld3lnyq9USwsNppotkyYxUWYWYW7I/8Q63O6 klTosgC2OYVp5PlN9vKdBVmzxPBtZJxOMOviUOy3uWFFUHuZ1CvxGkJ8MaoO5t3KFOCEW4vlzYU X4iQtNJTHY/15jHuCoYJQi2U3O3hTSVjlrJBvt52Zhzt0lp89NwciRy/l1g7JAMdQT2B6bYm30O s= X-Gm-Gg: AY/fxX53qqbtfU+G5xQPtBRsEF/xZ6vAg/sGXODQc5N1dy8Z4ZLkCxp8WFzTLuHJcdM grYc/RYe0js4aPYxlkL6JDYF/8nAwfGvJ5lLu+bBmwpcRp3XAFQozFl8m3bQcRWYbvZhzE6scbT GgUkjDOykIqelsL6mkDPu8vP2xDJshu92g2RPxW+VGzRJiFGoldGiGYDImERAuA6W5vin1lVtLg /R/3Bu6MjtBh2lFdLm3g53NdvGyHjLtdEKb0Gy6gNJLyFqbdjsVaUUsDEL2rwhbUbxXv5NPYT/m AFbvRrVt6WpwmNgjBMs+tUz1Tu25bNPk3+JrK14xzGuzYfguobbMU8VDW1mxKT/z7nXgilNw0qw wnBaOeV7HIjW2lODqKIKitB/D58Lphzj1fJeGqXg= X-Received: by 2002:a05:620a:258c:b0:88f:c0e1:ec2 with SMTP id af79cd13be357-8c3893f7e49mr762586085a.60.1767879570787; Thu, 08 Jan 2026 05:39:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZdxC7dh0OB77YvPHWkJ1apfDQISjG8KTfaLYvrKSDHxYPPqIPGscbzAKY2oNRCUJ1FewAXg== X-Received: by 2002:a05:620a:258c:b0:88f:c0e1:ec2 with SMTP id af79cd13be357-8c3893f7e49mr762582885a.60.1767879570377; Thu, 08 Jan 2026 05:39:30 -0800 (PST) Received: from brgl-qcom.local ([2a01:cb1d:dc:7e00:5171:301c:72f8:fd25]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f68f686sm152930485e9.3.2026.01.08.05.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 05:39:29 -0800 (PST) From: Bartosz Golaszewski Date: Thu, 08 Jan 2026 14:39:19 +0100 Subject: [PATCH] gpio: shared: fix a false-positive sharing detection with reset-gpios 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: <20260108-gpio-shared-false-positive-v1-1-5dbf8d1b2f7d@oss.qualcomm.com> X-B4-Tracking: v=1; b=H4sIAIazX2kC/x3MTQqDMBAG0KvIrDuQpODfVUoXg/nUATEhU0QQ7 97g8m3eRYaiMBqbiwoONU17hX81NK2yL2CN1RRcaJ13PS9ZE9sqBZFn2Qyck+lPD/AA17+7QaS dItUgF8x6Pvnne99/mhWb42wAAAA= X-Change-ID: 20260108-gpio-shared-false-positive-9e08379aa6cd To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3334; i=bartosz.golaszewski@oss.qualcomm.com; h=from:subject:message-id; bh=nCRiDCaT8yK5ye8iHjJw9IcWUflG3KmvYZ4eH9WPKZA=; b=owEBbQKS/ZANAwAKAQWdLsv/NoTDAcsmYgBpX7OLwR27FnXinmfI56jPOMbMNSrBPnTOoKxf7 VMcsJCevquJAjMEAAEKAB0WIQSR5RMt5bVGHXuiZfwFnS7L/zaEwwUCaV+ziwAKCRAFnS7L/zaE w/jVEAC658jNRrJsZKWTgi9njV4fjHkX4/uwMQCi6sxEhMwmB/f0shgnzwG4IG7jA3o9V+tUHuA zttpw3cedTyXP8KvtoUkni3sod/+p3Pmou2zaAb1pkopA1qzQRIeLmGnlIpNdFJNkYohFbLRpEB 40I1Zceq4QGE8I3f5fhn/bArFxpuUeirIfmf28yvlDaBPJ+oa/2xqWVk3X9+vHzloUJVTQ8iPQ5 Km91LZB+5VlKeqjAObAGq1Fmye4twQtntbPrjD+tI/S1n1ind7sRGNco/3zcS1WKGVQ16MeZWlX 9kRLQKTjCwqUxvU3dLutVVnC0fWFYYiyVip8klSCne2/fAknSw3oNSqWixy0ynQwlVzTSOBW8T8 S/vTwKGV3BUeZ1rygw1OgavmypE6PNjGoJGEDm/l2oNWv2Ava7Pit99sPSA++sx5VcrDs5BVPGF lwfd9zuVD2TPA2Y7uxv3TaIr8fRsg83+l6IZ0DSeY6R4vmY352M5aCJDVxd/e0PxYkBuQtCCP3Z tnZEfy92hBgJHnppCPg0fe9SEVMe5G5MEgQ1SPyCuUKl4o69QWnFoB0QGWGc9QbiyjnTkhEsG+j 9JTFOaY1Ue6LrPIsAfUS2B6CT7f9p+352H6+v3KjVuBbDDAFWRnhabxKZJCF6ok8aCG1VHd6Ft+ RBbPmwjCHFLs0yg== X-Developer-Key: i=bartosz.golaszewski@oss.qualcomm.com; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA4MDA5NiBTYWx0ZWRfX0h+vMKspUyiV 743Q5gRSvta0A/Yl0bhSNcgHmskUw7evdjksX4pjePquXG0Yi0BahNmf2l1jzpFLr5ebnyKY56J CdGsvkOl32ydRA+gdmXAKLigonhELT91rwdDZQgUZJA1xIVZy29BTHXtDSvJscC7BeYgjTto9aI r2XHb7FNsRvNhxumXXHuAefo4M0MIPie9/vITw/Xf1h3noqRtN2LAufIaqI5Br9iXXaveorl3s6 +EsKSeBYu2IZE2GM7jMn0gJnoqcb0kZqLpDJfOnQwntNISOE2SNLLMrbn/jbmhAPH+ncIcCucz1 CEgJ6xPLACL69ldMyPvQtYY1Hc/rR5K6yGq9BPF8in7m1jzIqgSBFhyVHAZ7No3yKMMWEPzZaij YQ1fTP4moHTjCe4itbK+nozY/XMGdnyJwNZqlYwGW2M+GVl20QgwNQFcHj1SVq3C/kpCuiZXsLz SSLlu2D0BITO7MtsyRw== X-Proofpoint-ORIG-GUID: 89oRMKv1CIHkrqy3bK2RS2jLmiVmz78i X-Proofpoint-GUID: 89oRMKv1CIHkrqy3bK2RS2jLmiVmz78i X-Authority-Analysis: v=2.4 cv=S4nUAYsP c=1 sm=1 tr=0 ts=695fb393 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=i1YPiP8vL7GWhwZyTnAA:9 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-08_02,2026-01-07_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 spamscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2601080096 After scanning the devicetree, we remove all entries that have only one reference, while creating GPIO shared proxies for the remaining, shared entries. However: for the reset-gpio corner-case, we will have two references for a "reset-gpios" pin that's not really shared. In this case one will come from the actual consumer fwnode and the other from the potential auxiliary reset-gpio device. This causes the GPIO core to create unnecessary GPIO shared proxy devices for pins that are not really shared. Add a function that can detect this situation and remove entries that have exactly two references but one of them is a reset-gpio. Fixes: 7b78b26757e0 ("gpio: shared: handle the reset-gpios corner case") Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib-shared.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c index 076d8642675c2723c8938cbd22b1b51014c23871..17343fdc9758402b3cc7c8d61ee= 908591c977539 100644 --- a/drivers/gpio/gpiolib-shared.c +++ b/drivers/gpio/gpiolib-shared.c @@ -41,6 +41,7 @@ struct gpio_shared_ref { struct lock_class_key lock_key; struct auxiliary_device adev; struct gpiod_lookup_table *lookup; + bool is_reset_gpio; }; =20 /* Represents a single GPIO pin. */ @@ -112,7 +113,8 @@ static int gpio_shared_setup_reset_proxy(struct gpio_sh= ared_entry *entry, struct gpio_shared_ref *ref; =20 list_for_each_entry(ref, &entry->refs, list) { - if (!ref->fwnode && ref->con_id && strcmp(ref->con_id, "reset") =3D=3D 0) + if (ref->is_reset_gpio) + /* Already set-up. */ return 0; } =20 @@ -120,6 +122,8 @@ static int gpio_shared_setup_reset_proxy(struct gpio_sh= ared_entry *entry, if (!ref) return -ENOMEM; =20 + ref->is_reset_gpio =3D true; + list_add_tail(&ref->list, &entry->refs); =20 pr_debug("Created a secondary shared GPIO reference for potential reset-g= pio device for GPIO %u at %s\n", @@ -714,12 +718,38 @@ static void __init gpio_shared_teardown(void) } } =20 +static bool gpio_shared_entry_is_really_shared(struct gpio_shared_entry *e= ntry) +{ + size_t num_nodes =3D list_count_nodes(&entry->refs); + struct gpio_shared_ref *ref; + + if (num_nodes <=3D 1) + return false; + + if (num_nodes > 2) + return true; + + /* Exactly two references: */ + list_for_each_entry(ref, &entry->refs, list) { + /* + * Corner-case: the second reference comes from the potential + * reset-gpio instance. However, this pin is not really shared + * as it would have three references in this case. Avoid + * creating unnecessary proxies. + */ + if (ref->is_reset_gpio) + return false; + } + + return true; +} + static void gpio_shared_free_exclusive(void) { struct gpio_shared_entry *entry, *epos; =20 list_for_each_entry_safe(entry, epos, &gpio_shared_list, list) { - if (list_count_nodes(&entry->refs) > 1) + if (gpio_shared_entry_is_really_shared(entry)) continue; =20 gpio_shared_drop_ref(list_first_entry(&entry->refs, --- base-commit: fc4e91c639c0af93d63c3d5bc0ee45515dd7504a change-id: 20260108-gpio-shared-false-positive-9e08379aa6cd Best regards, --=20 Bartosz Golaszewski