[haiku-commits] r35087 - haiku/trunk/src/add-ons/kernel/generic/ata_adapter

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 15 Jan 2010 20:21:52 +0100 (CET)

Author: mmlr
Date: 2010-01-15 20:21:52 +0100 (Fri, 15 Jan 2010)
New Revision: 35087
Changeset: http://dev.haiku-os.org/changeset/35087/haiku

Modified:
   haiku/trunk/src/add-ons/kernel/generic/ata_adapter/ata_adapter.c
Log:
* Don't call into the ATA stack if we're not transferring data since the
  interrupt could be triggered early in the boot process where the ATA channel
  might not yet be fully set up leading to KDLs accessing uninitialized memory.
* Automatic whitespace cleanup


Modified: haiku/trunk/src/add-ons/kernel/generic/ata_adapter/ata_adapter.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/generic/ata_adapter/ata_adapter.c    
2010-01-15 12:35:37 UTC (rev 35086)
+++ haiku/trunk/src/add-ons/kernel/generic/ata_adapter/ata_adapter.c    
2010-01-15 19:21:52 UTC (rev 35087)
@@ -25,7 +25,7 @@
 #define TRACE dprintf
 
 #define INTERRUPT_TRACING 0
-#if INTERRUPT_TRACING 
+#if INTERRUPT_TRACING
        #define TRACE_INT(a...)         ktrace_printf(a)
 #else
        #define TRACE_INT(a...)
@@ -213,11 +213,18 @@
                statusATA = pci->read_io_8(device, channel->command_block_base 
+ 7);
                TRACE_INT("ata_adapter_inthand: ATA-status 0x%02x\n", 
statusATA);
 
-               // clear pending PCI bus master DMA interrupt, for those 
+               // clear pending PCI bus master DMA interrupt, for those
                // controllers who don't clear it themselves
                pci->write_io_8(device, channel->bus_master_base + 
ATA_BM_STATUS_REG,
                        (statusBM & 0xf8) | ATA_BM_STATUS_INTERRUPT);
 
+               if (!channel->dmaing) {
+                       // we check this late so that potential spurious 
interrupts
+                       // are acknoledged above
+                       TRACE_INT("ata_adapter_inthand: no DMA transfer 
active\n");
+                       return B_UNHANDLED_INTERRUPT;
+               }
+
                // signal interrupt to ATA stack
                return sATA->interrupt_handler(channel->ataChannel, statusATA);
        } else {
@@ -238,7 +245,7 @@
        prd_entry *prd = channel->prdt;
        int i;
 
-       TRACE_DMA("ata_adapter: prepare_dma (%s) %u entrys:\n", 
+       TRACE_DMA("ata_adapter: prepare_dma (%s) %u entrys:\n",
                writeToDevice ? "write" : "read", sgListCount);
 
        for (i = sgListCount - 1, prd = channel->prdt; i >= 0; --i, ++prd, 
++sgList) {
@@ -247,7 +254,7 @@
                prd->count = B_HOST_TO_LENDIAN_INT16((uint16)sgList->size);
                prd->EOT = i == 0;
 
-               TRACE_DMA("ata_adapter: %p, %ld => 0x%08x, %d, %d\n", 
+               TRACE_DMA("ata_adapter: %p, %ld => 0x%08x, %d, %d\n",
                        sgList->address, sgList->size, prd->address, 
prd->count, prd->EOT);
                SHOW_FLOW( 4, "%x, %x, %d", (int)prd->address, prd->count, 
prd->EOT);
        }
@@ -564,7 +571,7 @@
        }
        if (pcicmdOld != pcicmdNew) {
                pci->write_pci_config(pci_device, PCI_command, 2, pcicmdNew);
-               TRACE("PCI-ATA: pcicmd changed from 0x%04x to 0x%04x\n", 
+               TRACE("PCI-ATA: pcicmd changed from 0x%04x to 0x%04x\n",
                        pcicmdOld, pcicmdNew);
        }
 
@@ -644,7 +651,7 @@
        }
        if (pcicmdOld != pcicmdNew) {
                pci->write_pci_config(node, PCI_command, 2, pcicmdNew);
-               TRACE("PCI-ATA: adapter init: pcicmd old 0x%04x, new 0x%04x\n", 
+               TRACE("PCI-ATA: adapter init: pcicmd old 0x%04x, new 0x%04x\n",
                        pcicmdOld, pcicmdNew);
        }
 #endif


Other related posts:

  • » [haiku-commits] r35087 - haiku/trunk/src/add-ons/kernel/generic/ata_adapter - mmlr