Re: [PATCH v5 12/29] compat_ioctl: move drivers to compat_ptr_ioctl

2019-07-31 Thread Cornelia Huck
On Tue, 30 Jul 2019 21:50:28 +0200
Arnd Bergmann  wrote:

> Each of these drivers has a copy of the same trivial helper function to
> convert the pointer argument and then call the native ioctl handler.
> 
> We now have a generic implementation of that, so use it.
> 
> Acked-by: Greg Kroah-Hartman 
> Acked-by: Michael S. Tsirkin 
> Reviewed-by: Jarkko Sakkinen 
> Reviewed-by: Jason Gunthorpe 
> Reviewed-by: Jiri Kosina 
> Reviewed-by: Stefan Hajnoczi 
> Signed-off-by: Arnd Bergmann 
> ---

>  drivers/vfio/vfio.c   | 39 +++

vfio changes:

Reviewed-by: Cornelia Huck 


Re: Oops in xhci_endpoint_reset

2019-07-31 Thread Enric Balletbo Serra
Hi Mathias,

Thanks to look into this.

Missatge de Mathias Nyman  del dia dt.,
30 de jul. 2019 a les 21:39:
>
> On 27.7.2019 23.43, Bob Gleitsmann wrote:
> > OK, here's the result of the bisection:
> >
> > ef513be0a9057cc6baf5d29566aaaefa214ba344 is the first bad commit
> > commit ef513be0a9057cc6baf5d29566aaaefa214ba344
> > Author: Jim Lin 
> > Date: Mon Jun 3 18:53:44 2019 +0800
> >
> > ?? usb: xhci: Add Clear_TT_Buffer
> > ??
> > ?? USB 2.0 specification chapter 11.17.5 says "as part of endpoint halt
> > ?? processing for full-/low-speed endpoints connected via a TT, the host
> > ?? software must use the Clear_TT_Buffer request to the TT to ensure
> > ?? that the buffer is not in the busy state".
> > ??
> > ?? In our case, a full-speed speaker (ConferenceCam) is behind a high-
> > ?? speed hub (ConferenceCam Connect), sometimes once we get STALL on a
> > ?? request we may continue to get STALL with the folllowing requests,
> > ?? like Set_Interface.
> > ??
> > ?? Here we invoke usb_hub_clear_tt_buffer() to send Clear_TT_Buffer
> > ?? request to the hub of the device for the following Set_Interface
> > ?? requests to the device to get ACK successfully.
> > ??
> > ?? Signed-off-by: Jim Lin 
> > ?? Acked-by: Mathias Nyman 
> > ?? Signed-off-by: Greg Kroah-Hartman 
> >
> > ??drivers/usb/host/xhci-ring.c | 27 ++-
> > ??drivers/usb/host/xhci.c?? | 21 +
> > ??drivers/usb/host/xhci.h?? |?? 5 +
> > ??3 files changed, 52 insertions(+), 1 deletion(-)
> >
> >
>
> Thanks, a quick look doesn't immediately open up the cause to me.
> Most likely an endpoint or struct usb_device got dropped and freed at 
> suspend/resume,
> but we probably have some old stale pointer still in a a TD or URB to it.
>
> could you apply the hack below, it should show more details about this issue.
>
> grep for "Mathias" after resume, if you find it we just prevented a crash.
>

With the below patch the oops disappears and the reason is

root@debian:~# dmesg | grep "Mathias"
[   67.747933] xhci-hcd xhci-hcd.8.auto: Mathias: No vdev for slot id 0


> also adding more xhci debugging and tracing would help:
>
> mount -t debugfs none /sys/kernel/debug
> echo 'module xhci_hcd =p' >/sys/kernel/debug/dynamic_debug/control
> echo 'module usbcore =p' >/sys/kernel/debug/dynamic_debug/control
> echo 81920 > /sys/kernel/debug/tracing/buffer_size_kb
> echo 1 > /sys/kernel/debug/tracing/events/xhci-hcd/enable
> < suspend/resume >
> Send output of dmesg
> Send content of /sys/kernel/debug/tracing/trace
>

