<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/drivers/usb/cdns3, branch v5.10</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>usb: cdns3: core: fix goto label for error path</title>
<updated>2020-11-30T05:48:32+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-11-26T06:02:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6b8137517e70f6e96d0251a98930b1f29d0be161'/>
<id>6b8137517e70f6e96d0251a98930b1f29d0be161</id>
<content type='text'>
The usb_role_switch_register has been already called, so if the
devm_request_irq has failed, it needs to call usb_role_switch_unregister.

Fixes: b1234e3b3b26 ("usb: cdns3: add runtime PM support")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The usb_role_switch_register has been already called, so if the
devm_request_irq has failed, it needs to call usb_role_switch_unregister.

Fixes: b1234e3b3b26 ("usb: cdns3: add runtime PM support")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: clear trb-&gt;length as zero after preparing every trb</title>
<updated>2020-11-30T05:48:32+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-11-25T12:35:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=24fdaeeb294c14ea743ec99ada92380c060a428a'/>
<id>24fdaeeb294c14ea743ec99ada92380c060a428a</id>
<content type='text'>
It clears trb-&gt;length as zero before preparing td, but if scatter
buffer is used for td, there are several trbs within td, it needs to clear
every trb-&gt;length as zero, otherwise, the default value for trb-&gt;length
may not be zero after it begins to use the second round of trb rings.

Fixes: abc6b579048e ("usb: cdns3: gadget: using correct sg operations")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It clears trb-&gt;length as zero before preparing td, but if scatter
buffer is used for td, there are several trbs within td, it needs to clear
every trb-&gt;length as zero, otherwise, the default value for trb-&gt;length
may not be zero after it begins to use the second round of trb rings.

Fixes: abc6b579048e ("usb: cdns3: gadget: using correct sg operations")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: Fix hardware based role switch</title>
<updated>2020-11-30T05:48:32+00:00</updated>
<author>
<name>Roger Quadros</name>
<email>rogerq@ti.com</email>
</author>
<published>2020-11-25T12:49:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6703052fe30fa0d85f1fbbf50171486cb0148d2d'/>
<id>6703052fe30fa0d85f1fbbf50171486cb0148d2d</id>
<content type='text'>
Hardware based role switch is broken as the driver always skips it.
Fix this by registering for  SW role switch only if 'usb-role-switch'
property is present in the device tree.

Fixes: 50642709f659 ("usb: cdns3: core: quit if it uses role switch class")
Signed-off-by: Roger Quadros &lt;rogerq@ti.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hardware based role switch is broken as the driver always skips it.
Fix this by registering for  SW role switch only if 'usb-role-switch'
property is present in the device tree.

Fixes: 50642709f659 ("usb: cdns3: core: quit if it uses role switch class")
Signed-off-by: Roger Quadros &lt;rogerq@ti.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: calculate TD_SIZE based on TD</title>
<updated>2020-11-16T07:08:52+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-11-03T14:16:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=40252dd7cf7cad81c784c695c36bc475b518f0ea'/>
<id>40252dd7cf7cad81c784c695c36bc475b518f0ea</id>
<content type='text'>
The TRB entry TD_SIZE is the packet number for the TD (request) but not the
each TRB, so it only needs to be assigned for the first TRB during the TD,
and the value of it is for TD too.

Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The TRB entry TD_SIZE is the packet number for the TD (request) but not the
each TRB, so it only needs to be assigned for the first TRB during the TD,
and the value of it is for TD too.

Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: initialize link_trb as NULL</title>
<updated>2020-11-16T07:08:52+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-11-03T11:23:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=78e91588510919a0dc9bd48916e760c1ba5797d2'/>
<id>78e91588510919a0dc9bd48916e760c1ba5797d2</id>
<content type='text'>
There is an uninitialized variable "link_trb" usage at function cdns3_ep_run_transfer.
Fixed it by initialize "link_trb" as NULL.

Fixes: 4e218882eb5a ("usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer")
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is an uninitialized variable "link_trb" usage at function cdns3_ep_run_transfer.
Fixed it by initialize "link_trb" as NULL.

