[03/13] serial: 8250_dma: Support for deferred probing when requesting DMA channels
diff mbox

Message ID 1432646768-12532-4-git-send-email-peter.ujfalusi@ti.com
State New
Headers show

Commit Message

Peter Ujfalusi May 26, 2015, 1:25 p.m. UTC
Switch to use ma_request_slave_channel_compat_reason() to request the DMA
channels. In case of error, return the error code we received including
-EPROBE_DEFER

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/tty/serial/8250/8250_dma.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Greg KH May 26, 2015, 2:44 p.m. UTC | #1
On Tue, May 26, 2015 at 04:25:58PM +0300, Peter Ujfalusi wrote:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channels. In case of error, return the error code we received including
> -EPROBE_DEFER

I think you typed the function name wrong here :(

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren May 26, 2015, 3:08 p.m. UTC | #2
* Peter Ujfalusi <peter.ujfalusi@ti.com> [150526 06:28]:
> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
> channels. In case of error, return the error code we received including
> -EPROBE_DEFER
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/tty/serial/8250/8250_dma.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
> index 21d01a491405..a617eca4e97d 100644
> --- a/drivers/tty/serial/8250/8250_dma.c
> +++ b/drivers/tty/serial/8250/8250_dma.c
> @@ -182,21 +182,19 @@ int serial8250_request_dma(struct uart_8250_port *p)
>  	dma_cap_set(DMA_SLAVE, mask);
>  
>  	/* Get a channel for RX */
> -	dma->rxchan = dma_request_slave_channel_compat(mask,
> -						       dma->fn, dma->rx_param,
> -						       p->port.dev, "rx");
> -	if (!dma->rxchan)
> -		return -ENODEV;
> +	dma->rxchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
> +					dma->rx_param, p->port.dev, "rx");
> +	if (IS_ERR(dma->rxchan))
> +		return PTR_ERR(dma->rxchan);
>  
>  	dmaengine_slave_config(dma->rxchan, &dma->rxconf);
>  
>  	/* Get a channel for TX */
> -	dma->txchan = dma_request_slave_channel_compat(mask,
> -						       dma->fn, dma->tx_param,
> -						       p->port.dev, "tx");
> -	if (!dma->txchan) {
> +	dma->txchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
> +					dma->tx_param, p->port.dev, "tx");
> +	if (IS_ERR(dma->txchan)) {
>  		dma_release_channel(dma->rxchan);
> -		return -ENODEV;
> +		return PTR_ERR(dma->txchan);
>  	}
>  
>  	dmaengine_slave_config(dma->txchan, &dma->txconf);

In general the drivers need to work just fine also without DMA.

