Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bae73e80 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull USB fixes from Greg KH:
 "Here are a few small USB fixes and new device ids for 4.9-rc7.

  The majority of these fixes are in the musb driver, fixing a number of
  regressions that have been reported but took a while to resolve. The
  other fixes are all small ones, to resolve other reported minor
  issues.

  All have been in linux-next for a while with no reported issues"

* tag 'usb-4.9-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  usb: gadget: f_fs: fix wrong parenthesis in ffs_func_req_match()
  phy: twl4030-usb: Fix for musb session bit based PM
  usb: musb: Drop pointless PM runtime code for dsps glue
  usb: musb: Add missing pm_runtime_disable and drop 2430 PM timeout
  usb: musb: Fix PM for hub disconnect
  usb: musb: Fix sleeping function called from invalid context for hdrc glue
  usb: musb: Fix broken use of static variable for multiple instances
  USB: serial: cp210x: add ID for the Zone DPMX
  usb: chipidea: move the lock initialization to core file
  Fix USB CB/CBI storage devices with CONFIG_VMAP_STACK=y
  USB: serial: ftdi_sio: add support for TI CC3200 LaunchPad
parents e2b6535d c0da038d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -459,8 +459,6 @@ static int twl4030_phy_power_off(struct phy *phy)
	struct twl4030_usb *twl = phy_get_drvdata(phy);

	dev_dbg(twl->dev, "%s\n", __func__);
	pm_runtime_mark_last_busy(twl->dev);
	pm_runtime_put_autosuspend(twl->dev);

	return 0;
}
@@ -472,6 +470,8 @@ static int twl4030_phy_power_on(struct phy *phy)
	dev_dbg(twl->dev, "%s\n", __func__);
	pm_runtime_get_sync(twl->dev);
	schedule_delayed_work(&twl->id_workaround_work, HZ);
	pm_runtime_mark_last_busy(twl->dev);
	pm_runtime_put_autosuspend(twl->dev);

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -914,6 +914,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
	if (!ci)
		return -ENOMEM;

	spin_lock_init(&ci->lock);
	ci->dev = dev;
	ci->platdata = dev_get_platdata(dev);
	ci->imx28_write_fix = !!(ci->platdata->flags &
+0 −2
Original line number Diff line number Diff line
@@ -1889,8 +1889,6 @@ static int udc_start(struct ci_hdrc *ci)
	struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
	int retval = 0;

	spin_lock_init(&ci->lock);

	ci->gadget.ops          = &usb_gadget_ops;
	ci->gadget.speed        = USB_SPEED_UNKNOWN;
	ci->gadget.max_speed    = USB_SPEED_HIGH;
+4 −4
Original line number Diff line number Diff line
@@ -3225,11 +3225,11 @@ static bool ffs_func_req_match(struct usb_function *f,

	switch (creq->bRequestType & USB_RECIP_MASK) {
	case USB_RECIP_INTERFACE:
		return ffs_func_revmap_intf(func,
					    le16_to_cpu(creq->wIndex) >= 0);
		return (ffs_func_revmap_intf(func,
					     le16_to_cpu(creq->wIndex)) >= 0);
	case USB_RECIP_ENDPOINT:
		return ffs_func_revmap_ep(func,
					  le16_to_cpu(creq->wIndex) >= 0);
		return (ffs_func_revmap_ep(func,
					   le16_to_cpu(creq->wIndex)) >= 0);
	default:
		return (bool) (func->ffs->user_flags &
			       FUNCTIONFS_ALL_CTRL_RECIP);
+129 −18
Original line number Diff line number Diff line
@@ -986,7 +986,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
	}
#endif

	schedule_work(&musb->irq_work);
	schedule_delayed_work(&musb->irq_work, 0);

	return handled;
}
@@ -1855,14 +1855,23 @@ static void musb_pm_runtime_check_session(struct musb *musb)
		MUSB_DEVCTL_HR;
	switch (devctl & ~s) {
	case MUSB_QUIRK_B_INVALID_VBUS_91:
		if (!musb->session && !musb->quirk_invalid_vbus) {
			musb->quirk_invalid_vbus = true;
		if (musb->quirk_retries--) {
			musb_dbg(musb,
				 "First invalid vbus, assume no session");
				 "Poll devctl on invalid vbus, assume no session");
			schedule_delayed_work(&musb->irq_work,
					      msecs_to_jiffies(1000));

			return;
		}
		break;
	case MUSB_QUIRK_A_DISCONNECT_19:
		if (musb->quirk_retries--) {
			musb_dbg(musb,
				 "Poll devctl on possible host mode disconnect");
			schedule_delayed_work(&musb->irq_work,
					      msecs_to_jiffies(1000));

			return;
		}
		if (!musb->session)
			break;
		musb_dbg(musb, "Allow PM on possible host mode disconnect");
@@ -1886,9 +1895,9 @@ static void musb_pm_runtime_check_session(struct musb *musb)
		if (error < 0)
			dev_err(musb->controller, "Could not enable: %i\n",
				error);
		musb->quirk_retries = 3;
	} else {
		musb_dbg(musb, "Allow PM with no session: %02x", devctl);
		musb->quirk_invalid_vbus = false;
		pm_runtime_mark_last_busy(musb->controller);
		pm_runtime_put_autosuspend(musb->controller);
	}
@@ -1899,7 +1908,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
/* Only used to provide driver mode change events */
static void musb_irq_work(struct work_struct *data)
{
	struct musb *musb = container_of(data, struct musb, irq_work);
	struct musb *musb = container_of(data, struct musb, irq_work.work);

	musb_pm_runtime_check_session(musb);

@@ -1969,6 +1978,7 @@ static struct musb *allocate_instance(struct device *dev,
	INIT_LIST_HEAD(&musb->control);
	INIT_LIST_HEAD(&musb->in_bulk);
	INIT_LIST_HEAD(&musb->out_bulk);
	INIT_LIST_HEAD(&musb->pending_list);

	musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
	musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
@@ -2018,6 +2028,84 @@ static void musb_free(struct musb *musb)
	musb_host_free(musb);
}

struct musb_pending_work {
	int (*callback)(struct musb *musb, void *data);
	void *data;
	struct list_head node;
};

/*
 * Called from musb_runtime_resume(), musb_resume(), and
 * musb_queue_resume_work(). Callers must take musb->lock.
 */
static int musb_run_resume_work(struct musb *musb)
{
	struct musb_pending_work *w, *_w;
	unsigned long flags;
	int error = 0;

	spin_lock_irqsave(&musb->list_lock, flags);
	list_for_each_entry_safe(w, _w, &musb->pending_list, node) {
		if (w->callback) {
			error = w->callback(musb, w->data);
			if (error < 0) {
				dev_err(musb->controller,
					"resume callback %p failed: %i\n",
					w->callback, error);
			}
		}
		list_del(&w->node);
		devm_kfree(musb->controller, w);
	}
	spin_unlock_irqrestore(&musb->list_lock, flags);

	return error;
}

/*
 * Called to run work if device is active or else queue the work to happen
 * on resume. Caller must take musb->lock and must hold an RPM reference.
 *
 * Note that we cowardly refuse queuing work after musb PM runtime
 * resume is done calling musb_run_resume_work() and return -EINPROGRESS
 * instead.
 */
int musb_queue_resume_work(struct musb *musb,
			   int (*callback)(struct musb *musb, void *data),
			   void *data)
{
	struct musb_pending_work *w;
	unsigned long flags;
	int error;

	if (WARN_ON(!callback))
		return -EINVAL;

	if (pm_runtime_active(musb->controller))
		return callback(musb, data);

	w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC);
	if (!w)
		return -ENOMEM;

	w->callback = callback;
	w->data = data;
	spin_lock_irqsave(&musb->list_lock, flags);
	if (musb->is_runtime_suspended) {
		list_add_tail(&w->node, &musb->pending_list);
		error = 0;
	} else {
		dev_err(musb->controller, "could not add resume work %p\n",
			callback);
		devm_kfree(musb->controller, w);
		error = -EINPROGRESS;
	}
	spin_unlock_irqrestore(&musb->list_lock, flags);

	return error;
}
EXPORT_SYMBOL_GPL(musb_queue_resume_work);

static void musb_deassert_reset(struct work_struct *work)
{
	struct musb *musb;
@@ -2065,6 +2153,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
	}

	spin_lock_init(&musb->lock);
	spin_lock_init(&musb->list_lock);
	musb->board_set_power = plat->set_power;
	musb->min_power = plat->min_power;
	musb->ops = plat->platform_ops;
@@ -2208,7 +2297,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
	musb_generic_disable(musb);

	/* Init IRQ workqueue before request_irq */
	INIT_WORK(&musb->irq_work, musb_irq_work);
	INIT_DELAYED_WORK(&musb->irq_work, musb_irq_work);
	INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset);
	INIT_DELAYED_WORK(&musb->finish_resume_work, musb_host_finish_resume);

