Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1466245rwp; Thu, 13 Jul 2023 11:14:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2c0LbrSxwO/XZQy3cftuiz3jGWgKyGjXZOJL0kDJbt/PbdKdryv9094Wd1PBFQZuQXuTx X-Received: by 2002:a17:906:535b:b0:993:fba5:cdf3 with SMTP id j27-20020a170906535b00b00993fba5cdf3mr2251186ejo.6.1689272070038; Thu, 13 Jul 2023 11:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689272070; cv=none; d=google.com; s=arc-20160816; b=des7s0TDJXWwO/wHH9wD0ZByHnawqUJ69LRXzgHXwac2zckDxeAcZ2oWqY1vR39VEz 4iLtGPTC8Gc2MwP8XP90Z15axFDixxTxG3pE/30curqMzrZiSEcMoD0IvGUaanIWQDS8 y8tTYonq1YiL5L0o0wMzlLCsSZvLV8PgNQhR+VC1cM/9Yn/ji57b8e7oHIufKAW7mv4M V3SGwAVszraHkfBSLItmymy0l8Aookr/u/BiZRYmmUjqDbK9ygJXTmMJPBjpSvvCmaZ0 hKPaAIpYehb8xvKw5eiUXsZNkHkqIBKLdg1dFTucNkyVy2w3cM7P046MW2i1KnqrdP+9 3Q0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DIomgEdXaOAf5F39I6vC7qp0d2CQ9lZJ9M3fn9vi0b8=; fh=USGgnPS5MMsrgpIgeGQEC8eZaSso0GEfs7j71jSb3q4=; b=GBv0JiYGWmmySnERygX8hmrTZP+BDGyZAZtpXwSbRemnuzuaNAUxT7iQPwvkuvOttN lA1A2hY9kZpbcWS+YO/bLOf7/S4+7agn5YoXQwG6Jb1LSGni+52OagIfwl9uhkLuua90 eMyYMljKFaBrv+5+mkIphrCdJ0d9k91LWBu1Qg0HgneR3p5QCsW/GbmvbqSw0z39ybSI dTHHKBEjS9aWLgEYO8EGvQOIQx5kMg8/+GcOTIlamBrhyqRvej3fcRBMuR8AHj6uCqqw XXfOq4wuJwqkVoQxXIl/WyGNoZGwCTyf/jTz4JXmDLNnHCfRqxlCKm1he7zAoO6KVLvC LU2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=EkihYalI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jp2-20020a170906f74200b0099363826e3fsi7229547ejb.177.2023.07.13.11.14.04; Thu, 13 Jul 2023 11:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=EkihYalI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbjGMRxP (ORCPT + 99 others); Thu, 13 Jul 2023 13:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjGMRxO (ORCPT ); Thu, 13 Jul 2023 13:53:14 -0400 Received: from bee.tesarici.cz (bee.tesarici.cz [77.93.223.253]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3968271F; Thu, 13 Jul 2023 10:53:12 -0700 (PDT) Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 5EE5814DBB9; Thu, 13 Jul 2023 19:53:09 +0200 (CEST) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=none dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tesarici.cz; s=mail; t=1689270789; bh=bPL0dJQsO71F+7x2c6oBcd15kYFwAiWbA6uxbyrkpGE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EkihYalIeEcrIel7VgAhcpVNo9/pboyyZekjWK0jOnc5F1ahW2sgtlX2s4G3xz2aa 7/pVJP13bkUSQtOnx/qTC561TvfhmkpEWgCjkNF0dnKtNeOHHWOPNueuVhTFgK2ELk wUOXEGu3hH49hYFoW2UWlnrBscc4Wib4CIVTdHzIxE5HMHeeuN7aydOSwzOTqbpdDv gD5Bsyr0BRxuvTKvkDlRDW5xFxEeTF4ZsC7VFVRP05INsvS0TzW3gxx20lzeEnkYdG ce/RvNC6zV5zfoC3oip2w9zTQ1heZ9+LR1nTdovemvPME96D6qgBeJM/SIEWJ77vyR +exPMHF3hrfBg== Date: Thu, 13 Jul 2023 19:53:07 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Petr Tesarik Cc: Stefano Stabellini , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Juergen Gross , Oleksandr Tyshchenko , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Jonathan Corbet , Andy Shevchenko , Hans de Goede , James Seo , James Clark , Kees Cook , xen-devel@lists.xenproject.org (moderated list:XEN HYPERVISOR ARM), linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT), linux-kernel@vger.kernel.org (open list), linux-mips@vger.kernel.org (open list:MIPS), iommu@lists.linux.dev (open list:XEN SWIOTLB SUBSYSTEM), Roberto Sassu , Kefeng Wang Subject: Re: [PATCH v4 3/8] swiotlb: separate memory pool data from other allocator data Message-ID: <20230713195307.08d68b01@meshulam.tesarici.cz> In-Reply-To: References: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Jul 2023 17:23:14 +0200 Petr Tesarik wrote: > From: Petr Tesarik > > Carve out memory pool specific fields from struct io_tlb_mem. The original > struct now contains shared data for the whole allocator, while the new > struct io_tlb_pool contains data that is specific to one memory pool of > (potentially) many. > > Allocate both structures together for restricted DMA pools to keep the > error cleanup path simple. > > Signed-off-by: Petr Tesarik > --- > include/linux/device.h | 2 +- > include/linux/swiotlb.h | 47 +++++++---- > kernel/dma/swiotlb.c | 181 +++++++++++++++++++++++++--------------- > 3 files changed, 147 insertions(+), 83 deletions(-) > > diff --git a/include/linux/device.h b/include/linux/device.h > index bbaeabd04b0d..d9754a68ba95 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -625,7 +625,7 @@ struct device_physical_location { > * @dma_pools: Dma pools (if dma'ble device). > * @dma_mem: Internal for coherent mem override. > * @cma_area: Contiguous memory area for dma allocations > - * @dma_io_tlb_mem: Pointer to the swiotlb pool used. Not for driver use. > + * @dma_io_tlb_mem: Software IO TLB allocator. Not for driver use. > * @archdata: For arch-specific additions. > * @of_node: Associated device tree node. > * @fwnode: Associated device node supplied by platform firmware. > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > index 39313c3a791a..d669e11e2827 100644 > --- a/include/linux/swiotlb.h > +++ b/include/linux/swiotlb.h > @@ -62,8 +62,7 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys, > #ifdef CONFIG_SWIOTLB > > /** > - * struct io_tlb_mem - IO TLB Memory Pool Descriptor > - * > + * struct io_tlb_pool - IO TLB memory pool descriptor > * @start: The start address of the swiotlb memory pool. Used to do a quick > * range check to see if the memory was in fact allocated by this > * API. > @@ -73,15 +72,36 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys, > * @vaddr: The vaddr of the swiotlb memory pool. The swiotlb memory pool > * may be remapped in the memory encrypted case and store virtual > * address for bounce buffer operation. > - * @nslabs: The number of IO TLB blocks (in groups of 64) between @start and > - * @end. For default swiotlb, this is command line adjustable via > - * setup_io_tlb_npages. > + * @nslabs: The number of IO TLB slots between @start and @end. For the > + * default swiotlb, this can be adjusted with a boot parameter, > + * see setup_io_tlb_npages(). > + * @used: The number of used IO TLB slots. > + * @late_alloc: %true if allocated using the page allocator. > + * @nareas: Number of areas in the pool. > + * @area_nslabs: Number of slots in each area. > + * @areas: Array of memory area descriptors. > + * @slots: Array of slot descriptors. > + */ > +struct io_tlb_pool { > + phys_addr_t start; > + phys_addr_t end; > + void *vaddr; > + unsigned long nslabs; > + unsigned long used; Oops. This member should not be re-introduced here after I removed it with commit efa76afdde16... I'm going to fix this in a v5, but I don't think it's critical enough to make an immediate resend. Petr T