sdhci: extend bus_dma_tag boundary to 64-bit space

This patch adds support for the SDHCI_CAN_DO_64BIT
capability, so that to allow 64-bit DMA operation
for the controllers which support this feature.

Reviewed by: manu
Obtained from: Semihalf
Sponsored by: Marvell
Differential Revision: https://reviews.freebsd.org/D30560
MFC after: 2 weeks
This commit is contained in:
Marcin Wojtas 2021-04-28 10:55:40 +02:00
parent 9cf66a0458
commit 7d8700bc29

View File

@ -132,7 +132,7 @@ static int sdhci_cam_update_ios(struct sdhci_slot *slot);
#endif #endif
/* helper routines */ /* helper routines */
static int sdhci_dma_alloc(struct sdhci_slot *slot); static int sdhci_dma_alloc(struct sdhci_slot *slot, uint32_t caps);
static void sdhci_dma_free(struct sdhci_slot *slot); static void sdhci_dma_free(struct sdhci_slot *slot);
static void sdhci_dumpregs(struct sdhci_slot *slot); static void sdhci_dumpregs(struct sdhci_slot *slot);
static void sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, static void sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs,
@ -717,7 +717,7 @@ sdhci_card_poll(void *arg)
} }
static int static int
sdhci_dma_alloc(struct sdhci_slot *slot) sdhci_dma_alloc(struct sdhci_slot *slot, uint32_t caps)
{ {
int err; int err;
@ -750,7 +750,8 @@ sdhci_dma_alloc(struct sdhci_slot *slot)
* be aligned to the SDMA boundary. * be aligned to the SDMA boundary.
*/ */
err = bus_dma_tag_create(bus_get_dma_tag(slot->bus), slot->sdma_bbufsz, err = bus_dma_tag_create(bus_get_dma_tag(slot->bus), slot->sdma_bbufsz,
0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 0, (caps & SDHCI_CAN_DO_64BIT) ? BUS_SPACE_MAXADDR :
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
slot->sdma_bbufsz, 1, slot->sdma_bbufsz, BUS_DMA_ALLOCNOW, slot->sdma_bbufsz, 1, slot->sdma_bbufsz, BUS_DMA_ALLOCNOW,
NULL, NULL, &slot->dmatag); NULL, NULL, &slot->dmatag);
if (err != 0) { if (err != 0) {
@ -1032,7 +1033,7 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot, int num)
slot->opt &= ~SDHCI_HAVE_DMA; slot->opt &= ~SDHCI_HAVE_DMA;
if (slot->opt & SDHCI_HAVE_DMA) { if (slot->opt & SDHCI_HAVE_DMA) {
err = sdhci_dma_alloc(slot); err = sdhci_dma_alloc(slot, caps);
if (err != 0) { if (err != 0) {
if (slot->opt & SDHCI_TUNING_SUPPORTED) { if (slot->opt & SDHCI_TUNING_SUPPORTED) {
free(slot->tune_req, M_DEVBUF); free(slot->tune_req, M_DEVBUF);