linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] fixes for atmel-hlcdc
@ 2019-12-13 15:04 Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 1/6] drm: atmel-hlcdc: use double rate for pixel clock only if supported Claudiu Beznea
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea

Hi,

I have few fixes for atmel-hlcdc driver in this series as well
as two reverts.
Revert "drm: atmel-hlcdc: enable sys_clk during initalization." is
due to the fix in in patch 2/5.

Thank you,
Claudiu Beznea

Changes in v2:
- introduce patch 3/6
- use dev_err() inpatch 4/6
- introduce patch 5/6 instead of reverting commit f6f7ad323461
  ("drm/atmel-hlcdc: allow selecting a higher pixel-clock than requested")

Claudiu Beznea (5):
  drm: atmel-hlcdc: use double rate for pixel clock only if supported
  drm: atmel-hlcdc: enable clock before configuring timing engine
  mfd: atmel-hlcdc: add struct device member to struct
    atmel_hlcdc_regmap
  mfd: atmel-hlcdc: return in case of error
  Revert "drm: atmel-hlcdc: enable sys_clk during initalization."

Peter Rosin (1):
  drm: atmel-hlcdc: prefer a lower pixel-clock than requested

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 18 ++++++++++++------
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   | 19 +------------------
 drivers/mfd/atmel-hlcdc.c                      | 18 ++++++++++++++----
 3 files changed, 27 insertions(+), 28 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/6] drm: atmel-hlcdc: use double rate for pixel clock only if supported
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 2/6] drm: atmel-hlcdc: enable clock before configuring timing engine Claudiu Beznea
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea

Doubled system clock should be used as pixel cock source only if this
is supported. This is emphasized by the value of
atmel_hlcdc_crtc::dc::desc::fixed_clksrc.

Fixes: a6eca2abdd42 ("drm: atmel-hlcdc: add config option for clock selection")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index f2e73e6d46b8..5040ed8d0871 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -95,14 +95,14 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
 		     (adj->crtc_hdisplay - 1) |
 		     ((adj->crtc_vdisplay - 1) << 16));
 
+	prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
+	mode_rate = adj->crtc_clock * 1000;
 	if (!crtc->dc->desc->fixed_clksrc) {
+		prate *= 2;
 		cfg |= ATMEL_HLCDC_CLKSEL;
 		mask |= ATMEL_HLCDC_CLKSEL;
 	}
 
-	prate = 2 * clk_get_rate(crtc->dc->hlcdc->sys_clk);
-	mode_rate = adj->crtc_clock * 1000;
-
 	div = DIV_ROUND_UP(prate, mode_rate);
 	if (div < 2) {
 		div = 2;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 2/6] drm: atmel-hlcdc: enable clock before configuring timing engine
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 1/6] drm: atmel-hlcdc: use double rate for pixel clock only if supported Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap Claudiu Beznea
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea

Changing pixel clock source without having this clock source enabled
will block the timing engine and the next operations after (in this case
setting ATMEL_HLCDC_CFG(5) settings in atmel_hlcdc_crtc_mode_set_nofb()
will fail). It is recomended (although in datasheet this is not present)
to actually enabled pixel clock source before doing any changes on timing
enginge (only SAM9X60 datasheet specifies that the peripheral clock and
pixel clock must be enabled before using LCD controller).

Fixes: 1a396789f65a ("drm: add Atmel HLCDC Display Controller support")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 5040ed8d0871..721fa88bf71d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -73,7 +73,11 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
 	unsigned long prate;
 	unsigned int mask = ATMEL_HLCDC_CLKDIV_MASK | ATMEL_HLCDC_CLKPOL;
 	unsigned int cfg = 0;
-	int div;
+	int div, ret;
+
+	ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
+	if (ret)
+		return;
 
 	vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay;
 	vm.vback_porch = adj->crtc_vtotal - adj->crtc_vsync_end;
@@ -147,6 +151,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
 			   ATMEL_HLCDC_VSPSU | ATMEL_HLCDC_VSPHO |
 			   ATMEL_HLCDC_GUARDTIME_MASK | ATMEL_HLCDC_MODE_MASK,
 			   cfg);
