From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] usb: dwc3: host: inherit dma configuration from parent dev
Date: Thu, 08 Sep 2016 10:26:05 +0200 [thread overview]
Message-ID: <6739240.VDAnDBppH0@wuerfel> (raw)
In-Reply-To: <8737lakedd.fsf@linux.intel.com>
On Thursday, September 8, 2016 11:03:10 AM CEST Felipe Balbi wrote:
> Arnd Bergmann <arnd@arndb.de> writes:
> >> Arnd Bergmann <arnd@arndb.de> writes:
> just look at the history of the file, you'll see that an Intel employee
> was a maintainer of chipidea driver. Also:
>
> $ git ls-files drivers/usb/chipidea/ | grep pci
> drivers/usb/chipidea/ci_hdrc_pci.c
Right, Peter pointed that one out too.
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index 35d092456bec..08db66c64c66 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -25,6 +25,7 @@
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <linux/platform_device.h>
> > +#include <linux/pci.h>
>
> actually, we don't want the core to know what it's attached to.
Agreed. This was just a first draft and I couldn't come up with
a better way to detect the case in which the parent device is
probed from another HW bus and the child is not known to the
firmware.
> > #include <linux/pm_runtime.h>
> > #include <linux/interrupt.h>
> > #include <linux/ioport.h>
> > @@ -178,7 +179,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
> > static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
> > struct dwc3_event_buffer *evt)
> > {
> > - dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
> > + dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma);
>
> how about "dma_dev" instead? Is this used for anything other than DMA?
The two other things we have discussed in this thread are:
- connecting of_node pointers to usb_device structures for children
of sysdev->of_node. Note that this can happen even for PCI devices
in case you have a USB ethernet device hardwired to a PCI-USB bridge
and put the mac address in DT.
- finding the PHY device for a HCD
There might be others. Basically sysdev here is what the USB core code
can use for looking up any kind of properties provided by the firmware.
> > @@ -846,6 +847,13 @@ static int dwc3_probe(struct platform_device *pdev)
> > dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
> > dwc->mem = mem;
> > dwc->dev = dev;
> > +#ifdef CONFIG_PCI
> > + /* TODO: or some other way of detecting this? */
> > + if (dwc->dev->parent && dwc->dev->parent->bus == &pci_bus_type)
> > + dwc->sysdev = dwc->dev->parent;
> > + else
> > +#endif
> > + dwc->sysdev = dwc->dev;
>
> Well, we can remove this ifdef and *always* use the parent. We will just
> require that dwc3 users provide a glue layer. In that case, your check
> becomes:
>
> if (dwc->dev->parent)
> dwc->sysdev = dwc->dev->parent;
> else
> dev_info(dwc->dev, "Please provide a glue layer!\n");
If we do that, we have to put child devices of the dwc3 devices into
the platform glue, and it also breaks those dwc3 devices that don't
have a parent driver.
> > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
> > index 2f1fb7e7aa54..e27899bb5706 100644
> > --- a/drivers/usb/dwc3/dwc3-exynos.c
> > +++ b/drivers/usb/dwc3/dwc3-exynos.c
> > @@ -20,7 +20,6 @@
> > #include <linux/kernel.h>
> > #include <linux/slab.h>
> > #include <linux/platform_device.h>
> > -#include <linux/dma-mapping.h>
> > #include <linux/clk.h>
> > #include <linux/usb/otg.h>
> > #include <linux/usb/usb_phy_generic.h>
> > @@ -117,15 +116,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
> > if (!exynos)
> > return -ENOMEM;
> >
> > - /*
> > - * Right now device-tree probed devices don't get dma_mask set.
> > - * Since shared usb code relies on it, set it here for now.
> > - * Once we move to full device tree support this will vanish off.
> > - */
> > - ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
> > - if (ret)
> > - return ret;
>
> this is a separate patch, right?
Yes, this is probably just a cleanup that we can apply regardless.
We have not needed this in a long time.
> > diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> > index 89a2f712fdfe..4d7439cb8cd8 100644
> > --- a/drivers/usb/dwc3/dwc3-st.c
> > +++ b/drivers/usb/dwc3/dwc3-st.c
> > @@ -218,7 +218,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
> > if (IS_ERR(regmap))
> > return PTR_ERR(regmap);
> >
> > - dma_set_coherent_mask(dev, dev->coherent_dma_mask);
>
> so is this.
>
> All in all, I like where you're going with this, we just need a matching
> acpi_dma_configure() and problems will be sorted out.
With this patch, I don't think we even need that any more, as the device
that we use the dma-mapping API is the one that already gets configured
correctly by the platform code for all cases: PCI, OF, ACPI and combinations
of those.
Arnd
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Felipe Balbi <balbi@kernel.org>
Cc: Peter Chen <hzpeterchen@gmail.com>, Leo Li <pku.leo@gmail.com>,
Grygorii Strashko <grygorii.strashko@ti.com>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Sekhar Nori <nsekhar@ti.com>, lkml <linux-kernel@vger.kernel.org>,
Stuart Yoder <stuart.yoder@nxp.com>,
Scott Wood <oss@buserror.net>,
David Fisher <david.fisher1@synopsys.com>,
"Thang Q. Nguyen" <tqnguyen@apm.com>,
Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] usb: dwc3: host: inherit dma configuration from parent dev
Date: Thu, 08 Sep 2016 10:26:05 +0200 [thread overview]
Message-ID: <6739240.VDAnDBppH0@wuerfel> (raw)
In-Reply-To: <8737lakedd.fsf@linux.intel.com>
On Thursday, September 8, 2016 11:03:10 AM CEST Felipe Balbi wrote:
> Arnd Bergmann <arnd@arndb.de> writes:
> >> Arnd Bergmann <arnd@arndb.de> writes:
> just look at the history of the file, you'll see that an Intel employee
> was a maintainer of chipidea driver. Also:
>
> $ git ls-files drivers/usb/chipidea/ | grep pci
> drivers/usb/chipidea/ci_hdrc_pci.c
Right, Peter pointed that one out too.
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > index 35d092456bec..08db66c64c66 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -25,6 +25,7 @@
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <linux/platform_device.h>
> > +#include <linux/pci.h>
>
> actually, we don't want the core to know what it's attached to.
Agreed. This was just a first draft and I couldn't come up with
a better way to detect the case in which the parent device is
probed from another HW bus and the child is not known to the
firmware.
> > #include <linux/pm_runtime.h>
> > #include <linux/interrupt.h>
> > #include <linux/ioport.h>
> > @@ -178,7 +179,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
> > static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
> > struct dwc3_event_buffer *evt)
> > {
> > - dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
> > + dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma);
>
> how about "dma_dev" instead? Is this used for anything other than DMA?
The two other things we have discussed in this thread are:
- connecting of_node pointers to usb_device structures for children
of sysdev->of_node. Note that this can happen even for PCI devices
in case you have a USB ethernet device hardwired to a PCI-USB bridge
and put the mac address in DT.
- finding the PHY device for a HCD
There might be others. Basically sysdev here is what the USB core code
can use for looking up any kind of properties provided by the firmware.
> > @@ -846,6 +847,13 @@ static int dwc3_probe(struct platform_device *pdev)
> > dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
> > dwc->mem = mem;
> > dwc->dev = dev;
> > +#ifdef CONFIG_PCI
> > + /* TODO: or some other way of detecting this? */
> > + if (dwc->dev->parent && dwc->dev->parent->bus == &pci_bus_type)
> > + dwc->sysdev = dwc->dev->parent;
> > + else
> > +#endif
> > + dwc->sysdev = dwc->dev;
>
> Well, we can remove this ifdef and *always* use the parent. We will just
> require that dwc3 users provide a glue layer. In that case, your check
> becomes:
>
> if (dwc->dev->parent)
> dwc->sysdev = dwc->dev->parent;
> else
> dev_info(dwc->dev, "Please provide a glue layer!\n");
If we do that, we have to put child devices of the dwc3 devices into
the platform glue, and it also breaks those dwc3 devices that don't
have a parent driver.
> > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
> > index 2f1fb7e7aa54..e27899bb5706 100644
> > --- a/drivers/usb/dwc3/dwc3-exynos.c
> > +++ b/drivers/usb/dwc3/dwc3-exynos.c
> > @@ -20,7 +20,6 @@
> > #include <linux/kernel.h>
> > #include <linux/slab.h>
> > #include <linux/platform_device.h>
> > -#include <linux/dma-mapping.h>
> > #include <linux/clk.h>
> > #include <linux/usb/otg.h>
> > #include <linux/usb/usb_phy_generic.h>
> > @@ -117,15 +116,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
> > if (!exynos)
> > return -ENOMEM;
> >
> > - /*
> > - * Right now device-tree probed devices don't get dma_mask set.
> > - * Since shared usb code relies on it, set it here for now.
> > - * Once we move to full device tree support this will vanish off.
> > - */
> > - ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
> > - if (ret)
> > - return ret;
>
> this is a separate patch, right?
Yes, this is probably just a cleanup that we can apply regardless.
We have not needed this in a long time.
> > diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> > index 89a2f712fdfe..4d7439cb8cd8 100644
> > --- a/drivers/usb/dwc3/dwc3-st.c
> > +++ b/drivers/usb/dwc3/dwc3-st.c
> > @@ -218,7 +218,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
> > if (IS_ERR(regmap))
> > return PTR_ERR(regmap);
> >
> > - dma_set_coherent_mask(dev, dev->coherent_dma_mask);
>
> so is this.
>
> All in all, I like where you're going with this, we just need a matching
> acpi_dma_configure() and problems will be sorted out.
With this patch, I don't think we even need that any more, as the device
that we use the dma-mapping API is the one that already gets configured
correctly by the platform code for all cases: PCI, OF, ACPI and combinations
of those.
Arnd
next prev parent reply other threads:[~2016-09-08 8:26 UTC|newest]
Thread overview: 182+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-25 19:21 [PATCH] usb: dwc3: host: inherit dma configuration from parent dev Grygorii Strashko
2016-04-25 19:21 ` Grygorii Strashko
2016-04-26 6:17 ` Felipe Balbi
2016-04-26 6:17 ` Felipe Balbi
2016-04-26 8:14 ` Grygorii Strashko
2016-04-26 8:14 ` Grygorii Strashko
2016-04-27 5:41 ` Felipe Balbi
2016-04-27 5:41 ` Felipe Balbi
2016-04-27 11:55 ` Grygorii Strashko
2016-04-27 11:55 ` Grygorii Strashko
2016-04-27 13:59 ` Catalin Marinas
2016-04-27 13:59 ` Catalin Marinas
2016-04-27 14:11 ` Arnd Bergmann
2016-04-27 14:11 ` Arnd Bergmann
2016-04-27 15:50 ` Catalin Marinas
2016-04-27 15:50 ` Catalin Marinas
2016-04-27 16:04 ` Arnd Bergmann
2016-04-27 16:04 ` Arnd Bergmann
2016-04-27 16:53 ` Felipe Balbi
2016-04-27 16:53 ` Felipe Balbi
2016-04-27 17:42 ` Arnd Bergmann
2016-04-27 17:42 ` Arnd Bergmann
2016-04-27 17:59 ` Alan Stern
2016-04-27 17:59 ` Alan Stern
2016-04-27 18:08 ` Arnd Bergmann
2016-04-27 18:08 ` Arnd Bergmann
2016-04-27 20:05 ` Felipe Balbi
2016-04-27 20:05 ` Felipe Balbi
2016-04-27 21:05 ` Arnd Bergmann
2016-04-27 21:05 ` Arnd Bergmann
2016-04-28 6:37 ` Felipe Balbi
2016-04-28 6:37 ` Felipe Balbi
2016-04-28 14:16 ` Russell King - ARM Linux
2016-04-28 14:16 ` Russell King - ARM Linux
2016-04-28 14:23 ` Arnd Bergmann
2016-04-28 14:23 ` Arnd Bergmann
2016-04-28 14:27 ` Felipe Balbi
2016-04-28 14:27 ` Felipe Balbi
2016-09-01 22:14 ` Leo Li
2016-09-01 22:14 ` Leo Li
2016-09-02 10:43 ` Arnd Bergmann
2016-09-02 10:43 ` Arnd Bergmann
2016-09-02 10:47 ` Russell King - ARM Linux
2016-09-02 10:47 ` Russell King - ARM Linux
2016-09-02 11:08 ` Felipe Balbi
2016-09-02 11:08 ` Felipe Balbi
2016-09-02 14:11 ` Felipe Balbi
2016-09-02 14:11 ` Felipe Balbi
2016-09-02 14:21 ` Alan Stern
2016-09-02 14:21 ` Alan Stern
2016-09-02 15:51 ` Arnd Bergmann
2016-09-02 15:51 ` Arnd Bergmann
2016-09-07 7:17 ` Roger Quadros
2016-09-07 7:17 ` Roger Quadros
2016-09-07 8:29 ` Arnd Bergmann
2016-09-07 8:29 ` Arnd Bergmann
2016-09-07 13:04 ` Roger Quadros
2016-09-07 13:04 ` Roger Quadros
2016-09-07 14:38 ` Arnd Bergmann
2016-09-07 14:38 ` Arnd Bergmann
2016-09-02 16:23 ` Grygorii Strashko
2016-09-02 16:23 ` Grygorii Strashko
2016-09-02 10:53 ` Felipe Balbi
2016-09-02 10:53 ` Felipe Balbi
2016-09-02 11:55 ` Robin Murphy
2016-09-02 11:55 ` Robin Murphy
2016-09-02 12:56 ` Felipe Balbi
2016-09-02 12:56 ` Felipe Balbi
2016-09-02 13:10 ` Arnd Bergmann
2016-09-02 13:10 ` Arnd Bergmann
2016-09-02 22:16 ` Leo Li
2016-09-02 22:16 ` Leo Li
2016-09-05 15:39 ` Arnd Bergmann
2016-09-05 15:39 ` Arnd Bergmann
2016-09-06 6:35 ` Peter Chen
2016-09-06 6:35 ` Peter Chen
2016-09-06 6:40 ` Felipe Balbi
2016-09-06 6:40 ` Felipe Balbi
2016-09-06 10:46 ` Arnd Bergmann
2016-09-06 10:46 ` Arnd Bergmann
2016-09-06 10:50 ` Felipe Balbi
2016-09-06 10:50 ` Felipe Balbi
2016-09-06 13:27 ` Arnd Bergmann
2016-09-06 13:27 ` Arnd Bergmann
2016-09-07 6:51 ` Felipe Balbi
2016-09-07 6:51 ` Felipe Balbi
2016-09-07 7:44 ` Peter Chen
2016-09-07 7:44 ` Peter Chen
2016-09-07 8:52 ` Arnd Bergmann
2016-09-07 8:52 ` Arnd Bergmann
2016-09-07 9:29 ` Peter Chen
2016-09-07 9:29 ` Peter Chen
2016-09-07 9:35 ` Russell King - ARM Linux
2016-09-07 9:35 ` Russell King - ARM Linux
2016-09-07 10:18 ` Felipe Balbi
2016-09-07 10:18 ` Felipe Balbi
2016-09-06 10:38 ` Arnd Bergmann
2016-09-06 10:38 ` Arnd Bergmann
2016-09-07 6:33 ` Peter Chen
2016-09-07 6:33 ` Peter Chen
2016-09-07 8:48 ` Arnd Bergmann
2016-09-07 8:48 ` Arnd Bergmann
2016-09-07 9:55 ` Peter Chen
2016-09-07 9:55 ` Peter Chen
2016-09-07 10:33 ` Robin Murphy
2016-09-07 10:33 ` Robin Murphy
2016-09-07 10:47 ` Felipe Balbi
2016-09-07 10:47 ` Felipe Balbi
2016-09-14 16:31 ` Lorenzo Pieralisi
2016-09-14 16:31 ` Lorenzo Pieralisi
2016-09-14 21:50 ` Arnd Bergmann
2016-09-14 21:50 ` Arnd Bergmann
2016-09-07 10:24 ` Felipe Balbi
2016-09-07 10:24 ` Felipe Balbi
2016-09-07 15:24 ` Arnd Bergmann
2016-09-07 15:24 ` Arnd Bergmann
2016-09-07 16:08 ` Alan Stern
2016-09-07 16:08 ` Alan Stern
2016-09-07 19:45 ` Arnd Bergmann
2016-09-07 19:45 ` Arnd Bergmann
2016-09-08 1:15 ` Peter Chen
2016-09-08 1:15 ` Peter Chen
2016-09-08 8:02 ` Arnd Bergmann
2016-09-08 8:02 ` Arnd Bergmann
2016-09-08 8:03 ` Felipe Balbi
2016-09-08 8:03 ` Felipe Balbi
2016-09-08 8:26 ` Arnd Bergmann [this message]
2016-09-08 8:26 ` Arnd Bergmann
2016-09-08 8:29 ` Felipe Balbi
2016-09-08 8:29 ` Felipe Balbi
2016-09-08 8:45 ` Arnd Bergmann
2016-09-08 8:45 ` Arnd Bergmann
2016-09-08 9:43 ` Felipe Balbi
2016-09-08 9:43 ` Felipe Balbi
2016-09-08 10:17 ` Arnd Bergmann
2016-09-08 10:17 ` Arnd Bergmann
2016-09-08 11:00 ` Felipe Balbi
2016-09-08 11:00 ` Felipe Balbi
2016-09-08 11:11 ` Arnd Bergmann
2016-09-08 11:11 ` Arnd Bergmann
2016-09-08 11:20 ` Felipe Balbi
2016-09-08 11:20 ` Felipe Balbi
2016-09-08 11:39 ` Arnd Bergmann
2016-09-08 11:39 ` Arnd Bergmann
2016-09-08 11:52 ` Felipe Balbi
2016-09-08 11:52 ` Felipe Balbi
2016-09-08 12:46 ` Arnd Bergmann
2016-09-08 12:46 ` Arnd Bergmann
2016-09-08 12:02 ` Grygorii Strashko
2016-09-08 12:02 ` Grygorii Strashko
2016-09-08 12:14 ` Arnd Bergmann
2016-09-08 12:14 ` Arnd Bergmann
2016-09-08 12:28 ` Peter Chen
2016-09-08 12:28 ` Peter Chen
2016-09-08 12:52 ` Arnd Bergmann
2016-09-08 12:52 ` Arnd Bergmann
2016-09-09 1:37 ` Peter Chen
2016-09-09 1:37 ` Peter Chen
2016-09-08 12:59 ` Grygorii Strashko
2016-09-08 12:59 ` Grygorii Strashko
2016-09-09 1:52 ` Peter Chen
2016-09-09 1:52 ` Peter Chen
2016-09-21 11:06 ` Sriram Dash
2016-09-21 11:06 ` Sriram Dash
2016-09-21 11:31 ` Arnd Bergmann
2016-09-21 11:31 ` Arnd Bergmann
2016-09-21 11:43 ` Sriram Dash
2016-09-21 11:43 ` Sriram Dash
2016-09-21 12:48 ` Arnd Bergmann
2016-09-21 12:48 ` Arnd Bergmann
2016-09-22 5:02 ` Sriram Dash
2016-09-22 5:02 ` Sriram Dash
2016-10-07 22:46 ` Leo Li
2016-10-07 22:46 ` Leo Li
2016-09-21 17:14 ` [PATCH] usb: xhci: Fix the patch inherit dma configuration from kbuild test robot
2016-09-21 17:14 ` kbuild test robot
2016-04-27 20:57 ` [PATCH] usb: dwc3: host: inherit dma configuration from parent dev Felipe Balbi
2016-04-27 20:57 ` Felipe Balbi
2016-04-27 14:14 ` Grygorii Strashko
2016-04-27 14:14 ` Grygorii Strashko
2016-05-05 17:07 ` Brian Norris
2016-05-05 17:07 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6739240.VDAnDBppH0@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.