Commit a5abd260 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide: limit drive capacity to 137GB if host doesn't support LBA48

Noticed by Andries.Brouwer@cwi.nl.

Also:
- kill probe_lba_addressing() wrapper
- rename hwif->addressing to hwif->no_lba48
parent 79d0f514
......@@ -1445,11 +1445,17 @@ static int set_using_tcq(ide_drive_t *drive, int arg)
}
#endif
static int probe_lba_addressing (ide_drive_t *drive, int arg)
/*
* drive->addressing:
* 0: 28-bit
* 1: 48-bit
* 2: 48-bit capable doing 28-bit
*/
static int set_lba_addressing(ide_drive_t *drive, int arg)
{
drive->addressing = 0;
if (HWIF(drive)->addressing)
if (HWIF(drive)->no_lba48)
return 0;
if (!idedisk_supports_lba48(drive->id))
......@@ -1458,11 +1464,6 @@ static int probe_lba_addressing (ide_drive_t *drive, int arg)
return 0;
}
static int set_lba_addressing (ide_drive_t *drive, int arg)
{
return probe_lba_addressing(drive, arg);
}
static void idedisk_add_settings(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
......@@ -1578,7 +1579,7 @@ static void idedisk_setup (ide_drive_t *drive)
}
}
(void) probe_lba_addressing(drive, 1);
(void)set_lba_addressing(drive, 1);
if (drive->addressing == 1) {
ide_hwif_t *hwif = HWIF(drive);
......@@ -1617,6 +1618,15 @@ static void idedisk_setup (ide_drive_t *drive)
/* calculate drive capacity, and select LBA if possible */
init_idedisk_capacity (drive);
/* limit drive capacity to 137GB if LBA48 cannot be used */
if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) {
printk("%s: cannot use LBA48 - full capacity "
"%llu sectors (%llu MB)\n",
drive->name,
drive->capacity64, sectors_to_MB(drive->capacity64));
drive->capacity64 = 1ULL << 28;
}
/*
* if possible, give fdisk access to more of the drive,
* by correcting bios_cyls:
......
......@@ -930,7 +930,7 @@ static int ide_init_queue(ide_drive_t *drive)
blk_queue_segment_boundary(q, 0xffff);
if (!hwif->rqsize)
hwif->rqsize = hwif->addressing ? 256 : 65536;
hwif->rqsize = hwif->no_lba48 ? 256 : 65536;
if (hwif->rqsize < max_sectors)
max_sectors = hwif->rqsize;
blk_queue_max_sectors(q, max_sectors);
......
......@@ -904,7 +904,7 @@ void ide_unregister (unsigned int index)
hwif->mmio = old_hwif.mmio;
hwif->rqsize = old_hwif.rqsize;
hwif->addressing = old_hwif.addressing;
hwif->no_lba48 = old_hwif.no_lba48;
#ifndef CONFIG_BLK_DEV_IDECS
hwif->irq = old_hwif.irq;
#endif /* CONFIG_BLK_DEV_IDECS */
......
......@@ -227,7 +227,7 @@ int __init setup_pdc4030(ide_hwif_t *hwif)
hwif2->mate = hwif;
hwif2->channel = 1;
hwif->rqsize = hwif2->rqsize = 127;
hwif->addressing = hwif2->addressing = 1;
hwif->no_lba48 = hwif2->no_lba48 = 1;
hwif->selectproc = hwif2->selectproc = &promise_selectproc;
hwif->serialized = hwif2->serialized = 1;
/* DC4030 hosted drives need their own identify... */
......
......@@ -745,7 +745,7 @@ static void __init init_hwif_common_ali15x3 (ide_hwif_t *hwif)
hwif->speedproc = &ali15x3_tune_chipset;
/* Don't use LBA48 on ALi devices before rev 0xC5 */
hwif->addressing = (m5229_revision <= 0xC4) ? 1 : 0;
hwif->no_lba48 = (m5229_revision <= 0xC4) ? 1 : 0;
if (!hwif->dma_base) {
hwif->drives[0].autotune = 1;
......
......@@ -750,7 +750,7 @@ static void __init init_hwif_pdc202xx (ide_hwif_t *hwif)
hwif->quirkproc = &pdc202xx_quirkproc;
if (hwif->pci_dev->device == PCI_DEVICE_ID_PROMISE_20265)
hwif->addressing = (hwif->channel) ? 0 : 1;
hwif->no_lba48 = (hwif->channel) ? 0 : 1;
if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) {
hwif->busproc = &pdc202xx_tristate;
......
......@@ -724,7 +724,7 @@ static void __init init_mmio_iops_siimage (ide_hwif_t *hwif)
}
#ifdef SIIMAGE_BUFFERED_TASKFILE
hwif->addressing = 1;
hwif->no_lba48 = 1;
#endif /* SIIMAGE_BUFFERED_TASKFILE */
hwif->irq = hw.irq;
hwif->hwif_data = pci_get_drvdata(hwif->pci_dev);
......
......@@ -309,7 +309,7 @@ void __init init_hwif_trm290 (ide_hwif_t *hwif)
u8 reg = 0;
struct pci_dev *dev = hwif->pci_dev;
hwif->addressing = 1;
hwif->no_lba48 = 1;
hwif->chipset = ide_trm290;
cfgbase = pci_resource_start(dev, 4);
if ((dev->class & 5) && cfgbase) {
......
......@@ -1007,7 +1007,6 @@ typedef struct hwif_s {
int mmio; /* hosts iomio (0), mmio (1) or custom (2) select */
int rqsize; /* max sectors per request */
int addressing; /* hosts addressing */
int irq; /* our irq number */
int initializing; /* set while initializing self */
......@@ -1036,6 +1035,7 @@ typedef struct hwif_s {
unsigned reset : 1; /* reset after probe */
unsigned autodma : 1; /* auto-attempt using DMA at boot */
unsigned udma_four : 1; /* 1=ATA-66 capable, 0=default */
unsigned no_lba48 : 1; /* 1 = cannot do LBA48 */
unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
unsigned auto_poll : 1; /* supports nop auto-poll */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment