linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup
@ 2025-07-25 22:08 Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
                   ` (18 more replies)
  0 siblings, 19 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

The USB/IP Virtual Host Controller (VHCI) platform driver is expected to
prevent entering system suspend when at least one remote device is
attached to the virtual USB root hub.

However, in some cases, the detection logic for active USB/IP
connections doesn't seem to work reliably, e.g. when all devices
attached to the virtual hub have been already suspended.  This will
normally lead to a broken suspend state, with unrecoverable resume.

The first patch of the series provides a workaround to ensure the
virtually attached devices do not enter suspend.  Note this is currently
limited to the client side (vhci_hcd) only, since the server side
(usbip_host) doesn't implement system suspend prevention.

Additionally, during the investigation I noticed and fixed a bunch of
coding style issues, hence the subsequent patches contain all the
changes needed to make checkpatch happy for the entire driver.

IMPORTANT:

Please note commit aa7a9275ab81 ("PM: sleep: Suspend async parents after
suspending children") from v6.16-rc1 introduced a regression which
breaks the suspend cancellation and hangs the system.

A fix [1] has been already provided, which also landed soon after in
v6.16-rc7 under commit ebd6884167ea ("PM: sleep: Update power.completion
for all devices on errors").

[1] https://lore.kernel.org/all/6191258.lOV4Wx5bFT@rjwysocki.net/

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Changes in v2:
- Updated cover letter to indicate the PM core fix has landed in
  v6.16-rc7
- Also made it clear that the patch fixing up suspend prevention only
  applies to the client side (vhci_hcd), since the server side
  (usbip_host) doesn't implement this functionality
- Documented the usage of dev_pm_syscore_device() in vhci_urb_enqueue()
- Reworked most of the cleanup patches according to the feedback
  received from Greg
- Link to v1: https://lore.kernel.org/r/20250717-vhci-hcd-suspend-fix-v1-0-2b000cd05952@collabora.com

---
Cristian Ciocaltea (18):
      usb: vhci-hcd: Prevent suspending virtually attached devices
      usb: vhci-hcd: Ensure lines do not end with '('
      usb: vhci-hcd: Consistently use the braces
      usb: vhci-hcd: Avoid unnecessary use of braces
      usb: vhci-hcd: Consistently use blank lines
      usb: vhci-hcd: Drop spaces after casts
      usb: vhci-hcd: Add spaces around operators
      usb: vhci-hcd: Drop unnecessary parentheses
      usb: vhci-hcd: Fix open parenthesis alignment
      usb: vhci-hcd: Simplify NULL comparison
      usb: vhci-hcd: Simplify kzalloc usage
      usb: vhci-hcd: Use the paranthesized form of sizeof
      usb: vhci-hcd: Fix block comments
      usb: vhci-hcd: Remove ftrace-like logging
      usb: vhci-hcd: Consistently use __func__
      usb: vhci-hcd: Do not split quoted strings
      usb: vhci-hcd: Switch to dev_err_probe() in probe path
      usb: vhci-hcd: Replace pr_*() with dev_*() logging

 drivers/usb/usbip/vhci_hcd.c | 274 +++++++++++++++++++++++--------------------
 1 file changed, 146 insertions(+), 128 deletions(-)
---
base-commit: 024e09e444bd2b06aee9d1f3fe7b313c7a2df1bb
change-id: 20250714-vhci-hcd-suspend-fix-7db5c25c509d


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-26  6:43   ` Greg Kroah-Hartman
  2025-07-26  7:06   ` Greg Kroah-Hartman
  2025-07-25 22:08 ` [PATCH v2 02/18] usb: vhci-hcd: Ensure lines do not end with '(' Cristian Ciocaltea
                   ` (17 subsequent siblings)
  18 siblings, 2 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

The VHCI platform driver aims to forbid entering system suspend when at
least one of the virtual USB ports are bound to an active USB/IP
connection.

However, in some cases, the detection logic doesn't work reliably, i.e.
when all devices attached to the virtual root hub have been already
suspended, leading to a broken suspend state, with unrecoverable resume.

Ensure the virtually attached devices do not enter suspend by setting
the syscore PM flag.  Note this is currently limited to the client side
only, since the server side doesn't implement system suspend prevention.

Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..b4b0ed5d64966214636b157968478600e2e4178a 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -765,6 +765,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 				 ctrlreq->wValue, vdev->rhport);
 
 			vdev->udev = usb_get_dev(urb->dev);
+			/*
+			 * FIXME: A similar operation has been done via
+			 * USB_REQ_GET_DESCRIPTOR handler below, which is
+			 * supposed to always precede USB_REQ_SET_ADDRESS.
+			 *
+			 * It's not entirely clear if operating on a different
+			 * usb_device instance here is a real possibility,
+			 * otherwise this call and vdev->udev assignment above
+			 * should be dropped.
+			 */
+			dev_pm_syscore_device(&vdev->udev->dev, true);
 			usb_put_dev(old);
 
 			spin_lock(&vdev->ud.lock);
@@ -785,6 +796,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
 			vdev->udev = usb_get_dev(urb->dev);
+			/*
+			 * Set syscore PM flag for the virtually attached
+			 * devices to ensure they will not enter suspend on
+			 * the client side.
+			 *
+			 * Note this doesn't have any impact on the physical
+			 * devices attached to the host system on the server
+			 * side, hence there is no need to undo the operation
+			 * on disconnect.
+			 */
+			dev_pm_syscore_device(&vdev->udev->dev, true);
 			usb_put_dev(old);
 			goto out;
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 02/18] usb: vhci-hcd: Ensure lines do not end with '('
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 03/18] usb: vhci-hcd: Consistently use the braces Cristian Ciocaltea
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Format code to get rid of the checkpatch complaint:

  CHECK: Lines should not end with a '('

While at it, also remove the leading whitespace from the quoted
strings passed as arguments to the affected functions.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 46 +++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index b4b0ed5d64966214636b157968478600e2e4178a..ec82a8dcabb90fd975e5a216c6e0835d2010a7b6 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -289,8 +289,8 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc)
 	memset(desc, 0, sizeof *desc);
 	desc->bDescriptorType = USB_DT_SS_HUB;
 	desc->bDescLength = 12;
-	desc->wHubCharacteristics = cpu_to_le16(
-		HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
+	desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
+						HUB_CHAR_COMMON_OCPM);
 	desc->bNbrPorts = VHCI_HC_PORTS;
 	desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/
 	desc->u.ss.DeviceRemovable = 0xffff;
@@ -302,9 +302,8 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
 
 	memset(desc, 0, sizeof(*desc));
 	desc->bDescriptorType = USB_DT_HUB;
-	desc->wHubCharacteristics = cpu_to_le16(
-		HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
-
+	desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
+						HUB_CHAR_COMMON_OCPM);
 	desc->bNbrPorts = VHCI_HC_PORTS;
 	BUILD_BUG_ON(VHCI_HC_PORTS > USB_MAXCHILDREN);
 	width = desc->bNbrPorts / 8 + 1;
@@ -378,8 +377,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				       "supported for USB 3.0 roothub\n");
 				goto error;
 			}
-			usbip_dbg_vhci_rh(
-				" ClearPortFeature: USB_PORT_FEAT_SUSPEND\n");
+
+			usbip_dbg_vhci_rh("ClearPortFeature: USB_PORT_FEAT_SUSPEND\n");
 			if (vhci_hcd->port_status[rhport] & USB_PORT_STAT_SUSPEND) {
 				/* 20msec signaling */
 				vhci_hcd->resuming = 1;
@@ -387,8 +386,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			}
 			break;
 		case USB_PORT_FEAT_POWER:
-			usbip_dbg_vhci_rh(
-				" ClearPortFeature: USB_PORT_FEAT_POWER\n");
+			usbip_dbg_vhci_rh("ClearPortFeature: USB_PORT_FEAT_POWER\n");
 			if (hcd->speed >= HCD_USB3)
 				vhci_hcd->port_status[rhport] &= ~USB_SS_PORT_STAT_POWER;
 			else
@@ -464,10 +462,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				VDEV_ST_NOTASSIGNED ||
 			    vhci_hcd->vdev[rhport].ud.status ==
 				VDEV_ST_USED) {
-				usbip_dbg_vhci_rh(
-					" enable rhport %d (status %u)\n",
-					rhport,
-					vhci_hcd->vdev[rhport].ud.status);
+				usbip_dbg_vhci_rh("enable rhport %d (status %u)\n",
+						  rhport,
+						  vhci_hcd->vdev[rhport].ud.status);
 				vhci_hcd->port_status[rhport] |=
 					USB_PORT_STAT_ENABLE;
 			}
@@ -502,8 +499,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	case SetPortFeature:
 		switch (wValue) {
 		case USB_PORT_FEAT_LINK_STATE:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
 			if (hcd->speed < HCD_USB3) {
 				pr_err("USB_PORT_FEAT_LINK_STATE req not "
 				       "supported for USB 2.0 roothub\n");
@@ -515,12 +511,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			 */
 			break;
 		case USB_PORT_FEAT_U1_TIMEOUT:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_U1_TIMEOUT\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U1_TIMEOUT\n");
 			fallthrough;
 		case USB_PORT_FEAT_U2_TIMEOUT:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
 			/* TODO: add suspend/resume support! */
 			if (hcd->speed < HCD_USB3) {
 				pr_err("USB_PORT_FEAT_U1/2_TIMEOUT req not "
@@ -529,8 +523,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			}
 			break;
 		case USB_PORT_FEAT_SUSPEND:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
 			/* Applicable only for USB2.0 hub */
 			if (hcd->speed >= HCD_USB3) {
 				pr_err("USB_PORT_FEAT_SUSPEND req not "
@@ -546,8 +539,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			vhci_hcd->port_status[rhport] |= USB_PORT_STAT_SUSPEND;
 			break;
 		case USB_PORT_FEAT_POWER:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_POWER\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_POWER\n");
 			if (invalid_rhport) {
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
@@ -558,8 +550,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				vhci_hcd->port_status[rhport] |= USB_PORT_STAT_POWER;
 			break;
 		case USB_PORT_FEAT_BH_PORT_RESET:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
 			if (invalid_rhport) {
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
@@ -572,8 +563,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			}
 			fallthrough;
 		case USB_PORT_FEAT_RESET:
-			usbip_dbg_vhci_rh(
-				" SetPortFeature: USB_PORT_FEAT_RESET\n");
+			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_RESET\n");
 			if (invalid_rhport) {
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
@@ -792,7 +782,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 
 		case USB_REQ_GET_DESCRIPTOR:
 			if (ctrlreq->wValue == cpu_to_le16(USB_DT_DEVICE << 8))
-				usbip_dbg_vhci_hc(
+				usbip_dbg_vhci_hc(/**/
 					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
 			vdev->udev = usb_get_dev(urb->dev);

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 03/18] usb: vhci-hcd: Consistently use the braces
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 02/18] usb: vhci-hcd: Ensure lines do not end with '(' Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 04/18] usb: vhci-hcd: Avoid unnecessary use of braces Cristian Ciocaltea
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Fix the inconsistent usage of braces as reported by checkpatch:

  CHECK: braces {} should be used on all arms of this statement
  CHECK: Unbalanced braces around else statement

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index ec82a8dcabb90fd975e5a216c6e0835d2010a7b6..dfdd6ae2cf95c7d5a24d97f713d86588c2dab350 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -346,8 +346,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		invalid_rhport = true;
 		if (wIndex > VHCI_HC_PORTS)
 			pr_err("invalid port number %d\n", wIndex);
-	} else
+	} else {
 		rhport = wIndex - 1;
+	}
 
 	vhci_hcd = hcd_to_vhci_hcd(hcd);
 	vhci = vhci_hcd->vhci;
@@ -598,11 +599,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				     USB_SS_PORT_STAT_POWER) != 0) {
 					vhci_hcd->port_status[rhport] |= (1 << wValue);
 				}
-			} else
+			} else {
 				if ((vhci_hcd->port_status[rhport] &
 				     USB_PORT_STAT_POWER) != 0) {
 					vhci_hcd->port_status[rhport] |= (1 << wValue);
 				}
+			}
 		}
 		break;
 	case GetPortErrorCount:

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 04/18] usb: vhci-hcd: Avoid unnecessary use of braces
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (2 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 03/18] usb: vhci-hcd: Consistently use the braces Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 05/18] usb: vhci-hcd: Consistently use blank lines Cristian Ciocaltea
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Improve code readability in vhci_urb_dequeue() by getting rid of a pair
of braces and reduce the indentation level of the related code block.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index dfdd6ae2cf95c7d5a24d97f713d86588c2dab350..cace9bbbd528602703869cf955f93b311fddd045 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -888,6 +888,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 	struct vhci_priv *priv;
 	struct vhci_device *vdev;
 	unsigned long flags;
+	int ret;
 
 	spin_lock_irqsave(&vhci->lock, flags);
 
@@ -899,14 +900,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 		return -EIDRM;
 	}
 
-	{
-		int ret = 0;
-
-		ret = usb_hcd_check_unlink_urb(hcd, urb, status);
-		if (ret) {
-			spin_unlock_irqrestore(&vhci->lock, flags);
-			return ret;
-		}
+	ret = usb_hcd_check_unlink_urb(hcd, urb, status);
+	if (ret) {
+		spin_unlock_irqrestore(&vhci->lock, flags);
+		return ret;
 	}
 
 	 /* send unlink request here? */

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 05/18] usb: vhci-hcd: Consistently use blank lines
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (3 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 04/18] usb: vhci-hcd: Avoid unnecessary use of braces Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 06/18] usb: vhci-hcd: Drop spaces after casts Cristian Ciocaltea
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Add blank lines where it helps improve code readability and drop those
which are really not required, as indicated by checkpatch:

  CHECK: Blank lines aren't necessary after an open brace '{'
  CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index cace9bbbd528602703869cf955f93b311fddd045..c739107a3e0411ba2e8227ea6db46802b4882177 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -145,6 +145,7 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status, bool usb3)
 			if (bit == 1) /* USB_PORT_STAT_CONNECTION */
 				pr_debug(" %c%s\n", change, "USB_PORT_STAT_SPEED_5GBPS");
 		}
+
 		bit <<= 1;
 		i++;
 	}
@@ -267,7 +268,6 @@ static struct {
 	struct usb_bos_descriptor bos;
 	struct usb_ss_cap_descriptor ss_cap;
 } __packed usb3_bos_desc = {
-
 	.bos = {
 		.bLength		= USB_DT_BOS_SIZE,
 		.bDescriptorType	= USB_DT_BOS,
@@ -306,6 +306,7 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
 						HUB_CHAR_COMMON_OCPM);
 	desc->bNbrPorts = VHCI_HC_PORTS;
 	BUILD_BUG_ON(VHCI_HC_PORTS > USB_MAXCHILDREN);
+
 	width = desc->bNbrPorts / 8 + 1;
 	desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
 	memset(&desc->u.hs.DeviceRemovable[0], 0, width);
@@ -371,6 +372,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			pr_err("invalid port number %d\n", wIndex);
 			goto error;
 		}
+
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
 			if (hcd->speed >= HCD_USB3) {
@@ -398,6 +400,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 					  wValue);
 			if (wValue >= 32)
 				goto error;
+
 			vhci_hcd->port_status[rhport] &= ~(1 << wValue);
 			break;
 		}
@@ -410,6 +413,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
 			goto error;
 		}
+
 		if (hcd->speed >= HCD_USB3)
 			ss_hub_descriptor((struct usb_hub_descriptor *) buf);
 		else
@@ -506,6 +510,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				       "supported for USB 2.0 roothub\n");
 				goto error;
 			}
+
 			/*
 			 * Since this is dummy we don't have an actual link so
 			 * there is nothing to do for the SET_LINK_STATE cmd
@@ -545,6 +550,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
 			}
+
 			if (hcd->speed >= HCD_USB3)
 				vhci_hcd->port_status[rhport] |= USB_SS_PORT_STAT_POWER;
 			else
@@ -556,6 +562,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
 			}
+
 			/* Applicable only for USB3.0 hub */
 			if (hcd->speed < HCD_USB3) {
 				pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
@@ -569,6 +576,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
 			}
+
 			/* if it's already enabled, disable */
 			if (hcd->speed >= HCD_USB3) {
 				vhci_hcd->port_status[rhport] = 0;
@@ -592,8 +600,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				pr_err("invalid port number %d\n", wIndex);
 				goto error;
 			}
+
 			if (wValue >= 32)
 				goto error;
+
 			if (hcd->speed >= HCD_USB3) {
 				if ((vhci_hcd->port_status[rhport] &
 				     USB_SS_PORT_STAT_POWER) != 0) {
@@ -722,6 +732,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 		spin_unlock_irqrestore(&vhci->lock, flags);
 		return -ENODEV;
 	}
+
 	spin_unlock(&vdev->ud.lock);
 
 	ret = usb_hcd_link_urb_to_ep(hcd, urb);
@@ -811,7 +822,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 			ret =  -EINVAL;
 			goto no_need_xmit;
 		}
-
 	}
 
 out:
@@ -832,6 +842,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 		usb_hcd_giveback_urb(hcd, urb, urb->status);
 		local_irq_enable();
 	}
+
 	return ret;
 }
 
@@ -1222,12 +1233,14 @@ static int vhci_start(struct usb_hcd *hcd)
 			dev_err(hcd_dev(hcd), "init attr group failed, err = %d\n", err);
 			return err;
 		}
+
 		err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
 		if (err) {
 			dev_err(hcd_dev(hcd), "create sysfs files failed, err = %d\n", err);
 			vhci_finish_attr_group();
 			return err;
 		}
+
 		pr_info("created sysfs %s\n", hcd_name(hcd));
 	}
 
@@ -1289,10 +1302,12 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
 	dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
 
 	spin_lock_irqsave(&vhci->lock, flags);
+
 	if (!HCD_HW_ACCESSIBLE(hcd))
 		rc = -ESHUTDOWN;
 	else
 		hcd->state = HC_STATE_RUNNING;
+
 	spin_unlock_irqrestore(&vhci->lock, flags);
 
 	return rc;
@@ -1365,6 +1380,7 @@ static int vhci_hcd_probe(struct platform_device *pdev)
 		pr_err("create primary hcd failed\n");
 		return -ENOMEM;
 	}
+
 	hcd_hs->has_tt = 1;
 
 	/*
@@ -1480,6 +1496,7 @@ static int vhci_hcd_resume(struct platform_device *pdev)
 	hcd = platform_get_drvdata(pdev);
 	if (!hcd)
 		return 0;
+
 	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
 	usb_hcd_poll_rh_status(hcd);
 
@@ -1511,6 +1528,7 @@ static void del_platform_devices(void)
 		platform_device_unregister(vhcis[i].pdev);
 		vhcis[i].pdev = NULL;
 	}
+
 	sysfs_remove_link(&platform_bus.kobj, driver_name);
 }
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 06/18] usb: vhci-hcd: Drop spaces after casts
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (4 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 05/18] usb: vhci-hcd: Consistently use blank lines Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 07/18] usb: vhci-hcd: Add spaces around operators Cristian Ciocaltea
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Fix a bunch of checkpatch reports:

  CHECK: No space is necessary after a cast

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index c739107a3e0411ba2e8227ea6db46802b4882177..5b2d4a57dddf06fcbb8ce8e39306d1b5c4b23b38 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -415,9 +415,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		}
 
 		if (hcd->speed >= HCD_USB3)
-			ss_hub_descriptor((struct usb_hub_descriptor *) buf);
+			ss_hub_descriptor((struct usb_hub_descriptor *)buf);
 		else
-			hub_descriptor((struct usb_hub_descriptor *) buf);
+			hub_descriptor((struct usb_hub_descriptor *)buf);
 		break;
 	case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
 		if (hcd->speed < HCD_USB3)
@@ -431,7 +431,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		break;
 	case GetHubStatus:
 		usbip_dbg_vhci_rh(" GetHubStatus\n");
-		*(__le32 *) buf = cpu_to_le32(0);
+		*(__le32 *)buf = cpu_to_le32(0);
 		break;
 	case GetPortStatus:
 		usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
@@ -490,8 +490,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 				}
 			}
 		}
-		((__le16 *) buf)[0] = cpu_to_le16(vhci_hcd->port_status[rhport]);
-		((__le16 *) buf)[1] =
+
+		((__le16 *)buf)[0] = cpu_to_le16(vhci_hcd->port_status[rhport]);
+		((__le16 *)buf)[1] =
 			cpu_to_le16(vhci_hcd->port_status[rhport] >> 16);
 
 		usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
@@ -625,7 +626,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			goto error;
 		}
 		/* We'll always return 0 since this is a dummy hub */
-		*(__le32 *) buf = cpu_to_le32(0);
+		*(__le32 *)buf = cpu_to_le32(0);
 		break;
 	case SetHubDepth:
 		usbip_dbg_vhci_rh(" SetHubDepth\n");
@@ -685,7 +686,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev)
 	priv->vdev = vdev;
 	priv->urb = urb;
 
-	urb->hcpriv = (void *) priv;
+	urb->hcpriv = (void *)priv;
 
 	list_add_tail(&priv->list, &vdev->priv_tx);
 
@@ -752,7 +753,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 		struct usb_device *old;
 		__u8 type = usb_pipetype(urb->pipe);
 		struct usb_ctrlrequest *ctrlreq =
-			(struct usb_ctrlrequest *) urb->setup_packet;
+			(struct usb_ctrlrequest *)urb->setup_packet;
 
 		if (type != PIPE_CONTROL || !ctrlreq) {
 			dev_err(dev, "invalid request to devnum 0\n");

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 07/18] usb: vhci-hcd: Add spaces around operators
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (5 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 06/18] usb: vhci-hcd: Drop spaces after casts Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 08/18] usb: vhci-hcd: Drop unnecessary parentheses Cristian Ciocaltea
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Fix a couple of checkpatch reports:

  CHECK: spaces preferred around that '-' (ctx:VxV)
  CHECK: spaces preferred around that '+' (ctx:VxV)

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 5b2d4a57dddf06fcbb8ce8e39306d1b5c4b23b38..00729ff76206905fafc263422c3ad4bcc28ba774 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -708,7 +708,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 		pr_err("invalid port number %d\n", portnum);
 		return -ENODEV;
 	}
-	vdev = &vhci_hcd->vdev[portnum-1];
+	vdev = &vhci_hcd->vdev[portnum - 1];
 
 	if (!urb->transfer_buffer && !urb->num_sgs &&
 	     urb->transfer_buffer_length) {
@@ -1157,7 +1157,7 @@ static int hcd_name_to_id(const char *name)
 	if (c == NULL)
 		return 0;
 
-	ret = kstrtol(c+1, 10, &val);
+	ret = kstrtol(c + 1, 10, &val);
 	if (ret < 0)
 		return ret;
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 08/18] usb: vhci-hcd: Drop unnecessary parentheses
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (6 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 07/18] usb: vhci-hcd: Add spaces around operators Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 09/18] usb: vhci-hcd: Fix open parenthesis alignment Cristian Ciocaltea
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Fix a checkpatch complaint:

  CHECK: Unnecessary parentheses around

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 00729ff76206905fafc263422c3ad4bcc28ba774..d74bfde1f71c50f2f4e7b69dfaf7687619e8c310 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -255,7 +255,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
 		}
 	}
 
-	if ((hcd->state == HC_STATE_SUSPENDED) && (changed == 1))
+	if (hcd->state == HC_STATE_SUSPENDED && changed == 1)
 		usb_hcd_resume_root_hub(hcd);
 
 done:

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 09/18] usb: vhci-hcd: Fix open parenthesis alignment
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (7 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 08/18] usb: vhci-hcd: Drop unnecessary parentheses Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 10/18] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Address a bunch of checkpatch complaints:

  CHECK: Alignment should match open parenthesis

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index d74bfde1f71c50f2f4e7b69dfaf7687619e8c310..15e1613f4d196e0172131ac722e62c5c579c6346 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -360,7 +360,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	if (usbip_dbg_flag_vhci_rh) {
 		if (!invalid_rhport)
 			memcpy(prev_port_status, vhci_hcd->port_status,
-				sizeof(prev_port_status));
+			       sizeof(prev_port_status));
 	}
 
 	switch (typeReq) {
@@ -408,8 +408,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	case GetHubDescriptor:
 		usbip_dbg_vhci_rh(" GetHubDescriptor\n");
 		if (hcd->speed >= HCD_USB3 &&
-				(wLength < USB_DT_SS_HUB_SIZE ||
-				 wValue != (USB_DT_SS_HUB << 8))) {
+		    (wLength < USB_DT_SS_HUB_SIZE || wValue != (USB_DT_SS_HUB << 8))) {
 			pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
 			goto error;
 		}
@@ -711,7 +710,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	vdev = &vhci_hcd->vdev[portnum - 1];
 
 	if (!urb->transfer_buffer && !urb->num_sgs &&
-	     urb->transfer_buffer_length) {
+	    urb->transfer_buffer_length) {
 		dev_dbg(dev, "Null URB transfer buffer\n");
 		return -EINVAL;
 	}
@@ -978,7 +977,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 }
 
 static void vhci_cleanup_unlink_list(struct vhci_device *vdev,
-		struct list_head *unlink_list)
+				     struct list_head *unlink_list)
 {
 	struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
 	struct usb_hcd *hcd = vhci_hcd_to_hcd(vhci_hcd);
@@ -1322,8 +1321,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
 
 /* Change a group of bulk endpoints to support multiple stream IDs */
 static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
-	struct usb_host_endpoint **eps, unsigned int num_eps,
-	unsigned int num_streams, gfp_t mem_flags)
+			      struct usb_host_endpoint **eps, unsigned int num_eps,
+			      unsigned int num_streams, gfp_t mem_flags)
 {
 	dev_dbg(&hcd->self.root_hub->dev, "vhci_alloc_streams not implemented\n");
 	return 0;
@@ -1331,8 +1330,8 @@ static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
 
 /* Reverts a group of bulk endpoints back to not using stream IDs. */
 static int vhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
-	struct usb_host_endpoint **eps, unsigned int num_eps,
-	gfp_t mem_flags)
+			     struct usb_host_endpoint **eps, unsigned int num_eps,
+			     gfp_t mem_flags)
 {
 	dev_dbg(&hcd->self.root_hub->dev, "vhci_free_streams not implemented\n");
 	return 0;

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 10/18] usb: vhci-hcd: Simplify NULL comparison
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (8 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 09/18] usb: vhci-hcd: Fix open parenthesis alignment Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 11/18] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Use the shorter variants as suggested by checkpatch.pl:

  CHECK: Comparison to NULL could be written "!c"
  CHECK: Comparison to NULL could be written "!vhcis"

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 15e1613f4d196e0172131ac722e62c5c579c6346..cda42ca492897e4ebf0055a317916874cab94ad6 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1153,7 +1153,7 @@ static int hcd_name_to_id(const char *name)
 	int ret;
 
 	c = strchr(name, '.');
-	if (c == NULL)
+	if (!c)
 		return 0;
 
 	ret = kstrtol(c + 1, 10, &val);
@@ -1543,7 +1543,7 @@ static int __init vhci_hcd_init(void)
 		vhci_num_controllers = 1;
 
 	vhcis = kcalloc(vhci_num_controllers, sizeof(struct vhci), GFP_KERNEL);
-	if (vhcis == NULL)
+	if (!vhcis)
 		return -ENOMEM;
 
 	ret = platform_driver_register(&vhci_driver);

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 11/18] usb: vhci-hcd: Simplify kzalloc usage
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (9 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 10/18] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 12/18] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Use the shorter variants as suggested by checkpatch.pl:

  CHECK: Prefer kzalloc(sizeof(*priv)...) over kzalloc(sizeof(struct vhci_priv)...)
  CHECK: Prefer kzalloc(sizeof(*unlink)...) over kzalloc(sizeof(struct vhci_unlink)...)

This also improves further maintainability.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index cda42ca492897e4ebf0055a317916874cab94ad6..34ce2d70cfca6ba7fd3003b878036c8eb332eb81 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -670,7 +670,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev)
 	struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
 	unsigned long flags;
 
-	priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC);
+	priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
 	if (!priv) {
 		usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
 		return;
@@ -948,7 +948,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 		spin_lock(&vdev->priv_lock);
 
 		/* setup CMD_UNLINK pdu */
-		unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
+		unlink = kzalloc(sizeof(*unlink), GFP_ATOMIC);
 		if (!unlink) {
 			spin_unlock(&vdev->priv_lock);
 			spin_unlock_irqrestore(&vhci->lock, flags);

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 12/18] usb: vhci-hcd: Use the paranthesized form of sizeof
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (10 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 11/18] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 13/18] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Fix the sizeof usage issue reported by checkpatch.pl:

  WARNING: sizeof *desc should be sizeof(*desc)

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 34ce2d70cfca6ba7fd3003b878036c8eb332eb81..96afb4242bf8bb7e9334d8dab08eb77cbcf24924 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -286,7 +286,7 @@ static struct {
 static inline void
 ss_hub_descriptor(struct usb_hub_descriptor *desc)
 {
-	memset(desc, 0, sizeof *desc);
+	memset(desc, 0, sizeof(*desc));
 	desc->bDescriptorType = USB_DT_SS_HUB;
 	desc->bDescLength = 12;
 	desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 13/18] usb: vhci-hcd: Fix block comments
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (11 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 12/18] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 14/18] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Address a couple of comment formatting issues indicated by
checkpatch.pl:

  WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 96afb4242bf8bb7e9334d8dab08eb77cbcf24924..0a552cf93be5d55409e2cffabce4c7a68e1360c4 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -905,8 +905,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
 	priv = urb->hcpriv;
 	if (!priv) {
-		/* URB was never linked! or will be soon given back by
-		 * vhci_rx. */
+		/* URB was never linked! or will be soon given back by vhci_rx */
 		spin_unlock_irqrestore(&vhci->lock, flags);
 		return -EIDRM;
 	}
@@ -962,8 +961,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
 		unlink->unlink_seqnum = priv->seqnum;
 
-		/* send cmd_unlink and try to cancel the pending URB in the
-		 * peer */
+		/* Send cmd_unlink and try to cancel the pending URB in the peer */
 		list_add_tail(&unlink->list, &vdev->unlink_tx);
 		wake_up(&vdev->waitq_tx);
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 14/18] usb: vhci-hcd: Remove ftrace-like logging
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (12 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 13/18] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 15/18] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Drop all superfluous log entries as reported by checkpatch:

  WARNING: Unnecessary ftrace-like logging - prefer using ftrace

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 0a552cf93be5d55409e2cffabce4c7a68e1360c4..f37f5f3680c2f1be8ed056d5c8579d75a0d0ad25 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1282,8 +1282,6 @@ static int vhci_bus_suspend(struct usb_hcd *hcd)
 	struct vhci *vhci = *((void **)dev_get_platdata(hcd->self.controller));
 	unsigned long flags;
 
-	dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
-
 	spin_lock_irqsave(&vhci->lock, flags);
 	hcd->state = HC_STATE_SUSPENDED;
 	spin_unlock_irqrestore(&vhci->lock, flags);
@@ -1297,8 +1295,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
 	int rc = 0;
 	unsigned long flags;
 
-	dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
-
 	spin_lock_irqsave(&vhci->lock, flags);
 
 	if (!HCD_HW_ACCESSIBLE(hcd))
@@ -1450,8 +1446,6 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
 	int ret = 0;
 	unsigned long flags;
 
-	dev_dbg(&pdev->dev, "%s\n", __func__);
-
 	hcd = platform_get_drvdata(pdev);
 	if (!hcd)
 		return 0;
@@ -1489,8 +1483,6 @@ static int vhci_hcd_resume(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd;
 
-	dev_dbg(&pdev->dev, "%s\n", __func__);
-
 	hcd = platform_get_drvdata(pdev);
 	if (!hcd)
 		return 0;

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 15/18] usb: vhci-hcd: Consistently use __func__
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (13 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 14/18] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 16/18] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Replace all explicit function names in string literals with __func__ and
silent several checkpatch complaints similar to the following one:

  WARNING: Prefer using '"%s...", __func__' to using 'vhci_start', this function's name, in a string

In case of the usbip_dbg_*() helpers, which are wrappers over
pr_debug(), the function names end up duplicated, hence replace the
superfluous strings with some useful info or simply drop the log entries
altogether if they become ftrace-like.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index f37f5f3680c2f1be8ed056d5c8579d75a0d0ad25..00377a7cbebd4e0de3f9a0fb756d93c9cedac148 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -160,8 +160,6 @@ void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
 	u32		status;
 	unsigned long	flags;
 
-	usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
-
 	spin_lock_irqsave(&vhci->lock, flags);
 
 	status = vhci_hcd->port_status[rhport];
@@ -183,6 +181,8 @@ void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
 
 	spin_unlock_irqrestore(&vhci->lock, flags);
 
+	usbip_dbg_vhci_rh("rhport: %d status: %u\n", rhport, status);
+
 	usb_hcd_poll_rh_status(vhci_hcd_to_hcd(vhci_hcd));
 }
 
@@ -194,8 +194,6 @@ static void rh_port_disconnect(struct vhci_device *vdev)
 	u32		status;
 	unsigned long	flags;
 
-	usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
-
 	spin_lock_irqsave(&vhci->lock, flags);
 
 	status = vhci_hcd->port_status[rhport];
@@ -206,6 +204,9 @@ static void rh_port_disconnect(struct vhci_device *vdev)
 	vhci_hcd->port_status[rhport] = status;
 
 	spin_unlock_irqrestore(&vhci->lock, flags);
+
+	usbip_dbg_vhci_rh("rhport: %d status: %u\n", rhport, status);
+
 	usb_hcd_poll_rh_status(vhci_hcd_to_hcd(vhci_hcd));
 }
 
@@ -1195,8 +1196,6 @@ static int vhci_start(struct usb_hcd *hcd)
 	int id, rhport;
 	int err;
 
-	usbip_dbg_vhci_hc("enter vhci_start\n");
-
 	if (usb_hcd_is_primary_hcd(hcd))
 		spin_lock_init(&vhci_hcd->vhci->lock);
 
@@ -1318,7 +1317,7 @@ static int vhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
 			      struct usb_host_endpoint **eps, unsigned int num_eps,
 			      unsigned int num_streams, gfp_t mem_flags)
 {
-	dev_dbg(&hcd->self.root_hub->dev, "vhci_alloc_streams not implemented\n");
+	dev_dbg(&hcd->self.root_hub->dev, "%s not implemented\n", __func__);
 	return 0;
 }
 
@@ -1327,7 +1326,7 @@ static int vhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
 			     struct usb_host_endpoint **eps, unsigned int num_eps,
 			     gfp_t mem_flags)
 {
-	dev_dbg(&hcd->self.root_hub->dev, "vhci_free_streams not implemented\n");
+	dev_dbg(&hcd->self.root_hub->dev, "%s not implemented\n", __func__);
 	return 0;
 }
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 16/18] usb: vhci-hcd: Do not split quoted strings
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (14 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 15/18] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 17/18] usb: vhci-hcd: Switch to dev_err_probe() in probe path Cristian Ciocaltea
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Join the split strings to make checkpatch happy and regain ability to
grep for those log messages in the source code:

  WARNING: quoted string split across lines

While at it, replace the affected pr_err() calls with dev_err().

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 00377a7cbebd4e0de3f9a0fb756d93c9cedac148..73c5979fee3ce345ea2c212fea03adabde55243a 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -377,8 +377,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
 			if (hcd->speed >= HCD_USB3) {
-				pr_err(" ClearPortFeature: USB_PORT_FEAT_SUSPEND req not "
-				       "supported for USB 3.0 roothub\n");
+				dev_err(hcd_dev(hcd),
+					"ClearPortFeature: USB_PORT_FEAT_SUSPEND req not supported for USB 3.0 roothub\n");
 				goto error;
 			}
 
@@ -507,8 +507,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		case USB_PORT_FEAT_LINK_STATE:
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_LINK_STATE\n");
 			if (hcd->speed < HCD_USB3) {
-				pr_err("USB_PORT_FEAT_LINK_STATE req not "
-				       "supported for USB 2.0 roothub\n");
+				dev_err(hcd_dev(hcd),
+					"USB_PORT_FEAT_LINK_STATE req not supported for USB 2.0 roothub\n");
 				goto error;
 			}
 
@@ -524,8 +524,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_U2_TIMEOUT\n");
 			/* TODO: add suspend/resume support! */
 			if (hcd->speed < HCD_USB3) {
-				pr_err("USB_PORT_FEAT_U1/2_TIMEOUT req not "
-				       "supported for USB 2.0 roothub\n");
+				dev_err(hcd_dev(hcd),
+					"USB_PORT_FEAT_U1/2_TIMEOUT req not supported for USB 2.0 roothub\n");
 				goto error;
 			}
 			break;
@@ -533,8 +533,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
 			/* Applicable only for USB2.0 hub */
 			if (hcd->speed >= HCD_USB3) {
-				pr_err("USB_PORT_FEAT_SUSPEND req not "
-				       "supported for USB 3.0 roothub\n");
+				dev_err(hcd_dev(hcd),
+					"USB_PORT_FEAT_SUSPEND req not supported for USB 3.0 roothub\n");
 				goto error;
 			}
 
@@ -566,8 +566,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
 			/* Applicable only for USB3.0 hub */
 			if (hcd->speed < HCD_USB3) {
-				pr_err("USB_PORT_FEAT_BH_PORT_RESET req not "
-				       "supported for USB 2.0 roothub\n");
+				dev_err(hcd_dev(hcd),
+					"USB_PORT_FEAT_BH_PORT_RESET req not supported for USB 2.0 roothub\n");
 				goto error;
 			}
 			fallthrough;
@@ -621,8 +621,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	case GetPortErrorCount:
 		usbip_dbg_vhci_rh(" GetPortErrorCount\n");
 		if (hcd->speed < HCD_USB3) {
-			pr_err("GetPortErrorCount req not "
-			       "supported for USB 2.0 roothub\n");
+			dev_err(hcd_dev(hcd),
+				"GetPortErrorCount req not supported for USB 2.0 roothub\n");
 			goto error;
 		}
 		/* We'll always return 0 since this is a dummy hub */
@@ -631,8 +631,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	case SetHubDepth:
 		usbip_dbg_vhci_rh(" SetHubDepth\n");
 		if (hcd->speed < HCD_USB3) {
-			pr_err("SetHubDepth req not supported for "
-			       "USB 2.0 roothub\n");
+			dev_err(hcd_dev(hcd),
+				"SetHubDepth req not supported for USB 2.0 roothub\n");
 			goto error;
 		}
 		break;

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 17/18] usb: vhci-hcd: Switch to dev_err_probe() in probe path
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (15 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 16/18] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-25 22:08 ` [PATCH v2 18/18] usb: vhci-hcd: Replace pr_*() with dev_*() logging Cristian Ciocaltea
  2025-07-26  6:43 ` [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Greg Kroah-Hartman
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Replace pr_err() calls in vhci_hcd_probe() with dev_err_probe(), to
simplify error handling a bit and improve consistency.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 73c5979fee3ce345ea2c212fea03adabde55243a..5d2983a6c2b05d2a769424e1595b4212a806c2a2 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1369,10 +1369,8 @@ static int vhci_hcd_probe(struct platform_device *pdev)
 	 * Our private data is also allocated automatically.
 	 */
 	hcd_hs = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev));
-	if (!hcd_hs) {
-		pr_err("create primary hcd failed\n");
-		return -ENOMEM;
-	}
+	if (!hcd_hs)
+		return dev_err_probe(&pdev->dev, -ENOMEM, "create primary hcd failed\n");
 
 	hcd_hs->has_tt = 1;
 
@@ -1381,22 +1379,21 @@ static int vhci_hcd_probe(struct platform_device *pdev)
 	 * Call the driver's reset() and start() routines.
 	 */
 	ret = usb_add_hcd(hcd_hs, 0, 0);
-	if (ret != 0) {
-		pr_err("usb_add_hcd hs failed %d\n", ret);
+	if (ret) {
+		dev_err_probe(&pdev->dev, ret, "usb_add_hcd hs failed\n");
 		goto put_usb2_hcd;
 	}
 
 	hcd_ss = usb_create_shared_hcd(&vhci_hc_driver, &pdev->dev,
 				       dev_name(&pdev->dev), hcd_hs);
 	if (!hcd_ss) {
-		ret = -ENOMEM;
-		pr_err("create shared hcd failed\n");
+		ret = dev_err_probe(&pdev->dev, -ENOMEM, "create shared hcd failed\n");
 		goto remove_usb2_hcd;
 	}
 
 	ret = usb_add_hcd(hcd_ss, 0, 0);
 	if (ret) {
-		pr_err("usb_add_hcd ss failed %d\n", ret);
+		dev_err_probe(&pdev->dev, ret, "usb_add_hcd ss failed\n");
 		goto put_usb3_hcd;
 	}
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 18/18] usb: vhci-hcd: Replace pr_*() with dev_*() logging
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (16 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 17/18] usb: vhci-hcd: Switch to dev_err_probe() in probe path Cristian Ciocaltea
@ 2025-07-25 22:08 ` Cristian Ciocaltea
  2025-07-26  6:43 ` [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Greg Kroah-Hartman
  18 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-25 22:08 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Hongren Zheng, Greg Kroah-Hartman,
	Brian G. Merrell
  Cc: kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Where possible, use driver model logging helpers dev_*() instead of
pr_*() to ensure the messages are always associated with the
corresponding device/driver.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/usb/usbip/vhci_hcd.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 5d2983a6c2b05d2a769424e1595b4212a806c2a2..96c93e47fba131fc32c969adfaa8f425c55ea7ae 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -347,7 +347,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	if (wIndex < 1 || wIndex > VHCI_HC_PORTS) {
 		invalid_rhport = true;
 		if (wIndex > VHCI_HC_PORTS)
-			pr_err("invalid port number %d\n", wIndex);
+			dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 	} else {
 		rhport = wIndex - 1;
 	}
@@ -370,7 +370,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		break;
 	case ClearPortFeature:
 		if (invalid_rhport) {
-			pr_err("invalid port number %d\n", wIndex);
+			dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 			goto error;
 		}
 
@@ -410,7 +410,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		usbip_dbg_vhci_rh(" GetHubDescriptor\n");
 		if (hcd->speed >= HCD_USB3 &&
 		    (wLength < USB_DT_SS_HUB_SIZE || wValue != (USB_DT_SS_HUB << 8))) {
-			pr_err("Wrong hub descriptor type for USB 3.0 roothub.\n");
+			dev_err(hcd_dev(hcd),
+				"Wrong hub descriptor type for USB 3.0 roothub.\n");
 			goto error;
 		}
 
@@ -436,7 +437,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	case GetPortStatus:
 		usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
 		if (invalid_rhport) {
-			pr_err("invalid port number %d\n", wIndex);
+			dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 			retval = -EPIPE;
 			goto error;
 		}
@@ -485,7 +486,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 						USB_PORT_STAT_LOW_SPEED;
 					break;
 				default:
-					pr_err("vhci_device speed not set\n");
+					dev_err(hcd_dev(hcd), "vhci_device speed not set\n");
 					break;
 				}
 			}
@@ -539,7 +540,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			}
 
 			if (invalid_rhport) {
-				pr_err("invalid port number %d\n", wIndex);
+				dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 				goto error;
 			}
 
@@ -548,7 +549,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		case USB_PORT_FEAT_POWER:
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_POWER\n");
 			if (invalid_rhport) {
-				pr_err("invalid port number %d\n", wIndex);
+				dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 				goto error;
 			}
 
@@ -560,7 +561,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		case USB_PORT_FEAT_BH_PORT_RESET:
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_BH_PORT_RESET\n");
 			if (invalid_rhport) {
-				pr_err("invalid port number %d\n", wIndex);
+				dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 				goto error;
 			}
 
@@ -574,7 +575,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		case USB_PORT_FEAT_RESET:
 			usbip_dbg_vhci_rh("SetPortFeature: USB_PORT_FEAT_RESET\n");
 			if (invalid_rhport) {
-				pr_err("invalid port number %d\n", wIndex);
+				dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 				goto error;
 			}
 
@@ -598,7 +599,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 			usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
 					  wValue);
 			if (invalid_rhport) {
-				pr_err("invalid port number %d\n", wIndex);
+				dev_err(hcd_dev(hcd), "invalid port number %d\n", wIndex);
 				goto error;
 			}
 
@@ -637,7 +638,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		}
 		break;
 	default:
-		pr_err("default hub control req: %04x v%04x i%04x l%d\n",
+		dev_err(hcd_dev(hcd),
+			"default hub control req: %04x v%04x i%04x l%d\n",
 			typeReq, wValue, wIndex, wLength);
 error:
 		/* "protocol stall" on error */
@@ -645,7 +647,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	}
 
 	if (usbip_dbg_flag_vhci_rh) {
-		pr_debug("port %d\n", rhport);
+		dev_dbg(hcd_dev(hcd), "%s port %d\n", __func__, rhport);
 		/* Only dump valid port status */
 		if (!invalid_rhport) {
 			dump_port_status_diff(prev_port_status[rhport],
@@ -705,7 +707,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	unsigned long flags;
 
 	if (portnum > VHCI_HC_PORTS) {
-		pr_err("invalid port number %d\n", portnum);
+		dev_err(hcd_dev(hcd), "invalid port number %d\n", portnum);
 		return -ENODEV;
 	}
 	vdev = &vhci_hcd->vdev[portnum - 1];
@@ -958,7 +960,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
 		unlink->seqnum = atomic_inc_return(&vhci_hcd->seqnum);
 		if (unlink->seqnum == 0xffff)
-			pr_info("seqnum max\n");
+			dev_info(hcd_dev(hcd), "seqnum max\n");
 
 		unlink->unlink_seqnum = priv->seqnum;
 
@@ -1035,10 +1037,11 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
 static void vhci_shutdown_connection(struct usbip_device *ud)
 {
 	struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
+	struct usb_hcd *hcd = vhci_hcd_to_hcd(vdev_to_vhci_hcd(vdev));
 
 	/* need this? see stub_dev.c */
 	if (ud->tcp_socket) {
-		pr_debug("shutdown tcp_socket %d\n", ud->sockfd);
+		dev_dbg(hcd_dev(hcd), "shutdown tcp_socket %d\n", ud->sockfd);
 		kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
 	}
 
@@ -1051,7 +1054,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
 		kthread_stop_put(vdev->ud.tcp_tx);
 		vdev->ud.tcp_tx = NULL;
 	}
-	pr_info("stop threads\n");
+	dev_info(hcd_dev(hcd), "stop threads\n");
 
 	/* active connection is closed */
 	if (vdev->ud.tcp_socket) {
@@ -1059,7 +1062,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
 		vdev->ud.tcp_socket = NULL;
 		vdev->ud.sockfd = -1;
 	}
-	pr_info("release socket\n");
+	dev_info(hcd_dev(hcd), "release socket\n");
 
 	vhci_device_unlink_cleanup(vdev);
 
@@ -1085,7 +1088,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
 	 */
 	rh_port_disconnect(vdev);
 
-	pr_info("disconnect device\n");
+	dev_info(hcd_dev(hcd), "disconnect device\n");
 }
 
 static void vhci_device_reset(struct usbip_device *ud)
@@ -1219,7 +1222,7 @@ static int vhci_start(struct usb_hcd *hcd)
 
 	id = hcd_name_to_id(hcd_name(hcd));
 	if (id < 0) {
-		pr_err("invalid vhci name %s\n", hcd_name(hcd));
+		dev_err(hcd_dev(hcd), "invalid vhci name %s\n", hcd_name(hcd));
 		return -EINVAL;
 	}
 
@@ -1238,7 +1241,7 @@ static int vhci_start(struct usb_hcd *hcd)
 			return err;
 		}
 
-		pr_info("created sysfs %s\n", hcd_name(hcd));
+		dev_info(hcd_dev(hcd), "created sysfs %s\n", hcd_name(hcd));
 	}
 
 	return 0;

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup
  2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
                   ` (17 preceding siblings ...)
  2025-07-25 22:08 ` [PATCH v2 18/18] usb: vhci-hcd: Replace pr_*() with dev_*() logging Cristian Ciocaltea
@ 2025-07-26  6:43 ` Greg Kroah-Hartman
  2025-07-28  9:41   ` Cristian Ciocaltea
  18 siblings, 1 reply; 26+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-26  6:43 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On Sat, Jul 26, 2025 at 01:08:02AM +0300, Cristian Ciocaltea wrote:
> The USB/IP Virtual Host Controller (VHCI) platform driver is expected to
> prevent entering system suspend when at least one remote device is
> attached to the virtual USB root hub.
> 
> However, in some cases, the detection logic for active USB/IP
> connections doesn't seem to work reliably, e.g. when all devices
> attached to the virtual hub have been already suspended.  This will
> normally lead to a broken suspend state, with unrecoverable resume.
> 
> The first patch of the series provides a workaround to ensure the
> virtually attached devices do not enter suspend.  Note this is currently
> limited to the client side (vhci_hcd) only, since the server side
> (usbip_host) doesn't implement system suspend prevention.
> 
> Additionally, during the investigation I noticed and fixed a bunch of
> coding style issues, hence the subsequent patches contain all the
> changes needed to make checkpatch happy for the entire driver.

You are doing two major things here, fixing suspend, and cleaning up
checkpatch issues.  Please make that two different patch sets as those
are not logical things to put together at all.  Work on the suspend
issue first, and after that is all done and working, then consider
checkpatch cleanups, those are not that important overall :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices
  2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
@ 2025-07-26  6:43   ` Greg Kroah-Hartman
  2025-07-26  7:06   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 26+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-26  6:43 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On Sat, Jul 26, 2025 at 01:08:03AM +0300, Cristian Ciocaltea wrote:
