mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel: tpmi: Remove hardcoded unit and offset
@ 2023-06-17  1:44 Srinivas Pandruvada
  2023-06-20 10:45 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2023-06-17  1:44 UTC (permalink / raw)
  To: hdegoede, markgross, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada

Use sizeof(u32) for TPMI entry size units. Also add a define
for capability offset unit size.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/platform/x86/intel/tpmi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
index a5227951decc..9c606ee2030c 100644
--- a/drivers/platform/x86/intel/tpmi.c
+++ b/drivers/platform/x86/intel/tpmi.c
@@ -222,7 +222,7 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
 	snprintf(feature_id_name, sizeof(feature_id_name), "tpmi-%s", name);
 
 	for (i = 0, tmp = res; i < pfs->pfs_header.num_entries; i++, tmp++) {
-		u64 entry_size_bytes = pfs->pfs_header.entry_size * 4;
+		u64 entry_size_bytes = pfs->pfs_header.entry_size * sizeof(u32);
 
 		tmp->start = pfs->vsec_offset + entry_size_bytes * i;
 		tmp->end = tmp->start + entry_size_bytes - 1;
@@ -277,7 +277,7 @@ static int tpmi_process_info(struct intel_tpmi_info *tpmi_info,
 	void __iomem *info_mem;
 
 	info_mem = ioremap(pfs->vsec_offset + TPMI_INFO_BUS_INFO_OFFSET,
-			   pfs->pfs_header.entry_size * 4 - TPMI_INFO_BUS_INFO_OFFSET);
+			   pfs->pfs_header.entry_size * sizeof(u32) - TPMI_INFO_BUS_INFO_OFFSET);
 	if (!info_mem)
 		return -ENOMEM;
 
@@ -308,6 +308,8 @@ static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, i
 	return 0;
 }
 
+#define TPMI_CAP_OFFSET_UNIT	1024
+
 static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
 {
 	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
@@ -354,7 +356,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
 		if (!pfs_start)
 			pfs_start = res_start;
 
-		pfs->pfs_header.cap_offset *= 1024;
+		pfs->pfs_header.cap_offset *= TPMI_CAP_OFFSET_UNIT;
 
 		pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset;
 
-- 
2.38.1


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

* Re: [PATCH] platform/x86/intel: tpmi: Remove hardcoded unit and offset
  2023-06-17  1:44 [PATCH] platform/x86/intel: tpmi: Remove hardcoded unit and offset Srinivas Pandruvada
@ 2023-06-20 10:45 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2023-06-20 10:45 UTC (permalink / raw)
  To: Srinivas Pandruvada, markgross, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel

Hi,

On 6/17/23 03:44, Srinivas Pandruvada wrote:
> Use sizeof(u32) for TPMI entry size units. Also add a define
> for capability offset unit size.
> 
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans



> ---
>  drivers/platform/x86/intel/tpmi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
> index a5227951decc..9c606ee2030c 100644
> --- a/drivers/platform/x86/intel/tpmi.c
> +++ b/drivers/platform/x86/intel/tpmi.c
> @@ -222,7 +222,7 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
>  	snprintf(feature_id_name, sizeof(feature_id_name), "tpmi-%s", name);
>  
>  	for (i = 0, tmp = res; i < pfs->pfs_header.num_entries; i++, tmp++) {
> -		u64 entry_size_bytes = pfs->pfs_header.entry_size * 4;
> +		u64 entry_size_bytes = pfs->pfs_header.entry_size * sizeof(u32);
>  
>  		tmp->start = pfs->vsec_offset + entry_size_bytes * i;
>  		tmp->end = tmp->start + entry_size_bytes - 1;
> @@ -277,7 +277,7 @@ static int tpmi_process_info(struct intel_tpmi_info *tpmi_info,
>  	void __iomem *info_mem;
>  
>  	info_mem = ioremap(pfs->vsec_offset + TPMI_INFO_BUS_INFO_OFFSET,
> -			   pfs->pfs_header.entry_size * 4 - TPMI_INFO_BUS_INFO_OFFSET);
> +			   pfs->pfs_header.entry_size * sizeof(u32) - TPMI_INFO_BUS_INFO_OFFSET);
>  	if (!info_mem)
>  		return -ENOMEM;
>  
> @@ -308,6 +308,8 @@ static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, i
>  	return 0;
>  }
>  
> +#define TPMI_CAP_OFFSET_UNIT	1024
> +
>  static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
>  {
>  	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
> @@ -354,7 +356,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
>  		if (!pfs_start)
>  			pfs_start = res_start;
>  
> -		pfs->pfs_header.cap_offset *= 1024;
> +		pfs->pfs_header.cap_offset *= TPMI_CAP_OFFSET_UNIT;
>  
>  		pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset;
>  


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

end of thread, other threads:[~2023-06-20 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-17  1:44 [PATCH] platform/x86/intel: tpmi: Remove hardcoded unit and offset Srinivas Pandruvada
2023-06-20 10:45 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®