From nobody Thu Oct 2 20:42:52 2025 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 B2B57273D6D for ; Thu, 11 Sep 2025 20:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757622178; cv=none; b=hgVnF+0dLp3e2/yzoIEtJZlQgddkS36sl1tjhixz5sfsCfPMhJgj1X3kTt2Stfo19d5HmmRHreoc/gWc8oimK5ObuYUpi32pVHYNRHorRe+K0dG6Y21/r8LvNRYkU31hNyluna4CFCuE5/i6ei0VmSJVoHNTnaaUDX7pNs3L0rE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757622178; c=relaxed/simple; bh=NOqmee/dDD5cagjg4HvJgFuGnZ/TnFg8cXA8JExo+/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Qwmxk+DMLZ/EgBVfnhkNUWPer9wLivJ+aZBYD/DvKQ+I83C6t4nt/2/QHjNXfzsbbkid0DsGDvkF/toWaj51BFdoUB256dkJx3OpaH13Bki1GO1QMsUu3DReoL3rCfxj+KBjIzIxDDOyBIYyyKNG7SSHGJgF6uQGiZSpUJmCQPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1uwnog-0005yg-JB; Thu, 11 Sep 2025 22:22:50 +0200 From: Marco Felsch Date: Thu, 11 Sep 2025 22:22:42 +0200 Subject: [PATCH v4 1/5] usb: port: track the disabled state 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: <20250911-v6-16-topic-usb-onboard-dev-v4-1-1af288125d74@pengutronix.de> References: <20250911-v6-16-topic-usb-onboard-dev-v4-0-1af288125d74@pengutronix.de> In-Reply-To: <20250911-v6-16-topic-usb-onboard-dev-v4-0-1af288125d74@pengutronix.de> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Fabio Estevam , Matthias Kaehlcke , Liam Girdwood , Mark Brown Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de, Marco Felsch X-Mailer: b4 0.14.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org The disable state isn't tracked at the moment, instead the state is directly passed to the hub driver. Change this behavior to only trigger the hub if a state change happened. Exit early in case of no state changes but don't return an error. Signed-off-by: Marco Felsch --- drivers/usb/core/hub.h | 2 ++ drivers/usb/core/port.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 9ebc5ef54a325d63e01b0deb59a1853d2b13c8d5..297adf2c6078809ca582104f228= e5222c464f999 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -97,6 +97,7 @@ struct usb_hub { * @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted. * @early_stop: whether port initialization will be stopped earlier. * @ignore_event: whether events of the port are ignored. + * @disabled: whether the port is disabled */ struct usb_port { struct usb_device *child; @@ -118,6 +119,7 @@ struct usb_port { unsigned int is_superspeed:1; unsigned int usb3_lpm_u1_permit:1; unsigned int usb3_lpm_u2_permit:1; + unsigned int disabled:1; }; =20 #define to_usb_port(_dev) \ diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index f54198171b6a3fb49c5f74f4a8a303b422d099eb..cae08a9a71e65c42fb9a8f53690= 60bd82b8daebb 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -117,6 +117,10 @@ static ssize_t disable_store(struct device *dev, struc= t device_attribute *attr, if (rc) return rc; =20 + /* Early quit if no change was detected */ + if (port_dev->disabled =3D=3D disabled) + return count; + hub_get(hub); rc =3D usb_autopm_get_interface(intf); if (rc < 0) @@ -148,6 +152,8 @@ static ssize_t disable_store(struct device *dev, struct= device_attribute *attr, usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE); } =20 + port_dev->disabled =3D disabled; + if (!rc) rc =3D count; =20 --=20 2.47.3