Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49CB4C433EF for ; Tue, 4 Jan 2022 09:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiADJ0Y (ORCPT ); Tue, 4 Jan 2022 04:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiADJ0X (ORCPT ); Tue, 4 Jan 2022 04:26:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79718C061761 for ; Tue, 4 Jan 2022 01:26:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EDBE6612FD for ; Tue, 4 Jan 2022 09:26:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55CA2C36AEB; Tue, 4 Jan 2022 09:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641288382; bh=1j0Dd9vlo28TqtscKketQ5t/0IHCPhGo7kG2ZdsYAsE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UvOip0wbNZAOcCFm/Hrv9JdjI8jRei5ilHWwf8i8TDO81Mmt/ffG2a4lMs6HxGPkU XFpUMRFMZkdYihusNF4ipbi3QHNmAN0hJuos3KJl2NlLNvuoXGmKNbW4XRQHtVcHta 1J9nfnymViMzjoIOaE5ERF4W2xztRQ9oePxwdGexZhfMZdpuYaPc+APoOPAy0smLym X4UCQ1Eh60qqNpDsZm63j508j7I5uEcb3MHx9d/OIO30AczZ4XLHnVRDp2Fl9wxplI 1BCgGJM48LVBLxfClB9iQtH1hiaNizCmbpX+O8470eTT53hrviWvIBqOnsskOO9X+B /7OfkM35rU/eQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n4g5D-00Fs6B-8H; Tue, 04 Jan 2022 09:26:19 +0000 Date: Tue, 04 Jan 2022 09:26:18 +0000 Message-ID: <87pmp7volh.wl-maz@kernel.org> From: Marc Zyngier To: Sergey Shtylyov Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , , Thomas Gleixner , Geert Uytterhoeven Subject: Re: [PATCH] platform: finally disallow IRQ0 in platform_get_irq() and its ilk In-Reply-To: <5e001ec1-d3f1-bcb8-7f30-a6301fd9930c@omp.ru> References: <5e001ec1-d3f1-bcb8-7f30-a6301fd9930c@omp.ru> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: s.shtylyov@omp.ru, gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, geert@linux-m68k.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Adding Geert] On Sat, 06 Nov 2021 20:26:47 +0000, Sergey Shtylyov wrote: >=20 > 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! >=20 > Fixes: a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invali= d") > Signed-off-by: Sergey Shtylyov >=20 > --- > The patch is against the 'driver-core-linus' branch of Greg Kroah-Hartman= 's > 'driver-core.git' repo. >=20 > drivers/base/platform.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > Index: driver-core/drivers/base/platform.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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 =3D -ENXIO; > out: > - WARN(ret =3D=3D 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 > =20 > r =3D platform_get_resource_byname(dev, IORESOURCE_IRQ, name); > if (r) { > - WARN(r->start =3D=3D 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. =46rom 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 M. --=20 Without deviation from the norm, progress is not possible.