Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1767273pxb; Wed, 9 Feb 2022 04:10:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYrrOwBkTjkb5glsB7WCYkwhd6yjA2MPe+jqS7pTYRdyid68XkMCF5TVOgfbYvceoUQEZj X-Received: by 2002:aa7:9a51:: with SMTP id x17mr1342065pfj.9.1644408604288; Wed, 09 Feb 2022 04:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644408604; cv=none; d=google.com; s=arc-20160816; b=IGuUsmZL5MFQ5wN1J6N/ojguZaQo9uW/Oqjj3kkdl6LfdgwHv1YZDvdoFd5W6sVQE5 dqh33tA6+MzJsWqXJ7weNYIZIQjWWAMnFCS/iNykrSSZpuOgYYjWEx1SADCjwKDxA6F3 nnMInbtZUOw5mdV8clwhPjaEFUJuO7qHh2BVtHTZpgsm5RA8hfz3kpMeVj7Zld+E3Q8Y jAscgl5srwK+hk6fv7pycE3XkL8kgBeaDVwh+UQ4phFwmKxShvhQ98yrUHLxRVMmOUHa OAD19bEdH+Lg68UcKHDuum4J5CR7Uwowr2ODWwIqJ7TJoOpaM375dqh9o+94iptXdPlU QxQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=wP3VQPaW3fwYnYYHRw5iguGd67J9LSJ4yzDD3NeEY1I=; b=v+LB+fyjBNGagFq2JBi7XeCpavt9vyBwoNTPjlZKTlk5JioHzn5z0uYISgCdcAorSm sgWNvJurANPkHcrKzDxBeP8G8unvvl3B8r8vIFVwr1i046T3KiCpNOtEcsP7mog/uM+i GktKngDHSEa7CsHbPeIqceZmRyaQkalmzosOObXF/cgacwpMLPvVk4mMPj4PBXY2voC5 zwWK2pPxll/E73Z0BskMKOoHFMLYZzlgzLxvpbcW6skIwDTKn1zB48UbJVouTPlAhd60 poCtQzRIeQ92Cqs9D0g6DwwGY0XXaigwsq8+zXROq6VWHaSNLxzkHHMcfepbPqON9R9E 9Hqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bf3si14066411plb.222.2022.02.09.04.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 04:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66D7FE02F544; Wed, 9 Feb 2022 02:08:09 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380195AbiBHP27 (ORCPT + 99 others); Tue, 8 Feb 2022 10:28:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348422AbiBHP26 (ORCPT ); Tue, 8 Feb 2022 10:28:58 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 62D48C061576 for ; Tue, 8 Feb 2022 07:28:57 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A18B2B; Tue, 8 Feb 2022 07:28:57 -0800 (PST) Received: from [10.57.70.89] (unknown [10.57.70.89]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 02BD33F73B; Tue, 8 Feb 2022 07:28:54 -0800 (PST) Message-ID: Date: Tue, 8 Feb 2022 15:28:50 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count Content-Language: en-GB To: Will Deacon Cc: Lad Prabhakar , Joerg Roedel , Rob Clark , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, Xin Tan , Sai Prakash Ranjan , "Isaac J. Manjarres" , Rob Herring , linux-kernel@vger.kernel.org, Prabhakar References: <20211223130046.9365-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20211223130046.9365-2-prabhakar.mahadev-lad.rj@bp.renesas.com> <20220208151932.GB1802@willie-the-truck> From: Robin Murphy In-Reply-To: <20220208151932.GB1802@willie-the-truck> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-02-08 15:19, Will Deacon wrote: > On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote: >> On 2021-12-23 13:00, Lad Prabhakar wrote: >>> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static >>> allocation of IRQ resources in DT core code, this causes an issue >>> when using hierarchical interrupt domains using "interrupts" property >>> in the node as this bypasses the hierarchical setup and messes up the >>> irq chaining. >>> >>> In preparation for removal of static setup of IRQ resource from DT core >>> code use platform_get_irq_count(). >> >> Nit: platform_irq_count() >> >>> Signed-off-by: Lad Prabhakar >>> --- >>> drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------ >>> 1 file changed, 6 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c >>> index 4bc75c4ce402..4844cd075644 100644 >>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c >>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c >>> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev) >>> if (IS_ERR(smmu)) >>> return PTR_ERR(smmu); >>> - num_irqs = 0; >>> - while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) { >>> - num_irqs++; >>> - if (num_irqs > smmu->num_global_irqs) >>> - smmu->num_context_irqs++; >>> - } >>> + num_irqs = platform_irq_count(pdev); >>> + if (num_irqs < 0) >>> + return num_irqs; >>> + >>> + if (num_irqs > smmu->num_global_irqs) >>> + smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs); >> >> This seems a bit overcomplicated. I reckon: >> >> smmu->num_context_irqs = num_irqs - smmu->num_global_irqs; >> if (num_irqs <= smmu->num_global_irqs) { >> dev_err(... >> >> should do it. >> >> However, FYI I have some patches refactoring most of the IRQ stuff here that >> I plan to post next cycle (didn't quite have time to get them done for 5.17 >> as I'd hoped...), so unless this needs to go in right now as an urgent fix, >> I'm happy to take care of removing platform_get_resource() as part of that >> if it's easier. > > Did you get anywhere with this? December 23rd is long forgotten by now ;) Yup: https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9 I'm still cleaning up the PMU driver that justifies the whole thing, but I can send that patch now if you reckon it's not complete nonsense out of context. Otherwise, I'll aim to get the whole lot out next week. Cheers, Robin.