Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1231451ybi; Fri, 21 Jun 2019 16:58:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwir+Ug9tzAlRgTW8Ws5kAEQTBe5fisnSArArB6Vi4gf4ttGYLWWQXDxU0uvwFvqIFeYAuf X-Received: by 2002:a63:5207:: with SMTP id g7mr15850296pgb.284.1561161496287; Fri, 21 Jun 2019 16:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561161496; cv=none; d=google.com; s=arc-20160816; b=pivDYKcd0peN4rCW6vb6Rw2pdQoMWdSzTK+VwGCVXHMsCr9mS7e0VqLxEdCex4G8gR Kol6P8AoqBKXBXgqdj1dLIun8qWkE1GY9jzBuzfa5K5GeNtlhxr9RikLqpp4+4KLPwPp 2aUajT9lctYSyOUNgYLUGvHnnxoaVFGKapSeg+tLqzcncRrrQ2S5BnhyzN++6BhIgws0 p4fBxh/3NuSqTijYgVBS1a9zk5KN6zO1LZVljhBVUeKdlc49EKyJJFpZmGJXxH36Ypmh h24N1bt5ThRKx3P5wlxCy7OHWDBgpjGJnlUEKO/BTbgFPhr4LLd8o9trVmC/9Y6zHPc9 GQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=RymYcdXNb1/dLWHS2907gcbkjeEqC85Yo1dnHipPkGY=; b=GjAdoMrpwwaqeadqN/O9Qq9j0j0Qu1kROOs9yQRiJ1vdWiUBtqH9g3Diyzm0M9/9qt ZdsdLKE/defBNIz8yEli0/XTkIdhDcnqpa2WSuru5qQngfX04wDh+56iPw/423mGGdYK wPOsxpeVbKW2mGleicHCPvlmmnlhKq/bgwCaIFEgUCuLQe0FLIA18aUDOuafpE5SH62k TN6/pL74cIpuGxU57H2ZLOf/OIA0uHhQbczihB03mvE9YtWFWMNKL8jrzKvZmKHz009l KajdEpNOjW5WjSfYCQ5WSnpLgfV1VEuXTTN6m5n5EZvjrha6/7yf+dl6NF/LLqggtv0Y O+LQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x188si4093788pfb.104.2019.06.21.16.58.01; Fri, 21 Jun 2019 16:58:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726434AbfFUX5l (ORCPT + 99 others); Fri, 21 Jun 2019 19:57:41 -0400 Received: from mga09.intel.com ([134.134.136.24]:48780 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfFUX5Y (ORCPT ); Fri, 21 Jun 2019 19:57:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2019 16:57:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,402,1557212400"; d="scan'208";a="359022898" Received: from megha-z97x-ud7-th.sc.intel.com ([143.183.85.162]) by fmsmga005.fm.intel.com with ESMTP; 21 Jun 2019 16:57:21 -0700 From: Megha Dey To: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, marc.zyngier@arm.com, ashok.raj@intel.com, jacob.jun.pan@linux.intel.com, megha.dey@intel.com, Megha Dey Subject: [RFC V1 RESEND 6/6] Documentation: PCI/MSI: Document dynamic MSI-X infrastructure Date: Fri, 21 Jun 2019 17:19:38 -0700 Message-Id: <1561162778-12669-7-git-send-email-megha.dey@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1561162778-12669-1-git-send-email-megha.dey@linux.intel.com> References: <1561162778-12669-1-git-send-email-megha.dey@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Documentation for the newly introduced dynamic allocation and deallocation of MSI-X vectors. Cc: Jacob Pan Cc: Ashok Raj Signed-off-by: Megha Dey --- Documentation/PCI/MSI-HOWTO.txt | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index 618e13d..5f6daf4 100644 --- a/Documentation/PCI/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt @@ -156,6 +156,44 @@ the driver can specify that only MSI or MSI-X is acceptable: if (nvec < 0) goto out_err; +4.2.1 Dynamic MSI-X Allocation: + +The pci_alloc_irq_vectors() API is a one-shot method to allocate MSI resources +i.e. they cannot be called multiple times. In order to allocate MSI-X vectors +post probe phase, multiple times, use the following API: + + int pci_alloc_irq_vectors_dyn(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, int *group_id); + +This API allocates up to max_vecs interrupt vectors for a PCI device. It returns +the number of vectors allocated or a negative error. If the device has a +requirement for a minimum number of vectors the driver can pass a min_vecs +argument set to this limit, and the PCI core will return -ENOSPC if it can't +meet the minimum number of vectors. This API is only to be used for MSI-X vectors. + +A group ID pointer is passed which gets populated by this function. A unique +group_id will associated with all the MSI-X vectors allocated each time this +function is called: + + int group_id; + nvec = pci_alloc_irq_vectors_dyn(pdev, minvecs, maxvecs, + flags | PCI_IRQ_MSIX, &group_id); + if (nvec < 0) + goto out_err; + +To get the Linux IRQ numbers to pass to request_irq() and free_irq(), use the +following function: + + int pci_irq_vec_grp(struct pci_dev *dev, unsigned int nr, unsigned int group_id); + +In order to free the MSI-X resources associated with a particular group, use +the following function: + + int pci_free_irq_vectors_grp(struct pci_dev *dev, int group_id); + +For example, to delete the group allocated with the pci_alloc_irq_vectors_dyn(), + nvec = pci_free_irq_vectors_grp(pdev, group_id); + 4.3 Legacy APIs The following old APIs to enable and disable MSI or MSI-X interrupts should -- 2.7.4