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.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 8838FC33CB1 for ; Tue, 14 Jan 2020 11:56:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B6E02467A for ; Tue, 14 Jan 2020 11:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579002985; bh=ahbXe4hwMQQLlrN5u66UYJDrMHT3NIY/p5dKKof/mlc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=GWKPg5zjX0mZTsKY4gh0Y4vSuqXFt2R0awJBMrLIxY5gOp+0ce4qfO7KKcNyHW7Pe HSCrRP3W7tV6KiNBYDFFLYOV7YYK4EySMztnfxyfLiLUXcQ6JDdp9TllhjBw0P+3aM UWg3CvwSEyYVYLD1qxJBsg7Xuhu3Ug+OBRJRowbg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729074AbgANL4S (ORCPT ); Tue, 14 Jan 2020 06:56:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:59540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728826AbgANL4S (ORCPT ); Tue, 14 Jan 2020 06:56:18 -0500 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 Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org, joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, robin.murphy@arm.com, bhelgaas@google.com, eric.auger@redhat.com, jonathan.cameron@huawei.com, zhangfei.gao@linaro.org 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200114115230.GA1799@myrica> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 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 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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 D3878C33CB6 for ; Tue, 14 Jan 2020 11:56:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 90CC424672 for ; Tue, 14 Jan 2020 11:56:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hnwfphNY"; 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 90CC424672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sF48klfq0UyOPi8XsfavwPhmYkpOC2OEWprAxSh6NDM=; b=hnwfphNYTCAeHj 9Z1PbtAfzT4nEYh2ubtk5CZdCCGlsfMIA1jIHF+ahVWoynhZmjb+CbkwURdKBVZiBK9crhxKK6B3O BXBv6XfMPHeSm5B+e2/bea6nUBaHyKZ9f7yNUKRxssfxNiqWK8BHcLRgaEEdpMcowHTWb5jN0Px6l Hnj7H2ypEzVJ+GkEnaG3tYH/zxVZARJtbxCcUOjSPpHdpKv/Opj/3Vu7m/pM0NTEbdjiy+e0+gvEF j0ClDMUKO8Nj41XFmpR6SBi39U1DNaKBFMM2LFmngCpQFJlpUpGlGUQdONE+C+m21qrTNOnzKVpqY eYbjKC5mLNZtNW47ysWw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1irKo1-00025F-LC; Tue, 14 Jan 2020 11:56:21 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irKny-00024N-D7 for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2020 11:56:19 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200114_035618_466456_19748DF6 X-CRM114-Status: GOOD ( 15.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com, eric.auger@redhat.com, linux-pci@vger.kernel.org, joro@8bytes.org, sudeep.holla@arm.com, rjw@rjwysocki.net, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, jonathan.cameron@huawei.com, guohanjun@huawei.com, bhelgaas@google.com, zhangfei.gao@linaro.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, lenb@kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel