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

Re: [PATCH 5/5] vPCI/MSI-X: tidy init_msix()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 28 Dec 2020 18:58:42 +0100
  • 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-SenderADCheck; bh=Uy5bTNHDCVjBbuIW4X/SGecNJtqr+d0lbXOznEpwKM8=; b=Gwhf/oedZLScX2BB1nlPobKSsorAbPmuHLtgFhGK5Fll1Aqw5QBq7NN+Ssp9hqJ1gGT3vvny76MxCZqDHESFd8wDbOl9Y3zVAYOvJp0fKRA4riA5e3l8htnzQPTpw07tk1vlBO5TrQcfw0BLE7iaZzEgAZfj//XMqXi/mmVwMv0Zs9ErYjobWBfI0j5vSgTXrww5xzviqCJ8cUy3bi/IU8R4nmYyk9t1hHeMXYHDZ0Z0eQBDBIt8YXnE1d+h7yGOCc0MuSoiDJIkIjXw+ehwQcCBbvTg/ngYwIvZhy4QuzgxYtv4wvxnGv9yPN5YPlVEpEVZoEVTw5DYm3Mp4/u86g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uz/74jtQqUWlOVq3WoobWp3gzmo2bXj3HLPPVBOS3XqWOV3RGrf8ianAUJJ/+xscJ2id6VS4WcxThJmBvs5U0DrRTCh8Tm/x+1cSYhd8llKsdvf/XmCX+OuIeq4+gN6xsV/SH3lpX/9fnmNzLW1n0FCIcYBIVrM48ifUA8Gjhkf8SGRNzsrL6r+/cbzX2ofYXhu+cuTTxJoP3G5fjFgsUPzHYSz2CWcTMMSd/z4u6iZdibGVEHl7qHvNgkBVRPqRpDow058pHwpx+83mKn+v0CfLrbNgbdetVOuzOxcCBZd7rUFctNP4b9dwUERUoa8YYtTNbzvvPsfctBY90RJi+g==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 28 Dec 2020 17:59:00 +0000
  • Ironport-sdr: wUNWyeMFFXT4wr//cR26S3uDH9qZ9Qjr0YDX/qJ+OGL7PYSOfXgSEKW5zs71IKTLRvEwmWKWfF U8X7Ajb6pbWyao6mkOHhx45JLIK5cEtOcXwMuI9KtkNhPEEaPtJ5Yq4O55ozZQpmrQS0XPbH0E svIzmHAdn7QgNrMCCJy8cYCkllNzwsTDo0pn0RJTwj0So4VmavfakkfXAu4eM+6IIfKd1/h+hf NX352P3IoJx/MWtcnTaLR8MiQYi34HwMfYqxKb8yr04ebDlgd/e3sDOEjq3y6cplYCnqV+mjYR s4Y=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Dec 07, 2020 at 11:38:42AM +0100, Jan Beulich wrote:
> First of all introduce a local variable for the to be allocated struct.
> The compiler can't CSE all the occurrences (I'm observing 80 bytes of
> code saved with gcc 10). Additionally, while the caller can cope and
> there was no memory leak, globally "announce" the struct only once done
> initializing it. This also removes the dependency of the function on
> the caller cleaning up after it in case of an error.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Just a couple of comments.

> ---
> I was heavily tempted to also move up the call to vpci_add_register(),
> such that there would be no pointless init done in case of an error
> coming back from there.

Feel free to do so.

> 
> --- a/xen/drivers/vpci/msix.c
> +++ b/xen/drivers/vpci/msix.c
> @@ -436,6 +436,7 @@ static int init_msix(struct pci_dev *pde
>      uint8_t slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn);
>      unsigned int msix_offset, i, max_entries;
>      uint16_t control;
> +    struct vpci_msix *msix;
>      int rc;
>  
>      msix_offset = pci_find_cap_offset(pdev->seg, pdev->bus, slot, func,
> @@ -447,34 +448,37 @@ static int init_msix(struct pci_dev *pde
>  
>      max_entries = msix_table_size(control);
>  
> -    pdev->vpci->msix = xzalloc_flex_struct(struct vpci_msix, entries,
> -                                           max_entries);
> -    if ( !pdev->vpci->msix )
> +    msix = xzalloc_flex_struct(struct vpci_msix, entries, max_entries);
> +    if ( !msix )
>          return -ENOMEM;
>  
> -    pdev->vpci->msix->max_entries = max_entries;
> -    pdev->vpci->msix->pdev = pdev;
> +    msix->max_entries = max_entries;
> +    msix->pdev = pdev;
>  
> -    pdev->vpci->msix->tables[VPCI_MSIX_TABLE] =
> +    msix->tables[VPCI_MSIX_TABLE] =
>          pci_conf_read32(pdev->sbdf, msix_table_offset_reg(msix_offset));
> -    pdev->vpci->msix->tables[VPCI_MSIX_PBA] =
> +    msix->tables[VPCI_MSIX_PBA] =
>          pci_conf_read32(pdev->sbdf, msix_pba_offset_reg(msix_offset));
>  
> -    for ( i = 0; i < pdev->vpci->msix->max_entries; i++)
> +    for ( i = 0; i < msix->max_entries; i++)

Feel free to just use max_entries directly here.

>      {
> -        pdev->vpci->msix->entries[i].masked = true;
> -        vpci_msix_arch_init_entry(&pdev->vpci->msix->entries[i]);
> +        msix->entries[i].masked = true;

I think we should also set msix->entries[i].updated = true; for
correctness? Albeit this will never lead to a working configuration,
as the address field will be 0 and thus cause and error to trigger if
enabled without prior setup.

Maybe on a different patch anyway.

Thanks, Roger.



 


Rackspace

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