Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1486925ybh; Sun, 19 Jul 2020 22:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB4xsPeugkEaOkrJyzINOBy20nbjA3S00gvzH9DToQmgYeOIgwol4ekAnJiYbE25F86hkV X-Received: by 2002:a17:906:f2c4:: with SMTP id gz4mr19026298ejb.484.1595222552983; Sun, 19 Jul 2020 22:22:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1595222552; cv=pass; d=google.com; s=arc-20160816; b=E6vzp40dDgMjuT/PX5gNlULpDRqbJvp7oAquCq5SGfkr7QbIG/A/Uom7g8yBU+iaKV s7jepziX/4dhMK5rvvXfngOETg/rZkvGVYoDuYJFjmeY8FSJclLhyH3cmXNqUiEOhX8y kfJ3HMbL4EOSnYvUq3eQgKpBME+h23oZ6RPmiuyGonKZ7qN1IHGqApJ8zrpJNwLZmQk4 i4qlsu8yoZ4hUOS6T4ho2y8JLsx8zYhXy925M2YJGnuHuDb7FjtrW+WfzUmlzgSYbyO8 G8pmyCc5KNVpwzmWNqCO4ERnugZXykNWm5fD5uvwkrQHbrEHnGeVCR6F2RIDDnXYa00j 8RgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=hkGS3oBnWPmH7USF1p1dYNJ6wG+q8/gO873T7sBMXTw=; b=Ryy4mx1TcREahLuPIjkjU/OnGfzSQIVeATtQSj5h45nW4mPdkkz9qt6gKRT7qnMNln pXxrMLuaB7MuoqE5WJn3pagUbvCbhTkF+Zny2+eDMwmzY61Fx0sY+TOW0kOmPVH+h0uM qKThjrq7+LU6n15bjvr46RUtiHE1yjbuhf3P5n2NewYcvEo8vQUs7+EEaxLbybz5jmdz IReZ5fwYvdUu5M+odpBl0qDuw2skA8IQtLTygbXd/wzLbKlEzygU3zI4Bxqn85J4kZC5 d5+h0zZHntV8QiJ3KK0DqosMCVw3olSPa1RKIi3JNHhj3mshP2yBwEh0c7Y/2TkR/84X DitA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=tSgdldUE; arc=pass (i=1 spf=pass spfdomain=mellanox.com dkim=pass dkdomain=mellanox.com dmarc=pass fromdomain=mellanox.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l6si9974911ejx.493.2020.07.19.22.22.09; Sun, 19 Jul 2020 22:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=tSgdldUE; arc=pass (i=1 spf=pass spfdomain=mellanox.com dkim=pass dkdomain=mellanox.com dmarc=pass fromdomain=mellanox.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgGTFTt (ORCPT + 99 others); Mon, 20 Jul 2020 01:19:49 -0400 Received: from mail-am6eur05on2083.outbound.protection.outlook.com ([40.107.22.83]:51809 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725287AbgGTFTs (ORCPT ); Mon, 20 Jul 2020 01:19:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bILze/TnnIO+ZkhzvJjg19QZbWnBYKtPJf2SFaTThXQwa0WRD4sgJagXcT6hhnnlgST4YQRcmlrcyflzePYM016C5fWh/2L7RgCYsWqx8yTD5mHXNXls30KVAJvjkfPwAnQQlmozIYii3iitax4YOOmxXY/YfXUy3o/p9t4SXj/GLiCne0ojwcmfTUNLb1LxOKRy95c4JwhfwdfZ5yy/LhOhknRHDSvPiblCBK/3FB4/VSxuzPuDZbsJLPh2xWI1IM1S18codEerSr9n+Egx9NAa9nTg+W4BbhHpg9rFcJ8nfjYbSUu4zVZIjHVY5tsROC+pALnGvqd3XfXmc/7XSA== 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=hkGS3oBnWPmH7USF1p1dYNJ6wG+q8/gO873T7sBMXTw=; b=O52yZb723JDyrnP9rIXHIp5K4gQKEnE/DG7g+ckH6kzAZdtNJiRjXLdQZAvyYKHOFCgZJGLndkHZWHas+zWFvT1YjaHG36PbQK6NBufZ8LjlRsZ3y97kLJ8cUZ0RC6LKqHJgUa7vo2UNq5ux3moH8L1gjj8O5wE5iepRw2x0A5H3IB3/j76hx/Sth5ZiOKgAglWFilV8ejPT5mI6vaRvf2l/SCX4DdtDTmhsxAc1WvbI/btifD9k01K0BvpTc6EGhpVQtgZeMhXmuG2aC9VTiE6idHN8ijP9NW0QzsXYmqvrl4nEhzZF1Wvr9cGYstlQdkrdKzZ1gmoQXsTvxTKTjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hkGS3oBnWPmH7USF1p1dYNJ6wG+q8/gO873T7sBMXTw=; b=tSgdldUEMXM9zpqqti+bbwXDvvvvtel6/fn6/Mm5YoBmm1iXe4Os0IL8j98Oicq7pvL3cU2Y/0MPfBKG/v/Dw421E4VjP3zohQV3DjeS1ljfrNHvPt40L+lnR2quAiRUIOnCqfKrw7MS68HmmmgviCbYH9loZzK+e6bOaSp3rqM= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4786.eurprd05.prod.outlook.com (2603:10a6:208:b3::15) by AM4PR0501MB2228.eurprd05.prod.outlook.com (2603:10a6:200:45::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.23; Mon, 20 Jul 2020 05:19:44 +0000 Received: from AM0PR05MB4786.eurprd05.prod.outlook.com ([fe80::e00a:324b:e95c:750f]) by AM0PR05MB4786.eurprd05.prod.outlook.com ([fe80::e00a:324b:e95c:750f%7]) with mapi id 15.20.3195.025; Mon, 20 Jul 2020 05:19:44 +0000 Date: Mon, 20 Jul 2020 08:19:40 +0300 From: Eli Cohen To: Jason Wang Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, shahafs@mellanox.com, saeedm@mellanox.com, Parav Pandit , Eugenio Perez Martin Subject: Re: [PATCH vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices Message-ID: <20200720051940.GA116013@mtl-vdi-166.wap.labs.mlnx> References: <20200716072327.5359-1-eli@mellanox.com> <20200716072327.5359-11-eli@mellanox.com> <454850cc-269b-72aa-4511-2bf793a215cc@redhat.com> <20200716115428.GC186790@mtl-vdi-166.wap.labs.mlnx> <20200718194902.GA52765@mtl-vdi-166.wap.labs.mlnx> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-ClientProxiedBy: AM3PR07CA0075.eurprd07.prod.outlook.com (2603:10a6:207:4::33) To AM0PR05MB4786.eurprd05.prod.outlook.com (2603:10a6:208:b3::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mtl-vdi-166.wap.labs.mlnx (94.188.199.18) by AM3PR07CA0075.eurprd07.prod.outlook.com (2603:10a6:207:4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.17 via Frontend Transport; Mon, 20 Jul 2020 05:19:43 +0000 X-Originating-IP: [94.188.199.18] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 95094744-bbe6-4d2d-0ba1-08d82c6c8340 X-MS-TrafficTypeDiagnostic: AM4PR0501MB2228: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DGQ5gbndmgYXrpQxZItLu5Mvqm57+CcAVi7uwPMo79WgW7qIFh4yMbRSfm3up+Upavgne6ziXvhDdL7T8WjRQXWdEsHrZN3a8RSortO/ZDsJDD3RmF8gkso8rsmLNM6/cd3+fg1oe09DHzJI7P8MILDhjGA8GpnI+neRK7p25K7YYcR+z1kOXrUbRddhFZ4iu2cDL4OFMNPh7uoC3WlEewejLict6SlWRKXfx5kV4T5amfbgsFyxmU8hFsNLp13MqwkekgKkt8gEfHt3Rtm1n4LPCGjeJj6qsLZCtVl3egX+9HicDXNMImElu5B6dFjKNbuNhdccJPwg8qDTZGUcbQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR05MB4786.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(396003)(376002)(366004)(26005)(5660300002)(8676002)(8936002)(316002)(55016002)(66556008)(66946007)(54906003)(9686003)(478600001)(186003)(16526019)(66476007)(52116002)(7696005)(4326008)(2906002)(86362001)(1076003)(956004)(6916009)(6506007)(83380400001)(33656002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fGNzDJXk7fJvomHs6MjDrugU0VZGjxRdzQHU+QMNtBS1gZXMtCWLAU2WkhCfQ9IkS8J98+R2RHg7gdQ8sSozqamXsZC55CrB4wTxhg4rVDuIUIloNuO0Y5AhbDiKtAfQ/oeTL4QXLqad3Fv0mfWzqjkNQGIuxK3t2Gz/r5ZR+kSjtWwcXvqkMFigZA7Sy3+M7aclghW1TGwaJZDwC3NHwMHiqvPfM0SOvGJYfzwR35IzFwXY0PgHE0/Ng/MT/DucTuyPRB+Cu03cN632rIf/7Ab+zF7V+nnYFOrGh4IpY4UviW1GVTP2icJcalETFahNFmnEP8v0qw+UQ9IGS+lRzEtBMy9vLuy5L4PCITAClp//DA7ULFyIwnsuI5Og3L3qwjGrQhkJtQI/lG/uxTJTaN6i6HxesVk/Bj3RCFap3zBA5U+GuOKq0GuUx7ayGoovfMLsHD47iLSBYAW9rVkSLko8iXaxUTx/Wrjdzq82qCw= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95094744-bbe6-4d2d-0ba1-08d82c6c8340 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4786.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2020 05:19:44.5076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KJGHsou9TtS7Jtnpx3378LLsZkOJTeQINvImhLl1RLqafeKDCyzl6OhUk4EY9Ed9E9Yg2S8GvLquzLi7q5usPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2228 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 12:12:30PM +0800, Jason Wang wrote: > > On 2020/7/19 上午3:49, Eli Cohen wrote: > >On Fri, Jul 17, 2020 at 04:57:29PM +0800, Jason Wang wrote: > >>>Looks like checking intialized is enough. Will fix this. > >>>>>+ > >>>>>+static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready) > >>>>>+{ > >>>>>+ struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); > >>>>>+ struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); > >>>>>+ struct mlx5_vdpa_virtqueue *mvq = &ndev->vqs[idx]; > >>>>>+ int err; > >>>>>+ > >>>>>+ if (!mvq->ready && ready && mvq->fw_state != MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY) { > >>>>>+ err = modify_virtqueue(ndev, mvq, MLX5_VIRTIO_NET_Q_OBJECT_STATE_RDY); > >>>>>+ if (err) { > >>>>>+ mlx5_vdpa_warn(mvdev, "failed to modify virtqueue(%d)\n", err); > >>>>>+ return; > >>>>>+ } > >>>>>+ } > >>>>I wonder what's the reason of changing vq state on the hardware > >>>>here. I think we can defer it to set_status(). > >>>> > >>>I can defer this to set status. > >>> > >>>I just wonder if it is possible that the core vdpa driver may call this > >>>function with ready equals false and after some time call it with ready > >>>equals true. > >> > >>Good point, so I think we can keep the logic. But looks like the > >>code can not work if ready equals false since it only tries to > >>modify vq state to RDY. > >> > >The point is that you cannot modify the virtqueue to "not ready". > > > Is this a hardware limitation of software one? Sorry, but I was not accruate in my statement above. You can suspend the hardware VQ but you cannot mover out of suspend back to ready. > > I'm asking since we need support live migration. But a questions is > how to stop the device but not reset, since we need get e.g > last_avail_idx from the device. > > It could be either: > > 1) set_status(0) > 2) get_vq_state() > > or > > 1) set_queue_ready(0) > 2) get_vq_state() > This can work. > Set_status(0) means reset the virtio device but last_avail_idx is > something out of virtio spec. I guess using set_queue_ready() is > better. > > What's you opinion? So if the intention to set ready(0) as a preliminary state for live migration then we're ok. We just need to keep in mind that there's no way of suspend but destroy the hardware vq. > > Thanks > > > > The > >only option is to destroy it and create a new one. This means that if I > >get ready equals false after the virtqueue has been created I need to > >teardown the driver and set it up again. > > > >Given that, I think your original suggestion to defer this logic is > >reasonable. > > >