From nobody Sat Feb 7 06:54:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631253568110470.98107306603185; Thu, 9 Sep 2021 22:59:28 -0700 (PDT) Received: from localhost ([::1]:38548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOZZP-0004Jb-3V for importer@patchew.org; Fri, 10 Sep 2021 01:59:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOZWh-0007U9-RP for qemu-devel@nongnu.org; Fri, 10 Sep 2021 01:56:40 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:41742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOZWf-0002Lf-3r for qemu-devel@nongnu.org; Fri, 10 Sep 2021 01:56:39 -0400 Received: by mail-pf1-x434.google.com with SMTP id x7so927013pfa.8 for ; Thu, 09 Sep 2021 22:56:36 -0700 (PDT) Received: from localhost.localdomain (123-193-74-252.dynamic.kbronet.com.tw. [123.193.74.252]) by smtp.gmail.com with ESMTPSA id v17sm3739101pff.6.2021.09.09.22.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 22:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FDLzGUOT6C8RfO+UO6QhrMPhIy0i56XefPIavUICbBo=; b=ljWj/BM33cT+TsQBFb/KjacYm0VfCaKCKPDzYmZj2VCo9hzjEM7zcr3o3dt6jblgz/ rtZuZh68KS7h2uWlhMrfdgfbltkilJO0ewieKxnd/UBJ21tzT3jQ3T0vZ/JPn6b9xpOh 0wXhYhVblBYo+1aeEipHTwO1eSxy/InBw36lfkrHVbz8EizJEx3diE2EEHRWRWQkwSRf jeERVMVhFvkFIuaiXB1YCwoFTYaEDj6AcCAfjw5MYWAq7zk8GrM1K+0vm6NTieoU6F/a gaBN3geaeQxCYc57yllyHu0pXlUNOIGLKLI2z2TDJ8QUSgEZEqLmitmMzE39+BxbfsGw 5mdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FDLzGUOT6C8RfO+UO6QhrMPhIy0i56XefPIavUICbBo=; b=1nkthP3HCtrY+rHmhF4no7safs6bIHokEi/1iqOnFubY8TIEghggxRt4vP3vbe5Fx1 ahTgnAJo3CsCeMPQmgCKDZ1flVWk4TWljn1DJCbwwn+STD1wcNCI9sKhLYD5TFza70LV 0d3nWFxdsmVsjQhb/lNkLDl2lScTeAxetB+BiR0VFD3P8GoBvMDsGrGV/HlKYOTgA/Bo /D8bd4vGa/uTCACWbjgQlE8vo8LKL6CxDFXf8Ovof09LtYZOG2BYZQq3p4Gco+Bg9duq nJCPTgY33YJD8/0ufVCqy1YeDGCvvoSnDmeKPTHmqytnqH9tJ3O193DjFHtIaUSAsM0z sZdA== X-Gm-Message-State: AOAM532rrZGXW+y6DqOrUdkZPFgyVUM8OPoE5QWWDdJ7RAiIGdODGBMg IH6mspu2sziCweMaAE65CBOdsGyL2MFDv9mb X-Google-Smtp-Source: ABdhPJzyw/YkbGj0eLNS8lWlRG4uoEazA4n7ik72ETGWuAICvayRN+QTCs8AVJYF2O693jJSHsGVUg== X-Received: by 2002:a63:4384:: with SMTP id q126mr5931242pga.1.1631253395683; Thu, 09 Sep 2021 22:56:35 -0700 (PDT) From: frank.chang@sifive.com To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 2/4] hw/dma: sifive_pdma: claim bit must be set before DMA transactions Date: Fri, 10 Sep 2021 13:56:14 +0800 Message-Id: <20210910055620.946625-3-frank.chang@sifive.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910055620.946625-1-frank.chang@sifive.com> References: <20210910055620.946625-1-frank.chang@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=frank.chang@sifive.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Chang , Palmer Dabbelt , Bin Meng , Alistair Francis , Max Hsu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631253570284100001 Content-Type: text/plain; charset="utf-8" From: Frank Chang Real PDMA must have Control.claim bit to be set before Control.run bit is set to start any DMA transactions. Otherwise nothing will be transferred. The following result is PDMA tested in U-boot on Unmatched board: =3D> mw.l 0x3000000 0x0 <=3D Disclaim channel 0 (Channel 0 is not claimed) =3D> mw.l 0x3000004 0x55000000 <=3D wsize =3D rsize =3D 5 (2^= 5 =3D 32 bytes) =3D> mw.q 0x3000008 0x2 <=3D NextBytes =3D 2 =3D> mw.q 0x3000010 0x84000000 <=3D NextDestination =3D 0x840= 00000 =3D> mw.q 0x3000018 0x84001000 <=3D NextSource =3D 0x84001000 =3D> mw.l 0x84000000 0x87654321 <=3D Fill test data to dst =3D> mw.l 0x84001000 0x12345678 <=3D Fill test data to src =3D> md.l 0x84000000 1; md.l 0x84001000 1 <=3D Dump src/dst memory conte= nts 84000000: 87654321 !Ce. 84001000: 12345678 xV4. =3D> md.l 0x3000000 8 <=3D Dump PDMA status 03000000: 00000000 55000000 00000002 00000000 .......U........ 03000010: 84000000 00000000 84001000 00000000 ................ =3D> mw.l 0x3000000 0x3 <=3D Set channel 0 run and cla= im bits =3D> md.l 0x3000000 8 <=3D Dump PDMA status 03000000: 00000001 66000000 00000000 00000000 .......f........ 03000010: 00000000 00000000 00000000 00000000 ................ =3D> md.l 0x84000000 1; md.l 0x84001000 1 <=3D Dump src/dst memory conte= nts 84000000: 87654321 !Ce. 84001000: 12345678 xV4. Signed-off-by: Frank Chang Tested-by: Max Hsu Reviewed-by: Bin Meng Tested-by: Bin Meng --- hw/dma/sifive_pdma.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/dma/sifive_pdma.c b/hw/dma/sifive_pdma.c index e723db9d700..1311b80a5cd 100644 --- a/hw/dma/sifive_pdma.c +++ b/hw/dma/sifive_pdma.c @@ -248,6 +248,15 @@ static void sifive_pdma_write(void *opaque, hwaddr off= set, =20 s->chan[ch].control =3D value; =20 + /* + * If channel was not claimed before run bit is set, + * DMA won't run. + */ + if (!claimed) { + s->chan[ch].control &=3D ~CONTROL_RUN; + return; + } + if (value & CONTROL_RUN) { sifive_pdma_run(s, ch); } --=20 2.25.1