Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 12/16] drm/panel: use inline comments in drm_panel.h
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Inline comments provide better space for additional comments.
Comments was slightly edited to follow the normal style,
but no change to actual content.
Used the opportuniy to change the order in drm_panel_funcs
to follow the order they will be used by a panel.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 include/drm/drm_panel.h | 82 +++++++++++++++++++++++++++++++++--------
 1 file changed, 66 insertions(+), 16 deletions(-)

diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 053d611656b9..5e62deea49ba 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -36,14 +36,6 @@ struct display_timing;
 
 /**
  * struct drm_panel_funcs - perform operations on a given panel
- * @disable: disable panel (turn off back light, etc.)
- * @unprepare: turn off panel
- * @prepare: turn on panel and perform set up
- * @enable: enable panel (turn on back light, etc.)
- * @get_modes: add modes to the connector that the panel is attached to and
- * return the number of modes added
- * @get_timings: copy display timings into the provided array and return
- * the number of display timings available
  *
  * The .prepare() function is typically called before the display controller
  * starts to transmit video data. Panel drivers can use this to turn the panel
@@ -69,31 +61,89 @@ struct display_timing;
  * the panel. This is the job of the .unprepare() function.
  */
 struct drm_panel_funcs {
-	int (*disable)(struct drm_panel *panel);
-	int (*unprepare)(struct drm_panel *panel);
+	/**
+	 * @prepare:
+	 *
+	 * Turn on panel and perform set up.
+	 */
 	int (*prepare)(struct drm_panel *panel);
+
+	/**
+	 * @enable:
+	 *
+	 * Enable panel (turn on back light, etc.).
+	 */
 	int (*enable)(struct drm_panel *panel);
+
+	/**
+	 * @disable:
+	 *
+	 * Disable panel (turn off back light, etc.).
+	 */
+	int (*disable)(struct drm_panel *panel);
+
+	/**
+	 * @unprepare:
+	 *
+	 * Turn off panel.
+	 */
+	int (*unprepare)(struct drm_panel *panel);
+
+	/**
+	 * @get_modes:
+	 *
+	 * Add modes to the connector that the panel is attached to and
+	 * return the number of modes added.
+	 */
 	int (*get_modes)(struct drm_panel *panel);
+
+	/**
+	 * @get_timings:
+	 *
+	 * Copy display timings into the provided array and return
+	 * the number of display timings available.
+	 */
 	int (*get_timings)(struct drm_panel *panel, unsigned int num_timings,
 			   struct display_timing *timings);
 };
 
 /**
  * struct drm_panel - DRM panel object
- * @drm: DRM device owning the panel
- * @connector: DRM connector that the panel is attached to
- * @dev: parent device of the panel
- * @link: link from panel device (supplier) to DRM device (consumer)
- * @funcs: operations that can be performed on the panel
- * @list: panel entry in registry
  */
 struct drm_panel {
+	/**
+	 * @drm:
+	 *
+	 * DRM device owning the panel.
+	 */
 	struct drm_device *drm;
+
+	/**
+	 * @connector:
+	 *
+	 * DRM connector that the panel is attached to.
+	 */
 	struct drm_connector *connector;
+
+	/**
+	 * @dev:
+	 *
+	 * Parent device of the panel.
+	 */
 	struct device *dev;
 
+	/**
+	 * @funcs:
+	 *
+	 * Operations that can be performed on the panel.
+	 */
 	const struct drm_panel_funcs *funcs;
 
+	/**
+	 * @list:
+	 *
+	 * Panel entry in registry.
+	 */
 	struct list_head list;
 };
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 11/16] drm/panel: move drm_panel functions to .c file
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Move inline functions from include/drm/drm_panel.h to drm_panel.c.
This is in preparation for follow-up patches that will add extra
logic to the functions.
As they are no longer static inline, EXPORT them.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/drm_panel.c | 96 +++++++++++++++++++++++++++++++++++
 include/drm/drm_panel.h     | 99 +++----------------------------------
 2 files changed, 104 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index dbd5b873e8f2..9946b8d9bacc 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -54,6 +54,102 @@ void drm_panel_init(struct drm_panel *panel)
 }
 EXPORT_SYMBOL(drm_panel_init);
 
+/**
+ * drm_panel_prepare - power on a panel
+ * @panel: DRM panel
+ *
+ * Calling this function will enable power and deassert any reset signals to
+ * the panel. After this has completed it is possible to communicate with any
+ * integrated circuitry via a command bus.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int drm_panel_prepare(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->prepare)
+		return panel->funcs->prepare(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+EXPORT_SYMBOL(drm_panel_prepare);
+
+/**
+ * drm_panel_enable - enable a panel
+ * @panel: DRM panel
+ *
+ * Calling this function will cause the panel display drivers to be turned on
+ * and the backlight to be enabled. Content will be visible on screen after
+ * this call completes.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int drm_panel_enable(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->enable)
+		return panel->funcs->enable(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+EXPORT_SYMBOL(drm_panel_enable);
+
+/**
+ * drm_panel_disable - disable a panel
+ * @panel: DRM panel
+ *
+ * This will typically turn off the panel's backlight or disable the display
+ * drivers. For smart panels it should still be possible to communicate with
+ * the integrated circuitry via any command bus after this call.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int drm_panel_disable(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->disable)
+		return panel->funcs->disable(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+EXPORT_SYMBOL(drm_panel_disable);
+
+/**
+ * drm_panel_unprepare - power off a panel
+ * @panel: DRM panel
+ *
+ * Calling this function will completely power off a panel (assert the panel's
+ * reset, turn off power supplies, ...). After this function has completed, it
+ * is usually no longer possible to communicate with the panel until another
+ * call to drm_panel_prepare().
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int drm_panel_unprepare(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->unprepare)
+		return panel->funcs->unprepare(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+EXPORT_SYMBOL(drm_panel_unprepare);
+
+/**
+ * drm_panel_get_modes - probe the available display modes of a panel
+ * @panel: DRM panel
+ *
+ * The modes probed from the panel are automatically added to the connector
+ * that the panel is attached to.
+ *
+ * Return: The number of modes available from the panel on success or a
+ * negative error code on failure.
+ */
+int drm_panel_get_modes(struct drm_panel *panel)
+{
+	if (panel && panel->funcs && panel->funcs->get_modes)
+		return panel->funcs->get_modes(panel);
+
+	return panel ? -ENOSYS : -EINVAL;
+}
+EXPORT_SYMBOL(drm_panel_get_modes);
+
 /**
  * drm_panel_add - add a panel to the global registry
  * @panel: panel to add
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 26377836141c..053d611656b9 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -97,97 +97,6 @@ struct drm_panel {
 	struct list_head list;
 };
 
-/**
- * drm_disable_unprepare - power off a panel
- * @panel: DRM panel
- *
- * Calling this function will completely power off a panel (assert the panel's
- * reset, turn off power supplies, ...). After this function has completed, it
- * is usually no longer possible to communicate with the panel until another
- * call to drm_panel_prepare().
- *
- * Return: 0 on success or a negative error code on failure.
- */
-static inline int drm_panel_unprepare(struct drm_panel *panel)
-{
-	if (panel && panel->funcs && panel->funcs->unprepare)
-		return panel->funcs->unprepare(panel);
-
-	return panel ? -ENOSYS : -EINVAL;
-}
-
-/**
- * drm_panel_disable - disable a panel
- * @panel: DRM panel
- *
- * This will typically turn off the panel's backlight or disable the display
- * drivers. For smart panels it should still be possible to communicate with
- * the integrated circuitry via any command bus after this call.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-static inline int drm_panel_disable(struct drm_panel *panel)
-{
-	if (panel && panel->funcs && panel->funcs->disable)
-		return panel->funcs->disable(panel);
-
-	return panel ? -ENOSYS : -EINVAL;
-}
-
-/**
- * drm_panel_prepare - power on a panel
- * @panel: DRM panel
- *
- * Calling this function will enable power and deassert any reset signals to
- * the panel. After this has completed it is possible to communicate with any
- * integrated circuitry via a command bus.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-static inline int drm_panel_prepare(struct drm_panel *panel)
-{
-	if (panel && panel->funcs && panel->funcs->prepare)
-		return panel->funcs->prepare(panel);
-
-	return panel ? -ENOSYS : -EINVAL;
-}
-
-/**
- * drm_panel_enable - enable a panel
- * @panel: DRM panel
- *
- * Calling this function will cause the panel display drivers to be turned on
- * and the backlight to be enabled. Content will be visible on screen after
- * this call completes.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-static inline int drm_panel_enable(struct drm_panel *panel)
-{
-	if (panel && panel->funcs && panel->funcs->enable)
-		return panel->funcs->enable(panel);
-
-	return panel ? -ENOSYS : -EINVAL;
-}
-
-/**
- * drm_panel_get_modes - probe the available display modes of a panel
- * @panel: DRM panel
- *
- * The modes probed from the panel are automatically added to the connector
- * that the panel is attached to.
- *
- * Return: The number of modes available from the panel on success or a
- * negative error code on failure.
- */
-static inline int drm_panel_get_modes(struct drm_panel *panel)
-{
-	if (panel && panel->funcs && panel->funcs->get_modes)
-		return panel->funcs->get_modes(panel);
-
-	return panel ? -ENOSYS : -EINVAL;
-}
-
 void drm_panel_init(struct drm_panel *panel);
 
 int drm_panel_add(struct drm_panel *panel);
