Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp291281pxb; Wed, 13 Jan 2021 03:53:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfWX49jBRXtRY9YjW6A1tvkDZUYAvf6HUBkbMhZbRrcM/UnwOUtrPBkmIJXJdaQbYkUhQF X-Received: by 2002:a17:906:c1d9:: with SMTP id bw25mr1279942ejb.452.1610538804643; Wed, 13 Jan 2021 03:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610538804; cv=none; d=google.com; s=arc-20160816; b=T5NATsYahQ4TU5B2371PlScSkdPKJLiVNORvNlz79Y1UPjVkhJ6a7/FSRK39aTMtqP RAHU1WvY1gbuog1x4vOdkrVWoHLPY7pNcT9eEXyaifAQSAqSs6wcrf5MMHWq7v2zCICL TsKW5Q2Cc0wHHH2u0xPmfHNg9qYcKKgsS9FfrLbNnw+SAwZYw8Uw7xZwKqHYrl47aUta kFWCjYo5q2XIqU6Cw/g7TwIiHYKOzhOqI6BTy33YtoWzYv/Q7eHlX56mLcaTW3p5ezUv KRwDa2IdQyicruOssSISgYrhxvoHqEYnD5YMjaAxsCgu5M23A/9Nug/9lsr0JPz2jyPI RW0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=kdNjujOdcUVvWkMaAo/MRYEmiD0ajVzMK/2Hotn9jL4=; b=jYHVOhS9TfxK81G4cYNXzcEfQmH4h0A5jVOLLKIvi9ps9o9ZHOFZ5QWlMxLy2hMzQj ShOBtywmdPFiUHxnxFr5XUVS4UAgOOWUarWxvn+65DOVrUxFOn16GzS7pttld+wzCA2Z WhrerBFHRFfijGQ1OACm09s6CG2oNV9IrAxOZG8kxG6P8St7I8NUQZspua2zcFaEqf6l YdnQmDPw2JW7wwkYeaTs4jrdABRxLfbjn+h1MukcZnJXaZ2LU/vdxXxg86D5ibDkvug7 ywerYIzR8B4LR1fjmCk5dKxKfnR0wgehjdgouqy3b+pwoC35t6k8N3aH5Wsh0g3+YgUv phFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si973342edr.53.2021.01.13.03.53.01; Wed, 13 Jan 2021 03:53:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726603AbhAMLvR (ORCPT + 99 others); Wed, 13 Jan 2021 06:51:17 -0500 Received: from verein.lst.de ([213.95.11.211]:59750 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbhAMLvQ (ORCPT ); Wed, 13 Jan 2021 06:51:16 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id AA26B68AFE; Wed, 13 Jan 2021 12:50:31 +0100 (CET) Date: Wed, 13 Jan 2021 12:50:31 +0100 From: Christoph Hellwig To: Claire Chang Cc: robh+dt@kernel.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, joro@8bytes.org, will@kernel.org, frowand.list@gmail.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, grant.likely@arm.com, xypron.glpk@gmx.de, treding@nvidia.com, mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, gregkh@linuxfoundation.org, saravanak@google.com, rafael.j.wysocki@intel.com, heikki.krogerus@linux.intel.com, andriy.shevchenko@linux.intel.com, rdunlap@infradead.org, dan.j.williams@intel.com, bgolaszewski@baylibre.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, xen-devel@lists.xenproject.org, tfiga@chromium.org, drinkcat@chromium.org Subject: Re: [RFC PATCH v3 1/6] swiotlb: Add io_tlb_mem struct Message-ID: <20210113115031.GA29376@lst.de> References: <20210106034124.30560-1-tientzu@chromium.org> <20210106034124.30560-2-tientzu@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210106034124.30560-2-tientzu@chromium.org> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 06, 2021 at 11:41:19AM +0800, Claire Chang wrote: > Added a new struct, io_tlb_mem, as the IO TLB memory pool descriptor and > moved relevant global variables into that struct. > This will be useful later to allow for restricted DMA pool. I like where this is going, but a few comments. Mostly I'd love to be able to entirely hide io_tlb_default_mem and struct io_tlb_mem inside of swiotlb.c. > --- a/arch/powerpc/platforms/pseries/svm.c > +++ b/arch/powerpc/platforms/pseries/svm.c > @@ -55,8 +55,8 @@ void __init svm_swiotlb_init(void) > if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, false)) > return; > > - if (io_tlb_start) > - memblock_free_early(io_tlb_start, > + if (io_tlb_default_mem.start) > + memblock_free_early(io_tlb_default_mem.start, > PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT)); I think this should switch to use the local vstart variable in prep patch. > panic("SVM: Cannot allocate SWIOTLB buffer"); > } > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > index 2b385c1b4a99..4d17dff7ffd2 100644 > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -192,8 +192,8 @@ int __ref xen_swiotlb_init(int verbose, bool early) > /* > * IO TLB memory already allocated. Just use it. > */ > - if (io_tlb_start != 0) { > - xen_io_tlb_start = phys_to_virt(io_tlb_start); > + if (io_tlb_default_mem.start != 0) { > + xen_io_tlb_start = phys_to_virt(io_tlb_default_mem.start); > goto end; xen_io_tlb_start is interesting. It is used only in two functions: 1) is_xen_swiotlb_buffer, where I think we should be able to just use is_swiotlb_buffer instead of open coding it with the extra phys_to_virt/virt_to_phys cycle. 2) xen_swiotlb_init, where except for the assignment it only is used locally for the case not touched above and could this be replaced with a local variable. Konrad, does this make sense to you? > static inline bool is_swiotlb_buffer(phys_addr_t paddr) > { > - return paddr >= io_tlb_start && paddr < io_tlb_end; > + struct io_tlb_mem *mem = &io_tlb_default_mem; > + > + return paddr >= mem->start && paddr < mem->end; We'd then have to move this out of line as well.