linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm: Do not remap from ACPI resouces again for Pluton TPM
@ 2023-07-01 15:33 Valentin David
  2023-07-06 19:13 ` [PATCH v2] " Valentin David
  0 siblings, 1 reply; 5+ messages in thread
From: Valentin David @ 2023-07-01 15:33 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe
  Cc: linux-integrity, linux-kernel, valentin.david

For Pluton TPM devices, it was assumed that there was no ACPI memory
regions. This is not true for ASUS ROG Ally. ACPI advertises
0xfd500000-0xfd5fffff.

Since remapping is already done in `crb_map_pluton`, remapping again
in `crb_map_io` causes EBUSY error:
```
[    3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff]
[    3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16
```
---
 drivers/char/tpm/tpm_crb.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index d43a0d7b97a8..1a5d09b18513 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
 	u32 rsp_size;
 	int ret;
 
-	INIT_LIST_HEAD(&acpi_resource_list);
-	ret = acpi_dev_get_resources(device, &acpi_resource_list,
-				     crb_check_resource, iores_array);
-	if (ret < 0)
-		return ret;
-	acpi_dev_free_resource_list(&acpi_resource_list);
-
-	/* Pluton doesn't appear to define ACPI memory regions */
+	/*
+	 * Pluton sometimes does not define ACPI memory regions.
+	 * Mapping is then done in crb_map_pluton
+	 */
 	if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
+		INIT_LIST_HEAD(&acpi_resource_list);
+		ret = acpi_dev_get_resources(device, &acpi_resource_list,
+					     crb_check_resource, iores_array);
+		if (ret < 0)
+			return ret;
+		acpi_dev_free_resource_list(&acpi_resource_list);
+
 		if (resource_type(iores_array) != IORESOURCE_MEM) {
 			dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n");
 			return -EINVAL;
-- 
2.41.0


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

* [PATCH v2] tpm: Do not remap from ACPI resouces again for Pluton TPM
  2023-07-01 15:33 [PATCH] tpm: Do not remap from ACPI resouces again for Pluton TPM Valentin David
@ 2023-07-06 19:13 ` Valentin David
  2023-07-10 13:33   ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Valentin David @ 2023-07-06 19:13 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe
  Cc: linux-integrity, linux-kernel, Valentin David

For Pluton TPM devices, it was assumed that there was no ACPI memory
regions. This is not true for ASUS ROG Ally. ACPI advertises
0xfd500000-0xfd5fffff.

Since remapping is already done in `crb_map_pluton`, remapping again
in `crb_map_io` causes EBUSY error:
```
[    3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff]
[    3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16
```

Signed-off-by: Valentin David <valentin.david@gmail.com>
---
v2: add missing sign-off in commit message
---
 drivers/char/tpm/tpm_crb.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index d43a0d7b97a8..1a5d09b18513 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
 	u32 rsp_size;
 	int ret;
 
-	INIT_LIST_HEAD(&acpi_resource_list);
-	ret = acpi_dev_get_resources(device, &acpi_resource_list,
-				     crb_check_resource, iores_array);
-	if (ret < 0)
-		return ret;
-	acpi_dev_free_resource_list(&acpi_resource_list);
-
-	/* Pluton doesn't appear to define ACPI memory regions */
+	/*
+	 * Pluton sometimes does not define ACPI memory regions.
+	 * Mapping is then done in crb_map_pluton
+	 */
 	if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
+		INIT_LIST_HEAD(&acpi_resource_list);
+		ret = acpi_dev_get_resources(device, &acpi_resource_list,
+					     crb_check_resource, iores_array);
+		if (ret < 0)
+			return ret;
+		acpi_dev_free_resource_list(&acpi_resource_list);
+
 		if (resource_type(iores_array) != IORESOURCE_MEM) {
 			dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n");
 			return -EINVAL;
-- 
2.41.0


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

* Re: [PATCH v2] tpm: Do not remap from ACPI resouces again for Pluton TPM
  2023-07-06 19:13 ` [PATCH v2] " Valentin David
@ 2023-07-10 13:33   ` Jarkko Sakkinen
  2023-07-10 20:27     ` [PATCH v3] " Valentin David
  0 siblings, 1 reply; 5+ messages in thread
From: Jarkko Sakkinen @ 2023-07-10 13:33 UTC (permalink / raw)
  To: Valentin David, Peter Huewe, Jason Gunthorpe
  Cc: linux-integrity, linux-kernel

On Thu Jul 6, 2023 at 10:13 PM EEST, Valentin David wrote:
> For Pluton TPM devices, it was assumed that there was no ACPI memory
> regions. This is not true for ASUS ROG Ally. ACPI advertises
> 0xfd500000-0xfd5fffff.
>
> Since remapping is already done in `crb_map_pluton`, remapping again
> in `crb_map_io` causes EBUSY error:
> ```
> [    3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff]
> [    3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16
> ```
>
> Signed-off-by: Valentin David <valentin.david@gmail.com>

Please add a fixes tag.

> ---
> v2: add missing sign-off in commit message
> ---
>  drivers/char/tpm/tpm_crb.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> index d43a0d7b97a8..1a5d09b18513 100644
> --- a/drivers/char/tpm/tpm_crb.c
> +++ b/drivers/char/tpm/tpm_crb.c
> @@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
>  	u32 rsp_size;
>  	int ret;
>  
> -	INIT_LIST_HEAD(&acpi_resource_list);
> -	ret = acpi_dev_get_resources(device, &acpi_resource_list,
> -				     crb_check_resource, iores_array);
> -	if (ret < 0)
> -		return ret;
> -	acpi_dev_free_resource_list(&acpi_resource_list);
> -
> -	/* Pluton doesn't appear to define ACPI memory regions */
> +	/*
> +	 * Pluton sometimes does not define ACPI memory regions.
> +	 * Mapping is then done in crb_map_pluton
> +	 */
>  	if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
> +		INIT_LIST_HEAD(&acpi_resource_list);
> +		ret = acpi_dev_get_resources(device, &acpi_resource_list,
> +					     crb_check_resource, iores_array);
> +		if (ret < 0)
> +			return ret;
> +		acpi_dev_free_resource_list(&acpi_resource_list);
> +
>  		if (resource_type(iores_array) != IORESOURCE_MEM) {
>  			dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n");
>  			return -EINVAL;
> -- 
> 2.41.0

I don't see anything else to complain about.

BR, Jarkko

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

* [PATCH v3] tpm: Do not remap from ACPI resouces again for Pluton TPM
  2023-07-10 13:33   ` Jarkko Sakkinen
@ 2023-07-10 20:27     ` Valentin David
  2023-07-10 22:06       ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Valentin David @ 2023-07-10 20:27 UTC (permalink / raw)
  To: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe
  Cc: linux-integrity, linux-kernel, Valentin David

For Pluton TPM devices, it was assumed that there was no ACPI memory
regions. This is not true for ASUS ROG Ally. ACPI advertises
0xfd500000-0xfd5fffff.

Since remapping is already done in `crb_map_pluton`, remapping again
in `crb_map_io` causes EBUSY error:
```
[    3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff]
[    3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16
```

Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton")

Signed-off-by: Valentin David <valentin.david@gmail.com>
---
v3: Add fixes tag
---
 drivers/char/tpm/tpm_crb.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index d43a0d7b97a8..1a5d09b18513 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
 	u32 rsp_size;
 	int ret;
 
-	INIT_LIST_HEAD(&acpi_resource_list);
-	ret = acpi_dev_get_resources(device, &acpi_resource_list,
-				     crb_check_resource, iores_array);
-	if (ret < 0)
-		return ret;
-	acpi_dev_free_resource_list(&acpi_resource_list);
-
-	/* Pluton doesn't appear to define ACPI memory regions */
+	/*
+	 * Pluton sometimes does not define ACPI memory regions.
+	 * Mapping is then done in crb_map_pluton
+	 */
 	if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
+		INIT_LIST_HEAD(&acpi_resource_list);
+		ret = acpi_dev_get_resources(device, &acpi_resource_list,
+					     crb_check_resource, iores_array);
+		if (ret < 0)
+			return ret;
+		acpi_dev_free_resource_list(&acpi_resource_list);
+
 		if (resource_type(iores_array) != IORESOURCE_MEM) {
 			dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n");
 			return -EINVAL;
-- 
2.41.0


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

* Re: [PATCH v3] tpm: Do not remap from ACPI resouces again for Pluton TPM
  2023-07-10 20:27     ` [PATCH v3] " Valentin David
@ 2023-07-10 22:06       ` Jarkko Sakkinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2023-07-10 22:06 UTC (permalink / raw)
  To: Valentin David, Peter Huewe, Jason Gunthorpe
  Cc: linux-integrity, linux-kernel

On Mon Jul 10, 2023 at 11:27 PM EEST, Valentin David wrote:
> For Pluton TPM devices, it was assumed that there was no ACPI memory
> regions. This is not true for ASUS ROG Ally. ACPI advertises
> 0xfd500000-0xfd5fffff.
>
> Since remapping is already done in `crb_map_pluton`, remapping again
> in `crb_map_io` causes EBUSY error:
> ```
> [    3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff]
> [    3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16
> ```
>
> Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton")
>
> Signed-off-by: Valentin David <valentin.david@gmail.com>
> ---
> v3: Add fixes tag
> ---
>  drivers/char/tpm/tpm_crb.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> index d43a0d7b97a8..1a5d09b18513 100644
> --- a/drivers/char/tpm/tpm_crb.c
> +++ b/drivers/char/tpm/tpm_crb.c
> @@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv,
>  	u32 rsp_size;
>  	int ret;
>  
> -	INIT_LIST_HEAD(&acpi_resource_list);
> -	ret = acpi_dev_get_resources(device, &acpi_resource_list,
> -				     crb_check_resource, iores_array);
> -	if (ret < 0)
> -		return ret;
> -	acpi_dev_free_resource_list(&acpi_resource_list);
> -
> -	/* Pluton doesn't appear to define ACPI memory regions */
> +	/*
> +	 * Pluton sometimes does not define ACPI memory regions.
> +	 * Mapping is then done in crb_map_pluton
> +	 */
>  	if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
> +		INIT_LIST_HEAD(&acpi_resource_list);
> +		ret = acpi_dev_get_resources(device, &acpi_resource_list,
> +					     crb_check_resource, iores_array);
> +		if (ret < 0)
> +			return ret;
> +		acpi_dev_free_resource_list(&acpi_resource_list);
> +
>  		if (resource_type(iores_array) != IORESOURCE_MEM) {
>  			dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n");
>  			return -EINVAL;
> -- 
> 2.41.0

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

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

end of thread, other threads:[~2023-07-10 22:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-01 15:33 [PATCH] tpm: Do not remap from ACPI resouces again for Pluton TPM Valentin David
2023-07-06 19:13 ` [PATCH v2] " Valentin David
2023-07-10 13:33   ` Jarkko Sakkinen
2023-07-10 20:27     ` [PATCH v3] " Valentin David
2023-07-10 22:06       ` Jarkko Sakkinen

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).