Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Ensure bus_dmatag_subregion is called with an in...
details: https://anonhg.NetBSD.org/src/rev/ac305539c30f
branches: trunk
changeset: 359783:ac305539c30f
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Jan 22 15:10:30 2022 +0000
description:
Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
diffstat:
sys/arch/alpha/isa/isadma_bounce.c | 8 ++++----
sys/arch/arc/isa/isadma_bounce.c | 8 ++++----
sys/arch/arm/include/bus_defs.h | 4 ++--
sys/arch/arm/nvidia/tegra_sdhc.c | 6 +++---
sys/arch/atari/isa/isa_dma.c | 8 ++++----
sys/arch/emips/emips/bus_dma.c | 6 +++---
sys/arch/evbmips/isa/isadma_bounce.c | 12 ++++++------
sys/arch/evbmips/malta/pci/pcib.c | 6 +++---
sys/arch/mips/include/bus_dma_defs.h | 4 ++--
sys/arch/mips/mips/bus_dma.c | 16 ++++++++--------
sys/arch/mips/rmi/rmixl_obio.c | 8 ++++----
sys/arch/mips/rmi/rmixl_pcix.c | 8 ++++----
sys/arch/mips/sibyte/pci/sbbrz.c | 4 ++--
sys/arch/newsmips/newsmips/bus.c | 6 +++---
sys/arch/playstation2/playstation2/bus_dma.c | 6 +++---
sys/arch/pmax/pmax/bus_dma.c | 6 +++---
sys/arch/powerpc/isa/isadma_machdep.c | 8 ++++----
sys/arch/x86/include/bus_private.h | 4 ++--
sys/arch/x86/x86/bus_dma.c | 16 ++++++++--------
sys/dev/pci/if_bce.c | 6 +++---
sys/dev/pci/if_bge.c | 9 ++++-----
sys/dev/pci/if_nfe.c | 6 +++---
sys/dev/pci/if_stge.c | 6 +++---
sys/dev/pci/if_vge.c | 6 +++---
24 files changed, 88 insertions(+), 89 deletions(-)
diffs (truncated from 709 to 300 lines):
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/alpha/isa/isadma_bounce.c
--- a/sys/arch/alpha/isa/isadma_bounce.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/alpha/isa/isadma_bounce.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isadma_bounce.c,v 1.16 2021/12/17 06:28:20 skrll Exp $ */
+/* $NetBSD: isadma_bounce.c,v 1.17 2022/01/22 15:10:30 skrll Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.16 2021/12/17 06:28:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.17 2022/01/22 15:10:30 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -565,9 +565,9 @@
paddr_t high;
if (avail_end > ISA_DMA_BOUNCE_THRESHOLD)
- high = trunc_page(ISA_DMA_BOUNCE_THRESHOLD);
+ high = ISA_DMA_BOUNCE_THRESHOLD - 1;
else
- high = trunc_page(avail_end);
+ high = avail_end - 1;
return (_bus_dmamem_alloc_range(t, size, alignment, boundary,
segs, nsegs, rsegs, flags, 0, high));
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/arc/isa/isadma_bounce.c
--- a/sys/arch/arc/isa/isadma_bounce.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/arc/isa/isadma_bounce.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isadma_bounce.c,v 1.18 2021/12/17 06:28:20 skrll Exp $ */
+/* $NetBSD: isadma_bounce.c,v 1.19 2022/01/22 15:10:30 skrll Exp $ */
/* NetBSD: isadma_bounce.c,v 1.2 2000/06/01 05:49:36 thorpej Exp */
/*-
@@ -33,7 +33,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.18 2021/12/17 06:28:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.19 2022/01/22 15:10:30 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -613,9 +613,9 @@
paddr_t high;
if (pmap_limits.avail_end > ISA_DMA_BOUNCE_THRESHOLD)
- high = trunc_page(ISA_DMA_BOUNCE_THRESHOLD);
+ high = ISA_DMA_BOUNCE_THRESHOLD - 1;
else
- high = trunc_page(pmap_limits.avail_end);
+ high = pmap_limits.avail_end - 1;
return _bus_dmamem_alloc_range(t, size, alignment, boundary,
segs, nsegs, rsegs, flags, 0, high);
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/arm/include/bus_defs.h
--- a/sys/arch/arm/include/bus_defs.h Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/arm/include/bus_defs.h Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_defs.h,v 1.17 2021/08/30 22:56:26 jmcneill Exp $ */
+/* $NetBSD: bus_defs.h,v 1.18 2022/01/22 15:10:30 skrll Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -506,7 +506,7 @@
#define _BUS_DMA_BUFTYPE_RAW 4
#ifdef _ARM32_BUS_DMA_PRIVATE
-#define _BUS_AVAIL_END physical_end
+#define _BUS_AVAIL_END (physical_end - 1)
/*
* Cookie used for bounce buffers. A pointer to one of these it stashed in
* the DMA map.
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/arm/nvidia/tegra_sdhc.c
--- a/sys/arch/arm/nvidia/tegra_sdhc.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/arm/nvidia/tegra_sdhc.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_sdhc.c,v 1.29 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: tegra_sdhc.c,v 1.30 2022/01/22 15:10:30 skrll Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.29 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.30 2022/01/22 15:10:30 skrll Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -115,7 +115,7 @@
sc->sc.sc_dmat = faa->faa_dmat;
#ifdef _LP64
- error = bus_dmatag_subregion(faa->faa_dmat, 0, 0xffffffff,
+ error = bus_dmatag_subregion(faa->faa_dmat, 0, __MASK(32),
&sc->sc.sc_dmat, BUS_DMA_WAITOK);
if (error != 0) {
aprint_error(": couldn't create DMA tag: %d\n", error);
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/atari/isa/isa_dma.c
--- a/sys/arch/atari/isa/isa_dma.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/atari/isa/isa_dma.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isa_dma.c,v 1.15 2021/12/17 06:28:20 skrll Exp $ */
+/* $NetBSD: isa_dma.c,v 1.16 2022/01/22 15:10:30 skrll Exp $ */
#define ISA_DMA_STATS
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_dma.c,v 1.15 2021/12/17 06:28:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_dma.c,v 1.16 2022/01/22 15:10:30 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -614,9 +614,9 @@
paddr_t high;
if (avail_end > ISA_DMA_BOUNCE_THRESHOLD)
- high = trunc_page(ISA_DMA_BOUNCE_THRESHOLD);
+ high = ISA_DMA_BOUNCE_THRESHOLD - 1;
else
- high = trunc_page(avail_end);
+ high = avail_end - 1;
return (bus_dmamem_alloc_range(t, size, alignment, boundary,
segs, nsegs, rsegs, flags, 0, high));
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/emips/emips/bus_dma.c
--- a/sys/arch/emips/emips/bus_dma.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/emips/emips/bus_dma.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.7 2022/01/22 15:08:10 skrll Exp $ */
+/* $NetBSD: bus_dma.c,v 1.8 2022/01/22 15:10:31 skrll Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.7 2022/01/22 15:08:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.8 2022/01/22 15:10:31 skrll Exp $");
#include "opt_cputype.h"
@@ -666,7 +666,7 @@
return _bus_dmamem_alloc_range_common(t, size, alignment, boundary,
segs, nsegs, rsegs, flags,
pmap_limits.avail_start /*low*/,
- pmap_limits.avail_end - PAGE_SIZE /*high*/);
+ pmap_limits.avail_end - 1 /*high*/);
}
/*
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/evbmips/isa/isadma_bounce.c
--- a/sys/arch/evbmips/isa/isadma_bounce.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/evbmips/isa/isadma_bounce.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isadma_bounce.c,v 1.14 2021/12/17 06:28:20 skrll Exp $ */
+/* $NetBSD: isadma_bounce.c,v 1.15 2022/01/22 15:10:31 skrll Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.14 2021/12/17 06:28:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.15 2022/01/22 15:10:31 skrll Exp $");
#define _MIPS_BUS_DMA_PRIVATE
@@ -99,7 +99,7 @@
* ISA DMA controller), we may have to bounce it as well.
*/
cookieflags = 0;
- if (_BUS_AVAIL_END > (t->_wbase + t->_bounce_alloc_hi - t->_bounce_alloc_lo)
+ if (_BUS_AVAIL_END > (t->_wbase + t->_bounce_alloc_hi - t->_bounce_alloc_lo - 1)
|| ((map->_dm_size / PAGE_SIZE) + 1) > map->_dm_segcnt) {
cookieflags |= _BUS_DMA_MIGHT_NEED_BOUNCE;
cookiesize += (sizeof(bus_dma_segment_t) *
@@ -499,10 +499,10 @@
{
paddr_t high;
- if (_BUS_AVAIL_END > ISA_DMA_BOUNCE_THRESHOLD)
- high = trunc_page(ISA_DMA_BOUNCE_THRESHOLD);
+ if (_BUS_AVAIL_END > ISA_DMA_BOUNCE_THRESHOLD - 1)
+ high = ISA_DMA_BOUNCE_THRESHOLD - 1;
else
- high = trunc_page(_BUS_AVAIL_END);
+ high = _BUS_AVAIL_END;
return (_bus_dmamem_alloc_range(t, size, alignment, boundary,
segs, nsegs, rsegs, flags, 0, high));
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/evbmips/malta/pci/pcib.c
--- a/sys/arch/evbmips/malta/pci/pcib.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/evbmips/malta/pci/pcib.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcib.c,v 1.23 2022/01/22 15:08:10 skrll Exp $ */
+/* $NetBSD: pcib.c,v 1.24 2022/01/22 15:10:31 skrll Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.23 2022/01/22 15:08:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.24 2022/01/22 15:10:31 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -196,7 +196,7 @@
* Initialize the DMA tag used for ISA DMA.
*/
error = bus_dmatag_subregion(pa->pa_dmat, MALTA_DMA_ISA_PHYSBASE,
- MALTA_DMA_ISA_PHYSBASE + MALTA_DMA_ISA_SIZE, &sc->sc_dmat, 0);
+ MALTA_DMA_ISA_PHYSBASE + MALTA_DMA_ISA_SIZE - 1, &sc->sc_dmat, 0);
if (error)
panic("malta_dma_init: failed to create ISA dma tag: %d",
error);
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/mips/include/bus_dma_defs.h
--- a/sys/arch/mips/include/bus_dma_defs.h Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/mips/include/bus_dma_defs.h Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma_defs.h,v 1.5 2020/07/26 08:08:41 simonb Exp $ */
+/* $NetBSD: bus_dma_defs.h,v 1.6 2022/01/22 15:10:31 skrll Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -215,7 +215,7 @@
};
#ifdef _MIPS_BUS_DMA_PRIVATE
-#define _BUS_AVAIL_END pmap_limits.avail_end
+#define _BUS_AVAIL_END (pmap_limits.avail_end - 1)
/*
* Cookie used for bounce buffers. A pointer to one of these it stashed in
* the DMA map.
diff -r 0dfc1a0ac7a2 -r ac305539c30f sys/arch/mips/mips/bus_dma.c
--- a/sys/arch/mips/mips/bus_dma.c Sat Jan 22 15:08:10 2022 +0000
+++ b/sys/arch/mips/mips/bus_dma.c Sat Jan 22 15:10:30 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.45 2022/01/22 15:08:10 skrll Exp $ */
+/* $NetBSD: bus_dma.c,v 1.46 2022/01/22 15:10:31 skrll Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.45 2022/01/22 15:08:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.46 2022/01/22 15:10:31 skrll Exp $");
#define _MIPS_BUS_DMA_PRIVATE
@@ -353,7 +353,7 @@
int cookieflags;
void *cookiestore;
- if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh)
+ if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh - 1)
map->_dm_bounce_thresh = 0;
cookieflags = 0;
@@ -987,10 +987,10 @@
{
bus_addr_t high;
- if (t->_bounce_alloc_hi != 0 && _BUS_AVAIL_END > t->_bounce_alloc_hi)
- high = trunc_page(t->_bounce_alloc_hi);
+ if (t->_bounce_alloc_hi != 0 && _BUS_AVAIL_END > t->_bounce_alloc_hi - 1)
+ high = t->_bounce_alloc_hi - 1;
else
- high = trunc_page(_BUS_AVAIL_END);
+ high = _BUS_AVAIL_END;
return _bus_dmamem_alloc_range(t, size, alignment, boundary,
segs, nsegs, rsegs, flags, t->_bounce_alloc_lo, high);
@@ -1327,8 +1327,8 @@
{
#ifdef _MIPS_NEED_BUS_DMA_BOUNCE
- if ((((tag->_bounce_thresh != 0 && max_addr >= tag->_bounce_thresh)
- && (tag->_bounce_alloc_hi != 0 && max_addr >= tag->_bounce_alloc_hi))
+ if ((((tag->_bounce_thresh != 0 && max_addr >= tag->_bounce_thresh - 1)
+ && (tag->_bounce_alloc_hi != 0 && max_addr >= tag->_bounce_alloc_hi - 1))
|| (tag->_bounce_alloc_hi == 0 && max_addr > _BUS_AVAIL_END))
&& (min_addr <= tag->_bounce_alloc_lo)) {
*newtag = tag;
Home |
Main Index |
Thread Index |
Old Index