+
+	clk_disable_unprepare(crtc->dc->hlcdc->sys_clk);
 }
 
 static enum drm_mode_status
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 1/6] drm: atmel-hlcdc: use double rate for pixel clock only if supported Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 2/6] drm: atmel-hlcdc: enable clock before configuring timing engine Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  2019-12-16 16:17   ` Lee Jones
  2019-12-13 15:04 ` [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error Claudiu Beznea
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea

Add struct device member to struct atmel_hlcdc_regmap to be
able to use dev_*() specific logging functions.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/mfd/atmel-hlcdc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
index 64013c57a920..92bfcaa62ace 100644
--- a/drivers/mfd/atmel-hlcdc.c
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -19,6 +19,7 @@
 
 struct atmel_hlcdc_regmap {
 	void __iomem *regs;
+	struct device *dev;
 };
 
 static const struct mfd_cell atmel_hlcdc_cells[] = {
@@ -90,6 +91,8 @@ static int atmel_hlcdc_probe(struct platform_device *pdev)
 	if (IS_ERR(hregmap->regs))
 		return PTR_ERR(hregmap->regs);
 
+	hregmap->dev = &pdev->dev;
+
 	hlcdc->irq = platform_get_irq(pdev, 0);
 	if (hlcdc->irq < 0)
 		return hlcdc->irq;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
                   ` (2 preceding siblings ...)
  2019-12-13 15:04 ` [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  2019-12-16 16:22   ` Lee Jones
  2019-12-16 16:24   ` Lee Jones
  2019-12-13 15:04 ` [PATCH v2 5/6] drm: atmel-hlcdc: prefer a lower pixel-clock than requested Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 6/6] Revert "drm: atmel-hlcdc: enable sys_clk during initalization." Claudiu Beznea
  5 siblings, 2 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea

For HLCDC timing engine configurations bit ATMEL_HLCDC_SIP of
ATMEL_HLCDC_SR needs to be polled before applying new config. In case of
timeout there is no indicator about this, so, return in case of timeout
and also print a message about this.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/mfd/atmel-hlcdc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
index 92bfcaa62ace..a1e46c87b956 100644
--- a/drivers/mfd/atmel-hlcdc.c
+++ b/drivers/mfd/atmel-hlcdc.c
@@ -40,10 +40,17 @@ static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
 
 	if (reg <= ATMEL_HLCDC_DIS) {
 		u32 status;
-
-		readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
-					  status, !(status & ATMEL_HLCDC_SIP),
-					  1, 100);
+		int ret;
+
+		ret = readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
+						status,
+						!(status & ATMEL_HLCDC_SIP),
+						1, 100);
+		if (ret) {
+			dev_err(hregmap->dev,
+				"Timeout waiting for ATMEL_HLCDC_SIP\n");
+			return ret;
+		}
 	}
 
 	writel(val, hregmap->regs + reg);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 5/6] drm: atmel-hlcdc: prefer a lower pixel-clock than requested
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
                   ` (3 preceding siblings ...)
  2019-12-13 15:04 ` [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  2019-12-13 15:04 ` [PATCH v2 6/6] Revert "drm: atmel-hlcdc: enable sys_clk during initalization." Claudiu Beznea
  5 siblings, 0 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Peter Rosin

From: Peter Rosin <peda@axentia.se>

The intention was to only select a higher pixel-clock rate than the
requested, if a slight overclocking would result in a rate significantly
closer to the requested rate than if the conservative lower pixel-clock
rate is selected. The fixed patch has the logic the other way around and
actually prefers the higher frequency. Fix that.

Fixes: f6f7ad323461 ("drm/atmel-hlcdc: allow selecting a higher pixel-clock than requested")
Reported-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 721fa88bf71d..10985134ce0b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -121,8 +121,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
 		int div_low = prate / mode_rate;
 
 		if (div_low >= 2 &&
-		    ((prate / div_low - mode_rate) <
-		     10 * (mode_rate - prate / div)))
+		    (10 * (prate / div_low - mode_rate) <
+		     (mode_rate - prate / div)))
 			/*
 			 * At least 10 times better when using a higher
 			 * frequency than requested, instead of a lower.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 6/6] Revert "drm: atmel-hlcdc: enable sys_clk during initalization."
  2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
                   ` (4 preceding siblings ...)
  2019-12-13 15:04 ` [PATCH v2 5/6] drm: atmel-hlcdc: prefer a lower pixel-clock than requested Claudiu Beznea
@ 2019-12-13 15:04 ` Claudiu Beznea
  5 siblings, 0 replies; 11+ messages in thread
From: Claudiu Beznea @ 2019-12-13 15:04 UTC (permalink / raw)
  To: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, lee.jones
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Claudiu Beznea,
	Sandeep Sheriker Mallikarjun

This reverts commit d2c755e66617620b729041c625a6396c81d1231c
("drm: atmel-hlcdc: enable sys_clk during initalization."). With
commit "drm: atmel-hlcdc: enable clock before configuring timing engine"
there is no need for this patch. Code is also simpler.

Cc: Sandeep Sheriker Mallikarjun <sandeepsheriker.mallikarjun@microchip.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---

Hi Sam,

I still kept this as a patch as I didn't got any answer from you at my
last email up to this moment.

If you think it is better to squash this one with patch 2/6 in this seris
let me know.

Thank you,
Claudiu Beznea

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8dc917a1270b..112aa5066cee 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -721,18 +721,10 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
 	dc->hlcdc = dev_get_drvdata(dev->dev->parent);
 	dev->dev_private = dc;
 
-	if (dc->desc->fixed_clksrc) {
-		ret = clk_prepare_enable(dc->hlcdc->sys_clk);
-		if (ret) {
-			dev_err(dev->dev, "failed to enable sys_clk\n");
-			goto err_destroy_wq;
-		}
-	}
-
 	ret = clk_prepare_enable(dc->hlcdc->periph_clk);
 	if (ret) {
 		dev_err(dev->dev, "failed to enable periph_clk\n");
-		goto err_sys_clk_disable;
+		goto err_destroy_wq;
 	}
 
 	pm_runtime_enable(dev->dev);
@@ -768,9 +760,6 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
 err_periph_clk_disable:
 	pm_runtime_disable(dev->dev);
 	clk_disable_unprepare(dc->hlcdc->periph_clk);
-err_sys_clk_disable:
-	if (dc->desc->fixed_clksrc)
-		clk_disable_unprepare(dc->hlcdc->sys_clk);
 
 err_destroy_wq:
 	destroy_workqueue(dc->wq);
@@ -795,8 +784,6 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
 
 	pm_runtime_disable(dev->dev);
 	clk_disable_unprepare(dc->hlcdc->periph_clk);
-	if (dc->desc->fixed_clksrc)
-		clk_disable_unprepare(dc->hlcdc->sys_clk);
 	destroy_workqueue(dc->wq);
 }
 
@@ -910,8 +897,6 @@ static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
 	regmap_read(regmap, ATMEL_HLCDC_IMR, &dc->suspend.imr);
 	regmap_write(regmap, ATMEL_HLCDC_IDR, dc->suspend.imr);
 	clk_disable_unprepare(dc->hlcdc->periph_clk);
-	if (dc->desc->fixed_clksrc)
-		clk_disable_unprepare(dc->hlcdc->sys_clk);
 
 	return 0;
 }
@@ -921,8 +906,6 @@ static int atmel_hlcdc_dc_drm_resume(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct atmel_hlcdc_dc *dc = drm_dev->dev_private;
 
-	if (dc->desc->fixed_clksrc)
-		clk_prepare_enable(dc->hlcdc->sys_clk);
 	clk_prepare_enable(dc->hlcdc->periph_clk);
 	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, dc->suspend.imr);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap
  2019-12-13 15:04 ` [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap Claudiu Beznea
@ 2019-12-16 16:17   ` Lee Jones
  0 siblings, 0 replies; 11+ messages in thread
From: Lee Jones @ 2019-12-16 16:17 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, dri-devel,
	linux-arm-kernel, linux-kernel

On Fri, 13 Dec 2019, Claudiu Beznea wrote:

> Add struct device member to struct atmel_hlcdc_regmap to be
> able to use dev_*() specific logging functions.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>  drivers/mfd/atmel-hlcdc.c | 3 +++
>  1 file changed, 3 insertions(+)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error
  2019-12-13 15:04 ` [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error Claudiu Beznea
@ 2019-12-16 16:22   ` Lee Jones
  2019-12-16 16:24   ` Lee Jones
  1 sibling, 0 replies; 11+ messages in thread
From: Lee Jones @ 2019-12-16 16:22 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, dri-devel,
	linux-arm-kernel, linux-kernel

On Fri, 13 Dec 2019, Claudiu Beznea wrote:

> For HLCDC timing engine configurations bit ATMEL_HLCDC_SIP of
> ATMEL_HLCDC_SR needs to be polled before applying new config. In case of
> timeout there is no indicator about this, so, return in case of timeout
> and also print a message about this.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>  drivers/mfd/atmel-hlcdc.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error
  2019-12-13 15:04 ` [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error Claudiu Beznea
  2019-12-16 16:22   ` Lee Jones
@ 2019-12-16 16:24   ` Lee Jones
  2019-12-18 10:02     ` Claudiu.Beznea
  1 sibling, 1 reply; 11+ messages in thread
From: Lee Jones @ 2019-12-16 16:24 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: sam, bbrezillon, airlied, daniel, nicolas.ferre,
	alexandre.belloni, ludovic.desroches, dri-devel,
	linux-arm-kernel, linux-kernel

On Fri, 13 Dec 2019, Claudiu Beznea wrote:

> For HLCDC timing engine configurations bit ATMEL_HLCDC_SIP of
> ATMEL_HLCDC_SR needs to be polled before applying new config. In case of
> timeout there is no indicator about this, so, return in case of timeout
> and also print a message about this.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> ---
>  drivers/mfd/atmel-hlcdc.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
> index 92bfcaa62ace..a1e46c87b956 100644
> --- a/drivers/mfd/atmel-hlcdc.c
> +++ b/drivers/mfd/atmel-hlcdc.c
> @@ -40,10 +40,17 @@ static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
>  
>  	if (reg <= ATMEL_HLCDC_DIS) {
>  		u32 status;
> -
> -		readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
> -					  status, !(status & ATMEL_HLCDC_SIP),
> -					  1, 100);
> +		int ret;
> +
> +		ret = readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
> +						status,
> +						!(status & ATMEL_HLCDC_SIP),
> +						1, 100);
> +		if (ret) {
> +			dev_err(hregmap->dev,
> +				"Timeout waiting for ATMEL_HLCDC_SIP\n");

Nit: Just in case you have to rework this, placing register names in
the kernel log isn't usually helpful.  Can you swap it out for a more
user friendly message?

"Timed out waiting for ..."

... X status
... Y to update
... setting Z configuration

Etc.

> +			return ret;
> +		}
>  	}
>  
>  	writel(val, hregmap->regs + reg);

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error
  2019-12-16 16:24   ` Lee Jones
@ 2019-12-18 10:02     ` Claudiu.Beznea
  0 siblings, 0 replies; 11+ messages in thread
From: Claudiu.Beznea @ 2019-12-18 10:02 UTC (permalink / raw)
  To: lee.jones
  Cc: alexandre.belloni, bbrezillon, airlied, dri-devel, linux-kernel,
	Ludovic.Desroches, daniel, sam, linux-arm-kernel



On 16.12.2019 18:24, Lee Jones wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Fri, 13 Dec 2019, Claudiu Beznea wrote:
> 
>> For HLCDC timing engine configurations bit ATMEL_HLCDC_SIP of
>> ATMEL_HLCDC_SR needs to be polled before applying new config. In case of
>> timeout there is no indicator about this, so, return in case of timeout
>> and also print a message about this.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>> ---
>>  drivers/mfd/atmel-hlcdc.c | 15 +++++++++++----
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mfd/atmel-hlcdc.c b/drivers/mfd/atmel-hlcdc.c
>> index 92bfcaa62ace..a1e46c87b956 100644
>> --- a/drivers/mfd/atmel-hlcdc.c
>> +++ b/drivers/mfd/atmel-hlcdc.c
>> @@ -40,10 +40,17 @@ static int regmap_atmel_hlcdc_reg_write(void *context, unsigned int reg,
>>
>>       if (reg <= ATMEL_HLCDC_DIS) {
>>               u32 status;
>> -
>> -             readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
>> -                                       status, !(status & ATMEL_HLCDC_SIP),
>> -                                       1, 100);
>> +             int ret;
>> +
>> +             ret = readl_poll_timeout_atomic(hregmap->regs + ATMEL_HLCDC_SR,
>> +                                             status,
>> +                                             !(status & ATMEL_HLCDC_SIP),
>> +                                             1, 100);
>> +             if (ret) {
>> +                     dev_err(hregmap->dev,
>> +                             "Timeout waiting for ATMEL_HLCDC_SIP\n");
> 
> Nit: Just in case you have to rework this, placing register names in
> the kernel log isn't usually helpful.  Can you swap it out for a more
> user friendly message?

Sure! I'll do a v3 for it.

Thank you,
Claudiu Beznea

> 
> "Timed out waiting for ..."
> 
> ... X status
> ... Y to update
> ... setting Z configuration
> 
> Etc.
> 
>> +                     return ret;
>> +             }
>>       }
>>
>>       writel(val, hregmap->regs + reg);
> 
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-12-18 10:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-13 15:04 [PATCH v2 0/6] fixes for atmel-hlcdc Claudiu Beznea
2019-12-13 15:04 ` [PATCH v2 1/6] drm: atmel-hlcdc: use double rate for pixel clock only if supported Claudiu Beznea
2019-12-13 15:04 ` [PATCH v2 2/6] drm: atmel-hlcdc: enable clock before configuring timing engine Claudiu Beznea
2019-12-13 15:04 ` [PATCH v2 3/6] mfd: atmel-hlcdc: add struct device member to struct atmel_hlcdc_regmap Claudiu Beznea
2019-12-16 16:17   ` Lee Jones
2019-12-13 15:04 ` [PATCH v2 4/6] mfd: atmel-hlcdc: return in case of error Claudiu Beznea
2019-12-16 16:22   ` Lee Jones
2019-12-16 16:24   ` Lee Jones
2019-12-18 10:02     ` Claudiu.Beznea
2019-12-13 15:04 ` [PATCH v2 5/6] drm: atmel-hlcdc: prefer a lower pixel-clock than requested Claudiu Beznea
2019-12-13 15:04 ` [PATCH v2 6/6] Revert "drm: atmel-hlcdc: enable sys_clk during initalization." Claudiu Beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).