Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3768483rdb; Sun, 10 Dec 2023 21:37:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKVdBVf9Ee6E6SiwamRFso6GV7ORWJ/6BKIx698m/a2sivom9WVG8OUpSlVBWZ3S/W6Dt7 X-Received: by 2002:a17:90a:bc04:b0:286:6cc1:3f29 with SMTP id w4-20020a17090abc0400b002866cc13f29mr2581585pjr.96.1702273046710; Sun, 10 Dec 2023 21:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702273046; cv=none; d=google.com; s=arc-20160816; b=KfImOHC8pOYsERTqbIpPNTtrLwws/AjWrleDXhc4gQXXj6XNxTyvGcKkY4+6OtACx/ 0dRhJ7Y5fDaruMxnF8RvPixloKw53MNEXOtr9clc0riIVcmOLzdLnhse3SOCuvuDacSV UH2SduxK2EIU8EMNbbOTrAayBWLPCTh+MR7LWNbE67as/cNp5nII1yTlwQzfFQba+QKQ /bD6iEnvsgSY9kQ9KGg7ilfP/eQtPfP9YBVmD6x62UMZFivoTyHrngPL09sWs3f5X9+p 041WROXZZWBFxvQBYfxX+qk81mbCuK6yHykYMDXu3Yn8mUPKcgJwPpxZd/zYvIWswpf8 DqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5g8eFkgUbuzL/Oz4PVnu+1lzw3hd3oq7NnNEsDnKi1E=; fh=un7dZAZp9pSkRKfeT5a2d+I0o7/mCh6YSrYzyba6bng=; b=CvsbuuPpmv9igobY/0V9LpA9aadGkvXYO9iKwdyU4eIy6LZcR5dExwsCg4qRtJUk+x y4m9Vzq1zIjOWXsePh95zUZZtDnKfr9TWidngCfOJX5IaKntTW7lc3K73yudEhg9MxER +zqi0yjftpEA96U8sA3EfmrHIrdjFHngZOKeoyad/hvRLY4O7siGB0jmZzsoyraxqY70 u3GeUf7v33bLvATWqmhG1O2+S16aiZTdjDDB/XHwVUbU4O9+jdEB8w0qk3yTVXtFszRs kbazx9QEEOFRJgNWuqtPS6yasNKxvJ6BZuBR9bMDJEFwYS6Rn2/uRdjJTTty7YYrVjCr 39Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i6-20020a17090ad34600b0028a281c4e9esi5264722pjx.129.2023.12.10.21.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 21:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B7B568095034; Sun, 10 Dec 2023 21:37:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233203AbjLKFhG (ORCPT + 99 others); Mon, 11 Dec 2023 00:37:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233068AbjLKFhD (ORCPT ); Mon, 11 Dec 2023 00:37:03 -0500 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0358EEA; Sun, 10 Dec 2023 21:37:08 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=guanjun@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0VyAqSe0_1702273025; Received: from localhost(mailfrom:guanjun@linux.alibaba.com fp:SMTPD_---0VyAqSe0_1702273025) by smtp.aliyun-inc.com; Mon, 11 Dec 2023 13:37:06 +0800 From: 'Guanjun' To: dave.jiang@intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, tony.luck@intel.com, fenghua.yu@intel.com Cc: jing.lin@intel.com, ashok.raj@intel.com, sanjay.k.kumar@intel.com, megha.dey@intel.com, jacob.jun.pan@intel.com, yi.l.liu@intel.com, tglx@linutronix.de, guanjun@linux.alibaba.com Subject: [PATCH v5 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor Date: Mon, 11 Dec 2023 13:37:03 +0800 Message-Id: <20231211053704.2725417-2-guanjun@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231211053704.2725417-1-guanjun@linux.alibaba.com> References: <20231211053704.2725417-1-guanjun@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 10 Dec 2023 21:37:25 -0800 (PST) From: Guanjun The int_handle field in hw descriptor should also be protected by wmb() before possibly triggering a DMA read. Fixes: eb0cf33a91b4 (dmaengine: idxd: move interrupt handle assignment) Signed-off-by: Guanjun Reviewed-by: Dave Jiang Reviewed-by: Fenghua Yu Reviewed-by: Lijun Pan --- drivers/dma/idxd/submit.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/dma/idxd/submit.c b/drivers/dma/idxd/submit.c index c01db23e3333..3f922518e3a5 100644 --- a/drivers/dma/idxd/submit.c +++ b/drivers/dma/idxd/submit.c @@ -182,13 +182,6 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc) portal = idxd_wq_portal_addr(wq); - /* - * The wmb() flushes writes to coherent DMA data before - * possibly triggering a DMA read. The wmb() is necessary - * even on UP because the recipient is a device. - */ - wmb(); - /* * Pending the descriptor to the lockless list for the irq_entry * that we designated the descriptor to. @@ -199,6 +192,13 @@ int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc) llist_add(&desc->llnode, &ie->pending_llist); } + /* + * The wmb() flushes writes to coherent DMA data before + * possibly triggering a DMA read. The wmb() is necessary + * even on UP because the recipient is a device. + */ + wmb(); + if (wq_dedicated(wq)) { iosubmit_cmds512(portal, desc->hw, 1); } else { -- 2.39.3