Re: [patch] Re: PYXIS bug detection

From: Ivan Kokshaysky (ink@jurassic.park.msu.ru)
Date: Fri Dec 21 2001 - 06:13:13 EST


On Fri, Dec 21, 2001 at 02:28:20AM +0100, Kurt Garloff wrote:
> Floppy access won't work anymore. Instead I get those:
>
> Dec 21 02:04:18 pws kernel: pci_map_single failed: no hw sg

Ugh. I should notice that myself, thanks.
This also fixes potential NULL pointer deference in pci_map_sg.

Ivan.

--- linux/arch/alpha/kernel/pci_iommu.c.orig Mon Nov 5 20:47:41 2001
+++ linux/arch/alpha/kernel/pci_iommu.c Fri Dec 21 12:42:20 2001
@@ -171,6 +171,8 @@ iommu_arena_free(struct pci_iommu_arena
                 p[i] = 0;
 }
 
+dma_addr_t isa_dma_mask = 0x00ffffff;
+
 /* Map a single buffer of the indicated size for PCI DMA in streaming
    mode. The 32-bit PCI bus mastering address to use is returned.
    Once the device is given the dma address, the device owns this memory
@@ -181,7 +183,7 @@ pci_map_single_1(struct pci_dev *pdev, v
                  int dac_allowed)
 {
         struct pci_controller *hose = pdev ? pdev->sysdata : pci_isa_hose;
- dma_addr_t max_dma = pdev ? pdev->dma_mask : 0x00ffffff;
+ dma_addr_t max_dma = pdev ? pdev->dma_mask : isa_dma_mask;
         struct pci_iommu_arena *arena;
         long npages, dma_ofs, i;
         unsigned long paddr;
@@ -558,7 +560,7 @@ pci_map_sg(struct pci_dev *pdev, struct
         if (direction == PCI_DMA_NONE)
                 BUG();
 
- dac_allowed = ((pdev->dma_mask >> 32) != 0);
+ dac_allowed = (pdev ? (pdev->dma_mask >> 32) != 0 : 0);
 
         /* Fast path single entry scatterlists. */
         if (nents == 1) {
@@ -578,7 +580,7 @@ pci_map_sg(struct pci_dev *pdev, struct
         /* Second, figure out where we're going to map things. */
         if (alpha_mv.mv_pci_tbi) {
                 hose = pdev ? pdev->sysdata : pci_isa_hose;
- max_dma = pdev ? pdev->dma_mask : 0x00ffffff;
+ max_dma = pdev ? pdev->dma_mask : isa_dma_mask;
                 arena = hose->sg_pci;
                 if (!arena || arena->dma_base + arena->size > max_dma)
                         arena = hose->sg_isa;
@@ -641,7 +643,7 @@ pci_unmap_sg(struct pci_dev *pdev, struc
                 return;
 
         hose = pdev ? pdev->sysdata : pci_isa_hose;
- max_dma = pdev ? pdev->dma_mask : 0x00ffffff;
+ max_dma = pdev ? pdev->dma_mask : isa_dma_mask;
         arena = hose->sg_pci;
         if (!arena || arena->dma_base + arena->size > max_dma)
                 arena = hose->sg_isa;
--- linux/arch/alpha/kernel/sys_miata.c.orig Fri Dec 21 12:26:03 2001
+++ linux/arch/alpha/kernel/sys_miata.c Fri Dec 21 13:07:00 2001
@@ -226,6 +226,8 @@ miata_swizzle(struct pci_dev *dev, u8 *p
         return slot;
 }
 
+extern dma_addr_t isa_dma_mask;
+
 static void __init
 miata_init_pci(void)
 {
@@ -236,6 +238,8 @@ miata_init_pci(void)
            MIATAs, so disable SG DMA on such machines. */
         if (!SMC669_Init(0)) { /* MIATA GL has SMC37c669 Super I/O */
                 alpha_mv.mv_pci_tbi = NULL;
+ /* Fortunately the ISA DMA controller is 32-bit. */
+ isa_dma_mask = 0xffffffff;
                 printk(KERN_INFO "pci: pyxis 8K boundary dma bug - "
                                  "sg dma disabled\n");
         }
-
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html



This archive was generated by hypermail 2b29 : Sun Dec 23 2001 - 21:00:33 EST