Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP


1662 
1663         rv = ddi_dma_alloc_handle(dca->dca_dip, &dca_dmaattr,
1664             DDI_DMA_SLEEP, NULL, &reqp->dr_chain_out_dmah);
1665         if (rv != DDI_SUCCESS) {
1666                 dca_error(dca, "failure allocating chain_out DMA handle");
1667                 dca_destroyreq(reqp);
1668                 return (NULL);
1669         }
1670 
1671         /*
1672          * for driver hardening, allocate in whole pages.
1673          */
1674         size = ROUNDUP(MAXPACKET, dca->dca_pagesize);
1675 #if defined(i386) || defined(__i386)
1676         /*
1677          * Use kmem_alloc instead of ddi_dma_mem_alloc here since the latter
1678          * may fail on x86 platform if a physically contiguous memory chunk
1679          * cannot be found. From initial testing, we did not see performance
1680          * degradation as seen on Sparc.
1681          */
1682         if ((reqp->dr_ibuf_kaddr = kmem_alloc(size, KM_SLEEP)) == NULL) {
1683                 dca_error(dca, "unable to alloc request ibuf memory");
1684                 dca_destroyreq(reqp);
1685                 return (NULL);
1686         }
1687         if ((reqp->dr_obuf_kaddr = kmem_alloc(size, KM_SLEEP)) == NULL) {
1688                 dca_error(dca, "unable to alloc request obuf memory");
1689                 dca_destroyreq(reqp);
1690                 return (NULL);
1691         }
1692 #else
1693         /*
1694          * We could kmem_alloc for Sparc too. However, it gives worse
1695          * performance when transferring more than one page data. For example,
1696          * using 4 threads and 12032 byte data and 3DES on 900MHZ Sparc system,
1697          * kmem_alloc uses 80% CPU and ddi_dma_mem_alloc uses 50% CPU for
1698          * the same throughput.
1699          */
1700         rv = ddi_dma_mem_alloc(reqp->dr_ibuf_dmah,
1701             size, &dca_bufattr,
1702             DDI_DMA_STREAMING, DDI_DMA_SLEEP, NULL, &reqp->dr_ibuf_kaddr,
1703             &size, &reqp->dr_ibuf_acch);
1704         if (rv != DDI_SUCCESS) {
1705                 dca_error(dca, "unable to alloc request DMA memory");
1706                 dca_destroyreq(reqp);
1707                 return (NULL);
1708         }
1709 
1710         rv = ddi_dma_mem_alloc(reqp->dr_obuf_dmah,
1711             size, &dca_bufattr,




1662 
1663         rv = ddi_dma_alloc_handle(dca->dca_dip, &dca_dmaattr,
1664             DDI_DMA_SLEEP, NULL, &reqp->dr_chain_out_dmah);
1665         if (rv != DDI_SUCCESS) {
1666                 dca_error(dca, "failure allocating chain_out DMA handle");
1667                 dca_destroyreq(reqp);
1668                 return (NULL);
1669         }
1670 
1671         /*
1672          * for driver hardening, allocate in whole pages.
1673          */
1674         size = ROUNDUP(MAXPACKET, dca->dca_pagesize);
1675 #if defined(i386) || defined(__i386)
1676         /*
1677          * Use kmem_alloc instead of ddi_dma_mem_alloc here since the latter
1678          * may fail on x86 platform if a physically contiguous memory chunk
1679          * cannot be found. From initial testing, we did not see performance
1680          * degradation as seen on Sparc.
1681          */
1682         reqp->dr_ibuf_kaddr = kmem_alloc(size, KM_SLEEP);
1683         reqp->dr_obuf_kaddr = kmem_alloc(size, KM_SLEEP);








1684 #else
1685         /*
1686          * We could kmem_alloc for Sparc too. However, it gives worse
1687          * performance when transferring more than one page data. For example,
1688          * using 4 threads and 12032 byte data and 3DES on 900MHZ Sparc system,
1689          * kmem_alloc uses 80% CPU and ddi_dma_mem_alloc uses 50% CPU for
1690          * the same throughput.
1691          */
1692         rv = ddi_dma_mem_alloc(reqp->dr_ibuf_dmah,
1693             size, &dca_bufattr,
1694             DDI_DMA_STREAMING, DDI_DMA_SLEEP, NULL, &reqp->dr_ibuf_kaddr,
1695             &size, &reqp->dr_ibuf_acch);
1696         if (rv != DDI_SUCCESS) {
1697                 dca_error(dca, "unable to alloc request DMA memory");
1698                 dca_destroyreq(reqp);
1699                 return (NULL);
1700         }
1701 
1702         rv = ddi_dma_mem_alloc(reqp->dr_obuf_dmah,
1703             size, &dca_bufattr,