Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp274984pxb; Thu, 25 Feb 2021 02:04:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzPTj5xHB33+5zqAFiAhQ55Sjt8okgPNljx6FDgQTVn0+SIQjvWn5nhIG9U6OKCrP3TBQ8 X-Received: by 2002:a17:906:df51:: with SMTP id if17mr1874964ejc.370.1614247491871; Thu, 25 Feb 2021 02:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247491; cv=none; d=google.com; s=arc-20160816; b=Eu+RPaTrTO6HlCbVmwJ69dkeLXQpwJamKCQkyb+mVtrO2qiQjuA7QcPnBv7OEDLNYx d1G/YWaoDhn4VvBjMv4iaS7WGPhHzU8OcjTWhSDi686frW8dodFgRjq9aNNyVtl8YHZ4 leYooQLKLMJEdUKUNFh8TOAIRbG1oEAwabHUW0AmmrE8fimcd/UVTpSeIiXrvBEPSDzE 8n8WJDrRaRdnjQzOkQA0OpGZtGhSr9WE/iw0WAgwgl+UdjxIOMhVtZOf74+QItk3Wbn5 ununlLscJhkUHeVWw9/rbk02zZ6aPaqZiBBjodOimXglvqGIIT99CLaNEoZFOEnrYFzK flvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wuc3mpFwsNw512UrpRMNeFCO14RmPznMhRhpd8FRn9w=; b=hNVjKFydhvUP5AcwQL76H8Q0U8qCh2jIFYT/iK5W+nrDE2ylKv5eIlzEQu2RIUxuXU /t7moH6IWcESDdRg96hTmacJg46odXLHnL1oUeanHQbhmn/27Yr6I16HBmsj/2vjTLXf jSSV2UdYtRCe1F4yhZTxsgDXP425Pr9YOD3H4VsJ81ZA+e3PKAQRqDul3IUmVLDf1Vbd hkojFjJ9jONpbSt4dDqd0dHpKOoJw6XTYKIZ+cTyCchmxBweke5Q/oCo+MSFoOoiQgIt 81EQqS/nchBgI+vKTMulSuhjCpnnh8Ilw1gwRg9mcfUKEuN19VRuJL3/KQm3CFiLk34n Kp5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qFyrV+U7; 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 eb10si644681ejc.273.2021.02.25.02.04.29; Thu, 25 Feb 2021 02:04:51 -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=@kernel.org header.s=k20201202 header.b=qFyrV+U7; 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 S232923AbhBYJh3 (ORCPT + 99 others); Thu, 25 Feb 2021 04:37:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:49614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236530AbhBYJek (ORCPT ); Thu, 25 Feb 2021 04:34:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E19164EC3; Thu, 25 Feb 2021 09:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614245639; bh=8Do2C4WBXZBF/0ynfKiFsieMc4j7Q7V/sblXKRyy2/U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qFyrV+U7evW7a1f+VttInzAOAUpvh/39rN8QnzAN9k9HB7YfZPH4KOxvc6Letqy1g 33r3K8mSdgZiaytCB4/wa6mJEMPpBOUuV4iTnapx4mDRCNrmgIwHoaCgO9aMojTJY4 UioHSZV+6nfRm0PvDb0I/T2fOBrr33+5BeRqBU8vhOFLSY5qwkT/XKQN1vR5E6IFZl tePTPy2G7quKsSZMD5pk6y3yk8ob/oFVE+HtMGWki0EWP+6VaOCRX1JrI9IkrZXubZ u1P/oqS28P7nls4m0lyb+A64PXVmkWRMdGBRM2JMn9mJmMmOZ7gMJehS/zFOESgXV5 9FhNszGN9MMcA== Date: Thu, 25 Feb 2021 10:33:53 +0100 From: Robert Richter To: Dejin Zheng Cc: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] PCI: Introduce pcim_alloc_irq_vectors() Message-ID: References: <20210218150458.798347-1-zhengdejin5@gmail.com> <20210218150458.798347-2-zhengdejin5@gmail.com> <20210219164649.GA814637@nuc8i5> <20210222151415.GA896979@nuc8i5> <20210223141435.GA912403@nuc8i5> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210223141435.GA912403@nuc8i5> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.02.21 22:14:35, Dejin Zheng wrote: > On Tue, Feb 23, 2021 at 09:02:54AM +0100, Robert Richter wrote: > > On 22.02.21 23:14:15, Dejin Zheng wrote: > > > On Mon, Feb 22, 2021 at 11:56:08AM +0100, Robert Richter wrote: > > > > On 20.02.21 00:46:49, Dejin Zheng wrote: > > > > > > On 18.02.21 23:04:55, Dejin Zheng wrote: > > > > > > > > > > > + if (!dr || !dr->enabled) > > > > > here checks whether the pci device is enabled. > > > > > > > > What is the purpose of this? The device "is_managed" or not. > > > > > > > The device is managed or not by check whether "dr" is NULL. And > > > check the "dr->enabled" is for the PCI device enable. I think it > > > may not make sense to apply for irq vectors when PCI device is not > > > enabled. > > > > I don't see how a disabled device affects in any way the release of > > the irq vectors during device removal. dr is always non-null in case > > the device is managed, a check isn't needed for that. > > > Yes, the disabled device does not affect release irq vectors, But > the disabled device affects apply for irq vectors, It is wrong to apply > for the irq vectors when the device is not enabled. What is the scenario you have in mind here? What does happen then? The typical use case is to pcim_enable_device() it and then add the irq vectors. It is always enabled then. Even if the device could wrongly be disabled, it does not affect the device's release. Also, how is this related to pcim? There isn't a check in pci_alloc_irq_vectors() either for that case. > Add this check can > facilitate developers to find problems as soon as possible. No, there are many ways to shoot yourself in the foot. We cannot add checks here and there for this, esp. at runtime. If there is a valid reason that the device must always be enabled and we cannot assume this is the case, then we could add a WARN_ON(). But I doubt that. -Robert