Skip to contentSkip to conversation

drm/radeon: implement ACPI VFCT vbios fetch

PATCH In review [email protected] 7 participants 23 messages Aug 16, 2012 – Aug 22, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/radeon: implement ACPI VFCT vbios fetch

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

---
 drivers/gpu/drm/radeon/radeon_bios.c |   59 ++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +59 -0
index 501f488..f06494a7 100644
@@ -32,6 +32,9 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif
 /*
  * BIOS.
  */
@@ -476,6 +479,58 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 		return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -487,6 +542,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
+#ifdef CONFIG_ACPI
+	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+#endif
 	if (r == false) {
 		r = radeon_read_disabled_bios(rdev);
 	}
Signature · 1 line
1.7.7.5
#1 lore raw

PATCH 2/2 drm/radeon: split ATRM support out from the ATPX handler

From: Alex Deucher <[email protected]>

There are systems that use ATRM, but not ATPX.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=41265

---
 drivers/gpu/drm/radeon/radeon.h              |   15 -----
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |   56 +------------------
 drivers/gpu/drm/radeon/radeon_bios.c         |   79 ++++++++++++++++++++++++--
 3 files changed, 75 insertions(+), 75 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -15
index b70ec30..5dbd591 100644
@@ -142,21 +142,6 @@ struct radeon_device;
 /*
  * BIOS.
  */
-#define ATRM_BIOS_PAGE 4096
-
-#if defined(CONFIG_VGA_SWITCHEROO)
-bool radeon_atrm_supported(struct pci_dev *pdev);
-int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
-#else
-static inline bool radeon_atrm_supported(struct pci_dev *pdev)
-{
-	return false;
-}
-
-static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
-	return -EINVAL;
-}
-#endif
 bool radeon_get_bios(struct radeon_device *rdev);
 
 /*
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -55

78 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +74 -5

115 lines not on this page · raw message

Signature · 1 line
1.7.7.5
Reviewed-by on v1 1/2
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Thu, Aug 16, 2012 at 1:54 PM, <[email protected]> wrote:

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

Quoted 96 lines
---
 drivers/gpu/drm/radeon/radeon_bios.c |   59 ++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +59 -1
index 501f488..f06494a7 100644
@@ -32,6 +32,9 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif
 /*
  * BIOS.
  */
@@ -476,6 +479,58 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
                return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+       bool ret = false;
+       struct acpi_table_header *hdr;
+       /* acpi_get_table_with_size is not exported :( */
+       acpi_size tbl_size = 0x7fffffff;
+       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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+       vhdr = &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 != rdev->pdev->bus->number ||
+           vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+           vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+           vhdr->VendorID != rdev->pdev->vendor ||
+           vhdr->DeviceID != 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->ImageLength > tbl_size) {
+               DRM_ERROR("ACPI VFCT image truncated\n");
+               goto out_unmap;
+       }
+
+       rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+       ret = !!rdev->bios;
+
+out_unmap:
+       /* uh, no idea what to do here... */
+       return ret;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -487,6 +542,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
                r = igp_read_bios_from_vram(rdev);
        if (r == false)
                r = radeon_read_bios(rdev);
+#ifdef CONFIG_ACPI
+       if (r == false)
+               r = radeon_acpi_vfct_bios(rdev);
+#endif
        if (r == false) {
                r = radeon_read_disabled_bios(rdev);
        }
--

1.7.7.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to [email protected]
Quoted 19 lines · On Thu, Aug 16, 2012 at 01:54:55PM -0400, [email protected] wrote:

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

---
 drivers/gpu/drm/radeon/radeon_bios.c |   59 ++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +0 -0
index 501f488..f06494a7 100644

drivers/gpu/drm/radeon/radeon_bios.c line 37

Quoted 6 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
@@ -32,6 +32,9 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif

This #ifdef should not be needed, right?

Quoted 42 lines
drivers/gpu/drm/radeon/radeon_bios.c +42 -0
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 533

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_bios.c +10 -0
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#endif

Please provide an "empty" function here if the #ifdef is not true, which then makes the following #ifdef not needed:

drivers/gpu/drm/radeon/radeon_bios.c bool radeon_get_bios(struct radeon_device *rdev) · line 548

Quoted 8 lines
drivers/gpu/drm/radeon/radeon_bios.c +4 -0
@@ -487,6 +542,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
+#ifdef CONFIG_ACPI
+	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+#endif

See, then that #ifdef isn't needed.

That cleans up the code more, remember, we don't want #ifdefs in .c files unless we _really_ have to have them.