Does this handle the case properly where no DMA channel is configured
for the driver in the dts file?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Ujfalusi May 27, 2015, 10:41 a.m. UTC | #3
On 05/26/2015 05:44 PM, Greg Kroah-Hartman wrote:
> On Tue, May 26, 2015 at 04:25:58PM +0300, Peter Ujfalusi wrote:
>> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
>> channels. In case of error, return the error code we received including
>> -EPROBE_DEFER
> 
> I think you typed the function name wrong here :(

Oops. Also in other drivers :(
I will fix up the messages for the v2 series, which will not going to include
the patch against 8250_dma.

If I understand things right around the 8250_* is that the
serial8250_request_dma() which is called from serial8250_do_startup() is not
called at module probe time, so it can not be used to handle deferred probing.

Thus this patch can be dropped IMO.
Peter Ujfalusi May 27, 2015, 10:41 a.m. UTC | #4
On 05/27/2015 01:41 PM, Peter Ujfalusi wrote:
> On 05/26/2015 05:44 PM, Greg Kroah-Hartman wrote:
>> On Tue, May 26, 2015 at 04:25:58PM +0300, Peter Ujfalusi wrote:
>>> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
>>> channels. In case of error, return the error code we received including
>>> -EPROBE_DEFER
>>
>> I think you typed the function name wrong here :(
> 
> Oops. Also in other drivers :(

I mean in other patches ;)

> I will fix up the messages for the v2 series, which will not going to include
> the patch against 8250_dma.
> 
> If I understand things right around the 8250_* is that the
> serial8250_request_dma() which is called from serial8250_do_startup() is not
> called at module probe time, so it can not be used to handle deferred probing.
> 
> Thus this patch can be dropped IMO.
>
Peter Ujfalusi May 27, 2015, 10:58 a.m. UTC | #5
On 05/26/2015 06:08 PM, Tony Lindgren wrote:
> * Peter Ujfalusi <peter.ujfalusi@ti.com> [150526 06:28]:
>> Switch to use ma_request_slave_channel_compat_reason() to request the DMA
>> channels. In case of error, return the error code we received including
>> -EPROBE_DEFER
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>>  drivers/tty/serial/8250/8250_dma.c | 18 ++++++++----------
>>  1 file changed, 8 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
>> index 21d01a491405..a617eca4e97d 100644
>> --- a/drivers/tty/serial/8250/8250_dma.c
>> +++ b/drivers/tty/serial/8250/8250_dma.c
>> @@ -182,21 +182,19 @@ int serial8250_request_dma(struct uart_8250_port *p)
>>  	dma_cap_set(DMA_SLAVE, mask);
>>  
>>  	/* Get a channel for RX */
>> -	dma->rxchan = dma_request_slave_channel_compat(mask,
>> -						       dma->fn, dma->rx_param,
>> -						       p->port.dev, "rx");
>> -	if (!dma->rxchan)
>> -		return -ENODEV;
>> +	dma->rxchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
>> +					dma->rx_param, p->port.dev, "rx");
>> +	if (IS_ERR(dma->rxchan))
>> +		return PTR_ERR(dma->rxchan);
>>  
>>  	dmaengine_slave_config(dma->rxchan, &dma->rxconf);
>>  
>>  	/* Get a channel for TX */
>> -	dma->txchan = dma_request_slave_channel_compat(mask,
>> -						       dma->fn, dma->tx_param,
>> -						       p->port.dev, "tx");
>> -	if (!dma->txchan) {
>> +	dma->txchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
>> +					dma->tx_param, p->port.dev, "tx");
>> +	if (IS_ERR(dma->txchan)) {
>>  		dma_release_channel(dma->rxchan);
>> -		return -ENODEV;
>> +		return PTR_ERR(dma->txchan);
>>  	}
>>  
>>  	dmaengine_slave_config(dma->txchan, &dma->txconf);
> 
> In general the drivers need to work just fine also without DMA.
> 
> Does this handle the case properly where no DMA channel is configured
> for the driver in the dts file?

The 8250 core will fall back to PIO mode if the DMA can not be requested.
At the morning I was looking at the 8250 stack and realized that
serial8250_request_dma() will not be called at driver probe time so this patch
can be ignored and will be dropped from the v2 series.

Patch
diff mbox

diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 21d01a491405..a617eca4e97d 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -182,21 +182,19 @@  int serial8250_request_dma(struct uart_8250_port *p)
 	dma_cap_set(DMA_SLAVE, mask);
 
 	/* Get a channel for RX */
-	dma->rxchan = dma_request_slave_channel_compat(mask,
-						       dma->fn, dma->rx_param,
-						       p->port.dev, "rx");
-	if (!dma->rxchan)
-		return -ENODEV;
+	dma->rxchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
+					dma->rx_param, p->port.dev, "rx");
+	if (IS_ERR(dma->rxchan))
+		return PTR_ERR(dma->rxchan);
 
 	dmaengine_slave_config(dma->rxchan, &dma->rxconf);
 
 	/* Get a channel for TX */
-	dma->txchan = dma_request_slave_channel_compat(mask,
-						       dma->fn, dma->tx_param,
-						       p->port.dev, "tx");
-	if (!dma->txchan) {
+	dma->txchan = dma_request_slave_channel_compat_reason(mask, dma->fn,
+					dma->tx_param, p->port.dev, "tx");
+	if (IS_ERR(dma->txchan)) {
 		dma_release_channel(dma->rxchan);
-		return -ENODEV;
+		return PTR_ERR(dma->txchan);
 	}
 
 	dmaengine_slave_config(dma->txchan, &dma->txconf);