From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34E1D41DBF; Fri, 3 Mar 2023 06:45:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25FBE41149; Fri, 3 Mar 2023 06:45:36 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 2C30E40687 for ; Fri, 3 Mar 2023 06:45:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677822334; x=1709358334; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=aGku2HL42VKkRJJlB4dVmnM8A8mQC+HM7jblB0l9xaQ=; b=H7fiDkBdxpJv3NIBom8kQEjiSjf6uJZjPWLK9+0rceSK6M96vc0GbS6G KpDPdBUIYFxykxSddwfrlQmkZtd8yPETIFAteZ1eT920a57hwWMn+jUmi siyI0VoPF7mq/GmGzZE2dPlcmP44kglfoWMdw0sgAqGaG5E167iqzkKb1 87u5/S8AFOSAWxP0JH1Lc7oj4PFGSwp4GqXe21q0tIJUwhCLZ8qUOCZ0w LEkvV3VqQC1wKVky9lyK+Z4tC1HbZR9HMPDhU0Qp+Km48EDXujG+cHFBf uxiLI/Hof64OnArfRIA8ZAoiUruyeM8aSnprQBe3E4i3Men6i0XuJiU+v g==; X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="399770459" X-IronPort-AV: E=Sophos;i="5.98,229,1673942400"; d="scan'208";a="399770459" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2023 21:45:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="744139366" X-IronPort-AV: E=Sophos;i="5.98,229,1673942400"; d="scan'208";a="744139366" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP; 02 Mar 2023 21:45:32 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 2 Mar 2023 21:45:31 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 2 Mar 2023 21:45:31 -0800 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 2 Mar 2023 21:45:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaJY6mZxoGsf789LsnUIEhl9bJDiXMztCDOQGR8JlHA81VIqSZokDj0bNmvIAM8ScJWRURwvXq/hFlbmdz/5ErgE3Br5vSKnQOvRVK5bxd8VaA/U2j1wDbHehOvDSmFBUSfILpZSgbcAMhlJ0OxnhPD5sR4AKCQpp1xMyyz6DFCHbsno8FS5Lf65RUQhuROv0uKGf22fVwegWr8GJ1GIIh4DAEw2dYyURG93T42ttyihffzQafdyhMy1R4j5Kx4JoCwtgO97DfYVnNu7wuZoEIAye9N9ndnWkQU6r/KNoaxyypVY6n5aoQwQSptrF+13t4HGQ/dGjbdDRzXUdOxzbg== 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=tRkZIOFjlc4bKHxIDik3zFYaxJurwaSF1D7lAQG4eOE=; b=FTWq4WDUh1LaG4D51DL8agzw64Dryr5VB5vYzGx2c+/x2b1LhIMXhcRmyJNr1mRrPtbATkUbgjRdWpFGQeMTJLZ+lk954cEa/E/j9JtgdQrDSYDOVKpsdrCNzBv4fXbL918T+zXGOeTJywYaavRrT5QyOPj9fZcNBmMJJBD81kIee09Xp92Ss/oAUx2OBZwGuu2PU4nzAGKXCM/XSZc0hFowj4fJB6g5dfA4Hi5HLut+Dy3GZfTBOQKCsA00cX3EURFxLGjF3bGmFawQsUXq/T7YJMeEj99cDw4k+Q86RxfSctCJ8uUMzf1QiA2fqZsA7l+R9SwMNhf2mZOijVzIhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB3499.namprd11.prod.outlook.com (2603:10b6:5:61::24) by DM4PR11MB7302.namprd11.prod.outlook.com (2603:10b6:8:109::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18; Fri, 3 Mar 2023 05:45:30 +0000 Received: from DM6PR11MB3499.namprd11.prod.outlook.com ([fe80::8f75:8e66:322e:899]) by DM6PR11MB3499.namprd11.prod.outlook.com ([fe80::8f75:8e66:322e:899%3]) with mapi id 15.20.6156.017; Fri, 3 Mar 2023 05:45:30 +0000 From: "Xia, Chenbo" To: David Marchand , "dev@dpdk.org" CC: "ssimma@nvidia.com" , "yajunw@nvidia.com" , Maxime Coquelin , =?iso-8859-1?Q?Morten_Br=F8rup?= Subject: RE: [PATCH] vhost: fix vring enable with VDPA Thread-Topic: [PATCH] vhost: fix vring enable with VDPA Thread-Index: AQHZTOwglaSPrLGfF0eL1hjDabNmsK7ojNQw Date: Fri, 3 Mar 2023 05:45:29 +0000 Message-ID: References: <20230302094808.1519310-1-david.marchand@redhat.com> In-Reply-To: <20230302094808.1519310-1-david.marchand@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB3499:EE_|DM4PR11MB7302:EE_ x-ms-office365-filtering-correlation-id: 72b303b2-9ef7-4728-1e1b-08db1baa7f78 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ppOF2ySoK2vhr5Edg2CUk3fbWKzHLJjBJJKTL/8hrIZ10k3EvuP3xZOos8vk/aIb4oqgxA9jI+zuC7c1k/4+ylAakVFnKfJp7tGeFyYVLYDvCGjSefa/YDyJ1zNLkctFwf3OjWwlsf9BDu6sFNXqbFZukT+vohjhXwEYlod/CrTgksOZv/kbs+9cZeaJBmfwWIUZ8T/cJfnFatukmVs0naepAVRI8VI+hFMMoEp71bUuP5MT1uwHsWCRP/71hWU+nsEVcuG5+KZaSrXjj7V41ITngJci2YAAWjtfLM/ES1Fc58JLqUh2ynfwDuZ+Oya9TvGf0vqeCaxFkB+x6ouVCXFbbRBqnlvEFTkJ0VCMSccVq6i9oqVssKIORZNtHrK+vItGxK2lXZ+NOSrDoS2MfcVQRDpQchyVygSxf7j1JlhgoUg5JLBD6uWv/ju59Ed1JbQEGXF4j05eU6jQ/aQHhMDObduRlrZFRZ/XXmhnjbmbdCsHhD+AewdvxFA7OiioQkyQsI9kbiMMI5rraIvBPcCRORI9yemZHg8G1aiqYHapKFl7wZXvLAN2tW5pcg7NhYFahf6E/wYNvn3ihAC5Li0SOKYT2Se6HxnUHBJWX/WQsDSwvz1ak/is3+vzZgiCLXsDoFNSvTZYmxxvvRpAqfffOF4dvxtlHUieYYRdskfp8d0qhBAnL0KlOdvrfhB1RpsFTJPhWnEIQtK8jKR2Bg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB3499.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(376002)(39860400002)(346002)(396003)(136003)(451199018)(83380400001)(38100700002)(122000001)(71200400001)(82960400001)(8936002)(5660300002)(478600001)(33656002)(66556008)(55016003)(38070700005)(86362001)(66574015)(9686003)(186003)(26005)(53546011)(64756008)(7696005)(66476007)(76116006)(2906002)(52536014)(8676002)(66946007)(66446008)(6506007)(54906003)(316002)(41300700001)(4326008)(110136005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?aXqlR9eXPzcFBG1NWC7cVHgh7zRz9ol1lVtXo6Vd6DACYhnW/bCNZlUBiu?= =?iso-8859-1?Q?bfUSHXNqfW4pbufddS/VEKldsGk6shSDI0/wLMgPUGk8IO5BpMtk+eFqTj?= =?iso-8859-1?Q?N+jUfwW6U/SYhdYFcJoi7Lg6wWnTcxa9ovIrJeF01bPcHsFk4+VsGbG3Wq?= =?iso-8859-1?Q?nQPety7umrgVN8zX3O3b1Qog9QcxvG+koTt61555aozuPT1OnQDa1GU9tL?= =?iso-8859-1?Q?1SniEtmfCXgRRIocOveJ7NvpbJVRof6lHNsrfsC26wbbOghoe5B+ZqXRtK?= =?iso-8859-1?Q?0DvwfqqhlApxjBlVVlUr6UymxlMT07dBDjg48yCmZ5VK1jn4SMTepT/pcY?= =?iso-8859-1?Q?DbHZRliF3NsbwZN6+ZspcObvUndfpKTFxhNSnpz2TLKFppFFLMeEmJvFzh?= =?iso-8859-1?Q?SGq9j9ZGpMa3ga4BbDv8QDeBA6Z4IlK2tHcPTxHgHwIsNHVt23K5WENaw0?= =?iso-8859-1?Q?Qh5CLP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kXPFBzj4/CO0/ea?= =?iso-8859-1?Q?X+XpIjWFBg88S/RSN7HhaJxUKiA2Re0LMCu5PjkS06nPWmuMBbHdjtkU8b?= =?iso-8859-1?Q?mHlI2hGlq1wwFOJquSIfmp40mCHHMoWKPcrCLbu4KbPKXfhgltwJD1LMFe?= =?iso-8859-1?Q?A4rYJlMUTTCl4VR5etYPDpdAKEvwJ2Pk8MZaF4SFbZUpUrCM8lz3HhradF?= =?iso-8859-1?Q?HLSbN1SS2k7I1oydjWy1YN/8nl/5PxNFcI+RTtkyv6ZCj9rIKezUznxxx/?= =?iso-8859-1?Q?y2NzLymE6ACnOm5FPFKmAzuUZa+vkKenAg?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3499.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b303b2-9ef7-4728-1e1b-08db1baa7f78 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2023 05:45:29.9869 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uXfcelUn5tiz5Z8saKC0hi63zvQD7Z6D2xlrbIAZdQLOuerUZGXVVu/A8F0mxJpAYd5Z+cAkOtVss/10BUiSOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB7302 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: David Marchand > Sent: Thursday, March 2, 2023 5:48 PM > To: dev@dpdk.org > Cc: ssimma@nvidia.com; yajunw@nvidia.com; Maxime Coquelin > ; Xia, Chenbo ; Morten > Br=F8rup > Subject: [PATCH] vhost: fix vring enable with VDPA >=20 > For VDPA devices, vq are not locked once the device has been configured. > But we need to hold the vq lock to check if vhost async is enabled. >=20 > Combining VDPA and vhost async does not seem to make much sense, so > prevent this combination, and only assert the lock is taken when VDPA is > not configured on this vq. >=20 > Bugzilla ID: 1169 > Fixes: 4b02c2673757 ("vhost: annotate async accesses") >=20 > Signed-off-by: David Marchand > --- > lib/vhost/vhost.c | 4 ++-- > lib/vhost/vhost_user.c | 8 ++++---- > 2 files changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index c36dc06a0a..6b73c03224 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1754,7 +1754,7 @@ rte_vhost_async_channel_register(int vid, uint16_t > queue_id) >=20 > vq =3D dev->virtqueue[queue_id]; >=20 > - if (unlikely(vq =3D=3D NULL || !dev->async_copy)) > + if (unlikely(vq =3D=3D NULL || !dev->async_copy || dev->vdpa_dev)) > return -1; >=20 > rte_spinlock_lock(&vq->access_lock); > @@ -1778,7 +1778,7 @@ rte_vhost_async_channel_register_thread_unsafe(int > vid, uint16_t queue_id) >=20 > vq =3D dev->virtqueue[queue_id]; >=20 > - if (unlikely(vq =3D=3D NULL || !dev->async_copy)) > + if (unlikely(vq =3D=3D NULL || !dev->async_copy || dev->vdpa_dev)) > return -1; >=20 > vq_assert_lock(dev, vq); > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index d702d082dd..daf3458985 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2177,10 +2177,10 @@ vhost_user_set_vring_enable(struct virtio_net > **pdev, > enable, index); >=20 > vq =3D dev->virtqueue[index]; > - /* vhost_user_lock_all_queue_pairs locked all qps */ > - vq_assert_lock(dev, vq); > - if (enable && vq->async) { > - if (vq->async->pkts_inflight_n) { > + if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { > + /* vhost_user_lock_all_queue_pairs locked all qps */ > + vq_assert_lock(dev, vq); > + if (enable && vq->async && vq->async->pkts_inflight_n) { > VHOST_LOG_CONFIG(dev->ifname, ERR, > "failed to enable vring. Inflight packets must be > completed first\n"); > return RTE_VHOST_MSG_RESULT_ERR; > -- > 2.39.2 Reviewed-by: Chenbo Xia =20