@@ -196,6 +105,14 @@ void drm_panel_remove(struct drm_panel *panel);
 int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector);
 int drm_panel_detach(struct drm_panel *panel);
 
+int drm_panel_prepare(struct drm_panel *panel);
+int drm_panel_unprepare(struct drm_panel *panel);
+
+int drm_panel_enable(struct drm_panel *panel);
+int drm_panel_disable(struct drm_panel *panel);
+
+int drm_panel_get_modes(struct drm_panel *panel);
+
 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL)
 struct drm_panel *of_drm_find_panel(const struct device_node *np);
 #else
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 10/16] drm/panel: ili9322: move bus_flags to get_modes()
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

To prepare the driver to receive drm_connector only in the get_modes()
callback, move bus_flags handling to ili9322_get_modes().

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/panel/panel-ilitek-ili9322.c | 34 +++++++++-----------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9322.c b/drivers/gpu/drm/panel/panel-ilitek-ili9322.c
index 53dd1e128795..3c58f63adbf7 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9322.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9322.c
@@ -349,7 +349,6 @@ static const struct regmap_config ili9322_regmap_config = {
 
 static int ili9322_init(struct drm_panel *panel, struct ili9322 *ili)
 {
-	struct drm_connector *connector = panel->connector;
 	u8 reg;
 	int ret;
 	int i;
@@ -407,23 +406,11 @@ static int ili9322_init(struct drm_panel *panel, struct ili9322 *ili)
 	 * Polarity and inverted color order for RGB input.
 	 * None of this applies in the BT.656 mode.
 	 */
-	if (ili->conf->dclk_active_high) {
+	reg = 0;
+	if (ili->conf->dclk_active_high)
 		reg = ILI9322_POL_DCLK;
-		connector->display_info.bus_flags |=
-			DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
-	} else {
-		reg = 0;
-		connector->display_info.bus_flags |=
-			DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
-	}
-	if (ili->conf->de_active_high) {
+	if (ili->conf->de_active_high)
 		reg |= ILI9322_POL_DE;
-		connector->display_info.bus_flags |=
-			DRM_BUS_FLAG_DE_HIGH;
-	} else {
-		connector->display_info.bus_flags |=
-			DRM_BUS_FLAG_DE_LOW;
-	}
 	if (ili->conf->hsync_active_high)
 		reg |= ILI9322_POL_HSYNC;
 	if (ili->conf->vsync_active_high)
@@ -659,9 +646,20 @@ static int ili9322_get_modes(struct drm_panel *panel)
 	struct drm_connector *connector = panel->connector;
 	struct ili9322 *ili = panel_to_ili9322(panel);
 	struct drm_display_mode *mode;
+	struct drm_display_info *info;
+
+	info = &connector->display_info;
+	info->width_mm = ili->conf->width_mm;
+	info->height_mm = ili->conf->height_mm;
+	if (ili->conf->dclk_active_high)
+		info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
+	else
+		info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
 
-	connector->display_info.width_mm = ili->conf->width_mm;
-	connector->display_info.height_mm = ili->conf->height_mm;
+	if (ili->conf->de_active_high)
+		info->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
+	else
+		info->bus_flags |= DRM_BUS_FLAG_DE_LOW;
 
 	switch (ili->input) {
 	case ILI9322_INPUT_SRGB_DUMMY_320X240:
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 09/16] drm/tegra: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use the drm_panel_get_modes function.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org
---
 drivers/gpu/drm/tegra/output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 274cb955e2e1..52b8396ec2dc 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -23,7 +23,7 @@ int tegra_output_connector_get_modes(struct drm_connector *connector)
 	 * ignore any other means of obtaining a mode.
 	 */
 	if (output->panel) {
-		err = output->panel->funcs->get_modes(output->panel);
+		err = drm_panel_get_modes(output->panel);
 		if (err > 0)
 			return err;
 	}
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 08/16] drm/sti: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use the drm_panel_(enable|disable|get_modes) functions.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
---
 drivers/gpu/drm/sti/sti_dvo.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 9e6d5d8b7030..e55870190bf5 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -221,8 +221,7 @@ static void sti_dvo_disable(struct drm_bridge *bridge)
 
 	writel(0x00000000, dvo->regs + DVO_DOF_CFG);
 
-	if (dvo->panel)
-		dvo->panel->funcs->disable(dvo->panel);
+	drm_panel_disable(dvo->panel);
 
 	/* Disable/unprepare dvo clock */
 	clk_disable_unprepare(dvo->clk_pix);
@@ -262,8 +261,7 @@ static void sti_dvo_pre_enable(struct drm_bridge *bridge)
 	if (clk_prepare_enable(dvo->clk))
 		DRM_ERROR("Failed to prepare/enable dvo clk\n");
 
-	if (dvo->panel)
-		dvo->panel->funcs->enable(dvo->panel);
+	drm_panel_enable(dvo->panel);
 
 	/* Set LUT */
 	writel(config->lowbyte,  dvo->regs + DVO_LUT_PROG_LOW);
@@ -340,7 +338,7 @@ static int sti_dvo_connector_get_modes(struct drm_connector *connector)
 	struct sti_dvo *dvo = dvo_connector->dvo;
 
 	if (dvo->panel)
-		return dvo->panel->funcs->get_modes(dvo->panel);
+		return drm_panel_get_modes(dvo->panel);
 
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 07/16] drm/mxsfb: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use the drm_panel_get_modes() function.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/mxsfb/mxsfb_out.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_out.c b/drivers/gpu/drm/mxsfb/mxsfb_out.c
index 231d016c6f47..be36f4d6cc96 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_out.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_out.c
@@ -30,7 +30,7 @@ static int mxsfb_panel_get_modes(struct drm_connector *connector)
 			drm_connector_to_mxsfb_drm_private(connector);
 
 	if (mxsfb->panel)
-		return mxsfb->panel->funcs->get_modes(mxsfb->panel);
+		return drm_panel_get_modes(mxsfb->panel);
 
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 06/16] drm/msm: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use the function drm_panel_get_modes().

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Allison Randal <allison@lohutok.net>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Enrico Weigelt <info@metux.net>
---
 drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c
index ecef4f5b9f26..0e21252fd1d6 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c
@@ -55,7 +55,7 @@ static int mdp4_lvds_connector_get_modes(struct drm_connector *connector)
 	if (panel) {
 		drm_panel_attach(panel, connector);
 
-		ret = panel->funcs->get_modes(panel);
+		ret = drm_panel_get_modes(panel);
 
 		drm_panel_detach(panel);
 	}
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 05/16] drm/fsl-dcu: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use drm_panel_get_modes() to access modes.
This has a nice side effect to simplify the code.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Alison Wang <alison.wang@nxp.com>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 279d83eaffc0..a92fd6c70b09 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -65,17 +65,9 @@ static const struct drm_connector_funcs fsl_dcu_drm_connector_funcs = {
 static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
 {
 	struct fsl_dcu_drm_connector *fsl_connector;
-	int (*get_modes)(struct drm_panel *panel);
-	int num_modes = 0;
 
 	fsl_connector = to_fsl_dcu_connector(connector);
-	if (fsl_connector->panel && fsl_connector->panel->funcs &&
-	    fsl_connector->panel->funcs->get_modes) {
-		get_modes = fsl_connector->panel->funcs->get_modes;
-		num_modes = get_modes(fsl_connector->panel);
-	}
-
-	return num_modes;
+	return drm_panel_get_modes(fsl_connector->panel);
 }
 
 static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 04/16] drm/imx: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Use the drm_panel_get_modes() function to get the modes.

This patch leave one test for the function pointer:
    panel->funcs->get_modes