thanks,

greg k-h

#5 lore raw

PATCH 1/2 drm/radeon: implement ACPI VFCT vbios fetch (v2)

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---
 drivers/gpu/drm/radeon/radeon_bios.c |   62 ++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +62 -0
index 501f488..bf21f65 100644
@@ -32,6 +32,9 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif
 /*
  * BIOS.
  */
@@ -476,6 +479,63 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 		return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#else
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	return false;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -484,6 +544,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 
 	r = radeon_atrm_get_bios(rdev);
 	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+	if (r == false)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
Signature · 1 line
1.7.7.5
#6 lore raw

PATCH 2/2 drm/radeon: split ATRM support out from the ATPX handler (v2)

From: Alex Deucher <[email protected]>

There are systems that use ATRM, but not ATPX.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=41265

V2: fix #ifdefs as per Greg's comments

---
 drivers/gpu/drm/radeon/radeon.h              |   15 -----
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |   56 +-----------------
 drivers/gpu/drm/radeon/radeon_bios.c         |   82 ++++++++++++++++++++++++--
 3 files changed, 77 insertions(+), 76 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -15
index 9930419..59a1531 100644
@@ -142,21 +142,6 @@ struct radeon_device;
 /*
  * BIOS.
  */
-#define ATRM_BIOS_PAGE 4096
-
-#if defined(CONFIG_VGA_SWITCHEROO)
-bool radeon_atrm_supported(struct pci_dev *pdev);
-int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
-#else
-static inline bool radeon_atrm_supported(struct pci_dev *pdev)
-{
-	return false;
-}
-
-static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
-	return -EINVAL;
-}
-#endif
 bool radeon_get_bios(struct radeon_device *rdev);
 
 /*
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -55

78 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +76 -6

116 lines not on this page · raw message

Signature · 1 line
1.7.7.5
#7 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

In reply to [email protected]
Quoted 21 lines · On Thu, Aug 16, 2012 at 03:13:46PM -0400, [email protected] wrote:

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---
 drivers/gpu/drm/radeon/radeon_bios.c |   62 ++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +0 -0
index 501f488..bf21f65 100644

drivers/gpu/drm/radeon/radeon_bios.c line 37

Quoted 6 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
@@ -32,6 +32,9 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif

You forgot to remove this one :(

Quoted 50 lines
drivers/gpu/drm/radeon/radeon_bios.c +43 -0
 /*
  * BIOS.
  */
@@ -476,6 +479,63 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 		return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 534

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_bios.c +10 -0
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#else
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)

Make it inline, and then the compiler is smart enough to just delete the whole if () check you make when you call it.

Third time's a charm?

greg k-h

#8 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

Quoted 23 lines · Greg KH
Quoted 22 lines · On Thu, Aug 16, 2012 at 03:13:46PM -0400, [email protected] wrote:

From: David L <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---
 drivers/gpu/drm/radeon/radeon_bios.c |   62 ++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +0 -0
index 501f488..bf21f65 100644
@@ -32,6 +32,9 @@
 
Quoted 7 lines

drivers/gpu/drm/radeon/radeon_bios.c line 37

Quoted 5 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif

You forgot to remove this one :(

Argh! I squashed that into the wrong patch when I rebased my fixes.

Quoted 65 lines
Quoted 51 lines
drivers/gpu/drm/radeon/radeon_bios.c +43 -0
 /*
  * BIOS.
  */
@@ -476,6 +479,63 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
              return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+     bool ret = false;
+     struct acpi_table_header *hdr;
+     /* acpi_get_table_with_size is not exported :( */
+     acpi_size tbl_size = 0x7fffffff;
+     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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+     vhdr = &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 != rdev->pdev->bus->number ||
+         vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+         vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+         vhdr->VendorID != rdev->pdev->vendor ||
+         vhdr->DeviceID != 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->ImageLength > tbl_size) {
+             DRM_ERROR("ACPI VFCT image truncated\n");
+             goto out_unmap;
+     }

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 534

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_bios.c +10 -0
+
+     rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+     ret = !!rdev->bios;
+
+out_unmap:
+     /* uh, no idea what to do here... */
+     return ret;
+}
+#else
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)

Make it inline, and then the compiler is smart enough to just delete the whole if () check you make when you call it.

Quoted 1 line

Third time's a charm?

On the way.

Alex

#9 lore raw

PATCH 1/2 drm/radeon: implement ACPI VFCT vbios fetch (v3)

In reply to Greg KH

