Re: alpha iommu fixes

From: Andrew Morton (andrewm@uow.edu.au)
Date: Sun May 20 2001 - 09:05:20 EST


Andrea Arcangeli wrote:
>
> [ cc'ed to l-k ]
>
> > DMA-mapping.txt assumes that it cannot fail.
>
> DMA-mapping.txt is wrong. Both pci_map_sg and pci_map_single failed if
> they returned zero. You either have to drop the skb or to try again later
> if they returns zero.
>

Well this is news to me. No drivers understand this.
How long has this been the case? What platforms?

For netdevices at least, the pci_map_single() call is always close
to the site of the skb allocation. So what we can do is to roll
them together and use the existing oom-handling associated with alloc_skb(),
assuming the driver has it...

static inline struct sk_buff *pci_alloc_skb(
                int length, int gfp_mask, int reserve,
                pci_dev *pdev, dma_addr_t *dma_addr, int direction, int irq)
{
        struct sk_buff *skb = alloc_skb(length + 16, gfp_mask);
        if (skb) {
                skb_reserve(ret, 16 + reserve);
                *dma_addr = pci_map_single(pdev, skb->tail, size - reserve, direction);
                if (*dma_addr == 0) {
                        if (irq)
                                dev_kfree_skb_irq(skb);
                        else
                                dev_kfree_skb(skb);
                        skb = 0;
                }
        }
        return skb;
}

Sticky, but a lot of it will be compiled away.

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 23 2001 - 21:00:36 EST