Unfortunately, when the oops happens the machine is unresponsive :-(

Thanks,
~ Enric


> 8<---
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 9741cde..98a515c 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -1809,14 +1809,33 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
>   static void xhci_clear_hub_tt_buffer(struct xhci_hcd *xhci, struct xhci_td 
> *td,
>  struct xhci_virt_ep *ep)
>   {
> +   struct usb_device *udev;
> +
>  /*
>   * As part of low/full-speed endpoint-halt processing
>   * we must clear the TT buffer (USB 2.0 specification 11.17.5).
>   */
> +
>  if (td->urb->dev->tt && !usb_pipeint(td->urb->pipe) &&
>  (td->urb->dev->tt->hub != xhci_to_hcd(xhci)->self.root_hub) &&
>  !(ep->ep_state & EP_CLEARING_TT)) {
> +   udev = td->urb->dev;
> +   if (!udev) {
> +   xhci_err(xhci, "Mathias: missing udev\n");
> +   return;
> +   }
> +   if (!udev->slot_id)  {
> +   xhci_err(xhci, "Mathias: missing udev->slot_id\n");
> +   return;
> +   }
> +
> +   if (!xhci->devs[udev->slot_id])  {
> +   xhci_err(xhci, "Mathias: missing 
> xhci->devs[udev->slot_id]\n");
> +   return;
> +   }
>  ep->ep_state |= EP_CLEARING_TT;
> +   xhci_err(xhci, "urb->ep->hcpriv %p,  urb->hcpriv %p\n",
> +td->urb->ep->hcpriv, td->urb->dev);
>  td->urb->ep->hcpriv = td->urb->dev;
>  if (usb_hub_clear_tt_buffer(td->urb))
>  ep->ep_state &= ~EP_CLEARING_TT;
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 248cd7a..d7978e0 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -3090,8 +3090,19 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
>  udev = (struct usb_device *) host_ep->hcpriv;
>  vdev = xhci->devs[udev->slot_id];
>  ep_index = xhci_get_endpoint_index(&host_ep->desc);
> +
> +   if (!vdev) {
> +   xhci_warn(xhci, "Mathias: No vdev for slot id %d\n", 
> udev->slot_id);

Re: [RFC PATCH] usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests

2019-07-31 Thread Heikki Krogerus
On Tue, Jul 30, 2019 at 06:28:52AM -0700, Guenter Roeck wrote:
> On 7/30/19 5:07 AM, Heikki Krogerus wrote:
> > On Mon, Jul 29, 2019 at 10:31:04AM -0700, Guenter Roeck wrote:
> > > On Mon, Jul 29, 2019 at 05:04:57PM +0300, Heikki Krogerus wrote:
> > > > Hi,
> > > > 
> > > > On Wed, Jul 24, 2019 at 09:30:37PM -0700, Guenter Roeck wrote:
> > > > > TCPM may receive PD messages associated with unknown or unsupported
> > > > > alternate modes. If that happens, calls to typec_match_altmode()
> > > > > will return NULL. The tcpm code does not currently take this into
> > > > > account. This results in crashes.
> > > > > 
> > > > > Unable to handle kernel NULL pointer dereference at virtual address 
> > > > > 01f0
> > > > > pgd = 41dad9a1
> > > > > [01f0] *pgd=
> > > > > Internal error: Oops: 5 [#1] THUMB2
> > > > > Modules linked in: tcpci tcpm
> > > > > CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 5.1.18-sama5-armv7-r2 
> > > > > #6
> > > > > Hardware name: Atmel SAMA5
> > > > > Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
> > > > > PC is at typec_altmode_attention+0x0/0x14
> > > > > LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
> > > > > ...
> > > > > [] (typec_altmode_attention) from []
> > > > >   (tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
> > > > > [] (tcpm_pd_rx_handler [tcpm]) from []
> > > > >   (process_one_work+0x123/0x2a8)
> > > > > [] (process_one_work) from []
> > > > >   (worker_thread+0xbd/0x3b0)
> > > > > [] (worker_thread) from [] (kthread+0xcf/0xf4)
> > > > > [] (kthread) from [] (ret_from_fork+0x11/0x38)
> > > > > 
> > > > > Ignore PD messages if the asociated alternate mode is not supported.
> > > > > 
> > > > > Reported-by: Douglas Gilbert 
> > > > > Cc: Douglas Gilbert 
> > > > > Fixes: e9576fe8e605c ("usb: typec: tcpm: Support for Alternate Modes")
> > > > > Signed-off-by: Guenter Roeck 
> > > > > ---
> > > > > Taking a stab at the problem. I don't really know if this is the 
> > > > > correct
> > > > > fix, or even if my understanding of the problem is correct, thus 
> > > > > marking
> > > > > the patch as RFC.
> > > > 
> > > > My guess is that typec_match_altmode() is the real culprit. We can't
> > > > rely on the partner mode index number when identifying the port alt
> > > > mode.
> > > > 
> > > > Douglas, can you test the attached hack instead of this patch?
> > > > 
> > > > 
> > > > thanks,
> > > > 
> > > > -- 
> > > > heikki
> > > 
> > > > diff --git a/drivers/usb/typec/tcpm/tcpm.c 
> > > > b/drivers/usb/typec/tcpm/tcpm.c
> > > > index ec525811a9eb..033dc097ba83 100644
> > > > --- a/drivers/usb/typec/tcpm/tcpm.c
> > > > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > > > @@ -1067,12 +1067,11 @@ static int tcpm_pd_svdm(struct tcpm_port *port, 
> > > > const __le32 *payload, int cnt,
> > > > modep = &port->mode_data;
> > > > -   adev = typec_match_altmode(port->port_altmode, 
> > > > ALTMODE_DISCOVERY_MAX,
> > > > -  PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0]));
> > > > -
> > > > pdev = typec_match_altmode(port->partner_altmode, 
> > > > ALTMODE_DISCOVERY_MAX,
> > > >PD_VDO_VID(p[0]), PD_VDO_OPOS(p[0]));
> > > > +   adev = (void *)typec_altmode_get_partner(pdev);
> > > > +
> > > 
> > > I understand that typec_altmode_get_partner() returns a const *;
> > > maybe adev should be declared as const struct typec_altmode *
> > > instead of using a typecast.
> > 
> > Yes...
> > 
> > > Also, typec_altmode_get_partner() can return NULL as well if pdev is NULL.
> > > Is it guaranteed that typec_match_altmode() never returns NULL for pdev ?
> > 
> > ...and probable no. But I don't think we can receive Attention to a
> > mode that hasn't been entered.
> > 
> 
> If I understand correctly, the Attention was generated by a test system.
> What prevents badly implemented code in the connected system from sending
> such an Attention message ?

Oh, if that is the case, then I don't think my change has any effect.
I misunderstood the scenario. Sorry for that.

I think we should use your patch to fix this issue.

thanks,

-- 
heikki


[PATCH] usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role"

2019-07-31 Thread Yoshihiro Shimoda
Since the role_store() uses strncmp(), it's possible to refer
out-of-memory if the sysfs data size is smaller than strlen("host").
This patch fixes it by using sysfs_streq() instead of strncmp().

Fixes: cc995c9ec118 ("usb: gadget: udc: renesas_usb3: add support for usb role 
swap")
Cc:  # v4.12+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index 7dc2485..b6eec81 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2378,9 +2379,9 @@ static ssize_t role_store(struct device *dev, struct 
device_attribute *attr,
if (usb3->forced_b_device)
return -EBUSY;
 
-   if (!strncmp(buf, "host", strlen("host")))
+   if (sysfs_streq(buf, "host"))
new_mode_is_host = true;
-   else if (!strncmp(buf, "peripheral", strlen("peripheral")))
+   else if (sysfs_streq(buf, "peripheral"))
new_mode_is_host = false;
else
return -EINVAL;
-- 
2.7.4



[PATCH v2 1/5] phy: Add phy ports in attrs

2019-07-31 Thread Srinath Mannam
Add phy ports bitmask to contain enabled PHY ports.
set and get APIs added to set and get phy ports value.

Signed-off-by: Srinath Mannam 
---
 include/linux/phy/phy.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 15032f14..b8bca1d 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -109,10 +109,12 @@ struct phy_ops {
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
+ * @phy_ports: Bitmask of enabled ports
  * @mode: PHY mode
  */
 struct phy_attrs {
u32 bus_width;
+   u32 phy_ports;
enum phy_mode   mode;
 };
 
@@ -225,6 +227,14 @@ static inline void phy_set_bus_width(struct phy *phy, int 
bus_width)
 {
phy->attrs.bus_width = bus_width;
 }
+static inline int phy_get_phy_ports(struct phy *phy)
+{
+   return phy->attrs.phy_ports;
+}
+static inline void phy_set_phy_ports(struct phy *phy, int phy_ports)
+{
+   phy->attrs.phy_ports |= phy_ports;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
-- 
2.7.4



[PATCH v2 3/5] phy: sr-usb: Set phy ports

2019-07-31 Thread Srinath Mannam
set phy ports value in xlate handler which is taken from second argument
of PHY phandle.

Signed-off-by: Srinath Mannam 
---
 drivers/phy/broadcom/phy-bcm-sr-usb.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/broadcom/phy-bcm-sr-usb.c 
b/drivers/phy/broadcom/phy-bcm-sr-usb.c
index fe6c589..5274e45 100644
--- a/drivers/phy/broadcom/phy-bcm-sr-usb.c
+++ b/drivers/phy/broadcom/phy-bcm-sr-usb.c
@@ -278,9 +278,16 @@ static struct phy *bcm_usb_phy_xlate(struct device *dev,
if (WARN_ON(phy_idx > 1))
return ERR_PTR(-ENODEV);
 
+   if (args->args[1])
+   phy_set_phy_ports(phy_cfg[phy_idx].phy, args->args[1]);
+
return phy_cfg[phy_idx].phy;
-   } else
+   } else {
+   if (args->args[0])
+   phy_set_phy_ports(phy_cfg->phy, args->args[0]);
+
return phy_cfg->phy;
+   }
 }
 
 static int bcm_usb_phy_create(struct device *dev, struct device_node *node,
-- 
2.7.4



[PATCH v2 2/5] dt-bindings: phy: Modify Stingray USB PHY #phy-cells

2019-07-31 Thread Srinath Mannam
Increase #phy-cells from 1 to 2 to have bitmask of PHY enabled ports.

Signed-off-by: Srinath Mannam 
---
 .../devicetree/bindings/phy/brcm,stingray-usb-phy.txt  | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt
index 4ba2989..aeb0568 100644
--- a/Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt
+++ b/Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt
@@ -6,9 +6,11 @@ Required properties:
- "brcm,sr-usb-hs-phy" is a single HS PHY.
  - reg: offset and length of the PHY blocks registers
  - #phy-cells:
-   - Must be 1 for brcm,sr-usb-combo-phy as it expects one argument to indicate
- the PHY number of two PHYs. 0 for HS PHY and 1 for SS PHY.
-   - Must be 0 for brcm,sr-usb-hs-phy.
+   - Must be 2 for brcm,sr-usb-combo-phy.
+ - Cell 1 - PHY Number, 0 for HS PHY and 1 for SS PHY.
+ - Cell 2 - Bitmask of enabled ports connected to USB Host controller.
+   - Must be 1 for brcm,sr-usb-hs-phy to indicate Bit mask of ports connected
+ to USB Host controller.
 
 Refer to phy/phy-bindings.txt for the generic PHY binding properties
 
@@ -16,17 +18,17 @@ Example:
usbphy0: usb-phy@0 {
compatible = "brcm,sr-usb-combo-phy";
reg = <0x 0x100>;
-   #phy-cells = <1>;
+   #phy-cells = <2>;
};
 
usbphy1: usb-phy@1 {
compatible = "brcm,sr-usb-combo-phy";
reg = <0x0001 0x100>,
-   #phy-cells = <1>;
+   #phy-cells = <2>;
};
 
usbphy2: usb-phy@2 {
compatible = "brcm,sr-usb-hs-phy";
reg = <0x0002 0x100>,
-   #phy-cells = <0>;
+   #phy-cells = <1>;
};
-- 
2.7.4



[PATCH v2 5/5] drivers: xhci: Add quirk to reset xHCI port PHY

2019-07-31 Thread Srinath Mannam
Stingray USB HS PHY has an issue, that USB High Speed device detects
at Full Speed if the same port was connected to Full speed device.
This problem can be resolved by resetting that port's PHY on disconnect.
Add a quirk to reset xHCI port PHY on port disconnect event.
XHCI_RESET_PHY_ON_DISCONNECT quirk is introduced with xhci_plat_brcm_sr
platform data. New quirks parameter added in xhci_plat_priv structure to
assign platform specific quirks.

Signed-off-by: Srinath Mannam 
---
 drivers/usb/core/hcd.c   |  6 ++
 drivers/usb/core/phy.c   | 19 +++
 drivers/usb/core/phy.h   |  1 +
 drivers/usb/host/xhci-plat.c | 10 ++
 drivers/usb/host/xhci-plat.h |  1 +
 drivers/usb/host/xhci-ring.c |  9 ++---
 drivers/usb/host/xhci.h  |  1 +
 include/linux/usb/hcd.h  |  1 +
 8 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 94d2255..a23441b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2675,6 +2675,12 @@ int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, 
int port1)
return hcd->driver->find_raw_port_number(hcd, port1);
 }
 
+int usb_hcd_phy_port_reset(struct usb_hcd *hcd, int port)
+{
+   return usb_phy_roothub_port_reset(hcd->phy_roothub, port);
+}
+EXPORT_SYMBOL_GPL(usb_hcd_phy_port_reset);
+
 static int usb_hcd_request_irqs(struct usb_hcd *hcd,
unsigned int irqnum, unsigned long irqflags)
 {
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 7580493..4d1ac31 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -190,6 +190,25 @@ void usb_phy_roothub_power_off(struct usb_phy_roothub 
*phy_roothub)
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_power_off);
 
+int usb_phy_roothub_port_reset(struct usb_phy_roothub *phy_roothub, int port)
+{
+   struct usb_phy_roothub *roothub_entry;
+   struct list_head *head;
+
+   if (!phy_roothub)
+   return -EINVAL;
+
+   head = &phy_roothub->list;
+
+   list_for_each_entry(roothub_entry, head, list) {
+   if (phy_get_phy_ports(roothub_entry->phy) & BIT(port))
+   return phy_reset(roothub_entry->phy);
+   }
+
+   return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_port_reset);
+
 int usb_phy_roothub_suspend(struct device *controller_dev,
struct usb_phy_roothub *phy_roothub)
 {
diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h
index dad564e..3f682e8 100644
--- a/drivers/usb/core/phy.h
+++ b/drivers/usb/core/phy.h
@@ -20,6 +20,7 @@ int usb_phy_roothub_set_mode(struct usb_phy_roothub 
*phy_roothub,
 enum phy_mode mode);
 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
 void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);
+int usb_phy_roothub_port_reset(struct usb_phy_roothub *phy_roothub, int port);
 
 int usb_phy_roothub_suspend(struct device *controller_dev,
struct usb_phy_roothub *phy_roothub);
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 998241f..af23e92 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -47,6 +47,9 @@ static void xhci_priv_plat_start(struct usb_hcd *hcd)
 static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 {
struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+   xhci->quirks |= priv->quirks;
 
if (!priv->init_quirk)
return 0;
@@ -116,6 +119,10 @@ static const struct xhci_plat_priv 
xhci_plat_renesas_rcar_gen3 = {
.resume_quirk = xhci_rcar_resume_quirk,
 };
 
+static const struct xhci_plat_priv xhci_plat_brcm_sr = {
+   .quirks = XHCI_RESET_PHY_ON_DISCONNECT,
+};
+
 static const struct of_device_id usb_xhci_of_match[] = {
{
.compatible = "generic-xhci",
@@ -151,6 +158,9 @@ static const struct of_device_id usb_xhci_of_match[] = {
}, {
.compatible = "renesas,rcar-gen3-xhci",
.data = &xhci_plat_renesas_rcar_gen3,
+   }, {
+   .compatible = "brcm,sr-xhci",
+   .data = &xhci_plat_brcm_sr,
},
{},
 };
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index ae29f22..0cd61c6 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -15,6 +15,7 @@ struct xhci_plat_priv {
void (*plat_start)(struct usb_hcd *);
int (*init_quirk)(struct usb_hcd *);
int (*resume_quirk)(struct usb_hcd *);
+   unsigned long long  quirks;
 };
 
 #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index feffceb..77e94e8 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1696,9 +1696,12 @@ static void handle_port_status(struct xhci_hcd *xhci,
 

[PATCH v2 0/4] Reset xHCI port PHY on disconnect

2019-07-31 Thread Srinath Mannam
This patch set adds a quirk in xHCI driver to reset PHY of xHCI port on
its disconnect event.

This patch set is based on Linux-5.2-rc4.

Changes from v1:
  - Addressed Mathias's comments
- Modified mapping of HC ports and their corresponding PHYs
  - Addressed Rob's comments
- Removed usb-phy-port-reset DT property.
- Added quirk in platform data using HCI compatible string.
  - Add phy ports in phy attr structure to have enabled ports bitmask.
  - Modified #phy-cells of sr-phy to pass phy ports bitmask.

Srinath Mannam (4):
  phy: Add phy ports in attrs
  dt-bindings: phy: Modify Stingray USB PHY #phy-cells
  phy: sr-usb: Set phy ports
  dt-bindings: usb-xhci: Add platform specific compatible for Stingray
xHCI
  drivers: xhci: Add quirk to reset xHCI port PHY

 .../devicetree/bindings/phy/brcm,stingray-usb-phy.txt | 14 --
 Documentation/devicetree/bindings/usb/usb-xhci.txt|  1 +
 drivers/phy/broadcom/phy-bcm-sr-usb.c |  9 -
 drivers/usb/core/hcd.c|  6 ++
 drivers/usb/core/phy.c| 19 +++
 drivers/usb/core/phy.h|  1 +
 drivers/usb/host/xhci-plat.c  | 10 ++
 drivers/usb/host/xhci-plat.h  |  1 +
 drivers/usb/host/xhci-ring.c  |  9 ++---
 drivers/usb/host/xhci.h   |  1 +
 include/linux/phy/phy.h   | 10 ++
 include/linux/usb/hcd.h   |  1 +
 12 files changed, 72 insertions(+), 10 deletions(-)

-- 
2.7.4



[PATCH v2 4/5] dt-bindings: usb-xhci: Add platform specific compatible for Stingray xHCI

2019-07-31 Thread Srinath Mannam
Add Platform specific compatible, because xHCI of this SoC has an issue
with HS port which has to reset on disconnect event.

Signed-off-by: Srinath Mannam 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 97400e8..ee1f051 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -22,6 +22,7 @@ Required properties:
   device
 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 or RZ/G2 compatible
   device
+- "brcm,sr-xhci" for Stingray SoC
 - "xhci-platform" (deprecated)
 
 When compatible with the generic version, nodes must list the
-- 
2.7.4



Re: [PATCH] usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role"

2019-07-31 Thread Geert Uytterhoeven
On Wed, Jul 31, 2019 at 1:17 PM Yoshihiro Shimoda
 wrote:
> Since the role_store() uses strncmp(), it's possible to refer
> out-of-memory if the sysfs data size is smaller than strlen("host").
> This patch fixes it by using sysfs_streq() instead of strncmp().
>
> Fixes: cc995c9ec118 ("usb: gadget: udc: renesas_usb3: add support for usb 
> role swap")
> Cc:  # v4.12+
> Signed-off-by: Yoshihiro Shimoda 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[RESEND PATCH] usb: host: xhci-plat: Prevent an abnormally restrictive PHY init skipping

2019-07-31 Thread Miquel Raynal
In the past, USB PHY handling has been moved in the HCD core. Some
host controller drivers needing more control of the PHYs, they have
been granted the freedom to handle themselves the PHY states and to
prevent the HCD core to do so in commit 4e88d4c08301 ("usb: add a flag
to skip PHY initialization to struct usb_hcd"). With this change, any
USB host controller could set the hcd->skip_phy_initialization flag so
that the HCD core would just skip the PHY initialization sequence.

However, in the USB subsystem, there are currently two entirely
different forms of PHY: one is called 'usb_phy' and is
USB-subsystem-wide, while there is also the generic and kernel-wide
'phy' from the (recent) generic PHY framework.

When the commit above was introduced, both type of PHYs where handled
by the HCD core.

Later, commit bc40f5341741 ("USB: core: hcd: drop support for legacy
phys") removed the support for the former type of PHYs in the HCD
core. These 'usb_phy' are still present though, but managed from the
controller drivers only. Hence, setting the
hcd->skip_phy_initialization flag just because a 'usb_phy' is
initialized by a controller driver is a non-sense.

For instance on Armada CP110, a 'usb_phy' is there to enable the power
supply to the USB host, while there is also a COMPHY block providing
SERDES lanes configuration that is referenced as a PHY from the common
PHY framework.

Right now, users of the xhci-plat.c driver either use a 'usb_phy' only
and do not care about the attempt of generic PHY initialization within
the HCD core (as there is none); or they use a single 'phy' and the
code flow does not pass through the block setting
hcd->skip_phy_initialization anyway.

While there is not users of both PHY types at the same time, drop this
limitation from the xhci-plat.c driver. Note that the tegra driver
probably has the same limitation and could definitely benefit from a
similar change.

Cc: Johan Hovold 
Cc: Martin Blumenstingl 
Signed-off-by: Miquel Raynal 
Acked-by: Martin Blumenstingl 
---

Hello Greg, I am resending this patch as I think it got lost. Just
added Acked-by tag from Martin.

Cheers,
Miquèl

 drivers/usb/host/xhci-plat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 998241f5fce3..a1e5ce484bf8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -307,7 +307,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
ret = usb_phy_init(hcd->usb_phy);
if (ret)
goto put_usb3_hcd;
-   hcd->skip_phy_initialization = 1;
}
 
hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
-- 
2.20.1



[PATCH 0/2] usb: xhci: dbc: 2 smalll fixes for 'xhci_dbc_alloc_requests()'

2019-07-31 Thread Christophe JAILLET



Christophe JAILLET (2):
  usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'
  usb: xhci: dbc: Use GFP_KERNEL instead of GFP_ATOMIC in
'xhci_dbc_alloc_requests()'

 drivers/usb/host/xhci-dbgtty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.20.1



[PATCH 2/2] usb: xhci: dbc: Use GFP_KERNEL instead of GFP_ATOMIC in 'xhci_dbc_alloc_requests()'

2019-07-31 Thread Christophe JAILLET
There is no need to use GFP_ATOMIC to allocate 'req'. GFP_KERNEL should be
enough and is already used for another allocation juste a few lines below.

Signed-off-by: Christophe JAILLET 
---
I've done my best to check if a spinlock can be hold when reaching this
code. Apparently it is never the case.
But double check to be sure that it is not the kmalloc that should use
GFP_ATOMIC.
---
 drivers/usb/host/xhci-dbgtty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index 845939f8a0b8..be726c791323 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -139,7 +139,7 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct 
list_head *head,
struct dbc_request  *req;
 
for (i = 0; i < DBC_QUEUE_SIZE; i++) {
-   req = dbc_alloc_request(dep, GFP_ATOMIC);
+   req = dbc_alloc_request(dep, GFP_KERNEL);
if (!req)
break;
 
-- 
2.20.1



[PATCH 1/2] usb: xhci: dbc: Simplify error handling in 'xhci_dbc_alloc_requests()'

2019-07-31 Thread Christophe JAILLET
If the 'kmalloc()' fails, we need to undo the previous
'dbc_alloc_request()' call.

Because of the more similar function name, it is more logical to use
'dbc_free_request()' instead of 'xhci_dbc_free_req()'.

Both are equivalent here because:
 static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req)
 {
kfree(req->buf);
dbc_free_request(dep, req);
 }
and 'req->buf' is known to be NULL at this point

Signed-off-by: Christophe JAILLET 
---
 drivers/usb/host/xhci-dbgtty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index aff79ff5aba4..845939f8a0b8 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -146,7 +146,7 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct 
list_head *head,
req->length = DBC_MAX_PACKET;
req->buf = kmalloc(req->length, GFP_KERNEL);
if (!req->buf) {
-   xhci_dbc_free_req(dep, req);
+   dbc_free_request(dep, req);
break;
}
 
-- 
2.20.1



[PATCH] usb: wusbcore: Spelling s/disconenct/disconnect/

2019-07-31 Thread Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven 
---
 drivers/usb/wusbcore/devconnect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/wusbcore/devconnect.c 
b/drivers/usb/wusbcore/devconnect.c
index a93837d57d53bd04..1170f8baf6084df9 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -49,7 +49,7 @@
  *  for processing a DN_Alive pong from a device.
  *
  *   wusb_handle_dn_disconnect()Called by notif.c:wusb_handle_dn() to
- *  process a disconenct request from a
+ *  process a disconnect request from a
  *  device.
  *
  *   __wusb_dev_disable()   Called by rh.c:wusbhc_rh_clear_port_feat() when
-- 
2.17.1



Re: Oops in xhci_endpoint_reset

2019-07-31 Thread Mathias Nyman

On 31.7.2019 12.18, Enric Balletbo Serra wrote:

Hi Mathias,

Thanks to look into this.

Missatge de Mathias Nyman  del dia dt.,
30 de jul. 2019 a les 21:39:


On 27.7.2019 23.43, Bob Gleitsmann wrote:

OK, here's the result of the bisection:

ef513be0a9057cc6baf5d29566aaaefa214ba344 is the first bad commit
commit ef513be0a9057cc6baf5d29566aaaefa214ba344
Author: Jim Lin 
Date: Mon Jun 3 18:53:44 2019 +0800

?? usb: xhci: Add Clear_TT_Buffer
??
?? USB 2.0 specification chapter 11.17.5 says "as part of endpoint halt
?? processing for full-/low-speed endpoints connected via a TT, the host
?? software must use the Clear_TT_Buffer request to the TT to ensure
?? that the buffer is not in the busy state".
??
?? In our case, a full-speed speaker (ConferenceCam) is behind a high-
?? speed hub (ConferenceCam Connect), sometimes once we get STALL on a
?? request we may continue to get STALL with the folllowing requests,
?? like Set_Interface.
??
?? Here we invoke usb_hub_clear_tt_buffer() to send Clear_TT_Buffer
?? request to the hub of the device for the following Set_Interface
?? requests to the device to get ACK successfully.
??
?? Signed-off-by: Jim Lin 
?? Acked-by: Mathias Nyman 
?? Signed-off-by: Greg Kroah-Hartman 

??drivers/usb/host/xhci-ring.c | 27 ++-
??drivers/usb/host/xhci.c?? | 21 +
??drivers/usb/host/xhci.h?? |?? 5 +
??3 files changed, 52 insertions(+), 1 deletion(-)




Thanks, a quick look doesn't immediately open up the cause to me.
Most likely an endpoint or struct usb_device got dropped and freed at 
suspend/resume,
but we probably have some old stale pointer still in a a TD or URB to it.

could you apply the hack below, it should show more details about this issue.

grep for "Mathias" after resume, if you find it we just prevented a crash.



With the below patch the oops disappears and the reason is

root@debian:~# dmesg | grep "Mathias"
[   67.747933] xhci-hcd xhci-hcd.8.auto: Mathias: No vdev for slot id 0



Ok, thanks,
When we free the xhci virt_dev the udev->slot_is set to zero as well.
Looks like whole xHCI was reset are resume:
 
[ 2994.539409] usb usb8: root hub lost power or was reset

[ 2994.539411] usb usb9: root hub lost power or was reset

This means that xHC controller was reset and xhci driver re-allocated 
everything.

It makes sense to check that xhci virt_device exists in the endpoint reset 
callback.
This will fix the oops, but I'm still missing the big picture, how we ended up 
here.

Would it be possible for you to take traces and logs with the previous patch  
that prevents
the oops, but shows the "Mathias: No vdev for slot id 0" message?

-Mathias


Re: Oops in xhci_endpoint_reset

2019-07-31 Thread Enric Balletbo Serra
Missatge de Mathias Nyman  del dia dc.,
31 de jul. 2019 a les 16:16:
>
> On 31.7.2019 12.18, Enric Balletbo Serra wrote:
> > Hi Mathias,
> >
> > Thanks to look into this.
> >
> > Missatge de Mathias Nyman  del dia dt.,
> > 30 de jul. 2019 a les 21:39:
> >>
> >> On 27.7.2019 23.43, Bob Gleitsmann wrote:
> >>> OK, here's the result of the bisection:
> >>>
> >>> ef513be0a9057cc6baf5d29566aaaefa214ba344 is the first bad commit
> >>> commit ef513be0a9057cc6baf5d29566aaaefa214ba344
> >>> Author: Jim Lin 
> >>> Date: Mon Jun 3 18:53:44 2019 +0800
> >>>
> >>> ?? usb: xhci: Add Clear_TT_Buffer
> >>> ??
> >>> ?? USB 2.0 specification chapter 11.17.5 says "as part of endpoint 
> >>> halt
> >>> ?? processing for full-/low-speed endpoints connected via a TT, the 
> >>> host
> >>> ?? software must use the Clear_TT_Buffer request to the TT to ensure
> >>> ?? that the buffer is not in the busy state".
> >>> ??
> >>> ?? In our case, a full-speed speaker (ConferenceCam) is behind a high-
> >>> ?? speed hub (ConferenceCam Connect), sometimes once we get STALL on a
> >>> ?? request we may continue to get STALL with the folllowing requests,
> >>> ?? like Set_Interface.
> >>> ??
> >>> ?? Here we invoke usb_hub_clear_tt_buffer() to send Clear_TT_Buffer
> >>> ?? request to the hub of the device for the following Set_Interface
> >>> ?? requests to the device to get ACK successfully.
> >>> ??
> >>> ?? Signed-off-by: Jim Lin 
> >>> ?? Acked-by: Mathias Nyman 
> >>> ?? Signed-off-by: Greg Kroah-Hartman 
> >>>
> >>> ??drivers/usb/host/xhci-ring.c | 27 ++-
> >>> ??drivers/usb/host/xhci.c?? | 21 +
> >>> ??drivers/usb/host/xhci.h?? |?? 5 +
> >>> ??3 files changed, 52 insertions(+), 1 deletion(-)
> >>>
> >>>
> >>
> >> Thanks, a quick look doesn't immediately open up the cause to me.
> >> Most likely an endpoint or struct usb_device got dropped and freed at 
> >> suspend/resume,
> >> but we probably have some old stale pointer still in a a TD or URB to it.
> >>
> >> could you apply the hack below, it should show more details about this 
> >> issue.
> >>
> >> grep for "Mathias" after resume, if you find it we just prevented a crash.
> >>
> >
> > With the below patch the oops disappears and the reason is
> >
> > root@debian:~# dmesg | grep "Mathias"
> > [   67.747933] xhci-hcd xhci-hcd.8.auto: Mathias: No vdev for slot id 0
> >
>
> Ok, thanks,
> When we free the xhci virt_dev the udev->slot_is set to zero as well.
> Looks like whole xHCI was reset are resume:
>
> [ 2994.539409] usb usb8: root hub lost power or was reset
> [ 2994.539411] usb usb9: root hub lost power or was reset
>
> This means that xHC controller was reset and xhci driver re-allocated 
> everything.
>
> It makes sense to check that xhci virt_device exists in the endpoint reset 
> callback.
> This will fix the oops, but I'm still missing the big picture, how we ended 
> up here.
>
> Would it be possible for you to take traces and logs with the previous patch  
> that prevents
> the oops, but shows the "Mathias: No vdev for slot id 0" message?
>

Sure, here is:

dmesg: https://paste.debian.net/1093737/
traces: https://drive.google.com/open?id=1So-_zsu8ROtMH08hYVKIAZfr_51QLUPD

Thanks,
~ Enric




> -Mathias


Re: [PATCH v2] usb: typec: tcpm: Add NULL check before dereferencing config

2019-07-31 Thread Douglas Gilbert

On 2019-07-24 4:38 p.m., Guenter Roeck wrote:

When instantiating tcpm on an NXP OM 13588 board with NXP PTN5110,
the following crash is seen when writing into the 'preferred_role'
sysfs attribute.

Unable to handle kernel NULL pointer dereference at virtual address 0028
pgd = f69149ad
[0028] *pgd=
Internal error: Oops: 5 [#1] THUMB2
Modules linked in: tcpci tcpm
CPU: 0 PID: 1882 Comm: bash Not tainted 5.1.18-sama5-armv7-r2 #4
Hardware name: Atmel SAMA5
PC is at tcpm_try_role+0x3a/0x4c [tcpm]
LR is at tcpm_try_role+0x15/0x4c [tcpm]
pc : []lr : []psr: 60030033
sp : dc1a1e88  ip : c03fb47d  fp : 
r10: dc216190  r9 : dc1a1f78  r8 : 0001
r7 : df4ae044  r6 : dd032e90  r5 : dd1ce340  r4 : df4ae054
r3 :   r2 :   r1 :   r0 : df4ae044
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment none
Control: 50c53c7d  Table: 3efec059  DAC: 0051
Process bash (pid: 1882, stack limit = 0x6a6d4aa5)
Stack: (0xdc1a1e88 to 0xdc1a2000)
1e80:   dd05d808 dd1ce340 0001 0007 dd1ce340 c03fb4a7
1ea0: 0007 0007 dc216180   c01e1e03  
1ec0: c0907008 dee98b40 c01e1d5d c06106c4   0007 c0194e8b
1ee0: 000a 0400  c01a97db dc22bf00 e000 df4b6a00 df745900
1f00: 0001 0001 00dd c01a9c2f 7aeab3be c0907008  dc22bf00
1f20: c0907008     7aeab3be 0007 dee98b40
1f40: 005dc318 dc1a1f78   0007 c01969f7 000a c01a20cb
1f60: dee98b40 c0907008 dee98b40 005dc318  c0196b9b  
1f80: dee98b40 7aeab3be 0074 005dc318 b6f3bdb0 0004 c0101224 dc1a
1fa0: 0004 c0101001 0074 005dc318 0001 005dc318 0007 
1fc0: 0074 005dc318 b6f3bdb0 0004 0007 0007  
1fe0: 0004 be800880 b6ed35b3 b6e5c746 60030030 0001  
[] (tcpm_try_role [tcpm]) from [] 
(preferred_role_store+0x2b/0x5c)
[] (preferred_role_store) from [] 
(kernfs_fop_write+0xa7/0x150)
[] (kernfs_fop_write) from [] (__vfs_write+0x1f/0x104)
[] (__vfs_write) from [] (vfs_write+0x6b/0x104)
[] (vfs_write) from [] (ksys_write+0x43/0x94)
[] (ksys_write) from [] (ret_fast_syscall+0x1/0x62)

Since commit 96232cbc6c994 ("usb: typec: tcpm: support get typec and pd
config from device properties"), the 'config' pointer in struct tcpc_dev
is optional when registering a Type-C port. Since it is optional, we have
to check if it is NULL before dereferencing it.

Reported-by: Douglas Gilbert 
Cc: Douglas Gilbert 
Fixes: 96232cbc6c994 ("usb: typec: tcpm: support get typec and pd config from device 
properties")
Signed-off-by: Guenter Roeck 
---
v2: Added missing Cc:. Sorry for the noise.

Doug:
 I didn't add your Tested-by: since I added more code.
 It would be great if you can re-test.

  drivers/usb/typec/tcpm/tcpm.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)


Tested-by: Douglas Gilbert 


This time the Linux system is an Acme Systems Arietta which is a
Atmel at91sam9g25 based board. Test was run with lk 5.1.19 .
Without the patch I got the oops described above ("PC is at
tcpm_try_role+0x40/0x74 [tcpm]") when writing into the 'preferred_role'
sysfs attribute. With this patch it worked okay.

Can't test the "out of protocol" PD Attention command oops because I
don't have another OM13588 at the other end (of the USB-C cable) to
send it. I may be able to solve that problem as well. The OM13588
seems like a good attack vector ... and NXP continue to improve
its software (I'm talking about when it runs with a KL27Z which is
an Arduino clone). It can now read the current capability of an
E-marked USB-C (M to M) cable. The only 5 Amp cable I have is
the one that Apple sells (as an _extra_ (cheapskates) to their 87W
USB-C power adapter (for MacBooks)).


Re: Fwd: Re: New USB Device

2019-07-31 Thread Markus Breunig




Am 16.07.2019 um 11:23 schrieb Johan Hovold:

[ Pleas avoid top posting. ]

On Sun, Jul 07, 2019 at 09:38:00PM +0200, Markus Breunig wrote:

Hi Greg,

also the company GNS has a fragmented homepage, the handbook ist
available here:
http://www.servicedocs.com/ARTIKELEN/7200284490001.pdf
habe a look to page 10 "Remarks to Linux"

This is the log of "lsusb -v" (full scan result attached):

Bus 001 Device 004: ID 04d8:f8e8 Microchip Technology, Inc. Harmony
300/350 Remote


Are you sure this is the right device? This looks like a remote control,
and one that should be using the cdc-acm driver.



The output of lsusb before plugging the GNS5890 device into the USB-port:

Bus 001 Device 005: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 001 Device 004: ID 046a:0001 Cherry GmbH Keyboard
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

and the result of the lsusb after plugging the GNS5890 device into the
USB-port:

Bus 001 Device 005: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 001 Device 004: ID 046a:0001 Cherry GmbH Keyboard
Bus 001 Device 006: ID 04d8:f8e8 Microchip Technology, Inc. Harmony
300/350 Remote
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub



Device Descriptor:
bLength18
bDescriptorType 1
bcdUSB   2.00
bDeviceClass  255 Vendor Specific Class
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor   0x04d8 Microchip Technology, Inc.
idProduct  0xf8e8 Harmony 300/350 Remote
bcdDevice   48.12
iManufacturer   1
iProduct2
iSerial 3
bNumConfigurations  1
Configuration Descriptor:
  bLength 9
  bDescriptorType 2
  wTotalLength   67
  bNumInterfaces  2
  bConfigurationValue 1
  iConfiguration  0
  bmAttributes 0xc0
Self Powered
  MaxPower  100mA
  Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber0
bAlternateSetting   0
bNumEndpoints   1
bInterfaceClass 2 Communications
bInterfaceSubClass  2 Abstract (modem)
bInterfaceProtocol  1 AT-commands (v.25ter)
iInterface  0
CDC Header:
  bcdCDC   1.10
CDC ACM:
  bmCapabilities   0x02
line coding and serial state
CDC Union:
  bMasterInterface0
  bSlaveInterface 1
CDC Call Management:
  bmCapabilities   0x00
  bDataInterface  1
Endpoint Descriptor:
  bLength 7
  bDescriptorType 5
  bEndpointAddress 0x82  EP 2 IN
  bmAttributes3
Transfer TypeInterrupt
Synch Type   None
Usage Type   Data
  wMaxPacketSize 0x0008  1x 8 bytes
  bInterval   2
  Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber1
bAlternateSetting   0
bNumEndpoints   2
bInterfaceClass10 CDC Data
bInterfaceSubClass  0 Unused
bInterfaceProtocol  0
iInterface  0
Endpoint Descriptor:
  bLength 7
  bDescriptorType 5
  bEndpointAddress 0x03  EP 3 OUT
  bmAttributes2
Transfer TypeBulk
Synch Type   None
Usage Type   Data
  wMaxPacketSize 0x0040  1x 64 bytes
  bInterval   0
Endpoint Descriptor:
  bLength 7
  bDescriptorType 5
  bEndpointAddress 0x83  EP 3 IN
  bmAttributes2
Transfer TypeBulk
Synch Type   None
Usage Type   Data
  wMaxPacketSize 0x0040  1x 64 bytes
  bInterval   0



Am 05.07.2019 07:21, schrieb Greg KH:

On Thu, Jul 04, 2019 at 10:47:47PM +0200, Markus Breunig wrote:

Hi Greg,

using a serial device driver is the idea of the manufacturer
"www.gns-gmbh.com". In the LINUX instructions of the ADS-B receiver some
hints to use the device are given via usbserial.


Any pointers to those instructions?


In practice

[PATCH 00/14] ARM: move lpc32xx and dove to multiplatform

2019-07-31 Thread Arnd Bergmann
I revisited some older patches here, getting two of the remaining
ARM platforms to build with ARCH_MULTIPLATFORM like most others do.

In case of lpc32xx, I created a new set of patches, which seemed
easier than digging out what I did for an older release many
years ago.

For dove, the patches are basically what I had proposed back in
2015 when all other ARMv6/ARMv7 machines became part of a single
kernel build. I don't know what the state is mach-dove support is,
compared to the DT based support in mach-mvebu for the same
hardware. If they are functionally the same, we could also just
remove mach-dove rather than applying my patches.

I also created patches to remove the w90x900 and ks8695 platforms
that seem to have lost their last users a few years ago.
I will post them separately, but plan to apply them in the same
branch for linux-5.4 if there are no objections.

  Arnd

Arnd Bergmann (14):
  usb: ohci-nxp: enable compile-testing
  usb: udc: lpc32xx: allow compile-testing
  watchdog: pnx4008_wdt: allow compile-testing
  serial: lpc32xx_hs: allow compile-testing
  gpio: lpc32xx: allow building on non-lpc32xx targets
  net: lpc-enet: factor out iram access
  net: lpc-enet: move phy setup into platform code
  net: lpc-enet: allow compile testing
  serial: lpc32xx: allow compile testing
  ARM: lpc32xx: clean up header files
  ARM: lpc32xx: allow multiplatform build
  ARM: dove: clean up mach/*.h headers
  ARM: orion/mvebu: unify debug-ll virtual addresses
  ARM: dove: multiplatform support

 arch/arm/Kconfig  | 33 +-
 arch/arm/Kconfig.debug|  5 +-
 arch/arm/configs/dove_defconfig   |  2 +
 arch/arm/configs/lpc32xx_defconfig|  1 +
 arch/arm/mach-dove/Kconfig| 16 +++--
 arch/arm/mach-dove/Makefile   |  2 +
 .../{include/mach => }/bridge-regs.h  |  4 +-
 arch/arm/mach-dove/cm-a510.c  |  3 +-
 arch/arm/mach-dove/common.c   |  4 +-
 arch/arm/mach-dove/dove-db-setup.c|  2 +-
 arch/arm/mach-dove/{include/mach => }/dove.h  | 14 ++---
 arch/arm/mach-dove/include/mach/hardware.h| 19 --
 arch/arm/mach-dove/include/mach/uncompress.h  | 36 ---
 arch/arm/mach-dove/irq.c  |  5 +-
 arch/arm/mach-dove/{include/mach => }/irqs.h  |  2 -
 arch/arm/mach-dove/mpp.c  |  2 +-
 arch/arm/mach-dove/pcie.c |  4 +-
 arch/arm/mach-dove/{include/mach => }/pm.h|  4 +-
 arch/arm/mach-lpc32xx/Kconfig | 11 
 arch/arm/mach-lpc32xx/common.c| 24 +--
 arch/arm/mach-lpc32xx/common.h|  1 -
 arch/arm/mach-lpc32xx/include/mach/board.h| 15 -
 .../mach-lpc32xx/include/mach/entry-macro.S   | 28 -
 arch/arm/mach-lpc32xx/include/mach/hardware.h | 25 
 .../mach-lpc32xx/include/mach/uncompress.h| 50 ---
 .../{include/mach/platform.h => lpc32xx.h}| 18 +-
 arch/arm/mach-lpc32xx/pm.c|  3 +-
 arch/arm/mach-lpc32xx/serial.c| 33 +-
 arch/arm/mach-lpc32xx/suspend.S   |  3 +-
 arch/arm/mach-mv78xx0/mv78xx0.h   |  4 +-
 arch/arm/mach-orion5x/orion5x.h   |  4 +-
 drivers/gpio/Kconfig  |  8 +++
 drivers/gpio/Makefile |  2 +-
 drivers/gpio/gpio-lpc32xx.c   | 63 ---
 drivers/net/ethernet/nxp/Kconfig  |  2 +-
 drivers/net/ethernet/nxp/lpc_eth.c| 30 +++--
 drivers/tty/serial/Kconfig|  3 +-
 drivers/tty/serial/lpc32xx_hs.c   | 37 ++-
 drivers/usb/gadget/udc/Kconfig|  3 +-
 drivers/usb/gadget/udc/lpc32xx_udc.c  |  2 -
 drivers/usb/host/Kconfig  |  3 +-
 drivers/usb/host/ohci-nxp.c   | 25 +---
 drivers/watchdog/Kconfig  |  2 +-
 drivers/watchdog/pnx4008_wdt.c|  1 -
 include/linux/soc/nxp/lpc32xx-misc.h  | 33 ++
 45 files changed, 246 insertions(+), 345 deletions(-)
 rename arch/arm/mach-dove/{include/mach => }/bridge-regs.h (96%)
 rename arch/arm/mach-dove/{include/mach => }/dove.h (95%)
 delete mode 100644 arch/arm/mach-dove/include/mach/hardware.h
 delete mode 100644 arch/arm/mach-dove/include/mach/uncompress.h
 rename arch/arm/mach-dove/{include/mach => }/irqs.h (98%)
 rename arch/arm/mach-dove/{include/mach => }/pm.h (97%)
 create mode 100644 arch/arm/mach-lpc32xx/Kconfig
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/board.h
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/entry-macro.S
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/hardware.h
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/uncompress.h
 rename arch/arm/mach-lpc32xx/{include/mach/platform.h => lpc32xx.h} (98%)
 create mode 100644 include/linux/soc/nxp/lpc32xx-misc.h

-- 
2.20.0



[PATCH 01/14] usb: ohci-nxp: enable compile-testing

2019-07-31 Thread Arnd Bergmann
The driver hardcodes a hardware I/O address the way one should
generally not do, and this prevents both compile-testing, and
moving the platform to CONFIG_ARCH_MULTIPLATFORM.

Change the code to be independent of the machine headers
to allow those two. Removing the hardcoded address would
be hard and is not necessary, so leave that in place for now.

Signed-off-by: Arnd Bergmann 
---
 drivers/usb/host/Kconfig|  3 ++-
 drivers/usb/host/ohci-nxp.c | 25 ++---
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 40b5de597112..73d233d3bf4d 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -441,7 +441,8 @@ config USB_OHCI_HCD_S3C2410
 
 config USB_OHCI_HCD_LPC32XX
tristate "Support for LPC on-chip OHCI USB controller"
-   depends on USB_OHCI_HCD && ARCH_LPC32XX
+   depends on USB_OHCI_HCD
+   depends on ARCH_LPC32XX || COMPILE_TEST
depends on USB_ISP1301
default y
---help---
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index f5f532601092..c561881d0e79 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -29,10 +29,7 @@
 
 #include "ohci.h"
 
-#include 
-
 #define USB_CONFIG_BASE0x3102
-#define USB_OTG_STAT_CONTROL   IO_ADDRESS(USB_CONFIG_BASE + 0x110)
 
 /* USB_OTG_STAT_CONTROL bit defines */
 #define TRANSPARENT_I2C_EN (1 << 7)
@@ -122,19 +119,33 @@ static inline void isp1301_vbus_off(void)
 
 static void ohci_nxp_start_hc(void)
 {
-   unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN;
+   void __iomem *usb_otg_stat_control = ioremap(USB_CONFIG_BASE + 0x110, 
4);
+   unsigned long tmp;
+
+   if (WARN_ON(!usb_otg_stat_control))
+   return;
+
+   tmp = __raw_readl(usb_otg_stat_control) | HOST_EN;
 
-   __raw_writel(tmp, USB_OTG_STAT_CONTROL);
+   __raw_writel(tmp, usb_otg_stat_control);
isp1301_vbus_on();
+
+   iounmap(usb_otg_stat_control);
 }
 
 static void ohci_nxp_stop_hc(void)
 {
+   void __iomem *usb_otg_stat_control = ioremap(USB_CONFIG_BASE + 0x110, 
4);
unsigned long tmp;
 
+   if (WARN_ON(!usb_otg_stat_control))
+   return;
+
isp1301_vbus_off();
-   tmp = __raw_readl(USB_OTG_STAT_CONTROL) & ~HOST_EN;
-   __raw_writel(tmp, USB_OTG_STAT_CONTROL);
+   tmp = __raw_readl(usb_otg_stat_control) & ~HOST_EN;
+   __raw_writel(tmp, usb_otg_stat_control);
+
+   iounmap(usb_otg_stat_control);
 }
 
 static int ohci_hcd_nxp_probe(struct platform_device *pdev)
-- 
2.20.0



[PATCH 03/14] watchdog: pnx4008_wdt: allow compile-testing

2019-07-31 Thread Arnd Bergmann
The only thing that prevents building this driver on other
platforms is the mach/hardware.h include, which is not actually
used here at all, so remove the line and allow CONFIG_COMPILE_TEST.

Signed-off-by: Arnd Bergmann 
---
 drivers/watchdog/Kconfig   | 2 +-
 drivers/watchdog/pnx4008_wdt.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 8188963a405b..a45f9e3e442b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -551,7 +551,7 @@ config OMAP_WATCHDOG
 
 config PNX4008_WATCHDOG
tristate "LPC32XX Watchdog"
-   depends on ARCH_LPC32XX
+   depends on ARCH_LPC32XX || COMPILE_TEST
select WATCHDOG_CORE
help
  Say Y here if to include support for the watchdog timer
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 7b446b696f2b..e0ea133c1690 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 /* WatchDog Timer - Chapter 23 Page 207 */
 
-- 
2.20.0



[PATCH 02/14] usb: udc: lpc32xx: allow compile-testing

2019-07-31 Thread Arnd Bergmann
The only thing that prevents building this driver on other
platforms is the mach/hardware.h include, which is not actually
used here at all, so remove the line and allow CONFIG_COMPILE_TEST.

Signed-off-by: Arnd Bergmann 
---
 drivers/usb/gadget/udc/Kconfig   | 3 ++-
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 --
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index ef0259a950ba..d354036ff6c8 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -45,7 +45,8 @@ config USB_AT91
 
 config USB_LPC32XX
tristate "LPC32XX USB Peripheral Controller"
-   depends on ARCH_LPC32XX && I2C
+   depends on ARCH_LPC32XX || COMPILE_TEST
+   depends on I2C
select USB_ISP1301
help
   This option selects the USB device controller in the LPC32xx SoC.
diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c 
b/drivers/usb/gadget/udc/lpc32xx_udc.c
index 5f1b14f3e5a0..4d8847988a50 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -35,8 +35,6 @@
 #include 
 #endif
 
-#include 
-
 /*
  * USB device configuration structure
  */
-- 
2.20.0



[PATCH 04/14] serial: lpc32xx_hs: allow compile-testing

2019-07-31 Thread Arnd Bergmann
The only thing that prevents building this driver on other
platforms is the mach/hardware.h include, which is not actually
used here at all, so remove the line and allow CONFIG_COMPILE_TEST.

Signed-off-by: Arnd Bergmann 
---
 drivers/tty/serial/Kconfig  | 3 ++-
 drivers/tty/serial/lpc32xx_hs.c | 2 --
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 3083dbae35f7..518aac902e4b 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -739,7 +739,8 @@ config SERIAL_PNX8XXX_CONSOLE
 
 config SERIAL_HS_LPC32XX
tristate "LPC32XX high speed serial port support"
-   depends on ARCH_LPC32XX && OF
+   depends on ARCH_LPC32XX || COMPILE_TEST
+   depends on OF
select SERIAL_CORE
help
  Support for the LPC32XX high speed serial ports (up to 900kbps).
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index f4e27d0ad947..7f14cd8fac47 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -25,8 +25,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 /*
  * High Speed UART register offsets
-- 
2.20.0



[PATCH 05/14] gpio: lpc32xx: allow building on non-lpc32xx targets

2019-07-31 Thread Arnd Bergmann
The driver uses hardwire MMIO addresses instead of the data
that is passed in device tree. Change it over to only
hardcode the register offset values and allow compile-testing.

Signed-off-by: Arnd Bergmann 
---
 drivers/gpio/Kconfig|  8 +
 drivers/gpio/Makefile   |  2 +-
 drivers/gpio/gpio-lpc32xx.c | 63 -
 3 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index bb13c266c329..ae86ee963eae 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -311,6 +311,14 @@ config GPIO_LPC18XX
  Select this option to enable GPIO driver for
  NXP LPC18XX/43XX devices.
 
+config GPIO_LPC32XX
+   tristate "NXP LPC32XX GPIO support"
+   default ARCH_LPC32XX
+   depends on OF_GPIO && (ARCH_LPC32XX || COMPILE_TEST)
+   help
+ Select this option to enable GPIO driver for
+ NXP LPC32XX devices.
+
 config GPIO_LYNXPOINT
tristate "Intel Lynxpoint GPIO support"
depends on ACPI && X86
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index a4e91175c708..87d659ae95eb 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -74,7 +74,7 @@ obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o
 obj-$(CONFIG_GPIO_LP873X)  += gpio-lp873x.o
 obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o
 obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o
-obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o
+obj-$(CONFIG_GPIO_LPC32XX) += gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LYNXPOINT)   += gpio-lynxpoint.o
 obj-$(CONFIG_GPIO_MADERA)  += gpio-madera.o
 obj-$(CONFIG_GPIO_MAX3191X)+= gpio-max3191x.o
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 24885b3db3d5..548f7cb69386 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -16,8 +16,7 @@
 #include 
 #include 
 
-#include 
-#include 
+#define _GPREG(x)  (x)
 
 #define LPC32XX_GPIO_P3_INP_STATE  _GPREG(0x000)
 #define LPC32XX_GPIO_P3_OUTP_SET   _GPREG(0x004)
@@ -72,12 +71,12 @@
 #define LPC32XX_GPO_P3_GRP (LPC32XX_GPI_P3_GRP + LPC32XX_GPI_P3_MAX)
 
 struct gpio_regs {
-   void __iomem *inp_state;
-   void __iomem *outp_state;
-   void __iomem *outp_set;
-   void __iomem *outp_clr;
-   void __iomem *dir_set;
-   void __iomem *dir_clr;
+   unsigned long inp_state;
+   unsigned long outp_state;
+   unsigned long outp_set;
+   unsigned long outp_clr;
+   unsigned long dir_set;
+   unsigned long dir_clr;
 };
 
 /*
@@ -167,14 +166,26 @@ struct lpc32xx_gpio_chip {
struct gpio_regs*gpio_grp;
 };
 
+void __iomem *gpio_reg_base;
+
+static inline u32 gpreg_read(unsigned long offset)
+{
+   return __raw_readl(gpio_reg_base + offset);
+}
+
+static inline void gpreg_write(u32 val, unsigned long offset)
+{
+   __raw_writel(val, gpio_reg_base + offset);
+}
+
 static void __set_gpio_dir_p012(struct lpc32xx_gpio_chip *group,
unsigned pin, int input)
 {
if (input)
-   __raw_writel(GPIO012_PIN_TO_BIT(pin),
+   gpreg_write(GPIO012_PIN_TO_BIT(pin),
group->gpio_grp->dir_clr);
else
-   __raw_writel(GPIO012_PIN_TO_BIT(pin),
+   gpreg_write(GPIO012_PIN_TO_BIT(pin),
group->gpio_grp->dir_set);
 }
 
@@ -184,19 +195,19 @@ static void __set_gpio_dir_p3(struct lpc32xx_gpio_chip 
*group,
u32 u = GPIO3_PIN_TO_BIT(pin);
 
if (input)
-   __raw_writel(u, group->gpio_grp->dir_clr);
+   gpreg_write(u, group->gpio_grp->dir_clr);
else
-   __raw_writel(u, group->gpio_grp->dir_set);
+   gpreg_write(u, group->gpio_grp->dir_set);
 }
 
 static void __set_gpio_level_p012(struct lpc32xx_gpio_chip *group,
unsigned pin, int high)
 {
if (high)
-   __raw_writel(GPIO012_PIN_TO_BIT(pin),
+   gpreg_write(GPIO012_PIN_TO_BIT(pin),
group->gpio_grp->outp_set);
else
-   __raw_writel(GPIO012_PIN_TO_BIT(pin),
+   gpreg_write(GPIO012_PIN_TO_BIT(pin),
group->gpio_grp->outp_clr);
 }
 
@@ -206,31 +217,31 @@ static void __set_gpio_level_p3(struct lpc32xx_gpio_chip 
*group,
u32 u = GPIO3_PIN_TO_BIT(pin);
 
if (high)
-   __raw_writel(u, group->gpio_grp->outp_set);
+   gpreg_write(u, group->gpio_grp->outp_set);
else
-   __raw_writel(u, group->gpio_grp->outp_clr);
+   gpreg_write(u, group->gpio_grp->outp_clr);
 }
 
 static void __set_gpo_level_p3(struct lpc32xx_gpio_chip *group,
unsigned pin, int high)
 {
if (high)
-   __raw_writel(GPO3_PIN_TO_BIT(pin), group->gpio_grp->outp_set);
+   gpreg_write(GPO3_PIN_TO_BI

[PATCH 06/14] net: lpc-enet: factor out iram access

2019-07-31 Thread Arnd Bergmann
The lpc_eth driver uses a platform specific method to find
the internal sram. This prevents building it on other machines.

Rework to only use one function call and keep the other platform
internals where they belong. Ideally this would look up the
sram location from DT, but as this is a rarely used driver,
I want to keep the modifications to a minimum.

Signed-off-by: Arnd Bergmann 
---
 arch/arm/mach-lpc32xx/common.c |  9 ++--
 arch/arm/mach-lpc32xx/common.h |  1 -
 arch/arm/mach-lpc32xx/include/mach/board.h | 15 --
 drivers/net/ethernet/nxp/lpc_eth.c | 17 ---
 include/linux/soc/nxp/lpc32xx-misc.h   | 24 ++
 5 files changed, 39 insertions(+), 27 deletions(-)
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/board.h
 create mode 100644 include/linux/soc/nxp/lpc32xx-misc.h

diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index 5b71b4fab2cd..f648324d5fb4 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -32,7 +33,7 @@ void lpc32xx_get_uid(u32 devid[4])
  */
 #define LPC32XX_IRAM_BANK_SIZE SZ_128K
 static u32 iram_size;
-u32 lpc32xx_return_iram_size(void)
+u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr)
 {
if (iram_size == 0) {
u32 savedval1, savedval2;
@@ -53,10 +54,14 @@ u32 lpc32xx_return_iram_size(void)
} else
iram_size = LPC32XX_IRAM_BANK_SIZE * 2;
}
+   if (dmaaddr)
+   *dmaaddr = LPC32XX_IRAM_BASE;
+   if (mapbase)
+   *mapbase = io_p2v(LPC32XX_IRAM_BASE);
 
return iram_size;
 }
-EXPORT_SYMBOL_GPL(lpc32xx_return_iram_size);
+EXPORT_SYMBOL_GPL(lpc32xx_return_iram);
 
 static struct map_desc lpc32xx_io_desc[] __initdata = {
{
diff --git a/arch/arm/mach-lpc32xx/common.h b/arch/arm/mach-lpc32xx/common.h
index 8e597ce48a73..32f0ad217807 100644
--- a/arch/arm/mach-lpc32xx/common.h
+++ b/arch/arm/mach-lpc32xx/common.h
@@ -23,7 +23,6 @@ extern void __init lpc32xx_serial_init(void);
  */
 extern void lpc32xx_get_uid(u32 devid[4]);
 
-extern u32 lpc32xx_return_iram_size(void);
 /*
  * Pointers used for sizing and copying suspend function data
  */
diff --git a/arch/arm/mach-lpc32xx/include/mach/board.h 
b/arch/arm/mach-lpc32xx/include/mach/board.h
deleted file mode 100644
index 476513d970a4..
--- a/arch/arm/mach-lpc32xx/include/mach/board.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * arm/arch/mach-lpc32xx/include/mach/board.h
- *
- * Author: Kevin Wells 
- *
- * Copyright (C) 2010 NXP Semiconductors
- */
-
-#ifndef __ASM_ARCH_BOARD_H
-#define __ASM_ARCH_BOARD_H
-
-extern u32 lpc32xx_return_iram_size(void);
-
-#endif  /* __ASM_ARCH_BOARD_H */
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c 
b/drivers/net/ethernet/nxp/lpc_eth.c
index f7e11f1b0426..bcdd0adcfb0c 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -18,8 +18,8 @@
 #include 
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 
@@ -1311,16 +1311,15 @@ static int lpc_eth_drv_probe(struct platform_device 
*pdev)
/* Get size of DMA buffers/descriptors region */
pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE +
sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t));
-   pldat->dma_buff_base_v = 0;
 
if (use_iram_for_net(dev)) {
-   dma_handle = LPC32XX_IRAM_BASE;
-   if (pldat->dma_buff_size <= lpc32xx_return_iram_size())
-   pldat->dma_buff_base_v =
-   io_p2v(LPC32XX_IRAM_BASE);
-   else
+   if (pldat->dma_buff_size >
+   lpc32xx_return_iram(&pldat->dma_buff_base_v, &dma_handle)) {
+   pldat->dma_buff_base_v = NULL;
+   pldat->dma_buff_size = 0;
netdev_err(ndev,
"IRAM not big enough for net buffers, using 
SDRAM instead.\n");
+   }
}
 
if (pldat->dma_buff_base_v == 0) {
@@ -1409,7 +1408,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
unregister_netdev(ndev);
 err_out_dma_unmap:
if (!use_iram_for_net(dev) ||
-   pldat->dma_buff_size > lpc32xx_return_iram_size())
+   pldat->dma_buff_size > lpc32xx_return_iram(NULL, NULL))
dma_free_coherent(dev, pldat->dma_buff_size,
  pldat->dma_buff_base_v,
  pldat->dma_buff_base_p);
@@ -1436,7 +1435,7 @@ static int lpc_eth_drv_remove(struct platform_device 
*pdev)
unregister_netdev(ndev);
 
if (!use_iram_for_net(&pldat->pdev->dev) ||
-   pldat->dma_buff_size > lpc32xx_return_iram_size())
+   pldat->

[PATCH 07/14] net: lpc-enet: move phy setup into platform code

2019-07-31 Thread Arnd Bergmann
Setting the phy mode requires touching a platform specific
register, which prevents us from building the driver without
its header files.

Move it into a separate function in arch/arm/mach/lpc32xx
to hide the core registers from the network driver.

Signed-off-by: Arnd Bergmann 
---
 arch/arm/mach-lpc32xx/common.c   | 12 
 drivers/net/ethernet/nxp/lpc_eth.c   | 12 +---
 include/linux/soc/nxp/lpc32xx-misc.h |  5 +
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index f648324d5fb4..a475339333c1 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -63,6 +63,18 @@ u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t 
*dmaaddr)
 }
 EXPORT_SYMBOL_GPL(lpc32xx_return_iram);
 
+void lpc32xx_set_phy_interface_mode(phy_interface_t mode)
+{
+   u32 tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
+   tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
+   if (mode == PHY_INTERFACE_MODE_MII)
+   tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
+   else
+   tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
+   __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL);
+}
+EXPORT_SYMBOL_GPL(lpc32xx_set_phy_interface_mode);
+
 static struct map_desc lpc32xx_io_desc[] __initdata = {
{
.virtual= (unsigned long)IO_ADDRESS(LPC32XX_AHB0_START),
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c 
b/drivers/net/ethernet/nxp/lpc_eth.c
index bcdd0adcfb0c..0893b77c385d 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -20,9 +20,6 @@
 #include 
 #include 
 
-#include 
-#include 
-
 #define MODNAME "lpc-eth"
 #define DRV_VERSION "1.00"
 
@@ -1237,16 +1234,9 @@ static int lpc_eth_drv_probe(struct platform_device 
*pdev)
dma_addr_t dma_handle;
struct resource *res;
int irq, ret;
-   u32 tmp;
 
/* Setup network interface for RMII or MII mode */
-   tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
-   tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
-   if (lpc_phy_interface_mode(dev) == PHY_INTERFACE_MODE_MII)
-   tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
-   else
-   tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
-   __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL);
+   lpc32xx_set_phy_interface_mode(lpc_phy_interface_mode(dev));
 
/* Get platform resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/include/linux/soc/nxp/lpc32xx-misc.h 
b/include/linux/soc/nxp/lpc32xx-misc.h
index f232e1a1bcdc..af4f82f6cf3b 100644
--- a/include/linux/soc/nxp/lpc32xx-misc.h
+++ b/include/linux/soc/nxp/lpc32xx-misc.h
@@ -9,9 +9,11 @@
 #define __SOC_LPC32XX_MISC_H
 
 #include 
+#include 
 
 #ifdef CONFIG_ARCH_LPC32XX
 extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr);
+extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode);
 #else
 static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t 
*dmaaddr)
 {
@@ -19,6 +21,9 @@ static inline u32 lpc32xx_return_iram(void __iomem **mapbase, 
dma_addr_t *dmaadd
*dmaaddr = 0;
return 0;
 }
+static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode)
+{
+}
 #endif
 
 #endif  /* __SOC_LPC32XX_MISC_H */
-- 
2.20.0



[PATCH 08/14] net: lpc-enet: allow compile testing

2019-07-31 Thread Arnd Bergmann
The lpc-enet driver can now be built on all platforms, so
allow compile testing as well.

Signed-off-by: Arnd Bergmann 
---
 drivers/net/ethernet/nxp/Kconfig   | 2 +-
 drivers/net/ethernet/nxp/lpc_eth.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/nxp/Kconfig b/drivers/net/ethernet/nxp/Kconfig
index 261f107e2be0..418afb84c84b 100644
--- a/drivers/net/ethernet/nxp/Kconfig
+++ b/drivers/net/ethernet/nxp/Kconfig
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config LPC_ENET
 tristate "NXP ethernet MAC on LPC devices"
-depends on ARCH_LPC32XX
+depends on ARCH_LPC32XX || COMPILE_TEST
 select PHYLIB
 help
  Say Y or M here if you want to use the NXP ethernet MAC included on
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c 
b/drivers/net/ethernet/nxp/lpc_eth.c
index 0893b77c385d..34fdf2100772 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.20.0



[PATCH 09/14] serial: lpc32xx: allow compile testing

2019-07-31 Thread Arnd Bergmann
The lpc32xx_loopback_set() function in hte lpc32xx_hs driver is the
one thing that relies on platform header files. Move that into the
core platform code so we only need a variable declaration for it,
and enable COMPILE_TEST building.

Signed-off-by: Arnd Bergmann 
---
 arch/arm/mach-lpc32xx/serial.c   | 30 
 drivers/tty/serial/lpc32xx_hs.c  | 35 
 include/linux/soc/nxp/lpc32xx-misc.h |  4 
 3 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/serial.c b/arch/arm/mach-lpc32xx/serial.c
index 3f9b30df9f0e..cfb35e5691cd 100644
--- a/arch/arm/mach-lpc32xx/serial.c
+++ b/arch/arm/mach-lpc32xx/serial.c
@@ -60,6 +60,36 @@ static struct uartinit uartinit_data[] __initdata = {
},
 };
 
+/* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */
+void lpc32xx_loopback_set(resource_size_t mapbase, int state)
+{
+   int bit;
+   u32 tmp;
+
+   switch (mapbase) {
+   case LPC32XX_HS_UART1_BASE:
+   bit = 0;
+   break;
+   case LPC32XX_HS_UART2_BASE:
+   bit = 1;
+   break;
+   case LPC32XX_HS_UART7_BASE:
+   bit = 6;
+   break;
+   default:
+   WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase);
+   return;
+   }
+
+   tmp = readl(LPC32XX_UARTCTL_CLOOP);
+   if (state)
+   tmp |= (1 << bit);
+   else
+   tmp &= ~(1 << bit);
+   writel(tmp, LPC32XX_UARTCTL_CLOOP);
+}
+EXPORT_SYMBOL_GPL(lpc32xx_loopback_set);
+
 void __init lpc32xx_serial_init(void)
 {
u32 tmp, clkmodes = 0;
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index 7f14cd8fac47..d3843f722182 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /*
  * High Speed UART register offsets
@@ -79,6 +81,8 @@
 #define LPC32XX_HSU_TX_TL8B(0x2 << 0)
 #define LPC32XX_HSU_TX_TL16B   (0x3 << 0)
 
+#define LPC32XX_MAIN_OSC_FREQ  1300
+
 #define MODNAME "lpc32xx_hsuart"
 
 struct lpc32xx_hsuart_port {
@@ -149,8 +153,6 @@ static void lpc32xx_hsuart_console_write(struct console 
*co, const char *s,
local_irq_restore(flags);
 }
 
-static void lpc32xx_loopback_set(resource_size_t mapbase, int state);
-
 static int __init lpc32xx_hsuart_console_setup(struct console *co,
   char *options)
 {
@@ -437,35 +439,6 @@ static void serial_lpc32xx_break_ctl(struct uart_port 
*port,
spin_unlock_irqrestore(&port->lock, flags);
 }
 
-/* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */
-static void lpc32xx_loopback_set(resource_size_t mapbase, int state)
-{
-   int bit;
-   u32 tmp;
-
-   switch (mapbase) {
-   case LPC32XX_HS_UART1_BASE:
-   bit = 0;
-   break;
-   case LPC32XX_HS_UART2_BASE:
-   bit = 1;
-   break;
-   case LPC32XX_HS_UART7_BASE:
-   bit = 6;
-   break;
-   default:
-   WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase);
-   return;
-   }
-
-   tmp = readl(LPC32XX_UARTCTL_CLOOP);
-   if (state)
-   tmp |= (1 << bit);
-   else
-   tmp &= ~(1 << bit);
-   writel(tmp, LPC32XX_UARTCTL_CLOOP);
-}
-
 /* port->lock is not held.  */
 static int serial_lpc32xx_startup(struct uart_port *port)
 {
diff --git a/include/linux/soc/nxp/lpc32xx-misc.h 
b/include/linux/soc/nxp/lpc32xx-misc.h
index af4f82f6cf3b..699c6f1e3aab 100644
--- a/include/linux/soc/nxp/lpc32xx-misc.h
+++ b/include/linux/soc/nxp/lpc32xx-misc.h
@@ -14,6 +14,7 @@
 #ifdef CONFIG_ARCH_LPC32XX
 extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr);
 extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode);
+extern void lpc32xx_loopback_set(resource_size_t mapbase, int state);
 #else
 static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t 
*dmaaddr)
 {
@@ -24,6 +25,9 @@ static inline u32 lpc32xx_return_iram(void __iomem **mapbase, 
dma_addr_t *dmaadd
 static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode)
 {
 }
+static inline void lpc32xx_loopback_set(resource_size_t mapbase, int state)
+{
+}
 #endif
 
 #endif  /* __SOC_LPC32XX_MISC_H */
-- 
2.20.0



[PATCH 10/14] ARM: lpc32xx: clean up header files

2019-07-31 Thread Arnd Bergmann
All device drivers have stopped relying on mach/*.h headers,
so move the remaining headers into arch/arm/mach-lpc32xx/lpc32xx.h
to prepare for multiplatform builds.

The mach/entry-macro.S file has been unused for a long time now
and can simply get removed.

Signed-off-by: Arnd Bergmann 
---
 arch/arm/mach-lpc32xx/common.c|  3 +-
 .../mach-lpc32xx/include/mach/entry-macro.S   | 28 ---
 arch/arm/mach-lpc32xx/include/mach/hardware.h | 25 -
 .../mach-lpc32xx/include/mach/uncompress.h|  4 +--
 .../{include/mach/platform.h => lpc32xx.h}| 18 ++--
 arch/arm/mach-lpc32xx/pm.c|  3 +-
 arch/arm/mach-lpc32xx/serial.c|  3 +-
 arch/arm/mach-lpc32xx/suspend.S   |  3 +-
 8 files changed, 21 insertions(+), 66 deletions(-)
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/entry-macro.S
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/hardware.h
 rename arch/arm/mach-lpc32xx/{include/mach/platform.h => lpc32xx.h} (98%)

diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index a475339333c1..304ea61a0716 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -13,8 +13,7 @@
 #include 
 #include 
 
-#include 
-#include 
+#include "lpc32xx.h"
 #include "common.h"
 
 /*
diff --git a/arch/arm/mach-lpc32xx/include/mach/entry-macro.S 
b/arch/arm/mach-lpc32xx/include/mach/entry-macro.S
deleted file mode 100644
index eec0f5f7e722..
--- a/arch/arm/mach-lpc32xx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * arch/arm/mach-lpc32xx/include/mach/entry-macro.S
- *
- * Author: Kevin Wells 
- *
- * Copyright (C) 2010 NXP Semiconductors
- */
-
-#include 
-#include 
-
-#define LPC32XX_INTC_MASKED_STATUS_OFS 0x8
-
-   .macro  get_irqnr_preamble, base, tmp
-   ldr \base, =IO_ADDRESS(LPC32XX_MIC_BASE)
-   .endm
-
-/*
- * Return IRQ number in irqnr. Also return processor Z flag status in CPSR
- * as set if an interrupt is pending.
- */
-   .macro  get_irqnr_and_base, irqnr, irqstat, base, tmp
-   ldr \irqstat, [\base, #LPC32XX_INTC_MASKED_STATUS_OFS]
-   clz \irqnr, \irqstat
-   rsb \irqnr, \irqnr, #31
-   teq \irqstat, #0
-   .endm
diff --git a/arch/arm/mach-lpc32xx/include/mach/hardware.h 
b/arch/arm/mach-lpc32xx/include/mach/hardware.h
deleted file mode 100644
index 4866f096ffce..
--- a/arch/arm/mach-lpc32xx/include/mach/hardware.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * arch/arm/mach-lpc32xx/include/mach/hardware.h
- *
- * Copyright (c) 2005 MontaVista Software, Inc. 
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-/*
- * Start of virtual addresses for IO devices
- */
-#define IO_BASE0xF000
-
-/*
- * This macro relies on fact that for all HW i/o addresses bits 20-23 are 0
- */
-#define IO_ADDRESS(x)  IOMEM(x) & 0xff00) >> 4) | ((x) & 0xf)) |\
-IO_BASE)
-
-#define io_p2v(x)  ((void __iomem *) (unsigned long) IO_ADDRESS(x))
-#define io_v2p(x)  x) & 0x0ff0) << 4) | ((x) & 0x000f))
-
-#endif
diff --git a/arch/arm/mach-lpc32xx/include/mach/uncompress.h 
b/arch/arm/mach-lpc32xx/include/mach/uncompress.h
index a568812a0b91..74b7aa0da0e4 100644
--- a/arch/arm/mach-lpc32xx/include/mach/uncompress.h
+++ b/arch/arm/mach-lpc32xx/include/mach/uncompress.h
@@ -12,15 +12,13 @@
 
 #include 
 
-#include 
-#include 
-
 /*
  * Uncompress output is hardcoded to standard UART 5
  */
 
 #define UART_FIFO_CTL_TX_RESET (1 << 2)
 #define UART_STATUS_TX_MT  (1 << 6)
+#define LPC32XX_UART5_BASE 0x4009
 
 #define _UARTREG(x)(void __iomem *)(LPC32XX_UART5_BASE + (x))
 
diff --git a/arch/arm/mach-lpc32xx/include/mach/platform.h 
b/arch/arm/mach-lpc32xx/lpc32xx.h
similarity index 98%
rename from arch/arm/mach-lpc32xx/include/mach/platform.h
rename to arch/arm/mach-lpc32xx/lpc32xx.h
index 1c53790444fc..5eeb884a1993 100644
--- a/arch/arm/mach-lpc32xx/include/mach/platform.h
+++ b/arch/arm/mach-lpc32xx/lpc32xx.h
@@ -7,8 +7,8 @@
  * Copyright (C) 2010 NXP Semiconductors
  */
 
-#ifndef __ASM_ARCH_PLATFORM_H
-#define __ASM_ARCH_PLATFORM_H
+#ifndef __ARM_LPC32XX_H
+#define __ARM_LPC32XX_H
 
 #define _SBF(f, v) ((v) << (f))
 #define _BIT(n)_SBF(n, 1)
@@ -700,4 +700,18 @@
 #define LPC32XX_USB_OTG_DEV_CLOCK_ON   _BIT(1)
 #define LPC32XX_USB_OTG_HOST_CLOCK_ON  _BIT(0)
 
+/*
+ * Start of virtual addresses for IO devices
+ */
+#define IO_BASE0xF000
+
+/*
+ * This macro relies on fact that for all HW i/o addresses bits 20-23 are 0
+ */
+#define IO_ADDRESS(x)  IOMEM(x) & 0xff00) >> 4) | ((x) & 0xf)) |\
+IO_BASE)
+
+#define io_p2v(x)  ((void __iomem *) (unsigned long) IO_ADDRE

[PATCH 11/14] ARM: lpc32xx: allow multiplatform build

2019-07-31 Thread Arnd Bergmann
All preparation work is done, so the platform can finally
be moved into ARCH_MULTIPLATFORM. This requires a small
change to the defconfig file to enable the platform.

Signed-off-by: Arnd Bergmann 
---
 arch/arm/Kconfig  | 17 +--
 arch/arm/configs/lpc32xx_defconfig|  1 +
 arch/arm/mach-lpc32xx/Kconfig | 11 +
 .../mach-lpc32xx/include/mach/uncompress.h| 48 ---
 4 files changed, 14 insertions(+), 63 deletions(-)
 create mode 100644 arch/arm/mach-lpc32xx/Kconfig
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/uncompress.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 33b00579beff..65808e17cb3b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -478,21 +478,6 @@ config ARCH_W90X900
  
 
-config ARCH_LPC32XX
-   bool "NXP LPC32XX"
-   select ARM_AMBA
-   select CLKDEV_LOOKUP
-   select CLKSRC_LPC32XX
-   select COMMON_CLK
-   select CPU_ARM926T
-   select GENERIC_CLOCKEVENTS
-   select GENERIC_IRQ_MULTI_HANDLER
-   select GPIOLIB
-   select SPARSE_IRQ
-   select USE_OF
-   help
- Support for the NXP LPC32XX family of processors
-
 config ARCH_PXA
bool "PXA2xx/PXA3xx-based"
depends on MMU
@@ -746,6 +731,8 @@ source "arch/arm/mach-keystone/Kconfig"
 
 source "arch/arm/mach-ks8695/Kconfig"
 
+source "arch/arm/mach-lpc32xx/Kconfig"
+
 source "arch/arm/mach-mediatek/Kconfig"
 
 source "arch/arm/mach-meson/Kconfig"
diff --git a/arch/arm/configs/lpc32xx_defconfig 
b/arch/arm/configs/lpc32xx_defconfig
index 0cdc6c7974b3..2d75bd8dbaf0 100644
--- a/arch/arm/configs/lpc32xx_defconfig
+++ b/arch/arm/configs/lpc32xx_defconfig
@@ -12,6 +12,7 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL_SYSCALL=y
 CONFIG_EMBEDDED=y
 CONFIG_SLAB=y
+# CONFIG_ARCH_MULTI_V7 is not set
 CONFIG_ARCH_LPC32XX=y
 CONFIG_AEABI=y
 CONFIG_ZBOOT_ROM_TEXT=0x0
diff --git a/arch/arm/mach-lpc32xx/Kconfig b/arch/arm/mach-lpc32xx/Kconfig
new file mode 100644
index ..ec87c65f4536
--- /dev/null
+++ b/arch/arm/mach-lpc32xx/Kconfig
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config ARCH_LPC32XX
+   bool "NXP LPC32XX"
+   depends on ARCH_MULTI_V5
+   select ARM_AMBA
+   select CLKSRC_LPC32XX
+   select CPU_ARM926T
+   select GPIOLIB
+   help
+ Support for the NXP LPC32XX family of processors
diff --git a/arch/arm/mach-lpc32xx/include/mach/uncompress.h 
b/arch/arm/mach-lpc32xx/include/mach/uncompress.h
deleted file mode 100644
index 74b7aa0da0e4..
--- a/arch/arm/mach-lpc32xx/include/mach/uncompress.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * arch/arm/mach-lpc32xx/include/mach/uncompress.h
- *
- * Author: Kevin Wells 
- *
- * Copyright (C) 2010 NXP Semiconductors
- */
-
-#ifndef __ASM_ARM_ARCH_UNCOMPRESS_H
-#define __ASM_ARM_ARCH_UNCOMPRESS_H
-
-#include 
-
-/*
- * Uncompress output is hardcoded to standard UART 5
- */
-
-#define UART_FIFO_CTL_TX_RESET (1 << 2)
-#define UART_STATUS_TX_MT  (1 << 6)
-#define LPC32XX_UART5_BASE 0x4009
-
-#define _UARTREG(x)(void __iomem *)(LPC32XX_UART5_BASE + (x))
-
-#define LPC32XX_UART_DLLFIFO_O 0x00
-#define LPC32XX_UART_IIRFCR_O  0x08
-#define LPC32XX_UART_LSR_O 0x14
-
-static inline void putc(int ch)
-{
-   /* Wait for transmit FIFO to empty */
-   while ((__raw_readl(_UARTREG(LPC32XX_UART_LSR_O)) &
-   UART_STATUS_TX_MT) == 0)
-   ;
-
-   __raw_writel((u32) ch, _UARTREG(LPC32XX_UART_DLLFIFO_O));
-}
-
-static inline void flush(void)
-{
-   __raw_writel(__raw_readl(_UARTREG(LPC32XX_UART_IIRFCR_O)) |
-   UART_FIFO_CTL_TX_RESET, _UARTREG(LPC32XX_UART_IIRFCR_O));
-}
-
-/* NULL functions; we don't presently need them */
-#define arch_decomp_setup()
-
-#endif
-- 
2.20.0



[PATCH 12/14] ARM: dove: clean up mach/*.h headers

2019-07-31 Thread Arnd Bergmann
This is a simple move of all header files that are no longer
included by anything else from the include/mach directory
to the platform directory itself as preparation for
multiplatform support.

The mach/uncompress.h headers are left in place for now,
and are mildly modified to be independent of the other
headers. They will be removed entirely when ARCH_MULTIPLATFORM
gets enabled and they become obsolete.

Rather than updating the path names inside of the comments
of each header, I delete those comments to avoid having to
update them again, should they get moved or copied another
time.

Signed-off-by: Arnd Bergmann 
Acked-by: Andrew Lunn 
---
 .../{include/mach => }/bridge-regs.h  |  4 +---
 arch/arm/mach-dove/cm-a510.c  |  3 +--
 arch/arm/mach-dove/common.c   |  4 ++--
 arch/arm/mach-dove/dove-db-setup.c|  2 +-
 arch/arm/mach-dove/{include/mach => }/dove.h  |  4 +---
 arch/arm/mach-dove/include/mach/hardware.h| 19 ---
 arch/arm/mach-dove/include/mach/uncompress.h  |  8 +++-
 arch/arm/mach-dove/irq.c  |  5 -
 arch/arm/mach-dove/{include/mach => }/irqs.h  |  2 --
 arch/arm/mach-dove/mpp.c  |  2 +-
 arch/arm/mach-dove/pcie.c |  4 ++--
 arch/arm/mach-dove/{include/mach => }/pm.h|  4 +---
 12 files changed, 17 insertions(+), 44 deletions(-)
 rename arch/arm/mach-dove/{include/mach => }/bridge-regs.h (96%)
 rename arch/arm/mach-dove/{include/mach => }/dove.h (99%)
 delete mode 100644 arch/arm/mach-dove/include/mach/hardware.h
 rename arch/arm/mach-dove/{include/mach => }/irqs.h (98%)
 rename arch/arm/mach-dove/{include/mach => }/pm.h (97%)

diff --git a/arch/arm/mach-dove/include/mach/bridge-regs.h 
b/arch/arm/mach-dove/bridge-regs.h
similarity index 96%
rename from arch/arm/mach-dove/include/mach/bridge-regs.h
rename to arch/arm/mach-dove/bridge-regs.h
index f4a5b34489b7..ace0b0bfbf11 100644
--- a/arch/arm/mach-dove/include/mach/bridge-regs.h
+++ b/arch/arm/mach-dove/bridge-regs.h
@@ -1,6 +1,4 @@
 /*
- * arch/arm/mach-dove/include/mach/bridge-regs.h
- *
  * Mbus-L to Mbus Bridge Registers
  *
  * This file is licensed under the terms of the GNU General Public
@@ -11,7 +9,7 @@
 #ifndef __ASM_ARCH_BRIDGE_REGS_H
 #define __ASM_ARCH_BRIDGE_REGS_H
 
-#include 
+#include "dove.h"
 
 #define CPU_CONFIG (BRIDGE_VIRT_BASE + 0x)
 
diff --git a/arch/arm/mach-dove/cm-a510.c b/arch/arm/mach-dove/cm-a510.c
index b9a7c33db29a..9f25c993d863 100644
--- a/arch/arm/mach-dove/cm-a510.c
+++ b/arch/arm/mach-dove/cm-a510.c
@@ -22,8 +22,7 @@
 #include 
 #include 
 
-#include 
-
+#include "dove.h"
 #include "common.h"
 
 static struct mv643xx_eth_platform_data cm_a510_ge00_data = {
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
index d7b826d2695c..01b830afcea9 100644
--- a/arch/arm/mach-dove/common.c
+++ b/arch/arm/mach-dove/common.c
@@ -22,11 +22,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
+#include "bridge-regs.h"
+#include "pm.h"
 #include "common.h"
 
 /* These can go away once Dove uses the mvebu-mbus DT binding */
diff --git a/arch/arm/mach-dove/dove-db-setup.c 
b/arch/arm/mach-dove/dove-db-setup.c
index 8971c3c0f0fe..418ab21b9d9b 100644
--- a/arch/arm/mach-dove/dove-db-setup.c
+++ b/arch/arm/mach-dove/dove-db-setup.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "dove.h"
 #include "common.h"
 
 static struct mv643xx_eth_platform_data dove_db_ge00_data = {
diff --git a/arch/arm/mach-dove/include/mach/dove.h b/arch/arm/mach-dove/dove.h
similarity index 99%
rename from arch/arm/mach-dove/include/mach/dove.h
rename to arch/arm/mach-dove/dove.h
index 00f45458b3ec..539e735f968d 100644
--- a/arch/arm/mach-dove/include/mach/dove.h
+++ b/arch/arm/mach-dove/dove.h
@@ -1,6 +1,4 @@
 /*
- * arch/arm/mach-dove/include/mach/dove.h
- *
  * Generic definitions for Marvell Dove 88AP510 SoC
  *
  * This file is licensed under the terms of the GNU General Public
@@ -11,7 +9,7 @@
 #ifndef __ASM_ARCH_DOVE_H
 #define __ASM_ARCH_DOVE_H
 
-#include 
+#include "irqs.h"
 
 /*
  * Marvell Dove address maps.
diff --git a/arch/arm/mach-dove/include/mach/hardware.h 
b/arch/arm/mach-dove/include/mach/hardware.h
deleted file mode 100644
index f1368b9a8ece..
--- a/arch/arm/mach-dove/include/mach/hardware.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * arch/arm/mach-dove/include/mach/hardware.h
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-#include "dove.h"
-
-/* Macros below are required for compatibility with PXA AC'97 driver.  */
-#define __REG(x)   (*((volatile u32 *)((x) - DOVE_SB_REGS_PHYS_BASE + \
-   DOVE_SB_REGS_VIRT_BASE)))
-#define __PREG(x)  

[PATCH 13/14] ARM: orion/mvebu: unify debug-ll virtual addresses

2019-07-31 Thread Arnd Bergmann
In a multiplatform configuration, enabling DEBUG_LL breaks booting
on all platforms with incompatible settings. In case of the Marvell
platforms of the Orion/MVEBU family, the physical addresses are
all the same, we just map them at different virtual addresses,
which makes it impossible to run a kernel with DEBUG_LL enabled on
a combination of the merged mvebu and the legacy boardfile based
platforms.

This is easily solved by using the same virtual address everywhere.
I picked the address that is already used by mach-mvebu for UART0:
0xfec12000. All these platforms have a 1MB region with their internal
registers, almost always at physical address 0xf100, so I'm
updating the iotable for that entry.

In case of mach-dove, this is slightly trickier, as the existing
mapping is 8MB and a second 8MB mapping is already at the 0xfec0
address. I have verified from the datasheet that the last 7MB of the
physical mapping are "reserved" and nothing in Linux tries to use
it either. I'm putting this 1MB mapping at the same address as the
others, and the second 8MB register area immediately before that.

Link: 
https://lore.kernel.org/linux-arm-kernel/87si3eb1z8@free-electrons.com/
Signed-off-by: Arnd Bergmann 
---
I posted this in 2015, and Gregory said he would like to see
some testing on it. I don't think anyone ever tested it, but
we probably still want to have this.
---
 arch/arm/Kconfig.debug  |  5 +
 arch/arm/mach-dove/dove.h   | 10 +-
 arch/arm/mach-mv78xx0/mv78xx0.h |  4 ++--
 arch/arm/mach-orion5x/orion5x.h |  4 ++--
 4 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 85710e078afb..0ad316a160c7 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1772,10 +1772,7 @@ config DEBUG_UART_VIRT
default 0xfc705000 if DEBUG_ZTE_ZX
default 0xfcfe8600 if DEBUG_BCM63XX_UART
default 0xfd00 if DEBUG_SPEAR3XX || DEBUG_SPEAR13XX
-   default 0xfd012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_MV78XX0
default 0xfd883000 if DEBUG_ALPINE_UART0
-   default 0xfde12000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_DOVE
-   default 0xfe012000 if DEBUG_MVEBU_UART0_ALTERNATE && ARCH_ORION5X
default 0xfe017000 if DEBUG_MMP_UART2
default 0xfe018000 if DEBUG_MMP_UART3
default 0xfe10 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
@@ -1790,7 +1787,7 @@ config DEBUG_UART_VIRT
default 0xfec02000 if DEBUG_SOCFPGA_UART0
default 0xfec02100 if DEBUG_SOCFPGA_ARRIA10_UART1
default 0xfec03000 if DEBUG_SOCFPGA_CYCLONE5_UART1
-   default 0xfec12000 if (DEBUG_MVEBU_UART0 || 
DEBUG_MVEBU_UART0_ALTERNATE) && ARCH_MVEBU
+   default 0xfec12000 if DEBUG_MVEBU_UART0 || DEBUG_MVEBU_UART0_ALTERNATE
default 0xfec12100 if DEBUG_MVEBU_UART1_ALTERNATE
default 0xfec1 if DEBUG_SIRFATLAS7_UART0
default 0xfec2 if DEBUG_DAVINCI_DMx_UART0
diff --git a/arch/arm/mach-dove/dove.h b/arch/arm/mach-dove/dove.h
index 539e735f968d..320ed1696abd 100644
--- a/arch/arm/mach-dove/dove.h
+++ b/arch/arm/mach-dove/dove.h
@@ -18,8 +18,8 @@
  * c800fdb01M  Cryptographic SRAM
  * e000@runtime128MPCIe-0 Memory space
  * e800@runtime128MPCIe-1 Memory space
- * f100fde08M  on-chip south-bridge registers
- * f180fe608M  on-chip north-bridge registers
+ * f100fec01M  on-chip south-bridge registers
+ * f180fe408M  on-chip north-bridge registers
  * f200fee01M  PCIe-0 I/O space
  * f210fef01M  PCIe-1 I/O space
  */
@@ -42,11 +42,11 @@
 #define DOVE_SCRATCHPAD_SIZE   SZ_1M
 
 #define DOVE_SB_REGS_PHYS_BASE 0xf100
-#define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde0)
-#define DOVE_SB_REGS_SIZE  SZ_8M
+#define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfec0)
+#define DOVE_SB_REGS_SIZE  SZ_1M
 
 #define DOVE_NB_REGS_PHYS_BASE 0xf180
-#define DOVE_NB_REGS_VIRT_BASE IOMEM(0xfe60)
+#define DOVE_NB_REGS_VIRT_BASE IOMEM(0xfe40)
 #define DOVE_NB_REGS_SIZE  SZ_8M
 
 #define DOVE_PCIE0_IO_PHYS_BASE0xf200
diff --git a/arch/arm/mach-mv78xx0/mv78xx0.h b/arch/arm/mach-mv78xx0/mv78xx0.h
index 2db1265ec121..c1a9a1d1b295 100644
--- a/arch/arm/mach-mv78xx0/mv78xx0.h
+++ b/arch/arm/mach-mv78xx0/mv78xx0.h
@@ -37,7 +37,7 @@
  * fee5f0d064K PCIe #5 I/O space
  * fee6f0e064K PCIe #6 I/O space
  * fee7f0f064K PCIe #7 I/O space
- * fd00f1001M  on-chip peripheral registers
+ * fec0f1001M  on-chip peripheral registers
  */
 #define MV78XX0_CORE0_REGS_PHYS_BASE   0xf102
 #define MV78XX0_CORE1_REGS_PHYS_BASE   0xf1024000
@@ -49,7 +49,7 @@
 #defin

[PATCH 14/14] ARM: dove: multiplatform support

2019-07-31 Thread Arnd Bergmann
The dove platform is now ready to be enabled for multiplatform
support, this patch does the switch over by modifying the Kconfig file,
the defconfig and removing the last mach/*.h header that becomes obsolete
with this.

This work was originally done in 2015 as all the ARMv7 machiens
gove moved over to multiplatform builds, but at the time it conflicted
with some patches that Russell was trying to upstream, so we
left it at that.

I hope that there is no longer a need to keep dove separate from the
rest, so we can either add it to the other ARMv7 platforms, or just
replace it with the DT based platform code for the same hardware
in mach-mvebu and remove mach-dove entirely.

Acked-by: Andrew Lunn 
Cc: Russell King 
Signed-off-by: Arnd Bergmann 
---
 arch/arm/Kconfig | 16 -
 arch/arm/configs/dove_defconfig  |  2 ++
 arch/arm/mach-dove/Kconfig   | 16 ++---
 arch/arm/mach-dove/Makefile  |  2 ++
 arch/arm/mach-dove/include/mach/uncompress.h | 34 
 5 files changed, 16 insertions(+), 54 deletions(-)
 delete mode 100644 arch/arm/mach-dove/include/mach/uncompress.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 65808e17cb3b..67f98f1ab399 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -435,22 +435,6 @@ config ARCH_IXP4XX
help
  Support for Intel's IXP4XX (XScale) family of processors.
 
-config ARCH_DOVE
-   bool "Marvell Dove"
-   select CPU_PJ4
-   select GENERIC_CLOCKEVENTS
-   select GENERIC_IRQ_MULTI_HANDLER
-   select GPIOLIB
-   select HAVE_PCI
-   select MVEBU_MBUS
-   select PINCTRL
-   select PINCTRL_DOVE
-   select PLAT_ORION_LEGACY
-   select SPARSE_IRQ
-   select PM_GENERIC_DOMAINS if PM
-   help
- Support for the Marvell Dove SoC 88AP510
-
 config ARCH_KS8695
bool "Micrel/Kendin KS8695"
select CLKSRC_MMIO
diff --git a/arch/arm/configs/dove_defconfig b/arch/arm/configs/dove_defconfig
index e70c997d5f4c..1ced32deac75 100644
--- a/arch/arm/configs/dove_defconfig
+++ b/arch/arm/configs/dove_defconfig
@@ -8,6 +8,8 @@ CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ARCH_MULTI_V6 is not set
+CONFIG_ARCH_MULTI_V7=y
 CONFIG_ARCH_DOVE=y
 CONFIG_MACH_DOVE_DB=y
 CONFIG_MACH_CM_A510=y
diff --git a/arch/arm/mach-dove/Kconfig b/arch/arm/mach-dove/Kconfig
index 7747fe64420a..c30c69c664ea 100644
--- a/arch/arm/mach-dove/Kconfig
+++ b/arch/arm/mach-dove/Kconfig
@@ -1,7 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0
-if ARCH_DOVE
+menuconfig ARCH_DOVE
+   bool "Marvell Dove" if ARCH_MULTI_V7
+   select CPU_PJ4
+   select GPIOLIB
+   select MVEBU_MBUS
+   select PINCTRL
+   select PINCTRL_DOVE
+   select PLAT_ORION_LEGACY
+   select PM_GENERIC_DOMAINS if PM
+   help
+ Support for the Marvell Dove SoC 88AP510
 
-menu "Marvell Dove Implementations"
+if ARCH_DOVE
 
 config DOVE_LEGACY
bool
@@ -21,6 +31,4 @@ config MACH_CM_A510
  Say 'Y' here if you want your kernel to support the
  CompuLab CM-A510 Board.
 
-endmenu
-
 endif
diff --git a/arch/arm/mach-dove/Makefile b/arch/arm/mach-dove/Makefile
index cdf163cab738..e83f6492834d 100644
--- a/arch/arm/mach-dove/Makefile
+++ b/arch/arm/mach-dove/Makefile
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := 
-I$(srctree)/arch/arm/plat-orion/include
+
 obj-y  += common.o
 obj-$(CONFIG_DOVE_LEGACY)  += irq.o mpp.o
 obj-$(CONFIG_PCI)  += pcie.o
diff --git a/arch/arm/mach-dove/include/mach/uncompress.h 
b/arch/arm/mach-dove/include/mach/uncompress.h
deleted file mode 100644
index 7a4bd8838036..
--- a/arch/arm/mach-dove/include/mach/uncompress.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#define UART0_PHYS_BASE (0xf100 + 0x12000)
-
-#define UART_THR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x0))
-#define UART_LSR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x14))
-
-#define LSR_THRE   0x20
-
-static void putc(const char c)
-{
-   int i;
-
-   for (i = 0; i < 0x1000; i++) {
-   /* Transmit fifo not full? */
-   if (*UART_LSR & LSR_THRE)
-   break;
-   }
-
-   *UART_THR = c;
-}
-
-static void flush(void)
-{
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-- 
2.20.0



Re: [PATCH 03/14] watchdog: pnx4008_wdt: allow compile-testing

2019-07-31 Thread Guenter Roeck
On Wed, Jul 31, 2019 at 09:56:45PM +0200, Arnd Bergmann wrote:
> The only thing that prevents building this driver on other
> platforms is the mach/hardware.h include, which is not actually
> used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> 
> Signed-off-by: Arnd Bergmann 

Reviewed-by: Guenter Roeck 

What is the plan for this patch ? Push through watchdog
or through your branch ?

Thanks,
Guenter


Re: [PATCH 03/14] watchdog: pnx4008_wdt: allow compile-testing

2019-07-31 Thread Arnd Bergmann
On Wed, Jul 31, 2019 at 10:23 PM Guenter Roeck  wrote:
>
> On Wed, Jul 31, 2019 at 09:56:45PM +0200, Arnd Bergmann wrote:
> > The only thing that prevents building this driver on other
> > platforms is the mach/hardware.h include, which is not actually
> > used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> >
> > Signed-off-by: Arnd Bergmann 
>
> Reviewed-by: Guenter Roeck 
>
> What is the plan for this patch ? Push through watchdog
> or through your branch ?

I would prefer my branch so I can apply the final patch without waiting
for another release. Not in a hurry though, so if some other maintainer
wants to take the respective driver patch through their tree instead of the
arm-soc one, I'll just wait anyway.

Arnd


Re: [PATCH 03/14] watchdog: pnx4008_wdt: allow compile-testing

2019-07-31 Thread Guenter Roeck
On Wed, Jul 31, 2019 at 10:26:35PM +0200, Arnd Bergmann wrote:
> On Wed, Jul 31, 2019 at 10:23 PM Guenter Roeck  wrote:
> >
> > On Wed, Jul 31, 2019 at 09:56:45PM +0200, Arnd Bergmann wrote:
> > > The only thing that prevents building this driver on other
> > > platforms is the mach/hardware.h include, which is not actually
> > > used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> > >
> > > Signed-off-by: Arnd Bergmann 
> >
> > Reviewed-by: Guenter Roeck 
> >
> > What is the plan for this patch ? Push through watchdog
> > or through your branch ?
> 
> I would prefer my branch so I can apply the final patch without waiting
> for another release. Not in a hurry though, so if some other maintainer

Ok with me.

Guenter


[PATCH] usb: musb: remove redundant assignment to variable ret

2019-07-31 Thread Colin King
From: Colin Ian King 

Variable ret is being initialized with a value that is never read
and ret is being re-assigned a little later on. The assignment is
redundant and hence can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9f5a4819a744..2bc55e0ceace 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1721,7 +1721,7 @@ mode_show(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
struct musb *musb = dev_to_musb(dev);
unsigned long flags;
-   int ret = -EINVAL;
+   int ret;
 
spin_lock_irqsave(&musb->lock, flags);
ret = sprintf(buf, "%s\n", 
usb_otg_state_string(musb->xceiv->otg->state));
-- 
2.20.1



Re: [PATCH 00/14] ARM: move lpc32xx and dove to multiplatform

2019-07-31 Thread Russell King - ARM Linux admin
On Wed, Jul 31, 2019 at 09:56:42PM +0200, Arnd Bergmann wrote:
> For dove, the patches are basically what I had proposed back in
> 2015 when all other ARMv6/ARMv7 machines became part of a single
> kernel build. I don't know what the state is mach-dove support is,
> compared to the DT based support in mach-mvebu for the same
> hardware. If they are functionally the same, we could also just
> remove mach-dove rather than applying my patches.

Well, the good news is that I'm down to a small board support file
for the Dove Cubox now - but the bad news is, that there's still a
board support file necessary to support everything the Dove SoC has
to offer.

Even for a DT based Dove Cubox, I'm still using mach-dove, but it
may be possible to drop most of mach-dove now.  Without spending a
lot of time digging through it, it's impossible to really know.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up


Re: [PATCH 01/14] usb: ohci-nxp: enable compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:43PM +0200, Arnd Bergmann wrote:
> The driver hardcodes a hardware I/O address the way one should
> generally not do, and this prevents both compile-testing, and
> moving the platform to CONFIG_ARCH_MULTIPLATFORM.
> 
> Change the code to be independent of the machine headers
> to allow those two. Removing the hardcoded address would
> be hard and is not necessary, so leave that in place for now.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/host/Kconfig|  3 ++-
>  drivers/usb/host/ohci-nxp.c | 25 ++---
>  2 files changed, 20 insertions(+), 8 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 02/14] usb: udc: lpc32xx: allow compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:44PM +0200, Arnd Bergmann wrote:
> The only thing that prevents building this driver on other
> platforms is the mach/hardware.h include, which is not actually
> used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/usb/gadget/udc/Kconfig   | 3 ++-
>  drivers/usb/gadget/udc/lpc32xx_udc.c | 2 --
>  2 files changed, 2 insertions(+), 3 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 04/14] serial: lpc32xx_hs: allow compile-testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:46PM +0200, Arnd Bergmann wrote:
> The only thing that prevents building this driver on other
> platforms is the mach/hardware.h include, which is not actually
> used here at all, so remove the line and allow CONFIG_COMPILE_TEST.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/tty/serial/Kconfig  | 3 ++-
>  drivers/tty/serial/lpc32xx_hs.c | 2 --
>  2 files changed, 2 insertions(+), 3 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH 09/14] serial: lpc32xx: allow compile testing

2019-07-31 Thread Greg Kroah-Hartman
On Wed, Jul 31, 2019 at 09:56:51PM +0200, Arnd Bergmann wrote:
> The lpc32xx_loopback_set() function in hte lpc32xx_hs driver is the
> one thing that relies on platform header files. Move that into the
> core platform code so we only need a variable declaration for it,
> and enable COMPILE_TEST building.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm/mach-lpc32xx/serial.c   | 30 
>  drivers/tty/serial/lpc32xx_hs.c  | 35 
>  include/linux/soc/nxp/lpc32xx-misc.h |  4 
>  3 files changed, 38 insertions(+), 31 deletions(-)

Acked-by: Greg Kroah-Hartman 


Re: [PATCH v2 2/2] usbip: Implement SG support to vhci

2019-07-31 Thread Suwan Kim
On Mon, Jul 29, 2019 at 10:32:31AM -0600, shuah wrote:
> On 7/29/19 8:52 AM, Suwan Kim wrote:
> > Hi Shuah,
> > 
> > On Tue, Jul 23, 2019 at 06:21:53PM -0600, shuah wrote:
> > > Hi Suwan,
> > > 
> > > On 7/5/19 10:43 AM, Suwan Kim wrote:
> > > > There are bugs on vhci with usb 3.0 storage device. Originally, vhci
> > > > doesn't supported SG, so USB storage driver on vhci breaks SG list
> > > > into multiple URBs and it causes error that a transfer got terminated
> > > > too early because the transfer length for one of the URBs was not
> > > > divisible by the maxpacket size.
> > > > 
> > > > In this patch, vhci basically support SG and it sends each SG list
> > > > entry to the stub driver. Then, the stub driver sees the total length
> > > > of the buffer and allocates SG table and pages according to the total
> > > > buffer length calling sgl_alloc(). After the stub driver receives
> > > > completed URB, it again sends each SG list entry to vhci.
> > > > 
> > > > If HCD of the server doesn't support SG, the stub driver breaks a
> > > > single SG reqeust into several URBs and submit them to the server's
> > > > HCD. When all the split URBs are completed, the stub driver
> > > > reassembles the URBs into a single return command and sends it to
> > > > vhci.
> > > > 
> > > > Signed-off-by: Suwan Kim 
> > > > ---
> > > >drivers/usb/usbip/stub.h |   7 +-
> > > >drivers/usb/usbip/stub_main.c|  52 +---
> > > >drivers/usb/usbip/stub_rx.c  | 207 
> > > > ++-
> > > >drivers/usb/usbip/stub_tx.c  | 108 +++-
> > > >drivers/usb/usbip/usbip_common.c |  60 +++-- >   
> > > > drivers/usb/usbip/vhci_hcd.c |  10 +-
> > > >drivers/usb/usbip/vhci_tx.c  |  49 ++--
> > > >7 files changed, 372 insertions(+), 121 deletions(-)
> > > 
> > > While you are working on v3 to fix chekpatch and other issues
> > > I pointed out, I have more for you.
> > > 
> > > What happens when you have mismatched server and client side?
> > > i.e stub does and vhci doesn't and vice versa.
> > > 
> > > Make sure to run checkpatch. Also check spelling errors in
> > > comments and your commit log.
> > > 
> > > I am not sure if your eeror paths are correct. Run usbip_test.sh
> > > 
> > > tools/testing/selftests/drivers/usb/usbip
> > 
> > I don't know what mismatch you mentioned. Are you saying
> > "match busid table" at the end of usbip_test.sh?
> > How does it relate to SG support of this patch?
> > Could you tell me more about the problem situation?
> > 
> 
> What happens when usbip_host is running a kernel without the sg
> support and vhci_hcd does? Just make sure this works with the
> checks for sg support status as a one of your tests for this
> sg feature.

Now I understand. Thanks for the details!
As a result of testing, in the situation where vhci supports SG,
but stub does not, or vice versa, usbip works normally. Moreover,
because there is no protocol modification, there is no problem in
communication between server and client even if the one has a kernel
without SG support.

In the case of vhci supports SG and stub doesn't, because vhci sends
only the total length of the buffer to stub as it did before the
patch applied, stub only needs to allocate the required length of
buffers regardless of whether vhci supports SG or not.

If stub needs to send data buffer to vhci because of IN pipe, stub
also sends only total length of buffer as metadata and then send real
data as vhci does. Then vhci receive data from stub and store it to
the corresponding buffer of SG list entry.

In the case of stub that supports SG, if SG buffer is requested by
vhci, buffer is allocated by sgl_alloc(). However, stub that does
not support SG allocates buffer using only kmalloc(). Therefore, if
vhci supports SG and stub doesn't, stub has to allocate buffer with
kmalloc() as much as the total length of SG buffer which is quite
huge when vhci sends SG request, so it has big overhead in buffer
allocation.

And for the case of stub supports SG and vhci doesn't, since the
USB storage driver checks that vhci doesn't support SG and sends
the request to stub by splitting the SG list into multiple URBs,
stub allocates a buffer with kmalloc() as it did before this patch.

Therefore, everything works normally in a mismatch situation.
I will send the v3 soon.

Regards
Suwan Kim