Skip to contentSkip to conversation

drm/amd: Don't initialize PSP twice for Navi3x

PATCH In review Mario Limonciello 3 participants 7 messages Jun 26, 2023 – Jun 27, 2023

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

PATCH 1/5 drm/amd: Don't initialize PSP twice for Navi3x

PSP functions are already set by psp_early_init() so initializing them a second time is unnecessary.
No intended functional changes.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -4
index a150b7a4b4aae..eb687a338a1bd 100644
@@ -3621,10 +3621,6 @@ int amdgpu_psp_sysfs_init(struct amdgpu_device *adev)
 	switch (adev->ip_versions[MP0_HWIP][0]) {
 	case IP_VERSION(13, 0, 0):
 	case IP_VERSION(13, 0, 7):
-		if (!psp->adev) {
-			psp->adev = adev;
-			psp_v13_0_set_psp_funcs(psp);
-		}
 		ret = sysfs_create_bin_file(&adev->dev->kobj, &psp_vbflash_bin_attr);
 		if (ret)
 			dev_err(adev->dev, "Failed to create device file psp_vbflash");
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/5 drm/amd: Use attribute groups for PSP flashing attributes

Individually creating attributes can be racy, instead make attributes using attribute groups and control their visibility with an is_visible callback to only show when using appropriate products.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 -----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    | 49 +++++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h    |  1 -
 5 files changed, 27 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index 02b827785e399..a7ef43e25c758 100644
@@ -1004,7 +1004,6 @@ struct amdgpu_device {
 	bool                            has_pr3;
 
 	bool                            ucode_sysfs_en;
-	bool                            psp_sysfs_en;
 
 	/* Chip product information */
 	char				product_number[20];
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -10
index 5c7d40873ee20..65fe0f3488679 100644
@@ -3907,14 +3907,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	} else
 		adev->ucode_sysfs_en = true;
 
-	r = amdgpu_psp_sysfs_init(adev);
-	if (r) {
-		adev->psp_sysfs_en = false;
-		if (!amdgpu_sriov_vf(adev))
-			DRM_ERROR("Creating psp sysfs failed\n");
-	} else
-		adev->psp_sysfs_en = true;
-
 	/*
 	 * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost.
 	 * Otherwise the mgpu fan boost feature will be skipped due to the
@@ -4064,8 +4056,6 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 		amdgpu_pm_sysfs_fini(adev);
 	if (adev->ucode_sysfs_en)
 		amdgpu_ucode_sysfs_fini(adev);
-	if (adev->psp_sysfs_en)
-		amdgpu_psp_sysfs_fini(adev);
 	sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
 
 	/* disable ras feature must before hw fini */
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
index 393b6fb7a71d3..99b8d3113d6af 100644
@@ -2827,11 +2827,13 @@ static struct pci_error_handlers amdgpu_pci_err_handler = {
 extern const struct attribute_group amdgpu_vram_mgr_attr_group;
 extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
 extern const struct attribute_group amdgpu_vbios_version_attr_group;
+extern const struct attribute_group amdgpu_flash_attr_group;
 
 static const struct attribute_group *amdgpu_sysfs_groups[] = {
 	&amdgpu_vram_mgr_attr_group,
 	&amdgpu_gtt_mgr_attr_group,
 	&amdgpu_vbios_version_attr_group,
+	&amdgpu_flash_attr_group,
 	NULL,
 };
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +25 -24

82 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -1
index cf4f60c661223..b441c07e5a16f 100644
@@ -522,5 +522,4 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
 int is_psp_fw_valid(struct psp_bin_desc bin);
 
 int amdgpu_psp_sysfs_init(struct amdgpu_device *adev);
-void amdgpu_psp_sysfs_fini(struct amdgpu_device *adev);
 #endif
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/5] drm/amd: Use attribute groups for PSP flashing attributes

Quoted 93 lines · Mario Limonciello

Individually creating attributes can be racy, instead make attributes using attribute groups and control their visibility with an is_visible callback to only show when using appropriate products.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 -
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 -----
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  2 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    | 49 +++++++++++-----------
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h    |  1 -
  5 files changed, 27 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index 02b827785e399..a7ef43e25c758 100644
@@ -1004,7 +1004,6 @@ struct amdgpu_device {
  	bool                            has_pr3;
 
  	bool                            ucode_sysfs_en;
-	bool                            psp_sysfs_en;
 
  	/* Chip product information */
  	char				product_number[20];
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -10
index 5c7d40873ee20..65fe0f3488679 100644
@@ -3907,14 +3907,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  	} else
  		adev->ucode_sysfs_en = true;
 
-	r = amdgpu_psp_sysfs_init(adev);
-	if (r) {
-		adev->psp_sysfs_en = false;
-		if (!amdgpu_sriov_vf(adev))
-			DRM_ERROR("Creating psp sysfs failed\n");
-	} else
-		adev->psp_sysfs_en = true;
-
  	/*
  	 * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost.
  	 * Otherwise the mgpu fan boost feature will be skipped due to the
@@ -4064,8 +4056,6 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
  		amdgpu_pm_sysfs_fini(adev);
  	if (adev->ucode_sysfs_en)
  		amdgpu_ucode_sysfs_fini(adev);
-	if (adev->psp_sysfs_en)
-		amdgpu_psp_sysfs_fini(adev);
  	sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
 
  	/* disable ras feature must before hw fini */
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
index 393b6fb7a71d3..99b8d3113d6af 100644
@@ -2827,11 +2827,13 @@ static struct pci_error_handlers amdgpu_pci_err_handler = {
  extern const struct attribute_group amdgpu_vram_mgr_attr_group;
  extern const struct attribute_group amdgpu_gtt_mgr_attr_group;
  extern const struct attribute_group amdgpu_vbios_version_attr_group;
+extern const struct attribute_group amdgpu_flash_attr_group;
 
  static const struct attribute_group *amdgpu_sysfs_groups[] = {
  	&amdgpu_vram_mgr_attr_group,
  	&amdgpu_gtt_mgr_attr_group,
  	&amdgpu_vbios_version_attr_group,
+	&amdgpu_flash_attr_group,
  	NULL,
  };
 
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
index eb687a338a1bd..4286c0b4beb90 100644
@@ -3584,6 +3584,13 @@ static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *kobj,
  	return 0;
  }
 
+static struct bin_attribute psp_vbflash_bin_attr = {
+	.attr = {.name = "psp_vbflash", .mode = 0660},
+	.size = 0,
+	.write = amdgpu_psp_vbflash_write,
+	.read = amdgpu_psp_vbflash_read,
+};
+
  static ssize_t amdgpu_psp_vbflash_status(struct device *dev,
  					 struct device_attribute *attr,
  					 char *buf)
@@ -3600,39 +3607,39 @@ static ssize_t amdgpu_psp_vbflash_status(struct device *dev,
 
  	return sysfs_emit(buf, "0x%x\n", vbflash_status);
  }

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static ssize_t amdgpu_psp_vbflash_status(struct device *dev, · line 3614

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -5
+static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NULL);
 
-static const struct bin_attribute psp_vbflash_bin_attr = {
-	.attr = {.name = "psp_vbflash", .mode = 0660},
-	.size = 0,
-	.write = amdgpu_psp_vbflash_write,
-	.read = amdgpu_psp_vbflash_read,
+static struct attribute *flash_attrs[] = {
+	&dev_attr_psp_vbflash_status.attr,
+	&psp_vbflash_bin_attr.attr,

There is a separate bin_attrs/is_bin_visible in attribute group. Better to make use of that instead of mixing bin and regular attributes.

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -5
+	NULL
  };
 
-static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NULL);
-
-int amdgpu_psp_sysfs_init(struct amdgpu_device *adev)
+static umode_t amdgpu_flash_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
  {
-	int ret = 0;
-	struct psp_context *psp = &adev->psp;
+	struct device *dev = kobj_to_dev(kobj);

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static ssize_t amdgpu_psp_vbflash_status(struct device *dev, · line 3629

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -1
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(ddev);
 
  	if (amdgpu_sriov_vf(adev))
-		return -EINVAL;
+		return 0;
 
  	switch (adev->ip_versions[MP0_HWIP][0]) {
  	case IP_VERSION(13, 0, 0):
  	case IP_VERSION(13, 0, 7):

If we can init some flags during early init of each IP, then this type of check can be removed here. Instead check the flags. May need more work for such flags when some IPs support only read vs some supporting both read/write.

Thanks,
Lijo

Quoted 46 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +8 -13
-		ret = sysfs_create_bin_file(&adev->dev->kobj, &psp_vbflash_bin_attr);
-		if (ret)
-			dev_err(adev->dev, "Failed to create device file psp_vbflash");
-		ret = device_create_file(adev->dev, &dev_attr_psp_vbflash_status);
-		if (ret)
-			dev_err(adev->dev, "Failed to create device file psp_vbflash_status");
-		return ret;
+		if (attr == &psp_vbflash_bin_attr.attr)
+			return 0660;
+		return 0440;
  	default:
  		return 0;
  	}
  }
 
+const struct attribute_group amdgpu_flash_attr_group = {
+	.attrs = flash_attrs,
+	.is_visible = amdgpu_flash_attr_is_visible,
+};
+
  const struct amd_ip_funcs psp_ip_funcs = {
  	.name = "psp",
  	.early_init = psp_early_init,
@@ -3661,12 +3668,6 @@ static int psp_sysfs_init(struct amdgpu_device *adev)
  	return ret;
  }
 
-void amdgpu_psp_sysfs_fini(struct amdgpu_device *adev)
-{
-	sysfs_remove_bin_file(&adev->dev->kobj, &psp_vbflash_bin_attr);
-	device_remove_file(adev->dev, &dev_attr_psp_vbflash_status);
-}
-
  static void psp_sysfs_fini(struct amdgpu_device *adev)
  {
  	device_remove_file(adev->dev, &dev_attr_usbc_pd_fw);
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -1
index cf4f60c661223..b441c07e5a16f 100644
@@ -522,5 +522,4 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
  int is_psp_fw_valid(struct psp_bin_desc bin);
 
  int amdgpu_psp_sysfs_init(struct amdgpu_device *adev);
-void amdgpu_psp_sysfs_fini(struct amdgpu_device *adev);
  #endif
#3 lore raw

PATCH 3/5 drm/amd: Make flashing messages quieter

In reply to Mario Limonciello

Debug messages related to the kernel process of flashing an updated IFWI are needlessly noisy and also confusing.

Downgrade them to debug instead and clarify what they are actually doing.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -4
index 4286c0b4beb90..93d014e69ee39 100644
@@ -3531,7 +3531,7 @@ static ssize_t amdgpu_psp_vbflash_write(struct file *filp, struct kobject *kobj,
 	adev->psp.vbflash_image_size += count;
 	mutex_unlock(&adev->psp.mutex);
 
-	dev_info(adev->dev, "VBIOS flash write PSP done");
+	dev_dbg(adev->dev, "IFWI staged for update");
 
 	return count;
 }
@@ -3551,7 +3551,7 @@ static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *kobj,
 	if (adev->psp.vbflash_image_size == 0)
 		return -EINVAL;
 
-	dev_info(adev->dev, "VBIOS flash to PSP started");
+	dev_dbg(adev->dev, "PSP IFWI flash process initiated");
 
 	ret = amdgpu_bo_create_kernel(adev, adev->psp.vbflash_image_size,
 					AMDGPU_GPU_PAGE_SIZE,
@@ -3576,11 +3576,11 @@ static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *kobj,
 	adev->psp.vbflash_image_size = 0;
 
 	if (ret) {
-		dev_err(adev->dev, "Failed to load VBIOS FW, err = %d", ret);
+		dev_err(adev->dev, "Failed to load IFWI, err = %d", ret);
 		return ret;
 	}
 
-	dev_info(adev->dev, "VBIOS flash to PSP done");
+	dev_dbg(adev->dev, "PSP IFWI flash process done");
 	return 0;
 }
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/5 drm/amd: Convert USB-C PD F/W attributes into groups

In reply to Mario Limonciello

Rather than special casing the creation of the file, special case the visibility to the supported dGPUs.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 40 ++++++-------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -
 2 files changed, 9 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -31
index 93d014e69ee39..7872004ed7f9b 100644
@@ -45,9 +45,6 @@
 
 #define AMD_VBIOS_FILE_MAX_SIZE_B      (1024*1024*3)
 
-static int psp_sysfs_init(struct amdgpu_device *adev);
-static void psp_sysfs_fini(struct amdgpu_device *adev);
-
 static int psp_load_smu_fw(struct psp_context *psp);
 static int psp_rap_terminate(struct psp_context *psp);
 static int psp_securedisplay_terminate(struct psp_context *psp);
@@ -456,14 +453,6 @@ static int psp_sw_init(void *handle)
 		}
 	}
 
-	if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 0) ||
-	    adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 7)) {
-		ret= psp_sysfs_init(adev);
-		if (ret) {
-			return ret;
-		}
-	}
-
 	ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
 				      amdgpu_sriov_vf(adev) ?
 				      AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT,
