Subject: bus_dma
To: None <port-mips@NetBSD.org>
From: Nitin P Mahajan <Nitin@soc-soft.com>
List: port-mips
Date: 03/05/2004 09:47:28
Hi!
I am writing a code as given bellow to get a data buffer of one
page size from DMA memory.
I want the data buffer to be 4 byte aligned hence I am passing the fifth
argument in the create function as the alignment. But the
bus_dmamap_load fails returning EFBIG.
If I pass the alignment argument as 0 in the bus_dmamap_create function
the call to bus_dmamap_load succeeds.
Could any one please tell me whre am I making a mistake in this....
Thanking u in advance=20
Regards,
Nitin=20
struct my_softc {
struct device if_device;
=09
uint8_t phy_addr;
=09
u_int32_t ebase_addr;
struct mips_bus_dma_tag sc_eth_dmat;
=09
bus_dma_segment_t sc_eth_dmaseg_data;
int sc_eth_dmanseg_data;
bus_dmamap_t Data_Buf_dmamap;
caddr_t Data_Buff;
}; =20
struct my_softc sc;
caddr_t data_buff;
/*Following code is inside attach.*/
/*Allocate DMA-safe memory for the data buffers.*/
if ((error =3D bus_dmamem_alloc(&sc->sc_eth_dmat,
/*RX_BUF_PAGES*/PAGE_SIZE, PAGE_SIZE, PAGE_SIZE ,
&sc->sc_eth_dmaseg_data, 1,
&sc->sc_eth_dmanseg_data,BUS_DMA_NOWAIT)) !=3D 0) {
printf("%s: can't allocate data buffer, error =3D %d\n",
sc->if_device.dv_xname, error);
return error;
}
printf("MAP DMA-safe memory for the data buffers.\n");
/*Allocate DMA-safe memory for the data buffers.*/
if ((error =3D bus_dmamem_map(&sc->sc_eth_dmat,
&sc->sc_eth_dmaseg_data, sc->sc_eth_dmanseg_data,
/*RX_BUF_PAGES*/PAGE_SIZE,(caddr_t *)&sc->Data_Buff,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) !=3D 0) {
printf("%s: can't map data buffer, error =3D %d\n",
sc->if_device.dv_xname, error);
bus_dmamem_free(&sc->sc_eth_dmat,
&sc->sc_eth_dmaseg_data, sc->sc_eth_dmanseg_data);
return error;
}
data_buff =3D sc->Data_Buff;
=09
if ((error =3D bus_dmamap_create(&sc->sc_eth_dmat,
PAGE_SIZE, 1, PAGE_SIZE, 4, BUS_DMA_NOWAIT,
&sc->Data_Buf_dmamap[i])) !=3D 0) {
printf("%s: can't create data buffer DMA map, error =3D
%d\n",
sc->if_device.dv_xname, error);
return error;
}
if ((error =3D bus_dmamap_load(&sc->sc_eth_dmat,
sc->Data_Buf_dmamap[i],
data_buff, PAGE_SIZE,
NULL, BUS_DMA_READ | BUS_DMA_NOWAIT)) !=3D 0) {
printf("%s: can't load data buffer DMA map, error =3D
%d\n",
sc->if_device.dv_xname, error);
return error;
}
=09
=09