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=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 8CEDAC47409 for ; Tue, 14 Jan 2020 11:56:25 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 59D2524672 for ; Tue, 14 Jan 2020 11:56:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="OZd5ICnc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59D2524672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2C89020464; Tue, 14 Jan 2020 11:56:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1HQ7FF1dqWsn; Tue, 14 Jan 2020 11:56:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id C87E0203C7; Tue, 14 Jan 2020 11:56:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 93143C18DD; Tue, 14 Jan 2020 11:56:20 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E893AC077D for ; Tue, 14 Jan 2020 11:56:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D6218203F0 for ; Tue, 14 Jan 2020 11:56:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DPgRijH30HCa for ; Tue, 14 Jan 2020 11:56:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by silver.osuosl.org (Postfix) with ESMTPS id D30A2203C7 for ; Tue, 14 Jan 2020 11:56:17 +0000 (UTC) Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2B6424672; Tue, 14 Jan 2020 11:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579002977; bh=ahbXe4hwMQQLlrN5u66UYJDrMHT3NIY/p5dKKof/mlc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OZd5ICnclBnHLWVfm9YUQb5LWnL7oJhvwxZkC88/Qfz/xVf7KUgZ8/ayoCIO7ZVY4 kzZacU3EMKl9p71FFs2ixfivPi6PsnxWs/K7aKsLkECRQmsPqQyhhtdDdv7bv1Inov /MVYLw34ynCIxhIjPlRlKlOz7eRnPqLnOObYNQdM= Date: Tue, 14 Jan 2020 11:56:11 +0000 From: Will Deacon To: Jean-Philippe Brucker Subject: Re: [PATCH v4 06/13] iommu/arm-smmu-v3: Add context descriptor tables allocators Message-ID: <20200114115611.GB29222@willie-the-truck> References: <20191219163033.2608177-1-jean-philippe@linaro.org> <20191219163033.2608177-7-jean-philippe@linaro.org> <20200114110651.GA29222@willie-the-truck> <20200114115230.GA1799@myrica> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200114115230.GA1799@myrica> User-Agent: Mutt/1.10.1 (2018-07-13) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, guohanjun@huawei.com, bhelgaas@google.com, zhangfei.gao@linaro.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, lenb@kernel.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Tue, Jan 14, 2020 at 12:52:30PM +0100, Jean-Philippe Brucker wrote: > On Tue, Jan 14, 2020 at 11:06:52AM +0000, Will Deacon wrote: > > > /* Context descriptor manipulation functions */ > > > +static int arm_smmu_alloc_cd_leaf_table(struct arm_smmu_device *smmu, > > > + struct arm_smmu_cd_table *table, > > > + size_t num_entries) > > > +{ > > > + size_t size = num_entries * (CTXDESC_CD_DWORDS << 3); > > > + > > > + table->ptr = dmam_alloc_coherent(smmu->dev, size, &table->ptr_dma, > > > + GFP_KERNEL); > > > + if (!table->ptr) { > > > + dev_warn(smmu->dev, > > > + "failed to allocate context descriptor table\n"); > > > + return -ENOMEM; > > > + } > > > + return 0; > > > +} > > > + > > > +static void arm_smmu_free_cd_leaf_table(struct arm_smmu_device *smmu, > > > + struct arm_smmu_cd_table *table, > > > + size_t num_entries) > > > +{ > > > + size_t size = num_entries * (CTXDESC_CD_DWORDS << 3); > > > + > > > + dmam_free_coherent(smmu->dev, size, table->ptr, table->ptr_dma); > > > +} > > > > I think we'd be better off taking the 'arm_smmu_s1_cfg' as a parameter here > > instead of the table pointer and a num_entries value, since the code above > > implies that we support partial freeing of the context descriptors. > > > > I can do that as a follow-up patch if you agree. Thoughts? > > Do you mean only changing the arguments of arm_smmu_free_cd_leaf_table(), > or arm_smmu_alloc_cd_leaf_table() as well? For free() I agree, for alloc() > I'm not sure it would look better. Yeah, just for free(). I'll spin something on top after I've finished reviewing the series. > For my tests I have a debug patch that allocates PASIDs randomly which > quickly consumes DMA for leaf tables. So I do have to free the leaves > individually when they aren't used, but it will be easy for me to update. Cool. Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu