* Re: [PATCH v6] dt-bindings: usb: Add new compatible string for AM64 SoC
From: Rob Herring @ 2020-12-15 18:18 UTC (permalink / raw)
To: Aswath Govindraju
Cc: Greg Kroah-Hartman, Sekhar Nori, Vignesh Raghavendra, Rob Herring,
Roger Quadros, devicetree, linux-kernel, linux-usb
In-Reply-To: <20201215042549.7956-1-a-govindraju@ti.com>
On Tue, 15 Dec 2020 09:55:49 +0530, Aswath Govindraju wrote:
> Add compatible string in j721e-usb binding file as the same USB subsystem
> is present in AM64.
>
> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
> ---
>
> Changes since v5:
> - Added const as the type for objects in items.
>
> Changes since v4:
> - used oneOf instead of enum, as the schema has to convey that the strings
> ti,j721e-usb and ti,am64-usb can be used combined or seperately in the
> DT nodes.
>
> Changes since v3:
> - used enum instead of anyOf.
>
> Changes since v2:
> - added changes done over the versions.
>
> Changes since v1:
> - replaced the '\t' at the beginning of the lines with spaces as it was
> causing the dt_binding_check to fail.
>
> Documentation/devicetree/bindings/usb/ti,j721e-usb.yaml | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* [PATCH 1/4] USB: usbtmc: Fix reading stale status byte
From: Dave Penkler @ 2020-12-15 15:56 UTC (permalink / raw)
To: gregkh, linux-usb
Cc: guido.kiener, john.harvey, jian-wei_wu, gabe.jones, dpenkler
In-Reply-To: <20201215155621.9592-1-dpenkler@gmail.com>
The ioctl USBTMC488_IOCTL_READ_STB either returns a cached status byte
(STB) sent by the device due to a service request (SRQ) condition or
the STB obtained from a query to the device with a READ_STATUS_BYTE
control message.
When the query is interrupted by an SRQ message on the interrupt pipe,
the ioctl still returns the requested STB while the STB of the
out-of-band SRQ message is cached for the next call of this
ioctl. However the cached SRQ STB represents a state that was previous
to the last returned STB. Furthermore the cached SRQ STB can be stale
and not reflect the current state of the device.
The fixed ioctl now always reads the STB from the device and if the
associated file descriptor has the srq_asserted bit set it ors in the
RQS bit to the returned STB and clears the srq_asserted bit conformant
to subclass USB488 devices.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
Reviewed-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Tested-by: Jian-Wei Wu <jian-wei_wu@keysight.com>
---
drivers/usb/class/usbtmc.c | 46 +++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index b222b777e6a4..189f06dcb7d3 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -475,33 +475,17 @@ static int usbtmc_ioctl_abort_bulk_out(struct usbtmc_device_data *data)
return usbtmc_ioctl_abort_bulk_out_tag(data, data->bTag_last_write);
}
-static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
- void __user *arg)
+static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
{
struct usbtmc_device_data *data = file_data->data;
struct device *dev = &data->intf->dev;
- int srq_asserted = 0;
u8 *buffer;
u8 tag;
- __u8 stb;
int rv;
dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n",
data->iin_ep_present);
- spin_lock_irq(&data->dev_lock);
- srq_asserted = atomic_xchg(&file_data->srq_asserted, srq_asserted);
- if (srq_asserted) {
- /* a STB with SRQ is already received */
- stb = file_data->srq_byte;
- spin_unlock_irq(&data->dev_lock);
- rv = put_user(stb, (__u8 __user *)arg);
- dev_dbg(dev, "stb:0x%02x with srq received %d\n",
- (unsigned int)stb, rv);
- return rv;
- }
- spin_unlock_irq(&data->dev_lock);
-
buffer = kmalloc(8, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
@@ -548,13 +532,12 @@ static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
data->iin_bTag, tag);
}
- stb = data->bNotify2;
+ *stb = data->bNotify2;
} else {
- stb = buffer[2];
+ *stb = buffer[2];
}
- rv = put_user(stb, (__u8 __user *)arg);
- dev_dbg(dev, "stb:0x%02x received %d\n", (unsigned int)stb, rv);
+ dev_dbg(dev, "stb:0x%02x received %d\n", (unsigned int)*stb, rv);
exit:
/* bump interrupt bTag */
@@ -567,6 +550,27 @@ static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
return rv;
}
+static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
+ void __user *arg)
+{
+ int srq_asserted = 0;
+ __u8 stb;
+ int rv;
+
+ rv = usbtmc_get_stb(file_data, &stb);
+
+ if (rv > 0) {
+ srq_asserted = atomic_xchg(&file_data->srq_asserted,
+ srq_asserted);
+ if (srq_asserted)
+ stb |= 0x40; /* Set RQS bit */
+
+ rv = put_user(stb, (__u8 __user *)arg);
+ }
+ return rv;
+
+}
+
static int usbtmc488_ioctl_wait_srq(struct usbtmc_file_data *file_data,
__u32 __user *arg)
{
--
2.29.2
^ permalink raw reply related
* [PATCH 2/4] USB: usbtmc: Add USBTMC_IOCTL_GET_STB
From: Dave Penkler @ 2020-12-15 15:56 UTC (permalink / raw)
To: gregkh, linux-usb
Cc: guido.kiener, john.harvey, jian-wei_wu, gabe.jones, dpenkler
In-Reply-To: <20201215155621.9592-1-dpenkler@gmail.com>
This new ioctl reads the status byte (STB) from the device and returns
the STB unmodified to the application. The srq_asserted bit is not taken
into account and not changed.
This ioctl is useful to support non USBTMC-488 compliant devices.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
Reviewed-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Tested-by: Jian-Wei Wu <jian-wei_wu@keysight.com>
---
drivers/usb/class/usbtmc.c | 6 ++++++
include/uapi/linux/usb/tmc.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 189f06dcb7d3..8918e2182eca 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -2149,6 +2149,12 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
file_data->auto_abort = !!tmp_byte;
break;
+ case USBTMC_IOCTL_GET_STB:
+ retval = usbtmc_get_stb(file_data, &tmp_byte);
+ if (retval > 0)
+ retval = put_user(tmp_byte, (__u8 __user *)arg);
+ break;
+
case USBTMC_IOCTL_CANCEL_IO:
retval = usbtmc_ioctl_cancel_io(file_data);
break;
diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index fdd4d88a7b95..1e7878fe591f 100644
--- a/include/uapi/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
@@ -102,6 +102,8 @@ struct usbtmc_message {
#define USBTMC_IOCTL_MSG_IN_ATTR _IOR(USBTMC_IOC_NR, 24, __u8)
#define USBTMC_IOCTL_AUTO_ABORT _IOW(USBTMC_IOC_NR, 25, __u8)
+#define USBTMC_IOCTL_GET_STB _IOR(USBTMC_IOC_NR, 26, __u8)
+
/* Cancel and cleanup asynchronous calls */
#define USBTMC_IOCTL_CANCEL_IO _IO(USBTMC_IOC_NR, 35)
#define USBTMC_IOCTL_CLEANUP_IO _IO(USBTMC_IOC_NR, 36)
--
2.29.2
^ permalink raw reply related
* [PATCH 3/4] USB: usbtmc: Add separate USBTMC_IOCTL_GET_SRQ_STB
From: Dave Penkler @ 2020-12-15 15:56 UTC (permalink / raw)
To: gregkh, linux-usb
Cc: guido.kiener, john.harvey, jian-wei_wu, gabe.jones, dpenkler
In-Reply-To: <20201215155621.9592-1-dpenkler@gmail.com>
This new ioctl only returns the status byte (STB) that was originally
sent by the device due to a service request (SRQ) condition.
This ioctl checks the srq_asserted bit of the associated file
descriptor. If set, the srq_asserted bit is reset and the cached
STB with original SRQ information is returned. Otherwise the ioctl
returns the error code ENOMSG.
This ioctl is useful to support non USBTMC-488 compliant devices.
Time sensitive applications can read the cached STB without incurring
the cost of an urb transaction over the bus.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
Reviewed-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Tested-by: Jian-Wei Wu <jian-wei_wu@keysight.com>
---
drivers/usb/class/usbtmc.c | 31 +++++++++++++++++++++++++++++++
include/uapi/linux/usb/tmc.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 8918e2182eca..d2fcc698c745 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -571,6 +571,32 @@ static int usbtmc488_ioctl_read_stb(struct usbtmc_file_data *file_data,
}
+static int usbtmc_ioctl_get_srq_stb(struct usbtmc_file_data *file_data,
+ void __user *arg)
+{
+ struct usbtmc_device_data *data = file_data->data;
+ struct device *dev = &data->intf->dev;
+ int srq_asserted = 0;
+ __u8 stb = 0;
+ int rv;
+
+ spin_lock_irq(&data->dev_lock);
+ srq_asserted = atomic_xchg(&file_data->srq_asserted, srq_asserted);
+
+ if (srq_asserted) {
+ stb = file_data->srq_byte;
+ spin_unlock_irq(&data->dev_lock);
+ rv = put_user(stb, (__u8 __user *)arg);
+ } else {
+ spin_unlock_irq(&data->dev_lock);
+ rv = -ENOMSG;
+ }
+
+ dev_dbg(dev, "stb:0x%02x with srq received %d\n", (unsigned int)stb, rv);
+
+ return rv;
+}
+
static int usbtmc488_ioctl_wait_srq(struct usbtmc_file_data *file_data,
__u32 __user *arg)
{
@@ -2155,6 +2181,11 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
retval = put_user(tmp_byte, (__u8 __user *)arg);
break;
+ case USBTMC_IOCTL_GET_SRQ_STB:
+ retval = usbtmc_ioctl_get_srq_stb(file_data,
+ (void __user *)arg);
+ break;
+
case USBTMC_IOCTL_CANCEL_IO:
retval = usbtmc_ioctl_cancel_io(file_data);
break;
diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index 1e7878fe591f..d791cc58a7f0 100644
--- a/include/uapi/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
@@ -103,6 +103,7 @@ struct usbtmc_message {
#define USBTMC_IOCTL_AUTO_ABORT _IOW(USBTMC_IOC_NR, 25, __u8)
#define USBTMC_IOCTL_GET_STB _IOR(USBTMC_IOC_NR, 26, __u8)
+#define USBTMC_IOCTL_GET_SRQ_STB _IOR(USBTMC_IOC_NR, 27, __u8)
/* Cancel and cleanup asynchronous calls */
#define USBTMC_IOCTL_CANCEL_IO _IO(USBTMC_IOC_NR, 35)
--
2.29.2
^ permalink raw reply related
* [PATCH 4/4] USB: usbtmc: Bump USBTMC_API_VERSION value
From: Dave Penkler @ 2020-12-15 15:56 UTC (permalink / raw)
To: gregkh, linux-usb
Cc: guido.kiener, john.harvey, jian-wei_wu, gabe.jones, dpenkler
In-Reply-To: <20201215155621.9592-1-dpenkler@gmail.com>
The previous patches in this series have changed the behaviour of the
driver and added new calls.
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
Reviewed-by: Guido Kiener <guido.kiener@rohde-schwarz.com>
Tested-by: Jian-Wei Wu <jian-wei_wu@keysight.com>
---
drivers/usb/class/usbtmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index d2fcc698c745..74d5a9c5238a 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -25,7 +25,7 @@
/* Increment API VERSION when changing tmc.h with new flags or ioctls
* or when changing a significant behavior of the driver.
*/
-#define USBTMC_API_VERSION (2)
+#define USBTMC_API_VERSION (3)
#define USBTMC_HEADER_SIZE 12
#define USBTMC_MINOR_BASE 176
--
2.29.2
^ permalink raw reply related
* [PATCH 0/4] USB: usbtmc: Fix stale status byte ioctl
From: Dave Penkler @ 2020-12-15 15:56 UTC (permalink / raw)
To: gregkh, linux-usb
Cc: guido.kiener, john.harvey, jian-wei_wu, gabe.jones, dpenkler
The ioctl USBTMC488_IOCTL_READ_STB either returns a cached status byte
(STB) sent by the device due to a service request (SRQ) condition or
the STB obtained from a query to the device with a READ_STATUS_BYTE
control message.
When the query is interrupted by an SRQ message on the interrupt pipe,
the ioctl still returns the requested STB while the STB of the
out-of-band SRQ message is cached for the next call of this
ioctl. However the cached SRQ STB represents a state that was previous
to the last returned STB. Furthermore the cached SRQ STB can be
stale and not reflect the current state of the device.
This set of patches separates out the behaviour into 3 ioctls:
[PATCH 1]
USBTMC488_IOCTL_READ_STB always reads the STB from the device and if the
associated file descriptor has the srq_asserted bit set it ors in the
RQS bit to the returned STB and clears the srq_asserted bit conformant
to subclass USB488 devices.
[PATCH 2]
USBTMC_IOCTL_GET_STB reads the status byte (STB) from the device and
returns the STB unmodified to the application. The srq_asserted bit is
not taken into account and not changed.
[PATCH 3]
USBTMC_IOCTL_GET_SRQ_STB only returns the status byte (STB) that was
originally sent by the device due to a service request (SRQ) condition.
This ioctl checks the srq_asserted bit of the associated file
descriptor. If set, the srq_asserted bit is reset and the cached
STB with original SRQ information is returned. Otherwise the ioctl
returns the error code ENOMSG.
The latter 2 ioctls are useful to support non USBTMC-488 compliant
devices. Time sensitive applications can read the cached STB without
incurring the cost of an urb transaction over the bus.
[PATCH 4]
Increase the API version number
Dave Penkler (4):
USB: usbtmc: Fix reading stale status byte
USB: usbtmc: Add USBTMC_IOCTL_GET_STB
USB: usbtmc: Add separate USBTMC_IOCTL_GET_SRQ_STB
USB: usbtmc: Bump USBTMC_API_VERSION value
drivers/usb/class/usbtmc.c | 85 ++++++++++++++++++++++++++----------
include/uapi/linux/usb/tmc.h | 3 ++
2 files changed, 66 insertions(+), 22 deletions(-)
--
2.29.2
^ permalink raw reply
* Re: port power is on again after turning off by user space
From: Alan Stern @ 2020-12-15 15:55 UTC (permalink / raw)
To: Peter Chen; +Cc: Jun Li, linux-usb@vger.kernel.org
In-Reply-To: <DBBPR04MB79790C8D243173467AE94D4E8BC60@DBBPR04MB7979.eurprd04.prod.outlook.com>
On Tue, Dec 15, 2020 at 09:57:53AM +0000, Peter Chen wrote:
>
> > > > Hi Alan,
> > > >
> > > > I use one HUB power control application
> > > >
> > (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.
> > com%2Fmvp%2Fuhubctl&data=04%7C01%7Cpeter.chen%40nxp.com%7C
> > 736ece19bc7a430c98b808d8a0b6975c%7C686ea1d3bc2b4c6fa92cd99c5c3016
> > 35%7C0%7C0%7C637436053362151022%7CUnknown%7CTWFpbGZsb3d8eyJ
> > WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7
> > C1000&sdata=lptf1XO5yeb6lQbAFlKUrZ%2BEX5ATXQRftGwm26WowFA%
> > 3D&reserved=0) to investigate power switchable HUB, and find the kernel
> > turns port power on again at drivers/usb/core/hub.c, after port power is turned
> > off by user space.
> > > >
> > > > 5122 if (hub_is_port_power_switchable(hub)
> > > > 5123 && !port_is_power_on(hub,
> > portstatus)
> > > > 5124 && !port_dev->port_owner)
> > > > 5125 set_port_feature(hdev, port1,
> > USB_PORT_FEAT_POWER);
> > > >
> > > > The main sequence for testing turn port power off like below:
> > > >
> > > > - uhubctl sends command to turn specifc port (eg, 2-1.4) power off.
> > > > - devio at kernel gets that command, and send to hub.
> > > > - port power is off, the hub_event is triggered due to port status is changed.
> > > > - usb_disconnect is called, but port power is on again by kernel at function
> > hub_port_connect.
> > > >
> > > > I can't find the code history why the port power needs to turn on after
> > device is disconnected, do you know why?
> > > > Any sugguestions to fix it? Thanks.
> > >
> > > Seems in this case the port need claimed by user app, I am seeing this
> > > commit
> > >
> > > commit fbaecff06a7db4defa899a664fe2758e5161b39d
> > > Author: Deepak Das <deepakdas.linux@gmail.com>
> > > Date: Wed Jan 21 23:39:58 2015 +0530
> > >
> > > usb: core: hub: modify hub reset logic in hub driver
> > >
> > > Currently if port power is turned off by user on hub port
> > > using USBDEVFS then port power is turned back ON
> > > by hub driver.
> > > This commit modifies hub reset logic in hub_port_connect() to prevent
> > > hub driver from turning back the port power ON if port is not owned
> > > by kernel.
> > >
> > > Signed-off-by: Deepak Das <deepakdas.linux@gmail.com>
> > > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > >
> > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index
> > > b4bfa3a..3e9c4d4 100644
> > > --- a/drivers/usb/core/hub.c
> > > +++ b/drivers/usb/core/hub.c
> > > @@ -4655,9 +4655,13 @@ static void hub_port_connect(struct usb_hub
> > > *hub, int port1, u16 portstatus,
> > > if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
> > > test_bit(port1, hub->removed_bits)) {
> > >
> > > - /* maybe switch power back on (e.g. root hub was reset)
> > */
> > > + /*
> > > + * maybe switch power back on (e.g. root hub was reset)
> > > + * but only if the port isn't owned by someone else.
> > > + */
> > > if (hub_is_port_power_switchable(hub)
> > > - && !port_is_power_on(hub,
> > portstatus))
> > > + && !port_is_power_on(hub,
> > portstatus)
> > > + && !port_dev->port_owner)
> > > set_port_feature(hdev, port1,
> > > USB_PORT_FEAT_POWER);
> > >
> > > if (portstatus & USB_PORT_STAT_ENABLE)
> > >
> >
> > Yes, I saw this commit. But the port is owned by kernel, the device on the port
> > could be enumerated by kernel, just the power on the port could be changed by
> > user space.
You've got the general idea.
Normally ports are owned by the hub driver. If one of them loses power
for some reason (for example, the user turns it off), the hub driver
will turn the power back on. This is because the hub driver wants
ports to be powered at all times unless they are in runtime suspend.
The way to prevent the hub driver from managing the port power is to
claim the port for the user, by issuing the USBDEVFS_CLAIM_PORT ioctl.
Also, when that is done, the kernel wno't try to manage a device
attached to the port -- that is, the kernel won't automatically install
a configuration for a new device and it won't try to probe drivers for
the device's interfaces if the user installs a config.
> I find this issue has discussed there, but I can't open the URL: https://bit.ly/2JzczjZ
> Below the description from: https://github.com/mvp/uhubctl.
> Their workarounds are not good.
>
> Power comes back on after few seconds on Linux
>
> Some device drivers in kernel are surprised by USB device
> being turned off and automatically try to power it back on.
>
> You can use option -r N where N is some number from 10 to 1000
> to fix this - uhubctl will try to turn power off many times in quick
> succession, and it should suppress that. This may be eventually fixed
> in kernel, see more discussion here.
>
> Disabling USB authorization for device in question before
> turning power off with uhubctl should help:
>
> echo 0 > sudo tee /sys/bus/usb/devices/${location}.${port}/authorized
> If your device is USB mass storage, invoking udisksctl before calling uhubctl
> should help too:
>
> sudo udisksctl power-off --block-device /dev/disk/...`
> sudo uhubctl -a off ...
Yes, this certainly indicates that they don't understand the real
problem or the appropriate solution. You could file a bug report for
the github project to tell them.
Alan Stern
^ permalink raw reply
* Re: WARNING in yurex_write/usb_submit_urb
From: Andrey Konovalov @ 2020-12-15 14:08 UTC (permalink / raw)
To: Johan Hovold
Cc: syzbot, Greg Kroah-Hartman, LKML, USB list, stable,
syzkaller-bugs
In-Reply-To: <X9eB5ZZMq6q5j4eW@localhost>
On Mon, Dec 14, 2020 at 4:16 PM Johan Hovold <johan@kernel.org> wrote:
>
> On Mon, Dec 14, 2020 at 04:06:49PM +0100, Andrey Konovalov wrote:
> > On Mon, Dec 14, 2020 at 4:02 PM Johan Hovold <johan@kernel.org> wrote:
> > >
> > > On Mon, Dec 14, 2020 at 06:48:03AM -0800, syzbot wrote:
> > > > Hello,
> > > >
> > > > syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> > > > WARNING in yurex_write/usb_submit_urb
> > >
> > > It appears syzbot never tested the patch from the thread. Probably using
> > > it's mail interface incorrectly, I don't know and I don't have time to
> > > investigate. The patch itself is correct.
> >
> > Hi Johan,
> >
> > I wasn't CCed on the testing request, so I can't say what exactly was wrong.
>
> Here's the patch and the "syz test" command in a reply:
>
> https://lore.kernel.org/r/20201214104444.28386-1-johan@kernel.org
>
> Probably needs to go in the same mail, right?
Yes, both the syz test command and the patch must be in the same
email, which is sent as a response to the initial report.
> How about including the command needed to test a patch in the syzbot
> report mail to assist the casual user of its interfaces? I had to browse
> the web page you link to and still got it wrong apparently.
I think it's deliberately not included to not overload the report
email with too many details.
> > Could you send me the patch you were trying to test?
>
> Does this work better:
>
> #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
This worked :)
Thanks!
^ permalink raw reply
* Re: [PATCH] xhci: Introduce max wait timeout in xhci_handshake()
From: Greg KH @ 2020-12-15 13:39 UTC (permalink / raw)
To: Chen Yu
Cc: Mathias Nyman, linux-usb, linux-kernel, Muchowski, MaciejX,
Paczynski, Lukasz
In-Reply-To: <20201215132240.4094-1-yu.c.chen@intel.com>
On Tue, Dec 15, 2020 at 09:22:40PM +0800, Chen Yu wrote:
> The time to finish a xhci_handshake() is platform specific
> and sometimes during suspend resume test the followng
> errors were encountered:
> [53455.418330] ACPI: Waking up from system sleep state S4
> [66838.490856] xhci_hcd 0000:00:14.0: xHCI dying, ignoring interrupt.
> Shouldn't IRQs be disabled?
> After changing the poll time granularity from 1 usec to 20 usec in
> xhci_handshake() this issue was not reproduced. While tuning on the
> poll time granularity might be painful on different platforms, it is
> applicable to introduce a module parameter to allow the xhci driver to wait
> for at max 16 ms.
>
> Reported-by: "Muchowski, MaciejX" <maciejx.muchowski@intel.com>
I doubt the "X" is part of this person's name, please just spell it out
without the "," please.
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> drivers/usb/host/xhci.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index d4a8d0efbbc4..b8be9f3cc987 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -38,6 +38,10 @@ static unsigned long long quirks;
> module_param(quirks, ullong, S_IRUGO);
> MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
>
> +static int wait_handshake;
> +module_param(wait_handshake, int, 0644);
> +MODULE_PARM_DESC(wait_handshake, "Force wait for completion of handshake");
This is not the 1990's, we are not adding new module parameters that no
one will know how to change.
Make this dynamic, and per-device, and work properly instead. This can
not handle multiple controllers in the system at all :(
thanks,
greg k-h
^ permalink raw reply
* [PATCH] xhci: Introduce max wait timeout in xhci_handshake()
From: Chen Yu @ 2020-12-15 13:22 UTC (permalink / raw)
To: Mathias Nyman
Cc: linux-usb, linux-kernel, Muchowski, MaciejX, Paczynski, Lukasz,
Chen Yu
The time to finish a xhci_handshake() is platform specific
and sometimes during suspend resume test the followng
errors were encountered:
[53455.418330] ACPI: Waking up from system sleep state S4
[66838.490856] xhci_hcd 0000:00:14.0: xHCI dying, ignoring interrupt.
Shouldn't IRQs be disabled?
After changing the poll time granularity from 1 usec to 20 usec in
xhci_handshake() this issue was not reproduced. While tuning on the
poll time granularity might be painful on different platforms, it is
applicable to introduce a module parameter to allow the xhci driver to wait
for at max 16 ms.
Reported-by: "Muchowski, MaciejX" <maciejx.muchowski@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
drivers/usb/host/xhci.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d4a8d0efbbc4..b8be9f3cc987 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -38,6 +38,10 @@ static unsigned long long quirks;
module_param(quirks, ullong, S_IRUGO);
MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
+static int wait_handshake;
+module_param(wait_handshake, int, 0644);
+MODULE_PARM_DESC(wait_handshake, "Force wait for completion of handshake");
+
static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
{
struct xhci_segment *seg = ring->first_seg;
@@ -74,7 +78,7 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
ret = readl_poll_timeout_atomic(ptr, result,
(result & mask) == done ||
result == U32_MAX,
- 1, usec);
+ 1, wait_handshake ? XHCI_MAX_HALT_USEC : usec);
if (result == U32_MAX) /* card removed */
return -ENODEV;
--
2.17.1
^ permalink raw reply related
* [PATCH] HID: fix spelling mistake in Kconfig "Uninterruptable" -> "Uninterruptible"
From: Colin King @ 2020-12-15 12:52 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, linux-usb, linux-input
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
There is a spelling mistake in the Kconfig help text. Fix it.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/hid/usbhid/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index dcf3a235870f..7c2032f7f44d 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -38,7 +38,7 @@ config USB_HIDDEV
help
Say Y here if you want to support HID devices (from the USB
specification standpoint) that aren't strictly user interface
- devices, like monitor controls and Uninterruptable Power Supplies.
+ devices, like monitor controls and Uninterruptible Power Supplies.
This module supports these devices separately using a separate
event interface on /dev/usb/hiddevX (char 180:96 to 180:111).
--
2.29.2
^ permalink raw reply related
* DWC3 controller Runtime PM
From: Shah, Nehal-bakulchandra @ 2020-12-15 10:33 UTC (permalink / raw)
To: Heikki Krogerus, Felipe Balbi; +Cc: linux-usb
Hi Heikkie and all,
On one of our platform , i have added pci ids in dwc3-pci.c file.
Now when controller is switched to host mode and nothing is connected to port all ports are showing run time power status
as "suspended". But controller on PCI bus always shows active. The xhci_plat_probe function already sets pm run time enabled.
Anything is missing?
thanks
Nehal
^ permalink raw reply
* [PATCH v2] usb: cdns3: Adds missing __iomem markers
From: Pawel Laszczak @ 2020-12-15 10:27 UTC (permalink / raw)
To: peter.chen
Cc: rogerq, a-govindraju, nsekhar, gregkh, linux-usb, linux-kernel,
kurahul, Pawel Laszczak
Patch adds missing __iomem markers in core.h file
and makes some changes in drd.c file related with
these markers.
The lack of __iomem has reported by sparse checker
on parsic architecture.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
Changelog:
v2
- fixed typo in cdns_otg_irq_regs name
- fixed incorrect argument in readl
drivers/usb/cdns3/core.h | 12 ++++++------
drivers/usb/cdns3/drd.c | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h
index f8e350cef699..ab0cb68acd23 100644
--- a/drivers/usb/cdns3/core.h
+++ b/drivers/usb/cdns3/core.h
@@ -86,12 +86,12 @@ struct cdns {
struct resource xhci_res[CDNS_XHCI_RESOURCES_NUM];
struct cdns3_usb_regs __iomem *dev_regs;
- struct resource otg_res;
- struct cdns3_otg_legacy_regs *otg_v0_regs;
- struct cdns3_otg_regs *otg_v1_regs;
- struct cdnsp_otg_regs *otg_cdnsp_regs;
- struct cdns_otg_common_regs *otg_regs;
- struct cdns_otg_irq_regs *otg_irq_regs;
+ struct resource otg_res;
+ struct cdns3_otg_legacy_regs __iomem *otg_v0_regs;
+ struct cdns3_otg_regs __iomem *otg_v1_regs;
+ struct cdnsp_otg_regs __iomem *otg_cdnsp_regs;
+ struct cdns_otg_common_regs __iomem *otg_regs;
+ struct cdns_otg_irq_regs __iomem *otg_irq_regs;
#define CDNS3_CONTROLLER_V0 0
#define CDNS3_CONTROLLER_V1 1
#define CDNSP_CONTROLLER_V2 2
diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c
index 605a413db727..fa5318ade3e1 100644
--- a/drivers/usb/cdns3/drd.c
+++ b/drivers/usb/cdns3/drd.c
@@ -27,7 +27,7 @@
*/
static int cdns_set_mode(struct cdns *cdns, enum usb_dr_mode mode)
{
- u32 __iomem *override_reg;
+ void __iomem *override_reg;
u32 reg;
switch (mode) {
@@ -406,7 +406,7 @@ int cdns_drd_init(struct cdns *cdns)
cdns->otg_v1_regs = NULL;
cdns->otg_cdnsp_regs = NULL;
cdns->otg_regs = regs;
- cdns->otg_irq_regs = (struct cdns_otg_irq_regs *)
+ cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
&cdns->otg_v0_regs->ien;
writel(1, &cdns->otg_v0_regs->simulate);
dev_dbg(cdns->dev, "DRD version v0 (%08x)\n",
@@ -416,14 +416,14 @@ int cdns_drd_init(struct cdns *cdns)
cdns->otg_v1_regs = regs;
cdns->otg_cdnsp_regs = regs;
- cdns->otg_regs = (void *)&cdns->otg_v1_regs->cmd;
+ cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd;
- if (cdns->otg_cdnsp_regs->did == OTG_CDNSP_DID) {
- cdns->otg_irq_regs = (struct cdns_otg_irq_regs *)
+ if (readl(&cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
+ cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
&cdns->otg_cdnsp_regs->ien;
cdns->version = CDNSP_CONTROLLER_V2;
} else {
- cdns->otg_irq_regs = (struct cdns_otg_irq_regs *)
+ cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
&cdns->otg_v1_regs->ien;
writel(1, &cdns->otg_v1_regs->simulate);
cdns->version = CDNS3_CONTROLLER_V1;
--
2.17.1
^ permalink raw reply related
* [GIT PULL] USB / Thunderbolt driver changes for 5.11-rc1
From: Greg KH @ 2020-12-15 10:17 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel, linux-usb
The following changes since commit 0477e92881850d44910a7e94fc2c46f96faa131f:
Linux 5.10-rc7 (2020-12-06 14:25:12 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git tags/usb-5.11-rc1
for you to fetch changes up to a256e24021bf7ceedd29fe65eb45c7adfffffad2:
usb: phy: convert comma to semicolon (2020-12-11 16:51:20 +0100)
----------------------------------------------------------------
USB / Thunderbolt patches for 5.11-rc1
Here is the big USB and thunderbolt pull request for 5.11-rc1.
Nothing major in here, just the grind of constant development to support
new hardware and fix old issues:
- thunderbolt updates for new USB4 hardware
- cdns3 major driver updates
- lots of typec updates and additions as more hardware is available
- usb serial driver updates and fixes
- other tiny USB driver updates
All have been in linux-next with no reported issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----------------------------------------------------------------
Ahmed S. Darwish (7):
USB: serial: digi_acceleport: remove in_interrupt() usage
usb: hosts: Remove in_interrupt() from comments
usb: gadget: udc: Remove in_interrupt()/in_irq() from comments
usb: core: Replace in_interrupt() in comments
usb: gadget: pxa27x_udc: Replace in_interrupt() usage in comments
usbip: Remove in_interrupt() check
usb: xhci: Remove in_interrupt() checks
Al Cooper (2):
dt-bindings: Add support for Broadcom USB pin map driver
usb: Add driver to allow any GPIO to be used for 7211 USB signals
Alan Stern (1):
USB: legotower: fix logical error in recent commit
Andrey Konovalov (1):
kcov, usb: only collect coverage from __usb_hcd_giveback_urb in softirq
Aswath Govindraju (1):
MAINTAINERS: Add myself as a reviewer for CADENCE USB3 DRD IP DRIVER
Badhri Jagan Sridharan (21):
dt-bindings: connector: Add property to set initial current cap for FRS
usb: typec: tcpm: Refactor logic for new-source-frs-typec-current
usb: typec: tcpm: frs sourcing vbus callback
usb: typec: tcpci: frs sourcing vbus callback
usb: typec: tcpci_maxim: Fix vbus stuck on upon diconnecting sink
usb: typec: tcpm: Implement enabling Auto Discharge disconnect support
usb: typec: tcpci: Implement Auto discharge disconnect callbacks
usb: typec: tcpci_maxim: Enable auto discharge disconnect
usb: typec: tcpci_maxim: Fix uninitialized return variable
dt-bindings: usb: Maxim type-c controller device tree binding document
usb: typec: tcpci_maxim: Fix the compatible string
usb: typec: tcpm: Disregard vbus off while in PR_SWAP_SNK_SRC_SOURCE_ON
usb: typec: tcpm: Stay in SNK_TRY_WAIT_DEBOUNCE_CHECK_VBUS till Rp is seen
usb: typec: tcpm: Pass down negotiated rev to update retry count
usb: typec: tcpm: Clear send_discover in tcpm_check_send_discover
usb: typec: tcpm: Introduce vsafe0v for vbus
usb: typec: tcpci: Add support to report vSafe0V
usb: typec: tcpci_maxim: Enable VSAFE0V signalling
USB: typec: tcpci: Add Bleed discharge to POWER_CONTROL definition
usb: typec: tcpci: Enable bleed discharge when auto discharge is enabled
usb: typec: tcpm: Update vbus_vsafe0v on init
Benjamin Berg (2):
usb: typec: ucsi: acpi: Always decode connector change information
usb: typec: ucsi: Work around PPM losing change information
Bui Quang Minh (1):
USB: dummy-hcd: Fix uninitialized array use in init()
Colin Ian King (1):
usb: phy: Fix spelling mistake in Kconfig help text
Dan Carpenter (4):
usb: misc: brcmstb-usb-pinmap: Fix an IS_ERR() vs NULL check
USB: apple-mfi-fastcharge: Fix use after free in probe
usb: mtu3: mtu3_debug: remove an unused struct member
usb: mtu3: fix memory corruption in mtu3_debugfs_regset()
Davidlohr Bueso (1):
USB: serial: mos7720: defer state restore to a workqueue
Enrico Weigelt, metux IT consult (3):
drivers: usb: atm: reduce noise
drivers: usb: atm: use atm_info() instead of atm_printk(KERN_INFO ...
drivers: usb: atm: use pr_err() and pr_warn() instead of raw printk()
Fabio Estevam (5):
usb: host: imx21-hcd: Remove the driver
usb: host: ehci-mxc: Remove the driver
usb: chipidea: ci_hdrc_imx: Pass DISABLE_DEVICE_STREAMING flag to imx6ul
usb: chipidea: usbmisc_imx: Use of_device_get_match_data()
usb: chipidea: ci_hdrc_imx: Use of_device_get_match_data()
Greg Kroah-Hartman (10):
USB: host: isp1362: delete isp1362_show_regs()
Merge 5.10-rc2 into usb-next
Merge 5.10-rc3 into usb-next
Merge 5.10-rc4 into here.
Merge 5.10-rc6 into usb-next
Merge 5.10-rc7 into usb-next
Merge tag 'thunderbolt-for-v5.11-rc1' of git://git.kernel.org/.../westeri/thunderbolt into usb-next
Merge tag 'usb-v5.11-rc1' of git://git.kernel.org/.../peter.chen/usb into usb-next
USB: gadget: f_fs: remove likely/unlikely
Merge tag 'usb-serial-5.11-rc1' of https://git.kernel.org/.../johan/usb-serial into usb-next
Guido Günther (2):
usb: typec: tps6598x: Select USB_ROLE_SWITCH and REGMAP_I2C
usb: typec: tps6598x: Export some power supply properties
Gustavo A. R. Silva (1):
usb: Fix fall-through warnings for Clang
Hans de Goede (1):
xhci-pci: Allow host runtime PM as default for Intel Alpine Ridge LP
Heikki Krogerus (2):
usb: pd: DFP product types
usb: typec: Add type sysfs attribute file for partners
Isaac Hazan (4):
thunderbolt: Add link_speed and link_width to XDomain
thunderbolt: Add functions for enabling and disabling lane bonding on XDomain
thunderbolt: Add DMA traffic test driver
MAINTAINERS: Add Isaac as maintainer of Thunderbolt DMA traffic test driver
Jack Pham (1):
usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus
Johan Hovold (27):
USB: serial: keyspan_pda: fix dropped unthrottle interrupts
USB: serial: keyspan_pda: fix write deadlock
USB: serial: keyspan_pda: fix stalled writes
USB: serial: keyspan_pda: fix write-wakeup use-after-free
USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
USB: serial: keyspan_pda: fix write unthrottling
USB: serial: keyspan_pda: refactor write-room handling
USB: serial: keyspan_pda: fix write implementation
USB: serial: keyspan_pda: increase transmitter threshold
USB: serial: keyspan_pda: add write-fifo support
USB: serial: keyspan_pda: clean up xircom/entrega support
USB: serial: keyspan_pda: clean up comments and whitespace
USB: serial: keyspan_pda: use BIT() macro
USB: serial: keyspan_pda: drop redundant usb-serial pointer
USB: serial: digi_acceleport: fix write-wakeup deadlocks
USB: serial: remove write wait queue
USB: serial: mos7720: fix parallel-port state restore
USB: serial: cp210x: return early on unchanged termios
USB: serial: cp210x: clean up line-control handling
USB: serial: cp210x: set terminal settings on open
USB: serial: cp210x: drop flow-control debugging
USB: serial: cp210x: refactor flow-control handling
USB: serial: cp210x: clean up dtr_rts()
USB: core: drop short-transfer check from usb_control_msg_send()
USB: core: return -EREMOTEIO on short usb_control_msg_recv()
USB: core: drop pipe-type check from new control-message helpers
USB: serial: option: add interface-number sanity check to flag handling
Kyle Tso (2):
USB: typec: tcpm: Fix PR_SWAP error handling
USB: typec: tcpm: Add a 30ms room for tPSSourceOn in PR_SWAP
Li Jun (1):
xhci: Give USB2 ports time to enter U3 in bus suspend
Linus Walleij (1):
usb: isp1301-omap: Convert to use GPIO descriptors
Lucas Tanure (1):
USB: apple-mfi-fastcharge: Fix kfree after failed kzalloc
Lukas Bulwahn (1):
USB: storage: avoid use of uninitialized values in error path
Marc Zyngier (3):
USB: serial: ftdi_sio: report the valid GPIO lines to gpiolib
USB: serial: ftdi_sio: drop GPIO line checking dead code
USB: serial: ftdi_sio: log the CBUS GPIO validity
Mika Westerberg (19):
thunderbolt: Do not clear USB4 router protocol adapter IFC and ISE bits
thunderbolt: Find XDomain by route instead of UUID
thunderbolt: Create XDomain devices for loops back to the host
thunderbolt: Create debugfs directory automatically for services
thunderbolt: Make it possible to allocate one directional DMA tunnel
thunderbolt: Add support for end-to-end flow control
thunderbolt: Move max_boot_acl field to correct place in struct icm
thunderbolt: Log which connection manager implementation is used
thunderbolt: Log adapter numbers in decimal in path activation/deactivation
thunderbolt: Keep the parent runtime resumed for a while on device disconnect
thunderbolt: Return -ENOTCONN when ERR_CONN is received
thunderbolt: Perform USB4 router NVM upgrade in two phases
thunderbolt: Pass metadata directly to usb4_switch_op()
thunderbolt: Pass TX and RX data directly to usb4_switch_op()
thunderbolt: Add connection manager specific hooks for USB4 router operations
thunderbolt: Move constants for USB4 router operations to tb_regs.h
thunderbolt: Add USB4 router operation proxy for firmware connection manager
thunderbolt: Add support for Intel Maple Ridge
xhci-pci: Allow host runtime PM as default for Intel Maple Ridge xHCI
Nick Desaulniers (1):
usb: fix a few cases of -Wfallthrough
Oliver Neukum (2):
USB: add RESET_RESUME quirk for Snapscan 1212
USB: UAS: introduce a quirk to set no_write_same
Pawel Laszczak (2):
usb: cdns3: Add static to cdns3_gadget_exit function
usb: cdns3: Rids of duplicate error message
Peter Chen (8):
usb: cdns3: host: add .suspend_quirk for xhci-plat.c
usb: cdns3: host: add xhci_plat_priv quirk XHCI_SKIP_PHY_INIT
usb: cdns3: host: disable BEI support
usb: cdns3: add quirk for enable runtime pm by default
usb: cdns3: imx: enable runtime pm by default
doc: dt-binding: cdns,usb3: add wakeup-irq
usb: chipidea: add tracepoint support for udc
usb: chipidea: trace: fix the endian issue
Prashant Malani (7):
usb: pd: Add captive Type C cable type
usb: typec: Add number of altmodes partner attr
usb: typec: Add plug num_altmodes sysfs attr
usb: typec: Fix num_altmodes kernel-doc error
usb: typec: Consolidate sysfs ABI documentation
usb: typec: Expose Product Type VDOs via sysfs
usb: typec: Add class for plug alt mode device
Rikard Falkeborn (3):
USB: core: Constify static attribute_group structs
usb: typec: Constify static attribute_group structs
usb: common: ulpi: Constify static attribute_group struct
Roger Quadros (1):
usb: cdns3: fix NULL pointer dereference on no platform data
Sebastian Andrzej Siewior (1):
usb: hcd.h: Remove RUN_CONTEXT
Sudip Mukherjee (1):
usb: host: ehci-sched: add comment about find_tt() not returning error
Tejas Joglekar (2):
usb: xhci: Set quirk for XHCI_SG_TRB_CACHE_SIZE_QUIRK
usb: xhci: Use temporary buffer to consolidate SG
Thomas Gleixner (3):
USB: sisusbvga: Make console support depend on BROKEN
usb: atm: Replace in_interrupt() usage in comment
USB: host: ehci-pmcmsp: Cleanup usb_hcd_msp_remove()
Tom Rix (5):
USB: serial: iuu_phoenix: remove unneeded break
usb: misc: iowarrior: remove unneeded break
usb: storage: freecom: remove unneeded break
usb: host: xhci-mem: remove unneeded break
USB: host: u123-hcd: remove trailing semicolon in macro definition
Utkarsh Patel (6):
usb: typec: Correct the bit values for the Thunderbolt rounded/non-rounded cable support
platform/chrome: cros_ec_typec: Correct the Thunderbolt rounded/non-rounded cable support
usb: typec: intel_pmc_mux: Configure Thunderbolt cable generation bits
usb: typec: Remove one bit support for the Thunderbolt rounded/non-rounded cable
usb: typec: intel_pmc_mux: Use correct response message bits
usb: typec: intel_pmc_mux: Configure cable generation value for USB4
Will McVicker (2):
USB: gadget: f_rndis: fix bitrate for SuperSpeed and above
USB: gadget: f_midi: setup SuperSpeed Plus descriptors
Xu Wang (1):
usb: fotg210-hcd: remove casting dma_alloc_coherent
Yang Yingliang (1):
usb/max3421: fix return error code in max3421_probe()
Zhang Qilong (2):
usb: ehci-omap: Fix PM disable depth umbalance in ehci_hcd_omap_probe
usb: oxu210hp-hcd: Fix memory leak in oxu_create
Zheng Yongjun (3):
usb: typec: tcpm: convert comma to semicolon
usb: ucsi: convert comma to semicolon
usb: phy: convert comma to semicolon
Zou Wei (1):
usb: misc: brcmstb-usb-pinmap: Make sync_all_pins static
pumahsu (1):
USB: typec: tcpm: Hard Reset after not receiving a Request
taehyun.cho (1):
USB: gadget: f_acm: add support for SuperSpeed Plus
Documentation/ABI/testing/sysfs-bus-thunderbolt | 28 +
Documentation/ABI/testing/sysfs-class-typec | 142 +-
Documentation/admin-guide/kernel-parameters.txt | 1 +
.../bindings/connector/usb-connector.yaml | 19 +
.../devicetree/bindings/usb/brcm,usb-pinmap.yaml | 70 +
.../devicetree/bindings/usb/cdns,usb3.yaml | 5 +
.../devicetree/bindings/usb/maxim,max33359.yaml | 75 +
MAINTAINERS | 15 +
arch/arm/configs/badge4_defconfig | 1 -
arch/arm/configs/corgi_defconfig | 1 -
arch/arm/configs/pxa_defconfig | 1 -
arch/arm/configs/spitz_defconfig | 1 -
arch/arm/mach-omap1/board-h2.c | 22 +-
arch/mips/configs/mtx1_defconfig | 1 -
arch/mips/configs/rm200_defconfig | 1 -
arch/powerpc/configs/g5_defconfig | 1 -
arch/powerpc/configs/ppc6xx_defconfig | 1 -
drivers/net/thunderbolt.c | 2 +-
drivers/platform/chrome/cros_ec_typec.c | 3 +-
drivers/thunderbolt/Kconfig | 13 +
drivers/thunderbolt/Makefile | 3 +
drivers/thunderbolt/ctl.c | 7 +-
drivers/thunderbolt/debugfs.c | 24 +
drivers/thunderbolt/dma_test.c | 736 ++++++++
drivers/thunderbolt/icm.c | 240 ++-
drivers/thunderbolt/nhi.c | 36 +-
drivers/thunderbolt/nhi.h | 1 +
drivers/thunderbolt/path.c | 17 +-
drivers/thunderbolt/switch.c | 53 +-
drivers/thunderbolt/tb.c | 2 +
drivers/thunderbolt/tb.h | 22 +
drivers/thunderbolt/tb_msgs.h | 28 +
drivers/thunderbolt/tb_regs.h | 14 +
drivers/thunderbolt/tunnel.c | 50 +-
drivers/thunderbolt/usb4.c | 269 +--
drivers/thunderbolt/xdomain.c | 148 +-
drivers/usb/Makefile | 1 -
drivers/usb/atm/cxacru.c | 9 +-
drivers/usb/atm/usbatm.c | 4 +-
drivers/usb/atm/xusbatm.c | 2 +-
drivers/usb/cdns3/cdns3-imx.c | 2 +-
drivers/usb/cdns3/core.c | 15 +-
drivers/usb/cdns3/core.h | 4 +
drivers/usb/cdns3/gadget-export.h | 3 -
drivers/usb/cdns3/gadget.c | 2 +-
drivers/usb/cdns3/host-export.h | 6 +
drivers/usb/cdns3/host.c | 60 +-
drivers/usb/chipidea/Makefile | 5 +-
drivers/usb/chipidea/ci_hdrc_imx.c | 10 +-
drivers/usb/chipidea/trace.c | 23 +
drivers/usb/chipidea/trace.h | 92 +
drivers/usb/chipidea/udc.c | 10 +-
drivers/usb/chipidea/usbmisc_imx.c | 7 +-
drivers/usb/common/ulpi.c | 2 +-
drivers/usb/core/buffer.c | 6 +-
drivers/usb/core/config.c | 1 +
drivers/usb/core/endpoint.c | 2 +-
drivers/usb/core/hcd-pci.c | 6 +-
drivers/usb/core/hcd.c | 37 +-
drivers/usb/core/hub.c | 3 +-
drivers/usb/core/message.c | 47 +-
drivers/usb/core/port.c | 4 +-
drivers/usb/core/quirks.c | 3 +
drivers/usb/core/sysfs.c | 14 +-
drivers/usb/core/usb.c | 4 +-
drivers/usb/gadget/function/f_acm.c | 2 +-
drivers/usb/gadget/function/f_fs.c | 184 +-
drivers/usb/gadget/function/f_loopback.c | 2 +-
drivers/usb/gadget/function/f_midi.c | 6 +
drivers/usb/gadget/function/f_rndis.c | 4 +-
drivers/usb/gadget/function/f_sourcesink.c | 1 +
drivers/usb/gadget/udc/core.c | 2 -
drivers/usb/gadget/udc/dummy_hcd.c | 10 +-
drivers/usb/gadget/udc/pxa27x_udc.c | 19 +-
drivers/usb/host/Kconfig | 17 -
drivers/usb/host/Makefile | 2 -
drivers/usb/host/ehci-fsl.c | 9 +-
drivers/usb/host/ehci-hcd.c | 2 +-
drivers/usb/host/ehci-mxc.c | 213 ---
drivers/usb/host/ehci-omap.c | 1 +
drivers/usb/host/ehci-pmcmsp.c | 15 +-
drivers/usb/host/ehci-sched.c | 12 +
drivers/usb/host/fotg210-hcd.c | 4 +-
drivers/usb/host/imx21-dbg.c | 439 -----
drivers/usb/host/imx21-hcd.c | 1933 --------------------
drivers/usb/host/imx21-hcd.h | 431 -----
drivers/usb/host/isp116x-hcd.c | 1 +
drivers/usb/host/isp1362.h | 54 -
drivers/usb/host/max3421-hcd.c | 4 +-
drivers/usb/host/ohci-at91.c | 11 +-
drivers/usb/host/ohci-hcd.c | 2 +-
drivers/usb/host/ohci-hub.c | 1 +
drivers/usb/host/ohci-omap.c | 9 +-
drivers/usb/host/ohci-pxa27x.c | 11 +-
drivers/usb/host/ohci-s3c2410.c | 12 +-
drivers/usb/host/oxu210hp-hcd.c | 5 +-
drivers/usb/host/u132-hcd.c | 6 +-
drivers/usb/host/xhci-hub.c | 4 +
drivers/usb/host/xhci-mem.c | 3 +-
drivers/usb/host/xhci-pci.c | 6 +-
drivers/usb/host/xhci-plat.c | 3 +
drivers/usb/host/xhci-ring.c | 4 +-
drivers/usb/host/xhci.c | 135 +-
drivers/usb/host/xhci.h | 5 +
drivers/usb/misc/Kconfig | 9 +
drivers/usb/misc/Makefile | 1 +
drivers/usb/misc/apple-mfi-fastcharge.c | 13 +-
drivers/usb/misc/brcmstb-usb-pinmap.c | 351 ++++
drivers/usb/misc/iowarrior.c | 3 -
drivers/usb/misc/legousbtower.c | 2 +-
drivers/usb/misc/sisusbvga/Kconfig | 2 +-
drivers/usb/misc/yurex.c | 1 +
drivers/usb/mtu3/mtu3_debug.h | 1 -
drivers/usb/mtu3/mtu3_debugfs.c | 2 +-
drivers/usb/musb/tusb6010.c | 1 +
drivers/usb/phy/Kconfig | 2 +-
drivers/usb/phy/phy-isp1301-omap.c | 31 +-
drivers/usb/serial/Kconfig | 19 +-
drivers/usb/serial/Makefile | 1 -
drivers/usb/serial/cp210x.c | 499 ++---
drivers/usb/serial/digi_acceleport.c | 62 +-
drivers/usb/serial/ftdi_sio.c | 23 +-
drivers/usb/serial/iuu_phoenix.c | 2 -
drivers/usb/serial/keyspan_pda.c | 548 +++---
drivers/usb/serial/mos7720.c | 236 +--
drivers/usb/serial/option.c | 23 +-
drivers/usb/storage/ene_ub6250.c | 1 +
drivers/usb/storage/freecom.c | 1 -
drivers/usb/storage/transport.c | 9 +-
drivers/usb/storage/uas.c | 4 +
drivers/usb/storage/unusual_uas.h | 7 +-
drivers/usb/storage/usb.c | 3 +
drivers/usb/typec/Kconfig | 5 +-
drivers/usb/typec/class.c | 298 ++-
drivers/usb/typec/mux/intel_pmc_mux.c | 17 +-
drivers/usb/typec/tcpm/fusb302.c | 16 +-
drivers/usb/typec/tcpm/tcpci.c | 123 +-
drivers/usb/typec/tcpm/tcpci.h | 25 +-
drivers/usb/typec/tcpm/tcpci_maxim.c | 51 +-
drivers/usb/typec/tcpm/tcpm.c | 227 ++-
drivers/usb/typec/tcpm/wcove.c | 3 +-
drivers/usb/typec/tps6598x.c | 103 ++
drivers/usb/typec/ucsi/psy.c | 6 +-
drivers/usb/typec/ucsi/ucsi.c | 125 +-
drivers/usb/typec/ucsi/ucsi.h | 2 +
drivers/usb/typec/ucsi/ucsi_acpi.c | 5 +-
drivers/usb/usbip/usbip_common.c | 5 -
include/dt-bindings/usb/pd.h | 8 +
include/linux/platform_data/usb-ehci-mxc.h | 14 -
include/linux/thunderbolt.h | 18 +-
include/linux/usb/hcd.h | 4 -
include/linux/usb/pd.h | 2 +
include/linux/usb/pd_vdo.h | 19 +-
include/linux/usb/serial.h | 2 -
include/linux/usb/tcpm.h | 28 +-
include/linux/usb/typec.h | 2 +
include/linux/usb/typec_tbt.h | 6 +-
include/linux/usb_usual.h | 2 +
158 files changed, 4292 insertions(+), 4702 deletions(-)
create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb-pinmap.yaml
create mode 100644 Documentation/devicetree/bindings/usb/maxim,max33359.yaml
create mode 100644 drivers/thunderbolt/dma_test.c
create mode 100644 drivers/usb/chipidea/trace.c
create mode 100644 drivers/usb/chipidea/trace.h
delete mode 100644 drivers/usb/host/ehci-mxc.c
delete mode 100644 drivers/usb/host/imx21-dbg.c
delete mode 100644 drivers/usb/host/imx21-hcd.c
delete mode 100644 drivers/usb/host/imx21-hcd.h
create mode 100644 drivers/usb/misc/brcmstb-usb-pinmap.c
delete mode 100644 include/linux/platform_data/usb-ehci-mxc.h
^ permalink raw reply
* RE: port power is on again after turning off by user space
From: Peter Chen @ 2020-12-15 9:57 UTC (permalink / raw)
To: Jun Li, Alan Stern; +Cc: linux-usb@vger.kernel.org
In-Reply-To: <20201215051402.GC2142@b29397-desktop>
> > > Hi Alan,
> > >
> > > I use one HUB power control application
> > >
> (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.
> com%2Fmvp%2Fuhubctl&data=04%7C01%7Cpeter.chen%40nxp.com%7C
> 736ece19bc7a430c98b808d8a0b6975c%7C686ea1d3bc2b4c6fa92cd99c5c3016
> 35%7C0%7C0%7C637436053362151022%7CUnknown%7CTWFpbGZsb3d8eyJ
> WIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7
> C1000&sdata=lptf1XO5yeb6lQbAFlKUrZ%2BEX5ATXQRftGwm26WowFA%
> 3D&reserved=0) to investigate power switchable HUB, and find the kernel
> turns port power on again at drivers/usb/core/hub.c, after port power is turned
> off by user space.
> > >
> > > 5122 if (hub_is_port_power_switchable(hub)
> > > 5123 && !port_is_power_on(hub,
> portstatus)
> > > 5124 && !port_dev->port_owner)
> > > 5125 set_port_feature(hdev, port1,
> USB_PORT_FEAT_POWER);
> > >
> > > The main sequence for testing turn port power off like below:
> > >
> > > - uhubctl sends command to turn specifc port (eg, 2-1.4) power off.
> > > - devio at kernel gets that command, and send to hub.
> > > - port power is off, the hub_event is triggered due to port status is changed.
> > > - usb_disconnect is called, but port power is on again by kernel at function
> hub_port_connect.
> > >
> > > I can't find the code history why the port power needs to turn on after
> device is disconnected, do you know why?
> > > Any sugguestions to fix it? Thanks.
> >
> > Seems in this case the port need claimed by user app, I am seeing this
> > commit
> >
> > commit fbaecff06a7db4defa899a664fe2758e5161b39d
> > Author: Deepak Das <deepakdas.linux@gmail.com>
> > Date: Wed Jan 21 23:39:58 2015 +0530
> >
> > usb: core: hub: modify hub reset logic in hub driver
> >
> > Currently if port power is turned off by user on hub port
> > using USBDEVFS then port power is turned back ON
> > by hub driver.
> > This commit modifies hub reset logic in hub_port_connect() to prevent
> > hub driver from turning back the port power ON if port is not owned
> > by kernel.
> >
> > Signed-off-by: Deepak Das <deepakdas.linux@gmail.com>
> > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index
> > b4bfa3a..3e9c4d4 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -4655,9 +4655,13 @@ static void hub_port_connect(struct usb_hub
> > *hub, int port1, u16 portstatus,
> > if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
> > test_bit(port1, hub->removed_bits)) {
> >
> > - /* maybe switch power back on (e.g. root hub was reset)
> */
> > + /*
> > + * maybe switch power back on (e.g. root hub was reset)
> > + * but only if the port isn't owned by someone else.
> > + */
> > if (hub_is_port_power_switchable(hub)
> > - && !port_is_power_on(hub,
> portstatus))
> > + && !port_is_power_on(hub,
> portstatus)
> > + && !port_dev->port_owner)
> > set_port_feature(hdev, port1,
> > USB_PORT_FEAT_POWER);
> >
> > if (portstatus & USB_PORT_STAT_ENABLE)
> >
>
> Yes, I saw this commit. But the port is owned by kernel, the device on the port
> could be enumerated by kernel, just the power on the port could be changed by
> user space.
>
I find this issue has discussed there, but I can't open the URL: https://bit.ly/2JzczjZ
Below the description from: https://github.com/mvp/uhubctl.
Their workarounds are not good.
Power comes back on after few seconds on Linux
Some device drivers in kernel are surprised by USB device
being turned off and automatically try to power it back on.
You can use option -r N where N is some number from 10 to 1000
to fix this - uhubctl will try to turn power off many times in quick
succession, and it should suppress that. This may be eventually fixed
in kernel, see more discussion here.
Disabling USB authorization for device in question before
turning power off with uhubctl should help:
echo 0 > sudo tee /sys/bus/usb/devices/${location}.${port}/authorized
If your device is USB mass storage, invoking udisksctl before calling uhubctl
should help too:
sudo udisksctl power-off --block-device /dev/disk/...`
sudo uhubctl -a off ...
Peter
^ permalink raw reply
* Re: [kbuild-all] Re: [PATCH] usb: cdns3: Adds missing __iomem markers
From: Rong Chen @ 2020-12-15 9:42 UTC (permalink / raw)
To: Peter Chen, kernel test robot
Cc: Pawel Laszczak, kbuild-all@lists.01.org, rogerq@ti.com,
a-govindraju@ti.com, nsekhar@ti.com, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
kurahul@cadence.com
In-Reply-To: <20201215055812.GA18223@b29397-desktop>
On 12/15/20 1:58 PM, Peter Chen wrote:
> On 20-12-14 23:35:56, kernel test robot wrote:
>> Hi Pawel,
>>
>> I love your patch! Perhaps something to improve:
>>
>> [auto build test WARNING on next-20201211]
>> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
> Sorry, I changed the branch name to reflect the branch does not only queue
> chipidea USB patches.
>
> next branch: for-usb-next
> fixes branch: for-usb-fixes
>
> Peter
Hi Peter,
Thanks for the feedback, we'll update it on the CI system.
Best Regards,
Rong Chen
>
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fdocs%2Fgit-format-patch&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Cy3huYNzWiJ57OKmzmaleCT14gcFr8RyYDnqTfZWNG4%3D&reserved=0]
>>
>> url: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommits%2FPawel-Laszczak%2Fusb-cdns3-Adds-missing-__iomem-markers%2F20201214-205353&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=x5XoDUUskeGteTFaPjgS24Hrbb712XqMqaIkqwXWu14%3D&reserved=0
>> base: 3cc2bd440f2171f093b3a8480a4b54d8c270ed38
>> config: riscv-allmodconfig (attached as .config)
>> compiler: riscv64-linux-gcc (GCC) 9.3.0
>> reproduce (this is a W=1 build):
>> wget https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fintel%2Flkp-tests%2Fmaster%2Fsbin%2Fmake.cross&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jAavg0T3itnjkbHXADvePHHgtYeqiVTBt%2BoatHT0VHU%3D&reserved=0 -O ~/bin/make.cross
>> chmod +x ~/bin/make.cross
>> # https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommit%2F315bfcf1e0604de6ecfc1856cf5820876390f16c&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SQ75IXxfld6HMRIFkZ%2F8Z4YqxnFP%2F%2BZ%2BsYZIycNeO%2FA%3D&reserved=0
>> git remote add linux-review https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZVS4723WbEO03hbsLXJ%2B%2FmB5EZElulY7lAsMEMatiko%3D&reserved=0
>> git fetch --no-tags linux-review Pawel-Laszczak/usb-cdns3-Adds-missing-__iomem-markers/20201214-205353
>> git checkout 315bfcf1e0604de6ecfc1856cf5820876390f16c
>> # save the attached .config to linux build tree
>> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> All warnings (new ones prefixed by >>):
>>
>> In file included from arch/riscv/include/asm/io.h:23,
>> from include/linux/io.h:13,
>> from include/linux/irq.h:20,
>> from include/asm-generic/hardirq.h:17,
>> from ./arch/riscv/include/generated/asm/hardirq.h:1,
>> from include/linux/hardirq.h:10,
>> from include/linux/interrupt.h:11,
>> from drivers/usb/cdns3/drd.c:13:
>> drivers/usb/cdns3/drd.c: In function 'cdns_otg_disable_irq':
>> drivers/usb/cdns3/drd.c:159:31: error: dereferencing pointer to incomplete type 'struct cdns_otg_irq_reg'
>> 159 | writel(0, &cdns->otg_irq_regs->ien);
>> | ^~
>> arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
>> 93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
>> | ^
>> drivers/usb/cdns3/drd.c:159:2: note: in expansion of macro 'writel'
>> 159 | writel(0, &cdns->otg_irq_regs->ien);
>> | ^~~~~~
>> drivers/usb/cdns3/drd.c: In function 'cdns_drd_init':
>> drivers/usb/cdns3/drd.c:409:22: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
>> 409 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> | ^
>> In file included from include/linux/byteorder/little_endian.h:5,
>> from arch/riscv/include/uapi/asm/byteorder.h:10,
>> from include/asm-generic/bitops/le.h:6,
>> from arch/riscv/include/asm/bitops.h:202,
>> from include/linux/bitops.h:32,
>> from include/linux/kernel.h:11,
>> from drivers/usb/cdns3/drd.c:12:
>>>> drivers/usb/cdns3/drd.c:421:33: warning: passing argument 1 of '__raw_readl' makes pointer from integer without a cast [-Wint-conversion]
>> 421 | if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
>> | ~~~~~~~~~~~~~~~~~~~~^~~~~
>> | |
>> | __le32 {aka unsigned int}
>> include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
>> 34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
>> | ^
>> arch/riscv/include/asm/mmio.h:140:47: note: in expansion of macro 'readl_cpu'
>> 140 | #define readl(c) ({ u32 __v; __io_br(); __v = readl_cpu(c); __io_ar(__v); __v; })
>> | ^~~~~~~~~
>> drivers/usb/cdns3/drd.c:421:7: note: in expansion of macro 'readl'
>> 421 | if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
>> | ^~~~~
>> In file included from arch/riscv/include/asm/io.h:23,
>> from include/linux/io.h:13,
>> from include/linux/irq.h:20,
>> from include/asm-generic/hardirq.h:17,
>> from ./arch/riscv/include/generated/asm/hardirq.h:1,
>> from include/linux/hardirq.h:10,
>> from include/linux/interrupt.h:11,
>> from drivers/usb/cdns3/drd.c:13:
>> arch/riscv/include/asm/mmio.h:63:60: note: expected 'const volatile void *' but argument is of type '__le32' {aka 'unsigned int'}
>> 63 | static inline u32 __raw_readl(const volatile void __iomem *addr)
>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
>> drivers/usb/cdns3/drd.c:422:23: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
>> 422 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> | ^
>> drivers/usb/cdns3/drd.c:426:23: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
>> 426 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> | ^
>> cc1: some warnings being treated as errors
>>
>> vim +/__raw_readl +421 drivers/usb/cdns3/drd.c
>>
>> 383
>> 384 int cdns_drd_init(struct cdns *cdns)
>> 385 {
>> 386 void __iomem *regs;
>> 387 u32 state;
>> 388 int ret;
>> 389
>> 390 regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
>> 391 if (IS_ERR(regs))
>> 392 return PTR_ERR(regs);
>> 393
>> 394 /* Detection of DRD version. Controller has been released
>> 395 * in three versions. All are very similar and are software compatible,
>> 396 * but they have same changes in register maps.
>> 397 * The first register in oldest version is command register and it's
>> 398 * read only. Driver should read 0 from it. On the other hand, in v1
>> 399 * and v2 the first register contains device ID number which is not
>> 400 * set to 0. Driver uses this fact to detect the proper version of
>> 401 * controller.
>> 402 */
>> 403 cdns->otg_v0_regs = regs;
>> 404 if (!readl(&cdns->otg_v0_regs->cmd)) {
>> 405 cdns->version = CDNS3_CONTROLLER_V0;
>> 406 cdns->otg_v1_regs = NULL;
>> 407 cdns->otg_cdnsp_regs = NULL;
>> 408 cdns->otg_regs = regs;
>> 409 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> 410 &cdns->otg_v0_regs->ien;
>> 411 writel(1, &cdns->otg_v0_regs->simulate);
>> 412 dev_dbg(cdns->dev, "DRD version v0 (%08x)\n",
>> 413 readl(&cdns->otg_v0_regs->version));
>> 414 } else {
>> 415 cdns->otg_v0_regs = NULL;
>> 416 cdns->otg_v1_regs = regs;
>> 417 cdns->otg_cdnsp_regs = regs;
>> 418
>> 419 cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd;
>> 420
>> > 421 if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
>> 422 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> 423 &cdns->otg_cdnsp_regs->ien;
>> 424 cdns->version = CDNSP_CONTROLLER_V2;
>> 425 } else {
>> 426 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
>> 427 &cdns->otg_v1_regs->ien;
>> 428 writel(1, &cdns->otg_v1_regs->simulate);
>> 429 cdns->version = CDNS3_CONTROLLER_V1;
>> 430 }
>> 431
>> 432 dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
>> 433 readl(&cdns->otg_v1_regs->did),
>> 434 readl(&cdns->otg_v1_regs->rid));
>> 435 }
>> 436
>> 437 state = OTGSTS_STRAP(readl(&cdns->otg_regs->sts));
>> 438
>> 439 /* Update dr_mode according to STRAP configuration. */
>> 440 cdns->dr_mode = USB_DR_MODE_OTG;
>> 441
>> 442 if ((cdns->version == CDNSP_CONTROLLER_V2 &&
>> 443 state == OTGSTS_CDNSP_STRAP_HOST) ||
>> 444 (cdns->version != CDNSP_CONTROLLER_V2 &&
>> 445 state == OTGSTS_STRAP_HOST)) {
>> 446 dev_dbg(cdns->dev, "Controller strapped to HOST\n");
>> 447 cdns->dr_mode = USB_DR_MODE_HOST;
>> 448 } else if ((cdns->version == CDNSP_CONTROLLER_V2 &&
>> 449 state == OTGSTS_CDNSP_STRAP_GADGET) ||
>> 450 (cdns->version != CDNSP_CONTROLLER_V2 &&
>> 451 state == OTGSTS_STRAP_GADGET)) {
>> 452 dev_dbg(cdns->dev, "Controller strapped to PERIPHERAL\n");
>> 453 cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
>> 454 }
>> 455
>> 456 ret = devm_request_threaded_irq(cdns->dev, cdns->otg_irq,
>> 457 cdns_drd_irq,
>> 458 cdns_drd_thread_irq,
>> 459 IRQF_SHARED,
>> 460 dev_name(cdns->dev), cdns);
>> 461 if (ret) {
>> 462 dev_err(cdns->dev, "couldn't get otg_irq\n");
>> 463 return ret;
>> 464 }
>> 465
>> 466 state = readl(&cdns->otg_regs->sts);
>> 467 if (OTGSTS_OTG_NRDY(state)) {
>> 468 dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");
>> 469 return -ENODEV;
>> 470 }
>> 471
>> 472 return 0;
>> 473 }
>> 474
>>
>> ---
>> 0-DAY CI Kernel Test Service, Intel Corporation
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fhyperkitty%2Flist%2Fkbuild-all%40lists.01.org&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=v9fQGKZKobtIysXu43lCekV%2FoXCc2EZZXIxoTtQpSdw%3D&reserved=0
>
>
^ permalink raw reply
* [RESEND PATCH v3 2/2] usb: dwc3: Add driver for Xilinx platforms
From: Manish Narani @ 2020-12-15 6:54 UTC (permalink / raw)
To: gregkh, robh+dt, michal.simek, balbi, p.zabel
Cc: git, linux-usb, devicetree, linux-arm-kernel, linux-kernel,
Manish Narani
In-Reply-To: <1608015291-52007-1-git-send-email-manish.narani@xilinx.com>
Add a new driver for supporting Xilinx platforms. This driver is used
for some sequence of operations required for Xilinx USB controllers.
This driver is also used to choose between PIPE clock coming from SerDes
and the Suspend Clock. Before the controller is out of reset, the clock
selection should be changed to PIPE clock in order to make the USB
controller work. There is a register added in Xilinx USB controller
register space for the same.
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
drivers/usb/dwc3/Kconfig | 9 +
drivers/usb/dwc3/Makefile | 1 +
drivers/usb/dwc3/dwc3-of-simple.c | 1 -
drivers/usb/dwc3/dwc3-xilinx.c | 334 ++++++++++++++++++++++++++++++
4 files changed, 344 insertions(+), 1 deletion(-)
create mode 100644 drivers/usb/dwc3/dwc3-xilinx.c
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 7a2304565a73..0e00e6dfccd8 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -139,4 +139,13 @@ config USB_DWC3_QCOM
for peripheral mode support.
Say 'Y' or 'M' if you have one such device.
+config USB_DWC3_XILINX
+ tristate "Xilinx Platforms"
+ depends on (ARCH_ZYNQMP || ARCH_VERSAL) && OF
+ default USB_DWC3
+ help
+ Support Xilinx SoCs with DesignWare Core USB3 IP.
+ This driver handles both ZynqMP and Versal SoC operations.
+ Say 'Y' or 'M' if you have one such device.
+
endif
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index ae86da0dc5bd..add567578b1f 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -51,3 +51,4 @@ obj-$(CONFIG_USB_DWC3_MESON_G12A) += dwc3-meson-g12a.o
obj-$(CONFIG_USB_DWC3_OF_SIMPLE) += dwc3-of-simple.o
obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o
obj-$(CONFIG_USB_DWC3_QCOM) += dwc3-qcom.o
+obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index e62ecd22b3ed..71fd620c5161 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -172,7 +172,6 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = {
static const struct of_device_id of_dwc3_simple_match[] = {
{ .compatible = "rockchip,rk3399-dwc3" },
- { .compatible = "xlnx,zynqmp-dwc3" },
{ .compatible = "cavium,octeon-7130-usb-uctl" },
{ .compatible = "sprd,sc9860-dwc3" },
{ .compatible = "allwinner,sun50i-h6-dwc3" },
diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
new file mode 100644
index 000000000000..7e485951d2f7
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -0,0 +1,334 @@
+// SPDX-License-Identifier: GPL-2.0
+/**
+ * dwc3-xilinx.c - Xilinx DWC3 controller specific glue driver
+ *
+ * Authors: Manish Narani <manish.narani@xilinx.com>
+ * Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
+#include <linux/reset.h>
+#include <linux/of_address.h>
+#include <linux/delay.h>
+#include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/io.h>
+
+#include <linux/phy/phy.h>
+
+/* USB phy reset mask register */
+#define XLNX_USB_PHY_RST_EN 0x001C
+#define XLNX_PHY_RST_MASK 0x1
+
+/* Xilinx USB 3.0 IP Register */
+#define XLNX_USB_TRAFFIC_ROUTE_CONFIG 0x005C
+#define XLNX_USB_TRAFFIC_ROUTE_FPD 0x1
+
+/* Versal USB Reset ID */
+#define VERSAL_USB_RESET_ID 0xC104036
+
+#define XLNX_USB_FPD_PIPE_CLK 0x7c
+#define PIPE_CLK_DESELECT 1
+#define PIPE_CLK_SELECT 0
+#define XLNX_USB_FPD_POWER_PRSNT 0x80
+#define PIPE_POWER_ON 1
+#define PIPE_POWER_OFF 0
+
+struct dwc3_xlnx {
+ int num_clocks;
+ struct clk_bulk_data *clks;
+ struct device *dev;
+ void __iomem *regs;
+ int (*pltfm_init)(struct dwc3_xlnx *data);
+};
+
+static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
+{
+ u32 reg;
+
+ /*
+ * Enable or disable ULPI PHY reset from USB Controller.
+ * This does not actually reset the phy, but just controls
+ * whether USB controller can or cannot reset ULPI PHY.
+ */
+ reg = readl(priv_data->regs + XLNX_USB_PHY_RST_EN);
+
+ if (mask)
+ reg &= ~XLNX_PHY_RST_MASK;
+ else
+ reg |= XLNX_PHY_RST_MASK;
+
+ writel(reg, priv_data->regs + XLNX_USB_PHY_RST_EN);
+}
+
+static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
+{
+ struct device *dev = priv_data->dev;
+ int ret;
+
+ dwc3_xlnx_mask_phy_rst(priv_data, false);
+
+ /* Assert and De-assert reset */
+ ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
+ PM_RESET_ACTION_ASSERT);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "failed to assert Reset\n");
+ return ret;
+ }
+
+ ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
+ PM_RESET_ACTION_RELEASE);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "failed to De-assert Reset\n");
+ return ret;
+ }
+
+ dwc3_xlnx_mask_phy_rst(priv_data, true);
+
+ return 0;
+}
+
+static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
+{
+ struct device *dev = priv_data->dev;
+ struct reset_control *crst, *hibrst, *apbrst;
+ struct phy *usb3_phy;
+ int ret;
+ u32 reg;
+
+ crst = devm_reset_control_get_exclusive(dev, "usb_crst");
+ if (IS_ERR(crst)) {
+ ret = PTR_ERR(crst);
+ dev_err_probe(dev, ret,
+ "failed to get core reset signal\n");
+ goto err;
+ }
+
+ hibrst = devm_reset_control_get_exclusive(dev, "usb_hibrst");
+ if (IS_ERR(hibrst)) {
+ ret = PTR_ERR(hibrst);
+ dev_err_probe(dev, ret,
+ "failed to get hibernation reset signal\n");
+ goto err;
+ }
+
+ apbrst = devm_reset_control_get_exclusive(dev, "usb_apbrst");
+ if (IS_ERR(apbrst)) {
+ ret = PTR_ERR(apbrst);
+ dev_err_probe(dev, ret,
+ "failed to get APB reset signal\n");
+ goto err;
+ }
+
+ ret = reset_control_assert(crst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to assert core reset\n");
+ goto err;
+ }
+
+ ret = reset_control_assert(hibrst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to assert hibernation reset\n");
+ goto err;
+ }
+
+ ret = reset_control_assert(apbrst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to assert APB reset\n");
+ goto err;
+ }
+
+ usb3_phy = devm_phy_get(dev, "usb3-phy");
+
+ ret = phy_init(usb3_phy);
+ if (ret < 0) {
+ phy_exit(usb3_phy);
+ goto err;
+ }
+
+ ret = reset_control_deassert(apbrst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to release APB reset\n");
+ goto err;
+ }
+
+ /* Set PIPE Power Present signal in FPD Power Present Register*/
+ writel(PIPE_POWER_ON, priv_data->regs + XLNX_USB_FPD_POWER_PRSNT);
+
+ /* Set the PIPE Clock Select bit in FPD PIPE Clock register */
+ writel(PIPE_CLK_SELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
+
+ ret = reset_control_deassert(crst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to release core reset\n");
+ goto err;
+ }
+
+ ret = reset_control_deassert(hibrst);
+ if (ret < 0) {
+ dev_err(dev, "Failed to release hibernation reset\n");
+ goto err;
+ }
+
+ ret = phy_power_on(usb3_phy);
+ if (ret < 0) {
+ phy_exit(usb3_phy);
+ goto err;
+ }
+
+ /*
+ * This routes the USB DMA traffic to go through FPD path instead
+ * of reaching DDR directly. This traffic routing is needed to
+ * make SMMU and CCI work with USB DMA.
+ */
+ if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
+ reg = readl(priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
+ reg |= XLNX_USB_TRAFFIC_ROUTE_FPD;
+ writel(reg, priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
+ }
+
+err:
+ return ret;
+}
+
+static const struct of_device_id dwc3_xlnx_of_match[] = {
+ {
+ .compatible = "xlnx,zynqmp-dwc3",
+ .data = &dwc3_xlnx_init_zynqmp,
+ },
+ {
+ .compatible = "xlnx,versal-dwc3",
+ .data = &dwc3_xlnx_init_versal,
+ },
+ { /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, dwc3_xlnx_of_match);
+
+static int dwc3_xlnx_probe(struct platform_device *pdev)
+{
+ struct dwc3_xlnx *priv_data;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ const struct of_device_id *match;
+ void __iomem *regs;
+ int ret;
+
+ priv_data = devm_kzalloc(dev, sizeof(*priv_data), GFP_KERNEL);
+ if (!priv_data)
+ return -ENOMEM;
+
+ regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(regs)) {
+ ret = PTR_ERR(regs);
+ dev_err_probe(dev, ret, "failed to map registers\n");
+ return ret;
+ }
+
+ match = of_match_node(dwc3_xlnx_of_match, pdev->dev.of_node);
+
+ priv_data->pltfm_init = match->data;
+ priv_data->regs = regs;
+ priv_data->dev = dev;
+
+ platform_set_drvdata(pdev, priv_data);
+
+ ret = devm_clk_bulk_get_all(priv_data->dev, &priv_data->clks);
+ if (ret < 0)
+ return ret;
+
+ priv_data->num_clocks = ret;
+
+ ret = clk_bulk_prepare_enable(priv_data->num_clocks, priv_data->clks);
+ if (ret)
+ return ret;
+
+ ret = priv_data->pltfm_init(priv_data);
+ if (ret)
+ goto err_clk_put;
+
+ ret = of_platform_populate(np, NULL, NULL, dev);
+ if (ret)
+ goto err_clk_put;
+
+ pm_runtime_set_active(dev);
+ pm_runtime_enable(dev);
+ pm_suspend_ignore_children(dev, false);
+ pm_runtime_get_sync(dev);
+
+ return 0;
+
+err_clk_put:
+ clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
+ clk_bulk_put_all(priv_data->num_clocks, priv_data->clks);
+
+ return ret;
+}
+
+static int dwc3_xlnx_remove(struct platform_device *pdev)
+{
+ struct dwc3_xlnx *priv_data = platform_get_drvdata(pdev);
+ struct device *dev = &pdev->dev;
+
+ of_platform_depopulate(dev);
+
+ clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
+ clk_bulk_put_all(priv_data->num_clocks, priv_data->clks);
+ priv_data->num_clocks = 0;
+
+ pm_runtime_disable(dev);
+ pm_runtime_put_noidle(dev);
+ pm_runtime_set_suspended(dev);
+
+ return 0;
+}
+
+static int __maybe_unused dwc3_xlnx_suspend_common(struct device *dev)
+{
+ struct dwc3_xlnx *priv_data = dev_get_drvdata(dev);
+
+ clk_bulk_disable(priv_data->num_clocks, priv_data->clks);
+
+ return 0;
+}
+
+static int __maybe_unused dwc3_xlnx_resume_common(struct device *dev)
+{
+ struct dwc3_xlnx *priv_data = dev_get_drvdata(dev);
+
+ return clk_bulk_enable(priv_data->num_clocks, priv_data->clks);
+}
+
+static int __maybe_unused dwc3_xlnx_runtime_idle(struct device *dev)
+{
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_autosuspend(dev);
+
+ return 0;
+}
+
+static UNIVERSAL_DEV_PM_OPS(dwc3_xlnx_dev_pm_ops, dwc3_xlnx_suspend_common,
+ dwc3_xlnx_resume_common, dwc3_xlnx_runtime_idle);
+
+static struct platform_driver dwc3_xlnx_driver = {
+ .probe = dwc3_xlnx_probe,
+ .remove = dwc3_xlnx_remove,
+ .driver = {
+ .name = "dwc3-xilinx",
+ .of_match_table = dwc3_xlnx_of_match,
+ .pm = &dwc3_xlnx_dev_pm_ops,
+ },
+};
+
+module_platform_driver(dwc3_xlnx_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Xilinx DWC3 controller specific glue driver");
+MODULE_AUTHOR("Manish Narani <manish.narani@xilinx.com>");
+MODULE_AUTHOR("Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>");
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 1/2] usb: cdnsp: Fixes for sparse warnings
From: Peter Chen @ 2020-12-15 6:55 UTC (permalink / raw)
To: Pawel Laszczak
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Rahul Kumar
In-Reply-To: <BYAPR07MB5381C42748CC8276E9D21F15DDC60@BYAPR07MB5381.namprd07.prod.outlook.com>
On 20-12-15 06:14:07, Pawel Laszczak wrote:
> >On 20-12-15 05:27:38, Pawel Laszczak wrote:
> >> >
> >> >
> >> >On 20-12-14 13:03:44, Pawel Laszczak wrote:
> >> >> Patch fixes all sparse warnings in cdsnp driver.
> >> >>
> >> >> It fixes the following warnings:
> >> >> cdnsp-ring.c:1441: warning: incorrect type in assignment
> >> >> cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
> >> >> cdnsp-ring.c:2200: warning: dubious: x | !y
> >> >> cdnsp-gadget.c:501: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:509: warning: invalid assignment: |=
> >> >> cdnsp-gadget.c:510: warning: cast from restricted __le32
> >> >> cdnsp-gadget.c:558: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:1571: warning: incorrect type in argument 1
> >> >> cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
> >> >> cdnsp-gadget.c:1760: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1762: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1763: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1764: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1765: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1766: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:1767: warning: incorrect type in assignment
> >> >> cdnsp-gadget.c:458: warning: cast truncates bits from constant value
> >> >> (ffffffff07ffffff becomes 7ffffff)
> >> >> cdnsp-gadget.c:666: warning: cast truncates bits from constant value
> >> >> (ffffffff07ffffff becomes 7ffffff)
> >> >> cdnsp-mem.c:762: warning: incorrect type in assignment
> >> >> cdnsp-mem.c:763: warning: incorrect type in assignment
> >> >> cdnsp-mem.c:928: warning: cast from restricted __le16
> >> >> cdnsp-mem.c:1187: warning: incorrect type in assignment
> >> >> cdnsp-mem.c:1191: warning: incorrect type in assignment
> >> >> cdnsp-ep0.c:142: warning: incorrect type in assignment
> >> >> cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
> >> >> cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
> >> >> cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
> >> >> cdnsp-ep0.c:179: warning: incorrect type in argument 1
> >> >> cdnsp-ep0.c:311: warning: incorrect type in argument 1
> >> >> cdnsp-ep0.c:469: warning: incorrect type in assignment
> >> >> cdnsp-trace.h:611:1: warning: cast from restricted __le32
> >> >>
> >> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> >> >> Reported-by: kernel test robot <lkp@intel.com>
> >> >
> >> >Hi Pawel,
> >> >
> >> >The Reported-by tag should be above your Sob tag, I will change it.
> >> >Except the patch reported build error by kernel test robot, I will apply
> >> >your other four patches after finishing the compile test.
> >> >
> >> >Peter
> >>
> >> Hi Peter,
> >>
> >> I'm going to fix the "usb: cdns3: Adds missing __iomem markers" today.
> >> I haven't seen any issue on ARCH=parisc. Maybe it's some specific riscv arch issue.
> >>
> >> I believe that:
> >> [auto build test WARNING on next-20201211]
> >> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
> >>
> >> is not the problem. I based on peter.chen-usb/for-usb-next.
> >>
> >> Also I can't open the url from kernel test robot report.
> >> Maybe there is some temporary issue with server.
> >>
> >
> >Thanks for checking it, I have already pushed your other four patches.
> >Besides, there is still a build error issue for new cdns3 driver.
> >
> >https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fwww.spinics.net%2Flists%2Flinux-&data=04%7C01%7Cpeter.chen%40nxp.com%7Cf036cd7630664c9e0c5c08d8a0c0a637%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637436096594708469%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DLBFVB2px5GgA6Y%2FTU4DrfVru6z3P4RXz2x7BSpdE4o%3D&reserved=0
> >usb/msg206073.html__;!!EHscmS1ygiU1lA!X6rYk64ILtzjyHW903LAhBRjMKi9C2eyJWEXVlEZm0ly2BiNzY2wK46Ulq7q5w$
> >
>
> Did you applied: [PATCH] usb: cdnsp: Fix for undefined reference to `usb_hcd_is_primary_hcd' ?
>
Applied now.
--
Thanks,
Peter Chen
^ permalink raw reply
* [RESEND PATCH v3 1/2] dt-bindings: usb: dwc3-xilinx: Add documentation for Versal DWC3 Controller
From: Manish Narani @ 2020-12-15 6:54 UTC (permalink / raw)
To: gregkh, robh+dt, michal.simek, balbi, p.zabel
Cc: git, linux-usb, devicetree, linux-arm-kernel, linux-kernel,
Manish Narani
In-Reply-To: <1608015291-52007-1-git-send-email-manish.narani@xilinx.com>
Add documentation for Versal DWC3 controller. Add required property
'reg' for the same. Also add optional properties for snps,dwc3.
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
.../devicetree/bindings/usb/dwc3-xilinx.txt | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/dwc3-xilinx.txt b/Documentation/devicetree/bindings/usb/dwc3-xilinx.txt
index 4aae5b2cef56..0629f48cc807 100644
--- a/Documentation/devicetree/bindings/usb/dwc3-xilinx.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3-xilinx.txt
@@ -1,7 +1,8 @@
Xilinx SuperSpeed DWC3 USB SoC controller
Required properties:
-- compatible: Should contain "xlnx,zynqmp-dwc3"
+- compatible: May contain "xlnx,zynqmp-dwc3" or "xlnx,versal-dwc3"
+- reg: Base address and length of the register control block
- clocks: A list of phandles for the clocks listed in clock-names
- clock-names: Should contain the following:
"bus_clk" Master/Core clock, have to be >= 125 MHz for SS
@@ -13,12 +14,22 @@ Required child node:
A child node must exist to represent the core DWC3 IP block. The name of
the node is not important. The content of the node is defined in dwc3.txt.
+Optional properties for snps,dwc3:
+- dma-coherent: Enable this flag if CCI is enabled in design. Adding this
+ flag configures Global SoC bus Configuration Register and
+ Xilinx USB 3.0 IP - USB coherency register to enable CCI.
+- interrupt-names: Should contain the following:
+ "dwc_usb3" USB gadget mode interrupts
+ "otg" USB OTG mode interrupts
+ "hiber" USB hibernation interrupts
+
Example device node:
usb@0 {
#address-cells = <0x2>;
#size-cells = <0x1>;
compatible = "xlnx,zynqmp-dwc3";
+ reg = <0x0 0xff9d0000 0x0 0x100>;
clock-names = "bus_clk" "ref_clk";
clocks = <&clk125>, <&clk125>;
ranges;
@@ -26,7 +37,9 @@ Example device node:
dwc3@fe200000 {
compatible = "snps,dwc3";
reg = <0x0 0xfe200000 0x40000>;
- interrupts = <0x0 0x41 0x4>;
+ interrupt-names = "dwc_usb3", "otg", "hiber";
+ interrupts = <0 65 4>, <0 69 4>, <0 75 4>;
dr_mode = "host";
+ dma-coherent;
};
};
--
2.17.1
^ permalink raw reply related
* [RESEND PATCH v3 0/2] Add a separate DWC3 OF driver for Xilinx platforms
From: Manish Narani @ 2020-12-15 6:54 UTC (permalink / raw)
To: gregkh, robh+dt, michal.simek, balbi, p.zabel
Cc: git, linux-usb, devicetree, linux-arm-kernel, linux-kernel,
Manish Narani
This patch series documents the Xilinx Versal DWC3 controller. This also
adds a new Xilinx specific driver for adding new features in the future.
Changes in v2:
- Addressed review comments from v1
- merged normal and runtime suspend resume functions as they are
same
- Improved description of some register operations to avoid
confusion
- Updated commit log for patch 2/2 for better clarity.
Changes in v3:
- Removed snps,enable-hibernation property from the devicetree
binding.
Manish Narani (2):
dt-bindings: usb: dwc3-xilinx: Add documentation for Versal DWC3
Controller
usb: dwc3: Add driver for Xilinx platforms
.../devicetree/bindings/usb/dwc3-xilinx.txt | 17 +-
drivers/usb/dwc3/Kconfig | 9 +
drivers/usb/dwc3/Makefile | 1 +
drivers/usb/dwc3/dwc3-of-simple.c | 1 -
drivers/usb/dwc3/dwc3-xilinx.c | 334 ++++++++++++++++++
5 files changed, 359 insertions(+), 3 deletions(-)
create mode 100644 drivers/usb/dwc3/dwc3-xilinx.c
--
2.17.1
^ permalink raw reply
* RE: [PATCH 1/2] usb: cdnsp: Fixes for sparse warnings
From: Pawel Laszczak @ 2020-12-15 6:20 UTC (permalink / raw)
To: Peter Chen
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Rahul Kumar
In-Reply-To: <BYAPR07MB5381C42748CC8276E9D21F15DDC60@BYAPR07MB5381.namprd07.prod.outlook.com>
>>On 20-12-15 05:27:38, Pawel Laszczak wrote:
>>> >
>>> >
>>> >On 20-12-14 13:03:44, Pawel Laszczak wrote:
>>> >> Patch fixes all sparse warnings in cdsnp driver.
>>> >>
>>> >> It fixes the following warnings:
>>> >> cdnsp-ring.c:1441: warning: incorrect type in assignment
>>> >> cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
>>> >> cdnsp-ring.c:2200: warning: dubious: x | !y
>>> >> cdnsp-gadget.c:501: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:509: warning: invalid assignment: |=
>>> >> cdnsp-gadget.c:510: warning: cast from restricted __le32
>>> >> cdnsp-gadget.c:558: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:1571: warning: incorrect type in argument 1
>>> >> cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
>>> >> cdnsp-gadget.c:1760: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1762: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1763: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1764: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1765: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1766: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:1767: warning: incorrect type in assignment
>>> >> cdnsp-gadget.c:458: warning: cast truncates bits from constant value
>>> >> (ffffffff07ffffff becomes 7ffffff)
>>> >> cdnsp-gadget.c:666: warning: cast truncates bits from constant value
>>> >> (ffffffff07ffffff becomes 7ffffff)
>>> >> cdnsp-mem.c:762: warning: incorrect type in assignment
>>> >> cdnsp-mem.c:763: warning: incorrect type in assignment
>>> >> cdnsp-mem.c:928: warning: cast from restricted __le16
>>> >> cdnsp-mem.c:1187: warning: incorrect type in assignment
>>> >> cdnsp-mem.c:1191: warning: incorrect type in assignment
>>> >> cdnsp-ep0.c:142: warning: incorrect type in assignment
>>> >> cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
>>> >> cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
>>> >> cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
>>> >> cdnsp-ep0.c:179: warning: incorrect type in argument 1
>>> >> cdnsp-ep0.c:311: warning: incorrect type in argument 1
>>> >> cdnsp-ep0.c:469: warning: incorrect type in assignment
>>> >> cdnsp-trace.h:611:1: warning: cast from restricted __le32
>>> >>
>>> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>>> >> Reported-by: kernel test robot <lkp@intel.com>
>>> >
>>> >Hi Pawel,
>>> >
>>> >The Reported-by tag should be above your Sob tag, I will change it.
>>> >Except the patch reported build error by kernel test robot, I will apply
>>> >your other four patches after finishing the compile test.
>>> >
>>> >Peter
>>>
>>> Hi Peter,
>>>
>>> I'm going to fix the "usb: cdns3: Adds missing __iomem markers" today.
>>> I haven't seen any issue on ARCH=parisc. Maybe it's some specific riscv arch issue.
>>>
>>> I believe that:
>>> [auto build test WARNING on next-20201211]
>>> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
>>>
>>> is not the problem. I based on peter.chen-usb/for-usb-next.
>>>
>>> Also I can't open the url from kernel test robot report.
>>> Maybe there is some temporary issue with server.
>>>
>>
>>Thanks for checking it, I have already pushed your other four patches.
>>Besides, there is still a build error issue for new cdns3 driver.
>>
>>https://urldefense.com/v3/__https://www.spinics.net/lists/linux-
>>usb/msg206073.html__;!!EHscmS1ygiU1lA!X6rYk64ILtzjyHW903LAhBRjMKi9C2eyJWEXVlEZm0ly2BiNzY2wK46Ulq7q5w$
>>
>
>Did you applied: [PATCH] usb: cdnsp: Fix for undefined reference to `usb_hcd_is_primary_hcd' ?
It's my local log:
ab474baa0302 (HEAD -> for-usb-next) usb: cdns3: Adds missing __iomem markers
4af8270829f2 usb: cdnsp: Fixes for sparse warnings
4f5f85f26e77 usb: cdns3: Fixes for sparse warnings
cd41bb30fc26 dan.carpenter@oracle.comusb: cdnsp: fix error handling in cdnsp_mem_init()
1918b1486f94 usb: cdns3: Removes xhci_cdns3_suspend_quirk from host-export.h
d47d84a1cd8a usb: cdnsp: Fix for undefined reference to `usb_hcd_is_primary_hcd'
df1b6960d363 (peter.chen-usb/for-usb-next) usb: cdnsp: Removes some not useful function arguments
94e0623337a6 usb: cdns3: fix warning when USB_CDNS_HOST is not set
>Pawel
>
>>Peter
>>> Thanks,
>>> Pawel
>>>
>>> >> ---
>>> >> drivers/usb/cdns3/cdnsp-debug.h | 2 +-
>>> >> drivers/usb/cdns3/cdnsp-ep0.c | 13 ++++++-------
>>> >> drivers/usb/cdns3/cdnsp-gadget.c | 24 +++++++++---------------
>>> >> drivers/usb/cdns3/cdnsp-gadget.h | 13 +++++++------
>>> >> drivers/usb/cdns3/cdnsp-mem.c | 11 ++++++-----
>>> >> drivers/usb/cdns3/cdnsp-ring.c | 4 ++--
>>> >> drivers/usb/cdns3/cdnsp-trace.h | 2 +-
>>> >> 7 files changed, 32 insertions(+), 37 deletions(-)
>>> >>
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-debug.h b/drivers/usb/cdns3/cdnsp-debug.h
>>> >> index d6345d4d2911..a8776df2d4e0 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-debug.h
>>> >> +++ b/drivers/usb/cdns3/cdnsp-debug.h
>>> >> @@ -414,7 +414,7 @@ static inline const char *cdnsp_decode_slot_context(u32 info, u32 info2,
>>> >> s = "UNKNOWN speed";
>>> >> }
>>> >>
>>> >> - ret = sprintf(str, "%s Ctx Entries %ld",
>>> >> + ret = sprintf(str, "%s Ctx Entries %d",
>>> >> s, (info & LAST_CTX_MASK) >> 27);
>>> >>
>>> >> ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c
>>> >> index d55b59ed7381..e2b1bcb3f80e 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-ep0.c
>>> >> +++ b/drivers/usb/cdns3/cdnsp-ep0.c
>>> >> @@ -137,10 +137,8 @@ int cdnsp_status_stage(struct cdnsp_device *pdev)
>>> >> return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
>>> >> }
>>> >>
>>> >> -static int cdnsp_w_index_to_ep_index(__le32 wIndex)
>>> >> +static int cdnsp_w_index_to_ep_index(u16 wIndex)
>>> >> {
>>> >> - wIndex = le32_to_cpu(wIndex);
>>> >> -
>>> >> if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
>>> >> return 0;
>>> >>
>>> >> @@ -176,7 +174,8 @@ static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,
>>> >> */
>>> >> return cdnsp_ep0_delegate_req(pdev, ctrl);
>>> >> case USB_RECIP_ENDPOINT:
>>> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>>> >> + ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
>>> >> + pep = &pdev->eps[ep_sts];
>>> >> ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
>>> >>
>>> >> /* check if endpoint is stalled */
>>> >> @@ -305,10 +304,10 @@ static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
>>> >> int set)
>>> >> {
>>> >> struct cdnsp_ep *pep;
>>> >> - u32 wValue;
>>> >> + u16 wValue;
>>> >>
>>> >> wValue = le16_to_cpu(ctrl->wValue);
>>> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>>> >> + pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
>>> >>
>>> >> switch (wValue) {
>>> >> case USB_ENDPOINT_HALT:
>>> >> @@ -435,7 +434,7 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
>>> >> {
>>> >> struct usb_ctrlrequest *ctrl = &pdev->setup;
>>> >> int ret = 0;
>>> >> - __le16 len;
>>> >> + u16 len;
>>> >>
>>> >> trace_cdnsp_ctrl_req(ctrl);
>>> >>
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
>>> >> index 1668f72fdf30..f28f1508f049 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-gadget.c
>>> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
>>> >> @@ -491,7 +491,7 @@ static void cdnsp_invalidate_ep_events(struct cdnsp_device *pdev,
>>> >> struct cdnsp_segment *segment;
>>> >> union cdnsp_trb *event;
>>> >> u32 cycle_state;
>>> >> - __le32 data;
>>> >> + u32 data;
>>> >>
>>> >> event = pdev->event_ring->dequeue;
>>> >> segment = pdev->event_ring->deq_seg;
>>> >> @@ -527,9 +527,9 @@ int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev)
>>> >> dma_addr_t cmd_deq_dma;
>>> >> union cdnsp_trb *event;
>>> >> u32 cycle_state;
>>> >> - __le32 flags;
>>> >> int ret, val;
>>> >> u64 cmd_dma;
>>> >> + u32 flags;
>>> >>
>>> >> cmd_trb = pdev->cmd.command_trb;
>>> >> pdev->cmd.status = 0;
>>> >> @@ -1568,7 +1568,7 @@ static void cdnsp_get_ep_buffering(struct cdnsp_device *pdev,
>>> >> return;
>>> >> }
>>> >>
>>> >> - endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2;
>>> >> + endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2;
>>> >>
>>> >> /* Set to XBUF_TX_TAG_MASK_0 register. */
>>> >> reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32);
>>> >> @@ -1754,22 +1754,16 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)
>>> >> static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
>>> >> {
>>> >> void __iomem *reg = &pdev->cap_regs->hc_capbase;
>>> >> - struct cdnsp_rev_cap *rev_cap;
>>> >>
>>> >> reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
>>> >> - rev_cap = reg;
>>> >> -
>>> >> - pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision);
>>> >> - pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision);
>>> >> - pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported);
>>> >> - pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap);
>>> >> - pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size);
>>> >> - pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size);
>>> >> + pdev->rev_cap = reg;
>>> >>
>>> >> dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
>>> >> - pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision,
>>> >> - pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size,
>>> >> - pdev->rev_cap.tx_buff_size);
>>> >> + readl(&pdev->rev_cap->ctrl_revision),
>>> >> + readl(&pdev->rev_cap->rtl_revision),
>>> >> + readl(&pdev->rev_cap->ep_supported),
>>> >> + readl(&pdev->rev_cap->rx_buff_size),
>>> >> + readl(&pdev->rev_cap->tx_buff_size));
>>> >> }
>>> >>
>>> >> static int cdnsp_gen_setup(struct cdnsp_device *pdev)
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
>>> >> index 8eb1b85a08b4..6bbb26548c04 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-gadget.h
>>> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.h
>>> >> @@ -493,11 +493,12 @@ struct cdnsp_3xport_cap {
>>> >> #define CDNSP_VER_1 0x00000000
>>> >> #define CDNSP_VER_2 0x10000000
>>> >>
>>> >> -#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \
>>> >> - (BIT(ep_num) << ((dir) ? 0 : 16)))
>>> >> +#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
>>> >> + (readl(&(pdev)->rev_cap->ep_supported) & \
>>> >> + (BIT(ep_num) << ((dir) ? 0 : 16)))
>>> >>
>>> >> /**
>>> >> - * struct cdnsp_rev_cap - controller capabilities .
>>> >> + * struct cdnsp_rev_cap - controller capabilities.
>>> >> * @ext_cap: Header for RTL Revision Extended Capability.
>>> >> * @rtl_revision: RTL revision.
>>> >> * @rx_buff_size: Rx buffer sizes.
>>> >> @@ -594,7 +595,7 @@ struct cdnsp_slot_ctx {
>>> >> #define DEV_SPEED GENMASK(23, 20)
>>> >> #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20)
>>> >> /* Index of the last valid endpoint context in this device context - 27:31. */
>>> >> -#define LAST_CTX_MASK GENMASK(31, 27)
>>> >> +#define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27))
>>> >> #define LAST_CTX(p) ((p) << 27)
>>> >> #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
>>> >> #define SLOT_FLAG BIT(0)
>>> >> @@ -1351,9 +1352,9 @@ struct cdnsp_port {
>>> >> * @ir_set: Current interrupter register set.
>>> >> * @port20_regs: Port 2.0 Peripheral Configuration Registers.
>>> >> * @port3x_regs: USB3.x Port Peripheral Configuration Registers.
>>> >> + * @rev_cap: Controller Capabilities Registers.
>>> >> * @hcs_params1: Cached register copies of read-only HCSPARAMS1
>>> >> * @hcc_params: Cached register copies of read-only HCCPARAMS1
>>> >> - * @rev_cap: Controller capability.
>>> >> * @setup: Temporary buffer for setup packet.
>>> >> * @ep0_preq: Internal allocated request used during enumeration.
>>> >> * @ep0_stage: ep0 stage during enumeration process.
>>> >> @@ -1402,12 +1403,12 @@ struct cdnsp_device {
>>> >> struct cdnsp_intr_reg __iomem *ir_set;
>>> >> struct cdnsp_20port_cap __iomem *port20_regs;
>>> >> struct cdnsp_3xport_cap __iomem *port3x_regs;
>>> >> + struct cdnsp_rev_cap __iomem *rev_cap;
>>> >>
>>> >> /* Cached register copies of read-only CDNSP data */
>>> >> __u32 hcs_params1;
>>> >> __u32 hcs_params3;
>>> >> __u32 hcc_params;
>>> >> - struct cdnsp_rev_cap rev_cap;
>>> >> /* Lock used in interrupt thread context. */
>>> >> spinlock_t lock;
>>> >> struct usb_ctrlrequest setup;
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
>>> >> index 4c7d77fb097e..7a84e928710e 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-mem.c
>>> >> +++ b/drivers/usb/cdns3/cdnsp-mem.c
>>> >> @@ -759,8 +759,9 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev)
>>> >>
>>> >> port = DEV_PORT(pdev->active_port->port_num);
>>> >> slot_ctx->dev_port |= cpu_to_le32(port);
>>> >> - slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK);
>>> >> - ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8);
>>> >> + slot_ctx->dev_state = cpu_to_le32((pdev->device_address &
>>> >> + DEV_ADDR_MASK));
>>> >> + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8));
>>> >> ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
>>> >> ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
>>> >> max_packets);
>>> >> @@ -925,7 +926,7 @@ static u32 cdnsp_get_max_esit_payload(struct usb_gadget *g,
>>> >> /* SuperSpeedPlus Isoc ep sending over 48k per EIST. */
>>> >> if (g->speed >= USB_SPEED_SUPER_PLUS &&
>>> >> USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes))
>>> >> - return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>>> >> + return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>>> >> /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */
>>> >> else if (g->speed >= USB_SPEED_SUPER)
>>> >> return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>>> >> @@ -1184,11 +1185,11 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)
>>> >>
>>> >> trace_cdnsp_init("Found USB 2.0 ports and USB 3.0 ports.");
>>> >>
>>> >> - pdev->usb2_port.regs = (struct cdnsp_port_regs *)
>>> >> + pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *)
>>> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>>> >> (pdev->usb2_port.port_num - 1));
>>> >>
>>> >> - pdev->usb3_port.regs = (struct cdnsp_port_regs *)
>>> >> + pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *)
>>> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>>> >> (pdev->usb3_port.port_num - 1));
>>> >>
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
>>> >> index 874d9ff5406c..e15e13ba27dc 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-ring.c
>>> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c
>>> >> @@ -1432,7 +1432,7 @@ static bool cdnsp_handle_event(struct cdnsp_device *pdev)
>>> >> unsigned int comp_code;
>>> >> union cdnsp_trb *event;
>>> >> bool update_ptrs = true;
>>> >> - __le32 cycle_bit;
>>> >> + u32 cycle_bit;
>>> >> int ret = 0;
>>> >> u32 flags;
>>> >>
>>> >> @@ -2198,7 +2198,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
>>> >> * inverted in the first TDs isoc TRB.
>>> >> */
>>> >> field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
>>> >> - !start_cycle | TRB_SIA | TRB_TBC(burst_count);
>>> >> + start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
>>> >>
>>> >> /* Fill the rest of the TRB fields, and remaining normal TRBs. */
>>> >> for (i = 0; i < trbs_per_td; i++) {
>>> >> diff --git a/drivers/usb/cdns3/cdnsp-trace.h b/drivers/usb/cdns3/cdnsp-trace.h
>>> >> index b68e282464d2..a9de1daadf07 100644
>>> >> --- a/drivers/usb/cdns3/cdnsp-trace.h
>>> >> +++ b/drivers/usb/cdns3/cdnsp-trace.h
>>> >> @@ -620,7 +620,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_slot_ctx,
>>> >> TP_fast_assign(
>>> >> __entry->info = le32_to_cpu(ctx->dev_info);
>>> >> __entry->info2 = le32_to_cpu(ctx->dev_port);
>>> >> - __entry->int_target = le64_to_cpu(ctx->int_target);
>>> >> + __entry->int_target = le32_to_cpu(ctx->int_target);
>>> >> __entry->state = le32_to_cpu(ctx->dev_state);
>>> >> ),
>>> >> TP_printk("%s", cdnsp_decode_slot_context(__entry->info,
>>> >> --
>>> >> 2.17.1
>>> >>
>>>
>>> --
>>>
>>> Regards
>>> Pawel Laszcak
>>
>>--
>>
>>Thanks,
>>Peter Chen
^ permalink raw reply
* RE: [PATCH 1/2] usb: cdnsp: Fixes for sparse warnings
From: Pawel Laszczak @ 2020-12-15 6:14 UTC (permalink / raw)
To: Peter Chen
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Rahul Kumar
In-Reply-To: <20201215060206.GB18223@b29397-desktop>
>On 20-12-15 05:27:38, Pawel Laszczak wrote:
>> >
>> >
>> >On 20-12-14 13:03:44, Pawel Laszczak wrote:
>> >> Patch fixes all sparse warnings in cdsnp driver.
>> >>
>> >> It fixes the following warnings:
>> >> cdnsp-ring.c:1441: warning: incorrect type in assignment
>> >> cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
>> >> cdnsp-ring.c:2200: warning: dubious: x | !y
>> >> cdnsp-gadget.c:501: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:509: warning: invalid assignment: |=
>> >> cdnsp-gadget.c:510: warning: cast from restricted __le32
>> >> cdnsp-gadget.c:558: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:1571: warning: incorrect type in argument 1
>> >> cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
>> >> cdnsp-gadget.c:1760: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1762: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1763: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1764: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1765: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1766: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:1767: warning: incorrect type in assignment
>> >> cdnsp-gadget.c:458: warning: cast truncates bits from constant value
>> >> (ffffffff07ffffff becomes 7ffffff)
>> >> cdnsp-gadget.c:666: warning: cast truncates bits from constant value
>> >> (ffffffff07ffffff becomes 7ffffff)
>> >> cdnsp-mem.c:762: warning: incorrect type in assignment
>> >> cdnsp-mem.c:763: warning: incorrect type in assignment
>> >> cdnsp-mem.c:928: warning: cast from restricted __le16
>> >> cdnsp-mem.c:1187: warning: incorrect type in assignment
>> >> cdnsp-mem.c:1191: warning: incorrect type in assignment
>> >> cdnsp-ep0.c:142: warning: incorrect type in assignment
>> >> cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
>> >> cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
>> >> cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
>> >> cdnsp-ep0.c:179: warning: incorrect type in argument 1
>> >> cdnsp-ep0.c:311: warning: incorrect type in argument 1
>> >> cdnsp-ep0.c:469: warning: incorrect type in assignment
>> >> cdnsp-trace.h:611:1: warning: cast from restricted __le32
>> >>
>> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> >> Reported-by: kernel test robot <lkp@intel.com>
>> >
>> >Hi Pawel,
>> >
>> >The Reported-by tag should be above your Sob tag, I will change it.
>> >Except the patch reported build error by kernel test robot, I will apply
>> >your other four patches after finishing the compile test.
>> >
>> >Peter
>>
>> Hi Peter,
>>
>> I'm going to fix the "usb: cdns3: Adds missing __iomem markers" today.
>> I haven't seen any issue on ARCH=parisc. Maybe it's some specific riscv arch issue.
>>
>> I believe that:
>> [auto build test WARNING on next-20201211]
>> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
>>
>> is not the problem. I based on peter.chen-usb/for-usb-next.
>>
>> Also I can't open the url from kernel test robot report.
>> Maybe there is some temporary issue with server.
>>
>
>Thanks for checking it, I have already pushed your other four patches.
>Besides, there is still a build error issue for new cdns3 driver.
>
>https://urldefense.com/v3/__https://www.spinics.net/lists/linux-
>usb/msg206073.html__;!!EHscmS1ygiU1lA!X6rYk64ILtzjyHW903LAhBRjMKi9C2eyJWEXVlEZm0ly2BiNzY2wK46Ulq7q5w$
>
Did you applied: [PATCH] usb: cdnsp: Fix for undefined reference to `usb_hcd_is_primary_hcd' ?
Pawel
>Peter
>> Thanks,
>> Pawel
>>
>> >> ---
>> >> drivers/usb/cdns3/cdnsp-debug.h | 2 +-
>> >> drivers/usb/cdns3/cdnsp-ep0.c | 13 ++++++-------
>> >> drivers/usb/cdns3/cdnsp-gadget.c | 24 +++++++++---------------
>> >> drivers/usb/cdns3/cdnsp-gadget.h | 13 +++++++------
>> >> drivers/usb/cdns3/cdnsp-mem.c | 11 ++++++-----
>> >> drivers/usb/cdns3/cdnsp-ring.c | 4 ++--
>> >> drivers/usb/cdns3/cdnsp-trace.h | 2 +-
>> >> 7 files changed, 32 insertions(+), 37 deletions(-)
>> >>
>> >> diff --git a/drivers/usb/cdns3/cdnsp-debug.h b/drivers/usb/cdns3/cdnsp-debug.h
>> >> index d6345d4d2911..a8776df2d4e0 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-debug.h
>> >> +++ b/drivers/usb/cdns3/cdnsp-debug.h
>> >> @@ -414,7 +414,7 @@ static inline const char *cdnsp_decode_slot_context(u32 info, u32 info2,
>> >> s = "UNKNOWN speed";
>> >> }
>> >>
>> >> - ret = sprintf(str, "%s Ctx Entries %ld",
>> >> + ret = sprintf(str, "%s Ctx Entries %d",
>> >> s, (info & LAST_CTX_MASK) >> 27);
>> >>
>> >> ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
>> >> diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c
>> >> index d55b59ed7381..e2b1bcb3f80e 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-ep0.c
>> >> +++ b/drivers/usb/cdns3/cdnsp-ep0.c
>> >> @@ -137,10 +137,8 @@ int cdnsp_status_stage(struct cdnsp_device *pdev)
>> >> return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
>> >> }
>> >>
>> >> -static int cdnsp_w_index_to_ep_index(__le32 wIndex)
>> >> +static int cdnsp_w_index_to_ep_index(u16 wIndex)
>> >> {
>> >> - wIndex = le32_to_cpu(wIndex);
>> >> -
>> >> if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
>> >> return 0;
>> >>
>> >> @@ -176,7 +174,8 @@ static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,
>> >> */
>> >> return cdnsp_ep0_delegate_req(pdev, ctrl);
>> >> case USB_RECIP_ENDPOINT:
>> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>> >> + ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
>> >> + pep = &pdev->eps[ep_sts];
>> >> ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
>> >>
>> >> /* check if endpoint is stalled */
>> >> @@ -305,10 +304,10 @@ static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
>> >> int set)
>> >> {
>> >> struct cdnsp_ep *pep;
>> >> - u32 wValue;
>> >> + u16 wValue;
>> >>
>> >> wValue = le16_to_cpu(ctrl->wValue);
>> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>> >> + pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
>> >>
>> >> switch (wValue) {
>> >> case USB_ENDPOINT_HALT:
>> >> @@ -435,7 +434,7 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
>> >> {
>> >> struct usb_ctrlrequest *ctrl = &pdev->setup;
>> >> int ret = 0;
>> >> - __le16 len;
>> >> + u16 len;
>> >>
>> >> trace_cdnsp_ctrl_req(ctrl);
>> >>
>> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
>> >> index 1668f72fdf30..f28f1508f049 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-gadget.c
>> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
>> >> @@ -491,7 +491,7 @@ static void cdnsp_invalidate_ep_events(struct cdnsp_device *pdev,
>> >> struct cdnsp_segment *segment;
>> >> union cdnsp_trb *event;
>> >> u32 cycle_state;
>> >> - __le32 data;
>> >> + u32 data;
>> >>
>> >> event = pdev->event_ring->dequeue;
>> >> segment = pdev->event_ring->deq_seg;
>> >> @@ -527,9 +527,9 @@ int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev)
>> >> dma_addr_t cmd_deq_dma;
>> >> union cdnsp_trb *event;
>> >> u32 cycle_state;
>> >> - __le32 flags;
>> >> int ret, val;
>> >> u64 cmd_dma;
>> >> + u32 flags;
>> >>
>> >> cmd_trb = pdev->cmd.command_trb;
>> >> pdev->cmd.status = 0;
>> >> @@ -1568,7 +1568,7 @@ static void cdnsp_get_ep_buffering(struct cdnsp_device *pdev,
>> >> return;
>> >> }
>> >>
>> >> - endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2;
>> >> + endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2;
>> >>
>> >> /* Set to XBUF_TX_TAG_MASK_0 register. */
>> >> reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32);
>> >> @@ -1754,22 +1754,16 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)
>> >> static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
>> >> {
>> >> void __iomem *reg = &pdev->cap_regs->hc_capbase;
>> >> - struct cdnsp_rev_cap *rev_cap;
>> >>
>> >> reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
>> >> - rev_cap = reg;
>> >> -
>> >> - pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision);
>> >> - pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision);
>> >> - pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported);
>> >> - pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap);
>> >> - pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size);
>> >> - pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size);
>> >> + pdev->rev_cap = reg;
>> >>
>> >> dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
>> >> - pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision,
>> >> - pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size,
>> >> - pdev->rev_cap.tx_buff_size);
>> >> + readl(&pdev->rev_cap->ctrl_revision),
>> >> + readl(&pdev->rev_cap->rtl_revision),
>> >> + readl(&pdev->rev_cap->ep_supported),
>> >> + readl(&pdev->rev_cap->rx_buff_size),
>> >> + readl(&pdev->rev_cap->tx_buff_size));
>> >> }
>> >>
>> >> static int cdnsp_gen_setup(struct cdnsp_device *pdev)
>> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
>> >> index 8eb1b85a08b4..6bbb26548c04 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-gadget.h
>> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.h
>> >> @@ -493,11 +493,12 @@ struct cdnsp_3xport_cap {
>> >> #define CDNSP_VER_1 0x00000000
>> >> #define CDNSP_VER_2 0x10000000
>> >>
>> >> -#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \
>> >> - (BIT(ep_num) << ((dir) ? 0 : 16)))
>> >> +#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
>> >> + (readl(&(pdev)->rev_cap->ep_supported) & \
>> >> + (BIT(ep_num) << ((dir) ? 0 : 16)))
>> >>
>> >> /**
>> >> - * struct cdnsp_rev_cap - controller capabilities .
>> >> + * struct cdnsp_rev_cap - controller capabilities.
>> >> * @ext_cap: Header for RTL Revision Extended Capability.
>> >> * @rtl_revision: RTL revision.
>> >> * @rx_buff_size: Rx buffer sizes.
>> >> @@ -594,7 +595,7 @@ struct cdnsp_slot_ctx {
>> >> #define DEV_SPEED GENMASK(23, 20)
>> >> #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20)
>> >> /* Index of the last valid endpoint context in this device context - 27:31. */
>> >> -#define LAST_CTX_MASK GENMASK(31, 27)
>> >> +#define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27))
>> >> #define LAST_CTX(p) ((p) << 27)
>> >> #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
>> >> #define SLOT_FLAG BIT(0)
>> >> @@ -1351,9 +1352,9 @@ struct cdnsp_port {
>> >> * @ir_set: Current interrupter register set.
>> >> * @port20_regs: Port 2.0 Peripheral Configuration Registers.
>> >> * @port3x_regs: USB3.x Port Peripheral Configuration Registers.
>> >> + * @rev_cap: Controller Capabilities Registers.
>> >> * @hcs_params1: Cached register copies of read-only HCSPARAMS1
>> >> * @hcc_params: Cached register copies of read-only HCCPARAMS1
>> >> - * @rev_cap: Controller capability.
>> >> * @setup: Temporary buffer for setup packet.
>> >> * @ep0_preq: Internal allocated request used during enumeration.
>> >> * @ep0_stage: ep0 stage during enumeration process.
>> >> @@ -1402,12 +1403,12 @@ struct cdnsp_device {
>> >> struct cdnsp_intr_reg __iomem *ir_set;
>> >> struct cdnsp_20port_cap __iomem *port20_regs;
>> >> struct cdnsp_3xport_cap __iomem *port3x_regs;
>> >> + struct cdnsp_rev_cap __iomem *rev_cap;
>> >>
>> >> /* Cached register copies of read-only CDNSP data */
>> >> __u32 hcs_params1;
>> >> __u32 hcs_params3;
>> >> __u32 hcc_params;
>> >> - struct cdnsp_rev_cap rev_cap;
>> >> /* Lock used in interrupt thread context. */
>> >> spinlock_t lock;
>> >> struct usb_ctrlrequest setup;
>> >> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
>> >> index 4c7d77fb097e..7a84e928710e 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-mem.c
>> >> +++ b/drivers/usb/cdns3/cdnsp-mem.c
>> >> @@ -759,8 +759,9 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev)
>> >>
>> >> port = DEV_PORT(pdev->active_port->port_num);
>> >> slot_ctx->dev_port |= cpu_to_le32(port);
>> >> - slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK);
>> >> - ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8);
>> >> + slot_ctx->dev_state = cpu_to_le32((pdev->device_address &
>> >> + DEV_ADDR_MASK));
>> >> + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8));
>> >> ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
>> >> ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
>> >> max_packets);
>> >> @@ -925,7 +926,7 @@ static u32 cdnsp_get_max_esit_payload(struct usb_gadget *g,
>> >> /* SuperSpeedPlus Isoc ep sending over 48k per EIST. */
>> >> if (g->speed >= USB_SPEED_SUPER_PLUS &&
>> >> USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes))
>> >> - return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> >> + return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> >> /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */
>> >> else if (g->speed >= USB_SPEED_SUPER)
>> >> return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> >> @@ -1184,11 +1185,11 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)
>> >>
>> >> trace_cdnsp_init("Found USB 2.0 ports and USB 3.0 ports.");
>> >>
>> >> - pdev->usb2_port.regs = (struct cdnsp_port_regs *)
>> >> + pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *)
>> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>> >> (pdev->usb2_port.port_num - 1));
>> >>
>> >> - pdev->usb3_port.regs = (struct cdnsp_port_regs *)
>> >> + pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *)
>> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>> >> (pdev->usb3_port.port_num - 1));
>> >>
>> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
>> >> index 874d9ff5406c..e15e13ba27dc 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-ring.c
>> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c
>> >> @@ -1432,7 +1432,7 @@ static bool cdnsp_handle_event(struct cdnsp_device *pdev)
>> >> unsigned int comp_code;
>> >> union cdnsp_trb *event;
>> >> bool update_ptrs = true;
>> >> - __le32 cycle_bit;
>> >> + u32 cycle_bit;
>> >> int ret = 0;
>> >> u32 flags;
>> >>
>> >> @@ -2198,7 +2198,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
>> >> * inverted in the first TDs isoc TRB.
>> >> */
>> >> field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
>> >> - !start_cycle | TRB_SIA | TRB_TBC(burst_count);
>> >> + start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
>> >>
>> >> /* Fill the rest of the TRB fields, and remaining normal TRBs. */
>> >> for (i = 0; i < trbs_per_td; i++) {
>> >> diff --git a/drivers/usb/cdns3/cdnsp-trace.h b/drivers/usb/cdns3/cdnsp-trace.h
>> >> index b68e282464d2..a9de1daadf07 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-trace.h
>> >> +++ b/drivers/usb/cdns3/cdnsp-trace.h
>> >> @@ -620,7 +620,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_slot_ctx,
>> >> TP_fast_assign(
>> >> __entry->info = le32_to_cpu(ctx->dev_info);
>> >> __entry->info2 = le32_to_cpu(ctx->dev_port);
>> >> - __entry->int_target = le64_to_cpu(ctx->int_target);
>> >> + __entry->int_target = le32_to_cpu(ctx->int_target);
>> >> __entry->state = le32_to_cpu(ctx->dev_state);
>> >> ),
>> >> TP_printk("%s", cdnsp_decode_slot_context(__entry->info,
>> >> --
>> >> 2.17.1
>> >>
>>
>> --
>>
>> Regards
>> Pawel Laszcak
>
>--
>
>Thanks,
>Peter Chen
^ permalink raw reply
* Re: [PATCH 1/2] usb: cdnsp: Fixes for sparse warnings
From: Peter Chen @ 2020-12-15 6:02 UTC (permalink / raw)
To: Pawel Laszczak
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Rahul Kumar
In-Reply-To: <BYAPR07MB5381FB3C8AF9039D8C30E8AFDDC60@BYAPR07MB5381.namprd07.prod.outlook.com>
On 20-12-15 05:27:38, Pawel Laszczak wrote:
> >
> >
> >On 20-12-14 13:03:44, Pawel Laszczak wrote:
> >> Patch fixes all sparse warnings in cdsnp driver.
> >>
> >> It fixes the following warnings:
> >> cdnsp-ring.c:1441: warning: incorrect type in assignment
> >> cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
> >> cdnsp-ring.c:2200: warning: dubious: x | !y
> >> cdnsp-gadget.c:501: warning: incorrect type in assignment
> >> cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:509: warning: invalid assignment: |=
> >> cdnsp-gadget.c:510: warning: cast from restricted __le32
> >> cdnsp-gadget.c:558: warning: incorrect type in assignment
> >> cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:1571: warning: incorrect type in argument 1
> >> cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
> >> cdnsp-gadget.c:1760: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1762: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1763: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1764: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1765: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1766: warning: incorrect type in assignment
> >> cdnsp-gadget.c:1767: warning: incorrect type in assignment
> >> cdnsp-gadget.c:458: warning: cast truncates bits from constant value
> >> (ffffffff07ffffff becomes 7ffffff)
> >> cdnsp-gadget.c:666: warning: cast truncates bits from constant value
> >> (ffffffff07ffffff becomes 7ffffff)
> >> cdnsp-mem.c:762: warning: incorrect type in assignment
> >> cdnsp-mem.c:763: warning: incorrect type in assignment
> >> cdnsp-mem.c:928: warning: cast from restricted __le16
> >> cdnsp-mem.c:1187: warning: incorrect type in assignment
> >> cdnsp-mem.c:1191: warning: incorrect type in assignment
> >> cdnsp-ep0.c:142: warning: incorrect type in assignment
> >> cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
> >> cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
> >> cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
> >> cdnsp-ep0.c:179: warning: incorrect type in argument 1
> >> cdnsp-ep0.c:311: warning: incorrect type in argument 1
> >> cdnsp-ep0.c:469: warning: incorrect type in assignment
> >> cdnsp-trace.h:611:1: warning: cast from restricted __le32
> >>
> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> >> Reported-by: kernel test robot <lkp@intel.com>
> >
> >Hi Pawel,
> >
> >The Reported-by tag should be above your Sob tag, I will change it.
> >Except the patch reported build error by kernel test robot, I will apply
> >your other four patches after finishing the compile test.
> >
> >Peter
>
> Hi Peter,
>
> I'm going to fix the "usb: cdns3: Adds missing __iomem markers" today.
> I haven't seen any issue on ARCH=parisc. Maybe it's some specific riscv arch issue.
>
> I believe that:
> [auto build test WARNING on next-20201211]
> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
>
> is not the problem. I based on peter.chen-usb/for-usb-next.
>
> Also I can't open the url from kernel test robot report.
> Maybe there is some temporary issue with server.
>
Thanks for checking it, I have already pushed your other four patches.
Besides, there is still a build error issue for new cdns3 driver.
https://www.spinics.net/lists/linux-usb/msg206073.html
Peter
> Thanks,
> Pawel
>
> >> ---
> >> drivers/usb/cdns3/cdnsp-debug.h | 2 +-
> >> drivers/usb/cdns3/cdnsp-ep0.c | 13 ++++++-------
> >> drivers/usb/cdns3/cdnsp-gadget.c | 24 +++++++++---------------
> >> drivers/usb/cdns3/cdnsp-gadget.h | 13 +++++++------
> >> drivers/usb/cdns3/cdnsp-mem.c | 11 ++++++-----
> >> drivers/usb/cdns3/cdnsp-ring.c | 4 ++--
> >> drivers/usb/cdns3/cdnsp-trace.h | 2 +-
> >> 7 files changed, 32 insertions(+), 37 deletions(-)
> >>
> >> diff --git a/drivers/usb/cdns3/cdnsp-debug.h b/drivers/usb/cdns3/cdnsp-debug.h
> >> index d6345d4d2911..a8776df2d4e0 100644
> >> --- a/drivers/usb/cdns3/cdnsp-debug.h
> >> +++ b/drivers/usb/cdns3/cdnsp-debug.h
> >> @@ -414,7 +414,7 @@ static inline const char *cdnsp_decode_slot_context(u32 info, u32 info2,
> >> s = "UNKNOWN speed";
> >> }
> >>
> >> - ret = sprintf(str, "%s Ctx Entries %ld",
> >> + ret = sprintf(str, "%s Ctx Entries %d",
> >> s, (info & LAST_CTX_MASK) >> 27);
> >>
> >> ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
> >> diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c
> >> index d55b59ed7381..e2b1bcb3f80e 100644
> >> --- a/drivers/usb/cdns3/cdnsp-ep0.c
> >> +++ b/drivers/usb/cdns3/cdnsp-ep0.c
> >> @@ -137,10 +137,8 @@ int cdnsp_status_stage(struct cdnsp_device *pdev)
> >> return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
> >> }
> >>
> >> -static int cdnsp_w_index_to_ep_index(__le32 wIndex)
> >> +static int cdnsp_w_index_to_ep_index(u16 wIndex)
> >> {
> >> - wIndex = le32_to_cpu(wIndex);
> >> -
> >> if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
> >> return 0;
> >>
> >> @@ -176,7 +174,8 @@ static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,
> >> */
> >> return cdnsp_ep0_delegate_req(pdev, ctrl);
> >> case USB_RECIP_ENDPOINT:
> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
> >> + ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
> >> + pep = &pdev->eps[ep_sts];
> >> ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
> >>
> >> /* check if endpoint is stalled */
> >> @@ -305,10 +304,10 @@ static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
> >> int set)
> >> {
> >> struct cdnsp_ep *pep;
> >> - u32 wValue;
> >> + u16 wValue;
> >>
> >> wValue = le16_to_cpu(ctrl->wValue);
> >> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
> >> + pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
> >>
> >> switch (wValue) {
> >> case USB_ENDPOINT_HALT:
> >> @@ -435,7 +434,7 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
> >> {
> >> struct usb_ctrlrequest *ctrl = &pdev->setup;
> >> int ret = 0;
> >> - __le16 len;
> >> + u16 len;
> >>
> >> trace_cdnsp_ctrl_req(ctrl);
> >>
> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> >> index 1668f72fdf30..f28f1508f049 100644
> >> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> >> @@ -491,7 +491,7 @@ static void cdnsp_invalidate_ep_events(struct cdnsp_device *pdev,
> >> struct cdnsp_segment *segment;
> >> union cdnsp_trb *event;
> >> u32 cycle_state;
> >> - __le32 data;
> >> + u32 data;
> >>
> >> event = pdev->event_ring->dequeue;
> >> segment = pdev->event_ring->deq_seg;
> >> @@ -527,9 +527,9 @@ int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev)
> >> dma_addr_t cmd_deq_dma;
> >> union cdnsp_trb *event;
> >> u32 cycle_state;
> >> - __le32 flags;
> >> int ret, val;
> >> u64 cmd_dma;
> >> + u32 flags;
> >>
> >> cmd_trb = pdev->cmd.command_trb;
> >> pdev->cmd.status = 0;
> >> @@ -1568,7 +1568,7 @@ static void cdnsp_get_ep_buffering(struct cdnsp_device *pdev,
> >> return;
> >> }
> >>
> >> - endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2;
> >> + endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2;
> >>
> >> /* Set to XBUF_TX_TAG_MASK_0 register. */
> >> reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32);
> >> @@ -1754,22 +1754,16 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)
> >> static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
> >> {
> >> void __iomem *reg = &pdev->cap_regs->hc_capbase;
> >> - struct cdnsp_rev_cap *rev_cap;
> >>
> >> reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
> >> - rev_cap = reg;
> >> -
> >> - pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision);
> >> - pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision);
> >> - pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported);
> >> - pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap);
> >> - pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size);
> >> - pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size);
> >> + pdev->rev_cap = reg;
> >>
> >> dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
> >> - pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision,
> >> - pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size,
> >> - pdev->rev_cap.tx_buff_size);
> >> + readl(&pdev->rev_cap->ctrl_revision),
> >> + readl(&pdev->rev_cap->rtl_revision),
> >> + readl(&pdev->rev_cap->ep_supported),
> >> + readl(&pdev->rev_cap->rx_buff_size),
> >> + readl(&pdev->rev_cap->tx_buff_size));
> >> }
> >>
> >> static int cdnsp_gen_setup(struct cdnsp_device *pdev)
> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
> >> index 8eb1b85a08b4..6bbb26548c04 100644
> >> --- a/drivers/usb/cdns3/cdnsp-gadget.h
> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.h
> >> @@ -493,11 +493,12 @@ struct cdnsp_3xport_cap {
> >> #define CDNSP_VER_1 0x00000000
> >> #define CDNSP_VER_2 0x10000000
> >>
> >> -#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \
> >> - (BIT(ep_num) << ((dir) ? 0 : 16)))
> >> +#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
> >> + (readl(&(pdev)->rev_cap->ep_supported) & \
> >> + (BIT(ep_num) << ((dir) ? 0 : 16)))
> >>
> >> /**
> >> - * struct cdnsp_rev_cap - controller capabilities .
> >> + * struct cdnsp_rev_cap - controller capabilities.
> >> * @ext_cap: Header for RTL Revision Extended Capability.
> >> * @rtl_revision: RTL revision.
> >> * @rx_buff_size: Rx buffer sizes.
> >> @@ -594,7 +595,7 @@ struct cdnsp_slot_ctx {
> >> #define DEV_SPEED GENMASK(23, 20)
> >> #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20)
> >> /* Index of the last valid endpoint context in this device context - 27:31. */
> >> -#define LAST_CTX_MASK GENMASK(31, 27)
> >> +#define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27))
> >> #define LAST_CTX(p) ((p) << 27)
> >> #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
> >> #define SLOT_FLAG BIT(0)
> >> @@ -1351,9 +1352,9 @@ struct cdnsp_port {
> >> * @ir_set: Current interrupter register set.
> >> * @port20_regs: Port 2.0 Peripheral Configuration Registers.
> >> * @port3x_regs: USB3.x Port Peripheral Configuration Registers.
> >> + * @rev_cap: Controller Capabilities Registers.
> >> * @hcs_params1: Cached register copies of read-only HCSPARAMS1
> >> * @hcc_params: Cached register copies of read-only HCCPARAMS1
> >> - * @rev_cap: Controller capability.
> >> * @setup: Temporary buffer for setup packet.
> >> * @ep0_preq: Internal allocated request used during enumeration.
> >> * @ep0_stage: ep0 stage during enumeration process.
> >> @@ -1402,12 +1403,12 @@ struct cdnsp_device {
> >> struct cdnsp_intr_reg __iomem *ir_set;
> >> struct cdnsp_20port_cap __iomem *port20_regs;
> >> struct cdnsp_3xport_cap __iomem *port3x_regs;
> >> + struct cdnsp_rev_cap __iomem *rev_cap;
> >>
> >> /* Cached register copies of read-only CDNSP data */
> >> __u32 hcs_params1;
> >> __u32 hcs_params3;
> >> __u32 hcc_params;
> >> - struct cdnsp_rev_cap rev_cap;
> >> /* Lock used in interrupt thread context. */
> >> spinlock_t lock;
> >> struct usb_ctrlrequest setup;
> >> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
> >> index 4c7d77fb097e..7a84e928710e 100644
> >> --- a/drivers/usb/cdns3/cdnsp-mem.c
> >> +++ b/drivers/usb/cdns3/cdnsp-mem.c
> >> @@ -759,8 +759,9 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev)
> >>
> >> port = DEV_PORT(pdev->active_port->port_num);
> >> slot_ctx->dev_port |= cpu_to_le32(port);
> >> - slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK);
> >> - ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8);
> >> + slot_ctx->dev_state = cpu_to_le32((pdev->device_address &
> >> + DEV_ADDR_MASK));
> >> + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8));
> >> ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
> >> ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
> >> max_packets);
> >> @@ -925,7 +926,7 @@ static u32 cdnsp_get_max_esit_payload(struct usb_gadget *g,
> >> /* SuperSpeedPlus Isoc ep sending over 48k per EIST. */
> >> if (g->speed >= USB_SPEED_SUPER_PLUS &&
> >> USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes))
> >> - return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
> >> + return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
> >> /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */
> >> else if (g->speed >= USB_SPEED_SUPER)
> >> return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
> >> @@ -1184,11 +1185,11 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)
> >>
> >> trace_cdnsp_init("Found USB 2.0 ports and USB 3.0 ports.");
> >>
> >> - pdev->usb2_port.regs = (struct cdnsp_port_regs *)
> >> + pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *)
> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
> >> (pdev->usb2_port.port_num - 1));
> >>
> >> - pdev->usb3_port.regs = (struct cdnsp_port_regs *)
> >> + pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *)
> >> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
> >> (pdev->usb3_port.port_num - 1));
> >>
> >> diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
> >> index 874d9ff5406c..e15e13ba27dc 100644
> >> --- a/drivers/usb/cdns3/cdnsp-ring.c
> >> +++ b/drivers/usb/cdns3/cdnsp-ring.c
> >> @@ -1432,7 +1432,7 @@ static bool cdnsp_handle_event(struct cdnsp_device *pdev)
> >> unsigned int comp_code;
> >> union cdnsp_trb *event;
> >> bool update_ptrs = true;
> >> - __le32 cycle_bit;
> >> + u32 cycle_bit;
> >> int ret = 0;
> >> u32 flags;
> >>
> >> @@ -2198,7 +2198,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
> >> * inverted in the first TDs isoc TRB.
> >> */
> >> field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
> >> - !start_cycle | TRB_SIA | TRB_TBC(burst_count);
> >> + start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
> >>
> >> /* Fill the rest of the TRB fields, and remaining normal TRBs. */
> >> for (i = 0; i < trbs_per_td; i++) {
> >> diff --git a/drivers/usb/cdns3/cdnsp-trace.h b/drivers/usb/cdns3/cdnsp-trace.h
> >> index b68e282464d2..a9de1daadf07 100644
> >> --- a/drivers/usb/cdns3/cdnsp-trace.h
> >> +++ b/drivers/usb/cdns3/cdnsp-trace.h
> >> @@ -620,7 +620,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_slot_ctx,
> >> TP_fast_assign(
> >> __entry->info = le32_to_cpu(ctx->dev_info);
> >> __entry->info2 = le32_to_cpu(ctx->dev_port);
> >> - __entry->int_target = le64_to_cpu(ctx->int_target);
> >> + __entry->int_target = le32_to_cpu(ctx->int_target);
> >> __entry->state = le32_to_cpu(ctx->dev_state);
> >> ),
> >> TP_printk("%s", cdnsp_decode_slot_context(__entry->info,
> >> --
> >> 2.17.1
> >>
>
> --
>
> Regards
> Pawel Laszcak
--
Thanks,
Peter Chen
^ permalink raw reply
* Re: [PATCH] usb: cdns3: Adds missing __iomem markers
From: Peter Chen @ 2020-12-15 5:58 UTC (permalink / raw)
To: kernel test robot
Cc: Pawel Laszczak, kbuild-all@lists.01.org, rogerq@ti.com,
a-govindraju@ti.com, nsekhar@ti.com, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
kurahul@cadence.com
In-Reply-To: <202012142359.ZshcbBoP-lkp@intel.com>
On 20-12-14 23:35:56, kernel test robot wrote:
> Hi Pawel,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on next-20201211]
> [cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
Sorry, I changed the branch name to reflect the branch does not only queue
chipidea USB patches.
next branch: for-usb-next
fixes branch: for-usb-fixes
Peter
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fdocs%2Fgit-format-patch&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Cy3huYNzWiJ57OKmzmaleCT14gcFr8RyYDnqTfZWNG4%3D&reserved=0]
>
> url: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommits%2FPawel-Laszczak%2Fusb-cdns3-Adds-missing-__iomem-markers%2F20201214-205353&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=x5XoDUUskeGteTFaPjgS24Hrbb712XqMqaIkqwXWu14%3D&reserved=0
> base: 3cc2bd440f2171f093b3a8480a4b54d8c270ed38
> config: riscv-allmodconfig (attached as .config)
> compiler: riscv64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fintel%2Flkp-tests%2Fmaster%2Fsbin%2Fmake.cross&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jAavg0T3itnjkbHXADvePHHgtYeqiVTBt%2BoatHT0VHU%3D&reserved=0 -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommit%2F315bfcf1e0604de6ecfc1856cf5820876390f16c&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SQ75IXxfld6HMRIFkZ%2F8Z4YqxnFP%2F%2BZ%2BsYZIycNeO%2FA%3D&reserved=0
> git remote add linux-review https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZVS4723WbEO03hbsLXJ%2B%2FmB5EZElulY7lAsMEMatiko%3D&reserved=0
> git fetch --no-tags linux-review Pawel-Laszczak/usb-cdns3-Adds-missing-__iomem-markers/20201214-205353
> git checkout 315bfcf1e0604de6ecfc1856cf5820876390f16c
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> In file included from arch/riscv/include/asm/io.h:23,
> from include/linux/io.h:13,
> from include/linux/irq.h:20,
> from include/asm-generic/hardirq.h:17,
> from ./arch/riscv/include/generated/asm/hardirq.h:1,
> from include/linux/hardirq.h:10,
> from include/linux/interrupt.h:11,
> from drivers/usb/cdns3/drd.c:13:
> drivers/usb/cdns3/drd.c: In function 'cdns_otg_disable_irq':
> drivers/usb/cdns3/drd.c:159:31: error: dereferencing pointer to incomplete type 'struct cdns_otg_irq_reg'
> 159 | writel(0, &cdns->otg_irq_regs->ien);
> | ^~
> arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
> 93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
> | ^
> drivers/usb/cdns3/drd.c:159:2: note: in expansion of macro 'writel'
> 159 | writel(0, &cdns->otg_irq_regs->ien);
> | ^~~~~~
> drivers/usb/cdns3/drd.c: In function 'cdns_drd_init':
> drivers/usb/cdns3/drd.c:409:22: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
> 409 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> | ^
> In file included from include/linux/byteorder/little_endian.h:5,
> from arch/riscv/include/uapi/asm/byteorder.h:10,
> from include/asm-generic/bitops/le.h:6,
> from arch/riscv/include/asm/bitops.h:202,
> from include/linux/bitops.h:32,
> from include/linux/kernel.h:11,
> from drivers/usb/cdns3/drd.c:12:
> >> drivers/usb/cdns3/drd.c:421:33: warning: passing argument 1 of '__raw_readl' makes pointer from integer without a cast [-Wint-conversion]
> 421 | if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
> | ~~~~~~~~~~~~~~~~~~~~^~~~~
> | |
> | __le32 {aka unsigned int}
> include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
> 34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
> | ^
> arch/riscv/include/asm/mmio.h:140:47: note: in expansion of macro 'readl_cpu'
> 140 | #define readl(c) ({ u32 __v; __io_br(); __v = readl_cpu(c); __io_ar(__v); __v; })
> | ^~~~~~~~~
> drivers/usb/cdns3/drd.c:421:7: note: in expansion of macro 'readl'
> 421 | if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
> | ^~~~~
> In file included from arch/riscv/include/asm/io.h:23,
> from include/linux/io.h:13,
> from include/linux/irq.h:20,
> from include/asm-generic/hardirq.h:17,
> from ./arch/riscv/include/generated/asm/hardirq.h:1,
> from include/linux/hardirq.h:10,
> from include/linux/interrupt.h:11,
> from drivers/usb/cdns3/drd.c:13:
> arch/riscv/include/asm/mmio.h:63:60: note: expected 'const volatile void *' but argument is of type '__le32' {aka 'unsigned int'}
> 63 | static inline u32 __raw_readl(const volatile void __iomem *addr)
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
> drivers/usb/cdns3/drd.c:422:23: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
> 422 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> | ^
> drivers/usb/cdns3/drd.c:426:23: error: assignment to 'struct cdns_otg_irq_reg *' from incompatible pointer type 'struct cdns_otg_irq_regs *' [-Werror=incompatible-pointer-types]
> 426 | cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> | ^
> cc1: some warnings being treated as errors
>
> vim +/__raw_readl +421 drivers/usb/cdns3/drd.c
>
> 383
> 384 int cdns_drd_init(struct cdns *cdns)
> 385 {
> 386 void __iomem *regs;
> 387 u32 state;
> 388 int ret;
> 389
> 390 regs = devm_ioremap_resource(cdns->dev, &cdns->otg_res);
> 391 if (IS_ERR(regs))
> 392 return PTR_ERR(regs);
> 393
> 394 /* Detection of DRD version. Controller has been released
> 395 * in three versions. All are very similar and are software compatible,
> 396 * but they have same changes in register maps.
> 397 * The first register in oldest version is command register and it's
> 398 * read only. Driver should read 0 from it. On the other hand, in v1
> 399 * and v2 the first register contains device ID number which is not
> 400 * set to 0. Driver uses this fact to detect the proper version of
> 401 * controller.
> 402 */
> 403 cdns->otg_v0_regs = regs;
> 404 if (!readl(&cdns->otg_v0_regs->cmd)) {
> 405 cdns->version = CDNS3_CONTROLLER_V0;
> 406 cdns->otg_v1_regs = NULL;
> 407 cdns->otg_cdnsp_regs = NULL;
> 408 cdns->otg_regs = regs;
> 409 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> 410 &cdns->otg_v0_regs->ien;
> 411 writel(1, &cdns->otg_v0_regs->simulate);
> 412 dev_dbg(cdns->dev, "DRD version v0 (%08x)\n",
> 413 readl(&cdns->otg_v0_regs->version));
> 414 } else {
> 415 cdns->otg_v0_regs = NULL;
> 416 cdns->otg_v1_regs = regs;
> 417 cdns->otg_cdnsp_regs = regs;
> 418
> 419 cdns->otg_regs = (void __iomem *)&cdns->otg_v1_regs->cmd;
> 420
> > 421 if (readl(cdns->otg_cdnsp_regs->did) == OTG_CDNSP_DID) {
> 422 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> 423 &cdns->otg_cdnsp_regs->ien;
> 424 cdns->version = CDNSP_CONTROLLER_V2;
> 425 } else {
> 426 cdns->otg_irq_regs = (struct cdns_otg_irq_regs __iomem *)
> 427 &cdns->otg_v1_regs->ien;
> 428 writel(1, &cdns->otg_v1_regs->simulate);
> 429 cdns->version = CDNS3_CONTROLLER_V1;
> 430 }
> 431
> 432 dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
> 433 readl(&cdns->otg_v1_regs->did),
> 434 readl(&cdns->otg_v1_regs->rid));
> 435 }
> 436
> 437 state = OTGSTS_STRAP(readl(&cdns->otg_regs->sts));
> 438
> 439 /* Update dr_mode according to STRAP configuration. */
> 440 cdns->dr_mode = USB_DR_MODE_OTG;
> 441
> 442 if ((cdns->version == CDNSP_CONTROLLER_V2 &&
> 443 state == OTGSTS_CDNSP_STRAP_HOST) ||
> 444 (cdns->version != CDNSP_CONTROLLER_V2 &&
> 445 state == OTGSTS_STRAP_HOST)) {
> 446 dev_dbg(cdns->dev, "Controller strapped to HOST\n");
> 447 cdns->dr_mode = USB_DR_MODE_HOST;
> 448 } else if ((cdns->version == CDNSP_CONTROLLER_V2 &&
> 449 state == OTGSTS_CDNSP_STRAP_GADGET) ||
> 450 (cdns->version != CDNSP_CONTROLLER_V2 &&
> 451 state == OTGSTS_STRAP_GADGET)) {
> 452 dev_dbg(cdns->dev, "Controller strapped to PERIPHERAL\n");
> 453 cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
> 454 }
> 455
> 456 ret = devm_request_threaded_irq(cdns->dev, cdns->otg_irq,
> 457 cdns_drd_irq,
> 458 cdns_drd_thread_irq,
> 459 IRQF_SHARED,
> 460 dev_name(cdns->dev), cdns);
> 461 if (ret) {
> 462 dev_err(cdns->dev, "couldn't get otg_irq\n");
> 463 return ret;
> 464 }
> 465
> 466 state = readl(&cdns->otg_regs->sts);
> 467 if (OTGSTS_OTG_NRDY(state)) {
> 468 dev_err(cdns->dev, "Cadence USB3 OTG device not ready\n");
> 469 return -ENODEV;
> 470 }
> 471
> 472 return 0;
> 473 }
> 474
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fhyperkitty%2Flist%2Fkbuild-all%40lists.01.org&data=04%7C01%7Cpeter.chen%40nxp.com%7C6ce79474794448ae12b008d8a045f9ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637435572341553421%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=v9fQGKZKobtIysXu43lCekV%2FoXCc2EZZXIxoTtQpSdw%3D&reserved=0
--
Thanks,
Peter Chen
^ permalink raw reply
* RE: [PATCH 1/2] usb: cdnsp: Fixes for sparse warnings
From: Pawel Laszczak @ 2020-12-15 5:27 UTC (permalink / raw)
To: Peter Chen
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Rahul Kumar
In-Reply-To: <20201215050528.GB2142@b29397-desktop>
>
>
>On 20-12-14 13:03:44, Pawel Laszczak wrote:
>> Patch fixes all sparse warnings in cdsnp driver.
>>
>> It fixes the following warnings:
>> cdnsp-ring.c:1441: warning: incorrect type in assignment
>> cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
>> cdnsp-ring.c:2200: warning: dubious: x | !y
>> cdnsp-gadget.c:501: warning: incorrect type in assignment
>> cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:509: warning: invalid assignment: |=
>> cdnsp-gadget.c:510: warning: cast from restricted __le32
>> cdnsp-gadget.c:558: warning: incorrect type in assignment
>> cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:1571: warning: incorrect type in argument 1
>> cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
>> cdnsp-gadget.c:1760: warning: incorrect type in assignment
>> cdnsp-gadget.c:1762: warning: incorrect type in assignment
>> cdnsp-gadget.c:1763: warning: incorrect type in assignment
>> cdnsp-gadget.c:1764: warning: incorrect type in assignment
>> cdnsp-gadget.c:1765: warning: incorrect type in assignment
>> cdnsp-gadget.c:1766: warning: incorrect type in assignment
>> cdnsp-gadget.c:1767: warning: incorrect type in assignment
>> cdnsp-gadget.c:458: warning: cast truncates bits from constant value
>> (ffffffff07ffffff becomes 7ffffff)
>> cdnsp-gadget.c:666: warning: cast truncates bits from constant value
>> (ffffffff07ffffff becomes 7ffffff)
>> cdnsp-mem.c:762: warning: incorrect type in assignment
>> cdnsp-mem.c:763: warning: incorrect type in assignment
>> cdnsp-mem.c:928: warning: cast from restricted __le16
>> cdnsp-mem.c:1187: warning: incorrect type in assignment
>> cdnsp-mem.c:1191: warning: incorrect type in assignment
>> cdnsp-ep0.c:142: warning: incorrect type in assignment
>> cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
>> cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
>> cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
>> cdnsp-ep0.c:179: warning: incorrect type in argument 1
>> cdnsp-ep0.c:311: warning: incorrect type in argument 1
>> cdnsp-ep0.c:469: warning: incorrect type in assignment
>> cdnsp-trace.h:611:1: warning: cast from restricted __le32
>>
>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> Reported-by: kernel test robot <lkp@intel.com>
>
>Hi Pawel,
>
>The Reported-by tag should be above your Sob tag, I will change it.
>Except the patch reported build error by kernel test robot, I will apply
>your other four patches after finishing the compile test.
>
>Peter
Hi Peter,
I'm going to fix the "usb: cdns3: Adds missing __iomem markers" today.
I haven't seen any issue on ARCH=parisc. Maybe it's some specific riscv arch issue.
I believe that:
[auto build test WARNING on next-20201211]
[cannot apply to peter.chen-usb/ci-for-usb-next v5.10 v5.10-rc7 v5.10-rc6 v5.10]
is not the problem. I based on peter.chen-usb/for-usb-next.
Also I can't open the url from kernel test robot report.
Maybe there is some temporary issue with server.
Thanks,
Pawel
>> ---
>> drivers/usb/cdns3/cdnsp-debug.h | 2 +-
>> drivers/usb/cdns3/cdnsp-ep0.c | 13 ++++++-------
>> drivers/usb/cdns3/cdnsp-gadget.c | 24 +++++++++---------------
>> drivers/usb/cdns3/cdnsp-gadget.h | 13 +++++++------
>> drivers/usb/cdns3/cdnsp-mem.c | 11 ++++++-----
>> drivers/usb/cdns3/cdnsp-ring.c | 4 ++--
>> drivers/usb/cdns3/cdnsp-trace.h | 2 +-
>> 7 files changed, 32 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/usb/cdns3/cdnsp-debug.h b/drivers/usb/cdns3/cdnsp-debug.h
>> index d6345d4d2911..a8776df2d4e0 100644
>> --- a/drivers/usb/cdns3/cdnsp-debug.h
>> +++ b/drivers/usb/cdns3/cdnsp-debug.h
>> @@ -414,7 +414,7 @@ static inline const char *cdnsp_decode_slot_context(u32 info, u32 info2,
>> s = "UNKNOWN speed";
>> }
>>
>> - ret = sprintf(str, "%s Ctx Entries %ld",
>> + ret = sprintf(str, "%s Ctx Entries %d",
>> s, (info & LAST_CTX_MASK) >> 27);
>>
>> ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
>> diff --git a/drivers/usb/cdns3/cdnsp-ep0.c b/drivers/usb/cdns3/cdnsp-ep0.c
>> index d55b59ed7381..e2b1bcb3f80e 100644
>> --- a/drivers/usb/cdns3/cdnsp-ep0.c
>> +++ b/drivers/usb/cdns3/cdnsp-ep0.c
>> @@ -137,10 +137,8 @@ int cdnsp_status_stage(struct cdnsp_device *pdev)
>> return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
>> }
>>
>> -static int cdnsp_w_index_to_ep_index(__le32 wIndex)
>> +static int cdnsp_w_index_to_ep_index(u16 wIndex)
>> {
>> - wIndex = le32_to_cpu(wIndex);
>> -
>> if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
>> return 0;
>>
>> @@ -176,7 +174,8 @@ static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,
>> */
>> return cdnsp_ep0_delegate_req(pdev, ctrl);
>> case USB_RECIP_ENDPOINT:
>> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>> + ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
>> + pep = &pdev->eps[ep_sts];
>> ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
>>
>> /* check if endpoint is stalled */
>> @@ -305,10 +304,10 @@ static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
>> int set)
>> {
>> struct cdnsp_ep *pep;
>> - u32 wValue;
>> + u16 wValue;
>>
>> wValue = le16_to_cpu(ctrl->wValue);
>> - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
>> + pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
>>
>> switch (wValue) {
>> case USB_ENDPOINT_HALT:
>> @@ -435,7 +434,7 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
>> {
>> struct usb_ctrlrequest *ctrl = &pdev->setup;
>> int ret = 0;
>> - __le16 len;
>> + u16 len;
>>
>> trace_cdnsp_ctrl_req(ctrl);
>>
>> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
>> index 1668f72fdf30..f28f1508f049 100644
>> --- a/drivers/usb/cdns3/cdnsp-gadget.c
>> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
>> @@ -491,7 +491,7 @@ static void cdnsp_invalidate_ep_events(struct cdnsp_device *pdev,
>> struct cdnsp_segment *segment;
>> union cdnsp_trb *event;
>> u32 cycle_state;
>> - __le32 data;
>> + u32 data;
>>
>> event = pdev->event_ring->dequeue;
>> segment = pdev->event_ring->deq_seg;
>> @@ -527,9 +527,9 @@ int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev)
>> dma_addr_t cmd_deq_dma;
>> union cdnsp_trb *event;
>> u32 cycle_state;
>> - __le32 flags;
>> int ret, val;
>> u64 cmd_dma;
>> + u32 flags;
>>
>> cmd_trb = pdev->cmd.command_trb;
>> pdev->cmd.status = 0;
>> @@ -1568,7 +1568,7 @@ static void cdnsp_get_ep_buffering(struct cdnsp_device *pdev,
>> return;
>> }
>>
>> - endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2;
>> + endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2;
>>
>> /* Set to XBUF_TX_TAG_MASK_0 register. */
>> reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32);
>> @@ -1754,22 +1754,16 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)
>> static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
>> {
>> void __iomem *reg = &pdev->cap_regs->hc_capbase;
>> - struct cdnsp_rev_cap *rev_cap;
>>
>> reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
>> - rev_cap = reg;
>> -
>> - pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision);
>> - pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision);
>> - pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported);
>> - pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap);
>> - pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size);
>> - pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size);
>> + pdev->rev_cap = reg;
>>
>> dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
>> - pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision,
>> - pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size,
>> - pdev->rev_cap.tx_buff_size);
>> + readl(&pdev->rev_cap->ctrl_revision),
>> + readl(&pdev->rev_cap->rtl_revision),
>> + readl(&pdev->rev_cap->ep_supported),
>> + readl(&pdev->rev_cap->rx_buff_size),
>> + readl(&pdev->rev_cap->tx_buff_size));
>> }
>>
>> static int cdnsp_gen_setup(struct cdnsp_device *pdev)
>> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
>> index 8eb1b85a08b4..6bbb26548c04 100644
>> --- a/drivers/usb/cdns3/cdnsp-gadget.h
>> +++ b/drivers/usb/cdns3/cdnsp-gadget.h
>> @@ -493,11 +493,12 @@ struct cdnsp_3xport_cap {
>> #define CDNSP_VER_1 0x00000000
>> #define CDNSP_VER_2 0x10000000
>>
>> -#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \
>> - (BIT(ep_num) << ((dir) ? 0 : 16)))
>> +#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
>> + (readl(&(pdev)->rev_cap->ep_supported) & \
>> + (BIT(ep_num) << ((dir) ? 0 : 16)))
>>
>> /**
>> - * struct cdnsp_rev_cap - controller capabilities .
>> + * struct cdnsp_rev_cap - controller capabilities.
>> * @ext_cap: Header for RTL Revision Extended Capability.
>> * @rtl_revision: RTL revision.
>> * @rx_buff_size: Rx buffer sizes.
>> @@ -594,7 +595,7 @@ struct cdnsp_slot_ctx {
>> #define DEV_SPEED GENMASK(23, 20)
>> #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20)
>> /* Index of the last valid endpoint context in this device context - 27:31. */
>> -#define LAST_CTX_MASK GENMASK(31, 27)
>> +#define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27))
>> #define LAST_CTX(p) ((p) << 27)
>> #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1)
>> #define SLOT_FLAG BIT(0)
>> @@ -1351,9 +1352,9 @@ struct cdnsp_port {
>> * @ir_set: Current interrupter register set.
>> * @port20_regs: Port 2.0 Peripheral Configuration Registers.
>> * @port3x_regs: USB3.x Port Peripheral Configuration Registers.
>> + * @rev_cap: Controller Capabilities Registers.
>> * @hcs_params1: Cached register copies of read-only HCSPARAMS1
>> * @hcc_params: Cached register copies of read-only HCCPARAMS1
>> - * @rev_cap: Controller capability.
>> * @setup: Temporary buffer for setup packet.
>> * @ep0_preq: Internal allocated request used during enumeration.
>> * @ep0_stage: ep0 stage during enumeration process.
>> @@ -1402,12 +1403,12 @@ struct cdnsp_device {
>> struct cdnsp_intr_reg __iomem *ir_set;
>> struct cdnsp_20port_cap __iomem *port20_regs;
>> struct cdnsp_3xport_cap __iomem *port3x_regs;
>> + struct cdnsp_rev_cap __iomem *rev_cap;
>>
>> /* Cached register copies of read-only CDNSP data */
>> __u32 hcs_params1;
>> __u32 hcs_params3;
>> __u32 hcc_params;
>> - struct cdnsp_rev_cap rev_cap;
>> /* Lock used in interrupt thread context. */
>> spinlock_t lock;
>> struct usb_ctrlrequest setup;
>> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
>> index 4c7d77fb097e..7a84e928710e 100644
>> --- a/drivers/usb/cdns3/cdnsp-mem.c
>> +++ b/drivers/usb/cdns3/cdnsp-mem.c
>> @@ -759,8 +759,9 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev)
>>
>> port = DEV_PORT(pdev->active_port->port_num);
>> slot_ctx->dev_port |= cpu_to_le32(port);
>> - slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK);
>> - ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8);
>> + slot_ctx->dev_state = cpu_to_le32((pdev->device_address &
>> + DEV_ADDR_MASK));
>> + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8));
>> ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
>> ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
>> max_packets);
>> @@ -925,7 +926,7 @@ static u32 cdnsp_get_max_esit_payload(struct usb_gadget *g,
>> /* SuperSpeedPlus Isoc ep sending over 48k per EIST. */
>> if (g->speed >= USB_SPEED_SUPER_PLUS &&
>> USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes))
>> - return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> + return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */
>> else if (g->speed >= USB_SPEED_SUPER)
>> return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
>> @@ -1184,11 +1185,11 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)
>>
>> trace_cdnsp_init("Found USB 2.0 ports and USB 3.0 ports.");
>>
>> - pdev->usb2_port.regs = (struct cdnsp_port_regs *)
>> + pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *)
>> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>> (pdev->usb2_port.port_num - 1));
>>
>> - pdev->usb3_port.regs = (struct cdnsp_port_regs *)
>> + pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *)
>> (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
>> (pdev->usb3_port.port_num - 1));
>>
>> diff --git a/drivers/usb/cdns3/cdnsp-ring.c b/drivers/usb/cdns3/cdnsp-ring.c
>> index 874d9ff5406c..e15e13ba27dc 100644
>> --- a/drivers/usb/cdns3/cdnsp-ring.c
>> +++ b/drivers/usb/cdns3/cdnsp-ring.c
>> @@ -1432,7 +1432,7 @@ static bool cdnsp_handle_event(struct cdnsp_device *pdev)
>> unsigned int comp_code;
>> union cdnsp_trb *event;
>> bool update_ptrs = true;
>> - __le32 cycle_bit;
>> + u32 cycle_bit;
>> int ret = 0;
>> u32 flags;
>>
>> @@ -2198,7 +2198,7 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
>> * inverted in the first TDs isoc TRB.
>> */
>> field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
>> - !start_cycle | TRB_SIA | TRB_TBC(burst_count);
>> + start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
>>
>> /* Fill the rest of the TRB fields, and remaining normal TRBs. */
>> for (i = 0; i < trbs_per_td; i++) {
>> diff --git a/drivers/usb/cdns3/cdnsp-trace.h b/drivers/usb/cdns3/cdnsp-trace.h
>> index b68e282464d2..a9de1daadf07 100644
>> --- a/drivers/usb/cdns3/cdnsp-trace.h
>> +++ b/drivers/usb/cdns3/cdnsp-trace.h
>> @@ -620,7 +620,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_slot_ctx,
>> TP_fast_assign(
>> __entry->info = le32_to_cpu(ctx->dev_info);
>> __entry->info2 = le32_to_cpu(ctx->dev_port);
>> - __entry->int_target = le64_to_cpu(ctx->int_target);
>> + __entry->int_target = le32_to_cpu(ctx->int_target);
>> __entry->state = le32_to_cpu(ctx->dev_state);
>> ),
>> TP_printk("%s", cdnsp_decode_slot_context(__entry->info,
>> --
>> 2.17.1
>>
--
Regards
Pawel Laszcak
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox