[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] xen-pciback: Consider INTx disabled when MSI/MSI-X is enabled


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 16 Oct 2023 11:05:10 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nQNWR/uKHtslOLw/DN5/pH6PYcISdgRH0Qk5gK7rFDw=; b=L/ry/2xGl0OtKb+ZPK50280Rz53xaMDEqeHrW3ys3PJ3HUUYz+uCGseH1e0w7+eremQuzjspaJbYoc62/jHhAMOdzPH3rUhez3Z0f59m+sKpB2uMKyRsoHi9u3hrFh1SZvJlzI9murSQOvpkCI/iGAkjLyEXxVopOAGFhsk9BNqpssBTMlsswDHedz0QN5zmABcRC5VHCOhog6Y9F/1wTcimD3p5jMI0wV8sL5mTs94jl3Ms6f0WBXQggY1ecuHNAvx0Lpovw9ci1lSSWKebf/ZAmQXiVRFdEbqIy2P6h0L03iqQFwbCRoq0NaNLnChbpN0dbvW9o3D93yjx4aPRCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2gBcT08NsK63AZ0W+MyzLwDkScfQLUmyOjDL293y8a6R/evM4M0P13cLZhnA3j51XLK83m3s2qLFyd/34augYIn+ycDXMFPuaHIN7vjFZWe9jOt2Jz3s5RR6VYiBGmFNq9EV8FZuhBS8m3PX5vWS2hFd6+s050Xw1z1JYTMRClhRLmaUN4Ze8yYGetXXLiy7leBNZal9XtYt6EC8K5Wdhbe5y0vU9vX+9NIu2rdDU+TW5tHbHd0Ss/q/UGJb8tkfvtc/acM/kwLCDBPfEgkzzvG7XOMNFw2VAJzGALUF1Em7kNHbTGAuisWp2CrDpdA2Bgv1UJO6+0kPd5yOD4HYA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: linux-kernel@xxxxxxxxxxxxxxx, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "moderated list:XEN HYPERVISOR INTERFACE" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 16 Oct 2023 09:05:28 +0000
  • Ironport-data: A9a23:VuDy5qr3e+NrNw6LEM6dcVM1Wp5eBmKDZBIvgKrLsJaIsI4StFCzt garIBmAb6qDYjf3f9B3PY20908F7MLXx9BhHlFtri5gFitE9puZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GhwUmAWP6gR5waGzidNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXABdXTCqtmsaH+ZnhTu1KvMQHE/LzP5xK7xmMzRmBZRonabbqZvySoPV+g3I3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3j+CraYKMEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdhPSuLkqaE76LGV7jEfM0wMdFydnfOWyXO5fPVTG U0rxwN7+MDe82TuFLERRSaQpXeeuxcGVtl4Eusk6RqMwK7Z/waYAGcfSjdLLtchsaceQT0sy 0/MnN7zAzFrmKOaRGjb9bqOqz62fy8PIgcqZyAeShAey8L+u4x1hRXKJv54C7K8hNDxHTD2w hiJoTI4irFVitQEv428+V3EmDuqqoL+Uh8u5g7XU2Sm6St0fIegIYev7DDz7/xNMYKYRVmpp 2Uflo6V6+VmJYGAkmmBTfsAGJmt5u2ZK3vMjFh3BZ4j+j+xvXm5cuhtDCpWIU5oNoMOf2Dva UqK4QdJvsYLZT2tcLN9ZJ+3B4Iy16/8GN/5V/fSKN1Tfpx2cwzB9yZrDaKN413QfIEXuflXE f+mnQyEVB721YwPIOKKetog
  • Ironport-hdrordr: A9a23:kWdZpK2tP6mQDTNe3QVHdwqjBEQkLtp133Aq2lEZdPU0SKGlfg 6V/MjztCWE7gr5PUtLpTnuAsa9qB/nm6KdpLNhX4tKPzOW31dATrsSjrcKqgeIc0HDH6xmpM JdmsBFY+EYZmIK6foSjjPYLz4hquP3j5xBh43lvglQpdcBUdAQ0+97YDzrYnGfXGN9dOME/A L33Ls7m9KnE05nFviTNz0+cMXogcbEr57iaQ5uPW9a1OHf5QnYk4ITCnKjr20jbw8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Nov 18, 2022 at 04:49:23PM +0100, Marek Marczykowski-Górecki wrote:
