Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: subhasish@mistralsolutions.com (Subhasish Ghosh)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 13/13] tty: pruss SUART driver
Date: Tue, 22 Feb 2011 14:13:21 +0530	[thread overview]
Message-ID: <DADE3366197E4479A57F3B967A881C33@subhasishg> (raw)
In-Reply-To: <201102181951.32631.arnd@arndb.de>

I agree with the Codingstyle which needs to be fixed and would appreciate 
more feedback on it.

I have also gotten rid of the semaphore completely, please let me know what 
you feel of this implementation:
I have tested this without any problem.
What I am basically doing below is that, I am getting the data from the circ 
buff and then using the interrupt handler to
pump out the data. As the circ buff empties, I am accepting another request 
from the TTY.
Are you noticing any problems with this:

diff --git a/drivers/tty/serial/da8xx_pruss/pruss_suart.c 
b/drivers/tty/serial/da8xx_pruss/pruss_suart.c
index d222e2e..edc3863 100644
--- a/drivers/tty/serial/da8xx_pruss/pruss_suart.c
+++ b/drivers/tty/serial/da8xx_pruss/pruss_suart.c
@@ -72,7 +72,7 @@ struct suart_fifo {
 struct omapl_pru_suart {
        struct uart_port port[NR_SUART];
        struct device *dev; /* pdev->dev */
-       struct semaphore port_sem[NR_SUART];
+       bool tx_empty[NR_SUART];
        struct clk *clk_mcasp;
        struct suart_fifo suart_fifo_addr[NR_SUART];
        const struct firmware *fw;
@@ -122,13 +122,10 @@ static void omapl_pru_tx_chars(struct omapl_pru_suart 
*soft_uart, u32 uart_no)
        if (!(suart_get_duplex(soft_uart, uart_no) & ePRU_SUART_HALF_TX))
                return;

-       if (down_trylock(&soft_uart->port_sem[uart_no]))
-               return;
-
        if (uart_circ_empty(xmit) ||
                        uart_tx_stopped(&soft_uart->port[uart_no])) {
                pruss_suart_stop_tx(&soft_uart->port[uart_no]);
-               up(&soft_uart->port_sem[uart_no]);
+               soft_uart->tx_empty[uart_no] = true;
                return;
        }

@@ -259,7 +256,6 @@ static irqreturn_t pruss_suart_interrupt(s32 irq, void 
*dev_id)
                        pru_intr_clr_isrstatus(dev, uart_num, PRU_TX_INTR);
                        pru_softuart_clr_tx_status(dev, 
&soft_uart->suart_hdl
                                                 [port->line]);
-                       up(&soft_uart->port_sem[port->line]);
                        omapl_pru_tx_chars(soft_uart, port->line);
                }
        } while (txrx_flag & (PRU_RX_INTR | PRU_TX_INTR));
@@ -294,7 +290,10 @@ static void pruss_suart_start_tx(struct uart_port 
*port)

        suart_intr_setmask(dev, soft_uart->suart_hdl[port->line].uart_num,
                           PRU_TX_INTR, CHN_TXRX_IE_MASK_CMPLT);
-       omapl_pru_tx_chars(soft_uart, port->line);
+       if (soft_uart->tx_empty[port->line] == true) {
+               soft_uart->tx_empty[port->line] = false;
+               omapl_pru_tx_chars(soft_uart, port->line);
+       }
 }


--------------------------------------------------
From: "Arnd Bergmann" <arnd@arndb.de>
Sent: Saturday, February 19, 2011 12:21 AM
To: <linux-arm-kernel@lists.infradead.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>; "Alan Cox" 
<alan@lxorguk.ukuu.org.uk>; <sachi@mistralsolutions.com>; 
<davinci-linux-open-source@linux.davincidsp.com>; "Subhasish Ghosh" 
<subhasish@mistralsolutions.com>; "Greg Kroah-Hartman" <gregkh@suse.de>; 
<nsekhar@ti.com>; "open list" <linux-kernel@vger.kernel.org>; 
<m-watkins@ti.com>
Subject: Re: [PATCH v2 13/13] tty: pruss SUART driver

> On Friday 18 February 2011 19:23:49 Thomas Gleixner wrote:
>> On Fri, 18 Feb 2011, Alan Cox wrote:
>>
>> > On Fri, 18 Feb 2011 19:17:38 +0530
>> > "Subhasish Ghosh" <subhasish@mistralsolutions.com> wrote:
>> >
>> > > Hello,
>> > >
>> > > Regarding the semaphore to mutex migration.
>> > > We are using down_trylock in interrupt context,
>> > > mutex_trylock cannot be used in interrupt context, so we cannot use 
>> > > mutex in
>> > > our driver.
>> >
>> > Then you probably need to rework your locking. Best bet might be to fix
>> > all the other stuff and report the driver, and people can think about 
>> > the
>> > locking problem.
>>
>> That semaphore is utterly useless to begin with. There are more
>> serious locking problems than this one. Non serialized calls to
>> suart_intr_clrmask/suart_intr_setmask are the most obvious ones.
>>
>> Aside of that the code is complete unreadable.
>
> I think it mostly suffers from the same problem as the CAN driver
> I commented on earlier: One of the files (pruss_suart_api.c) was
> clearly not written with Linux as the target, and the other files
> try to work around this by wrapping a Linux driver around it.
>
> The suart_api HAL stuff clearly needs to go away, so that the rest
> can be rewritten into a proper device driver.
>
> Arnd 

  parent reply	other threads:[~2011-02-22  8:43 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11 14:51 [PATCH v2 00/13] pruss mfd drivers Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 01/13] mfd: pruss mfd driver Subhasish Ghosh
