From patchwork Sun Sep 11 20:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 12973061 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6071EC6FA86 for ; Sun, 11 Sep 2022 20:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbiIKUki (ORCPT ); Sun, 11 Sep 2022 16:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiIKUkg (ORCPT ); Sun, 11 Sep 2022 16:40:36 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-centralusazon11021023.outbound.protection.outlook.com [52.101.62.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18AAE222BC; Sun, 11 Sep 2022 13:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cLFFA4E5qctspooiw5yghbPC0m0qtuy/KRVJsPr+1/jEEpQWvfhcsvG1t7yn1TkHWYdGiGsy+x7Qr97fljyuLCojatP1/9tex7QaMFyYHxh0HDzpdNLt4E3AKrt9sAbvE2uHBc5beaYnf969jxU9zaKva40ZbhvTSGJ5Ue9wB2pGm4HtMKBpo7TM6R/dkx67nGob98zoOxUjEq7dFMcvJWLyALHQf210/cbmdsvtTE16iD2Bti7Nweh0btjVlRBg6PdPA/BVyWtnqtQX0eMty06VlToIeRC7gSaGucy5pw8PGxRMW5X8rm+y4RMlOfDUCo+8+nXEzre3VsqlbVszZA== 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=HqZ04fRvj+jUk70oPR9hq9VQGwD/RYO0EaRoRKDKBig=; b=XILCDe5SojuDqo2uZgIaHRPK2VOBTbF9+Ph6y/1uD5SYtXStoOafgvK3GIi+yszXG5GsBSgC6fjstwr3EAU7PJE40L4UJeV4kcP3FEgHVGMp1KfildvSEJo8q8rErb4Zt8939bSlGzYgGcexGxptf0ZOH9Q/7RRsU6Rwe1IrQT4TDzanYmSGg09agw2/icJilLmuIZd3Zc4hXY4f1r8Wtd1byMP06asZ6PYjn8aDOi7AHBz7eKww9AHG4XuIN3o37XdHR1EnyGXA2M9kGQTc2UhwvGnJOVs3MUmW2HfdOxnL9swa6+9B/9u4A/Q0lYEHSwMNPqAOZiwNCuH+XIpGPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HqZ04fRvj+jUk70oPR9hq9VQGwD/RYO0EaRoRKDKBig=; b=DTU4NhBWUoGb1FS5YHfuDG0ynwIFEfnXGfnjn3pUtVkOxB7TrSYmemyVPgRFmVZAONjA+B5k0CbCXtc/672FwgfLmqUI098cfyUgVhjFtr2kFpwle2d7PUQHOiehZ23c0OmX/CAAdZG1lJ8hc63k7et++kdNWkwCvJMd65wg3NQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by DS7PR21MB3694.namprd21.prod.outlook.com (2603:10b6:8:90::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.3; Sun, 11 Sep 2022 20:40:32 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3581:1d96:33ac:7305]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::3581:1d96:33ac:7305%4]) with mapi id 15.20.5654.003; Sun, 11 Sep 2022 20:40:32 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, paulros@microsoft.com, shacharr@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net] net: mana: Add rmb after checking owner bits Date: Sun, 11 Sep 2022 13:40:05 -0700 Message-Id: <1662928805-15861-1-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-ClientProxiedBy: MW4PR04CA0159.namprd04.prod.outlook.com (2603:10b6:303:85::14) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|DS7PR21MB3694:EE_ X-MS-Office365-Filtering-Correlation-Id: ab5b9f09-c28d-494b-7d1b-08da9435dee3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8aon7iKAHAJnGjsX7ORXiaVuuLlFc9dVbznHu/7f0tyAJaiycx26/7dKPvWqb/orYv76iSnA3KBuszF/HzlxEtmA4MdK9Vi2lUKorY88AGDZWtCz0UFJZXGOK3kGK+AbBV5T4VYbckf7yoKIE0KSPz/xdGYedQM5Uq5niHsCx7O6+bwsCtYhBpakBldnMbuZZBYHsxF5+XbynkmBs2mjgpRFNJl6mS/3TXKZFIMcw+DLFJwESOCTmc65jpDBY7EHk0DjeH7W1QgjSEsEZfhxckr1OWUrjJD+X4stA/RBQ0prbcPk5/6KSSGmsFp+fPN5pFCvMg+mEFO8cAngvEQWm1AaWm3eq+JYkrmGpszLWyx6b0HyPs7uNui/SX0xbp/144R11RbF+fIaKUh50aAUKtIFVOYdCNXEw/86WqgqfSK+3uJ8EpQ+sGEFNsJoGVhsNpUzH/724uCx8HKS4xOaP6DX/k2XlmcJg6Qe4ulDxA7sX0cnKibnphvnMpuQkNaz73+DIWFTVLAVwRVrFB//DxziOelh/gecJeMwWfMx0Xf4feVgn4jXtKbw12wNLFF1auplaJkg5cZ+nSaji4d1rwdY0Rcw5EIZy632vcRdg6E6cUz1SQdk3y1DBke+AXW1Dt5trV+8KIGVVeQ+SqwFumSpJJSsa5znEBYGB32GKk8fEV3gxJZEravhHsPAYKYeXZDwISBMADXJV5AuqIfHe8pGbAWG1NPlYXYk/qBFurDFxJ791claKufzH+w0R9916UTRdo5GgWi1Vb5+oUeWkf7JyKZF6lrxdC9QnQpNC4OeYs4gYbdn9zbt+3MYrsfQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(376002)(136003)(346002)(39860400002)(366004)(396003)(451199009)(186003)(82960400001)(82950400001)(2616005)(6506007)(316002)(10290500003)(41300700001)(26005)(52116002)(6512007)(38100700002)(6666004)(38350700002)(66476007)(478600001)(6486002)(2906002)(36756003)(7846003)(8936002)(66946007)(66556008)(4326008)(8676002)(5660300002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pf8PePbBGUIDo85DLjwJB6H6dEki02HPcqGQIHj3Lm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CwA4PD2HroTiOiL3TjmScUXIsWpCvCC11IhJmqX++VxU4/cTbXN4zgtF3KrD6h5WbTPExOFebrQU925irByPvZlAub413rv1iGOg9V0as2sC6LkIRi0JoKdBg0oHgoUs16nybhrHV0LYPZcAhNIx771QIxrBn3Ok4snk8Jb0WJn7PqO/3gYh6JunDEJhm7hzjlnn6qWQT4YnmQCyDfl7h8q68aCwerizphUN0CkIAL2l/BvfVl8ac0xon1egRFgyznnfQt1WaASh7td5Y31iVRK7Cyby7F2/6sTY0+AOj15ISUOKTt3LWOddX84ScMS6hRKZJTpSp6pcfGuCaDnD/EKFWUjxGQxPjBtazegaHK7SSnx4rnSt2zKLzabsGTg3GJwN7H3kaK4SKo2d0Ftov1OoSSVsgKwOXyOIK4lvOh8Wv6XvnirXqdMp9b8ktFi+W4AHe9EOpr4izVC8YnPsKYUC0cBHb4WewHhW X-OriginatorOrg: microsoft.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR21MB3694 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Per GDMA spec, rmb is necessary after checking owner_bits, before reading EQ or CQ entries. Add rmb in these two places to comply with the specs. Cc: stable@vger.kernel.org Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Reported-by: Sinan Kaya Signed-off-by: Haiyang Zhang Reviewed-by: Dexuan Cui --- drivers/net/ethernet/microsoft/mana/gdma_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c index 5f9240182351..e10b9f8f89e1 100644 --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c @@ -397,6 +397,11 @@ static void mana_gd_process_eq_events(void *arg) break; } + /* Per GDMA spec, rmb is necessary after checking owner_bits, before + * reading eqe. + */ + rmb(); + mana_gd_process_eqe(eq); eq->head++; @@ -1134,6 +1139,11 @@ static int mana_gd_read_cqe(struct gdma_queue *cq, struct gdma_comp *comp) if (WARN_ON_ONCE(owner_bits != new_bits)) return -1; + /* Per GDMA spec, rmb is necessary after checking owner_bits, before + * reading completion info + */ + rmb(); + comp->wq_num = cqe->cqe_info.wq_num; comp->is_sq = cqe->cqe_info.is_sq; memcpy(comp->cqe_data, cqe->cqe_data, GDMA_COMP_DATA_SIZE);