This is used to check if the panel may have any modes.
There is no direct replacement.
We may be able to just check that drm_panel_get_modes() return > 0,
but as this is not the same functionality it is left for later.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/imx/imx-ldb.c          | 11 ++++-------
 drivers/gpu/drm/imx/parallel-display.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index db461b6a257f..695f307f36b2 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -124,14 +124,11 @@ static void imx_ldb_ch_set_bus_format(struct imx_ldb_channel *imx_ldb_ch,
 static int imx_ldb_connector_get_modes(struct drm_connector *connector)
 {
 	struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
-	int num_modes = 0;
+	int num_modes;
 
-	if (imx_ldb_ch->panel && imx_ldb_ch->panel->funcs &&
-	    imx_ldb_ch->panel->funcs->get_modes) {
-		num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
-		if (num_modes > 0)
-			return num_modes;
-	}
+	num_modes = drm_panel_get_modes(imx_ldb_ch->panel);
+	if (num_modes > 0)
+		return num_modes;
 
 	if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
 		imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index 2e51b2fade75..e7ce17503ae1 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -47,14 +47,11 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
 {
 	struct imx_parallel_display *imxpd = con_to_imxpd(connector);
 	struct device_node *np = imxpd->dev->of_node;
-	int num_modes = 0;
+	int num_modes;
 
-	if (imxpd->panel && imxpd->panel->funcs &&
-	    imxpd->panel->funcs->get_modes) {
-		num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
-		if (num_modes > 0)
-			return num_modes;
-	}
+	num_modes = drm_panel_get_modes(imxpd->panel);
+	if (num_modes > 0)
+		return num_modes;
 
 	if (imxpd->edid) {
 		drm_connector_update_edid_property(connector, imxpd->edid);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 03/16] drm/exynos: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Call via drm_panel_get_modes().

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
---
 drivers/gpu/drm/exynos/exynos_drm_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 6926cee91b36..36b02b456d9c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1460,7 +1460,7 @@ static int exynos_dsi_get_modes(struct drm_connector *connector)
 	struct exynos_dsi *dsi = connector_to_dsi(connector);
 
 	if (dsi->panel)
-		return dsi->panel->funcs->get_modes(dsi->panel);
+		return drm_panel_get_modes(dsi->panel);
 
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 02/16] drm/exynos: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

drm_panel_attach() will check if there is a controller
already attached - drop the check in the driver.

Use drm_panel_get_modes() so the driver no longer uses the function
pointer.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 3cebb19ec1c4..5479ff71cbc6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -43,7 +43,7 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
-	if (ctx->panel && !ctx->panel->connector)
+	if (ctx->panel)
 		drm_panel_attach(ctx->panel, &ctx->connector);
 
 	return connector_status_connected;
@@ -85,7 +85,7 @@ static int exynos_dpi_get_modes(struct drm_connector *connector)
 	}
 
 	if (ctx->panel)
-		return ctx->panel->funcs->get_modes(ctx->panel);
+		return drm_panel_get_modes(ctx->panel);
 
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 01/16] drm/bridge: tc358767: fix opencoded use of drm_panel_*
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt
In-Reply-To: <20190804201637.1240-1-sam@ravnborg.org>

Replace open coded version with call to drm_panel_get_modes().

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/bridge/tc358767.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 42f03a985ac0..cebc8e620820 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1312,7 +1312,7 @@ static int tc_connector_get_modes(struct drm_connector *connector)
 {
 	struct tc_data *tc = connector_to_tc(connector);
 	struct edid *edid;
-	unsigned int count;
+	int count;
 	int ret;
 
 	ret = tc_get_display_props(tc);
@@ -1321,11 +1321,9 @@ static int tc_connector_get_modes(struct drm_connector *connector)
 		return 0;
 	}
 
-	if (tc->panel && tc->panel->funcs && tc->panel->funcs->get_modes) {
-		count = tc->panel->funcs->get_modes(tc->panel);
-		if (count > 0)
-			return count;
-	}
+	count = drm_panel_get_modes(tc->panel);
+	if (count > 0)
+		return count;
 
 	edid = drm_get_edid(connector, &tc->aux.ddc);
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH v1 0/16] drm: panel related updates
From: Sam Ravnborg @ 2019-08-04 20:16 UTC (permalink / raw)
  To: dri-devel, Thierry Reding
  Cc: Neil Armstrong, David Airlie, Linus Walleij, Stefan Agner,
	Andrzej Hajda, Laurent Pinchart, Benjamin Gaignard, Fabio Estevam,
	Marek Vasut, Laurent Pinchart, Joonyoung Shim, Sam Ravnborg,
	Krzysztof Kozlowski, Jonathan Hunter, Maxime Ripard, Kukjin Kim,
	Allison Randal, Philipp Zabel, NXP Linux Team,
	Pengutronix Kernel Team, Jonas Karlman, Sascha Hauer, Alison Wang,
	Maarten Lankhorst, Gwan-gyeong Mun, Inki Dae, Alexios Zavras,
	linux-samsung-soc, linux-tegra, Thomas Gleixner, Sean Paul,
	linux-arm-kernel, Jernej Skrabec, Shawn Guo, Seung-Woo Kim,
	Vincent Abriou, Kyungmin Park, Daniel Vetter, Enrico Weigelt

The first 9 patches replaces direct use of the drm_panel
function pointers with their drm_panel_* counterparts.
The function pointers are only supposed to be used by
the drm_panel infrastructure and direct use are discouraged.

ili9322 is updated to handle bus_flags in get_modes like everyone else.
This is in preparation for a later patch series where controller
becomes an arugument to get_modes() and not like today where drm_panel
is attached to a controller.

The remaining patches move functionality to the drm_panel core that
today are repeated in many drivers.
As preparation for this the inline functions are moved to drm_panel.c
and kernel-doc is made inline.
panel-simple is updated to benefit from the additional infrastructure
and is an example for the simplifications that can be done.

The patchset has been tested on my embedded target,
and build tested.

Feedback welcome!

The "fix opencoded" patches are all independent and can be applied
out of order. They were kept here to keep panel related patches in one series.

	Sam

Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Alison Wang <alison.wang@nxp.com>
Cc: Allison Randal <allison@lohutok.net>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: Enrico Weigelt <info@metux.net>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Paul <sean@poorly.run>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincent Abriou <vincent.abriou@st.com>

Sam Ravnborg (16):
      drm/bridge: tc358767: fix opencoded use of drm_panel_*
      drm/exynos: fix opencoded use of drm_panel_*
      drm/exynos: fix opencoded use of drm_panel_*
      drm/imx: fix opencoded use of drm_panel_*
      drm/fsl-dcu: fix opencoded use of drm_panel_*
      drm/msm: fix opencoded use of drm_panel_*
      drm/mxsfb: fix opencoded use of drm_panel_*
      drm/sti: fix opencoded use of drm_panel_*
      drm/tegra: fix opencoded use of drm_panel_*
      drm/panel: ili9322: move bus_flags to get_modes()
      drm/panel: move drm_panel functions to .c file
      drm/panel: use inline comments in drm_panel.h
      drm/panel: drop return code from drm_panel_detach()
      drm/panel: call prepare/enable only once
      drm/panel: add backlight support
      drm/panel: simple: use drm_panel infrastructure

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c |   3 +-
 drivers/gpu/drm/bridge/tc358767.c                  |  10 +-
 drivers/gpu/drm/drm_panel.c                        | 185 ++++++++++++++++-
 drivers/gpu/drm/exynos/exynos_drm_dpi.c            |   4 +-
 drivers/gpu/drm/exynos/exynos_drm_dsi.c            |   2 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c          |  10 +-
 drivers/gpu/drm/imx/imx-ldb.c                      |  11 +-
 drivers/gpu/drm/imx/parallel-display.c             |  11 +-
 .../gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c    |   2 +-
 drivers/gpu/drm/mxsfb/mxsfb_out.c                  |   2 +-
 drivers/gpu/drm/panel/panel-ilitek-ili9322.c       |  34 ++-
 drivers/gpu/drm/panel/panel-simple.c               |  73 +------
 drivers/gpu/drm/sti/sti_dvo.c                      |   8 +-
 drivers/gpu/drm/tegra/output.c                     |   2 +-
 include/drm/drm_panel.h                            | 227 +++++++++++----------
 15 files changed, 349 insertions(+), 235 deletions(-)



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 1/3] RFT: drm/pl111: Support grayscale
From: Fabian Vogt @ 2019-08-04 20:13 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Daniel Tang, open list:DRM PANEL DRIVERS, Linux ARM
In-Reply-To: <CACRpkda-5xu2-X5yo=dXchSvuD=ZmZSpTbGNrkv6V+UKs27xWA@mail.gmail.com>

Hi,