@@ -513,10 +502,6 @@ static int psp_sw_fini(void *handle)
 	amdgpu_ucode_release(&psp->cap_fw);
 	amdgpu_ucode_release(&psp->toc_fw);
 
-	if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 0) ||
-	    adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 7))
-		psp_sysfs_fini(adev);
-
 	kfree(cmd);
 	cmd = NULL;
 
@@ -3612,6 +3597,7 @@ static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NULL);
 static struct attribute *flash_attrs[] = {
 	&dev_attr_psp_vbflash_status.attr,
 	&psp_vbflash_bin_attr.attr,
+	&dev_attr_usbc_pd_fw.attr,
 	NULL
 };
 
@@ -3625,9 +3611,16 @@ static umode_t amdgpu_flash_attr_is_visible(struct kobject *kobj, struct attribu
 		return 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 == &psp_vbflash_bin_attr.attr)
+		if (attr == &dev_attr_usbc_pd_fw.attr)
+			return 0;
+		else if (attr == &psp_vbflash_bin_attr.attr)
 			return 0660;
 		return 0440;
 	default:
@@ -3658,21 +3651,6 @@ const struct amd_ip_funcs psp_ip_funcs = {
 	.set_powergating_state = psp_set_powergating_state,
 };
 
-static int psp_sysfs_init(struct amdgpu_device *adev)
-{
-	int ret = device_create_file(adev->dev, &dev_attr_usbc_pd_fw);
-
-	if (ret)
-		DRM_ERROR("Failed to create USBC PD FW control file!");
-
-	return ret;
-}
-
-static void psp_sysfs_fini(struct amdgpu_device *adev)
-{
-	device_remove_file(adev->dev, &dev_attr_usbc_pd_fw);
-}
-
 const struct amdgpu_ip_block_version psp_v3_1_ip_block =
 {
 	.type = AMD_IP_BLOCK_TYPE_PSP,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -1
index b441c07e5a16f..619b27e891b5b 100644
@@ -521,5 +521,4 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
 
 int is_psp_fw_valid(struct psp_bin_desc bin);
 
-int amdgpu_psp_sysfs_init(struct amdgpu_device *adev);
 #endif
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/5 drm/amd: Add documentation for how to flash a dGPU

In reply to Mario Limonciello
---
 Documentation/gpu/amdgpu/flashing.rst   | 33 +++++++++++++++++++++++++
 Documentation/gpu/amdgpu/index.rst      |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 16 ++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 Documentation/gpu/amdgpu/flashing.rst
Documentation/gpu/amdgpu/flashing.rst new file +33 -0
new file mode 100644
index 0000000000000..bd745c42a538f
@@ -0,0 +1,33 @@
+=======================
+ dGPU firmware flashing
+=======================
+
+IFWI
+----
+Flashing the dGPU integrated firmware image (IFWI) is supported by GPUs that
+use the PSP to orchestrate the update (Navi3x or newer GPUs).
+For supported GPUs, `amdgpu` will export a series of sysfs files that can be
+used for the flash process.
+
+The IFWI flash process is:
+
+1. Ensure the IFWI image is intended for the dGPU on the system.
+2. "Write" the IFWI image to the sysfs file `psp_vbflash`. This will stage the IFWI in memory.
+3. "Read" from the `psp_vbflash` sysfs file to initiate the flash process.
+4. Poll the `psp_vbflash_status` sysfs file to determine when the flash process completes.
+
+USB-C PD F/W
+------------
+On GPUs that support flashing an updated USB-C PD firmware image, the process
+is done using the `usbc_pd_fw` sysfs file.
+
+* Reading the file will provide the current firmware version.
+* Writing the name of a firmware payload stored in `/lib/firmware/amdgpu` to the sysfs file will initiate the flash process.
+
+The firmware payload stored in `/lib/firmware/amdgpu` can be named any name
+as long as it doesn't conflict with other existing binaries that are used by
+`amdgpu`.
+
+sysfs files
+-----------
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
Documentation/gpu/amdgpu/index.rst +1 -0
index 03c2966cae798..912e699fd3731 100644
@@ -10,6 +10,7 @@ Next (GCN), Radeon DNA (RDNA), and Compute DNA (CDNA) architectures.
    module-parameters
    driver-core
    display/index
+   flashing
    xgmi
    ras
    thermal
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +16 -0
index 7872004ed7f9b..047760bafcc23 100644
@@ -3476,6 +3476,11 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
 	drm_dev_exit(idx);
 }
 
