Re: [PATCH v2] tpm: Fix the ioremap() call for Braswell systems

2017-06-28 Thread Jarkko Sakkinen
On Thu, Jun 22, 2017 at 02:32:01PM -0700, Azhar Shaikh wrote:
> ioremap() for Intel Braswell processors was done in
> tpm_tis_pnp_init(). But before this function gets called,
> platform driver 'tis_drv' gets registered and its probe function
> tpm_tis_plat_probe() is invoked, which does a TPM
> access. Now for Braswell processors tpm_platform_begin_xfer()
> will do an ioread32() without having a mapped address, which
> will lead to a bad I/O access warning.
> Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis()
> before registering the 'tis_drv' or basically before any TPM access.
> Accordingly also move the iounmap() call from tpm_tis_pnp_remove()
> to cleanup_tis() after all TPM access are completed.
> 
> Signed-off-by: Azhar Shaikh 

Reviewed-by: Jarkko Sakkinen 

> ---
> Changes from v1:
> - Do error handling in init_ts().
> - Update the commit message.
> 
>  drivers/char/tpm/tpm_tis.c | 25 +
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 506e62ca3576..d97ce22267fb 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
>   else
>   tpm_info.irq = -1;
>  
> -#ifdef CONFIG_X86
> - if (is_bsw())
> - ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
> - ILB_REMAP_SIZE);
> -#endif
> -
>   return tpm_tis_init(_dev->dev, _info);
>  }
>  
> @@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
>  
>   tpm_chip_unregister(chip);
>   tpm_tis_remove(chip);
> -
> -#ifdef CONFIG_X86
> - if (is_bsw())
> - iounmap(ilb_base_addr);
> -#endif
> -
>  }
>  
>  static struct pnp_driver tis_pnp_driver = {
> @@ -472,6 +460,11 @@ static int __init init_tis(void)
>   if (rc)
>   goto err_force;
>  
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
> + ILB_REMAP_SIZE);
> +#endif
>   rc = platform_driver_register(_drv);
>   if (rc)
>   goto err_platform;
> @@ -490,6 +483,10 @@ static int __init init_tis(void)
>  err_platform:
>   if (force_pdev)
>   platform_device_unregister(force_pdev);
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + iounmap(ilb_base_addr);
> +#endif
>  err_force:
>   return rc;
>  }
> @@ -499,6 +496,10 @@ static void __exit cleanup_tis(void)
>   pnp_unregister_driver(_pnp_driver);
>   platform_driver_unregister(_drv);
>  
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + iounmap(ilb_base_addr);
> +#endif
>   if (force_pdev)
>   platform_device_unregister(force_pdev);
>  }
> -- 
> 1.9.1
> 


Re: [PATCH v2] tpm: Fix the ioremap() call for Braswell systems

2017-06-28 Thread Jarkko Sakkinen
On Thu, Jun 22, 2017 at 02:32:01PM -0700, Azhar Shaikh wrote:
> ioremap() for Intel Braswell processors was done in
> tpm_tis_pnp_init(). But before this function gets called,
> platform driver 'tis_drv' gets registered and its probe function
> tpm_tis_plat_probe() is invoked, which does a TPM
> access. Now for Braswell processors tpm_platform_begin_xfer()
> will do an ioread32() without having a mapped address, which
> will lead to a bad I/O access warning.
> Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis()
> before registering the 'tis_drv' or basically before any TPM access.
> Accordingly also move the iounmap() call from tpm_tis_pnp_remove()
> to cleanup_tis() after all TPM access are completed.
> 
> Signed-off-by: Azhar Shaikh 

Reviewed-by: Jarkko Sakkinen 

> ---
> Changes from v1:
> - Do error handling in init_ts().
> - Update the commit message.
> 
>  drivers/char/tpm/tpm_tis.c | 25 +
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 506e62ca3576..d97ce22267fb 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
>   else
>   tpm_info.irq = -1;
>  
> -#ifdef CONFIG_X86
> - if (is_bsw())
> - ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
> - ILB_REMAP_SIZE);
> -#endif
> -
>   return tpm_tis_init(_dev->dev, _info);
>  }
>  
> @@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
>  
>   tpm_chip_unregister(chip);
>   tpm_tis_remove(chip);
> -
> -#ifdef CONFIG_X86
> - if (is_bsw())
> - iounmap(ilb_base_addr);
> -#endif
> -
>  }
>  
>  static struct pnp_driver tis_pnp_driver = {
> @@ -472,6 +460,11 @@ static int __init init_tis(void)
>   if (rc)
>   goto err_force;
>  
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
> + ILB_REMAP_SIZE);
> +#endif
>   rc = platform_driver_register(_drv);
>   if (rc)
>   goto err_platform;
> @@ -490,6 +483,10 @@ static int __init init_tis(void)
>  err_platform:
>   if (force_pdev)
>   platform_device_unregister(force_pdev);
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + iounmap(ilb_base_addr);
> +#endif
>  err_force:
>   return rc;
>  }
> @@ -499,6 +496,10 @@ static void __exit cleanup_tis(void)
>   pnp_unregister_driver(_pnp_driver);
>   platform_driver_unregister(_drv);
>  
> +#ifdef CONFIG_X86
> + if (is_bsw())
> + iounmap(ilb_base_addr);
> +#endif
>   if (force_pdev)
>   platform_device_unregister(force_pdev);
>  }
> -- 
> 1.9.1
> 


