Skip to contentSkip to conversation

drm/amdgpu: Optimize the asic type fix code

PATCH In review Ma Jun 3 participants 4 messages Nov 1, 2023 – Nov 2, 2023

Subsystems (2)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH v2 1/2 drm/amdgpu: Optimize the asic type fix code

Use a new struct array to define the asic information which asic type needs to be fixed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 35 ++++++++++++++++++-------
 include/drm/amd_asic_type.h             |  5 ++++
 2 files changed, 31 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +26 -9
index 84703e0a73bd..756cf49557a2 100644
@@ -2067,6 +2067,14 @@ static const struct pci_device_id pciidlist[] = {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static const struct amdgpu_asic_type_quirk asic_type_quirks[] = {
+	/* differentiate between P10 and P11 asics with the same DID */
+	{0x67FF, 0xE3, CHIP_POLARIS10},
+	{0x67FF, 0xE7, CHIP_POLARIS10},
+	{0x67FF, 0xF3, CHIP_POLARIS10},
+	{0x67FF, 0xF7, CHIP_POLARIS10},
+};
+
 static struct drm_driver amdgpu_kms_driver;
 
 static void amdgpu_get_secondary_funcs(struct amdgpu_device *adev)
@@ -2109,6 +2117,22 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)
 	}
 }
 
+static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(asic_type_quirks); i++) {
+		if (pdev->device == asic_type_quirks[i].device &&
+			pdev->revision == asic_type_quirks[i].revision) {
+				flags &= ~AMD_ASIC_MASK;
+				flags |= asic_type_quirks[i].type;
+				break;
+			}
+	}
+
+	return flags;
+}
+
 static int amdgpu_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
@@ -2138,15 +2162,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 			 "See modparam exp_hw_support\n");
 		return -ENODEV;
 	}
-	/* differentiate between P10 and P11 asics with the same DID */
-	if (pdev->device == 0x67FF &&
-	    (pdev->revision == 0xE3 ||
-	     pdev->revision == 0xE7 ||
-	     pdev->revision == 0xF3 ||
-	     pdev->revision == 0xF7)) {
-		flags &= ~AMD_ASIC_MASK;
-		flags |= CHIP_POLARIS10;
-	}
+
+	flags = amdgpu_fix_asic_type(pdev, flags);
 
 	/* Due to hardware bugs, S/G Display on raven requires a 1:1 IOMMU mapping,
 	 * however, SME requires an indirect IOMMU mapping because the encryption
include/drm/amd_asic_type.h +5 -0
index 90b69270f2fa..724c45e3e9a7 100644
@@ -68,4 +68,9 @@ enum amd_asic_type {
 
 extern const char *amdgpu_asic_name[];
 
+struct amdgpu_asic_type_quirk {
+	unsigned short device;	/* PCI device ID */
+	u8 revision;	/* revision ID */
+	unsigned short type;	/* real ASIC type */
+};
 #endif /*__AMD_ASIC_TYPE_H__ */
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 2/2 drm/amdgpu: Fix the the asic type of some new asics

Some new asics use the same device id as Sienna_Cichlid. So fix it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +11 -0
index 756cf49557a2..93c8c8b763ed 100644
@@ -2073,6 +2073,17 @@ static const struct amdgpu_asic_type_quirk asic_type_quirks[] = {
 	{0x67FF, 0xE7, CHIP_POLARIS10},
 	{0x67FF, 0xF3, CHIP_POLARIS10},
 	{0x67FF, 0xF7, CHIP_POLARIS10},
+	/* differentiate between Sienna_Cichlid and new asics with the same DID */
+	{0x73BF, 0x18, CHIP_IP_DISCOVERY},
+	{0x73BF, 0x19, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD2, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD4, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD5, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD6, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD8, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xD9, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xDA, CHIP_IP_DISCOVERY},
+	{0x73BF, 0xDB, CHIP_IP_DISCOVERY},
 };
 
 static struct drm_driver amdgpu_kms_driver;
Signature · 1 line
2.34.1
#2 lore raw
In reply to Ma Jun

ping...

Regards,
Ma Jun

Quoted 83 lines · Ma Jun

Use a new struct array to define the asic information which asic type needs to be fixed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 35 ++++++++++++++++++-------
 include/drm/amd_asic_type.h             |  5 ++++
 2 files changed, 31 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +26 -9
index 84703e0a73bd..756cf49557a2 100644
@@ -2067,6 +2067,14 @@ static const struct pci_device_id pciidlist[] = {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static const struct amdgpu_asic_type_quirk asic_type_quirks[] = {
+	/* differentiate between P10 and P11 asics with the same DID */
+	{0x67FF, 0xE3, CHIP_POLARIS10},
+	{0x67FF, 0xE7, CHIP_POLARIS10},
+	{0x67FF, 0xF3, CHIP_POLARIS10},
+	{0x67FF, 0xF7, CHIP_POLARIS10},
+};
+
 static struct drm_driver amdgpu_kms_driver;
 
 static void amdgpu_get_secondary_funcs(struct amdgpu_device *adev)
@@ -2109,6 +2117,22 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)
 	}
 }
 