@@ -2291,6 +2380,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
	if (status)
		goto fail5;

	musb->is_initialized = 1;
	pm_runtime_mark_last_busy(musb->controller);
	pm_runtime_put_autosuspend(musb->controller);

@@ -2304,7 +2394,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
	musb_host_cleanup(musb);

fail3:
	cancel_work_sync(&musb->irq_work);
	cancel_delayed_work_sync(&musb->irq_work);
	cancel_delayed_work_sync(&musb->finish_resume_work);
	cancel_delayed_work_sync(&musb->deassert_reset_work);
	if (musb->dma_controller)
@@ -2371,7 +2461,7 @@ static int musb_remove(struct platform_device *pdev)
	 */
	musb_exit_debugfs(musb);

	cancel_work_sync(&musb->irq_work);
	cancel_delayed_work_sync(&musb->irq_work);
	cancel_delayed_work_sync(&musb->finish_resume_work);
	cancel_delayed_work_sync(&musb->deassert_reset_work);
	pm_runtime_get_sync(musb->controller);
@@ -2557,6 +2647,7 @@ static int musb_suspend(struct device *dev)

	musb_platform_disable(musb);
	musb_generic_disable(musb);
	WARN_ON(!list_empty(&musb->pending_list));

	spin_lock_irqsave(&musb->lock, flags);