[PATCH v2] tpm: Fix the ioremap() call for Braswell systems

2017-06-22 Thread Azhar Shaikh
ioremap() for Intel Braswell processors was done in
tpm_tis_pnp_init(). But before this function gets called,
platform driver 'tis_drv' gets registered and its probe function
tpm_tis_plat_probe() is invoked, which does a TPM
access. Now for Braswell processors tpm_platform_begin_xfer()
will do an ioread32() without having a mapped address, which
will lead to a bad I/O access warning.
Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis()
before registering the 'tis_drv' or basically before any TPM access.
Accordingly also move the iounmap() call from tpm_tis_pnp_remove()
to cleanup_tis() after all TPM access are completed.

Signed-off-by: Azhar Shaikh 
---
Changes from v1:
- Do error handling in init_ts().
- Update the commit message.

 drivers/char/tpm/tpm_tis.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 506e62ca3576..d97ce22267fb 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
else
tpm_info.irq = -1;
 
-#ifdef CONFIG_X86
-   if (is_bsw())
-   ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
-   ILB_REMAP_SIZE);
-#endif
-
return tpm_tis_init(_dev->dev, _info);
 }
 
@@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
 
tpm_chip_unregister(chip);
tpm_tis_remove(chip);
-
-#ifdef CONFIG_X86
-   if (is_bsw())
-   iounmap(ilb_base_addr);
-#endif
-
 }
 
 static struct pnp_driver tis_pnp_driver = {
@@ -472,6 +460,11 @@ static int __init init_tis(void)
if (rc)
goto err_force;
 
+#ifdef CONFIG_X86
+   if (is_bsw())
+   ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
+   ILB_REMAP_SIZE);
+#endif
rc = platform_driver_register(_drv);
if (rc)
goto err_platform;
@@ -490,6 +483,10 @@ static int __init init_tis(void)
 err_platform:
if (force_pdev)
platform_device_unregister(force_pdev);
+#ifdef CONFIG_X86
+   if (is_bsw())
+   iounmap(ilb_base_addr);
+#endif
 err_force:
return rc;
 }
@@ -499,6 +496,10 @@ static void __exit cleanup_tis(void)
pnp_unregister_driver(_pnp_driver);
platform_driver_unregister(_drv);
 
+#ifdef CONFIG_X86
+   if (is_bsw())
+   iounmap(ilb_base_addr);
+#endif
if (force_pdev)
platform_device_unregister(force_pdev);
 }
-- 
1.9.1



[PATCH v2] tpm: Fix the ioremap() call for Braswell systems

2017-06-22 Thread Azhar Shaikh
ioremap() for Intel Braswell processors was done in
tpm_tis_pnp_init(). But before this function gets called,
platform driver 'tis_drv' gets registered and its probe function
tpm_tis_plat_probe() is invoked, which does a TPM
access. Now for Braswell processors tpm_platform_begin_xfer()
will do an ioread32() without having a mapped address, which
will lead to a bad I/O access warning.
Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis()
before registering the 'tis_drv' or basically before any TPM access.
Accordingly also move the iounmap() call from tpm_tis_pnp_remove()
to cleanup_tis() after all TPM access are completed.

Signed-off-by: Azhar Shaikh 
---
Changes from v1:
- Do error handling in init_ts().
- Update the commit message.

 drivers/char/tpm/tpm_tis.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 506e62ca3576..d97ce22267fb 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
else
tpm_info.irq = -1;
 
-#ifdef CONFIG_X86
-   if (is_bsw())
-   ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
-   ILB_REMAP_SIZE);
-#endif
-
return tpm_tis_init(_dev->dev, _info);
 }
 
@@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
 
tpm_chip_unregister(chip);
tpm_tis_remove(chip);
-
-#ifdef CONFIG_X86
-   if (is_bsw())
-   iounmap(ilb_base_addr);
-#endif
-
 }
 
 static struct pnp_driver tis_pnp_driver = {
@@ -472,6 +460,11 @@ static int __init init_tis(void)
if (rc)
goto err_force;
 
+#ifdef CONFIG_X86
+   if (is_bsw())
+   ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR,
+   ILB_REMAP_SIZE);
+#endif
rc = platform_driver_register(_drv);
if (rc)
goto err_platform;
@@ -490,6 +483,10 @@ static int __init init_tis(void)
 err_platform:
if (force_pdev)
platform_device_unregister(force_pdev);
+#ifdef CONFIG_X86
+   if (is_bsw())
+   iounmap(ilb_base_addr);
+#endif
 err_force:
return rc;
 }
@@ -499,6 +496,10 @@ static void __exit cleanup_tis(void)
pnp_unregister_driver(_pnp_driver);
platform_driver_unregister(_drv);
 
+#ifdef CONFIG_X86
+   if (is_bsw())
+   iounmap(ilb_base_addr);
+#endif
if (force_pdev)
platform_device_unregister(force_pdev);
 }
-- 
1.9.1