* [PATCH RFC 36/77] ipr: Enable MSI-X when IPR_USE_MSIX type is set, not IPR_USE_MSI
[not found] ` <2d4272136269f3cb3b1a5ac53b12aa45c7ea65c0.1380703263.git.agordeev@redhat.com>
@ 2013-10-02 19:31 ` Brian King
0 siblings, 0 replies; 53+ messages in thread
From: Brian King @ 2013-10-02 19:31 UTC (permalink / raw)
On 10/02/2013 05:48 AM, Alexander Gordeev wrote:
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/scsi/ipr.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
> index fb57e21..762a93e 100644
> --- a/drivers/scsi/ipr.c
> +++ b/drivers/scsi/ipr.c
> @@ -9527,7 +9527,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,
> ipr_number_of_msix = IPR_MAX_MSIX_VECTORS;
> }
>
> - if (ioa_cfg->ipr_chip->intr_type == IPR_USE_MSI &&
> + if (ioa_cfg->ipr_chip->intr_type == IPR_USE_MSIX &&
> ipr_enable_msix(ioa_cfg) == 0)
> ioa_cfg->intr_flag = IPR_USE_MSIX;
> else if (ioa_cfg->ipr_chip->intr_type == IPR_USE_MSI &&
>
Nack. ioa_cfg->ipr_chip->intr_type gets initialized from the ipr_chip table
at the top of the driver which never sets intr_type to IPR_USE_MSIX, so this
will break MSI-X support for ipr.
We indicate at the chip level only whether we want to force LSI or whether
we want to enable MSI / MSI-X and then try enabling MSI-X and fall back to
MSI if MSI-X is not available or does not work. We then set intr_flag to indicate
what we are actually using on the specific adapter.
Thanks,
Brian
--
Brian King
Power Linux I/O
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 40/77] ixgbevf: Update MSI/MSI-X interrupts enablement code
[not found] ` <338c9012577acf694eb23622902185584987bd8f.1380703263.git.agordeev@redhat.com>
@ 2013-10-02 20:50 ` Keller, Jacob E
0 siblings, 0 replies; 53+ messages in thread
From: Keller, Jacob E @ 2013-10-02 20:50 UTC (permalink / raw)
On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
> As result of recent re-design of the MSI/MSI-X interrupts enabling
> pattern this driver has to be updated to use the new technique to
> obtain a optimal number of MSI/MSI-X interrupts required.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 18 +++++++-----------
> 1 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> index fa0537a..d506a01 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
> @@ -1749,8 +1749,7 @@ void ixgbevf_reset(struct ixgbevf_adapter *adapter)
> static int ixgbevf_acquire_msix_vectors(struct ixgbevf_adapter *adapter,
> int vectors)
> {
> - int err = 0;
> - int vector_threshold;
> + int err, vector_threshold;
>
> /* We'll want at least 2 (vector_threshold):
> * 1) TxQ[0] + RxQ[0] handler
> @@ -1763,18 +1762,15 @@ static int ixgbevf_acquire_msix_vectors(struct ixgbevf_adapter *adapter,
> * Right now, we simply care about how many we'll get; we'll
> * set them up later while requesting irq's.
> */
> - while (vectors >= vector_threshold) {
> - err = pci_enable_msix(adapter->pdev, adapter->msix_entries,
> - vectors);
> - if (!err || err < 0) /* Success or a nasty failure. */
> - break;
> - else /* err == number of vectors we should try again with */
> - vectors = err;
> - }
> + err = pci_msix_table_size(adapter->pdev);
I would prefer to use something other than "err" here since the value
isn't really an error if it's greater than 0. However, it's not really a
big issue, since you immediately conver to using vectors on the next
line of code.. I think its alright overall.
Regards,
Jake
> + if (err < 0)
> + return err;
>
> + vectors = min(vectors, err);
> if (vectors < vector_threshold)
> - err = -ENOSPC;
> + return -ENOSPC;
>
> + err = pci_enable_msix(adapter->pdev, adapter->msix_entries, vectors);
> if (err) {
> dev_err(&adapter->pdev->dev,
> "Unable to allocate MSI-X interrupts\n");
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 77/77] vxge: Update MSI/MSI-X interrupts enablement code
[not found] ` <467ce10b1df795edf80ed222816ab739fee7b0ea.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 0:29 ` Jon Mason
0 siblings, 0 replies; 53+ messages in thread
From: Jon Mason @ 2013-10-03 0:29 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:49:33PM +0200, Alexander Gordeev wrote:
> As result of recent re-design of the MSI/MSI-X interrupts enabling
> pattern this driver has to be updated to use the new technique to
> obtain a optimal number of MSI/MSI-X interrupts required.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/net/ethernet/neterion/vxge/vxge-main.c | 36 ++++++++++-------------
> 1 files changed, 16 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
> index b81ff8b..b4d40dd 100644
> --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
> +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
> @@ -2297,7 +2297,21 @@ static int vxge_alloc_msix(struct vxgedev *vdev)
> int msix_intr_vect = 0, temp;
> vdev->intr_cnt = 0;
>
> -start:
> + ret = pci_msix_table_size(vdev->pdev);
> + if (ret < 0)
> + goto alloc_entries_failed;
> +
> + if (ret < (vdev->no_of_vpath * 2 + 1)) {
> + if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) {
> + ret = -ENOSPC;
> + goto alloc_entries_failed;
> + }
> + /* Try with less no of vector by reducing no of vpaths count */
> + temp = (ret - 1)/2;
> + vxge_close_vpaths(vdev, temp);
> + vdev->no_of_vpath = temp;
> + }
The original code was ugly (not my code, so I can say that). I'd like
to see it a little stream lined. Something like:
vdev->intr_cnt = pci_msix_table_size(vdev->pdev);
if (vdev->intr_cnt % 2 == 0)
vdev->intr_cnt--;
if (vdev->intr_cnt < 3 || max_config_vpath != VXGE_USE_DEFAULT)
goto alloc_entries_failed;
if (vdev->intr_cnt != vdev->no_of_vpath * 2 + 1) {
vxge_close_vpaths(vdev, vdev->intr_cnt / 2);
vdev->no_of_vpath = vdev->intr_cnt / 2;
}
> +
> /* Tx/Rx MSIX Vectors count */
> vdev->intr_cnt = vdev->no_of_vpath * 2;
>
> @@ -2347,25 +2361,7 @@ start:
> vdev->vxge_entries[j].in_use = 0;
>
> ret = pci_enable_msix(vdev->pdev, vdev->entries, vdev->intr_cnt);
> - if (ret > 0) {
> - vxge_debug_init(VXGE_ERR,
> - "%s: MSI-X enable failed for %d vectors, ret: %d",
> - VXGE_DRIVER_NAME, vdev->intr_cnt, ret);
> - if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3)) {
> - ret = -ENOSPC;
> - goto enable_msix_failed;
> - }
> -
> - kfree(vdev->entries);
> - kfree(vdev->vxge_entries);
> - vdev->entries = NULL;
> - vdev->vxge_entries = NULL;
> - /* Try with less no of vector by reducing no of vpaths count */
> - temp = (ret - 1)/2;
> - vxge_close_vpaths(vdev, temp);
> - vdev->no_of_vpath = temp;
> - goto start;
> - } else if (ret < 0)
> + if (ret)
> goto enable_msix_failed;
Nit, space here please.
> return 0;
>
> --
> 1.7.7.6
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 01/77] PCI/MSI: Fix return value when populate_msi_sysfs() failed
[not found] ` <3ff5236944aae69f2cd934b5b6da7c1c269df7c1.1380703262.git.agordeev@redhat.com>
@ 2013-10-03 0:39 ` Jon Mason
0 siblings, 0 replies; 53+ messages in thread
From: Jon Mason @ 2013-10-03 0:39 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:48:17PM +0200, Alexander Gordeev wrote:
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
Since you are changing the behavior of the msix_capability_init
function on populate_msi_sysfs error, a comment describing why in this
commit would be nice.
> ---
> drivers/pci/msi.c | 11 +++++------
> 1 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index d5f90d6..b43f391 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -719,7 +719,7 @@ static int msix_capability_init(struct pci_dev *dev,
>
> ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
> if (ret)
> - goto error;
> + goto out_avail;
>
> /*
> * Some devices require MSI-X to be enabled before we can touch the
> @@ -732,10 +732,8 @@ static int msix_capability_init(struct pci_dev *dev,
> msix_program_entries(dev, entries);
>
> ret = populate_msi_sysfs(dev);
> - if (ret) {
> - ret = 0;
> - goto error;
> - }
> + if (ret)
> + goto out_free;
>
> /* Set MSI-X enabled bits and unmask the function */
> pci_intx_for_msi(dev, 0);
> @@ -746,7 +744,7 @@ static int msix_capability_init(struct pci_dev *dev,
>
> return 0;
>
> -error:
> +out_avail:
> if (ret < 0) {
> /*
> * If we had some success, report the number of irqs
> @@ -763,6 +761,7 @@ error:
> ret = avail;
> }
>
> +out_free:
> free_msi_irqs(dev);
>
> return ret;
> --
> 1.7.7.6
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt
[not found] ` <5d9c5b2d3bbc444ff32bddeece7a239d046bd79c.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 0:48 ` Jon Mason
2013-10-05 21:43 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Jon Mason @ 2013-10-03 0:48 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:49:10PM +0200, Alexander Gordeev wrote:
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/ntb/ntb_hw.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> index de2062c..eccd5e5 100644
> --- a/drivers/ntb/ntb_hw.c
> +++ b/drivers/ntb/ntb_hw.c
> @@ -1066,7 +1066,7 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> /* On SNB, the link interrupt is always tied to 4th vector. If
> * we can't get all 4, then we can't use MSI-X.
> */
> - if (ndev->hw_type != BWD_HW) {
> + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
Nack, this check is unnecessary.
Also, no comment in the commit on why it could be necessary.
> rc = -EIO;
> goto err1;
> }
> --
> 1.7.7.6
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 53/77] ntb: Fix missed call to pci_enable_msix()
[not found] ` <0590d63c3432229a3824bada71e07a08fb955498.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 0:49 ` Jon Mason
0 siblings, 0 replies; 53+ messages in thread
From: Jon Mason @ 2013-10-03 0:49 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:49:09PM +0200, Alexander Gordeev wrote:
> Current MSI-X enablement code assumes MSI-Xs were successfully
> allocated in case less than requested vectors were available.
> That assumption is wrong, since MSI-Xs should be enabled with
> a repeated call to pci_enable_msix(). This update fixes this.
Good catch, I'll pull it in for my next NTB release.
Thanks,
Jon
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/ntb/ntb_hw.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> index 1cb6e51..de2062c 100644
> --- a/drivers/ntb/ntb_hw.c
> +++ b/drivers/ntb/ntb_hw.c
> @@ -1075,6 +1075,10 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> "Only %d MSI-X vectors. Limiting the number of queues to that number.\n",
> rc);
> msix_entries = rc;
> +
> + rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries);
> + if (rc)
> + goto err1;
> }
>
> for (i = 0; i < msix_entries; i++) {
> --
> 1.7.7.6
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 55/77] ntb: Update MSI/MSI-X interrupts enablement code
[not found] ` <49eb592e15aaec804f9c11ca132d2b85c516aefa.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 1:02 ` Jon Mason
0 siblings, 0 replies; 53+ messages in thread
From: Jon Mason @ 2013-10-03 1:02 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:49:11PM +0200, Alexander Gordeev wrote:
> As result of recent re-design of the MSI/MSI-X interrupts enabling
> pattern this driver has to be updated to use the new technique to
> obtain a optimal number of MSI/MSI-X interrupts required.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> drivers/ntb/ntb_hw.c | 41 +++++++++++++----------------------------
> drivers/ntb/ntb_hw.h | 2 --
> 2 files changed, 13 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> index eccd5e5..7776429 100644
> --- a/drivers/ntb/ntb_hw.c
> +++ b/drivers/ntb/ntb_hw.c
> @@ -1032,23 +1032,26 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> struct msix_entry *msix;
> int msix_entries;
> int rc, i;
> - u16 val;
>
> - if (!pdev->msix_cap) {
> - rc = -EIO;
> + rc = pci_msix_table_size(pdev);
> + if (rc < 0)
> goto err;
> - }
>
> - rc = pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &val);
> - if (rc)
> + /*
> + * On SNB, the link interrupt is always tied to 4th vector. If
> + * we can't get all 4, then we can't use MSI-X.
> + */
> + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
Please check for the HW type first, and then compare to
ndev->limits.msix_cnt (which will be SNB_MSIX_CNT on SNB HW). Also,
put the comment inside the if statement and remove the unecessary "()"
around the comparisons. OCD on my part, but I like it that way.
> + rc = -ENOSPC;
> goto err;
> -
> - msix_entries = msix_table_size(val);
> - if (msix_entries > ndev->limits.msix_cnt) {
> + }
else if...
> + if (rc > ndev->limits.msix_cnt) {
> rc = -EINVAL;
> goto err;
> }
>
> + msix_entries = rc;
> +
> ndev->msix_entries = kmalloc(sizeof(struct msix_entry) * msix_entries,
> GFP_KERNEL);
> if (!ndev->msix_entries) {
> @@ -1060,26 +1063,8 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> ndev->msix_entries[i].entry = i;
>
> rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries);
> - if (rc < 0)
> + if (rc)
> goto err1;
> - if (rc > 0) {
> - /* On SNB, the link interrupt is always tied to 4th vector. If
> - * we can't get all 4, then we can't use MSI-X.
> - */
> - if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
> - rc = -EIO;
> - goto err1;
> - }
> -
> - dev_warn(&pdev->dev,
> - "Only %d MSI-X vectors. Limiting the number of queues to that number.\n",
> - rc);
> - msix_entries = rc;
> -
> - rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries);
> - if (rc)
> - goto err1;
> - }
>
> for (i = 0; i < msix_entries; i++) {
> msix = &ndev->msix_entries[i];
> diff --git a/drivers/ntb/ntb_hw.h b/drivers/ntb/ntb_hw.h
> index 0a31ced..50bd760 100644
> --- a/drivers/ntb/ntb_hw.h
> +++ b/drivers/ntb/ntb_hw.h
> @@ -60,8 +60,6 @@
> #define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F
> #define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E
>
> -#define msix_table_size(control) ((control & PCI_MSIX_FLAGS_QSIZE)+1)
Good riddance! :-)
> -
> #ifndef readq
> static inline u64 readq(void __iomem *addr)
> {
> --
> 1.7.7.6
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 50/77] mlx5: Update MSI/MSI-X interrupts enablement code
[not found] ` <9650a7dfbcfd5f1da21f7b093665abf4b1041071.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 7:14 ` Eli Cohen
2013-10-03 19:48 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Eli Cohen @ 2013-10-03 7:14 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:49:06PM +0200, Alexander Gordeev wrote:
>
> + err = pci_msix_table_size(dev->pdev);
> + if (err < 0)
> + return err;
> +
> nvec = dev->caps.num_ports * num_online_cpus() + MLX5_EQ_VEC_COMP_BASE;
> nvec = min_t(int, nvec, num_eqs);
> + nvec = min_t(int, nvec, err);
> if (nvec <= MLX5_EQ_VEC_COMP_BASE)
> return -ENOSPC;
Making sure we don't request more vectors then the device's is capable
of -- looks good.
>
> @@ -131,20 +136,15 @@ static int mlx5_enable_msix(struct mlx5_core_dev *dev)
> for (i = 0; i < nvec; i++)
> table->msix_arr[i].entry = i;
>
> -retry:
> - table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE;
> err = pci_enable_msix(dev->pdev, table->msix_arr, nvec);
> - if (err <= 0) {
> + if (err) {
> + kfree(table->msix_arr);
> return err;
> - } else if (err > MLX5_EQ_VEC_COMP_BASE) {
> - nvec = err;
> - goto retry;
> }
>
According to latest sources, pci_enable_msix() may still fail so why
do you want to remove this code?
> - mlx5_core_dbg(dev, "received %d MSI vectors out of %d requested\n", err, nvec);
> - kfree(table->msix_arr);
> + table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE;
>
> - return -ENOSPC;
> + return 0;
> }
>
> static void mlx5_disable_msix(struct mlx5_core_dev *dev)
> --
> 1.7.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 51/77] mthca: Update MSI/MSI-X interrupts enablement code
[not found] ` <9d424912ef78993dc75e2af5006cd12913e9e7e7.1380703263.git.agordeev@redhat.com>
@ 2013-10-03 16:11 ` Jack Morgenstein
0 siblings, 0 replies; 53+ messages in thread
From: Jack Morgenstein @ 2013-10-03 16:11 UTC (permalink / raw)
On Wed, 2 Oct 2013 12:49:07 +0200
Alexander Gordeev <agordeev@redhat.com> wrote:
> Subject: [PATCH RFC 51/77] mthca: Update MSI/MSI-X interrupts
> enablement code Date: Wed, 2 Oct 2013 12:49:07 +0200
> Sender: linux-rdma-owner at vger.kernel.org
> X-Mailer: git-send-email 1.7.7.6
>
> As result of recent re-design of the MSI/MSI-X interrupts enabling
> pattern this driver has to be updated to use the new technique to
> obtain a optimal number of MSI/MSI-X interrupts required.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
ACK.
-Jack
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 50/77] mlx5: Update MSI/MSI-X interrupts enablement code
2013-10-03 7:14 ` [PATCH RFC 50/77] mlx5: " Eli Cohen
@ 2013-10-03 19:48 ` Alexander Gordeev
2013-10-10 15:29 ` Eli Cohen
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-03 19:48 UTC (permalink / raw)
On Thu, Oct 03, 2013@10:14:33AM +0300, Eli Cohen wrote:
> On Wed, Oct 02, 2013@12:49:06PM +0200, Alexander Gordeev wrote:
> >
> > + err = pci_msix_table_size(dev->pdev);
> > + if (err < 0)
> > + return err;
> > +
> > nvec = dev->caps.num_ports * num_online_cpus() + MLX5_EQ_VEC_COMP_BASE;
> > nvec = min_t(int, nvec, num_eqs);
> > + nvec = min_t(int, nvec, err);
> > if (nvec <= MLX5_EQ_VEC_COMP_BASE)
> > return -ENOSPC;
>
> Making sure we don't request more vectors then the device's is capable
> of -- looks good.
> >
> > @@ -131,20 +136,15 @@ static int mlx5_enable_msix(struct mlx5_core_dev *dev)
> > for (i = 0; i < nvec; i++)
> > table->msix_arr[i].entry = i;
> >
> > -retry:
> > - table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE;
> > err = pci_enable_msix(dev->pdev, table->msix_arr, nvec);
> > - if (err <= 0) {
> > + if (err) {
> > + kfree(table->msix_arr);
> > return err;
> > - } else if (err > MLX5_EQ_VEC_COMP_BASE) {
> > - nvec = err;
> > - goto retry;
> > }
> >
>
> According to latest sources, pci_enable_msix() may still fail so why
> do you want to remove this code?
pci_enable_msix() may fail, but it can not return a positive number.
We first calculate how many MSI-Xs we need, adjust to what we can get,
check if that is enough and only then go for it.
> > - mlx5_core_dbg(dev, "received %d MSI vectors out of %d requested\n", err, nvec);
> > - kfree(table->msix_arr);
> > + table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE;
> >
> > - return -ENOSPC;
> > + return 0;
> > }
> >
> > static void mlx5_disable_msix(struct mlx5_core_dev *dev)
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 06/77] PCI/MSI: Factor out pci_get_msi_cap() interface
[not found] ` <9c282c4ab92731c719d161d2db6fc54ce33891d9.1380703262.git.agordeev@redhat.com>
@ 2013-10-03 21:52 ` Ben Hutchings
2013-10-04 5:13 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Ben Hutchings @ 2013-10-03 21:52 UTC (permalink / raw)
On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
[...]
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -812,6 +812,21 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
> return 0;
> }
>
> +int pci_get_msi_cap(struct pci_dev *dev)
> +{
> + int ret;
> + u16 msgctl;
> +
> + if (!dev->msi_cap)
> + return -EINVAL;
[...]
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1144,6 +1144,11 @@ struct msix_entry {
>
>
> #ifndef CONFIG_PCI_MSI
> +static inline int pci_get_msi_cap(struct pci_dev *dev)
> +{
> + return -1;
[...]
Shouldn't this also return -EINVAL?
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
[not found] <cover.1380703262.git.agordeev@redhat.com>
` (9 preceding siblings ...)
[not found] ` <9c282c4ab92731c719d161d2db6fc54ce33891d9.1380703262.git.agordeev@redhat.com>
@ 2013-10-03 22:49 ` Ben Hutchings
2013-10-04 8:29 ` Alexander Gordeev
[not found] ` <8c9811b13fd93e73641dab8e3bd1bd5b2dc37a61.1380703262.git.agordeev@redhat.com>
` (7 subsequent siblings)
18 siblings, 1 reply; 53+ messages in thread
From: Ben Hutchings @ 2013-10-03 22:49 UTC (permalink / raw)
On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
> This series is against "next" branch in Bjorn's repo:
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>
> Currently pci_enable_msi_block() and pci_enable_msix() interfaces
> return a error code in case of failure, 0 in case of success and a
> positive value which indicates the number of MSI-X/MSI interrupts
> that could have been allocated. The latter value should be passed
> to a repeated call to the interfaces until a failure or success:
>
>
> for (i = 0; i < FOO_DRIVER_MAXIMUM_NVEC; i++)
> adapter->msix_entries[i].entry = i;
>
> while (nvec >= FOO_DRIVER_MINIMUM_NVEC) {
> rc = pci_enable_msix(adapter->pdev,
> adapter->msix_entries, nvec);
> if (rc > 0)
> nvec = rc;
> else
> return rc;
> }
>
> return -ENOSPC;
>
>
> This technique proved to be confusing and error-prone. Vast share
> of device drivers simply fail to follow the described guidelines.
>
> This update converts pci_enable_msix() and pci_enable_msi_block()
> interfaces to canonical kernel functions and makes them return a
> error code in case of failure or 0 in case of success.
[...]
I think this is fundamentally flawed: pci_msix_table_size() and
pci_get_msi_cap() can only report the limits of the *device* (which the
driver usually already knows), whereas MSI allocation can also be
constrained due to *global* limits on the number of distinct IRQs.
Currently pci_enable_msix() will report a positive value if it fails due
to the global limit. Your patch 7 removes that. pci_enable_msi_block()
unfortunately doesn't appear to do this.
It seems to me that a more useful interface would take a minimum and
maximum number of vectors from the driver. This wouldn't allow the
driver to specify that it could only accept, say, any even number within
a certain range, but you could still leave the current functions
available for any driver that needs that.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 06/77] PCI/MSI: Factor out pci_get_msi_cap() interface
2013-10-03 21:52 ` [PATCH RFC 06/77] PCI/MSI: Factor out pci_get_msi_cap() interface Ben Hutchings
@ 2013-10-04 5:13 ` Alexander Gordeev
0 siblings, 0 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-04 5:13 UTC (permalink / raw)
On Thu, Oct 03, 2013@10:52:54PM +0100, Ben Hutchings wrote:
> On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
> > #ifndef CONFIG_PCI_MSI
> > +static inline int pci_get_msi_cap(struct pci_dev *dev)
> > +{
> > + return -1;
> [...]
>
> Shouldn't this also return -EINVAL?
Yep, all inliners here are better to return -EINVAL.
Will do unless someone speaks out against.
> Ben.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 03/77] PCI/MSI/s390: Fix single MSI only check
[not found] ` <8c9811b13fd93e73641dab8e3bd1bd5b2dc37a61.1380703262.git.agordeev@redhat.com>
@ 2013-10-04 7:39 ` Martin Schwidefsky
0 siblings, 0 replies; 53+ messages in thread
From: Martin Schwidefsky @ 2013-10-04 7:39 UTC (permalink / raw)
On Wed, 2 Oct 2013 12:48:19 +0200
Alexander Gordeev <agordeev@redhat.com> wrote:
> Multiple MSIs have never been supported on s390 architecture,
> but the platform code fails to report single MSI only.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> arch/s390/pci/pci.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index f17a834..c79c6e4 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -427,6 +427,8 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
> pr_debug("%s: requesting %d MSI-X interrupts...", __func__, nvec);
> if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
> return -EINVAL;
> + if (type == PCI_CAP_ID_MSI && nvec > 1)
> + return 1;
> msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
> msi_vecs = min_t(unsigned int, msi_vecs, CONFIG_PCI_NR_MSI);
>
Acked-by: Martin Schwidefsky <schwidefsky at de.ibm.com>
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 04/77] PCI/MSI/s390: Remove superfluous check of MSI type
[not found] ` <bae65aa3e30dfd23bd5ed47add7310cfbb96243a.1380703262.git.agordeev@redhat.com>
@ 2013-10-04 7:40 ` Martin Schwidefsky
0 siblings, 0 replies; 53+ messages in thread
From: Martin Schwidefsky @ 2013-10-04 7:40 UTC (permalink / raw)
On Wed, 2 Oct 2013 12:48:20 +0200
Alexander Gordeev <agordeev@redhat.com> wrote:
> arch_setup_msi_irqs() hook can only be called from the generic
> MSI code which ensures correct MSI type parameter.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> ---
> arch/s390/pci/pci.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index c79c6e4..61a3c2c 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -425,8 +425,6 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
> int rc;
>
> pr_debug("%s: requesting %d MSI-X interrupts...", __func__, nvec);
> - if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
> - return -EINVAL;
> if (type == PCI_CAP_ID_MSI && nvec > 1)
> return 1;
> msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
Acked-by: Martin Schwidefsky <schwidefsky at de.ibm.com>
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-03 22:49 ` [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern Ben Hutchings
@ 2013-10-04 8:29 ` Alexander Gordeev
2013-10-04 8:31 ` David Laight
2013-10-04 21:29 ` Ben Hutchings
0 siblings, 2 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-04 8:29 UTC (permalink / raw)
On Thu, Oct 03, 2013@11:49:45PM +0100, Ben Hutchings wrote:
> On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
> > This update converts pci_enable_msix() and pci_enable_msi_block()
> > interfaces to canonical kernel functions and makes them return a
> > error code in case of failure or 0 in case of success.
> [...]
>
> I think this is fundamentally flawed: pci_msix_table_size() and
> pci_get_msi_cap() can only report the limits of the *device* (which the
> driver usually already knows), whereas MSI allocation can also be
> constrained due to *global* limits on the number of distinct IRQs.
Even the current implementation by no means addresses it. Although it
might seem a case for architectures to report the number of IRQs available
for a driver to retry, in fact they all just fail. The same applies to
*any* other type of resource involved: irq_desc's, CPU interrupt vector
space, msi_desc's etc. No platform cares about it and just bails out once
a constrain met (please correct me if I am wrong here). Given that Linux
has been doing well even on embedded I think we should not change it.
The only exception to the above is pSeries platform which takes advantage
of the current design (to implement MSI quota). There are indications we
can satisfy pSeries requirements, but the design proposed in this RFC
is not going to change drastically anyway. The start of the discusstion
is here: https://lkml.org/lkml/2013/9/5/293
> Currently pci_enable_msix() will report a positive value if it fails due
> to the global limit. Your patch 7 removes that. pci_enable_msi_block()
> unfortunately doesn't appear to do this.
pci_enable_msi_block() can do more than one MSI only on x86 (with IOMMU),
but it does not bother to return positive numbers, indeed.
> It seems to me that a more useful interface would take a minimum and
> maximum number of vectors from the driver. This wouldn't allow the
> driver to specify that it could only accept, say, any even number within
> a certain range, but you could still leave the current functions
> available for any driver that needs that.
Mmmm.. I am not sure I am getting it. Could you please rephrase?
> Ben.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-04 8:29 ` Alexander Gordeev
@ 2013-10-04 8:31 ` David Laight
2013-10-04 9:21 ` Alexander Gordeev
2013-10-04 21:29 ` Ben Hutchings
1 sibling, 1 reply; 53+ messages in thread
From: David Laight @ 2013-10-04 8:31 UTC (permalink / raw)
> > It seems to me that a more useful interface would take a minimum and
> > maximum number of vectors from the driver. This wouldn't allow the
> > driver to specify that it could only accept, say, any even number within
> > a certain range, but you could still leave the current functions
> > available for any driver that needs that.
>
> Mmmm.. I am not sure I am getting it. Could you please rephrase?
One possibility is for drivers than can use a lot of interrupts to
request a minimum number initially and then request the additional
ones much later on.
That would make it less likely that none will be available for
devices/drivers that need them but are initialised later.
David
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-04 8:31 ` David Laight
@ 2013-10-04 9:21 ` Alexander Gordeev
0 siblings, 0 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-04 9:21 UTC (permalink / raw)
On Fri, Oct 04, 2013@09:31:49AM +0100, David Laight wrote:
> > Mmmm.. I am not sure I am getting it. Could you please rephrase?
>
> One possibility is for drivers than can use a lot of interrupts to
> request a minimum number initially and then request the additional
> ones much later on.
> That would make it less likely that none will be available for
> devices/drivers that need them but are initialised later.
It sounds as a whole new topic for me. Isn't it?
Anyway, what prevents the above from being done with pci_enable_msix(nvec1) -
pci_disable_msix() - pci_enable_msix(nvec2) where nvec1 < nvec2?
> David
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-04 8:29 ` Alexander Gordeev
2013-10-04 8:31 ` David Laight
@ 2013-10-04 21:29 ` Ben Hutchings
2013-10-05 14:20 ` Alexander Gordeev
1 sibling, 1 reply; 53+ messages in thread
From: Ben Hutchings @ 2013-10-04 21:29 UTC (permalink / raw)
On Fri, 2013-10-04@10:29 +0200, Alexander Gordeev wrote:
> On Thu, Oct 03, 2013@11:49:45PM +0100, Ben Hutchings wrote:
> > On Wed, 2013-10-02@12:48 +0200, Alexander Gordeev wrote:
> > > This update converts pci_enable_msix() and pci_enable_msi_block()
> > > interfaces to canonical kernel functions and makes them return a
> > > error code in case of failure or 0 in case of success.
> > [...]
> >
> > I think this is fundamentally flawed: pci_msix_table_size() and
> > pci_get_msi_cap() can only report the limits of the *device* (which the
> > driver usually already knows), whereas MSI allocation can also be
> > constrained due to *global* limits on the number of distinct IRQs.
>
> Even the current implementation by no means addresses it. Although it
> might seem a case for architectures to report the number of IRQs available
> for a driver to retry, in fact they all just fail. The same applies to
> *any* other type of resource involved: irq_desc's, CPU interrupt vector
> space, msi_desc's etc. No platform cares about it and just bails out once
> a constrain met (please correct me if I am wrong here). Given that Linux
> has been doing well even on embedded I think we should not change it.
>
> The only exception to the above is pSeries platform which takes advantage
> of the current design (to implement MSI quota). There are indications we
> can satisfy pSeries requirements, but the design proposed in this RFC
> is not going to change drastically anyway. The start of the discusstion
> is here: https://lkml.org/lkml/2013/9/5/293
All I can see there is that Tejun didn't think that the global limits
and positive return values were implemented by any architecture. But
you have a counter-example, so I'm not sure what your point is.
It has been quite a while since I saw this happen on x86. But I just
checked on a test system running RHEL 5 i386 (Linux 2.6.18). If I ask
for 16 MSI-X vectors on a device that supports 1024, the return value is
8, and indeed I can then successfully allocate 8.
Now that's going quite a way back, and it may be that global limits
aren't a significant problem any more. With the x86_64 build of RHEL 5
on an identical system, I can allocate 16 or even 32, so this is
apparently not a hardware limit in this case.
> > Currently pci_enable_msix() will report a positive value if it fails due
> > to the global limit. Your patch 7 removes that. pci_enable_msi_block()
> > unfortunately doesn't appear to do this.
>
> pci_enable_msi_block() can do more than one MSI only on x86 (with IOMMU),
> but it does not bother to return positive numbers, indeed.
>
> > It seems to me that a more useful interface would take a minimum and
> > maximum number of vectors from the driver. This wouldn't allow the
> > driver to specify that it could only accept, say, any even number within
> > a certain range, but you could still leave the current functions
> > available for any driver that needs that.
>
> Mmmm.. I am not sure I am getting it. Could you please rephrase?
Most drivers seem to either:
(a) require exactly a certain number of MSI vectors, or
(b) require a minimum number of MSI vectors, usually want to allocate
more, and work with any number in between
We can support drivers in both classes by adding new allocation
functions that allow specifying a minimum (required) and maximum
(wanted) number of MSI vectors. Those in class (a) would just specify
the same value for both. These new functions can take account of any
global limit or allocation policy without any further changes to the
drivers that use them.
The few drivers with more specific requirements would still need to
implement the currently recommended loop, using the old allocation
functions.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-04 21:29 ` Ben Hutchings
@ 2013-10-05 14:20 ` Alexander Gordeev
2013-10-05 21:46 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-05 14:20 UTC (permalink / raw)
On Fri, Oct 04, 2013@10:29:16PM +0100, Ben Hutchings wrote:
> On Fri, 2013-10-04@10:29 +0200, Alexander Gordeev wrote:
> All I can see there is that Tejun didn't think that the global limits
> and positive return values were implemented by any architecture.
I would say more than just that :) I picked few quotes which in my
reading represent the guys positions:
Tejun Heo: "...do we really
care about possible partial success? This sort of interface is
unnecessarily complex and actively harmful. It forces all users to
wonder what could possibly happen and implement all sorts of nutty
fallback logic which is highly likely to be error-prone on both the
software and hardware side. Seriously, how much testing would such
code path would get both on the driver and firmware sides?"
Bjorn Helgaas: "I agree, that would be much simpler.
I propose that you rework it that way, and at least find out what
(if anything) would break if we do that."
Michael Ellerman: "I really think you're overstating the complexity here.
Functions typically return a boolean -> nothing to see here
This function returns a tristate value -> brain explosion!";
"All a lot of bother for no real gain IMHO."
> But you have a counter-example, so I'm not sure what your point is.
I concur with Tejun. I think we need to get rid of the loop.
As of the counter-example I think we could honour the pSeries quota by
inroducing an interface to interrogate what you call global limits -
pci_get_msix_limit(), i.e.:
rc = pci_msix_table_size(pdev, nvec);
if (rc < 0)
return rc;
nvec = min(rc, nvec);
rc = pci_get_msix_limit(pdev, nvec);
if (rc < 0)
return rc;
nvec = min(rc, nvec);
for (i = 0; i < nvec; i++)
msix_entry[i].entry = i;
rc = pci_enable_msix(pdev, msix_entry, nvec);
if (rc)
return rc;
The latest state of those discussion is somewhere around Michael's:
"We could probably make that work." and Tejun's: "Are we talking about
some limited number of device drivers here? Also, is the quota still
necessary for machines in production today?"
So my point is - drivers should first obtain a number of MSIs they *can*
get, then *derive* a number of MSIs the device is fine with and only then
request that number. Not terribly different from memory or any other type
of resource allocation ;)
> It has been quite a while since I saw this happen on x86. But I just
> checked on a test system running RHEL 5 i386 (Linux 2.6.18). If I ask
> for 16 MSI-X vectors on a device that supports 1024, the return value is
> 8, and indeed I can then successfully allocate 8.
>
> Now that's going quite a way back, and it may be that global limits
> aren't a significant problem any more. With the x86_64 build of RHEL 5
> on an identical system, I can allocate 16 or even 32, so this is
> apparently not a hardware limit in this case.
Well, I do not know how to comment here. 2.6.18 has a significantly
different codebase wrt MSIs. What about a recent version?
> Most drivers seem to either:
> (a) require exactly a certain number of MSI vectors, or
> (b) require a minimum number of MSI vectors, usually want to allocate
> more, and work with any number in between
>
> We can support drivers in both classes by adding new allocation
> functions that allow specifying a minimum (required) and maximum
> (wanted) number of MSI vectors. Those in class (a) would just specify
> the same value for both. These new functions can take account of any
> global limit or allocation policy without any further changes to the
> drivers that use them.
I think such interface is redundant wrt the current pci_enable_msix()
implementation.. and you propose to leave it. IMO it unnecessarily blows
the generic MSI API with no demand from drivers.
> The few drivers with more specific requirements would still need to
> implement the currently recommended loop, using the old allocation
> functions.
Although the classes of drivers you specified indeed exist, I do believe
just a single interface is enough to handle them all.
> Ben.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt
2013-10-03 0:48 ` [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt Jon Mason
@ 2013-10-05 21:43 ` Alexander Gordeev
2013-10-07 16:50 ` Jon Mason
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-05 21:43 UTC (permalink / raw)
On Wed, Oct 02, 2013@05:48:05PM -0700, Jon Mason wrote:
> On Wed, Oct 02, 2013@12:49:10PM +0200, Alexander Gordeev wrote:
> > Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> > ---
> > drivers/ntb/ntb_hw.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> > index de2062c..eccd5e5 100644
> > --- a/drivers/ntb/ntb_hw.c
> > +++ b/drivers/ntb/ntb_hw.c
> > @@ -1066,7 +1066,7 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> > /* On SNB, the link interrupt is always tied to 4th vector. If
> > * we can't get all 4, then we can't use MSI-X.
> > */
> > - if (ndev->hw_type != BWD_HW) {
> > + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
>
> Nack, this check is unnecessary.
If SNB can do more than SNB_MSIX_CNT MSI-Xs then this check is needed
to enable less than maximum MSI-Xs in case the maximum was not allocated.
Otherwise SNB will fallback to single MSI instead of multiple MSI-Xs.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-05 14:20 ` Alexander Gordeev
@ 2013-10-05 21:46 ` Benjamin Herrenschmidt
2013-10-06 6:02 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Benjamin Herrenschmidt @ 2013-10-05 21:46 UTC (permalink / raw)
On Sat, 2013-10-05@16:20 +0200, Alexander Gordeev wrote:
> So my point is - drivers should first obtain a number of MSIs they *can*
> get, then *derive* a number of MSIs the device is fine with and only then
> request that number. Not terribly different from memory or any other type
> of resource allocation ;)
What if the limit is for a group of devices ? Your interface is racy in
that case, another driver could have eaten into the limit in between the
calls.
Ben.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-05 21:46 ` Benjamin Herrenschmidt
@ 2013-10-06 6:02 ` Alexander Gordeev
2013-10-06 6:19 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-06 6:02 UTC (permalink / raw)
On Sun, Oct 06, 2013@08:46:26AM +1100, Benjamin Herrenschmidt wrote:
> On Sat, 2013-10-05@16:20 +0200, Alexander Gordeev wrote:
> > So my point is - drivers should first obtain a number of MSIs they *can*
> > get, then *derive* a number of MSIs the device is fine with and only then
> > request that number. Not terribly different from memory or any other type
> > of resource allocation ;)
>
> What if the limit is for a group of devices ? Your interface is racy in
> that case, another driver could have eaten into the limit in between the
> calls.
Well, the another driver has had a better karma ;) But seriously, the
current scheme with a loop is not race-safe wrt to any other type of
resource which might exhaust. What makes the quota so special so we
should care about it and should not care i.e. about lack of msi_desc's?
Yeah, I know the quota might hit more likely. But why it is not addressed
right now then? Not a single function in chains...
rtas_msi_check_device() -> msi_quota_for_device() -> traverse_pci_devices()
rtas_setup_msi_irqs() -> msi_quota_for_device() -> traverse_pci_devices()
...is race-safe. So if it has not been bothering anyone until now then
no reason to start worrying now :)
In fact, in the current design to address the quota race decently the
drivers would have to protect the *loop* to prevent the quota change
between a pci_enable_msix() returned a positive number and the the next
call to pci_enable_msix() with that number. Is it doable?
> Ben.
>
>
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-06 6:02 ` Alexander Gordeev
@ 2013-10-06 6:19 ` Benjamin Herrenschmidt
2013-10-06 7:10 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Benjamin Herrenschmidt @ 2013-10-06 6:19 UTC (permalink / raw)
On Sun, 2013-10-06@08:02 +0200, Alexander Gordeev wrote:
> On Sun, Oct 06, 2013@08:46:26AM +1100, Benjamin Herrenschmidt wrote:
> > On Sat, 2013-10-05@16:20 +0200, Alexander Gordeev wrote:
> > > So my point is - drivers should first obtain a number of MSIs they *can*
> > > get, then *derive* a number of MSIs the device is fine with and only then
> > > request that number. Not terribly different from memory or any other type
> > > of resource allocation ;)
> >
> > What if the limit is for a group of devices ? Your interface is racy in
> > that case, another driver could have eaten into the limit in between the
> > calls.
>
> Well, the another driver has had a better karma ;) But seriously, the
> current scheme with a loop is not race-safe wrt to any other type of
> resource which might exhaust. What makes the quota so special so we
> should care about it and should not care i.e. about lack of msi_desc's?
I'm not saying the current scheme is better but I prefer the option of
passing a min,max to the request function.
> Yeah, I know the quota might hit more likely. But why it is not addressed
> right now then? Not a single function in chains...
> rtas_msi_check_device() -> msi_quota_for_device() -> traverse_pci_devices()
> rtas_setup_msi_irqs() -> msi_quota_for_device() -> traverse_pci_devices()
> ...is race-safe. So if it has not been bothering anyone until now then
> no reason to start worrying now :)
>
> In fact, in the current design to address the quota race decently the
> drivers would have to protect the *loop* to prevent the quota change
> between a pci_enable_msix() returned a positive number and the the next
> call to pci_enable_msix() with that number. Is it doable?
I am not advocating for the current design, simply saying that your
proposal doesn't address this issue while Ben's does.
Cheers,
Ben.
> > Ben.
> >
> >
>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-06 6:19 ` Benjamin Herrenschmidt
@ 2013-10-06 7:10 ` Alexander Gordeev
2013-10-07 18:01 ` Tejun Heo
2013-10-07 20:48 ` Ben Hutchings
0 siblings, 2 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-06 7:10 UTC (permalink / raw)
On Sun, Oct 06, 2013@05:19:46PM +1100, Benjamin Herrenschmidt wrote:
> On Sun, 2013-10-06@08:02 +0200, Alexander Gordeev wrote:
> > In fact, in the current design to address the quota race decently the
> > drivers would have to protect the *loop* to prevent the quota change
> > between a pci_enable_msix() returned a positive number and the the next
> > call to pci_enable_msix() with that number. Is it doable?
>
> I am not advocating for the current design, simply saying that your
> proposal doesn't address this issue while Ben's does.
There is one major flaw in min-max approach - the generic MSI layer
will have to take decisions on exact number of MSIs to request, not
device drivers.
This will never work for all devices, because there might be specific
requirements which are not covered by the min-max. That is what Ben
described "...say, any even number within a certain range". Ben suggests
to leave the existing loop scheme to cover such devices, which I think is
not right.
What about introducing pci_lock_msi() and pci_unlock_msi() and let device
drivers care about their ranges and specifics in race-safe manner?
I do not call to introduce it right now (since it appears pSeries has not
been hitting the race for years) just as a possible alternative to Ben's
proposal.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt
2013-10-05 21:43 ` Alexander Gordeev
@ 2013-10-07 16:50 ` Jon Mason
2013-10-07 18:38 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Jon Mason @ 2013-10-07 16:50 UTC (permalink / raw)
On Sat, Oct 05, 2013@11:43:04PM +0200, Alexander Gordeev wrote:
> On Wed, Oct 02, 2013@05:48:05PM -0700, Jon Mason wrote:
> > On Wed, Oct 02, 2013@12:49:10PM +0200, Alexander Gordeev wrote:
> > > Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> > > ---
> > > drivers/ntb/ntb_hw.c | 2 +-
> > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> > > index de2062c..eccd5e5 100644
> > > --- a/drivers/ntb/ntb_hw.c
> > > +++ b/drivers/ntb/ntb_hw.c
> > > @@ -1066,7 +1066,7 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> > > /* On SNB, the link interrupt is always tied to 4th vector. If
> > > * we can't get all 4, then we can't use MSI-X.
> > > */
> > > - if (ndev->hw_type != BWD_HW) {
> > > + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
> >
> > Nack, this check is unnecessary.
>
> If SNB can do more than SNB_MSIX_CNT MSI-Xs then this check is needed
> to enable less than maximum MSI-Xs in case the maximum was not allocated.
> Otherwise SNB will fallback to single MSI instead of multiple MSI-Xs.
Per the comment in the code snippet above, "If we can't get all 4,
then we can't use MSI-X". There is already a check to see if more
than 4 were acquired. So it's not possible to hit this. Even if it
was, don't use SNB_MSIX_CNT here (limits.msix_cnt is the preferred
variable). Also, the "()" are unnecessary.
Thanks,
Jon
> --
> Regards,
> Alexander Gordeev
> agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-06 7:10 ` Alexander Gordeev
@ 2013-10-07 18:01 ` Tejun Heo
2013-10-07 20:10 ` Benjamin Herrenschmidt
` (2 more replies)
2013-10-07 20:48 ` Ben Hutchings
1 sibling, 3 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-07 18:01 UTC (permalink / raw)
Hey, guys.
On Sun, Oct 06, 2013@09:10:30AM +0200, Alexander Gordeev wrote:
> On Sun, Oct 06, 2013@05:19:46PM +1100, Benjamin Herrenschmidt wrote:
> > On Sun, 2013-10-06@08:02 +0200, Alexander Gordeev wrote:
> > > In fact, in the current design to address the quota race decently the
> > > drivers would have to protect the *loop* to prevent the quota change
> > > between a pci_enable_msix() returned a positive number and the the next
> > > call to pci_enable_msix() with that number. Is it doable?
> >
> > I am not advocating for the current design, simply saying that your
> > proposal doesn't address this issue while Ben's does.
Hmmm... yean, the race condition could be an issue as multiple msi
allocation might fail even if the driver can and explicitly handle
multiple allocation if the quota gets reduced inbetween.
> There is one major flaw in min-max approach - the generic MSI layer
> will have to take decisions on exact number of MSIs to request, not
> device drivers.
The min-max approach would actually be pretty nice for the users which
actually care about this.
> This will never work for all devices, because there might be specific
> requirements which are not covered by the min-max. That is what Ben
> described "...say, any even number within a certain range". Ben suggests
> to leave the existing loop scheme to cover such devices, which I think is
> not right.
if it could work.
> What about introducing pci_lock_msi() and pci_unlock_msi() and let device
> drivers care about their ranges and specifics in race-safe manner?
> I do not call to introduce it right now (since it appears pSeries has not
> been hitting the race for years) just as a possible alternative to Ben's
> proposal.
I don't think the same race condition would happen with the loop. The
problem case is where multiple msi(x) allocation fails completely
because the global limit went down before inquiry and allocation. In
the loop based interface, it'd retry with the lower number.
As long as the number of drivers which need this sort of adaptive
allocation isn't too high and the common cases can be made simple, I
don't think the "complex" part of interface is all that important.
Maybe we can have reserve / cancel type interface or just keep the
loop with more explicit function names (ie. try_enable or something
like that).
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 05/77] PCI/MSI: Convert pci_msix_table_size() to a public interface
[not found] ` <e8b51bd48c24d0fc4ee8adea5c138c9bf84191e9.1380703262.git.agordeev@redhat.com>
@ 2013-10-07 18:10 ` Tejun Heo
2013-10-08 7:56 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Tejun Heo @ 2013-10-07 18:10 UTC (permalink / raw)
Hello,
On Wed, Oct 02, 2013@12:48:21PM +0200, Alexander Gordeev wrote:
> Make pci_msix_table_size() to return a error code if the device
> does not support MSI-X. This update is needed to facilitate a
> forthcoming re-design MSI/MSI-X interrupts enabling pattern.
>
> Device drivers will use this interface to obtain maximum number
> of MSI-X interrupts the device supports and use that value in
> the following call to pci_enable_msix() interface.
>
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
Hmmm... I probably missed something but why is this necessary? To
discern between -EINVAL and -ENOSPC? If so, does that really matter?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 07/77] PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern
[not found] ` <d8c36203ada6efbfa9f7ce92c2f713ee3b6d6b8d.1380703262.git.agordeev@redhat.com>
@ 2013-10-07 18:17 ` Tejun Heo
2013-10-08 7:48 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: Tejun Heo @ 2013-10-07 18:17 UTC (permalink / raw)
Hello,
On Wed, Oct 02, 2013@12:48:23PM +0200, Alexander Gordeev wrote:
> +static int foo_driver_enable_msi(struct foo_adapter *adapter, int nvec)
> +{
> + rc = pci_get_msi_cap(adapter->pdev);
> + if (rc < 0)
> + return rc;
> +
> + nvec = min(nvec, rc);
> + if (nvec < FOO_DRIVER_MINIMUM_NVEC) {
> + return -ENOSPC;
> +
> + rc = pci_enable_msi_block(adapter->pdev, nvec);
> + return rc;
> +}
If there are many which duplicate the above pattern, it'd probably be
worthwhile to provide a helper? It's usually a good idea to reduce
the amount of boilerplate code in drivers.
> static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec)
> {
> + rc = pci_msix_table_size(adapter->pdev);
> + if (rc < 0)
> + return rc;
> +
> + nvec = min(nvec, rc);
> + if (nvec < FOO_DRIVER_MINIMUM_NVEC) {
> + return -ENOSPC;
> +
> + for (i = 0; i < nvec; i++)
> + adapter->msix_entries[i].entry = i;
> +
> + rc = pci_enable_msix(adapter->pdev, adapter->msix_entries, nvec);
> + return rc;
> }
Ditto.
> @@ -975,7 +951,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
> if (nr_entries < 0)
> return nr_entries;
> if (nvec > nr_entries)
> - return nr_entries;
> + return -EINVAL;
>
> /* Check for any invalid entries */
> for (i = 0; i < nvec; i++) {
If we do things this way, it breaks all drivers using this interface
until they're converted, right? Also, it probably isn't the best idea
to flip the behavior like this as this can go completely unnoticed (no
compiler warning or anything, the same function just behaves
differently). Maybe it'd be a better idea to introduce a simpler
interface that most can be converted to?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
[not found] <cover.1380703262.git.agordeev@redhat.com>
` (14 preceding siblings ...)
[not found] ` <d8c36203ada6efbfa9f7ce92c2f713ee3b6d6b8d.1380703262.git.agordeev@redhat.com>
@ 2013-10-07 18:21 ` Tejun Heo
2013-10-08 9:07 ` Alexander Gordeev
2013-10-08 4:33 ` Michael Ellerman
` (2 subsequent siblings)
18 siblings, 1 reply; 53+ messages in thread
From: Tejun Heo @ 2013-10-07 18:21 UTC (permalink / raw)
Hello, Alexander.
On Wed, Oct 02, 2013@12:48:16PM +0200, Alexander Gordeev wrote:
> Alexander Gordeev (77):
> PCI/MSI: Fix return value when populate_msi_sysfs() failed
> PCI/MSI/PPC: Fix wrong RTAS error code reporting
> PCI/MSI/s390: Fix single MSI only check
> PCI/MSI/s390: Remove superfluous check of MSI type
> PCI/MSI: Convert pci_msix_table_size() to a public interface
> PCI/MSI: Factor out pci_get_msi_cap() interface
> PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern
> PCI/MSI: Get rid of pci_enable_msi_block_auto() interface
> ahci: Update MSI/MSI-X interrupts enablement code
> ahci: Check MRSM bit when multiple MSIs enabled
...
Whee.... that's a lot more than I expected. I was just scanning
multiple msi users. Maybe we can stage the work in more manageable
steps so that you don't have to go through massive conversion only to
do it all over again afterwards and likewise people don't get
bombarded on each iteration? Maybe we can first update pci / msi code
proper, msi and then msix?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt
2013-10-07 16:50 ` Jon Mason
@ 2013-10-07 18:38 ` Alexander Gordeev
2013-10-07 20:31 ` Jon Mason
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-07 18:38 UTC (permalink / raw)
On Mon, Oct 07, 2013@09:50:57AM -0700, Jon Mason wrote:
> On Sat, Oct 05, 2013@11:43:04PM +0200, Alexander Gordeev wrote:
> > On Wed, Oct 02, 2013@05:48:05PM -0700, Jon Mason wrote:
> > > On Wed, Oct 02, 2013@12:49:10PM +0200, Alexander Gordeev wrote:
> > > > Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> > > > ---
> > > > drivers/ntb/ntb_hw.c | 2 +-
> > > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > > >
> > > > diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> > > > index de2062c..eccd5e5 100644
> > > > --- a/drivers/ntb/ntb_hw.c
> > > > +++ b/drivers/ntb/ntb_hw.c
> > > > @@ -1066,7 +1066,7 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> > > > /* On SNB, the link interrupt is always tied to 4th vector. If
> > > > * we can't get all 4, then we can't use MSI-X.
> > > > */
> > > > - if (ndev->hw_type != BWD_HW) {
> > > > + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
> > >
> > > Nack, this check is unnecessary.
> >
> > If SNB can do more than SNB_MSIX_CNT MSI-Xs then this check is needed
> > to enable less than maximum MSI-Xs in case the maximum was not allocated.
> > Otherwise SNB will fallback to single MSI instead of multiple MSI-Xs.
>
> Per the comment in the code snippet above, "If we can't get all 4,
> then we can't use MSI-X". There is already a check to see if more
> than 4 were acquired. So it's not possible to hit this. Even if it
> was, don't use SNB_MSIX_CNT here (limits.msix_cnt is the preferred
> variable). Also, the "()" are unnecessary.
The changelog is definitely bogus. I meant here an improvement to the
existing scheme, not a conversion to the new one:
msix_entries = msix_table_size(val);
Getting i.e. 16 vectors here.
if (msix_entries > ndev->limits.msix_cnt) {
rc = -EINVAL;
goto err;
}
Upper limit check i.e. succeeds.
[...]
rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries);
pci_enable_msix() does not success and returns i.e. 8 here, should retry.
if (rc < 0)
goto err1;
if (rc > 0) {
/* On SNB, the link interrupt is always tied to 4th vector. If
* we can't get all 4, then we can't use MSI-X.
*/
if (ndev->hw_type != BWD_HW) {
On SNB bail out here, although could have continue with 8 vectors.
Can only use SNB_MSIX_CNT here, since limits.msix_cnt is the upper limit.
rc = -EIO;
goto err1;
}
[...]
}
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 18:01 ` Tejun Heo
@ 2013-10-07 20:10 ` Benjamin Herrenschmidt
2013-10-07 20:46 ` Ben Hutchings
2013-10-08 12:22 ` Alexander Gordeev
2013-10-09 12:57 ` Alexander Gordeev
2 siblings, 1 reply; 53+ messages in thread
From: Benjamin Herrenschmidt @ 2013-10-07 20:10 UTC (permalink / raw)
On Mon, 2013-10-07@14:01 -0400, Tejun Heo wrote:
> I don't think the same race condition would happen with the loop. The
> problem case is where multiple msi(x) allocation fails completely
> because the global limit went down before inquiry and allocation. In
> the loop based interface, it'd retry with the lower number.
>
> As long as the number of drivers which need this sort of adaptive
> allocation isn't too high and the common cases can be made simple, I
> don't think the "complex" part of interface is all that important.
> Maybe we can have reserve / cancel type interface or just keep the
> loop with more explicit function names (ie. try_enable or something
> like that).
I'm thinking a better API overall might just have been to request
individual MSI-X one by one :-)
We want to be able to request an MSI-X at runtime anyway ... if I want
to dynamically add a queue to my network interface, I want it to be able
to pop a new arbitrary MSI-X.
And we don't want to lock drivers into contiguous MSI-X sets either.
And for the cleanup ... well that's what the "pcim" functions are for,
we can just make MSI-X variants.
Ben.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt
2013-10-07 18:38 ` Alexander Gordeev
@ 2013-10-07 20:31 ` Jon Mason
0 siblings, 0 replies; 53+ messages in thread
From: Jon Mason @ 2013-10-07 20:31 UTC (permalink / raw)
On Mon, Oct 07, 2013@08:38:45PM +0200, Alexander Gordeev wrote:
> On Mon, Oct 07, 2013@09:50:57AM -0700, Jon Mason wrote:
> > On Sat, Oct 05, 2013@11:43:04PM +0200, Alexander Gordeev wrote:
> > > On Wed, Oct 02, 2013@05:48:05PM -0700, Jon Mason wrote:
> > > > On Wed, Oct 02, 2013@12:49:10PM +0200, Alexander Gordeev wrote:
> > > > > Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
> > > > > ---
> > > > > drivers/ntb/ntb_hw.c | 2 +-
> > > > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > > > >
> > > > > diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
> > > > > index de2062c..eccd5e5 100644
> > > > > --- a/drivers/ntb/ntb_hw.c
> > > > > +++ b/drivers/ntb/ntb_hw.c
> > > > > @@ -1066,7 +1066,7 @@ static int ntb_setup_msix(struct ntb_device *ndev)
> > > > > /* On SNB, the link interrupt is always tied to 4th vector. If
> > > > > * we can't get all 4, then we can't use MSI-X.
> > > > > */
> > > > > - if (ndev->hw_type != BWD_HW) {
> > > > > + if ((rc < SNB_MSIX_CNT) && (ndev->hw_type != BWD_HW)) {
> > > >
> > > > Nack, this check is unnecessary.
> > >
> > > If SNB can do more than SNB_MSIX_CNT MSI-Xs then this check is needed
> > > to enable less than maximum MSI-Xs in case the maximum was not allocated.
> > > Otherwise SNB will fallback to single MSI instead of multiple MSI-Xs.
> >
> > Per the comment in the code snippet above, "If we can't get all 4,
> > then we can't use MSI-X". There is already a check to see if more
> > than 4 were acquired. So it's not possible to hit this. Even if it
> > was, don't use SNB_MSIX_CNT here (limits.msix_cnt is the preferred
> > variable). Also, the "()" are unnecessary.
>
> The changelog is definitely bogus. I meant here an improvement to the
> existing scheme, not a conversion to the new one:
>
> msix_entries = msix_table_size(val);
>
> Getting i.e. 16 vectors here.
>
> if (msix_entries > ndev->limits.msix_cnt) {
On SNB HW, limits.msix_cnt is set to SNB_MSIX_CNT (4)
http://lxr.free-electrons.com/source/drivers/ntb/ntb_hw.c#L558
> rc = -EINVAL;
> goto err;
> }
>
> Upper limit check i.e. succeeds.
>
> [...]
>
> rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries);
>
> pci_enable_msix() does not success and returns i.e. 8 here, should retry.
Per the above, since our upper bound is 4. We will either have this
return 0 for all 4 or a number between 1 and 3 (or an error, but
that's not relevant to this discussion).
> if (rc < 0)
> goto err1;
> if (rc > 0) {
> /* On SNB, the link interrupt is always tied to 4th vector. If
> * we can't get all 4, then we can't use MSI-X.
> */
> if (ndev->hw_type != BWD_HW) {
>
> On SNB bail out here, although could have continue with 8 vectors.
> Can only use SNB_MSIX_CNT here, since limits.msix_cnt is the upper limit.
Since we can guarantee that rc is between 1 and 3 at this point (on
SNB HW), we should error out.
Thanks,
Jon
>
> rc = -EIO;
> goto err1;
> }
>
> [...]
> }
>
> --
> Regards,
> Alexander Gordeev
> agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 20:10 ` Benjamin Herrenschmidt
@ 2013-10-07 20:46 ` Ben Hutchings
0 siblings, 0 replies; 53+ messages in thread
From: Ben Hutchings @ 2013-10-07 20:46 UTC (permalink / raw)
On Tue, 2013-10-08@07:10 +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2013-10-07@14:01 -0400, Tejun Heo wrote:
> > I don't think the same race condition would happen with the loop. The
> > problem case is where multiple msi(x) allocation fails completely
> > because the global limit went down before inquiry and allocation. In
> > the loop based interface, it'd retry with the lower number.
> >
> > As long as the number of drivers which need this sort of adaptive
> > allocation isn't too high and the common cases can be made simple, I
> > don't think the "complex" part of interface is all that important.
> > Maybe we can have reserve / cancel type interface or just keep the
> > loop with more explicit function names (ie. try_enable or something
> > like that).
>
> I'm thinking a better API overall might just have been to request
> individual MSI-X one by one :-)
>
> We want to be able to request an MSI-X at runtime anyway ... if I want
> to dynamically add a queue to my network interface, I want it to be able
> to pop a new arbitrary MSI-X.
Yes, this would be very useful.
> And we don't want to lock drivers into contiguous MSI-X sets either.
I don't think there's any such limitation now. The entries array passed
to pci_enable_msix() specifies which MSI-X vectors the driver wants to
enable. It's usually filled with 0..nvec-1 in order, but not always.
And the IRQ numbers returned aren't usually contiguous either, on x86.
Ben.
> And for the cleanup ... well that's what the "pcim" functions are for,
> we can just make MSI-X variants.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-06 7:10 ` Alexander Gordeev
2013-10-07 18:01 ` Tejun Heo
@ 2013-10-07 20:48 ` Ben Hutchings
2013-10-09 15:46 ` Tejun Heo
1 sibling, 1 reply; 53+ messages in thread
From: Ben Hutchings @ 2013-10-07 20:48 UTC (permalink / raw)
On Sun, 2013-10-06@09:10 +0200, Alexander Gordeev wrote:
> On Sun, Oct 06, 2013@05:19:46PM +1100, Benjamin Herrenschmidt wrote:
> > On Sun, 2013-10-06@08:02 +0200, Alexander Gordeev wrote:
> > > In fact, in the current design to address the quota race decently the
> > > drivers would have to protect the *loop* to prevent the quota change
> > > between a pci_enable_msix() returned a positive number and the the next
> > > call to pci_enable_msix() with that number. Is it doable?
> >
> > I am not advocating for the current design, simply saying that your
> > proposal doesn't address this issue while Ben's does.
>
> There is one major flaw in min-max approach - the generic MSI layer
> will have to take decisions on exact number of MSIs to request, not
> device drivers.
[...
No, the min-max functions should be implemented using the same loop that
drivers are expected to use now.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
[not found] <cover.1380703262.git.agordeev@redhat.com>
` (15 preceding siblings ...)
2013-10-07 18:21 ` [PATCH RFC 00/77] " Tejun Heo
@ 2013-10-08 4:33 ` Michael Ellerman
2013-10-08 7:33 ` Alexander Gordeev
[not found] ` <c92efbde96541d08f37510422c096d543bb01279.1380703263.git.agordeev@redhat.com>
[not found] ` <5254D397.9030307@zytor.com>
18 siblings, 1 reply; 53+ messages in thread
From: Michael Ellerman @ 2013-10-08 4:33 UTC (permalink / raw)
On Wed, Oct 02, 2013@12:29:04PM +0200, Alexander Gordeev wrote:
> This series is against "next" branch in Bjorn's repo:
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
>
> Currently pci_enable_msi_block() and pci_enable_msix() interfaces
> return a error code in case of failure, 0 in case of success and a
> positive value which indicates the number of MSI-X/MSI interrupts
> that could have been allocated. The latter value should be passed
> to a repeated call to the interfaces until a failure or success:
>
>
> for (i = 0; i < FOO_DRIVER_MAXIMUM_NVEC; i++)
> adapter->msix_entries[i].entry = i;
>
> while (nvec >= FOO_DRIVER_MINIMUM_NVEC) {
> rc = pci_enable_msix(adapter->pdev,
> adapter->msix_entries, nvec);
> if (rc > 0)
> nvec = rc;
> else
> return rc;
> }
>
> return -ENOSPC;
>
>
> This technique proved to be confusing and error-prone. Vast share
> of device drivers simply fail to follow the described guidelines.
To clarify "Vast share of device drivers":
- 58 drivers call pci_enable_msix()
- 24 try a single allocation and then fallback to MSI/LSI
- 19 use the loop style allocation as above
- 14 try an allocation, and if it fails retry once
- 1 incorrectly continues when pci_enable_msix() returns > 0
So 33 drivers (> 50%) successfully make use of the "confusing and
error-prone" return value.
Another 24 happily ignore it, which is also entirely fine.
And yes, one is buggy, so obviously the interface is too complex. Thanks
drivers/ntb/ntb_hw.c
cheers
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-08 4:33 ` Michael Ellerman
@ 2013-10-08 7:33 ` Alexander Gordeev
2013-10-09 1:34 ` Michael Ellerman
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-08 7:33 UTC (permalink / raw)
On Tue, Oct 08, 2013@03:33:30PM +1100, Michael Ellerman wrote:
> On Wed, Oct 02, 2013@12:29:04PM +0200, Alexander Gordeev wrote:
> > This technique proved to be confusing and error-prone. Vast share
> > of device drivers simply fail to follow the described guidelines.
>
> To clarify "Vast share of device drivers":
>
> - 58 drivers call pci_enable_msix()
> - 24 try a single allocation and then fallback to MSI/LSI
> - 19 use the loop style allocation as above
> - 14 try an allocation, and if it fails retry once
> - 1 incorrectly continues when pci_enable_msix() returns > 0
>
> So 33 drivers (> 50%) successfully make use of the "confusing and
> error-prone" return value.
Ok, you caught me - 'vast share' is incorrect and is a subject to
rewording. But out of 19/58 how many drivers tested fallbacks on the
real hardware? IOW, which drivers are affected by the pSeries quota?
> And yes, one is buggy, so obviously the interface is too complex. Thanks
> drivers/ntb/ntb_hw.c
vmxnet3 would be the best example.
> cheers
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 07/77] PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 18:17 ` [PATCH RFC 07/77] PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern Tejun Heo
@ 2013-10-08 7:48 ` Alexander Gordeev
2013-10-09 15:54 ` Tejun Heo
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-08 7:48 UTC (permalink / raw)
On Mon, Oct 07, 2013@02:17:49PM -0400, Tejun Heo wrote:
> Hello,
>
> On Wed, Oct 02, 2013@12:48:23PM +0200, Alexander Gordeev wrote:
> > +static int foo_driver_enable_msi(struct foo_adapter *adapter, int nvec)
> > +{
> > + rc = pci_get_msi_cap(adapter->pdev);
> > + if (rc < 0)
> > + return rc;
> > +
> > + nvec = min(nvec, rc);
> > + if (nvec < FOO_DRIVER_MINIMUM_NVEC) {
> > + return -ENOSPC;
> > +
> > + rc = pci_enable_msi_block(adapter->pdev, nvec);
> > + return rc;
> > +}
>
> If there are many which duplicate the above pattern, it'd probably be
> worthwhile to provide a helper? It's usually a good idea to reduce
> the amount of boilerplate code in drivers.
I wanted to limit discussion in v1 to as little changes as possible.
I 'planned' those helper(s) for a separate effort if/when the most
important change is accepted and soaked a bit.
> > @@ -975,7 +951,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
> > if (nr_entries < 0)
> > return nr_entries;
> > if (nvec > nr_entries)
> > - return nr_entries;
> > + return -EINVAL;
> >
> > /* Check for any invalid entries */
> > for (i = 0; i < nvec; i++) {
>
> If we do things this way, it breaks all drivers using this interface
> until they're converted, right?
Right. And the rest of the series does it.
> Also, it probably isn't the best idea
> to flip the behavior like this as this can go completely unnoticed (no
> compiler warning or anything, the same function just behaves
> differently). Maybe it'd be a better idea to introduce a simpler
> interface that most can be converted to?
Well, an *other* interface is a good idea. What do you mean with the
simpler here?
> tejun
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 05/77] PCI/MSI: Convert pci_msix_table_size() to a public interface
2013-10-07 18:10 ` [PATCH RFC 05/77] PCI/MSI: Convert pci_msix_table_size() to a public interface Tejun Heo
@ 2013-10-08 7:56 ` Alexander Gordeev
0 siblings, 0 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-08 7:56 UTC (permalink / raw)
On Mon, Oct 07, 2013@02:10:43PM -0400, Tejun Heo wrote:
> On Wed, Oct 02, 2013@12:48:21PM +0200, Alexander Gordeev wrote:
> > Make pci_msix_table_size() to return a error code if the device
> > does not support MSI-X. This update is needed to facilitate a
> > forthcoming re-design MSI/MSI-X interrupts enabling pattern.
> >
> > Device drivers will use this interface to obtain maximum number
> > of MSI-X interrupts the device supports and use that value in
> > the following call to pci_enable_msix() interface.
>
> Hmmm... I probably missed something but why is this necessary? To
> discern between -EINVAL and -ENOSPC? If so, does that really matter?
pci_msix_table_size() is kind of helper and returns 0 if a device does
not have MSI-X table. If we want drivers to use it we need return -EINVAL
for MSI-X incapable/disabled devices. Nothing about -ENOSPC.
> tejun
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 18:21 ` [PATCH RFC 00/77] " Tejun Heo
@ 2013-10-08 9:07 ` Alexander Gordeev
2013-10-09 15:57 ` Tejun Heo
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-08 9:07 UTC (permalink / raw)
On Mon, Oct 07, 2013@02:21:17PM -0400, Tejun Heo wrote:
> Whee.... that's a lot more than I expected. I was just scanning
> multiple msi users. Maybe we can stage the work in more manageable
> steps so that you don't have to go through massive conversion only to
> do it all over again afterwards and likewise people don't get
> bombarded on each iteration? Maybe we can first update pci / msi code
> proper, msi and then msix?
Multipe MSIs is just a handful of drivers, really. MSI-X impact still
will be huge. But if we opt a different name for the new pci_enable_msix()
then we could first update pci/msi, then drivers (in few stages possibly)
and finally remove the old implementation.
> tejun
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 18:01 ` Tejun Heo
2013-10-07 20:10 ` Benjamin Herrenschmidt
@ 2013-10-08 12:22 ` Alexander Gordeev
2013-10-09 15:41 ` Tejun Heo
2013-10-09 12:57 ` Alexander Gordeev
2 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-08 12:22 UTC (permalink / raw)
On Mon, Oct 07, 2013@02:01:11PM -0400, Tejun Heo wrote:
> > What about introducing pci_lock_msi() and pci_unlock_msi() and let device
> > drivers care about their ranges and specifics in race-safe manner?
> > I do not call to introduce it right now (since it appears pSeries has not
> > been hitting the race for years) just as a possible alternative to Ben's
> > proposal.
>
> I don't think the same race condition would happen with the loop.
We need to distinguish the contexts we're discussing.
If we talk about pSeries quota, then the current pSeries pci_enable_msix()
implementation is racy internally and could fail if the quota went down
*while* pci_enable_msix() is executing. In this case the loop will have to
exit rather than retry with a lower number (what number?).
In this regard the new scheme does not bring anything new and relies on
the fact this race does not hit and therefore does not worry.
If we talk about quota as it has to be, then yes - the loop scheme seems
more preferable.
Overall, looks like we just need to fix the pSeries implementation,
if the guys want it, he-he :)
> The problem case is where multiple msi(x) allocation fails completely
> because the global limit went down before inquiry and allocation. In
> the loop based interface, it'd retry with the lower number.
I am probably missing something here. If the global limit went down before
inquiry then the inquiry will get what is available and try to allocate with
than number.
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 63/77] qlcnic: Update MSI/MSI-X interrupts enablement code
[not found] ` <c92efbde96541d08f37510422c096d543bb01279.1380703263.git.agordeev@redhat.com>
@ 2013-10-08 22:46 ` Himanshu Madhani
0 siblings, 0 replies; 53+ messages in thread
From: Himanshu Madhani @ 2013-10-08 22:46 UTC (permalink / raw)
> -----Original Message-----
> From: Alexander Gordeev [mailto:agordeev at redhat.com]
> Sent: Wednesday, October 02, 2013 3:49 AM
> To: linux-kernel
> Cc: Alexander Gordeev; Bjorn Helgaas; Ralf Baechle; Michael Ellerman;
> Benjamin Herrenschmidt; Martin Schwidefsky; Ingo Molnar; Tejun Heo; Dan
> Williams; Andy King; Jon Mason; Matt Porter; linux-pci; linux-mips at linux-
> mips.org; linuxppc-dev at lists.ozlabs.org; linux390 at de.ibm.com; linux-
> s390 at vger.kernel.org; x86 at kernel.org; linux-ide at vger.kernel.org;
> iss_storagedev at hp.com; linux-nvme at lists.infradead.org; linux-
> rdma at vger.kernel.org; netdev; e1000-devel at lists.sourceforge.net; Dept-
> Eng Linux Driver; Solarflare linux maintainers; VMware, Inc.; linux-scsi
> Subject: [PATCH RFC 63/77] qlcnic: Update MSI/MSI-X interrupts enablement
> code
>
> As result of recent re-design of the MSI/MSI-X interrupts enabling pattern
> this driver has to be updated to use the new technique to obtain a optimal
> number of MSI/MSI-X interrupts required.
>
"We will test this change for the driver and provide feedback."
> Signed-off-by: Alexander Gordeev <agordeev at redhat.com>
Thanks,
Himanshu
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-08 7:33 ` Alexander Gordeev
@ 2013-10-09 1:34 ` Michael Ellerman
0 siblings, 0 replies; 53+ messages in thread
From: Michael Ellerman @ 2013-10-09 1:34 UTC (permalink / raw)
On Tue, Oct 08, 2013@09:33:02AM +0200, Alexander Gordeev wrote:
> On Tue, Oct 08, 2013@03:33:30PM +1100, Michael Ellerman wrote:
> > On Wed, Oct 02, 2013@12:29:04PM +0200, Alexander Gordeev wrote:
> > > This technique proved to be confusing and error-prone. Vast share
> > > of device drivers simply fail to follow the described guidelines.
> >
> > To clarify "Vast share of device drivers":
> >
> > - 58 drivers call pci_enable_msix()
> > - 24 try a single allocation and then fallback to MSI/LSI
> > - 19 use the loop style allocation as above
> > - 14 try an allocation, and if it fails retry once
> > - 1 incorrectly continues when pci_enable_msix() returns > 0
> >
> > So 33 drivers (> 50%) successfully make use of the "confusing and
> > error-prone" return value.
>
> Ok, you caught me - 'vast share' is incorrect and is a subject to
> rewording. But out of 19/58 how many drivers tested fallbacks on the
> real hardware? IOW, which drivers are affected by the pSeries quota?
It's not 19/58, it's 33/58.
As to how many we care about on powerpc I can't say, so you have a point
there. But I still think the interface is not actually that terrible.
cheers
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 18:01 ` Tejun Heo
2013-10-07 20:10 ` Benjamin Herrenschmidt
2013-10-08 12:22 ` Alexander Gordeev
@ 2013-10-09 12:57 ` Alexander Gordeev
2013-10-09 15:43 ` Tejun Heo
2 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-09 12:57 UTC (permalink / raw)
On Mon, Oct 07, 2013@02:01:11PM -0400, Tejun Heo wrote:
> Hmmm... yean, the race condition could be an issue as multiple msi
> allocation might fail even if the driver can and explicitly handle
> multiple allocation if the quota gets reduced inbetween.
BTW, should we care about the quota getting increased inbetween?
That would entail.. kind of pci_get_msi_limit() :), but IMHO it is
not worth it.
> tejun
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-08 12:22 ` Alexander Gordeev
@ 2013-10-09 15:41 ` Tejun Heo
0 siblings, 0 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-09 15:41 UTC (permalink / raw)
Hello,
On Tue, Oct 08, 2013@02:22:16PM +0200, Alexander Gordeev wrote:
> If we talk about pSeries quota, then the current pSeries pci_enable_msix()
> implementation is racy internally and could fail if the quota went down
> *while* pci_enable_msix() is executing. In this case the loop will have to
> exit rather than retry with a lower number (what number?).
Ah, okay, so that one is already broken.
> In this regard the new scheme does not bring anything new and relies on
> the fact this race does not hit and therefore does not worry.
>
> If we talk about quota as it has to be, then yes - the loop scheme seems
> more preferable.
>
> Overall, looks like we just need to fix the pSeries implementation,
> if the guys want it, he-he :)
If we can't figure out a better interface for the retry case, I think
what can really help is having a simple interface for the simpler
cases.
> > The problem case is where multiple msi(x) allocation fails completely
> > because the global limit went down before inquiry and allocation. In
> > the loop based interface, it'd retry with the lower number.
>
> I am probably missing something here. If the global limit went down before
> inquiry then the inquiry will get what is available and try to allocate with
> than number.
Oh, I should have written between inquiry and allocation. Sorry.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-09 12:57 ` Alexander Gordeev
@ 2013-10-09 15:43 ` Tejun Heo
0 siblings, 0 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-09 15:43 UTC (permalink / raw)
Hello,
On Wed, Oct 09, 2013@02:57:16PM +0200, Alexander Gordeev wrote:
> On Mon, Oct 07, 2013@02:01:11PM -0400, Tejun Heo wrote:
> > Hmmm... yean, the race condition could be an issue as multiple msi
> > allocation might fail even if the driver can and explicitly handle
> > multiple allocation if the quota gets reduced inbetween.
>
> BTW, should we care about the quota getting increased inbetween?
> That would entail.. kind of pci_get_msi_limit() :), but IMHO it is
> not worth it.
I think we shouldn't. If the resource was low during a point in time
during allocation, it's fine to base the result on that - the resource
was actually low and which answer we return is just a question of
timing and both are correct. The only reason the existing race
condition is problematic is because it may fail even if the resource
never falls below the failure point.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-07 20:48 ` Ben Hutchings
@ 2013-10-09 15:46 ` Tejun Heo
0 siblings, 0 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-09 15:46 UTC (permalink / raw)
On Mon, Oct 07, 2013@09:48:01PM +0100, Ben Hutchings wrote:
> > There is one major flaw in min-max approach - the generic MSI layer
> > will have to take decisions on exact number of MSIs to request, not
> > device drivers.
> [...
>
> No, the min-max functions should be implemented using the same loop that
> drivers are expected to use now.
Wheee... earlier in the thread I thought you guys were referring to
yourselves in the third person and was getting a bit worried. :)
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 07/77] PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern
2013-10-08 7:48 ` Alexander Gordeev
@ 2013-10-09 15:54 ` Tejun Heo
0 siblings, 0 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-09 15:54 UTC (permalink / raw)
Hello, Alexander.
On Tue, Oct 08, 2013@09:48:26AM +0200, Alexander Gordeev wrote:
> > If there are many which duplicate the above pattern, it'd probably be
> > worthwhile to provide a helper? It's usually a good idea to reduce
> > the amount of boilerplate code in drivers.
>
> I wanted to limit discussion in v1 to as little changes as possible.
> I 'planned' those helper(s) for a separate effort if/when the most
> important change is accepted and soaked a bit.
The thing is doing it this way generates more churns and noises. Once
the simpler ones live behind a wrapper which can be built on the
existing interface, we can have both reduced cost and more latitude on
the complex cases.
> > If we do things this way, it breaks all drivers using this interface
> > until they're converted, right?
>
> Right. And the rest of the series does it.
Which breaks bisection which we shouldn't do.
> > Also, it probably isn't the best idea
> > to flip the behavior like this as this can go completely unnoticed (no
> > compiler warning or anything, the same function just behaves
> > differently). Maybe it'd be a better idea to introduce a simpler
> > interface that most can be converted to?
>
> Well, an *other* interface is a good idea. What do you mean with the
> simpler here?
I'm still talking about a simpler wrapper for common cases, which is
the important part anyway.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-08 9:07 ` Alexander Gordeev
@ 2013-10-09 15:57 ` Tejun Heo
0 siblings, 0 replies; 53+ messages in thread
From: Tejun Heo @ 2013-10-09 15:57 UTC (permalink / raw)
Hello,
On Tue, Oct 08, 2013@11:07:16AM +0200, Alexander Gordeev wrote:
> Multipe MSIs is just a handful of drivers, really. MSI-X impact still
Yes, so it's pretty nice to try out things there before going full-on.
> will be huge. But if we opt a different name for the new pci_enable_msix()
> then we could first update pci/msi, then drivers (in few stages possibly)
> and finally remove the old implementation.
Yes, that probably should be the steps to follow eventually. My point
was that you don't have to submit patches for all 7x conversions for
an RFC round. Scanning them and seeing what would be necessary
definitely is a good idea but just giving summary of the full
conversion with several examples should be good enough before settling
on the way forward, which should be easier for all involved.
Thanks a lot for your effort!
--
tejun
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
[not found] ` <1381292648.645.259.camel@pasglop>
@ 2013-10-10 10:17 ` Alexander Gordeev
2013-10-10 16:28 ` H. Peter Anvin
0 siblings, 1 reply; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-10 10:17 UTC (permalink / raw)
On Wed, Oct 09, 2013@03:24:08PM +1100, Benjamin Herrenschmidt wrote:
> On Tue, 2013-10-08@20:55 -0700, H. Peter Anvin wrote:
> > Why not add a minimum number to pci_enable_msix(), i.e.:
> >
> > pci_enable_msix(pdev, msix_entries, nvec, minvec)
> >
> > ... which means "nvec" is the number of interrupts *requested*, and
> > "minvec" is the minimum acceptable number (otherwise fail).
>
> Which is exactly what Ben (the other Ben :-) suggested and that I
> supports...
Ok, this suggestion sounded in one or another form by several people.
What about name it pcim_enable_msix_range() and wrap in couple more
helpers to complete an API:
int pcim_enable_msix_range(pdev, msix_entries, nvec, minvec);
<0 - error code
>0 - number of MSIs allocated, where minvec >= result <= nvec
int pcim_enable_msix(pdev, msix_entries, nvec);
<0 - error code
>0 - number of MSIs allocated, where 1 >= result <= nvec
int pcim_enable_msix_exact(pdev, msix_entries, nvec);
<0 - error code
>0 - number of MSIs allocated, where result == nvec
The latter's return value seems odd, but I can not help to make
it consistent with the first two.
(Sorry if you see this message twice - my MUA seems struggle with one of CC).
> Cheers,
> Ben.
>
>
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 50/77] mlx5: Update MSI/MSI-X interrupts enablement code
2013-10-03 19:48 ` Alexander Gordeev
@ 2013-10-10 15:29 ` Eli Cohen
0 siblings, 0 replies; 53+ messages in thread
From: Eli Cohen @ 2013-10-10 15:29 UTC (permalink / raw)
On Thu, Oct 03, 2013@09:48:39PM +0200, Alexander Gordeev wrote:
>
> pci_enable_msix() may fail, but it can not return a positive number.
>
That is true according to the current logic but the comment on top of
pci_enable_msix() still says:
"A return of < 0 indicates a failure. Or a return of > 0 indicates
that driver request is exceeding the number of irqs or MSI-X vectors
available"
So you're counting on an implementation that may change in the future.
I think leaving the code as it is now is safer.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-10 10:17 ` [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern Alexander Gordeev
@ 2013-10-10 16:28 ` H. Peter Anvin
2013-10-10 18:07 ` Alexander Gordeev
0 siblings, 1 reply; 53+ messages in thread
From: H. Peter Anvin @ 2013-10-10 16:28 UTC (permalink / raw)
On 10/10/2013 03:17 AM, Alexander Gordeev wrote:
> On Wed, Oct 09, 2013@03:24:08PM +1100, Benjamin Herrenschmidt wrote:
>
> Ok, this suggestion sounded in one or another form by several people.
> What about name it pcim_enable_msix_range() and wrap in couple more
> helpers to complete an API:
>
> int pcim_enable_msix_range(pdev, msix_entries, nvec, minvec);
> <0 - error code
> >0 - number of MSIs allocated, where minvec >= result <= nvec
>
> int pcim_enable_msix(pdev, msix_entries, nvec);
> <0 - error code
> >0 - number of MSIs allocated, where 1 >= result <= nvec
>
> int pcim_enable_msix_exact(pdev, msix_entries, nvec);
> <0 - error code
> >0 - number of MSIs allocated, where result == nvec
>
> The latter's return value seems odd, but I can not help to make
> it consistent with the first two.
>
Is there a reason for the wrappers, as opposed to just specifying either
1 or nvec as the minimum?
-hpa
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern
2013-10-10 16:28 ` H. Peter Anvin
@ 2013-10-10 18:07 ` Alexander Gordeev
0 siblings, 0 replies; 53+ messages in thread
From: Alexander Gordeev @ 2013-10-10 18:07 UTC (permalink / raw)
On Thu, Oct 10, 2013@09:28:27AM -0700, H. Peter Anvin wrote:
> On 10/10/2013 03:17 AM, Alexander Gordeev wrote:
> > On Wed, Oct 09, 2013@03:24:08PM +1100, Benjamin Herrenschmidt wrote:
> >
> > Ok, this suggestion sounded in one or another form by several people.
> > What about name it pcim_enable_msix_range() and wrap in couple more
> > helpers to complete an API:
> >
> > int pcim_enable_msix_range(pdev, msix_entries, nvec, minvec);
> > <0 - error code
> > >0 - number of MSIs allocated, where minvec >= result <= nvec
> >
> > int pcim_enable_msix(pdev, msix_entries, nvec);
> > <0 - error code
> > >0 - number of MSIs allocated, where 1 >= result <= nvec
> >
> > int pcim_enable_msix_exact(pdev, msix_entries, nvec);
> > <0 - error code
> > >0 - number of MSIs allocated, where result == nvec
> >
> > The latter's return value seems odd, but I can not help to make
> > it consistent with the first two.
> >
>
> Is there a reason for the wrappers, as opposed to just specifying either
> 1 or nvec as the minimum?
The wrappers are more handy IMO.
I.e. can imagine people start struggling to figure out what minvec to provide:
1 or 0? Why 1? Oh.. okay.. Or should we tolerate 0 (as opposite to -ERANGE)?
Well, do not know.. pcim_enable_msix(pdev, msix_entries, nvec, nvec) is
less readable for me than just pcim_enable_msix_exact(pdev, msix_entries,
nvec).
> -hpa
--
Regards,
Alexander Gordeev
agordeev at redhat.com
^ permalink raw reply [flat|nested] 53+ messages in thread
end of thread, other threads:[~2013-10-10 18:07 UTC | newest]
Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1380703262.git.agordeev@redhat.com>
[not found] ` <2d4272136269f3cb3b1a5ac53b12aa45c7ea65c0.1380703263.git.agordeev@redhat.com>
2013-10-02 19:31 ` [PATCH RFC 36/77] ipr: Enable MSI-X when IPR_USE_MSIX type is set, not IPR_USE_MSI Brian King
[not found] ` <338c9012577acf694eb23622902185584987bd8f.1380703263.git.agordeev@redhat.com>
2013-10-02 20:50 ` [PATCH RFC 40/77] ixgbevf: Update MSI/MSI-X interrupts enablement code Keller, Jacob E
[not found] ` <467ce10b1df795edf80ed222816ab739fee7b0ea.1380703263.git.agordeev@redhat.com>
2013-10-03 0:29 ` [PATCH RFC 77/77] vxge: " Jon Mason
[not found] ` <3ff5236944aae69f2cd934b5b6da7c1c269df7c1.1380703262.git.agordeev@redhat.com>
2013-10-03 0:39 ` [PATCH RFC 01/77] PCI/MSI: Fix return value when populate_msi_sysfs() failed Jon Mason
[not found] ` <5d9c5b2d3bbc444ff32bddeece7a239d046bd79c.1380703263.git.agordeev@redhat.com>
2013-10-03 0:48 ` [PATCH RFC 54/77] ntb: Ensure number of MSIs on SNB is enough for the link interrupt Jon Mason
2013-10-05 21:43 ` Alexander Gordeev
2013-10-07 16:50 ` Jon Mason
2013-10-07 18:38 ` Alexander Gordeev
2013-10-07 20:31 ` Jon Mason
[not found] ` <0590d63c3432229a3824bada71e07a08fb955498.1380703263.git.agordeev@redhat.com>
2013-10-03 0:49 ` [PATCH RFC 53/77] ntb: Fix missed call to pci_enable_msix() Jon Mason
[not found] ` <49eb592e15aaec804f9c11ca132d2b85c516aefa.1380703263.git.agordeev@redhat.com>
2013-10-03 1:02 ` [PATCH RFC 55/77] ntb: Update MSI/MSI-X interrupts enablement code Jon Mason
[not found] ` <9650a7dfbcfd5f1da21f7b093665abf4b1041071.1380703263.git.agordeev@redhat.com>
2013-10-03 7:14 ` [PATCH RFC 50/77] mlx5: " Eli Cohen
2013-10-03 19:48 ` Alexander Gordeev
2013-10-10 15:29 ` Eli Cohen
[not found] ` <9d424912ef78993dc75e2af5006cd12913e9e7e7.1380703263.git.agordeev@redhat.com>
2013-10-03 16:11 ` [PATCH RFC 51/77] mthca: " Jack Morgenstein
[not found] ` <9c282c4ab92731c719d161d2db6fc54ce33891d9.1380703262.git.agordeev@redhat.com>
2013-10-03 21:52 ` [PATCH RFC 06/77] PCI/MSI: Factor out pci_get_msi_cap() interface Ben Hutchings
2013-10-04 5:13 ` Alexander Gordeev
2013-10-03 22:49 ` [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern Ben Hutchings
2013-10-04 8:29 ` Alexander Gordeev
2013-10-04 8:31 ` David Laight
2013-10-04 9:21 ` Alexander Gordeev
2013-10-04 21:29 ` Ben Hutchings
2013-10-05 14:20 ` Alexander Gordeev
2013-10-05 21:46 ` Benjamin Herrenschmidt
2013-10-06 6:02 ` Alexander Gordeev
2013-10-06 6:19 ` Benjamin Herrenschmidt
2013-10-06 7:10 ` Alexander Gordeev
2013-10-07 18:01 ` Tejun Heo
2013-10-07 20:10 ` Benjamin Herrenschmidt
2013-10-07 20:46 ` Ben Hutchings
2013-10-08 12:22 ` Alexander Gordeev
2013-10-09 15:41 ` Tejun Heo
2013-10-09 12:57 ` Alexander Gordeev
2013-10-09 15:43 ` Tejun Heo
2013-10-07 20:48 ` Ben Hutchings
2013-10-09 15:46 ` Tejun Heo
[not found] ` <8c9811b13fd93e73641dab8e3bd1bd5b2dc37a61.1380703262.git.agordeev@redhat.com>
2013-10-04 7:39 ` [PATCH RFC 03/77] PCI/MSI/s390: Fix single MSI only check Martin Schwidefsky
[not found] ` <bae65aa3e30dfd23bd5ed47add7310cfbb96243a.1380703262.git.agordeev@redhat.com>
2013-10-04 7:40 ` [PATCH RFC 04/77] PCI/MSI/s390: Remove superfluous check of MSI type Martin Schwidefsky
[not found] ` <e8b51bd48c24d0fc4ee8adea5c138c9bf84191e9.1380703262.git.agordeev@redhat.com>
2013-10-07 18:10 ` [PATCH RFC 05/77] PCI/MSI: Convert pci_msix_table_size() to a public interface Tejun Heo
2013-10-08 7:56 ` Alexander Gordeev
[not found] ` <d8c36203ada6efbfa9f7ce92c2f713ee3b6d6b8d.1380703262.git.agordeev@redhat.com>
2013-10-07 18:17 ` [PATCH RFC 07/77] PCI/MSI: Re-design MSI/MSI-X interrupts enablement pattern Tejun Heo
2013-10-08 7:48 ` Alexander Gordeev
2013-10-09 15:54 ` Tejun Heo
2013-10-07 18:21 ` [PATCH RFC 00/77] " Tejun Heo
2013-10-08 9:07 ` Alexander Gordeev
2013-10-09 15:57 ` Tejun Heo
2013-10-08 4:33 ` Michael Ellerman
2013-10-08 7:33 ` Alexander Gordeev
2013-10-09 1:34 ` Michael Ellerman
[not found] ` <c92efbde96541d08f37510422c096d543bb01279.1380703263.git.agordeev@redhat.com>
2013-10-08 22:46 ` [PATCH RFC 63/77] qlcnic: Update MSI/MSI-X interrupts enablement code Himanshu Madhani
[not found] ` <5254D397.9030307@zytor.com>
[not found] ` <1381292648.645.259.camel@pasglop>
2013-10-10 10:17 ` [PATCH RFC 00/77] Re-design MSI/MSI-X interrupts enablement pattern Alexander Gordeev
2013-10-10 16:28 ` H. Peter Anvin
2013-10-10 18:07 ` Alexander Gordeev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).