<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/usb/isp1760/isp1760-core.c, branch linux-6.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2022-05-19T16:10:59Z</updated>
<entry>
<title>usb: isp1760: Fix out-of-bounds array access</title>
<updated>2022-05-19T16:10:59Z</updated>
<author>
<name>Linus Walleij</name>
<email>linus.walleij@linaro.org</email>
</author>
<published>2022-05-16T09:14:24Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=26ae2c942b5702f2e43d36b2a4389cfb7d616b6a'/>
<id>urn:sha1:26ae2c942b5702f2e43d36b2a4389cfb7d616b6a</id>
<content type='text'>
Running the driver through kasan gives an interesting splat:

  BUG: KASAN: global-out-of-bounds in isp1760_register+0x180/0x70c
  Read of size 20 at addr f1db2e64 by task swapper/0/1
  (...)
  isp1760_register from isp1760_plat_probe+0x1d8/0x220
  (...)

This happens because the loop reading the regmap fields for the
different ISP1760 variants look like this:

  for (i = 0; i &lt; HC_FIELD_MAX; i++) { ... }

Meaning it expects the arrays to be at least HC_FIELD_MAX - 1 long.

However the arrays isp1760_hc_reg_fields[], isp1763_hc_reg_fields[],
isp1763_hc_volatile_ranges[] and isp1763_dc_volatile_ranges[] are
dynamically sized during compilation.

Fix this by putting an empty assignment to the [HC_FIELD_MAX]
and [DC_FIELD_MAX] array member at the end of each array.
This will make the array one member longer than it needs to be,
but avoids the risk of overwriting whatever is inside
[HC_FIELD_MAX - 1] and is simple and intuitive to read. Also
add comments explaining what is going on.

Fixes: 1da9e1c06873 ("usb: isp1760: move to regmap for register access")
Cc: stable@vger.kernel.org
Cc: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Cc: Dietmar Eggemann &lt;dietmar.eggemann@arm.com&gt;
Reviewed-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Link: https://lore.kernel.org/r/20220516091424.391209-1-linus.walleij@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: otg control register access</title>
<updated>2021-08-27T14:11:39Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-08-27T13:11:54Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9c1587d99f9305aa4f10b47fcf1981012aa5381f'/>
<id>urn:sha1:9c1587d99f9305aa4f10b47fcf1981012aa5381f</id>
<content type='text'>
The set/clear of the otg control values is done writing to
two different 16bit registers, however we setup the regmap
width for isp1760/61 to 32bit value bits.

So, just access the clear register address (0x376)as the high
part of the otg control register set (0x374), and write the
values in one go to make sure they get clear/set.

Reported-by: Dietmar Eggemann &lt;dietmar.eggemann@arm.com&gt;
Tested-by: Dietmar Eggemann &lt;dietmar.eggemann@arm.com&gt;
Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210827131154.4151862-6-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: clean never read udc_enabled warning</title>
<updated>2021-08-26T11:30:39Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-08-19T18:09:29Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=de940244e8987a76d73fb2b0057ecd494cbfeefd'/>
<id>urn:sha1:de940244e8987a76d73fb2b0057ecd494cbfeefd</id>
<content type='text'>
When CONFIG_USB_ISP1761_UDC is not enabled the udc_enabled variable is
never used since it is short circuited before in the logic operations.

This would trigger the following warning by clang analyzer:

