From 14edd68e6a4948d2244829bbd092d21a09e8127c Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 29 Mar 2021 17:04:00 +0000 Subject: [PATCH] Turns out the PCIe DARTs support a full 32-bit device virtual address space. Adjust the region managed by the extend accordingly but avoid the first and last page. The last page collides with the MSI address used by the PCIe controller and not using the first page helps finding bugs. ok patrick@ --- sys/arch/arm64/dev/apldart.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/arch/arm64/dev/apldart.c b/sys/arch/arm64/dev/apldart.c index 2397fbbb13b..4e52e47c9d5 100644 --- a/sys/arch/arm64/dev/apldart.c +++ b/sys/arch/arm64/dev/apldart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apldart.c,v 1.1 2021/02/27 16:19:14 kettenis Exp $ */ +/* $OpenBSD: apldart.c,v 1.2 2021/03/29 17:04:00 kettenis Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -190,9 +190,14 @@ apldart_attach(struct device *parent, struct device *self, void *aux) sc->sc_sid_mask = OF_getpropint(faa->fa_node, "sid-mask", 0xffff); sc->sc_nsid = fls(sc->sc_sid_mask); - /* Default aperture for PCIe DART. */ - sc->sc_dvabase = 0x00100000UL; - sc->sc_dvaend = 0x3fefffffUL; + /* + * Skip the first page to help catching bugs where a device is + * doing DMA to/from address zero because we didn't properly + * set up the DMA transfer. Skip the last page to avoid using + * the address reserved for MSIs. + */ + sc->sc_dvabase = DART_PAGE_SIZE; + sc->sc_dvaend = 0xffffffff - DART_PAGE_SIZE; /* Disable translations. */ for (sid = 0; sid < sc->sc_nsid; sid++) -- 2.20.1