[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN PATCH v8 1/5] xen/vpci: Clear all vpci status of device
- To: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Daniel P . Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
- From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
- Date: Fri, 17 May 2024 09:15:35 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- 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=8TcHqf/2wKc5G2hwPJnRH1JFlS15hzlrRu4ufDXl3Gs=; b=HdQmliV1e/BF6uG23JYhW/cnkg61YeLkPf8ye/l365ddC+dRTx0ZawEKWdsIKJyRqoHyVha0+Nf5vQTPmFoxWCaaVrawneSc6oenHiEvtPx57PeaYGrDoakJyp/cpLqW9v/3mT+NntjdODrioJCEIkhg4VFNrSfi6ziyBiSm8Pw9b79eBtYwbp5X/mayBJzQ7oXHmN8E3fB3TiznsYm8mpHlVI83uodosipFwvTIUoE/XlhlTuJ+ztv2I/LAzsHE1jrUM6v0cp4BKiLSP5xi+aizxq6AXl11tSjXySdZf47UjpE0csQl24ZuHhAE4wpZ1pxk4KK1SThoJEVx/3Y5qQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJK8/fj8iiF7XhBBX/FwaN4cyGcVwWO6DzH0kPWX6qdHPvfsmPX1xIITsLyAczrdJLci4JrKwfeG5J2yGL4OLXNPp1vCgc6gjTlnBRYVo4mDsMJHZ6FwzwVBI+nUhRQrJywrIg1NJBWo82LNoZ/bFQUpSZHQZy0++jYCmOXATsUviUVv/gO8B4grJN/jfEhjSC8yhFGoJSu+rG3a2WhHdR55qW7LmYNGC+YFD9NgN8txxj/xoHm89KrXb0uYpOpOgjrzdGUNTEJUFQIMLgraCBIt/+K82+4KIABYZ00A8myQPzyaWNUkFjdDku7rrPdkuXS8q5YjAAgydrRkG0WKvg==
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Fri, 17 May 2024 13:16:08 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 5/17/24 04:08, Chen, Jiqian wrote:
> On 2024/5/16 21:08, Jan Beulich wrote:
>> On 16.05.2024 11:52, Jiqian Chen wrote:
>>> @@ -67,6 +68,41 @@ ret_t pci_physdev_op(int cmd,
>>> XEN_GUEST_HANDLE_PARAM(void) arg)
>>> + pcidevs_lock();
>>> + pdev = pci_get_pdev(NULL, sbdf);
>>> + if ( !pdev )
>>> + {
>>> + pcidevs_unlock();
>>> + ret = -ENODEV;
>>> + break;
>>> + }
>>> +
>>> + write_lock(&pdev->domain->pci_lock);
>>> + ret = vpci_reset_device_state(pdev);
>>> + write_unlock(&pdev->domain->pci_lock);
>>> + pcidevs_unlock();
>>
>> Can't this be done right after the write_lock()?
> You are right, I will move it in next version.
So that we are clear on the proposed order of calls here:
+ write_lock(&pdev->domain->pci_lock);
+ pcidevs_unlock();
+ ret = vpci_reset_device_state(pdev);
+ write_unlock(&pdev->domain->pci_lock);
>>> --- a/xen/drivers/vpci/vpci.c
>>> +++ b/xen/drivers/vpci/vpci.c
>>> @@ -115,6 +115,16 @@ int vpci_assign_device(struct pci_dev *pdev)
>>>
>>> return rc;
>>> }
>>> +
>>> +int vpci_reset_device_state(struct pci_dev *pdev)
>>> +{
>>> + ASSERT(pcidevs_locked());
>>
>> Is this necessary for ...
>>
>>> + ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
>>> +
>>> + vpci_deassign_device(pdev);
>>> + return vpci_assign_device(pdev);
>>
>> ... either of these calls? Both functions do themselves only have the
>> 2nd of the asserts you add.
> I checked codes again; I will remove the two asserts here in next version.
Nit: I think it's okay to keep the
ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
|