2011-02-21 16:30   ` Samuel Ortiz
2011-02-22  5:43     ` Subhasish Ghosh
2011-02-22 10:31       ` Samuel Ortiz
2011-02-22 10:48         ` Wolfgang Grandegger
2011-02-22 11:33           ` Samuel Ortiz
2011-02-22 12:49             ` Subhasish Ghosh
2011-02-22 16:27               ` Wolfgang Grandegger
2011-02-23 12:25         ` Subhasish Ghosh
2011-02-23 13:09         ` Russell King - ARM Linux
2011-02-11 14:51 ` [PATCH v2 02/13] da850: pruss platform specific additions Subhasish Ghosh
2011-02-11 18:41   ` Sergei Shtylyov
2011-02-18  7:18     ` Subhasish Ghosh
2011-02-28 13:04   ` TK, Pratheesh Gangadhar
2011-03-01  6:59     ` Subhasish Ghosh
2011-03-03 11:12       ` TK, Pratheesh Gangadhar
2011-02-11 14:51 ` [PATCH v2 03/13] da850: pruss board " Subhasish Ghosh
2011-02-11 18:43   ` Sergei Shtylyov
2011-02-18  7:18     ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 04/13] mfd: pruss CAN private data Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 05/13] da850: pruss CAN platform specific additions Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 06/13] da850: pruss CAN board " Subhasish Ghosh
2011-02-11 18:45   ` Sergei Shtylyov
2011-02-18  7:19     ` Subhasish Ghosh
2011-02-18  7:19     ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 07/13] da850: pruss CAN platform specific changes for gpios Subhasish Ghosh
2011-02-11 18:47   ` Sergei Shtylyov
2011-02-18  7:20     ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 08/13] da850: pruss CAN board " Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 09/13] can: pruss CAN driver Subhasish Ghosh
2011-02-11 15:06   ` Kurt Van Dijck
2011-02-14  4:54     ` Subhasish Ghosh
     [not found]       ` <4D58D854.5090503@grandegger.com>
2011-02-14  7:42         ` Kurt Van Dijck
2011-02-14  8:45         ` Subhasish Ghosh
     [not found]           ` <4D58F77B.9080005@pengutronix.de>
2011-02-14 13:15             ` Subhasish Ghosh
2011-02-11 15:20   ` Kurt Van Dijck
2011-02-18  7:07     ` Subhasish Ghosh
     [not found]       ` <4D5E2570.10108@grandegger.com>
2011-02-18  8:15         ` Subhasish Ghosh
2011-02-18  8:36           ` Marc Kleine-Budde
2011-02-18  9:09             ` Subhasish Ghosh
2011-02-18 15:07   ` Arnd Bergmann
2011-03-22  7:30     ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 10/13] mfd: pruss SUART private data Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 11/13] da850: pruss SUART board specific additions Subhasish Ghosh
2011-02-11 15:26   ` Michael Williamson
2011-02-18  7:13     ` Subhasish Ghosh
2011-02-11 18:50   ` Sergei Shtylyov
2011-02-22  6:22     ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 12/13] da850: pruss SUART platform " Subhasish Ghosh
2011-02-11 18:55   ` Sergei Shtylyov
2011-02-22  9:18     ` Subhasish Ghosh
2011-02-22 11:20       ` Sergei Shtylyov
2011-02-22 13:24         ` Subhasish Ghosh
2011-02-11 14:51 ` [PATCH v2 13/13] tty: pruss SUART driver Subhasish Ghosh
2011-02-11 16:28   ` Alan Cox
2011-02-18 13:47     ` Subhasish Ghosh
2011-02-18 14:35       ` Alan Cox
2011-02-18 18:23         ` Thomas Gleixner
2011-02-18 18:51           ` Arnd Bergmann
2011-02-22  8:42             ` Subhasish Ghosh
2011-02-22 14:37               ` Greg KH
2011-02-23  5:30                 ` Subhasish Ghosh
2011-02-23 18:20                   ` Greg KH
2011-02-22  8:43             ` Subhasish Ghosh [this message]
2011-02-22 16:34               ` Arnd Bergmann
2011-02-24 10:31                 ` Subhasish Ghosh
2011-02-22 10:26     ` Subhasish
2011-02-22 11:11       ` Alan Cox
2011-03-01 13:37         ` Subhasish Ghosh
2011-03-01 14:07           ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2011-02-23 13:34 Subhasish Ghosh
2011-02-23 18:21 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DADE3366197E4479A57F3B967A881C33@subhasishg \
    --to=subhasish@mistralsolutions.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox