Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb-storage: reject probe of device one non-DMA HCDs when using highmem

usb-storage is the last user of the block layer bounce buffering now,
and only uses it for HCDs that do not support DMA on highmem configs.

Remove this support and fail the probe so that the block layer bounce
buffering can go away.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20250505081138.3435992-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
48610ec2 27a0918d

+14 -6
+14 -6
drivers/usb/storage/usb.c
··· 1056 1056 goto BadDevice; 1057 1057 1058 1058 /* 1059 - * Some USB host controllers can't do DMA; they have to use PIO. 1060 - * For such controllers we need to make sure the block layer sets 1061 - * up bounce buffers in addressable memory. 1059 + * Some USB host controllers can't do DMA: They have to use PIO, or they 1060 + * have to use a small dedicated local memory area, or they have other 1061 + * restrictions on addressable memory. 1062 + * 1063 + * We can't support these controllers on highmem systems as we don't 1064 + * kmap or bounce buffer. 1062 1065 */ 1063 - if (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) || 1064 - bus_to_hcd(us->pusb_dev->bus)->localmem_pool) 1065 - host->no_highmem = true; 1066 + if (IS_ENABLED(CONFIG_HIGHMEM) && 1067 + (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) || 1068 + bus_to_hcd(us->pusb_dev->bus)->localmem_pool)) { 1069 + dev_warn(&intf->dev, "USB Mass Storage not supported on this host controller\n"); 1070 + result = -EINVAL; 1071 + goto release; 1072 + } 1066 1073 1067 1074 /* Get the unusual_devs entries and the descriptors */ 1068 1075 result = get_device_info(us, id, unusual_dev); ··· 1088 1081 1089 1082 BadDevice: 1090 1083 usb_stor_dbg(us, "storage_probe() failed\n"); 1084 + release: 1091 1085 release_everything(us); 1092 1086 return result; 1093 1087 }