Skip to contentSkip to conversation

drm/amd: Detect IFWI or PD upgrade support in psp_early_init()

PATCH In review Mario Limonciello 2 participants 3 messages Jun 28, 2023

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

PATCH v2 1/2 drm/amd: Detect IFWI or PD upgrade support in psp_early_init()

Rather than evaluating the IP version for visibility, evaluate it at the same time as the IP is initialized.

---
v1->v2:
* Move to psp_context

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 45 ++++++++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  4 +++
 2 files changed, 29 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +25 -20
index 6929fefb26cfb..270b5b5a3a6d1 100644
@@ -177,9 +177,11 @@ static int psp_early_init(void *handle)
 		psp->autoload_supported = false;
 		break;
 	case IP_VERSION(11, 0, 0):
+	case IP_VERSION(11, 0, 7):
+		adev->psp.sup_pd_fw_up = !amdgpu_sriov_vf(adev);
+		fallthrough;
 	case IP_VERSION(11, 0, 5):
 	case IP_VERSION(11, 0, 9):
-	case IP_VERSION(11, 0, 7):
 	case IP_VERSION(11, 0, 11):
 	case IP_VERSION(11, 5, 0):
 	case IP_VERSION(11, 0, 12):
@@ -214,6 +216,7 @@ static int psp_early_init(void *handle)
 	case IP_VERSION(13, 0, 7):
 		psp_v13_0_set_psp_funcs(psp);
 		psp->autoload_supported = true;
+		adev->psp.sup_ifwi_up = !amdgpu_sriov_vf(adev);
 		break;
 	case IP_VERSION(13, 0, 4):
 		psp_v13_0_4_set_psp_funcs(psp);
@@ -3704,9 +3707,13 @@ static ssize_t amdgpu_psp_vbflash_status(struct device *dev,
 }
 static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NULL);
 
+static struct bin_attribute *bin_flash_attrs[] = {
+	&psp_vbflash_bin_attr,
+	NULL
+};
+
 static struct attribute *flash_attrs[] = {
 	&dev_attr_psp_vbflash_status.attr,
-	&psp_vbflash_bin_attr.attr,
 	&dev_attr_usbc_pd_fw.attr,
 	NULL
 };
@@ -3717,29 +3724,27 @@ static umode_t amdgpu_flash_attr_is_visible(struct kobject *kobj, struct attribu
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(ddev);
 
-	if (amdgpu_sriov_vf(adev))
-		return 0;
+	if (attr == &dev_attr_usbc_pd_fw.attr)
+		return adev->psp.sup_pd_fw_up ? 0660 : 0;
 
-	switch (adev->ip_versions[MP0_HWIP][0]) {
-	case IP_VERSION(11, 0, 0):
-	case IP_VERSION(11, 0, 7):
-		if (attr == &dev_attr_usbc_pd_fw.attr)
-			return 0660;
-		return 0;
-	case IP_VERSION(13, 0, 0):
-	case IP_VERSION(13, 0, 7):
-		if (attr == &dev_attr_usbc_pd_fw.attr)
-			return 0;
-		else if (attr == &psp_vbflash_bin_attr.attr)
-			return 0660;
-		return 0440;
-	default:
-		return 0;
-	}
+	return adev->psp.sup_ifwi_up ? 0440 : 0;
+}
+
+static umode_t amdgpu_bin_flash_attr_is_visible(struct kobject *kobj,
+						struct bin_attribute *attr,
+						int idx)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(ddev);
+
+	return adev->psp.sup_ifwi_up ? 0660 : 0;
 }
 
 const struct attribute_group amdgpu_flash_attr_group = {
 	.attrs = flash_attrs,
+	.bin_attrs = bin_flash_attrs,
+	.is_bin_visible = amdgpu_bin_flash_attr_is_visible,
 	.is_visible = amdgpu_flash_attr_is_visible,
 };
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +4 -0
index 4847aacdf9dca..e176cf204202f 100644
@@ -384,6 +384,10 @@ struct psp_context
 
 	uint32_t			boot_cfg_bitmask;
 
+	/* firmware upgrades supported */
+	bool				sup_pd_fw_up;
+	bool				sup_ifwi_up;
+
 	char *vbflash_tmp_buf;
 	size_t vbflash_image_size;
 	bool vbflash_done;
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/2 drm/amd: adjust whitespace for amdgpu_psp.h

Adjust the whitespace to be consistent with the rest of the struct psp_context structure.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -6
index e176cf204202f..050230114e88e 100644
@@ -309,8 +309,8 @@ struct psp_runtime_scpm_entry {
 
 struct psp_context
 {
-	struct amdgpu_device            *adev;
-	struct psp_ring                 km_ring;
+	struct amdgpu_device		*adev;
+	struct psp_ring			km_ring;
 	struct psp_gfx_cmd_resp		*cmd;
 
 	const struct psp_funcs		*funcs;
@@ -339,7 +339,7 @@ struct psp_context
 	uint64_t			tmr_mc_addr;
 
 	/* asd firmware */
-	const struct firmware	*asd_fw;
+	const struct firmware		*asd_fw;
 
 	/* toc firmware */
 	const struct firmware		*toc_fw;
@@ -388,9 +388,9 @@ struct psp_context
 	bool				sup_pd_fw_up;
 	bool				sup_ifwi_up;
 
-	char *vbflash_tmp_buf;
-	size_t vbflash_image_size;
-	bool vbflash_done;
+	char				*vbflash_tmp_buf;
+	size_t				vbflash_image_size;
+	bool				vbflash_done;
 };
 
 struct amdgpu_psp_funcs {
Signature · 1 line
2.34.1
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] drm/amd: adjust whitespace for amdgpu_psp.h

Quoted 4 lines · Mario Limonciello

Adjust the whitespace to be consistent with the rest of the struct psp_context structure.

Series is -

Thanks,
Lijo

Quoted 41 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -6
index e176cf204202f..050230114e88e 100644
@@ -309,8 +309,8 @@ struct psp_runtime_scpm_entry {
 
  struct psp_context
  {
-	struct amdgpu_device            *adev;
-	struct psp_ring                 km_ring;
+	struct amdgpu_device		*adev;
+	struct psp_ring			km_ring;
  	struct psp_gfx_cmd_resp		*cmd;
 
  	const struct psp_funcs		*funcs;
@@ -339,7 +339,7 @@ struct psp_context
  	uint64_t			tmr_mc_addr;
 
  	/* asd firmware */
-	const struct firmware	*asd_fw;
+	const struct firmware		*asd_fw;
 
  	/* toc firmware */
  	const struct firmware		*toc_fw;
@@ -388,9 +388,9 @@ struct psp_context
  	bool				sup_pd_fw_up;
  	bool				sup_ifwi_up;
 
-	char *vbflash_tmp_buf;
-	size_t vbflash_image_size;
-	bool vbflash_done;
+	char				*vbflash_tmp_buf;
+	size_t				vbflash_image_size;
+	bool				vbflash_done;
  };
 
  struct amdgpu_psp_funcs {