linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: chengang@emindsoft.com.cn
Cc: gregkh@linuxfoundation.org, jslaby@suse.com, sr@denx.de,
	mika.westerberg@linux.intel.com, yegorslists@googlemail.com,
	yuehaibing@huawei.com, haolee.swjtu@gmail.com, dsterba@suse.com,
	mojha@codeaurora.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Lv Li-song <lvlisong@emindsoft.com.cn>
Subject: Re: [PATCH] drivers: tty: serial: 8250: fintek: Can enable or disable irq sharing based on isa or pci bus
Date: Fri, 13 Dec 2019 12:50:33 +0200	[thread overview]
Message-ID: <20191213105033.GT32742@smile.fi.intel.com> (raw)
In-Reply-To: <20191213051717.2058-1-chengang@emindsoft.com.cn>

On Fri, Dec 13, 2019 at 01:17:17PM +0800, chengang@emindsoft.com.cn wrote:
> From: Chen Gang <chengang@emindsoft.com.cn>

Thanks for the patch, my comments below.

> Sorry for this patch being too late, which is for linux-next 20151127 (
> about linux 4.4-rc2).  After 4 years, much things have been changed. But
> I think it might be still valuable for some old versions. Welcome anyone
> to refact this patch for their own.

This part should go after '---' line below.

> Fintek serial ports can share irq, but they need be enabled firstly, so
> enable or disable irq sharing based on isa or pci bus. From kconfig, it

irq -> IRQ
isa -> ISA
pci -> PCI
kconfig -> Kconfig

> can be configured.
> 
> For integrated 8250 drivers, kernel always calls pnp driver, which will
> not use integrated fintek driver for ever. So let pnp driver try the

fintek -> Fintek or Fintek 8250

> other drivers firstly (e.g. fintek), if fail, try pnp driver its own.

Ditto.

...

> --- a/drivers/tty/serial/8250/8250.h
> +++ b/drivers/tty/serial/8250/8250.h
> @@ -14,6 +14,7 @@
>  #include <linux/serial_8250.h>
>  #include <linux/serial_reg.h>
>  #include <linux/dmaengine.h>

> +#include <linux/pnp.h>

The changes below doesn't require a header.
Pointers are known to the compiler. Names of data structures can be forward
declared. Moreover, these declarations may go inside respective #ifdef.

...

> +#if IS_ENABLED(CONFIG_SERIAL_8250_FINTEK_IRQ_SHARING)
> +
> +static void set_icsr(u16 base_port, u8 index)
> +{
> +	uint8_t icsr = 0;
> +
> +	outb(LDN, base_port + ADDR_PORT);
> +	outb(index, base_port + DATA_PORT);
> +	outb(ICSR, base_port + ADDR_PORT);
> +	icsr = inb(base_port + DATA_PORT);
> +

> +	if (icsr != 0xff) {

	if (icsr == 0xff)
		return;

?

> +		icsr |= IRQ_SHARING_MOD;
> +#if IS_ENABLED(CONFIG_SERIAL_8250_FINTEK_IRQ_SHARING_ISA)
> +		icsr |= ISA_IRQ_SHARING;
> +#else
> +		icsr |= PCI_IRQ_SHARING;
> +#endif
> +		outb(ICSR, base_port + ADDR_PORT);
> +		outb(icsr, base_port + DATA_PORT);
> +	}
> +}
> +
> +#endif

...

>  				aux |= inb(addr[i] + DATA_PORT) << 8;
>  				if (aux != io_address)
>  					continue;

> -

What the point?

> +#if IS_ENABLED(CONFIG_SERIAL_8250_FINTEK_IRQ_SHARING)
> +				set_icsr(addr[i], k);
> +#endif
>  				fintek_8250_exit_key(addr[i]);
>  				*key = keys[j];
>  				*index = k;
> @@ -179,53 +212,6 @@ static int fintek_8250_base_port(u16 io_address, u8 *key, u8 *index)
>  	return -ENODEV;
>  }
>  
> -static int
> -fintek_8250_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)

Why did you move this function?
It's now not only hard to follow what has been changed, and to review.

> --- a/drivers/tty/serial/8250/8250_pnp.c
> +++ b/drivers/tty/serial/8250/8250_pnp.c
> @@ -438,8 +438,13 @@ static int
>  serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
>  {
>  	struct uart_8250_port uart, *port;
> -	int ret, line, flags = dev_id->driver_data;
> +	int ret, line, flags;
>  

> +#if IS_BUILTIN(CONFIG_SERIAL_8250_FINTEK)
> +	if (!fintek_8250_probe(dev, dev_id))
> +		return 0;
> +#endif
> +	flags = dev_id->driver_data;

Oh, I don't like this.
It needs a bit more refactoring done first.

The idea that we are not going to pollute generic driver(s) with quirks anymore
(only when it's really unavoidable).


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2019-12-13 10:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  5:17 [PATCH] drivers: tty: serial: 8250: fintek: Can enable or disable irq sharing based on isa or pci bus chengang
2019-12-13 10:50 ` Andy Shevchenko [this message]
2019-12-16  2:27   ` Chen Gang
2019-12-16  9:51     ` Andy Shevchenko
2019-12-17  1:22       ` Chen Gang
2019-12-19  9:35         ` Chen Gang
2019-12-19 10:28           ` Andy Shevchenko

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=20191213105033.GT32742@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=chengang@emindsoft.com.cn \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haolee.swjtu@gmail.com \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lvlisong@emindsoft.com.cn \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mojha@codeaurora.org \
    --cc=sr@denx.de \
    --cc=yegorslists@googlemail.com \
    --cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).