Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/fsl_pamu: replace DOMAIN_ATTR_FSL_PAMU_STASH with a direct call

Add a fsl_pamu_configure_l1_stash API that qman_portal can call directly
instead of indirecting through the iommu attr API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Li Yang <leoyang.li@nxp.com>
Link: https://lore.kernel.org/r/20210401155256.298656-8-hch@lst.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Christoph Hellwig and committed by
Joerg Roedel
4eeb96f6 376dfd2a

+9 -40
+3 -9
arch/powerpc/include/asm/fsl_pamu_stash.h
··· 7 7 #ifndef __FSL_PAMU_STASH_H 8 8 #define __FSL_PAMU_STASH_H 9 9 10 + struct iommu_domain; 11 + 10 12 /* cache stash targets */ 11 13 enum pamu_stash_target { 12 14 PAMU_ATTR_CACHE_L1 = 1, ··· 16 14 PAMU_ATTR_CACHE_L3, 17 15 }; 18 16 19 - /* 20 - * This attribute allows configuring stashig specific parameters 21 - * in the PAMU hardware. 22 - */ 23 - 24 - struct pamu_stash_attribute { 25 - u32 cpu; /* cpu number */ 26 - u32 cache; /* cache to stash to: L1,L2,L3 */ 27 - }; 17 + int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu); 28 18 29 19 #endif /* __FSL_PAMU_STASH_H */
+3 -13
drivers/iommu/fsl_pamu_domain.c
··· 372 372 } 373 373 374 374 /* Set the domain stash attribute */ 375 - static int configure_domain_stash(struct fsl_dma_domain *dma_domain, void *data) 375 + int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu) 376 376 { 377 - struct pamu_stash_attribute *stash_attr = data; 377 + struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); 378 378 unsigned long flags; 379 379 int ret; 380 380 381 381 spin_lock_irqsave(&dma_domain->domain_lock, flags); 382 - 383 - memcpy(&dma_domain->dma_stash, stash_attr, 384 - sizeof(struct pamu_stash_attribute)); 385 - 386 - dma_domain->stash_id = get_stash_id(stash_attr->cache, 387 - stash_attr->cpu); 382 + dma_domain->stash_id = get_stash_id(PAMU_ATTR_CACHE_L1, cpu); 388 383 if (dma_domain->stash_id == ~(u32)0) { 389 384 pr_debug("Invalid stash attributes\n"); 390 385 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); 391 386 return -EINVAL; 392 387 } 393 - 394 388 ret = update_domain_stash(dma_domain, dma_domain->stash_id); 395 - 396 389 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); 397 390 398 391 return ret; ··· 419 426 int ret = 0; 420 427 421 428 switch (attr_type) { 422 - case DOMAIN_ATTR_FSL_PAMU_STASH: 423 - ret = configure_domain_stash(dma_domain, data); 424 - break; 425 429 case DOMAIN_ATTR_FSL_PAMU_ENABLE: 426 430 ret = configure_domain_dma_state(dma_domain, *(int *)data); 427 431 break;
-2
drivers/iommu/fsl_pamu_domain.h
··· 22 22 * 23 23 */ 24 24 int enabled; 25 - /* stash_id obtained from the stash attribute details */ 26 25 u32 stash_id; 27 - struct pamu_stash_attribute dma_stash; 28 26 u32 snoop_id; 29 27 struct iommu_domain iommu_domain; 30 28 spinlock_t domain_lock;
+3 -15
drivers/soc/fsl/qbman/qman_portal.c
··· 47 47 #ifdef CONFIG_FSL_PAMU 48 48 struct device *dev = pcfg->dev; 49 49 int window_count = 1; 50 - struct pamu_stash_attribute stash_attr; 51 50 int ret; 52 51 53 52 pcfg->iommu_domain = iommu_domain_alloc(&platform_bus_type); ··· 54 55 dev_err(dev, "%s(): iommu_domain_alloc() failed", __func__); 55 56 goto no_iommu; 56 57 } 57 - stash_attr.cpu = cpu; 58 - stash_attr.cache = PAMU_ATTR_CACHE_L1; 59 - ret = iommu_domain_set_attr(pcfg->iommu_domain, 60 - DOMAIN_ATTR_FSL_PAMU_STASH, 61 - &stash_attr); 58 + ret = fsl_pamu_configure_l1_stash(pcfg->iommu_domain, cpu); 62 59 if (ret < 0) { 63 - dev_err(dev, "%s(): iommu_domain_set_attr() = %d", 60 + dev_err(dev, "%s(): fsl_pamu_configure_l1_stash() = %d", 64 61 __func__, ret); 65 62 goto out_domain_free; 66 63 } ··· 138 143 unsigned int cpu) 139 144 { 140 145 #ifdef CONFIG_FSL_PAMU /* TODO */ 141 - struct pamu_stash_attribute stash_attr; 142 - int ret; 143 - 144 146 if (pcfg->iommu_domain) { 145 - stash_attr.cpu = cpu; 146 - stash_attr.cache = PAMU_ATTR_CACHE_L1; 147 - ret = iommu_domain_set_attr(pcfg->iommu_domain, 148 - DOMAIN_ATTR_FSL_PAMU_STASH, &stash_attr); 149 - if (ret < 0) { 147 + if (fsl_pamu_configure_l1_stash(pcfg->iommu_domain, cpu) < 0) { 150 148 dev_err(pcfg->dev, 151 149 "Failed to update pamu stash setting\n"); 152 150 return;
-1
include/linux/iommu.h
··· 109 109 enum iommu_attr { 110 110 DOMAIN_ATTR_GEOMETRY, 111 111 DOMAIN_ATTR_PAGING, 112 - DOMAIN_ATTR_FSL_PAMU_STASH, 113 112 DOMAIN_ATTR_FSL_PAMU_ENABLE, 114 113 DOMAIN_ATTR_NESTING, /* two stages of translation */ 115 114 DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,