On 3/6/2018 2:56 PM, Stephen Boyd wrote:
Quoting Karthik Ramasubramanian (2018-03-02 16:58:23)

+       return iova;
+ * geni_se_rx_dma_prep() - Prepare the Serial Engine for RX DMA transfer
+ * @se:                        Pointer to the concerned Serial Engine.
+ * @buf:               Pointer to the RX buffer.
+ * @len:               Length of the RX buffer.
+ *
+ * This function is used to prepare the buffers for DMA RX.
+ *
+ * Return: Mapped DMA Address of the buffer on success, NULL on failure.
+ */
+dma_addr_t geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len)
+       dma_addr_t iova;
+       struct geni_wrapper *wrapper = se->wrapper;
+       u32 val;
+       iova = dma_map_single(wrapper->dev, buf, len, DMA_FROM_DEVICE);
+       if (dma_mapping_error(wrapper->dev, iova))
+               return (dma_addr_t)NULL;

Can't return a dma_mapping_error address to the caller and have them
figure it out?
Earlier we used to return the DMA_ERROR_CODE which has been removed
recently in arm64 architecture. If we return the dma_mapping_error, then
the caller also needs the device which encountered the mapping error.
The serial interface drivers can use their parent currently to resolve
the mapping error. Once the wrapper starts mapping using IOMMU context
bank, then the serial interface drivers do not know which device to use
to know if there is an error.

Having said that, the dma_ops suggestion might help with handling this
situation. I will look into it further.

Ok, thanks.

+       struct geni_wrapper *wrapper = se->wrapper;
+       if (iova)
+               dma_unmap_single(wrapper->dev, iova, len, DMA_FROM_DEVICE);

Instead of having the functions exported, could we set the dma_ops on
all child devices of the wrapper that this driver populates and then
implement the DMA ops for those devices here? I assume that there's
never another DMA master between the wrapper and the serial engine, so I
think it would work.
This suggestion looks like it will work.

It would be a good idea to check with some other people on the dma_ops
suggestion. Maybe add the DMA mapping subsystem folks to help out here
I have added the DMA mapping subsystem folks to help out here.

To present an overview, we have a wrapper controller which is composed of several serial engines. The serial engines are programmed with UART, I2C or SPI protocol and support DMA transfer. When the serial engines perform DMA transfer, the wrapper controller device is used to perform the mapping. The reason wrapper device is used is because of IOMMU and there is only one IOMMU context bank to perform the translation for the entire wrapper controller. So the wrapper controller exports map and unmap functions to the individual protocol drivers.

There is a suggestion to make the parent wrapper controller implement the dma_map_ops, instead of exported map/unmap functions and populate those dma_map_ops on all the children serial engines. Can you please provide your inputs regarding this suggestion?

M:      Christoph Hellwig <h...@lst.de>
M:      Marek Szyprowski <m.szyprow...@samsung.com>
R:      Robin Murphy <robin.mur...@arm.com>
L:      io...@lists.linux-foundation.org

Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to