Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

From: Andrew Lunn
Date: Thu Apr 05 2018 - 12:56:43 EST


> > Hi Andrew,
> >
> > We're waiting for the DPIO driver (which we depend on) to be moved
> > out of staging first, it's currently under review:
> > https://lkml.org/lkml/2018/3/27/1086
>
> That's stalled on my side right now as the merge window is open and I
> can't do any new stuff until after 4.17-rc1 is out. So everyone please
> be patient a bit...

I took a quick look.

There are a few inline functions in .c files which is generally
frowned upon. Let the compiler decide.

e.g:

static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
int cpu)
static inline struct dpaa2_io *service_select(struct dpaa2_io *d)

dpaa2_io_down() seems to be too simple. dpaa2_io_create() sets up
interrupt triggers, notifications, and adds the new object to the
dpio_list. dpaa2_io_down() seems to just free the memory. Do
notifications need to be disabled, the object taken off the list?

dpaa2_io_store_create() allocates memory using kzalloc() and then uses
dma_map_single(,,DMA_FROM_DEVICE). The documentation says:

DMA_FROM_DEVICE synchronisation must be done before the driver
accesses data that may be changed by the device. This memory
should be treated as read-only by the driver. If the driver needs
to write to it at any point, it should be DMA_BIDIRECTIONAL (see
below).

Since it has just been allocated, this seems questionable.

I'm also not sure where the correct call to
dma_map_single(,,DMA_FROM_DEVICE) is? Should dpaa2_io_store_next()
doing this?

The DMA API usage might need a closer review.

Andrew