From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.14 07/32] MIPS: Alchemy: fix dbdma2
Date: Mon, 19 Jun 2023 12:28:55 +0200 [thread overview]
Message-ID: <20230619102127.882423018@linuxfoundation.org> (raw)
In-Reply-To: <20230619102127.461443957@linuxfoundation.org>
From: Manuel Lauss <manuel.lauss@gmail.com>
[ Upstream commit 2d645604f69f3a772d58ead702f9a8e84ab2b342 ]
Various fixes for the Au1200/Au1550/Au1300 DBDMA2 code:
- skip cache invalidation if chip has working coherency circuitry.
- invalidate KSEG0-portion of the (physical) data address.
- force the dma channel doorbell write out to bus immediately with
a sync.
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/mips/alchemy/common/dbdma.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c
index fc482d900dddb..122f8c0d258ef 100644
--- a/arch/mips/alchemy/common/dbdma.c
+++ b/arch/mips/alchemy/common/dbdma.c
@@ -30,6 +30,7 @@
*
*/
+#include <linux/dma-map-ops.h> /* for dma_default_coherent */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
@@ -623,17 +624,18 @@ u32 au1xxx_dbdma_put_source(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
dp->dscr_cmd0 &= ~DSCR_CMD0_IE;
/*
- * There is an errata on the Au1200/Au1550 parts that could result
- * in "stale" data being DMA'ed. It has to do with the snoop logic on
- * the cache eviction buffer. DMA_NONCOHERENT is on by default for
- * these parts. If it is fixed in the future, these dma_cache_inv will
- * just be nothing more than empty macros. See io.h.
+ * There is an erratum on certain Au1200/Au1550 revisions that could
+ * result in "stale" data being DMA'ed. It has to do with the snoop
+ * logic on the cache eviction buffer. dma_default_coherent is set
+ * to false on these parts.
*/
- dma_cache_wback_inv((unsigned long)buf, nbytes);
+ if (!dma_default_coherent)
+ dma_cache_wback_inv(KSEG0ADDR(buf), nbytes);
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
wmb(); /* drain writebuffer */
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
ctp->chan_ptr->ddma_dbell = 0;
+ wmb(); /* force doorbell write out to dma engine */
/* Get next descriptor pointer. */
ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
@@ -685,17 +687,18 @@ u32 au1xxx_dbdma_put_dest(u32 chanid, dma_addr_t buf, int nbytes, u32 flags)
dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
#endif
/*
- * There is an errata on the Au1200/Au1550 parts that could result in
- * "stale" data being DMA'ed. It has to do with the snoop logic on the
- * cache eviction buffer. DMA_NONCOHERENT is on by default for these
- * parts. If it is fixed in the future, these dma_cache_inv will just
- * be nothing more than empty macros. See io.h.
+ * There is an erratum on certain Au1200/Au1550 revisions that could
+ * result in "stale" data being DMA'ed. It has to do with the snoop
+ * logic on the cache eviction buffer. dma_default_coherent is set
+ * to false on these parts.
*/
- dma_cache_inv((unsigned long)buf, nbytes);
+ if (!dma_default_coherent)
+ dma_cache_inv(KSEG0ADDR(buf), nbytes);
dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
wmb(); /* drain writebuffer */
dma_cache_wback_inv((unsigned long)dp, sizeof(*dp));
ctp->chan_ptr->ddma_dbell = 0;
+ wmb(); /* force doorbell write out to dma engine */
/* Get next descriptor pointer. */
ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
--
2.39.2
next prev parent reply other threads:[~2023-06-19 10:30 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 10:28 [PATCH 4.14 00/32] 4.14.319-rc1 review Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 01/32] power: supply: ab8500: Fix external_power_changed race Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 02/32] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 03/32] ARM: dts: vexpress: add missing cache properties Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 04/32] power: supply: Ratelimit no data debug output Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 05/32] regulator: Fix error checking for debugfs_create_dir Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 06/32] power: supply: Fix logic checking if system is running from battery Greg Kroah-Hartman
2023-06-19 10:28 ` Greg Kroah-Hartman [this message]
2023-06-19 10:28 ` [PATCH 4.14 08/32] mips: Move initrd_start check after initrd address sanitisation Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 09/32] xen/blkfront: Only check REQ_FUA for writes Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 10/32] ocfs2: fix use-after-free when unmounting read-only filesystem Greg Kroah-Hartman
2023-06-19 10:28 ` [PATCH 4.14 11/32] ocfs2: check new file size on fallocate call Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 12/32] nios2: dts: Fix tse_mac "max-frame-size" property Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 13/32] nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 14/32] nilfs2: fix possible out-of-bounds segment allocation in resize ioctl Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 15/32] net: usb: qmi_wwan: add support for Compal RXM-G1 Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 16/32] Remove DECnet support from kernel Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 17/32] USB: serial: option: add Quectel EM061KGL series Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 18/32] netfilter: nfnetlink: skip error delivery on batch in case of ENOMEM Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 19/32] ping6: Fix send to link-local addresses with VRF Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 20/32] IB/isert: Fix dead lock in ib_isert Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 21/32] IB/isert: Fix possible list corruption in CMA handler Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 22/32] IB/isert: Fix incorrect release of isert connection Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 23/32] sctp: fix an error code in sctp_sf_eat_auth() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 24/32] igb: fix nvm.ops.read() error handling Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 25/32] drm/nouveau/dp: check for NULL nv_connector->native_mode Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 26/32] net: lapbether: only support ethernet devices Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 27/32] net: tipc: resize nlattr array to correct size Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 28/32] selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 29/32] neighbour: Remove unused inline function neigh_key_eq16() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 30/32] neighbour: delete neigh_lookup_nodev as not used Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 31/32] powerpc: Fix defconfig choice logic when cross compiling Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.14 32/32] mmc: block: ensure error propagation for non-blk Greg Kroah-Hartman
2023-06-20 9:19 ` [PATCH 4.14 00/32] 4.14.319-rc1 review Chris Paterson
2023-06-20 9:28 ` Harshit Mogalapalli
2023-06-20 10:05 ` Naresh Kamboju
2023-06-20 10:21 ` Jon Hunter
2023-06-21 0:37 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230619102127.882423018@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).