[PATCH] libata: add ap->pflags and move core dynamic flags to it

ap->flags is way too clamped. Separate out core dynamic flags to
ap->pflags. ATA_FLAG_DISABLED is a dynamic flag but left alone as
it's referenced by a lot of LLDs and it's gonna be removed once all
LLDs are converted to new EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik b51e9e5d e6d902a3

+58 -52
+1 -1
drivers/scsi/ahci.c
··· 1052 1052 1053 1053 static void ahci_error_handler(struct ata_port *ap) 1054 1054 { 1055 - if (!(ap->flags & ATA_FLAG_FROZEN)) { 1055 + if (!(ap->pflags & ATA_PFLAG_FROZEN)) { 1056 1056 /* restart engine */ 1057 1057 ahci_stop_engine(ap); 1058 1058 ahci_start_engine(ap);
+12 -12
drivers/scsi/libata-core.c
··· 907 907 { 908 908 int rc; 909 909 910 - if (ap->flags & ATA_FLAG_FLUSH_PORT_TASK) 910 + if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK) 911 911 return; 912 912 913 913 PREPARE_WORK(&ap->port_task, fn, data); ··· 938 938 DPRINTK("ENTER\n"); 939 939 940 940 spin_lock_irqsave(ap->lock, flags); 941 - ap->flags |= ATA_FLAG_FLUSH_PORT_TASK; 941 + ap->pflags |= ATA_PFLAG_FLUSH_PORT_TASK; 942 942 spin_unlock_irqrestore(ap->lock, flags); 943 943 944 944 DPRINTK("flush #1\n"); ··· 957 957 } 958 958 959 959 spin_lock_irqsave(ap->lock, flags); 960 - ap->flags &= ~ATA_FLAG_FLUSH_PORT_TASK; 960 + ap->pflags &= ~ATA_PFLAG_FLUSH_PORT_TASK; 961 961 spin_unlock_irqrestore(ap->lock, flags); 962 962 963 963 if (ata_msg_ctl(ap)) ··· 1009 1009 spin_lock_irqsave(ap->lock, flags); 1010 1010 1011 1011 /* no internal command while frozen */ 1012 - if (ap->flags & ATA_FLAG_FROZEN) { 1012 + if (ap->pflags & ATA_PFLAG_FROZEN) { 1013 1013 spin_unlock_irqrestore(ap->lock, flags); 1014 1014 return AC_ERR_SYSTEM; 1015 1015 } ··· 2641 2641 2642 2642 /* if SATA, resume phy */ 2643 2643 if (ap->cbl == ATA_CBL_SATA) { 2644 - if (ap->flags & ATA_FLAG_LOADING) 2644 + if (ap->pflags & ATA_PFLAG_LOADING) 2645 2645 timing = sata_deb_timing_boot; 2646 2646 else 2647 2647 timing = sata_deb_timing_eh; ··· 4294 4294 unsigned int i; 4295 4295 4296 4296 /* no command while frozen */ 4297 - if (unlikely(ap->flags & ATA_FLAG_FROZEN)) 4297 + if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) 4298 4298 return NULL; 4299 4299 4300 4300 /* the last tag is reserved for internal command. */ ··· 4416 4416 * taken care of. 4417 4417 */ 4418 4418 if (ap->ops->error_handler) { 4419 - WARN_ON(ap->flags & ATA_FLAG_FROZEN); 4419 + WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); 4420 4420 4421 4421 if (unlikely(qc->err_mask)) 4422 4422 qc->flags |= ATA_QCFLAG_FAILED; ··· 5051 5051 { 5052 5052 struct ata_port *ap = dev->ap; 5053 5053 5054 - if (ap->flags & ATA_FLAG_SUSPENDED) { 5054 + if (ap->pflags & ATA_PFLAG_SUSPENDED) { 5055 5055 struct ata_device *failed_dev; 5056 5056 5057 5057 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 5058 5058 ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 200000); 5059 5059 5060 - ap->flags &= ~ATA_FLAG_SUSPENDED; 5060 + ap->pflags &= ~ATA_PFLAG_SUSPENDED; 5061 5061 while (ata_set_mode(ap, &failed_dev)) 5062 5062 ata_dev_disable(failed_dev); 5063 5063 } ··· 5088 5088 5089 5089 if (state.event != PM_EVENT_FREEZE) 5090 5090 ata_standby_drive(dev); 5091 - ap->flags |= ATA_FLAG_SUSPENDED; 5091 + ap->pflags |= ATA_PFLAG_SUSPENDED; 5092 5092 return 0; 5093 5093 } 5094 5094 ··· 5459 5459 ap->eh_info.probe_mask = (1 << ATA_MAX_DEVICES) - 1; 5460 5460 ap->eh_info.action |= ATA_EH_SOFTRESET; 5461 5461 5462 - ap->flags |= ATA_FLAG_LOADING; 5462 + ap->pflags |= ATA_PFLAG_LOADING; 5463 5463 ata_port_schedule_eh(ap); 5464 5464 5465 5465 spin_unlock_irqrestore(ap->lock, flags); ··· 5527 5527 5528 5528 /* tell EH we're leaving & flush EH */ 5529 5529 spin_lock_irqsave(ap->lock, flags); 5530 - ap->flags |= ATA_FLAG_UNLOADING; 5530 + ap->pflags |= ATA_PFLAG_UNLOADING; 5531 5531 spin_unlock_irqrestore(ap->lock, flags); 5532 5532 5533 5533 ata_port_wait_eh(ap);
+25 -25
drivers/scsi/libata-eh.c
··· 270 270 ap->eh_context.i = ap->eh_info; 271 271 memset(&ap->eh_info, 0, sizeof(ap->eh_info)); 272 272 273 - ap->flags |= ATA_FLAG_EH_IN_PROGRESS; 274 - ap->flags &= ~ATA_FLAG_EH_PENDING; 273 + ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 274 + ap->pflags &= ~ATA_PFLAG_EH_PENDING; 275 275 276 276 spin_unlock_irqrestore(ap_lock, flags); 277 277 278 278 /* invoke EH. if unloading, just finish failed qcs */ 279 - if (!(ap->flags & ATA_FLAG_UNLOADING)) 279 + if (!(ap->pflags & ATA_PFLAG_UNLOADING)) 280 280 ap->ops->error_handler(ap); 281 281 else 282 282 ata_eh_finish(ap); ··· 287 287 */ 288 288 spin_lock_irqsave(ap_lock, flags); 289 289 290 - if (ap->flags & ATA_FLAG_EH_PENDING) { 290 + if (ap->pflags & ATA_PFLAG_EH_PENDING) { 291 291 if (--repeat_cnt) { 292 292 ata_port_printk(ap, KERN_INFO, 293 293 "EH pending after completion, " ··· 323 323 /* clean up */ 324 324 spin_lock_irqsave(ap_lock, flags); 325 325 326 - if (ap->flags & ATA_FLAG_LOADING) { 327 - ap->flags &= ~ATA_FLAG_LOADING; 326 + if (ap->pflags & ATA_PFLAG_LOADING) { 327 + ap->pflags &= ~ATA_PFLAG_LOADING; 328 328 } else { 329 - if (ap->flags & ATA_FLAG_SCSI_HOTPLUG) 329 + if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) 330 330 queue_work(ata_aux_wq, &ap->hotplug_task); 331 - if (ap->flags & ATA_FLAG_RECOVERED) 331 + if (ap->pflags & ATA_PFLAG_RECOVERED) 332 332 ata_port_printk(ap, KERN_INFO, "EH complete\n"); 333 333 } 334 334 335 - ap->flags &= ~(ATA_FLAG_SCSI_HOTPLUG | ATA_FLAG_RECOVERED); 335 + ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); 336 336 337 337 /* tell wait_eh that we're done */ 338 - ap->flags &= ~ATA_FLAG_EH_IN_PROGRESS; 338 + ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; 339 339 wake_up_all(&ap->eh_wait_q); 340 340 341 341 spin_unlock_irqrestore(ap_lock, flags); ··· 360 360 retry: 361 361 spin_lock_irqsave(ap->lock, flags); 362 362 363 - while (ap->flags & (ATA_FLAG_EH_PENDING | ATA_FLAG_EH_IN_PROGRESS)) { 363 + while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { 364 364 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); 365 365 spin_unlock_irqrestore(ap->lock, flags); 366 366 schedule(); ··· 489 489 WARN_ON(!ap->ops->error_handler); 490 490 491 491 qc->flags |= ATA_QCFLAG_FAILED; 492 - qc->ap->flags |= ATA_FLAG_EH_PENDING; 492 + qc->ap->pflags |= ATA_PFLAG_EH_PENDING; 493 493 494 494 /* The following will fail if timeout has already expired. 495 495 * ata_scsi_error() takes care of such scmds on EH entry. ··· 513 513 { 514 514 WARN_ON(!ap->ops->error_handler); 515 515 516 - ap->flags |= ATA_FLAG_EH_PENDING; 516 + ap->pflags |= ATA_PFLAG_EH_PENDING; 517 517 scsi_schedule_eh(ap->host); 518 518 519 519 DPRINTK("port EH scheduled\n"); ··· 578 578 if (ap->ops->freeze) 579 579 ap->ops->freeze(ap); 580 580 581 - ap->flags |= ATA_FLAG_FROZEN; 581 + ap->pflags |= ATA_PFLAG_FROZEN; 582 582 583 583 DPRINTK("ata%u port frozen\n", ap->id); 584 584 } ··· 646 646 647 647 spin_lock_irqsave(ap->lock, flags); 648 648 649 - ap->flags &= ~ATA_FLAG_FROZEN; 649 + ap->pflags &= ~ATA_PFLAG_FROZEN; 650 650 651 651 if (ap->ops->thaw) 652 652 ap->ops->thaw(ap); ··· 731 731 732 732 if (ata_scsi_offline_dev(dev)) { 733 733 dev->flags |= ATA_DFLAG_DETACHED; 734 - ap->flags |= ATA_FLAG_SCSI_HOTPLUG; 734 + ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; 735 735 } 736 736 737 737 /* clear per-dev EH actions */ ··· 761 761 762 762 spin_lock_irqsave(ap->lock, flags); 763 763 ata_eh_clear_action(dev, &ap->eh_info, action); 764 - ap->flags |= ATA_FLAG_RECOVERED; 764 + ap->pflags |= ATA_PFLAG_RECOVERED; 765 765 spin_unlock_irqrestore(ap->lock, flags); 766 766 } 767 767 ··· 1027 1027 int tag, rc; 1028 1028 1029 1029 /* if frozen, we can't do much */ 1030 - if (ap->flags & ATA_FLAG_FROZEN) 1030 + if (ap->pflags & ATA_PFLAG_FROZEN) 1031 1031 return; 1032 1032 1033 1033 /* is it NCQ device error? */ ··· 1327 1327 } 1328 1328 1329 1329 /* enforce default EH actions */ 1330 - if (ap->flags & ATA_FLAG_FROZEN || 1330 + if (ap->pflags & ATA_PFLAG_FROZEN || 1331 1331 all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) 1332 1332 action |= ATA_EH_SOFTRESET; 1333 1333 else if (all_err_mask) ··· 1385 1385 return; 1386 1386 1387 1387 frozen = ""; 1388 - if (ap->flags & ATA_FLAG_FROZEN) 1388 + if (ap->pflags & ATA_PFLAG_FROZEN) 1389 1389 frozen = " frozen"; 1390 1390 1391 1391 if (ehc->i.dev) { ··· 1465 1465 struct ata_eh_context *ehc = &ap->eh_context; 1466 1466 unsigned int *classes = ehc->classes; 1467 1467 int tries = ATA_EH_RESET_TRIES; 1468 - int verbose = !(ap->flags & ATA_FLAG_LOADING); 1468 + int verbose = !(ap->pflags & ATA_PFLAG_LOADING); 1469 1469 unsigned int action; 1470 1470 ata_reset_fn_t reset; 1471 1471 int i, did_followup_srst, rc; ··· 1636 1636 } 1637 1637 1638 1638 spin_lock_irqsave(ap->lock, flags); 1639 - ap->flags |= ATA_FLAG_SCSI_HOTPLUG; 1639 + ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; 1640 1640 spin_unlock_irqrestore(ap->lock, flags); 1641 1641 } 1642 1642 } ··· 1673 1673 struct ata_eh_context *ehc = &ap->eh_context; 1674 1674 int i; 1675 1675 1676 - if (ap->flags & ATA_FLAG_FROZEN || ata_port_nr_enabled(ap)) 1676 + if (ap->pflags & ATA_PFLAG_FROZEN || ata_port_nr_enabled(ap)) 1677 1677 return 0; 1678 1678 1679 1679 /* skip if class codes for all vacant slots are ATA_DEV_NONE */ ··· 1744 1744 rc = 0; 1745 1745 1746 1746 /* if UNLOADING, finish immediately */ 1747 - if (ap->flags & ATA_FLAG_UNLOADING) 1747 + if (ap->pflags & ATA_PFLAG_UNLOADING) 1748 1748 goto out; 1749 1749 1750 1750 /* skip EH if possible. */ ··· 1908 1908 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1909 1909 ata_postreset_fn_t postreset) 1910 1910 { 1911 - if (!(ap->flags & ATA_FLAG_LOADING)) { 1911 + if (!(ap->pflags & ATA_PFLAG_LOADING)) { 1912 1912 ata_eh_autopsy(ap); 1913 1913 ata_eh_report(ap); 1914 1914 }
+1 -1
drivers/scsi/libata-scsi.c
··· 2930 2930 struct ata_port *ap = data; 2931 2931 int i; 2932 2932 2933 - if (ap->flags & ATA_FLAG_UNLOADING) { 2933 + if (ap->pflags & ATA_PFLAG_UNLOADING) { 2934 2934 DPRINTK("ENTER/EXIT - unloading\n"); 2935 2935 return; 2936 2936 }
+1 -1
drivers/scsi/sata_sil.c
··· 370 370 * during hardreset makes controllers with broken SIEN 371 371 * repeat probing needlessly. 372 372 */ 373 - if (!(ap->flags & ATA_FLAG_FROZEN)) { 373 + if (!(ap->pflags & ATA_PFLAG_FROZEN)) { 374 374 ata_ehi_hotplugged(&ap->eh_info); 375 375 ap->eh_info.serror |= serror; 376 376 }
+18 -12
include/linux/libata.h
··· 160 160 ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */ 161 161 ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H 162 162 * Register FIS clearing BSY */ 163 - 164 163 ATA_FLAG_DEBUGMSG = (1 << 13), 165 - ATA_FLAG_FLUSH_PORT_TASK = (1 << 14), /* flush port task */ 166 164 167 - ATA_FLAG_EH_PENDING = (1 << 15), /* EH pending */ 168 - ATA_FLAG_EH_IN_PROGRESS = (1 << 16), /* EH in progress */ 169 - ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */ 170 - ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */ 171 - ATA_FLAG_LOADING = (1 << 19), /* boot/loading probe */ 172 - ATA_FLAG_UNLOADING = (1 << 20), /* module is unloading */ 173 - ATA_FLAG_SCSI_HOTPLUG = (1 << 21), /* SCSI hotplug scheduled */ 165 + /* The following flag belongs to ap->pflags but is kept in 166 + * ap->flags because it's referenced in many LLDs and will be 167 + * removed in not-too-distant future. 168 + */ 169 + ATA_FLAG_DISABLED = (1 << 23), /* port is disabled, ignore it */ 174 170 175 - ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */ 176 - ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */ 171 + /* bits 24:31 of ap->flags are reserved for LLD specific flags */ 177 172 178 - /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ 173 + /* struct ata_port pflags */ 174 + ATA_PFLAG_EH_PENDING = (1 << 0), /* EH pending */ 175 + ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */ 176 + ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */ 177 + ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */ 178 + ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ 179 + ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ 180 + ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ 181 + 182 + ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ 183 + ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 179 184 180 185 /* struct ata_queued_cmd flags */ 181 186 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ ··· 491 486 const struct ata_port_operations *ops; 492 487 spinlock_t *lock; 493 488 unsigned long flags; /* ATA_FLAG_xxx */ 489 + unsigned int pflags; /* ATA_PFLAG_xxx */ 494 490 unsigned int id; /* unique id req'd by scsi midlyr */ 495 491 unsigned int port_no; /* unique port #; from zero */ 496 492 unsigned int hard_port_no; /* hardware port #; from zero */