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: 33381 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E5D5821140 for ; Thu, 10 Jul 2014 06:57:04 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id s7sf8316262qap.3 for ; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=XQTl3juxlsmtSr5YePxMg5U0zWGfd8jVG89i6DofYRE=; b=F6KURJTYIjy9jQJMtaOU5w+fTQUBBCyYzZVxTNIFHPRXgaBNETcpmN0ab6V+QAWlF4 6znCM8dtQ3c1a4dJ+o0+JqTUFynGFkTwk3WstIndiSaVHgHOkpJn4uMDhmEeVJTYF0Kp NQBxuFUrSErJxi1Ez1UAGz36FrR0cGkVhppXBDkOPN/FlxF6XjDA1TcGP3xC04ACzNWy MreMzy3dmma1AQJgrH+3o5sP1UNVp8fOPgrGEYJ/K+Pb5JwEg2q7IsMOtcqZboCXt//p AJxGLpi7kG9ZK7gQjEzgXZRJpXru1Fq9rb4mUWtepdPsZ3nomHahWkCaZSPRDU6h4RrD 4vGQ== X-Gm-Message-State: ALoCoQlP1ATaEQgJ8vQzsEOhj6dP9BRGmp8gRu9NmDxvlzCfbgQtv2oQ0pg6Vw0kSrIp6bmUMRnW X-Received: by 10.236.98.33 with SMTP id u21mr19019434yhf.39.1404975424708; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.46.99 with SMTP id j90ls2828056qga.49.gmail; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-Received: by 10.52.116.194 with SMTP id jy2mr5480634vdb.39.1404975424626; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id hw3si2397053vdb.67.2014.07.09.23.57.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 23:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id im17so9753978vcb.11 for ; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-Received: by 10.220.203.134 with SMTP id fi6mr43661526vcb.18.1404975424559; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp109608vcb; Wed, 9 Jul 2014 23:57:04 -0700 (PDT) X-Received: by 10.68.171.131 with SMTP id au3mr1713975pbc.125.1404975423461; Wed, 09 Jul 2014 23:57:03 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id bz5si8236657pdb.501.2014.07.09.23.57.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 23:57:03 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [119.145.14.66 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [119.145.14.66 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: thunder.leizhen@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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);