diff mbox series

[v2] powerpc/iommu: limit number of TCEs to 512 for H_STUFF_TCE hcall

Message ID 20230525143454.56878-1-gbatra@linux.vnet.ibm.com (mailing list archive)
State Accepted
Commit 9d2ccf00bddc268045e3d65a8108d61ada0e4b4e
Headers show
Series [v2] powerpc/iommu: limit number of TCEs to 512 for H_STUFF_TCE hcall | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.

Commit Message

Gaurav Batra May 25, 2023, 2:34 p.m. UTC
As of now, in tce_freemulti_pSeriesLP(), there is no limit on how many TCEs
are passed to H_STUFF_TCE hcall. This was not an issue until now. Newer
firmware releases have started enforcing this requirement.

The interface has been in it's current form since the beginning.

Cc: stable@vger.kernel.org

Signed-off-by: Gaurav Batra <gbatra@linux.vnet.ibm.com>
Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/iommu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Gaurav Batra May 25, 2023, 2:40 p.m. UTC | #1
Hello Michael,

Here are the changes in v2 of the patch

1. added some wording to change log to specify why we are seeing the 
issue now. Also added "CC: stable@vger.kernel.org"

2. changed "limit" to unsigned long. I have kept "rpages" as "long"

Thanks,

Gaurav

On 5/25/23 9:34 AM, Gaurav Batra wrote:
> As of now, in tce_freemulti_pSeriesLP(), there is no limit on how many TCEs
> are passed to H_STUFF_TCE hcall. This was not an issue until now. Newer
> firmware releases have started enforcing this requirement.
>
> The interface has been in it's current form since the beginning.
>
> Cc: stable@vger.kernel.org
>
> Signed-off-by: Gaurav Batra <gbatra@linux.vnet.ibm.com>
> Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
> ---
>   arch/powerpc/platforms/pseries/iommu.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index c74b71d4733d..f159a195101d 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -306,13 +306,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift,
>   static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
>   {
>   	u64 rc;
> +	long rpages = npages;
> +	unsigned long limit;
>
>   	if (!firmware_has_feature(FW_FEATURE_STUFF_TCE))
>   		return tce_free_pSeriesLP(tbl->it_index, tcenum,
>   					  tbl->it_page_shift, npages);
>
> -	rc = plpar_tce_stuff((u64)tbl->it_index,
> -			     (u64)tcenum << tbl->it_page_shift, 0, npages);
> +	do {
> +		limit = min_t(unsigned long, rpages, 512);
> +
> +		rc = plpar_tce_stuff((u64)tbl->it_index,
> +			     	(u64)tcenum << tbl->it_page_shift, 0, limit);
> +
> +		rpages -= limit;
> +		tcenum += limit;
> +	} while (rpages > 0 && !rc);
>
>   	if (rc && printk_ratelimit()) {
>   		printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");
Michael Ellerman July 3, 2023, 4:02 a.m. UTC | #2
On Thu, 25 May 2023 09:34:54 -0500, Gaurav Batra wrote:
> As of now, in tce_freemulti_pSeriesLP(), there is no limit on how many TCEs
> are passed to H_STUFF_TCE hcall. This was not an issue until now. Newer
> firmware releases have started enforcing this requirement.
> 
> The interface has been in it's current form since the beginning.
> 
> Cc: stable@vger.kernel.org
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/iommu: limit number of TCEs to 512 for H_STUFF_TCE hcall
      https://git.kernel.org/powerpc/c/9d2ccf00bddc268045e3d65a8108d61ada0e4b4e

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index c74b71d4733d..f159a195101d 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -306,13 +306,22 @@  static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift,
 static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
 {
 	u64 rc;
+	long rpages = npages;
+	unsigned long limit;
 
 	if (!firmware_has_feature(FW_FEATURE_STUFF_TCE))
 		return tce_free_pSeriesLP(tbl->it_index, tcenum,
 					  tbl->it_page_shift, npages);
 
-	rc = plpar_tce_stuff((u64)tbl->it_index,
-			     (u64)tcenum << tbl->it_page_shift, 0, npages);
+	do {
+		limit = min_t(unsigned long, rpages, 512);
+
+		rc = plpar_tce_stuff((u64)tbl->it_index,
+			     	(u64)tcenum << tbl->it_page_shift, 0, limit);
+
+		rpages -= limit;
+		tcenum += limit;
+	} while (rpages > 0 && !rc);
 
 	if (rc && printk_ratelimit()) {
 		printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");