From patchwork Thu Jul 10 06:53:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 4521141 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 C179B9F26C for ; Thu, 10 Jul 2014 06:58:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D78D72021B for ; Thu, 10 Jul 2014 06:57:59 +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 DF45B202FF for ; Thu, 10 Jul 2014 06:57:58 +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 1X58GA-0002qH-Ig; Thu, 10 Jul 2014 06:55:14 +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-0001h9-6O 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 ARL48892; 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 09/13] iommu/arm: Change context_map to dynamic memory allocation Date: Thu, 10 Jul 2014 14:53:02 +0800 Message-ID: <1404975186-12032-10-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.0A020209.53BE38A5.0071,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: 300f1c9a63a7702758a4322d1da1b72c X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_235510_620031_72AD1182 X-CRM114-Status: GOOD ( 11.70 ) 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), the number of context banks is more than 128. Static array size does not fit. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-base.c | 9 ++++++++- drivers/iommu/arm-smmu.h | 5 +---- 2 files changed, 9 insertions(+), 5 deletions(-) -- 1.8.0 diff --git a/drivers/iommu/arm-smmu-base.c b/drivers/iommu/arm-smmu-base.c index be73eba..400de39 100644 --- a/drivers/iommu/arm-smmu-base.c +++ b/drivers/iommu/arm-smmu-base.c @@ -947,6 +947,13 @@ int arm_smmu_device_dt_probe(struct platform_device *pdev, if (err) goto out_put_parent; + smmu->context_map = devm_kzalloc(dev, + BITS_TO_LONGS(smmu->num_context_banks), GFP_KERNEL); + if (!smmu->context_map) { + dev_err(dev, "failed to allocate context map\n"); + return -ENOMEM; + } + parse_driver_options(smmu); if (smmu->version > 1 && @@ -1029,7 +1036,7 @@ int arm_smmu_device_remove(struct platform_device *pdev) of_node_put(master->of_node); } - if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS)) + if (!bitmap_empty(smmu->context_map, smmu->num_context_banks)) dev_err(dev, "removing device with active domains!\n"); for (i = 0; i < smmu->num_global_irqs; ++i) diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index f7346d89..fff2b98 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -26,9 +26,6 @@ /* Maximum number of stream IDs assigned to a single device */ #define MAX_MASTER_STREAMIDS MAX_PHANDLE_ARGS -/* Maximum number of context banks per SMMU */ -#define ARM_SMMU_MAX_CBS 128 - /* Maximum number of mapping groups per SMMU */ #define ARM_SMMU_MAX_SMRS 128 @@ -164,7 +161,7 @@ struct arm_smmu_device { u32 num_context_banks; u32 num_s2_context_banks; - DECLARE_BITMAP(context_map, ARM_SMMU_MAX_CBS); + unsigned long *context_map; atomic_t irptndx; u32 num_mapping_groups;