drivers/usb/isp1760/isp1760-core.c:490:2: warning: Value stored to 'udc_enabled' is never read [clang-analyzer-deadcode.DeadStores]
        udc_enabled = ((devflags &amp; ISP1760_FLAG_ISP1763) ||
        ^
drivers/usb/isp1760/isp1760-core.c:490:2: note: Value stored to 'udc_enabled' is never read

Just swap the other of the operands in the logic operations.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210819180929.1327349-6-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1763: add peripheral mode</title>
<updated>2021-05-21T18:05:32Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-05-13T08:47:17Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d369c9187c1897ce5339716354ce47b2c2f67352'/>
<id>urn:sha1:d369c9187c1897ce5339716354ce47b2c2f67352</id>
<content type='text'>
Besides the already host mode support add peripheral mode support for
the isp1763 IP from the isp1760 family.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210513084717.2487366-10-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: add support for isp1763</title>
<updated>2021-05-21T18:05:32Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-05-13T08:47:15Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=60d789f3bfbb7428e6ba2949de70a6db8e12e8fa'/>
<id>urn:sha1:60d789f3bfbb7428e6ba2949de70a6db8e12e8fa</id>
<content type='text'>
isp1763 have some differences from the isp1760, 8 bit address for
registers and 16 bit for values, no bulk access to memory addresses,
16 PTD's instead of 32.

Following the regmap work done before add the registers, memory access
and add the functions to support differences in setup sequences.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210513084717.2487366-8-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: use dr_mode binding</title>
<updated>2021-05-21T18:05:32Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-05-13T08:47:14Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3eb96e04be9918afa54b64fac943de86a9798bda'/>
<id>urn:sha1:3eb96e04be9918afa54b64fac943de86a9798bda</id>
<content type='text'>
There is already a binding to describe the dual role mode (dr_mode),
use that instead of defining a new one (port1-otg).

Update driver code and devicetree files that use that port1-otg
binding.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210513084717.2487366-7-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: hcd: refactor mempool config and setup</title>
<updated>2021-05-21T18:05:32Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-05-13T08:47:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=a74f639c5b5618e2c9f311c93bc3e7405de8ca85'/>
<id>urn:sha1:a74f639c5b5618e2c9f311c93bc3e7405de8ca85</id>
<content type='text'>
In preparation to support other family member IP, which may have
different memory layout. Drop macros and setup a configuration
struct.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210513084717.2487366-6-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: move to regmap for register access</title>
<updated>2021-05-21T18:05:31Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2021-05-13T08:47:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1da9e1c06873350c99ba49a052f92de85f2c69f2'/>
<id>urn:sha1:1da9e1c06873350c99ba49a052f92de85f2c69f2</id>
<content type='text'>
Rework access to registers and memory to use regmap framework.
No change in current feature or way of work is intended with this
change.

This will allow to reuse this driver with other IP of this family,
for example isp1763, with little changes and effort.

Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Link: https://lore.kernel.org/r/20210513084717.2487366-3-rui.silva@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: add a HCD_DMA flag instead of guestimating DMA capabilities</title>
<updated>2019-08-21T17:03:35Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2019-08-16T06:24:32Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7b81cb6bddd2c4f2489506771070924bd0ae9902'/>
<id>urn:sha1:7b81cb6bddd2c4f2489506771070924bd0ae9902</id>
<content type='text'>
The usb core is the only major place in the kernel that checks for
a non-NULL device dma_mask to see if a device is DMA capable.  This
is generally a bad idea, as all major busses always set up a DMA mask,
even if the device is not DMA capable - in fact bus layers like PCI
can't even know if a device is DMA capable at enumeration time.  This
leads to lots of workaround in HCD drivers, and also prevented us from
setting up a DMA mask for platform devices by default last time we
tried.

Replace this guess with an explicit HCD_DMA that is set by drivers that
appear to have DMA support.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Link: https://lore.kernel.org/r/20190816062435.881-4-hch@lst.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: isp1760: Replace mdelay with msleep in isp1760_init_core</title>
<updated>2018-04-22T13:49:42Z</updated>
<author>
<name>Jia-Ju Bai</name>
<email>baijiaju1990@gmail.com</email>
</author>
<published>2018-04-10T07:36:40Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0f0290089abd37ca54db764c294fe7e47624a313'/>
<id>urn:sha1:0f0290089abd37ca54db764c294fe7e47624a313</id>
<content type='text'>
isp1760_init_core() is never called in atomic context.

The call chains ending up at isp1760_init_core() are:
[1] isp1760_init_core() &lt;- isp1760_register() &lt;- isp1760_plat_probe()
[2] isp1760_init_core() &lt;- isp1760_register() &lt;- isp1761_pci_probe()

isp1760_plat_probe() is set as ".probe" in struct platform_driver.
isp1761_pci_probe() is set as ".probe" in struct pci_driver.
These functions are not called in atomic context.

Despite never getting called from atomic context, isp1761_pci_probe()
calls mdelay() to busily wait.
This is not necessary and can be replaced with msleep() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai &lt;baijiaju1990@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
