From patchwork Sun Oct 29 08:00:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guanjun X-Patchwork-Id: 159344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1572068vqb; Sun, 29 Oct 2023 01:01:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmtrdAizyJ6/Rv33Uf2nq7rlJrcNsaauSj9+APwMdzjsolUwdVEaUHESoRv5w7BDmvDDdp X-Received: by 2002:a05:6358:785:b0:169:5d77:cd8f with SMTP id n5-20020a056358078500b001695d77cd8fmr4168937rwj.11.1698566482172; Sun, 29 Oct 2023 01:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698566482; cv=none; d=google.com; s=arc-20160816; b=Y1xC7Q6aCKd6Ri+2Q0fHziUwK0ugvahepn5JcmJXo4ic2uxbAbAScyNN/nEqkYz7Aw 65WhCfN+dxp21tY12hXv2tMGX9pzTsDifsfoKkxFqcFYWUnEMVuAc3qLm5E8BLhj0Y8k 7lhBkLRrDnysrHCkDuEMlk3VVWFM4/n84eggd08xi2PxzVnrho12upc0cfrIgpbgYISc o9w69PGnaeigzYFg411HOT3zA3x3QEeLhHFkS4VypPXFVbkh5Z4QYMLAIXu6TKxGVuDP CglhjSHSR3S2HNClqcFYg22dkrfISGlCRi2vhIdq3664ctgkhr2V7ZJtKgBlCLL43WZk +UhQ== 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=gzc9iTTpvVjslsvB4sPMAForhnWUue9zFC+Klgiq8ls=; fh=QBHJhMFaY+lWbqr2wKEcOz8zsPIdmcjBYs3CtaAVoV4=; b=t27yHw9l8ruWKmIgr8/Y0m4kJErS1EoK4pwD5tHxtDeqj9P1SczlCluNQ4cy3DNfv2 ennp3qNc94fOJNRWwgwLzu9becPFRg9FqM4qO46EvSAIf4u0DZSNevnM07hEWtAmSmko mV/SnqXmQmyOY+DaM+cDOZ5MF5tJvy6m+87D/atltv9KgulUTIFOvA2BhQvnxnIB290q e54HtE/ghyj1eZR5xhZpXV7uhnvavTKkKtLSOZ7pBSdgyE6ybCWssRKUFzhvH+67A2vm FtndEBJFdiUI7qAHEi+T67SW/x9Kvdzl9uJ45MsU5uDDDC4wrVFOHRGTi7xGfrY/6wFX DUzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id rm6-20020a17090b3ec600b0027d29e618f7si3375582pjb.78.2023.10.29.01.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 01:01:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id C79EF805CCE4; Sun, 29 Oct 2023 01:01:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbjJ2IBE (ORCPT + 30 others); Sun, 29 Oct 2023 04:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjJ2IA7 (ORCPT ); Sun, 29 Oct 2023 04:00:59 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E3BC9; Sun, 29 Oct 2023 01:00:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R881e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=guanjun@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0Vv31XWv_1698566451; Received: from localhost(mailfrom:guanjun@linux.alibaba.com fp:SMTPD_---0Vv31XWv_1698566451) by smtp.aliyun-inc.com; Sun, 29 Oct 2023 16:00:52 +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 Subject: [PATCH v1 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor Date: Sun, 29 Oct 2023 16:00:48 +0800 Message-Id: <20231029080049.1482701-2-guanjun@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231029080049.1482701-1-guanjun@linux.alibaba.com> References: <20231029080049.1482701-1-guanjun@linux.alibaba.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Sun, 29 Oct 2023 01:01:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781076047388928727 X-GMAIL-MSGID: 1781076047388928727 From: Guanjun The int_handle field in hw descriptor should also be protected by wmb() before possibly triggering a DMA read. Signed-off-by: Guanjun Reviewed-by: Dave Jiang Reviewed-by: Fenghua Yu --- 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 {