Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5133239pxb; Mon, 15 Feb 2021 10:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHue3bmfhGkja0AAKCsh5cPvHzKaVg86igcm1tWR+LwJdnRENEvbSA/B8RYEpTlhxe6kL/ X-Received: by 2002:a05:6402:5107:: with SMTP id m7mr17018858edd.52.1613413126406; Mon, 15 Feb 2021 10:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613413126; cv=none; d=google.com; s=arc-20160816; b=xlqMpZjtLsN0vVi8sBSl0Epj3GKS5B6F7SAPjZW0H8bENKOBryRiMnMMF3pHwjpyNG I2jfrptunQmom60q9LygP2WT/o6PELexTq4QbxFF9eKjuK0FlV6q8IBpJ4XOa2/Tw9Qf tPeF121/daLdEpJ82mxifo9Cj3extpWwp7fPNUJUYPXvURrwWYAopXhHoz3oVwUTHUmP pJbTsQBfjuEvGPqwWONcXlEVsNsaRD3yM0JtLilmq+1I2ug4If4HviqaxKejrnL5FbLp ABp296av8f3SOKasc67F1Dt1SDbfQizO2MLwSzn9Htb9ipSKo7Wh4BcT9H+OYq13zWHP ReCQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NWxmyj7Bp5pN/aMN4QfyoKCmw5EEMRBvUVT5cqlYd+I=; b=RI9Xf1R63MINDJ9tMSJ+zBQ/5Q1vhhOeTABse2Ix2fHLsXnavXSo0b5xfF2vXVvLO3 HNj9pN9WP1hQvIHc0MeOg9DUqIhsreE5Qg01fhJNzQ0tY6jv2XYK9XXtmpTPKk226EtU mV69qtTWQbEfnk73GNCvflfyYA9mffRusQr+RVrHwJIOBE8obLR2JYHcnCr++V11y2Ay DhrBBrw8zmAZBZuA/Mv0GOKalJ+tCNyQfc01nlBYYUnhgc3BkfO7nnySA0htgUh/jXh1 JtIzXTq8q6orgUX/B0p69gHQV2NYyB2cfb35K9oIv/TaWPcSbU0MgW6UaMSHetOJhhGG sFuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=js6qKmr0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs7si14815501ejc.128.2021.02.15.10.18.22; Mon, 15 Feb 2021 10:18:46 -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=@gmail.com header.s=20161025 header.b=js6qKmr0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230526AbhBOSQi (ORCPT + 99 others); Mon, 15 Feb 2021 13:16:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbhBOSQO (ORCPT ); Mon, 15 Feb 2021 13:16:14 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50DECC061574; Mon, 15 Feb 2021 10:15:58 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id o38so4651047pgm.9; Mon, 15 Feb 2021 10:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NWxmyj7Bp5pN/aMN4QfyoKCmw5EEMRBvUVT5cqlYd+I=; b=js6qKmr0DTmFPRdODmv5PsTpD17vhd0Cou4+q9nPUOS+/w3/vpzYalMzk0sFpqJO/n LTLPmu6XdlAoDjwNT7+WauXcbOVeuxcBczfuKn011MKhxJumr1PvWQJ1NkOMXIpX9PwI +2Zq/lMyAtUWT1Zr5bzbW7VT5rzY+SdZf63pjh0vFRplg75yo1eX8d6YGg3HmUHyeL0g Em9Qj1v9hUfUkHladIypOvoEM9TGJXA794IQuJ0UUnjtxabWBq3f61egr80SabAzpqAw 7m+M/UYxtBKU/bWqQTyhTZVX5JygZKqDsg9qcz2SkSZ26UwQVNQxSd+PdOCau8F4ZGrN FUTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NWxmyj7Bp5pN/aMN4QfyoKCmw5EEMRBvUVT5cqlYd+I=; b=a5tHS2bS4c55SiVh/5DPJH4yhXEfEk3R/SpHLicUI5JoI5BuXJsSm2oWMkADevQ8G1 PYSD2CJ+xlcTLfAl4c+FxGO0A295rMkUDjWQQlZOOv/he+fjkQZglDLrknM/E85tVWB6 XmiOOUG6X9529jZ/jPxBXywLmXRkSzGEhqEWUX+x21EWbLo5yWs5RmMH73zlIgXgbPTh uIgIh8/7qD4V5Z/HG2zPmhA9d5BisXbTz2TeeOM7J8E1+2F/ilaDbd3ypFAtexsCfEhZ fA7YJg+LG42vEx64BCNM56aHchf3iyobM1IjpAsFdlSdzI9Ti3oALmCWiuMcMuMZ0Du5 wWsQ== X-Gm-Message-State: AOAM531TG1GrRhLZVKUn2zElmJ/E8h9RkZsInKpQSxIY7A+F1ldbigDd fnpgVhuxxY5uTg2UNZLE6hc= X-Received: by 2002:a62:6304:0:b029:1c0:d62d:d213 with SMTP id x4-20020a6263040000b02901c0d62dd213mr16203137pfb.79.1613412957932; Mon, 15 Feb 2021 10:15:57 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id z2sm19202572pfj.100.2021.02.15.10.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 10:15:57 -0800 (PST) From: Dejin Zheng To: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v1 1/4] PCI: Introduce pcim_alloc_irq_vectors() Date: Tue, 16 Feb 2021 02:15:47 +0800 Message-Id: <20210215181550.714101-2-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210215181550.714101-1-zhengdejin5@gmail.com> References: <20210215181550.714101-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce pcim_alloc_irq_vectors(), a explicit device-managed version of pci_alloc_irq_vectors(). Suggested-by: Andy Shevchenko Signed-off-by: Dejin Zheng --- drivers/pci/pci.c | 19 +++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b67c4327d307..33244b512057 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2054,6 +2054,25 @@ void pcim_pin_device(struct pci_dev *pdev) } EXPORT_SYMBOL(pcim_pin_device); +/** + * pcim_alloc_irq_vectors - a device-managed pci_alloc_irq_vectors() + * + * It depends on calling pcim_enable_device() to make irq resources manageable. + */ +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags) +{ + struct pci_devres *dr; + + /*Ensure that the pcim_enable_device() function has been called*/ + dr = find_pci_dr(dev); + if (!dr || !dr->enabled) + return -EINVAL; + + return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags); +} +EXPORT_SYMBOL(pcim_alloc_irq_vectors); + /* * pcibios_add_device - provide arch specific hooks when adding device dev * @dev: the PCI device being added diff --git a/include/linux/pci.h b/include/linux/pci.h index 86c799c97b77..d75ba85ddfc5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1818,6 +1818,9 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, NULL); } +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags); + /* Include architecture-dependent settings and functions */ #include -- 2.25.0