From: David Lamparter <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments
V3: fix it harder

---
 drivers/gpu/drm/radeon/radeon_bios.c |   60 ++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +60 -0
index 501f488..a32232f 100644
@@ -32,6 +32,7 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
 /*
  * BIOS.
  */
@@ -476,6 +477,63 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 		return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#else
+static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	return false;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -484,6 +542,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 
 	r = radeon_atrm_get_bios(rdev);
 	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+	if (r == false)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
Signature · 1 line
1.7.7.5
#10 lore raw

PATCH 2/2 drm/radeon: split ATRM support out from the ATPX handler (v3)

From: Alex Deucher <[email protected]>

There are systems that use ATRM, but not ATPX.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=41265

V2: fix #ifdefs as per Greg's comments
V3: fix it harder

---
 drivers/gpu/drm/radeon/radeon.h              |   15 -----
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |   56 +------------------
 drivers/gpu/drm/radeon/radeon_bios.c         |   80 ++++++++++++++++++++++++-
 3 files changed, 77 insertions(+), 74 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -15
index 9930419..59a1531 100644
@@ -142,21 +142,6 @@ struct radeon_device;
 /*
  * BIOS.
  */
-#define ATRM_BIOS_PAGE 4096
-
-#if defined(CONFIG_VGA_SWITCHEROO)
-bool radeon_atrm_supported(struct pci_dev *pdev);
-int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
-#else
-static inline bool radeon_atrm_supported(struct pci_dev *pdev)
-{
-	return false;
-}
-
-static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
-	return -EINVAL;
-}
-#endif
 bool radeon_get_bios(struct radeon_device *rdev);
 
 /*
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -55

78 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +76 -4

107 lines not on this page · raw message

Signature · 1 line
1.7.7.5
#11 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

In reply to [email protected]
Quoted 1 line · On Thu, Aug 16, 2012 at 03:13:46PM -0400, [email protected] wrote:

From: David L <[email protected]>

From: David Lamparter <[email protected]>

There are still two rough edges left in here, I didn't get around to clean it up, other stuff came up -- sorry...

Quoted 11 lines

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---

[...]

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 488

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 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.

Quoted 32 lines
drivers/gpu/drm/radeon/radeon_bios.c +32 -0
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != rdev->pdev->device) {
+		DRM_INFO("ACPI VFCT table is not for this card\n");
+		goto out_unmap;
+	};
+

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 530

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_bios.c +10 -0
+	if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!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?

Quoted 23 lines
drivers/gpu/drm/radeon/radeon_bios.c +10 -0
+	return ret;
+}
+#else
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	return false;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -484,6 +544,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 
 	r = radeon_atrm_get_bios(rdev);
 	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+	if (r == false)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
Signature · 1 line
1.7.7.5

Cheers,

-David

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

Quoted 19 lines · David Lamparter
Quoted 1 line · On Thu, Aug 16, 2012 at 03:13:46PM -0400, [email protected] wrote:

From: David L <[email protected]>

From: David Lamparter <[email protected]>

There are still two rough edges left in here, I didn't get around to clean it up, other stuff came up -- sorry...

Quoted 11 lines

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---

[...]

Quoted 8 lines

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 488

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
+     struct acpi_table_header *hdr;
+     /* acpi_get_table_with_size is not exported :( */
+     acpi_size tbl_size = 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.

I guess we could leave it as is for now for -fixes and then switch it use use the new exported symbol for -next? Is it ok to export a new symbol for -fixes?

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/radeon/radeon_bios.c +38 -0
+     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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+     vhdr = &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 != rdev->pdev->bus->number ||
+         vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+         vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+         vhdr->VendorID != rdev->pdev->vendor ||
+         vhdr->DeviceID != 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->ImageLength > tbl_size) {
+             DRM_ERROR("ACPI VFCT image truncated\n");
+             goto out_unmap;
+     }
+
+     rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
Quoted 8 lines

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 530

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_bios.c +4 -0
+     ret = !!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?

Not sure on that. Anyone know more about the acpi code?

Alex

#13 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

Adding Matthew in case he as any ideas.

Quoted 84 lines · Alex Deucher
Quoted 19 lines · David Lamparter
Quoted 1 line · On Thu, Aug 16, 2012 at 03:13:46PM -0400, [email protected] wrote:

From: David L <[email protected]>

From: David Lamparter <[email protected]>

There are still two rough edges left in here, I didn't get around to clean it up, other stuff came up -- sorry...

Quoted 11 lines

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments

---

[...]

