* Re: port power is on again after turning off by user space
From: Alan Stern @ 2020-12-22 2:35 UTC (permalink / raw)
To: Peter Chen; +Cc: Jun Li, linux-usb@vger.kernel.org, Frank Li
In-Reply-To: <20201222020215.GA4706@b29397-desktop>
On Tue, Dec 22, 2020 at 02:02:44AM +0000, Peter Chen wrote:
> On 20-12-21 11:25:51, Alan Stern wrote:
> > Okay. This can be done as follows:
> >
> > while (1) {
> > - Check Flash Drive is there (eg, cat /proc/partitions)
> > - Claim port 1 on 1-1
> > - Turn port 1 at 1-1 off
> > - Check Flash Drive is gone
> > - Release port 1 on 1-1
> > - Turn port 1 at 1-1 on
> > - Delay for 10 seconds (time for device probing)
> > }
> >
> >
> > > > On the other hand, if the port is managed by the kernel then the kernel
> > > > (not the user) should be responsible for deciding whether or not to
> > > > turn off the port's power.
> > > >
> > > > If there's some real reason for turning the port power off for an
> > > > extended period of time, the user can claim the port and turn off the
> > > > power. Then later on, the user can release the port and turn the power
> > > > back on.
> > > >
> > >
> > > Yes, I think this is one of the use cases. We want power power control
> > > at one application (A), but different with our test application(B), it means
> > > if the user claims the port, and power off using A, then the A will end.
> > > After the B finished running, A runs again for power on, but at this time,
> > > the port owner has changed.
> >
> > Yes, that won't work. If you want to keep the port power turned off
> > then you have to keep the usbfs device file open -- which means your
> > program A must not end and then restart.
> >
> > (Acutally, I'm not certain about that. If you claim a port, turn off
> > its power, and then release the port, I don't remember whether the hub
> > driver will then turn the power back on right away. It might not.
> > But in any case, it isn't good programming to release a port without
> > turning its power back on.)
> >
> > Can A be rewritten so that it doesn't end when B is running?
> >
>
> Of course. I think the similar use case like below:
>
> Program A (Port power control program)
>
> while (1) {
> - Wait "turn off" command;
> - Claim requested port;
> - Turn off requested port;
> - Wait "turn on" command;
> - Turn on requested port
> - Release requested port;
You have to be a little careful about this. Let's say you turn on the
port power. THen the device will connect and be enumerated.
But if you haven't released the port at this point, the kernel won't
select a configuration for the device; it will leave the device in the
unconfigured state. Perhaps the code in usb_hub_release_port() and
usb_hub_release_all_ports() needs to be changed; perhaps these routines
should select and install a configuration if the child device isn't
already configured.
For the time being, the safest approach is to release the port first
and then turn on the power. Of course, that's not ideal either because
it would mean changing the power setting for a port you don't own. But
right now that's the best you can do.
> };
>
> Program B actually is a script:
>
> {
> while [ "$i" -lt 10000 ];
> do
> - Check Flash Drive is there (eg, cat /proc/partitions);
> - Send "turn off" command;
> - Wait 5 seconds, and check if Flash Drive has gone;
> - Send "turn on" command;
> - i=`expr $i + 1`;
> done
> terminate program A;
> };
>
> I need to find communication solution between program A and script B.
> Or would you have any suggestions to design such kinds of test case?
Normally programs like this would communicate by a pipe or a Unix
socket. One way to make this work is for program B to run A in the
background before the "while" loop starts, so that B could control
the standard input and output files that A uses. That's probably the
approach I would take.
Alan Stern
^ permalink raw reply
* RE: [PATCH 1/2] of: platform: introduce platform data length for auxdata
From: Peter Chen @ 2020-12-22 2:23 UTC (permalink / raw)
To: Rob Herring
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Frank Rowand,
Linux USB List, dl-linux-imx, Aswath Govindraju, Frank Li,
devicetree@vger.kernel.org
In-Reply-To: <20201211020155.GA490@b29397-desktop>
> Subject: Re: [PATCH 1/2] of: platform: introduce platform data length for
> auxdata
>
> On 20-12-10 09:38:49, Rob Herring wrote:
> > On Thu, Dec 10, 2020 at 7:42 AM Peter Chen <peter.chen@kernel.org>
> wrote:
> > >
> > > From: Peter Chen <peter.chen@nxp.com>
> > >
> > > When a platform device is released, it frees the device
> > > platform_data memory region using kfree, if the memory is not
> > > allocated by kmalloc, it may run into trouble. See the below comments from
> kfree API.
> > >
> > > * Don't free memory not originally allocated by kmalloc()
> > > * or you will run into trouble.
> > >
> > > For the device which is created dynamically using
> > > of_platform_populate, if the platform_data is existed at
> > > of_dev_auxdata structure, the OF code simply assigns the
> > > platform_data pointer to newly created device, but not using
> > > platform_device_add_data to allocate one. For most of platform data
> > > region at device driver, which may not be allocated by kmalloc, they are at
> global data region or at stack region at some situations.
> >
> > auxdata is a "temporary" thing for transitioning to DT which I want to
> > remove. So I don't really want to see it expanded nor new users. We've
> > got about a dozen arm32 platforms and 5 cases under drivers/.
> >
>
> How to handle the below user case:
> Parent device creates child device through device tree node (eg, usb/dwc3,
> usb/cdns3), there are some platform quirks at parent device(vendor glue
> layer) need child device (core IP device) driver to handle. The quirks are not
> limited to the hardware quirk, may include the callbacks, software flag (eg:
> XHCI_DEFAULT_PM_RUNTIME_ALLOW/XHCI_SKIP_PHY_INIT, at
> drivers/usb/host/xhci.h)
>
> > > + int platform_data_length = 0;
> > > int rc = 0;
> > >
> > > /* Make sure it has a compatible property */ @@ -378,6
> > > +387,9 @@ static int of_platform_bus_create(struct device_node *bus,
> > > if (auxdata) {
> > > bus_id = auxdata->name;
> > > platform_data = auxdata->platform_data;
> > > + platform_data_length =
> auxdata->platform_data_length;
> > > + if (platform_data && !platform_data_length)
> > > + pr_warn("Make sure platform_data is
> > > + allocated by kmalloc\n");
> >
> > Isn't this going to warn on the majority of users as static data is the norm.
>
> This warning only triggers at the cases which driver defines auxdata and
> platform_data pointer is in it. Besides, directly assign the address of static data
> to device platfrom_data pointer is wrong thing, this region will be freed using
> kfree at platform_device_release. Using platform_device_add_data API is the
> correct thing to do that.
>
Hi Rob,
Would you please give me some suggestions how we could fix/workaround this issue?
Peter
^ permalink raw reply
* Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Peter Chen @ 2020-12-22 2:14 UTC (permalink / raw)
To: Pali Rohár
Cc: Mathias Nyman, Greg Kroah-Hartman, Jun Li,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20201221150903.26630-1-pali@kernel.org>
On 20-12-21 16:09:03, Pali Rohár wrote:
> Currently init_quirk callbacks for xhci platform drivers are called
> xhci_plat_setup() function which is called after chip reset completes.
> It happens in the middle of the usb_add_hcd() function.
>
> But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
> prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
> currently does nothing as prior xhci_plat_setup() it is not set.
>
> Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
> which really needs to be set prior calling usb_add_hcd() as this function
> at its beginning skips PHY init if this member is set.
>
> This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
> init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
> XHCI_SKIP_PHY_INIT is set.
>
> Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
> drivers/usb/host/xhci-plat.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 4d34f6005381..58704c5b002b 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
> /* called during probe() after chip reset completes */
> static int xhci_plat_setup(struct usb_hcd *hcd)
> {
> - int ret;
> -
> -
> - ret = xhci_priv_init_quirk(hcd);
> - if (ret)
> - return ret;
> -
> return xhci_gen_setup(hcd, xhci_plat_quirks);
> }
>
> @@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
>
> hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
> xhci->shared_hcd->tpl_support = hcd->tpl_support;
> +
> + if (priv) {
> + ret = xhci_priv_init_quirk(hcd);
> + if (ret)
> + goto disable_usb_phy;
> + }
> +
> if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> hcd->skip_phy_initialization = 1;
>
Hi Pali,
What's problem you have met? In structure xhci_plat_priv, the quirks are
defined at .quirks entry which is got at below code. .init_quirk is the
routine if special initializations are needed.
if (pdev->dev.of_node)
priv_match = of_device_get_match_data(&pdev->dev);
else
priv_match = dev_get_platdata(&pdev->dev);
if (priv_match) {
priv = hcd_to_xhci_priv(hcd);
/* Just copy data for now */
*priv = *priv_match;
}
--
Thanks,
Peter Chen
^ permalink raw reply
* Re: port power is on again after turning off by user space
From: Peter Chen @ 2020-12-22 2:02 UTC (permalink / raw)
To: Alan Stern; +Cc: Jun Li, linux-usb@vger.kernel.org, Frank Li
In-Reply-To: <20201221162551.GB436749@rowland.harvard.edu>
On 20-12-21 11:25:51, Alan Stern wrote:
> On Mon, Dec 21, 2020 at 05:37:29AM +0000, Peter Chen wrote:
> > On 20-12-16 10:51:44, Alan Stern wrote:
> > > On Wed, Dec 16, 2020 at 02:56:20AM +0000, Peter Chen wrote:
> > > > On 20-12-15 10:55:41, Alan Stern wrote:
> > > > > You've got the general idea.
> > > > >
> > > > > Normally ports are owned by the hub driver. If one of them loses power
> > > > > for some reason (for example, the user turns it off), the hub driver
> > > > > will turn the power back on. This is because the hub driver wants
> > > > > ports to be powered at all times unless they are in runtime suspend.
> > > > >
> > > > > The way to prevent the hub driver from managing the port power is to
> > > > > claim the port for the user, by issuing the USBDEVFS_CLAIM_PORT ioctl.
> > > > > Also, when that is done, the kernel wno't try to manage a device
> > > > > attached to the port -- that is, the kernel won't automatically install
> > > > > a configuration for a new device and it won't try to probe drivers for
> > > > > the device's interfaces if the user installs a config.
> > > > >
> > > >
> > > > Alan, we have several use cases for power switchable HUB, one of the use
> > > > cases is USB port is managed by kernel (eg, needs mass storage
> > > > class), but needs to toggle port power, is it reasonable we add a sysfs
> > > > entry to support it?
> > >
> > > Can you give more information about your use cases? After all, if the
> > > port power is turned off then the port can't possibly handle
> > > mass-storage devices -- or anything else.
> >
> > Sorry, Alan. Due to holiday season, the U.S team doesn't reply me the
> > use case. I think the basic use cases are emulate the hot-plug test for
> > USB devices, the USB devices could be Flash Drive on market or DUT (Device
> > Under test) for the same controller works at device mode. Assume one
> > typical test case:
> >
> > Plug in Flash Drive at port 1-1.1 during the boots up:
> >
> > while (1) {
> > - Check Flash Drive is there (eg, cat /proc/partitions)
> > - Turn port 1 at 1-1 off
> > - Check Flash Drive is gone
> > - Turn port 1 at 1-1 on
> > }
>
> Okay. This can be done as follows:
>
> while (1) {
> - Check Flash Drive is there (eg, cat /proc/partitions)
> - Claim port 1 on 1-1
> - Turn port 1 at 1-1 off
> - Check Flash Drive is gone
> - Release port 1 on 1-1
> - Turn port 1 at 1-1 on
> - Delay for 10 seconds (time for device probing)
> }
>
>
> > > On the other hand, if the port is managed by the kernel then the kernel
> > > (not the user) should be responsible for deciding whether or not to
> > > turn off the port's power.
> > >
> > > If there's some real reason for turning the port power off for an
> > > extended period of time, the user can claim the port and turn off the
> > > power. Then later on, the user can release the port and turn the power
> > > back on.
> > >
> >
> > Yes, I think this is one of the use cases. We want power power control
> > at one application (A), but different with our test application(B), it means
> > if the user claims the port, and power off using A, then the A will end.
> > After the B finished running, A runs again for power on, but at this time,
> > the port owner has changed.
>
> Yes, that won't work. If you want to keep the port power turned off
> then you have to keep the usbfs device file open -- which means your
> program A must not end and then restart.
>
> (Acutally, I'm not certain about that. If you claim a port, turn off
> its power, and then release the port, I don't remember whether the hub
> driver will then turn the power back on right away. It might not.
> But in any case, it isn't good programming to release a port without
> turning its power back on.)
>
> Can A be rewritten so that it doesn't end when B is running?
>
Of course. I think the similar use case like below:
Program A (Port power control program)
while (1) {
- Wait "turn off" command;
- Claim requested port;
- Turn off requested port;
- Wait "turn on" command;
- Turn on requested port
- Release requested port;
};
Program B actually is a script:
{
while [ "$i" -lt 10000 ];
do
- Check Flash Drive is there (eg, cat /proc/partitions);
- Send "turn off" command;
- Wait 5 seconds, and check if Flash Drive has gone;
- Send "turn on" command;
- i=`expr $i + 1`;
done
terminate program A;
};
I need to find communication solution between program A and script B.
Or would you have any suggestions to design such kinds of test case?
--
Thanks,
Peter Chen
^ permalink raw reply
* Re: [PATCH] usb: musb: add printf attribute to log function
From: Tom Rix @ 2020-12-21 20:55 UTC (permalink / raw)
To: Joe Perches, b-liu, gregkh; +Cc: linux-usb, linux-kernel
In-Reply-To: <6e214d120372681fd9bfb60bb1ac880248d8924f.camel@perches.com>
On 12/21/20 12:33 PM, Joe Perches wrote:
> On Mon, 2020-12-21 at 08:25 -0800, trix@redhat.com wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> Attributing the function allows the compiler to more thoroughly
>> check the use of the function with -Wformat and similar flags.
>>
>> Signed-off-by: Tom Rix <trix@redhat.com>
>> ---
>> drivers/usb/musb/musb_debug.h | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
>> index e5b3506c7b3f..dfc0d02695fa 100644
>> --- a/drivers/usb/musb/musb_debug.h
>> +++ b/drivers/usb/musb/musb_debug.h
>> @@ -17,6 +17,7 @@
>> #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
>> #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
>>
>>
>> +__printf(2, 3)
>> void musb_dbg(struct musb *musb, const char *fmt, ...);
> Maybe convert all the WARN/INFO/ERR uses to dev_<level> equivalents too?
>
> Use more typical logging styles:
>
> o Add musb_<level> macros that use dev_<level>
> o Add struct musb * to musb_<level> calls
> o Remove __func__ and __LINE__ uses
> o Remove newlines from formats and add to macros for consistency with musb_dbg
> o Remove unnecessary newlines from musb_dbg uses
> o Coalesce formats and align arguments
I will looking into cleaning these up.
The propose of this and similar changes today was to add the __printf so the the %hhx cleaner would find them.
Thanks for the suggestion,
Tom
>
> ---
>
> (compiled x86-64 only, untested)
>
> drivers/usb/musb/am35x.c | 2 +-
> drivers/usb/musb/cppi_dma.c | 160 ++++++++++++++++++-------------------
> drivers/usb/musb/da8xx.c | 2 +-
> drivers/usb/musb/davinci.c | 7 +-
> drivers/usb/musb/musb_core.c | 74 ++++++++---------
> drivers/usb/musb/musb_cppi41.c | 2 +-
> drivers/usb/musb/musb_debug.h | 14 ++--
> drivers/usb/musb/musb_dsps.c | 2 +-
> drivers/usb/musb/musb_gadget.c | 76 +++++++++---------
> drivers/usb/musb/musb_gadget_ep0.c | 33 ++++----
> drivers/usb/musb/musb_host.c | 98 +++++++++++------------
> drivers/usb/musb/musb_virthub.c | 4 +-
> drivers/usb/musb/musbhsdma.c | 20 ++---
> drivers/usb/musb/tusb6010.c | 24 +++---
> drivers/usb/musb/tusb6010_omap.c | 4 +-
> drivers/usb/musb/ux500_dma.c | 4 +-
> 16 files changed, 256 insertions(+), 270 deletions(-)
>
> diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
> index 660641ab1545..39d830e633c1 100644
> --- a/drivers/usb/musb/am35x.c
> +++ b/drivers/usb/musb/am35x.c
> @@ -260,7 +260,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
> - WARNING("VBUS error workaround (delay coming)\n");
> + musb_warn(musb, "VBUS error workaround (delay coming)");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
> index edb5b63d7063..021395de3b38 100644
> --- a/drivers/usb/musb/cppi_dma.c
> +++ b/drivers/usb/musb/cppi_dma.c
> @@ -317,7 +317,7 @@ cppi_channel_allocate(struct dma_controller *c,
> */
> if (cppi_ch->hw_ep)
> musb_dbg(musb, "re-allocating DMA%d %cX channel %p",
> - index, transmit ? 'T' : 'R', cppi_ch);
> + index, transmit ? 'T' : 'R', cppi_ch);
> cppi_ch->hw_ep = ep;
> cppi_ch->channel.status = MUSB_DMA_STATUS_FREE;
> cppi_ch->channel.max_len = 0x7fffffff;
> @@ -338,7 +338,7 @@ static void cppi_channel_release(struct dma_channel *channel)
> tibase = c->controller->tibase;
> if (!c->hw_ep)
> musb_dbg(c->controller->controller.musb,
> - "releasing idle DMA channel %p", c);
> + "releasing idle DMA channel %p", c);
> else if (!c->transmit)
> core_rxirq_enable(tibase, c->index + 1);
>
> @@ -357,23 +357,21 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char *tag)
> musb_ep_select(base, c->index + 1);
>
> musb_dbg(c->controller->controller.musb,
> - "RX DMA%d%s: %d left, csr %04x, "
> - "%08x H%08x S%08x C%08x, "
> - "B%08x L%08x %08x .. %08x",
> - c->index, tag,
> - musb_readl(c->controller->tibase,
> - DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index),
> - musb_readw(c->hw_ep->regs, MUSB_RXCSR),
> -
> - musb_readl(&rx->rx_skipbytes, 0),
> - musb_readl(&rx->rx_head, 0),
> - musb_readl(&rx->rx_sop, 0),
> - musb_readl(&rx->rx_current, 0),
> -
> - musb_readl(&rx->rx_buf_current, 0),
> - musb_readl(&rx->rx_len_len, 0),
> - musb_readl(&rx->rx_cnt_cnt, 0),
> - musb_readl(&rx->rx_complete, 0)
> + "RX DMA%d%s: %d left, csr %04x, %08x H%08x S%08x C%08x, B%08x L%08x %08x .. %08x",
> + c->index, tag,
> + musb_readl(c->controller->tibase,
> + DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index),
> + musb_readw(c->hw_ep->regs, MUSB_RXCSR),
> +
> + musb_readl(&rx->rx_skipbytes, 0),
> + musb_readl(&rx->rx_head, 0),
> + musb_readl(&rx->rx_sop, 0),
> + musb_readl(&rx->rx_current, 0),
> +
> + musb_readl(&rx->rx_buf_current, 0),
> + musb_readl(&rx->rx_len_len, 0),
> + musb_readl(&rx->rx_cnt_cnt, 0),
> + musb_readl(&rx->rx_complete, 0)
> );
> }
>
> @@ -387,21 +385,19 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char *tag)
> musb_ep_select(base, c->index + 1);
>
> musb_dbg(c->controller->controller.musb,
> - "TX DMA%d%s: csr %04x, "
> - "H%08x S%08x C%08x %08x, "
> - "F%08x L%08x .. %08x",
> - c->index, tag,
> - musb_readw(c->hw_ep->regs, MUSB_TXCSR),
> -
> - musb_readl(&tx->tx_head, 0),
> - musb_readl(&tx->tx_buf, 0),
> - musb_readl(&tx->tx_current, 0),
> - musb_readl(&tx->tx_buf_current, 0),
> -
> - musb_readl(&tx->tx_info, 0),
> - musb_readl(&tx->tx_rem_len, 0),
> - /* dummy/unused word 6 */
> - musb_readl(&tx->tx_complete, 0)
> + "TX DMA%d%s: csr %04x, H%08x S%08x C%08x %08x, F%08x L%08x .. %08x",
> + c->index, tag,
> + musb_readw(c->hw_ep->regs, MUSB_TXCSR),
> +
> + musb_readl(&tx->tx_head, 0),
> + musb_readl(&tx->tx_buf, 0),
> + musb_readl(&tx->tx_current, 0),
> + musb_readl(&tx->tx_buf_current, 0),
> +
> + musb_readl(&tx->tx_info, 0),
> + musb_readl(&tx->tx_rem_len, 0),
> + /* dummy/unused word 6 */
> + musb_readl(&tx->tx_complete, 0)
> );
> }
>
> @@ -592,11 +588,11 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
> }
>
> musb_dbg(musb, "TX DMA%d, pktSz %d %s bds %d dma 0x%llx len %u",
> - tx->index,
> - maxpacket,
> - rndis ? "rndis" : "transparent",
> - n_bds,
> - (unsigned long long)addr, length);
> + tx->index,
> + maxpacket,
> + rndis ? "rndis" : "transparent",
> + n_bds,
> + (unsigned long long)addr, length);
>
> cppi_rndis_update(tx, 0, musb->ctrl_base, rndis);
>
> @@ -649,8 +645,8 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
> }
>
> musb_dbg(musb, "TXBD %p: nxt %08x buf %08x len %04x opt %08x",
> - bd, bd->hw_next, bd->hw_bufp,
> - bd->hw_off_len, bd->hw_options);
> + bd, bd->hw_next, bd->hw_bufp,
> + bd->hw_off_len, bd->hw_options);
>
> /* update the last BD enqueued to the list */
> tx->tail = bd;
> @@ -812,18 +808,17 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
>
> length = min(n_bds * maxpacket, length);
>
> - musb_dbg(musb, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) "
> - "dma 0x%llx len %u %u/%u",
> - rx->index, maxpacket,
> - onepacket
> - ? (is_rndis ? "rndis" : "onepacket")
> - : "multipacket",
> - n_bds,
> - musb_readl(tibase,
> - DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4))
> - & 0xffff,
> - (unsigned long long)addr, length,
> - rx->channel.actual_len, rx->buf_len);
> + musb_dbg(musb, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) dma 0x%llx len %u %u/%u",
> + rx->index, maxpacket,
> + onepacket
> + ? (is_rndis ? "rndis" : "onepacket")
> + : "multipacket",
> + n_bds,
> + musb_readl(tibase,
> + DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4))
> + & 0xffff,
> + (unsigned long long)addr, length,
> + rx->channel.actual_len, rx->buf_len);
>
> /* only queue one segment at a time, since the hardware prevents
> * correct queue shutdown after unexpected short packets
> @@ -863,10 +858,13 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
>
> /* we always expect at least one reusable BD! */
> if (!tail) {
> - WARNING("rx dma%d -- no BDs? need %d\n", rx->index, n_bds);
> + musb_warn(musb, "rx dma%d -- no BDs? need %d",
> + rx->index, n_bds);
> return;
> - } else if (i < n_bds)
> - WARNING("rx dma%d -- only %d of %d BDs\n", rx->index, i, n_bds);
> + }
> + if (i < n_bds)
> + musb_warn(musb, "rx dma%d -- only %d of %d BDs",
> + rx->index, i, n_bds);
>
> tail->next = NULL;
> tail->hw_next = 0;
> @@ -924,7 +922,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
> & 0xffff;
> if (i < (2 + n_bds)) {
> musb_dbg(musb, "bufcnt%d underrun - %d (for %d)",
> - rx->index, i, n_bds);
> + rx->index, i, n_bds);
> musb_writel(tibase,
> DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4),
> n_bds + 2);
> @@ -960,21 +958,21 @@ static int cppi_channel_program(struct dma_channel *ch,
> case MUSB_DMA_STATUS_BUS_ABORT:
> case MUSB_DMA_STATUS_CORE_ABORT:
> /* fault irq handler should have handled cleanup */
> - WARNING("%cX DMA%d not cleaned up after abort!\n",
> - cppi_ch->transmit ? 'T' : 'R',
> - cppi_ch->index);
> + musb_warn(musb, "%cX DMA%d not cleaned up after abort!",
> + cppi_ch->transmit ? 'T' : 'R',
> + cppi_ch->index);
> /* WARN_ON(1); */
> break;
> case MUSB_DMA_STATUS_BUSY:
> - WARNING("program active channel? %cX DMA%d\n",
> - cppi_ch->transmit ? 'T' : 'R',
> - cppi_ch->index);
> + musb_warn(musb, "program active channel? %cX DMA%d",
> + cppi_ch->transmit ? 'T' : 'R',
> + cppi_ch->index);
> /* WARN_ON(1); */
> break;
> case MUSB_DMA_STATUS_UNKNOWN:
> musb_dbg(musb, "%cX DMA%d not allocated!",
> - cppi_ch->transmit ? 'T' : 'R',
> - cppi_ch->index);
> + cppi_ch->transmit ? 'T' : 'R',
> + cppi_ch->index);
> fallthrough;
> case MUSB_DMA_STATUS_FREE:
> break;
> @@ -1028,11 +1026,10 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
> if (!completed && (bd->hw_options & CPPI_OWN_SET))
> break;
>
> - musb_dbg(musb, "C/RXBD %llx: nxt %08x buf %08x "
> - "off.len %08x opt.len %08x (%d)",
> - (unsigned long long)bd->dma, bd->hw_next, bd->hw_bufp,
> - bd->hw_off_len, bd->hw_options,
> - rx->channel.actual_len);
> + musb_dbg(musb, "C/RXBD %llx: nxt %08x buf %08x off.len %08x opt.len %08x (%d)",
> + (unsigned long long)bd->dma, bd->hw_next, bd->hw_bufp,
> + bd->hw_off_len, bd->hw_options,
> + rx->channel.actual_len);
>
> /* actual packet received length */
> if ((bd->hw_options & CPPI_SOP_SET) && !completed)
> @@ -1051,8 +1048,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
> */
> completed = true;
> musb_dbg(musb, "rx short %d/%d (%d)",
> - len, bd->buflen,
> - rx->channel.actual_len);
> + len, bd->buflen, rx->channel.actual_len);
> }
>
> /* If we got here, we expect to ack at least one BD; meanwhile
> @@ -1101,14 +1097,14 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
> csr = musb_readw(regs, MUSB_RXCSR);
> if (csr & MUSB_RXCSR_DMAENAB) {
> musb_dbg(musb, "list%d %p/%p, last %llx%s, csr %04x",
> - rx->index,
> - rx->head, rx->tail,
> - rx->last_processed
> - ? (unsigned long long)
> - rx->last_processed->dma
> - : 0,
> - completed ? ", completed" : "",
> - csr);
> + rx->index,
> + rx->head, rx->tail,
> + rx->last_processed
> + ? (unsigned long long)
> + rx->last_processed->dma
> + : 0,
> + completed ? ", completed" : "",
> + csr);
> cppi_dump_rxq(4, "/what?", rx);
> }
> }
> @@ -1207,8 +1203,8 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
> break;
>
> musb_dbg(musb, "C/TXBD %p n %x b %x off %x opt %x",
> - bd, bd->hw_next, bd->hw_bufp,
> - bd->hw_off_len, bd->hw_options);
> + bd, bd->hw_next, bd->hw_bufp,
> + bd->hw_off_len, bd->hw_options);
>
> len = bd->hw_off_len & CPPI_BUFFER_LEN_MASK;
> tx_ch->channel.actual_len += len;
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index 1c023c0091c4..2bc2924af5d9 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -276,7 +276,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
> - WARNING("VBUS error workaround (delay coming)\n");
> + musb_warn(musb, "VBUS error workaround (delay coming)");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
> index 704435526394..625cd2e07fa6 100644
> --- a/drivers/usb/musb/davinci.c
> +++ b/drivers/usb/musb/davinci.c
> @@ -92,8 +92,7 @@ static void davinci_musb_enable(struct musb *musb)
> musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_SET_REG, tmp);
>
> if (is_dma_capable() && !dma_off)
> - printk(KERN_WARNING "%s %s: dma not reactivated\n",
> - __FILE__, __func__);
> + musb_warn(musb, "dma not reactivated");
> else
> dma_off = 0;
>
> @@ -119,7 +118,7 @@ static void davinci_musb_disable(struct musb *musb)
> musb_writel(musb->ctrl_base, DAVINCI_USB_EOI_REG, 0);
>
> if (is_dma_capable() && !dma_off)
> - WARNING("dma still active\n");
> + musb_warn(musb, "dma still active");
> }
>
>
> @@ -308,7 +307,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
> - WARNING("VBUS error workaround (delay coming)\n");
> + musb_warn(musb, "VBUS error workaround (delay coming)");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 849e0b770130..c6961184afff 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -600,8 +600,7 @@ static void musb_otg_timer_func(struct timer_list *t)
> spin_lock_irqsave(&musb->lock, flags);
> switch (musb->xceiv->otg->state) {
> case OTG_STATE_B_WAIT_ACON:
> - musb_dbg(musb,
> - "HNP: b_wait_acon timeout; back to b_peripheral");
> + musb_dbg(musb, "HNP: b_wait_acon timeout; back to b_peripheral");
> musb_g_disconnect(musb);
> musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb->is_active = 0;
> @@ -609,13 +608,13 @@ static void musb_otg_timer_func(struct timer_list *t)
> case OTG_STATE_A_SUSPEND:
> case OTG_STATE_A_WAIT_BCON:
> musb_dbg(musb, "HNP: %s timeout",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> musb_platform_set_vbus(musb, 0);
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> break;
> default:
> musb_dbg(musb, "HNP: Unhandled mode %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> spin_unlock_irqrestore(&musb->lock, flags);
> }
> @@ -630,13 +629,13 @@ void musb_hnp_stop(struct musb *musb)
> u8 reg;
>
> musb_dbg(musb, "HNP: stop from %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> musb_g_disconnect(musb);
> musb_dbg(musb, "HNP: back to %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> case OTG_STATE_B_HOST:
> musb_dbg(musb, "HNP: Disabling HR");
> @@ -651,7 +650,7 @@ void musb_hnp_stop(struct musb *musb)
> break;
> default:
> musb_dbg(musb, "HNP: Stopping in unknown state %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
>
> /*
> @@ -667,7 +666,7 @@ static void musb_recover_from_babble(struct musb *musb);
> static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
> {
> musb_dbg(musb, "RESUME (%s)",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> if (devctl & MUSB_DEVCTL_HM) {
> switch (musb->xceiv->otg->state) {
> @@ -690,9 +689,8 @@ static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
> MUSB_DEV_MODE(musb);
> break;
> default:
> - WARNING("bogus %s RESUME (%s)\n",
> - "host",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "bogus host RESUME (%s)",
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else {
> switch (musb->xceiv->otg->state) {
> @@ -719,9 +717,8 @@ static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
> musb->int_usb &= ~MUSB_INTR_SUSPEND;
> break;
> default:
> - WARNING("bogus %s RESUME (%s)\n",
> - "peripheral",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "bogus peripheral RESUME (%s)",
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -738,7 +735,7 @@ static irqreturn_t musb_handle_intr_sessreq(struct musb *musb, u8 devctl)
> }
>
> musb_dbg(musb, "SESSION_REQUEST (%s)",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
>
> /* IRQ arrives from ID pin sense or (later, if VBUS power
> * is removed) SRP. responses are time critical:
> @@ -830,7 +827,7 @@ static void musb_handle_intr_vbuserr(struct musb *musb, u8 devctl)
> static void musb_handle_intr_suspend(struct musb *musb, u8 devctl)
> {
> musb_dbg(musb, "SUSPEND (%s) devctl %02x",
> - usb_otg_state_string(musb->xceiv->otg->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
>
> switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_PERIPHERAL:
> @@ -938,14 +935,14 @@ static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb)
> musb_host_poke_root_hub(musb);
>
> musb_dbg(musb, "CONNECT (%s) devctl %02x",
> - usb_otg_state_string(musb->xceiv->otg->state), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state), devctl);
> }
>
> static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
> {
> musb_dbg(musb, "DISCONNECT (%s) as %s, devctl %02x",
> - usb_otg_state_string(musb->xceiv->otg->state),
> - MUSB_MODE(musb), devctl);
> + usb_otg_state_string(musb->xceiv->otg->state),
> + MUSB_MODE(musb), devctl);
>
> switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_HOST:
> @@ -979,8 +976,8 @@ static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
> musb_g_disconnect(musb);
> break;
> default:
> - WARNING("unhandled DISCONNECT transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "unhandled DISCONNECT transition (%s)",
> + usb_otg_state_string(musb->xceiv->otg->state));
> break;
> }
> }
> @@ -1004,7 +1001,7 @@ static void musb_handle_intr_reset(struct musb *musb)
> musb_recover_from_babble(musb);
> } else {
> musb_dbg(musb, "BUS RESET as %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> switch (musb->xceiv->otg->state) {
> case OTG_STATE_A_SUSPEND:
> musb_g_reset(musb);
> @@ -1012,8 +1009,8 @@ static void musb_handle_intr_reset(struct musb *musb)
> case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
> /* never use invalid T(a_wait_bcon) */
> musb_dbg(musb, "HNP: in %s, %d msec timeout",
> - usb_otg_state_string(musb->xceiv->otg->state),
> - TA_WAIT_BCON(musb));
> + usb_otg_state_string(musb->xceiv->otg->state),
> + TA_WAIT_BCON(musb));
> mod_timer(&musb->otg_timer, jiffies
> + msecs_to_jiffies(TA_WAIT_BCON(musb)));
> break;
> @@ -1023,7 +1020,7 @@ static void musb_handle_intr_reset(struct musb *musb)
> break;
> case OTG_STATE_B_WAIT_ACON:
> musb_dbg(musb, "HNP: RESET (%s), to b_peripheral",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
> musb_g_reset(musb);
> break;
> @@ -1035,7 +1032,7 @@ static void musb_handle_intr_reset(struct musb *musb)
> break;
> default:
> musb_dbg(musb, "Unhandled BUS RESET as %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> }
> @@ -1692,19 +1689,19 @@ static int musb_core_init(u16 musb_type, struct musb *musb)
>
> if (hw_ep->max_packet_sz_tx) {
> musb_dbg(musb, "%s: hw_ep %d%s, %smax %d",
> - musb_driver_name, i,
> - hw_ep->is_shared_fifo ? "shared" : "tx",
> - hw_ep->tx_double_buffered
> - ? "doublebuffer, " : "",
> - hw_ep->max_packet_sz_tx);
> + musb_driver_name, i,
> + hw_ep->is_shared_fifo ? "shared" : "tx",
> + hw_ep->tx_double_buffered
> + ? "doublebuffer, " : "",
> + hw_ep->max_packet_sz_tx);
> }
> if (hw_ep->max_packet_sz_rx && !hw_ep->is_shared_fifo) {
> musb_dbg(musb, "%s: hw_ep %d%s, %smax %d",
> - musb_driver_name, i,
> - "rx",
> - hw_ep->rx_double_buffered
> - ? "doublebuffer, " : "",
> - hw_ep->max_packet_sz_rx);
> + musb_driver_name, i,
> + "rx",
> + hw_ep->rx_double_buffered
> + ? "doublebuffer, " : "",
> + hw_ep->max_packet_sz_rx);
> }
> if (!(hw_ep->max_packet_sz_tx || hw_ep->max_packet_sz_rx))
> musb_dbg(musb, "hw_ep %d not configured", i);
> @@ -2004,7 +2001,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
> MUSB_DEVCTL_HR;
> switch (devctl & ~s) {
> case MUSB_QUIRK_B_DISCONNECT_99:
> - musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n");
> + musb_dbg(musb, "Poll devctl in case of suspend after disconnect");
> schedule_delayed_work(&musb->irq_work,
> msecs_to_jiffies(1000));
> break;
> @@ -2048,8 +2045,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
> musb_dbg(musb, "Block PM on active session: %02x", devctl);
> error = pm_runtime_get_sync(musb->controller);
> if (error < 0)
> - dev_err(musb->controller, "Could not enable: %i\n",
> - error);
> + musb_err(musb, "Could not enable: %i", error);
> musb->quirk_retries = 3;
> } else {
> musb_dbg(musb, "Allow PM with no session: %02x", devctl);
> diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
> index 7fbb8a307145..2e8323fd4613 100644
> --- a/drivers/usb/musb/musb_cppi41.c
> +++ b/drivers/usb/musb/musb_cppi41.c
> @@ -91,7 +91,7 @@ static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
> if (!toggle && toggle == cppi41_channel->usb_toggle) {
> csr |= MUSB_RXCSR_H_DATATOGGLE | MUSB_RXCSR_H_WR_DATATOGGLE;
> musb_writew(cppi41_channel->hw_ep->regs, MUSB_RXCSR, csr);
> - musb_dbg(musb, "Restoring DATA1 toggle.");
> + musb_dbg(musb, "Restoring DATA1 toggle");
> }
>
> cppi41_channel->usb_toggle = toggle;
> diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
> index e5b3506c7b3f..8c96428dade5 100644
> --- a/drivers/usb/musb/musb_debug.h
> +++ b/drivers/usb/musb/musb_debug.h
> @@ -10,12 +10,14 @@
> #ifndef __MUSB_LINUX_DEBUG_H__
> #define __MUSB_LINUX_DEBUG_H__
>
> -#define yprintk(facility, format, args...) \
> - do { printk(facility "%s %d: " format , \
> - __func__, __LINE__ , ## args); } while (0)
> -#define WARNING(fmt, args...) yprintk(KERN_WARNING, fmt, ## args)
> -#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
> -#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
> +#define musb_err(musb, fmt, ...) \
> + dev_err((musb)->controller, fmt "\n", ##__VA_ARGS__)
> +#define musb_warn(musb, fmt, ...) \
> + dev_warn((musb)->controller, fmt "\n", ##__VA_ARGS__)
> +#define musb_notice(musb, fmt, ...) \
> + dev_notice((musb)->controller, fmt "\n", ##__VA_ARGS__)
> +#define musb_info(musb, fmt, ...) \
> + dev_info((musb)->controller, fmt "\n", ##__VA_ARGS__)
>
> void musb_dbg(struct musb *musb, const char *fmt, ...);
>
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 5892f3ce0cdc..a045cd85197b 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -366,7 +366,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
> musb->int_usb &= ~MUSB_INTR_VBUSERROR;
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
> dsps_mod_timer_optional(glue);
> - WARNING("VBUS error workaround (delay coming)\n");
> + musb_warn(musb, "VBUS error workaround (delay coming)");
> } else if (drvvbus) {
> MUSB_HST_MODE(musb);
> musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index f62ffaede1ab..f5b76e689fca 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -234,7 +234,7 @@ static void txstate(struct musb *musb, struct musb_request *req)
> /* Check if EP is disabled */
> if (!musb_ep->desc) {
> musb_dbg(musb, "ep:%s disabled - ignore request",
> - musb_ep->end_point.name);
> + musb_ep->end_point.name);
> return;
> }
>
> @@ -252,20 +252,19 @@ static void txstate(struct musb *musb, struct musb_request *req)
> (int)(request->length - request->actual));
>
> if (csr & MUSB_TXCSR_TXPKTRDY) {
> - musb_dbg(musb, "%s old packet still ready , txcsr %03x",
> - musb_ep->end_point.name, csr);
> + musb_dbg(musb, "%s old packet still ready, txcsr %03x",
> + musb_ep->end_point.name, csr);
> return;
> }
>
> if (csr & MUSB_TXCSR_P_SENDSTALL) {
> musb_dbg(musb, "%s stalling, txcsr %03x",
> - musb_ep->end_point.name, csr);
> + musb_ep->end_point.name, csr);
> return;
> }
>
> musb_dbg(musb, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x",
> - epnum, musb_ep->packet_sz, fifo_count,
> - csr);
> + epnum, musb_ep->packet_sz, fifo_count, csr);
>
> #ifndef CONFIG_MUSB_PIO_ONLY
> if (is_buffer_mapped(req)) {
> @@ -392,11 +391,11 @@ static void txstate(struct musb *musb, struct musb_request *req)
>
> /* host may already have the data when this message shows... */
> musb_dbg(musb, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d",
> - musb_ep->end_point.name, use_dma ? "dma" : "pio",
> - request->actual, request->length,
> - musb_readw(epio, MUSB_TXCSR),
> - fifo_count,
> - musb_readw(epio, MUSB_TXMAXP));
> + musb_ep->end_point.name, use_dma ? "dma" : "pio",
> + request->actual, request->length,
> + musb_readw(epio, MUSB_TXCSR),
> + fifo_count,
> + musb_readw(epio, MUSB_TXMAXP));
> }
>
> /*
> @@ -464,7 +463,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
> csr = musb_readw(epio, MUSB_TXCSR);
> request->actual += musb_ep->dma->actual_len;
> musb_dbg(musb, "TXCSR%d %04x, DMA off, len %zu, req %p",
> - epnum, csr, musb_ep->dma->actual_len, request);
> + epnum, csr, musb_ep->dma->actual_len, request);
> }
>
> /*
> @@ -501,7 +500,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
> req = musb_ep->desc ? next_request(musb_ep) : NULL;
> if (!req) {
> musb_dbg(musb, "%s idle now",
> - musb_ep->end_point.name);
> + musb_ep->end_point.name);
> return;
> }
> }
> @@ -537,7 +536,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
> /* Check if EP is disabled */
> if (!musb_ep->desc) {
> musb_dbg(musb, "ep:%s disabled - ignore request",
> - musb_ep->end_point.name);
> + musb_ep->end_point.name);
> return;
> }
>
> @@ -549,7 +548,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
>
> if (csr & MUSB_RXCSR_P_SENDSTALL) {
> musb_dbg(musb, "%s stalling, RXCSR %04x",
> - musb_ep->end_point.name, csr);
> + musb_ep->end_point.name, csr);
> return;
> }
>
> @@ -724,9 +723,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
>
> len = request->length - request->actual;
> musb_dbg(musb, "%s OUT/RX pio fifo %d/%d, maxpacket %d",
> - musb_ep->end_point.name,
> - fifo_count, len,
> - musb_ep->packet_sz);
> + musb_ep->end_point.name,
> + fifo_count, len,
> + musb_ep->packet_sz);
>
> fifo_count = min_t(unsigned, len, fifo_count);
>
> @@ -812,8 +811,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
> csr = musb_readw(epio, MUSB_RXCSR);
> dma = is_dma_capable() ? musb_ep->dma : NULL;
>
> - musb_dbg(musb, "<== %s, rxcsr %04x%s %p", musb_ep->end_point.name,
> - csr, dma ? " (dma)" : "", request);
> + musb_dbg(musb, "<== %s, rxcsr %04x%s %p",
> + musb_ep->end_point.name, csr, dma ? " (dma)" : "", request);
>
> if (csr & MUSB_RXCSR_P_SENTSTALL) {
> csr |= MUSB_RXCSR_P_WZC_BITS;
> @@ -839,7 +838,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)
> if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
> /* "should not happen"; likely RXPKTRDY pending for DMA */
> musb_dbg(musb, "%s busy, csr %04x",
> - musb_ep->end_point.name, csr);
> + musb_ep->end_point.name, csr);
> return;
> }
>
> @@ -1232,8 +1231,8 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
>
> /* don't queue if the ep is down */
> if (!musb_ep->desc) {
> - musb_dbg(musb, "req %p queued to %s while ep %s",
> - req, ep->name, "disabled");
> + musb_dbg(musb, "req %p queued to %s while ep disabled",
> + req, ep->name);
> status = -ESHUTDOWN;
> unmap_dma_buffer(request, musb);
> goto unlock;
> @@ -1349,7 +1348,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value)
> if (value) {
> if (request) {
> musb_dbg(musb, "request in progress, cannot halt %s",
> - ep->name);
> + ep->name);
> status = -EAGAIN;
> goto done;
> }
> @@ -1358,7 +1357,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value)
> csr = musb_readw(epio, MUSB_TXCSR);
> if (csr & MUSB_TXCSR_FIFONOTEMPTY) {
> musb_dbg(musb, "FIFO busy, cannot halt %s",
> - ep->name);
> + ep->name);
> status = -EAGAIN;
> goto done;
> }
> @@ -1559,7 +1558,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
> goto done;
> default:
> musb_dbg(musb, "Unhandled wake: %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> goto done;
> }
>
> @@ -1600,8 +1599,7 @@ static void musb_pullup(struct musb *musb, int is_on)
>
> /* FIXME if on, HdrcStart; if off, HdrcStop */
>
> - musb_dbg(musb, "gadget D+ pullup %s",
> - is_on ? "on" : "off");
> + musb_dbg(musb, "gadget D+ pullup %s", is_on ? "on" : "off");
> musb_writeb(musb->mregs, MUSB_POWER, power);
> }
>
> @@ -1936,8 +1934,8 @@ void musb_g_resume(struct musb *musb)
> }
> break;
> default:
> - WARNING("unhandled RESUME transition (%s)\n",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "unhandled RESUME transition (%s)",
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -1966,8 +1964,8 @@ void musb_g_suspend(struct musb *musb)
> /* REVISIT if B_HOST, clear DEVCTL.HOSTREQ;
> * A_PERIPHERAL may need care too
> */
> - WARNING("unhandled SUSPEND transition (%s)",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "unhandled SUSPEND transition (%s)",
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
>
> @@ -2001,7 +1999,7 @@ void musb_g_disconnect(struct musb *musb)
> switch (musb->xceiv->otg->state) {
> default:
> musb_dbg(musb, "Unhandled disconnect %s, setting a_idle",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> musb->xceiv->otg->state = OTG_STATE_A_IDLE;
> MUSB_HST_MODE(musb);
> break;
> @@ -2031,12 +2029,12 @@ __acquires(musb->lock)
> u8 power;
>
> musb_dbg(musb, "<== %s driver '%s'",
> - (devctl & MUSB_DEVCTL_BDEVICE)
> - ? "B-Device" : "A-Device",
> - musb->gadget_driver
> - ? musb->gadget_driver->driver.name
> - : NULL
> - );
> + (devctl & MUSB_DEVCTL_BDEVICE)
> + ? "B-Device" : "A-Device",
> + musb->gadget_driver
> + ? musb->gadget_driver->driver.name
> + : NULL
> + );
>
> /* report reset, if we didn't already (flushing EP state) */
> if (musb->gadget_driver && musb->g.speed != USB_SPEED_UNKNOWN) {
> diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
> index 6d7336727388..130db182bf09 100644
> --- a/drivers/usb/musb/musb_gadget_ep0.c
> +++ b/drivers/usb/musb/musb_gadget_ep0.c
> @@ -583,11 +583,11 @@ musb_read_setup(struct musb *musb, struct usb_ctrlrequest *req)
> * order, but now USB packets always stay in USB byte order.
> */
> musb_dbg(musb, "SETUP req%02x.%02x v%04x i%04x l%d",
> - req->bRequestType,
> - req->bRequest,
> - le16_to_cpu(req->wValue),
> - le16_to_cpu(req->wIndex),
> - le16_to_cpu(req->wLength));
> + req->bRequestType,
> + req->bRequest,
> + le16_to_cpu(req->wValue),
> + le16_to_cpu(req->wIndex),
> + le16_to_cpu(req->wLength));
>
> /* clean up any leftover transfers */
> r = next_ep0_request(musb);
> @@ -651,7 +651,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
> len = musb_readb(regs, MUSB_COUNT0);
>
> musb_dbg(musb, "csr %04x, count %d, ep0stage %s",
> - csr, len, decode_ep0stage(musb->ep0_state));
> + csr, len, decode_ep0stage(musb->ep0_state));
>
> if (csr & MUSB_CSR0_P_DATAEND) {
> /*
> @@ -683,8 +683,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
> musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;
> break;
> default:
> - ERR("SetupEnd came in a wrong ep0stage %s\n",
> - decode_ep0stage(musb->ep0_state));
> + musb_err(musb, "SetupEnd came in a wrong ep0stage %s",
> + decode_ep0stage(musb->ep0_state));
> }
> csr = musb_readw(regs, MUSB_CSR0);
> /* NOTE: request may need completion */
> @@ -776,7 +776,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
> int handled = 0;
>
> if (len != 8) {
> - ERR("SETUP packet len %d != 8 ?\n", len);
> + musb_err(musb, "SETUP packet len %d != 8 ?",
> + len);
> break;
> }
> musb_read_setup(musb, &setup);
> @@ -786,9 +787,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
> if (unlikely(musb->g.speed == USB_SPEED_UNKNOWN)) {
> u8 power;
>
> - printk(KERN_NOTICE "%s: peripheral reset "
> - "irq lost!\n",
> - musb_driver_name);
> + musb_notice(musb, "peripheral reset irq lost!");
> power = musb_readb(mbase, MUSB_POWER);
> musb->g.speed = (power & MUSB_POWER_HSMODE)
> ? USB_SPEED_HIGH : USB_SPEED_FULL;
> @@ -840,8 +839,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
> }
>
> musb_dbg(musb, "handled %d, csr %04x, ep0stage %s",
> - handled, csr,
> - decode_ep0stage(musb->ep0_state));
> + handled, csr,
> + decode_ep0stage(musb->ep0_state));
>
> /* unless we need to delegate this to the gadget
> * driver, we know how to wrap this up: csr0 has
> @@ -937,7 +936,7 @@ musb_g_ep0_queue(struct usb_ep *e, struct usb_request *r, gfp_t gfp_flags)
> break;
> default:
> musb_dbg(musb, "ep0 request queued in state %d",
> - musb->ep0_state);
> + musb->ep0_state);
> status = -EINVAL;
> goto cleanup;
> }
> @@ -946,8 +945,8 @@ musb_g_ep0_queue(struct usb_ep *e, struct usb_request *r, gfp_t gfp_flags)
> list_add_tail(&req->list, &ep->req_list);
>
> musb_dbg(musb, "queue to %s (%s), length=%d",
> - ep->name, ep->is_in ? "IN/TX" : "OUT/RX",
> - req->request.length);
> + ep->name, ep->is_in ? "IN/TX" : "OUT/RX",
> + req->request.length);
>
> musb_ep_select(musb->mregs, 0);
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 30c5e7de0761..abc2af31dc4e 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -263,8 +263,8 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
> break;
> default:
> start:
> - musb_dbg(musb, "Start TX%d %s", epnum,
> - hw_ep->tx_channel ? "dma" : "pio");
> + musb_dbg(musb, "Start TX%d %s",
> + epnum, hw_ep->tx_channel ? "dma" : "pio");
>
> if (!hw_ep->tx_channel)
> musb_h_tx_start(hw_ep);
> @@ -376,7 +376,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
>
> if (qh != NULL && qh->is_ready) {
> musb_dbg(musb, "... next ep%d %cX urb %p",
> - hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
> + hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
> musb_start_urb(musb, is_in, qh);
> }
> }
> @@ -420,9 +420,10 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err)
>
> /* musb_ep_select(mbase, epnum); */
> rx_count = musb_readw(epio, MUSB_RXCOUNT);
> - musb_dbg(musb, "RX%d count %d, buffer %p len %d/%d", epnum, rx_count,
> - urb->transfer_buffer, qh->offset,
> - urb->transfer_buffer_length);
> + musb_dbg(musb, "RX%d count %d, buffer %p len %d/%d",
> + epnum, rx_count,
> + urb->transfer_buffer, qh->offset,
> + urb->transfer_buffer_length);
>
> /* unload FIFO */
> if (usb_pipeisoc(pipe)) {
> @@ -537,8 +538,8 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, u8 epnum)
> }
> csr = musb_readw(ep->regs, MUSB_RXCSR);
> if (csr & MUSB_RXCSR_RXPKTRDY)
> - WARNING("rx%d, packet/%d ready?\n", ep->epnum,
> - musb_readw(ep->regs, MUSB_RXCOUNT));
> + musb_warn(musb, "rx%d, packet/%d ready?",
> + ep->epnum, musb_readw(ep->regs, MUSB_RXCOUNT));
>
> musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG);
>
> @@ -681,13 +682,12 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
> u8 use_dma = 1;
> u16 csr;
>
> - musb_dbg(musb, "%s hw%d urb %p spd%d dev%d ep%d%s "
> - "h_addr%02x h_port%02x bytes %d",
> - is_out ? "-->" : "<--",
> - epnum, urb, urb->dev->speed,
> - qh->addr_reg, qh->epnum, is_out ? "out" : "in",
> - qh->h_addr_reg, qh->h_port_reg,
> - len);
> + musb_dbg(musb, "%s hw%d urb %p spd%d dev%d ep%d%s h_addr%02x h_port%02x bytes %d",
> + is_out ? "-->" : "<--",
> + epnum, urb, urb->dev->speed,
> + qh->addr_reg, qh->epnum, is_out ? "out" : "in",
> + qh->h_addr_reg, qh->h_port_reg,
> + len);
>
> musb_ep_select(mbase, epnum);
>
> @@ -852,8 +852,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
> if (csr & (MUSB_RXCSR_RXPKTRDY
> | MUSB_RXCSR_DMAENAB
> | MUSB_RXCSR_H_REQPKT))
> - ERR("broken !rx_reinit, ep%d csr %04x\n",
> - hw_ep->epnum, csr);
> + musb_err(musb, "broken !rx_reinit, ep%d csr %04x",
> + hw_ep->epnum, csr);
>
> /* scrub any stale state, leaving toggle alone */
> csr &= MUSB_RXCSR_DISNYET;
> @@ -1028,9 +1028,9 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
> fifo_dest = (u8 *) (urb->transfer_buffer
> + urb->actual_length);
> musb_dbg(musb, "Sending %d byte%s to ep0 fifo %p",
> - fifo_count,
> - (fifo_count == 1) ? "" : "s",
> - fifo_dest);
> + fifo_count,
> + (fifo_count == 1) ? "" : "s",
> + fifo_dest);
> musb_write_fifo(hw_ep, fifo_count, fifo_dest);
>
> urb->actual_length += fifo_count;
> @@ -1038,7 +1038,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
> }
> break;
> default:
> - ERR("bogus ep0 stage %d\n", musb->ep0_stage);
> + musb_err(musb, "bogus ep0 stage %d", musb->ep0_stage);
> break;
> }
>
> @@ -1073,7 +1073,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
> : 0;
>
> musb_dbg(musb, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d",
> - csr, qh, len, urb, musb->ep0_stage);
> + csr, qh, len, urb, musb->ep0_stage);
>
> /* if we just did status stage, we are done */
> if (MUSB_EP0_STATUS == musb->ep0_stage) {
> @@ -1131,7 +1131,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
> if (unlikely(!urb)) {
> /* stop endpoint since we have no place for its data, this
> * SHOULD NEVER HAPPEN! */
> - ERR("no URB for end 0\n");
> + musb_err(musb, "no URB for end 0");
>
> musb_h_ep0_flush_fifo(hw_ep);
> goto done;
> @@ -1220,8 +1220,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
> pipe = urb->pipe;
> dma = is_dma_capable() ? hw_ep->tx_channel : NULL;
> trace_musb_urb_tx(musb, urb);
> - musb_dbg(musb, "OUT/TX%d end, csr %04x%s", epnum, tx_csr,
> - dma ? ", dma" : "");
> + musb_dbg(musb, "OUT/TX%d end, csr %04x%s",
> + epnum, tx_csr, dma ? ", dma" : "");
>
> /* check for errors */
> if (tx_csr & MUSB_TXCSR_H_RXSTALL) {
> @@ -1349,8 +1349,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
> */
> if (tx_csr & (MUSB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) {
> musb_dbg(musb,
> - "DMA complete but FIFO not empty, CSR %04x",
> - tx_csr);
> + "DMA complete but FIFO not empty, CSR %04x",
> + tx_csr);
> return;
> }
> }
> @@ -1635,7 +1635,7 @@ static int musb_rx_dma_in_inventra_cppi41(struct dma_controller *dma,
> urb->error_count++;
> }
> musb_dbg(musb, "** OVERFLOW %d into %d",
> - rx_count, d->length);
> + rx_count, d->length);
>
> length = d->length;
> } else
> @@ -1758,7 +1758,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> * with fifo full. (Only with DMA??)
> */
> musb_dbg(musb, "BOGUS RX%d ready, csr %04x, count %d",
> - epnum, val, musb_readw(epio, MUSB_RXCOUNT));
> + epnum, val, musb_readw(epio, MUSB_RXCOUNT));
> musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG);
> return;
> }
> @@ -1820,7 +1820,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> }
> } else if (rx_csr & MUSB_RXCSR_INCOMPRX) {
> musb_dbg(musb, "end %d high bandwidth incomplete ISO packet RX",
> - epnum);
> + epnum);
> status = -EPROTO;
> }
>
> @@ -1840,7 +1840,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
>
> if (unlikely(dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY)) {
> /* SHOULD NEVER HAPPEN ... but at least DaVinci has done it */
> - ERR("RX%d dma busy, csr %04x\n", epnum, rx_csr);
> + musb_err(musb, "RX%d dma busy, csr %04x", epnum, rx_csr);
> goto finish;
> }
>
> @@ -1864,8 +1864,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> done = true;
> }
>
> - musb_dbg(musb, "RXCSR%d %04x, reqpkt, len %zu%s", epnum, rx_csr,
> - xfer_len, dma ? ", dma" : "");
> + musb_dbg(musb, "RXCSR%d %04x, reqpkt, len %zu%s",
> + epnum, rx_csr, xfer_len, dma ? ", dma" : "");
> rx_csr &= ~MUSB_RXCSR_H_REQPKT;
>
> musb_ep_select(mbase, epnum);
> @@ -1886,10 +1886,10 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> musb_dma_cppi41(musb)) {
> done = musb_rx_dma_inventra_cppi41(c, hw_ep, qh, urb, xfer_len);
> musb_dbg(hw_ep->musb,
> - "ep %d dma %s, rxcsr %04x, rxcount %d",
> - epnum, done ? "off" : "reset",
> - musb_readw(epio, MUSB_RXCSR),
> - musb_readw(epio, MUSB_RXCOUNT));
> + "ep %d dma %s, rxcsr %04x, rxcount %d",
> + epnum, done ? "off" : "reset",
> + musb_readw(epio, MUSB_RXCSR),
> + musb_readw(epio, MUSB_RXCOUNT));
> } else {
> done = true;
> }
> @@ -1898,7 +1898,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> /* if no errors, be sure a packet is ready for unloading */
> if (unlikely(!(rx_csr & MUSB_RXCSR_RXPKTRDY))) {
> status = -EPROTO;
> - ERR("Rx interrupt with no errors or packet!\n");
> + musb_err(musb, "Rx interrupt with no errors or packet!");
>
> /* FIXME this is another "SHOULD NEVER HAPPEN" */
>
> @@ -1914,12 +1914,10 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> if ((musb_dma_inventra(musb) || musb_dma_ux500(musb) ||
> musb_dma_cppi41(musb)) && dma) {
> musb_dbg(hw_ep->musb,
> - "RX%d count %d, buffer 0x%llx len %d/%d",
> - epnum, musb_readw(epio, MUSB_RXCOUNT),
> - (unsigned long long) urb->transfer_dma
> - + urb->actual_length,
> - qh->offset,
> - urb->transfer_buffer_length);
> + "RX%d count %d, buffer 0x%llx len %d/%d",
> + epnum, musb_readw(epio, MUSB_RXCOUNT),
> + (u64)urb->transfer_dma + urb->actual_length,
> + qh->offset, urb->transfer_buffer_length);
>
> if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb,
> xfer_len, iso_err))
> @@ -2324,8 +2322,7 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
> if (dma) {
> status = ep->musb->dma_controller->channel_abort(dma);
> musb_dbg(musb, "abort %cX%d DMA for urb %p --> %d",
> - is_in ? 'R' : 'T', ep->epnum,
> - urb, status);
> + is_in ? 'R' : 'T', ep->epnum, urb, status);
> urb->actual_length += dma->actual_len;
> }
> }
> @@ -2524,11 +2521,12 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> }
>
> if (musb->is_active) {
> - WARNING("trying to suspend as %s while active\n",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + musb_warn(musb, "trying to suspend as %s while active",
> + usb_otg_state_string(musb->xceiv->otg->state));
> return -EBUSY;
> - } else
> - return 0;
> + }
> +
> + return 0;
> }
>
> static int musb_bus_resume(struct usb_hcd *hcd)
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index cafc69536e1d..065fdb8b91e0 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -102,7 +102,7 @@ int musb_port_suspend(struct musb *musb, bool do_suspend)
> break;
> default:
> musb_dbg(musb, "bogus rh suspend? %s",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> } else if (power & MUSB_POWER_SUSPENDM) {
> power &= ~MUSB_POWER_SUSPENDM;
> @@ -221,7 +221,7 @@ void musb_root_disconnect(struct musb *musb)
> break;
> default:
> musb_dbg(musb, "host disconnect (%s)",
> - usb_otg_state_string(musb->xceiv->otg->state));
> + usb_otg_state_string(musb->xceiv->otg->state));
> }
> }
> EXPORT_SYMBOL_GPL(musb_root_disconnect);
> diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> index 0aacfc8be5a1..d8130f58bca3 100644
> --- a/drivers/usb/musb/musbhsdma.c
> +++ b/drivers/usb/musb/musbhsdma.c
> @@ -152,7 +152,7 @@ static void configure_channel(struct dma_channel *channel,
> u16 csr = 0;
>
> musb_dbg(musb, "%p, pkt_sz %d, addr %pad, len %d, mode %d",
> - channel, packet_sz, &dma_addr, len, mode);
> + channel, packet_sz, &dma_addr, len, mode);
>
> if (mode) {
> csr |= 1 << MUSB_HSDMA_MODE1_SHIFT;
> @@ -187,9 +187,9 @@ static int dma_channel_program(struct dma_channel *channel,
> struct musb *musb = controller->private_data;
>
> musb_dbg(musb, "ep%d-%s pkt_sz %d, dma_addr %pad length %d, mode %d",
> - musb_channel->epnum,
> - musb_channel->transmit ? "Tx" : "Rx",
> - packet_sz, &dma_addr, len, mode);
> + musb_channel->epnum,
> + musb_channel->transmit ? "Tx" : "Rx",
> + packet_sz, &dma_addr, len, mode);
>
> BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
> channel->status == MUSB_DMA_STATUS_BUSY);
> @@ -329,12 +329,12 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> - musb_channel->start_addr;
>
> musb_dbg(musb, "ch %p, 0x%x -> 0x%x (%zu / %d) %s",
> - channel, musb_channel->start_addr,
> - addr, channel->actual_len,
> - musb_channel->len,
> - (channel->actual_len
> - < musb_channel->len) ?
> - "=> reconfig 0" : "=> complete");
> + channel, musb_channel->start_addr,
> + addr, channel->actual_len,
> + musb_channel->len,
> + (channel->actual_len
> + < musb_channel->len) ?
> + "=> reconfig 0" : "=> complete");
>
> devctl = musb_readb(mbase, MUSB_DEVCTL);
>
> diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> index c42937692207..4147c361bfc6 100644
> --- a/drivers/usb/musb/tusb6010.c
> +++ b/drivers/usb/musb/tusb6010.c
> @@ -667,8 +667,8 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode)
> otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
> if ((musb_mode == MUSB_PERIPHERAL) &&
> !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS))
> - INFO("Cannot be peripheral with mini-A cable "
> - "otg_stat: %08x\n", otg_stat);
> + musb_info(musb, "Cannot be peripheral with mini-A cable otg_stat: %08x",
> + otg_stat);
>
> return 0;
> }
> @@ -793,7 +793,8 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
> + msecs_to_jiffies(musb->a_wait_bcon);
> } else {
> /* REVISIT report overcurrent to hub? */
> - ERR("vbus too slow, devctl %02x\n", devctl);
> + musb_err(musb, "vbus too slow, devctl %02x",
> + devctl);
> tusb_musb_set_vbus(musb, 0);
> }
> break;
> @@ -957,8 +958,7 @@ static void tusb_musb_enable(struct musb *musb)
> TUSB_INT_SRC_ID_STATUS_CHNG);
>
> if (is_dma_capable() && dma_off)
> - printk(KERN_WARNING "%s %s: dma not reactivated\n",
> - __FILE__, __func__);
> + musb_warn(musb, "dma not reactivated");
> else
> dma_off = 1;
> }
> @@ -981,8 +981,7 @@ static void tusb_musb_disable(struct musb *musb)
> del_timer(&musb->dev_timer);
>
> if (is_dma_capable() && !dma_off) {
> - printk(KERN_WARNING "%s %s: dma still active\n",
> - __FILE__, __func__);
> + musb_warn(musb, "dma still active");
> dma_off = 1;
> }
> }
> @@ -1028,7 +1027,7 @@ static int tusb_musb_start(struct musb *musb)
> if (musb->board_set_power)
> ret = musb->board_set_power(1);
> if (ret != 0) {
> - printk(KERN_ERR "tusb: Cannot enable TUSB6010\n");
> + musb_err(musb, "tusb: Cannot enable TUSB6010");
> return ret;
> }
>
> @@ -1036,15 +1035,15 @@ static int tusb_musb_start(struct musb *musb)
>
> if (musb_readl(tbase, TUSB_PROD_TEST_RESET) !=
> TUSB_PROD_TEST_RESET_VAL) {
> - printk(KERN_ERR "tusb: Unable to detect TUSB6010\n");
> + musb_err(musb, "tusb: Unable to detect TUSB6010");
> goto err;
> }
>
> musb->tusb_revision = tusb_get_revision(musb);
> tusb_print_revision(musb);
> if (musb->tusb_revision < 2) {
> - printk(KERN_ERR "tusb: Unsupported TUSB6010 revision %i\n",
> - musb->tusb_revision);
> + musb_err(musb, "tusb: Unsupported TUSB6010 revision %i",
> + musb->tusb_revision);
> goto err;
> }
>
> @@ -1129,8 +1128,7 @@ static int tusb_musb_init(struct musb *musb)
>
> ret = tusb_musb_start(musb);
> if (ret) {
> - printk(KERN_ERR "Could not start tusb6010 (%d)\n",
> - ret);
> + musb_err(musb, "Could not start tusb6010 (%d)", ret);
> goto done;
> }
> musb->isr = tusb_musb_interrupt;
> diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
> index 60a93b8bbe3c..88f2923cfdc4 100644
> --- a/drivers/usb/musb/tusb6010_omap.c
> +++ b/drivers/usb/musb/tusb6010_omap.c
> @@ -83,8 +83,8 @@ static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat)
> u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP);
>
> if ((reg & 0xf) != chdat->epnum) {
> - printk(KERN_ERR "ep%i trying to release dmareq0 for ep%i\n",
> - chdat->epnum, reg & 0xf);
> + musb_err(chdat->musb, "ep%i trying to release dmareq0 for ep%i",
> + chdat->epnum, reg & 0xf);
> return;
> }
> musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0);
> diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
> index d5cf5e8bb1ca..9979a733954d 100644
> --- a/drivers/usb/musb/ux500_dma.c
> +++ b/drivers/usb/musb/ux500_dma.c
> @@ -323,8 +323,8 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
> NULL);
>
> if (!ux500_channel->dma_chan) {
> - ERR("Dma pipe allocation error dir=%d ch=%d\n",
> - dir, ch_num);
> + musb_err(musb, "Dma pipe allocation error dir=%d ch=%d",
> + dir, ch_num);
>
> /* Release already allocated channels */
> ux500_dma_controller_stop(controller);
>
>
^ permalink raw reply
* Re: [PATCH] usb: musb: add printf attribute to log function
From: Joe Perches @ 2020-12-21 20:33 UTC (permalink / raw)
To: trix, b-liu, gregkh; +Cc: linux-usb, linux-kernel
In-Reply-To: <20201221162547.3756889-1-trix@redhat.com>
On Mon, 2020-12-21 at 08:25 -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> Attributing the function allows the compiler to more thoroughly
> check the use of the function with -Wformat and similar flags.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/usb/musb/musb_debug.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
> index e5b3506c7b3f..dfc0d02695fa 100644
> --- a/drivers/usb/musb/musb_debug.h
> +++ b/drivers/usb/musb/musb_debug.h
> @@ -17,6 +17,7 @@
> #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
> #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
>
>
> +__printf(2, 3)
> void musb_dbg(struct musb *musb, const char *fmt, ...);
Maybe convert all the WARN/INFO/ERR uses to dev_<level> equivalents too?
Use more typical logging styles:
o Add musb_<level> macros that use dev_<level>
o Add struct musb * to musb_<level> calls
o Remove __func__ and __LINE__ uses
o Remove newlines from formats and add to macros for consistency with musb_dbg
o Remove unnecessary newlines from musb_dbg uses
o Coalesce formats and align arguments
---
(compiled x86-64 only, untested)
drivers/usb/musb/am35x.c | 2 +-
drivers/usb/musb/cppi_dma.c | 160 ++++++++++++++++++-------------------
drivers/usb/musb/da8xx.c | 2 +-
drivers/usb/musb/davinci.c | 7 +-
drivers/usb/musb/musb_core.c | 74 ++++++++---------
drivers/usb/musb/musb_cppi41.c | 2 +-
drivers/usb/musb/musb_debug.h | 14 ++--
drivers/usb/musb/musb_dsps.c | 2 +-
drivers/usb/musb/musb_gadget.c | 76 +++++++++---------
drivers/usb/musb/musb_gadget_ep0.c | 33 ++++----
drivers/usb/musb/musb_host.c | 98 +++++++++++------------
drivers/usb/musb/musb_virthub.c | 4 +-
drivers/usb/musb/musbhsdma.c | 20 ++---
drivers/usb/musb/tusb6010.c | 24 +++---
drivers/usb/musb/tusb6010_omap.c | 4 +-
drivers/usb/musb/ux500_dma.c | 4 +-
16 files changed, 256 insertions(+), 270 deletions(-)
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 660641ab1545..39d830e633c1 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -260,7 +260,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
- WARNING("VBUS error workaround (delay coming)\n");
+ musb_warn(musb, "VBUS error workaround (delay coming)");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index edb5b63d7063..021395de3b38 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -317,7 +317,7 @@ cppi_channel_allocate(struct dma_controller *c,
*/
if (cppi_ch->hw_ep)
musb_dbg(musb, "re-allocating DMA%d %cX channel %p",
- index, transmit ? 'T' : 'R', cppi_ch);
+ index, transmit ? 'T' : 'R', cppi_ch);
cppi_ch->hw_ep = ep;
cppi_ch->channel.status = MUSB_DMA_STATUS_FREE;
cppi_ch->channel.max_len = 0x7fffffff;
@@ -338,7 +338,7 @@ static void cppi_channel_release(struct dma_channel *channel)
tibase = c->controller->tibase;
if (!c->hw_ep)
musb_dbg(c->controller->controller.musb,
- "releasing idle DMA channel %p", c);
+ "releasing idle DMA channel %p", c);
else if (!c->transmit)
core_rxirq_enable(tibase, c->index + 1);
@@ -357,23 +357,21 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char *tag)
musb_ep_select(base, c->index + 1);
musb_dbg(c->controller->controller.musb,
- "RX DMA%d%s: %d left, csr %04x, "
- "%08x H%08x S%08x C%08x, "
- "B%08x L%08x %08x .. %08x",
- c->index, tag,
- musb_readl(c->controller->tibase,
- DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index),
- musb_readw(c->hw_ep->regs, MUSB_RXCSR),
-
- musb_readl(&rx->rx_skipbytes, 0),
- musb_readl(&rx->rx_head, 0),
- musb_readl(&rx->rx_sop, 0),
- musb_readl(&rx->rx_current, 0),
-
- musb_readl(&rx->rx_buf_current, 0),
- musb_readl(&rx->rx_len_len, 0),
- musb_readl(&rx->rx_cnt_cnt, 0),
- musb_readl(&rx->rx_complete, 0)
+ "RX DMA%d%s: %d left, csr %04x, %08x H%08x S%08x C%08x, B%08x L%08x %08x .. %08x",
+ c->index, tag,
+ musb_readl(c->controller->tibase,
+ DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index),
+ musb_readw(c->hw_ep->regs, MUSB_RXCSR),
+
+ musb_readl(&rx->rx_skipbytes, 0),
+ musb_readl(&rx->rx_head, 0),
+ musb_readl(&rx->rx_sop, 0),
+ musb_readl(&rx->rx_current, 0),
+
+ musb_readl(&rx->rx_buf_current, 0),
+ musb_readl(&rx->rx_len_len, 0),
+ musb_readl(&rx->rx_cnt_cnt, 0),
+ musb_readl(&rx->rx_complete, 0)
);
}
@@ -387,21 +385,19 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char *tag)
musb_ep_select(base, c->index + 1);
musb_dbg(c->controller->controller.musb,
- "TX DMA%d%s: csr %04x, "
- "H%08x S%08x C%08x %08x, "
- "F%08x L%08x .. %08x",
- c->index, tag,
- musb_readw(c->hw_ep->regs, MUSB_TXCSR),
-
- musb_readl(&tx->tx_head, 0),
- musb_readl(&tx->tx_buf, 0),
- musb_readl(&tx->tx_current, 0),
- musb_readl(&tx->tx_buf_current, 0),
-
- musb_readl(&tx->tx_info, 0),
- musb_readl(&tx->tx_rem_len, 0),
- /* dummy/unused word 6 */
- musb_readl(&tx->tx_complete, 0)
+ "TX DMA%d%s: csr %04x, H%08x S%08x C%08x %08x, F%08x L%08x .. %08x",
+ c->index, tag,
+ musb_readw(c->hw_ep->regs, MUSB_TXCSR),
+
+ musb_readl(&tx->tx_head, 0),
+ musb_readl(&tx->tx_buf, 0),
+ musb_readl(&tx->tx_current, 0),
+ musb_readl(&tx->tx_buf_current, 0),
+
+ musb_readl(&tx->tx_info, 0),
+ musb_readl(&tx->tx_rem_len, 0),
+ /* dummy/unused word 6 */
+ musb_readl(&tx->tx_complete, 0)
);
}
@@ -592,11 +588,11 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
}
musb_dbg(musb, "TX DMA%d, pktSz %d %s bds %d dma 0x%llx len %u",
- tx->index,
- maxpacket,
- rndis ? "rndis" : "transparent",
- n_bds,
- (unsigned long long)addr, length);
+ tx->index,
+ maxpacket,
+ rndis ? "rndis" : "transparent",
+ n_bds,
+ (unsigned long long)addr, length);
cppi_rndis_update(tx, 0, musb->ctrl_base, rndis);
@@ -649,8 +645,8 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
}
musb_dbg(musb, "TXBD %p: nxt %08x buf %08x len %04x opt %08x",
- bd, bd->hw_next, bd->hw_bufp,
- bd->hw_off_len, bd->hw_options);
+ bd, bd->hw_next, bd->hw_bufp,
+ bd->hw_off_len, bd->hw_options);
/* update the last BD enqueued to the list */
tx->tail = bd;
@@ -812,18 +808,17 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
length = min(n_bds * maxpacket, length);
- musb_dbg(musb, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) "
- "dma 0x%llx len %u %u/%u",
- rx->index, maxpacket,
- onepacket
- ? (is_rndis ? "rndis" : "onepacket")
- : "multipacket",
- n_bds,
- musb_readl(tibase,
- DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4))
- & 0xffff,
- (unsigned long long)addr, length,
- rx->channel.actual_len, rx->buf_len);
+ musb_dbg(musb, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) dma 0x%llx len %u %u/%u",
+ rx->index, maxpacket,
+ onepacket
+ ? (is_rndis ? "rndis" : "onepacket")
+ : "multipacket",
+ n_bds,
+ musb_readl(tibase,
+ DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4))
+ & 0xffff,
+ (unsigned long long)addr, length,
+ rx->channel.actual_len, rx->buf_len);
/* only queue one segment at a time, since the hardware prevents
* correct queue shutdown after unexpected short packets
@@ -863,10 +858,13 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
/* we always expect at least one reusable BD! */
if (!tail) {
- WARNING("rx dma%d -- no BDs? need %d\n", rx->index, n_bds);
+ musb_warn(musb, "rx dma%d -- no BDs? need %d",
+ rx->index, n_bds);
return;
- } else if (i < n_bds)
- WARNING("rx dma%d -- only %d of %d BDs\n", rx->index, i, n_bds);
+ }
+ if (i < n_bds)
+ musb_warn(musb, "rx dma%d -- only %d of %d BDs",
+ rx->index, i, n_bds);
tail->next = NULL;
tail->hw_next = 0;
@@ -924,7 +922,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
& 0xffff;
if (i < (2 + n_bds)) {
musb_dbg(musb, "bufcnt%d underrun - %d (for %d)",
- rx->index, i, n_bds);
+ rx->index, i, n_bds);
musb_writel(tibase,
DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4),
n_bds + 2);
@@ -960,21 +958,21 @@ static int cppi_channel_program(struct dma_channel *ch,
case MUSB_DMA_STATUS_BUS_ABORT:
case MUSB_DMA_STATUS_CORE_ABORT:
/* fault irq handler should have handled cleanup */
- WARNING("%cX DMA%d not cleaned up after abort!\n",
- cppi_ch->transmit ? 'T' : 'R',
- cppi_ch->index);
+ musb_warn(musb, "%cX DMA%d not cleaned up after abort!",
+ cppi_ch->transmit ? 'T' : 'R',
+ cppi_ch->index);
/* WARN_ON(1); */
break;
case MUSB_DMA_STATUS_BUSY:
- WARNING("program active channel? %cX DMA%d\n",
- cppi_ch->transmit ? 'T' : 'R',
- cppi_ch->index);
+ musb_warn(musb, "program active channel? %cX DMA%d",
+ cppi_ch->transmit ? 'T' : 'R',
+ cppi_ch->index);
/* WARN_ON(1); */
break;
case MUSB_DMA_STATUS_UNKNOWN:
musb_dbg(musb, "%cX DMA%d not allocated!",
- cppi_ch->transmit ? 'T' : 'R',
- cppi_ch->index);
+ cppi_ch->transmit ? 'T' : 'R',
+ cppi_ch->index);
fallthrough;
case MUSB_DMA_STATUS_FREE:
break;
@@ -1028,11 +1026,10 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
if (!completed && (bd->hw_options & CPPI_OWN_SET))
break;
- musb_dbg(musb, "C/RXBD %llx: nxt %08x buf %08x "
- "off.len %08x opt.len %08x (%d)",
- (unsigned long long)bd->dma, bd->hw_next, bd->hw_bufp,
- bd->hw_off_len, bd->hw_options,
- rx->channel.actual_len);
+ musb_dbg(musb, "C/RXBD %llx: nxt %08x buf %08x off.len %08x opt.len %08x (%d)",
+ (unsigned long long)bd->dma, bd->hw_next, bd->hw_bufp,
+ bd->hw_off_len, bd->hw_options,
+ rx->channel.actual_len);
/* actual packet received length */
if ((bd->hw_options & CPPI_SOP_SET) && !completed)
@@ -1051,8 +1048,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
*/
completed = true;
musb_dbg(musb, "rx short %d/%d (%d)",
- len, bd->buflen,
- rx->channel.actual_len);
+ len, bd->buflen, rx->channel.actual_len);
}
/* If we got here, we expect to ack at least one BD; meanwhile
@@ -1101,14 +1097,14 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
csr = musb_readw(regs, MUSB_RXCSR);
if (csr & MUSB_RXCSR_DMAENAB) {
musb_dbg(musb, "list%d %p/%p, last %llx%s, csr %04x",
- rx->index,
- rx->head, rx->tail,
- rx->last_processed
- ? (unsigned long long)
- rx->last_processed->dma
- : 0,
- completed ? ", completed" : "",
- csr);
+ rx->index,
+ rx->head, rx->tail,
+ rx->last_processed
+ ? (unsigned long long)
+ rx->last_processed->dma
+ : 0,
+ completed ? ", completed" : "",
+ csr);
cppi_dump_rxq(4, "/what?", rx);
}
}
@@ -1207,8 +1203,8 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
break;
musb_dbg(musb, "C/TXBD %p n %x b %x off %x opt %x",
- bd, bd->hw_next, bd->hw_bufp,
- bd->hw_off_len, bd->hw_options);
+ bd, bd->hw_next, bd->hw_bufp,
+ bd->hw_off_len, bd->hw_options);
len = bd->hw_off_len & CPPI_BUFFER_LEN_MASK;
tx_ch->channel.actual_len += len;
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 1c023c0091c4..2bc2924af5d9 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -276,7 +276,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
- WARNING("VBUS error workaround (delay coming)\n");
+ musb_warn(musb, "VBUS error workaround (delay coming)");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 704435526394..625cd2e07fa6 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -92,8 +92,7 @@ static void davinci_musb_enable(struct musb *musb)
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_SET_REG, tmp);
if (is_dma_capable() && !dma_off)
- printk(KERN_WARNING "%s %s: dma not reactivated\n",
- __FILE__, __func__);
+ musb_warn(musb, "dma not reactivated");
else
dma_off = 0;
@@ -119,7 +118,7 @@ static void davinci_musb_disable(struct musb *musb)
musb_writel(musb->ctrl_base, DAVINCI_USB_EOI_REG, 0);
if (is_dma_capable() && !dma_off)
- WARNING("dma still active\n");
+ musb_warn(musb, "dma still active");
}
@@ -308,7 +307,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ);
- WARNING("VBUS error workaround (delay coming)\n");
+ musb_warn(musb, "VBUS error workaround (delay coming)");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 849e0b770130..c6961184afff 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -600,8 +600,7 @@ static void musb_otg_timer_func(struct timer_list *t)
spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->otg->state) {
case OTG_STATE_B_WAIT_ACON:
- musb_dbg(musb,
- "HNP: b_wait_acon timeout; back to b_peripheral");
+ musb_dbg(musb, "HNP: b_wait_acon timeout; back to b_peripheral");
musb_g_disconnect(musb);
musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
@@ -609,13 +608,13 @@ static void musb_otg_timer_func(struct timer_list *t)
case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON:
musb_dbg(musb, "HNP: %s timeout",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb_platform_set_vbus(musb, 0);
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break;
default:
musb_dbg(musb, "HNP: Unhandled mode %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -630,13 +629,13 @@ void musb_hnp_stop(struct musb *musb)
u8 reg;
musb_dbg(musb, "HNP: stop from %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
musb_g_disconnect(musb);
musb_dbg(musb, "HNP: back to %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
case OTG_STATE_B_HOST:
musb_dbg(musb, "HNP: Disabling HR");
@@ -651,7 +650,7 @@ void musb_hnp_stop(struct musb *musb)
break;
default:
musb_dbg(musb, "HNP: Stopping in unknown state %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
/*
@@ -667,7 +666,7 @@ static void musb_recover_from_babble(struct musb *musb);
static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
{
musb_dbg(musb, "RESUME (%s)",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
if (devctl & MUSB_DEVCTL_HM) {
switch (musb->xceiv->otg->state) {
@@ -690,9 +689,8 @@ static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
MUSB_DEV_MODE(musb);
break;
default:
- WARNING("bogus %s RESUME (%s)\n",
- "host",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "bogus host RESUME (%s)",
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else {
switch (musb->xceiv->otg->state) {
@@ -719,9 +717,8 @@ static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
musb->int_usb &= ~MUSB_INTR_SUSPEND;
break;
default:
- WARNING("bogus %s RESUME (%s)\n",
- "peripheral",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "bogus peripheral RESUME (%s)",
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -738,7 +735,7 @@ static irqreturn_t musb_handle_intr_sessreq(struct musb *musb, u8 devctl)
}
musb_dbg(musb, "SESSION_REQUEST (%s)",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
/* IRQ arrives from ID pin sense or (later, if VBUS power
* is removed) SRP. responses are time critical:
@@ -830,7 +827,7 @@ static void musb_handle_intr_vbuserr(struct musb *musb, u8 devctl)
static void musb_handle_intr_suspend(struct musb *musb, u8 devctl)
{
musb_dbg(musb, "SUSPEND (%s) devctl %02x",
- usb_otg_state_string(musb->xceiv->otg->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL:
@@ -938,14 +935,14 @@ static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb)
musb_host_poke_root_hub(musb);
musb_dbg(musb, "CONNECT (%s) devctl %02x",
- usb_otg_state_string(musb->xceiv->otg->state), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state), devctl);
}
static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
{
musb_dbg(musb, "DISCONNECT (%s) as %s, devctl %02x",
- usb_otg_state_string(musb->xceiv->otg->state),
- MUSB_MODE(musb), devctl);
+ usb_otg_state_string(musb->xceiv->otg->state),
+ MUSB_MODE(musb), devctl);
switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST:
@@ -979,8 +976,8 @@ static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
musb_g_disconnect(musb);
break;
default:
- WARNING("unhandled DISCONNECT transition (%s)\n",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "unhandled DISCONNECT transition (%s)",
+ usb_otg_state_string(musb->xceiv->otg->state));
break;
}
}
@@ -1004,7 +1001,7 @@ static void musb_handle_intr_reset(struct musb *musb)
musb_recover_from_babble(musb);
} else {
musb_dbg(musb, "BUS RESET as %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND:
musb_g_reset(musb);
@@ -1012,8 +1009,8 @@ static void musb_handle_intr_reset(struct musb *musb)
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
/* never use invalid T(a_wait_bcon) */
musb_dbg(musb, "HNP: in %s, %d msec timeout",
- usb_otg_state_string(musb->xceiv->otg->state),
- TA_WAIT_BCON(musb));
+ usb_otg_state_string(musb->xceiv->otg->state),
+ TA_WAIT_BCON(musb));
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(TA_WAIT_BCON(musb)));
break;
@@ -1023,7 +1020,7 @@ static void musb_handle_intr_reset(struct musb *musb)
break;
case OTG_STATE_B_WAIT_ACON:
musb_dbg(musb, "HNP: RESET (%s), to b_peripheral",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb_g_reset(musb);
break;
@@ -1035,7 +1032,7 @@ static void musb_handle_intr_reset(struct musb *musb)
break;
default:
musb_dbg(musb, "Unhandled BUS RESET as %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
}
@@ -1692,19 +1689,19 @@ static int musb_core_init(u16 musb_type, struct musb *musb)
if (hw_ep->max_packet_sz_tx) {
musb_dbg(musb, "%s: hw_ep %d%s, %smax %d",
- musb_driver_name, i,
- hw_ep->is_shared_fifo ? "shared" : "tx",
- hw_ep->tx_double_buffered
- ? "doublebuffer, " : "",
- hw_ep->max_packet_sz_tx);
+ musb_driver_name, i,
+ hw_ep->is_shared_fifo ? "shared" : "tx",
+ hw_ep->tx_double_buffered
+ ? "doublebuffer, " : "",
+ hw_ep->max_packet_sz_tx);
}
if (hw_ep->max_packet_sz_rx && !hw_ep->is_shared_fifo) {
musb_dbg(musb, "%s: hw_ep %d%s, %smax %d",
- musb_driver_name, i,
- "rx",
- hw_ep->rx_double_buffered
- ? "doublebuffer, " : "",
- hw_ep->max_packet_sz_rx);
+ musb_driver_name, i,
+ "rx",
+ hw_ep->rx_double_buffered
+ ? "doublebuffer, " : "",
+ hw_ep->max_packet_sz_rx);
}
if (!(hw_ep->max_packet_sz_tx || hw_ep->max_packet_sz_rx))
musb_dbg(musb, "hw_ep %d not configured", i);
@@ -2004,7 +2001,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
MUSB_DEVCTL_HR;
switch (devctl & ~s) {
case MUSB_QUIRK_B_DISCONNECT_99:
- musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n");
+ musb_dbg(musb, "Poll devctl in case of suspend after disconnect");
schedule_delayed_work(&musb->irq_work,
msecs_to_jiffies(1000));
break;
@@ -2048,8 +2045,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
musb_dbg(musb, "Block PM on active session: %02x", devctl);
error = pm_runtime_get_sync(musb->controller);
if (error < 0)
- dev_err(musb->controller, "Could not enable: %i\n",
- error);
+ musb_err(musb, "Could not enable: %i", error);
musb->quirk_retries = 3;
} else {
musb_dbg(musb, "Allow PM with no session: %02x", devctl);
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 7fbb8a307145..2e8323fd4613 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -91,7 +91,7 @@ static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
if (!toggle && toggle == cppi41_channel->usb_toggle) {
csr |= MUSB_RXCSR_H_DATATOGGLE | MUSB_RXCSR_H_WR_DATATOGGLE;
musb_writew(cppi41_channel->hw_ep->regs, MUSB_RXCSR, csr);
- musb_dbg(musb, "Restoring DATA1 toggle.");
+ musb_dbg(musb, "Restoring DATA1 toggle");
}
cppi41_channel->usb_toggle = toggle;
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index e5b3506c7b3f..8c96428dade5 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -10,12 +10,14 @@
#ifndef __MUSB_LINUX_DEBUG_H__
#define __MUSB_LINUX_DEBUG_H__
-#define yprintk(facility, format, args...) \
- do { printk(facility "%s %d: " format , \
- __func__, __LINE__ , ## args); } while (0)
-#define WARNING(fmt, args...) yprintk(KERN_WARNING, fmt, ## args)
-#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
-#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
+#define musb_err(musb, fmt, ...) \
+ dev_err((musb)->controller, fmt "\n", ##__VA_ARGS__)
+#define musb_warn(musb, fmt, ...) \
+ dev_warn((musb)->controller, fmt "\n", ##__VA_ARGS__)
+#define musb_notice(musb, fmt, ...) \
+ dev_notice((musb)->controller, fmt "\n", ##__VA_ARGS__)
+#define musb_info(musb, fmt, ...) \
+ dev_info((musb)->controller, fmt "\n", ##__VA_ARGS__)
void musb_dbg(struct musb *musb, const char *fmt, ...);
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 5892f3ce0cdc..a045cd85197b 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -366,7 +366,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
dsps_mod_timer_optional(glue);
- WARNING("VBUS error workaround (delay coming)\n");
+ musb_warn(musb, "VBUS error workaround (delay coming)");
} else if (drvvbus) {
MUSB_HST_MODE(musb);
musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index f62ffaede1ab..f5b76e689fca 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -234,7 +234,7 @@ static void txstate(struct musb *musb, struct musb_request *req)
/* Check if EP is disabled */
if (!musb_ep->desc) {
musb_dbg(musb, "ep:%s disabled - ignore request",
- musb_ep->end_point.name);
+ musb_ep->end_point.name);
return;
}
@@ -252,20 +252,19 @@ static void txstate(struct musb *musb, struct musb_request *req)
(int)(request->length - request->actual));
if (csr & MUSB_TXCSR_TXPKTRDY) {
- musb_dbg(musb, "%s old packet still ready , txcsr %03x",
- musb_ep->end_point.name, csr);
+ musb_dbg(musb, "%s old packet still ready, txcsr %03x",
+ musb_ep->end_point.name, csr);
return;
}
if (csr & MUSB_TXCSR_P_SENDSTALL) {
musb_dbg(musb, "%s stalling, txcsr %03x",
- musb_ep->end_point.name, csr);
+ musb_ep->end_point.name, csr);
return;
}
musb_dbg(musb, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x",
- epnum, musb_ep->packet_sz, fifo_count,
- csr);
+ epnum, musb_ep->packet_sz, fifo_count, csr);
#ifndef CONFIG_MUSB_PIO_ONLY
if (is_buffer_mapped(req)) {
@@ -392,11 +391,11 @@ static void txstate(struct musb *musb, struct musb_request *req)
/* host may already have the data when this message shows... */
musb_dbg(musb, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d",
- musb_ep->end_point.name, use_dma ? "dma" : "pio",
- request->actual, request->length,
- musb_readw(epio, MUSB_TXCSR),
- fifo_count,
- musb_readw(epio, MUSB_TXMAXP));
+ musb_ep->end_point.name, use_dma ? "dma" : "pio",
+ request->actual, request->length,
+ musb_readw(epio, MUSB_TXCSR),
+ fifo_count,
+ musb_readw(epio, MUSB_TXMAXP));
}
/*
@@ -464,7 +463,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
csr = musb_readw(epio, MUSB_TXCSR);
request->actual += musb_ep->dma->actual_len;
musb_dbg(musb, "TXCSR%d %04x, DMA off, len %zu, req %p",
- epnum, csr, musb_ep->dma->actual_len, request);
+ epnum, csr, musb_ep->dma->actual_len, request);
}
/*
@@ -501,7 +500,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
req = musb_ep->desc ? next_request(musb_ep) : NULL;
if (!req) {
musb_dbg(musb, "%s idle now",
- musb_ep->end_point.name);
+ musb_ep->end_point.name);
return;
}
}
@@ -537,7 +536,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
/* Check if EP is disabled */
if (!musb_ep->desc) {
musb_dbg(musb, "ep:%s disabled - ignore request",
- musb_ep->end_point.name);
+ musb_ep->end_point.name);
return;
}
@@ -549,7 +548,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
if (csr & MUSB_RXCSR_P_SENDSTALL) {
musb_dbg(musb, "%s stalling, RXCSR %04x",
- musb_ep->end_point.name, csr);
+ musb_ep->end_point.name, csr);
return;
}
@@ -724,9 +723,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
len = request->length - request->actual;
musb_dbg(musb, "%s OUT/RX pio fifo %d/%d, maxpacket %d",
- musb_ep->end_point.name,
- fifo_count, len,
- musb_ep->packet_sz);
+ musb_ep->end_point.name,
+ fifo_count, len,
+ musb_ep->packet_sz);
fifo_count = min_t(unsigned, len, fifo_count);
@@ -812,8 +811,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
csr = musb_readw(epio, MUSB_RXCSR);
dma = is_dma_capable() ? musb_ep->dma : NULL;
- musb_dbg(musb, "<== %s, rxcsr %04x%s %p", musb_ep->end_point.name,
- csr, dma ? " (dma)" : "", request);
+ musb_dbg(musb, "<== %s, rxcsr %04x%s %p",
+ musb_ep->end_point.name, csr, dma ? " (dma)" : "", request);
if (csr & MUSB_RXCSR_P_SENTSTALL) {
csr |= MUSB_RXCSR_P_WZC_BITS;
@@ -839,7 +838,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)
if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
/* "should not happen"; likely RXPKTRDY pending for DMA */
musb_dbg(musb, "%s busy, csr %04x",
- musb_ep->end_point.name, csr);
+ musb_ep->end_point.name, csr);
return;
}
@@ -1232,8 +1231,8 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
/* don't queue if the ep is down */
if (!musb_ep->desc) {
- musb_dbg(musb, "req %p queued to %s while ep %s",
- req, ep->name, "disabled");
+ musb_dbg(musb, "req %p queued to %s while ep disabled",
+ req, ep->name);
status = -ESHUTDOWN;
unmap_dma_buffer(request, musb);
goto unlock;
@@ -1349,7 +1348,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value)
if (value) {
if (request) {
musb_dbg(musb, "request in progress, cannot halt %s",
- ep->name);
+ ep->name);
status = -EAGAIN;
goto done;
}
@@ -1358,7 +1357,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value)
csr = musb_readw(epio, MUSB_TXCSR);
if (csr & MUSB_TXCSR_FIFONOTEMPTY) {
musb_dbg(musb, "FIFO busy, cannot halt %s",
- ep->name);
+ ep->name);
status = -EAGAIN;
goto done;
}
@@ -1559,7 +1558,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done;
default:
musb_dbg(musb, "Unhandled wake: %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
goto done;
}
@@ -1600,8 +1599,7 @@ static void musb_pullup(struct musb *musb, int is_on)
/* FIXME if on, HdrcStart; if off, HdrcStop */
- musb_dbg(musb, "gadget D+ pullup %s",
- is_on ? "on" : "off");
+ musb_dbg(musb, "gadget D+ pullup %s", is_on ? "on" : "off");
musb_writeb(musb->mregs, MUSB_POWER, power);
}
@@ -1936,8 +1934,8 @@ void musb_g_resume(struct musb *musb)
}
break;
default:
- WARNING("unhandled RESUME transition (%s)\n",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "unhandled RESUME transition (%s)",
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
@@ -1966,8 +1964,8 @@ void musb_g_suspend(struct musb *musb)
/* REVISIT if B_HOST, clear DEVCTL.HOSTREQ;
* A_PERIPHERAL may need care too
*/
- WARNING("unhandled SUSPEND transition (%s)",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "unhandled SUSPEND transition (%s)",
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
@@ -2001,7 +1999,7 @@ void musb_g_disconnect(struct musb *musb)
switch (musb->xceiv->otg->state) {
default:
musb_dbg(musb, "Unhandled disconnect %s, setting a_idle",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb);
break;
@@ -2031,12 +2029,12 @@ __acquires(musb->lock)
u8 power;
musb_dbg(musb, "<== %s driver '%s'",
- (devctl & MUSB_DEVCTL_BDEVICE)
- ? "B-Device" : "A-Device",
- musb->gadget_driver
- ? musb->gadget_driver->driver.name
- : NULL
- );
+ (devctl & MUSB_DEVCTL_BDEVICE)
+ ? "B-Device" : "A-Device",
+ musb->gadget_driver
+ ? musb->gadget_driver->driver.name
+ : NULL
+ );
/* report reset, if we didn't already (flushing EP state) */
if (musb->gadget_driver && musb->g.speed != USB_SPEED_UNKNOWN) {
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 6d7336727388..130db182bf09 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -583,11 +583,11 @@ musb_read_setup(struct musb *musb, struct usb_ctrlrequest *req)
* order, but now USB packets always stay in USB byte order.
*/
musb_dbg(musb, "SETUP req%02x.%02x v%04x i%04x l%d",
- req->bRequestType,
- req->bRequest,
- le16_to_cpu(req->wValue),
- le16_to_cpu(req->wIndex),
- le16_to_cpu(req->wLength));
+ req->bRequestType,
+ req->bRequest,
+ le16_to_cpu(req->wValue),
+ le16_to_cpu(req->wIndex),
+ le16_to_cpu(req->wLength));
/* clean up any leftover transfers */
r = next_ep0_request(musb);
@@ -651,7 +651,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
len = musb_readb(regs, MUSB_COUNT0);
musb_dbg(musb, "csr %04x, count %d, ep0stage %s",
- csr, len, decode_ep0stage(musb->ep0_state));
+ csr, len, decode_ep0stage(musb->ep0_state));
if (csr & MUSB_CSR0_P_DATAEND) {
/*
@@ -683,8 +683,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;
break;
default:
- ERR("SetupEnd came in a wrong ep0stage %s\n",
- decode_ep0stage(musb->ep0_state));
+ musb_err(musb, "SetupEnd came in a wrong ep0stage %s",
+ decode_ep0stage(musb->ep0_state));
}
csr = musb_readw(regs, MUSB_CSR0);
/* NOTE: request may need completion */
@@ -776,7 +776,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
int handled = 0;
if (len != 8) {
- ERR("SETUP packet len %d != 8 ?\n", len);
+ musb_err(musb, "SETUP packet len %d != 8 ?",
+ len);
break;
}
musb_read_setup(musb, &setup);
@@ -786,9 +787,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
if (unlikely(musb->g.speed == USB_SPEED_UNKNOWN)) {
u8 power;
- printk(KERN_NOTICE "%s: peripheral reset "
- "irq lost!\n",
- musb_driver_name);
+ musb_notice(musb, "peripheral reset irq lost!");
power = musb_readb(mbase, MUSB_POWER);
musb->g.speed = (power & MUSB_POWER_HSMODE)
? USB_SPEED_HIGH : USB_SPEED_FULL;
@@ -840,8 +839,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
}
musb_dbg(musb, "handled %d, csr %04x, ep0stage %s",
- handled, csr,
- decode_ep0stage(musb->ep0_state));
+ handled, csr,
+ decode_ep0stage(musb->ep0_state));
/* unless we need to delegate this to the gadget
* driver, we know how to wrap this up: csr0 has
@@ -937,7 +936,7 @@ musb_g_ep0_queue(struct usb_ep *e, struct usb_request *r, gfp_t gfp_flags)
break;
default:
musb_dbg(musb, "ep0 request queued in state %d",
- musb->ep0_state);
+ musb->ep0_state);
status = -EINVAL;
goto cleanup;
}
@@ -946,8 +945,8 @@ musb_g_ep0_queue(struct usb_ep *e, struct usb_request *r, gfp_t gfp_flags)
list_add_tail(&req->list, &ep->req_list);
musb_dbg(musb, "queue to %s (%s), length=%d",
- ep->name, ep->is_in ? "IN/TX" : "OUT/RX",
- req->request.length);
+ ep->name, ep->is_in ? "IN/TX" : "OUT/RX",
+ req->request.length);
musb_ep_select(musb->mregs, 0);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 30c5e7de0761..abc2af31dc4e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -263,8 +263,8 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
break;
default:
start:
- musb_dbg(musb, "Start TX%d %s", epnum,
- hw_ep->tx_channel ? "dma" : "pio");
+ musb_dbg(musb, "Start TX%d %s",
+ epnum, hw_ep->tx_channel ? "dma" : "pio");
if (!hw_ep->tx_channel)
musb_h_tx_start(hw_ep);
@@ -376,7 +376,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
if (qh != NULL && qh->is_ready) {
musb_dbg(musb, "... next ep%d %cX urb %p",
- hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
+ hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
musb_start_urb(musb, is_in, qh);
}
}
@@ -420,9 +420,10 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err)
/* musb_ep_select(mbase, epnum); */
rx_count = musb_readw(epio, MUSB_RXCOUNT);
- musb_dbg(musb, "RX%d count %d, buffer %p len %d/%d", epnum, rx_count,
- urb->transfer_buffer, qh->offset,
- urb->transfer_buffer_length);
+ musb_dbg(musb, "RX%d count %d, buffer %p len %d/%d",
+ epnum, rx_count,
+ urb->transfer_buffer, qh->offset,
+ urb->transfer_buffer_length);
/* unload FIFO */
if (usb_pipeisoc(pipe)) {
@@ -537,8 +538,8 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, u8 epnum)
}
csr = musb_readw(ep->regs, MUSB_RXCSR);
if (csr & MUSB_RXCSR_RXPKTRDY)
- WARNING("rx%d, packet/%d ready?\n", ep->epnum,
- musb_readw(ep->regs, MUSB_RXCOUNT));
+ musb_warn(musb, "rx%d, packet/%d ready?",
+ ep->epnum, musb_readw(ep->regs, MUSB_RXCOUNT));
musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG);
@@ -681,13 +682,12 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
u8 use_dma = 1;
u16 csr;
- musb_dbg(musb, "%s hw%d urb %p spd%d dev%d ep%d%s "
- "h_addr%02x h_port%02x bytes %d",
- is_out ? "-->" : "<--",
- epnum, urb, urb->dev->speed,
- qh->addr_reg, qh->epnum, is_out ? "out" : "in",
- qh->h_addr_reg, qh->h_port_reg,
- len);
+ musb_dbg(musb, "%s hw%d urb %p spd%d dev%d ep%d%s h_addr%02x h_port%02x bytes %d",
+ is_out ? "-->" : "<--",
+ epnum, urb, urb->dev->speed,
+ qh->addr_reg, qh->epnum, is_out ? "out" : "in",
+ qh->h_addr_reg, qh->h_port_reg,
+ len);
musb_ep_select(mbase, epnum);
@@ -852,8 +852,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
if (csr & (MUSB_RXCSR_RXPKTRDY
| MUSB_RXCSR_DMAENAB
| MUSB_RXCSR_H_REQPKT))
- ERR("broken !rx_reinit, ep%d csr %04x\n",
- hw_ep->epnum, csr);
+ musb_err(musb, "broken !rx_reinit, ep%d csr %04x",
+ hw_ep->epnum, csr);
/* scrub any stale state, leaving toggle alone */
csr &= MUSB_RXCSR_DISNYET;
@@ -1028,9 +1028,9 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
fifo_dest = (u8 *) (urb->transfer_buffer
+ urb->actual_length);
musb_dbg(musb, "Sending %d byte%s to ep0 fifo %p",
- fifo_count,
- (fifo_count == 1) ? "" : "s",
- fifo_dest);
+ fifo_count,
+ (fifo_count == 1) ? "" : "s",
+ fifo_dest);
musb_write_fifo(hw_ep, fifo_count, fifo_dest);
urb->actual_length += fifo_count;
@@ -1038,7 +1038,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
}
break;
default:
- ERR("bogus ep0 stage %d\n", musb->ep0_stage);
+ musb_err(musb, "bogus ep0 stage %d", musb->ep0_stage);
break;
}
@@ -1073,7 +1073,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
: 0;
musb_dbg(musb, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d",
- csr, qh, len, urb, musb->ep0_stage);
+ csr, qh, len, urb, musb->ep0_stage);
/* if we just did status stage, we are done */
if (MUSB_EP0_STATUS == musb->ep0_stage) {
@@ -1131,7 +1131,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
if (unlikely(!urb)) {
/* stop endpoint since we have no place for its data, this
* SHOULD NEVER HAPPEN! */
- ERR("no URB for end 0\n");
+ musb_err(musb, "no URB for end 0");
musb_h_ep0_flush_fifo(hw_ep);
goto done;
@@ -1220,8 +1220,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
pipe = urb->pipe;
dma = is_dma_capable() ? hw_ep->tx_channel : NULL;
trace_musb_urb_tx(musb, urb);
- musb_dbg(musb, "OUT/TX%d end, csr %04x%s", epnum, tx_csr,
- dma ? ", dma" : "");
+ musb_dbg(musb, "OUT/TX%d end, csr %04x%s",
+ epnum, tx_csr, dma ? ", dma" : "");
/* check for errors */
if (tx_csr & MUSB_TXCSR_H_RXSTALL) {
@@ -1349,8 +1349,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
*/
if (tx_csr & (MUSB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) {
musb_dbg(musb,
- "DMA complete but FIFO not empty, CSR %04x",
- tx_csr);
+ "DMA complete but FIFO not empty, CSR %04x",
+ tx_csr);
return;
}
}
@@ -1635,7 +1635,7 @@ static int musb_rx_dma_in_inventra_cppi41(struct dma_controller *dma,
urb->error_count++;
}
musb_dbg(musb, "** OVERFLOW %d into %d",
- rx_count, d->length);
+ rx_count, d->length);
length = d->length;
} else
@@ -1758,7 +1758,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
* with fifo full. (Only with DMA??)
*/
musb_dbg(musb, "BOGUS RX%d ready, csr %04x, count %d",
- epnum, val, musb_readw(epio, MUSB_RXCOUNT));
+ epnum, val, musb_readw(epio, MUSB_RXCOUNT));
musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG);
return;
}
@@ -1820,7 +1820,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
}
} else if (rx_csr & MUSB_RXCSR_INCOMPRX) {
musb_dbg(musb, "end %d high bandwidth incomplete ISO packet RX",
- epnum);
+ epnum);
status = -EPROTO;
}
@@ -1840,7 +1840,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
if (unlikely(dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY)) {
/* SHOULD NEVER HAPPEN ... but at least DaVinci has done it */
- ERR("RX%d dma busy, csr %04x\n", epnum, rx_csr);
+ musb_err(musb, "RX%d dma busy, csr %04x", epnum, rx_csr);
goto finish;
}
@@ -1864,8 +1864,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
done = true;
}
- musb_dbg(musb, "RXCSR%d %04x, reqpkt, len %zu%s", epnum, rx_csr,
- xfer_len, dma ? ", dma" : "");
+ musb_dbg(musb, "RXCSR%d %04x, reqpkt, len %zu%s",
+ epnum, rx_csr, xfer_len, dma ? ", dma" : "");
rx_csr &= ~MUSB_RXCSR_H_REQPKT;
musb_ep_select(mbase, epnum);
@@ -1886,10 +1886,10 @@ void musb_host_rx(struct musb *musb, u8 epnum)
musb_dma_cppi41(musb)) {
done = musb_rx_dma_inventra_cppi41(c, hw_ep, qh, urb, xfer_len);
musb_dbg(hw_ep->musb,
- "ep %d dma %s, rxcsr %04x, rxcount %d",
- epnum, done ? "off" : "reset",
- musb_readw(epio, MUSB_RXCSR),
- musb_readw(epio, MUSB_RXCOUNT));
+ "ep %d dma %s, rxcsr %04x, rxcount %d",
+ epnum, done ? "off" : "reset",
+ musb_readw(epio, MUSB_RXCSR),
+ musb_readw(epio, MUSB_RXCOUNT));
} else {
done = true;
}
@@ -1898,7 +1898,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
/* if no errors, be sure a packet is ready for unloading */
if (unlikely(!(rx_csr & MUSB_RXCSR_RXPKTRDY))) {
status = -EPROTO;
- ERR("Rx interrupt with no errors or packet!\n");
+ musb_err(musb, "Rx interrupt with no errors or packet!");
/* FIXME this is another "SHOULD NEVER HAPPEN" */
@@ -1914,12 +1914,10 @@ void musb_host_rx(struct musb *musb, u8 epnum)
if ((musb_dma_inventra(musb) || musb_dma_ux500(musb) ||
musb_dma_cppi41(musb)) && dma) {
musb_dbg(hw_ep->musb,
- "RX%d count %d, buffer 0x%llx len %d/%d",
- epnum, musb_readw(epio, MUSB_RXCOUNT),
- (unsigned long long) urb->transfer_dma
- + urb->actual_length,
- qh->offset,
- urb->transfer_buffer_length);
+ "RX%d count %d, buffer 0x%llx len %d/%d",
+ epnum, musb_readw(epio, MUSB_RXCOUNT),
+ (u64)urb->transfer_dma + urb->actual_length,
+ qh->offset, urb->transfer_buffer_length);
if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb,
xfer_len, iso_err))
@@ -2324,8 +2322,7 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
if (dma) {
status = ep->musb->dma_controller->channel_abort(dma);
musb_dbg(musb, "abort %cX%d DMA for urb %p --> %d",
- is_in ? 'R' : 'T', ep->epnum,
- urb, status);
+ is_in ? 'R' : 'T', ep->epnum, urb, status);
urb->actual_length += dma->actual_len;
}
}
@@ -2524,11 +2521,12 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
}
if (musb->is_active) {
- WARNING("trying to suspend as %s while active\n",
- usb_otg_state_string(musb->xceiv->otg->state));
+ musb_warn(musb, "trying to suspend as %s while active",
+ usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY;
- } else
- return 0;
+ }
+
+ return 0;
}
static int musb_bus_resume(struct usb_hcd *hcd)
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index cafc69536e1d..065fdb8b91e0 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -102,7 +102,7 @@ int musb_port_suspend(struct musb *musb, bool do_suspend)
break;
default:
musb_dbg(musb, "bogus rh suspend? %s",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
} else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM;
@@ -221,7 +221,7 @@ void musb_root_disconnect(struct musb *musb)
break;
default:
musb_dbg(musb, "host disconnect (%s)",
- usb_otg_state_string(musb->xceiv->otg->state));
+ usb_otg_state_string(musb->xceiv->otg->state));
}
}
EXPORT_SYMBOL_GPL(musb_root_disconnect);
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 0aacfc8be5a1..d8130f58bca3 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -152,7 +152,7 @@ static void configure_channel(struct dma_channel *channel,
u16 csr = 0;
musb_dbg(musb, "%p, pkt_sz %d, addr %pad, len %d, mode %d",
- channel, packet_sz, &dma_addr, len, mode);
+ channel, packet_sz, &dma_addr, len, mode);
if (mode) {
csr |= 1 << MUSB_HSDMA_MODE1_SHIFT;
@@ -187,9 +187,9 @@ static int dma_channel_program(struct dma_channel *channel,
struct musb *musb = controller->private_data;
musb_dbg(musb, "ep%d-%s pkt_sz %d, dma_addr %pad length %d, mode %d",
- musb_channel->epnum,
- musb_channel->transmit ? "Tx" : "Rx",
- packet_sz, &dma_addr, len, mode);
+ musb_channel->epnum,
+ musb_channel->transmit ? "Tx" : "Rx",
+ packet_sz, &dma_addr, len, mode);
BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
channel->status == MUSB_DMA_STATUS_BUSY);
@@ -329,12 +329,12 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
- musb_channel->start_addr;
musb_dbg(musb, "ch %p, 0x%x -> 0x%x (%zu / %d) %s",
- channel, musb_channel->start_addr,
- addr, channel->actual_len,
- musb_channel->len,
- (channel->actual_len
- < musb_channel->len) ?
- "=> reconfig 0" : "=> complete");
+ channel, musb_channel->start_addr,
+ addr, channel->actual_len,
+ musb_channel->len,
+ (channel->actual_len
+ < musb_channel->len) ?
+ "=> reconfig 0" : "=> complete");
devctl = musb_readb(mbase, MUSB_DEVCTL);
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index c42937692207..4147c361bfc6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -667,8 +667,8 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode)
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if ((musb_mode == MUSB_PERIPHERAL) &&
!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS))
- INFO("Cannot be peripheral with mini-A cable "
- "otg_stat: %08x\n", otg_stat);
+ musb_info(musb, "Cannot be peripheral with mini-A cable otg_stat: %08x",
+ otg_stat);
return 0;
}
@@ -793,7 +793,8 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
+ msecs_to_jiffies(musb->a_wait_bcon);
} else {
/* REVISIT report overcurrent to hub? */
- ERR("vbus too slow, devctl %02x\n", devctl);
+ musb_err(musb, "vbus too slow, devctl %02x",
+ devctl);
tusb_musb_set_vbus(musb, 0);
}
break;
@@ -957,8 +958,7 @@ static void tusb_musb_enable(struct musb *musb)
TUSB_INT_SRC_ID_STATUS_CHNG);
if (is_dma_capable() && dma_off)
- printk(KERN_WARNING "%s %s: dma not reactivated\n",
- __FILE__, __func__);
+ musb_warn(musb, "dma not reactivated");
else
dma_off = 1;
}
@@ -981,8 +981,7 @@ static void tusb_musb_disable(struct musb *musb)
del_timer(&musb->dev_timer);
if (is_dma_capable() && !dma_off) {
- printk(KERN_WARNING "%s %s: dma still active\n",
- __FILE__, __func__);
+ musb_warn(musb, "dma still active");
dma_off = 1;
}
}
@@ -1028,7 +1027,7 @@ static int tusb_musb_start(struct musb *musb)
if (musb->board_set_power)
ret = musb->board_set_power(1);
if (ret != 0) {
- printk(KERN_ERR "tusb: Cannot enable TUSB6010\n");
+ musb_err(musb, "tusb: Cannot enable TUSB6010");
return ret;
}
@@ -1036,15 +1035,15 @@ static int tusb_musb_start(struct musb *musb)
if (musb_readl(tbase, TUSB_PROD_TEST_RESET) !=
TUSB_PROD_TEST_RESET_VAL) {
- printk(KERN_ERR "tusb: Unable to detect TUSB6010\n");
+ musb_err(musb, "tusb: Unable to detect TUSB6010");
goto err;
}
musb->tusb_revision = tusb_get_revision(musb);
tusb_print_revision(musb);
if (musb->tusb_revision < 2) {
- printk(KERN_ERR "tusb: Unsupported TUSB6010 revision %i\n",
- musb->tusb_revision);
+ musb_err(musb, "tusb: Unsupported TUSB6010 revision %i",
+ musb->tusb_revision);
goto err;
}
@@ -1129,8 +1128,7 @@ static int tusb_musb_init(struct musb *musb)
ret = tusb_musb_start(musb);
if (ret) {
- printk(KERN_ERR "Could not start tusb6010 (%d)\n",
- ret);
+ musb_err(musb, "Could not start tusb6010 (%d)", ret);
goto done;
}
musb->isr = tusb_musb_interrupt;
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 60a93b8bbe3c..88f2923cfdc4 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -83,8 +83,8 @@ static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat)
u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP);
if ((reg & 0xf) != chdat->epnum) {
- printk(KERN_ERR "ep%i trying to release dmareq0 for ep%i\n",
- chdat->epnum, reg & 0xf);
+ musb_err(chdat->musb, "ep%i trying to release dmareq0 for ep%i",
+ chdat->epnum, reg & 0xf);
return;
}
musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0);
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index d5cf5e8bb1ca..9979a733954d 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -323,8 +323,8 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
NULL);
if (!ux500_channel->dma_chan) {
- ERR("Dma pipe allocation error dir=%d ch=%d\n",
- dir, ch_num);
+ musb_err(musb, "Dma pipe allocation error dir=%d ch=%d",
+ dir, ch_num);
/* Release already allocated channels */
ux500_dma_controller_stop(controller);
^ permalink raw reply related
* Re: [PATCH 2/3] usb: xhci-mtk: fix UAS issue by XHCI_BROKEN_STREAMS quirk
From: Rob Herring @ 2020-12-21 19:35 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Nicolas Boichat, Mathias Nyman, Greg Kroah-Hartman,
Matthias Brugger, linux-usb, linux-arm Mailing List,
moderated list:ARM/Mediatek SoC support, Devicetree List, lkml,
Hsin-Yi Wang, Ikjoon Jang
In-Reply-To: <1608186230.23328.78.camel@mhfsdcap03>
On Thu, Dec 17, 2020 at 02:23:50PM +0800, Chunfeng Yun wrote:
> On Thu, 2020-12-17 at 11:32 +0800, Nicolas Boichat wrote:
> > On Thu, Dec 17, 2020 at 10:19 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> > >
> > > On Wed, 2020-12-16 at 20:28 +0800, Nicolas Boichat wrote:
> > > > On Wed, Dec 16, 2020 at 7:53 PM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
> > > > >
> > > > > The 0.96 xHCI controller on some platforms does not support
> > > > > bulk stream even HCCPARAMS says supporting, due to MaxPSASize
> > > > > is set a non-zero default value by mistake, here use
> > > > > XHCI_BROKEN_STREAMS quirk to fix it.
> > > > >
> > > > > Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
> > > > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > > > > ---
> > > > > drivers/usb/host/xhci-mtk.c | 7 ++++++-
> > > > > drivers/usb/host/xhci-mtk.h | 1 +
> > > > > 2 files changed, 7 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > > > > index 8f321f39ab96..08dab974d847 100644
> > > > > --- a/drivers/usb/host/xhci-mtk.c
> > > > > +++ b/drivers/usb/host/xhci-mtk.c
> > > > > @@ -395,6 +395,9 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
> > > > > xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
> > > > > if (mtk->lpm_support)
> > > > > xhci->quirks |= XHCI_LPM_SUPPORT;
> > > > > +
> > > > > + if (mtk->broken_streams)
> > > > > + xhci->quirks |= XHCI_BROKEN_STREAMS;
> > > > > }
> > > > >
> > > > > /* called during probe() after chip reset completes */
> > > > > @@ -460,6 +463,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > > > > return ret;
> > > > >
> > > > > mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
> > > > > + mtk->broken_streams =
> > > > > + of_property_read_bool(node, "mediatek,broken_streams_quirk");
> > > >
> > > > Would it be better to add a data field to struct of_device_id
> > > > mtk_xhci_of_match, and enable this quirk on mediatek,mt8173-xhci only?
> > > This is the common issue for all SoCs (before 2016.06) with 0.96 xHCI
> > > when the controller don't support bulk stream. If enable this quirk only
> > > for mt8173, then for other SoCs, the compatible need include
> > > "mediatek,mt8173-xhci" in dts, this may be not flexible for some cases,
> > > e.g. a new SoC has the broken stream as mt8173, but also has another
> > > different quirk, the way you suggested will not handle it.
> >
> > It can, we do this regularly for many other components. One example:
> > https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-mt65xx.c#L402
> >
> Got it. Indeed works when add compatible private data.
>
> Due to many SoCs supports USB and not upstream, I'd prefer to avoid
> adding new compatible in driver when support new SoCs, and leave the
> code as simple as possible.
No. The problem is adding new fixes requires updating the DT. That would
be fine if you knew all possible issues and quirks up front. You may for
some, but you won't catch them all.
Save DT properties for per board quirks/features, not per SoC ones.
>
> > > And I plan to remove "mediatek,mt8173-xhci" in mtk_xhci_of_match after
> > > converting the binding to YMAL.
> > >
> > > >
> > > > (IMHO usb3-lpm-capable detection should also be done in the same way)
I tend to agree, but am more tolerable of standard USB features than
specific IP block quirks.
Rob
^ permalink raw reply
* Re: [PATCH 1/3] dt-bindings: usb: mtk-xhci: add a new property for broken streams
From: Rob Herring @ 2020-12-21 19:29 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Mathias Nyman, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
linux-arm-kernel, linux-mediatek, devicetree, linux-kernel,
Hsin-Yi Wang, Ikjoon Jang
In-Reply-To: <20201216115125.5886-1-chunfeng.yun@mediatek.com>
On Wed, Dec 16, 2020 at 07:51:23PM +0800, Chunfeng Yun wrote:
> The 0.96 xHCI controller on some platforms does not support
> bulk stream even HCCPARAMS says supporting, due to MaxPSASize
> is set a non-zero default value by mistake, so add a new
> property "mediatek,broken_streams_quirk" to fix it.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> this patch depends on:
> https://patchwork.kernel.org/project/linux-mediatek/list/?series=402773
> [v4,09/11] dt-bindings: usb: convert mediatek, mtk-xhci.txt to YAML schema
> ---
> Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> index e5e03f902802..330f7294bf34 100644
> --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> @@ -120,6 +120,11 @@ properties:
> description: The mask to disable u3ports, bit0 for u3port0,
> bit1 for u3port1, ... etc
>
> + mediatek,broken_streams_quirk:
You should imply this from the compatible property.
(Also, don't use '_' in property names).
> + description: set if the controller doesn't support bulk stream but
> + HCCPARAMS says support.
> + type: boolean
> +
> "#address-cells":
> const: 1
>
> --
> 2.18.0
^ permalink raw reply
* Re: [PATCH v4 10/11] dt-bindings: usb: convert mediatek,mtu3.txt to YAML schema
From: Rob Herring @ 2020-12-21 19:26 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Kishon Vijay Abraham I,
Vinod Koul, Matthias Brugger, Greg Kroah-Hartman, Stanley Chu,
Min Guo, dri-devel, devicetree, linux-kernel, netdev,
linux-arm-kernel, linux-mediatek, linux-usb, Serge Semin
In-Reply-To: <20201216093012.24406-10-chunfeng.yun@mediatek.com>
On Wed, Dec 16, 2020 at 05:30:11PM +0800, Chunfeng Yun wrote:
> Convert mediatek,mtu3.txt to YAML schema mediatek,mtu3.yaml
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v4:
> 1. refer to usb-drd.yaml insstead of usb/generic.txt
> the following ones suggested by Rob:
> 2. add the number of phys supported
> 3. fix indentation of wakeup
> 4. add examples for port and connector
>
> v3:
> 1. fix yamllint warning
> 2. remove pinctrl* properties
> 3. remove unnecessary '|'
> 4. drop unused labels in example
>
> v2: new patch
> ---
> .../devicetree/bindings/usb/mediatek,mtu3.txt | 108 -------
> .../bindings/usb/mediatek,mtu3.yaml | 278 ++++++++++++++++++
> 2 files changed, 278 insertions(+), 108 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
> create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
>
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
> deleted file mode 100644
> index a82ca438aec1..000000000000
> --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
> +++ /dev/null
> @@ -1,108 +0,0 @@
> -The device node for Mediatek USB3.0 DRD controller
> -
> -Required properties:
> - - compatible : should be "mediatek,<soc-model>-mtu3", "mediatek,mtu3",
> - soc-model is the name of SoC, such as mt8173, mt2712 etc,
> - when using "mediatek,mtu3" compatible string, you need SoC specific
> - ones in addition, one of:
> - - "mediatek,mt8173-mtu3"
> - - reg : specifies physical base address and size of the registers
> - - reg-names: should be "mac" for device IP and "ippc" for IP port control
> - - interrupts : interrupt used by the device IP
> - - power-domains : a phandle to USB power domain node to control USB's
> - mtcmos
> - - vusb33-supply : regulator of USB avdd3.3v
> - - clocks : a list of phandle + clock-specifier pairs, one for each
> - entry in clock-names
> - - clock-names : must contain "sys_ck" for clock of controller,
> - the following clocks are optional:
> - "ref_ck", "mcu_ck" and "dma_ck";
> - - phys : see usb-hcd.yaml in the current directory
> - - dr_mode : should be one of "host", "peripheral" or "otg",
> - refer to usb/generic.txt
> -
> -Optional properties:
> - - #address-cells, #size-cells : should be '2' if the device has sub-nodes
> - with 'reg' property
> - - ranges : allows valid 1:1 translation between child's address space and
> - parent's address space
> - - extcon : external connector for vbus and idpin changes detection, needed
> - when supports dual-role mode.
> - it's considered valid for compatibility reasons, not allowed for
> - new bindings, and use "usb-role-switch" property instead.
> - - vbus-supply : reference to the VBUS regulator, needed when supports
> - dual-role mode.
> - it's considered valid for compatibility reasons, not allowed for
> - new bindings, and put into a usb-connector node.
> - see connector/usb-connector.yaml.
> - - pinctrl-names : a pinctrl state named "default" is optional, and need be
> - defined if auto drd switch is enabled, that means the property dr_mode
> - is set as "otg", and meanwhile the property "mediatek,enable-manual-drd"
> - is not set.
> - - pinctrl-0 : pin control group
> - See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
> -
> - - maximum-speed : valid arguments are "super-speed", "high-speed" and
> - "full-speed"; refer to usb/generic.txt
> - - usb-role-switch : use USB Role Switch to support dual-role switch, but
> - not extcon; see usb/generic.txt.
> - - enable-manual-drd : supports manual dual-role switch via debugfs; usually
> - used when receptacle is TYPE-A and also wants to support dual-role
> - mode.
> - - wakeup-source: enable USB remote wakeup of host mode.
> - - mediatek,syscon-wakeup : phandle to syscon used to access the register
> - of the USB wakeup glue layer between SSUSB and SPM; it depends on
> - "wakeup-source", and has two arguments:
> - - the first one : register base address of the glue layer in syscon;
> - - the second one : hardware version of the glue layer
> - - 1 : used by mt8173 etc
> - - 2 : used by mt2712 etc
> - - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
> - bit1 for u3port1, ... etc;
> -
> -additionally the properties from usb-hcd.yaml (in the current directory) are
> -supported.
> -
> -Sub-nodes:
> -The xhci should be added as subnode to mtu3 as shown in the following example
> -if host mode is enabled. The DT binding details of xhci can be found in:
> -Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
> -
> -The port would be added as subnode if use "usb-role-switch" property.
> - see graph.txt
> -
> -Example:
> -ssusb: usb@11271000 {
> - compatible = "mediatek,mt8173-mtu3";
> - reg = <0 0x11271000 0 0x3000>,
> - <0 0x11280700 0 0x0100>;
> - reg-names = "mac", "ippc";
> - interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
> - phys = <&phy_port0 PHY_TYPE_USB3>,
> - <&phy_port1 PHY_TYPE_USB2>;
> - power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> - clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
> - <&pericfg CLK_PERI_USB0>,
> - <&pericfg CLK_PERI_USB1>;
> - clock-names = "sys_ck", "ref_ck";
> - vusb33-supply = <&mt6397_vusb_reg>;
> - vbus-supply = <&usb_p0_vbus>;
> - extcon = <&extcon_usb>;
> - dr_mode = "otg";
> - wakeup-source;
> - mediatek,syscon-wakeup = <&pericfg 0x400 1>;
> - #address-cells = <2>;
> - #size-cells = <2>;
> - ranges;
> -
> - usb_host: xhci@11270000 {
> - compatible = "mediatek,mt8173-xhci";
> - reg = <0 0x11270000 0 0x1000>;
> - reg-names = "mac";
> - interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> - power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> - clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
> - clock-names = "sys_ck", "ref_ck";
> - vusb33-supply = <&mt6397_vusb_reg>;
> - };
> -};
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> new file mode 100644
> index 000000000000..e39850dff073
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> @@ -0,0 +1,278 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (c) 2020 MediaTek
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/usb/mediatek,mtu3.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MediaTek USB3 DRD Controller Device Tree Bindings
> +
> +maintainers:
> + - Chunfeng Yun <chunfeng.yun@mediatek.com>
> +
> +allOf:
> + - $ref: "usb-drd.yaml"
> +
> +description: |
> + The DRD controller has a glue layer IPPC (IP Port Control), and its host is
> + based on xHCI.
> +
> +properties:
> + compatible:
> + items:
> + - enum:
> + - mediatek,mt2712-mtu3
> + - mediatek,mt8173-mtu3
> + - mediatek,mt8183-mtu3
> + - const: mediatek,mtu3
> +
> + reg:
> + items:
> + - description: the registers of device MAC
> + - description: the registers of IP Port Control
> +
> + reg-names:
> + items:
> + - const: mac
> + - const: ippc
> +
> + interrupts:
> + maxItems: 1
> +
> + power-domains:
> + description: A phandle to USB power domain node to control USB's MTCMOS
> + maxItems: 1
> +
> + clocks:
> + minItems: 1
> + maxItems: 4
Don't need maxItems here.
> + items:
> + - description: Controller clock used by normal mode
> + - description: Reference clock used by low power mode etc
> + - description: Mcu bus clock for register access
> + - description: DMA bus clock for data transfer
> +
> + clock-names:
> + minItems: 1
> + maxItems: 4
> + items:
> + - const: sys_ck # required, the following ones are optional
> + - const: ref_ck
> + - const: mcu_ck
> + - const: dma_ck
> +
> + phys:
> + description: List of all the USB PHYs used
> + minItems: 0
> + maxItems: 9
Need to define what each one is.
> +
> + vusb33-supply:
> + description: Regulator of USB AVDD3.3v
> +
> + vbus-supply:
> + deprecated: true
> + description: |
> + Regulator of USB VBUS5v, needed when supports dual-role mode.
> + Particularly, if use an output GPIO to control a VBUS regulator, should
> + model it as a regulator. See bindings/regulator/fixed-regulator.yaml
> + It's considered valid for compatibility reasons, not allowed for
> + new bindings, and put into a usb-connector node.
> +
> + dr_mode:
> + enum: [host, peripheral, otg]
> + default: otg
> +
> + maximum-speed:
> + enum: [super-speed-plus, super-speed, high-speed, full-speed]
> +
> + "#address-cells":
> + enum: [1, 2]
> +
> + "#size-cells":
> + enum: [1, 2]
> +
> + ranges: true
> +
> + extcon:
> + deprecated: true
> + description: |
> + Phandle to the extcon device detecting the IDDIG/VBUS state, neede
> + when supports dual-role mode.
> + It's considered valid for compatibility reasons, not allowed for
> + new bindings, and use "usb-role-switch" property instead.
> +
> + usb-role-switch:
> + $ref: /schemas/types.yaml#/definitions/flag
> + description: Support role switch.
> + type: boolean
> +
> + connector:
> + $ref: /connector/usb-connector.yaml#
> + description:
> + Connector for dual role switch, especially for "gpio-usb-b-connector"
> + type: object
> +
> + port:
> + description:
> + Any connector to the data bus of this controller should be modelled
> + using the OF graph bindings specified, if the "usb-role-switch"
> + property is used. See graph.txt
> + type: object
> +
> + enable-manual-drd:
> + $ref: /schemas/types.yaml#/definitions/flag
> + description:
> + supports manual dual-role switch via debugfs; usually used when
> + receptacle is TYPE-A and also wants to support dual-role mode.
> + type: boolean
> +
> + wakeup-source:
> + description: enable USB remote wakeup, see power/wakeup-source.txt
> + type: boolean
> +
> + mediatek,syscon-wakeup:
> + $ref: /schemas/types.yaml#/definitions/phandle-array
> + maxItems: 1
> + description:
> + A phandle to syscon used to access the register of the USB wakeup glue
> + layer between xHCI and SPM, the field should always be 3 cells long.
> + items:
> + items:
> + - description:
> + The first cell represents a phandle to syscon
> + - description:
> + The second cell represents the register base address of the glue
> + layer in syscon
> + - description:
> + The third cell represents the hardware version of the glue layer,
> + 1 is used by mt8173 etc, 2 is used by mt2712 etc
> + enum: [1, 2]
> +
> + mediatek,u3p-dis-msk:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: The mask to disable u3ports, bit0 for u3port0,
> + bit1 for u3port1, ... etc
> +
> +# Required child node when support dual-role
> +patternProperties:
> + "^usb@[0-9a-f]+$":
> + type: object
> + $ref: /usb/mediatek,mtk-xhci.yaml#
> + description:
> + The xhci should be added as subnode to mtu3 as shown in the following
> + example if the host mode is enabled.
> +
> +dependencies:
> + connector: [ 'usb-role-switch' ]
> + port: [ 'usb-role-switch' ]
> + wakeup-source: [ 'mediatek,syscon-wakeup' ]
> +
> +required:
> + - compatible
> + - reg
> + - reg-names
> + - interrupts
> + - clocks
> + - clock-names
> +
> +additionalProperties: false
> +
> +examples:
> + # Dual role switch by extcon
> + - |
> + #include <dt-bindings/clock/mt8173-clk.h>
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/interrupt-controller/irq.h>
> + #include <dt-bindings/phy/phy.h>
> + #include <dt-bindings/power/mt8173-power.h>
> +
> + usb@11271000 {
> + compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
> + reg = <0x11271000 0x3000>, <0x11280700 0x0100>;
> + reg-names = "mac", "ippc";
> + interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
> + phys = <&phy_port0 PHY_TYPE_USB3>, <&phy_port1 PHY_TYPE_USB2>;
> + power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> + clocks = <&topckgen CLK_TOP_USB30_SEL>;
> + clock-names = "sys_ck";
> + vusb33-supply = <&mt6397_vusb_reg>;
> + vbus-supply = <&usb_p0_vbus>;
> + extcon = <&extcon_usb>;
> + dr_mode = "otg";
> + wakeup-source;
> + mediatek,syscon-wakeup = <&pericfg 0x400 1>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> +
> + xhci: usb@11270000 {
> + compatible = "mediatek,mt8173-xhci", "mediatek,mtk-xhci";
> + reg = <0x11270000 0x1000>;
> + reg-names = "mac";
> + interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> + power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
> + clock-names = "sys_ck", "ref_ck";
> + vusb33-supply = <&mt6397_vusb_reg>;
> + };
> + };
> +
> + # Enable/disable device by an input gpio for VBUS pin
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> + #include <dt-bindings/power/mt2712-power.h>
> +
> + usb@112c1000 {
> + compatible = "mediatek,mt2712-mtu3", "mediatek,mtu3";
> + reg = <0x112c1000 0x3000>, <0x112d0700 0x0100>;
> + reg-names = "mac", "ippc";
> + interrupts = <GIC_SPI 248 IRQ_TYPE_LEVEL_LOW>;
> + phys = <&u2port2 PHY_TYPE_USB2>;
> + power-domains = <&scpsys MT2712_POWER_DOMAIN_USB2>;
> + clocks = <&topckgen CLK_TOP_USB30_SEL>;
> + clock-names = "sys_ck";
> + dr_mode = "peripheral";
> + usb-role-switch;
> +
> + connector {
> + compatible = "gpio-usb-b-connector", "usb-b-connector";
> + type = "micro";
> + vbus-gpios = <&pio 13 GPIO_ACTIVE_HIGH>;
> + };
> + };
> +
> + # Dual role switch with type-c
> + - |
> + usb@11201000 {
> + compatible ="mediatek,mt8183-mtu3", "mediatek,mtu3";
> + reg = <0x11201000 0x2e00>, <0x11203e00 0x0100>;
> + reg-names = "mac", "ippc";
> + interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>;
> + phys = <&u2port0 PHY_TYPE_USB2>;
> + clocks = <&clk26m>;
> + clock-names = "sys_ck";
> + mediatek,syscon-wakeup = <&pericfg 0x400 1>;
> + wakeup-source;
> + dr_mode = "otg";
> + usb-role-switch;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> +
> + host: usb@11200000 {
> + compatible = "mediatek,mt8183-xhci", "mediatek,mtk-xhci";
> + reg = <0x11200000 0x1000>;
> + reg-names = "mac";
> + interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_LOW>;
> + clocks = <&clk26m>;
> + clock-names = "sys_ck";
> + };
> +
> + port {
> + usb_role_sw: endpoint {
> + remote-endpoint = <&hs_ep>;
> + };
> + };
> + };
> +
> +...
> --
> 2.18.0
>
^ permalink raw reply
* Re: [PATCH v4 09/11] dt-bindings: usb: convert mediatek,mtk-xhci.txt to YAML schema
From: Rob Herring @ 2020-12-21 19:23 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Kishon Vijay Abraham I,
Vinod Koul, Matthias Brugger, Greg Kroah-Hartman, Stanley Chu,
Min Guo, dri-devel, devicetree, linux-kernel, netdev,
linux-arm-kernel, linux-mediatek, linux-usb, Serge Semin
In-Reply-To: <20201216093012.24406-9-chunfeng.yun@mediatek.com>
On Wed, Dec 16, 2020 at 05:30:10PM +0800, Chunfeng Yun wrote:
> Convert mediatek,mtk-xhci.txt to YAML schema mediatek,mtk-xhci.yaml
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v4: update it according to Rob's suggestion
> 1. modify dictionary of phys
> 2. fix endentation in "mediatek,syscon-wakeup" items
> 3. remove reference to usb-hcd.yaml
>
> v3:
> 1. fix yamllint warning
> 2. remove pinctrl* properties supported by default suggested by Rob
> 3. drop unused labels
> 4. modify description of mediatek,syscon-wakeup
> 5. remove type of imod-interval-ns
>
> v2: new patch
> ---
> .../bindings/usb/mediatek,mtk-xhci.txt | 121 -------------
> .../bindings/usb/mediatek,mtk-xhci.yaml | 171 ++++++++++++++++++
> 2 files changed, 171 insertions(+), 121 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
> create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
>
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
> deleted file mode 100644
> index 42d8814f903a..000000000000
> --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
> +++ /dev/null
> @@ -1,121 +0,0 @@
> -MT8173 xHCI
> -
> -The device node for Mediatek SOC USB3.0 host controller
> -
> -There are two scenarios: the first one only supports xHCI driver;
> -the second one supports dual-role mode, and the host is based on xHCI
> -driver. Take account of backward compatibility, we divide bindings
> -into two parts.
> -
> -1st: only supports xHCI driver
> -------------------------------------------------------------------------
> -
> -Required properties:
> - - compatible : should be "mediatek,<soc-model>-xhci", "mediatek,mtk-xhci",
> - soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
> - "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
> - addition, one of:
> - - "mediatek,mt8173-xhci"
> - - reg : specifies physical base address and size of the registers
> - - reg-names: should be "mac" for xHCI MAC and "ippc" for IP port control
> - - interrupts : interrupt used by the controller
> - - power-domains : a phandle to USB power domain node to control USB's
> - mtcmos
> - - vusb33-supply : regulator of USB avdd3.3v
> -
> - - clocks : a list of phandle + clock-specifier pairs, one for each
> - entry in clock-names
> - - clock-names : must contain
> - "sys_ck": controller clock used by normal mode,
> - the following ones are optional:
> - "ref_ck": reference clock used by low power mode etc,
> - "mcu_ck": mcu_bus clock for register access,
> - "dma_ck": dma_bus clock for data transfer by DMA,
> - "xhci_ck": controller clock
> -
> - - phys : see usb-hcd.yaml in the current directory
> -
> -Optional properties:
> - - wakeup-source : enable USB remote wakeup;
> - - mediatek,syscon-wakeup : phandle to syscon used to access the register
> - of the USB wakeup glue layer between xHCI and SPM; it depends on
> - "wakeup-source", and has two arguments:
> - - the first one : register base address of the glue layer in syscon;
> - - the second one : hardware version of the glue layer
> - - 1 : used by mt8173 etc
> - - 2 : used by mt2712 etc
> - - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
> - bit1 for u3port1, ... etc;
> - - vbus-supply : reference to the VBUS regulator;
> - - usb3-lpm-capable : supports USB3.0 LPM
> - - pinctrl-names : a pinctrl state named "default" must be defined
> - - pinctrl-0 : pin control group
> - See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
> - - imod-interval-ns: default interrupt moderation interval is 5000ns
> -
> -additionally the properties from usb-hcd.yaml (in the current directory) are
> -supported.
> -
> -Example:
> -usb30: usb@11270000 {
> - compatible = "mediatek,mt8173-xhci";
> - reg = <0 0x11270000 0 0x1000>,
> - <0 0x11280700 0 0x0100>;
> - reg-names = "mac", "ippc";
> - interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> - power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> - clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
> - <&pericfg CLK_PERI_USB0>,
> - <&pericfg CLK_PERI_USB1>;
> - clock-names = "sys_ck", "ref_ck";
> - phys = <&phy_port0 PHY_TYPE_USB3>,
> - <&phy_port1 PHY_TYPE_USB2>;
> - vusb33-supply = <&mt6397_vusb_reg>;
> - vbus-supply = <&usb_p1_vbus>;
> - usb3-lpm-capable;
> - mediatek,syscon-wakeup = <&pericfg 0x400 1>;
> - wakeup-source;
> - imod-interval-ns = <10000>;
> -};
> -
> -2nd: dual-role mode with xHCI driver
> -------------------------------------------------------------------------
> -
> -In the case, xhci is added as subnode to mtu3. An example and the DT binding
> -details of mtu3 can be found in:
> -Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
> -
> -Required properties:
> - - compatible : should be "mediatek,<soc-model>-xhci", "mediatek,mtk-xhci",
> - soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
> - "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
> - addition, one of:
> - - "mediatek,mt8173-xhci"
> - - reg : specifies physical base address and size of the registers
> - - reg-names: should be "mac" for xHCI MAC
> - - interrupts : interrupt used by the host controller
> - - power-domains : a phandle to USB power domain node to control USB's
> - mtcmos
> - - vusb33-supply : regulator of USB avdd3.3v
> -
> - - clocks : a list of phandle + clock-specifier pairs, one for each
> - entry in clock-names
> - - clock-names : must contain "sys_ck", and the following ones are optional:
> - "ref_ck", "mcu_ck" and "dma_ck", "xhci_ck"
> -
> -Optional properties:
> - - vbus-supply : reference to the VBUS regulator;
> - - usb3-lpm-capable : supports USB3.0 LPM
> -
> -Example:
> -usb30: usb@11270000 {
> - compatible = "mediatek,mt8173-xhci";
> - reg = <0 0x11270000 0 0x1000>;
> - reg-names = "mac";
> - interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> - power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> - clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
> - clock-names = "sys_ck", "ref_ck";
> - vusb33-supply = <&mt6397_vusb_reg>;
> - usb3-lpm-capable;
> -};
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> new file mode 100644
> index 000000000000..e5e03f902802
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> @@ -0,0 +1,171 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (c) 2020 MediaTek
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MediaTek USB3 xHCI Device Tree Bindings
> +
> +maintainers:
> + - Chunfeng Yun <chunfeng.yun@mediatek.com>
> +
> +allOf:
> + - $ref: "usb-hcd.yaml"
This will need to reference Serge's xhci.yaml instead.
> +
> +description: |
> + There are two scenarios:
> + case 1: only supports xHCI driver;
> + case 2: supports dual-role mode, and the host is based on xHCI driver.
> +
> +properties:
> + # common properties for both case 1 and case 2
> + compatible:
> + items:
> + - enum:
> + - mediatek,mt2712-xhci
> + - mediatek,mt7622-xhci
> + - mediatek,mt7629-xhci
> + - mediatek,mt8173-xhci
> + - mediatek,mt8183-xhci
> + - const: mediatek,mtk-xhci
> +
> + reg:
> + minItems: 1
> + maxItems: 2
You can drop maxItems, as that is implied by length of 'items'.
> + items:
> + - description: the registers of xHCI MAC
> + - description: the registers of IP Port Control
> +
> + reg-names:
> + minItems: 1
> + maxItems: 2
> + items:
> + - const: mac
> + - const: ippc # optional, only needed for case 1.
> +
> + interrupts:
> + maxItems: 1
> +
> + power-domains:
> + description: A phandle to USB power domain node to control USB's MTCMOS
> + maxItems: 1
> +
> + clocks:
> + minItems: 1
> + maxItems: 5
> + items:
> + - description: Controller clock used by normal mode
> + - description: Reference clock used by low power mode etc
> + - description: Mcu bus clock for register access
> + - description: DMA bus clock for data transfer
> + - description: controller clock
> +
> + clock-names:
> + minItems: 1
> + maxItems: 5
> + items:
> + - const: sys_ck # required, the following ones are optional
> + - const: ref_ck
> + - const: mcu_ck
> + - const: dma_ck
> + - const: xhci_ck
> +
> + phys:
> + description: List of at most 5 USB2 PHYs and 4 USB3 PHYs on this HCD
If it's less, how does one know what each phy is?
> + minItems: 0
minItems: 0 is never correct. That's phys not being present.
> + maxItems: 9
> +
> + vusb33-supply:
> + description: Regulator of USB AVDD3.3v
> +
> + vbus-supply:
> + description: Regulator of USB VBUS5v
> +
> + usb3-lpm-capable:
> + description: supports USB3.0 LPM
> + type: boolean
> +
> + imod-interval-ns:
> + description:
> + Interrupt moderation interval value, it is 8 times as much as that
> + defined in the xHCI spec on MTK's controller.
> + default: 5000
> +
> + # the following properties are only used for case 1
> + wakeup-source:
> + description: enable USB remote wakeup, see power/wakeup-source.txt
> + type: boolean
> +
> + mediatek,syscon-wakeup:
> + $ref: /schemas/types.yaml#/definitions/phandle-array
> + maxItems: 1
> + description:
> + A phandle to syscon used to access the register of the USB wakeup glue
> + layer between xHCI and SPM, the field should always be 3 cells long.
> + items:
> + items:
> + - description:
> + The first cell represents a phandle to syscon
> + - description:
> + The second cell represents the register base address of the glue
> + layer in syscon
> + - description:
> + The third cell represents the hardware version of the glue layer,
> + 1 is used by mt8173 etc, 2 is used by mt2712 etc
> + enum: [1, 2]
> +
> + mediatek,u3p-dis-msk:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: The mask to disable u3ports, bit0 for u3port0,
> + bit1 for u3port1, ... etc
> +
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> +patternProperties:
> + "^[a-f]+@[0-9a-f]+$":
[a-f]+ doesn't cover all possible node names. Just '@[0-9a-f]+$', though
I assume you have some max number of ports less than 16?
> + type: object
> + description: The hard wired USB devices.
This needs to reference usb-device.yaml. Or usb-hcd.yaml does and
then this isn't needed. It depends if child nodes of USB host controller
are always USB devices or not. Serge?
> +
> +dependencies:
> + wakeup-source: [ 'mediatek,syscon-wakeup' ]
> +
> +required:
> + - compatible
> + - reg
> + - reg-names
> + - interrupts
> + - clocks
> + - clock-names
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/clock/mt8173-clk.h>
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/interrupt-controller/irq.h>
> + #include <dt-bindings/phy/phy.h>
> + #include <dt-bindings/power/mt8173-power.h>
> +
> + usb@11270000 {
> + compatible = "mediatek,mt8173-xhci", "mediatek,mtk-xhci";
> + reg = <0x11270000 0x1000>, <0x11280700 0x0100>;
> + reg-names = "mac", "ippc";
> + interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
> + power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
> + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
> + clock-names = "sys_ck", "ref_ck";
> + phys = <&u3port0 PHY_TYPE_USB3>, <&u2port1 PHY_TYPE_USB2>;
> + vusb33-supply = <&mt6397_vusb_reg>;
> + vbus-supply = <&usb_p1_vbus>;
> + imod-interval-ns = <10000>;
> + mediatek,syscon-wakeup = <&pericfg 0x400 1>;
> + wakeup-source;
> + usb3-lpm-capable;
> + };
> +...
> --
> 2.18.0
>
^ permalink raw reply
* Re: [PATCH v4 07/11] dt-bindings: phy: convert MIPI DSI PHY binding to YAML schema
From: Rob Herring @ 2020-12-21 19:11 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Rob Herring, Min Guo, Kishon Vijay Abraham I, David S . Miller,
Chun-Kuang Hu, linux-arm-kernel, David Airlie, Greg Kroah-Hartman,
Vinod Koul, netdev, Stanley Chu, Jakub Kicinski, dri-devel,
linux-kernel, Serge Semin, linux-mediatek, linux-usb,
Matthias Brugger, devicetree
In-Reply-To: <20201216093012.24406-7-chunfeng.yun@mediatek.com>
On Wed, 16 Dec 2020 17:30:08 +0800, Chunfeng Yun wrote:
> Convert MIPI DSI PHY binding to YAML schema mediatek,dsi-phy.yaml
>
> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v4:
> 1. add maintainer Philipp add support mt8183 suggested by Chun-Kuang
> 2. use keyword multipleOf suggested by Rob
> 3. fix typo of 'MIPI' in title
>
> v3: new patch
> ---
> .../display/mediatek/mediatek,dsi.txt | 18 +---
> .../bindings/phy/mediatek,dsi-phy.yaml | 85 +++++++++++++++++++
> 2 files changed, 86 insertions(+), 17 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v4 02/11] dt-bindings: net: btusb: change reference file name
From: Rob Herring @ 2020-12-21 19:09 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Serge Semin, David S . Miller, linux-kernel, devicetree,
Vinod Koul, Stanley Chu, Min Guo, David Airlie, Jakub Kicinski,
linux-usb, Chun-Kuang Hu, linux-arm-kernel, netdev,
Kishon Vijay Abraham I, linux-mediatek, dri-devel,
Greg Kroah-Hartman, Matthias Brugger, Rob Herring
In-Reply-To: <20201216093012.24406-2-chunfeng.yun@mediatek.com>
On Wed, 16 Dec 2020 17:30:03 +0800, Chunfeng Yun wrote:
> Due to usb-device.txt is converted into usb-device.yaml,
> so modify reference file names at the same time.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v2~v4: no changes
> ---
> Documentation/devicetree/bindings/net/btusb.txt | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v4 01/11] dt-bindings: usb: convert usb-device.txt to YAML schema
From: Rob Herring @ 2020-12-21 19:09 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Kishon Vijay Abraham I,
Vinod Koul, Matthias Brugger, Greg Kroah-Hartman, Stanley Chu,
Min Guo, dri-devel, devicetree, linux-kernel, netdev,
linux-arm-kernel, linux-mediatek, linux-usb, Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
On Wed, Dec 16, 2020 at 05:30:02PM +0800, Chunfeng Yun wrote:
> Convert usb-device.txt to YAML schema usb-device.yaml
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v4: no changes, update dependent series:
> https://patchwork.kernel.org/project/linux-usb/list/?series=399561
> [v6,00/19] dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema
>
> v3:
> 1. remove $nodenmae and items key word for compatilbe;
> 2. add additionalProperties;
>
> The followings are suggested by Rob:
> 3. merge the following patch
> [v2,1/4] dt-bindings: usb: convert usb-device.txt to YAML schema
> [v2,2/4] dt-bindings: usb: add properties for hard wired devices
> 4. define the unit-address for hard-wired device in usb-hcd.yaml,
> also define its 'reg' and 'compatible';
> 5. This series is base on Serge's series:
> https://patchwork.kernel.org/project/linux-usb/cover/20201111090853.14112-1-Sergey.Semin@baikalelectronics.ru/
> [v4,00/18] dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema
>
> v2 changes suggested by Rob:
> 1. modify pattern to support any USB class
> 2. convert usb-device.txt into usb-device.yaml
> ---
> .../devicetree/bindings/usb/usb-device.txt | 102 --------------
> .../devicetree/bindings/usb/usb-device.yaml | 125 ++++++++++++++++++
> .../devicetree/bindings/usb/usb-hcd.yaml | 33 +++++
> 3 files changed, 158 insertions(+), 102 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/usb/usb-device.txt
> create mode 100644 Documentation/devicetree/bindings/usb/usb-device.yaml
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-device.txt b/Documentation/devicetree/bindings/usb/usb-device.txt
> deleted file mode 100644
> index 036be172b1ae..000000000000
> --- a/Documentation/devicetree/bindings/usb/usb-device.txt
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -Generic USB Device Properties
> -
> -Usually, we only use device tree for hard wired USB device.
> -The reference binding doc is from:
> -http://www.devicetree.org/open-firmware/bindings/usb/usb-1_0.ps
> -
> -Four types of device-tree nodes are defined: "host-controller nodes"
> -representing USB host controllers, "device nodes" representing USB devices,
> -"interface nodes" representing USB interfaces and "combined nodes"
> -representing simple USB devices.
> -
> -A combined node shall be used instead of a device node and an interface node
> -for devices of class 0 or 9 (hub) with a single configuration and a single
> -interface.
> -
> -A "hub node" is a combined node or an interface node that represents a USB
> -hub.
> -
> -
> -Required properties for device nodes:
> -- compatible: "usbVID,PID", where VID is the vendor id and PID the product id.
> - The textual representation of VID and PID shall be in lower case hexadecimal
> - with leading zeroes suppressed. The other compatible strings from the above
> - standard binding could also be used, but a device adhering to this binding
> - may leave out all except for "usbVID,PID".
> -- reg: the number of the USB hub port or the USB host-controller port to which
> - this device is attached. The range is 1-255.
> -
> -
> -Required properties for device nodes with interface nodes:
> -- #address-cells: shall be 2
> -- #size-cells: shall be 0
> -
> -
> -Required properties for interface nodes:
> -- compatible: "usbifVID,PID.configCN.IN", where VID is the vendor id, PID is
> - the product id, CN is the configuration value and IN is the interface
> - number. The textual representation of VID, PID, CN and IN shall be in lower
> - case hexadecimal with leading zeroes suppressed. The other compatible
> - strings from the above standard binding could also be used, but a device
> - adhering to this binding may leave out all except for
> - "usbifVID,PID.configCN.IN".
> -- reg: the interface number and configuration value
> -
> -The configuration component is not included in the textual representation of
> -an interface-node unit address for configuration 1.
> -
> -
> -Required properties for combined nodes:
> -- compatible: "usbVID,PID", where VID is the vendor id and PID the product id.
> - The textual representation of VID and PID shall be in lower case hexadecimal
> - with leading zeroes suppressed. The other compatible strings from the above
> - standard binding could also be used, but a device adhering to this binding
> - may leave out all except for "usbVID,PID".
> -- reg: the number of the USB hub port or the USB host-controller port to which
> - this device is attached. The range is 1-255.
> -
> -
> -Required properties for hub nodes with device nodes:
> -- #address-cells: shall be 1
> -- #size-cells: shall be 0
> -
> -
> -Required properties for host-controller nodes with device nodes:
> -- #address-cells: shall be 1
> -- #size-cells: shall be 0
> -
> -
> -Example:
> -
> -&usb1 { /* host controller */
> - #address-cells = <1>;
> - #size-cells = <0>;
> -
> - hub@1 { /* hub connected to port 1 */
> - compatible = "usb5e3,608";
> - reg = <1>;
> - };
> -
> - device@2 { /* device connected to port 2 */
> - compatible = "usb123,4567";
> - reg = <2>;
> - };
> -
> - device@3 { /* device connected to port 3 */
> - compatible = "usb123,abcd";
> - reg = <3>;
> -
> - #address-cells = <2>;
> - #size-cells = <0>;
> -
> - interface@0 { /* interface 0 of configuration 1 */
> - compatible = "usbif123,abcd.config1.0";
> - reg = <0 1>;
> - };
> -
> - interface@0,2 { /* interface 0 of configuration 2 */
> - compatible = "usbif123,abcd.config2.0";
> - reg = <0 2>;
> - };
> - };
> -};
> diff --git a/Documentation/devicetree/bindings/usb/usb-device.yaml b/Documentation/devicetree/bindings/usb/usb-device.yaml
> new file mode 100644
> index 000000000000..f31d8a85d3e6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/usb-device.yaml
> @@ -0,0 +1,125 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/usb/usb-device.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: The device tree bindings for the Generic USB Device
> +
> +maintainers:
> + - Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> +
> +description: |
> + Usually, we only use device tree for hard wired USB device.
> + The reference binding doc is from:
> + http://www.devicetree.org/open-firmware/bindings/usb/usb-1_0.ps
> +
> + Four types of device-tree nodes are defined: "host-controller nodes"
> + representing USB host controllers, "device nodes" representing USB devices,
> + "interface nodes" representing USB interfaces and "combined nodes"
> + representing simple USB devices.
> +
> + A combined node shall be used instead of a device node and an interface node
> + for devices of class 0 or 9 (hub) with a single configuration and a single
> + interface.
> +
> + A "hub node" is a combined node or an interface node that represents a USB
> + hub.
> +
> +properties:
> + compatible:
> + pattern: "^usb[0-9a-f]+,[0-9a-f]+$"
You can refine the length allowed a bit: [0-9a-f]{1,4}
Same applies elsewhere.
> + description: Device nodes or combined nodes.
> + "usbVID,PID", where VID is the vendor id and PID the product id.
> + The textual representation of VID and PID shall be in lower case
> + hexadecimal with leading zeroes suppressed. The other compatible
> + strings from the above standard binding could also be used,
> + but a device adhering to this binding may leave out all except
> + for "usbVID,PID".
> +
> + reg:
> + description: the number of the USB hub port or the USB host-controller
> + port to which this device is attached. The range is 1-255.
> + maxItems: 1
> +
> + "#address-cells":
> + description: should be 1 for hub nodes with device nodes,
> + should be 2 for device nodes with interface nodes.
> + enum: [1, 2]
> +
> + "#size-cells":
> + const: 0
> +
> +patternProperties:
> + "^interface@[0-9]+(,[0-9]+)$":
> + type: object
> + description: USB interface nodes.
> + The configuration component is not included in the textual
> + representation of an interface-node unit address for configuration 1.
> +
> + properties:
> + compatible:
> + pattern: "^usbif[0-9a-f]+,[0-9a-f]+.config[0-9a-f]+.[0-9a-f]+$"
> + description: Interface nodes.
> + "usbifVID,PID.configCN.IN", where VID is the vendor id, PID is
> + the product id, CN is the configuration value and IN is the interface
> + number. The textual representation of VID, PID, CN and IN shall be
> + in lower case hexadecimal with leading zeroes suppressed.
> + The other compatible strings from the above standard binding could
> + also be used, but a device adhering to this binding may leave out
> + all except for "usbifVID,PID.configCN.IN".
> +
> + reg:
> + description: should be 2 cells long, the first cell represents
> + the interface number and the second cell represents the
> + configuration value.
> + maxItems: 1
> +
> +required:
> + - compatile
> + - reg
> +
> +additionalProperties: true
> +
> +examples:
> + #hub connected to port 1
> + #device connected to port 2
> + #device connected to port 3
> + # interface 0 of configuration 1
> + # interface 0 of configuration 2
> + - |
> + usb@11270000 {
> + compatible = "generic-xhci";
> + reg = <0x11270000 0x1000>;
> + interrupts = <0x0 0x4e 0x0>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + hub@1 {
> + compatible = "usb5e3,608";
> + reg = <1>;
> + };
> +
> + device@2 {
> + compatible = "usb123,4567";
> + reg = <2>;
> + };
> +
> + device@3 {
> + compatible = "usb123,abcd";
> + reg = <3>;
> +
> + #address-cells = <2>;
> + #size-cells = <0>;
> +
> + interface@0 {
> + compatible = "usbif123,abcd.config1.0";
> + reg = <0 1>;
> + };
> +
> + interface@0,2 {
> + compatible = "usbif123,abcd.config2.0";
> + reg = <0 2>;
> + };
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/usb/usb-hcd.yaml b/Documentation/devicetree/bindings/usb/usb-hcd.yaml
> index 9881ac10380d..5d0c6b5500d6 100755
> --- a/Documentation/devicetree/bindings/usb/usb-hcd.yaml
> +++ b/Documentation/devicetree/bindings/usb/usb-hcd.yaml
> @@ -23,6 +23,32 @@ properties:
> targeted hosts (non-PC hosts).
> type: boolean
>
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> +patternProperties:
> + "@[0-9a-f]+$":
> + type: object
> + description: The hard wired USB devices
> +
> + properties:
> + compatible:
> + pattern: "^usb[0-9a-f]+,[0-9a-f]+$"
> + $ref: /usb/usb-device.yaml
This is wrong. It should be up a level. And no need to define
'compatible' or 'reg' here because those are defined within
usb-device.yaml.
> + description: the string is 'usbVID,PID', where VID is the vendor id
> + and PID is the product id
> +
> + reg:
> + $ref: /usb/usb-device.yaml
> + maxItems: 1
> +
> + required:
> + - compatible
> + - reg
> +
> additionalProperties: true
>
> examples:
> @@ -30,4 +56,11 @@ examples:
> usb {
> phys = <&usb2_phy1>, <&usb3_phy1>;
> phy-names = "usb";
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + hub@1 {
> + compatible = "usb5e3,610";
> + reg = <1>;
> + };
> };
> --
> 2.18.0
>
^ permalink raw reply
* Re: [PATCH v3] usb: gadget: audio: Free requests only after callback
From: Jerome Brunet @ 2020-12-21 16:15 UTC (permalink / raw)
To: Jack Pham, Felipe Balbi, Ruslan Bilovol
Cc: Greg Kroah-Hartman, Thinh Nguyen, Andy Shevchenko, linux-usb,
Peter Chen, Ferry Toth
In-Reply-To: <20201029175949.6052-1-jackp@codeaurora.org>
On Thu 29 Oct 2020 at 18:59, Jack Pham <jackp@codeaurora.org> wrote:
> As per the kernel doc for usb_ep_dequeue(), it states that "this
> routine is asynchronous, that is, it may return before the completion
> routine runs". And indeed since v5.0 the dwc3 gadget driver updated
> its behavior to place dequeued requests on to a cancelled list to be
> given back later after the endpoint is stopped.
>
> The free_ep() was incorrectly assuming that a request was ready to
> be freed after calling dequeue which results in a use-after-free
> in dwc3 when it traverses its cancelled list. Fix this by moving
> the usb_ep_free_request() call to the callback itself in case the
> ep is disabled.
>
> Fixes: eb9fecb9e69b0 ("usb: gadget: f_uac2: split out audio core")
> Reported-and-tested-by: Ferry Toth <fntoth@gmail.com>
> Reviewed-and-tested-by: Peter Chen <peter.chen@nxp.com>
Tested-by: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Jack Pham <jackp@codeaurora.org>
> ---
> v3: Fixed incorrect 'req' parameter and added Peter's tag
>
> v2: call free_request() in case of ep_dequeue() failure
>
> drivers/usb/gadget/function/u_audio.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
> index e6d32c536781..6e69ccf02c95 100644
> --- a/drivers/usb/gadget/function/u_audio.c
> +++ b/drivers/usb/gadget/function/u_audio.c
> @@ -89,7 +89,12 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
> struct snd_uac_chip *uac = prm->uac;
>
> /* i/f shutting down */
> - if (!prm->ep_enabled || req->status == -ESHUTDOWN)
> + if (!prm->ep_enabled) {
> + usb_ep_free_request(ep, req);
> + return;
> + }
> +
> + if (req->status == -ESHUTDOWN)
> return;
>
> /*
> @@ -336,8 +341,9 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
>
> for (i = 0; i < params->req_number; i++) {
> if (prm->ureq[i].req) {
> - usb_ep_dequeue(ep, prm->ureq[i].req);
> - usb_ep_free_request(ep, prm->ureq[i].req);
> + if (usb_ep_dequeue(ep, prm->ureq[i].req))
> + usb_ep_free_request(ep, prm->ureq[i].req);
> + /* else will be freed in u_audio_iso_complete() */
> prm->ureq[i].req = NULL;
> }
> }
^ permalink raw reply
* [PATCH 3/4] usb: gadget: u_audio: remove struct uac_req
From: Jerome Brunet @ 2020-12-21 17:35 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Jerome Brunet, Ruslan Bilovol, linux-usb, linux-kernel
In-Reply-To: <20201221173531.215169-1-jbrunet@baylibre.com>
'struct uac_req' purpose is to link 'struct usb_request' to the
corresponding 'struct uac_rtd_params'. However member req is never
used. Using the context of the usb request, we can keep track of the
corresponding 'struct uac_rtd_params' just as well, without allocating
extra memory.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/usb/gadget/function/u_audio.c | 58 ++++++++++++---------------
1 file changed, 26 insertions(+), 32 deletions(-)
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 2f69bd572ed7..3eba31b8ebcb 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -23,11 +23,6 @@
#define PRD_SIZE_MAX PAGE_SIZE
#define MIN_PERIODS 4
-struct uac_req {
- struct uac_rtd_params *pp; /* parent param */
- struct usb_request *req;
-};
-
/* Runtime data params for one stream */
struct uac_rtd_params {
struct snd_uac_chip *uac; /* parent chip */
@@ -41,7 +36,7 @@ struct uac_rtd_params {
void *rbuf;
unsigned int max_psize; /* MaxPacketSize of endpoint */
- struct uac_req *ureq;
+ struct usb_request **reqs;
spinlock_t lock;
};
@@ -82,10 +77,9 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
unsigned long flags, flags2;
unsigned int hw_ptr;
int status = req->status;
- struct uac_req *ur = req->context;
struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime;
- struct uac_rtd_params *prm = ur->pp;
+ struct uac_rtd_params *prm = req->context;
struct snd_uac_chip *uac = prm->uac;
/* i/f shutting down */
@@ -339,11 +333,11 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
params = &audio_dev->params;
for (i = 0; i < params->req_number; i++) {
- if (prm->ureq[i].req) {
- if (usb_ep_dequeue(ep, prm->ureq[i].req))
- usb_ep_free_request(ep, prm->ureq[i].req);
+ if (prm->reqs[i]) {
+ if (usb_ep_dequeue(ep, prm->reqs[i]))
+ usb_ep_free_request(ep, prm->reqs[i]);
/* else will be freed in u_audio_iso_complete() */
- prm->ureq[i].req = NULL;
+ prm->reqs[i] = NULL;
}
}
@@ -372,22 +366,21 @@ int u_audio_start_capture(struct g_audio *audio_dev)
usb_ep_enable(ep);
for (i = 0; i < params->req_number; i++) {
- if (!prm->ureq[i].req) {
+ if (!prm->reqs[i]) {
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
if (req == NULL)
return -ENOMEM;
- prm->ureq[i].req = req;
- prm->ureq[i].pp = prm;
+ prm->reqs[i] = req;
req->zero = 0;
- req->context = &prm->ureq[i];
+ req->context = prm;
req->length = req_len;
req->complete = u_audio_iso_complete;
req->buf = prm->rbuf + i * ep->maxpacket;
}
- if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
+ if (usb_ep_queue(ep, prm->reqs[i], GFP_ATOMIC))
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
}
@@ -450,22 +443,21 @@ int u_audio_start_playback(struct g_audio *audio_dev)
usb_ep_enable(ep);
for (i = 0; i < params->req_number; i++) {
- if (!prm->ureq[i].req) {
+ if (!prm->reqs[i]) {
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
if (req == NULL)
return -ENOMEM;
- prm->ureq[i].req = req;
- prm->ureq[i].pp = prm;
+ prm->reqs[i] = req;
req->zero = 0;
- req->context = &prm->ureq[i];
+ req->context = prm;
req->length = req_len;
req->complete = u_audio_iso_complete;
req->buf = prm->rbuf + i * ep->maxpacket;
}
- if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
+ if (usb_ep_queue(ep, prm->reqs[i], GFP_ATOMIC))
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
}
@@ -510,9 +502,10 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
uac->c_prm.uac = uac;
prm->max_psize = g_audio->out_ep_maxpsize;
- prm->ureq = kcalloc(params->req_number, sizeof(struct uac_req),
- GFP_KERNEL);
- if (!prm->ureq) {
+ prm->reqs = kcalloc(params->req_number,
+ sizeof(struct usb_request *),
+ GFP_KERNEL);
+ if (!prm->reqs) {
err = -ENOMEM;
goto fail;
}
@@ -532,9 +525,10 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
uac->p_prm.uac = uac;
prm->max_psize = g_audio->in_ep_maxpsize;
- prm->ureq = kcalloc(params->req_number, sizeof(struct uac_req),
- GFP_KERNEL);
- if (!prm->ureq) {
+ prm->reqs = kcalloc(params->req_number,
+ sizeof(struct usb_request *),
+ GFP_KERNEL);
+ if (!prm->reqs) {
err = -ENOMEM;
goto fail;
}
@@ -587,8 +581,8 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
snd_fail:
snd_card_free(card);
fail:
- kfree(uac->p_prm.ureq);
- kfree(uac->c_prm.ureq);
+ kfree(uac->p_prm.reqs);
+ kfree(uac->c_prm.reqs);
kfree(uac->p_prm.rbuf);
kfree(uac->c_prm.rbuf);
kfree(uac);
@@ -610,8 +604,8 @@ void g_audio_cleanup(struct g_audio *g_audio)
if (card)
snd_card_free(card);
- kfree(uac->p_prm.ureq);
- kfree(uac->c_prm.ureq);
+ kfree(uac->p_prm.reqs);
+ kfree(uac->c_prm.reqs);
kfree(uac->p_prm.rbuf);
kfree(uac->c_prm.rbuf);
kfree(uac);
--
2.29.2
^ permalink raw reply related
* [PATCH 2/4] usb: gadget: u_audio: factorize ssize to alsa fmt conversion
From: Jerome Brunet @ 2020-12-21 17:35 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Jerome Brunet, Ruslan Bilovol, linux-usb, linux-kernel
In-Reply-To: <20201221173531.215169-1-jbrunet@baylibre.com>
Factorize format related code common to the capture and playback path.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/usb/gadget/function/u_audio.c | 43 +++++++++++++--------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 71dd9f16c246..2f69bd572ed7 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -244,6 +244,25 @@ static snd_pcm_uframes_t uac_pcm_pointer(struct snd_pcm_substream *substream)
return bytes_to_frames(substream->runtime, prm->hw_ptr);
}
+static unsigned long uac_ssize_to_fmt(int ssize)
+{
+ unsigned long ret;
+
+ switch (ssize) {
+ case 3:
+ ret = SNDRV_PCM_FMTBIT_S24_3LE;
+ break;
+ case 4:
+ ret = SNDRV_PCM_FMTBIT_S32_LE;
+ break;
+ default:
+ ret = SNDRV_PCM_FMTBIT_S16_LE;
+ break;
+ }
+
+ return ret;
+}
+
static int uac_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_uac_chip *uac = snd_pcm_substream_chip(substream);
@@ -269,34 +288,14 @@ static int uac_pcm_open(struct snd_pcm_substream *substream)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
spin_lock_init(&uac->p_prm.lock);
runtime->hw.rate_min = p_srate;
- switch (p_ssize) {
- case 3:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
- break;
- case 4:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
- break;
- default:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
- break;
- }
+ runtime->hw.formats = uac_ssize_to_fmt(p_ssize);
runtime->hw.channels_min = num_channels(p_chmask);
runtime->hw.period_bytes_min = 2 * uac->p_prm.max_psize
/ runtime->hw.periods_min;
} else {
spin_lock_init(&uac->c_prm.lock);
runtime->hw.rate_min = c_srate;
- switch (c_ssize) {
- case 3:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
- break;
- case 4:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
- break;
- default:
- runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
- break;
- }
+ runtime->hw.formats = uac_ssize_to_fmt(c_ssize);
runtime->hw.channels_min = num_channels(c_chmask);
runtime->hw.period_bytes_min = 2 * uac->c_prm.max_psize
/ runtime->hw.periods_min;
--
2.29.2
^ permalink raw reply related
* Re: [RFC PATCH 3/3] gpio: ej1x8: Add GPIO driver for Etron Tech Inc. EJ168/EJ188/EJ198
From: Martin Blumenstingl @ 2020-12-21 15:28 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-usb, linux-pci,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list:GPIO SUBSYSTEM, Rob Herring, Bartosz Golaszewski,
linux-kernel@vger.kernel.org, Bjorn Helgaas
In-Reply-To: <CAFBinCCLubmDvxfabQHx2-ucgAsm1NArMUrtPx-UA2nX5xoFFA@mail.gmail.com>
Hi Linus,
On Wed, Oct 7, 2020 at 9:44 PM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
[...]
> > As noted on the earlier patches I think this should be folded into the
> > existing XHCI USB driver in drivers/usb/host/xhci-pci.c or, if that
> > gets messy, as a separate bolt-on, something like
> > xhci-pci-gpio.[c|h] in the drivers/usb/host/* directory.
> > You can use a Kconfig symbol for the GPIO portions or not.
> OK, I will do that if there are no objections from other developers
> I am intending to place the relevant code in xhci-pci-etron.c, similar
> to what we already have with xhci-pci-renesas.c
I tried this and unfortunately there's a catch.
the nice thing about having a separate GPIO driver means that the
xhci-pci driver doesn't need to know about it.
I implemented xhci-pci-etron.c and gave it a Kconfig option.
xhci-pci is then calling into xhci-pci-etron (through some
etron_xhci_pci_probe function).
unfortunately this means that xhci-pci now depends on xhci-pci-etron.
for xhci-pci-renesas this is fine (I think) because that part of the
code is needed to get the xHCI controller going
but for xhci-pci-etron this is a different story: the GPIO controller
is entirely optional and only used on few devices
my goal is (at some point in the future) to have the GPIO driver in OpenWrt.
I am not sure if they would accept a patch where xhci-pci would then
pull in the dependencies for that Etron controller, even though most
boards don't need it.
Please let me know if you have any idea on how to solve this.
Best regards,
Martin
^ permalink raw reply
* [PATCH 0/4] usb: gadget: audio fixes and clean ups
From: Jerome Brunet @ 2020-12-21 17:35 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Jerome Brunet, Ruslan Bilovol, linux-usb, linux-kernel
This patchset is a collection of fixes and clean ups found while
working on the uac2 gadget. Details are provided in each change.
The series depends on this fix [0] by Jack Pham to apply cleanly
[0]: https://lore.kernel.org/linux-usb/20201029175949.6052-1-jackp@codeaurora.org/
Jerome Brunet (4):
usb: gadget: f_uac2: reset wMaxPacketSize
usb: gadget: u_audio: factorize ssize to alsa fmt conversion
usb: gadget: u_audio: remove struct uac_req
usb: gadget: u_audio: clean up locking
drivers/usb/gadget/function/f_uac2.c | 69 ++++++++++++---
drivers/usb/gadget/function/u_audio.c | 122 +++++++++++---------------
2 files changed, 105 insertions(+), 86 deletions(-)
--
2.29.2
^ permalink raw reply
* Re: [RESEND PATCH v3 2/2] usb: dwc3: Add driver for Xilinx platforms
From: Michael Tretter @ 2020-12-21 18:05 UTC (permalink / raw)
To: Manish Narani
Cc: gregkh, robh+dt, michal.simek, balbi, p.zabel, devicetree,
linux-usb, linux-kernel, git, linux-arm-kernel
In-Reply-To: <1608015291-52007-3-git-send-email-manish.narani@xilinx.com>
On Tue, 15 Dec 2020 12:24:51 +0530, Manish Narani wrote:
> Add a new driver for supporting Xilinx platforms. This driver is used
> for some sequence of operations required for Xilinx USB controllers.
> This driver is also used to choose between PIPE clock coming from SerDes
> and the Suspend Clock. Before the controller is out of reset, the clock
> selection should be changed to PIPE clock in order to make the USB
> controller work. There is a register added in Xilinx USB controller
> register space for the same.
>
> Signed-off-by: Manish Narani <manish.narani@xilinx.com>
> ---
> drivers/usb/dwc3/Kconfig | 9 +
> drivers/usb/dwc3/Makefile | 1 +
> drivers/usb/dwc3/dwc3-of-simple.c | 1 -
> drivers/usb/dwc3/dwc3-xilinx.c | 334 ++++++++++++++++++++++++++++++
> 4 files changed, 344 insertions(+), 1 deletion(-)
> create mode 100644 drivers/usb/dwc3/dwc3-xilinx.c
>
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index 7a2304565a73..0e00e6dfccd8 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -139,4 +139,13 @@ config USB_DWC3_QCOM
> for peripheral mode support.
> Say 'Y' or 'M' if you have one such device.
>
> +config USB_DWC3_XILINX
> + tristate "Xilinx Platforms"
> + depends on (ARCH_ZYNQMP || ARCH_VERSAL) && OF
> + default USB_DWC3
> + help
> + Support Xilinx SoCs with DesignWare Core USB3 IP.
> + This driver handles both ZynqMP and Versal SoC operations.
> + Say 'Y' or 'M' if you have one such device.
> +
> endif
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index ae86da0dc5bd..add567578b1f 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -51,3 +51,4 @@ obj-$(CONFIG_USB_DWC3_MESON_G12A) += dwc3-meson-g12a.o
> obj-$(CONFIG_USB_DWC3_OF_SIMPLE) += dwc3-of-simple.o
> obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
> obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o
> +obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o
> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
> index e62ecd22b3ed..71fd620c5161 100644
> --- a/drivers/usb/dwc3/dwc3-of-simple.c
> +++ b/drivers/usb/dwc3/dwc3-of-simple.c
> @@ -172,7 +172,6 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
>
> static const struct of_device_id of_dwc3_simple_match[] = {
> { .compatible = "rockchip,rk3399-dwc3" },
> - { .compatible = "xlnx,zynqmp-dwc3" },
> { .compatible = "cavium,octeon-7130-usb-uctl" },
> { .compatible = "sprd,sc9860-dwc3" },
> { .compatible = "allwinner,sun50i-h6-dwc3" },
> diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
> new file mode 100644
> index 000000000000..7e485951d2f7
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-xilinx.c
> @@ -0,0 +1,334 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/**
> + * dwc3-xilinx.c - Xilinx DWC3 controller specific glue driver
> + *
> + * Authors: Manish Narani <manish.narani@xilinx.com>
> + * Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/slab.h>
> +#include <linux/clk.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/of_platform.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/reset.h>
> +#include <linux/of_address.h>
> +#include <linux/delay.h>
> +#include <linux/firmware/xlnx-zynqmp.h>
> +#include <linux/io.h>
> +
> +#include <linux/phy/phy.h>
> +
> +/* USB phy reset mask register */
> +#define XLNX_USB_PHY_RST_EN 0x001C
> +#define XLNX_PHY_RST_MASK 0x1
> +
> +/* Xilinx USB 3.0 IP Register */
> +#define XLNX_USB_TRAFFIC_ROUTE_CONFIG 0x005C
> +#define XLNX_USB_TRAFFIC_ROUTE_FPD 0x1
> +
> +/* Versal USB Reset ID */
> +#define VERSAL_USB_RESET_ID 0xC104036
> +
> +#define XLNX_USB_FPD_PIPE_CLK 0x7c
> +#define PIPE_CLK_DESELECT 1
> +#define PIPE_CLK_SELECT 0
> +#define XLNX_USB_FPD_POWER_PRSNT 0x80
> +#define PIPE_POWER_ON 1
> +#define PIPE_POWER_OFF 0
Don't use values for the defines, but rather define the bit. Its name in the
register reference is "option". Therefore, define it as
#define FPD_POWER_PRSNT_OPTION BIT(0)
and set/unset the bit in the code. The same for the other registers/bits.
> +
> +struct dwc3_xlnx {
> + int num_clocks;
> + struct clk_bulk_data *clks;
> + struct device *dev;
> + void __iomem *regs;
> + int (*pltfm_init)(struct dwc3_xlnx *data);
> +};
> +
> +static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
> +{
> + u32 reg;
> +
> + /*
> + * Enable or disable ULPI PHY reset from USB Controller.
> + * This does not actually reset the phy, but just controls
> + * whether USB controller can or cannot reset ULPI PHY.
> + */
> + reg = readl(priv_data->regs + XLNX_USB_PHY_RST_EN);
> +
> + if (mask)
> + reg &= ~XLNX_PHY_RST_MASK;
> + else
> + reg |= XLNX_PHY_RST_MASK;
> +
> + writel(reg, priv_data->regs + XLNX_USB_PHY_RST_EN);
> +}
> +
> +static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
> +{
> + struct device *dev = priv_data->dev;
> + int ret;
> +
> + dwc3_xlnx_mask_phy_rst(priv_data, false);
> +
> + /* Assert and De-assert reset */
> + ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
> + PM_RESET_ACTION_ASSERT);
> + if (ret < 0) {
> + dev_err_probe(dev, ret, "failed to assert Reset\n");
> + return ret;
> + }
> +
> + ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
> + PM_RESET_ACTION_RELEASE);
> + if (ret < 0) {
> + dev_err_probe(dev, ret, "failed to De-assert Reset\n");
> + return ret;
> + }
> +
> + dwc3_xlnx_mask_phy_rst(priv_data, true);
> +
> + return 0;
> +}
> +
> +static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
> +{
> + struct device *dev = priv_data->dev;
> + struct reset_control *crst, *hibrst, *apbrst;
> + struct phy *usb3_phy;
> + int ret;
> + u32 reg;
> +
> + crst = devm_reset_control_get_exclusive(dev, "usb_crst");
The resets and reset-names are not documented in the dt-binding.
> + if (IS_ERR(crst)) {
> + ret = PTR_ERR(crst);
> + dev_err_probe(dev, ret,
> + "failed to get core reset signal\n");
> + goto err;
> + }
> +
> + hibrst = devm_reset_control_get_exclusive(dev, "usb_hibrst");
> + if (IS_ERR(hibrst)) {
> + ret = PTR_ERR(hibrst);
> + dev_err_probe(dev, ret,
> + "failed to get hibernation reset signal\n");
> + goto err;
> + }
> +
> + apbrst = devm_reset_control_get_exclusive(dev, "usb_apbrst");
> + if (IS_ERR(apbrst)) {
> + ret = PTR_ERR(apbrst);
> + dev_err_probe(dev, ret,
> + "failed to get APB reset signal\n");
> + goto err;
> + }
> +
> + ret = reset_control_assert(crst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to assert core reset\n");
> + goto err;
> + }
> +
> + ret = reset_control_assert(hibrst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to assert hibernation reset\n");
> + goto err;
> + }
> +
> + ret = reset_control_assert(apbrst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to assert APB reset\n");
> + goto err;
> + }
> +
> + usb3_phy = devm_phy_get(dev, "usb3-phy");
Error handling is missing.
The "usb3-phy" phy binding in not documented in the dt-binding.
Thanks,
Michael
> +
> + ret = phy_init(usb3_phy);
> + if (ret < 0) {
> + phy_exit(usb3_phy);
> + goto err;
> + }
> +
> + ret = reset_control_deassert(apbrst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to release APB reset\n");
> + goto err;
> + }
> +
> + /* Set PIPE Power Present signal in FPD Power Present Register*/
> + writel(PIPE_POWER_ON, priv_data->regs + XLNX_USB_FPD_POWER_PRSNT);
> +
> + /* Set the PIPE Clock Select bit in FPD PIPE Clock register */
> + writel(PIPE_CLK_SELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
> +
> + ret = reset_control_deassert(crst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to release core reset\n");
> + goto err;
> + }
> +
> + ret = reset_control_deassert(hibrst);
> + if (ret < 0) {
> + dev_err(dev, "Failed to release hibernation reset\n");
> + goto err;
> + }
> +
> + ret = phy_power_on(usb3_phy);
> + if (ret < 0) {
> + phy_exit(usb3_phy);
> + goto err;
> + }
> +
> + /*
> + * This routes the USB DMA traffic to go through FPD path instead
> + * of reaching DDR directly. This traffic routing is needed to
> + * make SMMU and CCI work with USB DMA.
> + */
> + if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
> + reg = readl(priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
> + reg |= XLNX_USB_TRAFFIC_ROUTE_FPD;
> + writel(reg, priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
> + }
> +
> +err:
> + return ret;
> +}
> +
> +static const struct of_device_id dwc3_xlnx_of_match[] = {
> + {
> + .compatible = "xlnx,zynqmp-dwc3",
> + .data = &dwc3_xlnx_init_zynqmp,
> + },
> + {
> + .compatible = "xlnx,versal-dwc3",
> + .data = &dwc3_xlnx_init_versal,
> + },
> + { /* Sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, dwc3_xlnx_of_match);
> +
> +static int dwc3_xlnx_probe(struct platform_device *pdev)
> +{
> + struct dwc3_xlnx *priv_data;
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
> + const struct of_device_id *match;
> + void __iomem *regs;
> + int ret;
> +
> + priv_data = devm_kzalloc(dev, sizeof(*priv_data), GFP_KERNEL);
> + if (!priv_data)
> + return -ENOMEM;
> +
> + regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(regs)) {
> + ret = PTR_ERR(regs);
> + dev_err_probe(dev, ret, "failed to map registers\n");
> + return ret;
> + }
> +
> + match = of_match_node(dwc3_xlnx_of_match, pdev->dev.of_node);
> +
> + priv_data->pltfm_init = match->data;
> + priv_data->regs = regs;
> + priv_data->dev = dev;
> +
> + platform_set_drvdata(pdev, priv_data);
> +
> + ret = devm_clk_bulk_get_all(priv_data->dev, &priv_data->clks);
> + if (ret < 0)
> + return ret;
> +
> + priv_data->num_clocks = ret;
> +
> + ret = clk_bulk_prepare_enable(priv_data->num_clocks, priv_data->clks);
> + if (ret)
> + return ret;
> +
> + ret = priv_data->pltfm_init(priv_data);
> + if (ret)
> + goto err_clk_put;
> +
> + ret = of_platform_populate(np, NULL, NULL, dev);
> + if (ret)
> + goto err_clk_put;
> +
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + pm_suspend_ignore_children(dev, false);
> + pm_runtime_get_sync(dev);
> +
> + return 0;
> +
> +err_clk_put:
> + clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
> + clk_bulk_put_all(priv_data->num_clocks, priv_data->clks);
> +
> + return ret;
> +}
> +
> +static int dwc3_xlnx_remove(struct platform_device *pdev)
> +{
> + struct dwc3_xlnx *priv_data = platform_get_drvdata(pdev);
> + struct device *dev = &pdev->dev;
> +
> + of_platform_depopulate(dev);
> +
> + clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
> + clk_bulk_put_all(priv_data->num_clocks, priv_data->clks);
> + priv_data->num_clocks = 0;
> +
> + pm_runtime_disable(dev);
> + pm_runtime_put_noidle(dev);
> + pm_runtime_set_suspended(dev);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused dwc3_xlnx_suspend_common(struct device *dev)
> +{
> + struct dwc3_xlnx *priv_data = dev_get_drvdata(dev);
> +
> + clk_bulk_disable(priv_data->num_clocks, priv_data->clks);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused dwc3_xlnx_resume_common(struct device *dev)
> +{
> + struct dwc3_xlnx *priv_data = dev_get_drvdata(dev);
> +
> + return clk_bulk_enable(priv_data->num_clocks, priv_data->clks);
> +}
> +
> +static int __maybe_unused dwc3_xlnx_runtime_idle(struct device *dev)
> +{
> + pm_runtime_mark_last_busy(dev);
> + pm_runtime_autosuspend(dev);
> +
> + return 0;
> +}
> +
> +static UNIVERSAL_DEV_PM_OPS(dwc3_xlnx_dev_pm_ops, dwc3_xlnx_suspend_common,
> + dwc3_xlnx_resume_common, dwc3_xlnx_runtime_idle);
> +
> +static struct platform_driver dwc3_xlnx_driver = {
> + .probe = dwc3_xlnx_probe,
> + .remove = dwc3_xlnx_remove,
> + .driver = {
> + .name = "dwc3-xilinx",
> + .of_match_table = dwc3_xlnx_of_match,
> + .pm = &dwc3_xlnx_dev_pm_ops,
> + },
> +};
> +
> +module_platform_driver(dwc3_xlnx_driver);
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("Xilinx DWC3 controller specific glue driver");
> +MODULE_AUTHOR("Manish Narani <manish.narani@xilinx.com>");
> +MODULE_AUTHOR("Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>");
> --
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
Pengutronix e.K. | Michael Tretter |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* [PATCH 1/4] usb: gadget: f_uac2: reset wMaxPacketSize
From: Jerome Brunet @ 2020-12-21 17:35 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Jerome Brunet, Ruslan Bilovol, linux-usb, linux-kernel
In-Reply-To: <20201221173531.215169-1-jbrunet@baylibre.com>
With commit 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
wMaxPacketSize is computed dynamically but the value is never reset.
Because of this, the actual maximum packet size can only decrease each time
the audio gadget is instantiated.
Reset the endpoint maximum packet size and mark wMaxPacketSize as dynamic
to solve the problem.
Fixes: 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/usb/gadget/function/f_uac2.c | 69 ++++++++++++++++++++++------
1 file changed, 55 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 3633df6d7610..5d960b6603b6 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -271,7 +271,7 @@ static struct usb_endpoint_descriptor fs_epout_desc = {
.bEndpointAddress = USB_DIR_OUT,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
- .wMaxPacketSize = cpu_to_le16(1023),
+ /* .wMaxPacketSize = DYNAMIC */
.bInterval = 1,
};
@@ -280,7 +280,7 @@ static struct usb_endpoint_descriptor hs_epout_desc = {
.bDescriptorType = USB_DT_ENDPOINT,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
- .wMaxPacketSize = cpu_to_le16(1024),
+ /* .wMaxPacketSize = DYNAMIC */
.bInterval = 4,
};
@@ -348,7 +348,7 @@ static struct usb_endpoint_descriptor fs_epin_desc = {
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
- .wMaxPacketSize = cpu_to_le16(1023),
+ /* .wMaxPacketSize = DYNAMIC */
.bInterval = 1,
};
@@ -357,7 +357,7 @@ static struct usb_endpoint_descriptor hs_epin_desc = {
.bDescriptorType = USB_DT_ENDPOINT,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
- .wMaxPacketSize = cpu_to_le16(1024),
+ /* .wMaxPacketSize = DYNAMIC */
.bInterval = 4,
};
@@ -444,12 +444,28 @@ struct cntrl_range_lay3 {
__le32 dRES;
} __packed;
-static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
+static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
struct usb_endpoint_descriptor *ep_desc,
- unsigned int factor, bool is_playback)
+ enum usb_device_speed speed, bool is_playback)
{
int chmask, srate, ssize;
- u16 max_packet_size;
+ u16 max_size_bw, max_size_ep;
+ unsigned int factor;
+
+ switch (speed) {
+ case USB_SPEED_FULL:
+ max_size_ep = 1023;
+ factor = 1000;
+ break;
+
+ case USB_SPEED_HIGH:
+ max_size_ep = 1024;
+ factor = 8000;
+ break;
+
+ default:
+ return -EINVAL;
+ }
if (is_playback) {
chmask = uac2_opts->p_chmask;
@@ -461,10 +477,12 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
ssize = uac2_opts->c_ssize;
}
- max_packet_size = num_channels(chmask) * ssize *
+ max_size_bw = num_channels(chmask) * ssize *
DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
- ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_packet_size,
- le16_to_cpu(ep_desc->wMaxPacketSize)));
+ ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
+ max_size_ep));
+
+ return 0;
}
/* Use macro to overcome line length limitation */
@@ -670,10 +688,33 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
}
/* Calculate wMaxPacketSize according to audio bandwidth */
- set_ep_max_packet_size(uac2_opts, &fs_epin_desc, 1000, true);
- set_ep_max_packet_size(uac2_opts, &fs_epout_desc, 1000, false);
- set_ep_max_packet_size(uac2_opts, &hs_epin_desc, 8000, true);
- set_ep_max_packet_size(uac2_opts, &hs_epout_desc, 8000, false);
+ ret = set_ep_max_packet_size(uac2_opts, &fs_epin_desc, USB_SPEED_FULL,
+ true);
+ if (ret < 0) {
+ dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
+ return ret;
+ }
+
+ ret = set_ep_max_packet_size(uac2_opts, &fs_epout_desc, USB_SPEED_FULL,
+ false);
+ if (ret < 0) {
+ dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
+ return ret;
+ }
+
+ ret = set_ep_max_packet_size(uac2_opts, &hs_epin_desc, USB_SPEED_HIGH,
+ true);
+ if (ret < 0) {
+ dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
+ return ret;
+ }
+
+ ret = set_ep_max_packet_size(uac2_opts, &hs_epout_desc, USB_SPEED_HIGH,
+ false);
+ if (ret < 0) {
+ dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
+ return ret;
+ }
if (EPOUT_EN(uac2_opts)) {
agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
--
2.29.2
^ permalink raw reply related
* [PATCH 4/4] usb: gadget: u_audio: clean up locking
From: Jerome Brunet @ 2020-12-21 17:35 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman
Cc: Jerome Brunet, Ruslan Bilovol, linux-usb, linux-kernel
In-Reply-To: <20201221173531.215169-1-jbrunet@baylibre.com>
snd_pcm_stream_lock() is held when the ALSA .trigger() callback is called.
The lock of 'struct uac_rtd_params' is not necessary since all its locking
operation are done under the snd_pcm_stream_lock() too.
Also, usb_request .complete() is called with irqs disabled, so saving and
restoring the irqs is not necessary.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/usb/gadget/function/u_audio.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 3eba31b8ebcb..d94f95edca40 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -36,9 +36,8 @@ struct uac_rtd_params {
void *rbuf;
unsigned int max_psize; /* MaxPacketSize of endpoint */
- struct usb_request **reqs;
- spinlock_t lock;
+ struct usb_request **reqs;
};
struct snd_uac_chip {
@@ -74,7 +73,6 @@ static const struct snd_pcm_hardware uac_pcm_hardware = {
static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
{
unsigned int pending;
- unsigned long flags, flags2;
unsigned int hw_ptr;
int status = req->status;
struct snd_pcm_substream *substream;
@@ -105,16 +103,14 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
if (!substream)
goto exit;
- snd_pcm_stream_lock_irqsave(substream, flags2);
+ snd_pcm_stream_lock(substream);
runtime = substream->runtime;
if (!runtime || !snd_pcm_running(substream)) {
- snd_pcm_stream_unlock_irqrestore(substream, flags2);
+ snd_pcm_stream_unlock(substream);
goto exit;
}
- spin_lock_irqsave(&prm->lock, flags);
-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
/*
* For each IN packet, take the quotient of the current data
@@ -141,8 +137,6 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
hw_ptr = prm->hw_ptr;
- spin_unlock_irqrestore(&prm->lock, flags);
-
/* Pack USB load in ALSA ring buffer */
pending = runtime->dma_bytes - hw_ptr;
@@ -166,12 +160,10 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
}
}
- spin_lock_irqsave(&prm->lock, flags);
/* update hw_ptr after data is copied to memory */
prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes;
hw_ptr = prm->hw_ptr;
- spin_unlock_irqrestore(&prm->lock, flags);
- snd_pcm_stream_unlock_irqrestore(substream, flags2);
+ snd_pcm_stream_unlock(substream);
if ((hw_ptr % snd_pcm_lib_period_bytes(substream)) < req->actual)
snd_pcm_period_elapsed(substream);
@@ -187,7 +179,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
struct uac_rtd_params *prm;
struct g_audio *audio_dev;
struct uac_params *params;
- unsigned long flags;
int err = 0;
audio_dev = uac->audio_dev;
@@ -198,8 +189,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
else
prm = &uac->c_prm;
- spin_lock_irqsave(&prm->lock, flags);
-
/* Reset */
prm->hw_ptr = 0;
@@ -216,8 +205,6 @@ static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
err = -EINVAL;
}
- spin_unlock_irqrestore(&prm->lock, flags);
-
/* Clear buffer after Play stops */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !prm->ss)
memset(prm->rbuf, 0, prm->max_psize * params->req_number);
@@ -280,14 +267,12 @@ static int uac_pcm_open(struct snd_pcm_substream *substream)
runtime->hw = uac_pcm_hardware;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- spin_lock_init(&uac->p_prm.lock);
runtime->hw.rate_min = p_srate;
runtime->hw.formats = uac_ssize_to_fmt(p_ssize);
runtime->hw.channels_min = num_channels(p_chmask);
runtime->hw.period_bytes_min = 2 * uac->p_prm.max_psize
/ runtime->hw.periods_min;
} else {
- spin_lock_init(&uac->c_prm.lock);
runtime->hw.rate_min = c_srate;
runtime->hw.formats = uac_ssize_to_fmt(c_ssize);
runtime->hw.channels_min = num_channels(c_chmask);
--
2.29.2
^ permalink raw reply related
* [Bug 210801] TopSeed Technology Corp. eHome Infrared Transceiver spams log with Error: urb status = -71
From: bugzilla-daemon @ 2020-12-21 17:09 UTC (permalink / raw)
To: linux-usb
In-Reply-To: <bug-210801-208809@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=210801
--- Comment #2 from Alan Stern (stern@rowland.harvard.edu) ---
There are two things you can do to help solve the problem. The first is to use
git bisect to find the kernel change which caused the error messages to start
appearing.
The second is to capture some usbmon traces (see Documentation/usb/usbmon.rst
in the kernel source). Comparing a trace from the current kernel with a trace
from an earlier kernel where the errors don't appear might provide some clues.
--
You may reply to this email to add a comment.
You are receiving this mail because:
You are watching the assignee of the bug.
^ permalink raw reply
* [PATCH] usb: musb: add printf attribute to log function
From: trix @ 2020-12-21 16:25 UTC (permalink / raw)
To: b-liu, gregkh; +Cc: linux-usb, linux-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
Attributing the function allows the compiler to more thoroughly
check the use of the function with -Wformat and similar flags.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/usb/musb/musb_debug.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h
index e5b3506c7b3f..dfc0d02695fa 100644
--- a/drivers/usb/musb/musb_debug.h
+++ b/drivers/usb/musb/musb_debug.h
@@ -17,6 +17,7 @@
#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
+__printf(2, 3)
void musb_dbg(struct musb *musb, const char *fmt, ...);
#ifdef CONFIG_DEBUG_FS
--
2.27.0
^ permalink raw reply related
* Re: port power is on again after turning off by user space
From: Alan Stern @ 2020-12-21 16:25 UTC (permalink / raw)
To: Peter Chen; +Cc: Jun Li, linux-usb@vger.kernel.org
In-Reply-To: <20201221053659.GA26433@b29397-desktop>
On Mon, Dec 21, 2020 at 05:37:29AM +0000, Peter Chen wrote:
> On 20-12-16 10:51:44, Alan Stern wrote:
> > On Wed, Dec 16, 2020 at 02:56:20AM +0000, Peter Chen wrote:
> > > On 20-12-15 10:55:41, Alan Stern wrote:
> > > > You've got the general idea.
> > > >
> > > > Normally ports are owned by the hub driver. If one of them loses power
> > > > for some reason (for example, the user turns it off), the hub driver
> > > > will turn the power back on. This is because the hub driver wants
> > > > ports to be powered at all times unless they are in runtime suspend.
> > > >
> > > > The way to prevent the hub driver from managing the port power is to
> > > > claim the port for the user, by issuing the USBDEVFS_CLAIM_PORT ioctl.
> > > > Also, when that is done, the kernel wno't try to manage a device
> > > > attached to the port -- that is, the kernel won't automatically install
> > > > a configuration for a new device and it won't try to probe drivers for
> > > > the device's interfaces if the user installs a config.
> > > >
> > >
> > > Alan, we have several use cases for power switchable HUB, one of the use
> > > cases is USB port is managed by kernel (eg, needs mass storage
> > > class), but needs to toggle port power, is it reasonable we add a sysfs
> > > entry to support it?
> >
> > Can you give more information about your use cases? After all, if the
> > port power is turned off then the port can't possibly handle
> > mass-storage devices -- or anything else.
>
> Sorry, Alan. Due to holiday season, the U.S team doesn't reply me the
> use case. I think the basic use cases are emulate the hot-plug test for
> USB devices, the USB devices could be Flash Drive on market or DUT (Device
> Under test) for the same controller works at device mode. Assume one
> typical test case:
>
> Plug in Flash Drive at port 1-1.1 during the boots up:
>
> while (1) {
> - Check Flash Drive is there (eg, cat /proc/partitions)
> - Turn port 1 at 1-1 off
> - Check Flash Drive is gone
> - Turn port 1 at 1-1 on
> }
Okay. This can be done as follows:
while (1) {
- Check Flash Drive is there (eg, cat /proc/partitions)
- Claim port 1 on 1-1
- Turn port 1 at 1-1 off
- Check Flash Drive is gone
- Release port 1 on 1-1
- Turn port 1 at 1-1 on
- Delay for 10 seconds (time for device probing)
}
> > On the other hand, if the port is managed by the kernel then the kernel
> > (not the user) should be responsible for deciding whether or not to
> > turn off the port's power.
> >
> > If there's some real reason for turning the port power off for an
> > extended period of time, the user can claim the port and turn off the
> > power. Then later on, the user can release the port and turn the power
> > back on.
> >
>
> Yes, I think this is one of the use cases. We want power power control
> at one application (A), but different with our test application(B), it means
> if the user claims the port, and power off using A, then the A will end.
> After the B finished running, A runs again for power on, but at this time,
> the port owner has changed.
Yes, that won't work. If you want to keep the port power turned off
then you have to keep the usbfs device file open -- which means your
program A must not end and then restart.
(Acutally, I'm not certain about that. If you claim a port, turn off
its power, and then release the port, I don't remember whether the hub
driver will then turn the power back on right away. It might not.
But in any case, it isn't good programming to release a port without
turning its power back on.)
Can A be rewritten so that it doesn't end when B is running?
ALan Stern
^ permalink raw reply
* [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT quirk
From: Pali Rohár @ 2020-12-21 15:09 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman, Peter Chen
Cc: Jun Li, linux-usb, linux-kernel
Currently init_quirk callbacks for xhci platform drivers are called
xhci_plat_setup() function which is called after chip reset completes.
It happens in the middle of the usb_add_hcd() function.
But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
currently does nothing as prior xhci_plat_setup() it is not set.
Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
which really needs to be set prior calling usb_add_hcd() as this function
at its beginning skips PHY init if this member is set.
This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
XHCI_SKIP_PHY_INIT is set.
Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/usb/host/xhci-plat.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 4d34f6005381..58704c5b002b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
/* called during probe() after chip reset completes */
static int xhci_plat_setup(struct usb_hcd *hcd)
{
- int ret;
-
-
- ret = xhci_priv_init_quirk(hcd);
- if (ret)
- return ret;
-
return xhci_gen_setup(hcd, xhci_plat_quirks);
}
@@ -330,6 +323,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
xhci->shared_hcd->tpl_support = hcd->tpl_support;
+
+ if (priv) {
+ ret = xhci_priv_init_quirk(hcd);
+ if (ret)
+ goto disable_usb_phy;
+ }
+
if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
hcd->skip_phy_initialization = 1;
--
2.20.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox