[PATCH V4] ASoC: fsl_esai: Add pm runtime function

2019-04-27 Thread S.j. Wang
Add pm runtime support and move clock handling there.
Close the clocks at suspend to reduce the power consumption.

fsl_esai_suspend is replaced by pm_runtime_force_suspend.
fsl_esai_resume is replaced by pm_runtime_force_resume.

Signed-off-by: Shengjiu Wang 
Acked-by: Nicolin Chen 
---
Changes in v4
-resend base on for-5.2

Changes in v3
-refine the commit comments.
-add acked-by

Changes in v2
-refine the commit comments.
-move regcache_mark_dirty to runtime suspend.

 sound/soc/fsl/fsl_esai.c | 141 ++-
 1 file changed, 77 insertions(+), 64 deletions(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index bad0dfed6b68..10d2210c91ef 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -466,30 +467,6 @@ static int fsl_esai_startup(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
-   int ret;
-
-   /*
-* Some platforms might use the same bit to gate all three or two of
-* clocks, so keep all clocks open/close at the same time for safety
-*/
-   ret = clk_prepare_enable(esai_priv->coreclk);
-   if (ret)
-   return ret;
-   if (!IS_ERR(esai_priv->spbaclk)) {
-   ret = clk_prepare_enable(esai_priv->spbaclk);
-   if (ret)
-   goto err_spbaclk;
-   }
-   if (!IS_ERR(esai_priv->extalclk)) {
-   ret = clk_prepare_enable(esai_priv->extalclk);
-   if (ret)
-   goto err_extalck;
-   }
-   if (!IS_ERR(esai_priv->fsysclk)) {
-   ret = clk_prepare_enable(esai_priv->fsysclk);
-   if (ret)
-   goto err_fsysclk;
-   }
 
if (!dai->active) {
/* Set synchronous mode */
@@ -506,16 +483,6 @@ static int fsl_esai_startup(struct snd_pcm_substream 
*substream,
 
return 0;
 
-err_fsysclk:
-   if (!IS_ERR(esai_priv->extalclk))
-   clk_disable_unprepare(esai_priv->extalclk);
-err_extalck:
-   if (!IS_ERR(esai_priv->spbaclk))
-   clk_disable_unprepare(esai_priv->spbaclk);
-err_spbaclk:
-   clk_disable_unprepare(esai_priv->coreclk);
-
-   return ret;
 }
 
 static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
@@ -576,20 +543,6 @@ static int fsl_esai_hw_params(struct snd_pcm_substream 
*substream,
return 0;
 }
 
-static void fsl_esai_shutdown(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
-{
-   struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
-
-   if (!IS_ERR(esai_priv->fsysclk))
-   clk_disable_unprepare(esai_priv->fsysclk);
-   if (!IS_ERR(esai_priv->extalclk))
-   clk_disable_unprepare(esai_priv->extalclk);
-   if (!IS_ERR(esai_priv->spbaclk))
-   clk_disable_unprepare(esai_priv->spbaclk);
-   clk_disable_unprepare(esai_priv->coreclk);
-}
-
 static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
 {
@@ -658,7 +611,6 @@ static int fsl_esai_trigger(struct snd_pcm_substream 
*substream, int cmd,
 
 static const struct snd_soc_dai_ops fsl_esai_dai_ops = {
.startup = fsl_esai_startup,
-   .shutdown = fsl_esai_shutdown,
.trigger = fsl_esai_trigger,
.hw_params = fsl_esai_hw_params,
.set_sysclk = fsl_esai_set_dai_sysclk,
@@ -947,6 +899,10 @@ static int fsl_esai_probe(struct platform_device *pdev)
return ret;
}
 
+   pm_runtime_enable(>dev);
+
+   regcache_cache_only(esai_priv->regmap, true);
+
ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE);
if (ret)
dev_err(>dev, "failed to init imx pcm dma: %d\n", ret);
@@ -954,6 +910,13 @@ static int fsl_esai_probe(struct platform_device *pdev)
return ret;
 }
 
+static int fsl_esai_remove(struct platform_device *pdev)
+{
+   pm_runtime_disable(>dev);
+
+   return 0;
+}
+
 static const struct of_device_id fsl_esai_dt_ids[] = {
{ .compatible = "fsl,imx35-esai", },
{ .compatible = "fsl,vf610-esai", },
@@ -961,22 +924,35 @@ static int fsl_esai_probe(struct platform_device *pdev)
 };
 MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids);
 
-#ifdef CONFIG_PM_SLEEP
-static int fsl_esai_suspend(struct device *dev)
-{
-   struct fsl_esai *esai = dev_get_drvdata(dev);
-
-   regcache_cache_only(esai->regmap, true);
-   regcache_mark_dirty(esai->regmap);
-
-   return 0;
-}
-
-static int fsl_esai_resume(struct device *dev)
+#ifdef CONFIG_PM
+static int fsl_esai_runtime_resume(struct device *dev)
 {
struct fsl_esai *esai = dev_get_drvdata(dev);
int ret;
 
+   /*
+* Some platforms might use the same bit to 

Re: [PATCH V3] ASoC: fsl_esai: Add pm runtime function

2019-04-27 Thread S.j. Wang
Hi  Mark

> On Fri, Apr 26, 2019 at 10:51:15AM +, S.j. Wang wrote:
> > > On Mon, Apr 22, 2019 at 02:31:55AM +, S.j. Wang wrote:
> > > > Add pm runtime support and move clock handling there.
> > > > Close the clocks at suspend to reduce the power consumption.
> 
> > > > fsl_esai_suspend is replaced by pm_runtime_force_suspend.
> > > > fsl_esai_resume is replaced by pm_runtime_force_resume.
> 
> > > This doesn't apply against current code, please check and resend.
> 
> > Which branch are you using?  I tried for-next and for-linus, both Are
> > successful applied.
> 
> I'm applying against for-5.2, though if it depends on a patch queued for
> 5.1 that's fine, I can just merge that up - please just resend.  I think I 
> did try
> merging 5.1 though...

I think may be caused by the patch " ASoC: fsl_esai: Fix missing break
in switch statement", so I resend them both base on for-5.2.

best regards
wang shengjiu


[PATCH V6] ASoC: fsl_esai: Fix missing break in switch statement

2019-04-27 Thread S.j. Wang
case ESAI_HCKT_EXTAL and case ESAI_HCKR_EXTAL should be
independent of each other, so replace fall-through with break.

Fixes: 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver")
Signed-off-by: Shengjiu Wang 
Acked-by: Nicolin Chen 
Cc: 
---
Changes in V6
- resend base one for-5.2

Changes in v5
- remove new line after Fixes

Changes in v4
- Add acked-by

Changes in v3
- Update subject line and cc stable

Changes in v2
- Fix "Fixes" tag

 sound/soc/fsl/fsl_esai.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index c7410bbfd2af..bad0dfed6b68 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -251,7 +251,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, 
int clk_id,
break;
case ESAI_HCKT_EXTAL:
ecr |= ESAI_ECR_ETI;
-   /* fall through */
+   break;
case ESAI_HCKR_EXTAL:
ecr |= esai_priv->synchronous ? ESAI_ECR_ETI : ESAI_ECR_ERI;
break;
-- 
1.9.1



Re: [PATCH 2/3 v2] ASoC: fsl_sai: Add support for runtime pm

2019-04-27 Thread Mark Brown
On Fri, Apr 26, 2019 at 03:10:10PM +0300, Daniel Baluta wrote:

> The only patch left in the series that needs to be applied is this:

> https://www.spinics.net/lists/alsa-devel/msg89733.html

> I will reply also to that email, to be easier for you to find it.

Content free pings don't help...


signature.asc
Description: PGP signature


Re: [PATCH V3] ASoC: fsl_esai: Add pm runtime function

2019-04-27 Thread Mark Brown
On Fri, Apr 26, 2019 at 10:51:15AM +, S.j. Wang wrote:
> > On Mon, Apr 22, 2019 at 02:31:55AM +, S.j. Wang wrote:
> > > Add pm runtime support and move clock handling there.
> > > Close the clocks at suspend to reduce the power consumption.

> > > fsl_esai_suspend is replaced by pm_runtime_force_suspend.
> > > fsl_esai_resume is replaced by pm_runtime_force_resume.

> > This doesn't apply against current code, please check and resend.

> Which branch are you using?  I tried for-next and for-linus, both
> Are successful applied.

I'm applying against for-5.2, though if it depends on a patch queued for
5.1 that's fine, I can just merge that up - please just resend.  I think
I did try merging 5.1 though...


signature.asc
Description: PGP signature


Re: [PATCH v2 9/9] dpaa_eth: fix SG frame cleanup

2019-04-27 Thread Joakim Tjernlund
On Sat, 2019-04-27 at 10:10 +0300, laurentiu.tu...@nxp.com wrote:
> From: Laurentiu Tudor 
> 
> Fix issue with the entry indexing in the sg frame cleanup code being
> off-by-1. This problem showed up when doing some basic iperf tests and
> manifested in traffic coming to a halt.
> 
> Signed-off-by: Laurentiu Tudor 
> Acked-by: Madalin Bucur 

Wasn't this a stable candidate too?

> ---
>  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> index daede7272768..40420edc9ce6 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -1663,7 +1663,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct 
> dpaa_priv *priv,
>  qm_sg_entry_get_len([0]), dma_dir);
> 
> /* remaining pages were mapped with skb_frag_dma_map() */
> -   for (i = 1; i < nr_frags; i++) {
> +   for (i = 1; i <= nr_frags; i++) {
> WARN_ON(qm_sg_entry_is_ext([i]));
> 
> dma_unmap_page(dev, qm_sg_addr([i]),
> --
> 2.17.1
> 



Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour

2019-04-27 Thread Florian Fainelli



On 4/26/2019 4:06 PM, Petr Štetiar wrote:
> As of_get_mac_address now supports NVMEM under the hood, we should
> update the bindings documentation with the new nvmem-cell* properties.
> While at it, fix also other missing properties supported by
> of_get_mac_address.
> 
> Signed-off-by: Petr Štetiar 

While I appreciate your effort in making the bindings up to date and
consistent, this does really scale well and is an error prone exercise,
how about consolidating all MAC address related properties into the
ethernet.txt document like you just did and update all bindings to
indicate something along the lines of:

For all other standard Ethernet related properties, please refer to
ethernet.txt or something like that?
-- 
Florian


Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour

2019-04-27 Thread Andrew Lunn
> diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
> b/Documentation/devicetree/bindings/net/ethernet.txt
> index 2974e63..1e2bc9a 100644
> --- a/Documentation/devicetree/bindings/net/ethernet.txt
> +++ b/Documentation/devicetree/bindings/net/ethernet.txt
> @@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
>the boot program; should be used in cases where the MAC address assigned to
>the device by the boot program is different from the "local-mac-address"
>property;
> +- nvmem-cells: phandle, reference to an nvmem node for the MAC address
> +- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used

You put the new values after local-mac-address and mac-address. That
suggests they are of lower priority. That conflicts with the current
patch. If you think NVMEM should take priority, please put the
properties first.

   Andrew


Re: [PATCH v2 7/9] dpaa_eth: fix iova handling for contiguous frames

2019-04-27 Thread Christoph Hellwig
On Sat, Apr 27, 2019 at 10:10:29AM +0300, laurentiu.tu...@nxp.com wrote:
> From: Laurentiu Tudor 
> 
> The driver relies on the no longer valid assumption that dma addresses
> (iovas) are identical to physical addressees and uses phys_to_virt() to
> make iova -> vaddr conversions. Fix this by adding a function that does
> proper iova -> phys conversions using the iommu api and update the code
> to use it.
> Also, a dma_unmap_single() call had to be moved further down the code
> because iova -> vaddr conversions were required before the unmap.
> For now only the contiguous frame case is handled and the SG case is
> split in a following patch.
> While at it, clean-up a redundant dpaa_bpid2pool() and pass the bp
> as parameter.

Err, this is broken.  A driver using the DMA API has no business
call IOMMU APIs.  Just save the _virtual_ address used for the mapping
away and use that again.  We should not go through crazy gymnastics
like this.


Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour

2019-04-27 Thread Andrew Lunn
> diff --git a/Documentation/devicetree/bindings/net/macb.txt 
> b/Documentation/devicetree/bindings/net/macb.txt
> index 8b80515..92c5642 100644
> --- a/Documentation/devicetree/bindings/net/macb.txt
> +++ b/Documentation/devicetree/bindings/net/macb.txt
> @@ -26,15 +26,15 @@ Required properties:
>   Optional elements: 'tsu_clk'
>  - clocks: Phandles to input clocks.
>  
> -Optional properties:
> -- nvmem-cells: phandle, reference to an nvmem node for the MAC address
> -- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used
> -
>  Optional properties for PHY child node:
>  - reset-gpios : Should specify the gpio for phy reset
>  - magic-packet : If present, indicates that the hardware supports waking
>up via magic packet.
>  - phy-handle : see ethernet.txt file in the same directory
> +- mac-address: See ethernet.txt in the same directory.
> +- local-mac-address: See ethernet.txt in the same directory.
> +- nvmem-cells: See ethernet.txt in the same directory.
> +- nvmem-cell-names: See ethernet.txt in the same directory.

This looks wrong. The MAC address is not a PHY property, so should not
be inside the PHY child node.

phy-handle is in the wrong place, but that is a separate problem.

   Andrew


Re: [PATCH v2 3/9] fsl/fman: backup and restore ICID registers

2019-04-27 Thread David Miller
From: laurentiu.tu...@nxp.com
Date: Sat, 27 Apr 2019 10:10:25 +0300

> @@ -1914,7 +1936,10 @@ static int fman_reset(struct fman *fman)
>  static int fman_init(struct fman *fman)
>  {
>   struct fman_cfg *cfg = NULL;
> - int err = 0, i, count;
> + int err = 0, count;
> +#ifdef CONFIG_PPC
> + int i;
> +#endif
>  
>   if (is_init_done(fman->cfg))
>   return -EINVAL;
> @@ -1934,6 +1959,7 @@ static int fman_init(struct fman *fman)
>   memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0,
> fman->state->fm_port_num_of_cg);
>  
> +#ifdef CONFIG_PPC
>   /* Save LIODN info before FMan reset
>* Skipping non-existent port 0 (i = 1)
>*/

Sorry, I'm not OK with littering a networking driver with arch ifdefs
all over the place.

Please create a proper abstraction and set of interfaces.

Thank you.


Re: [PATCH 10/41] drivers: tty: serial: sb1250-duart: fix missing parentheses

2019-04-27 Thread Greg KH
On Sat, Apr 27, 2019 at 02:51:51PM +0200, Enrico Weigelt, metux IT consult 
wrote:
> Fix checkpatch warning:
> 
> ERROR: Macros with complex values should be enclosed in parentheses
> #911: FILE: drivers/tty/serial/sb1250-duart.c:911:
> +#define SERIAL_SB1250_DUART_CONSOLE  _console
> 
> Signed-off-by: Enrico Weigelt 
> ---
>  drivers/tty/serial/sb1250-duart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/sb1250-duart.c 
> b/drivers/tty/serial/sb1250-duart.c
> index 1184226..ec74f09 100644
> --- a/drivers/tty/serial/sb1250-duart.c
> +++ b/drivers/tty/serial/sb1250-duart.c
> @@ -908,7 +908,7 @@ static int __init sbd_serial_console_init(void)
>  
>  console_initcall(sbd_serial_console_init);
>  
> -#define SERIAL_SB1250_DUART_CONSOLE  _console
> +#define SERIAL_SB1250_DUART_CONSOLE  (_console)

No, that's foolish.

checkpatch is a hint, it's not always right.

Also, checkpatch cleanups for really old drivers is not generally a good
idea, especially if you do not have the hardware for them.  Please don't
cause unneeded churn for this type of thing in this subsystem, unless
you have the hardware.

thanks,

greg k-h


Re: [PATCH 01/41] drivers: tty: serial: dz: use dev_err() instead of printk()

2019-04-27 Thread Greg KH
On Sat, Apr 27, 2019 at 02:51:42PM +0200, Enrico Weigelt, metux IT consult 
wrote:
> Using dev_err() instead of printk() for more consistent output.
> (prints device name, etc).
> 
> Signed-off-by: Enrico Weigelt 
> ---
>  drivers/tty/serial/dz.c | 8 

Do you have this hardware to test any of these changes with?

thanks,

greg k-h


Re: [PATCH 05/41] drivers: tty: serial: dz: use pr_info() instead of incomplete printk()

2019-04-27 Thread Greg KH
On Sat, Apr 27, 2019 at 02:51:46PM +0200, Enrico Weigelt, metux IT consult 
wrote:
> Fix the checkpatch warning:
> 
> WARNING: printk() should include KERN_ facility level
> #934: FILE: dz.c:934:
> + printk("%s%s\n", dz_name, dz_version);
> 
> Signed-off-by: Enrico Weigelt 
> ---
>  drivers/tty/serial/dz.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
> index 559d076..e2670c4 100644
> --- a/drivers/tty/serial/dz.c
> +++ b/drivers/tty/serial/dz.c
> @@ -931,7 +931,7 @@ static int __init dz_init(void)
>   if (IOASIC)
>   return -ENXIO;
>  
> - printk("%s%s\n", dz_name, dz_version);
> + pr_info("%s%s\n", dz_name, dz_version);

Just drop this line, it's not needed and generally just noise.

thanks,

greg k-h


Re: [PATCH 01/41] drivers: tty: serial: dz: use dev_err() instead of printk()

2019-04-27 Thread Greg KH
On Sat, Apr 27, 2019 at 02:51:42PM +0200, Enrico Weigelt, metux IT consult 
wrote:
> Using dev_err() instead of printk() for more consistent output.
> (prints device name, etc).
> 
> Signed-off-by: Enrico Weigelt 

Your "From:" line does not match the signed-off-by line, so I can't take
any of these if I wanted to :(

Please fix up.

thanks,

greg k-h


Re: [PATCH 37/41] drivers: tty: serial: 8250: simplify io resource size computation

2019-04-27 Thread John Paul Adrian Glaubitz
On 4/27/19 2:52 PM, Enrico Weigelt, metux IT consult wrote:
> Simpily io resource size computation by setting mapsize field.

Here's a typo

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


[PATCH 40/41] drivers: tty: serial: helper for setting mmio range

2019-04-27 Thread Enrico Weigelt, metux IT consult
Introduce a little helpers for settings the mmio range from an
struct resource or start/len parameters with less code.
(also setting iotype to UPIO_MEM)

Also converting drivers to use these new helpers as well as
fetching mapsize field instead of using hardcoded values.
(the runtime overhead of that should be negligible)

The idea is moving to a consistent scheme, so later common
calls like request+ioremap combination can be done by generic
helpers.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/8250/8250_acorn.c|  5 ++--
 drivers/tty/serial/8250/8250_aspeed_vuart.c |  4 +--
 drivers/tty/serial/8250/8250_dw.c   |  3 +--
 drivers/tty/serial/8250/8250_em.c   |  2 +-
 drivers/tty/serial/8250/8250_exar.c |  6 +++--
 drivers/tty/serial/8250/8250_hp300.c| 11 +---
 drivers/tty/serial/8250/8250_of.c   |  9 ++-
 drivers/tty/serial/meson_uart.c |  5 ++--
 drivers/tty/serial/mps2-uart.c  |  5 ++--
 drivers/tty/serial/pmac_zilog.c |  8 ++
 drivers/tty/serial/vt8500_serial.c  |  4 +--
 drivers/tty/serial/xilinx_uartps.c  |  3 +--
 drivers/tty/serial/zs.c | 10 +---
 include/linux/serial_core.h | 40 +
 14 files changed, 76 insertions(+), 39 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_acorn.c 
b/drivers/tty/serial/8250/8250_acorn.c
index 758c4aa..359171b 100644
--- a/drivers/tty/serial/8250/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
@@ -63,14 +63,15 @@ struct serial_card_info {
uart.port.irq   = ec->irq;
uart.port.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
uart.port.uartclk   = type->uartclk;
-   uart.port.iotype= UPIO_MEM;
uart.port.regshift  = 2;
uart.port.dev   = >dev;
 
for (i = 0; i < info->num_ports; i++) {
uart.port.membase = info->vaddr + type->offset[i];
-   uart.port.mapbase = bus_addr + type->offset[i];
 
+   /* mapsize is computed by serial8250_register_8250_port() */
+   uart_memres_set_start_len(,
+ bus_addr + type->offset[i], 0);
info->ports[i] = serial8250_register_8250_port();
}
 
diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c 
b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 0438d9a..0e06391 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -328,8 +328,6 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
memset(, 0, sizeof(port));
port.port.private_data = vuart;
port.port.membase = vuart->regs;
-   port.port.mapbase = res->start;
-   port.port.mapsize = resource_size(res);
port.port.startup = aspeed_vuart_startup;
port.port.shutdown = aspeed_vuart_shutdown;
port.port.throttle = aspeed_vuart_throttle;
@@ -337,6 +335,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
port.port.status = UPSTAT_SYNC_FIFO;
port.port.dev = >dev;
 
+   uart_memres_set_res(, res);
+
rc = sysfs_create_group(>dev->kobj, _vuart_attr_group);
if (rc < 0)
return rc;
diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index d31b975..cb65256 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -513,18 +513,17 @@ static int dw8250_probe(struct platform_device *pdev)
}
 
spin_lock_init(>lock);
-   p->mapbase  = regs->start;
p->irq  = irq;
p->handle_irq   = dw8250_handle_irq;
p->pm   = dw8250_do_pm;
p->type = PORT_8250;
p->flags= UPF_SHARE_IRQ | UPF_FIXED_PORT;
p->dev  = dev;
-   p->iotype   = UPIO_MEM;
p->serial_in= dw8250_serial_in;
p->serial_out   = dw8250_serial_out;
p->set_ldisc= dw8250_set_ldisc;
p->set_termios  = dw8250_set_termios;
+   uart_memres_set_res(p, regs);
 
p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
if (!p->membase)
diff --git a/drivers/tty/serial/8250/8250_em.c 
b/drivers/tty/serial/8250/8250_em.c
index 2a76e22..7610441 100644
--- a/drivers/tty/serial/8250/8250_em.c
+++ b/drivers/tty/serial/8250/8250_em.c
@@ -100,12 +100,12 @@ static int serial8250_em_probe(struct platform_device 
*pdev)
}
 
memset(, 0, sizeof(up));
-   up.port.mapbase = regs->start;
up.port.irq = irq->start;
up.port.type = PORT_UNKNOWN;
up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP;
up.port.dev = >dev;
up.port.private_data = priv;
+   uart_memres_set_res(, res);
 
clk_prepare_enable(priv->sclk);
up.port.uartclk = clk_get_rate(priv->sclk);
diff --git a/drivers/tty/serial/8250/8250_exar.c 

[PATCH 24/41] drivers: tty: serial: timbuart: use dev_err() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/timbuart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 19d38b5..dcce936 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -470,8 +470,7 @@ static int timbuart_probe(struct platform_device *dev)
 err_register:
kfree(uart);
 err_mem:
-   printk(KERN_ERR "timberdale: Failed to register Timberdale UART: %d\n",
-   err);
+   dev_err(>dev, "Failed to register Timberdale UART: %d\n", err);
 
return err;
 }
-- 
1.9.1



[PATCH 27/41] drivers: tty: serial: sunzilog: fix formatting issues

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: Use #include  instead of 
#38: FILE: drivers/tty/serial/sunzilog.c:38:
+#include 

WARNING: line over 80 characters
#109: FILE: drivers/tty/serial/sunzilog.c:109:
+#define ZILOG_CHANNEL_FROM_PORT(PORT)  ((struct zilog_channel __iomem 
*)((PORT)->membase))

WARNING: line over 80 characters
#116: FILE: drivers/tty/serial/sunzilog.c:116:
+#define ZS_WANTS_MODEM_STATUS(UP)  ((UP)->flags & 
SUNZILOG_FLAG_MODEM_STATUS)

WARNING: line over 80 characters
#179: FILE: drivers/tty/serial/sunzilog.c:179:
+static int __load_zsregs(struct zilog_channel __iomem *channel, unsigned 
char *regs)

WARNING: Missing a blank line after declarations
#188: FILE: drivers/tty/serial/sunzilog.c:188:
+   unsigned char stat = read_zsreg(channel, R1);
+   if (stat & ALL_SNT)

ERROR: trailing whitespace
#231: FILE: drivers/tty/serial/sunzilog.c:231:
+^I$

WARNING: braces {} are not necessary for any arm of this statement
#276: FILE: drivers/tty/serial/sunzilog.c:276:
+   if (ZS_TX_ACTIVE(up)) {
[...]
+   } else {
[...]

ERROR: else should follow close brace '}'
#378: FILE: drivers/tty/serial/sunzilog.c:378:
+   }
+   else if (r1 & PAR_ERR)

ERROR: code indent should use tabs where possible
#397: FILE: drivers/tty/serial/sunzilog.c:397:
+^I^I^Itty_insert_flip_char(port, ch, flag);$

WARNING: please, no space before tabs
#397: FILE: drivers/tty/serial/sunzilog.c:397:
+^I^I^Itty_insert_flip_char(port, ch, flag);$

WARNING: line over 80 characters
#440: FILE: drivers/tty/serial/sunzilog.c:440:
+   /* The Zilog just gives us an interrupt when DCD/CTS/etc. 
change.

WARNING: line over 80 characters
#441: FILE: drivers/tty/serial/sunzilog.c:441:
+* But it does not tell us which bit has changed, we have to 
keep

WARNING: Missing a blank line after declarations
#464: FILE: drivers/tty/serial/sunzilog.c:464:
+   unsigned char status = readb(>control);
+   ZSDELAY();

WARNING: line over 80 characters
#468: FILE: drivers/tty/serial/sunzilog.c:468:
+* It can occur because of how we do serial console writes.  It 
would

WARNING: line over 80 characters
#469: FILE: drivers/tty/serial/sunzilog.c:469:
+* be nice to transmit console writes just like we normally 
would for

WARNING: line over 80 characters
#470: FILE: drivers/tty/serial/sunzilog.c:470:
+* a TTY line. (ie. buffered and TX interrupt driven).  That is 
not

WARNING: line over 80 characters
#471: FILE: drivers/tty/serial/sunzilog.c:471:
+* easy because console writes cannot sleep.  One solution 
might be

WARNING: line over 80 characters
#593: FILE: drivers/tty/serial/sunzilog.c:593:
+static __inline__ unsigned char sunzilog_read_channel_status(struct 
uart_port *port)

WARNING: plain inline is preferred over __inline__
#593: FILE: drivers/tty/serial/sunzilog.c:593:
+static __inline__ unsigned char sunzilog_read_channel_status(struct 
uart_port *port)

ERROR: trailing whitespace
#664: FILE: drivers/tty/serial/sunzilog.c:664:
+^I/* NOTE: Not subject to 'transmitter active' rule.  */ $

ERROR: trailing whitespace
#752: FILE: drivers/tty/serial/sunzilog.c:752:
+^I^I/* NOTE: Not subject to 'transmitter active' rule.  */ $

ERROR: trailing whitespace
#779: FILE: drivers/tty/serial/sunzilog.c:779:
+^I^I/* NOTE: Not subject to 'transmitter active' rule.  */ $

WARNING: line over 80 characters
#999: FILE: drivers/tty/serial/sunzilog.c:999:
+static int sunzilog_verify_port(struct uart_port *port, struct 
serial_struct *ser)

WARNING: Missing a blank line after declarations
#1142: FILE: drivers/tty/serial/sunzilog.c:1142:
+   unsigned char val = readb(>control);
+   if (val & Tx_BUF_EMP) {

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
#1230: FILE: drivers/tty/serial/sunzilog.c:1230:
+   printk(KERN_INFO "Console: ttyS%d (SunZilog zs%d)\n",

WARNING: braces {} are not necessary for single statement blocks
#1383: FILE: drivers/tty/serial/sunzilog.c:1383:
+   if (__load_zsregs(channel, up->curregs)) {
+   up->flags |= SUNZILOG_FLAG_ESCC;
+   }

WARNING: quoted string split across lines
#1493: FILE: drivers/tty/serial/sunzilog.c:1493:
+   dev_info(>dev, "Keyboard at MMIO 0x%llx (irq = %d) "
+  "is a %s\n",

WARNING: quoted string split across lines
#1497: FILE: drivers/tty/serial/sunzilog.c:1497:
+   dev_info(>dev, "Mouse at MMIO 0x%llx (irq = %d) "
+  "is a 

[PATCH 35/41] drivers: tty: serial: 8250: add mapsize to platform data

2019-04-27 Thread Enrico Weigelt, metux IT consult
Adding a mapsize field for the 8250 port platform data struct,
so we can now set the resource size (eg. *1) and don't need
funny runtime detections like serial8250_port_size() anymore.

For now, serial8250_port_size() is called everytime we need
the io resource size. That function checks which chip we
actually have and returns the appropriate size. This approach
is a bit clumpsy and not entirely easy to understand, and
it's a violation of layers :p

Obviously, that information cannot change after the driver init,
so we can safely do that probing once on driver init and just
use the stored value later.

*1) arch/mips/alchemy/common/platform.c

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/8250/8250_core.c | 1 +
 include/linux/serial_8250.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index e441221..71a398b 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -814,6 +814,7 @@ static int serial8250_probe(struct platform_device *dev)
uart.port.iotype= p->iotype;
uart.port.flags = p->flags;
uart.port.mapbase   = p->mapbase;
+   uart.port.mapsize   = p->mapsize;
uart.port.hub6  = p->hub6;
uart.port.private_data  = p->private_data;
uart.port.type  = p->type;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 5a655ba..8b8183a 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -22,6 +22,7 @@ struct plat_serial8250_port {
unsigned long   iobase; /* io base address */
void __iomem*membase;   /* ioremap cookie or NULL */
resource_size_t mapbase;/* resource base */
+   resource_size_t mapsize;/* resource size */
unsigned intirq;/* interrupt number */
unsigned long   irqflags;   /* request_irq flags */
unsigned intuartclk;/* UART clock rate */
-- 
1.9.1



[PATCH 41/41] drivers: tty: serial: lpc32xx_hs: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/lpc32xx_hs.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index f4e27d0..d1f09aa 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -579,7 +579,7 @@ static void serial_lpc32xx_release_port(struct uart_port 
*port)
port->membase = NULL;
}
 
-   release_mem_region(port->mapbase, SZ_4K);
+   release_mem_region(port->mapbase, port->mapsize);
}
 }
 
@@ -590,12 +590,15 @@ static int serial_lpc32xx_request_port(struct uart_port 
*port)
if ((port->iotype == UPIO_MEM32) && (port->mapbase)) {
ret = 0;
 
-   if (!request_mem_region(port->mapbase, SZ_4K, MODNAME))
+   if (!request_mem_region(port->mapbase,
+   port->mapsize, MODNAME))
ret = -EBUSY;
else if (port->flags & UPF_IOREMAP) {
-   port->membase = ioremap(port->mapbase, SZ_4K);
+   port->membase = ioremap(port->mapbase,
+   port->mapsize);
if (!port->membase) {
-   release_mem_region(port->mapbase, SZ_4K);
+   release_mem_region(port->mapbase,
+  port->mapsize);
ret = -ENOMEM;
}
}
@@ -684,6 +687,7 @@ static int serial_hs_lpc32xx_probe(struct platform_device 
*pdev)
return -ENXIO;
}
p->port.mapbase = res->start;
+   p->port.mapsize = SZ_4K;
p->port.membase = NULL;
 
ret = platform_get_irq(pdev, 0);
-- 
1.9.1



[PATCH 36/41] drivers: tty: serial: 8250: store mmio resource size in port struct

2019-04-27 Thread Enrico Weigelt, metux IT consult
The io resource size is currently recomputed when it's needed but this
actually needs to be done once (or drivers could specify fixed values)

Simplify that by doing this computation only once and storing the result
into the mapsize field. serial8250_register_8250_port() is now called
only once on driver init, the previous call sites now just fetch the
value from the mapsize field.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/8250/8250.h  |  2 ++
 drivers/tty/serial/8250/8250_core.c |  3 +++
 drivers/tty/serial/8250/8250_port.c | 33 +++--
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index ebfb0bd..89e3f09 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -255,3 +255,5 @@ static inline int serial_index(struct uart_port *port)
 {
return port->minor - 64;
 }
+
+unsigned int serial8250_port_size(struct uart_8250_port *pt);
diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index 71a398b..a9d4ba1 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -979,6 +979,9 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
if (up->port.uartclk == 0)
return -EINVAL;
 
+   /* compute the mapsize in case the driver didn't specify one */
+   up->mapsize = serial8250_port_size(up);
+
mutex_lock(_mutex);
 
uart = serial8250_find_match_or_unused(>port);
diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index d2f3310..d09af4c 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2829,7 +2829,7 @@ void serial8250_do_pm(struct uart_port *port, unsigned 
int state,
serial8250_do_pm(port, state, oldstate);
 }
 
-static unsigned int serial8250_port_size(struct uart_8250_port *pt)
+unsigned int serial8250_port_size(struct uart_8250_port *pt)
 {
if (pt->port.mapsize)
return pt->port.mapsize;
@@ -2849,9 +2849,7 @@ static unsigned int serial8250_port_size(struct 
uart_8250_port *pt)
  */
 static int serial8250_request_std_resource(struct uart_8250_port *up)
 {
-   unsigned int size = serial8250_port_size(up);
struct uart_port *port = >port;
-   int ret = 0;
 
switch (port->iotype) {
case UPIO_AU:
@@ -2863,32 +2861,31 @@ static int serial8250_request_std_resource(struct 
uart_8250_port *up)
if (!port->mapbase)
break;
 
-   if (!request_mem_region(port->mapbase, size, "serial")) {
-   ret = -EBUSY;
-   break;
-   }
+   if (!request_mem_region(port->mapbase,
+   port->mapsize, "serial"))
+   return -EBUSY;
 
if (port->flags & UPF_IOREMAP) {
-   port->membase = ioremap_nocache(port->mapbase, size);
-   if (!port->membase) {
-   release_mem_region(port->mapbase, size);
-   ret = -ENOMEM;
-   }
+   port->membase = ioremap_nocache(port->mapbase,
+   port->mapsize);
+   if (!port->membase)
+   release_mem_region(port->mapbase,
+  port->mapsize);
+   return -ENOMEM;
}
break;
 
case UPIO_HUB6:
case UPIO_PORT:
-   if (!request_region(port->iobase, size, "serial"))
-   ret = -EBUSY;
+   if (!request_region(port->iobase, port->mapsize, "serial"))
+   return -EBUSY;
break;
}
-   return ret;
+   return 0;
 }
 
 static void serial8250_release_std_resource(struct uart_8250_port *up)
 {
-   unsigned int size = serial8250_port_size(up);
struct uart_port *port = >port;
 
switch (port->iotype) {
@@ -2906,12 +2903,12 @@ static void serial8250_release_std_resource(struct 
uart_8250_port *up)
port->membase = NULL;
}
 
-   release_mem_region(port->mapbase, size);
+   release_mem_region(port->mapbase, port->mapsize);
break;
 
case UPIO_HUB6:
case UPIO_PORT:
-   release_region(port->iobase, size);
+   release_region(port->iobase, port->mapsize);
break;
}
 }
-- 
1.9.1



[PATCH 34/41] drivers: tty: serial: zs: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/zs.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
index adbfe79..ab432ba 100644
--- a/drivers/tty/serial/zs.c
+++ b/drivers/tty/serial/zs.c
@@ -986,14 +986,14 @@ static void zs_release_port(struct uart_port *uport)
 {
iounmap(uport->membase);
uport->membase = 0;
-   release_mem_region(uport->mapbase, ZS_CHAN_IO_SIZE);
+   release_mem_region(uport->mapbase, uport->mapsize);
 }
 
 static int zs_map_port(struct uart_port *uport)
 {
if (!uport->membase)
uport->membase = ioremap_nocache(uport->mapbase,
-ZS_CHAN_IO_SIZE);
+uport->mapsize);
if (!uport->membase) {
dev_err(port->dev, "zs: Cannot map MMIO\n");
return -ENOMEM;
@@ -1005,13 +1005,13 @@ static int zs_request_port(struct uart_port *uport)
 {
int ret;
 
-   if (!request_mem_region(uport->mapbase, ZS_CHAN_IO_SIZE, "scc")) {
+   if (!request_mem_region(uport->mapbase, uport->mapsize, "scc")) {
dev_err(uport->dev, "zs: Unable to reserve MMIO resource\n");
return -EBUSY;
}
ret = zs_map_port(uport);
if (ret) {
-   release_mem_region(uport->mapbase, ZS_CHAN_IO_SIZE);
+   release_mem_region(uport->mapbase, uport->mapsize);
return ret;
}
return 0;
@@ -1113,6 +1113,7 @@ static int __init zs_probe_sccs(void)
uport->flags= UPF_BOOT_AUTOCONF;
uport->ops  = _ops;
uport->line = chip * ZS_NUM_CHAN + side;
+   uport->mapsize  = ZS_CHAN_IO_SIZE;
uport->mapbase  = dec_kn_slot_base +
  zs_parms.scc[chip] +
  (side ^ ZS_CHAN_B) * ZS_CHAN_IO_SIZE;
-- 
1.9.1



[PATCH 33/41] drivers: tty: serial: zs: use dev_err() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/zs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
index b03d3e4..adbfe79 100644
--- a/drivers/tty/serial/zs.c
+++ b/drivers/tty/serial/zs.c
@@ -767,7 +767,7 @@ static int zs_startup(struct uart_port *uport)
  IRQF_SHARED, "scc", scc);
if (ret) {
atomic_add(-1, >irq_guard);
-   printk(KERN_ERR "zs: can't get irq %d\n",
+   dev_err(uport->dev, "zs: can't get irq %d\n",
   zport->port.irq);
return ret;
}
@@ -995,7 +995,7 @@ static int zs_map_port(struct uart_port *uport)
uport->membase = ioremap_nocache(uport->mapbase,
 ZS_CHAN_IO_SIZE);
if (!uport->membase) {
-   printk(KERN_ERR "zs: Cannot map MMIO\n");
+   dev_err(port->dev, "zs: Cannot map MMIO\n");
return -ENOMEM;
}
return 0;
@@ -1006,7 +1006,7 @@ static int zs_request_port(struct uart_port *uport)
int ret;
 
if (!request_mem_region(uport->mapbase, ZS_CHAN_IO_SIZE, "scc")) {
-   printk(KERN_ERR "zs: Unable to reserve MMIO resource\n");
+   dev_err(uport->dev, "zs: Unable to reserve MMIO resource\n");
return -EBUSY;
}
ret = zs_map_port(uport);
-- 
1.9.1



[PATCH 30/41] drivers: tty: serial: ioc4_serial: use dev_warn() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_warn() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/ioc4_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index db5b979..21c1b8f 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -2752,7 +2752,7 @@ static int ioc4_serial_remove_one(struct ioc4_driver_data 
*idd)
the_port->dev = >dev;
spin_lock_init(_port->lock);
if (uart_add_one_port(u_driver, the_port) < 0) {
-   printk(KERN_WARNING
+   dev_warn(>dev,
   "%s: unable to add port %d bus %d\n",
   __func__, the_port->line, pdev->bus->number);
} else {
-- 
1.9.1



[PATCH 06/41] drivers: tty: serial: sb1250-duart: use dev_err() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index 329aced..655961c 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -663,7 +663,6 @@ static void sbd_release_port(struct uart_port *uport)
 
 static int sbd_map_port(struct uart_port *uport)
 {
-   const char *err = KERN_ERR "sbd: Cannot map MMIO\n";
struct sbd_port *sport = to_sport(uport);
struct sbd_duart *duart = sport->duart;
 
@@ -671,7 +670,7 @@ static int sbd_map_port(struct uart_port *uport)
uport->membase = ioremap_nocache(uport->mapbase,
 DUART_CHANREG_SPACING);
if (!uport->membase) {
-   printk(err);
+   dev_err(uport->dev, "Cannot map MMIO (base)\n");
return -ENOMEM;
}
 
@@ -679,7 +678,7 @@ static int sbd_map_port(struct uart_port *uport)
sport->memctrl = ioremap_nocache(duart->mapctrl,
 DUART_CHANREG_SPACING);
if (!sport->memctrl) {
-   printk(err);
+   dev_err(uport->dev, "Cannot map MMIO (ctrl)\n");
iounmap(uport->membase);
uport->membase = NULL;
return -ENOMEM;
-- 
1.9.1



[PATCH 01/41] drivers: tty: serial: dz: use dev_err() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/dz.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 7b57e84..96e35af 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -416,7 +416,7 @@ static int dz_startup(struct uart_port *uport)
  IRQF_SHARED, "dz", mux);
if (ret) {
atomic_add(-1, >irq_guard);
-   printk(KERN_ERR "dz: Cannot get IRQ %d!\n", dport->port.irq);
+   dev_err(uport->dev, "Cannot get IRQ %d!\n", dport->port.irq);
return ret;
}
 
@@ -680,7 +680,7 @@ static int dz_map_port(struct uart_port *uport)
uport->membase = ioremap_nocache(uport->mapbase,
 dec_kn_slot_size);
if (!uport->membase) {
-   printk(KERN_ERR "dz: Cannot map MMIO\n");
+   dev_err(uport->dev, "Cannot map MMIO\n");
return -ENOMEM;
}
return 0;
@@ -697,8 +697,8 @@ static int dz_request_port(struct uart_port *uport)
if (!request_mem_region(uport->mapbase, dec_kn_slot_size,
"dz")) {
atomic_add(-1, >map_guard);
-   printk(KERN_ERR
-  "dz: Unable to reserve MMIO resource\n");
+   dev_err(uport->dev,
+   "Unable to reserve MMIO resource\n");
return -EBUSY;
}
}
-- 
1.9.1



[PATCH 25/41] drivers: tty: serial: timbuart: fix formatting issues

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: Missing a blank line after declarations
#43: FILE: drivers/tty/serial/timbuart.c:43:
+   u32 ier = ioread32(port->membase + TIMBUART_IER) & ~RXFLAGS;
+   iowrite32(ier, port->membase + TIMBUART_IER);

WARNING: Missing a blank line after declarations
#50: FILE: drivers/tty/serial/timbuart.c:50:
+   u32 ier = ioread32(port->membase + TIMBUART_IER) & ~TXBAE;
+   iowrite32(ier, port->membase + TIMBUART_IER);

WARNING: Missing a blank line after declarations
#86: FILE: drivers/tty/serial/timbuart.c:86:
+   u8 ch = ioread8(port->membase + TIMBUART_RXFIFO);
+   port->icount.rx++;

WARNING: Missing a blank line after declarations
#202: FILE: drivers/tty/serial/timbuart.c:202:
+   u8 cts = ioread8(port->membase + TIMBUART_CTRL);
+   dev_dbg(port->dev, "%s - cts %x\n", __func__, cts);

WARNING: Block comments use * on subsequent lines
#296: FILE: drivers/tty/serial/timbuart.c:296:
+   /* The serial layer calls into this once with old = NULL when setting
+  up initially */

WARNING: Block comments use a trailing */ on a separate line
#296: FILE: drivers/tty/serial/timbuart.c:296:

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/timbuart.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index dcce936..d80c332 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -40,6 +40,7 @@ static void timbuart_stop_rx(struct uart_port *port)
 {
/* spin lock held by upper layer, disable all RX interrupts */
u32 ier = ioread32(port->membase + TIMBUART_IER) & ~RXFLAGS;
+
iowrite32(ier, port->membase + TIMBUART_IER);
 }
 
@@ -47,6 +48,7 @@ static void timbuart_stop_tx(struct uart_port *port)
 {
/* spinlock held by upper layer, disable TX interrupt */
u32 ier = ioread32(port->membase + TIMBUART_IER) & ~TXBAE;
+
iowrite32(ier, port->membase + TIMBUART_IER);
 }
 
@@ -83,6 +85,7 @@ static void timbuart_rx_chars(struct uart_port *port)
 
while (ioread32(port->membase + TIMBUART_ISR) & RXDP) {
u8 ch = ioread8(port->membase + TIMBUART_RXFIFO);
+
port->icount.rx++;
tty_insert_flip_char(tport, ch, TTY_NORMAL);
}
@@ -199,6 +202,7 @@ static void timbuart_tasklet(unsigned long arg)
 static unsigned int timbuart_get_mctrl(struct uart_port *port)
 {
u8 cts = ioread8(port->membase + TIMBUART_CTRL);
+
dev_dbg(port->dev, "%s - cts %x\n", __func__, cts);
 
if (cts & TIMBUART_CTRL_CTS)
@@ -293,7 +297,8 @@ static void timbuart_set_termios(struct uart_port *port,
baud = baudrates[bindex];
 
/* The serial layer calls into this once with old = NULL when setting
-  up initially */
+* up initially
+*/
if (old)
tty_termios_copy_hw(termios, old);
tty_termios_encode_baud_rate(termios, baud, baud);
@@ -500,4 +505,3 @@ static int timbuart_remove(struct platform_device *dev)
 MODULE_DESCRIPTION("Timberdale UART driver");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:timb-uart");
-
-- 
1.9.1



[PATCH 07/41] drivers: tty: serial: sb1250-duart: include instead of

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warning:

WARNING: Use #include  instead of 
#41: FILE: drivers/tty/serial/sb1250-duart.c:41:
+#include 

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index 655961c..b4342c8 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -38,7 +38,7 @@
 #include 
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
-- 
1.9.1



[PATCH 28/41] drivers: tty: serial: sunzilog: fix includes

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warning:

WARNING: Use #include  instead of 
#38: FILE: drivers/tty/serial/sunzilog.c:38:
+#include 

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sunzilog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index 17b0520..85edb0d 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -34,8 +34,8 @@
 #endif
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 #include 
-- 
1.9.1



[PATCH 09/41] drivers: tty: serial: sb1250-duart: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index 227af87..1184226 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -658,7 +658,7 @@ static void sbd_release_port(struct uart_port *uport)
 
if(refcount_dec_and_test(>map_guard))
release_mem_region(duart->mapctrl, DUART_CHANREG_SPACING);
-   release_mem_region(uport->mapbase, DUART_CHANREG_SPACING);
+   release_mem_region(uport->mapbase, uport->mapsize);
 }
 
 static int sbd_map_port(struct uart_port *uport)
@@ -668,7 +668,7 @@ static int sbd_map_port(struct uart_port *uport)
 
if (!uport->membase)
uport->membase = ioremap_nocache(uport->mapbase,
-DUART_CHANREG_SPACING);
+uport->mapsize);
if (!uport->membase) {
dev_err(uport->dev, "Cannot map MMIO (base)\n");
return -ENOMEM;
@@ -693,7 +693,7 @@ static int sbd_request_port(struct uart_port *uport)
struct sbd_duart *duart = to_sport(uport)->duart;
int ret = 0;
 
-   if (!request_mem_region(uport->mapbase, DUART_CHANREG_SPACING,
+   if (!request_mem_region(uport->mapbase, uport->mapsize,
"sb1250-duart")) {
pr_err(err);
return -EBUSY;
@@ -716,7 +716,7 @@ static int sbd_request_port(struct uart_port *uport)
}
}
if (ret) {
-   release_mem_region(uport->mapbase, DUART_CHANREG_SPACING);
+   release_mem_region(uport->mapbase, uport->mapsize);
return ret;
}
return 0;
@@ -812,6 +812,7 @@ static void __init sbd_probe_duarts(void)
uport->ops  = _ops;
uport->line = line;
uport->mapbase  = SBD_CHANREGS(line);
+   uport->mapsize  = DUART_CHANREG_SPACING;
}
}
 }
-- 
1.9.1



[PATCH 20/41] drivers: tty: serial: cpm_uart: use dev_err()/dev_warn() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err()/dev_warn() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 6 +++---
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index b929c7a..374b8bb 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -265,7 +265,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
 * later, which will be the next rx-interrupt or a timeout
 */
if (tty_buffer_request_room(tport, i) < i) {
-   printk(KERN_WARNING "No room in flip buffer\n");
+   dev_warn(port->dev, "No room in flip buffer\n");
return;
}
 
@@ -1155,7 +1155,7 @@ static int cpm_uart_init_port(struct device_node *np,
if (!pinfo->clk) {
data = of_get_property(np, "fsl,cpm-brg", );
if (!data || len != 4) {
-   printk(KERN_ERR "CPM UART %pOFn has no/invalid "
+   dev_err(port->dev, "CPM UART %pOFn has no/invalid "
"fsl,cpm-brg property.\n", np);
return -EINVAL;
}
@@ -1164,7 +1164,7 @@ static int cpm_uart_init_port(struct device_node *np,
 
data = of_get_property(np, "fsl,cpm-command", );
if (!data || len != 4) {
-   printk(KERN_ERR "CPM UART %pOFn has no/invalid "
+   dev_err(port->dev, "CPM UART %pOFn has no/invalid "
"fsl,cpm-command property.\n", np);
return -EINVAL;
}
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 6a1cd03..ef1ae08 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -67,7 +67,7 @@ void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
return pram;
 
if (len != 2) {
-   printk(KERN_WARNING "cpm_uart[%d]: device tree references "
+   dev_warn(port->dev, "cpm_uart[%d]: device tree references "
"SMC pram, using boot loader/wrapper pram mapping. "
"Please fix your device tree to reference the pram "
"base register instead.\n",
-- 
1.9.1



[PATCH 10/41] drivers: tty: serial: sb1250-duart: fix missing parentheses

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warning:

ERROR: Macros with complex values should be enclosed in parentheses
#911: FILE: drivers/tty/serial/sb1250-duart.c:911:
+#define SERIAL_SB1250_DUART_CONSOLE_console

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index 1184226..ec74f09 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -908,7 +908,7 @@ static int __init sbd_serial_console_init(void)
 
 console_initcall(sbd_serial_console_init);
 
-#define SERIAL_SB1250_DUART_CONSOLE_console
+#define SERIAL_SB1250_DUART_CONSOLE(_console)
 #else
 #define SERIAL_SB1250_DUART_CONSOLENULL
 #endif /* CONFIG_SERIAL_SB1250_DUART_CONSOLE */
-- 
1.9.1



[PATCH 08/41] drivers: tty: serial: sb1250-duart: fix checkpatch warning on printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
checkpatch complaints:

WARNING: printk() should include KERN_ facility level
#698: FILE: drivers/tty/serial/sb1250-duart.c:698:
+   printk(err);

WARNING: printk() should include KERN_ facility level
#706: FILE: drivers/tty/serial/sb1250-duart.c:706:
+   printk(err);

Even though it's a false alarm here (the string is already prefixed
w/ KERN_ERR), it's nicer to use pr_err() here, which also makes
checkpatch happy.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index b4342c8..227af87 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -689,13 +689,13 @@ static int sbd_map_port(struct uart_port *uport)
 
 static int sbd_request_port(struct uart_port *uport)
 {
-   const char *err = KERN_ERR "sbd: Unable to reserve MMIO resource\n";
+   const char *err = "sbd: Unable to reserve MMIO resource\n";
struct sbd_duart *duart = to_sport(uport)->duart;
int ret = 0;
 
if (!request_mem_region(uport->mapbase, DUART_CHANREG_SPACING,
"sb1250-duart")) {
-   printk(err);
+   pr_err(err);
return -EBUSY;
}
refcount_inc(>map_guard);
@@ -703,7 +703,7 @@ static int sbd_request_port(struct uart_port *uport)
if (!request_mem_region(duart->mapctrl, DUART_CHANREG_SPACING,
"sb1250-duart")) {
refcount_dec(>map_guard);
-   printk(err);
+   pr_err(err);
ret = -EBUSY;
}
}
-- 
1.9.1



[PATCH 22/41] drivers: tty: serial: cpm_uart: fix logging calls

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings by using pr_err():

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#109: FILE: drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c:109:
+   printk(KERN_ERR

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#128: FILE: drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c:128:
+   printk(KERN_ERR

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
+   printk(KERN_ERR

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
+   printk(KERN_ERR

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 6 ++
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index 56fc527..aed61e9 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
@@ -71,8 +71,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned 
int is_con)
dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
dp_offset = cpm_dpalloc(dpmemsz, 8);
if (IS_ERR_VALUE(dp_offset)) {
-   printk(KERN_ERR
-  "cpm_uart_cpm1.c: could not allocate buffer 
descriptors\n");
+   pr_err("cpm_uart_cpm1.c: could not allocate buffer 
descriptors\n");
return -ENOMEM;
}
dp_mem = cpm_dpram_addr(dp_offset);
@@ -90,8 +89,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned 
int is_con)
 
if (mem_addr == NULL) {
cpm_dpfree(dp_offset);
-   printk(KERN_ERR
-  "cpm_uart_cpm1.c: could not allocate coherent memory\n");
+   pr_err("cpm_uart_cpm1.c: could not allocate coherent memory\n");
return -ENOMEM;
}
 
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 40cfcf4..a0fccda 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -106,8 +106,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned 
int is_con)
dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
dp_offset = cpm_dpalloc(dpmemsz, 8);
if (IS_ERR_VALUE(dp_offset)) {
-   printk(KERN_ERR
-  "cpm_uart_cpm.c: could not allocate buffer 
descriptors\n");
+   pr_err("cpm_uart_cpm.c: could not allocate buffer 
descriptors\n");
return -ENOMEM;
}
 
@@ -125,8 +124,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned 
int is_con)
 
if (mem_addr == NULL) {
cpm_dpfree(dp_offset);
-   printk(KERN_ERR
-  "cpm_uart_cpm.c: could not allocate coherent memory\n");
+   pr_err("cpm_uart_cpm.c: could not allocate coherent memory\n");
return -ENOMEM;
}
 
-- 
1.9.1



[PATCH 15/41] drivers: tty: serial: uartlite: fix use fix bare 'unsigned'

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#562: FILE: drivers/tty/serial/uartlite.c:562:
+   unsigned retries = 100;

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#574: FILE: drivers/tty/serial/uartlite.c:574:
+const char *s, unsigned n)

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/uartlite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 4c28600..6f79353 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -559,7 +559,7 @@ static void early_uartlite_putc(struct uart_port *port, int 
c)
 * we'll never timeout on a working UART.
 */
 
-   unsigned retries = 100;
+   unsigned int retries = 100;
/* read status bit - 0x8 offset */
while (--retries && (readl(port->membase + 8) & (1 << 3)))
;
@@ -571,7 +571,7 @@ static void early_uartlite_putc(struct uart_port *port, int 
c)
 }
 
 static void early_uartlite_write(struct console *console,
-const char *s, unsigned n)
+const char *s, unsigned int n)
 {
struct earlycon_device *device = console->data;
uart_console_write(>port, s, n, early_uartlite_putc);
-- 
1.9.1



[PATCH 14/41] drivers: tty: serial: uartlite: remove unnecessary braces

2019-04-27 Thread Enrico Weigelt, metux IT consult
checkpatch complains:

WARNING: braces {} are not necessary for any arm of this statement
#489: FILE: drivers/tty/serial/uartlite.c:489:
+   if (oops_in_progress) {
[...]
+   } else
[...]

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/uartlite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index c322ab6..4c28600 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -486,9 +486,9 @@ static void ulite_console_write(struct console *co, const 
char *s,
unsigned int ier;
int locked = 1;
 
-   if (oops_in_progress) {
+   if (oops_in_progress)
locked = spin_trylock_irqsave(>lock, flags);
-   } else
+   else
spin_lock_irqsave(>lock, flags);
 
/* save and disable interrupt */
-- 
1.9.1



[PATCH 17/41] drivers: tty: serial: apbuart: fix logging calls

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: Prefer using '"%s...", __func__' to using 'apbuart_console_setup', 
this function's name, in a string
#491: FILE: drivers/tty/serial/apbuart.c:491:
+   pr_debug("apbuart_console_setup co=%p, co->index=%i, options=%s\n",

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
#661: FILE: drivers/tty/serial/apbuart.c:661:
+   printk(KERN_INFO "Serial: GRLIB APBUART driver\n");

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#666: FILE: drivers/tty/serial/apbuart.c:666:
+   printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#673: FILE: drivers/tty/serial/apbuart.c:673:
+   printk(KERN_ERR

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/apbuart.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 60cd133..d2b86f7 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -482,8 +482,8 @@ static int __init apbuart_console_setup(struct console *co, 
char *options)
int parity = 'n';
int flow = 'n';
 
-   pr_debug("apbuart_console_setup co=%p, co->index=%i, options=%s\n",
-co, co->index, options);
+   pr_debug("%s() co=%p, co->index=%i, options=%s\n",
+__func__, co, co->index, options);
 
/*
 * Check whether an invalid uart number has been specified, and
@@ -650,21 +650,20 @@ static int __init grlib_apbuart_init(void)
if (ret)
return ret;
 
-   printk(KERN_INFO "Serial: GRLIB APBUART driver\n");
+   pr_info("Serial: GRLIB APBUART driver\n");
 
ret = uart_register_driver(_apbuart_driver);
 
if (ret) {
-   printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",
-  __FILE__, ret);
+   pr_err("%s: uart_register_driver failed (%i)\n",
+  __func__, ret);
return ret;
}
 
ret = platform_driver_register(_apbuart_of_driver);
if (ret) {
-   printk(KERN_ERR
-  "%s: platform_driver_register failed (%i)\n",
-  __FILE__, ret);
+   pr_err("%s: platform_driver_register failed (%i)\n",
+  __func__, ret);
uart_unregister_driver(_apbuart_driver);
return ret;
}
-- 
1.9.1



[PATCH 21/41] drivers: tty: serial: cpm_uart: fix includes

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fixing checkpatch warning:

WARNING: Use #include  instead of 
#25: FILE: drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c:25:
+#include 

WARNING: Use #include  instead of 
+#include 

WARNING: Use #include  instead of 
+#include 

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 4 ++--
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 374b8bb..c831d31 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -33,10 +33,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
-#include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index ef1ae08..40cfcf4 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -21,8 +21,8 @@
 #include 
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 #include 
-- 
1.9.1



[PATCH 37/41] drivers: tty: serial: 8250: simplify io resource size computation

2019-04-27 Thread Enrico Weigelt, metux IT consult
Simpily io resource size computation by setting mapsize field.

Some of the special cases handled by serial8250_port_size() can be
simplified by putting this data to corresponding platform data
or probe function.

Signed-off-by: Enrico Weigelt 
---
 arch/mips/alchemy/common/platform.c | 1 +
 drivers/tty/serial/8250/8250.h  | 1 +
 drivers/tty/serial/8250/8250_of.c   | 1 +
 drivers/tty/serial/8250/8250_port.c | 6 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/mips/alchemy/common/platform.c 
b/arch/mips/alchemy/common/platform.c
index 1454d9f..226096d 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -51,6 +51,7 @@ static void alchemy_8250_pm(struct uart_port *port, unsigned 
int state,
 #define PORT(_base, _irq)  \
{   \
.mapbase= _base,\
+   .mapsize= 0x1000,   \
.irq= _irq, \
.regshift   = 2,\
.iotype = UPIO_AU,  \
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 89e3f09..7984aad 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -105,6 +105,7 @@ struct serial8250_config {
 
 #define SERIAL8250_PORT(_base, _irq) SERIAL8250_PORT_FLAGS(_base, _irq, 0)
 
+#define SERIAL_RT2880_IOSIZE   0x100
 
 static inline int serial_in(struct uart_8250_port *up, int offset)
 {
diff --git a/drivers/tty/serial/8250/8250_of.c 
b/drivers/tty/serial/8250/8250_of.c
index 0277479c..08157a1 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -185,6 +185,7 @@ static int of_platform_serial_setup(struct platform_device 
*ofdev,
 
case PORT_RT2880:
port->iotype = UPIO_AU;
+   port->mapsize = SERIAL_RT2880_IOSIZE;
break;
}
 
diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index d09af4c..51d6076 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2833,11 +2833,7 @@ unsigned int serial8250_port_size(struct uart_8250_port 
*pt)
 {
if (pt->port.mapsize)
return pt->port.mapsize;
-   if (pt->port.iotype == UPIO_AU) {
-   if (pt->port.type == PORT_RT2880)
-   return 0x100;
-   return 0x1000;
-   }
+
if (is_omap1_8250(pt))
return 0x16 << pt->port.regshift;
 
-- 
1.9.1



[PATCH 39/41] drivers: tty: serial: pmac_zilog: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/pmac_zilog.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index bcb5bf7..1fef014 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -88,6 +88,8 @@
 #define PMACZILOG_NAME "ttyPZ"
 #endif
 
+#define PMZ_MAPSIZE0x1000
+
 #define pmz_debug(fmt, arg...) pr_debug("ttyPZ%d: " fmt, uap->port.line, ## 
arg)
 #define pmz_error(fmt, arg...) pr_err("ttyPZ%d: " fmt, uap->port.line, ## arg)
 #define pmz_info(fmt, arg...)  pr_info("ttyPZ%d: " fmt, uap->port.line, ## arg)
@@ -1411,7 +1413,8 @@ static int __init pmz_init_port(struct uart_pmac_port 
*uap)
if (of_address_to_resource(np, 0, _ports))
return -ENODEV;
uap->port.mapbase = r_ports.start;
-   uap->port.membase = ioremap(uap->port.mapbase, 0x1000);
+   uap->port.mapsize = PMZ_MAPSIZE;
+   uap->port.membase = ioremap(uap->port.mapbase, uap->port.mapsize);
 
uap->control_reg = uap->port.membase;
uap->data_reg = uap->control_reg + 0x10;
@@ -1709,6 +1712,7 @@ static int __init pmz_init_port(struct uart_pmac_port 
*uap)
return -ENODEV;
 
uap->port.mapbase  = r_ports->start;
+   uap->port.mapsize  = PMZ_MAPSIZE;
uap->port.membase  = (unsigned char __iomem *) r_ports->start;
uap->port.iotype   = UPIO_MEM;
uap->port.irq  = irq;
-- 
1.9.1



[PATCH 38/41] drivers: tty: serial: xilinx_uartps: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/xilinx_uartps.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c 
b/drivers/tty/serial/xilinx_uartps.c
index 74089f5..cf8ca66 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -953,15 +953,15 @@ static int cdns_uart_verify_port(struct uart_port *port,
  */
 static int cdns_uart_request_port(struct uart_port *port)
 {
-   if (!request_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE,
+   if (!request_mem_region(port->mapbase, port->mapsize,
 CDNS_UART_NAME)) {
return -ENOMEM;
}
 
-   port->membase = ioremap(port->mapbase, CDNS_UART_REGISTER_SPACE);
+   port->membase = ioremap(port->mapbase, port->mapsize);
if (!port->membase) {
dev_err(port->dev, "Unable to map registers\n");
-   release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE);
+   release_mem_region(port->mapbase, port->mapsize);
return -ENOMEM;
}
return 0;
@@ -976,7 +976,7 @@ static int cdns_uart_request_port(struct uart_port *port)
  */
 static void cdns_uart_release_port(struct uart_port *port)
 {
-   release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE);
+   release_mem_region(port->mapbase, port->mapsize);
iounmap(port->membase);
port->membase = NULL;
 }
@@ -1627,6 +1627,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
 * and triggers invocation of the config_port() entry point.
 */
port->mapbase = res->start;
+   port->mapsize = CDNS_UART_REGISTER_SPACE;
port->irq = irq;
port->dev = >dev;
port->uartclk = clk_get_rate(cdns_uart_data->uartclk);
-- 
1.9.1



[PATCH 31/41] drivers: tty: serial: ioc4_serial: use pr_*() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
This fixes a bunch of checkpatch warnings:

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#930: FILE: drivers/tty/serial/ioc4_serial.c:930:
+   printk(KERN_ERR

WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then 
dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#945: FILE: drivers/tty/serial/ioc4_serial.c:945:
+   printk(KERN_ERR

WARNING: printk() should include KERN_ facility level
#1028: FILE: drivers/tty/serial/ioc4_serial.c:1028:
+   printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x "

WARNING: space prohibited between function name and open parenthesis '('
#1028: FILE: drivers/tty/serial/ioc4_serial.c:1028:
+   printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x "

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
#1064: FILE: drivers/tty/serial/ioc4_serial.c:1064:
+   printk(KERN_INFO "IOC4 firmware revision %d\n", ioc4_revid);

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#1066: FILE: drivers/tty/serial/ioc4_serial.c:1066:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#1080: FILE: drivers/tty/serial/ioc4_serial.c:1080:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#1870: FILE: drivers/tty/serial/ioc4_serial.c:1870:
+   printk(KERN_WARNING "IOC4 serial: "

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2170: FILE: drivers/tty/serial/ioc4_serial.c:2170:
+   printk(KERN_WARNING "IOC4 serial: "

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2796: FILE: drivers/tty/serial/ioc4_serial.c:2796:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2804: FILE: drivers/tty/serial/ioc4_serial.c:2804:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2818: FILE: drivers/tty/serial/ioc4_serial.c:2818:
+   printk(KERN_WARNING "ioc4_attach_one"

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2828: FILE: drivers/tty/serial/ioc4_serial.c:2828:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2861: FILE: drivers/tty/serial/ioc4_serial.c:2861:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2917: FILE: drivers/tty/serial/ioc4_serial.c:2917:
+   printk(KERN_WARNING

WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then 
dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
#2923: FILE: drivers/tty/serial/ioc4_serial.c:2923:
+   printk(KERN_WARNING

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/ioc4_serial.c | 39 +++
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 21c1b8f..4ab67f1 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -927,8 +927,7 @@ static void handle_dma_error_intr(void *arg, uint32_t 
other_ir)
writel(hooks->intr_dma_error, >ip_mem->other_ir.raw);
 
if (readl(>ip_mem->pci_err_addr_l.raw) & IOC4_PCI_ERR_ADDR_VLD) {
-   printk(KERN_ERR
-   "PCI error address is 0x%llx, "
+   pr_err("PCI error address is 0x%llx, "
"master is serial port %c %s\n",
 (((uint64_t)readl(>ip_mem->pci_err_addr_h)
 << 32)
@@ -942,8 +941,7 @@ static void handle_dma_error_intr(void *arg, uint32_t 
other_ir)
 
if (readl(>ip_mem->pci_err_addr_l.raw)
& IOC4_PCI_ERR_ADDR_MUL_ERR) {
-   printk(KERN_ERR
-   "Multiple errors occurred\n");
+   

[PATCH 23/41] drivers: tty: serial: cpm_uart: fix styling issues

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch errors:

ERROR: else should follow close brace '}'
#121: FILE: drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c:121:
+   }
+   else

WARNING: line over 80 characters
#150: FILE: drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c:150:
+pinfo->tx_fifosize), (void __force 
*)pinfo->mem_addr,

WARNING: Block comments should align the * on each line
#66: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:66:
+ * Check, if transmit buffers are processed
+*/

WARNING: braces {} are not necessary for any arm of this statement
#170: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:170:
+   if (IS_SMC(pinfo)) {
[...]
+   } else {
[...]

WARNING: labels should not be indented
#292: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:292:
+ error_return:

ERROR: code indent should use tabs where possible
#299: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:299:
+^I^IBD_SC_OV | BD_SC_ID);$

WARNING: labels should not be indented
#319: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:319:
+  handle_error:

WARNING: line over 80 characters
#423: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:423:
+   setbits32(>sccp->scc_gsmrl, (SCC_GSMRL_ENR | 
SCC_GSMRL_ENT));

ERROR: space required before the open parenthesis '('
#451: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:451:
+   while(!cpm_uart_tx_empty(port)) {

WARNING: Missing a blank line after declarations
#462: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:462:
+   smc_t __iomem *smcp = pinfo->smcp;
+   clrbits16(>smc_smcmr, SMCMR_REN | SMCMR_TEN);

WARNING: line over 80 characters
#466: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:466:
+   clrbits32(>scc_gsmrl, SCC_GSMRL_ENR | 
SCC_GSMRL_ENT);

WARNING: Missing a blank line after declarations
#466: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:466:
+   scc_t __iomem *sccp = pinfo->sccp;
+   clrbits32(>scc_gsmrl, SCC_GSMRL_ENR | 
SCC_GSMRL_ENT);

ERROR: code indent should use tabs where possible
#484: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:484:
+ struct ktermios *termios,$

WARNING: please, no spaces at the start of a line
#484: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:484:
+ struct ktermios *termios,$

ERROR: code indent should use tabs where possible
#485: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:485:
+ struct ktermios *old)$

WARNING: please, no spaces at the start of a line
#485: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:485:
+ struct ktermios *old)$

WARNING: line over 80 characters
#624: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:624:
+   /* Output in *one* operation, so we don't interrupt RX/TX if 
they

WARNING: Block comments use a trailing */ on a separate line
#625: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:625:
+* were already enabled. */

WARNING: line over 80 characters
#629: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:629:
+   out_be16(>sccup->scc_genscc.scc_mrblr, 
pinfo->rx_fifosize);

WARNING: line over 80 characters
#773: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:773:
+   mem_addr = pinfo->mem_addr + L1_CACHE_ALIGN(pinfo->rx_nrfifos * 
pinfo->rx_fifosize);

ERROR: code indent should use tabs where possible
#797: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:797:
+^I (u8 __iomem *)pinfo->rx_bd_base - DPRAM_BASE);$

ERROR: code indent should use tabs where possible
#799: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:799:
+^I (u8 __iomem *)pinfo->tx_bd_base - DPRAM_BASE);$

ERROR: code indent should use tabs where possible
#836: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:836:
+^I SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);$

ERROR: code indent should use tabs where possible
#859: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:859:
+^I (u8 __iomem *)pinfo->rx_bd_base - DPRAM_BASE);$

ERROR: code indent should use tabs where possible
#861: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:861:
+^I (u8 __iomem *)pinfo->tx_bd_base - DPRAM_BASE);$

WARNING: space prohibited between function name and open parenthesis '('
#866: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:866:
+#if defined (CONFIG_I2C_SPI_SMC1_UCODE_PATCH)

WARNING: line over 80 characters
#921: FILE: drivers/tty/serial/cpm_uart/cpm_uart_core.c:921:
+   

[PATCH 32/41] drivers: tty: serial: 21285: define's for address/size, use mapsize field

2019-04-27 Thread Enrico Weigelt, metux IT consult
Instead of hardcoding raw numbers, add define's for the mmio address/size.
Also fill the mapsize field and use it on mem request/release calls, for
more consistency and allowing generic helpers to be used later.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/21285.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c
index 32b3acf..90684cd 100644
--- a/drivers/tty/serial/21285.c
+++ b/drivers/tty/serial/21285.c
@@ -27,6 +27,9 @@
 #define SERIAL_21285_MAJOR 204
 #define SERIAL_21285_MINOR 4
 
+#define SERIAL_21285_ADDRESS   0x42000160
+#define SERIAL_21285_SIZE  32
+
 #define RXSTAT_DUMMY_READ  0x8000
 #define RXSTAT_FRAME   (1 << 0)
 #define RXSTAT_PARITY  (1 << 1)
@@ -305,12 +308,14 @@ static const char *serial21285_type(struct uart_port 
*port)
 
 static void serial21285_release_port(struct uart_port *port)
 {
-   release_mem_region(port->mapbase, 32);
+   release_mem_region(port->mapbase, port->mapsize);
 }
 
 static int serial21285_request_port(struct uart_port *port)
 {
-   return request_mem_region(port->mapbase, 32, serial21285_name)
+   return request_mem_region(port->mapbase,
+ port->mapsize,
+ serial21285_name)
 != NULL ? 0 : -EBUSY;
 }
 
@@ -354,7 +359,8 @@ static int serial21285_verify_port(struct uart_port *port, 
struct serial_struct
 };
 
 static struct uart_port serial21285_port = {
-   .mapbase= 0x42000160,
+   .mapbase= SERIAL_21285_BASE,
+   .mapsize= SERIAL_21285_SIZE,
.iotype = UPIO_MEM,
.irq= 0,
.fifosize   = 16,
-- 
1.9.1



[PATCH 29/41] drivers: tty: serial: sunzilog: cleanup logging

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warning:

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
#1238: FILE: drivers/tty/serial/sunzilog.c:1238:
+   printk(KERN_INFO "Console: ttyS%d (SunZilog zs%d)\n",

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sunzilog.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index 85edb0d..dba723c 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -1235,7 +1235,7 @@ static int __init sunzilog_console_setup(struct console 
*con, char *options)
if (up->port.type != PORT_SUNZILOG)
return -1;
 
-   printk(KERN_INFO "Console: ttyS%d (SunZilog zs%d)\n",
+   pr_info("Console: ttyS%d (SunZilog zs%d)\n",
   (sunzilog_reg.minor - 64) + con->index, con->index);
 
/* Get firmware console settings.  */
@@ -1615,9 +1615,8 @@ static int __init sunzilog_init(void)
while (up) {
struct zilog_channel __iomem *channel;
 
-   /* printk(KERN_INFO
-*"Enable IRQ for ZILOG Hardware %p\n",
-*up);
+   /* pr_info("Enable IRQ for ZILOG Hardware %p\n",
+* up);
 */
channel  = ZILOG_CHANNEL_FROM_PORT(>port);
up->flags   |= SUNZILOG_FLAG_ISR_HANDLER;
@@ -1655,9 +1654,8 @@ static void __exit sunzilog_exit(void)
while (up) {
struct zilog_channel __iomem *channel;
 
-   /* printk(KERN_INFO
-*"Disable IRQ for ZILOG Hardware %p\n",
-*up);
+   /* pr_info("Disable IRQ for ZILOG Hardware %p\n",
+* up);
 */
channel  = ZILOG_CHANNEL_FROM_PORT(>port);
up->flags   &= ~SUNZILOG_FLAG_ISR_HANDLER;
-- 
1.9.1



[PATCH 03/41] drivers: tty: serial: dz: fix missing parentheses

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warning:

  ERROR: Macros with complex values should be enclosed in parentheses
  #912: FILE: dz.c:912:
  +#define SERIAL_DZ_CONSOLE_console

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/dz.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index fd4f0cc..b3e9313 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -909,7 +909,7 @@ static int __init dz_serial_console_init(void)
 
 console_initcall(dz_serial_console_init);
 
-#define SERIAL_DZ_CONSOLE  _console
+#define SERIAL_DZ_CONSOLE  (_console)
 #else
 #define SERIAL_DZ_CONSOLE  NULL
 #endif /* CONFIG_SERIAL_DZ_CONSOLE */
-- 
1.9.1



[PATCH 26/41] drivers: tty: serial: sunzilog: use dev_info() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_info() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sunzilog.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index bc7af8b..6285bba 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -1489,14 +1489,12 @@ static int zs_probe(struct platform_device *op)
}
uart_inst++;
} else {
-   printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) "
+   dev_info(>dev, "Keyboard at MMIO 0x%llx (irq = %d) "
   "is a %s\n",
-  dev_name(>dev),
   (unsigned long long) up[0].port.mapbase,
   op->archdata.irqs[0], sunzilog_type([0].port));
-   printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) "
+   dev_info(>dev, "Mouse at MMIO 0x%llx (irq = %d) "
   "is a %s\n",
-  dev_name(>dev),
   (unsigned long long) up[1].port.mapbase,
   op->archdata.irqs[0], sunzilog_type([1].port));
kbm_inst++;
-- 
1.9.1



serial drivers polishing

2019-04-27 Thread Enrico Weigelt, metux IT consult
Hello folks,


here's another attempt of polishing the serial drivers:

* lots of minor cleanups to make checkpatch happier
  (eg. formatting, includes, inttypes, ...)

* use appropriate logging helpers instead of printk()

* consequent use of mapsize/mapbase fields:
  the basic idea is, all drivers should fill mapbase/mapbase fields at
  init time and later only use those fields, instead of hardcoded values
  (later on, we can add generic helpers for the map/unmap stuff, etc)

* untwisting serial8250_port_size() at all:
  move the iomem size probing to initialization time, move out some
  platform specific magic to corresponding platform code, etc.


Unfortunately, I don't have the actual hardware to really test all
the code, so please let me know if there's something broken in here.


have fun,

--mtx



[PATCH 05/41] drivers: tty: serial: dz: use pr_info() instead of incomplete printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix the checkpatch warning:

WARNING: printk() should include KERN_ facility level
#934: FILE: dz.c:934:
+   printk("%s%s\n", dz_name, dz_version);

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/dz.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 559d076..e2670c4 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -931,7 +931,7 @@ static int __init dz_init(void)
if (IOASIC)
return -ENXIO;
 
-   printk("%s%s\n", dz_name, dz_version);
+   pr_info("%s%s\n", dz_name, dz_version);
 
dz_init_ports();
 
-- 
1.9.1



[PATCH 12/41] drivers: tty: serial: uartlite: use dev_dbg() instead of pr_debug()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_dbg() instead of pr_debg() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/uartlite.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index b8b912b..44d65bd 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -352,7 +352,8 @@ static int ulite_request_port(struct uart_port *port)
struct uartlite_data *pdata = port->private_data;
int ret;
 
-   pr_debug("ulite console: port=%p; port->mapbase=%llx\n",
+   dev_dbg(port->dev,
+   "ulite console: port=%p; port->mapbase=%llx\n",
 port, (unsigned long long) port->mapbase);
 
if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
@@ -519,7 +520,8 @@ static int ulite_console_setup(struct console *co, char 
*options)
 
/* Has the device been initialized yet? */
if (!port->mapbase) {
-   pr_debug("console on ttyUL%i not present\n", co->index);
+   dev_dbg(port->dev, "console on ttyUL%i not present\n",
+   co->index);
return -ENODEV;
}
 
-- 
1.9.1



[PATCH 11/41] drivers: tty: serial: sb1250-duart: fix formatting error

2019-04-27 Thread Enrico Weigelt, metux IT consult
checkpatch complains:

ERROR: space required before the open parenthesis '('
#659: FILE: drivers/tty/serial/sb1250-duart.c:659:
+   if(refcount_dec_and_test(>map_guard))

Just add this missing space to make checkpatch happy.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/sb1250-duart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sb1250-duart.c 
b/drivers/tty/serial/sb1250-duart.c
index ec74f09..0023ed0 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -656,7 +656,7 @@ static void sbd_release_port(struct uart_port *uport)
iounmap(uport->membase);
uport->membase = NULL;
 
-   if(refcount_dec_and_test(>map_guard))
+   if (refcount_dec_and_test(>map_guard))
release_mem_region(duart->mapctrl, DUART_CHANREG_SPACING);
release_mem_region(uport->mapbase, uport->mapsize);
 }
-- 
1.9.1



[PATCH 19/41] drivers: tty: serial: apbuart: fix code formatting

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: line over 80 characters
#9: FILE: drivers/tty/serial/apbuart.c:9:
+ *  Copyright (C) 2006 Daniel Hellstrom , Aeroflex 
Gaisler AB

WARNING: line over 80 characters
#11: FILE: drivers/tty/serial/apbuart.c:11:
+ *  Copyright (C) 2009 Kristoffer Glembo , 
Aeroflex Gaisler AB

WARNING: line over 80 characters
#16: FILE: drivers/tty/serial/apbuart.c:16:
+#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) && 
defined(CONFIG_MAGIC_SYSRQ)

WARNING: labels should not be indented
#122: FILE: drivers/tty/serial/apbuart.c:122:
+ ignore_char:

WARNING: Missing a blank line after declarations
#186: FILE: drivers/tty/serial/apbuart.c:186:
+   unsigned int status = UART_GET_STATUS(port);
+   return status & UART_STATUS_THE ? TIOCSER_TEMT : 0;

WARNING: Missing a blank line after declarations
#322: FILE: drivers/tty/serial/apbuart.c:322:
+   int ret = 0;
+   if (ser->type != PORT_UNKNOWN && ser->type != PORT_APBUART)

WARNING: Missing a blank line after declarations
#427: FILE: drivers/tty/serial/apbuart.c:427:
+   unsigned int status;
+   do {

WARNING: Missing a blank line after declarations
#463: FILE: drivers/tty/serial/apbuart.c:463:
+   unsigned int quot, status;
+   status = UART_GET_STATUS(port);

WARNING: line over 80 characters
#627: FILE: drivers/tty/serial/apbuart.c:627:
+   port->membase = ioremap(addr, sizeof(struct 
grlib_apbuart_regs_map));

WARNING: line over 80 characters
#634: FILE: drivers/tty/serial/apbuart.c:634:
+   port->fifosize = apbuart_scan_fifo_size((struct uart_port *) 
port, line);

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/apbuart.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 89e19b6..515a562 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -6,12 +6,15 @@
  *
  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
  *  Copyright (C) 2003 Konrad Eisele 
- *  Copyright (C) 2006 Daniel Hellstrom , Aeroflex Gaisler 
AB
+ *  Copyright (C) 2006 Daniel Hellstrom ,
+ * Aeroflex Gaisler AB
  *  Copyright (C) 2008 Gilead Kutnick 
- *  Copyright (C) 2009 Kristoffer Glembo , Aeroflex 
Gaisler AB
+ *  Copyright (C) 2009 Kristoffer Glembo ,
+ * Aeroflex Gaisler AB
  */
 
-#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) && 
defined(CONFIG_MAGIC_SYSRQ)
+#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) \
+   && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
 #endif
 
@@ -116,8 +119,7 @@ static void apbuart_rx_chars(struct uart_port *port)
 
uart_insert_char(port, rsr, UART_STATUS_OE, ch, flag);
 
-
- ignore_char:
+ignore_char:
status = UART_GET_STATUS(port);
}
 
@@ -181,6 +183,7 @@ static irqreturn_t apbuart_int(int irq, void *dev_id)
 static unsigned int apbuart_tx_empty(struct uart_port *port)
 {
unsigned int status = UART_GET_STATUS(port);
+
return status & UART_STATUS_THE ? TIOCSER_TEMT : 0;
 }
 
@@ -317,6 +320,7 @@ static int apbuart_verify_port(struct uart_port *port,
   struct serial_struct *ser)
 {
int ret = 0;
+
if (ser->type != PORT_UNKNOWN && ser->type != PORT_APBUART)
ret = -EINVAL;
if (ser->irq < 0 || ser->irq >= NR_IRQS)
@@ -422,6 +426,7 @@ static void apbuart_flush_fifo(struct uart_port *port)
 static void apbuart_console_putchar(struct uart_port *port, int ch)
 {
unsigned int status;
+
do {
status = UART_GET_STATUS(port);
} while (!UART_TX_READY(status));
@@ -458,6 +463,7 @@ static void apbuart_console_putchar(struct uart_port *port, 
int ch)
if (UART_GET_CTRL(port) & (UART_CTRL_RE | UART_CTRL_TE)) {
 
unsigned int quot, status;
+
status = UART_GET_STATUS(port);
 
*parity = 'n';
@@ -622,14 +628,16 @@ static int __init grlib_apbuart_configure(void)
port = _apbuart_ports[line];
 
port->mapbase = addr;
-   port->membase = ioremap(addr, sizeof(struct 
grlib_apbuart_regs_map));
+   port->membase = ioremap(addr,
+   sizeof(struct grlib_apbuart_regs_map));
port->irq = 0;
port->iotype = UPIO_MEM;
port->ops = _apbuart_ops;
port->flags = UPF_BOOT_AUTOCONF;
port->line = line;
port->uartclk = *freq_hz;
-   port->fifosize = apbuart_scan_fifo_size((struct uart_port *) 
port, line);
+   port->fifosize = apbuart_scan_fifo_size(
+   (struct uart_port *) port, line);
line++;
 
/* We support maximum UART_NR uarts 

[PATCH 02/41] drivers: tty: serial: dz: include instead of

2019-04-27 Thread Enrico Weigelt, metux IT consult
fixing checkpatch warning:

  WARNING: Use #include  instead of 
  #55: FILE: dz.c:55:
  +#include 

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/dz.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 96e35af..fd4f0cc 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -52,7 +52,7 @@
 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
-- 
1.9.1



[PATCH 04/41] drivers: tty: serial: dz: fix use fix bare 'unsigned'

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#103: FILE: dz.c:103:
+static u16 dz_in(struct dz_port *dport, unsigned offset)

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#110: FILE: dz.c:110:
+static void dz_out(struct dz_port *dport, unsigned offset, u16 value)

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/dz.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index b3e9313..559d076 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -100,14 +100,14 @@ static inline struct dz_port *to_dport(struct uart_port 
*uport)
  * 
  */
 
-static u16 dz_in(struct dz_port *dport, unsigned offset)
+static u16 dz_in(struct dz_port *dport, unsigned int offset)
 {
void __iomem *addr = dport->port.membase + offset;
 
return readw(addr);
 }
 
-static void dz_out(struct dz_port *dport, unsigned offset, u16 value)
+static void dz_out(struct dz_port *dport, unsigned int offset, u16 value)
 {
void __iomem *addr = dport->port.membase + offset;
 
-- 
1.9.1



[PATCH 18/41] drivers: tty: serial: apbuart: use dev_info() instead of printk()

2019-04-27 Thread Enrico Weigelt, metux IT consult
Using dev_err() instead of printk() for more consistent output.
(prints device name, etc).

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/apbuart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index d2b86f7..89e19b6 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -568,7 +568,7 @@ static int apbuart_probe(struct platform_device *op)
 
apbuart_flush_fifo((struct uart_port *) port);
 
-   printk(KERN_INFO "grlib-apbuart at 0x%llx, irq %d\n",
+   dev_info(>pdev, "grlib-apbuart at 0x%llx, irq %d\n",
   (unsigned long long) port->mapbase, port->irq);
return 0;
 }
-- 
1.9.1



[PATCH 13/41] drivers: tty: serial: uartlite: fill mapsize and use it

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/uartlite.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 44d65bd..c322ab6 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -342,7 +342,7 @@ static const char *ulite_type(struct uart_port *port)
 
 static void ulite_release_port(struct uart_port *port)
 {
-   release_mem_region(port->mapbase, ULITE_REGION);
+   release_mem_region(port->mapbase, port->mapsize);
iounmap(port->membase);
port->membase = NULL;
 }
@@ -356,15 +356,15 @@ static int ulite_request_port(struct uart_port *port)
"ulite console: port=%p; port->mapbase=%llx\n",
 port, (unsigned long long) port->mapbase);
 
-   if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
+   if (!request_mem_region(port->mapbase, port->mapsize, "uartlite")) {
dev_err(port->dev, "Memory region busy\n");
return -EBUSY;
}
 
-   port->membase = ioremap(port->mapbase, ULITE_REGION);
+   port->membase = ioremap(port->mapbase, port->mapsize);
if (!port->membase) {
dev_err(port->dev, "Unable to map registers\n");
-   release_mem_region(port->mapbase, ULITE_REGION);
+   release_mem_region(port->mapbase, port->mapsize);
return -EBUSY;
}
 
@@ -649,6 +649,7 @@ static int ulite_assign(struct device *dev, int id, u32 
base, int irq,
port->iotype = UPIO_MEM;
port->iobase = 1; /* mark port in use */
port->mapbase = base;
+   port->mapsize = ULITE_REGION;
port->membase = NULL;
port->ops = _ops;
port->irq = irq;
-- 
1.9.1



[PATCH 16/41] drivers: tty: serial: uartlite: fix overlong lines

2019-04-27 Thread Enrico Weigelt, metux IT consult
Fix checkpatch warnings:

WARNING: line over 80 characters
#283: FILE: drivers/tty/serial/uartlite.c:283:
+   ret = request_irq(port->irq, ulite_isr, IRQF_SHARED | 
IRQF_TRIGGER_RISING,

WARNING: Missing a blank line after declarations
#577: FILE: drivers/tty/serial/uartlite.c:577:
+   struct earlycon_device *device = console->data;
+   uart_console_write(>port, s, n, early_uartlite_putc);

WARNING: line over 80 characters
#590: FILE: drivers/tty/serial/uartlite.c:590:
+OF_EARLYCON_DECLARE(uartlite_b, "xlnx,opb-uartlite-1.00.b", 
early_uartlite_setup);

WARNING: line over 80 characters
#591: FILE: drivers/tty/serial/uartlite.c:591:
+OF_EARLYCON_DECLARE(uartlite_a, "xlnx,xps-uartlite-1.00.a", 
early_uartlite_setup);

Signed-off-by: Enrico Weigelt 
---
 drivers/tty/serial/uartlite.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 6f79353..0140cec 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -280,7 +280,8 @@ static int ulite_startup(struct uart_port *port)
return ret;
}
 
-   ret = request_irq(port->irq, ulite_isr, IRQF_SHARED | 
IRQF_TRIGGER_RISING,
+   ret = request_irq(port->irq, ulite_isr,
+ IRQF_SHARED | IRQF_TRIGGER_RISING,
  "uartlite", port);
if (ret)
return ret;
@@ -574,6 +575,7 @@ static void early_uartlite_write(struct console *console,
 const char *s, unsigned int n)
 {
struct earlycon_device *device = console->data;
+
uart_console_write(>port, s, n, early_uartlite_putc);
 }
 
@@ -587,8 +589,10 @@ static int __init early_uartlite_setup(struct 
earlycon_device *device,
return 0;
 }
 EARLYCON_DECLARE(uartlite, early_uartlite_setup);
-OF_EARLYCON_DECLARE(uartlite_b, "xlnx,opb-uartlite-1.00.b", 
early_uartlite_setup);
-OF_EARLYCON_DECLARE(uartlite_a, "xlnx,xps-uartlite-1.00.a", 
early_uartlite_setup);
+OF_EARLYCON_DECLARE(uartlite_b, "xlnx,opb-uartlite-1.00.b",
+   early_uartlite_setup);
+OF_EARLYCON_DECLARE(uartlite_a, "xlnx,xps-uartlite-1.00.a",
+   early_uartlite_setup);
 
 #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
 
-- 
1.9.1



Re: [PATCH v10 00/18] Introduce the Counter subsystem

2019-04-27 Thread Jonathan Cameron
On Thu, 25 Apr 2019 21:36:24 +0200
Greg KH  wrote:

> On Sun, Apr 07, 2019 at 03:25:50PM +0100, Jonathan Cameron wrote:
> > On Tue,  2 Apr 2019 15:30:35 +0900
> > William Breathitt Gray  wrote:
> >   
> > > Changes in v10:
> > >   - Fix minor typographical errors in documentation
> > >   - Merge the FlexTimer Module Quadrature decoder counter driver patches
> > > 
> > > This revision is functionally identical to the last; changes in this
> > > version were made to fix minor typos in the documentation files and also
> > > to pull in the new FTM quadrature decoder counter driver.
> > > 
> > > The Generic Counter API has been and is still in a feature freeze until
> > > it is merged into the mainline. The following features will be
> > > investigated after the merge: interrupt support for counter devices, and
> > > a character device interface for low-latency applications.  
> > 
> > Hi William / al,
> > 
> > So the question is how to move this forwards?  I'm happy with how it turned
> > out and the existing drivers we had in IIO are a lot cleaner under
> > the counter subsystem (other than the backwards compatibility for those that
> > ever existed in IIO).  For those  not following closely the situation is:  
> 
> I've now sucked this into my staging-testing branch and if 0-day is fine
> with it, I'll merge it to staging-next in a day or so.  This way you can
> build on it for any iio drivers that might be coming.

Great thanks. 

> 
> I do have reservations about that one sysfs file that is multi-line, and
> I think it will come to bite you in the end over time, so I reserve the
> right to say "I told you so" when that happens...
> 
> But, I don't have a better answer for it now, so don't really worry
> about it :)
> 
> thanks,
> 
> greg k-h

Looks like a few late breaking comments came in, but nothing that can't
be fixed up before this reaches a release.

Thanks,

Jonathan




Why is suspend with s2idle available on POWER8 systems?

2019-04-27 Thread Paul Menzel

Dear Linux folks,


Updating an IBM S822LC from Ubuntu 18.10 to 19.04 some user space stuff 
seems to have changed, so that going into sleep/suspend is enabled.


That raises two questions.

1.  Is suspend actually supported on a POWER8 processor?


Apr 27 10:18:13 power NetworkManager[7534]:   [1556353093.7224] manager: 
sleep: sleep requested (sleeping: no  e
Apr 27 10:18:13 power systemd[1]: Reached target Sleep.
Apr 27 10:18:13 power systemd[1]: Starting Suspend...
Apr 27 10:18:13 power systemd-sleep[82190]: Suspending system...
Apr 27 10:18:13 power kernel: PM: suspend entry (s2idle)
-- Reboot --



$ uname -m
ppc64le
$ more /proc/version
Linux version 5.1.0-rc6+ (joey@power) (gcc version 8.3.0 (Ubuntu 
8.3.0-6ubuntu1)) #1 SMP Sat Apr 27 10:01:48 CEST 2019
$ more /sys/power/mem_sleep
[s2idle]
$ more /sys/power/state
freeze mem
$ grep _SUSPEND /boot/config-5.0.0-14-generic # also enabled in Ubuntu’s 
configuration
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_SUSPEND=y
CONFIG_SUSPEND_FREEZER=y
# CONFIG_SUSPEND_SKIP_SYNC is not set
# CONFIG_PM_TEST_SUSPEND is not set


Should the Kconfig symbol `SUSPEND` be selectable? If yes, should their 
be some detection during runtime?


2.  If it is supported, what are the ways to getting it to resume? What 
would the IPMI command be?


For now I disabled the automatic suspend, masking the targets [1].


Kind regards,

Paul


[1]: https://wiki.debian.org/Suspend#Disable_suspend_and_hibernation


Re: BUG: crash in __tlb_remove_page_size with STRICT_KERNEL_RWX on BOOK3S_32

2019-04-27 Thread christophe leroy

Le 26/04/2019 à 19:07, Segher Boessenkool a écrit :

On Fri, Apr 26, 2019 at 05:38:50PM +0300, Serge Belyshev wrote:

---[ Instruction Block Address Translation ]---
0: 0xc000-0xc07f 0x Kernel EXEC coherent
1: 0xc080-0xc087 0x0080 Kernel EXEC coherent
2: -
3: -
4: -
5: -
6: -
7: -

---[ Data Block Address Translation ]---
0: 0xc000-0xc07f 0x Kernel RO coherent
1: 0xc080-0xc0bf 0x0080 Kernel RO coherent
2: 0xc0c0-0xc13f 0x00c0 Kernel RW coherent
3: 0xc140-0xc23f 0x0140 Kernel RW coherent
4: 0xc240-0xc43f 0x0240 Kernel RW coherent
5: 0xc440-0xc83f 0x0440 Kernel RW coherent
6: 0xc840-0xd03f 0x0840 Kernel RW coherent
7: 0xd040-0xe03f 0x1040 Kernel RW coherent


The starting address of a BAT block is always aligned to the block size.
All of DBAT2..DBAT7 are wrong?



Obviously function block_size() returns a wrong result, I'll try and fix 
that early next week.


Christophe

---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel 
antivirus Avast.
https://www.avast.com/antivirus



[PATCH v2 9/9] dpaa_eth: fix SG frame cleanup

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

Fix issue with the entry indexing in the sg frame cleanup code being
off-by-1. This problem showed up when doing some basic iperf tests and
manifested in traffic coming to a halt.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index daede7272768..40420edc9ce6 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -1663,7 +1663,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct 
dpaa_priv *priv,
 qm_sg_entry_get_len([0]), dma_dir);
 
/* remaining pages were mapped with skb_frag_dma_map() */
-   for (i = 1; i < nr_frags; i++) {
+   for (i = 1; i <= nr_frags; i++) {
WARN_ON(qm_sg_entry_is_ext([i]));
 
dma_unmap_page(dev, qm_sg_addr([i]),
-- 
2.17.1



[PATCH v2 8/9] dpaa_eth: fix iova handling for sg frames

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

The driver relies on the no longer valid assumption that dma addresses
(iovas) are identical to physical addressees and uses phys_to_virt() to
make iova -> vaddr conversions. Fix this also for scatter-gather frames
using the iova -> phys conversion function added in the previous patch.
While at it, clean-up a redundant dpaa_bpid2pool() and pass the bp
as parameter.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 41 +++
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index f17edc80dc37..daede7272768 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -1646,14 +1646,17 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct 
dpaa_priv *priv,
 
if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
nr_frags = skb_shinfo(skb)->nr_frags;
-   dma_unmap_single(dev, addr,
-qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
-dma_dir);
 
/* The sgt buffer has been allocated with netdev_alloc_frag(),
 * it's from lowmem.
 */
-   sgt = phys_to_virt(addr + qm_fd_get_offset(fd));
+   sgt = phys_to_virt(dpaa_iova_to_phys(dev,
+addr +
+qm_fd_get_offset(fd)));
+
+   dma_unmap_single(dev, addr,
+qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
+dma_dir);
 
/* sgt[0] is from lowmem, was dma_map_single()-ed */
dma_unmap_single(dev, qm_sg_addr([0]),
@@ -1668,7 +1671,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct 
dpaa_priv *priv,
}
 
/* Free the page frag that we allocated on Tx */
-   skb_free_frag(phys_to_virt(addr));
+   skb_free_frag(skbh);
} else {
dma_unmap_single(dev, addr,
 skb_tail_pointer(skb) - (u8 *)skbh, dma_dir);
@@ -1729,14 +1732,14 @@ static struct sk_buff *contig_fd_to_skb(const struct 
dpaa_priv *priv,
  * The page fragment holding the S/G Table is recycled here.
  */
 static struct sk_buff *sg_fd_to_skb(const struct dpaa_priv *priv,
-   const struct qm_fd *fd)
+   const struct qm_fd *fd,
+   struct dpaa_bp *dpaa_bp,
+   void *vaddr)
 {
ssize_t fd_off = qm_fd_get_offset(fd);
-   dma_addr_t addr = qm_fd_addr(fd);
const struct qm_sg_entry *sgt;
struct page *page, *head_page;
-   struct dpaa_bp *dpaa_bp;
-   void *vaddr, *sg_vaddr;
+   void *sg_vaddr;
int frag_off, frag_len;
struct sk_buff *skb;
dma_addr_t sg_addr;
@@ -1745,7 +1748,6 @@ static struct sk_buff *sg_fd_to_skb(const struct 
dpaa_priv *priv,
int *count_ptr;
int i;
 
-   vaddr = phys_to_virt(addr);
WARN_ON(!IS_ALIGNED((unsigned long)vaddr, SMP_CACHE_BYTES));
 
/* Iterate through the SGT entries and add data buffers to the skb */
@@ -1756,14 +1758,18 @@ static struct sk_buff *sg_fd_to_skb(const struct 
dpaa_priv *priv,
WARN_ON(qm_sg_entry_is_ext([i]));
 
sg_addr = qm_sg_addr([i]);
-   sg_vaddr = phys_to_virt(sg_addr);
-   WARN_ON(!IS_ALIGNED((unsigned long)sg_vaddr,
-   SMP_CACHE_BYTES));
 
/* We may use multiple Rx pools */
dpaa_bp = dpaa_bpid2pool(sgt[i].bpid);
-   if (!dpaa_bp)
+   if (!dpaa_bp) {
+   pr_info("%s: fail to get dpaa_bp for sg bpid %d\n",
+   __func__, sgt[i].bpid);
goto free_buffers;
+   }
+   sg_vaddr = phys_to_virt(dpaa_iova_to_phys(dpaa_bp->dev,
+ sg_addr));
+   WARN_ON(!IS_ALIGNED((unsigned long)sg_vaddr,
+   SMP_CACHE_BYTES));
 
count_ptr = this_cpu_ptr(dpaa_bp->percpu_count);
dma_unmap_single(dpaa_bp->dev, sg_addr, dpaa_bp->size,
@@ -1835,10 +1841,11 @@ static struct sk_buff *sg_fd_to_skb(const struct 
dpaa_priv *priv,
/* free all the SG entries */
for (i = 0; i < DPAA_SGT_MAX_ENTRIES ; i++) {
sg_addr = qm_sg_addr([i]);
-   sg_vaddr = phys_to_virt(sg_addr);
-   skb_free_frag(sg_vaddr);
dpaa_bp = dpaa_bpid2pool(sgt[i].bpid);
if (dpaa_bp) {
+   sg_addr = dpaa_iova_to_phys(dpaa_bp->dev, 

[PATCH v2 7/9] dpaa_eth: fix iova handling for contiguous frames

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

The driver relies on the no longer valid assumption that dma addresses
(iovas) are identical to physical addressees and uses phys_to_virt() to
make iova -> vaddr conversions. Fix this by adding a function that does
proper iova -> phys conversions using the iommu api and update the code
to use it.
Also, a dma_unmap_single() call had to be moved further down the code
because iova -> vaddr conversions were required before the unmap.
For now only the contiguous frame case is handled and the SG case is
split in a following patch.
While at it, clean-up a redundant dpaa_bpid2pool() and pass the bp
as parameter.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 44 ++-
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index cdc7e6d83f77..f17edc80dc37 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1595,6 +1596,17 @@ static int dpaa_eth_refill_bpools(struct dpaa_priv *priv)
return 0;
 }
 
+static phys_addr_t dpaa_iova_to_phys(struct device *dev, dma_addr_t addr)
+{
+   struct iommu_domain *domain;
+
+   domain = iommu_get_domain_for_dev(dev);
+   if (domain)
+   return iommu_iova_to_phys(domain, addr);
+   else
+   return addr;
+}
+
 /* Cleanup function for outgoing frame descriptors that were built on Tx path,
  * either contiguous frames or scatter/gather ones.
  * Skb freeing is not handled here.
@@ -1617,7 +1629,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct 
dpaa_priv *priv,
int nr_frags, i;
u64 ns;
 
-   skbh = (struct sk_buff **)phys_to_virt(addr);
+   skbh = (struct sk_buff **)phys_to_virt(dpaa_iova_to_phys(dev, addr));
skb = *skbh;
 
if (priv->tx_tstamp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
@@ -1687,25 +1699,21 @@ static u8 rx_csum_offload(const struct dpaa_priv *priv, 
const struct qm_fd *fd)
  * accommodate the shared info area of the skb.
  */
 static struct sk_buff *contig_fd_to_skb(const struct dpaa_priv *priv,
-   const struct qm_fd *fd)
+   const struct qm_fd *fd,
+   struct dpaa_bp *dpaa_bp,
+   void *vaddr)
 {
ssize_t fd_off = qm_fd_get_offset(fd);
-   dma_addr_t addr = qm_fd_addr(fd);
-   struct dpaa_bp *dpaa_bp;
struct sk_buff *skb;
-   void *vaddr;
 
-   vaddr = phys_to_virt(addr);
WARN_ON(!IS_ALIGNED((unsigned long)vaddr, SMP_CACHE_BYTES));
 
-   dpaa_bp = dpaa_bpid2pool(fd->bpid);
-   if (!dpaa_bp)
-   goto free_buffer;
-
skb = build_skb(vaddr, dpaa_bp->size +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
-   if (WARN_ONCE(!skb, "Build skb failure on Rx\n"))
-   goto free_buffer;
+   if (WARN_ONCE(!skb, "Build skb failure on Rx\n")) {
+   skb_free_frag(vaddr);
+   return NULL;
+   }
WARN_ON(fd_off != priv->rx_headroom);
skb_reserve(skb, fd_off);
skb_put(skb, qm_fd_get_length(fd));
@@ -1713,10 +1721,6 @@ static struct sk_buff *contig_fd_to_skb(const struct 
dpaa_priv *priv,
skb->ip_summed = rx_csum_offload(priv, fd);
 
return skb;
-
-free_buffer:
-   skb_free_frag(vaddr);
-   return NULL;
 }
 
 /* Build an skb with the data of the first S/G entry in the linear portion and
@@ -2309,12 +2313,12 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct 
qman_portal *portal,
if (!dpaa_bp)
return qman_cb_dqrr_consume;
 
-   dma_unmap_single(dpaa_bp->dev, addr, dpaa_bp->size, DMA_FROM_DEVICE);
-
/* prefetch the first 64 bytes of the frame or the SGT start */
-   vaddr = phys_to_virt(addr);
+   vaddr = phys_to_virt(dpaa_iova_to_phys(dpaa_bp->dev, addr));
prefetch(vaddr + qm_fd_get_offset(fd));
 
+   dma_unmap_single(dpaa_bp->dev, addr, dpaa_bp->size, DMA_FROM_DEVICE);
+
/* The only FD types that we may receive are contig and S/G */
WARN_ON((fd_format != qm_fd_contig) && (fd_format != qm_fd_sg));
 
@@ -2325,7 +2329,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct 
qman_portal *portal,
(*count_ptr)--;
 
if (likely(fd_format == qm_fd_contig))
-   skb = contig_fd_to_skb(priv, fd);
+   skb = contig_fd_to_skb(priv, fd, dpaa_bp, vaddr);
else
skb = sg_fd_to_skb(priv, fd);
if (!skb)
-- 
2.17.1



[PATCH v2 5/9] dpaa_eth: defer probing after qbman

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

Enabling SMMU altered the order of device probing causing the dpaa1
ethernet driver to get probed before qbman and causing a boot crash.
Add predictability in the probing order by deferring the ethernet
driver probe after qbman and portals by using the recently introduced
qbman APIs.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index dfebc30c4841..647e90e7434f 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2774,6 +2774,37 @@ static int dpaa_eth_probe(struct platform_device *pdev)
int err = 0, i, channel;
struct device *dev;
 
+   err = bman_is_probed();
+   if (!err)
+   return -EPROBE_DEFER;
+   if (err < 0) {
+   dev_err(>dev, "failing probe due to bman probe error\n");
+   return -ENODEV;
+   }
+   err = qman_is_probed();
+   if (!err)
+   return -EPROBE_DEFER;
+   if (err < 0) {
+   dev_err(>dev, "failing probe due to qman probe error\n");
+   return -ENODEV;
+   }
+   err = bman_portals_probed();
+   if (!err)
+   return -EPROBE_DEFER;
+   if (err < 0) {
+   dev_err(>dev,
+   "failing probe due to bman portals probe error\n");
+   return -ENODEV;
+   }
+   err = qman_portals_probed();
+   if (!err)
+   return -EPROBE_DEFER;
+   if (err < 0) {
+   dev_err(>dev,
+   "failing probe due to qman portals probe error\n");
+   return -ENODEV;
+   }
+
/* device used for DMA mapping */
dev = pdev->dev.parent;
err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40));
-- 
2.17.1



[PATCH v2 3/9] fsl/fman: backup and restore ICID registers

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

During probing, FMAN is reset thus losing all its register
settings. Backup port ICID registers before reset and restore
them after, similarly to how it's done on powerpc / PAMU based
platforms.
This also has the side effect of disabling the old code path
(liodn backup/restore handling) that obviously make no sense
in the context of SMMU on ARMs.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman.c | 35 +-
 drivers/net/ethernet/freescale/fman/fman.h |  4 +++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index e80fedb27cee..ae833e215b74 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -629,6 +629,7 @@ static void set_port_order_restoration(struct fman_fpm_regs 
__iomem *fpm_rg,
iowrite32be(tmp, _rg->fmfp_prc);
 }
 
+#ifdef CONFIG_PPC
 static void set_port_liodn(struct fman *fman, u8 port_id,
   u32 liodn_base, u32 liodn_ofst)
 {
@@ -646,6 +647,27 @@ static void set_port_liodn(struct fman *fman, u8 port_id,
iowrite32be(tmp, >dma_regs->fmdmplr[port_id / 2]);
iowrite32be(liodn_ofst, >bmi_regs->fmbm_spliodn[port_id - 1]);
 }
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+static void save_restore_port_icids(struct fman *fman, bool save)
+{
+   int port_idxes[] = {
+   0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc,
+   0xd, 0xe, 0xf, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+   0x10, 0x11, 0x30, 0x31
+   };
+   int idx, i;
+
+   for (i = 0; i < ARRAY_SIZE(port_idxes); i++) {
+   idx = port_idxes[i];
+   if (save)
+   fman->sp_icids[idx] =
+   ioread32be(>bmi_regs->fmbm_spliodn[idx]);
+   else
+   iowrite32be(fman->sp_icids[idx],
+   >bmi_regs->fmbm_spliodn[idx]);
+   }
+}
+#endif
 
 static void enable_rams_ecc(struct fman_fpm_regs __iomem *fpm_rg)
 {
@@ -1914,7 +1936,10 @@ static int fman_reset(struct fman *fman)
 static int fman_init(struct fman *fman)
 {
struct fman_cfg *cfg = NULL;
-   int err = 0, i, count;
+   int err = 0, count;
+#ifdef CONFIG_PPC
+   int i;
+#endif
 
if (is_init_done(fman->cfg))
return -EINVAL;
@@ -1934,6 +1959,7 @@ static int fman_init(struct fman *fman)
memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0,
  fman->state->fm_port_num_of_cg);
 
+#ifdef CONFIG_PPC
/* Save LIODN info before FMan reset
 * Skipping non-existent port 0 (i = 1)
 */
@@ -1953,6 +1979,9 @@ static int fman_init(struct fman *fman)
}
fman->liodn_base[i] = liodn_base;
}
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+   save_restore_port_icids(fman, true);
+#endif
 
err = fman_reset(fman);
if (err)
@@ -2181,8 +2210,12 @@ int fman_set_port_params(struct fman *fman,
if (err)
goto return_err;
 
+#ifdef CONFIG_PPC
set_port_liodn(fman, port_id, fman->liodn_base[port_id],
   fman->liodn_offset[port_id]);
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+   save_restore_port_icids(fman, false);
+#endif
 
if (fman->state->rev_info.major < 6)
set_port_order_restoration(fman->fpm_regs, port_id);
diff --git a/drivers/net/ethernet/freescale/fman/fman.h 
b/drivers/net/ethernet/freescale/fman/fman.h
index 935c317fa696..19f20fa58053 100644
--- a/drivers/net/ethernet/freescale/fman/fman.h
+++ b/drivers/net/ethernet/freescale/fman/fman.h
@@ -346,8 +346,12 @@ struct fman {
unsigned long fifo_offset;
size_t fifo_size;
 
+#ifdef CONFIG_PPC
u32 liodn_base[64];
u32 liodn_offset[64];
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+   u32 sp_icids[64];
+#endif
 
struct fman_dts_params dts_params;
 };
-- 
2.17.1



[PATCH v2 6/9] dpaa_eth: base dma mappings on the fman rx port

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

The dma transactions initiator is the rx fman port so that's the device
that the dma mappings should be done. Previously the mappings were done
through the MAC device which makes no sense because it's neither dma-able
nor connected in any way to smmu.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 647e90e7434f..cdc7e6d83f77 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2805,8 +2805,15 @@ static int dpaa_eth_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   mac_dev = dpaa_mac_dev_get(pdev);
+   if (IS_ERR(mac_dev)) {
+   dev_err(>dev, "dpaa_mac_dev_get() failed\n");
+   err = PTR_ERR(mac_dev);
+   goto probe_err;
+   }
+
/* device used for DMA mapping */
-   dev = pdev->dev.parent;
+   dev = fman_port_get_device(mac_dev->port[RX]);
err = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(40));
if (err) {
dev_err(dev, "dma_coerce_mask_and_coherent() failed\n");
@@ -2831,13 +2838,6 @@ static int dpaa_eth_probe(struct platform_device *pdev)
 
priv->msg_enable = netif_msg_init(debug, DPAA_MSG_DEFAULT);
 
-   mac_dev = dpaa_mac_dev_get(pdev);
-   if (IS_ERR(mac_dev)) {
-   dev_err(dev, "dpaa_mac_dev_get() failed\n");
-   err = PTR_ERR(mac_dev);
-   goto free_netdev;
-   }
-
/* If fsl_fm_max_frm is set to a higher value than the all-common 1500,
 * we choose conservatively and let the user explicitly set a higher
 * MTU via ifconfig. Otherwise, the user may end up with different MTUs
@@ -2973,9 +2973,9 @@ static int dpaa_eth_probe(struct platform_device *pdev)
qman_release_cgrid(priv->cgr_data.cgr.cgrid);
 free_dpaa_bps:
dpaa_bps_free(priv);
-free_netdev:
dev_set_drvdata(dev, NULL);
free_netdev(net_dev);
+probe_err:
 
return err;
 }
-- 
2.17.1



[PATCH v2 4/9] fsl/fman: add API to get the device behind a fman port

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add an API that retrieves the 'struct device' that the specified fman
port probed against. The new API will be used in a subsequent iommu
enablement related patch.

Signed-off-by: Laurentiu Tudor 
Acked-by: Madalin Bucur 
---
 drivers/net/ethernet/freescale/fman/fman_port.c | 14 ++
 drivers/net/ethernet/freescale/fman/fman_port.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c 
b/drivers/net/ethernet/freescale/fman/fman_port.c
index ee82ee1384eb..bd76c9730692 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -1728,6 +1728,20 @@ u32 fman_port_get_qman_channel_id(struct fman_port *port)
 }
 EXPORT_SYMBOL(fman_port_get_qman_channel_id);
 
+/**
+ * fman_port_get_device
+ * port:   Pointer to the FMan port device
+ *
+ * Get the 'struct device' associated to the specified FMan port device
+ *
+ * Return: pointer to associated 'struct device'
+ */
+struct device *fman_port_get_device(struct fman_port *port)
+{
+   return port->dev;
+}
+EXPORT_SYMBOL(fman_port_get_device);
+
 int fman_port_get_hash_result_offset(struct fman_port *port, u32 *offset)
 {
if (port->buffer_offsets.hash_result_offset == ILLEGAL_BASE)
diff --git a/drivers/net/ethernet/freescale/fman/fman_port.h 
b/drivers/net/ethernet/freescale/fman/fman_port.h
index 9dbb69f40121..82f12661a46d 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.h
+++ b/drivers/net/ethernet/freescale/fman/fman_port.h
@@ -157,4 +157,6 @@ int fman_port_get_tstamp(struct fman_port *port, const void 
*data, u64 *tstamp);
 
 struct fman_port *fman_port_bind(struct device *dev);
 
+struct device *fman_port_get_device(struct fman_port *port);
+
 #endif /* __FMAN_PORT_H */
-- 
2.17.1



[PATCH v2 1/9] soc/fsl/qman: fixup liodns only on ppc targets

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

ARM SoCs use SMMU so the liodn fixup done in the qman driver is no
longer making sense and it also breaks the ICID settings inherited
from u-boot. Do the fixups only for PPC targets.

Signed-off-by: Laurentiu Tudor 
---
 drivers/soc/fsl/qbman/qman_ccsr.c | 2 +-
 drivers/soc/fsl/qbman/qman_priv.h | 9 -
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c 
b/drivers/soc/fsl/qbman/qman_ccsr.c
index 109b38de3176..a6bb43007d03 100644
--- a/drivers/soc/fsl/qbman/qman_ccsr.c
+++ b/drivers/soc/fsl/qbman/qman_ccsr.c
@@ -596,7 +596,7 @@ static int qman_init_ccsr(struct device *dev)
 }
 
 #define LIO_CFG_LIODN_MASK 0x0fff
-void qman_liodn_fixup(u16 channel)
+void __qman_liodn_fixup(u16 channel)
 {
static int done;
static u32 liodn_offset;
diff --git a/drivers/soc/fsl/qbman/qman_priv.h 
b/drivers/soc/fsl/qbman/qman_priv.h
index 75a8f905f8f7..04515718cfd9 100644
--- a/drivers/soc/fsl/qbman/qman_priv.h
+++ b/drivers/soc/fsl/qbman/qman_priv.h
@@ -193,7 +193,14 @@ extern struct gen_pool *qm_cgralloc; /* CGR ID allocator */
 u32 qm_get_pools_sdqcr(void);
 
 int qman_wq_alloc(void);
-void qman_liodn_fixup(u16 channel);
+#ifdef CONFIG_FSL_PAMU
+#define qman_liodn_fixup __qman_liodn_fixup
+#else
+static inline void qman_liodn_fixup(u16 channel)
+{
+}
+#endif
+void __qman_liodn_fixup(u16 channel);
 void qman_set_sdest(u16 channel, unsigned int cpu_idx);
 
 struct qman_portal *qman_create_affine_portal(
-- 
2.17.1



[PATCH v2 2/9] soc/fsl/qbman_portals: add APIs to retrieve the probing status

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add a couple of new APIs to check the probing status of the required
cpu bound qman and bman portals:
 'int bman_portals_probed()' and 'int qman_portals_probed()'.
They return the following values.
 *  1 if qman/bman portals were all probed correctly
 *  0 if qman/bman portals were not yet probed
 * -1 if probing of qman/bman portals failed
Portals are considered successful probed if no error occurred during
the probing of any of the portals and if enough portals were probed
to have one available for each cpu.
The error handling paths were slightly rearranged in order to fit this
new functionality without being too intrusive.
Drivers that use qman/bman portal driver services are required to use
these APIs before calling any functions exported by these drivers or
otherwise they will crash the kernel.
First user will be the dpaa1 ethernet driver, coming in a subsequent
patch.

Signed-off-by: Laurentiu Tudor 
---
 drivers/soc/fsl/qbman/bman_portal.c | 20 
 drivers/soc/fsl/qbman/qman_portal.c | 21 +
 include/soc/fsl/bman.h  |  8 
 include/soc/fsl/qman.h  |  9 +
 4 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/fsl/qbman/bman_portal.c 
b/drivers/soc/fsl/qbman/bman_portal.c
index 2c95cf59f3e7..cf4f10d6f590 100644
--- a/drivers/soc/fsl/qbman/bman_portal.c
+++ b/drivers/soc/fsl/qbman/bman_portal.c
@@ -32,6 +32,7 @@
 
 static struct bman_portal *affine_bportals[NR_CPUS];
 static struct cpumask portal_cpus;
+static int __bman_portals_probed;
 /* protect bman global registers and global data shared among portals */
 static DEFINE_SPINLOCK(bman_lock);
 
@@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu)
return 0;
 }
 
+int bman_portals_probed(void)
+{
+   return __bman_portals_probed;
+}
+EXPORT_SYMBOL_GPL(bman_portals_probed);
+
 static int bman_portal_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev)
}
 
pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
-   if (!pcfg)
+   if (!pcfg) {
+   __bman_portals_probed = -1;
return -ENOMEM;
+   }
 
pcfg->dev = dev;
 
@@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev)
 DPAA_PORTAL_CE);
if (!addr_phys[0]) {
dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node);
-   return -ENXIO;
+   goto err_ioremap1;
}
 
addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM,
 DPAA_PORTAL_CI);
if (!addr_phys[1]) {
dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node);
-   return -ENXIO;
+   goto err_ioremap1;
}
 
pcfg->cpu = -1;
@@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
if (irq <= 0) {
dev_err(dev, "Can't get %pOF IRQ'\n", node);
-   return -ENXIO;
+   goto err_ioremap1;
}
pcfg->irq = irq;
 
@@ -150,6 +159,7 @@ static int bman_portal_probe(struct platform_device *pdev)
spin_lock(_lock);
cpu = cpumask_next_zero(-1, _cpus);
if (cpu >= nr_cpu_ids) {
+   __bman_portals_probed = 1;
/* unassigned portal, skip init */
spin_unlock(_lock);
return 0;
@@ -175,6 +185,8 @@ static int bman_portal_probe(struct platform_device *pdev)
 err_ioremap2:
memunmap(pcfg->addr_virt_ce);
 err_ioremap1:
+__bman_portals_probed = -1;
+
return -ENXIO;
 }
 
diff --git a/drivers/soc/fsl/qbman/qman_portal.c 
b/drivers/soc/fsl/qbman/qman_portal.c
index 661c9b234d32..e2186b681d87 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -38,6 +38,7 @@ EXPORT_SYMBOL(qman_dma_portal);
 #define CONFIG_FSL_DPA_PIRQ_FAST  1
 
 static struct cpumask portal_cpus;
+static int __qman_portals_probed;
 /* protect qman global registers and global data shared among portals */
 static DEFINE_SPINLOCK(qman_lock);
 
@@ -220,6 +221,12 @@ static int qman_online_cpu(unsigned int cpu)
return 0;
 }
 
+int qman_portals_probed(void)
+{
+   return __qman_portals_probed;
+}
+EXPORT_SYMBOL_GPL(qman_portals_probed);
+
 static int qman_portal_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -238,8 +245,10 @@ static int qman_portal_probe(struct platform_device *pdev)
}
 
pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
-   if (!pcfg)
+   if (!pcfg) {
+   __qman_portals_probed = -1;
return -ENOMEM;
+   }
 
pcfg->dev = dev;
 
@@ -247,19 +256,20 @@ static int qman_portal_probe(struct 

[PATCH v2 0/9] Prerequisites for NXP LS104xA SMMU enablement

2019-04-27 Thread laurentiu . tudor
From: Laurentiu Tudor 

This patch series contains several fixes in preparation for SMMU
support on NXP LS1043A and LS1046A chips. Once these get picked up,
I'll submit the actual SMMU enablement patches consisting in the
required device tree changes.

This patch series contains only part of the previously submitted one,
(including also the device tree changes) available here:

https://patchwork.kernel.org/cover/10634443/

Changes in v2:
 - dropped patches dealing with mapping reserved memory in iommu
 - changed logic for qman portal probe status (Leo)
 - moved "#ifdef CONFIG_PAMU" in header file (Leo)
 - rebased on v5.1.0-rc5

Laurentiu Tudor (9):
  soc/fsl/qman: fixup liodns only on ppc targets
  soc/fsl/qbman_portals: add APIs to retrieve the probing status
  fsl/fman: backup and restore ICID registers
  fsl/fman: add API to get the device behind a fman port
  dpaa_eth: defer probing after qbman
  dpaa_eth: base dma mappings on the fman rx port
  dpaa_eth: fix iova handling for contiguous frames
  dpaa_eth: fix iova handling for sg frames
  dpaa_eth: fix SG frame cleanup

 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 136 --
 drivers/net/ethernet/freescale/fman/fman.c|  35 -
 drivers/net/ethernet/freescale/fman/fman.h|   4 +
 .../net/ethernet/freescale/fman/fman_port.c   |  14 ++
 .../net/ethernet/freescale/fman/fman_port.h   |   2 +
 drivers/soc/fsl/qbman/bman_portal.c   |  20 ++-
 drivers/soc/fsl/qbman/qman_ccsr.c |   2 +-
 drivers/soc/fsl/qbman/qman_portal.c   |  21 ++-
 drivers/soc/fsl/qbman/qman_priv.h |   9 +-
 include/soc/fsl/bman.h|   8 ++
 include/soc/fsl/qman.h|   9 ++
 11 files changed, 202 insertions(+), 58 deletions(-)

-- 
2.17.1