Commit d055714a authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher

drm/amdgpu: Use pcie domain of xcc acpi objects

PCI domain/segment information of xccs is available through ACPI DSM
methods. Consider that also while looking for devices.
Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarRajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 406e8845
...@@ -68,7 +68,7 @@ struct amdgpu_acpi_xcc_info { ...@@ -68,7 +68,7 @@ struct amdgpu_acpi_xcc_info {
struct amdgpu_acpi_dev_info { struct amdgpu_acpi_dev_info {
struct list_head list; struct list_head list;
struct list_head xcc_list; struct list_head xcc_list;
uint16_t bdf; uint32_t sbdf;
uint16_t supp_xcp_mode; uint16_t supp_xcp_mode;
uint16_t xcp_mode; uint16_t xcp_mode;
uint16_t mem_mode; uint16_t mem_mode;
...@@ -927,7 +927,7 @@ static acpi_status amdgpu_acpi_get_node_id(acpi_handle handle, ...@@ -927,7 +927,7 @@ static acpi_status amdgpu_acpi_get_node_id(acpi_handle handle,
#endif #endif
} }
static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u16 bdf) static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u32 sbdf)
{ {
struct amdgpu_acpi_dev_info *acpi_dev; struct amdgpu_acpi_dev_info *acpi_dev;
...@@ -935,14 +935,14 @@ static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u16 bdf) ...@@ -935,14 +935,14 @@ static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u16 bdf)
return NULL; return NULL;
list_for_each_entry(acpi_dev, &amdgpu_acpi_dev_list, list) list_for_each_entry(acpi_dev, &amdgpu_acpi_dev_list, list)
if (acpi_dev->bdf == bdf) if (acpi_dev->sbdf == sbdf)
return acpi_dev; return acpi_dev;
return NULL; return NULL;
} }
static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info, static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,
struct amdgpu_acpi_xcc_info *xcc_info, u16 bdf) struct amdgpu_acpi_xcc_info *xcc_info, u32 sbdf)
{ {
struct amdgpu_acpi_dev_info *tmp; struct amdgpu_acpi_dev_info *tmp;
union acpi_object *obj; union acpi_object *obj;
...@@ -955,7 +955,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info, ...@@ -955,7 +955,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,
INIT_LIST_HEAD(&tmp->xcc_list); INIT_LIST_HEAD(&tmp->xcc_list);
INIT_LIST_HEAD(&tmp->list); INIT_LIST_HEAD(&tmp->list);
tmp->bdf = bdf; tmp->sbdf = sbdf;
obj = acpi_evaluate_dsm_typed(xcc_info->handle, &amd_xcc_dsm_guid, 0, obj = acpi_evaluate_dsm_typed(xcc_info->handle, &amd_xcc_dsm_guid, 0,
AMD_XCC_DSM_GET_SUPP_MODE, NULL, AMD_XCC_DSM_GET_SUPP_MODE, NULL,
...@@ -1007,7 +1007,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info, ...@@ -1007,7 +1007,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,
DRM_DEBUG_DRIVER( DRM_DEBUG_DRIVER(
"New dev(%x): Supported xcp mode: %x curr xcp_mode : %x mem mode : %x, tmr base: %llx tmr size: %llx ", "New dev(%x): Supported xcp mode: %x curr xcp_mode : %x mem mode : %x, tmr base: %llx tmr size: %llx ",
tmp->bdf, tmp->supp_xcp_mode, tmp->xcp_mode, tmp->mem_mode, tmp->sbdf, tmp->supp_xcp_mode, tmp->xcp_mode, tmp->mem_mode,
tmp->tmr_base, tmp->tmr_size); tmp->tmr_base, tmp->tmr_size);
list_add_tail(&tmp->list, &amdgpu_acpi_dev_list); list_add_tail(&tmp->list, &amdgpu_acpi_dev_list);
*dev_info = tmp; *dev_info = tmp;
...@@ -1023,7 +1023,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info, ...@@ -1023,7 +1023,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,
} }
static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info, static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info,
u16 *bdf) u32 *sbdf)
{ {
union acpi_object *obj; union acpi_object *obj;
acpi_status status; acpi_status status;
...@@ -1054,8 +1054,10 @@ static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info, ...@@ -1054,8 +1054,10 @@ static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info,
xcc_info->phy_id = (obj->integer.value >> 32) & 0xFF; xcc_info->phy_id = (obj->integer.value >> 32) & 0xFF;
/* xcp node of this xcc [47:40] */ /* xcp node of this xcc [47:40] */
xcc_info->xcp_node = (obj->integer.value >> 40) & 0xFF; xcc_info->xcp_node = (obj->integer.value >> 40) & 0xFF;
/* PF domain of this xcc [31:16] */
*sbdf = (obj->integer.value) & 0xFFFF0000;
/* PF bus/dev/fn of this xcc [63:48] */ /* PF bus/dev/fn of this xcc [63:48] */
*bdf = (obj->integer.value >> 48) & 0xFFFF; *sbdf |= (obj->integer.value >> 48) & 0xFFFF;
ACPI_FREE(obj); ACPI_FREE(obj);
obj = NULL; obj = NULL;
...@@ -1079,7 +1081,7 @@ static int amdgpu_acpi_enumerate_xcc(void) ...@@ -1079,7 +1081,7 @@ static int amdgpu_acpi_enumerate_xcc(void)
struct acpi_device *acpi_dev; struct acpi_device *acpi_dev;
char hid[ACPI_ID_LEN]; char hid[ACPI_ID_LEN];
int ret, id; int ret, id;
u16 bdf; u32 sbdf;
INIT_LIST_HEAD(&amdgpu_acpi_dev_list); INIT_LIST_HEAD(&amdgpu_acpi_dev_list);
xa_init(&numa_info_xa); xa_init(&numa_info_xa);
...@@ -1107,16 +1109,16 @@ static int amdgpu_acpi_enumerate_xcc(void) ...@@ -1107,16 +1109,16 @@ static int amdgpu_acpi_enumerate_xcc(void)
xcc_info->handle = acpi_device_handle(acpi_dev); xcc_info->handle = acpi_device_handle(acpi_dev);
acpi_dev_put(acpi_dev); acpi_dev_put(acpi_dev);
ret = amdgpu_acpi_get_xcc_info(xcc_info, &bdf); ret = amdgpu_acpi_get_xcc_info(xcc_info, &sbdf);
if (ret) { if (ret) {
kfree(xcc_info); kfree(xcc_info);
continue; continue;
} }
dev_info = amdgpu_acpi_get_dev(bdf); dev_info = amdgpu_acpi_get_dev(sbdf);
if (!dev_info) if (!dev_info)
ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, bdf); ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
if (ret == -ENOMEM) if (ret == -ENOMEM)
return ret; return ret;
...@@ -1136,13 +1138,14 @@ int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset, ...@@ -1136,13 +1138,14 @@ int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset,
u64 *tmr_size) u64 *tmr_size)
{ {
struct amdgpu_acpi_dev_info *dev_info; struct amdgpu_acpi_dev_info *dev_info;
u16 bdf; u32 sbdf;
if (!tmr_offset || !tmr_size) if (!tmr_offset || !tmr_size)
return -EINVAL; return -EINVAL;
bdf = pci_dev_id(adev->pdev); sbdf = (pci_domain_nr(adev->pdev->bus) << 16);
dev_info = amdgpu_acpi_get_dev(bdf); sbdf |= pci_dev_id(adev->pdev);
dev_info = amdgpu_acpi_get_dev(sbdf);
if (!dev_info) if (!dev_info)
return -ENOENT; return -ENOENT;
...@@ -1157,13 +1160,14 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id, ...@@ -1157,13 +1160,14 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
{ {
struct amdgpu_acpi_dev_info *dev_info; struct amdgpu_acpi_dev_info *dev_info;
struct amdgpu_acpi_xcc_info *xcc_info; struct amdgpu_acpi_xcc_info *xcc_info;
u16 bdf; u32 sbdf;
if (!numa_info) if (!numa_info)
return -EINVAL; return -EINVAL;
bdf = pci_dev_id(adev->pdev); sbdf = (pci_domain_nr(adev->pdev->bus) << 16);
dev_info = amdgpu_acpi_get_dev(bdf); sbdf |= pci_dev_id(adev->pdev);
dev_info = amdgpu_acpi_get_dev(sbdf);
if (!dev_info) if (!dev_info)
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment