From patchwork Tue Sep 18 03:49:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 970912 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42DpsR5lRfz9sCD for ; Tue, 18 Sep 2018 13:49:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728988AbeIRJUP (ORCPT ); Tue, 18 Sep 2018 05:20:15 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:51803 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726414AbeIRJUP (ORCPT ); Tue, 18 Sep 2018 05:20:15 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from saeedm@mellanox.com) with ESMTPS (AES256-SHA encrypted); 18 Sep 2018 05:53:56 +0200 Received: from sx1.hsd1.ca.comcast.net ([172.16.5.56]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w8I3nTSx015153; Tue, 18 Sep 2018 06:49:32 +0300 From: Saeed Mahameed To: "David S. Miller" Cc: netdev@vger.kernel.org, Eli Cohen , Saeed Mahameed Subject: [RESEND net 1/3] net/mlx5: Fix read from coherent memory Date: Mon, 17 Sep 2018 20:49:26 -0700 Message-Id: <20180918034928.28651-2-saeedm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918034928.28651-1-saeedm@mellanox.com> References: <20180918034928.28651-1-saeedm@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eli Cohen Use accessor function READ_ONCE to read from coherent memory modified by the device and read by the driver. This becomes most important in preemptive kernels where cond_resched implementation does not have the side effect which guaranteed the updated value. Fixes: 269d26f47f6f ("net/mlx5: Reduce command polling interval") Signed-off-by: Eli Cohen Reported-by: Jesper Dangaard Brouer Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 3ce14d42ddc8..a53736c26c0c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -206,7 +206,7 @@ static void poll_timeout(struct mlx5_cmd_work_ent *ent) u8 own; do { - own = ent->lay->status_own; + own = READ_ONCE(ent->lay->status_own); if (!(own & CMD_OWNER_HW)) { ent->ret = 0; return;