Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3739390pxu; Tue, 8 Dec 2020 22:15:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEGzp3YZzXsZjwlnbpUZPQWvhCwraAU1ykW8tfjwBG5mKPvYA5Q7oJPweeW6Dt8IitUkC2 X-Received: by 2002:a05:6402:318f:: with SMTP id di15mr575666edb.237.1607494511775; Tue, 08 Dec 2020 22:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607494511; cv=none; d=google.com; s=arc-20160816; b=sRcN5yYdt7V+uEKNwG45x0T076phfzCxqUOg+E6azGsgfLHvY1CYVBMTwKzvF30DIx FyZkvDOlhtXQohm2ENuL/b2HOXHw8ggUpkn6J0AY6wMvwK450kE82cl5jLH0nZq1AgIi fmBO+fACjIuUKc1JbtJTOT6T1SzkkQNNFgigMPUoGLGwmohzpUWYM34pNnpa4j2w5MGx sC8s4F2fxfgUy7JQ5susTWmHnzciu1FLpwrfYeh2Nq5jMgtN59X+VEqM7B+Me17Xc9fh AlUf2wZbpSdddri8WpG3z/2OBIP6hjv3090q8nAddLA1zkyuO8YM6RFaUP9JApL7u5IK L02Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CPDp5sL2SqKvhZg0mxRiRnuJ0QdXwiHSE4jTazP1OA8=; b=zSepb18+KKnNZ849mjSJzR3ZZK0PbiECzJE3S1jStg7xiUyDTQfvkW3eW8FmgZTqpD JijK9NtUMYDyinydWTYtIu6uSSULJgrBi00wtRP6R2oTo93pLqWqv1oYZs2AdVjAE6GP uc+KXp6QkZw3WGULLgKy2JjBhbD5pvOdiNYg+RsLWy/LTy/yQjB0/fV5jyCmuJLXxGFT F9k5Glwod3KNRAF3lw4imvqJLfGlcyIKp0cIiN7IuXuP1ct6QA6cYxbBynY8pv0HTVqd EdueZHGScSNDq78dsln+t722v6/i+uLtTnyq2+D6PW5nJ6r0rkXuGLAne8iV8WOrxERo KXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=E2HAOp86; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si294166edw.306.2020.12.08.22.14.49; Tue, 08 Dec 2020 22:15:11 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=E2HAOp86; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbgLIGDR (ORCPT + 99 others); Wed, 9 Dec 2020 01:03:17 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:19134 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbgLIGDR (ORCPT ); Wed, 9 Dec 2020 01:03:17 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 08 Dec 2020 22:02:37 -0800 Received: from mtl-vdi-166.wap.labs.mlnx (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 9 Dec 2020 06:02:35 +0000 Date: Wed, 9 Dec 2020 08:02:30 +0200 From: Eli Cohen To: "Michael S. Tsirkin" CC: , , , Subject: Re: [PATCH] vdpa/mlx5: Use write memory barrier after updating CQ index Message-ID: <20201209060230.GA57362@mtl-vdi-166.wap.labs.mlnx> References: <20201206105719.123753-1-elic@nvidia.com> <20201208164356-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20201208164356-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.9.5 (bf161cf53efb) (2018-04-13) X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1607493757; bh=CPDp5sL2SqKvhZg0mxRiRnuJ0QdXwiHSE4jTazP1OA8=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Originating-IP:X-ClientProxiedBy; b=E2HAOp86KwUh9tA8J7ATrlKWgvNkwiEHJoxZoJzVkbMivts5jPqfjueHBWrcF1yr3 7qX/8qZplACyvubWXD93ZhPcbXyBu4lHWGVG6VyPtiTJpzc+Ejz4uZBuRErEEHG6nm ZU/2DOROW/CIs6lbN1j07JyuaKtugxv38B3N1P+JFrY4Ly8VTCw3aGh9FFfiR0kDUf uPnsToN9PddpqQnWa44Y2RzAxgcd8EspW4Csa7aYL/iCVCLivc5SN5xFgKP5xgxNdV cGAJio+sD3XJ1n4Yv7nL34IJF2covzyvq+y42mBjsbW2c2LvzH9cwuygtuaT4bXjrf Z7f7GGAn2EGWg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 04:45:04PM -0500, Michael S. Tsirkin wrote: > On Sun, Dec 06, 2020 at 12:57:19PM +0200, Eli Cohen wrote: > > Make sure to put write memory barrier after updating CQ consumer index > > so the hardware knows that there are available CQE slots in the queue. > > > > Failure to do this can cause the update of the RX doorbell record to get > > updated before the CQ consumer index resulting in CQ overrun. > > > > Change-Id: Ib0ae4c118cce524c9f492b32569179f3c1f04cc1 > > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") > > Signed-off-by: Eli Cohen > > Aren't both memory writes? Not sure what exactly you mean here. > And given that, isn't dma_wmb() sufficient here? I agree that dma_wmb() is more appropriate here. > > > > --- > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > index 1f4089c6f9d7..295f46eea2a5 100644 > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > @@ -478,6 +478,11 @@ static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq) > > static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int num) > > { > > mlx5_cq_set_ci(&mvq->cq.mcq); > > + > > + /* make sure CQ cosumer update is visible to the hardware before updating > > + * RX doorbell record. > > + */ > > + wmb(); > > rx_post(&mvq->vqqp, num); > > if (mvq->event_cb.callback) > > mvq->event_cb.callback(mvq->event_cb.private); > > -- > > 2.27.0 >