> The VHCI platform driver aims to forbid entering system suspend when at
> least one of the virtual USB ports are bound to an active USB/IP
> connection.
> 
> However, in some cases, the detection logic doesn't work reliably, i.e.
> when all devices attached to the virtual root hub have been already
> suspended, leading to a broken suspend state, with unrecoverable resume.
> 
> Ensure the virtually attached devices do not enter suspend by setting
> the syscore PM flag.  Note this is currently limited to the client side
> only, since the server side doesn't implement system suspend prevention.
> 
> Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..b4b0ed5d64966214636b157968478600e2e4178a 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -765,6 +765,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>  				 ctrlreq->wValue, vdev->rhport);
>  
>  			vdev->udev = usb_get_dev(urb->dev);
> +			/*
> +			 * FIXME: A similar operation has been done via
> +			 * USB_REQ_GET_DESCRIPTOR handler below, which is
> +			 * supposed to always precede USB_REQ_SET_ADDRESS.
> +			 *
> +			 * It's not entirely clear if operating on a different
> +			 * usb_device instance here is a real possibility,
> +			 * otherwise this call and vdev->udev assignment above
> +			 * should be dropped.
> +			 */
> +			dev_pm_syscore_device(&vdev->udev->dev, true);
>  			usb_put_dev(old);
>  
>  			spin_lock(&vdev->ud.lock);
> @@ -785,6 +796,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>  					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
>  
>  			vdev->udev = usb_get_dev(urb->dev);
> +			/*
> +			 * Set syscore PM flag for the virtually attached
> +			 * devices to ensure they will not enter suspend on
> +			 * the client side.
> +			 *
> +			 * Note this doesn't have any impact on the physical
> +			 * devices attached to the host system on the server
> +			 * side, hence there is no need to undo the operation
> +			 * on disconnect.
> +			 */
> +			dev_pm_syscore_device(&vdev->udev->dev, true);
>  			usb_put_dev(old);
>  			goto out;
>  
> 
> -- 
> 2.50.0
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices
  2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
  2025-07-26  6:43   ` Greg Kroah-Hartman
@ 2025-07-26  7:06   ` Greg Kroah-Hartman
  2025-07-28 10:03     ` Cristian Ciocaltea
  1 sibling, 1 reply; 26+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-26  7:06 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On Sat, Jul 26, 2025 at 01:08:03AM +0300, Cristian Ciocaltea wrote:
> The VHCI platform driver aims to forbid entering system suspend when at
> least one of the virtual USB ports are bound to an active USB/IP
> connection.
> 
> However, in some cases, the detection logic doesn't work reliably, i.e.
> when all devices attached to the virtual root hub have been already
> suspended, leading to a broken suspend state, with unrecoverable resume.
> 
> Ensure the virtually attached devices do not enter suspend by setting
> the syscore PM flag.  Note this is currently limited to the client side
> only, since the server side doesn't implement system suspend prevention.
> 
> Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..b4b0ed5d64966214636b157968478600e2e4178a 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -765,6 +765,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>  				 ctrlreq->wValue, vdev->rhport);
>  
>  			vdev->udev = usb_get_dev(urb->dev);
> +			/*
> +			 * FIXME: A similar operation has been done via
> +			 * USB_REQ_GET_DESCRIPTOR handler below, which is
> +			 * supposed to always precede USB_REQ_SET_ADDRESS.

When is this FIXME going to be addressed and by whom?

> +			 *
> +			 * It's not entirely clear if operating on a different
> +			 * usb_device instance here is a real possibility,
> +			 * otherwise this call and vdev->udev assignment above
> +			 * should be dropped.

What is going to need to happen to figure this out?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup
  2025-07-26  6:43 ` [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Greg Kroah-Hartman
@ 2025-07-28  9:41   ` Cristian Ciocaltea
  2025-08-27  9:14     ` Cristian Ciocaltea
  0 siblings, 1 reply; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-28  9:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

Hi Greg,

On 7/26/25 9:43 AM, Greg Kroah-Hartman wrote:
> On Sat, Jul 26, 2025 at 01:08:02AM +0300, Cristian Ciocaltea wrote:
>> The USB/IP Virtual Host Controller (VHCI) platform driver is expected to
>> prevent entering system suspend when at least one remote device is
>> attached to the virtual USB root hub.
>>
>> However, in some cases, the detection logic for active USB/IP
>> connections doesn't seem to work reliably, e.g. when all devices
>> attached to the virtual hub have been already suspended.  This will
>> normally lead to a broken suspend state, with unrecoverable resume.
>>
>> The first patch of the series provides a workaround to ensure the
>> virtually attached devices do not enter suspend.  Note this is currently
>> limited to the client side (vhci_hcd) only, since the server side
>> (usbip_host) doesn't implement system suspend prevention.
>>
>> Additionally, during the investigation I noticed and fixed a bunch of
>> coding style issues, hence the subsequent patches contain all the
>> changes needed to make checkpatch happy for the entire driver.
> 
> You are doing two major things here, fixing suspend, and cleaning up
> checkpatch issues.  Please make that two different patch sets as those
> are not logical things to put together at all.  Work on the suspend
> issue first, and after that is all done and working, then consider
> checkpatch cleanups, those are not that important overall :)

