From patchwork Thu Jul 16 08:30:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 6804791 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4A2CC9F2F0 for ; Thu, 16 Jul 2015 08:33:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 502AF207C0 for ; Thu, 16 Jul 2015 08:33:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A13620751 for ; Thu, 16 Jul 2015 08:33:29 +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 1ZFeZm-0001Ku-Re; Thu, 16 Jul 2015 08:31:30 +0000 Received: from 8bytes.org ([81.169.241.247] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZFeZd-0001D0-SP for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2015 08:31:22 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id 8AA25398; Thu, 16 Jul 2015 10:30:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1437035453; bh=3lsKEjminQOy2A6Z2SCwV2z+hk1nZ4qeTFu9bV+lpRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hU+EPLBreysHy3d/Ijm/xMEp5PLA5c2WvC/M5cG/UoQoqi8afxNGjnvgAdWIB0qq2 NipvZ1R/CDzFet00n4yiAPGDbYtSgWSsPdxrpkWrn8XoyYg9bZA0v9Avwvn8c9w8FA uMMjJGZZPY2aEwBFl7OB6hMD05WQUKenvSQTafpX6hKFC+wyHdatwf0XUZ8T5mwVye EL8foCQzAw8f65hWaWN2KOq+d03KDlhwMyczALnhoSNzXSfRENLYUulaq+kxkT3ptq GLYMEoIKjJFI75jLMkkdp9y8kcsEyG3yfn7P8I7uTNIwY4x4+ax/czVAD0a65Ro0aP hlzEjetbzX0Cg== From: Joerg Roedel To: Will Deacon , Grant Likely , Rob Herring Subject: [PATCH 2/2] arm/smmu: Make use of of_parse_phandle_with_var_args Date: Thu, 16 Jul 2015 10:30:44 +0200 Message-Id: <1437035444-13867-3-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437035444-13867-1-git-send-email-joro@8bytes.org> References: <1437035444-13867-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150716_013122_108070_7757FBC3 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -3.4 (---) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Joerg Roedel The function of_parse_phandle_with_args() can only handle 16 args, but there are systems that require more (25 in my case). So use the newly introduced function of_parse_phandle_with_var_args() instead. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 4cd0c29..1fe7f35 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -47,7 +47,7 @@ #include "io-pgtable.h" /* Maximum number of stream IDs assigned to a single device */ -#define MAX_MASTER_STREAMIDS MAX_PHANDLE_ARGS +#define MAX_MASTER_STREAMIDS 128 /* Maximum number of context banks per SMMU */ #define ARM_SMMU_MAX_CBS 128 @@ -1698,7 +1698,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) struct arm_smmu_device *smmu; struct device *dev = &pdev->dev; struct rb_node *node; - struct of_phandle_args masterspec; + struct of_phandle_args *masterspec; int num_irqs, i, err; smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL); @@ -1757,15 +1757,19 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) if (err) return err; + masterspec = of_alloc_phandle_args(MAX_MASTER_STREAMIDS); + if (!masterspec) + return -ENOMEM; + i = 0; smmu->masters = RB_ROOT; - while (!of_parse_phandle_with_args(dev->of_node, "mmu-masters", - "#stream-id-cells", i, - &masterspec)) { - err = register_smmu_master(smmu, dev, &masterspec); + while (!of_parse_phandle_with_var_args(dev->of_node, "mmu-masters", + "#stream-id-cells", i, masterspec, + MAX_MASTER_STREAMIDS)) { + err = register_smmu_master(smmu, dev, masterspec); if (err) { dev_err(dev, "failed to add master %s\n", - masterspec.np->name); + masterspec->np->name); goto out_put_masters; } @@ -1797,6 +1801,8 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) } } + of_free_phandle_args(masterspec); + INIT_LIST_HEAD(&smmu->list); spin_lock(&arm_smmu_devices_lock); list_add(&smmu->list, &arm_smmu_devices); @@ -1810,6 +1816,9 @@ out_free_irqs: free_irq(smmu->irqs[i], smmu); out_put_masters: + + of_free_phandle_args(masterspec); + for (node = rb_first(&smmu->masters); node; node = rb_next(node)) { struct arm_smmu_master *master = container_of(node, struct arm_smmu_master, node);