<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div dir="ltr">
<div></div>
<div>
<div>Looks good to me. </div>
<div dir="ltr">Reviewed-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com></div>
<div id="ms-outlook-mobile-signature">
<div><br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Regards,</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Rajneesh</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Monday, October 23, 2023 2:43:01 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Kasiviswanathan, Harish <Harish.Kasiviswanathan@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Bhardwaj, Rajneesh <Rajneesh.Bhardwaj@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Use pcie domain of xcc acpi objects</font>
<div> </div>
</div>
<div>
<p align="Left" style="font-family:Arial; font-size:10pt; color:#0000FF; margin:5pt; font-style:normal; font-weight:normal; text-decoration:none">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div dir="auto"><ping></div>
<div id="x_ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Thanks,<br>
Lijo</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Lijo Lazar <lijo.lazar@amd.com><br>
<b>Sent:</b> Friday, October 20, 2023 8:44:22 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Kasiviswanathan, Harish <Harish.Kasiviswanathan@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Use pcie domain of xcc acpi objects</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">PCI domain/segment information of xccs is available through ACPI DSM<br>
methods. Consider that also while looking for devices.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 40 +++++++++++++-----------<br>
1 file changed, 22 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c<br>
index 2bca37044ad0..d62e49758635 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c<br>
@@ -68,7 +68,7 @@ struct amdgpu_acpi_xcc_info {<br>
struct amdgpu_acpi_dev_info {<br>
struct list_head list;<br>
struct list_head xcc_list;<br>
- uint16_t bdf;<br>
+ uint32_t sbdf;<br>
uint16_t supp_xcp_mode;<br>
uint16_t xcp_mode;<br>
uint16_t mem_mode;<br>
@@ -927,7 +927,7 @@ static acpi_status amdgpu_acpi_get_node_id(acpi_handle handle,<br>
#endif<br>
}<br>
<br>
-static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u16 bdf)<br>
+static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u32 sbdf)<br>
{<br>
struct amdgpu_acpi_dev_info *acpi_dev;<br>
<br>
@@ -935,14 +935,14 @@ static struct amdgpu_acpi_dev_info *amdgpu_acpi_get_dev(u16 bdf)<br>
return NULL;<br>
<br>
list_for_each_entry(acpi_dev, &amdgpu_acpi_dev_list, list)<br>
- if (acpi_dev->bdf == bdf)<br>
+ if (acpi_dev->sbdf == sbdf)<br>
return acpi_dev;<br>
<br>
return NULL;<br>
}<br>
<br>
static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,<br>
- struct amdgpu_acpi_xcc_info *xcc_info, u16 bdf)<br>
+ struct amdgpu_acpi_xcc_info *xcc_info, u32 sbdf)<br>
{<br>
struct amdgpu_acpi_dev_info *tmp;<br>
union acpi_object *obj;<br>
@@ -955,7 +955,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,<br>
<br>
INIT_LIST_HEAD(&tmp->xcc_list);<br>
INIT_LIST_HEAD(&tmp->list);<br>
- tmp->bdf = bdf;<br>
+ tmp->sbdf = sbdf;<br>
<br>
obj = acpi_evaluate_dsm_typed(xcc_info->handle, &amd_xcc_dsm_guid, 0,<br>
AMD_XCC_DSM_GET_SUPP_MODE, NULL,<br>
@@ -1007,7 +1007,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,<br>
<br>
DRM_DEBUG_DRIVER(<br>
"New dev(%x): Supported xcp mode: %x curr xcp_mode : %x mem mode : %x, tmr base: %llx tmr size: %llx ",<br>
- tmp->bdf, tmp->supp_xcp_mode, tmp->xcp_mode, tmp->mem_mode,<br>
+ tmp->sbdf, tmp->supp_xcp_mode, tmp->xcp_mode, tmp->mem_mode,<br>
tmp->tmr_base, tmp->tmr_size);<br>
list_add_tail(&tmp->list, &amdgpu_acpi_dev_list);<br>
*dev_info = tmp;<br>
@@ -1023,7 +1023,7 @@ static int amdgpu_acpi_dev_init(struct amdgpu_acpi_dev_info **dev_info,<br>
}<br>
<br>
static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info,<br>
- u16 *bdf)<br>
+ u32 *sbdf)<br>
{<br>
union acpi_object *obj;<br>
acpi_status status;<br>
@@ -1054,8 +1054,10 @@ static int amdgpu_acpi_get_xcc_info(struct amdgpu_acpi_xcc_info *xcc_info,<br>
xcc_info->phy_id = (obj->integer.value >> 32) & 0xFF;<br>
/* xcp node of this xcc [47:40] */<br>
xcc_info->xcp_node = (obj->integer.value >> 40) & 0xFF;<br>
+ /* PF domain of this xcc [31:16] */<br>
+ *sbdf = (obj->integer.value) & 0xFFFF0000;<br>
/* PF bus/dev/fn of this xcc [63:48] */<br>
- *bdf = (obj->integer.value >> 48) & 0xFFFF;<br>
+ *sbdf |= (obj->integer.value >> 48) & 0xFFFF;<br>
ACPI_FREE(obj);<br>
obj = NULL;<br>
<br>
@@ -1079,7 +1081,7 @@ static int amdgpu_acpi_enumerate_xcc(void)<br>
struct acpi_device *acpi_dev;<br>
char hid[ACPI_ID_LEN];<br>
int ret, id;<br>
- u16 bdf;<br>
+ u32 sbdf;<br>
<br>
INIT_LIST_HEAD(&amdgpu_acpi_dev_list);<br>
xa_init(&numa_info_xa);<br>
@@ -1107,16 +1109,16 @@ static int amdgpu_acpi_enumerate_xcc(void)<br>
xcc_info->handle = acpi_device_handle(acpi_dev);<br>
acpi_dev_put(acpi_dev);<br>
<br>
- ret = amdgpu_acpi_get_xcc_info(xcc_info, &bdf);<br>
+ ret = amdgpu_acpi_get_xcc_info(xcc_info, &sbdf);<br>
if (ret) {<br>
kfree(xcc_info);<br>
continue;<br>
}<br>
<br>
- dev_info = amdgpu_acpi_get_dev(bdf);<br>
+ dev_info = amdgpu_acpi_get_dev(sbdf);<br>
<br>
if (!dev_info)<br>
- ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, bdf);<br>
+ ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);<br>
<br>
if (ret == -ENOMEM)<br>
return ret;<br>
@@ -1136,13 +1138,14 @@ int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset,<br>
u64 *tmr_size)<br>
{<br>
struct amdgpu_acpi_dev_info *dev_info;<br>
- u16 bdf;<br>
+ u32 sbdf;<br>
<br>
if (!tmr_offset || !tmr_size)<br>
return -EINVAL;<br>
<br>
- bdf = pci_dev_id(adev->pdev);<br>
- dev_info = amdgpu_acpi_get_dev(bdf);<br>
+ sbdf = (pci_domain_nr(adev->pdev->bus) << 16);<br>
+ sbdf |= pci_dev_id(adev->pdev);<br>
+ dev_info = amdgpu_acpi_get_dev(sbdf);<br>
if (!dev_info)<br>
return -ENOENT;<br>
<br>
@@ -1157,13 +1160,14 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,<br>
{<br>
struct amdgpu_acpi_dev_info *dev_info;<br>
struct amdgpu_acpi_xcc_info *xcc_info;<br>
- u16 bdf;<br>
+ u32 sbdf;<br>
<br>
if (!numa_info)<br>
return -EINVAL;<br>
<br>
- bdf = pci_dev_id(adev->pdev);<br>
- dev_info = amdgpu_acpi_get_dev(bdf);<br>
+ sbdf = (pci_domain_nr(adev->pdev->bus) << 16);<br>
+ sbdf |= pci_dev_id(adev->pdev);<br>
+ dev_info = amdgpu_acpi_get_dev(sbdf);<br>
if (!dev_info)<br>
return -ENOENT;<br>
<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</body>
</html>