Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Aug 2021 00:39:32 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 15cb3b5404bd - main - pcib(4): Write window registers after resource adjustment
Message-ID:  <202108270039.17R0dWZj084644@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=15cb3b5404bd3181c0fbdc056f5a5299876f8f39

commit 15cb3b5404bd3181c0fbdc056f5a5299876f8f39
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-08-27 00:21:56 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-08-27 00:39:27 +0000

    pcib(4): Write window registers after resource adjustment
    
    When adjusting resources we should write updated window base/limit into
    the registers.  Without this newly added address range won't be routed
    through the bridge properly.
    
    Use MIN()/MAX() against current window base/limit to not shrink it on
    the other side if the window is shared by several resources.
    
    Align passed resource start/end to the set window granularity to keep
    it properly aligned.  Currently this is mostly called by other bridges
    having the same window alignment, but it may be change one day.
    
    Reviewed by:    jrtc27, jhb
    MFC after:      1 week
    Sponsored by:   iXsystems, Inc.
    Differential Revision:  https://reviews.freebsd.org/D31693
---
 sys/dev/pci/pci_pci.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 83106eaa455b..33e277ed01ae 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -2345,6 +2345,7 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
 {
 	struct pcib_softc *sc;
 	struct pcib_window *w;
+	rman_res_t wmask;
 	int error;
 
 	sc = device_get_softc(bus);
@@ -2375,9 +2376,18 @@ pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
 		 * then we need to expand the window.
 		 */
 		if (start < w->base || end > w->limit) {
-			error = pcib_expand_window(sc, w, type, start, end);
+			wmask = ((rman_res_t)1 << w->step) - 1;
+			error = pcib_expand_window(sc, w, type,
+			    MIN(start & ~wmask, w->base),
+			    MAX(end | wmask, w->limit));
 			if (error != 0)
 				return (error);
+			if (bootverbose)
+				device_printf(sc->dev,
+				    "grew %s window to %#jx-%#jx\n",
+				    w->name, (uintmax_t)w->base,
+				    (uintmax_t)w->limit);
+			pcib_write_windows(sc, w->mask);
 		}
 	}
 


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108270039.17R0dWZj084644>