Fixes: 4e218882eb5a ("usb: cdns3: gadget: improve the dump TRB operation at cdns3_ep_run_transfer")
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: own the lock wrongly at the suspend routine</title>
<updated>2020-10-30T03:40:54+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-10-29T09:55:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e11d2bf271589e70ea80a2ee3e116c40fcac62c2'/>
<id>e11d2bf271589e70ea80a2ee3e116c40fcac62c2</id>
<content type='text'>
When the system goes to suspend, if the controller is at device mode with
cable connecting to host, the call stack is: cdns3_suspend-&gt;
cdns3_gadget_suspend -&gt; cdns3_disconnect_gadget, after cdns3_disconnect_gadget
is called, it owns lock wrongly, it causes the system being deadlock after
resume due to at cdns3_device_thread_irq_handler, it tries to get the lock,
but can't get it forever.

To fix it, we delete the unlock-lock operations at cdns3_disconnect_gadget,
and do it at the caller.

Fixes: b1234e3b3b26 ("usb: cdns3: add runtime PM support")
Acked-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the system goes to suspend, if the controller is at device mode with
cable connecting to host, the call stack is: cdns3_suspend-&gt;
cdns3_gadget_suspend -&gt; cdns3_disconnect_gadget, after cdns3_disconnect_gadget
is called, it owns lock wrongly, it causes the system being deadlock after
resume due to at cdns3_device_thread_irq_handler, it tries to get the lock,
but can't get it forever.

To fix it, we delete the unlock-lock operations at cdns3_disconnect_gadget,
and do it at the caller.

Fixes: b1234e3b3b26 ("usb: cdns3: add runtime PM support")
Acked-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: Fix on-chip memory overflow issue</title>
<updated>2020-10-30T03:40:54+00:00</updated>
<author>
<name>Pawel Laszczak</name>
<email>pawell@cadence.com</email>
</author>
<published>2020-10-22T00:55:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=52d3967704aea6cb316d419a33a5e1d56d33a3c1'/>
<id>52d3967704aea6cb316d419a33a5e1d56d33a3c1</id>
<content type='text'>
Patch fixes issue caused setting On-chip memory overflow bit in usb_sts
register. The issue occurred because EP_CFG register was set twice
before USB_STS.CFGSTS was set. Every write operation on EP_CFG.BUFFERING
causes that controller increases internal counter holding the number
of reserved on-chip buffers. First time this register was updated in
function cdns3_ep_config before delegating SET_CONFIGURATION request
to class driver and again it was updated when class wanted to enable
endpoint.  This patch fixes this issue by configuring endpoints
enabled by class driver in cdns3_gadget_ep_enable and others just
before status stage.

Cc: stable@vger.kernel.org#v5.8+
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Reported-and-tested-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch fixes issue caused setting On-chip memory overflow bit in usb_sts
register. The issue occurred because EP_CFG register was set twice
before USB_STS.CFGSTS was set. Every write operation on EP_CFG.BUFFERING
causes that controller increases internal counter holding the number
of reserved on-chip buffers. First time this register was updated in
function cdns3_ep_config before delegating SET_CONFIGURATION request
to class driver and again it was updated when class wanted to enable
endpoint.  This patch fixes this issue by configuring endpoints
enabled by class driver in cdns3_gadget_ep_enable and others just
before status stage.

Cc: stable@vger.kernel.org#v5.8+
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Reported-and-tested-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: suspicious implicit sign extension</title>
<updated>2020-10-29T10:01:47+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-10-22T00:55:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=5fca3f062879f8e5214c56f3e3e2be6727900f5d'/>
<id>5fca3f062879f8e5214c56f3e3e2be6727900f5d</id>
<content type='text'>
The code:
trb-&gt;length = cpu_to_le32(TRB_BURST_LEN(priv_ep-&gt;trb_burst_size)
	       	| TRB_LEN(length));

TRB_BURST_LEN(priv_ep-&gt;trb_burst_size) may be overflow for int 32 if
priv_ep-&gt;trb_burst_size is equal or larger than 0x80;

