svn commit: r249853 - stable/9/sys/dev/ahci
Alexander Motin
mav at FreeBSD.org
Wed Apr 24 19:36:41 UTC 2013
Author: mav
Date: Wed Apr 24 19:36:40 2013
New Revision: 249853
URL: http://svnweb.freebsd.org/changeset/base/249853
Log:
MFC r249346:
Create controller-level DMA tag, handling range of supported addresses.
That simplifies logic for channels and gives the bus information about what
device actually allocated the tag.
Submitted by: jhb
Modified:
stable/9/sys/dev/ahci/ahci.c
stable/9/sys/dev/ahci/ahci.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/dev/ (props changed)
Modified: stable/9/sys/dev/ahci/ahci.c
==============================================================================
--- stable/9/sys/dev/ahci/ahci.c Wed Apr 24 19:33:37 2013 (r249852)
+++ stable/9/sys/dev/ahci/ahci.c Wed Apr 24 19:36:40 2013 (r249853)
@@ -459,9 +459,23 @@ ahci_attach(device_t dev)
ctlr->ccc = 0;
mtx_init(&ctlr->em_mtx, "AHCI EM lock", NULL, MTX_DEF);
ctlr->emloc = ATA_INL(ctlr->r_mem, AHCI_EM_LOC);
+
+ /* Create controller-wide DMA tag. */
+ if (bus_dma_tag_create(bus_get_dma_tag(dev), 0, 0,
+ (ctlr->caps & AHCI_CAP_64BIT) ? BUS_SPACE_MAXADDR :
+ BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+ BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED, BUS_SPACE_MAXSIZE,
+ 0, NULL, NULL, &ctlr->dma_tag)) {
+ bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid,
+ ctlr->r_mem);
+ rman_fini(&ctlr->sc_iomem);
+ return ENXIO;
+ }
+
ahci_ctlr_setup(dev);
/* Setup interrupts. */
if (ahci_setup_interrupt(dev)) {
+ bus_dma_tag_destroy(ctlr->dma_tag);
bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem);
rman_fini(&ctlr->sc_iomem);
return ENXIO;
@@ -555,6 +569,7 @@ ahci_detach(device_t dev)
}
}
pci_release_msi(dev);
+ bus_dma_tag_destroy(ctlr->dma_tag);
/* Free memory. */
rman_fini(&ctlr->sc_iomem);
if (ctlr->r_mem)
@@ -868,6 +883,14 @@ ahci_child_location_str(device_t dev, de
return (0);
}
+static bus_dma_tag_t
+ahci_get_dma_tag(device_t dev, device_t child)
+{
+ struct ahci_controller *ctlr = device_get_softc(dev);
+
+ return (ctlr->dma_tag);
+}
+
devclass_t ahci_devclass;
static device_method_t ahci_methods[] = {
DEVMETHOD(device_probe, ahci_probe),
@@ -881,6 +904,7 @@ static device_method_t ahci_methods[] =
DEVMETHOD(bus_setup_intr, ahci_setup_intr),
DEVMETHOD(bus_teardown_intr,ahci_teardown_intr),
DEVMETHOD(bus_child_location_str, ahci_child_location_str),
+ DEVMETHOD(bus_get_dma_tag, ahci_get_dma_tag),
{ 0, 0 }
};
static driver_t ahci_driver = {
@@ -1256,13 +1280,9 @@ ahci_dmainit(device_t dev)
struct ahci_dc_cb_args dcba;
size_t rfsize;
- if (ch->caps & AHCI_CAP_64BIT)
- ch->dma.max_address = BUS_SPACE_MAXADDR;
- else
- ch->dma.max_address = BUS_SPACE_MAXADDR_32BIT;
/* Command area. */
if (bus_dma_tag_create(bus_get_dma_tag(dev), 1024, 0,
- ch->dma.max_address, BUS_SPACE_MAXADDR,
+ BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
NULL, NULL, AHCI_WORK_SIZE, 1, AHCI_WORK_SIZE,
0, NULL, NULL, &ch->dma.work_tag))
goto error;
@@ -1281,7 +1301,7 @@ ahci_dmainit(device_t dev)
else
rfsize = 256;
if (bus_dma_tag_create(bus_get_dma_tag(dev), rfsize, 0,
- ch->dma.max_address, BUS_SPACE_MAXADDR,
+ BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
NULL, NULL, rfsize, 1, rfsize,
0, NULL, NULL, &ch->dma.rfis_tag))
goto error;
@@ -1296,7 +1316,7 @@ ahci_dmainit(device_t dev)
ch->dma.rfis_bus = dcba.maddr;
/* Data area. */
if (bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0,
- ch->dma.max_address, BUS_SPACE_MAXADDR,
+ BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
NULL, NULL,
AHCI_SG_ENTRIES * PAGE_SIZE * ch->numslots,
AHCI_SG_ENTRIES, AHCI_PRD_MAX,
Modified: stable/9/sys/dev/ahci/ahci.h
==============================================================================
--- stable/9/sys/dev/ahci/ahci.h Wed Apr 24 19:33:37 2013 (r249852)
+++ stable/9/sys/dev/ahci/ahci.h Wed Apr 24 19:36:40 2013 (r249853)
@@ -348,7 +348,6 @@ struct ata_dma {
uint8_t *rfis; /* FIS receive area */
bus_addr_t rfis_bus; /* bus address of rfis */
bus_dma_tag_t data_tag; /* data DMA tag */
- u_int64_t max_address; /* highest DMA'able address */
};
enum ahci_slot_states {
@@ -438,6 +437,7 @@ struct ahci_channel {
/* structure describing a AHCI controller */
struct ahci_controller {
device_t dev;
+ bus_dma_tag_t dma_tag;
int r_rid;
struct resource *r_mem;
struct rman sc_iomem;
More information about the svn-src-stable-9
mailing list