Skip to content

Commit dbab635

Browse files
Ma Junalexdeucher
authored andcommitted
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. Signed-off-by: Ma Jun <[email protected]> Reviewed-by: Kenneth Feng <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 36e7ff5 commit dbab635

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,14 @@ static const struct pci_device_id pciidlist[] = {
20412041

20422042
MODULE_DEVICE_TABLE(pci, pciidlist);
20432043

2044+
static const struct amdgpu_asic_type_quirk asic_type_quirks[] = {
2045+
/* differentiate between P10 and P11 asics with the same DID */
2046+
{0x67FF, 0xE3, CHIP_POLARIS10},
2047+
{0x67FF, 0xE7, CHIP_POLARIS10},
2048+
{0x67FF, 0xF3, CHIP_POLARIS10},
2049+
{0x67FF, 0xF7, CHIP_POLARIS10},
2050+
};
2051+
20442052
static const struct drm_driver amdgpu_kms_driver;
20452053

20462054
static void amdgpu_get_secondary_funcs(struct amdgpu_device *adev)
@@ -2083,6 +2091,22 @@ static void amdgpu_init_debug_options(struct amdgpu_device *adev)
20832091
}
20842092
}
20852093

2094+
static unsigned long amdgpu_fix_asic_type(struct pci_dev *pdev, unsigned long flags)
2095+
{
2096+
int i;
2097+
2098+
for (i = 0; i < ARRAY_SIZE(asic_type_quirks); i++) {
2099+
if (pdev->device == asic_type_quirks[i].device &&
2100+
pdev->revision == asic_type_quirks[i].revision) {
2101+
flags &= ~AMD_ASIC_MASK;
2102+
flags |= asic_type_quirks[i].type;
2103+
break;
2104+
}
2105+
}
2106+
2107+
return flags;
2108+
}
2109+
20862110
static int amdgpu_pci_probe(struct pci_dev *pdev,
20872111
const struct pci_device_id *ent)
20882112
{
@@ -2110,15 +2134,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
21102134
"See modparam exp_hw_support\n");
21112135
return -ENODEV;
21122136
}
2113-
/* differentiate between P10 and P11 asics with the same DID */
2114-
if (pdev->device == 0x67FF &&
2115-
(pdev->revision == 0xE3 ||
2116-
pdev->revision == 0xE7 ||
2117-
pdev->revision == 0xF3 ||
2118-
pdev->revision == 0xF7)) {
2119-
flags &= ~AMD_ASIC_MASK;
2120-
flags |= CHIP_POLARIS10;
2121-
}
2137+
2138+
flags = amdgpu_fix_asic_type(pdev, flags);
21222139

21232140
/* Due to hardware bugs, S/G Display on raven requires a 1:1 IOMMU mapping,
21242141
* however, SME requires an indirect IOMMU mapping because the encryption

include/drm/amd_asic_type.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ enum amd_asic_type {
6868

6969
extern const char *amdgpu_asic_name[];
7070

71+
struct amdgpu_asic_type_quirk {
72+
unsigned short device; /* PCI device ID */
73+
u8 revision; /* revision ID */
74+
unsigned short type; /* real ASIC type */
75+
};
7176
#endif /*__AMD_ASIC_TYPE_H__ */

0 commit comments

Comments
 (0)