add a newbus method for obtaining the bus's bus_dma_tag_t... This is
required by arches like sparc64 (not yet implemented) and sun4v where there are seperate IOMMU's for each PCI bus... For all other arches, it will end up returning NULL, which makes it a no-op... Convert a few drivers (the ones we've been working w/ on sun4v) to the new convection... Eventually all drivers will need to replace the parent tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for each driver, and will require hand inspection... Reviewed by: scottl (earlier version)
This commit is contained in:
parent
84ee477ac3
commit
c25fb06d92
@ -131,8 +131,8 @@ aic7770_attach(device_t dev)
|
||||
|
||||
/* Allocate a dmatag for our SCB DMA maps */
|
||||
/* XXX Should be a child of the PCI bus dma tag */
|
||||
error = aic_dma_tag_create(ahc, /*parent*/NULL, /*alignment*/1,
|
||||
/*boundary*/0,
|
||||
error = aic_dma_tag_create(ahc, /*parent*/bus_get_dma_tag(dev),
|
||||
/*alignment*/1, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
|
@ -254,8 +254,8 @@ ahc_isa_attach(device_t dev)
|
||||
|
||||
/* Allocate a dmatag for our SCB DMA maps */
|
||||
/* XXX Should be a child of the VLB/ISA bus dma tag */
|
||||
error = aic_dma_tag_create(ahc, /*parent*/NULL, /*alignment*/1,
|
||||
/*boundary*/0,
|
||||
error = aic_dma_tag_create(ahc, /*parent*/bus_get_dma_tag(dev),
|
||||
/*alignment*/1, /*boundary*/0,
|
||||
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
|
||||
/*highaddr*/BUS_SPACE_MAXADDR,
|
||||
/*filter*/NULL, /*filterarg*/NULL,
|
||||
|
@ -107,8 +107,8 @@ ahc_pci_attach(device_t dev)
|
||||
|
||||
/* Allocate a dmatag for our SCB DMA maps */
|
||||
/* XXX Should be a child of the PCI bus dma tag */
|
||||
error = aic_dma_tag_create(ahc, /*parent*/NULL, /*alignment*/1,
|
||||
/*boundary*/0,
|
||||
error = aic_dma_tag_create(ahc, /*parent*/bus_get_dma_tag(dev),
|
||||
/*alignment*/1, /*boundary*/0,
|
||||
(ahc->flags & AHC_39BIT_ADDRESSING)
|
||||
? 0x7FFFFFFFFFLL
|
||||
: BUS_SPACE_MAXADDR_32BIT,
|
||||
|
@ -109,8 +109,8 @@ ahd_pci_attach(device_t dev)
|
||||
|
||||
/* Allocate a dmatag for our SCB DMA maps */
|
||||
/* XXX Should be a child of the PCI bus dma tag */
|
||||
error = aic_dma_tag_create(ahd, /*parent*/NULL, /*alignment*/1,
|
||||
/*boundary*/0,
|
||||
error = aic_dma_tag_create(ahd, /*parent*/bus_get_dma_tag(dev),
|
||||
/*alignment*/1, /*boundary*/0,
|
||||
(ahd->flags & AHD_39BIT_ADDRESSING)
|
||||
? 0x7FFFFFFFFF
|
||||
: BUS_SPACE_MAXADDR_32BIT,
|
||||
|
@ -96,7 +96,7 @@ ata_dmaalloc(device_t dev)
|
||||
struct ata_channel *ch = device_get_softc(dev);
|
||||
struct ata_dc_cb_args ccba;
|
||||
|
||||
if (bus_dma_tag_create(NULL, ch->dma->alignment, 0,
|
||||
if (bus_dma_tag_create(bus_get_dma_tag(dev), ch->dma->alignment, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
||||
NULL, NULL, ch->dma->max_iosize,
|
||||
ATA_DMA_ENTRIES, ch->dma->segsize,
|
||||
|
@ -1702,7 +1702,7 @@ bge_dma_alloc(device_t dev)
|
||||
/*
|
||||
* Allocate the parent bus DMA tag appropriate for PCI.
|
||||
*/
|
||||
error = bus_dma_tag_create(NULL, /* parent */
|
||||
error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),/* parent */
|
||||
PAGE_SIZE, 0, /* alignment, boundary */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
|
@ -2389,7 +2389,7 @@ em_dma_malloc(struct adapter *adapter, bus_size_t size, struct em_dma_alloc *dma
|
||||
{
|
||||
int error;
|
||||
|
||||
error = bus_dma_tag_create(NULL, /* parent */
|
||||
error = bus_dma_tag_create(bus_get_dma_tag(adapter->dev), /* parent */
|
||||
EM_DBA_ALIGN, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
@ -2493,7 +2493,7 @@ em_setup_transmit_structures(struct adapter *adapter)
|
||||
* Setup DMA descriptor areas.
|
||||
*/
|
||||
size = roundup2(adapter->hw.max_frame_size, MCLBYTES);
|
||||
if ((error = bus_dma_tag_create(NULL, /* parent */
|
||||
if ((error = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
|
||||
1, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
@ -2905,7 +2905,7 @@ em_allocate_receive_structures(struct adapter *adapter)
|
||||
|
||||
bzero(adapter->rx_buffer_area, sizeof(struct em_buffer) * adapter->num_rx_desc);
|
||||
|
||||
error = bus_dma_tag_create(NULL, /* parent */
|
||||
error = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
|
||||
1, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
|
@ -153,9 +153,10 @@ gem_attach(sc)
|
||||
gem_reset(sc);
|
||||
GEM_UNLOCK(sc);
|
||||
|
||||
error = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
||||
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, GEM_NSEGS,
|
||||
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
|
||||
error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
||||
MCLBYTES, GEM_NSEGS, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
|
||||
&sc->sc_pdmatag);
|
||||
if (error)
|
||||
goto fail_ifnet;
|
||||
|
||||
|
@ -1442,8 +1442,9 @@ isp_pci_mbxdma(ispsoftc_t *isp)
|
||||
#endif
|
||||
|
||||
ISP_UNLOCK(isp);
|
||||
if (isp_dma_tag_create(NULL, 1, slim, llim, hlim,
|
||||
NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0, &pcs->dmat)) {
|
||||
if (isp_dma_tag_create(bus_get_dma_tag(pcs->pci_dev), 1, slim, llim,
|
||||
hlim, NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0,
|
||||
&pcs->dmat)) {
|
||||
isp_prt(isp, ISP_LOGERR, "could not create master dma tag");
|
||||
ISP_LOCK(isp);
|
||||
return (1);
|
||||
|
@ -307,10 +307,10 @@ ohci_pci_attach(device_t self)
|
||||
}
|
||||
|
||||
/* Allocate a parent dma tag for DMA maps */
|
||||
err = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT,
|
||||
BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT,
|
||||
USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
|
||||
&sc->sc_bus.parent_dmatag);
|
||||
err = bus_dma_tag_create(bus_get_dma_tag(self), 1, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
||||
BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
|
||||
NULL, NULL, &sc->sc_bus.parent_dmatag);
|
||||
if (err) {
|
||||
device_printf(self, "Could not allocate parent DMA tag (%d)\n",
|
||||
err);
|
||||
|
@ -529,3 +529,14 @@ METHOD void hinted_child {
|
||||
const char * _dname;
|
||||
int _dunit;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Returns bus_dma_tag_t for use w/ devices on the bus.
|
||||
*
|
||||
* @param _dev the parent device of @p _child
|
||||
* @param _child the device to which the tag will belong
|
||||
*/
|
||||
METHOD bus_dma_tag_t get_dma_tag {
|
||||
device_t _dev;
|
||||
device_t _child;
|
||||
} DEFAULT bus_generic_get_dma_tag;
|
||||
|
@ -3198,6 +3198,22 @@ bus_generic_config_intr(device_t dev, int irq, enum intr_trigger trig,
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper function for implementing BUS_GET_DMA_TAG().
|
||||
*
|
||||
* This simple implementation of BUS_GET_DMA_TAG() simply calls the
|
||||
* BUS_GET_DMA_TAG() method of the parent of @p dev.
|
||||
*/
|
||||
bus_dma_tag_t
|
||||
bus_generic_get_dma_tag(device_t dev, device_t child)
|
||||
{
|
||||
|
||||
/* Propagate up the bus hierarchy until someone handles it. */
|
||||
if (dev->parent != NULL)
|
||||
return (BUS_GET_DMA_TAG(dev->parent, child));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper function for implementing BUS_GET_RESOURCE().
|
||||
*
|
||||
@ -3599,6 +3615,23 @@ bus_child_location_str(device_t child, char *buf, size_t buflen)
|
||||
return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wrapper function for BUS_GET_DMA_TAG().
|
||||
*
|
||||
* This function simply calls the BUS_GET_DMA_TAG() method of the
|
||||
* parent of @p dev.
|
||||
*/
|
||||
bus_dma_tag_t
|
||||
bus_get_dma_tag(device_t dev)
|
||||
{
|
||||
device_t parent;
|
||||
|
||||
parent = device_get_parent(dev);
|
||||
if (parent == NULL)
|
||||
return (NULL);
|
||||
return (BUS_GET_DMA_TAG(parent, dev));
|
||||
}
|
||||
|
||||
/* Resume all devices and then notify userland that we're up again. */
|
||||
static int
|
||||
root_resume(device_t dev)
|
||||
|
@ -29,6 +29,8 @@
|
||||
#ifndef _SYS_BUS_H_
|
||||
#define _SYS_BUS_H_
|
||||
|
||||
#include <sys/_bus_dma.h>
|
||||
|
||||
/**
|
||||
* @defgroup NEWBUS newbus - a generic framework for managing devices
|
||||
* @{
|
||||
@ -252,6 +254,8 @@ int bus_generic_deactivate_resource(device_t dev, device_t child, int type,
|
||||
int rid, struct resource *r);
|
||||
int bus_generic_detach(device_t dev);
|
||||
void bus_generic_driver_added(device_t dev, driver_t *driver);
|
||||
bus_dma_tag_t
|
||||
bus_generic_get_dma_tag(device_t dev, device_t child);
|
||||
struct resource_list *
|
||||
bus_generic_get_resource_list (device_t, device_t);
|
||||
int bus_print_child_header(device_t dev, device_t child);
|
||||
@ -306,6 +310,7 @@ int bus_activate_resource(device_t dev, int type, int rid,
|
||||
struct resource *r);
|
||||
int bus_deactivate_resource(device_t dev, int type, int rid,
|
||||
struct resource *r);
|
||||
bus_dma_tag_t bus_get_dma_tag(device_t dev);
|
||||
int bus_release_resource(device_t dev, int type, int rid,
|
||||
struct resource *r);
|
||||
int bus_free_resource(device_t dev, int type, struct resource *r);
|
||||
|
Loading…
Reference in New Issue
Block a user