linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] drm/msm: use firmware-name to find zap fw
@ 2020-01-08  1:38 Rob Clark
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Rob Clark @ 2020-01-08  1:38 UTC (permalink / raw)
  To: dri-devel
  Cc: devicetree, freedreno, linux-arm-msm, Bjorn Andersson,
	Jordan Crouse, Sharat Masetty, Rob Clark, Brian Masney,
	Douglas Anderson, Fabio Estevam, Jeffrey Hugo, open list,
	Thomas Gleixner

From: Rob Clark <robdclark@chromium.org>

For devices which use zap fw to take the GPU out of secure mode on
reset, the firmware is likely to be signed with a device specific key.
Meaning that we can't have a single filesystem (or /lib/firmware) that
works on multiple devices.

So allow a firmware-name to be specified in the zap-shader node in dt.
This moves the zap-shader node out of the core sdm845.dtsi and into per-
device dts files.  Which also removes the need for /delete-node/ in
sdm845-cheza.dtsi (as cheza devices do not use zap).

This aligns with how Bjorn has been handling the similar situation with
adsp/cdsp/mpss fw:

   https://patchwork.kernel.org/patch/11160089/

Rob Clark (3):
  drm/msm: support firmware-name for zap fw
  dt-bindings: drm/msm/gpu: Document firmware-name
  arm64: dts: sdm845: move gpu zap nodes to per-device dts

 .../devicetree/bindings/display/msm/gpu.txt   |  3 ++
 arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi    |  1 -
 arch/arm64/boot/dts/qcom/sdm845-db845c.dts    |  7 ++++
 arch/arm64/boot/dts/qcom/sdm845-mtp.dts       |  8 +++++
 arch/arm64/boot/dts/qcom/sdm845.dtsi          |  6 +---
 .../boot/dts/qcom/sdm850-lenovo-yoga-c630.dts |  7 ++++
 drivers/gpu/drm/msm/adreno/adreno_gpu.c       | 32 +++++++++++++++++--
 7 files changed, 55 insertions(+), 9 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08  1:38 [PATCH 0/3] drm/msm: use firmware-name to find zap fw Rob Clark
