patch "usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore" added to usb-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 4c4e162d9cf38528c4f13df09d5755cbc06f6c77 Mon Sep 17 00:00:00 2001
From: Pawel Laszczak <[email protected]>
Date: Tue, 14 Dec 2021 05:55:27 +0100
Subject: usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
Patch puts content of cdnsp_gadget_pullup function inside spin_lock_irqsave and spin_lock_restore section.
This construction is required here to keep the data consistency, otherwise some data can be changed e.g. from interrupt context.
--
Changelog:
v2:
- added disable_irq/enable_irq as sugester by Peter Chen
drivers/usb/cdns3/cdnsp-gadget.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- drivers/usb/cdns3/cdnsp-gadget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/cdns3/cdnsp-gadget.c +12 -0
@@ -1541,15 +1541,27 @@ static int cdnsp_gadget_pullup(struct usb_gadget *gadget, int is_on) {struct cdnsp_device *pdev =gadget_to_cdnsp (gadget);struct cdns *cdns =dev_get_drvdata (pdev->dev); +unsigned long flags;trace_cdnsp_pullup (is_on); +/* +* Disable events handling while controller is being +* enabled/disabled. +*/ +disable_irq (cdns->dev_irq); +spin_lock_irqsave (&pdev->lock, flags); +if (!is_on) {cdnsp_reset_device (pdev);cdns_clear_vbus (cdns); }else {cdns_set_vbus (cdns); } + +spin_unlock_irqrestore (&pdev->lock, flags); +enable_irq (cdns->dev_irq); +return 0 ; }
Signature · 1 line
2.34.1