Ignore:
Timestamp:
Feb 16, 2011, 3:39:48 AM (14 years ago)
Author:
chris
Message:
  • ATAPI fixes; still having trouble with INQUIRY command bein sent with incorrect direction
  • fixes to port reset and restart handling
  • improved ATA IDENTIFY handling based on ATA reset signature
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/ahci.c

    r73 r74  
    408408  AHCI_PORT_CFG *pc = NULL;
    409409  u16 *id_buf;
     410  int is_ata;
    410411  int rc;
    411412  int p;
     413  int i;
    412414
    413415  spin_lock(drv_lock);
     
    453455      }
    454456
    455       /* this port has a device attached and is ready to accept commands */
     457      /* this port seems to have a device attached and ready for commands */
    456458      ddprintf("port #%d seems to be attached to a device; probing...\n", p);
    457       rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATA,
    458                                 AP_VADDR, (void _far *) id_buf, 512,
    459                                 AP_END);
    460       if (rc != 0 || id_buf[ATA_ID_CONFIG] & (1U << 15)) {
    461         /* this might be an ATAPI device; run IDENTIFY_PACKET_DEVICE */
    462         rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATAPI,
     459
     460      /* Get ATA(PI) identity. The so-called signature gives us a hint whether
     461       * this is an ATA or an ATAPI device but we'll try both in either case;
     462       * the signature will merely determine whether we're going to probe for
     463       * an ATA or ATAPI device, first, in order to reduce the chance of sending
     464       * the wrong command (which would result in a port reset given the way
     465       * ahci_exec_polled_cmd() was implemented).
     466       */
     467      is_ata = readl(port_base(ai, p) + PORT_SIG) == 0x00000101UL;
     468      for (i = 0; i < 2; i++) {
     469        rc = ahci_exec_polled_cmd(ai, p, 0, 500,
     470                                  (is_ata) ? ATA_CMD_ID_ATA : ATA_CMD_ID_ATAPI,
    463471                                  AP_VADDR, (void _far *) id_buf, 512,
    464472                                  AP_END);
     473        if (rc == 0) {
     474          break;
     475        }
     476
     477        /* try again with ATA/ATAPI swapped */
     478        is_ata = !is_ata;
    465479      }
    466480
    467481      if (rc == 0) {
    468482        /* we have a valid IDENTIFY or IDENTIFY_PACKET response */
    469         ddphex(id_buf, 512, "ATA_IDENTIFY(_PACKET) results:\n");
     483        ddphex(id_buf, 512, "ATA_IDENTIFY%s results:\n", (is_ata) ? "" : "_PACKET");
    470484        ahci_setup_device(ai, p, 0, id_buf);
    471485      } else {
     
    13991413  int d = iorb_unit_device(iorb);
    14001414
     1415  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
     1416        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
     1417        "ahci_execute_cdb(%d.%d.%d): ", a, p, d);
     1418
    14011419  if (ad_infos[a].ports[p].devs[d].atapi) {
    14021420    ahci_exec_iorb(iorb, 0, atapi_execute_cdb);
     
    14181436  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
    14191437        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
    1420         "ahci_execute_cdb(%d.%d.%d)", a, p, d);
     1438        "ahci_execute_cdb(%d.%d.%d): ", a, p, d);
    14211439
    14221440  if (ad_infos[a].ports[p].devs[d].atapi) {
     
    14611479    ai->ports[p].devs[d].atapi_16  = (id_buf[ATA_ID_CONFIG] & 0x0001U) != 0;
    14621480    ai->ports[p].devs[d].dev_type  = (id_buf[ATA_ID_CONFIG] & 0x1f00U) >> 8;
     1481    ai->ports[p].devs[d].ncq_max   = 1;
    14631482
    14641483  } else {
Note: See TracChangeset for help on using the changeset viewer.