Am Samstag, 3. August 2019, 11:51:59 CEST schrieb Linus Walleij:
> On Thu, Jul 25, 2019 at 9:26 PM Fabian Vogt <fabian@ritter-vogt.de> wrote:
> 
> > On a real CX the LCD displays shows content without
> > any other changes to the set, but has a ~3Hz pulsating effect scrolling from
> > the top to the bottom and the gray text changes color slightly.
> 
> So you mean something meaningful appears in the LCD
> but there are visual disturbances?
> 
> > Without the patchset applied everything looks perfectly.
> >
> > I tried setting vrefresh to 20, fb_bpp to 16 and forcing an inverted panel
> > clock, but the pulsing didn't change.
> >
> > Using the emulated CX I compared the contents of the registers and found
> > that only the IPC bit (which I tried to set, so that's likely not it) and
> > the interrupt registers have a different content.
> >
> > Any idea?
> 
> I think it's the clock settings in patch 2/3.
> 
> I just set them to "1000" (1MHz since its in kHz) based on some
> educated guesses.
> 
> The old driver set the clock to "1" (kHz) so just try that first,
> maybe it is really that slow.

Did that, it looked rather unhealthy for the LCD. Mostly white with some
glitching except for ~2-3 lines with content scrolling on the screen.

200kHz was still way to slow, so tried the opposite direction.
With a clock of 10MHz the display seems to be working fine and produces a
visibly stable output.

Thanks,
Fabian

> It's just that the old driver also set refres to 60 fps which doesn't
> add up, but I think that setting is simply ignored and that is why
> it works.
>
> Yours,
> Linus Walleij

---
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index e5cfe1398a3b..3addcdab8adb 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -2763,7 +2763,7 @@ static const struct panel_desc arm_rtsm = {
 
 static const struct drm_display_mode nspire_cx_lcd_mode[] = {
 	{
-		.clock = 1000,
+		.clock = 10000,
 		.hdisplay = 320,
 		.hsync_start = 320 + 50,
 		.hsync_end = 320 + 50 + 6,
@@ -2791,7 +2791,7 @@ static const struct panel_desc nspire_cx_lcd_panel = {
 
 static const struct drm_display_mode nspire_classic_lcd_mode[] = {
 	{
-		.clock = 1000,
+		.clock = 10000,
 		.hdisplay = 320,
 		.hsync_start = 320 + 6,
 		.hsync_end = 320 + 6 + 6,




_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] clk: versatile: Add of_node_put() in cm_osc_setup()
From: Nishka Dasgupta @ 2019-08-04 16:34 UTC (permalink / raw)
  To: mturquette, sboyd, linux-clk, linus.walleij, linux-arm-kernel
  Cc: Nishka Dasgupta

In function cm_osc_setup, variable parent takes the value returned by
of_get_parent, which gets a node but does not put it. If parent is not
put before it goes out of scope, it may cause a memory leak.
Hence put parent before the function terminates.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/clk/versatile/clk-versatile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c
index 90bb0b041b7a..fd54d5c0251c 100644
--- a/drivers/clk/versatile/clk-versatile.c
+++ b/drivers/clk/versatile/clk-versatile.c
@@ -70,6 +70,7 @@ static void __init cm_osc_setup(struct device_node *np,
 			return;
 		}
 		cm_base = of_iomap(parent, 0);
+		of_node_put(parent);
 		if (!cm_base) {
 			pr_err("could not remap core module base\n");
 			return;
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] pinctrl: freescale: mxs: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-08-04 16:04 UTC (permalink / raw)
  To: linus.walleij, linux-arm-kernel, linux-gpio, linux-imx, s.hauer,
	kernel, stefan, shawnguo, festevam, aisheng.dong
  Cc: Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in
the case of a return from the middle of the loop, there is no put, thus
causing a memory leak. Hence add an of_node_put before the return in
three places.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/freescale/pinctrl-mxs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c
index 641b3088876f..735cedd0958a 100644
--- a/drivers/pinctrl/freescale/pinctrl-mxs.c
+++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
@@ -488,8 +488,10 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 		if (of_property_read_u32(child, "reg", &val)) {
 			ret = mxs_pinctrl_parse_group(pdev, child,
 						      idxg++, NULL);
-			if (ret)
+			if (ret) {
+				of_node_put(child);
 				return ret;
+			}
 			continue;
 		}
 
@@ -499,15 +501,19 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 						 f->ngroups,
 						 sizeof(*f->groups),
 						 GFP_KERNEL);
-			if (!f->groups)
+			if (!f->groups) {
+				of_node_put(child);
 				return -ENOMEM;
+			}
 			fn = child->name;
 			i = 0;
 		}
 		ret = mxs_pinctrl_parse_group(pdev, child, idxg++,
 					      &f->groups[i++]);
-		if (ret)
+		if (ret) {
+			of_node_put(child);
 			return ret;
+		}
 	}
 
 	return 0;
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] pinctrl: samsung: exynos: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-08-04 16:02 UTC (permalink / raw)
  To: linus.walleij, linux-arm-kernel, linux-gpio, tomasz.figa, krzk,
	s.nawrocki, kgene, linux-samsung-soc
  Cc: Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in
the case of a return from the middle of the loop, there is no put, thus
causing a memory leak. Hence add an of_node_put before the return.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/samsung/pinctrl-exynos.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index ebc27b06718c..e7f4cbad2c92 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -486,8 +486,10 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		if (match) {
 			irq_chip = kmemdup(match->data,
 				sizeof(*irq_chip), GFP_KERNEL);
-			if (!irq_chip)
+			if (!irq_chip) {
+				of_node_put(np);
 				return -ENOMEM;
+			}
 			wkup_np = np;
 			break;
 		}
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] pinctrl: nomadik: abx500: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-08-04 15:51 UTC (permalink / raw)
  To: linus.walleij, linux-arm-kernel, linux-gpio; +Cc: Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in
the case of a return from the middle of the loop, there is no put, thus
causing a memory leak. Hence add an of_node_put before the return.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/nomadik/pinctrl-abx500.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index c3595200e1e6..7aa534576a45 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -815,6 +815,7 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
+			of_node_put(np);
 			return ret;
 		}
 	}
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] pinctrl: nomadik: nomadik: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-08-04 15:51 UTC (permalink / raw)
  To: linus.walleij, linux-arm-kernel, linux-gpio; +Cc: Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in
the case of a return from the middle of the loop, there is no put, thus
causing a memory leak. Hence add an of_node_put before the return.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index ddd1f466d302..2a8190b11d10 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -1508,6 +1508,7 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
+			of_node_put(np);
 			return ret;
 		}
 	}
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH] pinctrl: spear: spear: Add of_node_put() before return
From: Nishka Dasgupta @ 2019-08-04 15:49 UTC (permalink / raw)
  To: vireshk, linus.walleij, linux-arm-kernel, linux-gpio; +Cc: Nishka Dasgupta

Each iteration of for_each_child_of_node puts the previous node, but in
the case of a return from the middle of the loop, there is no put, thus
causing a memory leak. Hence add an of_node_put before the return in
two places.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/pinctrl/spear/pinctrl-spear.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
index c4f850345dc4..7ec19c73f870 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -157,12 +157,16 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	/* calculate number of maps required */
 	for_each_child_of_node(np_config, np) {
 		ret = of_property_read_string(np, "st,function", &function);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(np);
 			return ret;
+		}
 
 		ret = of_property_count_strings(np, "st,pins");
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(np);
 			return ret;
+		}
 
 		count += ret;
 	}
-- 
2.19.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* Re: [PATCH 0/1] coresight: Fix for v5.3-rc3
From: Mathieu Poirier @ 2019-08-04 13:26 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-arm-kernel, Suzuki K. Poulose
In-Reply-To: <20190802091028.GA14004@kroah.com>

On Fri, 2 Aug 2019 at 03:10, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Thu, Aug 01, 2019 at 02:16:46PM -0600, Mathieu Poirier wrote:
> > On Thu, 1 Aug 2019 at 12:17, Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Thu, Aug 01, 2019 at 11:23:22AM -0600, Mathieu Poirier wrote:
> > > > Good morning Greg,
> > > >
> > > > Here is a fix I'd like you to consider for this cycle.  Do you think you
> > > > could apply it to driver-core-next rather than char-misc-next?
> > >
> > > All of my -next branches are for 5.4-rc1, not 5.3 (i.e. the "next"
> > > kernel).
> > >
> > > So either one of them isn't going to matter to you for 5.3-final.
> > >
> > > > My current
> > > > coresight branch is based on driver-core-next to pick up Suzuki's
> > > > generic device lookup helpers patchset [1]. Applying it to char-misc-next
> > > > will create two different signature for the same patch, something that
> > > > gives Stephen a hard time when building the linux-next tree.
> > >
> > > Why would Suzuki's patch matter for 5.3-final?
> >
> > There was a similar situation during the 5.2 cycle [1].  Here too we
> > can fix a problem that is present in 5.3 rather than wait for 5.4.
> >
> > [1]. https://www.spinics.net/lists/arm-kernel/msg736274.html
>
> But that has nothing to do with Suzuki's patch that is in my driver core
> tree.  I still fail to see the dependency here.

There is indeed no correlation between the fix and the patches in the
core tree.  When writing the original email I didn't know in what tree
you would end up applying the patch and feared we'd end up having the
same patch in two different tree.  Thanks to your explanation below
this won't happen.

>
> > > > I also think this patch should go in stable but haven't marked it as such since
> > > > it doesn't apply to any of the stable trees.  Once it is part of v5.3 I intend
> > > > to send a new version of the patch that does apply cleanly to those trees.  Let
> > > > me know if you want me to proceed differently.
> > > >
> > > > Thanks,
> > > > Mathieu
> > > >
> > > > [1]. https://www.spinics.net/lists/dri-devel/msg219674.html
> > > >
> > > >
> > > > Suzuki K Poulose (1):
> > > >   coresight: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
> > > >
> > > >  drivers/hwtracing/coresight/coresight-etm-perf.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > >
> > > Why would this patch depend on anything in any of my trees?
> >
> > I send you patches for inclusion in the next cycle and as such I
> > thought it should be the same for fixes in the current cycle.  If that
> > is not the case, should I send them directly to Linus?
>
> You can send me fixes to forward on to Linus for this current cycle, if
> they are not depending on patches that are only for the -next release.
>
> I always keep 2 branches in my git trees:
>         -linus : patches for Linus this release cycle
>         -next  : patches for Linus the next release cycle
>
> If you have bugfixes, make them against my -linus branch and send them
> on.  Odds are they don't have dependancies other than what is in Linus's
> tree, so that's fine.