> Linux enables MSI-X before disabling INTx, but keeps MSI-X masked until
> the table is filled. Then it disables INTx just before clearing MASKALL
> bit. Currently this approach is rejected by xen-pciback.
> According to the PCIe spec, device cannot use INTx when MSI/MSI-X is
> enabled (in other words: enabling MSI/MSI-X implicitly disables INTx).
> 
> Change the logic to consider INTx disabled if MSI/MSI-X is enabled. This
> applies to three places:
>  - checking currently enabled interrupts type,
>  - transition to MSI/MSI-X - where INTx would be implicitly disabled,
>  - clearing INTx disable bit - which can be allowed even if MSI/MSI-X is
>    enabled, as device should consider INTx disabled anyway in that case

Is this last point strictly needed?  From the description above it
seems Linux only cares about enabling MSI(-X) without the disable INTx
bit set.

> 
> Fixes: 5e29500eba2a ("xen-pciback: Allow setting PCI_MSIX_FLAGS_MASKALL too")
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> Changes in v3:
>  - allow clearing INTx regardless of MSI/MSI-X state, to be consistent
>    with enabling MSI/MSI-X
> Changes in v2:
>  - restructure the patch to consider not only MASKALL bit, but enabling
>    MSI/MSI-X generally, without explicitly disabling INTx first
> ---
>  drivers/xen/xen-pciback/conf_space.c          | 19 +++++++++++------
>  .../xen/xen-pciback/conf_space_capability.c   |  3 ++-
>  drivers/xen/xen-pciback/conf_space_header.c   | 21 +++----------------
>  3 files changed, 18 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/xen/xen-pciback/conf_space.c 
> b/drivers/xen/xen-pciback/conf_space.c
> index 059de92aea7d..d47eee6c5143 100644
> --- a/drivers/xen/xen-pciback/conf_space.c
> +++ b/drivers/xen/xen-pciback/conf_space.c
> @@ -288,12 +288,6 @@ int xen_pcibk_get_interrupt_type(struct pci_dev *dev)
>       u16 val;
>       int ret = 0;
>  
> -     err = pci_read_config_word(dev, PCI_COMMAND, &val);
> -     if (err)
> -             return err;
> -     if (!(val & PCI_COMMAND_INTX_DISABLE))
> -             ret |= INTERRUPT_TYPE_INTX;
> -
>       /*
>        * Do not trust dev->msi(x)_enabled here, as enabling could be done
>        * bypassing the pci_*msi* functions, by the qemu.
> @@ -316,6 +310,19 @@ int xen_pcibk_get_interrupt_type(struct pci_dev *dev)
>               if (val & PCI_MSIX_FLAGS_ENABLE)
>                       ret |= INTERRUPT_TYPE_MSIX;
>       }

Since we are explicitly hiding INTx now, should we also do something
about MSI(X) being both enabled at the same time?  The spec states:

"System configuration software sets one of these bits to enable either
MSI or MSI-X, but never both simultaneously. Behavior is undefined if
both MSI and MSI-X are enabled simultaneously."

So finding both MSI and MSI-X enabled likely means something has gone
very wrong?  Likely to be done in a separate change, just realized
while looking at the patch context.

> +
> +     /*
> +      * PCIe spec says device cannot use INTx if MSI/MSI-X is enabled,
> +      * so check for INTx only when both are disabled.
> +      */
> +     if (!ret) {
> +             err = pci_read_config_word(dev, PCI_COMMAND, &val);
> +             if (err)
> +                     return err;
> +             if (!(val & PCI_COMMAND_INTX_DISABLE))
> +                     ret |= INTERRUPT_TYPE_INTX;
> +     }
> +
>       return ret ?: INTERRUPT_TYPE_NONE;
>  }
>  
> diff --git a/drivers/xen/xen-pciback/conf_space_capability.c 
> b/drivers/xen/xen-pciback/conf_space_capability.c
> index 097316a74126..eb4c1af44f5c 100644
> --- a/drivers/xen/xen-pciback/conf_space_capability.c
> +++ b/drivers/xen/xen-pciback/conf_space_capability.c
> @@ -236,10 +236,11 @@ static int msi_msix_flags_write(struct pci_dev *dev, 
> int offset, u16 new_value,
>               return PCIBIOS_SET_FAILED;
>  
>       if (new_value & field_config->enable_bit) {
> -             /* don't allow enabling together with other interrupt types */
> +             /* don't allow enabling together with other interrupt type */

This comment needs to be adjusted to note that we allow enabling while
INTx is not disabled in the command register, in order to please
Linuxes MSI(-X) startup sequence.

FWIW, another option would be to simply disable INTX here once MSI(-X)
is attempted to be enabled, won't that avoid having to modify
xen_pcibk_get_interrupt_type()?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.