Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4433830pxu; Wed, 9 Dec 2020 17:42:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcbEDoH3S8fEu3oGR/84vpGXLuTRHXoI7GpMs6T4OjAK6U1ulmdE9pxS4TTLsZLKxTAHg/ X-Received: by 2002:a17:906:12cf:: with SMTP id l15mr4342372ejb.540.1607564569088; Wed, 09 Dec 2020 17:42:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607564569; cv=none; d=google.com; s=arc-20160816; b=EzUZjyBRD7Q1sXfpZI025hLPF5NbPUgK3wf2KevNpLWfHlSwqq2U2bzcRL2O/KrElx baQOb/BgrRApjNKso6q8lPadt1PiKreMDy/MweQS4GL8YVZmN2z/41cxKaSYP9QUDOT1 Q39KUQ2zCpS0TXdBU+2HjpP8dAN3a/miUrxrfMr6rmIKj1fsLPjneLSDDC9yLZjeZuMX DqBrjqvpyNVcuOtWzMkR+RD1wEvh2RVzOc+o/iOxRoEbaktB6dKnN7YnI97FiB9jUEDE SClWEtFj7LPUIb4ujPHItlxK6aQOV5psQ3B96JEcsYt12ip321icS16bitor3ocO1JVO mewQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=5/w5thrUbO7coLFa91ISjV5KtPV9HKqfLYeWTRwEtkE=; b=Ze8OgBMDesfeogMvSNJgiZ9U8+rSjdjxlPLsNP5uMThyOMR7HJeJtcTqeMQQpJ120c VbGQ/w6KpPHekOUhwRZ/0TgbcWmN/XS0ZWiGZl35pHtp/JNTYkKhCokQxsLMqCXsTIJC JGTNvFl2QX6NfzGtw6PliLb7cBUdhlpc52Y3dg7+/zLAxJiGI9u5Dme+8hLNZcZi1dVK FeV8gA7jPj90/1hpZumG2b+599lMy5raXBiXvOZd+DNqFgeaOFP92iVBOTiKZNw2AH2b E5XHEDQpCk6j2M5s+vW4yoZADgDKjp4AEg05dgquAsAvr6MdeQyq58+6WTveyXUSu04L TMUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="a4z8z/bz"; 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 h17si1670652ejg.46.2020.12.09.17.42.23; Wed, 09 Dec 2020 17:42:49 -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="a4z8z/bz"; 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 S1728158AbgLIOBy (ORCPT + 99 others); Wed, 9 Dec 2020 09:01:54 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:1891 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728840AbgLIOBY (ORCPT ); Wed, 9 Dec 2020 09:01:24 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 09 Dec 2020 06:00:39 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 9 Dec 2020 14:00:38 +0000 Received: from vdi.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Wed, 9 Dec 2020 14:00:36 +0000 From: Eli Cohen To: , , , CC: , , Eli Cohen Subject: [PATCH v1] vdpa/mlx5: Use write memory barrier after updating CQ index Date: Wed, 9 Dec 2020 16:00:04 +0200 Message-ID: <20201209140004.15892-1-elic@nvidia.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1607522439; bh=5/w5thrUbO7coLFa91ISjV5KtPV9HKqfLYeWTRwEtkE=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type; b=a4z8z/bzLSAFmd3ybEquqOFl8aAqWlUfWBXDqwLpHw355BFXL8WpAmgHwk37R8ojG gt81bVN2tKT6aqokAmRRxO+h/4IjfblR1JSGURRydwMeyoQHiFBx+3N8lj63ShmaW5 2CibDzHwIlqPk5gq/jUWZXFYBQjf6IyQ7CH8vIqpaNF2b9fta34vsGorGjRaDdOtvb aons2by8UWxfLgKXeEu09p333gWz0uErltkP9S6v8Zn2vQ2gSA3lVGgqyarbpQQwOU uR1LwGDU+vvQX59vJXTdT4NpcYXqhLFBtlmmq6wjgO5TpnbgA/N9i1atKTSFOopFh0 Mi0t4vBq4w65w== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure to put dma 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. Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices= ") Signed-off-by: Eli Cohen --- V0 -> V1 Use dma_wmb() instead of wmb() 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 db87abc3cb60..43b0069ff8b1 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -479,6 +479,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. + */ + dma_wmb(); rx_post(&mvq->vqqp, num); if (mvq->event_cb.callback) mvq->event_cb.callback(mvq->event_cb.private); --=20 2.27.0