Perfect, that's the link I was missing.

Thanks,
Mathieu

>
> If you have patches for the next cycle, send them against my -next
> branch.
>
> thanks,
>
> greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH v4 6/6] dt-bindings: arm: coresight: Add support for coresight-needs-save-restore
From: Mathieu Poirier @ 2019-08-04 13:13 UTC (permalink / raw)
  To: Andrew Murray
  Cc: Al Grant, Suzuki K Poulose, Alexander Shishkin, Coresight ML,
	Sudeep Holla, Leo Yan, linux-arm-kernel, Mike Leach
In-Reply-To: <20190802143751.GP56241@e119886-lin.cambridge.arm.com>

On Fri, 2 Aug 2019 at 08:37, Andrew Murray <andrew.murray@arm.com> wrote:
>
> On Fri, Aug 02, 2019 at 11:40:54AM +0100, Suzuki K Poulose wrote:
> > Hi Andrew,
> >
> > On 30/07/2019 13:51, Andrew Murray wrote:
> > > Some coresight components, because of choices made during hardware
> > > integration, require their state to be saved and restored across CPU low
> > > power states.
> > >
> > > The software has no reliable method of detecting when save/restore is
> > > required thus let's add a binding to inform the kernel.
> > >
> > > Signed-off-by: Andrew Murray <andrew.murray@arm.com>
> > > ---
> > >   Documentation/devicetree/bindings/arm/coresight.txt | 3 +++
> > >   1 file changed, 3 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/arm/coresight.txt b/Documentation/devicetree/bindings/arm/coresight.txt
> > > index fcc3bacfd8bc..7cbdb7893af8 100644
> > > --- a/Documentation/devicetree/bindings/arm/coresight.txt
> > > +++ b/Documentation/devicetree/bindings/arm/coresight.txt
> > > @@ -92,6 +92,9 @@ its hardware characteristcs.
> > >     * arm,cp14: must be present if the system accesses ETM/PTM management
> > >       registers via co-processor 14.
> > > +   * arm,coresight-needs-save-restore: boolean. Indicates that software
> > > +     should save/restore state across power down.
> > > +
> >
> > Do you think we could be a bit more descriptive here about when people could add
> > it to the DT ? Here we don't mention when someone should use this property and
> > it may be added to platforms where it may be absolutely unnecessary. How about :
> >
> > "Indicates that the hardware implementation may not honor the Powerup request
> > from the software and thus might loose the register context on CPU power
> > down (e.g, during CPUIdle). Software must save/restore the context during a
> > CPU power transition cycle."
>
> How about the following:
>
> "Indicates that the hardware will loose register context on CPU power down (e.g.
> CPUIdle), despite the TRCPDCR.PU bit being set."
>
> I'm keen to avoid making suggestions about what the kernel will do when it sees
> this flag and thus prefer to focus on describing what the hardware does. So I
> dropped your last sentence. However the name of the flag still implies policy
> which I don't like.
>
> I also changed the 'may not honor' wording, I'm not sure if this is really the
> case or if the spec is open to interpretation.
>
> It would great for this wording to also apply to other CS components though I
> haven't investigated if these have a PU bit or something different.

Exactly - the definition needs to be broad enough to apply to other CS
components.  Mike what do you think would be appropriate for CTIs?

>
> Thanks,
>
> Andrew Murray
>
> >
> > Cheers
> > Suzuki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH] arm64: dts: rockchip: Add dts for Leez RK3399 P710 SBC
From: Heiko Stuebner @ 2019-08-04  9:59 UTC (permalink / raw)
  To: Andy Yan
  Cc: devicetree, robh+dt, linux-kernel, linux-arm-kernel,
	open list:ARM/Rockchip SoC...
In-Reply-To: <CANbgqATNLO=wJfKNDY74qmQUqAP_9Xv29nGhLj+Y0Cc7CAMQyg@mail.gmail.com>

Hi Andy,

Am Sonntag, 4. August 2019, 10:38:26 CEST schrieb Andy Yan:
> Heiko Stuebner <heiko@sntech.de> 于2019年8月4日周日 上午8:34写道:
> > Am Samstag, 3. August 2019, 13:46:12 CEST schrieb Andy Yan:
> > > Leez P710 is a RK3399 based SBC, designed by Leez team
> > > from lenovo [0].
> > >
> > > Specification
> > > - Rockchip RK3399
> > > - 4/2GB LPDDR4
> > > - TF sd scard slot
> > > - eMMC
> > > - M.2 B-Key for 4G LTE
> > > - AP6256 for WiFi + BT
> > > - Gigabit ethernet
> > > - HDMI out
> > > - 40 pin header
> > > - TYPE-C Power supply
> > >
> > > [0] https://leez.lenovo.com
> > >
> > > Signed-off-by: Andy Yan <andyshrk@gmail.com>
> > > ---
> > >  .../devicetree/bindings/arm/rockchip.yaml     |   5 +
> > >  arch/arm64/boot/dts/rockchip/Makefile         |   1 +
> > >  .../boot/dts/rockchip/rk3399-leez-p710.dts    | 635 ++++++++++++++++++
> > >  3 files changed, 641 insertions(+)
> > >  create mode 100644 arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts
> > >
> > > diff --git a/Documentation/devicetree/bindings/arm/rockchip.yaml
> > b/Documentation/devicetree/bindings/arm/rockchip.yaml
> > > index 34865042f4e4..da9cd947abfa 100644
> > > --- a/Documentation/devicetree/bindings/arm/rockchip.yaml
> > > +++ b/Documentation/devicetree/bindings/arm/rockchip.yaml
> > > @@ -329,6 +329,11 @@ properties:
> > >                - khadas,edge-v
> > >            - const: rockchip,rk3399
> > >
> > > +      - description: Leez RK3399 P710
> > > +        items:
> > > +          - const: leez,p710
> >
> > Is "leez" really the vendor?
> > Part of me would assume something like
> >         lenovo,leez-p710
> >
> >
> According to Leez team, they want to treat Leez an independent vendor here。

ok, that should be fine then. You'll just have to also add
an entry for them into the vendor-prefixes.yaml file then.

(And of course rework the regulator tree)

Thanks
Heiko

