Skip to content

Commit

Permalink
usb-storage: fix sdev->host->dma_dev
Browse files Browse the repository at this point in the history
Use scsi_add_host_with_dma() instead of scsi_add_host().

When the scsi request queue is initialized/allocated, hw_max_sectors is clamped
to the dma max mapping size. Therefore, the correct device that should be used
for the clamping needs to be set.

The same clamping is still needed in usb-storage as hw_max_sectors could be
changed there. The original clamping would be invalidated in such cases.

Signed-off-by: Tom Yan <tom.ty89@gmail.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20200903181725.2931-1-tom.ty89@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tom Yan authored and Greg Kroah-Hartman committed Sep 4, 2020
1 parent f0dbd25 commit 0154012
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/usb/storage/scsiglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int slave_alloc (struct scsi_device *sdev)
static int slave_configure(struct scsi_device *sdev)
{
struct us_data *us = host_to_us(sdev->host);
struct device *dev = us->pusb_dev->bus->sysdev;
struct device *dev = sdev->host->dma_dev;

/*
* Many devices have trouble transferring more than 32KB at a time,
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/storage/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,9 @@ int usb_stor_probe2(struct us_data *us)
goto BadDevice;
usb_autopm_get_interface_no_resume(us->pusb_intf);
snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
dev_name(&us->pusb_intf->dev));
result = scsi_add_host(us_to_host(us), dev);
dev_name(dev));
result = scsi_add_host_with_dma(us_to_host(us), dev,
us->pusb_dev->bus->sysdev);
if (result) {
dev_warn(dev,
"Unable to add the scsi host\n");
Expand Down

0 comments on commit 0154012

Please sign in to comment.