[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 05/14] vpci: add hooks for PCI device assign/de-assign
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Date: Mon, 31 Jan 2022 08:45:17 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=nfWLDqPactt6WNXrsH0X69C7Sfmdco0YC9oa7ja2Lyg=; b=PsnRhF13LJyYAMjNVA/4xWDWm6CD1V9J+sbveFrkxGnz4WvWn3FHRKYAXVwUBVdPYFDIOwSZEv+6e6YE/taS4Pb+grtECO5/buPJLOBC9Rny0Jq2Dz6wZZGzjzsH/Y1mtSWocFMH+1GZIAWjNzVhqblzudkK35sJW0clsX+8HWkkT3pOxeUwRg541j80uFizznxxwPVPefpLClUHjk0vo5sMUQAbWRMX/goqNoM7wZduVgG+YXLXmeVD/dZzCtFx/8j3ZlbsdNSLD5BDh2hXHrQs4dCr4fmhCO0KFpukq6EDT3FFiPxIwzhBKfUUI3ea852KynpGcoqo6kfA1V1Q3A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ep9JRvwcijnGIN81EvzecPMHULDWWNjxHM50npuH4kBwGSDkhSaxwr75n5Ysg6ei6St+ZtmRbPvHPJp7c2ije7WPcAg4Z9ktdKQ7tnXNFY1n5zBiCYgRWUjLD3UdqNMBDJ1sT66ywWVFTspGLGjfN3oUpIC5JJPFteGiklicjKcaApUosgb+iE5T6GftLWlQp8Uxu1mNZP9wSpD9xhSgzJGoZEwMQBb3PKXF7gFqQdXFoDyXLGpgVBVeB4htebm2a8C1HWLSenoYWINZsq+8OUamGC6nwrWFItYqPUW7MV4ySuqxWztTA0QnTojUcKB1NE1lXYj9DYAJZuYy6yDH8Q==
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
- Delivery-date: Mon, 31 Jan 2022 08:45:37 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHX4ewGcVFZUW6RNkyJ6BxXBZzZQqxhIP0AgBwY6IA=
- Thread-topic: [PATCH v5 05/14] vpci: add hooks for PCI device assign/de-assign
Hi, Roger!
On 13.01.22 13:40, Roger Pau Monné wrote:
> On Thu, Nov 25, 2021 at 01:02:42PM +0200, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
>> +/* Notify vPCI that device is assigned to guest. */
>> +int vpci_assign_device(struct domain *d, struct pci_dev *pdev)
>> +{
>> + int rc;
>> +
>> + /* It only makes sense to assign for hwdom or guest domain. */
>> + if ( is_system_domain(d) || !has_vpci(d) )
>> + return 0;
>> +
>> + spin_lock(&pdev->vpci_lock);
>> + rc = run_vpci_init(pdev);
> Following my comment below, this will likely need to call
> vpci_add_handlers in order to allocate the pdev->vpci field.
>
> It's not OK to carry the contents of pdev->vpci across domain
> assignations, as the device should be reset, and thus the content of
> pdev->vpci would be stale.
>
>> + spin_unlock(&pdev->vpci_lock);
>> + if ( rc )
>> + vpci_deassign_device(d, pdev);
>> +
>> + return rc;
>> +}
>> +
>> +/* Notify vPCI that device is de-assigned from guest. */
>> +int vpci_deassign_device(struct domain *d, struct pci_dev *pdev)
>> +{
>> + /* It only makes sense to de-assign from hwdom or guest domain. */
>> + if ( is_system_domain(d) || !has_vpci(d) )
>> + return 0;
>> +
>> + spin_lock(&pdev->vpci_lock);
>> + vpci_remove_device_handlers_locked(pdev);
> You need to free the pdev->vpci structure on deassign. I would expect
> the device to be reset on deassign, so keeping the pdev->vpci contents
> would be wrong.
Sure, I will re-allocate pdev->vpci then
>
> Thanks, Roger.
Thank you,
Oleksandr
|