From patchwork Thu Jul 10 06:52:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 33389 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56BE021140 for ; Thu, 10 Jul 2014 06:57:53 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id r10sf53306941pdi.2 for ; Wed, 09 Jul 2014 23:57:52 -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=0Nx18jcQyiZ5iMaFQQLnrWZ0eLqiZrsn+l7K9KyzIak=; b=U5r6V1hy9GxVqlfz3rYjHC4yba7qANpZ2zbCu7dXCNiT/rt9cj190repL/zkin3V38 WuXal8ZHbh9boYh6ROw1tpBkUxY7kNOGXVHRvN+yLwhtB2Zjgb4tviOOgWZ1tk+IgAKW 9L6oV74bZIN9uFbg9WxzzWZDomR9EOsCC36LMcnwetiT+vKIEBXWftdL1biKzPzvNPdp v+7rWwVWseltGelVamj5GoZkLn+AdcpDnstVikOFc/WokQqW5XeyuPhbLByQOHDVpEPG 2D8K47D8iHXteqzqXCaD6krjGUteH44ptuUdzFAWpzAmE5xeFjxRjUIrbwKMKnxxrPaz b7Uw== X-Gm-Message-State: ALoCoQnWt51WaGOhRZSiteLrAjWCyWGQqD+mehJ6eSFNR0emJsRhpC5edTYyNiBtLWJN/wv2PO/r X-Received: by 10.66.121.2 with SMTP id lg2mr11859731pab.43.1404975472640; Wed, 09 Jul 2014 23:57:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.132 with SMTP id 4ls1883493qgj.12.gmail; Wed, 09 Jul 2014 23:57:52 -0700 (PDT) X-Received: by 10.52.228.163 with SMTP id sj3mr36007974vdc.30.1404975472527; Wed, 09 Jul 2014 23:57:52 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id we6si22543992vdb.88.2014.07.09.23.57.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 23:57:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hy10so9772029vcb.3 for ; Wed, 09 Jul 2014 23:57:52 -0700 (PDT) X-Received: by 10.53.7.204 with SMTP id de12mr5157098vdd.41.1404975472445; Wed, 09 Jul 2014 23:57:52 -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 tc5csp109654vcb; Wed, 9 Jul 2014 23:57:52 -0700 (PDT) X-Received: by 10.66.142.42 with SMTP id rt10mr45537057pab.1.1404975471251; Wed, 09 Jul 2014 23:57:51 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qc2si8236284pdb.178.2014.07.09.23.57.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 23:57:51 -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 1X58HP-0003rE-Sb; Thu, 10 Jul 2014 06:56:31 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X58G9-0001gu-GN for linux-arm-kernel@lists.infradead.org; Thu, 10 Jul 2014 06:55:15 +0000 Received: from 172.24.2.119 (EHLO szxeml451-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BWM48163; Thu, 10 Jul 2014 14:54:25 +0800 (CST) Received: from localhost (10.177.27.142) by szxeml451-hub.china.huawei.com (10.82.67.194) with Microsoft SMTP Server id 14.3.158.1; Thu, 10 Jul 2014 14:54:17 +0800 From: Zhen Lei To: Catalin Marinas , Will Deacon , linux-arm-kernel Subject: [PATCH v3 06/13] iommu/arm: Split arm_smmu_destroy_domain_context to reuse code Date: Thu, 10 Jul 2014 14:52:59 +0800 Message-ID: <1404975186-12032-7-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_235513_976575_FF31A383 X-CRM114-Status: GOOD ( 13.01 ) 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.65 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 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.172 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 Free IRQ and context bank is a common operation, should be shared by all SMMUs. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-base.c | 20 ++++++++++++++++++++ drivers/iommu/arm-smmu.c | 15 ++------------- drivers/iommu/arm-smmu.h | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) -- 1.8.0 diff --git a/drivers/iommu/arm-smmu-base.c b/drivers/iommu/arm-smmu-base.c index 0b02da8..4d1c511 100644 --- a/drivers/iommu/arm-smmu-base.c +++ b/drivers/iommu/arm-smmu-base.c @@ -282,6 +282,26 @@ out_free_context: return ret; } +static void arm_smmu_destroy_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 = root_cfg->smmu; + int irq; + + if (!smmu) + return; + + smmu->hwdep_ops->destroy_context_bank(smmu_domain); + + if (root_cfg->irptndx != INVALID_IRPTNDX) { + irq = smmu->irqs[smmu->num_global_irqs + root_cfg->irptndx]; + free_irq(irq, domain); + } + + __arm_smmu_free_bitmap(smmu->context_map, root_cfg->cbndx); +} + static int arm_smmu_domain_init(struct iommu_domain *domain) { struct arm_smmu_domain *smmu_domain; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index b9538f6..d2fc14c 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -498,28 +498,16 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain) writel_relaxed(reg, cb_base + ARM_SMMU_CB_SCTLR); } -void arm_smmu_destroy_domain_context(struct iommu_domain *domain) +static void arm_smmu_destroy_context_bank(struct arm_smmu_domain *smmu_domain) { - struct arm_smmu_domain *smmu_domain = domain->priv; struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg; struct arm_smmu_device *smmu = root_cfg->smmu; void __iomem *cb_base; - int irq; - - if (!smmu) - return; /* Disable the context bank and nuke the TLB before freeing it. */ cb_base = ARM_SMMU_CB_BASE(smmu) + ARM_SMMU_CB(smmu, root_cfg->cbndx); writel_relaxed(0, cb_base + ARM_SMMU_CB_SCTLR); arm_smmu_tlb_inv_context(root_cfg); - - if (root_cfg->irptndx != INVALID_IRPTNDX) { - irq = smmu->irqs[smmu->num_global_irqs + root_cfg->irptndx]; - free_irq(irq, domain); - } - - __arm_smmu_free_bitmap(smmu->context_map, root_cfg->cbndx); } static int arm_smmu_master_configure_smrs(struct arm_smmu_device *smmu, @@ -885,6 +873,7 @@ static struct smmu_hwdep_ops arm_smmu_hwdep_ops = { .context_fault = arm_smmu_context_fault, .global_fault = arm_smmu_global_fault, .init_context_bank = arm_smmu_init_context_bank, + .destroy_context_bank = arm_smmu_destroy_context_bank, .domain_add_master = arm_smmu_domain_add_master, .domain_remove_master = arm_smmu_domain_remove_master, .device_reset = arm_smmu_device_reset, diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index d66a8c4..190f77c 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -213,6 +213,7 @@ struct arm_smmu_domain { * @context_fault: context fault handler * @global_fault: global fault handler * @init_context_bank: init a context bank + * @destroy_context_bank: disable a context bank and invalid the TLBs * @domain_add_master: add a master into a domain * @domain_remove_master: remove a master from a domain * @device_reset: initialize a smmu @@ -224,6 +225,7 @@ struct smmu_hwdep_ops { irqreturn_t (*context_fault)(int irq, void *dev); irqreturn_t (*global_fault)(int irq, void *dev); void (*init_context_bank)(struct arm_smmu_domain *smmu_domain); + void (*destroy_context_bank)(struct arm_smmu_domain *smmu_domain); int (*domain_add_master)(struct arm_smmu_domain *smmu_domain, struct arm_smmu_master *master); void (*domain_remove_master)(struct arm_smmu_domain *smmu_domain, @@ -242,6 +244,5 @@ extern int arm_smmu_device_dt_probe(struct platform_device *pdev, struct smmu_hwdep_ops *ops); extern int arm_smmu_device_remove(struct platform_device *pdev); -extern void arm_smmu_destroy_domain_context(struct iommu_domain *domain); extern int __init arm_smmu_ops_init(void); #endif