Quoted 8 lines

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 488

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_bios.c +3 -0
+     struct acpi_table_header *hdr;
+     /* acpi_get_table_with_size is not exported :( */
+     acpi_size tbl_size = 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.

I guess we could leave it as is for now for -fixes and then switch it use use the new exported symbol for -next? Is it ok to export a new symbol for -fixes?

Quoted 39 lines
Quoted 39 lines
drivers/gpu/drm/radeon/radeon_bios.c +38 -0
+     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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+     vhdr = &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 != rdev->pdev->bus->number ||
+         vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+         vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+         vhdr->VendorID != rdev->pdev->vendor ||
+         vhdr->DeviceID != 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->ImageLength > tbl_size) {
+             DRM_ERROR("ACPI VFCT image truncated\n");
+             goto out_unmap;
+     }
+
+     rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
Quoted 8 lines

drivers/gpu/drm/radeon/radeon_bios.c static bool radeon_read_disabled_bios(struct radeon_device *rdev) · line 530

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_bios.c +4 -0
+     ret = !!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?

Not sure on that. Anyone know more about the acpi code?

Alex

#14 lore raw

Re: [PATCH 1/2] drm/radeon: implement ACPI VFCT vbios fetch (v2)

Quoted 3 lines · Alex Deucher
Quoted 3 lines

I guess we could leave it as is for now for -fixes and then switch it use use the new exported symbol for -next? Is it ok to export a new symbol for -fixes?

I don't see why not, providing the ACPI people are happy with it.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

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?

Not sure on that. Anyone know more about the acpi code?

Not sure what you're asking here - acpi_get_table returns acpi_status, not a pointer.

Signature · 1 line
Matthew Garrett | [email protected]
#15 lore raw

PATCH 1/4 drm/radeon: implement ACPI VFCT vbios fetch (v3)

From: David Lamparter <[email protected]>

This is required for pure UEFI systems. The vbios is stored in ACPI rather than at the legacy vga location.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=26891

V2: fix #ifdefs as per Greg's comments
V3: fix it harder

---
 drivers/gpu/drm/radeon/radeon_bios.c |   60 ++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +60 -0
index 501f488..a32232f 100644
@@ -32,6 +32,7 @@
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
 /*
  * BIOS.
  */
@@ -476,6 +477,63 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev)
 		return legacy_read_disabled_bios(rdev);
 }
 
