From patchwork Thu Jun 25 15:52:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 6676311 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 DDF009F380 for ; Thu, 25 Jun 2015 15:55:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 148662051A for ; Thu, 25 Jun 2015 15:55:24 +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 C6ADC2038A for ; Thu, 25 Jun 2015 15:55:22 +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 1Z89SZ-0005u3-5O; Thu, 25 Jun 2015 15:53:03 +0000 Received: from 8bytes.org ([2a01:238:4383:600:38bc:a715:4b6d:a889] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z89SV-0005qk-8A for linux-arm-kernel@lists.infradead.org; Thu, 25 Jun 2015 15:53:00 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id 795501F9B; Thu, 25 Jun 2015 17:52:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1435247550; bh=yYMqyIRkp+fw083uCdWOtVHPLP3wK2Q49jWjKjjnG2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgB+FK834029CCfixJPkdjGPx2BhHlBdLE82VbyYeVoayZebxkL+GypCXYHOdkeya RCN6rDtLLkUsTWrU0UuL1ynfIl5OzgynE1+uZpSoGJlXwtFG2hyOPUkvEqWUUKWISR PX+ESFAj9QjoQbV15lQZ4aBfTKuIhSMecWA3q1LBxHBK26eLHNw7JzwMhFxlyz7TWM K06TOnDGJtgluEEPNS8cvHd8qhJ6FKGgPPvLn66JSU5jGjCShkbdS4GlNsS1CnmB+N j+Ju69bqUwMgo81f8vyDZwUUs2/EOZN5F9xlGDy2amDumXTs+syeed+Ou4WFFHMasD OPDu3kJ7B612A== From: Joerg Roedel To: Rob Herring , Grant Likely , Will Deacon , Joerg Roedel Subject: [PATCH 2/2] arm/smmu: Make use of of_parse_phandle_with_var_args Date: Thu, 25 Jun 2015 17:52:28 +0200 Message-Id: <1435247548-32201-2-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435247548-32201-1-git-send-email-joro@8bytes.org> References: <1435247548-32201-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150625_085259_473870_D8D0EA7D X-CRM114-Status: GOOD ( 12.32 ) X-Spam-Score: -3.4 (---) Cc: devicetree@vger.kernel.org, Joerg Roedel , Andre Przywara , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org 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: , 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.5 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 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 66a803b..da4d7ac 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 @@ -1699,7 +1699,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); @@ -1758,15 +1758,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; } @@ -1811,6 +1815,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);