summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-02-16 21:02:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-18 09:23:42 +0100
commit45b31c4a25e140cf6c20cd1430b776d5ec26391e (patch)
treee2364904fbd04cc286ad110b7503b999e044be92 /drivers
parent130fbc7f6c67357a58823c8f17ecef7d276386a9 (diff)
downloadbarebox-45b31c4a25e140cf6c20cd1430b776d5ec26391e.tar.gz
barebox-45b31c4a25e140cf6c20cd1430b776d5ec26391e.tar.xz
usb: storage: support USB disks up to 2TiB of size
SCSI Read Capacity (10) only supports up to 0xFFFF_FFFF sectors at most, which at 512 bytes per sector equals a disk size of 2 TiB. Due to barebox block layer limits, however, the barebox mass storage driver doesn't address sectors that need more than 31 bits to describe. These block layer limits were removed in a previous commit, so make the USB driver use the full 32 bit to support 512-byte sector USB disks up to 2 TiB of size. Disks that are larger than that must either implement SCSI Read Capacity (16) to support up to 16 Exabytes or increase the sector size beyond 512 bytes. This commit doesn't do that as I don't have the suitable hardware to test. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/storage/usb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 4a46bc14fd..c264dd4b71 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -305,10 +305,11 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
return result;
}
- if (last_lba > INT_MAX - 1) {
- last_lba = INT_MAX - 1;
+ if (last_lba == U32_MAX) {
+ last_lba = U32_MAX - 1;
dev_warn(dev,
- "Limiting device size due to 31 bit contraints\n");
+ "Limiting device size due to 32 bit constraints\n");
+ /* To support LBA >= U32_MAX, a READ CAPACITY (16) should be issued here */
}
pblk_dev->blk.num_blocks = last_lba + 1;