Skip to contentSkip to conversation

USB: usbip: clean up mixed use of _irq() and _irqsave()

PATCH In review Dan Carpenter 2 participants 2 messages May 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: usbip: clean up mixed use of _irq() and _irqsave()

It generally doesn't make sense to use _irq() and _irqsave() in the same function because either some of the callers have disabled IRQs or they haven't. In this case, the v_recv_cmd_submit() appears to always be called with IRQs enabled so the code works fine. That means I could convert it to either _irq() or _irqsave() but I chose to use _irqsave() because it's more conservative and easier to review.

---
 drivers/usb/usbip/vudc_rx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/usbip/vudc_rx.c +3 -3
index 1e8a23d92cb4..d4a2f30a7580 100644
@@ -104,18 +104,18 @@ static int v_recv_cmd_submit(struct vudc *udc,
 	if (pdu->base.direction == USBIP_DIR_IN)
 		address |= USB_DIR_IN;
 
-	spin_lock_irq(&udc->lock);
+	spin_lock_irqsave(&udc->lock, flags);
 	urb_p->ep = vudc_find_endpoint(udc, address);
 	if (!urb_p->ep) {
 		/* we don't know the type, there may be isoc data! */
 		dev_err(&udc->pdev->dev, "request to nonexistent endpoint");
-		spin_unlock_irq(&udc->lock);
+		spin_unlock_irqrestore(&udc->lock, flags);
 		usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP);
 		ret = -EPIPE;
 		goto free_urbp;
 	}
 	urb_p->type = urb_p->ep->type;
-	spin_unlock_irq(&udc->lock);
+	spin_unlock_irqrestore(&udc->lock, flags);
 
 	urb_p->new = 1;
 	urb_p->seqnum = pdu->base.seqnum;
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Dan Carpenter

It generally doesn't make sense to use _irq() and _irqsave() in the same function because either some of the callers have disabled IRQs or they haven't. In this case, the v_recv_cmd_submit() appears to always be called with IRQs enabled so the code works fine. That means I could convert it to either _irq() or _irqsave() but I chose to use _irqsave() because it's more conservative and easier to review.

---
  drivers/usb/usbip/vudc_rx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/usbip/vudc_rx.c +2 -2
index 1e8a23d92cb4..d4a2f30a7580 100644
@@ -104,18 +104,18 @@ static int v_recv_cmd_submit(struct vudc *udc,
  	if (pdu->base.direction == USBIP_DIR_IN)
  		address |= USB_DIR_IN;
 
-	spin_lock_irq(&udc->lock);
+	spin_lock_irqsave(&udc->lock, flags);
  	urb_p->ep = vudc_find_endpoint(udc, address);
  	if (!urb_p->ep) {
  		/* we don't know the type, there may be isoc data! */
  		dev_err(&udc->pdev->dev, "request to nonexistent endpoint");
-		spin_unlock_irq(&udc->lock);
+		spin_unlock_irqrestore(&udc->lock, flags);

drivers/usb/usbip/vudc_rx.c static int v_recv_cmd_submit(struct vudc *udc, · line 121

Quoted 10 lines
drivers/usb/usbip/vudc_rx.c +1 -1
  		usbip_event_add(&udc->ud, VUDC_EVENT_ERROR_TCP);
  		ret = -EPIPE;
  		goto free_urbp;
  	}
  	urb_p->type = urb_p->ep->type;
-	spin_unlock_irq(&udc->lock);
+	spin_unlock_irqrestore(&udc->lock, flags);
 
  	urb_p->new = 1;
  	urb_p->seqnum = pdu->base.seqnum;

Thank you for the patch.

Greg, please pick this up.

thanks,
-- Shuah