From patchwork Tue Oct 31 02:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guanjun X-Patchwork-Id: 159923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2629609vqb; Mon, 30 Oct 2023 19:20:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgI2kLA8//ixCjex8agdh7zYCZG5hhwpeFFClzGb8DfhXClYITZkZwPP9n8eAs+DN+AR4g X-Received: by 2002:a17:902:e30a:b0:1cc:644a:211b with SMTP id q10-20020a170902e30a00b001cc644a211bmr1217242plc.47.1698718847841; Mon, 30 Oct 2023 19:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698718847; cv=none; d=google.com; s=arc-20160816; b=d+OPnXNnuD07x70STsNG0hH0qlZMe9RcbMVjTh6yJ112cxFrPd5iqucswXzgJLiuIC 8wOaaYsVJD7XlsOoda86Zi84JUpwRQr1Y2O1ptM+dlR0WwAYfiQwYkNazMrb0eWgVgqz Qla39UxFBOsjjFj4i08ONI97mhfq6otd9fUR5KIBBxq6leiSQ+O+ItggsDLOMDiLfjxy fSYCNyC7Xcpss0OAs5GbF8hy2RY4SrDSkOJjz/GYm+h7DRJhkFfJAx1TlJCV2MIwSQx7 4Z2r1YV1QBq55B0i9LvkTEu98baKbgcOrUTNF6GJswP8Pgh35UxttXWlEkFNLBkwYYbU go9g== 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=YLT+0z5Hd0/f0myrnD1eJC6a0fukVISnMDvCx6STdHC0kFKjFKUeYt/xGYKagE2mPo Bei0gDUqmxNvblCjry45jIKS9bWkWeAe3RMC8duijZ7eYcZ/gKpdAMUtajU/7HrHfnOT p4UKXKVEL22a/YF9Xl8e3OM68qD4pcCDhCZV1HOrgfqK+LPuoS0Q1rsn8ZUv/b2jFUB/ xLzb5BpWs2S5npm0310vcCeEoSOhm7NGO/DxJuRZ5IqyzkbeWDFgErAHCdCpZ46Idbm0 y4SkMoAQXKWdCVw1pEuvMddzUOVNK/e03tEMhgYOCqmMRqNA27qKVmnG0/bMLUC/S84d LPnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id lh11-20020a170903290b00b001bbf293f45esi272655plb.625.2023.10.30.19.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 19:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 313F480407C0; Mon, 30 Oct 2023 19:20:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbjJaCUc (ORCPT + 33 others); Mon, 30 Oct 2023 22:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbjJaCU1 (ORCPT ); Mon, 30 Oct 2023 22:20:27 -0400 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15A0E8; Mon, 30 Oct 2023 19:20:23 -0700 (PDT) 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=ay29a033018046059;MF=guanjun@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0VvFgelA_1698718819; Received: from localhost(mailfrom:guanjun@linux.alibaba.com fp:SMTPD_---0VvFgelA_1698718819) by smtp.aliyun-inc.com; Tue, 31 Oct 2023 10:20:20 +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 v2 1/2] dmaengine: idxd: Protect int_handle field in hw descriptor Date: Tue, 31 Oct 2023 10:20:16 +0800 Message-Id: <20231031022017.1515471-2-guanjun@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231031022017.1515471-1-guanjun@linux.alibaba.com> References: <20231031022017.1515471-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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 30 Oct 2023 19:20:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781235814657189138 X-GMAIL-MSGID: 1781235814657189138 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 --- 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 {