From owner-dev-commits-src-branches@freebsd.org Wed Sep 1 20:57:34 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F0461671C98; Wed, 1 Sep 2021 20:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H0GbL5MFDz3sv1; Wed, 1 Sep 2021 20:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 99A583FBD; Wed, 1 Sep 2021 20:57:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 181KvYKT047292; Wed, 1 Sep 2021 20:57:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 181KvYAI047291; Wed, 1 Sep 2021 20:57:34 GMT (envelope-from git) Date: Wed, 1 Sep 2021 20:57:34 GMT Message-Id: <202109012057.181KvYAI047291@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: c4bd6b589c8d - stable/13 - pcib(4): Write window registers after resource adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c4bd6b589c8db00ef11e6c27943efba6129aacf1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 20:57:35 -0000 The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c4bd6b589c8db00ef11e6c27943efba6129aacf1 commit c4bd6b589c8db00ef11e6c27943efba6129aacf1 Author: Alexander Motin AuthorDate: 2021-08-27 00:21:56 +0000 Commit: Alexander Motin CommitDate: 2021-09-01 20:55:13 +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); } }