Yeah, the cleanup part ended up larger than initially anticipated, but I
don't really expect further changes on the fixup side.  I can handle the
split if another revision would be still required, or would you like me to
do this regardless?  I've just made a quick test moving the first patch to
the end of the series and it didn't cause any conflicts, hence there won't 
be any dependencies between the two patch sets.

Thanks,
Cristian

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices
  2025-07-26  7:06   ` Greg Kroah-Hartman
@ 2025-07-28 10:03     ` Cristian Ciocaltea
  0 siblings, 0 replies; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-07-28 10:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On 7/26/25 10:06 AM, Greg Kroah-Hartman wrote:
> On Sat, Jul 26, 2025 at 01:08:03AM +0300, Cristian Ciocaltea wrote:
>> The VHCI platform driver aims to forbid entering system suspend when at
>> least one of the virtual USB ports are bound to an active USB/IP
>> connection.
>>
>> However, in some cases, the detection logic doesn't work reliably, i.e.
>> when all devices attached to the virtual root hub have been already
>> suspended, leading to a broken suspend state, with unrecoverable resume.
>>
>> Ensure the virtually attached devices do not enter suspend by setting
>> the syscore PM flag.  Note this is currently limited to the client side
>> only, since the server side doesn't implement system suspend prevention.
>>
>> Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>> ---
>>  drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
>> index e70fba9f55d6a0edf3c5fde56a614dd3799406a1..b4b0ed5d64966214636b157968478600e2e4178a 100644
>> --- a/drivers/usb/usbip/vhci_hcd.c
>> +++ b/drivers/usb/usbip/vhci_hcd.c
>> @@ -765,6 +765,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
>>  				 ctrlreq->wValue, vdev->rhport);
>>  
>>  			vdev->udev = usb_get_dev(urb->dev);
>> +			/*
>> +			 * FIXME: A similar operation has been done via
>> +			 * USB_REQ_GET_DESCRIPTOR handler below, which is
>> +			 * supposed to always precede USB_REQ_SET_ADDRESS.
> 
> When is this FIXME going to be addressed and by whom?

Actually I should have probably used a NOTE or something similar as this is
only about the possibility to drop some redundant code, rather then fixing
something broken.

>> +			 *
>> +			 * It's not entirely clear if operating on a different
>> +			 * usb_device instance here is a real possibility,
>> +			 * otherwise this call and vdev->udev assignment above
>> +			 * should be dropped.
> 
> What is going to need to happen to figure this out?

I could only do some limited testing on my side, which is definitely not
enough to confirm it's safe to move on with the code removal, hence I'd very
much like to get some other opinions on the matter.  Regardless, I think
it's useful to keep this documented.

Thanks,
Cristian


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup
  2025-07-28  9:41   ` Cristian Ciocaltea
@ 2025-08-27  9:14     ` Cristian Ciocaltea
  2025-08-29 16:33       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 26+ messages in thread
From: Cristian Ciocaltea @ 2025-08-27  9:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On 7/28/25 12:41 PM, Cristian Ciocaltea wrote:
> Hi Greg,
> 
> On 7/26/25 9:43 AM, Greg Kroah-Hartman wrote:
>> On Sat, Jul 26, 2025 at 01:08:02AM +0300, Cristian Ciocaltea wrote:
>>> The USB/IP Virtual Host Controller (VHCI) platform driver is expected to
>>> prevent entering system suspend when at least one remote device is
>>> attached to the virtual USB root hub.
>>>
>>> However, in some cases, the detection logic for active USB/IP
>>> connections doesn't seem to work reliably, e.g. when all devices
>>> attached to the virtual hub have been already suspended.  This will
>>> normally lead to a broken suspend state, with unrecoverable resume.
>>>
>>> The first patch of the series provides a workaround to ensure the
>>> virtually attached devices do not enter suspend.  Note this is currently
>>> limited to the client side (vhci_hcd) only, since the server side
>>> (usbip_host) doesn't implement system suspend prevention.
>>>
>>> Additionally, during the investigation I noticed and fixed a bunch of
>>> coding style issues, hence the subsequent patches contain all the
>>> changes needed to make checkpatch happy for the entire driver.
>>
>> You are doing two major things here, fixing suspend, and cleaning up
>> checkpatch issues.  Please make that two different patch sets as those
>> are not logical things to put together at all.  Work on the suspend
>> issue first, and after that is all done and working, then consider
>> checkpatch cleanups, those are not that important overall :)
> 
> Yeah, the cleanup part ended up larger than initially anticipated, but I
> don't really expect further changes on the fixup side.  I can handle the
> split if another revision would be still required, or would you like me to
> do this regardless?  I've just made a quick test moving the first patch to
> the end of the series and it didn't cause any conflicts, hence there won't 
> be any dependencies between the two patch sets.

This continues to apply cleanly on recent linux-next, hence I'm not sure if
there's still a need to resend as two separate patch sets.

Please let me know how should we move further.

Thanks,
Cristian


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup
  2025-08-27  9:14     ` Cristian Ciocaltea
@ 2025-08-29 16:33       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 26+ messages in thread
From: Greg Kroah-Hartman @ 2025-08-29 16:33 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: Valentina Manea, Shuah Khan, Hongren Zheng, Brian G. Merrell,
	kernel, Greg Kroah-Hartman, linux-usb, linux-kernel

On Wed, Aug 27, 2025 at 12:14:15PM +0300, Cristian Ciocaltea wrote:
> On 7/28/25 12:41 PM, Cristian Ciocaltea wrote:
> > Hi Greg,
> > 
> > On 7/26/25 9:43 AM, Greg Kroah-Hartman wrote:
> >> On Sat, Jul 26, 2025 at 01:08:02AM +0300, Cristian Ciocaltea wrote:
> >>> The USB/IP Virtual Host Controller (VHCI) platform driver is expected to
> >>> prevent entering system suspend when at least one remote device is
> >>> attached to the virtual USB root hub.
> >>>
> >>> However, in some cases, the detection logic for active USB/IP
> >>> connections doesn't seem to work reliably, e.g. when all devices
> >>> attached to the virtual hub have been already suspended.  This will
> >>> normally lead to a broken suspend state, with unrecoverable resume.
> >>>
> >>> The first patch of the series provides a workaround to ensure the
> >>> virtually attached devices do not enter suspend.  Note this is currently
> >>> limited to the client side (vhci_hcd) only, since the server side
> >>> (usbip_host) doesn't implement system suspend prevention.
> >>>
> >>> Additionally, during the investigation I noticed and fixed a bunch of
> >>> coding style issues, hence the subsequent patches contain all the
> >>> changes needed to make checkpatch happy for the entire driver.
> >>
> >> You are doing two major things here, fixing suspend, and cleaning up
> >> checkpatch issues.  Please make that two different patch sets as those
> >> are not logical things to put together at all.  Work on the suspend
> >> issue first, and after that is all done and working, then consider
> >> checkpatch cleanups, those are not that important overall :)
> > 
> > Yeah, the cleanup part ended up larger than initially anticipated, but I
> > don't really expect further changes on the fixup side.  I can handle the
> > split if another revision would be still required, or would you like me to
> > do this regardless?  I've just made a quick test moving the first patch to
> > the end of the series and it didn't cause any conflicts, hence there won't 
> > be any dependencies between the two patch sets.
> 
> This continues to apply cleanly on recent linux-next, hence I'm not sure if
> there's still a need to resend as two separate patch sets.

As I no longer have any of these in my review queue, yes, you are going
to have to resend whatever you want us to accept :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2025-08-29 16:33 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 22:08 [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 01/18] usb: vhci-hcd: Prevent suspending virtually attached devices Cristian Ciocaltea
2025-07-26  6:43   ` Greg Kroah-Hartman
2025-07-26  7:06   ` Greg Kroah-Hartman
2025-07-28 10:03     ` Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 02/18] usb: vhci-hcd: Ensure lines do not end with '(' Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 03/18] usb: vhci-hcd: Consistently use the braces Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 04/18] usb: vhci-hcd: Avoid unnecessary use of braces Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 05/18] usb: vhci-hcd: Consistently use blank lines Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 06/18] usb: vhci-hcd: Drop spaces after casts Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 07/18] usb: vhci-hcd: Add spaces around operators Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 08/18] usb: vhci-hcd: Drop unnecessary parentheses Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 09/18] usb: vhci-hcd: Fix open parenthesis alignment Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 10/18] usb: vhci-hcd: Simplify NULL comparison Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 11/18] usb: vhci-hcd: Simplify kzalloc usage Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 12/18] usb: vhci-hcd: Use the paranthesized form of sizeof Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 13/18] usb: vhci-hcd: Fix block comments Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 14/18] usb: vhci-hcd: Remove ftrace-like logging Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 15/18] usb: vhci-hcd: Consistently use __func__ Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 16/18] usb: vhci-hcd: Do not split quoted strings Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 17/18] usb: vhci-hcd: Switch to dev_err_probe() in probe path Cristian Ciocaltea
2025-07-25 22:08 ` [PATCH v2 18/18] usb: vhci-hcd: Replace pr_*() with dev_*() logging Cristian Ciocaltea
2025-07-26  6:43 ` [PATCH v2 00/18] USB/IP VHCI suspend fix and driver cleanup Greg Kroah-Hartman
2025-07-28  9:41   ` Cristian Ciocaltea
2025-08-27  9:14     ` Cristian Ciocaltea
2025-08-29 16:33       ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).