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: 33380 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9723203C0 for ; Thu, 10 Jul 2014 06:57:04 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id l6sf6885935oag.11 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=ESUJykaW6PobJEnzshaEHcn1QRph53/2ZKyHhUBKh0o=; b=Yf0OSMvDiOH31OaCqJlMwA/+UG4UMmeDCu9GEkK53TKb60AA2exzrYv8vJ03pcvU17 k+qW/n32q/PpVhhsPYEHoaJQAnrN+GreUQ4kdw4L0DonDTWGrgSBlyesNw3xvBxT28s9 MIV/qZ1ss25loI+Z7Y2EO8/U8U6/UPN2qpgzgL9lQxa3imCtFXcXsXvcGKEiYBhoymZf zYGnz1z/t9yuQFvsJ/1PvhN+QuVTwAOUd6HnlONXeOczwR9ImFiTJ4SdV2/8YFOiTHtp Qk3iPUCbjmNZ1j0I3kjdBi0SMwUOJ9T0Ta6HoLrKnPyQEyNjiUw2YUbiDZdFF4LUwlnO chhA== X-Gm-Message-State: ALoCoQkDVVp6NYXrWvK+WnDYT7CBs+Y6MV85i/M9dOfgYCaHo/Bo0ZOer0hLOs1Voy/8s9RcpbAo X-Received: by 10.182.70.74 with SMTP id k10mr22730122obu.34.1404975424110; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.106 with SMTP id e97ls2210701qgd.43.gmail; Wed, 09 Jul 2014 23:57:04 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr43717158vcb.0.1404975424007; 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 dx8si22557333vdb.24.2014.07.09.23.57.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 23:57:03 -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 im17so9626570vcb.39 for ; Wed, 09 Jul 2014 23:57:03 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr43170315vcx.4.1404975423872; Wed, 09 Jul 2014 23:57:03 -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 tc5csp109607vcb; Wed, 9 Jul 2014 23:57:03 -0700 (PDT) X-Received: by 10.68.166.36 with SMTP id zd4mr45762315pbb.54.1404975422964; Wed, 09 Jul 2014 23:57:02 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ou8si3845798pdb.118.2014.07.09.23.57.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 23:57:02 -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 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 (-) 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), 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;