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

Re: [PATCH v4 2/3] xen/pci: Refactor PCI MSI intercept related code


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Wed, 5 May 2021 07:51:22 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=ei+MbNbWj9fMRiHITeteag47v3N76yJUMY45bCUTQxg=; b=GxUX4ZBnjH6OvXcl1KPVI7huPY86zQ2yWHZocA/2yiOsBpMfEuxl3WRtdZrFdfgrcta/I/qNYxMVJ5rI9Yznc+M0AoHNDaUiY8ciMHcZhaltKWhGoi5kZxUVc4Xi7yS8ik5GJznmSWmKqFqlrkYIkI3FN9FSC6s3H9qPNcqFJ+0e/mBifEw2ecGNjJ13szL5rNWoUpWirJOC6eZNa3GmU3EDvEnJsjwqpIuCtQkX9ZkrKV5vdZ0rXlkS1pa9KrZXr2wTOnBC8XVQV7hyZ/zCG5e6rAYamFKPXBLpmGqet43TRUsG07MgNnPXvmIgP+lEcvbcYjeEQ9AnpYLWCKWlaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O4T1dZcR8z+3GxqKSqSXTztuVaxSW0YvyCdftEaLJdCkVBKWPE5w+S+CTA2MXbCiU86Ke6cNbyI5wILWvG6DAgDVGa33JSuosRAgbXyNmwUTGn61QDQjViZ6Kn3Tu+7suP9Rp50tXnO1L6H6CPNxbKSTxrvWZUm5dDwdBBeQROt+wYf8u2DOxIeFXx37uIKsIiRFeUPvaVnhqu9Fl1RLVXdK8jos2Qt22CJR+AYAcwRrXArgqflKo3bcs5TlrwQCsBwT8ms3ADmmSEVTZw1GhHTqPo3V8Og1AfbLcVrTRygtRyoMLYkG5q/7RMVEZM/cIO7/ygdG46xE+6yHohm41Q==
  • Authentication-results-original: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 05 May 2021 07:51:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXPQaiQSZBgPx8y0KxY0XhVGEZGarR2gGAgAKy0wA=
  • Thread-topic: [PATCH v4 2/3] xen/pci: Refactor PCI MSI intercept related code

Hi Jan,

> On 3 May 2021, at 3:38 pm, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 29.04.2021 16:46, Rahul Singh wrote:
>> --- /dev/null
>> +++ b/xen/drivers/passthrough/msi-intercept.c
>> @@ -0,0 +1,53 @@
>> +/*
>> + * Copyright (C) 2008,  Netronome Systems, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along 
>> with
>> + * this program; If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#include <xen/init.h>
>> +#include <xen/pci.h>
>> +#include <asm/msi.h>
>> +#include <asm/hvm/io.h>
>> +
>> +int pdev_msix_assign(struct domain *d, struct pci_dev *pdev)
>> +{
>> +    int rc;
>> +
>> +    if ( pdev->msix )
>> +    {
>> +        rc = pci_reset_msix_state(pdev);
>> +        if ( rc )
>> +            return rc;
>> +        msixtbl_init(d);
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +void pdev_dump_msi(const struct pci_dev *pdev)
>> +{
>> +    const struct msi_desc *msi;
>> +
>> +    list_for_each_entry ( msi, &pdev->msi_list, list )
>> +        printk("- MSIs < %d >", msi->irq);
> 
> Only the %d and a blank should be part of the format string inside the
> loop body; the rest wants printing exactly once.

Yes I agree I missed this I will fix this in next patch.
 
> 
>> +static inline size_t vmsix_table_size(const struct vpci *vpci, unsigned int 
>> nr)
>> +{
>> +    return
>> +        (nr == VPCI_MSIX_TABLE) ? vpci->msix->max_entries * 
>> PCI_MSIX_ENTRY_SIZE
>> +                                : 
>> ROUNDUP(DIV_ROUND_UP(vpci->msix->max_entries,
>> +                                                       8), 8);
> 
> I'm afraid I don't view this as an acceptable way of wrapping lines.
> How about
> 
>    return (nr == VPCI_MSIX_TABLE)
>           ? vpci->msix->max_entries * PCI_MSIX_ENTRY_SIZE
>           : ROUNDUP(DIV_ROUND_UP(vpci->msix->max_entries, 8), 8);

Ok.

> 
>> @@ -428,6 +458,31 @@ int vpci_make_msix_hole(const struct pci_dev *pdev)
>>     return 0;
>> }
>> 
>> +int vpci_remove_msix_regions(const struct vpci *vpci, struct rangeset *mem)
>> +{
>> +    const struct vpci_msix *msix = vpci->msix;
>> +    unsigned int i;
>> +    int rc;
>> +
>> +    for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
>> +    {
>> +        unsigned long start = PFN_DOWN(vmsix_table_addr(vpci, i));
>> +        unsigned long end = PFN_DOWN(vmsix_table_addr(vpci, i) +
>> +                vmsix_table_size(vpci, i) - 1);
>> +
>> +        rc = rangeset_remove_range(mem, start, end);
>> +        if ( rc )
>> +        {
>> +            printk(XENLOG_G_WARNING
>> +                    "Failed to remove MSIX table [%lx, %lx]: %d\n",
>> +                    start, end, rc);
> 
> Indentation looks to be off by one space on the last two lines.

Ok.

> 
>> --- /dev/null
>> +++ b/xen/include/xen/msi-intercept.h
>> @@ -0,0 +1,49 @@
>> +/*
>> + * Copyright (C) 2008,  Netronome Systems, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along 
>> with
>> + * this program; If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#ifndef __XEN_MSI_INTERCEPT_H_
>> +#define __XEN_MSI_INTERCEPT_H_
>> +
>> +#ifdef CONFIG_HAS_PCI_MSI_INTERCEPT
>> +
>> +#include <asm/msi.h>
>> +
>> +int pdev_msix_assign(struct domain *d, struct pci_dev *pdev);
>> +void pdev_dump_msi(const struct pci_dev *pdev);
>> +
>> +#else /* !CONFIG_HAS_PCI_MSI_INTERCEPT */
>> +
>> +static inline int pdev_msix_assign(struct domain *d, struct pci_dev *pdev)
>> +{
>> +    return 0;
>> +}
>> +
>> +static inline void pdev_dump_msi(const struct pci_dev *pdev) {}
>> +static inline void pci_cleanup_msi(struct pci_dev *pdev) {}
> 
> I don't think this last one is intercept related (and hence doesn't belong
> here)?
> 
Ok I will move this to next patch in series.
>> @@ -148,6 +150,7 @@ struct vpci_vcpu {
>> };
>> 
>> #ifdef __XEN__
>> +#ifdef CONFIG_HAS_PCI_MSI_INTERCEPT
> 
> Since both start and ...
> 
>> +static inline void vpci_msi_free(struct vpci *vpci) {}
>> +#endif /* CONFIG_HAS_PCI_MSI_INTERCEPT */
>> #endif /* __XEN__ */
> 
> ... end look to match, may I suggest to simply replace the __XEN__ ones,
> as the test harness isn't supposed to (randomly) define CONFIG_*? Or
> alternatively at least combine both #ifdef-s?

Ok I will replace the line "#ifdef __XEN__"  with  " #ifdef 
CONFIG_HAS_PCI_MSI_INTERCEPT”

Regards,
Rahul

> 
> Jan
> 


 


Rackspace

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