Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp33324ybj; Mon, 4 May 2020 15:31:13 -0700 (PDT) X-Google-Smtp-Source: APiQypL27DgQrbZHjFuhaX6a1Y2kb4gSBmOhMFjvl0Byz7PVgVB76h6AhnXarDZ6Jin0xUqKZaxa X-Received: by 2002:a17:906:f1c3:: with SMTP id gx3mr29753ejb.25.1588631473703; Mon, 04 May 2020 15:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588631473; cv=none; d=google.com; s=arc-20160816; b=R+Jv8nTjrLxuoi7g0+InMlnIWAWMgkckXpYuU/QUBT6EY+5HpyX9DeeqrpAcVZ9UFL AQ6hpKJdCGqlvixiSuR+WHdw3tyOs4MUff+39fkNzipMGMmpWA1/U1f4osWohOY0Yi+X dnayFT3Dqvq689vcP2PNnsHwzBOwz7IxzNKtUjp+j1vVqYjKA4WQSzjcDL/1zKX0wzlH nVpPBqyaDVlfhyER8PNSCGjFpuFSLA094sf1mBM3EmBvh75C7GhAo6+DULEQ3DIFcQQI 5boZmP6eAQ8QgsHH+rJTX7WZV3XzWGHXCHi+1qUjH5XTtAv5XUfa7SD0RYPSUlhm/YwU qCnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=6o3sgjCTpPY8Hss9JNkn+jJAbSSqKKMyc9izXRoBS18=; b=zXs08SInK8yukYdUXQES2mWVcRJGKonVEz+YSkznGNAknJxOgGnjEBHrYQAbqowsu/ O3ZEfYQ3RoJ4x+7/vTIkClpUAbPWiw6s0SrpKQdSo/wm8+xHqR7KOBj2ynmhC6tkarc2 QcpRVbY/5e9XBctmvpy8XFf3bdYxeG/CQcMG2QRkZbSrdhKdbXva5wl56f/t0b0I9DgT JXCj1xyT2Gy/3BkABgKAiMJfFufW0WmpMK4MBxYzpPnsy8Fsi4Npz2UeWASFCQa+v8ot Dnva4LbSwx/2aGpCTeNEluzOS/U1f4prlF1GfW3i8YFu+8SRb7W+B2V+H6tDRToGFcTd KNpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WwaMsNt9; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si192336edv.347.2020.05.04.15.30.50; Mon, 04 May 2020 15:31:13 -0700 (PDT) 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=@kernel.org header.s=default header.b=WwaMsNt9; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbgEDW1C (ORCPT + 99 others); Mon, 4 May 2020 18:27:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:37978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbgEDW1C (ORCPT ); Mon, 4 May 2020 18:27:02 -0400 Received: from localhost (mobile-166-175-184-168.mycingular.net [166.175.184.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65C2B206A5; Mon, 4 May 2020 22:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588631221; bh=gaXNVmp8PLFGyCzzFdCT2QTkMNhSdkffHPKXOLJiVMU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=WwaMsNt9CjxpjlNuvE9SoPW61U5Fg1+pXOFoFCQJ2KEupgayuaJPjp9fPyNdHk463 WmOXxJXjvHR4h62hIObt93SzJtv6OJeTa1M4u39a/H7j5GxSOHKqTthEbSJiQWUPiK 78N3rT1pAOomtNdDGi9pxbvpaCW8x8ZtRuyjEpSg= Date: Mon, 4 May 2020 17:26:59 -0500 From: Bjorn Helgaas To: Greg Kroah-Hartman Cc: Thomas Gleixner , "Rafael J . Wysocki" , Aman Sharma , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH v2 1/2] driver core: platform: Clarify that IRQ 0 is invalid Message-ID: <20200504222659.GA296947@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200504190721.GA2810934@kroah.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 04, 2020 at 09:07:21PM +0200, Greg Kroah-Hartman wrote: > On Mon, May 04, 2020 at 01:08:22PM -0500, Bjorn Helgaas wrote: > > On Sat, May 02, 2020 at 08:15:37AM +0200, Greg Kroah-Hartman wrote: > > > On Fri, May 01, 2020 at 05:40:41PM -0500, Bjorn Helgaas wrote: > > > > From: Bjorn Helgaas > > > > > > > > These interfaces return a negative error number or an IRQ: > > > > > > > > platform_get_irq() > > > > platform_get_irq_optional() > > > > platform_get_irq_byname() > > > > platform_get_irq_byname_optional() > > > > > > > > The function comments suggest checking for error like this: > > > > > > > > irq = platform_get_irq(...); > > > > if (irq < 0) > > > > return irq; > > > > > > > > which is what most callers (~900 of 1400) do, so it's implicit > > > > that IRQ 0 is invalid. But some callers check for "irq <= 0", > > > > and it's not obvious from the source that we never return an > > > > IRQ 0. > > > > > > > > Make this more explicit by updating the comments to say that > > > > an IRQ number is always non-zero and adding a WARN() if we > > > > ever do return zero. If we do return IRQ 0, it likely > > > > indicates a bug in the arch-specific parts of > > > > platform_get_irq(). > > > > > > I worry about adding WARN() as there are systems that do > > > panic_on_warn() and syzbot trips over this as well. I don't > > > think that for this issue it would be a problem, but what really > > > is this warning about that someone could do anything with? > > > > > > Other than that minor thing, this looks good to me, thanks for > > > finally clearing this up. > > > > What I'm concerned about is an arch that returns 0. Most drivers > > don't check for 0 so they'll just try to use it, and things will > > fail in some obscure way. My assumption is that if there really > > is no IRQ, we should return -ENOENT or similar instead of 0. > > > > I could be convinced that it's not worth warning about at all, or > > we could do something like the following: > > > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > > index 084cf1d23d3f..4afa5875e14d 100644 > > --- a/drivers/base/platform.c > > +++ b/drivers/base/platform.c > > @@ -220,7 +220,11 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num) > > ret = -ENXIO; > > #endif > > out: > > - WARN(ret == 0, "0 is an invalid IRQ number\n"); > > + /* Returning zero here is likely a bug in the arch IRQ code */ > > + if (ret == 0) { > > + pr_warn("0 is an invalid IRQ number\n"); > > + dump_stack(); > > + } > > return ret; > > } > > ... > I like that, but you said this is something that the platform people > should only see when bringing up a new system, so maybe the WARN() is > fine. It's not user-triggerable, so your original is ok. Is that an ack? Thomas, any thoughts? I suspect we could see this given a broken DT, too, so I'm not sure it's strictly a bringup problem. I would probably argue that even this case would be an arch defect: the kernel should validate data from a DT at least enough to avoid giving a bogus, useless IRQ to a driver. Bjorn