Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4161591pxb; Fri, 11 Feb 2022 17:48:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIdkPxPAAGsxmCOdUNUQ2wB7QqHmUa3yreMtONN57G1pf+1NPDB1PfbNR/xjl2TlpSXFqj X-Received: by 2002:a17:906:14cb:: with SMTP id y11mr3428814ejc.405.1644630497715; Fri, 11 Feb 2022 17:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644630497; cv=none; d=google.com; s=arc-20160816; b=wti8VCwMdivgNXlTptGDSyzMsyQdkN9VmU9WPrC20y+SGlL+U43mtXUP90+igHQViW hSqawUanG62hm3Cv1KGR+Tonmprs3i2gwvKTkpxg/odmlLBoPQvsCLa6hCugzCzf22HG 7+L1/FufgrjJtnMg1ykFr91oLTworp7CpvHg7VTtFEPOQbxMO5+7mgCYt1nLgfN1ciNQ gurY1wIjpcJpJYanuk6Y87AWOsP56gF5tsrsSBEB1U5YIg4pYE86hjYFDYOMQ2KLbAlz ywxsAho0sip8Sk+BrkNMDIaVHWyRsflrR9tbCPcjHKOiuVuLTXaE0ZwEX1C3/AyUUCo6 Xl5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-filter; bh=fclEDWlZmIAtAqeWWb8IPCPvZf7fs2TAX4pfe6bZrvA=; b=ZHqh77E/wWBSSXbXkDgQqJtLnhX9FnltUbMEj3RYRgZ1CAmuQdGv4IJEpNHvdHdSbp lPUT9TxOGvi4qWQvvceY5n/4grBrNtF4Hq9zua4Fqu6ZJQGGwjvpgW1HwBE13bI2awmv jj2JTJkvGLrFwk8ZF29TB3b5Vt14d5hJAcmE+OTwwIftuH5639cdtNfC3YHorvaK5spu Yp9uDLIx7UeHv6SV7PsjLdMKGUmfl2a0B0wO1W91Hsm1Vwq6MfbWwqY7tRcxRu8NhmqV 9pXjTp4E7839omPnVb2GrIMs8oDXuOhVoL3sqFPlpgI7efaWcQV5zsFdQCKT2t7554fv 3FcQ== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en11si14386002edb.551.2022.02.11.17.47.53; Fri, 11 Feb 2022 17:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353142AbiBKUUP (ORCPT + 99 others); Fri, 11 Feb 2022 15:20:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239383AbiBKUUM (ORCPT ); Fri, 11 Feb 2022 15:20:12 -0500 Received: from mxout03.lancloud.ru (mxout03.lancloud.ru [45.84.86.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA87CF9 for ; Fri, 11 Feb 2022 12:20:10 -0800 (PST) Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru 8728320A8995 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH] platform: finally disallow IRQ0 in platform_get_irq() and its ilk To: Marc Zyngier CC: Greg Kroah-Hartman , "Rafael J. Wysocki" , , Thomas Gleixner , Geert Uytterhoeven References: <5e001ec1-d3f1-bcb8-7f30-a6301fd9930c@omp.ru> <87pmp7volh.wl-maz@kernel.org> <9c3f9a6e-89b6-b73b-032f-e4b4ee6f72ac@omp.ru> <58caf8b54828bcc25cfc65220d29b68f@kernel.org> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <394a53e7-ef96-b99d-e7ee-764e6d89bfb5@omp.ru> Date: Fri, 11 Feb 2022 23:20:07 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <58caf8b54828bcc25cfc65220d29b68f@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 1/12/22 9:08 PM, Marc Zyngier wrote: [...] >>>> The commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is >>>> invalid") only calls WARN() when IRQ0 is about to be returned, however >>>> using IRQ0 is considered invalid (according to Linus) outside the arch/ >>>> code where it's used by the i8253 drivers. Many driver subsystems treat >>>> 0 specially (e.g. as an indication of the polling mode by libata), so >>>> the users of platform_get_irq[_byname]() in them would have to filter >>>> out IRQ0 explicitly and this (quite obviously) doesn't scale... >>>> Let's finally get this straight and return -EINVAL instead of IRQ0! >>>> >>>> Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid") >>>> Signed-off-by: Sergey Shtylyov >>>> >>>> --- >>>> The patch is against the 'driver-core-linus' branch of Greg Kroah-Hartman's >>>> 'driver-core.git' repo. >>>> >>>>  drivers/base/platform.c |    6 ++++-- >>>>  1 file changed, 4 insertions(+), 2 deletions(-) >>>> >>>> Index: driver-core/drivers/base/platform.c >>>> =================================================================== >>>> --- driver-core.orig/drivers/base/platform.c >>>> +++ driver-core/drivers/base/platform.c >>>> @@ -231,7 +231,8 @@ int platform_get_irq_optional(struct pla >>>>  out_not_found: >>>>      ret = -ENXIO; >>>>  out: >>>> -    WARN(ret == 0, "0 is an invalid IRQ number\n"); >>>> +    if (WARN(!ret, "0 is an invalid IRQ number\n")) >>>> +        return -EINVAL; >>>>      return ret; >>>>  } >>>>  EXPORT_SYMBOL_GPL(platform_get_irq_optional); >>>> @@ -445,7 +446,8 @@ static int __platform_get_irq_byname(str >>>> >>>>      r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); >>>>      if (r) { >>>> -        WARN(r->start == 0, "0 is an invalid IRQ number\n"); >>>> +        if (WARN(!r->start, "0 is an invalid IRQ number\n")) >>>> +            return -EINVAL; >>>>          return r->start; >>>>      } >>> >>> Geert recently mentioned that a few architectures (such as sh?) still >>> use IRQ0 as something valid in limited cases. >>> >>> From my PoV, this patch is fine, but please be prepared to fix things >>> in a couple of years when someone decides to boot a recent kernel on >>> their pet dinosaur. With that in mind: >>> >>> Acked-by: Marc Zyngier >> >>    Greg, so would that ACK be enough? Is there a chance this patch >> gets finally included >> into 5.17-rc1? Or should I look into fixing the recently found >> arch/sh/ issue 1st (as you >> can see, just WARN()'ing about IRQ0 wasn't enough to get this fixed)? > > Fixing SH would be a good thing. Patch posted now, see: https://lore.kernel.org/all/2f419ed2-66b8-4098-7cd3-0fe698d341c9@omp.ru/. > Thanks, > >         M. MBR, Sergey