Changeset 13 for trunk/src/os2ahci/ahci.c
- Timestamp:
- Sep 14, 2010, 10:07:59 AM (15 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ahci.c
r12 r13 171 171 if (val & HOST_CAP_EMS) printf(" ems"); 172 172 if (val & HOST_CAP_SXS) printf(" sxs"); 173 printf(" ports:%d", (val & 0x1f) + 1); 173 printf(" cmd_slots:%d", (u16) ((val >> 8) & 0x1f) + 1); 174 printf(" ports:%d", (u16) (val & 0x1f) + 1); 174 175 175 176 } else if (i == HOST_CTL) { … … 829 830 ULONG timeout = (iorb->Timeout > 0) ? iorb->Timeout : DEFAULT_TIMEOUT; 830 831 u8 _far *port_mmio = port_base(ai, iorb_unit_port(iorb)); 832 u16 cmd_max = ai->cmd_max; 831 833 int i; 832 834 833 835 /* determine whether this will be an NCQ request */ 834 aws->is_ncq = ((ai->cap & HOST_CAP_NCQ) && ncq_capable && !aws->no_ncq);835 836 /* NCQ disabled temporarily until non-NCQ commands are fully working */837 836 aws->is_ncq = 0; 838 839 /* check whether adapter is available */ 837 if (ncq_capable && port->devs[iorb_unit_device(iorb)].ncq_max > 1 && 838 (ai->cap & HOST_CAP_NCQ) && !aws->no_ncq && init_complete) { 839 840 /* We can make this an NCQ request; limit command slots to the maximum 841 * NCQ tag number reported by the device - 1. Why "minus one"? I seem to 842 * recall an issue related to using all 32 tag numbers but can't quite 843 * pinpoint it right now. One less won't make much of a difference... 844 */ 845 aws->is_ncq = 1; 846 if ((cmd_max = port->devs[iorb_unit_device(iorb)].ncq_max - 1) > ai->cmd_max) { 847 cmd_max = ai->cmd_max; 848 } 849 ddprintf("NCQ command; cmd_max = %d->%d\n", (u16) ai->cmd_max, cmd_max); 850 } 851 852 /* make sure adapter is available */ 840 853 spin_lock(drv_lock); 841 854 if (!ai->busy) { … … 849 862 } 850 863 851 /* prevent NCQ/regular command mix */ 852 if (aws->is_ncq && port->reg_cmds == 0 || 853 !aws->is_ncq && port->ncq_cmds == 0) { 864 /* make sure we don't mix NCQ and regular commands */ 865 if (aws->is_ncq && port->reg_cmds == 0 || !aws->is_ncq && port->ncq_cmds == 0) { 854 866 855 867 /* Find next available command slot. We use a simple round-robin … … 858 870 */ 859 871 cmds = (aws->is_ncq) ? &port->ncq_cmds : &port->reg_cmds; 860 for (i = 0; i <= ai->cmd_max; i++) { 872 for (i = 0; i <= cmd_max; i++) { 873 if (++(port->cmd_slot) > cmd_max) { 874 port->cmd_slot = 0; 875 } 861 876 if ((*cmds & (1UL << port->cmd_slot)) == 0) { 862 877 break; 863 }864 if (++(port->cmd_slot) > ai->cmd_max) {865 port->cmd_slot = 0;866 878 } 867 879 } … … 895 907 readl(port_mmio + PORT_CMD_ISSUE); /* flush */ 896 908 897 /* make sure next cmd won't use the same slot to prevent starvation */898 if (++(port->cmd_slot) > ai->cmd_max) {899 port->cmd_slot = 0;900 }901 909 spin_unlock(drv_lock); 902 910 return; … … 916 924 * 917 925 * - We need to restore the BIOS configuration after we're done with this 918 * command because someone might still call int 13 routines; sending926 * command because someone might still call int 13h routines; sending 919 927 * asynchronous commands and waiting for interrupts to indicate completion 920 928 * won't work in such a scenario. … … 1226 1234 u8 _far *port_mmio = port_base(ai, p); 1227 1235 int reset_port = 0; 1236 u32 tmp; 1228 1237 1229 1238 /* Handle adapter and interface errors. Those typically require a port … … 1336 1345 dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd, 1337 1346 ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen, 1338 "ahci_execute_cdb(%d.%d.%d)", (int) iorb_unit_adapter(iorb), 1339 (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb)); 1347 "ahci_execute_cdb(%d.%d.%d)", a, p, d); 1340 1348 1341 1349 if (ad_infos[a].ports[p].devs[d].atapi) { … … 1358 1366 dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd, 1359 1367 ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen, 1360 "ahci_execute_cdb(%d.%d.%d)", (int) iorb_unit_adapter(iorb), 1361 (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb)); 1368 "ahci_execute_cdb(%d.%d.%d)", a, p, d); 1362 1369 1363 1370 if (ad_infos[a].ports[p].devs[d].atapi) { … … 1403 1410 } else { 1404 1411 /* complete ATA-specific device information */ 1405 ai->ports[p].devs[d].ncq_max = id_buf[ATA_ID_QUEUE_DEPTH] & 0x001fU; 1406 if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x40) { 1412 if (!disable_ncq[ad_no(ai)][p]) { 1413 ai->ports[p].devs[d].ncq_max = id_buf[ATA_ID_QUEUE_DEPTH] & 0x001fU; 1414 } 1415 if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x0400U) { 1407 1416 ai->ports[p].devs[d].lba48 = 1; 1408 1417 }
Note:
See TracChangeset
for help on using the changeset viewer.