From patchwork Thu Jul 10 06:53:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 4521091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 008B79F26C for ; Thu, 10 Jul 2014 06:57:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65AA9202FF for ; Thu, 10 Jul 2014 06:57:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 819CE2024C for ; Thu, 10 Jul 2014 06:57:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X58GH-0002sz-7H; Thu, 10 Jul 2014 06:55:21 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X58G6-0001h7-6I for linux-arm-kernel@lists.infradead.org; Thu, 10 Jul 2014 06:55:11 +0000 Received: from 172.24.2.119 (EHLO szxeml406-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ARL48891; Thu, 10 Jul 2014 14:54:28 +0800 (CST) Received: from localhost (10.177.27.142) by szxeml406-hub.china.huawei.com (10.82.67.93) with Microsoft SMTP Server id 14.3.158.1; Thu, 10 Jul 2014 14:54:19 +0800 From: Zhen Lei To: Catalin Marinas , Will Deacon , linux-arm-kernel Subject: [PATCH v3 08/13] iommu/arm: Add hook alloc_context Date: Thu, 10 Jul 2014 14:53:01 +0800 Message-ID: <1404975186-12032-9-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.8.4.msysgit.0 In-Reply-To: <1404975186-12032-1-git-send-email-thunder.leizhen@huawei.com> References: <1404975186-12032-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.27.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.53BE38A5.0034,ss=1,re=0.000,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2011-05-27 18:58:46 X-Mirapoint-Loop-Id: f44b584b550c2ba01d04bc864ee6eb3f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_235510_646277_4399C2F8 X-CRM114-Status: GOOD ( 12.18 ) X-Spam-Score: -1.4 (-) Cc: Zhen Lei X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some SMMUs(like hisi-smmu and SMMUv3), a given StreamID is bound to a fixed context bank. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-base.c | 8 +++++--- drivers/iommu/arm-smmu.c | 8 ++++++++ drivers/iommu/arm-smmu.h | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) -- 1.8.0 diff --git a/drivers/iommu/arm-smmu-base.c b/drivers/iommu/arm-smmu-base.c index 53f7907..be73eba 100644 --- a/drivers/iommu/arm-smmu-base.c +++ b/drivers/iommu/arm-smmu-base.c @@ -231,6 +231,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, struct arm_smmu_domain *smmu_domain = domain->priv; struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg; struct arm_smmu_device *smmu, *parent; + struct arm_smmu_master *master; /* * Walk the SMMU chain to find the root device for this chain. @@ -245,7 +246,8 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, smmu_domain->output_mask &= (1ULL << smmu->s2_output_size) - 1; } while ((parent = find_parent_smmu(smmu))); - if (!find_smmu_master(smmu, dev->of_node)) { + master = find_smmu_master(smmu, dev->of_node); + if (!master) { dev_err(dev, "unable to find root SMMU for device\n"); return -ENODEV; } @@ -265,8 +267,8 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, start = smmu->num_s2_context_banks; } - ret = __arm_smmu_alloc_bitmap(smmu->context_map, start, - smmu->num_context_banks); + ret = smmu->hwdep_ops->alloc_context(smmu, start, + smmu->num_context_banks, master); if (IS_ERR_VALUE(ret)) return ret; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index fa65c7c..dbd9c60 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -223,6 +223,13 @@ #define FSYNR0_WNR (1 << 4) + +static int arm_smmu_alloc_context(struct arm_smmu_device *smmu, + int start, int end, struct arm_smmu_master *master) +{ + return __arm_smmu_alloc_bitmap(smmu->context_map, start, end); +} + static int arm_smmu_tlb_sync_finished(struct arm_smmu_device *smmu) { u32 reg; @@ -869,6 +876,7 @@ static int arm_smmu_device_unload(struct arm_smmu_device *smmu) } static struct smmu_hwdep_ops arm_smmu_hwdep_ops = { + .alloc_context = arm_smmu_alloc_context, .tlb_sync_finished = arm_smmu_tlb_sync_finished, .tlb_inv_context = arm_smmu_tlb_inv_context, .context_fault = arm_smmu_context_fault, diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index 8332ff0..f7346d89 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -209,6 +209,7 @@ struct arm_smmu_domain { /** * struct smmu_hwdep_ops - smmu hardware dependent ops + * @alloc_context: alloc a free context bank * @tlb_sync_finished: check whether tlb sync operation is finished * @tlb_inv_context: invalid smmu context bank tlb * @context_fault: context fault handler @@ -222,6 +223,8 @@ struct arm_smmu_domain { * @device_remove: turn off a smmu and reclaim associated resources */ struct smmu_hwdep_ops { + int (*alloc_context)(struct arm_smmu_device *smmu, + int start, int end, struct arm_smmu_master *master); int (*tlb_sync_finished)(struct arm_smmu_device *smmu); void (*tlb_inv_context)(struct arm_smmu_cfg *cfg); irqreturn_t (*context_fault)(int irq, void *dev);