Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARCv3: Add CDMA support driver #138

Draft
wants to merge 1 commit into
base: arc64
Choose a base branch
from
Draft

Conversation

xxkent
Copy link

@xxkent xxkent commented Jul 18, 2023

Driver to support Cluster DMA(CDMA) controller for ARCv3. For HS58 tested on nSIM and HAPS using 'dmatest' driver. For HS68 tested on nSIM using 'dmatest' driver.

Known limitations:
Don't specify 'test_buf_size' 'dmatest' parameter more then 750000 when L2$ is enabled. Looks like L2$ operations in cache-arcv3.c:scm_op_rgn() fails when sz > 750000. Probably it is restriction in HW. Otherwise the kernel will crash.

Comment on lines 73 to 74
a = handle >> 5;
o = 1 << (handle & 0x1f);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not use these magic numbers and have proper defines instead (bits mask / bits shift)

Comment on lines 84 to 85
a = handle >> 5;
x = 1 << (handle & 0x1f);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

u32 len, /* DMA length in bytes */
struct cdma_c_attr_t a) /* Attributes */
{
/* Write will block iff busy i.e. DMA_C_STATUS_AUX.B bit is set */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Write will block iff busy i.e. DMA_C_STATUS_AUX.B bit is set */
/* Write will block if busy i.e. DMA_C_STATUS_AUX.B bit is set */

struct cdma_hw_desc *hw_desc;
unsigned long flags;
int done_flg;
int entry_notfound = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have it as bool var.

*/
for (ii = 0; ii < dw->nr_channels; ii++) {
chan = &dw->channels[ii];
dev_warn(chan2dev(chan), "WARN. Channel is overflowed.\n");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we can remove 'WARN' from comment - this info is provided by dev_warn. Same for dev_err

u32 tmp;

bcr.val = read_aux_reg(DMA_BUILD);
if (bcr.ver < 0x10)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number. Probably we can name it as DW_CDMA_MIN_VERSION or something like that.

Comment on lines 192 to 195
/* vv = (u32)(src >> 32ULL); */
/* WRITE_AUX(DMA_C_SRC_HI_AUX, vv); */
/* vv = (u32)(dst >> 32ULL); */
/* WRITE_AUX(DMA_C_DST_HI_AUX, vv); */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is suspicious as we set DMA_BIT_MASK(64)

struct dw_cluster_dma {
struct dma_device dma;
struct device_dma_parameters dma_parms;
int nr_channels;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra tab. I'd expect that it should be detected by checkpatch.

struct cdma_chip {
struct device *dev;
struct dw_cluster_dma *dw;
int irq;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

a = handle >> 5;
o = 1 << (handle & 0x1f);
READ_BCR(DMA_S_DONESTATD_AUX(a), x);
x = x & o;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x = x & o;
x &= o;

@xxkent xxkent force-pushed the bolsh-arcv3-cluster-dma branch from dd2a71f to 5cc2b79 Compare August 1, 2023 18:35
Driver to support Cluster DMA(CDMA) controller for ARCv3.
For HS58 tested on nSIM and HAPS using 'dmatest' driver.
For HS68 tested on nSIM using 'dmatest' driver.

Known limitations:
Don't specify 'test_buf_size' 'dmatest' parameter more then 750000 when
L2$ is enabled. Looks like L2$ operations in cache-arcv3.c:scm_op_rgn()
fails when sz > 750000. Probably it is restriction in HW. Otherwise
the kernel will crash.
@xxkent xxkent force-pushed the bolsh-arcv3-cluster-dma branch from 5cc2b79 to 0caba66 Compare August 1, 2023 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants