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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 23502C433E2 for ; Tue, 8 Sep 2020 18:43:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 C3F5D2080A for ; Tue, 8 Sep 2020 18:43:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EM5KUnQz"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="B9EQ36+Q"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="g3OqEzME" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3F5D2080A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.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=r8+4A9VYV2tcb3bV8c+InmjCfcKJWiYCJhlZ0XVsGIA=; b=EM5KUnQztD4SeMD0va3qBb+JC 2r4lMk6xLIP3pJLbTV5NgsvC4m+NMm3o9Qscz999pZaxL/qRwJIC0qJ9XJXCQBXCYMFUabmtFqPeH 1LbxCFPKo8kb9i2DM8SfdsZ6dSZl/mVf2t4dRaZLHIi5z7MLKO+ztQzOGJ2cFyJZZUSmtMm0G60wQ KRzC/p2D46OQnFmSqcu4HqM34Eg06OVwZRl5Agl+jSFQwWj79uqmsxXOz53lySm/B3cGcRH//VQTM S5BWsGjBXQVB3XRu6JQ2VEjMUXmJfsdKwyHECIxh0iNXoKZpnLByncjRKo8U5hVLihnMPjB0xt3fP AzzI90J8A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFiZJ-0007JU-I8; Tue, 08 Sep 2020 18:42:13 +0000 Received: from a27-10.smtp-out.us-west-2.amazonses.com ([54.240.27.10]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFiZG-0007IS-7t for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 18:42:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1599590526; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:In-Reply-To; bh=EiaJlKj7Ne8nGiRMenHLunM8+6hemqqH4NYaF6fj2gk=; b=B9EQ36+Q8prW+zIOzt153YGeFjA2Pc+diSCtuUqBR9TK3VlQzBYdPcI7OKwhh/Y3 L/DL3IpIm8zFJIkfUzmiDNRwk4bD+8S/8JMID75OBB+KTIUxc3BztJX678o2Xm/1Cvc pIWcG5k21hMnsZl7FsDXc5Cb3Xy5wtnhDIePxSI4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=hsbnp7p3ensaochzwyq5wwmceodymuwv; d=amazonses.com; t=1599590526; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:In-Reply-To:Feedback-ID; bh=EiaJlKj7Ne8nGiRMenHLunM8+6hemqqH4NYaF6fj2gk=; b=g3OqEzMEVxfe/OSzRqF3HuS/9bd3BH2aGVIpQVhAhrD1Qq6anv7vHGy0K3Utw99W 6rnlpGlqSG0XMS/IuO+eC7uZPZYurqb5H7gSnoXbY4z3YoNm4y9dgaszpJHACU8+VoW IeW0HoiZr+hiAifZ4L9JbB37swAIHcpO5nYY5NPs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0B5B5C433FE Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=jcrouse@codeaurora.org Date: Tue, 8 Sep 2020 18:42:06 +0000 From: Jordan Crouse To: Bjorn Andersson Subject: Re: [PATCH v3 1/8] iommu/arm-smmu: Refactor context bank allocation Message-ID: <010101746f066e36-69348f3b-cfa0-4307-83b3-f369df541c55-000000@us-west-2.amazonses.com> Mail-Followup-To: Bjorn Andersson , Will Deacon , Robin Murphy , Joerg Roedel , Sai Prakash Ranjan , Rob Clark , Sibi Sankar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-2-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200904155513.282067-2-bjorn.andersson@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SES-Outgoing: 2020.09.08-54.240.27.10 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_144210_699439_92B65113 X-CRM114-Status: GOOD ( 26.13 ) 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: Rob Clark , Sai Prakash Ranjan , Will Deacon , Joerg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Sibi Sankar , linux-arm-msm@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 04, 2020 at 03:55:06PM +0000, Bjorn Andersson wrote: > Extract the conditional invocation of the platform defined > alloc_context_bank() to a separate function to keep > arm_smmu_init_domain_context() cleaner. > > Instead pass a reference to the arm_smmu_device as parameter to the > call. Also remove the count parameter, as this can be read from the > newly passed object. > > This allows us to not assign smmu_domain->smmu before attempting to > allocate the context bank and as such we don't need to roll back this > assignment on failure. Much nicer. Reviewed-by: Jordan Crouse > Signed-off-by: Bjorn Andersson > --- > > Note that this series applies ontop of: > https://lore.kernel.org/linux-arm-msm/20200901164707.2645413-1-robdclark@gmail.com/ > > This could either go on its own, or be squashed with "[PATCH v16 14/20] > iommu/arm-smmu: Prepare for the adreno-smmu implementation" from Rob's series. > > Changes since v2: > - New patch > > drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 6 ++++-- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 23 ++++++++++++---------- > drivers/iommu/arm/arm-smmu/arm-smmu.h | 3 ++- > 3 files changed, 19 insertions(+), 13 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > index 2aa6249050ff..0663d7d26908 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > @@ -91,9 +91,10 @@ static int qcom_adreno_smmu_set_ttbr0_cfg(const void *cookie, > } > > static int qcom_adreno_smmu_alloc_context_bank(struct arm_smmu_domain *smmu_domain, > - struct device *dev, int start, int count) > + struct arm_smmu_device *smmu, > + struct device *dev, int start) > { > - struct arm_smmu_device *smmu = smmu_domain->smmu; > + int count; > > /* > * Assign context bank 0 to the GPU device so the GPU hardware can > @@ -104,6 +105,7 @@ static int qcom_adreno_smmu_alloc_context_bank(struct arm_smmu_domain *smmu_doma > count = 1; > } else { > start = 1; > + count = smmu->num_context_banks; > } > > return __arm_smmu_alloc_bitmap(smmu->context_map, start, count); > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index bbec5793faf8..e19d7bdc7674 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -623,6 +623,16 @@ void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx) > arm_smmu_cb_write(smmu, idx, ARM_SMMU_CB_SCTLR, reg); > } > > +static int arm_smmu_alloc_context_bank(struct arm_smmu_domain *smmu_domain, > + struct arm_smmu_device *smmu, > + struct device *dev, unsigned int start) > +{ > + if (smmu->impl && smmu->impl->alloc_context_bank) > + return smmu->impl->alloc_context_bank(smmu_domain, smmu, dev, start); > + > + return __arm_smmu_alloc_bitmap(smmu->context_map, start, smmu->num_context_banks); > +} > + > static int arm_smmu_init_domain_context(struct iommu_domain *domain, > struct arm_smmu_device *smmu, > struct device *dev) > @@ -741,20 +751,13 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, > goto out_unlock; > } > > - smmu_domain->smmu = smmu; > - > - if (smmu->impl && smmu->impl->alloc_context_bank) > - ret = smmu->impl->alloc_context_bank(smmu_domain, dev, > - start, smmu->num_context_banks); > - else > - ret = __arm_smmu_alloc_bitmap(smmu->context_map, start, > - smmu->num_context_banks); > - > + ret = arm_smmu_alloc_context_bank(smmu_domain, smmu, dev, start); > if (ret < 0) { > - smmu_domain->smmu = NULL; > goto out_unlock; > } > > + smmu_domain->smmu = smmu; > + > cfg->cbndx = ret; > if (smmu->version < ARM_SMMU_V2) { > cfg->irptndx = atomic_inc_return(&smmu->irptndx); > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index 2df3a70a8a41..ddf2ca4c923d 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -437,7 +437,8 @@ struct arm_smmu_impl { > irqreturn_t (*global_fault)(int irq, void *dev); > irqreturn_t (*context_fault)(int irq, void *dev); > int (*alloc_context_bank)(struct arm_smmu_domain *smmu_domain, > - struct device *dev, int start, int max); > + struct arm_smmu_device *smmu, > + struct device *dev, int start); > }; > > #define INVALID_SMENDX -1 > -- > 2.28.0 > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel