Re: [PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
On 4/9/2021 12:32 PM, Konrad Rzeszutek Wilk wrote: > On Thu, Apr 08, 2021 at 08:13:07PM -0700, Florian Fainelli wrote: >> >> >> On 3/24/2021 1:42 AM, Christoph Hellwig wrote: >>> On Mon, Mar 22, 2021 at 06:53:49PM -0700, Florian Fainelli wrote: When SWIOTLB_NO_FORCE is used, there should really be no allocations of default_nslabs to occur since we are not going to use those slabs. If a platform was somehow setting swiotlb_no_force and a later call to swiotlb_init() was to be made we would still be proceeding with allocating the default SWIOTLB size (64MB), whereas if swiotlb=noforce was set on the kernel command line we would have only allocated 2KB. This would be inconsistent and the point of initializing default_nslabs to 1, was intended to allocate the minimum amount of memory possible, so simply remove that minimal allocation period. Signed-off-by: Florian Fainelli >>> >>> Looks good, >>> >>> Reviewed-by: Christoph Hellwig >>> >> >> Thanks! Konrad, can you apply this patch to your for-linus-5.13 branch >> if you are also happy with it? > > It should be now visible? Not seeing it here: https://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git/log/?h=devel/for-linus-5.13 -- Florian ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
On Thu, Apr 08, 2021 at 08:13:07PM -0700, Florian Fainelli wrote: > > > On 3/24/2021 1:42 AM, Christoph Hellwig wrote: > > On Mon, Mar 22, 2021 at 06:53:49PM -0700, Florian Fainelli wrote: > >> When SWIOTLB_NO_FORCE is used, there should really be no allocations of > >> default_nslabs to occur since we are not going to use those slabs. If a > >> platform was somehow setting swiotlb_no_force and a later call to > >> swiotlb_init() was to be made we would still be proceeding with > >> allocating the default SWIOTLB size (64MB), whereas if swiotlb=noforce > >> was set on the kernel command line we would have only allocated 2KB. > >> > >> This would be inconsistent and the point of initializing default_nslabs > >> to 1, was intended to allocate the minimum amount of memory possible, so > >> simply remove that minimal allocation period. > >> > >> Signed-off-by: Florian Fainelli > > > > Looks good, > > > > Reviewed-by: Christoph Hellwig > > > > Thanks! Konrad, can you apply this patch to your for-linus-5.13 branch > if you are also happy with it? It should be now visible? > -- > Florian ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
On 3/24/2021 1:42 AM, Christoph Hellwig wrote: > On Mon, Mar 22, 2021 at 06:53:49PM -0700, Florian Fainelli wrote: >> When SWIOTLB_NO_FORCE is used, there should really be no allocations of >> default_nslabs to occur since we are not going to use those slabs. If a >> platform was somehow setting swiotlb_no_force and a later call to >> swiotlb_init() was to be made we would still be proceeding with >> allocating the default SWIOTLB size (64MB), whereas if swiotlb=noforce >> was set on the kernel command line we would have only allocated 2KB. >> >> This would be inconsistent and the point of initializing default_nslabs >> to 1, was intended to allocate the minimum amount of memory possible, so >> simply remove that minimal allocation period. >> >> Signed-off-by: Florian Fainelli > > Looks good, > > Reviewed-by: Christoph Hellwig > Thanks! Konrad, can you apply this patch to your for-linus-5.13 branch if you are also happy with it? -- Florian ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
On Mon, Mar 22, 2021 at 06:53:49PM -0700, Florian Fainelli wrote: > When SWIOTLB_NO_FORCE is used, there should really be no allocations of > default_nslabs to occur since we are not going to use those slabs. If a > platform was somehow setting swiotlb_no_force and a later call to > swiotlb_init() was to be made we would still be proceeding with > allocating the default SWIOTLB size (64MB), whereas if swiotlb=noforce > was set on the kernel command line we would have only allocated 2KB. > > This would be inconsistent and the point of initializing default_nslabs > to 1, was intended to allocate the minimum amount of memory possible, so > simply remove that minimal allocation period. > > Signed-off-by: Florian Fainelli Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
When SWIOTLB_NO_FORCE is used, there should really be no allocations of default_nslabs to occur since we are not going to use those slabs. If a platform was somehow setting swiotlb_no_force and a later call to swiotlb_init() was to be made we would still be proceeding with allocating the default SWIOTLB size (64MB), whereas if swiotlb=noforce was set on the kernel command line we would have only allocated 2KB. This would be inconsistent and the point of initializing default_nslabs to 1, was intended to allocate the minimum amount of memory possible, so simply remove that minimal allocation period. Signed-off-by: Florian Fainelli --- Changes in v3: - patch all call sites that can allocate SWIOTLB memory Changes in v2: - rebased against devel/for-linus-5.13 - updated commit message to reflect variable names kernel/dma/swiotlb.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 539c76beb52e..0a5b6f7e75bc 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -83,12 +83,10 @@ setup_io_tlb_npages(char *str) } if (*str == ',') ++str; - if (!strcmp(str, "force")) { + if (!strcmp(str, "force")) swiotlb_force = SWIOTLB_FORCE; - } else if (!strcmp(str, "noforce")) { + else if (!strcmp(str, "noforce")) swiotlb_force = SWIOTLB_NO_FORCE; - default_nslabs = 1; - } return 0; } @@ -174,6 +172,9 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) struct io_tlb_mem *mem; size_t alloc_size; + if (swiotlb_force == SWIOTLB_NO_FORCE) + return 0; + /* protect against double initialization */ if (WARN_ON_ONCE(io_tlb_default_mem)) return -ENOMEM; @@ -211,6 +212,9 @@ swiotlb_init(int verbose) size_t bytes = PAGE_ALIGN(default_nslabs << IO_TLB_SHIFT); void *tlb; + if (swiotlb_force == SWIOTLB_NO_FORCE) + return; + /* Get IO TLB memory from the low pages */ tlb = memblock_alloc_low(bytes, PAGE_SIZE); if (!tlb) @@ -240,6 +244,9 @@ swiotlb_late_init_with_default_size(size_t default_size) unsigned int order; int rc = 0; + if (swiotlb_force == SWIOTLB_NO_FORCE) + return 0; + /* * Get IO TLB memory from the low pages */ @@ -276,6 +283,9 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) unsigned long bytes = nslabs << IO_TLB_SHIFT, i; struct io_tlb_mem *mem; + if (swiotlb_force == SWIOTLB_NO_FORCE) + return 0; + /* protect against double initialization */ if (WARN_ON_ONCE(io_tlb_default_mem)) return -ENOMEM; -- 2.25.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu