usb: host: max3421-hcd: Add missing spi_device_id table
Subsystems (9)
Sasha Levin
maintainerPATCH 1/8 usb: host: max3421-hcd: Add missing spi_device_id table
From: Alexander Stein <[email protected]>
[ Upstream commit 41d5e3806cf589f658f92c75195095df0b66f66a ]
"maxim,max3421" DT compatible is missing its SPI device ID entry, not allowing module autoloading and leading to the following message:
"SPI driver max3421-hcd has no spi_device_id for maxim,max3421"
Fix this by adding the spi_device_id table.
--- drivers/usb/host/max3421-hcd.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/max3421-hcd.c +7 -0
@@ -1956,6 +1956,12 @@ max3421_remove(struct spi_device *spi)return 0 ; } +static const struct spi_device_id max3421_spi_ids[] = { + {"max3421" }, + { }, +}; +MODULE_DEVICE_TABLE (spi, max3421_spi_ids); +static const struct of_device_id max3421_of_match_table[] = { { .compatible ="maxim,max3421" , }, {},
@@ -1965,6 +1971,7 @@ MODULE_DEVICE_TABLE(of, max3421_of_match_table);static struct spi_driver max3421_driver = { .probe = max3421_probe, .remove = max3421_remove, + .id_table = max3421_spi_ids, .driver = { .name ="max3421-hcd" , .of_match_table =of_match_ptr (max3421_of_match_table),
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/8 fs/ntfs3: Fix WARNING in ntfs_extend_initialized_size
From: Edward Adam Davis <[email protected]>
[ Upstream commit ff355926445897cc9fdea3b00611e514232c213c ]
Syzbot reported a WARNING in ntfs_extend_initialized_size. The data type of in->i_valid and to is u64 in ntfs_file_mmap(). If their values are greater than LLONG_MAX, overflow will occur because the data types of the parameters valid and new_valid corresponding to the function ntfs_extend_initialized_size() are loff_t.
Before calling ntfs_extend_initialized_size() in the ntfs_file_mmap(), the "ni->i_valid < to" has been determined, so the same WARN_ON determination is not required in ntfs_extend_initialized_size().
Just execute the ntfs_extend_initialized_size() in ntfs_extend() to make a WARN_ON check.
--- fs/ntfs3/file.c | 1 + 1 file changed, 1 insertion(+)
fs/ntfs3/file.c +1 -0
@@ -435,6 +435,7 @@ static int ntfs_extend(struct inode *inode, loff_t pos, size_t count, }if (extend_init && !is_compressed (ni)) { +WARN_ON (ni->i_valid >= pos); err =ntfs_extend_initialized_size (file, ni, ni->i_valid, pos);if (err) goto out;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/8 usb: dwc3: gadget: Avoid using reserved endpoints on Intel Merrifield
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 461f24bff86808ee5fbfe74751a825f8a7ab24e0 ]
Intel Merrifield SoC uses these endpoints for tracing and they cannot be re-allocated if being used because the side band flow control signals are hard wired to certain endpoints:
• 1 High BW Bulk IN (IN#1) (RTIT)
• 1 1KB BW Bulk IN (IN#8) + 1 1KB BW Bulk OUT (Run Control) (OUT#8)
In device mode, since RTIT (EP#1) and EXI/RunControl (EP#8) uses External Buffer Control (EBC) mode, these endpoints are to be mapped to EBC mode (to be done by EXI target driver). Additionally TRB for RTIT and EXI are maintained in STM (System Trace Module) unit and the EXI target driver will as well configure the TRB location for EP #1 IN and EP#8 (IN and OUT). Since STM/PTI and EXI hardware blocks manage these endpoints and interface to OTG3 controller through EBC interface, there is no need to enable any events (such as XferComplete etc) for these end points.
--- drivers/usb/dwc3/dwc3-pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +10 -0
@@ -132,11 +132,21 @@ static const struct property_entry dwc3_pci_intel_byt_properties[] = { {} }; +/* +* Intel Merrifield SoC uses these endpoints for tracing and they cannot +* be re-allocated if being used because the side band flow control signals +* are hard wired to certain endpoints: +* - 1 High BW Bulk IN (IN#1) (RTIT) +* - 1 1KB BW Bulk IN (IN#8) + 1 1KB BW Bulk OUT (Run Control) (OUT#8) +*/ +static const u8 dwc3_pci_mrfld_reserved_endpoints[] = {3 ,16 ,17 }; +static const struct property_entry dwc3_pci_mrfld_properties[] = {PROPERTY_ENTRY_STRING ("dr_mode" ,"otg" ),PROPERTY_ENTRY_STRING ("linux,extcon-name" ,"mrfld_bcove_pwrsrc" ),PROPERTY_ENTRY_BOOL ("snps,dis_u3_susphy_quirk" ),PROPERTY_ENTRY_BOOL ("snps,dis_u2_susphy_quirk" ), +PROPERTY_ENTRY_U8_ARRAY ("snps,reserved-endpoints" , dwc3_pci_mrfld_reserved_endpoints),PROPERTY_ENTRY_BOOL ("snps,usb2-gadget-lpm-disable" ),PROPERTY_ENTRY_BOOL ("linux,sysdev_is_parent" ), {}
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 4/8 sound/virtio: Fix cancel_sync warnings on uninitialized work_structs
In reply to Sasha LevinFrom: John Stultz <[email protected]>
[ Upstream commit 3c7df2e27346eb40a0e86230db1ccab195c97cfe ]
Betty reported hitting the following warning:
[ 8.709131][ T221] WARNING: CPU: 2 PID: 221 at kernel/workqueue.c:4182 ... [ 8.713282][ T221] Call trace: [ 8.713365][ T221] __flush_work+0x8d0/0x914 [ 8.713468][ T221] __cancel_work_sync+0xac/0xfc [ 8.713570][ T221] cancel_work_sync+0x24/0x34 [ 8.713667][ T221] virtsnd_remove+0xa8/0xf8 [virtio_snd ab15f34d0dd772f6d11327e08a81d46dc9c36276] [ 8.713868][ T221] virtsnd_probe+0x48c/0x664 [virtio_snd ab15f34d0dd772f6d11327e08a81d46dc9c36276] [ 8.714035][ T221] virtio_dev_probe+0x28c/0x390 [ 8.714139][ T221] really_probe+0x1bc/0x4c8
...
It seems we're hitting the error path in virtsnd_probe(), which triggers a virtsnd_remove() which iterates over the substreams calling cancel_work_sync() on the elapsed_period work_struct.
Looking at the code, from earlier in:
virtsnd_probe()->virtsnd_build_devs()->virtsnd_pcm_parse_cfg()
We set snd->nsubstreams, allocate the snd->substreams, and if we then hit an error on the info allocation or something in virtsnd_ctl_query_info() fails, we will exit without having initialized the elapsed_period work_struct.
When that error path unwinds we then call virtsnd_remove() which as long as the substreams array is allocated, will iterate through calling cancel_work_sync() on the uninitialized work struct hitting this warning.
Takashi Iwai suggested this fix, which initializes the substreams structure right after allocation, so that if we hit the error paths we avoid trying to cleanup uninitialized data.
Note: I have not yet managed to reproduce the issue myself, so this patch has had limited testing.
Feedback or thoughts would be appreciated!
Message-Id: <[email protected]>
--- sound/virtio/virtio_pcm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
sound/virtio/virtio_pcm.c +15 -6
@@ -337,6 +337,21 @@ int virtsnd_pcm_parse_cfg(struct virtio_snd *snd)if (!snd->substreams)return -ENOMEM ; +/* +* Initialize critical substream fields early in case we hit an +* error path and end up trying to clean up uninitialized structures +* elsewhere. +*/ +for (i =0 ; i < snd->nsubstreams; ++i) { +struct virtio_pcm_substream *vss = &snd->substreams[i]; + + vss->snd = snd; + vss->sid = i; +INIT_WORK (&vss->elapsed_period, virtsnd_pcm_period_elapsed); +init_waitqueue_head (&vss->msg_empty); +spin_lock_init (&vss->lock); + } + info =kcalloc (snd->nsubstreams,sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
@@ -350,12 +365,6 @@ int virtsnd_pcm_parse_cfg(struct virtio_snd *snd)struct virtio_pcm_substream *vss = &snd->substreams[i];struct virtio_pcm *vpcm; - vss->snd = snd; - vss->sid = i; -INIT_WORK (&vss->elapsed_period, virtsnd_pcm_period_elapsed); -init_waitqueue_head (&vss->msg_empty); -spin_lock_init (&vss->lock); - rc =virtsnd_pcm_build_hw (vss, &info[i]);if (rc) goto on_exit;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 5/8 dmaengine: dmatest: Fix dmatest waiting less when interrupted
In reply to Sasha LevinFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit e87ca16e99118ab4e130a41bdf12abbf6a87656c ]
Change the "wait for operation finish" logic to take interrupts into account.
When using dmatest with idxd DMA engine, it's possible that during longer tests, the interrupt notifying the finish of an operation happens during wait_event_freezable_timeout(), which causes dmatest to cleanup all the resources, some of which might still be in use.
This fix ensures that the wait logic correctly handles interrupts, preventing premature cleanup of resources.
--- drivers/dma/dmatest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/dmatest.c +3 -3
@@ -828,9 +828,9 @@ static int dmatest_func(void *data) }else {dma_async_issue_pending (chan); -wait_event_freezable_timeout (thread->done_wait, - done->done, -msecs_to_jiffies (params->timeout)); +wait_event_timeout (thread->done_wait, + done->done, +msecs_to_jiffies (params->timeout)); status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL );
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 6/8 usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running
In reply to Sasha LevinFrom: Michal Pecio <[email protected]>
[ Upstream commit 28a76fcc4c85dd39633fb96edb643c91820133e3 ]
Nothing prevents a broken HC from claiming that an endpoint is Running and repeatedly rejecting Stop Endpoint with Context State Error.
Avoid infinite retries and give back cancelled TDs.
No such cases known so far, but HCs have bugs.
--- drivers/usb/host/xhci-ring.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +7 -4
@@ -1183,16 +1183,19 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,* Stopped state, but it will soon change to Running. * * Assume this bug on unexpected Stop Endpoint failures. -* Keep retrying until the EP starts and stops again, on -* chips where this is known to help. Wait for 100ms. +* Keep retrying until the EP starts and stops again. */ -if (time_is_before_jiffies (ep->stop_time +msecs_to_jiffies (100 ))) -break ; fallthrough;case EP_STATE_RUNNING :/* Race, HW handled stop ep cmd before ep was running */ xhci_dbg (xhci,"Stop ep completion ctx error, ctx_state %d\n" ,GET_EP_CTX_STATE (ep_ctx)); +/* +* Don't retry forever if we guessed wrong or a defective HC never starts +* the EP or says 'Running' but fails the command. We must give back TDs. +*/ +if (time_is_before_jiffies (ep->stop_time +msecs_to_jiffies (100 ))) +break ; command =xhci_alloc_command (xhci, false,GFP_ATOMIC );if (!command)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 7/8 usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev()
In reply to Sasha LevinFrom: Chenyuan Yang <[email protected]>
[ Upstream commit 8c75f3e6a433d92084ad4e78b029ae680865420f ]
The variable d->name, returned by devm_kasprintf(), could be NULL. A pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool
--- drivers/usb/gadget/udc/aspeed-vhub/dev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/udc/aspeed-vhub/dev.c +3 -0
@@ -538,6 +538,9 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx) d->vhub = vhub; d->index = idx; d->name =devm_kasprintf (parent,GFP_KERNEL ,"port%d" , idx+1 ); +if (!d->name) +return -ENOMEM ; + d->regs = vhub->regs +0x100 +0x10 * idx;ast_vhub_init_ep0 (vhub, &d->ep0, d);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 8/8 objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler()
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 060aed9c0093b341480770457093449771cf1496 ]
If 'port_id' is negative, the shift counts in wcd934x_slim_irq_handler() also become negative, resulting in undefined behavior due to shift out of bounds.
If I'm reading the code correctly, that appears to be not possible, but with KCOV enabled, Clang's range analysis isn't always able to determine that and generates undefined behavior.
As a result the code generation isn't optimal, and undefined behavior should be avoided regardless. Improve code generation and remove the undefined behavior by converting the signed variables to unsigned.
Fixes the following warning with UBSAN:
sound/soc/codecs/snd-soc-wcd934x.o: warning: objtool: .text.wcd934x_slim_irq_handler: unexpected end of section
--- sound/soc/codecs/wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wcd934x.c +1 -1
@@ -2281,7 +2281,7 @@ static irqreturn_t wcd934x_slim_irq_handler(int irq, void *data) {struct wcd934x_codec *wcd = data;unsigned long status =0 ; -int i, j, port_id; +unsigned int i, j, port_id;unsigned int val, int_val =0 ;irqreturn_t ret =IRQ_NONE ;bool tx;
Signature · 1 line
2.39.5