From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33ABEC433ED for ; Tue, 11 May 2021 16:43:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B653961182 for ; Tue, 11 May 2021 16:43:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B653961182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125821.236850 (Exim 4.92) (envelope-from ) id 1lgVTC-00022C-SA; Tue, 11 May 2021 16:42:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125821.236850; Tue, 11 May 2021 16:42:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgVTC-000225-P4; Tue, 11 May 2021 16:42:54 +0000 Received: by outflank-mailman (input) for mailman id 125821; Tue, 11 May 2021 16:42:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgVTB-0001hY-GC for xen-devel@lists.xenproject.org; Tue, 11 May 2021 16:42:53 +0000 Received: from mail-il1-x12e.google.com (unknown [2607:f8b0:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 050f473c-5752-4b4d-a2bb-9a2dbe2cde7b; Tue, 11 May 2021 16:42:52 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id w13so5561926ilv.11 for ; Tue, 11 May 2021 09:42:52 -0700 (PDT) Received: from mail-io1-f44.google.com (mail-io1-f44.google.com. [209.85.166.44]) by smtp.gmail.com with ESMTPSA id h14sm9744499ils.13.2021.05.11.09.42.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 May 2021 09:42:51 -0700 (PDT) Received: by mail-io1-f44.google.com with SMTP id z24so18806291ioj.7 for ; Tue, 11 May 2021 09:42:50 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 050f473c-5752-4b4d-a2bb-9a2dbe2cde7b 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=Ll12iwWOH+g7rF+Qcvmc/ZPVWK50RY5A+TnwOnViek8=; b=jF9yywweDau5byF0sr7SVkFA9hoYDaWzF8iy+wyA9wHf9oOaCvA+67rLL4jVjSY9gn QoY25mdgO7IV1eEXpAEk5s63+vTygeFS39HRXfLrmhNXD74fIDm9qeLodCWWHbiJG3ic G2KrYNbeLupAhGANRLweLDvdOuGV9VrSQUJi8= 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=Ll12iwWOH+g7rF+Qcvmc/ZPVWK50RY5A+TnwOnViek8=; b=sKPwvuxVX4eKie7Ocggs0RJvxLIz2PXwrJWaMU5KGxJS4Y45Flh4gqgAEX8wahj+u4 Bi9JCxVOWHBynAbLtCGRhnoERXSjhzzr5kDsygcltGoj0j1BXGExCA14HkesIr2WK4A0 Kkbknk7IuoYrlBG3Bm7olKRiG0JpVEuGoQx2KV2gxsCgVjgBOzQ0DgrHoKcVUklsgi/B APxy4MxD1H3dyfv4k0d3GYxRlsDRnxITvwBTcORZa43ktOVpZbkFZ6TrQNZsyWkjQUK8 ul0VUTQSdXDozz4kUfP8zyHWvZ/wkfyHQ+jZNhkNdgayLcmrGO2/mGKI1B+MlT/ri3Us Jsjw== X-Gm-Message-State: AOAM533LZHjmtfxtaHSz/NN8KVatpRqfaRC8/dDiP2bMJWAjQPONikfj s2K5iRYg3x5ZRFAO+BKRU2PnCHxRhK6klQ== X-Google-Smtp-Source: ABdhPJyX5PM2ls3gC0Yqw37UDScBGrMqLOzONvLWeu4F5s1UFJw36+Tem/TNHfJ5s/PH6W2P0pfRAA== X-Received: by 2002:a92:650d:: with SMTP id z13mr12888687ilb.193.1620751371621; Tue, 11 May 2021 09:42:51 -0700 (PDT) X-Received: by 2002:a05:6e02:e82:: with SMTP id t2mr17831684ilj.18.1620751359226; Tue, 11 May 2021 09:42:39 -0700 (PDT) MIME-Version: 1.0 References: <20210510095026.3477496-1-tientzu@chromium.org> <20210510095026.3477496-5-tientzu@chromium.org> <20210510150256.GC28066@lst.de> In-Reply-To: <20210510150256.GC28066@lst.de> From: Claire Chang Date: Wed, 12 May 2021 00:42:28 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 04/15] swiotlb: Add restricted DMA pool initialization To: Christoph Hellwig Cc: Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , sstabellini@kernel.org, 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" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , Tomasz Figa , bskeggs@redhat.com, Bjorn Helgaas , chris@chris-wilson.co.uk, Daniel Vetter , airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, Jianxiong Gao , joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, nouveau@lists.freedesktop.org, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Content-Type: text/plain; charset="UTF-8" On Mon, May 10, 2021 at 11:03 PM Christoph Hellwig wrote: > > > +#ifdef CONFIG_DMA_RESTRICTED_POOL > > +#include > > +#include > > +#include > > +#include > > +#include > > +#endif > > I don't think any of this belongs into swiotlb.c. Marking > swiotlb_init_io_tlb_mem non-static and having all this code in a separate > file is probably a better idea. Will do in the next version. > > > +#ifdef CONFIG_DMA_RESTRICTED_POOL > > +static int rmem_swiotlb_device_init(struct reserved_mem *rmem, > > + struct device *dev) > > +{ > > + struct io_tlb_mem *mem = rmem->priv; > > + unsigned long nslabs = rmem->size >> IO_TLB_SHIFT; > > + > > + if (dev->dma_io_tlb_mem) > > + return 0; > > + > > + /* 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 not the normal kernel comment style. Will fix this in the next version. > > > +#ifdef CONFIG_ARM > > + if (!PageHighMem(pfn_to_page(PHYS_PFN(rmem->base)))) { > > + kfree(mem); > > + return -EINVAL; > > + } > > +#endif /* CONFIG_ARM */ > > And this is weird. Why would ARM have such a restriction? And if we have > such rstrictions it absolutely belongs into an arch helper. Now I think the CONFIG_ARM can just be removed? The goal here is to make sure we're using linear map and can safely use phys_to_dma/dma_to_phys. > > > + swiotlb_init_io_tlb_mem(mem, rmem->base, nslabs, false); > > + > > + rmem->priv = mem; > > + > > +#ifdef CONFIG_DEBUG_FS > > + if (!debugfs_dir) > > + debugfs_dir = debugfs_create_dir("swiotlb", NULL); > > + > > + swiotlb_create_debugfs(mem, rmem->name, debugfs_dir); > > Doesn't the debugfs_create_dir belong into swiotlb_create_debugfs? Also > please use IS_ENABLEd or a stub to avoid ifdefs like this. Will move it into swiotlb_create_debugfs and use IS_ENABLED in the next version.