Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4404187pxb; Tue, 25 Jan 2022 09:34:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwbm+ic/i4JUnqUUy0dXqq6rsIPTlcNSzRUFStDCHFIAlFcEutsiA9dI9+k+H9TZw8IMvg X-Received: by 2002:a17:907:6e03:: with SMTP id sd3mr12216699ejc.536.1643132069007; Tue, 25 Jan 2022 09:34:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643132068; cv=none; d=google.com; s=arc-20160816; b=Eknc6gTexNr043PmAbV3wHpIg6Ea4G6z5gMUYsxHlcvZipjEjIZYI+uZgTfTTTSIGF H6saxi5laj9WqaE/uG5+2bFNc3n0NHt/bnw3QsWfwkx/F2y6nMDiIR0l13U+jWlaqoxT 7dtOodtRRR+a7mbLv2N68R4OBVLNvpW7cBavk7ByuR0QoG2uzsOJL7Kzq+I5qPe9ULxO YdoXKu41eowfm+VcGNwcJpAxYCroxfzq/qq/m0I7raZIYIPVTvS8YbqHSIBM7lUlLH28 N6N53t+n7JLL2ptbqfh8eJ8AlnAVDncxaFaoCgcGh5AnW+neRjOYZLTWdWHOoTWz1juX q61g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=qmHH9G8TVCwWdo3uTby79rF+j0/3SailZLcBZpByLtg=; b=sndxfxJoHaoNdoWU0fK9weiR8cIQk7T5zZ5NwsWS/PBJYBlqmqN2yFhqI+fNpucwYf cwP6JSdED6RHdahY6zr0HhxIwVqYa64i2EaNxKEl//lU6K38Zsoid9rYDLh4bRRDLH/z 8Ucv90+sW4CRshjLM3QO0TVqs39DeaXnDxjzF+Op4IVTowbiU/XSVGxoVj+xhxWF1c2M 3rj/KG4FT8L8IpMJBg+AcipW5CYnV6p7ReicTaSKLPEhmJqJv8IreMwqX6bZD5A04SSi QnWJzlX+ujNlQEH7pRArGt/L/1H59MeNsRjJ+uboSkfM+rb8UStwEr4qtxiF3Fe1BgAH 5kWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=MB4CtmBY; dkim=pass header.i=@tq-group.com header.s=key1 header.b=DZazWES6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si9485524ejl.162.2022.01.25.09.34.03; Tue, 25 Jan 2022 09:34:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=MB4CtmBY; dkim=pass header.i=@tq-group.com header.s=key1 header.b=DZazWES6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347837AbiAYM7m (ORCPT + 99 others); Tue, 25 Jan 2022 07:59:42 -0500 Received: from mx1.tq-group.com ([93.104.207.81]:23582 "EHLO mx1.tq-group.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359066AbiAYM4T (ORCPT ); Tue, 25 Jan 2022 07:56:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643115378; x=1674651378; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=qmHH9G8TVCwWdo3uTby79rF+j0/3SailZLcBZpByLtg=; b=MB4CtmBY/kKUZUkbx858aLxhxtieEwNP3ArjS4boMb6N8oV/9x7+oe+7 vBRLZ4YVEvZ/1JO2JM7klGULc8cKXlCkrMAODKUDhoRxB28SicAlb3MwA z4BaKpNCiXG7OZsbwPxYNCX20Nvck+6x4Hz/LZ+ldX2fSU+OXD7ABJ1L3 qhCGVEW1kcKUCt7niPCL5EASKNk6v9jLS3splPrSApHD9OyMA3IK+xWnD qyyDv4o+OVOldOqDDmEWH7qIkVMd4VmaPCCCi8zZkUsMRkMvEb3Tf3C3R UUuaUcupgO11DYD/qAb/ED5oLYw/xNWULPE2SGkeHr9g/mXySY1kfHonr w==; X-IronPort-AV: E=Sophos;i="5.88,315,1635199200"; d="scan'208";a="21697221" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 25 Jan 2022 13:56:08 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 25 Jan 2022 13:56:09 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 25 Jan 2022 13:56:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1643115368; x=1674651368; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=qmHH9G8TVCwWdo3uTby79rF+j0/3SailZLcBZpByLtg=; b=DZazWES6Z7qX74NIrM+i69skWo5ObJhdpFykKEns/urrKSV7FmjkeM2t YnBYyu8w987PyL5eZzlJ5LqVC1ihXP16gqLHPxLAtK9NLfyfbbnxMJjnE xkheSFbGqZGupY07RAOmoaOCOMZDwMnZDGO5NYbNANthuHRau78001vK2 zJddEGsKEXtkeB0hUhuWkr3kF7tYn69GziEH85Y5mupr+z4GI7q8lpN8I tHnvDwxI2K5PUlNNRZSdV0LyBsYg2DAs8tg6Mfpsr/QsP6qCBNv225Vhv 9E6GQFdFpwV+AAWYlFUvOpxFqY72lFs4EOW/dDH0eW9QyDbiOHxD6zCA3 Q==; X-IronPort-AV: E=Sophos;i="5.88,315,1635199200"; d="scan'208";a="21697220" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 25 Jan 2022 13:56:08 +0100 Received: from schifferm-ubuntu (SCHIFFERM-M2.tq-net.de [10.121.201.138]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id 966B4280065; Tue, 25 Jan 2022 13:56:07 +0100 (CET) Message-ID: <33e55c4c0a637b23d76db5d33872378ad04121bd.camel@ew.tq-group.com> Subject: Re: [PATCH] driver core: platform: Rename platform_get_irq_optional() to platform_get_irq_silent() From: Matthias Schiffer To: Geert Uytterhoeven , Sergey Shtylyov Cc: Andy Shevchenko , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , Andrew Lunn , Ulf Hansson , Vignesh Raghavendra , KVM list , "Rafael J. Wysocki" , linux-iio@vger.kernel.org, Linus Walleij , Amit Kucheria , ALSA Development Mailing List , Jaroslav Kysela , Guenter Roeck , Thierry Reding , MTD Maling List , Linux I2C , Miquel Raynal , linux-phy@lists.infradead.org, Jiri Slaby , openipmi-developer@lists.sourceforge.net, Khuong Dinh , Florian Fainelli , Joakim Zhang , Kamal Dasu , Greg Kroah-Hartman , Lee Jones , Bartosz Golaszewski , Daniel Lezcano , Kishon Vijay Abraham I , "open list:SERIAL DRIVERS" , bcm-kernel-feedback-list , Zhang Rui , Linux PWM List , Robert Richter , Saravanan Sekar , Corey Minyard , Linux PM list , Linux Kernel Mailing List , Mauro Carvalho Chehab , John Garry , Peter Korsgaard , William Breathitt Gray , Mark Gross , "open list:GPIO SUBSYSTEM" , Alex Williamson , Mark Brown , Borislav Petkov , Sebastian Reichel , Eric Auger , Jakub Kicinski , Matthias Brugger , Takashi Iwai , platform-driver-x86@vger.kernel.org, Benson Leung , Linux ARM , linux-edac@vger.kernel.org, Tony Luck , Mun Yew Tham , Hans de Goede , netdev@vger.kernel.org, Yoshihiro Shimoda , Cornelia Huck , Linux MMC List , Liam Girdwood , linux-spi , Linux-Renesas , Vinod Koul , James Morse , Zha Qipeng , Pengutronix Kernel Team , Richard Weinberger , Niklas =?ISO-8859-1?Q?S=F6derlund?= , linux-mediatek@lists.infradead.org, Brian Norris , "David S. Miller" Date: Tue, 25 Jan 2022 13:56:05 +0100 In-Reply-To: References: <20220112213121.5ruae5mxwj6t3qiy@pengutronix.de> <20220113110831.wvwbm75hbfysbn2d@pengutronix.de> <20220113194358.xnnbhsoyetihterb@pengutronix.de> <20220115154539.j3tsz5ioqexq2yuu@pengutronix.de> <20220120075718.5qtrpc543kkykaow@pengutronix.de> <15796e57-f7d4-9c66-3b53-0b026eaf31d8@omp.ru> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-01-25 at 09:25 +0100, Geert Uytterhoeven wrote: > Hi Sergey, > > On Mon, Jan 24, 2022 at 10:02 PM Sergey Shtylyov > wrote: > > On 1/24/22 6:01 PM, Andy Shevchenko wrote: > > > > > > > > > It'd certainly be good to name anything that doesn't > > > > > > > > > correspond to one > > > > > > > > > of the existing semantics for the API (!) something > > > > > > > > > different rather > > > > > > > > > than adding yet another potentially overloaded > > > > > > > > > meaning. > > > > > > > > > > > > > > > > It seems we're (at least) three who agree about this. > > > > > > > > Here is a patch > > > > > > > > fixing the name. > > > > > > > > > > > > > > And similar number of people are on the other side. > > > > > > > > > > > > If someone already opposed to the renaming (and not only > > > > > > the name) I > > > > > > must have missed that. > > > > > > > > > > > > So you think it's a good idea to keep the name > > > > > > platform_get_irq_optional() despite the "not found" value > > > > > > returned by it > > > > > > isn't usable as if it were a normal irq number? > > > > > > > > > > I meant that on the other side people who are in favour of > > > > > Sergey's patch. > > > > > Since that I commented already that I opposed the renaming > > > > > being a standalone > > > > > change. > > > > > > > > > > Do you agree that we have several issues with > > > > > platform_get_irq*() APIs? > > [...] > > > > > 2. The vIRQ0 handling: a) WARN() followed by b) returned > > > > > value 0 > > > > > > > > I'm happy with the vIRQ0 handling. Today platform_get_irq() and > > > > it's > > > > silent variant returns either a valid and usuable irq number or > > > > a > > > > negative error value. That's totally fine. > > > > > > It might return 0. > > > Actually it seems that the WARN() can only be issued in two > > > cases: > > > - SPARC with vIRQ0 in one of the array member > > > - fallback to ACPI for GPIO IRQ resource with index 0 > > > > You have probably missed the recent discovery that > > arch/sh/boards/board-aps4*.c > > causes IRQ0 to be passed as a direct IRQ resource? > > So far no one reported seeing the big fat warning ;-) FWIW, we had a similar issue with an IRQ resource passed from the tqmx86 MFD driver do the GPIO driver, which we noticed due to this warning, and which was fixed in a946506c48f3bd09363c9d2b0a178e55733bcbb6 and 9b87f43537acfa24b95c236beba0f45901356eb2. I believe these changes are what promted this whole discussion and led to my "Reported-by" on the patch? It is not entirely clear to me when IRQ 0 is valid and when it isn't, but the warning seems useful to me. Maybe it would make more sense to warn when such an IRQ resource is registered for a platform device, and not when it is looked up? My opinion is that it would be very confusing if there are any places in the kernel (on some platforms) where IRQ 0 is valid, but for platform_get_irq() it would suddenly mean "not found". Keeping a negative return value seems preferable to me for this reason. (An alternative, more involved idea would be to add 1 to all IRQ "cookies", so IRQ 0 would return 1, leaving 0 as a special value. I have absolutely no idea how big the API surface is that would need changes, and it is likely not worth the effort at all.) > > > > The bottom line here is the SPARC case. Anybody familiar with the > > > platform > > > can shed a light on this. If there is no such case, we may remove > > > warning > > > along with ret = 0 case from platfrom_get_irq(). > > > > I'm afraid you're too fast here... :-) > > We'll have a really hard time if we continue to allow IRQ0 to be > > returned by > > platform_get_irq() -- we'll have oto fileter it out in the callers > > then... > > So far no one reported seeing the big fat warning? > > > > > > 3. The specific cookie for "IRQ not found, while no error > > > > > happened" case > > > > > > > > Not sure what you mean here. I have no problem that a situation > > > > I can > > > > cope with is called an error for the query function. I just do > > > > error > > > > handling and continue happily. So the part "while no error > > > > happened" is > > > > irrelevant to me. > > > > > > I meant that instead of using special error code, 0 is very much > > > good for > > > the cases when IRQ is not found. It allows to distinguish -ENXIO > > > from the > > > low layer from -ENXIO with this magic meaning. > > > > I don't see how -ENXIO can trickle from the lower layers, > > frankly... > > It might one day, leading to very hard to track bugs. As gregkh noted, changing the return value without also making the compile fail will be a huge PITA whenever driver patches are back- or forward-ported, as it would require subtle changes in error paths, which can easily slip through unnoticed, in particular with half- automated stable backports. Even if another return value like -ENODEV might be better aligned with ...regulator_get_optional() and similar functions, or we even find a way to make 0 usable for this, none of the proposed changes strike me as big enough a win to outweigh the churn caused by making such a change at all. Kind regards, Matthias > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- > geert@linux-m68k.org > > In personal conversations with technical people, I call myself a > hacker. But > when I'm talking to journalists I just say "programmer" or something > like that. > -- Linus Torvalds