Re: About clamping max_sectors to (ambiguous) dma_max_mapping_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 01, 2020 at 08:55:07AM +0800, Tom Yan wrote:
> Hi,
> 
> So a recent commit that disable 64 bit dma addressing for ASM1142:
> https://github.com/torvalds/linux/commit/ec37198acca7b4c17b96247697406e47aafe0605
> 
> I notice that it also causes (hw) max_sectors of uas drives connected
> to the controller to drop from 1024 blocks (SCSI_DEFAULT_MAX_SECTORS)
> to 512 blocks, because we clamp it against
> dma_max_mapping_size($some_device).
> 
> For uas drives, $some_device is `sdev->host->dma_dev`:
> https://github.com/torvalds/linux/blob/v5.8/drivers/scsi/scsi_lib.c#L1778
> (`shost` is `sdev->host`:
> https://github.com/torvalds/linux/blob/v5.8/drivers/scsi/scsi_lib.c#L1873)
> 
> But for bot/msc drives: $some_device is some other device:
> https://github.com/torvalds/linux/blob/v5.8/drivers/usb/storage/scsiglue.c#L92
> 
> In that case, max_sectors remains to be 2048 blocks for SS BOT drives
> connected to the ASM1142 controller.
> 
> I tried to change it to `sdev->host->dma_dev`. It lowered their
> max_sectors to 512 blocks.
> 
> So my questions are:
> 1. Do we really need to do any clamping to max_sectors in either (uas/bot) case?
> 2. If so, should we change the $some_device in either case?
> 
> For the record, in the original commit (for BOT drives):
> https://github.com/torvalds/linux/commit/d74ffae8b8dd17eaa8b82fc163e6aa2076dc8fb1
> The commit message states that the clamping is needed because of some
> other change, which is supposed to cause max_segment_size to raise
> from 0x10000 to 0xffffffff, but when I check the sysfs files for both
> kinds of drives, all of the values are 0x10000.
> 
> Also see https://github.com/virtio-win/kvm-guest-drivers-windows/issues/498

You should take a look at Arnd Bergmann's commit a8c06e407ef9 ("usb: 
separate out sysdev pointer from usb_bus"), which is what introduced 
this difference originally.

As far as I know, both drivers (usb-storage and uas) should be using the 
bus->sysdev device for the purpose of clamping max_sectors.  If uas 
doesn't use that device then it should be fixed.

And yes, the clamping is necessary.

Alan Stern



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux