Re: [PATCH v6 2/4] dmaengine: tegra: Add tegra gpcdma driver

From: Jon Hunter
Date: Thu Sep 23 2021 - 09:20:39 EST



On 23/09/2021 13:51, Akhil R wrote:
On 22/09/2021 15:46, Akhil R wrote:

On 17/09/2021 15:11, Akhil R wrote:
+static int tegra_dma_slave_config(struct dma_chan *dc,
+ struct dma_slave_config *sconfig) {
+ struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
+
+ if (tdc->dma_desc) {
+ dev_err(tdc2dev(tdc), "Configuration not allowed\n");
+ return -EBUSY;
+ }
+
+ memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig));
+ if (tdc->slave_id == -1)
+ tdc->slave_id = sconfig->slave_id;
+
+ tdc->config_init = true;
+ return 0;
+}

So you have a function to reserve a slave ID, but you don't check
here if it is already reserved.
slave-id is reserved considering the direction as well.
'direction' is available only during prep_slave_sg function, I guess.

Sorry I don't understand what you mean by that.
I mean, it would not be possible to check if the sid is in use without knowing
if the direction is MEM_TO_DEV or DEV_TO_MEM. The bitmask to check the
sid reservation is separate for MEM_TO_DEV and DEV_TO_MEM.
To get the direction parameter, we would need to wait till dma_prep_slave_sg
is called, I guess. I saw in the documentation that the 'direction' element in
dma_slave_config struct is deprecated and should use the value passed to
dma_prep_slave_sg().

Do we even need to worry about slave_id here? Typically the slave_id is coming from device-tree and so is handled by tegra_dma_of_xlate(). I would drop this unless there is an actual use-case we need to support that uses this.

Jon

--
nvpublic