@@ -2579,6 +2670,8 @@ static int musb_suspend(struct device *dev)
static int musb_resume(struct device *dev)
{
	struct musb *musb = dev_to_musb(dev);
	unsigned long flags;
	int error;
	u8 devctl;
	u8 mask;

@@ -2614,6 +2707,13 @@ static int musb_resume(struct device *dev)

	musb_start(musb);

	spin_lock_irqsave(&musb->lock, flags);
	error = musb_run_resume_work(musb);
	if (error)
		dev_err(musb->controller, "resume work failed with %i\n",
			error);
	spin_unlock_irqrestore(&musb->lock, flags);

	return 0;
}

@@ -2622,6 +2722,7 @@ static int musb_runtime_suspend(struct device *dev)
	struct musb	*musb = dev_to_musb(dev);

	musb_save_context(musb);
	musb->is_runtime_suspended = 1;

	return 0;
}
@@ -2629,7 +2730,8 @@ static int musb_runtime_suspend(struct device *dev)
static int musb_runtime_resume(struct device *dev)
{
	struct musb *musb = dev_to_musb(dev);
	static int	first = 1;
	unsigned long flags;
	int error;

	/*
	 * When pm_runtime_get_sync called for the first time in driver
@@ -2640,9 +2742,10 @@ static int musb_runtime_resume(struct device *dev)
	 * Also context restore without save does not make
	 * any sense
	 */
	if (!first)
	if (!musb->is_initialized)
		return 0;

	musb_restore_context(musb);
	first = 0;

	if (musb->need_finish_resume) {
		musb->need_finish_resume = 0;
@@ -2650,6 +2753,14 @@ static int musb_runtime_resume(struct device *dev)
				msecs_to_jiffies(USB_RESUME_TIMEOUT));
	}

	spin_lock_irqsave(&musb->lock, flags);
	error = musb_run_resume_work(musb);
	if (error)
		dev_err(musb->controller, "resume work failed with %i\n",
			error);
	musb->is_runtime_suspended = 0;
	spin_unlock_irqrestore(&musb->lock, flags);

	return 0;
}

Loading