Skip to content

Commit 9d2ccf0

Browse files
Gaurav Batrampe
authored andcommitted
powerpc/iommu: Limit number of TCEs to 512 for H_STUFF_TCE hcall
Currently in tce_freemulti_pSeriesLP() there is no limit on how many TCEs are passed to the H_STUFF_TCE hcall. This has not caused an issue until now, but newer firmware releases have started enforcing a limit of 512 TCEs per call. The limit is correct per the specification (PAPR v2.12 § 14.5.4.2.3). The code has been in it's current form since it was initially merged. Cc: stable@vger.kernel.org Signed-off-by: Gaurav Batra <gbatra@linux.vnet.ibm.com> Reviewed-by: Brian King <brking@linux.vnet.ibm.com> [mpe: Tweak change log wording & add PAPR reference] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230525143454.56878-1-gbatra@linux.vnet.ibm.com
1 parent 81d358b commit 9d2ccf0

File tree

1 file changed

+11
-2
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+11
-2
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift,
317317
static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
318318
{
319319
u64 rc;
320+
long rpages = npages;
321+
unsigned long limit;
320322

321323
if (!firmware_has_feature(FW_FEATURE_STUFF_TCE))
322324
return tce_free_pSeriesLP(tbl->it_index, tcenum,
323325
tbl->it_page_shift, npages);
324326

325-
rc = plpar_tce_stuff((u64)tbl->it_index,
326-
(u64)tcenum << tbl->it_page_shift, 0, npages);
327+
do {
328+
limit = min_t(unsigned long, rpages, 512);
329+
330+
rc = plpar_tce_stuff((u64)tbl->it_index,
331+
(u64)tcenum << tbl->it_page_shift, 0, limit);
332+
333+
rpages -= limit;
334+
tcenum += limit;
335+
} while (rpages > 0 && !rc);
327336

328337
if (rc && printk_ratelimit()) {
329338
printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");

0 commit comments

Comments
 (0)