diff mbox series

[v2,2/2] soc/tegra: fuse: Explicitly request DMA channel from APB DMA driver

Message ID c2b55552d079f47564456ebfcd982116aad32be8.1507068874.git.digetx@gmail.com
State Changes Requested
Headers show
Series Correct Tegra20 FUSE driver DMA usage | expand

Commit Message

Dmitry Osipenko Oct. 3, 2017, 10:35 p.m. UTC
Currently fuse driver requests DMA channel from an arbitrary DMA device,
it is not a problem since there is only one DMA provider for Tegra20 yet,
but it will become troublesome once another provider will be added.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/soc/tegra/fuse/fuse-tegra20.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Jon Hunter Oct. 4, 2017, 10:48 a.m. UTC | #1
On 03/10/17 23:35, Dmitry Osipenko wrote:
> Currently fuse driver requests DMA channel from an arbitrary DMA device,
> it is not a problem since there is only one DMA provider for Tegra20 yet,
> but it will become troublesome once another provider will be added.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/soc/tegra/fuse/fuse-tegra20.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/tegra/fuse/fuse-tegra20.c b/drivers/soc/tegra/fuse/fuse-tegra20.c
> index a33f48c06771..e9e127a24c70 100644
> --- a/drivers/soc/tegra/fuse/fuse-tegra20.c
> +++ b/drivers/soc/tegra/fuse/fuse-tegra20.c
> @@ -37,6 +37,11 @@
>  #define FUSE_UID_LOW	0x08
>  #define FUSE_UID_HIGH	0x0c
>  
> +static const struct of_device_id apbdma_of_match[] = {
> +	{ .compatible = "nvidia,tegra20-apbdma" },
> +	{ },
> +};
> +
>  static u32 tegra20_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
>  {
>  	return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
> @@ -96,6 +101,11 @@ static u32 tegra20_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
>  	return value;
>  }
>  
> +static bool dma_filter(struct dma_chan *chan, void *filter_param)
> +{
> +	return of_match_device(apbdma_of_match, chan->device->dev) != NULL;

Is it simpler just to use of_device_is_compatible() here?

Cheers
Jon
Dmitry Osipenko Oct. 4, 2017, 11:11 a.m. UTC | #2
On 04.10.2017 13:48, Jon Hunter wrote:
> 
> 
> On 03/10/17 23:35, Dmitry Osipenko wrote:
>> Currently fuse driver requests DMA channel from an arbitrary DMA device,
>> it is not a problem since there is only one DMA provider for Tegra20 yet,
>> but it will become troublesome once another provider will be added.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/soc/tegra/fuse/fuse-tegra20.c | 12 +++++++++++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/tegra/fuse/fuse-tegra20.c b/drivers/soc/tegra/fuse/fuse-tegra20.c
>> index a33f48c06771..e9e127a24c70 100644
>> --- a/drivers/soc/tegra/fuse/fuse-tegra20.c
>> +++ b/drivers/soc/tegra/fuse/fuse-tegra20.c
>> @@ -37,6 +37,11 @@
>>  #define FUSE_UID_LOW	0x08
>>  #define FUSE_UID_HIGH	0x0c
>>  
>> +static const struct of_device_id apbdma_of_match[] = {
>> +	{ .compatible = "nvidia,tegra20-apbdma" },
>> +	{ },
>> +};
>> +
>>  static u32 tegra20_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
>>  {
>>  	return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
>> @@ -96,6 +101,11 @@ static u32 tegra20_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
>>  	return value;
>>  }
>>  
>> +static bool dma_filter(struct dma_chan *chan, void *filter_param)
>> +{
>> +	return of_match_device(apbdma_of_match, chan->device->dev) != NULL;
> 
> Is it simpler just to use of_device_is_compatible() here?
> 

Good point! I haven't noticed that function in the OF API.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/soc/tegra/fuse/fuse-tegra20.c b/drivers/soc/tegra/fuse/fuse-tegra20.c
index a33f48c06771..e9e127a24c70 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra20.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra20.c
@@ -37,6 +37,11 @@ 
 #define FUSE_UID_LOW	0x08
 #define FUSE_UID_HIGH	0x0c
 
+static const struct of_device_id apbdma_of_match[] = {
+	{ .compatible = "nvidia,tegra20-apbdma" },
+	{ },
+};
+
 static u32 tegra20_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
 {
 	return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
@@ -96,6 +101,11 @@  static u32 tegra20_fuse_read(struct tegra_fuse *fuse, unsigned int offset)
 	return value;
 }
 
+static bool dma_filter(struct dma_chan *chan, void *filter_param)
+{
+	return of_match_device(apbdma_of_match, chan->device->dev) != NULL;
+}
+
 static int tegra20_fuse_probe(struct tegra_fuse *fuse)
 {
 	dma_cap_mask_t mask;
@@ -103,7 +113,7 @@  static int tegra20_fuse_probe(struct tegra_fuse *fuse)
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	fuse->apbdma.chan = dma_request_channel(mask, NULL, NULL);
+	fuse->apbdma.chan = __dma_request_channel(&mask, dma_filter, NULL);
 	if (!fuse->apbdma.chan)
 		return -EPROBE_DEFER;