From owner-svn-src-all@FreeBSD.ORG Mon Sep 9 17:46:07 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0292D3C2; Mon, 9 Sep 2013 17:46:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C89A9283D; Mon, 9 Sep 2013 17:46:06 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D1776B9AD; Mon, 9 Sep 2013 13:46:05 -0400 (EDT) From: John Baldwin To: "=?iso-8859-15?q?Jean-S=E9bastien?= =?iso-8859-15?q?_P=E9dron?=" Subject: Re: svn commit: r254882 - head/sys/dev/pci Date: Mon, 9 Sep 2013 11:51:24 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; ) References: <201308251809.r7PI9CsE052978@svn.freebsd.org> <201309031410.46052.jhb@freebsd.org> <52298BCA.7040602@FreeBSD.org> In-Reply-To: <52298BCA.7040602@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <201309091151.24587.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 09 Sep 2013 13:46:05 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Sep 2013 17:46:07 -0000 On Friday, September 06, 2013 4:01:14 am Jean-S=E9bastien P=E9dron wrote: > Le 03/09/2013 20:10, John Baldwin a =E9crit : > > Yes, orm0 is eating it. Try this along with using RF_SHAREABLE in your > > call to BUS_ALLOC_RESOURCE(): > > > > Index: x86/isa/orm.c > > (...) > > - res =3D bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid, 0); > > + res =3D bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid, > > + RF_SHAREABLE); >=20 > I tried this patch + RF_SHAREABLE in vga_pci.c but without success. In=20 > the call to BUS_ALLOC_RESOURCE in vga_pci.c, I tried with various=20 > "parents"/"grand-parents" but it always returns NULL. Ok, let's punt on changing the API perhaps, but use the vgapci softc to fin= d=20 the resource: Index: vga_pci.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- vga_pci.c (revision 255414) +++ vga_pci.c (working copy) @@ -67,6 +67,12 @@ struct vga_pci_softc { =20 SYSCTL_DECL(_hw_pci); =20 +static struct vga_resource *lookup_res(struct vga_pci_softc *sc, int rid); +static struct resource *vga_pci_alloc_resource(device_t dev, device_t chil= d, + int type, int *rid, u_long start, u_long end, u_long count, u_int flag= s); +static int vga_pci_release_resource(device_t dev, device_t child, int type, + int rid, struct resource *r); + int vga_pci_default_unit =3D -1; TUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit); SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, @@ -80,7 +86,6 @@ vga_pci_is_boot_display(device_t dev) * Return true if the given device is the default display used * at boot time. */ =2D return ( (pci_get_class(dev) =3D=3D PCIC_DISPLAY || (pci_get_class(dev) =3D=3D PCIC_OLD && @@ -111,7 +116,8 @@ vga_pci_map_bios(device_t dev, size_t *size) #endif =20 rid =3D PCIR_BIOS; =2D res =3D bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + res =3D vga_pci_alloc_resource(dev, NULL, SYS_RES_MEMORY, &rid, 0ul, + ~0ul, 1, RF_ACTIVE); if (res =3D=3D NULL) { return (NULL); } @@ -123,8 +129,7 @@ vga_pci_map_bios(device_t dev, size_t *size) void vga_pci_unmap_bios(device_t dev, void *bios) { =2D int rid; =2D struct resource *res; + struct vga_resource *vr; =20 if (bios =3D=3D NULL) { return; @@ -140,25 +145,15 @@ vga_pci_unmap_bios(device_t dev, void *bios) #endif =20 /* =2D * FIXME: We returned only the virtual address of the resource =2D * to the caller. Now, to get the resource struct back, we =2D * allocate it again: the struct exists once in memory in =2D * device softc. Therefore, we release twice now to release the =2D * reference we just obtained to get the structure back and the =2D * caller's reference. + * Look up the PCIR_BIOS resource in our softc. It should match + * the address we returned previously. */ =2D =2D rid =3D PCIR_BIOS; =2D res =3D bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); =2D =2D KASSERT(res !=3D NULL, =2D ("%s: Can't get BIOS resource back", __func__)); =2D KASSERT(bios =3D=3D rman_get_virtual(res), =2D ("%s: Given BIOS address doesn't match " =2D "resource virtual address", __func__)); =2D =2D bus_release_resource(dev, SYS_RES_MEMORY, rid, bios); =2D bus_release_resource(dev, SYS_RES_MEMORY, rid, bios); + vr =3D lookup_res(device_get_softc(dev), PCIR_BIOS); + KASSERT(vr->vr_res !=3D NULL, ("vga_pci_unmap_bios: bios not mapped")); + KASSERT(rman_get_virtual(vr->vr_res) =3D=3D bios, + ("vga_pci_unmap_bios: mismatch")); + vga_pci_release_resource(dev, NULL, SYS_RES_MEMORY, PCIR_BIOS, + vr->vr_res); } =20 static int =2D-=20 John Baldwin