+static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(asic_type_quirks); i++) {
+		if (pdev->device == asic_type_quirks[i].device &&
+			pdev->revision == asic_type_quirks[i].revision) {
+				flags &= ~AMD_ASIC_MASK;
+				flags |= asic_type_quirks[i].type;
+				break;
+			}
+	}
+
+	return flags;
+}
+
 static int amdgpu_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *ent)
 {
@@ -2138,15 +2162,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 			 "See modparam exp_hw_support\n");
 		return -ENODEV;
 	}
-	/* differentiate between P10 and P11 asics with the same DID */
-	if (pdev->device == 0x67FF &&
-	    (pdev->revision == 0xE3 ||
-	     pdev->revision == 0xE7 ||
-	     pdev->revision == 0xF3 ||
-	     pdev->revision == 0xF7)) {
-		flags &= ~AMD_ASIC_MASK;
-		flags |= CHIP_POLARIS10;
-	}
+
+	flags = amdgpu_fix_asic_type(pdev, flags);
 
 	/* Due to hardware bugs, S/G Display on raven requires a 1:1 IOMMU mapping,
 	 * however, SME requires an indirect IOMMU mapping because the encryption
include/drm/amd_asic_type.h +5 -0
index 90b69270f2fa..724c45e3e9a7 100644
@@ -68,4 +68,9 @@ enum amd_asic_type {
 
 extern const char *amdgpu_asic_name[];
 
+struct amdgpu_asic_type_quirk {
+	unsigned short device;	/* PCI device ID */
+	u8 revision;	/* revision ID */
+	unsigned short type;	/* real ASIC type */
+};
 #endif /*__AMD_ASIC_TYPE_H__ */
Reviewed-by
#3 lore raw

[AMD Official Use Only - General]

-----Original Message-----
From: Ma, Jun <[email protected]>
Sent: Thursday, November 2, 2023 8:58 AM
To: Ma, Jun <[email protected]>; [email protected]; Feng, Kenneth <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Ma, Jun <[email protected]>
Subject: Re: [PATCH v2 1/2] drm/amdgpu: Optimize the asic type fix code

ping...

Regards,
Ma Jun

Quoted 84 lines · Ma Jun

Use a new struct array to define the asic information which asic type needs to be fixed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 35 ++++++++++++++++++-------
 include/drm/amd_asic_type.h             |  5 ++++
 2 files changed, 31 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8 -0
index 84703e0a73bd..756cf49557a2 100644
@@ -2067,6 +2067,14 @@ static const struct pci_device_id pciidlist[] =
 {
 
 MODULE_DEVICE_TABLE(pci, pciidlist);
 
+static const struct amdgpu_asic_type_quirk asic_type_quirks[] = {
+     /* differentiate between P10 and P11 asics with the same DID */
+     {0x67FF, 0xE3, CHIP_POLARIS10},
+     {0x67FF, 0xE7, CHIP_POLARIS10},
+     {0x67FF, 0xF3, CHIP_POLARIS10},
+     {0x67FF, 0xF7, CHIP_POLARIS10},
+};
+
 static struct drm_driver amdgpu_kms_driver;
 

static void amdgpu_get_secondary_funcs(struct amdgpu_device *adev) @@
-2109,6 +2117,22 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)

      }

}

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +16 -0
+static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev,
+unsigned long flags) {
+     int i;
+
+     for (i = 0; i < ARRAY_SIZE(asic_type_quirks); i++) {
+             if (pdev->device == asic_type_quirks[i].device &&
+                     pdev->revision == asic_type_quirks[i].revision) {
+                             flags &= ~AMD_ASIC_MASK;
+                             flags |= asic_type_quirks[i].type;
+                             break;
+                     }
+     }
+
+     return flags;
+}
+
 static int amdgpu_pci_probe(struct pci_dev *pdev,
                          const struct pci_device_id *ent)  { @@ -2138,15 +2162,8 @@

static int amdgpu_pci_probe(struct pci_dev *pdev,

                       "See modparam exp_hw_support\n");
              return -ENODEV;
      }
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -9
-     /* differentiate between P10 and P11 asics with the same DID */
-     if (pdev->device == 0x67FF &&
-         (pdev->revision == 0xE3 ||
-          pdev->revision == 0xE7 ||
-          pdev->revision == 0xF3 ||
-          pdev->revision == 0xF7)) {
-             flags &= ~AMD_ASIC_MASK;
-             flags |= CHIP_POLARIS10;
-     }
+
+     flags = amdgpu_fix_asic_type(pdev, flags);
 
      /* Due to hardware bugs, S/G Display on raven requires a 1:1 IOMMU mapping,
       * however, SME requires an indirect IOMMU mapping because the

encryption diff --git a/include/drm/amd_asic_type.h b/include/drm/amd_asic_type.h index 90b69270f2fa..724c45e3e9a7 100644

include/drm/amd_asic_type.h +5 -0
@@ -68,4 +68,9 @@ enum amd_asic_type {
 
 extern const char *amdgpu_asic_name[];
 
+struct amdgpu_asic_type_quirk {
+     unsigned short device;  /* PCI device ID */
+     u8 revision;    /* revision ID */
+     unsigned short type;    /* real ASIC type */
+};
 #endif /*__AMD_ASIC_TYPE_H__ */