> > So please clarify :-)
> > And also please make sure the decided vendor is part of the vendor-prefixes
> > binding in Documentation/devicestree/bindings/vendor-prefixes.yaml
> >
> > > +          - const: rockchip,rk3399
> > > +
> > >        - description: mqmaker MiQi
> > >          items:
> > >            - const: mqmaker,miqi
> > > diff --git a/arch/arm64/boot/dts/rockchip/Makefile
> > b/arch/arm64/boot/dts/rockchip/Makefile
> > > index daa2c78e22c3..1f18a9392d15 100644
> > > --- a/arch/arm64/boot/dts/rockchip/Makefile
> > > +++ b/arch/arm64/boot/dts/rockchip/Makefile
> > > @@ -20,6 +20,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-hugsun-x99.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge-captain.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge-v.dtb
> > > +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-leez-p710.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopc-t4.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopi-m4.dtb
> > >  dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopi-neo4.dtb
> > > diff --git a/arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts
> > b/arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts
> > > new file mode 100644
> > > index 000000000000..b342f5e8692b
> > > --- /dev/null
> > > +++ b/arch/arm64/boot/dts/rockchip/rk3399-leez-p710.dts
> > > @@ -0,0 +1,635 @@
> > > +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> > > +/*
> > > + * Copyright (c) 2019 Andy Yan <andy.yan@gmail.com>
> > > + */
> > > +
> > > +/dts-v1/;
> > > +#include <dt-bindings/input/linux-event-codes.h>
> > > +#include <dt-bindings/pwm/pwm.h>
> > > +#include "rk3399.dtsi"
> > > +#include "rk3399-opp.dtsi"
> > > +
> > > +/ {
> > > +     model = "Leez RK3399 P710";
> > > +     compatible = "leez,p710", "rockchip,rk3399";
> >
> > same comment as above, so maybe:
> >         model = "Lenovo Leez RK3399 P710";
> >         compatible = "lenovo,leez-p710", "rockchip,rk3399";
> >
> >
> >
> > > +
> > > +     chosen {
> > > +             stdout-path = "serial2:1500000n8";
> > > +     };
> > > +
> > > +     clkin_gmac: external-gmac-clock {
> > > +             compatible = "fixed-clock";
> > > +             clock-frequency = <125000000>;
> > > +             clock-output-names = "clkin_gmac";
> > > +             #clock-cells = <0>;
> > > +     };
> > > +
> > > +     sdio_pwrseq: sdio-pwrseq {
> > > +             compatible = "mmc-pwrseq-simple";
> > > +             clocks = <&rk808 1>;
> > > +             clock-names = "ext_clock";
> > > +             pinctrl-names = "default";
> > > +             pinctrl-0 = <&wifi_enable_h>;
> > > +             reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
> > > +     };
> > > +
> > > +     dc5v_adp: dc-5v {
> > > +             compatible = "regulator-fixed";
> > > +             regulator-name = "dc5v_adapter";
> > > +             regulator-always-on;
> > > +             regulator-boot-on;
> > > +             regulator-min-microvolt = <5000000>;
> > > +             regulator-max-microvolt = <5000000>;
> > > +     };
> > > +
> > > +     vcc5v0_sys: vcc-sys {
> >
> > vcc5v0_sys: vcc5v0-sys ?
> >
> > > +             compatible = "regulator-fixed";
> > > +             regulator-name = "vcc5v0_sys";
> > > +             regulator-always-on;
> > > +             regulator-boot-on;
> > > +             regulator-min-microvolt = <5000000>;
> > > +             regulator-max-microvolt = <5000000>;
> > > +             vin-supply = <&dc5v_adp>;
> > > +     };
> > > +
> > > +     vcc3v3_sys: vcc3v3-sys {
> > > +             compatible = "regulator-fixed";
> > > +             regulator-name = "vcc3v3_sys";
> > > +             regulator-always-on;
> > > +             regulator-boot-on;
> > > +             regulator-min-microvolt = <3300000>;
> > > +             regulator-max-microvolt = <3300000>;
> > > +             vin-supply = <&vcc5v0_sys>;
> > > +     };
> > > +
> > > +     vcc5v0_host: vcc5v0-host-regulator {
> > > +             compatible = "regulator-fixed";
> > > +             enable-active-high;
> > > +             gpio = <&gpio2 RK_PA2 GPIO_ACTIVE_HIGH>;
> > > +             pinctrl-names = "default";
> > > +             pinctrl-0 = <&vcc5v0_host_en>;
> > > +             regulator-name = "vcc5v0_host";
> > > +             regulator-always-on;
> > > +             vin-supply = <&vcc5v0_sys>;
> > > +     };
> > > +
> > > +     vcc_lan: vcc3v3-phy-regulator {
> > > +             compatible = "regulator-fixed";
> > > +             regulator-name = "vcc_lan";
> > > +             regulator-always-on;
> > > +             regulator-boot-on;
> > > +             regulator-min-microvolt = <3300000>;
> > > +             regulator-max-microvolt = <3300000>;
> > > +
> > > +             regulator-state-mem {
> > > +                     regulator-off-in-suspend;
> > > +             };
> > > +     };
> >
> > In general, please model an actual regulator-tree and do not copy the
> > unspecific Rockchip vendor tree. These unconnected regulators are a very
> > good indicator that the real power-tree got ignored (missing vin-supply
> > here)
> >
> > I found schematics on https://github.com/leezsbc/resources/wiki/Leez-P710:
> > 链接: https://pan.baidu.com/s/1NPWbuI5csT4zftKUCnRs7g
> > 提取码: rvrh
> >
> > and there the power-tree is described in a complete way.
> >
> > regulator/regulator_summaray in the kernels debugfs should
> > show a nice tree structure starting from the dc-adapter input.
> >
> > Also please use names matching the supply names from the schematics.
> >
> > Same for pinctrl names, please use names as used in the board schematics.
> >
> >
> > > +     vdd_log: vdd-log {
> > > +             compatible = "pwm-regulator";
> > > +             pwms = <&pwm2 0 25000 1>;
> > > +             regulator-name = "vdd_log";
> > > +             regulator-always-on;
> > > +             regulator-boot-on;
> > > +             regulator-min-microvolt = <800000>;
> > > +             regulator-max-microvolt = <1400000>;
> > > +             vin-supply = <&vcc5v0_sys>;
> > > +     };
> > > +};
> > > +
> > > +&cpu_l0 {
> > > +     cpu-supply = <&vdd_cpu_l>;
> > > +};
> > > +
> > > +&cpu_l1 {
> > > +     cpu-supply = <&vdd_cpu_l>;
> > > +};
> > > +
> > > +&cpu_l2 {
> > > +     cpu-supply = <&vdd_cpu_l>;
> > > +};
> > > +
> > > +&cpu_l3 {
> > > +     cpu-supply = <&vdd_cpu_l>;
> > > +};
> > > +
> > > +&cpu_b0 {
> > > +     cpu-supply = <&vdd_cpu_b>;
> > > +};
> > > +
> > > +&cpu_b1 {
> > > +     cpu-supply = <&vdd_cpu_b>;
> > > +};
> > > +
> > > +&emmc_phy {
> > > +     status = "okay";
> > > +};
> > > +
> > > +&gmac {
> > > +     assigned-clocks = <&cru SCLK_RMII_SRC>;
> > > +     assigned-clock-parents = <&clkin_gmac>;
> > > +     clock_in_out = "input";
> > > +     phy-supply = <&vcc_lan>;
> > > +     phy-mode = "rgmii";
> > > +     pinctrl-names = "default";
> > > +     pinctrl-0 = <&rgmii_pins>;
> > > +     snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
> > > +     snps,reset-active-low;
> > > +     snps,reset-delays-us = <0 10000 50000>;
> > > +     tx_delay = <0x28>;
> > > +     rx_delay = <0x11>;
> > > +     status = "okay";
> > > +};
> > > +
> > > +&gpu {
> > > +     mali-supply = <&vdd_gpu>;
> > > +     status = "okay";
> > > +};
> > > +
> > > +&hdmi {
> > > +     ddc-i2c-bus = <&i2c3>;
> >
> > can this also use the internal i2c inside the dw-hdmi?
> >
> >
> > > +     pinctrl-names = "default";
> > > +     pinctrl-0 = <&hdmi_cec>;
> > > +     status = "okay";
> > > +};
> > > +
> > > +&hdmi_sound {
> > > +     status = "okay";
> > > +};
> > > +
> > > +&i2c0 {
> > > +     clock-frequency = <400000>;
> > > +     i2c-scl-rising-time-ns = <168>;
> > > +     i2c-scl-falling-time-ns = <4>;
> > > +     status = "okay";
> > > +
> > > +     rk808: pmic@1b {
> > > +             compatible = "rockchip,rk808";
> > > +             reg = <0x1b>;
> > > +             interrupt-parent = <&gpio1>;
> > > +             interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
> > > +             #clock-cells = <1>;
> > > +             clock-output-names = "xin32k", "rk808-clkout2";
> > > +             pinctrl-names = "default";
> > > +             pinctrl-0 = <&pmic_int_l>;
> > > +             rockchip,system-power-controller;
> > > +             wakeup-source;
> > > +
> > > +             vcc1-supply = <&vcc5v0_sys>;
> > > +             vcc2-supply = <&vcc5v0_sys>;
> > > +             vcc3-supply = <&vcc5v0_sys>;
> > > +             vcc4-supply = <&vcc5v0_sys>;
> > > +             vcc6-supply = <&vcc5v0_sys>;
> > > +             vcc7-supply = <&vcc5v0_sys>;
> > > +             vcc8-supply = <&vcc3v3_sys>;
> > > +             vcc9-supply = <&vcc5v0_sys>;
> > > +             vcc10-supply = <&vcc5v0_sys>;
> > > +             vcc11-supply = <&vcc5v0_sys>;
> > > +             vcc12-supply = <&vcc3v3_sys>;
> > > +             vddio-supply = <&vcc_1v8>;
> > > +
> > > +             regulators {
> > > +                     vdd_center: DCDC_REG1 {
> > > +                             regulator-name = "vdd_center";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <750000>;
> > > +                             regulator-max-microvolt = <1350000>;
> > > +                             regulator-ramp-delay = <6001>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vdd_cpu_l: DCDC_REG2 {
> > > +                             regulator-name = "vdd_cpu_l";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <750000>;
> > > +                             regulator-max-microvolt = <1350000>;
> > > +                             regulator-ramp-delay = <6001>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc_ddr: DCDC_REG3 {
> > > +                             regulator-name = "vcc_ddr";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc_1v8: DCDC_REG4 {
> > > +                             regulator-name = "vcc_1v8";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <1800000>;
> > > +                             regulator-max-microvolt = <1800000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                                     regulator-suspend-microvolt =
> > <1800000>;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc1v8_dvp: LDO_REG1 {
> > > +                             regulator-name = "vcc1v8_dvp";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <1800000>;
> > > +                             regulator-max-microvolt = <1800000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc1v8_hdmi: LDO_REG2 {
> > > +                             regulator-name = "vcc1v8_hdmi";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <1800000>;
> > > +                             regulator-max-microvolt = <1800000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcca_1v8: LDO_REG3 {
> > > +                             regulator-name = "vcca_1v8";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <1800000>;
> > > +                             regulator-max-microvolt = <1800000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                                     regulator-suspend-microvolt =
> > <1800000>;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vccio_sd: LDO_REG4 {
> > > +                             regulator-name = "vccio_sd";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <3000000>;
> > > +                             regulator-max-microvolt = <3000000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                                     regulator-suspend-microvolt =
> > <3000000>;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcca3v0_codec: LDO_REG5 {
> > > +                             regulator-name = "vcca3v0_codec";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <3000000>;
> > > +                             regulator-max-microvolt = <3000000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc_1v5: LDO_REG6 {
> > > +                             regulator-name = "vcc_1v5";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <1500000>;
> > > +                             regulator-max-microvolt = <1500000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                                     regulator-suspend-microvolt =
> > <1500000>;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc0v9_hdmi: LDO_REG7 {
> > > +                             regulator-name = "vcc0v9_hdmi";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <900000>;
> > > +                             regulator-max-microvolt = <900000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-off-in-suspend;
> > > +                             };
> > > +                     };
> > > +
> > > +                     vcc_3v0: LDO_REG8 {
> > > +                             regulator-name = "vcc_3v0";
> > > +                             regulator-always-on;
> > > +                             regulator-boot-on;
> > > +                             regulator-min-microvolt = <3000000>;
> > > +                             regulator-max-microvolt = <3000000>;
> > > +                             regulator-state-mem {
> > > +                                     regulator-on-in-suspend;
> > > +                                     regulator-suspend-microvolt =
> > <3000000>;
> > > +                             };
> > > +                     };
> > > +
> >
> > unneeded blank line
> >
> > > +             };
> > > +     };
> > > +
> >
> >
> > Heiko
> >
> >
> >





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 9/9] arm64: Retrieve stolen time as paravirtualized guest
From: Marc Zyngier @ 2019-08-04  9:53 UTC (permalink / raw)
  To: Steven Price
  Cc: kvm, Radim Krčmář, Catalin Marinas,
	Suzuki K Pouloze, linux-doc, Russell King, linux-kernel,
	James Morse, linux-arm-kernel, Paolo Bonzini, Will Deacon, kvmarm,
	Julien Thierry
In-Reply-To: <20190802145017.42543-10-steven.price@arm.com>

On Fri,  2 Aug 2019 15:50:17 +0100
Steven Price <steven.price@arm.com> wrote:

> Enable paravirtualization features when running under a hypervisor
> supporting the PV_TIME_ST hypercall.
> 
> For each (v)CPU, we ask the hypervisor for the location of a shared
> page which the hypervisor will use to report stolen time to us. We set
> pv_time_ops to the stolen time function which simply reads the stolen
> value from the shared page for a VCPU. We guarantee single-copy
> atomicity using READ_ONCE which means we can also read the stolen
> time for another VCPU than the currently running one while it is
> potentially being updated by the hypervisor.
> 
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>  arch/arm64/kernel/Makefile |   1 +
>  arch/arm64/kernel/kvm.c    | 155 +++++++++++++++++++++++++++++++++++++

nit: Why not using paravirt.c, which clearly states what it does? The
alternative would be to name it kvm-pv.c.

>  include/linux/cpuhotplug.h |   1 +
>  3 files changed, 157 insertions(+)
>  create mode 100644 arch/arm64/kernel/kvm.c
> 
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 478491f07b4f..eb36edf9b930 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -63,6 +63,7 @@ obj-$(CONFIG_CRASH_CORE)		+= crash_core.o
>  obj-$(CONFIG_ARM_SDE_INTERFACE)		+= sdei.o
>  obj-$(CONFIG_ARM64_SSBD)		+= ssbd.o
>  obj-$(CONFIG_ARM64_PTR_AUTH)		+= pointer_auth.o
> +obj-$(CONFIG_PARAVIRT)			+= kvm.o
>  
>  obj-y					+= vdso/ probes/
>  obj-$(CONFIG_COMPAT_VDSO)		+= vdso32/
> diff --git a/arch/arm64/kernel/kvm.c b/arch/arm64/kernel/kvm.c
> new file mode 100644
> index 000000000000..245398c79dae
> --- /dev/null
> +++ b/arch/arm64/kernel/kvm.c
> @@ -0,0 +1,155 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2019 Arm Ltd.
> +
> +#define pr_fmt(fmt) "kvmarm-pv: " fmt
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/cpuhotplug.h>
> +#include <linux/io.h>
> +#include <linux/printk.h>
> +#include <linux/psci.h>
> +#include <linux/reboot.h>
> +#include <linux/slab.h>
> +
> +#include <asm/paravirt.h>
> +#include <asm/pvclock-abi.h>
> +#include <asm/smp_plat.h>
> +
> +struct kvmarm_stolen_time_region {
> +	struct pvclock_vcpu_stolen_time_info *kaddr;
> +};
> +
> +static DEFINE_PER_CPU(struct kvmarm_stolen_time_region, stolen_time_region);
> +
> +static bool steal_acc = true;
> +static int __init parse_no_stealacc(char *arg)
> +{
> +	steal_acc = false;
> +	return 0;
> +}
> +early_param("no-steal-acc", parse_no_stealacc);
> +
> +/* return stolen time in ns by asking the hypervisor */
> +static u64 kvm_steal_clock(int cpu)
> +{
> +	struct kvmarm_stolen_time_region *reg;
> +
> +	reg = per_cpu_ptr(&stolen_time_region, cpu);
> +	if (!reg->kaddr) {
> +		pr_warn_once("stolen time enabled but not configured for cpu %d\n",
> +			     cpu);
> +		return 0;
> +	}
> +
> +	return le64_to_cpu(READ_ONCE(reg->kaddr->stolen_time));
> +}
> +
> +static int disable_stolen_time_current_cpu(void)
> +{
> +	struct kvmarm_stolen_time_region *reg;
> +
> +	reg = this_cpu_ptr(&stolen_time_region);
> +	if (!reg->kaddr)
> +		return 0;
> +
> +	memunmap(reg->kaddr);
> +	memset(reg, 0, sizeof(*reg));
> +
> +	return 0;
> +}
> +
> +static int stolen_time_dying_cpu(unsigned int cpu)
> +{
> +	return disable_stolen_time_current_cpu();
> +}
> +
> +static int init_stolen_time_cpu(unsigned int cpu)
> +{
> +	struct kvmarm_stolen_time_region *reg;
> +	struct arm_smccc_res res;
> +
> +	reg = this_cpu_ptr(&stolen_time_region);
> +
> +	if (reg->kaddr)
> +		return 0;

Can this actually happen? It'd take two CPU_UP calls from the HP
notifiers to get in that situation...

> +
> +	arm_smccc_1_1_invoke(ARM_SMCCC_HV_PV_TIME_ST, &res);
> +
> +	if ((long)res.a0 < 0)
> +		return -EINVAL;
> +
> +	reg->kaddr = memremap(res.a0,
> +			sizeof(struct pvclock_vcpu_stolen_time_info),
> +			MEMREMAP_WB);
> +
> +	if (reg->kaddr == NULL) {
> +		pr_warn("Failed to map stolen time data structure\n");
> +		return -EINVAL;

-ENOMEM is the expected return code.

> +	}
> +
> +	if (le32_to_cpu(reg->kaddr->revision) != 0 ||
> +			le32_to_cpu(reg->kaddr->attributes) != 0) {
> +		pr_warn("Unexpected revision or attributes in stolen time data\n");
> +		return -ENXIO;
> +	}
> +
> +	return 0;
> +}
> +
> +static int kvm_arm_init_stolen_time(void)
> +{
> +	int ret;
> +
> +	ret = cpuhp_setup_state(CPUHP_AP_ARM_KVMPV_STARTING,
> +				"hypervisor/kvmarm/pv:starting",
> +				init_stolen_time_cpu, stolen_time_dying_cpu);
> +	if (ret < 0)
> +		return ret;
> +	return 0;
> +}
> +
> +static bool has_kvm_steal_clock(void)
> +{
> +	struct arm_smccc_res res;
> +
> +	/* To detect the presence of PV time support we require SMCCC 1.1+ */
> +	if (psci_ops.smccc_version < SMCCC_VERSION_1_1)
> +		return false;
> +
> +	arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
> +			     ARM_SMCCC_HV_PV_FEATURES, &res);
> +
> +	if (res.a0 != SMCCC_RET_SUCCESS)
> +		return false;
> +
> +	arm_smccc_1_1_invoke(ARM_SMCCC_HV_PV_FEATURES,
> +			     ARM_SMCCC_HV_PV_TIME_ST, &res);
> +
> +	if (res.a0 != SMCCC_RET_SUCCESS)
> +		return false;
> +
> +	return true;
> +}
> +
> +static int __init kvm_guest_init(void)
> +{
> +	int ret = 0;
> +
> +	if (!has_kvm_steal_clock())
> +		return 0;
> +
> +	ret = kvm_arm_init_stolen_time();
> +	if (ret)
> +		return ret;
> +
> +	pv_ops.time.steal_clock = kvm_steal_clock;
> +
> +	static_key_slow_inc(&paravirt_steal_enabled);
> +	if (steal_acc)
> +		static_key_slow_inc(&paravirt_steal_rq_enabled);
> +
> +	pr_info("using stolen time PV\n");
> +
> +	return 0;
> +}
> +early_initcall(kvm_guest_init);

Is there any reason why we wouldn't directly call into this rather than
using an initcall?

> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 068793a619ca..89d75edb5750 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -136,6 +136,7 @@ enum cpuhp_state {
>  	/* Must be the last timer callback */
>  	CPUHP_AP_DUMMY_TIMER_STARTING,
>  	CPUHP_AP_ARM_XEN_STARTING,
> +	CPUHP_AP_ARM_KVMPV_STARTING,
>  	CPUHP_AP_ARM_CORESIGHT_STARTING,
>  	CPUHP_AP_ARM64_ISNDEP_STARTING,
>  	CPUHP_AP_SMPCFD_DYING,


Thanks,

	M.
-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH] efi/arm: fix allocation failure when reserving the kernel base
From: Ard Biesheuvel @ 2019-08-04  7:57 UTC (permalink / raw)
  To: Chester Lin, linux@armlinux.org.uk
  Cc: Juergen Gross, linux-efi@vger.kernel.org,
	guillaume.gardet@arm.com, linux-kernel@vger.kernel.org,
	rppt@linux.ibm.com, Joey Lee, geert@linux-m68k.org,
	ren_guo@c-sky.com, Gary Lin, akpm@linux-foundation.org,
	mingo@kernel.org, linux-arm-kernel@lists.infradead.org
In-Reply-To: <20190802053744.5519-1-clin@suse.com>

Hello Chester,

On Fri, 2 Aug 2019 at 08:40, Chester Lin <clin@suse.com> wrote:
>
> In some cases the arm32 efistub could fail to allocate memory for
> uncompressed kernel. For example, we got the following error message when
> verifying EFI stub on Raspberry Pi-2 [kernel-5.2.1 + grub-2.04] :
>
>   EFI stub: Booting Linux Kernel...
>   EFI stub: ERROR: Unable to allocate memory for uncompressed kernel.
>   EFI stub: ERROR: Failed to relocate kernel
>
> After checking the EFI memory map we found that the first page [0 - 0xfff]
> had been reserved by Raspberry Pi-2's firmware, and the efistub tried to
> set the dram base at 0, which was actually in a reserved region.
>

This by itself is a violation of the Linux boot protocol for 32-bit
ARM when using the decompressor. The decompressor rounds down its own
base address to a multiple of 128 MB, and assumes the whole area is
available for the decompressed kernel and related data structures.
(The first TEXT_OFFSET bytes are no longer used in practice, which is
why putting a reserved region of 4 KB bytes works at the moment, but
this is fragile). Note that the decompressor does not look at any DT
or EFI provided memory maps *at all*.

So unfortunately, this is not something we can fix in the kernel, but
we should fix it in the bootloader or in GRUB, so it does not put any
reserved regions in the first 128 MB of memory,


>   grub> lsefimmap
>   Type      Physical start  - end             #Pages        Size Attributes
>   reserved  0000000000000000-0000000000000fff 00000001      4KiB WB
>   conv-mem  0000000000001000-0000000007ef5fff 00007ef5 130004KiB WB
>   RT-data   0000000007ef6000-0000000007f09fff 00000014     80KiB RT WB
>   conv-mem  0000000007f0a000-000000002d871fff 00025968 615840KiB WB
>   .....
>
> To avoid a reserved address, we have to ignore the memory regions which are
> marked as EFI_RESERVED_TYPE, and only conventional memory regions can be
> chosen. If the region before the kernel base is unaligned, it will be
> marked as EFI_RESERVED_TYPE and let kernel ignore it so that memblock_limit
> will not be sticked with a very low address such as 0x1000.
>
> Signed-off-by: Chester Lin <clin@suse.com>
> ---
>  arch/arm/mm/mmu.c                         |  3 ++
>  drivers/firmware/efi/libstub/arm32-stub.c | 43 ++++++++++++++++++-----
>  2 files changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
> index f3ce34113f89..909b11ba48d8 100644
> --- a/arch/arm/mm/mmu.c
> +++ b/arch/arm/mm/mmu.c
> @@ -1184,6 +1184,9 @@ void __init adjust_lowmem_bounds(void)
>                 phys_addr_t block_start = reg->base;
>                 phys_addr_t block_end = reg->base + reg->size;
>
> +               if (memblock_is_nomap(reg))
> +                       continue;
> +
>                 if (reg->base < vmalloc_limit) {
>                         if (block_end > lowmem_limit)
>                                 /*
> diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
> index e8f7aefb6813..10d33d36df00 100644
> --- a/drivers/firmware/efi/libstub/arm32-stub.c
> +++ b/drivers/firmware/efi/libstub/arm32-stub.c
> @@ -128,7 +128,7 @@ static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg,
>
>         for (l = 0; l < map_size; l += desc_size) {
>                 efi_memory_desc_t *desc;
> -               u64 start, end;
> +               u64 start, end, spare, kernel_base;
>
>                 desc = (void *)memory_map + l;
>                 start = desc->phys_addr;
> @@ -144,27 +144,52 @@ static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg,
>                 case EFI_BOOT_SERVICES_DATA:
>                         /* Ignore types that are released to the OS anyway */
>                         continue;
> -
> +               case EFI_RESERVED_TYPE:
> +                       /* Ignore reserved regions */
> +                       continue;
>                 case EFI_CONVENTIONAL_MEMORY:
>                         /*
>                          * Reserve the intersection between this entry and the
>                          * region.
>                          */
>                         start = max(start, (u64)dram_base);
> -                       end = min(end, (u64)dram_base + MAX_UNCOMP_KERNEL_SIZE);
> +                       kernel_base = round_up(start, PMD_SIZE);
> +                       spare = kernel_base - start;
> +                       end = min(end, kernel_base + MAX_UNCOMP_KERNEL_SIZE);
> +
> +                       status = efi_call_early(allocate_pages,
> +                                       EFI_ALLOCATE_ADDRESS,
> +                                       EFI_LOADER_DATA,
> +                                       MAX_UNCOMP_KERNEL_SIZE / EFI_PAGE_SIZE,
> +                                       &kernel_base);
> +                       if (status != EFI_SUCCESS) {
> +                               pr_efi_err(sys_table_arg,
> +                                       "reserve_kernel_base: alloc failed.\n");
> +                               goto out;
> +                       }
> +                       *reserve_addr = kernel_base;
>
> +                       if (!spare)
> +                               break;
> +                       /*
> +                        * If there's a gap between start and kernel_base,
> +                        * it needs be reserved so that the memblock_limit
> +                        * will not fall on a very low address when running
> +                        * adjust_lowmem_bounds(), wchich could eventually
> +                        * cause CMA reservation issue.
> +                        */
>                         status = efi_call_early(allocate_pages,
>                                                 EFI_ALLOCATE_ADDRESS,
> -                                               EFI_LOADER_DATA,
> -                                               (end - start) / EFI_PAGE_SIZE,
> +                                               EFI_RESERVED_TYPE,
> +                                               spare / EFI_PAGE_SIZE,
>                                                 &start);
>                         if (status != EFI_SUCCESS) {
>                                 pr_efi_err(sys_table_arg,
> -                                       "reserve_kernel_base(): alloc failed.\n");
> +                                       "reserve spare-region failed\n");
>                                 goto out;
>                         }
> -                       break;
>
> +                       break;
>                 case EFI_LOADER_CODE:
>                 case EFI_LOADER_DATA:
>                         /*
> @@ -220,7 +245,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
>         *image_size = image->image_size;
>         status = efi_relocate_kernel(sys_table, image_addr, *image_size,
>                                      *image_size,
> -                                    dram_base + MAX_UNCOMP_KERNEL_SIZE, 0);
> +                                    *reserve_addr + MAX_UNCOMP_KERNEL_SIZE, 0);
>         if (status != EFI_SUCCESS) {
>                 pr_efi_err(sys_table, "Failed to relocate kernel.\n");
>                 efi_free(sys_table, *reserve_size, *reserve_addr);
> @@ -233,7 +258,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
>          * in memory. The kernel determines the base of DRAM from the
>          * address at which the zImage is loaded.
>          */
> -       if (*image_addr + *image_size > dram_base + ZIMAGE_OFFSET_LIMIT) {
> +       if (*image_addr + *image_size > *reserve_addr + ZIMAGE_OFFSET_LIMIT) {
>                 pr_efi_err(sys_table, "Failed to relocate kernel, no low memory available.\n");
>                 efi_free(sys_table, *reserve_size, *reserve_addr);
>                 *reserve_size = 0;
> --
> 2.22.0
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox