aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-06-07 08:27:11 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-06-07 08:27:11 -0400
commit6250d3af2a1036fb356264442211a4246c7d64c7 (patch)
tree12474d59b96c0dc518159cb694f0e654cb18b5f6 /drivers/ide
parent4c9773ed7946fc375edba057770f5ef16d8b44fe (diff)
parent075affcbe01d4d7cefcd0e30a98df1253bcf8d92 (diff)
Merge branch 'for-linus' into for-next
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-disk.c71
-rw-r--r--drivers/ide/ide-gd.c14
-rw-r--r--drivers/ide/ide-pci-generic.c11
-rw-r--r--drivers/ide/ide.c10
-rw-r--r--drivers/ide/pdc202xx_old.c22
5 files changed, 102 insertions, 26 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index d345f5f23f01..b5f25387cc01 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -302,14 +302,12 @@ static const struct drive_list_entry hpa_list[] = {
302 { NULL, NULL } 302 { NULL, NULL }
303}; 303};
304 304
305static void idedisk_check_hpa(ide_drive_t *drive) 305static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48)
306{ 306{
307 unsigned long long capacity, set_max; 307 u64 capacity, set_max;
308 int lba48 = ata_id_lba48_enabled(drive->id);
309 308
310 capacity = drive->capacity64; 309 capacity = drive->capacity64;
311 310 set_max = idedisk_read_native_max_address(drive, lba48);
312 set_max = idedisk_read_native_max_address(drive, lba48);
313 311
314 if (ide_in_drive_list(drive->id, hpa_list)) { 312 if (ide_in_drive_list(drive->id, hpa_list)) {
315 /* 313 /*
@@ -320,9 +318,31 @@ static void idedisk_check_hpa(ide_drive_t *drive)
320 set_max--; 318 set_max--;
321 } 319 }
322 320
321 return set_max;
322}
323
324static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48)
325{
326 set_max = idedisk_set_max_address(drive, set_max, lba48);
327 if (set_max)
328 drive->capacity64 = set_max;
329
330 return set_max;
331}
332
333static void idedisk_check_hpa(ide_drive_t *drive)
334{
335 u64 capacity, set_max;
336 int lba48 = ata_id_lba48_enabled(drive->id);
337
338 capacity = drive->capacity64;
339 set_max = ide_disk_hpa_get_native_capacity(drive, lba48);
340
323 if (set_max <= capacity) 341 if (set_max <= capacity)
324 return; 342 return;
325 343
344 drive->probed_capacity = set_max;
345
326 printk(KERN_INFO "%s: Host Protected Area detected.\n" 346 printk(KERN_INFO "%s: Host Protected Area detected.\n"
327 "\tcurrent capacity is %llu sectors (%llu MB)\n" 347 "\tcurrent capacity is %llu sectors (%llu MB)\n"
328 "\tnative capacity is %llu sectors (%llu MB)\n", 348 "\tnative capacity is %llu sectors (%llu MB)\n",
@@ -330,13 +350,13 @@ static void idedisk_check_hpa(ide_drive_t *drive)
330 capacity, sectors_to_MB(capacity), 350 capacity, sectors_to_MB(capacity),
331 set_max, sectors_to_MB(set_max)); 351 set_max, sectors_to_MB(set_max));
332 352
333 set_max = idedisk_set_max_address(drive, set_max, lba48); 353 if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0)
354 return;
334 355
335 if (set_max) { 356 set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48);
336 drive->capacity64 = set_max; 357 if (set_max)
337 printk(KERN_INFO "%s: Host Protected Area disabled.\n", 358 printk(KERN_INFO "%s: Host Protected Area disabled.\n",
338 drive->name); 359 drive->name);
339 }
340} 360}
341 361
342static int ide_disk_get_capacity(ide_drive_t *drive) 362static int ide_disk_get_capacity(ide_drive_t *drive)
@@ -358,6 +378,8 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
358 drive->capacity64 = drive->cyl * drive->head * drive->sect; 378 drive->capacity64 = drive->cyl * drive->head * drive->sect;
359 } 379 }
360 380
381 drive->probed_capacity = drive->capacity64;
382
361 if (lba) { 383 if (lba) {
362 drive->dev_flags |= IDE_DFLAG_LBA; 384 drive->dev_flags |= IDE_DFLAG_LBA;
363 385
@@ -376,7 +398,7 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
376 "%llu sectors (%llu MB)\n", 398 "%llu sectors (%llu MB)\n",
377 drive->name, (unsigned long long)drive->capacity64, 399 drive->name, (unsigned long long)drive->capacity64,
378 sectors_to_MB(drive->capacity64)); 400 sectors_to_MB(drive->capacity64));
379 drive->capacity64 = 1ULL << 28; 401 drive->probed_capacity = drive->capacity64 = 1ULL << 28;
380 } 402 }
381 403
382 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && 404 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
@@ -392,6 +414,34 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
392 return 0; 414 return 0;
393} 415}
394 416
417static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity)
418{
419 u64 set = min(capacity, drive->probed_capacity);
420 u16 *id = drive->id;
421 int lba48 = ata_id_lba48_enabled(id);
422
423 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
424 ata_id_hpa_enabled(id) == 0)
425 goto out;
426
427 /*
428 * according to the spec the SET MAX ADDRESS command shall be
429 * immediately preceded by a READ NATIVE MAX ADDRESS command
430 */
431 capacity = ide_disk_hpa_get_native_capacity(drive, lba48);
432 if (capacity == 0)
433 goto out;
434
435 set = ide_disk_hpa_set_capacity(drive, set, lba48);
436 if (set) {
437 /* needed for ->resume to disable HPA */
438 drive->dev_flags |= IDE_DFLAG_NOHPA;
439 return set;
440 }
441out:
442 return drive->capacity64;
443}
444
395static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 445static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
396{ 446{
397 ide_drive_t *drive = q->queuedata; 447 ide_drive_t *drive = q->queuedata;
@@ -740,6 +790,7 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
740 790
741const struct ide_disk_ops ide_ata_disk_ops = { 791const struct ide_disk_ops ide_ata_disk_ops = {
742 .check = ide_disk_check, 792 .check = ide_disk_check,
793 .set_capacity = ide_disk_set_capacity,
743 .get_capacity = ide_disk_get_capacity, 794 .get_capacity = ide_disk_get_capacity,
744 .setup = ide_disk_setup, 795 .setup = ide_disk_setup,
745 .flush = ide_disk_flush, 796 .flush = ide_disk_flush,
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 4b6b71e2cdf5..214119026b3f 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -287,6 +287,19 @@ static int ide_gd_media_changed(struct gendisk *disk)
287 return ret; 287 return ret;
288} 288}
289 289
290static unsigned long long ide_gd_set_capacity(struct gendisk *disk,
291 unsigned long long capacity)
292{
293 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
294 ide_drive_t *drive = idkp->drive;
295 const struct ide_disk_ops *disk_ops = drive->disk_ops;
296
297 if (disk_ops->set_capacity)
298 return disk_ops->set_capacity(drive, capacity);
299
300 return drive->capacity64;
301}
302
290static int ide_gd_revalidate_disk(struct gendisk *disk) 303static int ide_gd_revalidate_disk(struct gendisk *disk)
291{ 304{
292 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 305 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
@@ -315,6 +328,7 @@ static struct block_device_operations ide_gd_ops = {
315 .locked_ioctl = ide_gd_ioctl, 328 .locked_ioctl = ide_gd_ioctl,
316 .getgeo = ide_gd_getgeo, 329 .getgeo = ide_gd_getgeo,
317 .media_changed = ide_gd_media_changed, 330 .media_changed = ide_gd_media_changed,
331 .set_capacity = ide_gd_set_capacity,
318 .revalidate_disk = ide_gd_revalidate_disk 332 .revalidate_disk = ide_gd_revalidate_disk
319}; 333};
320 334
diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c
index 61111fd27130..39d4e01f5c9c 100644
--- a/drivers/ide/ide-pci-generic.c
+++ b/drivers/ide/ide-pci-generic.c
@@ -33,6 +33,16 @@ static int ide_generic_all; /* Set to claim all devices */
33module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 33module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
34MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); 34MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers.");
35 35
36static void netcell_quirkproc(ide_drive_t *drive)
37{
38 /* mark words 85-87 as valid */
39 drive->id[ATA_ID_CSF_DEFAULT] |= 0x4000;
40}
41
42static const struct ide_port_ops netcell_port_ops = {
43 .quirkproc = netcell_quirkproc,
44};
45
36#define DECLARE_GENERIC_PCI_DEV(extra_flags) \ 46#define DECLARE_GENERIC_PCI_DEV(extra_flags) \
37 { \ 47 { \
38 .name = DRV_NAME, \ 48 .name = DRV_NAME, \
@@ -74,6 +84,7 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = {
74 84
75 { /* 6: Revolution */ 85 { /* 6: Revolution */
76 .name = DRV_NAME, 86 .name = DRV_NAME,
87 .port_ops = &netcell_port_ops,
77 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 88 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
78 IDE_HFLAG_TRUST_BIOS_FOR_DMA | 89 IDE_HFLAG_TRUST_BIOS_FOR_DMA |
79 IDE_HFLAG_OFF_BOARD, 90 IDE_HFLAG_OFF_BOARD,
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 92c9b90931e7..16d056939f9f 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -211,6 +211,11 @@ static unsigned int ide_noflush;
211module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); 211module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0);
212MODULE_PARM_DESC(noflush, "disable flush requests for a device"); 212MODULE_PARM_DESC(noflush, "disable flush requests for a device");
213 213
214static unsigned int ide_nohpa;
215
216module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0);
217MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device");
218
214static unsigned int ide_noprobe; 219static unsigned int ide_noprobe;
215 220
216module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); 221module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0);
@@ -281,6 +286,11 @@ static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
281 drive->name); 286 drive->name);
282 drive->dev_flags |= IDE_DFLAG_NOFLUSH; 287 drive->dev_flags |= IDE_DFLAG_NOFLUSH;
283 } 288 }
289 if (ide_nohpa & (1 << i)) {
290 printk(KERN_INFO "ide: disabling Host Protected Area for %s\n",
291 drive->name);
292 drive->dev_flags |= IDE_DFLAG_NOHPA;
293 }
284 if (ide_noprobe & (1 << i)) { 294 if (ide_noprobe & (1 << i)) {
285 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); 295 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
286 drive->dev_flags |= IDE_DFLAG_NOPROBE; 296 drive->dev_flags |= IDE_DFLAG_NOPROBE;
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 248a54bd2386..b3bc96f930a6 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 2006-2007 MontaVista Software, Inc. 3 * Copyright (C) 2006-2007, 2009 MontaVista Software, Inc.
4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
5 * 5 *
6 * Portions Copyright (C) 1999 Promise Technology, Inc. 6 * Portions Copyright (C) 1999 Promise Technology, Inc.
@@ -227,28 +227,19 @@ somebody_else:
227 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ 227 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */
228} 228}
229 229
230static void pdc202xx_reset_host (ide_hwif_t *hwif) 230static void pdc202xx_reset(ide_drive_t *drive)
231{ 231{
232 ide_hwif_t *hwif = drive->hwif;
232 unsigned long high_16 = hwif->extra_base - 16; 233 unsigned long high_16 = hwif->extra_base - 16;
233 u8 udma_speed_flag = inb(high_16 | 0x001f); 234 u8 udma_speed_flag = inb(high_16 | 0x001f);
234 235
236 printk(KERN_WARNING "PDC202xx: software reset...\n");
237
235 outb(udma_speed_flag | 0x10, high_16 | 0x001f); 238 outb(udma_speed_flag | 0x10, high_16 | 0x001f);
236 mdelay(100); 239 mdelay(100);
237 outb(udma_speed_flag & ~0x10, high_16 | 0x001f); 240 outb(udma_speed_flag & ~0x10, high_16 | 0x001f);
238 mdelay(2000); /* 2 seconds ?! */ 241 mdelay(2000); /* 2 seconds ?! */
239 242
240 printk(KERN_WARNING "PDC202XX: %s channel reset.\n",
241 hwif->channel ? "Secondary" : "Primary");
242}
243
244static void pdc202xx_reset (ide_drive_t *drive)
245{
246 ide_hwif_t *hwif = drive->hwif;
247 ide_hwif_t *mate = hwif->mate;
248
249 pdc202xx_reset_host(hwif);
250 pdc202xx_reset_host(mate);
251
252 ide_set_max_pio(drive); 243 ide_set_max_pio(drive);
253} 244}
254 245
@@ -328,9 +319,8 @@ static const struct ide_dma_ops pdc20246_dma_ops = {
328 .dma_start = ide_dma_start, 319 .dma_start = ide_dma_start,
329 .dma_end = ide_dma_end, 320 .dma_end = ide_dma_end,
330 .dma_test_irq = pdc202xx_dma_test_irq, 321 .dma_test_irq = pdc202xx_dma_test_irq,
331 .dma_lost_irq = pdc202xx_dma_lost_irq, 322 .dma_lost_irq = ide_dma_lost_irq,
332 .dma_timer_expiry = ide_dma_sff_timer_expiry, 323 .dma_timer_expiry = ide_dma_sff_timer_expiry,
333 .dma_clear = pdc202xx_reset,
334 .dma_sff_read_status = ide_dma_sff_read_status, 324 .dma_sff_read_status = ide_dma_sff_read_status,
335}; 325};
336 326