Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: gadget: tegra-xudc: fix PM use count underflow

Upon resume from system suspend, the PM runtime core issues the
following warning:

tegra-xudc 3550000.usb: Runtime PM usage count underflow!

This is because tegra_xudc_resume() unconditionally calls
schedule_work(&xudc->usb_role_sw_work) whether or not anything has
changed, which causes tegra_xudc_device_mode_off() to be called
even when we're already in that mode.

Keep track of the current state of "device_mode", and only schedule
this work if it has changed from the hardware state on resume.

Signed-off-by: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1uhtkH-007KDZ-JT@rmk-PC.armlinux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Russell King (Oracle) and committed by
Greg Kroah-Hartman
202ad1aa e664036c

+7 -2
+7 -2
drivers/usb/gadget/udc/tegra-xudc.c
··· 502 502 struct clk_bulk_data *clks; 503 503 504 504 bool device_mode; 505 + bool current_device_mode; 505 506 struct work_struct usb_role_sw_work; 506 507 507 508 struct phy **usb3_phy; ··· 716 715 717 716 phy_set_mode_ext(xudc->curr_utmi_phy, PHY_MODE_USB_OTG, 718 717 USB_ROLE_DEVICE); 718 + 719 + xudc->current_device_mode = true; 719 720 } 720 721 721 722 static void tegra_xudc_device_mode_off(struct tegra_xudc *xudc) ··· 727 724 int err; 728 725 729 726 dev_dbg(xudc->dev, "device mode off\n"); 727 + 728 + xudc->current_device_mode = false; 730 729 731 730 connected = !!(xudc_readl(xudc, PORTSC) & PORTSC_CCS); 732 731 ··· 4049 4044 4050 4045 spin_lock_irqsave(&xudc->lock, flags); 4051 4046 xudc->suspended = false; 4047 + if (xudc->device_mode != xudc->current_device_mode) 4048 + schedule_work(&xudc->usb_role_sw_work); 4052 4049 spin_unlock_irqrestore(&xudc->lock, flags); 4053 - 4054 - schedule_work(&xudc->usb_role_sw_work); 4055 4050 4056 4051 pm_runtime_enable(dev); 4057 4052