Changeset 80 for trunk/src/os2ahci/pci.c


Ignore:
Timestamp:
Mar 1, 2011, 10:10:11 AM (14 years ago)
Author:
chris
Message:

Version 1.06
============

  • Finally came across a BIOS which accesses the ICH7/8 controller via SATA registers (i.e. not AHCI mode). This required a few changes to the code at boot time because it turned out that COMRESETs are required whenever switching to/from AHCI mode to allow the AHCI or SATA controller to re-discover the attached devices:
  • 'init_reset' will now be forced on when finding a controller in non-AHCI mode at boot time.
  • A COMRESET is initiated for each implemented port after turning off AHCI mode when restoring the BIOS configuration; this is done only for Intel controllers at this point because they map the AHCI port SCR MMIO registers even when not in AHCI mode.
  • apm_suspend() has been adjusted to restore the BIOS configuration to prevent needless timeouts when the BIOS takes over during suspend or power-off operations.
  • Small changes to the functions which save/restore BIOS/port settings to avoid pitfalls; among others, the port save/restore code now also saves and restores the port's engine status.
  • Improvements to debug logging around port resets.
  • Moved code to clear pending interrupts from ahci_reset_port() to ahci_stop_port() because both need it and resetting a port involves stopping it, first.
  • NCQ mode has found to cause problems on a Dell D630. This may be related to the hard disk used for the test but since I've never seen more than one queued command regardless of the I/O load (even during simulaneous xcopy operations), NCQ mode is now off by default and needs to be turned on via the /N switch (i.e. the the /N switch now has a reversed meaning).
  • Removed the code which attempts to establish another MMIO base address in case the one assigned by the BIOS can't be reserved via resource manager; if there's a conflict, it's extremely unlikely we would ever be able to restore the BIOS MMIO address at boot time without the BIOS clashing with whatever conflicts with the MMIO address, thus there's no point trying to do any of this.
  • Implemented a reset context hook watchdog; in the early boot phase, some components apparently don't yield the CPU so the context hook will never execute without the watchdog. Now we'll give the context hook 10 seconds to execute, otherwise the watchdog will expire and we'll call the context hook directly from the corresponding timer callback.
File:
1 edited

Legend:

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

    r79 r80  
    183183 * other strings
    184184 */
    185 static char s_already_claimed[] = "Warning: device already claimed by other driver.\n";
     185static char s_already_claimed[] = "Warning: device already claimed by another driver.\n";
    186186
    187187
     
    684684   *       the MMIO base address register (BAR), read back the resulting value
    685685   *       and check the 0 bits from the right end. After doing this, we must
    686    *       restore the original value set up by the BIOS because we're not yet
    687    *       ready to take over.
     686   *       restore the original value set up by the BIOS.
    688687   *
    689688   * The least significant 4 bits are not relevant for the MMIO address, thus
     
    713712       mmio_size <<= 1);
    714713
    715   ddprintf("MMIO size            = %ld\n", mmio_size);
    716   ddprintf("MMIO address (BIOS)  = 0x%08lx\n", mmio_bios & 0xfffffff0UL);
     714  ddprintf("MMIO size    = %ld\n", mmio_size);
     715  ddprintf("MMIO address = 0x%08lx\n", mmio_bios & 0xfffffff0UL);
    717716
    718717  /* register BIOS MMIO address space with resource manager */
     
    724723
    725724  ret = RMAllocResource(rm_drvh, &ad_info->rm_mmio, &resource);
    726 
    727725  if (ret != RMRC_SUCCESS) {
    728726    if (ret == RMRC_RES_ALREADY_CLAIMED) {
    729       /* MT: according to my observations, this is the 2nd place
    730        * where we could fail due to the adapter having been already
    731        * claimed by another driver...
    732        */
    733727      cprintf(s_already_claimed);
    734       return;
     728    } else {
     729      cprintf("error: couldn't register MMIO region (rc = %d)\n", ret);
    735730    }
    736     /* didn't work; try to find another MMIO region */
    737     cprintf("warning: BIOS MMIO address not accepted by resource manager "
    738             "(code %d)\n", ret);
    739     memset(&resource, 0x00, sizeof(resource));
    740     resource.ResourceType         = RS_TYPE_MEM;
    741     resource.MEMResource.MemSize  = mmio_size;
    742     resource.MEMResource.MemFlags = RS_MEM_EXCLUSIVE | RS_SEARCH;
    743    
    744     ret = RMAllocResource(rm_drvh, &ad_info->rm_mmio, &resource);
    745    
    746     if (ret == RMRC_SUCCESS) {
    747       /* MT: got a new address from Resource Manager; now we
    748        * need to tell PCI about the new address.
    749        * Leave the last 4 bits of the original MMIO value alone.
    750        */
    751       mmio_bios = (mmio_bios & 0x0000000fUL) |
    752         (resource.MEMResource.MemBase & 0xfffffff0UL);
    753       ddprintf("address we got from RM: 0x%08lx\n",
    754                resource.MEMResource.MemBase);
    755       ddprintf("setting new MMIO addr to 0x%08lx\n", mmio_bios);
    756      
    757       if (pci_write_conf(bus, dev_func, AHCI_MMIO,
    758                          sizeof(u32), mmio_bios) != OH_SUCCESS) {
    759         /* failed to update MMIO address - bail out */
    760         cprintf("error: couldn't update MMIO address\n");
    761         ret = ~RMRC_SUCCESS;
    762         return;
    763       }
    764     }
    765   }
    766 
    767   if (ret != RMRC_SUCCESS) {
    768     cprintf("error: couldn't register MMIO region (rc = %d)\n", ret);
    769731    return;
    770732  }
    771733  rc_list->hResource[rc_list->NumResource++] = ad_info->rm_mmio;
    772   ddprintf("MMIO address (final) = 0x%08lx\n", resource.MEMResource.MemBase);
    773734
    774735  /****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.