From patchwork Tue Oct 31 02:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guanjun X-Patchwork-Id: 159935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2639156vqb; Mon, 30 Oct 2023 19:56:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx4udQd3ZDDviIrzUOrNhegWYJhaWYLFSYFGYsQzTX/uRc2IgfxL4yVRhEcRFz1Lgm1uRX X-Received: by 2002:a05:6358:6f14:b0:168:e637:9dfc with SMTP id r20-20020a0563586f1400b00168e6379dfcmr14580124rwn.0.1698720991647; Mon, 30 Oct 2023 19:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698720991; cv=none; d=google.com; s=arc-20160816; b=sjSAe+bTE6E4T85ofyUYL4zOvXU4fJRtEFGiBEMzEYb5o6jgTMOxX5WettwYYEKZeu +rkw5BwJMHeDJjyNXGvLHWHA54rLphoCIAeUGvWXVvoLmM6RtdYSVnPDTRzqfLkrYWyh tRvcyPNczHM3M0bOZIHqnMtgl4re9fjcRGu8+XUVq8SKZd/CxoNdUswo1BYwz5YaMEEU bauBTKXi12b0CxYxMnaBiZCuO9kx7LYO+7elWuTvCUtUbbXu08Croz5v7o8JpWesXm7g vIqGwkLT6NWMgAIGi+JXo2tf2L0tftf7ePPN8M5vrJBTA5jI0iIpY9ux+OdpsVKPagsu KRwg== 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=2+ZCd2Ukl3tdwspiNdzftO/ZiqT8EGhicvhl00o1cfk=; fh=QBHJhMFaY+lWbqr2wKEcOz8zsPIdmcjBYs3CtaAVoV4=; b=S69/Oz1nlg8VV3kcFztJ4LwAcTDJhsS/qLHX4uPC/pMgrvuODavpRYn3b/R+CQ5Mrw TIdNDd9QbmU9+4kpPVTBXii+Y+uzKwmaENR0gVA6fpaXEEM6Cl0mLeQhNDmpAEBFldMY 5Tky5b1AMiSyYnxqPhkRy1yCD35BNIfJTi5ZkXX1c+UPvV6GRx1mD5n3RzI7wrH68Tym gjTNAVCzVuG7HOYf5fsXE7eC2dd31QcC9HbXBbw/nfshE9zFq2GgmNF6BVLDh1bHH1ZE 513OzExIM3c6lN9G+yKv3GK+3GfXckE/5FaTev4ma323/WXk1Vwc3amsq3Kr9xf0Otnc ZU0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id v10-20020a63610a000000b005b9b68adda4si355048pgb.75.2023.10.30.19.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 19:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 1145E807749C; Mon, 30 Oct 2023 19:55:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234101AbjJaCzX (ORCPT + 33 others); Mon, 30 Oct 2023 22:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbjJaCzV (ORCPT ); Mon, 30 Oct 2023 22:55:21 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD69CC; Mon, 30 Oct 2023 19:55:17 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;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_---0VvFgpU9_1698720913; Received: from localhost(mailfrom:guanjun@linux.alibaba.com fp:SMTPD_---0VvFgpU9_1698720913) by smtp.aliyun-inc.com; Tue, 31 Oct 2023 10:55:14 +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 v4 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor Date: Tue, 31 Oct 2023 10:55:10 +0800 Message-Id: <20231031025511.1516342-2-guanjun@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231031025511.1516342-1-guanjun@linux.alibaba.com> References: <20231031025511.1516342-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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 19:55:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781238062449710469 X-GMAIL-MSGID: 1781238062449710469 From: Guanjun The int_handle field in hw descriptor should also be protected by wmb() before possibly triggering a DMA read. Fixes: ec0d64231615 (dmaengine: idxd: embed irq_entry in idxd_wq struct) 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 {