@ 2020-01-08  1:38 ` Rob Clark
  2020-01-08  5:00   ` Bjorn Andersson
                     ` (2 more replies)
  2020-01-08  1:38 ` [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name Rob Clark
  2020-01-08  1:38 ` [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts Rob Clark
  2 siblings, 3 replies; 12+ messages in thread
From: Rob Clark @ 2020-01-08  1:38 UTC (permalink / raw)
  To: dri-devel
  Cc: devicetree, freedreno, linux-arm-msm, Bjorn Andersson,
	Jordan Crouse, Sharat Masetty, Rob Clark, Rob Clark, Sean Paul,
	David Airlie, Daniel Vetter, Greg Kroah-Hartman,
	Douglas Anderson, Brian Masney, Fabio Estevam, Thomas Gleixner,
	open list

From: Rob Clark <robdclark@chromium.org>

Since zap firmware can be device specific, allow for a firmware-name
property in the zap node to specify which firmware to load, similarly to
the scheme used for dsp/wifi/etc.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 112e8b8a261e..aa8737bd58db 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
 {
 	struct device *dev = &gpu->pdev->dev;
 	const struct firmware *fw;
+	const char *signed_fwname = NULL;
 	struct device_node *np, *mem_np;
 	struct resource r;
 	phys_addr_t mem_phys;
@@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
 
 	mem_phys = r.start;
 
-	/* Request the MDT file for the firmware */
-	fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
+	/*
+	 * Check for a firmware-name property.  This is the new scheme
+	 * to handle firmware that may be signed with device specific
+	 * keys, allowing us to have a different zap fw path for different
+	 * devices.
+	 *
+	 * If the firmware-name property is found, we bypass the
+	 * adreno_request_fw() mechanism, because we don't need to handle
+	 * the /lib/firmware/qcom/* vs /lib/firmware/* case.
+	 *
+	 * If the firmware-name property is not found, for backwards
+	 * compatibility we fall back to the fwname from the gpulist
+	 * table.
+	 */
+	of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
+	if (signed_fwname) {
+		fwname = signed_fwname;
+		ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
+		if (ret) {
+			DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
+			fw = ERR_PTR(ret);
+		}
+	} else {
+		/* Request the MDT file for the firmware */
+		fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
+	}
+
 	if (IS_ERR(fw)) {
 		DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
 		return PTR_ERR(fw);
@@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
 	 * not.  But since we've already gotten through adreno_request_fw()
 	 * we know which of the two cases it is:
 	 */
-	if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
+	if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
 		ret = qcom_mdt_load(dev, fw, fwname, pasid,
 				mem_region, mem_phys, mem_size, NULL);
 	} else {
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name
  2020-01-08  1:38 [PATCH 0/3] drm/msm: use firmware-name to find zap fw Rob Clark
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
@ 2020-01-08  1:38 ` Rob Clark
  2020-01-08  4:57   ` Bjorn Andersson
  2020-01-08  1:38 ` [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts Rob Clark
  2 siblings, 1 reply; 12+ messages in thread
From: Rob Clark @ 2020-01-08  1:38 UTC (permalink / raw)
  To: dri-devel
  Cc: devicetree, freedreno, linux-arm-msm, Bjorn Andersson,
	Jordan Crouse, Sharat Masetty, Rob Clark, Rob Clark, Sean Paul,
	David Airlie, Daniel Vetter, Rob Herring, Mark Rutland,
	open list

From: Rob Clark <robdclark@chromium.org>

The firmware-name property in the zap node can be used to specify a
device specific zap firmware.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 Documentation/devicetree/bindings/display/msm/gpu.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt b/Documentation/devicetree/bindings/display/msm/gpu.txt
index 3e6cd3f64a78..7edc298a15f2 100644
--- a/Documentation/devicetree/bindings/display/msm/gpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
@@ -33,6 +33,8 @@ Required properties:
 - zap-shader: For a5xx and a6xx devices this node contains a memory-region that
   points to reserved memory to store the zap shader that can be used to help
   bring the GPU out of secure mode.
+- firmware-name: optional property of the 'zap-shader' node, listing the
+  relative path of the device specific zap firmware.
 
 Example 3xx/4xx/a5xx:
 
@@ -85,6 +87,7 @@ Example a6xx (with GMU):
 
 		zap-shader {
 			memory-region = <&zap_shader_region>;
+			firmware-name = "qcom/LENOVO/81JL/qcdxkmsuc850.mbn"
 		};
 	};
 };
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts
  2020-01-08  1:38 [PATCH 0/3] drm/msm: use firmware-name to find zap fw Rob Clark
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
  2020-01-08  1:38 ` [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name Rob Clark
@ 2020-01-08  1:38 ` Rob Clark
  2020-01-08  4:57   ` Bjorn Andersson
  2 siblings, 1 reply; 12+ messages in thread
From: Rob Clark @ 2020-01-08  1:38 UTC (permalink / raw)
  To: dri-devel
  Cc: devicetree, freedreno, linux-arm-msm, Bjorn Andersson,
	Jordan Crouse, Sharat Masetty, Rob Clark, Andy Gross,
	Rob Herring, Mark Rutland, open list

From: Rob Clark <robdclark@chromium.org>

We want to specify per-device firmware-name, so move the zap node into
the .dts file for individual boards/devices.  This lets us get rid of
the /delete-node/ for cheza, which does not use zap.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi           | 1 -
 arch/arm64/boot/dts/qcom/sdm845-db845c.dts           | 7 +++++++
 arch/arm64/boot/dts/qcom/sdm845-mtp.dts              | 8 ++++++++
 arch/arm64/boot/dts/qcom/sdm845.dtsi                 | 6 +-----
 arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 7 +++++++
 5 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
index 9a4ff57fc877..2db79c1ecdac 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
@@ -165,7 +165,6 @@ panel_in_edp: endpoint {
 /delete-node/ &venus_mem;
 /delete-node/ &cdsp_mem;
 /delete-node/ &cdsp_pas;
-/delete-node/ &zap_shader;
 /delete-node/ &gpu_mem;
 
 /* Increase the size from 120 MB to 128 MB */
diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
index d100f46791a6..c472195e44fb 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
@@ -352,6 +352,13 @@ &gcc {
 			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
 };
 
+&gpu {
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		firmware-name = "qcom/db845c/a630_zap.mbn";
+	};
+};
+
 &pm8998_gpio {
 	vol_up_pin_a: vol-up-active {
 		pins = "gpio6";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
index c57548b7b250..876155fc0547 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
@@ -360,6 +360,14 @@ &gcc {
 			   <GCC_LPASS_SWAY_CLK>;
 };
 
+&gpu {
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		// TODO presumably mtp can use same "test key" signed zap?
+		firmware-name = "qcom/db845c/a630_zap.mbn";
+	};
+};
+
 &i2c10 {
 	status = "okay";
 	clock-frequency = <400000>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index ddb1f23c936f..601c57cc9b6d 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2804,7 +2804,7 @@ dsi1_phy: dsi-phy@ae96400 {
 			};
 		};
 
-		gpu@5000000 {
+		gpu: gpu@5000000 {
 			compatible = "qcom,adreno-630.2", "qcom,adreno";
 			#stream-id-cells = <16>;
 
@@ -2824,10 +2824,6 @@ gpu@5000000 {
 
 			qcom,gmu = <&gmu>;
 
-			zap_shader: zap-shader {
-				memory-region = <&gpu_mem>;
-			};
-
 			gpu_opp_table: opp-table {
 				compatible = "operating-points-v2";
 
diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index 13dc619687f3..b255be3a4a0a 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -245,6 +245,13 @@ &gcc {
 			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
 };
 
+&gpu {
+	zap-shader {
+		memory-region = <&gpu_mem>;
+		firmware-name = "qcom/LENOVO/81JL/qcdxkmsuc850.mbn";
+	};
+};
+
 &i2c1 {
 	status = "okay";
 	clock-frequency = <400000>;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts
  2020-01-08  1:38 ` [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts Rob Clark
@ 2020-01-08  4:57   ` Bjorn Andersson
  0 siblings, 0 replies; 12+ messages in thread
From: Bjorn Andersson @ 2020-01-08  4:57 UTC (permalink / raw)
  To: Rob Clark
  Cc: dri-devel, devicetree, freedreno, linux-arm-msm, Jordan Crouse,
	Sharat Masetty, Rob Clark, Andy Gross, Rob Herring, Mark Rutland,
	open list

On Tue 07 Jan 17:38 PST 2020, Rob Clark wrote:

> From: Rob Clark <robdclark@chromium.org>
> 
> We want to specify per-device firmware-name, so move the zap node into
> the .dts file for individual boards/devices.  This lets us get rid of
> the /delete-node/ for cheza, which does not use zap.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
>  arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi           | 1 -
>  arch/arm64/boot/dts/qcom/sdm845-db845c.dts           | 7 +++++++
>  arch/arm64/boot/dts/qcom/sdm845-mtp.dts              | 8 ++++++++
>  arch/arm64/boot/dts/qcom/sdm845.dtsi                 | 6 +-----
>  arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts | 7 +++++++
>  5 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
> index 9a4ff57fc877..2db79c1ecdac 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi
> @@ -165,7 +165,6 @@ panel_in_edp: endpoint {
>  /delete-node/ &venus_mem;
>  /delete-node/ &cdsp_mem;
>  /delete-node/ &cdsp_pas;
> -/delete-node/ &zap_shader;
>  /delete-node/ &gpu_mem;
>  
>  /* Increase the size from 120 MB to 128 MB */
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
> index d100f46791a6..c472195e44fb 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts
> @@ -352,6 +352,13 @@ &gcc {
>  			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
>  };
>  
> +&gpu {
> +	zap-shader {
> +		memory-region = <&gpu_mem>;
> +		firmware-name = "qcom/db845c/a630_zap.mbn";

We agreed upon qcom/sdm845/* for the test-signed 845 firmware :)

> +	};
> +};
> +
>  &pm8998_gpio {
>  	vol_up_pin_a: vol-up-active {
>  		pins = "gpio6";
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
> index c57548b7b250..876155fc0547 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
> @@ -360,6 +360,14 @@ &gcc {
>  			   <GCC_LPASS_SWAY_CLK>;
>  };
>  
> +&gpu {
> +	zap-shader {
> +		memory-region = <&gpu_mem>;
> +		// TODO presumably mtp can use same "test key" signed zap?

Drop this comment after s/db845c/sdm845/

> +		firmware-name = "qcom/db845c/a630_zap.mbn";

Apart from that, I think this looks good!

Regards,
Bjorn

> +	};
> +};
> +
>  &i2c10 {
>  	status = "okay";
>  	clock-frequency = <400000>;
> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> index ddb1f23c936f..601c57cc9b6d 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> @@ -2804,7 +2804,7 @@ dsi1_phy: dsi-phy@ae96400 {
>  			};
>  		};
>  
> -		gpu@5000000 {
> +		gpu: gpu@5000000 {
>  			compatible = "qcom,adreno-630.2", "qcom,adreno";
>  			#stream-id-cells = <16>;
>  
> @@ -2824,10 +2824,6 @@ gpu@5000000 {
>  
>  			qcom,gmu = <&gmu>;
>  
> -			zap_shader: zap-shader {
> -				memory-region = <&gpu_mem>;
> -			};
> -
>  			gpu_opp_table: opp-table {
>  				compatible = "operating-points-v2";
>  
> diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> index 13dc619687f3..b255be3a4a0a 100644
> --- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> @@ -245,6 +245,13 @@ &gcc {
>  			   <GCC_QSPI_CNOC_PERIPH_AHB_CLK>;
>  };
>  
> +&gpu {
> +	zap-shader {
> +		memory-region = <&gpu_mem>;
> +		firmware-name = "qcom/LENOVO/81JL/qcdxkmsuc850.mbn";
> +	};
> +};
> +
>  &i2c1 {
>  	status = "okay";
>  	clock-frequency = <400000>;
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name
  2020-01-08  1:38 ` [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name Rob Clark
@ 2020-01-08  4:57   ` Bjorn Andersson
  0 siblings, 0 replies; 12+ messages in thread
From: Bjorn Andersson @ 2020-01-08  4:57 UTC (permalink / raw)
  To: Rob Clark
  Cc: dri-devel, devicetree, freedreno, linux-arm-msm, Jordan Crouse,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Rob Herring, Mark Rutland, open list

On Tue 07 Jan 17:38 PST 2020, Rob Clark wrote:

> From: Rob Clark <robdclark@chromium.org>
> 
> The firmware-name property in the zap node can be used to specify a
> device specific zap firmware.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  Documentation/devicetree/bindings/display/msm/gpu.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt b/Documentation/devicetree/bindings/display/msm/gpu.txt
> index 3e6cd3f64a78..7edc298a15f2 100644
> --- a/Documentation/devicetree/bindings/display/msm/gpu.txt
> +++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
> @@ -33,6 +33,8 @@ Required properties:
>  - zap-shader: For a5xx and a6xx devices this node contains a memory-region that
>    points to reserved memory to store the zap shader that can be used to help
>    bring the GPU out of secure mode.
> +- firmware-name: optional property of the 'zap-shader' node, listing the
> +  relative path of the device specific zap firmware.
>  
>  Example 3xx/4xx/a5xx:
>  
> @@ -85,6 +87,7 @@ Example a6xx (with GMU):
>  
>  		zap-shader {
>  			memory-region = <&zap_shader_region>;
> +			firmware-name = "qcom/LENOVO/81JL/qcdxkmsuc850.mbn"
>  		};
>  	};
>  };
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
@ 2020-01-08  5:00   ` Bjorn Andersson
  2020-01-08 15:38   ` Tom Rix
  2020-01-08 18:48   ` Jordan Crouse
  2 siblings, 0 replies; 12+ messages in thread
From: Bjorn Andersson @ 2020-01-08  5:00 UTC (permalink / raw)
  To: Rob Clark
  Cc: dri-devel, devicetree, freedreno, linux-arm-msm, Jordan Crouse,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list

On Tue 07 Jan 17:38 PST 2020, Rob Clark wrote:

> From: Rob Clark <robdclark@chromium.org>
> 
> Since zap firmware can be device specific, allow for a firmware-name
> property in the zap node to specify which firmware to load, similarly to
> the scheme used for dsp/wifi/etc.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 112e8b8a261e..aa8737bd58db 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  {
>  	struct device *dev = &gpu->pdev->dev;
>  	const struct firmware *fw;
> +	const char *signed_fwname = NULL;
>  	struct device_node *np, *mem_np;
>  	struct resource r;
>  	phys_addr_t mem_phys;
> @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  
>  	mem_phys = r.start;
>  
> -	/* Request the MDT file for the firmware */
> -	fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	/*
> +	 * Check for a firmware-name property.  This is the new scheme
> +	 * to handle firmware that may be signed with device specific
> +	 * keys, allowing us to have a different zap fw path for different
> +	 * devices.
> +	 *
> +	 * If the firmware-name property is found, we bypass the
> +	 * adreno_request_fw() mechanism, because we don't need to handle
> +	 * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> +	 *
> +	 * If the firmware-name property is not found, for backwards
> +	 * compatibility we fall back to the fwname from the gpulist
> +	 * table.
> +	 */
> +	of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> +	if (signed_fwname) {
> +		fwname = signed_fwname;
> +		ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> +		if (ret) {
> +			DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
> +			fw = ERR_PTR(ret);

Perhaps just return ret; here, or omit the error print here any rely
solely on the one below?

> +		}
> +	} else {
> +		/* Request the MDT file for the firmware */

How about changing this to "Request the MDT file from the default
location" or something like that?

Rest looks good.

Regards,
Bjorn

> +		fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	}
> +
>  	if (IS_ERR(fw)) {
>  		DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
>  		return PTR_ERR(fw);
> @@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  	 * not.  But since we've already gotten through adreno_request_fw()
>  	 * we know which of the two cases it is:
>  	 */
> -	if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
> +	if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
>  		ret = qcom_mdt_load(dev, fw, fwname, pasid,
>  				mem_region, mem_phys, mem_size, NULL);
>  	} else {
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
  2020-01-08  5:00   ` Bjorn Andersson
@ 2020-01-08 15:38   ` Tom Rix
  2020-01-08 16:30     ` Rob Clark
  2020-01-08 18:48   ` Jordan Crouse
  2 siblings, 1 reply; 12+ messages in thread
From: Tom Rix @ 2020-01-08 15:38 UTC (permalink / raw)
  To: Rob Clark
  Cc: freedreno, linux-arm-msm, Bjorn Andersson, Jordan Crouse,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list


On 1/7/20 5:38 PM, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
>
> Since zap firmware can be device specific, allow for a firmware-name
> property in the zap node to specify which firmware to load, similarly to
> the scheme used for dsp/wifi/etc.
>
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 112e8b8a261e..aa8737bd58db 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  {
>  	struct device *dev = &gpu->pdev->dev;
>  	const struct firmware *fw;
> +	const char *signed_fwname = NULL;
>  	struct device_node *np, *mem_np;
>  	struct resource r;
>  	phys_addr_t mem_phys;
> @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  
>  	mem_phys = r.start;
>  
> -	/* Request the MDT file for the firmware */
> -	fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	/*
> +	 * Check for a firmware-name property.  This is the new scheme
> +	 * to handle firmware that may be signed with device specific
> +	 * keys, allowing us to have a different zap fw path for different
> +	 * devices.
> +	 *
> +	 * If the firmware-name property is found, we bypass the
> +	 * adreno_request_fw() mechanism, because we don't need to handle
> +	 * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> +	 *
> +	 * If the firmware-name property is not found, for backwards
> +	 * compatibility we fall back to the fwname from the gpulist
> +	 * table.
> +	 */
> +	of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> +	if (signed_fwname) {
> +		fwname = signed_fwname;
> +		ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> +		if (ret) {
> +			DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
Could adreno_request_fw be called with fwname if request_firmware_direct fails ?
> +			fw = ERR_PTR(ret);
> +		}
> +	} else {
> +		/* Request the MDT file for the firmware */
> +		fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	}
> +
>  	if (IS_ERR(fw)) {
>  		DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
>  		return PTR_ERR(fw);
> @@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  	 * not.  But since we've already gotten through adreno_request_fw()
>  	 * we know which of the two cases it is:
>  	 */
> -	if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
> +	if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
>  		ret = qcom_mdt_load(dev, fw, fwname, pasid,
>  				mem_region, mem_phys, mem_size, NULL);
>  	} else {


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08 15:38   ` Tom Rix
@ 2020-01-08 16:30     ` Rob Clark
  2020-01-12 19:36       ` Rob Clark
  0 siblings, 1 reply; 12+ messages in thread
From: Rob Clark @ 2020-01-08 16:30 UTC (permalink / raw)
  To: Tom Rix
  Cc: freedreno, linux-arm-msm, Bjorn Andersson, Jordan Crouse,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list

On Wed, Jan 8, 2020 at 7:38 AM Tom Rix <trix@redhat.com> wrote:
>
>
> On 1/7/20 5:38 PM, Rob Clark wrote:
> > From: Rob Clark <robdclark@chromium.org>
> >
> > Since zap firmware can be device specific, allow for a firmware-name
> > property in the zap node to specify which firmware to load, similarly to
> > the scheme used for dsp/wifi/etc.
> >
> > Signed-off-by: Rob Clark <robdclark@chromium.org>
> > ---
> >  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
> >  1 file changed, 29 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > index 112e8b8a261e..aa8737bd58db 100644
> > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> >  {
> >       struct device *dev = &gpu->pdev->dev;
> >       const struct firmware *fw;
> > +     const char *signed_fwname = NULL;
> >       struct device_node *np, *mem_np;
> >       struct resource r;
> >       phys_addr_t mem_phys;
> > @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> >
> >       mem_phys = r.start;
> >
> > -     /* Request the MDT file for the firmware */
> > -     fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > +     /*
> > +      * Check for a firmware-name property.  This is the new scheme
> > +      * to handle firmware that may be signed with device specific
> > +      * keys, allowing us to have a different zap fw path for different
> > +      * devices.
> > +      *
> > +      * If the firmware-name property is found, we bypass the
> > +      * adreno_request_fw() mechanism, because we don't need to handle
> > +      * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> > +      *
> > +      * If the firmware-name property is not found, for backwards
> > +      * compatibility we fall back to the fwname from the gpulist
> > +      * table.
> > +      */
> > +     of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> > +     if (signed_fwname) {
> > +             fwname = signed_fwname;
> > +             ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> > +             if (ret) {
> > +                     DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
> Could adreno_request_fw be called with fwname if request_firmware_direct fails ?


*possibly*.. initially I avoided this because the failure mode for
incorrectly signed firmware was silent and catestrophic.  But Bjorn
tells me this has been fixed.. in which case we could try and detect
if it is the incorrect fw.  I need to try some experiments to confirm
we can detect this case properly.

BR,
-R

> > +                     fw = ERR_PTR(ret);
> > +             }
> > +     } else {
> > +             /* Request the MDT file for the firmware */
> > +             fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > +     }
> > +
> >       if (IS_ERR(fw)) {
> >               DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
> >               return PTR_ERR(fw);
> > @@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> >        * not.  But since we've already gotten through adreno_request_fw()
> >        * we know which of the two cases it is:
> >        */
> > -     if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
> > +     if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
> >               ret = qcom_mdt_load(dev, fw, fwname, pasid,
> >                               mem_region, mem_phys, mem_size, NULL);
> >       } else {
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
  2020-01-08  5:00   ` Bjorn Andersson
  2020-01-08 15:38   ` Tom Rix
@ 2020-01-08 18:48   ` Jordan Crouse
  2020-01-08 19:04     ` Bjorn Andersson
  2 siblings, 1 reply; 12+ messages in thread
From: Jordan Crouse @ 2020-01-08 18:48 UTC (permalink / raw)
  To: Rob Clark
  Cc: dri-devel, devicetree, freedreno, linux-arm-msm, Bjorn Andersson,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list

On Tue, Jan 07, 2020 at 05:38:42PM -0800, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
> 
> Since zap firmware can be device specific, allow for a firmware-name
> property in the zap node to specify which firmware to load, similarly to
> the scheme used for dsp/wifi/etc.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 112e8b8a261e..aa8737bd58db 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  {
>  	struct device *dev = &gpu->pdev->dev;
>  	const struct firmware *fw;
> +	const char *signed_fwname = NULL;
>  	struct device_node *np, *mem_np;
>  	struct resource r;
>  	phys_addr_t mem_phys;
> @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  
>  	mem_phys = r.start;
>  
> -	/* Request the MDT file for the firmware */
> -	fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	/*
> +	 * Check for a firmware-name property.  This is the new scheme
> +	 * to handle firmware that may be signed with device specific
> +	 * keys, allowing us to have a different zap fw path for different
> +	 * devices.
> +	 *
> +	 * If the firmware-name property is found, we bypass the
> +	 * adreno_request_fw() mechanism, because we don't need to handle
> +	 * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> +	 *
> +	 * If the firmware-name property is not found, for backwards
> +	 * compatibility we fall back to the fwname from the gpulist
> +	 * table.
> +	 */
> +	of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> +	if (signed_fwname) {
> +		fwname = signed_fwname;
> +		ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> +		if (ret) {
> +			DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
> +			fw = ERR_PTR(ret);
> +		}
> +	} else {
> +		/* Request the MDT file for the firmware */
> +		fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> +	}
> +

Since DT seems to be the trend for target specific firmware names I think we
should plan to quickly deprecate the legacy name and not require new targets to
set it. If a zap node is going to be opt in then it isn't onerous to ask
the developer to set the additional property for each target platform.

Jordan

>  	if (IS_ERR(fw)) {
>  		DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
>  		return PTR_ERR(fw);
> @@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>  	 * not.  But since we've already gotten through adreno_request_fw()
>  	 * we know which of the two cases it is:
>  	 */
> -	if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
> +	if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
>  		ret = qcom_mdt_load(dev, fw, fwname, pasid,
>  				mem_region, mem_phys, mem_size, NULL);
>  	} else {
> -- 
> 2.24.1
> 

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08 18:48   ` Jordan Crouse
@ 2020-01-08 19:04     ` Bjorn Andersson
  0 siblings, 0 replies; 12+ messages in thread
From: Bjorn Andersson @ 2020-01-08 19:04 UTC (permalink / raw)
  To: Rob Clark, dri-devel, devicetree, freedreno, linux-arm-msm,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list

On Wed 08 Jan 10:48 PST 2020, Jordan Crouse wrote:

> On Tue, Jan 07, 2020 at 05:38:42PM -0800, Rob Clark wrote:
> > From: Rob Clark <robdclark@chromium.org>
> > 
> > Since zap firmware can be device specific, allow for a firmware-name
> > property in the zap node to specify which firmware to load, similarly to
> > the scheme used for dsp/wifi/etc.
> > 
> > Signed-off-by: Rob Clark <robdclark@chromium.org>
> > ---
> >  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
> >  1 file changed, 29 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > index 112e8b8a261e..aa8737bd58db 100644
> > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> >  {
> >  	struct device *dev = &gpu->pdev->dev;
> >  	const struct firmware *fw;
> > +	const char *signed_fwname = NULL;
> >  	struct device_node *np, *mem_np;
> >  	struct resource r;
> >  	phys_addr_t mem_phys;
> > @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> >  
> >  	mem_phys = r.start;
> >  
> > -	/* Request the MDT file for the firmware */
> > -	fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > +	/*
> > +	 * Check for a firmware-name property.  This is the new scheme
> > +	 * to handle firmware that may be signed with device specific
> > +	 * keys, allowing us to have a different zap fw path for different
> > +	 * devices.
> > +	 *
> > +	 * If the firmware-name property is found, we bypass the
> > +	 * adreno_request_fw() mechanism, because we don't need to handle
> > +	 * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> > +	 *
> > +	 * If the firmware-name property is not found, for backwards
> > +	 * compatibility we fall back to the fwname from the gpulist
> > +	 * table.
> > +	 */
> > +	of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> > +	if (signed_fwname) {
> > +		fwname = signed_fwname;
> > +		ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> > +		if (ret) {
> > +			DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
> > +			fw = ERR_PTR(ret);
> > +		}
> > +	} else {
> > +		/* Request the MDT file for the firmware */
> > +		fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > +	}
> > +
> 
> Since DT seems to be the trend for target specific firmware names I think we
> should plan to quickly deprecate the legacy name and not require new targets to
> set it. If a zap node is going to be opt in then it isn't onerous to ask
> the developer to set the additional property for each target platform.
> 

For the zap specifically I agree that it would be nice to require this
property, but for non-zap firmware it seems reasonable to continue with
the existing scheme.

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] drm/msm: support firmware-name for zap fw
  2020-01-08 16:30     ` Rob Clark
@ 2020-01-12 19:36       ` Rob Clark
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2020-01-12 19:36 UTC (permalink / raw)
  To: Tom Rix
  Cc: freedreno, linux-arm-msm, Bjorn Andersson, Jordan Crouse,
	Sharat Masetty, Rob Clark, Sean Paul, David Airlie,
	Daniel Vetter, Greg Kroah-Hartman, Douglas Anderson,
	Brian Masney, Fabio Estevam, Thomas Gleixner, open list

On Wed, Jan 8, 2020 at 8:30 AM Rob Clark <robdclark@gmail.com> wrote:
>
> On Wed, Jan 8, 2020 at 7:38 AM Tom Rix <trix@redhat.com> wrote:
> >
> >
> > On 1/7/20 5:38 PM, Rob Clark wrote:
> > > From: Rob Clark <robdclark@chromium.org>
> > >
> > > Since zap firmware can be device specific, allow for a firmware-name
> > > property in the zap node to specify which firmware to load, similarly to
> > > the scheme used for dsp/wifi/etc.
> > >
> > > Signed-off-by: Rob Clark <robdclark@chromium.org>
> > > ---
> > >  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 32 ++++++++++++++++++++++---
> > >  1 file changed, 29 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > > index 112e8b8a261e..aa8737bd58db 100644
> > > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> > > @@ -26,6 +26,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> > >  {
> > >       struct device *dev = &gpu->pdev->dev;
> > >       const struct firmware *fw;
> > > +     const char *signed_fwname = NULL;
> > >       struct device_node *np, *mem_np;
> > >       struct resource r;
> > >       phys_addr_t mem_phys;
> > > @@ -58,8 +59,33 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> > >
> > >       mem_phys = r.start;
> > >
> > > -     /* Request the MDT file for the firmware */
> > > -     fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > > +     /*
> > > +      * Check for a firmware-name property.  This is the new scheme
> > > +      * to handle firmware that may be signed with device specific
> > > +      * keys, allowing us to have a different zap fw path for different
> > > +      * devices.
> > > +      *
> > > +      * If the firmware-name property is found, we bypass the
> > > +      * adreno_request_fw() mechanism, because we don't need to handle
> > > +      * the /lib/firmware/qcom/* vs /lib/firmware/* case.
> > > +      *
> > > +      * If the firmware-name property is not found, for backwards
> > > +      * compatibility we fall back to the fwname from the gpulist
> > > +      * table.
> > > +      */
> > > +     of_property_read_string_index(np, "firmware-name", 0, &signed_fwname);
> > > +     if (signed_fwname) {
> > > +             fwname = signed_fwname;
> > > +             ret = request_firmware_direct(&fw, signed_fwname, gpu->dev->dev);
> > > +             if (ret) {
> > > +                     DRM_DEV_ERROR(dev, "could not load signed zap firmware: %d\n", ret);
> > Could adreno_request_fw be called with fwname if request_firmware_direct fails ?
>
>
> *possibly*.. initially I avoided this because the failure mode for
> incorrectly signed firmware was silent and catestrophic.  But Bjorn
> tells me this has been fixed.. in which case we could try and detect
> if it is the incorrect fw.  I need to try some experiments to confirm
> we can detect this case properly.

I've been thinking about fallback to using fwname from the gpulist
table, but I think I don't really like the idea.

The failure mode for not falling back to $firmware/qcom/$fwname is
pretty safe.. you simply don't get gpu accel, but display and
everything else works, so you can boot up far enough to see what the
problem is and fix it.  But the failure mode if, with some device's
scm fw doesn't report incorrectly signed zap fw, is pretty
catastrophic (insta-reboot, which can be hard to debug on phone/laptop
without debug uart).

Since we haven't pushed the test-key signed qcom/sdm835/a630_zap.mbn
to linux-firmware yet, I think this is a good time to make this switch
for a6xx.

For a530 devices, maybe we hold of adding firmware-name to dt until
linux-firmware gains a qcom/msm8996/a530_zap.mbn (which would be a
good time to switch to the packed .mbn instead of split .mdt + .b0*
files).. or just not specify a firmware-name for device using test-key
signed zap and fallback to adreno_request_fw() and the existing path.

Fortunately zap is not used prior to a5xx, so we mainly just need to
care about backwards compat for a530.

BR,
-R

> BR,
> -R
>
> > > +                     fw = ERR_PTR(ret);
> > > +             }
> > > +     } else {
> > > +             /* Request the MDT file for the firmware */
> > > +             fw = adreno_request_fw(to_adreno_gpu(gpu), fwname);
> > > +     }
> > > +
> > >       if (IS_ERR(fw)) {
> > >               DRM_DEV_ERROR(dev, "Unable to load %s\n", fwname);
> > >               return PTR_ERR(fw);
> > > @@ -95,7 +121,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
> > >        * not.  But since we've already gotten through adreno_request_fw()
> > >        * we know which of the two cases it is:
> > >        */
> > > -     if (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY) {
> > > +     if (signed_fwname || (to_adreno_gpu(gpu)->fwloc == FW_LOCATION_LEGACY)) {
> > >               ret = qcom_mdt_load(dev, fw, fwname, pasid,
> > >                               mem_region, mem_phys, mem_size, NULL);
> > >       } else {
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-01-12 19:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08  1:38 [PATCH 0/3] drm/msm: use firmware-name to find zap fw Rob Clark
2020-01-08  1:38 ` [PATCH 1/3] drm/msm: support firmware-name for " Rob Clark
2020-01-08  5:00   ` Bjorn Andersson
2020-01-08 15:38   ` Tom Rix
2020-01-08 16:30     ` Rob Clark
2020-01-12 19:36       ` Rob Clark
2020-01-08 18:48   ` Jordan Crouse
2020-01-08 19:04     ` Bjorn Andersson
2020-01-08  1:38 ` [PATCH 2/3] dt-bindings: drm/msm/gpu: Document firmware-name Rob Clark
2020-01-08  4:57   ` Bjorn Andersson
2020-01-08  1:38 ` [PATCH 3/3] arm64: dts: sdm845: move gpu zap nodes to per-device dts Rob Clark
2020-01-08  4:57   ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).