+/**
+ * DOC: usbc_pd_fw
+ * Reading from this file will retrieve the USB-C PD firmware version. Writing to
+ * this file will trigger the update process.
+ */
 static DEVICE_ATTR(usbc_pd_fw, S_IRUGO | S_IWUSR,
 		   psp_usbc_pd_fw_sysfs_read,
 		   psp_usbc_pd_fw_sysfs_write);
@@ -3569,6 +3574,11 @@ static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *kobj,
 	return 0;
 }
 
+/**
+ * DOC: psp_vbflash
+ * Writing to this file will stage an IFWI for update. Reading from this file
+ * will trigger the update process.
+ */
 static struct bin_attribute psp_vbflash_bin_attr = {
 	.attr = {.name = "psp_vbflash", .mode = 0660},
 	.size = 0,
@@ -3576,6 +3586,12 @@ static struct bin_attribute psp_vbflash_bin_attr = {
 	.read = amdgpu_psp_vbflash_read,
 };
 
+/**
+ * DOC: psp_vbflash_status
+ * The status of the flash process.
+ * 0: IFWI flash not complete.
+ * 1: IFWI flash complete.
+ */
 static ssize_t amdgpu_psp_vbflash_status(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
Signature · 1 line
2.34.1
Reviewed-by on v1 5/5
#6 lore raw

Re: [PATCH 5/5] drm/amd: Add documentation for how to flash a dGPU

Quoted 1 line · Mario Limonciello

Needs a basic patch description. Even just "add documentation"

With that fixed, the series is:

Quoted 103 lines
---
 Documentation/gpu/amdgpu/flashing.rst   | 33 +++++++++++++++++++++++++
 Documentation/gpu/amdgpu/index.rst      |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 16 ++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 Documentation/gpu/amdgpu/flashing.rst
Documentation/gpu/amdgpu/flashing.rst new file +33 -0
new file mode 100644
index 0000000000000..bd745c42a538f
@@ -0,0 +1,33 @@
+=======================
+ dGPU firmware flashing
+=======================
+
+IFWI
+----
+Flashing the dGPU integrated firmware image (IFWI) is supported by GPUs that
+use the PSP to orchestrate the update (Navi3x or newer GPUs).
+For supported GPUs, `amdgpu` will export a series of sysfs files that can be
+used for the flash process.
+
+The IFWI flash process is:
+
+1. Ensure the IFWI image is intended for the dGPU on the system.
+2. "Write" the IFWI image to the sysfs file `psp_vbflash`. This will stage the IFWI in memory.
+3. "Read" from the `psp_vbflash` sysfs file to initiate the flash process.
+4. Poll the `psp_vbflash_status` sysfs file to determine when the flash process completes.
+
+USB-C PD F/W
+------------
+On GPUs that support flashing an updated USB-C PD firmware image, the process
+is done using the `usbc_pd_fw` sysfs file.
+
+* Reading the file will provide the current firmware version.
+* Writing the name of a firmware payload stored in `/lib/firmware/amdgpu` to the sysfs file will initiate the flash process.
+
+The firmware payload stored in `/lib/firmware/amdgpu` can be named any name
+as long as it doesn't conflict with other existing binaries that are used by
+`amdgpu`.
+
+sysfs files
+-----------
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
Documentation/gpu/amdgpu/index.rst +1 -0
index 03c2966cae798..912e699fd3731 100644
@@ -10,6 +10,7 @@ Next (GCN), Radeon DNA (RDNA), and Compute DNA (CDNA) architectures.
    module-parameters
    driver-core
    display/index
+   flashing
    xgmi
    ras
    thermal
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +16 -1
index 7872004ed7f9b..047760bafcc23 100644
@@ -3476,6 +3476,11 @@ void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size
        drm_dev_exit(idx);
 }
 
+/**
+ * DOC: usbc_pd_fw
+ * Reading from this file will retrieve the USB-C PD firmware version. Writing to
+ * this file will trigger the update process.
+ */
 static DEVICE_ATTR(usbc_pd_fw, S_IRUGO | S_IWUSR,
                   psp_usbc_pd_fw_sysfs_read,
                   psp_usbc_pd_fw_sysfs_write);
@@ -3569,6 +3574,11 @@ static ssize_t amdgpu_psp_vbflash_read(struct file *filp, struct kobject *kobj,
        return 0;
 }
 
+/**
+ * DOC: psp_vbflash
+ * Writing to this file will stage an IFWI for update. Reading from this file
+ * will trigger the update process.
+ */
 static struct bin_attribute psp_vbflash_bin_attr = {
        .attr = {.name = "psp_vbflash", .mode = 0660},
        .size = 0,
@@ -3576,6 +3586,12 @@ static struct bin_attribute psp_vbflash_bin_attr = {
        .read = amdgpu_psp_vbflash_read,
 };
 
+/**
+ * DOC: psp_vbflash_status
+ * The status of the flash process.
+ * 0: IFWI flash not complete.
+ * 1: IFWI flash complete.
+ */
 static ssize_t amdgpu_psp_vbflash_status(struct device *dev,
                                         struct device_attribute *attr,
                                         char *buf)
--

2.34.1