Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp838254ybh; Thu, 12 Mar 2020 12:03:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vud5BQXXkSD+p/CkTq06cVCunfP9xSm4N2s3DABu53aKLcG7jRMe88SBtXrR/vxppCyxUJr X-Received: by 2002:a9d:649a:: with SMTP id g26mr7821016otl.266.1584039788971; Thu, 12 Mar 2020 12:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584039788; cv=none; d=google.com; s=arc-20160816; b=wVtDEZ8SJ+9SwboA3B68p+gKC1AGEiQA3VUUWDGGA0/gvrLkNuNZ81YtaGbcmH85D9 OX9mHDchoAUFm2gSO0xI7nFy0lzzRVRNmXc8VHVf1OGJWS7F/yccfPw5R0eVABi9i6hd D8DWf0eO0HHKcyny74E4C558A2WdYQoDGKzH4X++6tWst/27BeiwXp2RZZcif3znLrIL SuPHQfkDNYA1vh0GQriBON+cWv3td6aiHLVvSx+4q9AcPiWMe/Hmt/YDAdZBbgQcwBPx gRh7nyAgtOAMoBJRAqYsGYiXrEvXcyBaN7hEEay0OK/xHbhLepImlM7bcdWCqXyBrCnZ SPCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=z7aD4rTz8Z5Cl/pFpHRVCeXMEPyKZIgD4a+8l84mzuo=; b=fapWSKUJmHFfAZ6GSau4mSsvIm3kwIhgz2/RxcHKs0owBmpg+ULWOsxQrbMXrVHuQw 6OaB0YOgTr92XLhUtCRz6gXysEwAoagBvUWMWXF2Ctkhp2PnNFIq/2M06oKdx6cjWgdB nCIQisTTbS4SD4IWMOTzaeD95pZlXguu5SnktJrfXfRnT5ynRydUq2LlLiibcdmxPIOW WpygDG2aFbF5guYJ5TiINWSZyhjxZHa2MVrcX6vLV3JgK/d1RBlQ8FACsI3csbFAgI7O Zf6bAAbRsTh+9YAfWuzb5DjgIGSYImrV6TJ6v4vdF3cBEtqIgB6W09A5TkWNbIV3YLuX 0a5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HduS9YsR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id c10si3161213oto.202.2020.03.12.12.02.54; Thu, 12 Mar 2020 12:03:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HduS9YsR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726720AbgCLTCF (ORCPT + 99 others); Thu, 12 Mar 2020 15:02:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726680AbgCLTCF (ORCPT ); Thu, 12 Mar 2020 15:02:05 -0400 Received: from localhost (mobile-166-175-186-165.mycingular.net [166.175.186.165]) (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 48FA9206EB; Thu, 12 Mar 2020 19:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584039724; bh=SlkhTmsxIrlEojuXYKZBatDWX41BUd/qNHIhRRSgdNI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=HduS9YsRfFqHiD9D0BPFGNc9LGRdKIq7LV4bMwx9D9gKIHDZxIv/oUpKkgvfT0MgW 2uLGu6gw8Wb7hWtlyDfCCyO6K8lu2T2oRjF49qzR2Nu9THEDcZBV03OO8o9hb2jBdo OB5TeC/AUJleYP6rcDcjWO1p43gbpGkMcyytIQB8= Date: Thu, 12 Mar 2020 14:02:02 -0500 From: Bjorn Helgaas To: Linus Walleij Cc: Aman Sharma , Thomas Petazzoni , Lorenzo Pieralisi , Andrew Murray , Ryder Lee , Karthikeyan Mitran , Hou Zhiqiang , Marc Gonzalez , Mans Rullgard , Matthias Brugger , linux-pci , Linux ARM , "linux-kernel@vger.kernel.org" , linux-mediatek@lists.infradead.org, Marc Zyngier , Thomas Gleixner Subject: Re: [PATCH 1/5] pci: handled return value of platform_get_irq correctly Message-ID: <20200312190202.GA110276@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Marc, Thomas] Hi Linus, On Thu, Mar 12, 2020 at 03:07:58PM +0100, Linus Walleij wrote: > On Wed, Mar 11, 2020 at 8:19 PM Aman Sharma wrote: > > Signed-off-by: Aman Sharma > > --- > > drivers/pci/controller/pci-v3-semi.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c > > index bd05221f5a22..a5bf945d2eda 100644 > > --- a/drivers/pci/controller/pci-v3-semi.c > > +++ b/drivers/pci/controller/pci-v3-semi.c > > @@ -777,9 +777,9 @@ static int v3_pci_probe(struct platform_device *pdev) > > > > /* Get and request error IRQ resource */ > > irq = platform_get_irq(pdev, 0); > > - if (irq <= 0) { > > + if (irq < 0) { > > Have you considered: > https://lwn.net/Articles/470820/ > > TL;DR Linus (both of them) are not with you on this. > > And that is why the code is written like this. I'm not sure I understand you here, so please correct me when I go in the weeds. I guess you're saying that platform_get_irq() can return 0 here and we should treat that as an error? This particular driver seems to be ARM-specific -- does that mean we need to check for 0 on some arches but not others? That would definitely be suboptimal, and that's what I'd like to fix here. IIUC, in the link you mentioned, Linus T says that "dev->irq == 0" means we don't have a valid IRQ. I think that makes sense, but I'm not sure it follows that 0 must be a sensical return value for platform_get_irq(). It seems to me that platform_get_irq() ought to return either a valid IRQ or an error, and the convention for errors is a negative errno. In fact, the platform_get_irq() function comment says it returns "IRQ number on success, negative error number on failure." If we need to interpret 0 as an error on some arches, it sounds like something is wrong in the arch-specific bowels of platform_get_irq(). If platform_get_irq() returns an error, a driver might want to continue in polled mode without IRQs, in which case it could set its "dev->irq = 0" to indicate that it has no valid IRQ. But I think we might be able to separate that "stored IRQ" situation from the platform_get_irq() interface. Bjorn