Below is the Coverity warning:
sign_extension: Suspicious implicit sign extension: priv_ep-&gt;trb_burst_size
with type u8 (8 bits, unsigned) is promoted in priv_ep-&gt;trb_burst_size &lt;&lt; 24
to type int (32 bits, signed), then sign-extended to type unsigned long
(64 bits, unsigned). If priv_ep-&gt;trb_burst_size &lt;&lt; 24 is greater than 0x7FFFFFFF,
the upper bits of the result will all be 1.

To fix it, it needs to add an explicit cast to unsigned int type for ((p) &lt;&lt; 24).

Reviewed-by: Jun Li &lt;jun.li@nxp.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The code:
trb-&gt;length = cpu_to_le32(TRB_BURST_LEN(priv_ep-&gt;trb_burst_size)
	       	| TRB_LEN(length));

TRB_BURST_LEN(priv_ep-&gt;trb_burst_size) may be overflow for int 32 if
priv_ep-&gt;trb_burst_size is equal or larger than 0x80;

Below is the Coverity warning:
sign_extension: Suspicious implicit sign extension: priv_ep-&gt;trb_burst_size
with type u8 (8 bits, unsigned) is promoted in priv_ep-&gt;trb_burst_size &lt;&lt; 24
to type int (32 bits, signed), then sign-extended to type unsigned long
(64 bits, unsigned). If priv_ep-&gt;trb_burst_size &lt;&lt; 24 is greater than 0x7FFFFFFF,
the upper bits of the result will all be 1.

To fix it, it needs to add an explicit cast to unsigned int type for ((p) &lt;&lt; 24).

Reviewed-by: Jun Li &lt;jun.li@nxp.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: Variable 'length' set but not used</title>
<updated>2020-10-28T07:25:59+00:00</updated>
<author>
<name>Pawel Laszczak</name>
<email>pawell@cadence.com</email>
</author>
<published>2020-10-12T06:45:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=defe40af1a7143a0538d7c3e87224459eea0a877'/>
<id>defe40af1a7143a0538d7c3e87224459eea0a877</id>
<content type='text'>
Patch removes not used variable 'length' from
cdns3_wa2_descmiss_copy_data function.

Fixes: 141e70fef4ee ("usb: cdns3: gadget: need to handle sg case for workaround 2 case")
Acked-by: Roger Quadros &lt;rogerq@ti.com&gt;
Signed-off-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch removes not used variable 'length' from
cdns3_wa2_descmiss_copy_data function.

Fixes: 141e70fef4ee ("usb: cdns3: gadget: need to handle sg case for workaround 2 case")
Acked-by: Roger Quadros &lt;rogerq@ti.com&gt;
Signed-off-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: cdns3: gadget: enlarge the TRB ring length</title>
<updated>2020-10-02T06:57:46+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2020-09-10T09:11:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=71ea88f6652a52f85b2110486ca99d26b71a3d8d'/>
<id>71ea88f6652a52f85b2110486ca99d26b71a3d8d</id>
<content type='text'>
At Android ADB and MTP use case, it uses f_fs which supports scatter list,
it means one request may need several TRBs for it. Besides, TRB consumes
very fast compared to TRB has prepared for above use case, there are at
most 120 pending requests, the date size is 16KB for each request, so four
TRBs (4KB per TRB) per sg entry at worst case. so we need to enlarge the
TRB ring length to avoid "no free TRB error". Since each TRB only consumes
12 bytes (3 * 32 bits), we enlarge the TRB length to 600, it leaves some
buffers for potential "no free TRB error", and only increases a little
memory cost.

Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Felipe Balbi &lt;balbi@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
At Android ADB and MTP use case, it uses f_fs which supports scatter list,
it means one request may need several TRBs for it. Besides, TRB consumes
very fast compared to TRB has prepared for above use case, there are at
most 120 pending requests, the date size is 16KB for each request, so four
TRBs (4KB per TRB) per sg entry at worst case. so we need to enlarge the
TRB ring length to avoid "no free TRB error". Since each TRB only consumes
12 bytes (3 * 32 bits), we enlarge the TRB length to 600, it leaves some
buffers for potential "no free TRB error", and only increases a little
memory cost.

Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Felipe Balbi &lt;balbi@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
