@@ -251,8 +251,6 @@ static inline bool arm_lpae_concat_mandatory(struct io_pgtable_cfg *cfg,
251251 (data -> start_level == 1 ) && (oas == 40 );
252252}
253253
254- static bool selftest_running = false;
255-
256254static dma_addr_t __arm_lpae_dma_addr (void * pages )
257255{
258256 return (dma_addr_t )virt_to_phys (pages );
@@ -371,7 +369,7 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,
371369 for (i = 0 ; i < num_entries ; i ++ )
372370 if (iopte_leaf (ptep [i ], lvl , data -> iop .fmt )) {
373371 /* We require an unmap first */
374- WARN_ON (!selftest_running );
372+ WARN_ON (!( data -> iop . cfg . quirks & IO_PGTABLE_QUIRK_NO_WARN ) );
375373 return - EEXIST ;
376374 } else if (iopte_type (ptep [i ]) == ARM_LPAE_PTE_TYPE_TABLE ) {
377375 /*
@@ -473,7 +471,7 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
473471 cptep = iopte_deref (pte , data );
474472 } else if (pte ) {
475473 /* We require an unmap first */
476- WARN_ON (!selftest_running );
474+ WARN_ON (!( cfg -> quirks & IO_PGTABLE_QUIRK_NO_WARN ) );
477475 return - EEXIST ;
478476 }
479477
@@ -641,8 +639,10 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
641639 unmap_idx_start = ARM_LPAE_LVL_IDX (iova , lvl , data );
642640 ptep += unmap_idx_start ;
643641 pte = READ_ONCE (* ptep );
644- if (WARN_ON (!pte ))
645- return 0 ;
642+ if (!pte ) {
643+ WARN_ON (!(data -> iop .cfg .quirks & IO_PGTABLE_QUIRK_NO_WARN ));
644+ return - ENOENT ;
645+ }
646646
647647 /* If the size matches this level, we're in the right place */
648648 if (size == ARM_LPAE_BLOCK_SIZE (lvl , data )) {
@@ -652,8 +652,10 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
652652 /* Find and handle non-leaf entries */
653653 for (i = 0 ; i < num_entries ; i ++ ) {
654654 pte = READ_ONCE (ptep [i ]);
655- if (WARN_ON (!pte ))
655+ if (!pte ) {
656+ WARN_ON (!(data -> iop .cfg .quirks & IO_PGTABLE_QUIRK_NO_WARN ));
656657 break ;
658+ }
657659
658660 if (!iopte_leaf (pte , lvl , iop -> fmt )) {
659661 __arm_lpae_clear_pte (& ptep [i ], & iop -> cfg , 1 );
@@ -968,7 +970,8 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie)
968970 if (cfg -> quirks & ~(IO_PGTABLE_QUIRK_ARM_NS |
969971 IO_PGTABLE_QUIRK_ARM_TTBR1 |
970972 IO_PGTABLE_QUIRK_ARM_OUTER_WBWA |
971- IO_PGTABLE_QUIRK_ARM_HD ))
973+ IO_PGTABLE_QUIRK_ARM_HD |
974+ IO_PGTABLE_QUIRK_NO_WARN ))
972975 return NULL ;
973976
974977 data = arm_lpae_alloc_pgtable (cfg );
@@ -1069,7 +1072,8 @@ arm_64_lpae_alloc_pgtable_s2(struct io_pgtable_cfg *cfg, void *cookie)
10691072 struct arm_lpae_io_pgtable * data ;
10701073 typeof (& cfg -> arm_lpae_s2_cfg .vtcr ) vtcr = & cfg -> arm_lpae_s2_cfg .vtcr ;
10711074
1072- if (cfg -> quirks & ~(IO_PGTABLE_QUIRK_ARM_S2FWB ))
1075+ if (cfg -> quirks & ~(IO_PGTABLE_QUIRK_ARM_S2FWB |
1076+ IO_PGTABLE_QUIRK_NO_WARN ))
10731077 return NULL ;
10741078
10751079 data = arm_lpae_alloc_pgtable (cfg );
@@ -1310,7 +1314,6 @@ static void __init arm_lpae_dump_ops(struct io_pgtable_ops *ops)
13101314#define __FAIL (ops , i ) ({ \
13111315 WARN(1, "selftest: test failed for fmt idx %d\n", (i)); \
13121316 arm_lpae_dump_ops(ops); \
1313- selftest_running = false; \
13141317 -EFAULT; \
13151318})
13161319
@@ -1326,8 +1329,6 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
13261329 size_t size , mapped ;
13271330 struct io_pgtable_ops * ops ;
13281331
1329- selftest_running = true;
1330-
13311332 for (i = 0 ; i < ARRAY_SIZE (fmts ); ++ i ) {
13321333 cfg_cookie = cfg ;
13331334 ops = alloc_io_pgtable_ops (fmts [i ], cfg , cfg );
@@ -1416,7 +1417,6 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
14161417 free_io_pgtable_ops (ops );
14171418 }
14181419
1419- selftest_running = false;
14201420 return 0 ;
14211421}
14221422
@@ -1438,6 +1438,7 @@ static int __init arm_lpae_do_selftests(void)
14381438 .tlb = & dummy_tlb_ops ,
14391439 .coherent_walk = true,
14401440 .iommu_dev = & dev ,
1441+ .quirks = IO_PGTABLE_QUIRK_NO_WARN ,
14411442 };
14421443
14431444 /* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
0 commit comments