+#ifdef CONFIG_ACPI
+static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	bool ret = false;
+	struct acpi_table_header *hdr;
+	/* acpi_get_table_with_size is not exported :( */
+	acpi_size tbl_size = 0x7fffffff;
+	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 = (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 = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset);
+	vhdr = &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 != rdev->pdev->bus->number ||
+	    vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) ||
+	    vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) ||
+	    vhdr->VendorID != rdev->pdev->vendor ||
+	    vhdr->DeviceID != 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->ImageLength > tbl_size) {
+		DRM_ERROR("ACPI VFCT image truncated\n");
+		goto out_unmap;
+	}
+
+	rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL);
+	ret = !!rdev->bios;
+
+out_unmap:
+	/* uh, no idea what to do here... */
+	return ret;
+}
+#else
+static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
+{
+	return false;
+}
+#endif
 
 bool radeon_get_bios(struct radeon_device *rdev)
 {
@@ -484,6 +542,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 
 	r = radeon_atrm_get_bios(rdev);
 	if (r == false)
+		r = radeon_acpi_vfct_bios(rdev);
+	if (r == false)
 		r = igp_read_bios_from_vram(rdev);
 	if (r == false)
 		r = radeon_read_bios(rdev);
Signature · 1 line
1.7.7.5
#16 lore raw

PATCH 2/4 ACPI: export symbol acpi_get_table_with_size

From: Alex Deucher <[email protected]>

We need it in the radeon drm module to fetch
and verify the vbios image on UEFI systems.

---
 drivers/acpi/acpica/tbxface.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/acpica/tbxface.c +1 -0
index ea4c6d5..29e51bc 100644
@@ -387,6 +387,7 @@ acpi_get_table_with_size(char *signature,
 
 	return (AE_NOT_FOUND);
 }
+ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
 
 acpi_status
 acpi_get_table(char *signature,
Signature · 1 line
1.7.7.5
#17 lore raw

Re: [PATCH 2/4] ACPI: export symbol acpi_get_table_with_size

Any objections from the ACPI folks to this patch going into 3.6 and stable?

Alex

Quoted 26 lines · On Mon, Aug 20, 2012 at 11:19 AM, <[email protected]> wrote:

From: Alex Deucher <[email protected]>

We need it in the radeon drm module to fetch
and verify the vbios image on UEFI systems.

---
 drivers/acpi/acpica/tbxface.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/acpica/tbxface.c +1 -1
index ea4c6d5..29e51bc 100644
@@ -387,6 +387,7 @@ acpi_get_table_with_size(char *signature,
 
        return (AE_NOT_FOUND);
 }
+ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
 
 acpi_status
 acpi_get_table(char *signature,
--

1.7.7.5

#20 lore raw

Re: [PATCH 2/4] ACPI: export symbol acpi_get_table_with_size

In reply to Alex Deucher

2012/8/21 Alex Deucher <[email protected]>:

Quoted 2 lines

Any objections from the ACPI folks to this patch going into 3.6 and stable?

hi Alex:
I saw the patch from Feng Tang.
http://marc.info/?l=linux-acpi&m=134380363332502&w=2
which is trying to replace acpi_get_table_with_size() with acpi_get_table(). Since the size can be get
via struct acpi_table_header->length, acpi_get_table_with_size() is redundant and it will be removed.

Quoted 33 lines

Alex

Quoted 24 lines · On Mon, Aug 20, 2012 at 11:19 AM, <[email protected]> wrote:

From: Alex Deucher <[email protected]>

We need it in the radeon drm module to fetch
and verify the vbios image on UEFI systems.

---
 drivers/acpi/acpica/tbxface.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/acpi/acpica/tbxface.c +1 -1
index ea4c6d5..29e51bc 100644
@@ -387,6 +387,7 @@ acpi_get_table_with_size(char *signature,
 
        return (AE_NOT_FOUND);
 }
+ACPI_EXPORT_SYMBOL(acpi_get_table_with_size)
 
 acpi_status
 acpi_get_table(char *signature,
--
Quoted 2 lines

1.7.7.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards
Tianyu Lan
#21 lore raw

PATCH 3/4 drm/radeon: convert radeon vfct code to use acpi_get_table_with_size

In reply to [email protected]

From: Alex Deucher <[email protected]>

Allows us to verify the table size.

---
 drivers/gpu/drm/radeon/radeon_bios.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_bios.c +2 -4
index a32232f..ab0b2f7 100644
@@ -482,13 +482,12 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
 {
 	bool ret = false;
 	struct acpi_table_header *hdr;
-	/* acpi_get_table_with_size is not exported :( */
-	acpi_size tbl_size = 0x7fffffff;
+	acpi_size tbl_size;
 	UEFI_ACPI_VFCT *vfct;
 	GOP_VBIOS_CONTENT *vbios;
 	VFCT_IMAGE_HEADER *vhdr;
 
-	if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr)))
+	if (!ACPI_SUCCESS(acpi_get_table_with_size("VFCT", 1, &hdr, &tbl_size)))
 		return false;
 	if (tbl_size < sizeof(UEFI_ACPI_VFCT)) {
 		DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n");
@@ -525,7 +524,6 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
 	ret = !!rdev->bios;
 
 out_unmap:
-	/* uh, no idea what to do here... */
 	return ret;
 }
 #else
Signature · 1 line
1.7.7.5
#22 lore raw

PATCH 4/4 drm/radeon: split ATRM support out from the ATPX handler (v3)

In reply to [email protected]

From: Alex Deucher <[email protected]>

There are systems that use ATRM, but not ATPX.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=41265

V2: fix #ifdefs as per Greg's comments
V3: fix it harder

---
 drivers/gpu/drm/radeon/radeon.h              |   15 -----
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |   56 +------------------
 drivers/gpu/drm/radeon/radeon_bios.c         |   80 ++++++++++++++++++++++++-
 3 files changed, 77 insertions(+), 74 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -15
index 9930419..59a1531 100644
@@ -142,21 +142,6 @@ struct radeon_device;
 /*
  * BIOS.
  */
-#define ATRM_BIOS_PAGE 4096
-
-#if defined(CONFIG_VGA_SWITCHEROO)
-bool radeon_atrm_supported(struct pci_dev *pdev);
-int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len);
-#else
-static inline bool radeon_atrm_supported(struct pci_dev *pdev)
-{
-	return false;
-}
-
-static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){
-	return -EINVAL;
-}
-#endif
 bool radeon_get_bios(struct radeon_device *rdev);
 
 /*
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -55

78 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +76 -4

107 lines not on this page · raw message

Signature · 1 line
1.7.7.5