Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp118808pxb; Thu, 14 Jan 2021 01:14:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzO00olHTmqce4JvH/Mbi9Y9LMxagfC37HBWq8jSJyiNa8jKkPUmJuEyGWyR+IJpZYU1/jC X-Received: by 2002:a17:906:cec7:: with SMTP id si7mr4437931ejb.123.1610615694132; Thu, 14 Jan 2021 01:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610615694; cv=none; d=google.com; s=arc-20160816; b=lL0sAlbWYtDl+aoL7iWCUPzPcWUg94u9TTnLQQemRajyw+RSZU+lKcBxTFEX2Xof9E VU5erRmiAJ4McFYuYMjwV2nagUuDRPHDqAn21tIjx3guMPltUB27gwmYRs9oCFAKx+Fp tpFAxTAM47oQzHoeGXUjVaJGwyc+eEdrvg5zC/uZLXdaDyJBO9wYAWPQ+siEJwi0ToGd X65Ow1iSSF0KySZzEVZdT5HgokvgkGv8nxoN5riJUkb7K3C/eItYnBU30nQzt7oa++lm +ZVfNkP3wtxHw4FeH8Q7w5+94xWGw2NZJGak8QOy0fElQ+xuA2V31KjVsVAi4+HXbtyn sDOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=r2clGFKfMvWdEL24a/hrPW/SoKgcT/5YZOK8G2tupLA=; b=etdj+xrdNnBtroaGxHW9ZRqLoDEy3a8ID5206i5IPeW5ocW1+SDTAw9eRjGP4oNtPu PrpLYY6I6ceQPgcP6OuuW+sRovKmTob5Th25C8eFQXCf32IshG3dOP3K84ba6eukTcD+ 07UGtnCzy+TYEjUTTab+gmJ7AaB+nnPjMg97QQYZPH3U/zi8XCEH0Gjx3/UDp1GW1BBq pVpR4PEHSkx13H1VwfgSo3aWJ6NQ72Drr0XeB7AGs8YR6UAndCr0075VcBrc6laliXF3 SPRwUvsTjL9DsRI6LAxZ9oaFFX8sZ6JK503K2xxD079uXss8tnc36bzqmssLFKVMmmBz BxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X7SGbsqs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by27si2292616edb.276.2021.01.14.01.14.31; Thu, 14 Jan 2021 01:14:54 -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; dkim=pass header.i=@chromium.org header.s=google header.b=X7SGbsqs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727971AbhANJNB (ORCPT + 99 others); Thu, 14 Jan 2021 04:13:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbhANJM7 (ORCPT ); Thu, 14 Jan 2021 04:12:59 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F35C061575 for ; Thu, 14 Jan 2021 01:12:13 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id s15so2593091plr.9 for ; Thu, 14 Jan 2021 01:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r2clGFKfMvWdEL24a/hrPW/SoKgcT/5YZOK8G2tupLA=; b=X7SGbsqsGRlUtP0PJCg54RJ4TAlmaAHUG3xPdqjVb0oScLVfStGatbndpS03GsNgnP Ay7KF7sGV28MuK8UBUQD50tmV7MICCg9iHgn3dDmdiN2V0+w2jb02zv0Fvhtiq/Aou7X FWO4E0ky5/69bheieFiKWNwRnHzuorBEbyewE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r2clGFKfMvWdEL24a/hrPW/SoKgcT/5YZOK8G2tupLA=; b=s/DNt5FkjiRVYrToQuTXuhEL3tJ0tE8sazy25Ovn4qnfVaJ7TRcIpIZRtUcMfdF6t4 Vf7ZjYmdebUN5bHSalDkN1bE3h0LvmUzcy7nyo5WsVWLBYyCdeIzzec4R9mQIzMRLvqg H1krL34v/SYIVRw5eB1QziAzZvhwWhCR//QfXhCdGfkMdTPq8OZXCProDG8kjQtXkzhK cZ1XWiifpKTjeEJjRYw+FBsORmcEIgoxnRW8ZDGU3or0Ar1K6SSt6b8XmXc2cJHu5jp1 jF1s0Stm3H11kpCKz8ulVjJlh4lijV1FV2IIsLvtqkXAuttKuMLhkio0XhokhC+iC8UH 2nbA== X-Gm-Message-State: AOAM5315/071aHLI72LLDqPBqIJrQubyf/CavNDXbeoEtce1EI/lcXY8 hd48kN4FT3FbpV4wNTXbIQyHPaHSuNgAug== X-Received: by 2002:a17:902:ea0f:b029:de:5fd5:abb9 with SMTP id s15-20020a170902ea0fb02900de5fd5abb9mr1123175plg.46.1610615532762; Thu, 14 Jan 2021 01:12:12 -0800 (PST) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com. [209.85.215.170]) by smtp.gmail.com with ESMTPSA id q16sm4801579pfg.139.2021.01.14.01.12.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jan 2021 01:12:12 -0800 (PST) Received: by mail-pg1-f170.google.com with SMTP id n7so3369396pgg.2 for ; Thu, 14 Jan 2021 01:12:12 -0800 (PST) X-Received: by 2002:a92:ce8f:: with SMTP id r15mr4926327ilo.303.1610615178346; Thu, 14 Jan 2021 01:06:18 -0800 (PST) MIME-Version: 1.0 References: <20210106034124.30560-1-tientzu@chromium.org> <20210106034124.30560-3-tientzu@chromium.org> <20210113124209.GA1383@lst.de> In-Reply-To: <20210113124209.GA1383@lst.de> From: Claire Chang Date: Thu, 14 Jan 2021 17:06:07 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v3 2/6] swiotlb: Add restricted DMA pool To: Christoph Hellwig Cc: Rob Herring , mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , will@kernel.org, Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, Marek Szyprowski , Robin Murphy , grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , rafael.j.wysocki@intel.com, heikki.krogerus@linux.intel.com, Andy Shevchenko , rdunlap@infradead.org, dan.j.williams@intel.com, Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , xen-devel@lists.xenproject.org, Tomasz Figa , Nicolas Boichat Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 8:42 PM Christoph Hellwig wrote: > > > +#ifdef CONFIG_SWIOTLB > > + struct io_tlb_mem *dma_io_tlb_mem; > > #endif > > Please add a new config option for this code instead of always building > it when swiotlb is enabled. > > > +static int swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start, > > + size_t size) > > Can you split the refactoring in swiotlb.c into one or more prep > patches? > > > +static int rmem_swiotlb_device_init(struct reserved_mem *rmem, > > + struct device *dev) > > +{ > > + struct io_tlb_mem *mem = rmem->priv; > > + int ret; > > + > > + if (dev->dma_io_tlb_mem) > > + return -EBUSY; > > + > > + if (!mem) { > > + mem = kzalloc(sizeof(*mem), GFP_KERNEL); > > + if (!mem) > > + return -ENOMEM; > > What is the calling convention here that allows for a NULL and non-NULL > private data? Since multiple devices can share the same pool, the private data, io_tlb_mem struct, will be initialized by the first device attached to it. This is similar to rmem_dma_device_init() in kernel/dma/coherent.c. I'll add a comment for it in next version.