From: David Lamparter Subject: Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2) Date: Thu, 16 Aug 2012 21:40:00 +0200 Message-ID: <20120816193959.GI496971@jupiter.n2.diac24.net> References: <20120816182547.GB31978@kroah.com> <1345144427-7175-1-git-send-email-alexdeucher@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1514173891==" Return-path: Received: from spaceboyz.net (spaceboyz.net [87.106.131.203]) by gabe.freedesktop.org (Postfix) with ESMTP id 220449E841 for ; Thu, 16 Aug 2012 13:09:02 -0700 (PDT) In-Reply-To: <1345144427-7175-1-git-send-email-alexdeucher@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: alexdeucher@gmail.com Cc: Alex Deucher , stable@vger.kernel.org, dri-devel@lists.freedesktop.org, David L List-Id: dri-devel@lists.freedesktop.org --===============1514173891== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lHGcFxmlz1yfXmOs" Content-Disposition: inline --lHGcFxmlz1yfXmOs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 16, 2012 at 03:13:46PM -0400, alexdeucher@gmail.com wrote: > From: David L =46rom: David Lamparter There are still two rough edges left in here, I didn't get around to clean it up, other stuff came up -- sorry... > This is required for pure UEFI systems. The vbios is stored > in ACPI rather than at the legacy vga location. >=20 > Fixes: > https://bugs.freedesktop.org/show_bug.cgi?id=3D26891 >=20 > V2: fix #ifdefs as per Greg's comments >=20 > Signed-off-by: Alex Deucher > Cc: stable@vger.kernel.org > --- [...] > + struct acpi_table_header *hdr; > + /* acpi_get_table_with_size is not exported :( */ > + acpi_size tbl_size =3D 0x7fffffff; I was using acpi_get_table_with_size, but that needs an export, with 0x7fffffff all the tests below are kinda useless because they always succeed. I think it'd be useful to keep the length checks in case some vendor breaks their ACPI tables, so this needs an EXPORT_SYMBOL. > + UEFI_ACPI_VFCT *vfct; > + GOP_VBIOS_CONTENT *vbios; > + VFCT_IMAGE_HEADER *vhdr; > + > + if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr))) > + return false; > + if (tbl_size < sizeof(UEFI_ACPI_VFCT)) { > + DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n"); > + goto out_unmap; > + } > + > + vfct =3D (UEFI_ACPI_VFCT *)hdr; > + if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) > tbl_size) { > + DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); > + goto out_unmap; > + } > + > + vbios =3D (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset); > + vhdr =3D &vbios->VbiosHeader; > + DRM_INFO("ACPI VFCT contains a BIOS for %02x:%02x.%d %04x:%04x, size %d= \n", > + vhdr->PCIBus, vhdr->PCIDevice, vhdr->PCIFunction, > + vhdr->VendorID, vhdr->DeviceID, vhdr->ImageLength); > + > + if (vhdr->PCIBus !=3D rdev->pdev->bus->number || > + vhdr->PCIDevice !=3D PCI_SLOT(rdev->pdev->devfn) || > + vhdr->PCIFunction !=3D PCI_FUNC(rdev->pdev->devfn) || > + vhdr->VendorID !=3D rdev->pdev->vendor || > + vhdr->DeviceID !=3D rdev->pdev->device) { > + DRM_INFO("ACPI VFCT table is not for this card\n"); > + goto out_unmap; > + }; > + > + if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLen= gth > tbl_size) { > + DRM_ERROR("ACPI VFCT image truncated\n"); > + goto out_unmap; > + } > + > + rdev->bios =3D kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KER= NEL); > + ret =3D !!rdev->bios; > + > +out_unmap: > + /* uh, no idea what to do here... */ So, er, I had no clue how to clean up the return value of acpi_get_table - does this actually need to be cleaned up? Or do you just get a pointer straight to the "real" ACPI table? > + return ret; > +} > +#else > +static bool radeon_acpi_vfct_bios(struct radeon_device *rdev) > +{ > + return false; > +} > +#endif > =20 > bool radeon_get_bios(struct radeon_device *rdev) > { > @@ -484,6 +544,8 @@ bool radeon_get_bios(struct radeon_device *rdev) > =20 > r =3D radeon_atrm_get_bios(rdev); > if (r =3D=3D false) > + r =3D radeon_acpi_vfct_bios(rdev); > + if (r =3D=3D false) > r =3D igp_read_bios_from_vram(rdev); > if (r =3D=3D false) > r =3D radeon_read_bios(rdev); > --=20 > 1.7.7.5 >=20 Cheers, -David --lHGcFxmlz1yfXmOs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iF4EAREIAAYFAlAtTI8ACgkQCy20tTec6eNBGAD/cchLhFq7BriFMBqbBX/2Wiy0 aZi/TTcM3FbRse3jzZ0A/RyLJSYNSM+M3sCp4pPIF1eYFy5FsmTF0K6vhMyP5SIj =kaEu -----END PGP SIGNATURE----- --lHGcFxmlz1yfXmOs-- --===============1514173891== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1514173891==--