mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Hammer Hsieh 謝宏孟" <hammer.hsieh@sunplus.com>
To: Jiri Slaby <jirislaby@kernel.org>,
	Hammer Hsieh <hammerh0314@gmail.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>
Cc: "Wells Lu 呂芳騰" <wells.lu@sunplus.com>
Subject: RE: [PATCH v5 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
Date: Mon, 13 Dec 2021 11:37:21 +0000	[thread overview]
Message-ID: <5040ff8d211b4d729f4bdae8ce6dabd8@sphcmbx02.sunplus.com.tw> (raw)
In-Reply-To: <61fefc9d-643d-ca31-9a6d-d2e10cd060bb@kernel.org>

Hi, Jiri Slaby:

Thanks for your review.
My response is below in mail.

Best Regards,
Hammer Hsieh

> -----Original Message-----
> From: Jiri Slaby <jirislaby@kernel.org>
> Sent: Monday, December 13, 2021 3:47 PM
> To: Hammer Hsieh <hammerh0314@gmail.com>; gregkh@linuxfoundation.org;
> robh+dt@kernel.org; linux-serial@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; p.zabel@pengutronix.de
> Cc: Wells Lu 呂芳騰 <wells.lu@sunplus.com>; Hammer Hsieh 謝宏孟
> <hammer.hsieh@sunplus.com>
> Subject: Re: [PATCH v5 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
> 
> On 13. 12. 21, 8:10, Hammer Hsieh wrote:
> > Add Sunplus SoC UART Driver
> >
> > Signed-off-by: Hammer Hsieh <hammer.hsieh@sunplus.com>
> 
> ...
> 
> > --- /dev/null
> > +++ b/drivers/tty/serial/sunplus-uart.c
> 
> ...
> 
> > +static void receive_chars(struct uart_port *port) {
> > +	unsigned int lsr = readl(port->membase + SUP_UART_LSR);
> > +	unsigned int ch, flag;
> > +
> > +	do {
> > +		ch = readl(port->membase + SUP_UART_DATA);
> > +		flag = TTY_NORMAL;
> > +		port->icount.rx++;
> > +
> > +		if (unlikely(lsr & SUP_UART_LSR_BRK_ERROR_BITS)) {
> > +			if (lsr & SUP_UART_LSR_BC) {
> > +				lsr &= ~(SUP_UART_LSR_FE | SUP_UART_LSR_PE);
> > +				port->icount.brk++;
> > +				if (uart_handle_break(port))
> > +					goto ignore_char;
> > +			} else if (lsr & SUP_UART_LSR_PE) {
> > +				port->icount.parity++;
> > +			} else if (lsr & SUP_UART_LSR_FE) {
> > +				port->icount.frame++;
> > +			}
> > +
> > +			if (lsr & SUP_UART_LSR_OE)
> > +				port->icount.overrun++;
> > +
> > +			if (lsr & SUP_UART_LSR_BC)
> > +				flag = TTY_BREAK;
> > +			else if (lsr & SUP_UART_LSR_PE)
> > +				flag = TTY_PARITY;
> > +			else if (lsr & SUP_UART_LSR_FE)
> > +				flag = TTY_FRAME;
> 
> Why do you handle these separately and not above?
> 

Indeed, I will modify as below.
		if (lsr & SUP_UART_LSR_BC) {
			lsr &= ~(SUP_UART_LSR_FE | SUP_UART_LSR_PE);
			port->icount.brk++;
			flag = TTY_BREAK;
			if (uart_handle_break(port))
				goto ignore_char;
			} else if (lsr & SUP_UART_LSR_PE) {
			port->icount.parity++;
			flag = TTY_PARITY;
		} else if (lsr & SUP_UART_LSR_FE) {
			port->icount.frame++;
			flag = TTY_FRAME;
		}

> > +		}
> > +
> > +		if (port->ignore_status_mask & SUP_DUMMY_READ)
> > +			goto ignore_char;
> > +
> > +		if (uart_handle_sysrq_char(port, ch))
> > +			goto ignore_char;
> > +
> > +		uart_insert_char(port, lsr, SUP_UART_LSR_OE, ch, flag);
> > +
> > +ignore_char:
> > +		lsr = readl(port->membase + SUP_UART_LSR);
> > +	} while (lsr & SUP_UART_LSR_RX);
> > +
> > +	tty_flip_buffer_push(&port->state->port);
> > +}
> > +
> > +static irqreturn_t sunplus_uart_irq(int irq, void *args) {
> > +	struct uart_port *port = (struct uart_port *)args;
> 
> No need to cast here.
> 

Ok, will modify it.

> > +	unsigned int isc = readl(port->membase + SUP_UART_ISC);
> 
> Shouldn't this be under the spinlock?
> 
> And "if (!isc) return IRQ_NONE"?
> 

Will modify it as below.
Spin_lock()
isc = readl(port->membase + SUP_UART_ISC);
if (!isc) return IRQ_NONE;
if(isc&RX) receive_chars();
if(isc&TX) transmit_chars();
Spin_unlock()

> > +	spin_lock(&port->lock);
> > +
> > +	if (isc & SUP_UART_ISC_RX)
> > +		receive_chars(port);
> > +
> > +	if (isc & SUP_UART_ISC_TX)
> > +		transmit_chars(port);
> > +
> > +	spin_unlock(&port->lock);
> > +
> > +	return IRQ_HANDLED;
> > +}
> > +
> > +static int sunplus_startup(struct uart_port *port) {
> > +	unsigned long flags;
> > +	unsigned int isc;
> > +	int ret;
> > +
> > +	ret = request_irq(port->irq, sunplus_uart_irq, 0, "sunplus_uart",
> > +port);
> 
> Cannot the interrupt be shared?
> 

Each UART have its own hardware interrupt in Sunplus SP7021 SoC.
No need to set IRQF_SHARED for serial driver.

> > +	if (ret)
> > +		return ret;
> > +
> > +	spin_lock_irqsave(&port->lock, flags);
> > +
> > +	isc |= SUP_UART_ISC_RXM;
> > +	writel(isc, port->membase + SUP_UART_ISC);
> > +
> > +	spin_unlock_irqrestore(&port->lock, flags);
> > +
> > +	return 0;
> > +}
> > +
> > +static void sunplus_shutdown(struct uart_port *port) {
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&port->lock, flags);
> > +	writel(0, port->membase + SUP_UART_ISC);
> 
> What bus is this -- posting?
> 

Here just clear interrupt.
Not really understand your comment?

> > +	spin_unlock_irqrestore(&port->lock, flags);
> > +
> > +	free_irq(port->irq, port);
> > +}
> 
> ...
> 
> > +static void sunplus_release_port(struct uart_port *port) { }
> > +
> > +static int sunplus_request_port(struct uart_port *port) {
> > +	return 0;
> > +}
> 
> These two are optional -- no need to provide them.
> 

Ok, thanks.
I will remove these two functions.

> regards,
> --
> js
> suse labs

  reply	other threads:[~2021-12-13 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13  7:10 [PATCH v5 0/2] Add UART driver for Suplus SP7021 SoC Hammer Hsieh
2021-12-13  7:10 ` [PATCH v5 1/2] dt-bindings:serial:Add bindings doc for Sunplus SoC UART Driver Hammer Hsieh
2021-12-13 17:26   ` Rob Herring
2021-12-13  7:10 ` [PATCH v5 2/2] serial:sunplus-uart:Add " Hammer Hsieh
2021-12-13  7:47   ` Jiri Slaby
2021-12-13 11:37     ` Hammer Hsieh 謝宏孟 [this message]
2021-12-20 15:47   ` Greg KH
2021-12-20 15:49   ` Greg KH
2021-12-20 15:51   ` Greg KH
2021-12-21  8:14     ` hammer hsieh
2021-12-21  8:21       ` Greg KH
2021-12-24  7:16         ` hammer hsieh
2021-12-24  8:59           ` Greg KH
2021-12-24  9:05             ` hammer hsieh
2021-12-24  9:21               ` hammer hsieh
2021-12-30 12:18                 ` 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=5040ff8d211b4d729f4bdae8ce6dabd8@sphcmbx02.sunplus.com.tw \
    --to=hammer.hsieh@sunplus.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hammerh0314@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=wells.lu@sunplus.com \
    /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

all inboxes | Powered by JetHome®