Arm DMA tags with _nranges=0 require no address translation. Handle this

in PHYS_TO_BUS_MEM and BUS_TO_PHYS_MEM instead of panicing.
This commit is contained in:
jmcneill 2019-11-05 23:27:23 +00:00
parent 336e4f812b
commit 810998e8ba

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_dma_hacks.h,v 1.17 2018/08/27 15:32:39 riastradh Exp $ */
/* $NetBSD: bus_dma_hacks.h,v 1.18 2019/11/05 23:27:23 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -51,6 +51,9 @@ PHYS_TO_BUS_MEM(bus_dma_tag_t dmat, paddr_t pa)
{
unsigned i;
if (dmat->_nranges == 0)
return (bus_addr_t)pa;
for (i = 0; i < dmat->_nranges; i++) {
const struct arm32_dma_range *dr = &dmat->_ranges[i];
@ -64,6 +67,9 @@ BUS_MEM_TO_PHYS(bus_dma_tag_t dmat, bus_addr_t ba)
{
unsigned i;
if (dmat->_nranges == 0)
return (paddr_t)ba;
for (i = 0; i < dmat->_nranges; i++) {
const struct arm32_dma_range *dr = &dmat->_ranges[i];