2021-05-25 00:04:42

by Doug Anderson

[permalink] [raw]
Subject: [PATCH v8 07/11] drm/panel: panel-simple: Stash DP AUX bus; allow using it for DDC

If panel-simple is instantiated as a DP AUX bus endpoint then we have
access to the DP AUX bus. Let's stash it in the panel-simple
structure, leaving it NULL for the cases where the panel is
instantiated in other ways.

If we happen to have access to the DP AUX bus and we weren't provided
the ddc-i2c-bus in some other manner, let's use the DP AUX bus for it.

Signed-off-by: Douglas Anderson <[email protected]>
Reviewed-by: Lyude Paul <[email protected]>
---

(no changes since v7)

Changes in v7:
- Patch using the DP AUX for DDC new for v7.

drivers/gpu/drm/panel/panel-simple.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index d3b5ae22d939..b09be6e5e147 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -37,6 +37,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_dp_aux_bus.h>
+#include <drm/drm_dp_helper.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_panel.h>

@@ -186,6 +187,7 @@ struct panel_simple {

struct regulator *supply;
struct i2c_adapter *ddc;
+ struct drm_dp_aux *aux;

struct gpio_desc *enable_gpio;
struct gpio_desc *hpd_gpio;
@@ -658,7 +660,8 @@ static void panel_simple_parse_panel_timing_node(struct device *dev,
dev_err(dev, "Reject override mode: No display_timing found\n");
}

-static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
+static int panel_simple_probe(struct device *dev, const struct panel_desc *desc,
+ struct drm_dp_aux *aux)
{
struct panel_simple *panel;
struct display_timing dt;
@@ -674,6 +677,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
panel->enabled = false;
panel->prepared_time = 0;
panel->desc = desc;
+ panel->aux = aux;

panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
if (!panel->no_hpd) {
@@ -708,6 +712,8 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)

if (!panel->ddc)
return -EPROBE_DEFER;
+ } else if (aux) {
+ panel->ddc = &aux->ddc;
}

if (desc == &panel_dpi) {
@@ -4633,7 +4639,7 @@ static int panel_simple_platform_probe(struct platform_device *pdev)
if (!id)
return -ENODEV;

- return panel_simple_probe(&pdev->dev, id->data);
+ return panel_simple_probe(&pdev->dev, id->data, NULL);
}

static int panel_simple_platform_remove(struct platform_device *pdev)
@@ -4913,7 +4919,7 @@ static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)

desc = id->data;

- err = panel_simple_probe(&dsi->dev, &desc->desc);
+ err = panel_simple_probe(&dsi->dev, &desc->desc, NULL);
if (err < 0)
return err;

@@ -4966,7 +4972,7 @@ static int panel_simple_dp_aux_ep_probe(struct dp_aux_ep_device *aux_ep)
if (!id)
return -ENODEV;

- return panel_simple_probe(&aux_ep->dev, id->data);
+ return panel_simple_probe(&aux_ep->dev, id->data, aux_ep->aux);
}

static void panel_simple_dp_aux_ep_remove(struct dp_aux_ep_device *aux_ep)
--
2.31.1.818.g46aad6cb9e-goog


2021-06-04 16:13:16

by Rajeev Nandan

[permalink] [raw]
Subject: Re: [PATCH v8 07/11] drm/panel: panel-simple: Stash DP AUX bus; allow using it for DDC

Hi Doug,

> panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
> if (!panel->no_hpd) {
> @@ -708,6 +712,8 @@ static int panel_simple_probe(struct device *dev,
> const struct panel_desc *desc)
>
> if (!panel->ddc)
> return -EPROBE_DEFER;
> + } else if (aux) {
> + panel->ddc = &aux->ddc;
> }

In panel_simple_probe(), the put_device(&panel->ddc->dev) call is
causing issue when the aux->ddc is used to assign panel->ddc
It works well when "ddc-i2c-bus" is used to assign panel->ddc

static int panel_simple_probe(...)
{
...

free_ddc:
if (panel->ddc)
put_device(&panel->ddc->dev);

return err;
}

== Log start ==

[ 2.393970] ------------[ cut here ]------------
[ 2.398747] kobject: '(null)' ((____ptrval____)): is not initialized,
yet kobject_put() is being called.
[ 2.408554] WARNING: CPU: 7 PID: 7 at lib/kobject.c:752
kobject_put+0x38/0xe0
...
...
[ 2.528574] Call trace:
[ 2.531092] kobject_put+0x38/0xe0
[ 2.534594] put_device+0x20/0x2c
[ 2.538002] panel_simple_probe+0x4bc/0x550
[ 2.542300] panel_simple_dp_aux_ep_probe+0x44/0x5c
[ 2.547305] dp_aux_ep_probe+0x58/0x80

== Log end ==


Sincerely,
Rajeev

2021-06-07 17:12:05

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH v8 07/11] drm/panel: panel-simple: Stash DP AUX bus; allow using it for DDC

Hi,

On Fri, Jun 4, 2021 at 9:10 AM <[email protected]> wrote:
>
> Hi Doug,
>
> > panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
> > if (!panel->no_hpd) {
> > @@ -708,6 +712,8 @@ static int panel_simple_probe(struct device *dev,
> > const struct panel_desc *desc)
> >
> > if (!panel->ddc)
> > return -EPROBE_DEFER;
> > + } else if (aux) {
> > + panel->ddc = &aux->ddc;
> > }
>
> In panel_simple_probe(), the put_device(&panel->ddc->dev) call is
> causing issue when the aux->ddc is used to assign panel->ddc
> It works well when "ddc-i2c-bus" is used to assign panel->ddc
>
> static int panel_simple_probe(...)
> {
> ...
>
> free_ddc:
> if (panel->ddc)
> put_device(&panel->ddc->dev);
>
> return err;
> }

Thanks for catching! Fixed in v9.


-Doug