mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-09 23:34:42 +08:00
can: kvaser_pciefd: Empty SRB buffer in probe
commitc589557dd1
upstream. Empty the "Shared receive buffer" (SRB) in probe, to assure we start in a known state, and don't process any irrelevant packets. Fixes:26ad340e58
("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices") Cc: stable@vger.kernel.org Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20230516134318.104279-5-extja@kvaser.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
da711a8af0
commit
f04628305c
@ -70,10 +70,12 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
|
||||
#define KVASER_PCIEFD_SYSID_BUILD_REG (KVASER_PCIEFD_SYSID_BASE + 0x14)
|
||||
/* Shared receive buffer registers */
|
||||
#define KVASER_PCIEFD_SRB_BASE 0x1f200
|
||||
#define KVASER_PCIEFD_SRB_FIFO_LAST_REG (KVASER_PCIEFD_SRB_BASE + 0x1f4)
|
||||
#define KVASER_PCIEFD_SRB_CMD_REG (KVASER_PCIEFD_SRB_BASE + 0x200)
|
||||
#define KVASER_PCIEFD_SRB_IEN_REG (KVASER_PCIEFD_SRB_BASE + 0x204)
|
||||
#define KVASER_PCIEFD_SRB_IRQ_REG (KVASER_PCIEFD_SRB_BASE + 0x20c)
|
||||
#define KVASER_PCIEFD_SRB_STAT_REG (KVASER_PCIEFD_SRB_BASE + 0x210)
|
||||
#define KVASER_PCIEFD_SRB_RX_NR_PACKETS_REG (KVASER_PCIEFD_SRB_BASE + 0x214)
|
||||
#define KVASER_PCIEFD_SRB_CTRL_REG (KVASER_PCIEFD_SRB_BASE + 0x218)
|
||||
/* EPCS flash controller registers */
|
||||
#define KVASER_PCIEFD_SPI_BASE 0x1fc00
|
||||
@ -110,6 +112,9 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
|
||||
/* DMA support */
|
||||
#define KVASER_PCIEFD_SRB_STAT_DMA BIT(24)
|
||||
|
||||
/* SRB current packet level */
|
||||
#define KVASER_PCIEFD_SRB_RX_NR_PACKETS_MASK 0xff
|
||||
|
||||
/* DMA Enable */
|
||||
#define KVASER_PCIEFD_SRB_CTRL_DMA_ENABLE BIT(0)
|
||||
|
||||
@ -1055,6 +1060,7 @@ static int kvaser_pciefd_setup_dma(struct kvaser_pciefd *pcie)
|
||||
{
|
||||
int i;
|
||||
u32 srb_status;
|
||||
u32 srb_packet_count;
|
||||
dma_addr_t dma_addr[KVASER_PCIEFD_DMA_COUNT];
|
||||
|
||||
/* Disable the DMA */
|
||||
@ -1082,6 +1088,15 @@ static int kvaser_pciefd_setup_dma(struct kvaser_pciefd *pcie)
|
||||
KVASER_PCIEFD_SRB_CMD_RDB1,
|
||||
pcie->reg_base + KVASER_PCIEFD_SRB_CMD_REG);
|
||||
|
||||
/* Empty Rx FIFO */
|
||||
srb_packet_count = ioread32(pcie->reg_base + KVASER_PCIEFD_SRB_RX_NR_PACKETS_REG) &
|
||||
KVASER_PCIEFD_SRB_RX_NR_PACKETS_MASK;
|
||||
while (srb_packet_count) {
|
||||
/* Drop current packet in FIFO */
|
||||
ioread32(pcie->reg_base + KVASER_PCIEFD_SRB_FIFO_LAST_REG);
|
||||
srb_packet_count--;
|
||||
}
|
||||
|
||||
srb_status = ioread32(pcie->reg_base + KVASER_PCIEFD_SRB_STAT_REG);
|
||||
if (!(srb_status & KVASER_PCIEFD_SRB_STAT_DI)) {
|
||||
dev_err(&pcie->pci->dev, "DMA not idle before enabling\n");
|
||||
|
Loading…
Reference in New Issue
Block a user