linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Al Cooper <al.cooper@broadcom.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Al Cooper <alcooperx@gmail.com>
Cc: linux-kernel@vger.kernel.org, Alban Bedel <albeu@free.fr>,
	Alex Elder <elder@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Avi Fishman <avifishman70@gmail.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	devicetree@vger.kernel.org, Dmitry Osipenko <digetx@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Hans de Goede <hdegoede@redhat.com>,
	James Hogan <jhogan@kernel.org>,
	Jianguo Sun <sunjianguo1@huawei.com>,
	Johan Hovold <johan@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	linux-usb@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Rishabh Bhatnagar <rishabhb@codeaurora.org>,
	Rob Herring <robh+dt@kernel.org>, Roger Quadros <rogerq@ti.com>
Subject: Re: [PATCH V3 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's
Date: Tue, 6 Nov 2018 15:44:21 -0800	[thread overview]
Message-ID: <674c3275-de47-57f4-84aa-58b318aef67b@gmail.com> (raw)
In-Reply-To: <d077971c-d7ef-d630-2d89-5a06fb481b28@broadcom.com>

On 11/6/18 1:40 PM, Al Cooper wrote:
> On 11/6/18 11:08 AM, Alan Stern wrote:
>> On Mon, 5 Nov 2018, Al Cooper wrote:
>>
>>> Add support for Broadcom STB SoC's to the ohci platform driver.
>>>
>>> Signed-off-by: Al Cooper <alcooperx@gmail.com>
>>> ---
>>
>>> @@ -177,6 +189,8 @@ static int ohci_platform_probe(struct
>>> platform_device *dev)
>>>           ohci->flags |= OHCI_QUIRK_FRAME_NO;
>>>       if (pdata->num_ports)
>>>           ohci->num_ports = pdata->num_ports;
>>> +    if (pdata->suspend_without_phy_exit)
>>> +        hcd->suspend_without_phy_exit = 1;
>>
>> Sorry if I missed this in the earlier discussions...  Is there any
>> possibility of adding a DT binding that could express this requirement,
>> instead of putting it in the platform data?
>>
>> Alan Stern
>>
> 
> Alan,
> 
> That was my original approach but internal review suggested that I use
> pdata instead. Below is my original patch for:

And the reason for that suggestion was really because it was percevied
as encoding a driver behavior as a Device Tree property as opposed to
describing something that was inherently and strictly a hardware
behavior (therefore suitable for Device Tree).

> [PATCH V3 2/6] usb: core: Add ability to skip phy exit on suspend and
> init on resume
> With this patch I can then use ohci_platform.c without any
> modifications. Could you let me know what you think?
> 
> Thanks
> Al
> 
> Add the ability to skip calling the PHY's exit routine on suspend
> and the PHY's init routine on resume. This is to handle a USB PHY
> that should have it's power_off function called on suspend but cannot
> have it's exit function called because on exit it will disable the
> PHY to the point where register accesses to the Host Controllers
> using the PHY will be disabled and the host drivers will crash.
> 
> This is enabled with the HCD flag "suspend_without_phy_exit" which
> can be set from any HCD driver or from the device-tree property
> "suspend-without-phy-exit".
> 
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  drivers/usb/core/hcd.c  |  8 ++++----
>  drivers/usb/core/phy.c  | 21 +++++++++++++++------
>  drivers/usb/core/phy.h  |  9 ++++++---
>  include/linux/usb/hcd.h |  3 +++
>  4 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 1c21955fe7c0..e67e4d6b3d21 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2263,7 +2263,7 @@ int hcd_bus_suspend(struct usb_device *rhdev,
> pm_message_t msg)
>          hcd->state = HC_STATE_SUSPENDED;
> 
>          if (!PMSG_IS_AUTO(msg))
> -            usb_phy_roothub_suspend(hcd->self.sysdev,
> +            usb_phy_roothub_suspend(hcd,
>                          hcd->phy_roothub);
> 
>          /* Did we race with a root-hub wakeup event? */
> @@ -2304,7 +2304,7 @@ int hcd_bus_resume(struct usb_device *rhdev,
> pm_message_t msg)
>      }
> 
>      if (!PMSG_IS_AUTO(msg)) {
> -        status = usb_phy_roothub_resume(hcd->self.sysdev,
> +        status = usb_phy_roothub_resume(hcd,
>                          hcd->phy_roothub);
>          if (status)
>              return status;
> @@ -2347,7 +2347,7 @@ int hcd_bus_resume(struct usb_device *rhdev,
> pm_message_t msg)
>          }
>      } else {
>          hcd->state = old_state;
> -        usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub);
> +        usb_phy_roothub_suspend(hcd, hcd->phy_roothub);
>          dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
>                  "resume", status);
>          if (status != -ESHUTDOWN)
> @@ -2744,7 +2744,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
>      struct usb_device *rhdev;
> 
>      if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
> -        hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
> +        hcd->phy_roothub = usb_phy_roothub_alloc(hcd);
>          if (IS_ERR(hcd->phy_roothub))
>              return PTR_ERR(hcd->phy_roothub);
> 
> diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
> index 9879767452a2..0eb12566f1c3 100644
> --- a/drivers/usb/core/phy.c
> +++ b/drivers/usb/core/phy.c
> @@ -45,10 +45,11 @@ static int usb_phy_roothub_add_phy(struct device
> *dev, int index,
>      return 0;
>  }
> 
> -struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
> +struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd)
>  {
>      struct usb_phy_roothub *phy_roothub;
>      int i, num_phys, err;
> +    struct device *dev = hcd->self.sysdev;
> 
>      if (!IS_ENABLED(CONFIG_GENERIC_PHY))
>          return NULL;
> @@ -58,6 +59,9 @@ struct usb_phy_roothub *usb_phy_roothub_alloc(struct
> device *dev)
>      if (num_phys <= 0)
>          return NULL;
> 
> +    if (device_property_read_bool(dev, "suspend-without-phy-exit"))
> +        hcd->suspend_without_phy_exit = 1;
> +
>      phy_roothub = devm_kzalloc(dev, sizeof(*phy_roothub), GFP_KERNEL);
>      if (!phy_roothub)
>          return ERR_PTR(-ENOMEM);
> @@ -161,26 +165,30 @@ void usb_phy_roothub_power_off(struct
> usb_phy_roothub *phy_roothub)
>  }
>  EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
> 
> -int usb_phy_roothub_suspend(struct device *controller_dev,
> +int usb_phy_roothub_suspend(struct usb_hcd *hcd,
>                  struct usb_phy_roothub *phy_roothub)
>  {
> +    struct device *controller_dev = hcd->self.sysdev;
> +
>      usb_phy_roothub_power_off(phy_roothub);
> 
>      /* keep the PHYs initialized so the device can wake up the system */
> -    if (device_may_wakeup(controller_dev))
> +    if (device_may_wakeup(controller_dev) ||
> hcd->suspend_without_phy_exit)
>          return 0;
> 
>      return usb_phy_roothub_exit(phy_roothub);
>  }
>  EXPORT_SYMBOL_GPL(usb_phy_roothub_suspend);
> 
> -int usb_phy_roothub_resume(struct device *controller_dev,
> +int usb_phy_roothub_resume(struct usb_hcd *hcd,
>                 struct usb_phy_roothub *phy_roothub)
>  {
> +    struct device *controller_dev = hcd->self.sysdev;
>      int err;
> 
>      /* if the device can't wake up the system _exit was called */
> -    if (!device_may_wakeup(controller_dev)) {
> +    if (!device_may_wakeup(controller_dev) &&
> +        !hcd->suspend_without_phy_exit) {
>          err = usb_phy_roothub_init(phy_roothub);
>          if (err)
>              return err;
> @@ -189,7 +197,8 @@ int usb_phy_roothub_resume(struct device
> *controller_dev,
>      err = usb_phy_roothub_power_on(phy_roothub);
> 
>      /* undo _init if _power_on failed */
> -    if (err && !device_may_wakeup(controller_dev))
> +    if (err && !device_may_wakeup(controller_dev)
> +        && !hcd->suspend_without_phy_exit)
>          usb_phy_roothub_exit(phy_roothub);
> 
>      return err;
> diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h
> index 88a3c037e9df..34293e11a917 100644
> --- a/drivers/usb/core/phy.h
> +++ b/drivers/usb/core/phy.h
> @@ -5,13 +5,16 @@
>   * Copyright (C) 2018 Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>
>   */
> 
> +#include <linux/usb.h>
> +#include <linux/usb/hcd.h>
> +
>  #ifndef __USB_CORE_PHY_H_
>  #define __USB_CORE_PHY_H_
> 
>  struct device;
>  struct usb_phy_roothub;
> 
> -struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev);
> +struct usb_phy_roothub *usb_phy_roothub_alloc(struct usb_hcd *hcd);
> 
>  int usb_phy_roothub_init(struct usb_phy_roothub *phy_roothub);
>  int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub);
> @@ -19,9 +22,9 @@
>  int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
>  void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);
> 
> -int usb_phy_roothub_suspend(struct device *controller_dev,
> +int usb_phy_roothub_suspend(struct usb_hcd *hcd,
>                  struct usb_phy_roothub *phy_roothub);
> -int usb_phy_roothub_resume(struct device *controller_dev,
> +int usb_phy_roothub_resume(struct usb_hcd *hcd,
>                 struct usb_phy_roothub *phy_roothub);
> 
>  #endif /* __USB_CORE_PHY_H_ */
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index 97e2ddec18b1..87a104055b5e 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -157,6 +157,9 @@ struct usb_hcd {
>       */
>      unsigned        skip_phy_initialization:1;
> 
> +    /* Some phys don't want the phy's exit/init called on
> suspend/resume */
> +    unsigned        suspend_without_phy_exit:1;
> +
>      /* The next flag is a stopgap, to be removed when all the HCDs
>       * support the new root-hub polling mechanism. */
>      unsigned        uses_new_polling:1;


-- 
Florian

  reply	other threads:[~2018-11-06 23:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05 21:31 [PATCH V3 0/6] Add XHCI, EHCI and OHCI support for Broadcom STB SoS's Al Cooper
2018-11-05 21:31 ` [PATCH V3 1/6] dt-bindings: Add Broadcom STB OHCI, EHCI and XHCI binding document Al Cooper
2018-11-05 21:31 ` [PATCH V3 2/6] usb: core: Add ability to skip phy exit on suspend and init on resume Al Cooper
2018-11-05 21:31 ` [PATCH V3 3/6] usb: xhci: xhci-plat: Add support for Broadcom STB SoC's Al Cooper
2018-11-05 21:31 ` [PATCH V3 4/6] usb: ohci-platform: " Al Cooper
2018-11-06 16:08   ` Alan Stern
2018-11-06 21:40     ` Al Cooper
2018-11-06 23:44       ` Florian Fainelli [this message]
2018-11-07 15:23         ` Alan Stern
2018-11-07 15:58           ` Al Cooper
2018-11-07 16:27             ` Alan Stern
2018-11-07 17:29               ` Florian Fainelli
2018-11-07 17:40                 ` Al Cooper
2018-11-07 18:11                   ` Florian Fainelli
     [not found]                     ` <20181112174532.GA14682@bogus>
2018-11-13 21:54                       ` Alan Cooper
2018-11-05 21:31 ` [PATCH V3 5/6] usb: ehci: Add new EHCI driver " Al Cooper
2018-11-05 21:31 ` [PATCH V3 6/6] usb: host: Add ability to build new Broadcom STB USB drivers Al Cooper
2018-11-06 11:09   ` Arnd Bergmann
2018-11-06 15:55     ` Alan Cooper
2018-11-06 18:22       ` Arnd Bergmann
2018-11-06 19:33         ` Alan Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=674c3275-de47-57f4-84aa-58b318aef67b@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=al.cooper@broadcom.com \
    --cc=albeu@free.fr \
    --cc=alcooperx@gmail.com \
    --cc=arnd@arndb.de \
    --cc=avifishman70@gmail.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=chunfeng.yun@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=digetx@gmail.com \
    --cc=elder@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=hdegoede@redhat.com \
    --cc=jhogan@kernel.org \
    --cc=johan@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=rishabhb@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=rogerq@ti.com \
    --cc=stern@rowland.harvard.edu \
    --cc=sunjianguo1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).