Re: [PATCH v8 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-09-08 Thread Mark yao

On 2017年09月08日 14:12, Mark yao wrote:

On 2017年09月08日 13:04, Heiko Stuebner wrote:

Am Freitag, 8. September 2017, 09:23:09 CEST schrieb Mark yao:

On 2017年09月07日 20:09, Heiko Stübner wrote:

Hi Mark,

Am Donnerstag, 7. September 2017, 18:16:29 CEST schrieb Mark yao:

Looks good for me, so:
Reviewed-by: Mark Yao 

I'd like to apply these lvds patches tomorrow if there is no more doubts.

Rob had some minor comments on v7 of the dt-binding, so you may want
to give him a bit more time to Ack the hopefully updated binding.

Rob already gave a Reviewed-by on v7 dt-binding, but maybe it has some doubts 
for his Ack.

Ok, let's wait some more time.

ah, I looked at v6 and found the comments, not v7 and v7 is not in my
archive because I likely accidentially deleted it.
So Sandy just forgot to carry over the Ack/Review tag. So I guess there is
no need to wait anymore and you just need to pick up Rob's tag from v7 then.


Right, Sandy forgot to carry those tag on new patchset, I will carry those tag:
Tested-by on v5, Reviewed-by on v6 and v7

Thanks.



Pushed patches 1+3 to drm-misc-next.

Best Regards
Mark


Heiko

___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip





___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4.4.y] drm: adv7511: Re-write the i2c address before EDID probing

2017-09-08 Thread Greg KH
On Fri, Sep 08, 2017 at 09:46:02AM +0700, Nhan Nguyen wrote:
> commit 3587c856675c45809010c2cee5b21096f6e8e938 upstream.
> 
> I've found that by just turning the chip on and off via the
> POWER_DOWN register, I end up getting i2c_transfer errors on
> HiKey.
> 
> Investigating further, it turns out that some of the register
> state in hardware is getting lost, as the device registers are
> reset when the chip is powered down.
> 
> Thus this patch simply re-writes the i2c address to the
> ADV7511_REG_EDID_I2C_ADDR register to ensure its properly set
> before we try to read the EDID data.
> 
> Cc: David Airlie 
> Cc: Archit Taneja 
> Cc: Wolfram Sang 
> Cc: Lars-Peter Clausen 
> Cc: Laurent Pinchart 
> Cc: dri-devel@lists.freedesktop.org
> Cc: sta...@vger.kernel.org
> Reviewed-by: Laurent Pinchart 
> Tested-by: Laurent Pinchart 
> Signed-off-by: John Stultz 
> Signed-off-by: Archit Taneja 
> Signed-off-by: Thong Ho 
> Signed-off-by: Nhan Nguyen 
> Link: 
> http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-7-git-send-email-john.stu...@linaro.org
> ---
>  drivers/gpu/drm/i2c/adv7511.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)

Can you provide a working backport for the 4.9-stable kernel as well?

Also, please do not send backports for patches that do not also work in
newer stable kernels, like 4.9, I backported some of this series there,
but I shouldn't have to check for you.

thanks,

greg k-h
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/sun4i: tcon: Unconditionally reset the TCON

2017-09-08 Thread Maxime Ripard
On Fri, Sep 08, 2017 at 02:49:52PM +0800, Chen-Yu Tsai wrote:
> On Fri, Sep 8, 2017 at 2:42 PM, Maxime Ripard
>  wrote:
> > Hi,
> >
> > On Fri, Sep 08, 2017 at 12:15:45PM +0800, Chen-Yu Tsai wrote:
> >> When binding the TCON, we were checking the reset control status and
> >> asserting reset if it wasn't in reset. The check failed to account for
> >> the reset control API returning error codes if the status callback was
> >> not implemented.
> >>
> >> Since we want the TCON to be reset in all cases, and re-asserting the
> >> reset control does no harm, just assert the reset unconditionally.
> >>
> >> Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
> >> Signed-off-by: Chen-Yu Tsai 
> >> ---
> >>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 3 +--
> >>  1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
> >> b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> index d9791292553e..eb32676d5b01 100644
> >> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> @@ -530,8 +530,7 @@ static int sun4i_tcon_bind(struct device *dev, struct 
> >> device *master,
> >>   }
> >>
> >>   /* Make sure our TCON is reset */
> >> - if (!reset_control_status(tcon->lcd_rst))
> >> - reset_control_assert(tcon->lcd_rst);
> >> + reset_control_assert(tcon->lcd_rst);
> >
> > That doesn't really reset it if it was already de-asserted. In that
> > case, the TCON will not be reset, unlike what your commit log says.
> 
> Why not? It is now asserting the reset control, regardless of the
> status.

Oh, right, sorry.

> > Maybe you wanted to use reset_control_reset?
> 
> If you prefer it, sure. When I did this patch we didn't support the
> .reset callback, so this is an explicit assert followed by the existing
> deassert.

Still, if we rework that part, I guess that just using reset
unconditonally would make it more obvious.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 8/8] ARM: dts: sun6i: Add cross pipeline connections between DRCs and TCONs

2017-09-08 Thread Chen-Yu Tsai
The TCONs on A31/A31s can select either backend as its input. As there
is no configurable mux in the backend or DRC to redirect their output,
or for the DRC to select an input, the connections are presumably from
the each DRC to each TCON, with the TCON having two input ports, like
the following diagram:

Backend 0  ---  DRC 0  --- [0]  TCON 0
   --   -- [1]
 \ /
  X
 / \
   --   -- [0]
Backend 1  ---  DRC 1  --- [1]  TCON 1

Add these connection endpoints to the device tree.

Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 00a4c7614e0a..93209cda28db 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -278,6 +278,11 @@
reg = <0>;
remote-endpoint = 
<&drc0_out_tcon0>;
};
+
+   tcon0_in_drc1: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = 
<&drc1_out_tcon0>;
+   };
};
 
tcon0_out: port@1 {
@@ -311,6 +316,11 @@
#size-cells = <0>;
reg = <0>;
 
+   tcon1_in_drc0: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = 
<&drc0_out_tcon1>;
+   };
+
tcon1_in_drc1: endpoint@1 {
reg = <1>;
remote-endpoint = 
<&drc1_out_tcon1>;
@@ -1079,6 +1089,11 @@
#size-cells = <0>;
reg = <1>;
 
+   drc1_out_tcon0: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = 
<&tcon0_in_drc1>;
+   };
+
drc1_out_tcon1: endpoint@1 {
reg = <1>;
remote-endpoint = 
<&tcon1_in_drc1>;
@@ -1170,6 +1185,11 @@
reg = <0>;
remote-endpoint = 
<&tcon0_in_drc0>;
};
+
+   drc0_out_tcon1: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = 
<&tcon1_in_drc0>;
+   };
};
};
};
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/8] drm/sun4i: add components in breadth first traversal order

2017-09-08 Thread Chen-Yu Tsai
The encoder drivers use drm_of_find_possible_crtcs to get upstream
crtcs from the device tree using of_graph. For the results to be
correct, encoders must be probed/bound after _all_ crtcs have been
created. The existing code uses a depth first recursive traversal
of the of_graph, which means the encoders downstream of the TCON
get add right after the first TCON. The second TCON or CRTC will
never be properly associated with encoders connected to it.

Other platforms, such as Rockchip, deal with this by probing all
CRTCs first, then all subsequent components. This is easy to do
since the CRTCs correspond to just one device node, and are the
first nodes in the pipeline.

However with Allwinner SoCs, the function of the CRTC is split
between the display backend (DE 1.0) or mixer (DE 2.0), which does
scan-out and compositing, and the TCON, which generates the display
timing signals. Further complicating the process, there may be a
Dynamic Range Controller between the backend and the TCON. Also, the
backend is preceded by the frontend, with a Display Enhancement Unit
possibly in between.

In a dual display pipeline setup, both frontends can feed either
backend, and both backends can feed either TCON. We want all
components of the same type to be added before the next type in the
pipeline. Fortunately, the pipelines are perfectly symmetric, i.e.
components of the same type are at the same depth when counted from
the frontend. The only exception is the third pipeline in the A80
SoC, which we do not support anyway.

Hence we can use a breadth first search traversal order to add
components. We do not need to check for duplicates. The component
matching system handles this for us.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 81 ++-
 1 file changed, 72 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index ace59651892f..2ff4233fe2da 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -200,11 +200,39 @@ static int compare_of(struct device *dev, void *data)
return dev->of_node == data;
 }
 
+/*
+ * The encoder drivers use drm_of_find_possible_crtcs to get upstream
+ * crtcs from the device tree using of_graph. For the results to be
+ * correct, encoders must be probed/bound after _all_ crtcs have been
+ * created. The existing code uses a depth first recursive traversal
+ * of the of_graph, which means the encoders downstream of the TCON
+ * get add right after the first TCON. The second TCON or CRTC will
+ * never be properly associated with encoders connected to it.
+ *
+ * Also, in a dual display pipeline setup, both frontends can feed
+ * either backend, and both backends can feed either TCON, we want
+ * all components of the same type to be added before the next type
+ * in the pipeline. Fortunately, the pipelines are perfectly symmetric,
+ * i.e. components of the same type are at the same depth when counted
+ * from the frontend. The only exception is the third pipeline in
+ * the A80 SoC, which we do not support anyway.
+ *
+ * Hence we can use a breadth first search traversal order to add
+ * components. We do not need to check for duplicates. The component
+ * matching system handles this for us.
+ */
+struct endpoint_list {
+   struct device_node *node;
+   struct list_head list;
+};
+
 static int sun4i_drv_add_endpoints(struct device *dev,
+  struct list_head *endpoints,
   struct component_match **match,
   struct device_node *node)
 {
struct device_node *port, *ep, *remote;
+   struct endpoint_list *endpoint;
int count = 0;
 
/*
@@ -264,10 +292,15 @@ static int sun4i_drv_add_endpoints(struct device *dev,
}
}
 
-   /* Walk down our tree */
-   count += sun4i_drv_add_endpoints(dev, match, remote);
+   /* Add downstream nodes to the queue */
+   endpoint = kzalloc(sizeof(*endpoint), GFP_KERNEL);
+   if (!endpoint) {
+   of_node_put(remote);
+   return -ENOMEM;
+   }
 
-   of_node_put(remote);
+   endpoint->node = remote;
+   list_add_tail(&endpoint->list, endpoints);
}
 
return count;
@@ -277,7 +310,9 @@ static int sun4i_drv_probe(struct platform_device *pdev)
 {
struct component_match *match = NULL;
struct device_node *np = pdev->dev.of_node;
-   int i, count = 0;
+   struct endpoint_list *endpoint, *endpoint_temp;
+   int i, ret, count = 0;
+   LIST_HEAD(endpoints);
 
for (i = 0;; i++) {
struct device_node *pipeline = of_parse_phandle(np,
@@ -286,12 +321,31 @@ static int sun4i_drv_probe(struct platform_device *pdev)
if (!pipeline)
  

[PATCH 6/8] drm/sun4i: tcon: Support backend input mux

2017-09-08 Thread Chen-Yu Tsai
The TCON has a mux to select the source of the data to display.
This mux includes selecting the display backends. On the A31,
which has two display pipelines, this mux can let the TCON
select either backend as its data source. Although the muxing
can be changed on the fly, DRM needs to be able to group a
bunch of layers such that they get switched to another crtc
together. This is because the display backend does the layer
compositing, while the TCON generates the display timings.
This constraint is not supported by DRM.

Here we simply pair up backends and TCONs with the same ID.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 25 +++--
 drivers/gpu/drm/sun4i/sun4i_tcon.h |  3 +++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index e9ab03f0bf6e..0951e3f0a35e 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -701,6 +701,25 @@ static int sun4i_tcon_bind(struct device *dev, struct 
device *master,
if (ret < 0)
goto err_free_clocks;
 
+   if (tcon->quirks->needs_de_be_mux) {
+   /*
+* We assume there is no dynamic muxing of backends
+* and TCONs, so we select the backend with same ID.
+*
+* While dynamic selection might be interesting, since
+* the CRTC is tied to the TCON, while the layers are
+* tied to the backends, this means, we will need to
+* switch between groups of layers. There might not be
+* a way to represent this constraint in DRM.
+*/
+   regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
+  SUN4I_TCON0_CTL_SRC_SEL_MASK,
+  tcon->id);
+   regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
+  SUN4I_TCON1_CTL_SRC_SEL_MASK,
+  tcon->id);
+   }
+
list_add_tail(&tcon->list, &drv->tcon_list);
 
return 0;
@@ -756,11 +775,13 @@ static const struct sun4i_tcon_quirks sun5i_a13_quirks = {
 };
 
 static const struct sun4i_tcon_quirks sun6i_a31_quirks = {
-   .has_channel_1  = true,
+   .has_channel_1  = true,
+   .needs_de_be_mux= true,
 };
 
 static const struct sun4i_tcon_quirks sun6i_a31s_quirks = {
-   .has_channel_1  = true,
+   .has_channel_1  = true,
+   .needs_de_be_mux= true,
 };
 
 static const struct sun4i_tcon_quirks sun8i_a33_quirks = {
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h 
b/drivers/gpu/drm/sun4i/sun4i_tcon.h
index 552c88ec16be..5a219d1ccc26 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
@@ -37,6 +37,7 @@
 #define SUN4I_TCON0_CTL_TCON_ENABLEBIT(31)
 #define SUN4I_TCON0_CTL_CLK_DELAY_MASK GENMASK(8, 4)
 #define SUN4I_TCON0_CTL_CLK_DELAY(delay)   ((delay << 4) & 
SUN4I_TCON0_CTL_CLK_DELAY_MASK)
+#define SUN4I_TCON0_CTL_SRC_SEL_MASK   GENMASK(2, 0)
 
 #define SUN4I_TCON0_DCLK_REG   0x44
 #define SUN4I_TCON0_DCLK_GATE_BIT  (31)
@@ -85,6 +86,7 @@
 #define SUN4I_TCON1_CTL_INTERLACE_ENABLE   BIT(20)
 #define SUN4I_TCON1_CTL_CLK_DELAY_MASK GENMASK(8, 4)
 #define SUN4I_TCON1_CTL_CLK_DELAY(delay)   ((delay << 4) & 
SUN4I_TCON1_CTL_CLK_DELAY_MASK)
+#define SUN4I_TCON1_CTL_SRC_SEL_MASK   GENMASK(1, 0)
 
 #define SUN4I_TCON1_BASIC0_REG 0x94
 #define SUN4I_TCON1_BASIC0_X(width)width) - 1) & 
0xfff) << 16)
@@ -146,6 +148,7 @@
 struct sun4i_tcon_quirks {
boolhas_unknown_mux; /* sun5i has undocumented mux */
boolhas_channel_1;  /* a33 does not have channel 1 */
+   boolneeds_de_be_mux; /* sun6i needs mux to select backend */
 };
 
 struct sun4i_tcon {
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/8] drm/sun4i: tcon: Simplify sun4i_tcon_find_engine_traverse for one input

2017-09-08 Thread Chen-Yu Tsai
Now that sun4i_tcon_find_engine_traverse() usage is restricted to the
single input case, we can remove the for_each_available_child_of_node
loop.

While at it, consolidate all the of_node_put calls into a common exit
path.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 51 +++---
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 33c20d2f9fb1..e9ab03f0bf6e 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -468,7 +468,7 @@ sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
struct device_node *node)
 {
struct device_node *port, *ep, *remote;
-   struct sunxi_engine *engine;
+   struct sunxi_engine *engine = ERR_PTR(-EINVAL);
 
port = of_graph_get_port_by_id(node, 0);
if (!port)
@@ -483,35 +483,34 @@ sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
 *
 * Bail out if there are multiple input connections.
 */
-   if (of_get_available_child_count(port) != 1) {
-   of_node_put(port);
-   return ERR_PTR(-EINVAL);
-   }
+   if (of_get_available_child_count(port) != 1)
+   goto out_put_port;
 
-   for_each_available_child_of_node(port, ep) {
-   remote = of_graph_get_remote_port_parent(ep);
-   if (!remote)
-   continue;
+   /* Get the first connection without specifying an ID */
+   ep = of_get_next_available_child(port, NULL);
+   if (!ep)
+   goto out_put_port;
 
-   /* does this node match any registered engines? */
-   list_for_each_entry(engine, &drv->engine_list, list) {
-   if (remote == engine->node) {
-   of_node_put(remote);
-   of_node_put(port);
-   return engine;
-   }
-   }
+   remote = of_graph_get_remote_port_parent(ep);
+   if (!remote)
+   goto out_put_ep;
 
-   /* keep looking through upstream ports */
-   engine = sun4i_tcon_find_engine_traverse(drv, remote);
-   if (!IS_ERR(engine)) {
-   of_node_put(remote);
-   of_node_put(port);
-   return engine;
-   }
-   }
+   /* does this node match any registered engines? */
+   list_for_each_entry(engine, &drv->engine_list, list)
+   if (remote == engine->node)
+   goto out_put_remote;
 
-   return ERR_PTR(-EINVAL);
+   /* keep looking through upstream ports */
+   engine = sun4i_tcon_find_engine_traverse(drv, remote);
+
+out_put_remote:
+   of_node_put(remote);
+out_put_ep:
+   of_node_put(ep);
+out_put_port:
+   of_node_put(port);
+
+   return engine;
 }
 
 /*
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/8] drm/sun4i: tcon: get TCON ID and matching engine with remote endpoint ID

2017-09-08 Thread Chen-Yu Tsai
The device tree binding for sun4i-drm says:

For all connections between components up to the TCONs in the display
pipeline, when there are multiple components of the same type at the
same depth, the local endpoint ID must be the same as the remote
component's index. For example, if the remote endpoint is Frontend 1,
then the local endpoint ID must be 1.

We should be able to get the TCON's ID directly from any of the remote
endpoints from its input port. With the ID, we can then go through the
list of registered engines and find a matching one by ID.

However the A31 device tree is incorrect. We assumed that there were no
cross pipeline connections between the backends and TCONs. As a result,
in all the endpoints between the backends and TCONs of the second
display pipeline, the endpoint IDs were incorrectly set to 0, when in
fact they should've been set to 1.

To maintain compatibility with this incorrect device tree, we first
check if the TCON's input port has 1 or many endpoints. If there are
more than 1, then it is likely a fixed version, and we can proceed
with the new method. If there is only 1 endpoint, then it is possibly
an incorrect version, or it could be the SoC only has one pipeline.
In either case we fall back to using the old method of traversing
the input connections to find a matching engine, and then get its
ID.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 121 -
 1 file changed, 118 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 065654dbfb2c..33c20d2f9fb1 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -463,8 +463,9 @@ static int sun4i_tcon_init_regmap(struct device *dev,
  * function in fact searches the corresponding engine, and the ID is
  * requested via the get_id function of the engine.
  */
-static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv,
-  struct device_node *node)
+static struct sunxi_engine *
+sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
+   struct device_node *node)
 {
struct device_node *port, *ep, *remote;
struct sunxi_engine *engine;
@@ -502,7 +503,7 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct 
sun4i_drv *drv,
}
 
/* keep looking through upstream ports */
-   engine = sun4i_tcon_find_engine(drv, remote);
+   engine = sun4i_tcon_find_engine_traverse(drv, remote);
if (!IS_ERR(engine)) {
of_node_put(remote);
of_node_put(port);
@@ -513,6 +514,120 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct 
sun4i_drv *drv,
return ERR_PTR(-EINVAL);
 }
 
+/*
+ * The device tree binding says that the remote endpoint ID of any
+ * connection between components, up to and including the TCON, of
+ * the display pipeline should be equal to the actual ID of the local
+ * component. Thus we can look at any one of the input connections of
+ * the TCONs, and use that connection's remote endpoint ID as our own.
+ *
+ * Since the user of this function already finds the input port,
+ * the port is passed in directly without further checks.
+ */
+static int sun4i_tcon_of_get_id_from_port(struct device_node *port)
+{
+   struct device_node *ep;
+   int ret = -EINVAL;
+
+   /* try finding an upstream endpoint */
+   for_each_available_child_of_node(port, ep) {
+   struct device_node *remote;
+   u32 reg;
+
+   remote = of_graph_get_remote_endpoint(ep);
+   if (!remote)
+   continue;
+
+   ret = of_property_read_u32(remote, "reg", ®);
+   if (ret)
+   continue;
+
+   ret = reg;
+   }
+
+   return ret;
+}
+
+/*
+ * Once we know the TCON's id, we can look through the list of
+ * engines to find a matching one. We assume all engines have
+ * been probed and added to the list.
+ */
+static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv,
+   int id)
+{
+   struct sunxi_engine *engine;
+
+   list_for_each_entry(engine, &drv->engine_list, list)
+   if (engine->id == id)
+   return engine;
+
+   return ERR_PTR(-EINVAL);
+}
+
+/*
+ * On SoCs with the old display pipeline design (Display Engine 1.0),
+ * we assumed the TCON was always tied to just one backend. However
+ * this proved not to be the case. On the A31, the TCON can select
+ * either backend as its source. On the A20 (and likely on the A10),
+ * the backend can choose which TCON to output to.
+ *
+ * The device tree binding says that the remote endpoint ID of any
+ * connection between components, up to and inclu

[PATCH 0/8] drm/sun4i: Make both display pipeline work together

2017-09-08 Thread Chen-Yu Tsai
Hi everyone,

Previously I added support for two display pipelines for the sun4i-drm
driver. At the time we did not have support for downstream encoders to
actually test the second pipeline, nor having both pipelines active at
the same time.

With HDMI encoder support now merged and support for it on sun6i in
progress, we are now able to test both pipelines being active at the
same time, with LCD output from one and HDMI from the other. Testing
has revealed some more issues, such as component probing order. Also,
we found out that muxing between the display backend and TCON was
possible, and required for the second pipeline to work as intended.
Last, the number of CRTCs provided to drm_vblank_init needs to be
increased for vblanks to work properly.

This patch series does a few things:

  - Fix endpoint IDs so they conform to what the DT binding stipulates.

  - Change the order the individual components are queued up.

  - Fix how the TCON gets its ID when the backend-TCON mux is present.

  - Support the input mux in the TCON (which selects which backend to
use on the A31/A31s).

  - Fix the drm_vblank_init call and pass the correct number of crtcs.

  - Add the cross pipeline connections between the DRCs and TCONs on
the A31, conforming to the DT binding and what the hardware is
capable of.

More details are available in each individual commit. Please have a look.

Regards
ChenYu


Chen-Yu Tsai (8):
  ARM: dts: sun6i: Fix endpoint IDs in second display pipeline
  drm/sun4i: add components in breadth first traversal order
  drm/sun4i: tcon: Check for multiple paths between TCONs and backends
  drm/sun4i: tcon: get TCON ID and matching engine with remote endpoint
ID
  drm/sun4i: tcon: Simplify sun4i_tcon_find_engine_traverse for one
input
  drm/sun4i: tcon: Support backend input mux
  drm/sun4i: call drm_vblank_init with correct number of crtcs
  ARM: dts: sun6i: Add cross pipeline connections between DRCs and TCONs

 arch/arm/boot/dts/sun6i-a31.dtsi   |  32 +--
 drivers/gpu/drm/sun4i/sun4i_drv.c  |  91 +++---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 191 +
 drivers/gpu/drm/sun4i/sun4i_tcon.h |   3 +
 4 files changed, 276 insertions(+), 41 deletions(-)

-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/8] drm/sun4i: tcon: Check for multiple paths between TCONs and backends

2017-09-08 Thread Chen-Yu Tsai
The patch b317fa3ba11a ("drm/sun4i: tcon: Find matching display backend
by device node matching") assumed a one-to-one mapping between TCONs
and backends. This turned out wrong, as we found muxing controls in the
TCON of the A31, and undocumented usage of the backend output selector
of the A20.

Make sun4i_tcon_find_engine() bail out if the current node has multiple
input connections.

Fixes: b317fa3ba11a ("drm/sun4i: tcon: Find matching display backend
  by device node matching")
Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index eb32676d5b01..065654dbfb2c 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -473,6 +473,20 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct 
sun4i_drv *drv,
if (!port)
return ERR_PTR(-EINVAL);
 
+   /*
+* This only works if there is only one path from the TCON
+* to any display engine. Otherwise the probe order of the
+* TCONs and display engines is not guaranteed. They may
+* either bind to the wrong one, or worse, bind to the same
+* one if additional checks are not done.
+*
+* Bail out if there are multiple input connections.
+*/
+   if (of_get_available_child_count(port) != 1) {
+   of_node_put(port);
+   return ERR_PTR(-EINVAL);
+   }
+
for_each_available_child_of_node(port, ep) {
remote = of_graph_get_remote_port_parent(ep);
if (!remote)
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/8] ARM: dts: sun6i: Fix endpoint IDs in second display pipeline

2017-09-08 Thread Chen-Yu Tsai
When the second display pipeline device nodes for the A31/A31s were
added, it was not known that the TCONs could (through either DRCs)
select either backend as their input. Thus in the endpoints connecting
these components together, the endpoint IDs were set to 0, while in
fact they should have been set to 1.

Fixes: 9a26882a7378 ("ARM: dts: sun6i: Add second display pipeline device
  nodes")
Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index f3d74dc5b292..00a4c7614e0a 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -311,8 +311,8 @@
#size-cells = <0>;
reg = <0>;
 
-   tcon1_in_drc1: endpoint@0 {
-   reg = <0>;
+   tcon1_in_drc1: endpoint@1 {
+   reg = <1>;
remote-endpoint = 
<&drc1_out_tcon1>;
};
};
@@ -1038,8 +1038,8 @@
#size-cells = <0>;
reg = <1>;
 
-   be1_out_drc1: endpoint@0 {
-   reg = <0>;
+   be1_out_drc1: endpoint@1 {
+   reg = <1>;
remote-endpoint = 
<&drc1_in_be1>;
};
};
@@ -1068,8 +1068,8 @@
#size-cells = <0>;
reg = <0>;
 
-   drc1_in_be1: endpoint@0 {
-   reg = <0>;
+   drc1_in_be1: endpoint@1 {
+   reg = <1>;
remote-endpoint = 
<&be1_out_drc1>;
};
};
@@ -1079,8 +1079,8 @@
#size-cells = <0>;
reg = <1>;
 
-   drc1_out_tcon1: endpoint@0 {
-   reg = <0>;
+   drc1_out_tcon1: endpoint@1 {
+   reg = <1>;
remote-endpoint = 
<&tcon1_in_drc1>;
};
};
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 7/8] drm/sun4i: call drm_vblank_init with correct number of crtcs

2017-09-08 Thread Chen-Yu Tsai
If we want to have vblank on both pipelines at the same time, we need
to call drm_vblank_init with num_crtcs = 2.

Instead, since the crtc init calls correctly set mode_config.num_crtc,
we can move the drm_vblank_init call to after the crtc init code is
called, which is the component bind part. Then we can just pass
mode_config.num_crtc in.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 2ff4233fe2da..a2012638d5f7 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -106,11 +106,6 @@ static int sun4i_drv_bind(struct device *dev)
goto free_drm;
}
 
-   /* drm_vblank_init calls kcalloc, which can fail */
-   ret = drm_vblank_init(drm, 1);
-   if (ret)
-   goto free_mem_region;
-
drm_mode_config_init(drm);
 
ret = component_bind_all(drm->dev, drm);
@@ -119,6 +114,11 @@ static int sun4i_drv_bind(struct device *dev)
goto cleanup_mode_config;
}
 
+   /* drm_vblank_init calls kcalloc, which can fail */
+   ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
+   if (ret)
+   goto free_mem_region;
+
drm->irq_enabled = true;
 
/* Remove early framebuffers (ie. simplefb) */
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.4.y] drm: adv7511: Switch to using drm_kms_helper_hotplug_event()

2017-09-08 Thread Nhan Nguyen
commit 6d5104c5a6b56385426e15047050584794bb6254 upstream.

In chasing down a previous issue with EDID probing from calling
drm_helper_hpd_irq_event() from irq context, Laurent noticed
that the DRM documentation suggests that
drm_kms_helper_hotplug_event() should be used instead.

Thus this patch replaces drm_helper_hpd_irq_event() with
drm_kms_helper_hotplug_event(), which requires we update the
connector.status entry and only call _hotplug_event() when the
status changes.

Cc: David Airlie 
Cc: Archit Taneja 
Cc: Wolfram Sang 
Cc: Lars-Peter Clausen 
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: sta...@vger.kernel.org
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 
Signed-off-by: John Stultz 
Signed-off-by: Archit Taneja 
Signed-off-by: Thong Ho 
Signed-off-by: Nhan Nguyen 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-3-git-send-email-john.stu...@linaro.org
---
 drivers/gpu/drm/i2c/adv7511.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index f8a8a0b..9844336 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -435,8 +435,21 @@ static bool adv7511_hpd(struct adv7511 *adv7511)
 static void adv7511_hpd_work(struct work_struct *work)
 {
struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+   enum drm_connector_status status;
+   unsigned int val;
+   int ret;
+   ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
+   if (ret < 0)
+   status = connector_status_disconnected;
+   else if (val & ADV7511_STATUS_HPD)
+   status = connector_status_connected;
+   else
+   status = connector_status_disconnected;
 
-   drm_helper_hpd_irq_event(adv7511->connector.dev);
+   if (adv7511->connector.status != status) {
+   adv7511->connector.status = status;
+   drm_kms_helper_hotplug_event(adv7511->connector.dev);
+   }
 }
 
 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.4.y] drm: adv7511: Re-write the i2c address before EDID probing

2017-09-08 Thread Nhan Nguyen
commit 3587c856675c45809010c2cee5b21096f6e8e938 upstream.

I've found that by just turning the chip on and off via the
POWER_DOWN register, I end up getting i2c_transfer errors on
HiKey.

Investigating further, it turns out that some of the register
state in hardware is getting lost, as the device registers are
reset when the chip is powered down.

Thus this patch simply re-writes the i2c address to the
ADV7511_REG_EDID_I2C_ADDR register to ensure its properly set
before we try to read the EDID data.

Cc: David Airlie 
Cc: Archit Taneja 
Cc: Wolfram Sang 
Cc: Lars-Peter Clausen 
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: sta...@vger.kernel.org
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 
Signed-off-by: John Stultz 
Signed-off-by: Archit Taneja 
Signed-off-by: Thong Ho 
Signed-off-by: Nhan Nguyen 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-7-git-send-email-john.stu...@linaro.org
---
 drivers/gpu/drm/i2c/adv7511.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index ebb0fc8..dba5c0e 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -51,6 +51,10 @@ struct adv7511 {
struct gpio_desc *gpio_pd;
 };
 
+static const int edid_i2c_addr = 0x7e;
+static const int packet_i2c_addr = 0x70;
+static const int cec_i2c_addr = 0x78;
+
 static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder)
 {
return to_encoder_slave(encoder)->slave_priv;
@@ -606,6 +610,9 @@ static int adv7511_get_modes(struct drm_encoder *encoder,
 ADV7511_INT1_DDC_ERROR);
}
adv7511->current_edid_segment = -1;
+   /* Reset the EDID_I2C_ADDR register as it might be cleared */
+   regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
+   edid_i2c_addr);
}
 
edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
@@ -881,10 +888,6 @@ static int adv7511_parse_dt(struct device_node *np,
return 0;
 }
 
-static const int edid_i2c_addr = 0x7e;
-static const int packet_i2c_addr = 0x70;
-static const int cec_i2c_addr = 0x78;
-
 static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id 
*id)
 {
struct adv7511_link_config link_config;
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.4.y] drm: adv7511: Use work_struct to defer hotplug handing to out of irq context

2017-09-08 Thread Nhan Nguyen
commit 518cb7057a59b9441336d2e88a396d52b6ab0cce upstream.

I was recently seeing issues with EDID probing, where
the logic to wait for the EDID read bit to be set by the
IRQ wasn't happening and the code would time out and fail.

Digging deeper, I found this was due to the fact that
IRQs were disabled as we were running in IRQ context from
the HPD signal.

Thus this patch changes the logic to handle the HPD signal
via a work_struct so we can be out of irq context.

With this patch, the EDID probing on hotplug does not time
out.

Cc: David Airlie 
Cc: Archit Taneja 
Cc: Wolfram Sang 
Cc: Lars-Peter Clausen 
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: sta...@vger.kernel.org
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 
Signed-off-by: John Stultz 
Signed-off-by: Archit Taneja 
Signed-off-by: Thong Ho 
Signed-off-by: Nhan Nguyen 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-2-git-send-email-john.stu...@linaro.org
---
 drivers/gpu/drm/i2c/adv7511.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index a79b612..f8a8a0b 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -36,7 +36,10 @@ struct adv7511 {
bool edid_read;
 
wait_queue_head_t wq;
+   struct work_struct hpd_work;
+
struct drm_encoder *encoder;
+   struct drm_connector connector;
 
bool embedded_sync;
enum adv7511_sync_polarity vsync_polarity;
@@ -429,6 +432,13 @@ static bool adv7511_hpd(struct adv7511 *adv7511)
return false;
 }
 
+static void adv7511_hpd_work(struct work_struct *work)
+{
+   struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+
+   drm_helper_hpd_irq_event(adv7511->connector.dev);
+}
+
 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
 {
unsigned int irq0, irq1;
@@ -446,7 +456,7 @@ static int adv7511_irq_process(struct adv7511 *adv7511, 
bool process_hpd)
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
 
if (process_hpd && irq0 & ADV7511_INT0_HDP && adv7511->encoder)
-   drm_helper_hpd_irq_event(adv7511->encoder->dev);
+   schedule_work(&adv7511->hpd_work);
 
if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
adv7511->edid_read = true;
@@ -922,6 +932,8 @@ static int adv7511_probe(struct i2c_client *i2c, const 
struct i2c_device_id *id)
if (!adv7511->i2c_edid)
return -ENOMEM;
 
+   INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work);
+
if (i2c->irq) {
init_waitqueue_head(&adv7511->wq);
 
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102500] [polaris10, vega10][amd-staging-4.12, amd-staging-drm-next] GPU fault detected, somethimes lockup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102500

--- Comment #12 from Christian König  ---
To repeat my question: Does patch "drm/amdgpu: fix moved list handling in the
VM" fix the issue?

Do you guys have this in your kernel branch yet? If not that lockup is
expected.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC PATCH v4 3/6] i2c: add docs to clarify DMA handling

2017-09-08 Thread Wolfram Sang
Hi Mauro,

thanks for your comments. Much appreciated!

> There are also a couple of things here that Sphinx would complain.
> So, it could be worth to rename it to *.rst, while you're writing
> it, and see what:
>   make htmldocs
> will complain and how it will look in html.

OK, I'll check that.

> > +Given that I2C is a low-speed bus where largely small messages are 
> > transferred,
> > +it is not considered a prime user of DMA access. At this time of writing, 
> > only
> > +10% of I2C bus master drivers have DMA support implemented.
> 
> Are you sure about that? I'd say that, on media, at least half of the
> drivers use DMA for I2C bus access, as the I2C bus is on a remote
> board that talks with CPU via USB, using DMA, and all communication
> with USB should be DMA-safe.

Well, the DMA-safe requirement comes then from the USB subsystem,
doesn't it? Or do you really use DMA on the remote board to transfer
data via I2C to an I2C client?

> I guess what you really wanted to say on most of this section is
> about SoC (and other CPUs) where the I2C bus master is is at the
> mainboard, and not on some peripheral.

I might be biased to that, yes. So, it is good talking about it.

> > And the vast
> > +majority of transactions are so small that setting up DMA for it will 
> > likely
> > +add more overhead than a plain PIO transfer.
> > +
> > +Therefore, it is *not* mandatory that the buffer of an I2C message is DMA 
> > safe.
> 
> Again, that may not be true on media boards. The code that implements the
> I2C transfers there, on most boards, have to be DMA safe, as it won't
> otherwise send/receive commands from the chips that are after the USB
> bridge.

That still sounds to me like the DMA-safe requirement comes from USB
(which is fine, of course.). In any case, a sentence like "Other
subsystem you might use for bridging I2C might impose other DMA
requirements" sounds like to nice to have.

> > +Drivers wishing to implement DMA can use helper functions from the I2C 
> > core.
> > +One gives you a DMA-safe buffer for a given i2c_msg as long as a certain
> > +threshold is met.
> > +
> > +   dma_buf = i2c_get_dma_safe_msg_buf(msg, threshold_in_byte);
> 
> I'm concerned about the new bits added by this call. Right now,
> USB drivers just use kalloc() for transfer buffers used to send and
> receive URB control messages for both setting the main device and
> for I2C messages. Before this changeset, buffers allocated this
> way are DMA save and have been working for years.

Can you give me a pointer to a driver doing this? I glimpsed around in
drivers/media/usb and found that most drivers are having their i2c_msg
buffers on the stack. Which is clearly not DMA-safe.

> When you add some flags that would make the I2C subsystem aware
> that a buffer is now DMA safe, I guess you could be breaking
> those drivers, as a DMA safe buffer will now be considered as
> DMA-unsafe.

Well, this flag is only relevant for i2c master drivers wishing to do
DMA. So, grepping in the above directory

grep dma $(grep -rl i2c_add_adapter *)

only gives one driver which is irrelevant because the i2c master it
registers is not doing any DMA?

Am I missing something? We are clearly not aligned yet...

Regards,

   Wolfram



signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm/sun4i: tcon: Unconditionally reset the TCON

2017-09-08 Thread Chen-Yu Tsai
When binding the TCON, we were checking the reset control status and
asserting reset if it wasn't in reset. The check failed to account for
the reset control API returning error codes if the status callback was
not implemented.

Since we want the TCON to be reset in all cases, use reset_control_reset
to force a reset instead.

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Chen-Yu Tsai 
---

Changes since v1:

  - Replaced reset_control_assert / reset_control_deassert sequence
with reset_control_reset, which conveys our intent more clearly

---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c 
b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index d9791292553e..36cf1a0acc65 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -530,10 +530,7 @@ static int sun4i_tcon_bind(struct device *dev, struct 
device *master,
}
 
/* Make sure our TCON is reset */
-   if (!reset_control_status(tcon->lcd_rst))
-   reset_control_assert(tcon->lcd_rst);
-
-   ret = reset_control_deassert(tcon->lcd_rst);
+   ret = reset_control_reset(tcon->lcd_rst);
if (ret) {
dev_err(dev, "Couldn't deassert our reset line\n");
return ret;
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/6] drm/i915: Always wait for flip_done, v2.

2017-09-08 Thread Maarten Lankhorst
Op 07-09-17 om 11:49 schreef Daniel Vetter:
> On Mon, Sep 04, 2017 at 12:48:33PM +0200, Maarten Lankhorst wrote:
>> The next commit removes the wait for flip_done in in
>> drm_atomic_helper_commit_cleanup_done, but we need it for the tests
>> to pass. Instead of using complicated vblank tracking which ends
>> up being ignored anyway, call the correct atomic helper. :)
>>
>> Changes since v1:
>> - Always call drm_atomic_helper_wait_for_flip_done,
>>   even for legacy cursor updates. (danvet)
>>
>> Signed-off-by: Maarten Lankhorst 
>> ---
>>  drivers/gpu/drm/i915/i915_drv.h  |  3 +-
>>  drivers/gpu/drm/i915/intel_display.c | 84 
>> +++-
>>  2 files changed, 8 insertions(+), 79 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h 
>> b/drivers/gpu/drm/i915/i915_drv.h
>> index 38bd08f2539b..79533ba6f387 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -725,8 +725,7 @@ struct drm_i915_display_funcs {
>>  struct drm_atomic_state *old_state);
>>  void (*crtc_disable)(struct intel_crtc_state *old_crtc_state,
>>   struct drm_atomic_state *old_state);
>> -void (*update_crtcs)(struct drm_atomic_state *state,
>> - unsigned int *crtc_vblank_mask);
>> +void (*update_crtcs)(struct drm_atomic_state *state);
>>  void (*audio_codec_enable)(struct drm_connector *connector,
>> struct intel_encoder *encoder,
>> const struct drm_display_mode 
>> *adjusted_mode);
>> diff --git a/drivers/gpu/drm/i915/intel_display.c 
>> b/drivers/gpu/drm/i915/intel_display.c
>> index 216cd9e0e08f..a6cf1c20c712 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -12136,73 +12136,10 @@ u32 intel_crtc_get_vblank_counter(struct 
>> intel_crtc *crtc)
>>  return dev->driver->get_vblank_counter(dev, crtc->pipe);
>>  }
>>  
>> -static void intel_atomic_wait_for_vblanks(struct drm_device *dev,
>> -  struct drm_i915_private *dev_priv,
>> -  unsigned crtc_mask)
>> -{
>> -unsigned last_vblank_count[I915_MAX_PIPES];
>> -enum pipe pipe;
>> -int ret;
>> -
>> -if (!crtc_mask)
>> -return;
>> -
>> -for_each_pipe(dev_priv, pipe) {
>> -struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv,
>> -  pipe);
>> -
>> -if (!((1 << pipe) & crtc_mask))
>> -continue;
>> -
>> -ret = drm_crtc_vblank_get(&crtc->base);
>> -if (WARN_ON(ret != 0)) {
>> -crtc_mask &= ~(1 << pipe);
>> -continue;
>> -}
>> -
>> -last_vblank_count[pipe] = drm_crtc_vblank_count(&crtc->base);
>> -}
>> -
>> -for_each_pipe(dev_priv, pipe) {
>> -struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv,
>> -  pipe);
>> -long lret;
>> -
>> -if (!((1 << pipe) & crtc_mask))
>> -continue;
>> -
>> -lret = wait_event_timeout(dev->vblank[pipe].queue,
>> -last_vblank_count[pipe] !=
>> -drm_crtc_vblank_count(&crtc->base),
>> -msecs_to_jiffies(50));
>> -
>> -WARN(!lret, "pipe %c vblank wait timed out\n", pipe_name(pipe));
>> -
>> -drm_crtc_vblank_put(&crtc->base);
>> -}
>> -}
>> -
>> -static bool needs_vblank_wait(struct intel_crtc_state *crtc_state)
>> -{
>> -/* fb updated, need to unpin old fb */
>> -if (crtc_state->fb_changed)
>> -return true;
>> -
>> -/* wm changes, need vblank before final wm's */
>> -if (crtc_state->update_wm_post)
>> -return true;
>> -
>> -if (crtc_state->wm.need_postvbl_update)
>> -return true;
>> -
>> -return false;
>> -}
>> -
>>  static void intel_update_crtc(struct drm_crtc *crtc,
>>struct drm_atomic_state *state,
>>struct drm_crtc_state *old_crtc_state,
>> -  struct drm_crtc_state *new_crtc_state,
>> -  unsigned int *crtc_vblank_mask)
>> +  struct drm_crtc_state *new_crtc_state)
>>  {
>>  struct drm_device *dev = crtc->dev;
>>  struct drm_i915_private *dev_priv = to_i915(dev);
>> @@ -12225,13 +12162,9 @@ static void intel_update_crtc(struct drm_crtc *crtc,
>>  }
>>  
>>  drm_atomic_helper_commit_planes_on_crtc(old_crtc_state);
>> -
>> -if (needs_vblank_wait(pipe_config))
>> -*crtc_vblank_mask |= drm_crtc_mask(crtc);
>>  }
>>  
>> -static void intel_update_crtcs(struct drm_atomic_state *state,
>> -   unsigned

[Bug 100387] War Thunder game has visual errors, missing textures

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=100387

--- Comment #11 from Peter  ---
Well, no problem, just please give me a reliable way to get this info. Listing
the X.org.log, I'm a bit confused.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102500] [polaris10, vega10][amd-staging-4.12, amd-staging-drm-next] GPU fault detected, somethimes lockup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102500

--- Comment #13 from Arek Ruśniak  ---
Christian sorry, I thought that was clear. 
Yes, I updated ASAP so it contains:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-4.12&id=8bd2cc0ab44b00346cc41f3ac828cbf992f6bc61
Doesn't help for vm-faults

Every test right before and after your comment is for: 
linux-amd-staging-4.12-c5def4cbdb61

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102543] [BAT][HSW] igt@tools_test@tools_test - Unclaimed read from register 0x[4c]400c

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102543

Martin Peres  changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102543] [BAT][HSW] igt@tools_test@tools_test - Unclaimed read from register 0x[4c]400c

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102543

Martin Peres  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Martin Peres  ---
Thanks Chris! I will close this bug.

What about https://bugs.freedesktop.org/show_bug.cgi?id=102249 though? Could
the patch you sent fix this too?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/11] drm/sun4i: add CEC support

2017-09-08 Thread Hans Verkuil
Hi Maxime,

On 07/18/17 18:29, Maxime Ripard wrote:
> Hi,
> 
> On Tue, Jul 11, 2017 at 11:06:52PM +0200, Hans Verkuil wrote:
>> On 11/07/17 22:39, Maxime Ripard wrote:
>>> On Tue, Jul 11, 2017 at 08:30:33AM +0200, Hans Verkuil wrote:
 From: Hans Verkuil 

 This patch series adds CEC support for the sun4i HDMI controller.

 The CEC hardware support for the A10 is very low-level as it just
 controls the CEC pin. Since I also wanted to support GPIO-based CEC
 hardware most of this patch series is in the CEC framework to
 add a generic low-level CEC pin framework. It is only the final patch
 that adds the sun4i support.

 This patch series first makes some small changes in the CEC framework
 (patches 1-4) to prepare for this CEC pin support.

 Patch 5-7 adds the new API elements and documents it. Patch 6 reworks
 the CEC core event handling.

 Patch 8 adds pin monitoring support (allows userspace to see all
 CEC pin transitions as they happen).

 Patch 9 adds the core cec-pin implementation that translates low-level
 pin transitions into valid CEC messages. Basically this does what any
 SoC with a proper CEC hardware implementation does.

 Patch 10 documents the cec-pin kAPI (and also the cec-notifier kAPI
 which was missing).

 Finally patch 11 adds the actual sun4i_hdmi CEC implementation.

 I tested this on my cubieboard. There were no errors at all
 after 126264 calls of 'cec-ctl --give-device-vendor-id' while at the
 same time running a 'make -j4' of the v4l-utils git repository and
 doing a continuous scp to create network traffic.

 This patch series is based on top of the mainline kernel as of
 yesterday (so with all the sun4i and cec patches for 4.13 merged).
>>>
>>> For the whole serie:
>>> Reviewed-by: Maxime Ripard 
>>>
 Maxime, patches 1-10 will go through the media subsystem. How do you
 want to handle the final patch? It can either go through the media
 subsystem as well, or you can sit on it and handle this yourself during
 the 4.14 merge window. Another option is to separate the Kconfig change
 into its own patch. That way you can merge the code changes and only
 have to handle the Kconfig patch as a final change during the merge
 window.
>>>
>>> We'll probably have a number of reworks for 4.14, so it would be
>>> better if I merged it.
>>>
>>> However, I guess if we just switch to a depends on CEC_PIN instead of
>>> a select, everything would just work even if we merge your patches in
>>> a separate tree, right?
>>
>> This small patch will do it:
>>
>> diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig
>> index e884d265c0b3..ebad80aefc87 100644
>> --- a/drivers/gpu/drm/sun4i/Kconfig
>> +++ b/drivers/gpu/drm/sun4i/Kconfig
>> @@ -25,7 +25,7 @@ config DRM_SUN4I_HDMI_CEC
>> bool "Allwinner A10 HDMI CEC Support"
>> depends on DRM_SUN4I_HDMI
>> select CEC_CORE
>> -   select CEC_PIN
>> +   depends on CEC_PIN
>> help
>>Choose this option if you have an Allwinner SoC with an HDMI
>>controller and want to use CEC.

Just a reminder: now that both this driver and the CEC_PIN code has been
merged in 4.14, this 'depends on' can become a 'select' again.

Regards,

Hans
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99349] Failed to build shader (translation from TGSI)

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99349

--- Comment #19 from Emil Velikov  ---
Note that the series adds an extra optimisation pass. As such it's not suitable
for stable. You'll have to use mesa from git until 17.3 is out.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102500] [polaris10, vega10][amd-staging-4.12, amd-staging-drm-next] GPU fault detected, somethimes lockup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102500

--- Comment #14 from Christian König  ---
(In reply to Arek Ruśniak from comment #13)
> Christian sorry, I thought that was clear. 

No problem, that just means that this is the same issue I'm still hunting for.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 192271] kernel 4.9 hangs during shutdown or reboot

2017-09-08 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=192271

fthhi...@emlhub.com changed:

   What|Removed |Added

 CC||fthhi...@emlhub.com

--- Comment #6 from fthhi...@emlhub.com ---
Hi

Same problem after upgrading to kernel 4.12.10-1-ARCH (ArchLinux 64Bit)

Radeon 5770 Evergreen

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102543] [BAT][HSW] igt@tools_test@tools_test - Unclaimed read from register 0x[4c]400c

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102543

--- Comment #7 from Chris Wilson  ---
(In reply to Martin Peres from comment #6)
> Thanks Chris! I will close this bug.
> 
> What about https://bugs.freedesktop.org/show_bug.cgi?id=102249 though? Could
> the patch you sent fix this too?

It's not intended to have any effect for any test except for tools_test; but
drv_suspend/forcewake, pm_rpm/debugfs-forcewake-user, gem_exec_latency,
gem_exec_parse, gem_workarounds and pm_lsps also poke around with registers
under forcewake - any may end up polluting the mmio debugger. #102249 looks
clear of outside influence.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/6] ARM: dts: exynos: Add clean name of compatible.

2017-09-08 Thread Robin Murphy
On 08/09/17 07:02, Hoegeun Kwon wrote:
> Exynos 5250 and 5420 have different hardware rotation limits. However,
> currently it uses only one compatible - "exynos5-gsc". Since we have
> to distinguish between these two, we add different compatible.
> 
> Signed-off-by: Hoegeun Kwon 
> ---
>  arch/arm/boot/dts/exynos5250.dtsi | 8 
>  arch/arm/boot/dts/exynos5420.dtsi | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
> b/arch/arm/boot/dts/exynos5250.dtsi
> index 8dbeb87..bf08101 100644
> --- a/arch/arm/boot/dts/exynos5250.dtsi
> +++ b/arch/arm/boot/dts/exynos5250.dtsi
> @@ -637,7 +637,7 @@
>   };
>  
>   gsc_0:  gsc@13e0 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";

These should be the other way round - the most specific compatible
should come first, then the more general fallback afterwards.

(and similarly in all cases below)

Robin.

>   reg = <0x13e0 0x1000>;
>   interrupts = ;
>   power-domains = <&pd_gsc>;
> @@ -647,7 +647,7 @@
>   };
>  
>   gsc_1:  gsc@13e1 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e1 0x1000>;
>   interrupts = ;
>   power-domains = <&pd_gsc>;
> @@ -657,7 +657,7 @@
>   };
>  
>   gsc_2:  gsc@13e2 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e2 0x1000>;
>   interrupts = ;
>   power-domains = <&pd_gsc>;
> @@ -667,7 +667,7 @@
>   };
>  
>   gsc_3:  gsc@13e3 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5250-gsc";
>   reg = <0x13e3 0x1000>;
>   interrupts = ;
>   power-domains = <&pd_gsc>;
> diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
> b/arch/arm/boot/dts/exynos5420.dtsi
> index 02d2f89..86afe77 100644
> --- a/arch/arm/boot/dts/exynos5420.dtsi
> +++ b/arch/arm/boot/dts/exynos5420.dtsi
> @@ -658,7 +658,7 @@
>   };
>  
>   gsc_0: video-scaler@13e0 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5420-gsc";
>   reg = <0x13e0 0x1000>;
>   interrupts = ;
>   clocks = <&clock CLK_GSCL0>;
> @@ -668,7 +668,7 @@
>   };
>  
>   gsc_1: video-scaler@13e1 {
> - compatible = "samsung,exynos5-gsc";
> + compatible = "samsung,exynos5-gsc", 
> "samsung,exynos5420-gsc";
>   reg = <0x13e1 0x1000>;
>   interrupts = ;
>   clocks = <&clock CLK_GSCL1>;
> 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/3] fb/drm: Add support for a panel-orientation connector prop

2017-09-08 Thread Hans de Goede
Hi All,

Some x86 clamshell design devices use portrait tablet LCD panels and a
display engine which cannot (transparently) rotate in hardware, so we
need to rotate things in software / let user space deal with this.

The fbcon code has a set of DMI based quirks to automatically detect
such tablet LCD panels and rotate the fbcon to compensate.

The plan was for userspace (e.g. a Wayland compositor) to simply read
/sys/class/graphics/fbcon/rotate and apply the rotation from there to
the LCD panel to compensate.

However this will not work when an external monitor gets plugged in,
since with fbcon rotation is not per output, so the fbcon quirk code
disables the rotation when an external monitor is present.

Using /sys/class/graphics/fbcon/rotate will not help in that case
since it will indicate no rotation is in use. So instead we are going
to need a drm connecter property for this.

This patch-series introduces such a drm connector properperty, it
consists of 3 patches:

1) Make the fbcon quirk table usable outside of the fbcon code
2) Add drm_connector_create_panel_orientation_property and
   drm_connector_attach_panel_orientation_property functions
3) Hook things up in intel_panel.c

Regards,

Hans


p.s.

Note this series does not yet get the panel orientation from the VBT
on Intel devices. I think that for devices which have the panel
upside-down (rather then rotated 90 degrees) this should work, but
I've an i915 patch series pending which corrects for the upside-down
scanario fully inside the i915 driver hiding the upside-down ness
from userspace (and fbcon) and if that series gets merged then in
the upside-down case the "panel orientation" property should read
"Normal" and not "Upside Down", so I've left out hooking up the VBTs
idea of the panel orientation for now.

Note that we could use the new "panel orientation" property for the
upside-down case too and drop my "[v4] drm/i915: Deal with upside-down
mounted LCD panels" patch:
https://patchwork.freedesktop.org/patch/173781/

That patch is not universally liked anyways, so just dropping it and
using the new prop this series introduces might be best.
 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/i915: Add "panel orientation" property to the panel connector

2017-09-08 Thread Hans de Goede
For now this is always set to DRM_MODE_PANEL_ORIENTATION_UNKNOWN
unless there is a dmi based quirk overriding the value.

In the future we should probably provide an initial value based on
the VBT (at least for some panel types).

Signed-off-by: Hans de Goede 
---
 drivers/gpu/drm/i915/intel_panel.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_panel.c 
b/drivers/gpu/drm/i915/intel_panel.c
index 72f8cbb237b1..4a52c9d5790a 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1926,6 +1926,22 @@ int intel_panel_init(struct intel_panel *panel,
 struct drm_display_mode *alt_fixed_mode,
 struct drm_display_mode *downclock_mode)
 {
+   struct intel_connector *intel_connector =
+   container_of(panel, struct intel_connector, panel);
+   int ret;
+
+   if (fixed_mode) {
+   ret = drm_connector_create_panel_orientation_property(
+   intel_connector->base.dev);
+   if (ret)
+   return ret;
+
+   drm_connector_attach_panel_orientation_property(
+   &intel_connector->base,
+   fixed_mode->hdisplay, fixed_mode->vdisplay,
+   DRM_MODE_PANEL_ORIENTATION_UNKNOWN);
+   }
+
intel_panel_init_backlight_funcs(panel);
 
panel->fixed_mode = fixed_mode;
-- 
2.13.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] video: fb: Make fbcon dmi quirks usuable for drm drivers too

2017-09-08 Thread Hans de Goede
Some x86 clamshell design devices use portrait tablet LCD panels and a
display engine which cannot (transparently) rotate in hardware, so we
need to rotate things in software / let user space deal with this.

The fbcon code has a set of DMI based quirks to automatically detect
such tablet LCD panels and rotate the fbcon to compensate.

The plan was for userspace (e.g. a Wayland compositor) to simply read
/sys/class/graphics/fbcon/rotate and apply the rotation from there to
the LCD panel to compensate.

However this will not work when an external monitor gets plugged in,
since with fbcon rotation is not per output, so the fbcon quirk code
disables the rotation when an external monitor is present.

Using /sys/class/graphics/fbcon/rotate will not help in that case
since it will indicate no rotation is in use. So instead we are going
to need a drm connecter property for this.

This commit is a preparation patch for adding the drm-connecter
property, by making the fbcon quirk code generally usable so that
the drm code can use it to check for rotation quirks.

Note this commit re-uses the FB_CMDLINE Kconfig option for selecting
if the quirk code should be build, since that is already selected by
both the drm and fbcon code.

Signed-off-by: Hans de Goede 
---
 drivers/video/console/Makefile |  3 ---
 drivers/video/console/fbcon.c  | 22 ++
 drivers/video/console/fbcon.h  |  6 --
 drivers/video/fbdev/core/Makefile  |  3 +++
 .../core/fb_dmi_quirks.c}  | 15 +--
 include/linux/fb.h |  6 ++
 6 files changed, 32 insertions(+), 23 deletions(-)
 rename drivers/video/{console/fbcon_dmi_quirks.c => 
fbdev/core/fb_dmi_quirks.c} (91%)

diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index 32ee2ad37369..43bfa485db96 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -15,8 +15,5 @@ ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE_ROTATION),y)
 obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
  fbcon_ccw.o
 endif
-ifeq ($(CONFIG_DMI),y)
-obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_dmi_quirks.o
-endif
 
 obj-$(CONFIG_FB_STI)  += sticore.o
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 3db5ac2bfbb7..f33f5a61405c 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -954,10 +954,13 @@ static const char *fbcon_startup(void)
ops->cur_rotate = -1;
ops->cur_blink_jiffies = HZ / 5;
info->fbcon_par = ops;
-   if (initial_rotation != -1)
-   p->con_rotate = initial_rotation;
-   else
-   p->con_rotate = fbcon_platform_get_rotate(info);
+   p->con_rotate = initial_rotation;
+   if (p->con_rotate == -1)
+   p->con_rotate = fb_get_panel_rotate_quirk(info->var.xres,
+ info->var.yres);
+   if (p->con_rotate == -1)
+   p->con_rotate = FB_ROTATE_UR;
+
set_blitting_type(vc, info);
 
if (info->fix.type != FB_TYPE_TEXT) {
@@ -1094,10 +1097,13 @@ static void fbcon_init(struct vc_data *vc, int init)
 
ops = info->fbcon_par;
ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
-   if (initial_rotation != -1)
-   p->con_rotate = initial_rotation;
-   else
-   p->con_rotate = fbcon_platform_get_rotate(info);
+   p->con_rotate = initial_rotation;
+   if (p->con_rotate == -1)
+   p->con_rotate = fb_get_panel_rotate_quirk(info->var.xres,
+ info->var.yres);
+   if (p->con_rotate == -1)
+   p->con_rotate = FB_ROTATE_UR;
+
set_blitting_type(vc, info);
 
cols = vc->vc_cols;
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 60e25e173fdb..73add376790c 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -261,10 +261,4 @@ extern void fbcon_set_rotate(struct fbcon_ops *ops);
 #define fbcon_set_rotate(x) do {} while(0)
 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
 
-#ifdef CONFIG_DMI
-int fbcon_platform_get_rotate(struct fb_info *info);
-#else
-#define fbcon_platform_get_rotate(i) FB_ROTATE_UR
-#endif /* CONFIG_DMI */
-
 #endif /* _VIDEO_FBCON_H */
diff --git a/drivers/video/fbdev/core/Makefile 
b/drivers/video/fbdev/core/Makefile
index 9e3ddf225393..b9162a2b6e88 100644
--- a/drivers/video/fbdev/core/Makefile
+++ b/drivers/video/fbdev/core/Makefile
@@ -1,4 +1,7 @@
 obj-$(CONFIG_FB_CMDLINE)  += fb_cmdline.o
+ifeq ($(CONFIG_DMI),y)
+obj-$(CONFIG_FB_CMDLINE)  += fb_dmi_quirks.o
+endif
 obj-$(CONFIG_FB_NOTIFY)   += fb_notify.o
 obj-$(CONFIG_FB)  += fb.o
 fb-y 

[PATCH 2/3] drm: Add support for a panel-orientation connector property

2017-09-08 Thread Hans de Goede
On some devices the LCD panel is mounted in the casing in such a way that
the up/top side of the panel does not match with the top side of the
device (e.g. it is mounted upside-down).

This commit adds the necessary infra for lcd-panel drm_connector-s to
have a "panel orientation" property to communicate how the panel is
orientated vs the casing.

Userspace can use this property to check for non-normal orientation and
then adjust the displayed image accordingly by rotating it to compensate.

Signed-off-by: Hans de Goede 
---
 drivers/gpu/drm/drm_connector.c | 92 +
 include/drm/drm_connector.h |  4 ++
 include/drm/drm_mode_config.h   |  7 
 include/uapi/drm/drm_mode.h |  7 
 4 files changed, 110 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index ba9f36cef68c..ea4cded1e328 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -665,6 +665,13 @@ static const struct drm_prop_enum_list 
drm_aspect_ratio_enum_list[] = {
{ DRM_MODE_PICTURE_ASPECT_16_9, "16:9" },
 };
 
+static const struct drm_prop_enum_list drm_panel_orientation_enum_list[] = {
+   { DRM_MODE_PANEL_ORIENTATION_NORMAL,"Normal"},
+   { DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP, "Upside Down"   },
+   { DRM_MODE_PANEL_ORIENTATION_LEFT_UP,   "Left Side Up"  },
+   { DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,  "Right Side Up" },
+};
+
 static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
{ DRM_MODE_SUBCONNECTOR_DVID,  "DVI-D" }, /* DVI-I  */
@@ -746,6 +753,18 @@ DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
  *
  * CRTC_ID:
  * Mode object ID of the &drm_crtc this connector should be connected to.
+ *
+ * Connectors for LCD panels may also have one standardized property:
+ *
+ * panel orientation:
+ * On some devices the LCD panel is mounted in the casing in such a way
+ * that the up/top side of the panel does not match with the top side of
+ * the device. Userspace can use this property to check for this.
+ * Note that input coordinates from touchscreens (input devices with
+ * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
+ * coordinates, so if userspace rotates the picture to adjust for
+ * the orientation it must also apply the same transformation to the
+ * touchscreen input coordinates.
  */
 
 int drm_connector_create_standard_properties(struct drm_device *dev)
@@ -1148,6 +1167,79 @@ int drm_mode_connector_set_tile_property(struct 
drm_connector *connector)
 EXPORT_SYMBOL(drm_mode_connector_set_tile_property);
 
 /**
+ * drm_mode_create_panel_orientation_property - create scaling mode property
+ * @dev: DRM device
+ *
+ * Called by a driver the first time it's needed, must be attached to desired
+ * connectors.
+ */
+int drm_connector_create_panel_orientation_property(struct drm_device *dev)
+{
+   struct drm_property *panel_orientation;
+
+   if (dev->mode_config.panel_orientation_property)
+   return 0;
+
+   panel_orientation =
+   drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
+   "panel orientation",
+   drm_panel_orientation_enum_list,
+   ARRAY_SIZE(drm_panel_orientation_enum_list));
+
+   dev->mode_config.panel_orientation_property = panel_orientation;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_connector_create_panel_orientation_property);
+
+/**
+ * drm_connector_attach_panel_orientation_property -
+ * attach panel-orientation property
+ * @connector: connector to attach panel-orientation property on.
+ * @width: width in pixels of the panel, used for panel quirk detection
+ * @height: height in pixels of the panel, used for panel quirk detection
+ * @panel_orientation: a DRM_MODE_PANEL_ORIENTATION_* value
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_attach_panel_orientation_property(
+   struct drm_connector *connector, int width, int height,
+   int panel_orientation)
+{
+   int orientation;
+
+   /*
+* Note fb_get_panel_rotate_quirk returns the rotation needed to
+* *correct* for the panel orientation.
+*/
+   switch (fb_get_panel_rotate_quirk(width, height)) {
+   case FB_ROTATE_UR:
+   orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
+   break;
+   case FB_ROTATE_CW:
+   orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
+   break;
+   case FB_ROTATE_UD:
+   orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
+   break;
+   case FB_ROTATE_CCW:
+   orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
+   break;
+   default:
+   orientation = panel_orientation;
+

Re: [PATCH v3 3/6] drm/exynos/gsc: Add hardware rotation limits

2017-09-08 Thread Robin Murphy
On 08/09/17 07:02, Hoegeun Kwon wrote:
> The gscaler has hardware rotation limits that need to be hardcoded
> into driver. Distinguish them and add them to the property list.
> 
> The hardware rotation limits are related to the cropped source size.
> When swap occurs, use rot_max size instead of crop_max size.
> 
> Also the scaling limits are related to pos size, use pos size to check
> the limits.
> 
> Signed-off-by: Hoegeun Kwon 
> ---
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c | 93 
> +++--
>  include/uapi/drm/exynos_drm.h   |  2 +
>  2 files changed, 66 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
> b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 0506b2b..a4fb347 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -150,6 +151,15 @@ struct gsc_context {
>   boolsuspended;
>  };
>  
> +/*
> + * struct gsc_driverdata - per device type driver data for init time.
> + *
> + * @rot_max: rotation max resolution.
> + */
> +struct gsc_driverdata {
> + struct drm_exynos_sz rot_max;
> +};
> +
>  /* 8-tap Filter Coefficient */
>  static const int h_coef_8t[GSC_COEF_RATIO][GSC_COEF_ATTR][GSC_COEF_H_8T] = {
>   {   /* Ratio <= 65536 (~8:8) */
> @@ -1401,6 +1411,23 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   bool swap;
>   int i;
>  
> + config = &property->config[EXYNOS_DRM_OPS_DST];
> +
> + /* check for degree */
> + switch (config->degree) {
> + case EXYNOS_DRM_DEGREE_90:
> + case EXYNOS_DRM_DEGREE_270:
> + swap = true;
> + break;
> + case EXYNOS_DRM_DEGREE_0:
> + case EXYNOS_DRM_DEGREE_180:
> + swap = false;
> + break;
> + default:
> + DRM_ERROR("invalid degree.\n");
> + goto err_property;
> + }
> +
>   for_each_ipp_ops(i) {
>   if ((i == EXYNOS_DRM_OPS_SRC) &&
>   (property->cmd == IPP_CMD_WB))
> @@ -1416,21 +1443,6 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   goto err_property;
>   }
>  
> - /* check for degree */
> - switch (config->degree) {
> - case EXYNOS_DRM_DEGREE_90:
> - case EXYNOS_DRM_DEGREE_270:
> - swap = true;
> - break;
> - case EXYNOS_DRM_DEGREE_0:
> - case EXYNOS_DRM_DEGREE_180:
> - swap = false;
> - break;
> - default:
> - DRM_ERROR("invalid degree.\n");
> - goto err_property;
> - }
> -
>   /* check for buffer bound */
>   if ((pos->x + pos->w > sz->hsize) ||
>   (pos->y + pos->h > sz->vsize)) {
> @@ -1438,21 +1450,27 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   goto err_property;
>   }
>  
> + /*
> +  * The rotation hardware limits are related to the cropped
> +  * source size. So use rot_max size to check the limits when
> +  * swap happens. And also the scaling limits are related to pos
> +  * size, use pos size to check the limits.
> +  */
>   /* check for crop */
>   if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
>   if (swap) {
>   if ((pos->h < pp->crop_min.hsize) ||
> - (sz->vsize > pp->crop_max.hsize) ||
> + (pos->h > pp->rot_max.hsize) ||
>   (pos->w < pp->crop_min.vsize) ||
> - (sz->hsize > pp->crop_max.vsize)) {
> + (pos->w > pp->rot_max.vsize)) {
>   DRM_ERROR("out of crop size.\n");
>   goto err_property;
>   }
>   } else {
>   if ((pos->w < pp->crop_min.hsize) ||
> - (sz->hsize > pp->crop_max.hsize) ||
> + (pos->w > pp->crop_max.hsize) ||
>   (pos->h < pp->crop_min.vsize) ||
> - (sz->vsize > pp->crop_max.vsize)) {
> + (pos->h > pp->crop_max.vsize)) {
>   DRM_ERROR("out of crop size.\n");
>   goto err_property;
>   }
> @@ -1463,17 +1481,17 @@ static int gsc_ippdrv_check_property(struct device 
> *dev,
>   if ((i == EXYNOS_DRM_OPS_DST) && (pp->sc

Re: [PATCH 0/3] fb/drm: Add support for a panel-orientation connector prop

2017-09-08 Thread Daniel Vetter
On Fri, Sep 08, 2017 at 01:54:41PM +0200, Hans de Goede wrote:
> Hi All,
> 
> Some x86 clamshell design devices use portrait tablet LCD panels and a
> display engine which cannot (transparently) rotate in hardware, so we
> need to rotate things in software / let user space deal with this.
> 
> The fbcon code has a set of DMI based quirks to automatically detect
> such tablet LCD panels and rotate the fbcon to compensate.
> 
> The plan was for userspace (e.g. a Wayland compositor) to simply read
> /sys/class/graphics/fbcon/rotate and apply the rotation from there to
> the LCD panel to compensate.
> 
> However this will not work when an external monitor gets plugged in,
> since with fbcon rotation is not per output, so the fbcon quirk code
> disables the rotation when an external monitor is present.

Hm, where is that handled? Afaiui the fbdev emulation in drm completel
hides that there's possibly multiple monitors connected, which means I
have no idea how fbcon can even figure this out. Can you give some
pointers to relevant code?

Thanks, Daniel

> 
> Using /sys/class/graphics/fbcon/rotate will not help in that case
> since it will indicate no rotation is in use. So instead we are going
> to need a drm connecter property for this.
> 
> This patch-series introduces such a drm connector properperty, it
> consists of 3 patches:
> 
> 1) Make the fbcon quirk table usable outside of the fbcon code
> 2) Add drm_connector_create_panel_orientation_property and
>drm_connector_attach_panel_orientation_property functions
> 3) Hook things up in intel_panel.c
> 
> Regards,
> 
> Hans
> 
> 
> p.s.
> 
> Note this series does not yet get the panel orientation from the VBT
> on Intel devices. I think that for devices which have the panel
> upside-down (rather then rotated 90 degrees) this should work, but
> I've an i915 patch series pending which corrects for the upside-down
> scanario fully inside the i915 driver hiding the upside-down ness
> from userspace (and fbcon) and if that series gets merged then in
> the upside-down case the "panel orientation" property should read
> "Normal" and not "Upside Down", so I've left out hooking up the VBTs
> idea of the panel orientation for now.
> 
> Note that we could use the new "panel orientation" property for the
> upside-down case too and drop my "[v4] drm/i915: Deal with upside-down
> mounted LCD panels" patch:
> https://patchwork.freedesktop.org/patch/173781/
> 
> That patch is not universally liked anyways, so just dropping it and
> using the new prop this series introduces might be best.
>  
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102500] [polaris10, vega10][amd-staging-4.12, amd-staging-drm-next] GPU fault detected, somethimes lockup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102500

--- Comment #15 from Christian König  ---
Created attachment 134082
  --> https://bugs.freedesktop.org/attachment.cgi?id=134082&action=edit
Possible fix

Please try the attached kernel patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4.4.y] drm: adv7511: Re-write the i2c address before EDID probing

2017-09-08 Thread Greg KH
On Fri, Sep 08, 2017 at 06:22:02PM +0700, Nhan Ngoc. Nguyen wrote:
> This patch is ported from linux stable 4.9, commit 
> 3587c856675c45809010c2cee5b21096f6e8e938.

No, commit 3587c856675c45809010c2cee5b21096f6e8e938 showed up in
4.11-rc1:
$ git describe --contains 3587c856675c45809010c2cee5b21096f6e8e938
v4.11-rc1~83^2~38^2~2

> So I think I don't need to port on version 4.9.

I think it is still needed there...

And please do not top-post...

greg k-h
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/7 v4] drm/pl111: Add all registers to debugfs

2017-09-08 Thread Linus Walleij
This adds all the main control registers to the debugfs
register file. This was helpful for my debugging so it will
likely help others as well.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Collect Eric's ACK.
---
 drivers/gpu/drm/pl111/pl111_debugfs.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/pl111/pl111_debugfs.c 
b/drivers/gpu/drm/pl111/pl111_debugfs.c
index 0d9dee199b2c..7ddc7e3b9e7d 100644
--- a/drivers/gpu/drm/pl111/pl111_debugfs.c
+++ b/drivers/gpu/drm/pl111/pl111_debugfs.c
@@ -22,8 +22,14 @@ static const struct {
REGDEF(CLCD_TIM2),
REGDEF(CLCD_TIM3),
REGDEF(CLCD_UBAS),
+   REGDEF(CLCD_LBAS),
REGDEF(CLCD_PL111_CNTL),
REGDEF(CLCD_PL111_IENB),
+   REGDEF(CLCD_PL111_RIS),
+   REGDEF(CLCD_PL111_MIS),
+   REGDEF(CLCD_PL111_ICR),
+   REGDEF(CLCD_PL111_UCUR),
+   REGDEF(CLCD_PL111_LCUR),
 };
 
 int pl111_debugfs_regs(struct seq_file *m, void *unused)
-- 
2.13.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/7 v4] drm/pl111: Replace custom connector with panel bridge

2017-09-08 Thread Linus Walleij
This replaces the custom connector in the PL111 with the
panel bridge helper.

This works nicely for all standard panels, but since there
are several PL11x-based systems that will need to use the dumb
VGA connector bridge we use drm_of_find_panel_or_bridge()
and make some headroom for dealing with bridges that are
not panels as well, and drop a TODO in the code.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- Drop the surplus drm_bridge_remove(bridge) calls.
- Collect Eric's review tag.
ChangeLog v2->v3:
- Rebase on DRM-TIP
- Use drm_simple_display_pipe_attach_bridge() as suggested
  by Daniel Vetter.
ChangeLog v1->v2:
- Remove the panel [un]prepare() and [en|dis]able() calls
  from the display driver, since this is now handled
  by the bridge.
---
 drivers/gpu/drm/pl111/Kconfig   |   3 +-
 drivers/gpu/drm/pl111/Makefile  |   3 +-
 drivers/gpu/drm/pl111/pl111_connector.c | 126 
 drivers/gpu/drm/pl111/pl111_display.c   |  13 +---
 drivers/gpu/drm/pl111/pl111_drm.h   |  17 ++---
 drivers/gpu/drm/pl111/pl111_drv.c   |  55 +-
 6 files changed, 49 insertions(+), 168 deletions(-)
 delete mode 100644 drivers/gpu/drm/pl111/pl111_connector.c

diff --git a/drivers/gpu/drm/pl111/Kconfig b/drivers/gpu/drm/pl111/Kconfig
index bbfba87cd1a8..e5e2abd66491 100644
--- a/drivers/gpu/drm/pl111/Kconfig
+++ b/drivers/gpu/drm/pl111/Kconfig
@@ -6,7 +6,8 @@ config DRM_PL111
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
select DRM_GEM_CMA_HELPER
-   select DRM_PANEL
+   select DRM_BRIDGE
+   select DRM_PANEL_BRIDGE
select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
help
  Choose this option for DRM support for the PL111 CLCD controller.
diff --git a/drivers/gpu/drm/pl111/Makefile b/drivers/gpu/drm/pl111/Makefile
index 59483d610ef5..c5f8f9684848 100644
--- a/drivers/gpu/drm/pl111/Makefile
+++ b/drivers/gpu/drm/pl111/Makefile
@@ -1,5 +1,4 @@
-pl111_drm-y += pl111_connector.o \
-   pl111_display.o \
+pl111_drm-y += pl111_display.o \
pl111_drv.o
 
 pl111_drm-$(CONFIG_DEBUG_FS) += pl111_debugfs.o
diff --git a/drivers/gpu/drm/pl111/pl111_connector.c 
b/drivers/gpu/drm/pl111/pl111_connector.c
deleted file mode 100644
index d335f9a29ce4..
--- a/drivers/gpu/drm/pl111/pl111_connector.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
- *
- * Parts of this file were based on sources as follows:
- *
- * Copyright (c) 2006-2008 Intel Corporation
- * Copyright (c) 2007 Dave Airlie 
- * Copyright (C) 2011 Texas Instruments
- *
- * This program is free software and is provided to you under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation, and any use by you of this program is subject to the terms of
- * such GNU licence.
- *
- */
-
-/**
- * pl111_drm_connector.c
- * Implementation of the connector functions for PL111 DRM
- */
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "pl111_drm.h"
-
-static void pl111_connector_destroy(struct drm_connector *connector)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   if (pl111_connector->panel)
-   drm_panel_detach(pl111_connector->panel);
-
-   drm_connector_unregister(connector);
-   drm_connector_cleanup(connector);
-}
-
-static enum drm_connector_status pl111_connector_detect(struct drm_connector
-   *connector, bool force)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   return (pl111_connector->panel ?
-   connector_status_connected :
-   connector_status_disconnected);
-}
-
-static int pl111_connector_helper_get_modes(struct drm_connector *connector)
-{
-   struct pl111_drm_connector *pl111_connector =
-   to_pl111_connector(connector);
-
-   if (!pl111_connector->panel)
-   return 0;
-
-   return drm_panel_get_modes(pl111_connector->panel);
-}
-
-const struct drm_connector_funcs connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = pl111_connector_destroy,
-   .detect = pl111_connector_detect,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-const struct drm_connector_helper_funcs connector_helper_funcs = {
-   .get_modes = pl111_connector_helper_get_modes,
-};
-
-/* Walks the OF graph to find the panel node and then asks DRM to look
- * up the panel.
- */
-static struct drm_panel *pl111_get_panel(struct device *dev)
-{
-   struct device_node *endpoint, *p

[PATCH 1/7 v4] drm/pl111: Cleanup local header file

2017-09-08 Thread Linus Walleij
The header file contains prototypes for two nonexisting
functions. Get rid of them.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Collect Eric's ACK.
---
 drivers/gpu/drm/pl111/pl111_drm.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_drm.h 
b/drivers/gpu/drm/pl111/pl111_drm.h
index 5c685bfc8fdc..a97f303f6833 100644
--- a/drivers/gpu/drm/pl111/pl111_drm.h
+++ b/drivers/gpu/drm/pl111/pl111_drm.h
@@ -58,10 +58,6 @@ int pl111_enable_vblank(struct drm_device *drm, unsigned int 
crtc);
 void pl111_disable_vblank(struct drm_device *drm, unsigned int crtc);
 irqreturn_t pl111_irq(int irq, void *data);
 int pl111_connector_init(struct drm_device *dev);
-int pl111_encoder_init(struct drm_device *dev);
-int pl111_dumb_create(struct drm_file *file_priv,
- struct drm_device *dev,
- struct drm_mode_create_dumb *args);
 int pl111_debugfs_init(struct drm_minor *minor);
 
 #endif /* _PL111_DRM_H_ */
-- 
2.13.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/7 v4] drm/pl111: Enable PL110 variant

2017-09-08 Thread Linus Walleij
We detect and enable the use of the PL110 variant, an earlier
incarnation of PL111. The only real difference is that the
control and interrupt enable registers have swapped place.
The Versatile AB and Versatile PB have a variant inbetween
PL110 and PL111, it is PL110 but they have already swapped the
two registers so those two need a bit of special handling.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Fix static const on the variant struct holders. (Had to
  insert a (void*) cast for this because amba_id is not
  consting this field)
- Collect Eric A's Reviewed-by
---
 drivers/gpu/drm/pl111/pl111_display.c | 30 
 drivers/gpu/drm/pl111/pl111_drm.h | 17 +++
 drivers/gpu/drm/pl111/pl111_drv.c | 86 +--
 3 files changed, 108 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_display.c 
b/drivers/gpu/drm/pl111/pl111_display.c
index 9caf50d130f4..c08706be4b7e 100644
--- a/drivers/gpu/drm/pl111/pl111_display.c
+++ b/drivers/gpu/drm/pl111/pl111_display.c
@@ -199,7 +199,7 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
break;
}
 
-   writel(cntl, priv->regs + CLCD_PL111_CNTL);
+   writel(cntl, priv->regs + priv->ctrl);
 
drm_crtc_vblank_on(crtc);
 }
@@ -213,7 +213,7 @@ void pl111_display_disable(struct drm_simple_display_pipe 
*pipe)
drm_crtc_vblank_off(crtc);
 
/* Disable and Power Down */
-   writel(0, priv->regs + CLCD_PL111_CNTL);
+   writel(0, priv->regs + priv->ctrl);
 
clk_disable_unprepare(priv->clk);
 }
@@ -251,7 +251,7 @@ int pl111_enable_vblank(struct drm_device *drm, unsigned 
int crtc)
 {
struct pl111_drm_dev_private *priv = drm->dev_private;
 
-   writel(CLCD_IRQ_NEXTBASE_UPDATE, priv->regs + CLCD_PL111_IENB);
+   writel(CLCD_IRQ_NEXTBASE_UPDATE, priv->regs + priv->ienb);
 
return 0;
 }
@@ -260,7 +260,7 @@ void pl111_disable_vblank(struct drm_device *drm, unsigned 
int crtc)
 {
struct pl111_drm_dev_private *priv = drm->dev_private;
 
-   writel(0, priv->regs + CLCD_PL111_IENB);
+   writel(0, priv->regs + priv->ienb);
 }
 
 static int pl111_display_prepare_fb(struct drm_simple_display_pipe *pipe,
@@ -404,22 +404,6 @@ int pl111_display_init(struct drm_device *drm)
struct device_node *endpoint;
u32 tft_r0b0g0[3];
int ret;
-   static const u32 formats[] = {
-   DRM_FORMAT_ABGR,
-   DRM_FORMAT_XBGR,
-   DRM_FORMAT_ARGB,
-   DRM_FORMAT_XRGB,
-   DRM_FORMAT_BGR565,
-   DRM_FORMAT_RGB565,
-   DRM_FORMAT_ABGR1555,
-   DRM_FORMAT_XBGR1555,
-   DRM_FORMAT_ARGB1555,
-   DRM_FORMAT_XRGB1555,
-   DRM_FORMAT_ABGR,
-   DRM_FORMAT_XBGR,
-   DRM_FORMAT_ARGB,
-   DRM_FORMAT_XRGB,
-   };
 
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
if (!endpoint)
@@ -448,8 +432,10 @@ int pl111_display_init(struct drm_device *drm)
 
ret = drm_simple_display_pipe_init(drm, &priv->pipe,
   &pl111_display_funcs,
-  formats, ARRAY_SIZE(formats),
-  NULL, priv->connector);
+  priv->variant->formats,
+  priv->variant->nformats,
+  NULL,
+  priv->connector);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/pl111/pl111_drm.h 
b/drivers/gpu/drm/pl111/pl111_drm.h
index 000534d85b43..b380a7b4fb58 100644
--- a/drivers/gpu/drm/pl111/pl111_drm.h
+++ b/drivers/gpu/drm/pl111/pl111_drm.h
@@ -31,6 +31,20 @@
 
 struct drm_minor;
 
+/**
+ * struct pl111_variant_data - encodes IP differences
+ * @name: the name of this variant
+ * @is_pl110: this is the early PL110 variant
+ * @formats: array of supported pixel formats on this variant
+ * @nformats: the length of the array of supported pixel formats
+ */
+struct pl111_variant_data {
+   const char *name;
+   bool is_pl110;
+   const u32 *formats;
+   unsigned int nformats;
+};
+
 struct pl111_drm_dev_private {
struct drm_device *drm;
 
@@ -41,6 +55,8 @@ struct pl111_drm_dev_private {
struct drm_fbdev_cma *fbdev;
 
void *regs;
+   u32 ienb;
+   u32 ctrl;
/* The pixel clock (a reference to our clock divider off of CLCDCLK). */
struct clk *clk;
/* pl111's internal clock divider. */
@@ -49,6 +65,7 @@ struct pl111_drm_dev_private {
 * subsystem and pl111_display_enable().
 */
spinlock_t tim2_lock;
+   const struct pl111_variant_dat

[PATCH 5/7 v4] drm/pl111: Insert delay before powering up PL11x

2017-09-08 Thread Linus Walleij
The old codebase has a delay between enabling and powering up the
PL11x.

According to the manual for PL110, ARM DDI 0161E page 1-5 and
the PL111 manual ARM DDI 0293C page 1-6, the power sequence should
be such that once Vdd is stable (which we assume it is at boot)
LCDEN is enabled first and then CLPOWER should be enabled
"after the signals have stabilized" and this is said to
be display-dependent. The old codebase uses 20ms.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Fall back to the delay of 20 ms from the old framebuffer
  driver to stabilize Vee in shortage of other alternatives.
---
 drivers/gpu/drm/pl111/pl111_display.c | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_display.c 
b/drivers/gpu/drm/pl111/pl111_display.c
index c08706be4b7e..3091fb4559cf 100644
--- a/drivers/gpu/drm/pl111/pl111_display.c
+++ b/drivers/gpu/drm/pl111/pl111_display.c
@@ -155,8 +155,8 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
 
writel(0, priv->regs + CLCD_TIM3);
 
-   /* Enable and Power Up */
-   cntl = CNTL_LCDEN | CNTL_LCDTFT | CNTL_LCDPWR | CNTL_LCDVCOMP(1);
+   /* Hard-code TFT panel */
+   cntl = CNTL_LCDEN | CNTL_LCDTFT | CNTL_LCDVCOMP(1);
 
/* Note that the the hardware's format reader takes 'r' from
 * the low bit, while DRM formats list channels from high bit
@@ -199,6 +199,17 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
break;
}
 
+   /* Power sequence: first enable and chill */
+   writel(cntl, priv->regs + priv->ctrl);
+
+   /*
+* We expect this delay to stabilize the contrast
+* voltage Vee as stipulated by the manual
+*/
+   msleep(20);
+
+   /* Power Up */
+   cntl |= CNTL_LCDPWR;
writel(cntl, priv->regs + priv->ctrl);
 
drm_crtc_vblank_on(crtc);
@@ -209,10 +220,24 @@ void pl111_display_disable(struct drm_simple_display_pipe 
*pipe)
struct drm_crtc *crtc = &pipe->crtc;
struct drm_device *drm = crtc->dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
+   u32 cntl;
 
drm_crtc_vblank_off(crtc);
 
-   /* Disable and Power Down */
+   /* Power Down */
+   cntl = readl(priv->regs + priv->ctrl);
+   if (cntl & CNTL_LCDPWR) {
+   cntl &= ~CNTL_LCDPWR;
+   writel(cntl, priv->regs + priv->ctrl);
+   }
+
+   /*
+* We expect this delay to stabilize the contrast voltage Vee as
+* stipulated by the manual
+*/
+   msleep(20);
+
+   /* Disable */
writel(0, priv->regs + priv->ctrl);
 
clk_disable_unprepare(priv->clk);
-- 
2.13.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 6/7 v4] drm/pl111: Add optional variant display en/disable callbacks

2017-09-08 Thread Linus Walleij
The silcon and components around the PL111 may require some
variants to perform special set-up of the display. Add two
callbacks to manage this.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Rebase on other display driver changes.
---
 drivers/gpu/drm/pl111/pl111_display.c | 6 ++
 drivers/gpu/drm/pl111/pl111_drm.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/pl111/pl111_display.c 
b/drivers/gpu/drm/pl111/pl111_display.c
index 3091fb4559cf..29148ff380d8 100644
--- a/drivers/gpu/drm/pl111/pl111_display.c
+++ b/drivers/gpu/drm/pl111/pl111_display.c
@@ -208,6 +208,9 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
 */
msleep(20);
 
+   if (priv->variant_display_enable)
+   priv->variant_display_enable(drm, fb->format->format);
+
/* Power Up */
cntl |= CNTL_LCDPWR;
writel(cntl, priv->regs + priv->ctrl);
@@ -237,6 +240,9 @@ void pl111_display_disable(struct drm_simple_display_pipe 
*pipe)
 */
msleep(20);
 
+   if (priv->variant_display_disable)
+   priv->variant_display_disable(drm);
+
/* Disable */
writel(0, priv->regs + priv->ctrl);
 
diff --git a/drivers/gpu/drm/pl111/pl111_drm.h 
b/drivers/gpu/drm/pl111/pl111_drm.h
index b380a7b4fb58..440f53ebee8c 100644
--- a/drivers/gpu/drm/pl111/pl111_drm.h
+++ b/drivers/gpu/drm/pl111/pl111_drm.h
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2)
 
@@ -66,6 +67,8 @@ struct pl111_drm_dev_private {
 */
spinlock_t tim2_lock;
const struct pl111_variant_data *variant;
+   void (*variant_display_enable) (struct drm_device *drm, u32 format);
+   void (*variant_display_disable) (struct drm_device *drm);
 };
 
 int pl111_display_init(struct drm_device *dev);
-- 
2.13.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 7/7 v4] drm/pl111: Add handling of Versatile platforms

2017-09-08 Thread Linus Walleij
The ARM reference designs in the Versatile family: Integrator,
Versatile and RealView can make use of the new DRM driver as well.
We just need to create a bit of platform-specific code for them
that we isolate to its own file.

Reviewed-by: Eric Anholt 
Signed-off-by: Linus Walleij 
---
ChangeLog v3->v4:
- No changes.
ChangeLog v2->v3:
- Rebase on DRM-TIP
ChangeLog v1->v2:
- Rebase on the other patches.
- Drop pad note from DOC section.
---
 drivers/gpu/drm/pl111/Makefile  |   1 +
 drivers/gpu/drm/pl111/pl111_display.c   |   7 -
 drivers/gpu/drm/pl111/pl111_drv.c   |   8 +-
 drivers/gpu/drm/pl111/pl111_versatile.c | 270 
 drivers/gpu/drm/pl111/pl111_versatile.h |   9 ++
 5 files changed, 285 insertions(+), 10 deletions(-)
 create mode 100644 drivers/gpu/drm/pl111/pl111_versatile.c
 create mode 100644 drivers/gpu/drm/pl111/pl111_versatile.h

diff --git a/drivers/gpu/drm/pl111/Makefile b/drivers/gpu/drm/pl111/Makefile
index c5f8f9684848..fce1453a93e1 100644
--- a/drivers/gpu/drm/pl111/Makefile
+++ b/drivers/gpu/drm/pl111/Makefile
@@ -1,4 +1,5 @@
 pl111_drm-y += pl111_display.o \
+   pl111_versatile.o \
pl111_drv.o
 
 pl111_drm-$(CONFIG_DEBUG_FS) += pl111_debugfs.o
diff --git a/drivers/gpu/drm/pl111/pl111_display.c 
b/drivers/gpu/drm/pl111/pl111_display.c
index 29148ff380d8..06c4bf756b69 100644
--- a/drivers/gpu/drm/pl111/pl111_display.c
+++ b/drivers/gpu/drm/pl111/pl111_display.c
@@ -450,13 +450,6 @@ int pl111_display_init(struct drm_device *drm)
}
of_node_put(endpoint);
 
-   if (tft_r0b0g0[0] != 0 ||
-   tft_r0b0g0[1] != 8 ||
-   tft_r0b0g0[2] != 16) {
-   dev_err(dev, "arm,pl11x,tft-r0g0b0-pads != [0,8,16] not yet 
supported\n");
-   return -EINVAL;
-   }
-
ret = pl111_init_clock_divider(drm);
if (ret)
return ret;
diff --git a/drivers/gpu/drm/pl111/pl111_drv.c 
b/drivers/gpu/drm/pl111/pl111_drv.c
index 7a47db066a78..201d57d5cb54 100644
--- a/drivers/gpu/drm/pl111/pl111_drv.c
+++ b/drivers/gpu/drm/pl111/pl111_drv.c
@@ -41,9 +41,6 @@
  * - Fix race between setting plane base address and getting IRQ for
  *   vsync firing the pageflip completion.
  *
- * - Expose the correct set of formats we can support based on the
- *   "arm,pl11x,tft-r0g0b0-pads" DT property.
- *
  * - Use the "max-memory-bandwidth" DT property to filter the
  *   supported formats.
  *
@@ -73,6 +70,7 @@
 #include 
 
 #include "pl111_drm.h"
+#include "pl111_versatile.h"
 
 #define DRIVER_DESC  "DRM module for PL111"
 
@@ -258,6 +256,10 @@ static int pl111_amba_probe(struct amba_device *amba_dev,
return ret;
}
 
+   ret = pl111_versatile_init(dev, priv);
+   if (ret)
+   goto dev_unref;
+
ret = pl111_modeset_init(drm);
if (ret != 0)
goto dev_unref;
diff --git a/drivers/gpu/drm/pl111/pl111_versatile.c 
b/drivers/gpu/drm/pl111/pl111_versatile.c
new file mode 100644
index ..97d4af6925a3
--- /dev/null
+++ b/drivers/gpu/drm/pl111/pl111_versatile.c
@@ -0,0 +1,270 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "pl111_versatile.h"
+#include "pl111_drm.h"
+
+static struct regmap *versatile_syscon_map;
+
+/*
+ * We detect the different syscon types from the compatible strings.
+ */
+enum versatile_clcd {
+   INTEGRATOR_CLCD_CM,
+   VERSATILE_CLCD,
+   REALVIEW_CLCD_EB,
+   REALVIEW_CLCD_PB1176,
+   REALVIEW_CLCD_PB11MP,
+   REALVIEW_CLCD_PBA8,
+   REALVIEW_CLCD_PBX,
+};
+
+static const struct of_device_id versatile_clcd_of_match[] = {
+   {
+   .compatible = "arm,core-module-integrator",
+   .data = (void *)INTEGRATOR_CLCD_CM,
+   },
+   {
+   .compatible = "arm,versatile-sysreg",
+   .data = (void *)VERSATILE_CLCD,
+   },
+   {
+   .compatible = "arm,realview-eb-syscon",
+   .data = (void *)REALVIEW_CLCD_EB,
+   },
+   {
+   .compatible = "arm,realview-pb1176-syscon",
+   .data = (void *)REALVIEW_CLCD_PB1176,
+   },
+   {
+   .compatible = "arm,realview-pb11mp-syscon",
+   .data = (void *)REALVIEW_CLCD_PB11MP,
+   },
+   {
+   .compatible = "arm,realview-pba8-syscon",
+   .data = (void *)REALVIEW_CLCD_PBA8,
+   },
+   {
+   .compatible = "arm,realview-pbx-syscon",
+   .data = (void *)REALVIEW_CLCD_PBX,
+   },
+   {},
+};
+
+/*
+ * Core module CLCD control on the Integrator/CP, bits
+ * 8 thru 19 of the CM_CONTROL register controls a bunch
+ * of CLCD settings.
+ */
+#define INTEGRATOR_HDR_CTRL_OFFSET 0x0C
+#define INTEGRATOR_CLCD_LCDBIASEN  BIT(8)
+#define INTEGRATOR_CLCD_LCDBIASUP  BIT(9)
+#define INTEGRATOR_CLCD_LCDBIASDN  BIT(10)
+/* Bits 11,12,13 controls the LCD type */
+#define

[Bug 102616] [CI][SNB,HSW,APL,KBL] igt@gem_eio@in-flight - Failed assertion: __vgem_fence_signal(fd, fence) == 0

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102616

Chris Wilson  changed:

   What|Removed |Added

 QA Contact|intel-gfx-bugs@lists.freede |
   |sktop.org   |
  Component|DRM/Intel   |IGT
   Assignee|intel-gfx-bugs@lists.freede |dri-devel@lists.freedesktop
   |sktop.org   |.org

--- Comment #3 from Chris Wilson  ---
https://patchwork.freedesktop.org/series/30022/

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102616] [CI][SNB,HSW,APL,KBL] igt@gem_eio@in-flight - Failed assertion: __vgem_fence_signal(fd, fence) == 0

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102616

--- Comment #4 from Chris Wilson  ---
*** Bug 102620 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 2/2] dma-buf/sw_sync: force signal all unsignaled fences on dying timeline

2017-09-08 Thread Gustavo Padovan
Hi Chris,

2017-09-07 Chris Wilson :

> Quoting Gustavo Padovan (2017-09-07 20:02:46)
> > From: Dominik Behr 
> > 
> > To avoid hanging userspace components that might have been waiting on the
> > active fences of the destroyed timeline we need to signal with error all
> > remaining fences on such timeline.
> > 
> > This restore the default behaviour of the Android sw_sync framework, which
> > Android still relies on. It was broken on the dma fence conversion a few
> > years ago and never fixed.
> > 
> > v2: Do not bother with cleanup do the list (Chris Wilson)
> > 
> > Signed-off-by: Dominik Behr 
> > Signed-off-by: Gustavo Padovan 
> Reviewed-by: Chris Wilson 
> 
> > ---
> >  drivers/dma-buf/sw_sync.c | 10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
> > index 38cc7389a6c1..f183eef074fd 100644
> > --- a/drivers/dma-buf/sw_sync.c
> > +++ b/drivers/dma-buf/sw_sync.c
> > @@ -321,9 +321,19 @@ static int sw_sync_debugfs_open(struct inode *inode, 
> > struct file *file)
> >  static int sw_sync_debugfs_release(struct inode *inode, struct file *file)
> >  {
> > struct sync_timeline *obj = file->private_data;
> > +   struct sync_pt *pt, *next;
> >  
> > smp_wmb();
> >  
> > +   spin_lock_irq(&obj->lock);
> 
> Given the spinlock, that uncommented barrier (what is it paired with?)
> above is redundant.

Okay, I'll remove the barrier and push that patch, I assume your r-b
will comtemplate that as well?

Gustavo
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 2/2] dma-buf/sw_sync: force signal all unsignaled fences on dying timeline

2017-09-08 Thread Chris Wilson
Quoting Gustavo Padovan (2017-09-08 14:03:00)
> Hi Chris,
> 
> 2017-09-07 Chris Wilson :
> 
> > Quoting Gustavo Padovan (2017-09-07 20:02:46)
> > > From: Dominik Behr 
> > > 
> > > To avoid hanging userspace components that might have been waiting on the
> > > active fences of the destroyed timeline we need to signal with error all
> > > remaining fences on such timeline.
> > > 
> > > This restore the default behaviour of the Android sw_sync framework, which
> > > Android still relies on. It was broken on the dma fence conversion a few
> > > years ago and never fixed.
> > > 
> > > v2: Do not bother with cleanup do the list (Chris Wilson)
> > > 
> > > Signed-off-by: Dominik Behr 
> > > Signed-off-by: Gustavo Padovan 
> > Reviewed-by: Chris Wilson 
> > 
> > > ---
> > >  drivers/dma-buf/sw_sync.c | 10 ++
> > >  1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
> > > index 38cc7389a6c1..f183eef074fd 100644
> > > --- a/drivers/dma-buf/sw_sync.c
> > > +++ b/drivers/dma-buf/sw_sync.c
> > > @@ -321,9 +321,19 @@ static int sw_sync_debugfs_open(struct inode *inode, 
> > > struct file *file)
> > >  static int sw_sync_debugfs_release(struct inode *inode, struct file 
> > > *file)
> > >  {
> > > struct sync_timeline *obj = file->private_data;
> > > +   struct sync_pt *pt, *next;
> > >  
> > > smp_wmb();
> > >  
> > > +   spin_lock_irq(&obj->lock);
> > 
> > Given the spinlock, that uncommented barrier (what is it paired with?)
> > above is redundant.
> 
> Okay, I'll remove the barrier and push that patch, I assume your r-b
> will comtemplate that as well?

No worries, either as one patch or two, slap my r-b on it.
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vc4: clean up error handling on devm_kzalloc failure

2017-09-08 Thread Colin King
From: Colin Ian King 

The current error handling on devm_kzalloc failures performs a non-null
check on connector. Thss check is redundant because connector is null
at that failure point.  With this check removed, we may as well make
the failure path into a trivial -ENOMEM return to clean up the error
handling.

Detected by CoverityScan CID#1339527 ("Logically dead code")

Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 937da8dd65b8..a8808c1a1e03 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -311,14 +311,11 @@ static struct drm_connector 
*vc4_hdmi_connector_init(struct drm_device *dev,
 {
struct drm_connector *connector = NULL;
struct vc4_hdmi_connector *hdmi_connector;
-   int ret = 0;
 
hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
  GFP_KERNEL);
-   if (!hdmi_connector) {
-   ret = -ENOMEM;
-   goto fail;
-   }
+   if (!hdmi_connector)
+   return ERR_PTR(-ENOMEM);
connector = &hdmi_connector->base;
 
hdmi_connector->encoder = encoder;
@@ -336,12 +333,6 @@ static struct drm_connector 
*vc4_hdmi_connector_init(struct drm_device *dev,
drm_mode_connector_attach_encoder(connector, encoder);
 
return connector;
-
- fail:
-   if (connector)
-   vc4_hdmi_connector_destroy(connector);
-
-   return ERR_PTR(ret);
 }
 
 static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.13 39/47] drm/nouveau: Fix error handling in nv50_disp_atomic_commit

2017-09-08 Thread Greg Kroah-Hartman
4.13-stable review patch.  If anyone has any objections, please let me know.

--

From: Maarten Lankhorst 

commit 813a7e1604eaad1c2792d37d402e1b48b8d0eb3f upstream.

Make it more clear that post commit return ret is really return 0,

and add a missing drm_atomic_helper_cleanup_planes when
drm_atomic_helper_wait_for_fences fails.

Fixes: 839ca903f12e ("drm/nouveau/kms/nv50: transition to atomic interfaces 
internally")
Cc: Ben Skeggs 
Cc: dri-devel@lists.freedesktop.org
Cc: nouv...@lists.freedesktop.org
Signed-off-by: Maarten Lankhorst 
Link: 
http://patchwork.freedesktop.org/patch/msgid/20170711143314.2148-2-maarten.lankho...@linux.intel.com
Reviewed-by: Sean Paul 
[mlankhorst: Use if (ret) to remove the goto in success case.]
Reviewed-by: Daniel Vetter 
Signed-off-by: Daniel Vetter 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/nouveau/nv50_display.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -4134,7 +4134,7 @@ nv50_disp_atomic_commit(struct drm_devic
if (!nonblock) {
ret = drm_atomic_helper_wait_for_fences(dev, state, true);
if (ret)
-   goto done;
+   goto err_cleanup;
}
 
for_each_plane_in_state(state, plane, plane_state, i) {
@@ -4162,7 +4162,7 @@ nv50_disp_atomic_commit(struct drm_devic
if (crtc->state->enable) {
if (!drm->have_disp_power_ref) {
drm->have_disp_power_ref = true;
-   return ret;
+   return 0;
}
active = true;
break;
@@ -4174,6 +4174,9 @@ nv50_disp_atomic_commit(struct drm_devic
drm->have_disp_power_ref = false;
}
 
+err_cleanup:
+   if (ret)
+   drm_atomic_helper_cleanup_planes(dev, state);
 done:
pm_runtime_put_autosuspend(dev->dev);
return ret;


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.12 35/43] drm/nouveau: Fix error handling in nv50_disp_atomic_commit

2017-09-08 Thread Greg Kroah-Hartman
4.12-stable review patch.  If anyone has any objections, please let me know.

--

From: Maarten Lankhorst 

commit 813a7e1604eaad1c2792d37d402e1b48b8d0eb3f upstream.

Make it more clear that post commit return ret is really return 0,

and add a missing drm_atomic_helper_cleanup_planes when
drm_atomic_helper_wait_for_fences fails.

Fixes: 839ca903f12e ("drm/nouveau/kms/nv50: transition to atomic interfaces 
internally")
Cc: Ben Skeggs 
Cc: dri-devel@lists.freedesktop.org
Cc: nouv...@lists.freedesktop.org
Signed-off-by: Maarten Lankhorst 
Link: 
http://patchwork.freedesktop.org/patch/msgid/20170711143314.2148-2-maarten.lankho...@linux.intel.com
Reviewed-by: Sean Paul 
[mlankhorst: Use if (ret) to remove the goto in success case.]
Reviewed-by: Daniel Vetter 
Signed-off-by: Daniel Vetter 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/nouveau/nv50_display.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -4091,7 +4091,7 @@ nv50_disp_atomic_commit(struct drm_devic
if (!nonblock) {
ret = drm_atomic_helper_wait_for_fences(dev, state, true);
if (ret)
-   goto done;
+   goto err_cleanup;
}
 
for_each_plane_in_state(state, plane, plane_state, i) {
@@ -4119,7 +4119,7 @@ nv50_disp_atomic_commit(struct drm_devic
if (crtc->state->enable) {
if (!drm->have_disp_power_ref) {
drm->have_disp_power_ref = true;
-   return ret;
+   return 0;
}
active = true;
break;
@@ -4131,6 +4131,9 @@ nv50_disp_atomic_commit(struct drm_devic
drm->have_disp_power_ref = false;
}
 
+err_cleanup:
+   if (ret)
+   drm_atomic_helper_cleanup_planes(dev, state);
 done:
pm_runtime_put_autosuspend(dev->dev);
return ret;


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.9 32/32] drm/bridge: adv7511: Switch to using drm_kms_helper_hotplug_event()

2017-09-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: John Stultz 

commit 6d5104c5a6b56385426e15047050584794bb6254 upstream.

In chasing down a previous issue with EDID probing from calling
drm_helper_hpd_irq_event() from irq context, Laurent noticed
that the DRM documentation suggests that
drm_kms_helper_hotplug_event() should be used instead.

Thus this patch replaces drm_helper_hpd_irq_event() with
drm_kms_helper_hotplug_event(), which requires we update the
connector.status entry and only call _hotplug_event() when the
status changes.

Cc: David Airlie 
Cc: Archit Taneja 
Cc: Wolfram Sang 
Cc: Lars-Peter Clausen 
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 
Signed-off-by: John Stultz 
Signed-off-by: Archit Taneja 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-3-git-send-email-john.stu...@linaro.org
Signed-off-by: Thong Ho 
Signed-off-by: Nhan Nguyen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -405,8 +405,22 @@ static bool adv7511_hpd(struct adv7511 *
 static void adv7511_hpd_work(struct work_struct *work)
 {
struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+   enum drm_connector_status status;
+   unsigned int val;
+   int ret;
 
-   drm_helper_hpd_irq_event(adv7511->connector.dev);
+   ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
+   if (ret < 0)
+   status = connector_status_disconnected;
+   else if (val & ADV7511_STATUS_HPD)
+   status = connector_status_connected;
+   else
+   status = connector_status_disconnected;
+
+   if (adv7511->connector.status != status) {
+   adv7511->connector.status = status;
+   drm_kms_helper_hotplug_event(adv7511->connector.dev);
+   }
 }
 
 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4.9 31/32] drm/bridge: adv7511: Use work_struct to defer hotplug handing to out of irq context

2017-09-08 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: John Stultz 

commit 518cb7057a59b9441336d2e88a396d52b6ab0cce upstream.

I was recently seeing issues with EDID probing, where
the logic to wait for the EDID read bit to be set by the
IRQ wasn't happening and the code would time out and fail.

Digging deeper, I found this was due to the fact that
IRQs were disabled as we were running in IRQ context from
the HPD signal.

Thus this patch changes the logic to handle the HPD signal
via a work_struct so we can be out of irq context.

With this patch, the EDID probing on hotplug does not time
out.

Cc: David Airlie 
Cc: Archit Taneja 
Cc: Wolfram Sang 
Cc: Lars-Peter Clausen 
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 
Signed-off-by: John Stultz 
Signed-off-by: Archit Taneja 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484614372-15342-2-git-send-email-john.stu...@linaro.org
Signed-off-by: Thong Ho 
Signed-off-by: Nhan Nguyen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/bridge/adv7511/adv7511.h |2 ++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |   11 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -315,6 +315,8 @@ struct adv7511 {
bool edid_read;
 
wait_queue_head_t wq;
+   struct work_struct hpd_work;
+
struct drm_bridge bridge;
struct drm_connector connector;
 
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -402,6 +402,13 @@ static bool adv7511_hpd(struct adv7511 *
return false;
 }
 
+static void adv7511_hpd_work(struct work_struct *work)
+{
+   struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+
+   drm_helper_hpd_irq_event(adv7511->connector.dev);
+}
+
 static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
 {
unsigned int irq0, irq1;
@@ -419,7 +426,7 @@ static int adv7511_irq_process(struct ad
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
 
if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
-   drm_helper_hpd_irq_event(adv7511->connector.dev);
+   schedule_work(&adv7511->hpd_work);
 
if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
adv7511->edid_read = true;
@@ -1006,6 +1013,8 @@ static int adv7511_probe(struct i2c_clie
goto err_i2c_unregister_edid;
}
 
+   INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work);
+
if (i2c->irq) {
init_waitqueue_head(&adv7511->wq);
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102625] Game Crashlands crashes on startup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102625

Bug ID: 102625
   Summary: Game Crashlands crashes on startup
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel@lists.freedesktop.org
  Reporter: ratatosk.yggdra...@googlemail.com
QA Contact: dri-devel@lists.freedesktop.org

Created attachment 134084
  --> https://bugs.freedesktop.org/attachment.cgi?id=134084&action=edit
gdb output when running crashlands

Running on Arch with latest Mesa in the official repositories (17.1.8) via
mesa-git from AUR or 17.0.x in Ubuntu 16.04 and 17.04 Crashlands crashes on
startup (a window opens and immediately closes again) in combination with a
Radeon RX 470. On another machine using integrated HD 6620G it runs fine
(Ubuntu 16.04).

Using LLVMPIPE via LIBGL_ALWAYS_SOFTWARE=1 and GALLIUM_DRIVER=llvmpipe the game
runs as expected.

When starting the game from command line I get a segfault with this message:
./run.sh: Zeile 3:  2218 Speicherzugriffsfehler  (Speicherabzug geschrieben)
LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH ./runner

This error however seems to be unrelated to the crash because it remains even
if using LLVMPIPE.

Running via gdb produces the attached output.

GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from runner...(no debugging symbols found)...done.
(gdb) run
Starting program:
/home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner 
/home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner:
/usr/lib32/libcrypto.so.1.0.0: no version information available (required by
/home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner)
/home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner:
/usr/lib32/libssl.so.1.0.0: no version information available (required by
/home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

***
* YoYo Games Linux Runner V1.3*
***  
CommandLine: -game game.unx
ExeName= /home/nagezahn/.local/share/Steam/steamapps/common/Crashlands/runner
MemoryManager allocated: 1723148
INI DisplayName=Crashlands
SavePrePend /home/nagezahn/.config/Crashlands/ 
GAMEPAD: Initialising Ubuntu support
Attempting to set gamepadcount to 4
Steam being initialised with appId 391730
Steam_Init
Error: Failed to load libsteam_api.so: libsteam_api.so: cannot open shared
object file: No such file or directory
Failed LoadSteamLib() call: Error loading libsteam_api.so
SteamInit failed: Error loading libsteam_api.so
Display Size(Pixels): 1920,1200
GameDisplayName=Crashlands
Win #1
XF86VidModeExtension-Version 2.2
libGL error: failed to create dri screen
libGL error: failed to load driver: swrast
Got Doublebuffered Visual!
glX-Version 1.4
Icon: w=120 h=120
X Error of failed request:  BadValue (integer parameter out of range for
operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  30
  Current serial number in output stream:  32
[Inferior 1 (process 3337) exited with code 01]

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/8] ARM: dts: sun6i: Fix endpoint IDs in second display pipeline

2017-09-08 Thread Maxime Ripard
Hi,

On Fri, Sep 08, 2017 at 03:50:09PM +0800, Chen-Yu Tsai wrote:
> When the second display pipeline device nodes for the A31/A31s were
> added, it was not known that the TCONs could (through either DRCs)
> select either backend as their input. Thus in the endpoints connecting
> these components together, the endpoint IDs were set to 0, while in
> fact they should have been set to 1.
> 
> Fixes: 9a26882a7378 ("ARM: dts: sun6i: Add second display pipeline device
> nodes")
> Signed-off-by: Chen-Yu Tsai 

Should we CC stable on this one?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 00/12] atomic modesetting for cirrus v2

2017-09-08 Thread Varad Gautam
Hello,

The v2 incorporates the feedback on v1 [1] and rebases the series to master.
We no longer force 32bpp, fix incorrect error handling during plane
initialization, and drom some irrelevant patches.

[1] https://lists.freedesktop.org/archives/dri-devel/2017-August/150703.html

Dominik Behr (1):
  drm/cirrus: initialize start and size fields

Varad Gautam (9):
  drm/cirrus: split out bo unpinning from cirrus_bo_push_sysram
  drm/cirrus: add drm_read to cirrus_driver_fops
  drm/cirrus: do not disable outputs on fbdev init for atomic.
  drm/cirrus: use universal plane interfaces for primary plane
  drm/cirrus: use atomic transition helpers for plane and crtc
  drm/cirrus: send vblank on crtc atomic_flush
  drm/cirrus: use atomic handlers for plane and crtc
  drm/cirrus: implement atomic hardware cursor support
  drm/cirrus: advertise DRIVER_ATOMIC

Zach Reizner (2):
  drm/cirrus: hardcode vram size
  drm/cirrus: implement PRIME export for cirrus

 drivers/gpu/drm/cirrus/Makefile   |   2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c   |  13 +-
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  25 ++
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |   6 +-
 drivers/gpu/drm/cirrus/cirrus_main.c  |  23 +-
 drivers/gpu/drm/cirrus/cirrus_mode.c  | 682 ++
 drivers/gpu/drm/cirrus/cirrus_prime.c |  63 
 drivers/gpu/drm/cirrus/cirrus_ttm.c   |  55 ++-
 8 files changed, 705 insertions(+), 164 deletions(-)
 create mode 100644 drivers/gpu/drm/cirrus/cirrus_prime.c

Thanks,
Varad
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 02/12] drm/cirrus: add drm_read to cirrus_driver_fops

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

allow reading the drm file from userspace.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 69c4e352dd78..452059780ddc 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -122,6 +122,7 @@ static int cirrus_pm_resume(struct device *dev)
 static const struct file_operations cirrus_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
+   .read = drm_read,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.mmap = cirrus_mmap,
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 05/12] drm/cirrus: hardcode vram size

2017-09-08 Thread Varad Gautam
From: Zach Reizner 

There is no reliable way of detecting actual VRAM size, which is
important in the case of cirrus because cursor data is always stored in
the last 16K of VRAM. Because qemu effectivaly hardcodes 4MB but reports
32MB, we hardcode 4MB in the cirrus driver to ensure the cursor works
properly.

initially reviewed at: https://chromium-review.googlesource.com/411344
Signed-off-by: Zach Reizner 
CC: Stéphane Marchesin 
---
 drivers/gpu/drm/cirrus/cirrus_main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index b5f528543956..332bb2169508 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -98,7 +98,12 @@ static int cirrus_vram_init(struct cirrus_device *cdev)
 {
/* BAR 0 is VRAM */
cdev->mc.vram_base = pci_resource_start(cdev->dev->pdev, 0);
-   cdev->mc.vram_size = pci_resource_len(cdev->dev->pdev, 0);
+
+   /*
+* While we can use the entire PCI bar for VRAM, qemu always expects to
+* find the cursor data at the 4M - 16K point.
+*/
+   cdev->mc.vram_size = 4 * 1024 * 1024;
 
if (!request_mem_region(cdev->mc.vram_base, cdev->mc.vram_size,
"cirrusdrmfb_vram")) {
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 04/12] drm/cirrus: initialize start and size fields

2017-09-08 Thread Varad Gautam
From: Dominik Behr 

initialize start and size fields in fb info
so user space drivers like fbdev can map the memory

cherry-pick from 3.14 to 3.18 kernel to let VMtest pass

dmesg now shows proper size and fb start

initially reviewed for chromiumos at:
https://chromium-review.googlesource.com/167396
https://chromium-review.googlesource.com/282933
https://chromium-review.googlesource.com/339092

Signed-off-by: Dominik Behr 
Signed-off-by: Zhuo-hao Lee 
Signed-off-by: Stphane Marchesin 
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 28383b828f47..30fb10cbb038 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -231,6 +231,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper,
info->screen_base = sysram;
info->screen_size = size;
 
+   info->fix.smem_start = cdev->dev->mode_config.fb_base;
+   info->fix.smem_len = size;
+
info->fix.mmio_start = 0;
info->fix.mmio_len = 0;
 
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 06/12] drm/cirrus: implement PRIME export for cirrus

2017-09-08 Thread Varad Gautam
From: Zach Reizner 

This patch implements PRIME export, but not import for cirrus.

initially reviewed at:
https://chromium-review.googlesource.com/229688
https://chromium-review.googlesource.com/339057

Signed-off-by: Zach Reizner 
Signed-off-by: Stphane Marchesin 
Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/Makefile   |  2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c   | 11 +-
 drivers/gpu/drm/cirrus/cirrus_drv.h   | 10 ++
 drivers/gpu/drm/cirrus/cirrus_prime.c | 63 +++
 4 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/cirrus/cirrus_prime.c

diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
index 919c0a336c97..f6bcc21454c6 100644
--- a/drivers/gpu/drm/cirrus/Makefile
+++ b/drivers/gpu/drm/cirrus/Makefile
@@ -1,4 +1,4 @@
 cirrus-y  := cirrus_main.o cirrus_mode.o \
-   cirrus_drv.o cirrus_fbdev.o cirrus_ttm.o
+   cirrus_drv.o cirrus_fbdev.o cirrus_ttm.o cirrus_prime.o
 
 obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 452059780ddc..09461868ed46 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -130,7 +130,7 @@ static const struct file_operations cirrus_driver_fops = {
.compat_ioctl = drm_compat_ioctl,
 };
 static struct drm_driver driver = {
-   .driver_features = DRIVER_MODESET | DRIVER_GEM,
+   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
.load = cirrus_driver_load,
.unload = cirrus_driver_unload,
.fops = &cirrus_driver_fops,
@@ -143,6 +143,15 @@ static struct drm_driver driver = {
.gem_free_object_unlocked = cirrus_gem_free_object,
.dumb_create = cirrus_dumb_create,
.dumb_map_offset = cirrus_dumb_mmap_offset,
+   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+   .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+   .gem_prime_export = drm_gem_prime_export,
+   .gem_prime_import = drm_gem_prime_import,
+   .gem_prime_pin = cirrus_gem_prime_pin,
+   .gem_prime_get_sg_table = cirrus_gem_prime_get_sg_table,
+   .gem_prime_import_sg_table = cirrus_gem_prime_import_sg_table,
+   .gem_prime_vmap = cirrus_gem_prime_vmap,
+   .gem_prime_vunmap = cirrus_gem_prime_vunmap,
 };
 
 static const struct dev_pm_ops cirrus_pm_ops = {
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index e16b86dd6c19..8c43cc963027 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -163,6 +163,7 @@ struct cirrus_bo {
struct ttm_buffer_object bo;
struct ttm_placement placement;
struct ttm_bo_kmap_obj kmap;
+   struct ttm_bo_kmap_obj dma_buf_vmap;
struct drm_gem_object gem;
struct ttm_place placements[3];
int pin_count;
@@ -256,6 +257,15 @@ int cirrus_bo_push_sysram(struct cirrus_bo *bo);
 int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr);
 int cirrus_bo_unpin(struct cirrus_bo *bo);
 
+struct sg_table *cirrus_gem_prime_get_sg_table(struct drm_gem_object *obj);
+void *cirrus_gem_prime_vmap(struct drm_gem_object *obj);
+void cirrus_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
+struct drm_gem_object *cirrus_gem_prime_import_sg_table(
+   struct drm_device *dev,
+   struct dma_buf_attachment *attach,
+   struct sg_table *sgt);
+int cirrus_gem_prime_pin(struct drm_gem_object *obj);
+
 extern int cirrus_bpp;
 
 #endif /* __CIRRUS_DRV_H__ */
diff --git a/drivers/gpu/drm/cirrus/cirrus_prime.c 
b/drivers/gpu/drm/cirrus/cirrus_prime.c
new file mode 100644
index ..a7fe6c73bfb6
--- /dev/null
+++ b/drivers/gpu/drm/cirrus/cirrus_prime.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2014 The Chromium OS Authors
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License version 2. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ */
+
+#include 
+#include 
+#include "cirrus_drv.h"
+
+struct sg_table *cirrus_gem_prime_get_sg_table(struct drm_gem_object *obj)
+{
+   struct cirrus_bo *cirrusbo = gem_to_cirrus_bo(obj);
+   unsigned long npages = cirrusbo->bo.num_pages;
+
+   return drm_prime_pages_to_sg(cirrusbo->bo.ttm->pages, npages);
+}
+
+void *cirrus_gem_prime_vmap(struct drm_gem_object *obj)
+{
+   struct cirrus_bo *cirrusbo = gem_to_cirrus_bo(obj);
+   int ret;
+
+   ret = ttm_bo_kmap(&cirrusbo->bo, 0, cirrusbo->bo.num_pages,
+ &cirrusbo->dma_buf_vmap);
+   if (ret)
+   return ERR_PTR(ret);
+
+   return cirrusbo->dma_buf_vmap.virtual;
+}
+
+void cirrus_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
+{
+   struct cirrus_bo *cirrusbo = gem_to_cirrus_bo(obj)

[PATCH 03/12] drm/cirrus: do not disable outputs on fbdev init for atomic.

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

drm_helper_disable_unused_functions should not be called by atomic drivers,
so disable it for later patches.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 32fbfba2c623..28383b828f47 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -293,9 +293,6 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
if (ret)
return ret;
 
-   /* disable all the possible outputs/crtcs before entering KMS mode */
-   drm_helper_disable_unused_functions(cdev->dev);
-
return drm_fb_helper_initial_config(&gfbdev->helper, bpp_sel);
 }
 
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 07/12] drm/cirrus: use universal plane interfaces for primary plane

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

cirrus exposes one legacy primary plane tied to the crtc. convert this to
use the universal planes interface in preparation for atomic.

v2: avoid early plane cleanup to fix faulty error handling. (krisman)

Signed-off-by: Varad Gautam 
Reviewed-by: Gabriel Krisman Bertazi 
---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 45 +++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 6a8d09c9a36b..d12399986c81 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -348,11 +348,29 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.commit = cirrus_crtc_commit,
 };
 
+static const uint32_t cirrus_plane_formats[] = {
+   DRM_FORMAT_XRGB,
+   DRM_FORMAT_ARGB,
+   DRM_FORMAT_RGB888,
+   DRM_FORMAT_RGB565,
+};
+
+static const struct drm_plane_funcs cirrus_plane_funcs = {
+   .update_plane   = drm_primary_helper_update,
+   .disable_plane  = drm_primary_helper_disable,
+   .destroy= drm_primary_helper_destroy,
+};
+
+static const struct drm_plane_helper_funcs cirrus_plane_helper_funcs = {
+};
+
 /* CRTC setup */
 static void cirrus_crtc_init(struct drm_device *dev)
 {
struct cirrus_device *cdev = dev->dev_private;
struct cirrus_crtc *cirrus_crtc;
+   struct drm_plane *primary;
+   int ret;
 
cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
  (CIRRUSFB_CONN_LIMIT * sizeof(struct 
drm_connector *)),
@@ -361,12 +379,37 @@ static void cirrus_crtc_init(struct drm_device *dev)
if (cirrus_crtc == NULL)
return;
 
-   drm_crtc_init(dev, &cirrus_crtc->base, &cirrus_crtc_funcs);
+   primary = kzalloc(sizeof(*primary), GFP_KERNEL);
+   if (primary == NULL)
+   goto cleanup_crtc;
 
+   drm_plane_helper_add(primary, &cirrus_plane_helper_funcs);
+   ret = drm_universal_plane_init(dev, primary, 1,
+  &cirrus_plane_funcs,
+  cirrus_plane_formats,
+  ARRAY_SIZE(cirrus_plane_formats),
+  NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+   if (ret) {
+   kfree(primary);
+   goto cleanup_crtc;
+   }
+
+   ret = drm_crtc_init_with_planes(dev, &cirrus_crtc->base, primary, NULL,
+   &cirrus_crtc_funcs, NULL);
+   if (ret)
+   goto cleanup;
drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
cdev->mode_info.crtc = cirrus_crtc;
 
drm_crtc_helper_add(&cirrus_crtc->base, &cirrus_helper_funcs);
+   return;
+
+cleanup:
+   drm_plane_cleanup(primary);
+   kfree(primary);
+cleanup_crtc:
+   kfree(cirrus_crtc);
+   return;
 }
 
 static void cirrus_encoder_mode_set(struct drm_encoder *encoder,
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 01/12] drm/cirrus: split out bo unpinning from cirrus_bo_push_sysram

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

add a cirrus_bo_unpin call, and move bo_{reserve,unreserve} operations
to bo_{pin,unpin} to ensure correct pinning/unpinning and simplify the call
sequence.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h  |  1 +
 drivers/gpu/drm/cirrus/cirrus_mode.c | 14 ++---
 drivers/gpu/drm/cirrus/cirrus_ttm.c  | 55 +---
 3 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index be2d7e488062..e16b86dd6c19 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -254,6 +254,7 @@ static inline void cirrus_bo_unreserve(struct cirrus_bo *bo)
 
 int cirrus_bo_push_sysram(struct cirrus_bo *bo);
 int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int cirrus_bo_unpin(struct cirrus_bo *bo);
 
 extern int cirrus_bpp;
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index a4c4a465b385..6a8d09c9a36b 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -112,26 +112,17 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
cirrus_fb = to_cirrus_framebuffer(fb);
obj = cirrus_fb->obj;
bo = gem_to_cirrus_bo(obj);
-   ret = cirrus_bo_reserve(bo, false);
-   if (ret)
-   return ret;
+   cirrus_bo_unpin(bo);
cirrus_bo_push_sysram(bo);
-   cirrus_bo_unreserve(bo);
}
 
cirrus_fb = to_cirrus_framebuffer(crtc->primary->fb);
obj = cirrus_fb->obj;
bo = gem_to_cirrus_bo(obj);
 
-   ret = cirrus_bo_reserve(bo, false);
-   if (ret)
-   return ret;
-
ret = cirrus_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-   if (ret) {
-   cirrus_bo_unreserve(bo);
+   if (ret)
return ret;
-   }
 
if (&cdev->mode_info.gfbdev->gfb == cirrus_fb) {
/* if pushing console in kmap it */
@@ -139,7 +130,6 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
if (ret)
DRM_ERROR("failed to kmap fbcon\n");
}
-   cirrus_bo_unreserve(bo);
 
cirrus_set_start_address(crtc, (u32)gpu_addr);
return 0;
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 1ff1838c0d44..a91d31da90ba 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -358,12 +358,17 @@ static inline u64 cirrus_bo_gpu_offset(struct cirrus_bo 
*bo)
 
 int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr)
 {
-   int i, ret;
+   int i, ret = 0;
+
+   ret = cirrus_bo_reserve(bo, false);
+   if (ret)
+   return ret;
 
if (bo->pin_count) {
bo->pin_count++;
if (gpu_addr)
*gpu_addr = cirrus_bo_gpu_offset(bo);
+   goto out;
}
 
cirrus_ttm_placement(bo, pl_flag);
@@ -371,24 +376,51 @@ int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 
*gpu_addr)
bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
if (ret)
-   return ret;
+   goto out;
 
bo->pin_count = 1;
if (gpu_addr)
*gpu_addr = cirrus_bo_gpu_offset(bo);
-   return 0;
+
+out:
+   cirrus_bo_unreserve(bo);
+   return ret;
+}
+
+int cirrus_bo_unpin(struct cirrus_bo *bo)
+{
+   int i, ret = 0;
+
+   ret = cirrus_bo_reserve(bo, false);
+   if (ret)
+   return ret;
+
+   if (!bo->pin_count || --bo->pin_count)
+   goto out;
+
+   for (i = 0; i < bo->placement.num_placement; i++)
+   bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
+   ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
+   if (ret)
+   goto out;
+
+out:
+   cirrus_bo_unreserve(bo);
+   return ret;
 }
 
 int cirrus_bo_push_sysram(struct cirrus_bo *bo)
 {
int i, ret;
-   if (!bo->pin_count) {
+
+   ret = cirrus_bo_reserve(bo, false);
+   if (ret)
+   return ret;
+
+   if (bo->pin_count) {
DRM_ERROR("unpin bad %p\n", bo);
-   return 0;
+   goto out;
}
-   bo->pin_count--;
-   if (bo->pin_count)
-   return 0;
 
if (bo->kmap.virtual)
ttm_bo_kunmap(&bo->kmap);
@@ -400,9 +432,12 @@ int cirrus_bo_push_sysram(struct cirrus_bo *bo)
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
if (ret) {
DRM_ERROR("pushing to VRAM failed\n");
-   return ret;
+   goto out;
}
-   return 0;
+
+out:
+   cirrus_bo_unreserve(bo);
+  

[PATCH 08/12] drm/cirrus: use atomic transition helpers for plane and crtc

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

split the driver to fit into atomic semantics, and switch to using
the atomic transition layer helpers for legacy modesetting.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h  |   1 +
 drivers/gpu/drm/cirrus/cirrus_main.c |   3 +
 drivers/gpu/drm/cirrus/cirrus_mode.c | 350 ++-
 3 files changed, 227 insertions(+), 127 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 8c43cc963027..1db0849b4bcb 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -167,6 +167,7 @@ struct cirrus_bo {
struct drm_gem_object gem;
struct ttm_place placements[3];
int pin_count;
+   u64 gpu_addr;
 };
 #define gem_to_cirrus_bo(gobj) container_of((gobj), struct cirrus_bo, gem)
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index 332bb2169508..f146a4129742 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -9,6 +9,7 @@
  *  Dave Airlie
  */
 #include 
+#include 
 #include 
 
 #include "cirrus_drv.h"
@@ -82,6 +83,8 @@ cirrus_user_framebuffer_create(struct drm_device *dev,
 
 static const struct drm_mode_config_funcs cirrus_mode_funcs = {
.fb_create = cirrus_user_framebuffer_create,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
 };
 
 /* Unmap the framebuffer from the core and release the memory */
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index d12399986c81..ee023c865165 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -15,6 +15,8 @@
  * Copyright 1999-2001 Jeff Garzik 
  */
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -72,95 +74,20 @@ static void cirrus_crtc_dpms(struct drm_crtc *crtc, int 
mode)
WREG_GFX(0xe, gr0e);
 }
 
-static void cirrus_set_start_address(struct drm_crtc *crtc, unsigned offset)
-{
-   struct cirrus_device *cdev = crtc->dev->dev_private;
-   u32 addr;
-   u8 tmp;
-
-   addr = offset >> 2;
-   WREG_CRT(0x0c, (u8)((addr >> 8) & 0xff));
-   WREG_CRT(0x0d, (u8)(addr & 0xff));
-
-   WREG8(CRT_INDEX, 0x1b);
-   tmp = RREG8(CRT_DATA);
-   tmp &= 0xf2;
-   tmp |= (addr >> 16) & 0x01;
-   tmp |= (addr >> 15) & 0x0c;
-   WREG_CRT(0x1b, tmp);
-   WREG8(CRT_INDEX, 0x1d);
-   tmp = RREG8(CRT_DATA);
-   tmp &= 0x7f;
-   tmp |= (addr >> 12) & 0x80;
-   WREG_CRT(0x1d, tmp);
-}
-
-/* cirrus is different - we will force move buffers out of VRAM */
-static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,
-   struct drm_framebuffer *fb,
-   int x, int y, int atomic)
-{
-   struct cirrus_device *cdev = crtc->dev->dev_private;
-   struct drm_gem_object *obj;
-   struct cirrus_framebuffer *cirrus_fb;
-   struct cirrus_bo *bo;
-   int ret;
-   u64 gpu_addr;
-
-   /* push the previous fb to system ram */
-   if (!atomic && fb) {
-   cirrus_fb = to_cirrus_framebuffer(fb);
-   obj = cirrus_fb->obj;
-   bo = gem_to_cirrus_bo(obj);
-   cirrus_bo_unpin(bo);
-   cirrus_bo_push_sysram(bo);
-   }
-
-   cirrus_fb = to_cirrus_framebuffer(crtc->primary->fb);
-   obj = cirrus_fb->obj;
-   bo = gem_to_cirrus_bo(obj);
-
-   ret = cirrus_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-   if (ret)
-   return ret;
-
-   if (&cdev->mode_info.gfbdev->gfb == cirrus_fb) {
-   /* if pushing console in kmap it */
-   ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
-   if (ret)
-   DRM_ERROR("failed to kmap fbcon\n");
-   }
-
-   cirrus_set_start_address(crtc, (u32)gpu_addr);
-   return 0;
-}
-
-static int cirrus_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-struct drm_framebuffer *old_fb)
-{
-   return cirrus_crtc_do_set_base(crtc, old_fb, x, y, 0);
-}
-
 /*
- * The meat of this driver. The core passes us a mode and we have to program
- * it. The modesetting here is the bare minimum required to satisfy the qemu
- * emulation of this hardware, and running this against a real device is
- * likely to result in an inadequately programmed mode. We've already had
- * the opportunity to modify the mode, so whatever we receive here should
- * be something that can be correctly programmed and displayed
+ * The core passes us a mode and we have to program it. The modesetting here
+ * is the bare minimum required to satisfy the qemu emulation of this
+ * hardware, and running this against a real device is likely to result in
+ * an inadequately programmed mode.
  */
-static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
-

[PATCH 10/12] drm/cirrus: use atomic handlers for plane and crtc

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

move from transition helpers to actual atomic handlers.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 30 +++---
 1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index 4c95447ac445..fb3d808ffb5f 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -160,15 +160,6 @@ static void cirrus_mode_set_nofb(struct drm_crtc *crtc)
 }
 
 /*
- * This is called before a mode is programmed. A typical use might be to
- * enable DPMS during the programming to avoid seeing intermediate stages,
- * but that's not relevant to us
- */
-static void cirrus_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
-/*
  * This is called after a mode is programmed. It should reverse anything done
  * by the prepare function
  */
@@ -237,8 +228,9 @@ static void cirrus_crtc_atomic_flush(struct drm_crtc *crtc,
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs cirrus_crtc_funcs = {
.gamma_set = cirrus_crtc_gamma_set,
-   .set_config = drm_crtc_helper_set_config,
+   .set_config = drm_atomic_helper_set_config,
.destroy = cirrus_crtc_destroy,
+   .page_flip = drm_atomic_helper_page_flip,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -246,27 +238,11 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = {
 
 static const struct drm_crtc_helper_funcs cirrus_helper_funcs = {
.dpms = cirrus_crtc_dpms,
-   .mode_set = drm_helper_crtc_mode_set,
-   .mode_set_base = drm_helper_crtc_mode_set_base,
.mode_set_nofb = cirrus_mode_set_nofb,
-   .prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
.atomic_flush = cirrus_crtc_atomic_flush,
 };
 
-static int cirrus_plane_update(struct drm_plane *plane,
-  struct drm_crtc *crtc,
-  struct drm_framebuffer *fb, int crtc_x,
-  int crtc_y, unsigned int crtc_w,
-  unsigned int crtc_h, uint32_t src_x,
-  uint32_t src_y, uint32_t src_w, uint32_t src_h,
-  struct drm_modeset_acquire_ctx *ctx)
-{
-   return drm_plane_helper_update(plane, crtc, fb,
-  crtc_x, crtc_y, crtc_w,
-  crtc_h, src_x, src_y, src_w, src_h);
-}
-
 static const uint32_t cirrus_plane_formats[] = {
DRM_FORMAT_XRGB,
DRM_FORMAT_ARGB,
@@ -275,7 +251,7 @@ static const uint32_t cirrus_plane_formats[] = {
 };
 
 static const struct drm_plane_funcs cirrus_plane_funcs = {
-   .update_plane   = cirrus_plane_update,
+   .update_plane   = drm_atomic_helper_update_plane,
.disable_plane  = drm_primary_helper_disable,
.destroy= drm_primary_helper_destroy,
.reset  = drm_atomic_helper_plane_reset,
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 11/12] drm/cirrus: implement atomic hardware cursor support

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

This enables cursor plane on cirrus. It only supports ARGB 8-bit cursors
from userspace, and downconverts them to 1-bit black and white with
masking, which is all cirrus hardware can support. Only cursors with
size 32x32 or 64x64 will work.

initial non-atomic version:
Reviewed-at:
https://chromium-review.googlesource.com/335579
https://chromium-review.googlesource.com/339091
Signed-off-by: Zach Reizner 

Signed-off-by: Varad Gautam 

CC: Haixia Shi 
CC: Stéphane Marchesin 

v2: rework faulty error handling (krisman )
---
 drivers/gpu/drm/cirrus/cirrus_drv.h  |  13 ++
 drivers/gpu/drm/cirrus/cirrus_main.c |  13 ++
 drivers/gpu/drm/cirrus/cirrus_mode.c | 273 ++-
 3 files changed, 294 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 1db0849b4bcb..639af38c035d 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -50,6 +50,17 @@
WREG8(SEQ_DATA, v); \
} while (0) \
 
+#define PAL_ADDR 8
+#define PAL_DATA 9
+
+#define WREG_PAL(addr, r, g, b)\
+   do {\
+   WREG8(PAL_ADDR, addr);  \
+   WREG8(PAL_DATA, r); \
+   WREG8(PAL_DATA, g); \
+   WREG8(PAL_DATA, b); \
+   } while (0) \
+
 #define CRT_INDEX 0x14
 #define CRT_DATA 0x15
 
@@ -136,6 +147,8 @@ struct cirrus_device {
void __iomem*rmmio;
 
struct cirrus_mcmc;
+   resource_size_t cursor_ram_size;
+   void __iomem*cursor_iomem;
struct cirrus_mode_info mode_info;
 
int num_crtc;
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index f146a4129742..deb531b6e3db 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -94,6 +94,8 @@ static void cirrus_vram_fini(struct cirrus_device *cdev)
cdev->rmmio = NULL;
if (cdev->mc.vram_base)
release_mem_region(cdev->mc.vram_base, cdev->mc.vram_size);
+   if (cdev->cursor_iomem)
+   iounmap(cdev->cursor_iomem);
 }
 
 /* Map the framebuffer from the card and configure the core */
@@ -107,12 +109,23 @@ static int cirrus_vram_init(struct cirrus_device *cdev)
 * find the cursor data at the 4M - 16K point.
 */
cdev->mc.vram_size = 4 * 1024 * 1024;
+   /* The last 16K of VRAM is for cursor */
+   cdev->cursor_ram_size = 16 * 1024;
 
if (!request_mem_region(cdev->mc.vram_base, cdev->mc.vram_size,
"cirrusdrmfb_vram")) {
DRM_ERROR("can't reserve VRAM\n");
return -ENXIO;
}
+   cdev->cursor_iomem = ioremap_nocache(cdev->mc.vram_base +
+cdev->mc.vram_size -
+cdev->cursor_ram_size,
+cdev->cursor_ram_size);
+   if (!cdev->cursor_iomem) {
+   release_mem_region(cdev->mc.vram_base, cdev->mc.vram_size);
+   DRM_ERROR("can't ioremap cursor VRAM\n");
+   return -ENXIO;
+   }
 
return 0;
 }
diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index fb3d808ffb5f..66b0750eb33a 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -243,6 +243,231 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.atomic_flush = cirrus_crtc_atomic_flush,
 };
 
+static void cirrus_argb_to_cursor(void *src , void __iomem *dst,
+ uint32_t cursor_size)
+{
+   uint8_t *pixel = (uint8_t *)src;
+   const uint32_t row_size = cursor_size / 8;
+   const uint32_t plane_size = row_size * cursor_size;
+   uint32_t row_skip;
+   void __iomem *plane_0 = dst;
+   void __iomem *plane_1;
+   uint32_t x;
+   uint32_t y;
+
+   switch (cursor_size) {
+   case 32:
+   row_skip = 0;
+   plane_1 = plane_0 + plane_size;
+   break;
+   case 64:
+   row_skip = row_size;
+   plane_1 = plane_0 + row_size;
+   break;
+   default:
+   DRM_DEBUG("Cursor plane format is undefined for given size");
+   return;
+   }
+
+   for (y = 0; y < cursor_size; y++) {
+   uint8_t bits_0 = 0;
+   uint8_t bits_1 = 0;
+
+   for (x = 0; x < cursor_size; x++) {
+   

[PATCH 09/12] drm/cirrus: send vblank on crtc atomic_flush

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

the hardware does not provide interrupts on vblank, so we just send a fake
vblank event on atomic_flush.

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_mode.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c 
b/drivers/gpu/drm/cirrus/cirrus_mode.c
index ee023c865165..4c95447ac445 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -217,6 +217,23 @@ static void cirrus_crtc_destroy(struct drm_crtc *crtc)
kfree(cirrus_crtc);
 }
 
+static void cirrus_crtc_atomic_flush(struct drm_crtc *crtc,
+struct drm_crtc_state *old_crtc_state)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_pending_vblank_event *event;
+   unsigned long flags;
+
+   if (crtc->state && crtc->state->event) {
+   event = crtc->state->event;
+   crtc->state->event = NULL;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   }
+}
+
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs cirrus_crtc_funcs = {
.gamma_set = cirrus_crtc_gamma_set,
@@ -234,6 +251,7 @@ static const struct drm_crtc_helper_funcs 
cirrus_helper_funcs = {
.mode_set_nofb = cirrus_mode_set_nofb,
.prepare = cirrus_crtc_prepare,
.commit = cirrus_crtc_commit,
+   .atomic_flush = cirrus_crtc_atomic_flush,
 };
 
 static int cirrus_plane_update(struct drm_plane *plane,
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 12/12] drm/cirrus: advertise DRIVER_ATOMIC

2017-09-08 Thread Varad Gautam
From: Varad Gautam 

allow userspace to use atomic ioctls.

we now pass the following tests when running with cirrus.bpp=32:
igt/kms_atomic_transition:
plane-all-transition
plane-use-after-nonblocking-unbind
plane-all-modeset-transition
plane-toggle-modeset-transition
1x-modeset-transitions
1x-modeset-transitions-nonblocking
igt/kms_atomic:
plane_primary_legacy
test_only
plane_cursor_legacy
plane_invalid_params
crtc_invalid_params
igt/kms_setmode
igt/kms_rmfb
drm-tests/atomictest:
disable_primary
fullscreen_video
overlay_pageflip
primary_pageflip
video_overlay

Signed-off-by: Varad Gautam 
---
 drivers/gpu/drm/cirrus/cirrus_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 09461868ed46..c2c010379b93 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -130,7 +130,8 @@ static const struct file_operations cirrus_driver_fops = {
.compat_ioctl = drm_compat_ioctl,
 };
 static struct drm_driver driver = {
-   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
+   .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
+   DRIVER_ATOMIC,
.load = cirrus_driver_load,
.unload = cirrus_driver_unload,
.fops = &cirrus_driver_fops,
-- 
2.13.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/8] ARM: dts: sun6i: Fix endpoint IDs in second display pipeline

2017-09-08 Thread Chen-Yu Tsai
On Fri, Sep 8, 2017 at 9:29 PM, Maxime Ripard
 wrote:
> Hi,
>
> On Fri, Sep 08, 2017 at 03:50:09PM +0800, Chen-Yu Tsai wrote:
>> When the second display pipeline device nodes for the A31/A31s were
>> added, it was not known that the TCONs could (through either DRCs)
>> select either backend as their input. Thus in the endpoints connecting
>> these components together, the endpoint IDs were set to 0, while in
>> fact they should have been set to 1.
>>
>> Fixes: 9a26882a7378 ("ARM: dts: sun6i: Add second display pipeline device
>> nodes")
>> Signed-off-by: Chen-Yu Tsai 
>
> Should we CC stable on this one?

It wouldn't matter for old kernels, but I suppose we should get it right
everywhere, so we should probably CC stable. Also I forgot to mention
that this patch should go in -fixes, while the rest can go in -next.

Thanks
ChenYu
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure

2017-09-08 Thread Eric Engestrom
On Friday, 2017-09-08 14:17:04 +0100, Colin King wrote:
> From: Colin Ian King 
> 
> The current error handling on devm_kzalloc failures performs a non-null
> check on connector. Thss check is redundant because connector is null
> at that failure point.  With this check removed, we may as well make
> the failure path into a trivial -ENOMEM return to clean up the error
> handling.
> 
> Detected by CoverityScan CID#1339527 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++---
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 937da8dd65b8..a8808c1a1e03 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -311,14 +311,11 @@ static struct drm_connector 
> *vc4_hdmi_connector_init(struct drm_device *dev,
>  {
>   struct drm_connector *connector = NULL;

This `= NULL` isn't needed anymore either.

Reviewed-by: Eric Engestrom 

>   struct vc4_hdmi_connector *hdmi_connector;
> - int ret = 0;
>  
>   hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
> GFP_KERNEL);
> - if (!hdmi_connector) {
> - ret = -ENOMEM;
> - goto fail;
> - }
> + if (!hdmi_connector)
> + return ERR_PTR(-ENOMEM);
>   connector = &hdmi_connector->base;
>  
>   hdmi_connector->encoder = encoder;
> @@ -336,12 +333,6 @@ static struct drm_connector 
> *vc4_hdmi_connector_init(struct drm_device *dev,
>   drm_mode_connector_attach_encoder(connector, encoder);
>  
>   return connector;
> -
> - fail:
> - if (connector)
> - vc4_hdmi_connector_destroy(connector);
> -
> - return ERR_PTR(ret);
>  }
>  
>  static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
> -- 
> 2.14.1
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102625] Game Crashlands crashes on startup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102625

ratatosk.yggdra...@googlemail.com changed:

   What|Removed |Added

 Attachment #134084|0   |1
is obsolete||
 CC||ratatosk.yggdrasil@googlema
   ||il.com

--- Comment #1 from ratatosk.yggdra...@googlemail.com ---
Created attachment 134086
  --> https://bugs.freedesktop.org/attachment.cgi?id=134086&action=edit
gdb output when running crashlands

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure

2017-09-08 Thread Emil Velikov
Hi Colin,

On 8 September 2017 at 14:17, Colin King  wrote:
> From: Colin Ian King 
>
> The current error handling on devm_kzalloc failures performs a non-null
> check on connector. Thss check is redundant because connector is null
> at that failure point.  With this check removed, we may as well make
> the failure path into a trivial -ENOMEM return to clean up the error
> handling.
>
> Detected by CoverityScan CID#1339527 ("Logically dead code")
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++---
>  1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 937da8dd65b8..a8808c1a1e03 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -311,14 +311,11 @@ static struct drm_connector 
> *vc4_hdmi_connector_init(struct drm_device *dev,
>  {
> struct drm_connector *connector = NULL;
I think you can drop the initializer now.

-Emil
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102625] Game Crashlands crashes on startup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102625

--- Comment #2 from ratatosk.yggdra...@googlemail.com ---
Apologies, please ignore the previous gdb output. The error printed there was
transient which was gone after a reboot. I have updated the attached gdb output
which should be more helpful now.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH][V2] drm/vc4: clean up error handling on devm_kzalloc failure

2017-09-08 Thread Colin King
From: Colin Ian King 

The current error handling when devm_kzalloc fails performs a
non-null check on connector which is redundant because connector
is null at that failure point.  Once this is removed, make the
failure path into a trivial -ENOMEM return to clean up the
error handling. Also remove need to initialize connector to NULL.

Detected by CoverityScan CID#1339527 ("Logically dead code")
Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 937da8dd65b8..fa37a1c07cf6 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -309,16 +309,13 @@ static const struct drm_connector_helper_funcs 
vc4_hdmi_connector_helper_funcs =
 static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
 struct drm_encoder 
*encoder)
 {
-   struct drm_connector *connector = NULL;
+   struct drm_connector *connector;
struct vc4_hdmi_connector *hdmi_connector;
-   int ret = 0;
 
hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
  GFP_KERNEL);
-   if (!hdmi_connector) {
-   ret = -ENOMEM;
-   goto fail;
-   }
+   if (!hdmi_connector)
+   return ERR_PTR(-ENOMEM);
connector = &hdmi_connector->base;
 
hdmi_connector->encoder = encoder;
@@ -336,12 +333,6 @@ static struct drm_connector 
*vc4_hdmi_connector_init(struct drm_device *dev,
drm_mode_connector_attach_encoder(connector, encoder);
 
return connector;
-
- fail:
-   if (connector)
-   vc4_hdmi_connector_destroy(connector);
-
-   return ERR_PTR(ret);
 }
 
 static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/amdkfd: check for null dev to avoid a null pointer dereference

2017-09-08 Thread Colin King
From: Colin Ian King 

The call to kfd_device_by_id can potentially return null, so check that
dev is null and return with -EINVAL to avoid a null pointer dereference.

Detected by CoverityScan CID#1454629 ("Dereference null return value")

Fixes: 5d71dbc3a588 ("drm/amdkfd: Implement image tiling mode support v2")
Signed-off-by: Colin Ian King 
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index e4a8c2e52cb2..660b3fbade41 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -892,6 +892,8 @@ static int kfd_ioctl_get_tile_config(struct file *filep,
int err = 0;
 
dev = kfd_device_by_id(args->gpu_id);
+   if (!dev)
+   return -EINVAL;
 
dev->kfd2kgd->get_tile_config(dev->kgd, &config);
 
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102625] Game Crashlands crashes on startup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102625

--- Comment #3 from Samuel Pitoiset  ---
I bet if you launch the game with R600_DEBUG="ps,vs,tcs,tes,cs,gs" it will
work.

It's similar to the "Peace, Death!" issue because they both use the same
engine.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/todo: Add s/dev_*/DRM_DEV_*/ coversion to TODO

2017-09-08 Thread Sean Paul
Now that we have the DRM_DEV_* variants, we should use them.

Signed-off-by: Sean Paul 
---
 Documentation/gpu/todo.rst | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 22af55d06ab8..e3b622094bf4 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -177,6 +177,17 @@ following drivers still use ``struct_mutex``: ``msm``, 
``omapdrm`` and
 
 Contact: Daniel Vetter, respective driver maintainers
 
+Convert instances of dev_info/dev_err/dev_warn to their DRM_DEV_* equivalent
+
+
+For drivers which could have multiple instances, it is necessary to
+differentiate between which is which in the logs. Since DRM_INFO/WARN/ERROR
+don't do this, drivers used dev_info/warn/err to make this differentiation. We
+now have DRM_DEV_* variants of the drm print macros, so we can start to convert
+those drivers back to using drm-formwatted specific log messages.
+
+Contact: Sean Paul, Maintainer of the driver you plan to convert
+
 Core refactorings
 =
 
-- 
2.14.1.581.gf28d330327-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/rockchip: Add forward declarations to cdn_dp_device and audio_info

2017-09-08 Thread Sean Paul
Add forward declarations in cdn-dp-reg.h to cdn_dp_device and audio_info

Signed-off-by: Sean Paul 
---
 drivers/gpu/drm/rockchip/cdn-dp-reg.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.h 
b/drivers/gpu/drm/rockchip/cdn-dp-reg.h
index c4bbb4a83319..84bdb4a49ae2 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-reg.h
+++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.h
@@ -459,6 +459,9 @@ enum vic_bt_type {
BT_709 = 0x1,
 };
 
+struct cdn_dp_device;
+struct audio_info;
+
 void cdn_dp_clock_reset(struct cdn_dp_device *dp);
 
 void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk);
-- 
2.14.1.581.gf28d330327-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/sun4i: tcon: Unconditionally reset the TCON

2017-09-08 Thread Maxime Ripard
On Fri, Sep 08, 2017 at 05:00:16PM +0800, Chen-Yu Tsai wrote:
> When binding the TCON, we were checking the reset control status and
> asserting reset if it wasn't in reset. The check failed to account for
> the reset control API returning error codes if the status callback was
> not implemented.
> 
> Since we want the TCON to be reset in all cases, use reset_control_reset
> to force a reset instead.
> 
> Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
> Signed-off-by: Chen-Yu Tsai 

Applied, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102358] WarThunder freezes at start, with activated vsync (vblank_mode=2)

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102358

--- Comment #20 from har...@gmx.de ---
@Thomas,

i get freezes in windowed mode with activated vsync too (tried with latest
git).

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 03/11] drm/fb-helper: Ensure driver module is pinned in fb_open()

2017-09-08 Thread Noralf Trønnes
If struct fb_ops is defined in a library like cma, fb_open() takes a
ref on the library instead of the driver module. Use
fb_ops.fb_open/fb_release to ensure that the driver module is pinned.

Add drm_fb_helper_fb_open() and drm_fb_helper_fb_release() to
DRM_FB_HELPER_DEFAULT_OPS().

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 41 +
 include/drm/drm_fb_helper.h | 14 ++
 2 files changed, 55 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 74c1053..b080004 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1037,6 +1037,47 @@ void drm_fb_helper_fb_destroy(struct fb_info *info)
 EXPORT_SYMBOL(drm_fb_helper_fb_destroy);
 
 /**
+ * drm_fb_helper_fb_open - implementation for &fb_ops.fb_open
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * If &fb_ops is wrapped in a library, pin the driver module.
+ */
+int drm_fb_helper_fb_open(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   /* Skip fbcon, it detaches itself in unregister_framebuffer() */
+   if (user && info->fbops->owner != dev->driver->fops->owner) {
+   if (!try_module_get(dev->driver->fops->owner))
+   return -ENODEV;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_open);
+
+/**
+ * drm_fb_helper_fb_release - implementation for &fb_ops.fb_release
+ * @info: fbdev registered by the helper
+ * @user: 1=userspace, 0=fbcon
+ *
+ * If &fb_ops is wrapped in a library, unpin the driver module.
+ */
+int drm_fb_helper_fb_release(struct fb_info *info, int user)
+{
+   struct drm_fb_helper *fb_helper = info->par;
+   struct drm_device *dev = fb_helper->dev;
+
+   if (user && info->fbops->owner != dev->driver->fops->owner)
+   module_put(dev->driver->fops->owner);
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_fb_release);
+
+/**
  * drm_fb_helper_sys_read - wrapper around fb_sys_read
  * @info: fb_info struct pointer
  * @buf: userspace buffer to read from framebuffer memory
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index dd78eb3..b44fc62 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -233,6 +233,8 @@ struct drm_fb_helper {
  */
 #define DRM_FB_HELPER_DEFAULT_OPS \
.fb_destroy = drm_fb_helper_fb_destroy, \
+   .fb_open= drm_fb_helper_fb_open, \
+   .fb_release = drm_fb_helper_fb_release, \
.fb_check_var   = drm_fb_helper_check_var, \
.fb_set_par = drm_fb_helper_set_par, \
.fb_setcmap = drm_fb_helper_setcmap, \
@@ -270,6 +272,8 @@ void drm_fb_helper_deferred_io(struct fb_info *info,
   struct list_head *pagelist);
 
 void drm_fb_helper_fb_destroy(struct fb_info *info);
+int drm_fb_helper_fb_open(struct fb_info *info, int user);
+int drm_fb_helper_fb_release(struct fb_info *info, int user);
 
 ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
   size_t count, loff_t *ppos);
@@ -405,6 +409,16 @@ static inline void drm_fb_helper_fb_destroy(struct fb_info 
*info)
 {
 }
 
+static inline int drm_fb_helper_fb_open(struct fb_info *info, int user)
+{
+   return -ENODEV;
+}
+
+static inline int drm_fb_helper_fb_release(struct fb_info *info, int user)
+{
+   return -ENODEV;
+}
+
 static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
 char __user *buf, size_t count,
 loff_t *ppos)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 05/11] drm/fb-cma-helper: Make struct drm_fbdev_cma public

2017-09-08 Thread Noralf Trønnes
Make struct drm_fbdev_cma public so we don't have to make more wrappers
to call the drm_fb_helper fbdev wrappers.

Cc: Laurent Pinchart 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_cma_helper.c |  5 -
 include/drm/drm_fb_cma_helper.h | 11 +++
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index f2ee883..a5dc586 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -27,11 +27,6 @@
 
 #define DEFAULT_FBDEFIO_DELAY_MS 50
 
-struct drm_fbdev_cma {
-   struct drm_fb_helperfb_helper;
-   const struct drm_framebuffer_funcs *fb_funcs;
-};
-
 /**
  * DOC: framebuffer cma helper functions
  *
diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h
index a323781..1a70017 100644
--- a/include/drm/drm_fb_cma_helper.h
+++ b/include/drm/drm_fb_cma_helper.h
@@ -1,20 +1,23 @@
 #ifndef __DRM_FB_CMA_HELPER_H__
 #define __DRM_FB_CMA_HELPER_H__
 
-struct drm_fbdev_cma;
+#include 
+
 struct drm_gem_cma_object;
 
-struct drm_fb_helper_surface_size;
 struct drm_framebuffer_funcs;
-struct drm_fb_helper_funcs;
 struct drm_framebuffer;
-struct drm_fb_helper;
 struct drm_device;
 struct drm_file;
 struct drm_mode_fb_cmd2;
 struct drm_plane;
 struct drm_plane_state;
 
+struct drm_fbdev_cma {
+   struct drm_fb_helper fb_helper;
+   const struct drm_framebuffer_funcs *fb_funcs;
+};
+
 struct drm_fbdev_cma *drm_fbdev_cma_init_with_funcs(struct drm_device *dev,
unsigned int preferred_bpp, unsigned int max_conn_count,
const struct drm_framebuffer_funcs *funcs);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 00/11] drm/tinydrm: Support device unplug

2017-09-08 Thread Noralf Trønnes
This adds device unplug support to drm_fb_helper, drm_fb_cma_helper
(fbdev) and tinydrm.

There are several changes in this version:

I've used Daniel's idea of protecting drm_device.unplugged with srcu to
provide race free drm_dev_unplug().

The fbdev helper unplug patch has become very small with Daniel's help.
Ref is now taken and dropped in the existing helpers, so I could drop
drm_fb_helper_simple_init().

I has annoyed me that fbdev is restored in drm_driver.last_close even if
fbdev isn't used. I've added a patch to fix that. This means I can drop
calling drm_atomic_helper_shutdown() in tinydrm_unregister(), since I
now can easily disable the pipeline from userspace by just closing the
users. Disabled pipeline means balanced regulator_enable/disable.

The 'Embed drm_device in tinydrm_device' patch has gained
drm_driver.release functions after a discussion with Laurent. My
previous version relied on obscure freeing in tinydrm_release().
This means that I didn't retain the ack's.

Laurent also caught an ugly devm_kmalloc() in
tinydrm_display_pipe_init() that I've fixed.

Noralf.

Noralf Trønnes (11):
  drm: Use srcu to protect drm_device.unplugged
  drm/fb-helper: Support device unplug
  drm/fb-helper: Ensure driver module is pinned in fb_open()
  drm/fb-helper: Don't restore if fbdev is not in use
  drm/fb-cma-helper: Make struct drm_fbdev_cma public
  drm/fb-cma-helper: Support device unplug
  drm/tinydrm: Drop driver registered message
  drm/tinydrm: Embed drm_device in tinydrm_device
  drm/tinydrm: Support device unplug in core
  drm/tinydrm/mi0283qt: Let the display pipe handle power
  drm/tinydrm: Support device unplug in drivers

 drivers/gpu/drm/drm_drv.c   |  54 +--
 drivers/gpu/drm/drm_fb_cma_helper.c |  13 +--
 drivers/gpu/drm/drm_fb_helper.c | 108 --
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 135 +++-
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c |  28 +++---
 drivers/gpu/drm/tinydrm/mi0283qt.c  |  81 +
 drivers/gpu/drm/tinydrm/mipi-dbi.c  |  58 +---
 drivers/gpu/drm/tinydrm/repaper.c   |  62 -
 drivers/gpu/drm/tinydrm/st7586.c|  54 ++-
 include/drm/drm_device.h|   9 +-
 include/drm/drm_drv.h   |  15 +++-
 include/drm/drm_fb_cma_helper.h |  11 ++-
 include/drm/drm_fb_helper.h |  28 ++
 include/drm/tinydrm/mipi-dbi.h  |   1 +
 include/drm/tinydrm/tinydrm.h   |  10 ++-
 15 files changed, 469 insertions(+), 198 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 04/11] drm/fb-helper: Don't restore if fbdev is not in use

2017-09-08 Thread Noralf Trønnes
Keep track of fbdev users and only restore fbdev in
drm_fb_helper_restore_fbdev_mode_unlocked() when in use. This avoids
fbdev being restored in drm_driver.last_close when nothing uses it.
Additionally fbdev is turned off when the last user is closing.
fbcon is a user in this context.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 14 ++
 include/drm/drm_fb_helper.h |  7 +++
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b080004..12a7675 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -504,6 +504,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
if (READ_ONCE(fb_helper->deferred_setup))
return 0;
 
+   /* Don't restore if we track opens and it's zero */
+   if (fb_helper->fbdev && fb_helper->fbdev->fbops &&
+   fb_helper->fbdev->fbops->fb_open == drm_fb_helper_fb_open &&
+   !atomic_read(&fb_helper->open_count))
+   return 0;
+
mutex_lock(&fb_helper->lock);
ret = restore_fbdev_mode(fb_helper);
 
@@ -1041,6 +1047,7 @@ EXPORT_SYMBOL(drm_fb_helper_fb_destroy);
  * @info: fbdev registered by the helper
  * @user: 1=userspace, 0=fbcon
  *
+ * Increase fbdev use count.
  * If &fb_ops is wrapped in a library, pin the driver module.
  */
 int drm_fb_helper_fb_open(struct fb_info *info, int user)
@@ -1054,6 +1061,8 @@ int drm_fb_helper_fb_open(struct fb_info *info, int user)
return -ENODEV;
}
 
+   atomic_inc(&fb_helper->open_count);
+
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_fb_open);
@@ -1063,6 +1072,7 @@ EXPORT_SYMBOL(drm_fb_helper_fb_open);
  * @info: fbdev registered by the helper
  * @user: 1=userspace, 0=fbcon
  *
+ * Decrease fbdev use count and turn off if there are no users left.
  * If &fb_ops is wrapped in a library, unpin the driver module.
  */
 int drm_fb_helper_fb_release(struct fb_info *info, int user)
@@ -1070,6 +1080,10 @@ int drm_fb_helper_fb_release(struct fb_info *info, int 
user)
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
 
+   if (atomic_dec_and_test(&fb_helper->open_count) &&
+   !drm_dev_is_unplugged(fb_helper->dev))
+   drm_fb_helper_blank(FB_BLANK_POWERDOWN, info);
+
if (user && info->fbops->owner != dev->driver->fops->owner)
module_put(dev->driver->fops->owner);
 
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index b44fc62..5a5509c 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -223,6 +223,13 @@ struct drm_fb_helper {
 * See also: @deferred_setup
 */
int preferred_bpp;
+
+   /**
+* @open_count:
+*
+* Keeps track of fbdev users to know when to restore fbdev.
+*/
+   atomic_t open_count;
 };
 
 /**
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 01/11] drm: Use srcu to protect drm_device.unplugged

2017-09-08 Thread Noralf Trønnes
Use srcu to protect drm_device.unplugged in a race free manner.
Drivers can use drm_dev_enter()/drm_dev_exit() to protect and mark
sections preventing access to device resources that are not available
after the device is gone.

Suggested-by: Daniel Vetter 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_drv.c | 54 ++-
 include/drm/drm_device.h  |  9 +++-
 include/drm/drm_drv.h | 15 +
 3 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index be38ac7..66ceb0e 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -74,6 +75,8 @@ static bool drm_core_init_complete = false;
 
 static struct dentry *drm_debugfs_root;
 
+DEFINE_STATIC_SRCU(drm_unplug_srcu);
+
 #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
 void drm_dev_printk(const struct device *dev, const char *level,
@@ -364,18 +367,51 @@ void drm_put_dev(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_put_dev);
 
-static void drm_device_set_unplugged(struct drm_device *dev)
+/**
+ * drm_dev_enter - Enter device critical section
+ * @dev: DRM device
+ * @idx: Pointer to index that will be passed to the matching drm_dev_exit()
+ *
+ * This function marks and protects the beginning of a section that should not
+ * be entered after the device has been unplugged. The section end is marked
+ * with drm_dev_exit(). Calls to this function can be nested.
+ *
+ * Returns:
+ * True if it is OK to enter the section, false otherwise.
+ */
+bool drm_dev_enter(struct drm_device *dev, int *idx)
+{
+   *idx = srcu_read_lock(&drm_unplug_srcu);
+
+   if (dev->unplugged) {
+   srcu_read_unlock(&drm_unplug_srcu, *idx);
+   return false;
+   }
+
+   return true;
+}
+EXPORT_SYMBOL(drm_dev_enter);
+
+/**
+ * drm_dev_exit - Exit device critical section
+ * @idx: index returned from drm_dev_enter()
+ *
+ * This function marks the end of a section that should not be entered after
+ * the device has been unplugged.
+ */
+void drm_dev_exit(int idx)
 {
-   smp_wmb();
-   atomic_set(&dev->unplugged, 1);
+   srcu_read_unlock(&drm_unplug_srcu, idx);
 }
+EXPORT_SYMBOL(drm_dev_exit);
 
 /**
  * drm_dev_unplug - unplug a DRM device
  * @dev: DRM device
  *
  * This unplugs a hotpluggable DRM device, which makes it inaccessible to
- * userspace operations. Entry-points can use drm_dev_is_unplugged(). This
+ * userspace operations. Entry-points can use drm_dev_enter() and
+ * drm_dev_exit() to protect device resources in a race free manner. This
  * essentially unregisters the device like drm_dev_unregister(), but can be
  * called while there are still open users of @dev.
  */
@@ -384,10 +420,18 @@ void drm_dev_unplug(struct drm_device *dev)
drm_dev_unregister(dev);
 
mutex_lock(&drm_global_mutex);
-   drm_device_set_unplugged(dev);
if (dev->open_count == 0)
drm_dev_unref(dev);
mutex_unlock(&drm_global_mutex);
+
+   /*
+* After synchronizing any critical read section is guaranteed to see
+* the new value of ->unplugged, and any critical section which might
+* still have seen the old value of ->unplugged is guaranteed to have
+* finished.
+*/
+   dev->unplugged = true;
+   synchronize_srcu(&drm_unplug_srcu);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index e21af87..b0cabbb 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -45,7 +45,14 @@ struct drm_device {
/* currently active master for this device. Protected by master_mutex */
struct drm_master *master;
 
-   atomic_t unplugged; /**< Flag whether dev is dead */
+   /**
+* @unplugged:
+*
+* Flag to tell if the device has been unplugged.
+* See drm_dev_enter() and drm_dev_is_unplugged().
+*/
+   bool unplugged;
+
struct inode *anon_inode;   /**< inode for private 
address-space */
char *unique;   /**< unique name of the device 
*/
/*@} */
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 71bbaae..101c824 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -614,6 +614,8 @@ void drm_dev_unregister(struct drm_device *dev);
 void drm_dev_ref(struct drm_device *dev);
 void drm_dev_unref(struct drm_device *dev);
 void drm_put_dev(struct drm_device *dev);
+bool drm_dev_enter(struct drm_device *dev, int *idx);
+void drm_dev_exit(int idx);
 void drm_dev_unplug(struct drm_device *dev);
 
 /**
@@ -625,11 +627,16 @@ void drm_dev_unplug(struct drm_device *dev);
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it complet

[PATCH v2 06/11] drm/fb-cma-helper: Support device unplug

2017-09-08 Thread Noralf Trønnes
Support using drm_fb_helper_unregister_fbi() in driver.remove prior to
calling drm_fbdev_cma_fini() in drm_driver.release.
Also make drm_fbdev_cma_fini() NULL tolerant.

Cc: Laurent Pinchart 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index a5dc586..2030a6f 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -466,7 +466,13 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
  */
 void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
 {
-   drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
+   if (!fbdev_cma)
+   return;
+
+   /* Make sure it hasn't been unregistered already */
+   if (fbdev_cma->fb_helper.fbdev && fbdev_cma->fb_helper.fbdev->dev)
+   drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
+
if (fbdev_cma->fb_helper.fbdev)
drm_fbdev_cma_defio_fini(fbdev_cma->fb_helper.fbdev);
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 08/11] drm/tinydrm: Embed drm_device in tinydrm_device

2017-09-08 Thread Noralf Trønnes
Might as well embed drm_device since tinydrm_device (embeds pipe struct
and fbdev pointer) needs to stick around after driver-device unbind to
handle open fd's after device removal.

tinydrm_release() will be expanded in a later patch.

Cc: David Lechner 
Signed-off-by: Noralf Trønnes 
---

Changes since version 1:
- Add drm_driver.release callbacks
- Free structure if devm_tinydrm_init() fails.
- Probe message has been removed in the previous patch, so no need to
  fix up those variables.

 drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 61 +
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c |  2 +-
 drivers/gpu/drm/tinydrm/mi0283qt.c  |  9 +++--
 drivers/gpu/drm/tinydrm/mipi-dbi.c  | 30 +++---
 drivers/gpu/drm/tinydrm/repaper.c   | 20 --
 drivers/gpu/drm/tinydrm/st7586.c| 17 
 include/drm/tinydrm/mipi-dbi.h  |  1 +
 include/drm/tinydrm/tinydrm.h   | 10 -
 8 files changed, 102 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index 551709e..c8ae2e9 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -44,7 +44,7 @@
  */
 void tinydrm_lastclose(struct drm_device *drm)
 {
-   struct tinydrm_device *tdev = drm->dev_private;
+   struct tinydrm_device *tdev = drm_to_tinydrm(drm);
 
DRM_DEBUG_KMS("\n");
drm_fbdev_cma_restore_mode(tdev->fbdev_cma);
@@ -126,7 +126,7 @@ static struct drm_framebuffer *
 tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
  const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-   struct tinydrm_device *tdev = drm->dev_private;
+   struct tinydrm_device *tdev = drm_to_tinydrm(drm);
 
return drm_fb_cma_create_with_funcs(drm, file_priv, mode_cmd,
tdev->fb_funcs);
@@ -138,27 +138,37 @@ static const struct drm_mode_config_funcs 
tinydrm_mode_config_funcs = {
.atomic_commit = drm_atomic_helper_commit,
 };
 
+/**
+ * tinydrm_release - DRM driver release helper
+ * @drm: DRM device
+ *
+ * This function finalizes &drm_device. The caller is responsible for freeing
+ * &tinydrm_device.
+ *
+ * Drivers must use this in their &drm_driver->release callback.
+ */
+void tinydrm_release(struct drm_device *drm)
+{
+   DRM_DEBUG_DRIVER("\n");
+
+   drm_dev_fini(drm);
+}
+EXPORT_SYMBOL(tinydrm_release);
+
 static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
const struct drm_framebuffer_funcs *fb_funcs,
struct drm_driver *driver)
 {
-   struct drm_device *drm;
+   struct drm_device *drm = &tdev->drm;
+   int ret;
 
mutex_init(&tdev->dirty_lock);
tdev->fb_funcs = fb_funcs;
 
-   /*
-* We don't embed drm_device, because that prevent us from using
-* devm_kzalloc() to allocate tinydrm_device in the driver since
-* drm_dev_unref() frees the structure. The devm_ functions provide
-* for easy error handling.
-*/
-   drm = drm_dev_alloc(driver, parent);
-   if (IS_ERR(drm))
-   return PTR_ERR(drm);
-
-   tdev->drm = drm;
-   drm->dev_private = tdev;
+   ret = drm_dev_init(drm, driver, parent);
+   if (ret)
+   return ret;
+
drm_mode_config_init(drm);
drm->mode_config.funcs = &tinydrm_mode_config_funcs;
 
@@ -167,10 +177,9 @@ static int tinydrm_init(struct device *parent, struct 
tinydrm_device *tdev,
 
 static void tinydrm_fini(struct tinydrm_device *tdev)
 {
-   drm_mode_config_cleanup(tdev->drm);
+   drm_mode_config_cleanup(&tdev->drm);
mutex_destroy(&tdev->dirty_lock);
-   tdev->drm->dev_private = NULL;
-   drm_dev_unref(tdev->drm);
+   drm_dev_unref(&tdev->drm);
 }
 
 static void devm_tinydrm_release(void *data)
@@ -212,12 +221,12 @@ EXPORT_SYMBOL(devm_tinydrm_init);
 
 static int tinydrm_register(struct tinydrm_device *tdev)
 {
-   struct drm_device *drm = tdev->drm;
+   struct drm_device *drm = &tdev->drm;
int bpp = drm->mode_config.preferred_depth;
struct drm_fbdev_cma *fbdev;
int ret;
 
-   ret = drm_dev_register(tdev->drm, 0);
+   ret = drm_dev_register(drm, 0);
if (ret)
return ret;
 
@@ -236,10 +245,10 @@ static void tinydrm_unregister(struct tinydrm_device 
*tdev)
 {
struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma;
 
-   drm_atomic_helper_shutdown(tdev->drm);
+   drm_atomic_helper_shutdown(&tdev->drm);
/* don't restore fbdev in lastclose, keep pipeline disabled */
tdev->fbdev_cma = NULL;
-   drm_dev_unregister(tdev->drm);
+   drm_dev_unregister(&tdev->drm);
if (fbdev_cma)
drm_fbdev_cma_fini(fbdev_cma);
 }
@@ -262,7 +271,7 @@ static void devm_tinydrm_register_release(voi

[PATCH v2 09/11] drm/tinydrm: Support device unplug in core

2017-09-08 Thread Noralf Trønnes
Support device unplugging to make tinydrm suitable for USB devices.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 84 +
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 26 -
 2 files changed, 72 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index c8ae2e9..082b347 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -32,6 +32,36 @@
  * The driver allocates &tinydrm_device, initializes it using
  * devm_tinydrm_init(), sets up the pipeline using tinydrm_display_pipe_init()
  * and registers the DRM device using devm_tinydrm_register().
+ *
+ * Device unplug
+ * -
+ *
+ * tinydrm supports device unplugging when there are still open DRM or fbdev
+ * file handles.
+ *
+ * There are 3 ways for driver-device unbinding to happen:
+ *
+ * - The driver module is unloaded causing the driver to be unregistered.
+ *   This can't happen as long as there are open file handles because a
+ *   reference is taken on the module.
+ *
+ * - The device is removed (USB, Device Tree overlay).
+ *   This can happen at any time.
+ *
+ * - The driver sysfs _unbind_ file can be used to unbind the driver from the
+ *   device. This can happen any time.
+ *
+ * The driver needs to protect device resources from access after the device is
+ * gone. This is done marking the region with drm_dev_enter() and
+ * drm_dev_exit(), typically in &drm_framebuffer_funcs.dirty,
+ * &drm_simple_display_pipe_funcs.enable and \.disable.
+ *
+ * Resources that don't face userspace and are only used with the
+ * device can be setup using devm\_ functions, but &tinydrm_device must be
+ * allocated using plain kzalloc() since it's lifetime can exceed that of the
+ * device.
+ *
+ * The structure should be freed in the &drm_driver->release callback.
  */
 
 /**
@@ -149,9 +179,16 @@ static const struct drm_mode_config_funcs 
tinydrm_mode_config_funcs = {
  */
 void tinydrm_release(struct drm_device *drm)
 {
+   struct tinydrm_device *tdev = drm_to_tinydrm(drm);
+
DRM_DEBUG_DRIVER("\n");
 
+   drm_fbdev_cma_fini(tdev->fbdev_cma);
+
+   drm_mode_config_cleanup(&tdev->drm);
drm_dev_fini(drm);
+
+   mutex_destroy(&tdev->dirty_lock);
 }
 EXPORT_SYMBOL(tinydrm_release);
 
@@ -175,16 +212,11 @@ static int tinydrm_init(struct device *parent, struct 
tinydrm_device *tdev,
return 0;
 }
 
-static void tinydrm_fini(struct tinydrm_device *tdev)
-{
-   drm_mode_config_cleanup(&tdev->drm);
-   mutex_destroy(&tdev->dirty_lock);
-   drm_dev_unref(&tdev->drm);
-}
-
 static void devm_tinydrm_release(void *data)
 {
-   tinydrm_fini(data);
+   struct tinydrm_device *tdev = data;
+
+   drm_dev_unref(&tdev->drm);
 }
 
 /**
@@ -194,9 +226,10 @@ static void devm_tinydrm_release(void *data)
  * @fb_funcs: Framebuffer functions
  * @driver: DRM driver
  *
- * This function initializes @tdev, the underlying DRM device and it's
- * mode_config. Resources will be automatically freed on driver detach (devres)
- * using drm_mode_config_cleanup() and drm_dev_unref().
+ * This function initializes @tdev, the underlying DRM device and its
+ * mode_config. drm_dev_unref() is called on driver detach (devres) and when
+ * all refs are dropped, the &drm_driver->release callback is called which in
+ * turn calls tinydrm_release().
  *
  * Returns:
  * Zero on success, negative error code on failure.
@@ -213,7 +246,7 @@ int devm_tinydrm_init(struct device *parent, struct 
tinydrm_device *tdev,
 
ret = devm_add_action(parent, devm_tinydrm_release, tdev);
if (ret)
-   tinydrm_fini(tdev);
+   devm_tinydrm_release(tdev);
 
return ret;
 }
@@ -243,14 +276,9 @@ static int tinydrm_register(struct tinydrm_device *tdev)
 
 static void tinydrm_unregister(struct tinydrm_device *tdev)
 {
-   struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma;
-
-   drm_atomic_helper_shutdown(&tdev->drm);
-   /* don't restore fbdev in lastclose, keep pipeline disabled */
-   tdev->fbdev_cma = NULL;
-   drm_dev_unregister(&tdev->drm);
-   if (fbdev_cma)
-   drm_fbdev_cma_fini(fbdev_cma);
+   if (tdev->fbdev_cma)
+   drm_fb_helper_unregister_fbi(&tdev->fbdev_cma->fb_helper);
+   drm_dev_unplug(&tdev->drm);
 }
 
 static void devm_tinydrm_register_release(void *data)
@@ -279,10 +307,20 @@ int devm_tinydrm_register(struct tinydrm_device *tdev)
return ret;
 
ret = devm_add_action(dev, devm_tinydrm_register_release, tdev);
-   if (ret)
-   tinydrm_unregister(tdev);
+   if (ret) {
+   devm_tinydrm_register_release(tdev);
+   return ret;
+   }
 
-   return ret;
+   /*
+* Take a ref that will be put in devm_tinydrm_release().
+* It's done like this so devr

Re: [PATCH 0/3] fb/drm: Add support for a panel-orientation connector prop

2017-09-08 Thread Hans de Goede

Hi,

On 08-09-17 14:05, Daniel Vetter wrote:

On Fri, Sep 08, 2017 at 01:54:41PM +0200, Hans de Goede wrote:

Hi All,

Some x86 clamshell design devices use portrait tablet LCD panels and a
display engine which cannot (transparently) rotate in hardware, so we
need to rotate things in software / let user space deal with this.

The fbcon code has a set of DMI based quirks to automatically detect
such tablet LCD panels and rotate the fbcon to compensate.

The plan was for userspace (e.g. a Wayland compositor) to simply read
/sys/class/graphics/fbcon/rotate and apply the rotation from there to
the LCD panel to compensate.

However this will not work when an external monitor gets plugged in,
since with fbcon rotation is not per output, so the fbcon quirk code
disables the rotation when an external monitor is present.


Hm, where is that handled? Afaiui the fbdev emulation in drm completel
hides that there's possibly multiple monitors connected, which means I
have no idea how fbcon can even figure this out. Can you give some
pointers to relevant code?


The quirk code is added by this commit:

https://github.com/bzolnier/linux/commit/b0d8e409c3626eae42b59a3d76574804f2cef5ef

As you can see the check for a quirk match not only checks for
DMI strings, but also for the fbcon resolution, there are 2 reasons
for this:

1) Since these devices tend to be cheap and thus sometimes have generic
DMI strings, this is an extra check to avoid false positives

2) Since fbcon rotate is an all or nothing thing (not per output)
the question becomes what to do on these devices when using an
external output. Rotating the external output seems wrong, more
wrong then leaving the internal panel as is, esp. since these
devices tend to have small screens, so when an external output
is used chances are the user will mainly be using that.

TL;DR: we do not want to do fbcon rotation to compensate for
the panel orientation when an external output is used, the
resolution check gives us this since when an external output
is present (at boot) the fbcon resolution will (almost always)
be different.


And perhaps more importantly then me coming to the conclusion that
userspace cannot use /sys/class/graphics/fbcon/rotate having the
panel orientation be a property on the drm_connector simply seems
like the right thing to do from a design perspective.

As mentioned this will also help with the upside-down LCD panel
case, in which case I believe we can simply get the orientation
from the VBT table and I expect no DMI quirks to be necessary.

Note the 90 degree rotation is not in the VBT table, I believe this
is because the hardware and thus the GOP cannot handle this.

Regards,

Hans




Using /sys/class/graphics/fbcon/rotate will not help in that case
since it will indicate no rotation is in use. So instead we are going
to need a drm connecter property for this.

This patch-series introduces such a drm connector properperty, it
consists of 3 patches:

1) Make the fbcon quirk table usable outside of the fbcon code
2) Add drm_connector_create_panel_orientation_property and
drm_connector_attach_panel_orientation_property functions
3) Hook things up in intel_panel.c

Regards,

Hans


p.s.

Note this series does not yet get the panel orientation from the VBT
on Intel devices. I think that for devices which have the panel
upside-down (rather then rotated 90 degrees) this should work, but
I've an i915 patch series pending which corrects for the upside-down
scanario fully inside the i915 driver hiding the upside-down ness
from userspace (and fbcon) and if that series gets merged then in
the upside-down case the "panel orientation" property should read
"Normal" and not "Upside Down", so I've left out hooking up the VBTs
idea of the panel orientation for now.

Note that we could use the new "panel orientation" property for the
upside-down case too and drop my "[v4] drm/i915: Deal with upside-down
mounted LCD panels" patch:
https://patchwork.freedesktop.org/patch/173781/

That patch is not universally liked anyways, so just dropping it and
using the new prop this series introduces might be best.
  
___

dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 07/11] drm/tinydrm: Drop driver registered message

2017-09-08 Thread Noralf Trønnes
No need to put out a driver registered message since drm_dev_register()
does that now. SPI speed is an important metric when dealing with
display problems, so retain that info.

Cc: David Lechner 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/mi0283qt.c | 14 +-
 drivers/gpu/drm/tinydrm/mipi-dbi.c |  2 ++
 drivers/gpu/drm/tinydrm/repaper.c  | 12 ++--
 drivers/gpu/drm/tinydrm/st7586.c   | 14 +-
 4 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d..7fd2691 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -163,7 +163,6 @@ MODULE_DEVICE_TABLE(spi, mi0283qt_id);
 static int mi0283qt_probe(struct spi_device *spi)
 {
struct device *dev = &spi->dev;
-   struct tinydrm_device *tdev;
struct mipi_dbi *mipi;
struct gpio_desc *dc;
u32 rotation = 0;
@@ -215,20 +214,9 @@ static int mi0283qt_probe(struct spi_device *spi)
return ret;
}
 
-   tdev = &mipi->tinydrm;
-
-   ret = devm_tinydrm_register(tdev);
-   if (ret)
-   return ret;
-
spi_set_drvdata(spi, mipi);
 
-   DRM_DEBUG_DRIVER("Initialized %s:%s @%uMHz on minor %d\n",
-tdev->drm->driver->name, dev_name(dev),
-spi->max_speed_hz / 100,
-tdev->drm->primary->index);
-
-   return 0;
+   return devm_tinydrm_register(&mipi->tinydrm);
 }
 
 static void mi0283qt_shutdown(struct spi_device *spi)
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index 2caeabc..f0dedc2 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -842,6 +842,8 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct 
mipi_dbi *mipi,
return -ENOMEM;
}
 
+   DRM_DEBUG_DRIVER("SPI speed: %uMHz\n", spi->max_speed_hz / 100);
+
return 0;
 }
 EXPORT_SYMBOL(mipi_dbi_spi_init);
diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
b/drivers/gpu/drm/tinydrm/repaper.c
index 30dc97b..5fbe147 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -1078,19 +1078,11 @@ static int repaper_probe(struct spi_device *spi)
return ret;
 
drm_mode_config_reset(tdev->drm);
-
-   ret = devm_tinydrm_register(tdev);
-   if (ret)
-   return ret;
-
spi_set_drvdata(spi, tdev);
 
-   DRM_DEBUG_DRIVER("Initialized %s:%s @%uMHz on minor %d\n",
-tdev->drm->driver->name, dev_name(dev),
-spi->max_speed_hz / 100,
-tdev->drm->primary->index);
+   DRM_DEBUG_DRIVER("SPI speed: %uMHz\n", spi->max_speed_hz / 100);
 
-   return 0;
+   return devm_tinydrm_register(tdev);
 }
 
 static void repaper_shutdown(struct spi_device *spi)
diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c
index b439956..07b4d31 100644
--- a/drivers/gpu/drm/tinydrm/st7586.c
+++ b/drivers/gpu/drm/tinydrm/st7586.c
@@ -343,7 +343,6 @@ MODULE_DEVICE_TABLE(spi, st7586_id);
 static int st7586_probe(struct spi_device *spi)
 {
struct device *dev = &spi->dev;
-   struct tinydrm_device *tdev;
struct mipi_dbi *mipi;
struct gpio_desc *a0;
u32 rotation = 0;
@@ -388,20 +387,9 @@ static int st7586_probe(struct spi_device *spi)
if (ret)
return ret;
 
-   tdev = &mipi->tinydrm;
-
-   ret = devm_tinydrm_register(tdev);
-   if (ret)
-   return ret;
-
spi_set_drvdata(spi, mipi);
 
-   DRM_DEBUG_DRIVER("Initialized %s:%s @%uMHz on minor %d\n",
-tdev->drm->driver->name, dev_name(dev),
-spi->max_speed_hz / 100,
-tdev->drm->primary->index);
-
-   return 0;
+   return devm_tinydrm_register(&mipi->tinydrm);
 }
 
 static void st7586_shutdown(struct spi_device *spi)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 02/11] drm/fb-helper: Support device unplug

2017-09-08 Thread Noralf Trønnes
Support device unplug by taking a ref on drm_device during probe, drop
it in fbops.destroy = drm_fb_helper_fb_destroy().
Use drm_dev_is_unplugged() to block futile operations.

drm_fb_helper_unregister_fbi() can now be called on device removal and
drm_fb_helper_fini() in drm_driver.release.

It turns out that fbdev has the necessary ref counting, so
unregister_framebuffer() together with fb_ops->destroy handles unplug
with open fd's. The ref counting doesn't apply to the fb_info structure
itself, but to use of the fbdev framebuffer.

Analysis of entry points after unregister_framebuffer():
- fbcon has been unbound (through notifier)
- sysfs files removed

First we look at possible operations on open fbdev file handles:

static const struct file_operations fb_fops = {
.read = fb_read,
.write =fb_write,
.unlocked_ioctl = fb_ioctl,
.compat_ioctl = fb_compat_ioctl,
.mmap = fb_mmap,
.open = fb_open,
.release =  fb_release,
.get_unmapped_area = get_fb_unmapped_area,
.fsync =fb_deferred_io_fsync,
};

Protected by file_fb_info() (-ENODEV):
fb_read() -> fb_ops.fb_read = drm_fb_helper_sys_read()
fb_write() -> fb_ops.fb_write = drm_fb_helper_sys_write()
fb_ioctl() -> fb_ops.fb_ioctl = drm_fb_helper_ioctl()
fb_compat_ioctl() -> fb_ops.fb_compat_ioctl
fb_mmap() -> fb_ops.fb_mmap

Safe:
fb_release() -> fb_ops.fb_release
get_fb_unmapped_area() : info->screen_base
fb_deferred_io_fsync() : if (info->fbdefio) schedule info->deferred_work

Active mmap's will need the backing buffer to be present.
If deferred IO is used, mmap writes will via a worker generate calls to
drm_fb_helper_deferred_io() which in turn via a worker calls into
drm_fb_helper_dirty_work().

The remaining struct fb_ops operations are safe since they're either
called through fb_ioctl(), fbcon or sysfs.

Next we look at other call paths:

drm_fb_helper_set_suspend{_unlocked}() and
drm_fb_helper_resume_worker():
Calls into fb_set_suspend(), but that's fine since it just uses the
fbdev notifier.

drm_fb_helper_restore_fbdev_mode_unlocked():
Called from drm_driver.last_close.

drm_fb_helper_force_kernel_mode():
Triggered by sysrq.

drm_fb_helper_hotplug_event():
Called by drm_kms_helper_hotplug_event().

Based on this analysis the following functions gets a check:
- drm_fb_helper_restore_fbdev_mode_unlocked()
- drm_fb_helper_force_kernel_mode()
- drm_fb_helper_hotplug_event()
- drm_fb_helper_dirty_work()

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/drm_fb_helper.c | 53 +
 include/drm/drm_fb_helper.h |  7 ++
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 6a31d13..74c1053 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -498,7 +498,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
bool do_delayed;
int ret;
 
-   if (!drm_fbdev_emulation)
+   if (!drm_fbdev_emulation || drm_dev_is_unplugged(fb_helper->dev))
return -ENODEV;
 
if (READ_ONCE(fb_helper->deferred_setup))
@@ -563,6 +563,9 @@ static bool drm_fb_helper_force_kernel_mode(void)
list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
struct drm_device *dev = helper->dev;
 
+   if (drm_dev_is_unplugged(dev))
+   continue;
+
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
continue;
 
@@ -735,6 +738,9 @@ static void drm_fb_helper_dirty_work(struct work_struct 
*work)
struct drm_clip_rect clip_copy;
unsigned long flags;
 
+   if (drm_dev_is_unplugged(helper->dev))
+   return;
+
spin_lock_irqsave(&helper->dirty_lock, flags);
clip_copy = *clip;
clip->x1 = clip->y1 = ~0;
@@ -886,13 +892,24 @@ EXPORT_SYMBOL(drm_fb_helper_alloc_fbi);
  * @fb_helper: driver-allocated fbdev helper
  *
  * A wrapper around unregister_framebuffer, to release the fb_info
- * framebuffer device. This must be called before releasing all resources for
- * @fb_helper by calling drm_fb_helper_fini().
+ * framebuffer device. Unless drm_fb_helper_fb_destroy() set by
+ * DRM_FB_HELPER_DEFAULT_OPS() is used, the ref taken on &drm_device in
+ * drm_fb_helper_initial_config() is dropped. This function must be called
+ * before releasing all resources for @fb_helper by calling
+ * drm_fb_helper_fini().
  */
 void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
 {
-   if (fb_helper && fb_helper->fbdev)
-   unregister_framebuffer(fb_helper->fbdev);
+   struct fb_info *info;
+
+   if (!fb_helper || !fb_helper->fbdev)
+   return;
+
+   info = fb_helper->fbdev;
+   unregister_framebuffer(info);
+   if (!(info->fbops &&
+ info->fbops->fb_des

[PATCH v2 10/11] drm/tinydrm/mi0283qt: Let the display pipe handle power

2017-09-08 Thread Noralf Trønnes
It's better to leave power handling and controller init to the
modesetting machinery using the simple pipe .enable and .disable
callbacks.

Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/mi0283qt.c | 55 +-
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 10 ---
 2 files changed, 19 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index d61f987..9495c9a 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -20,9 +20,11 @@
 #include 
 #include 
 
-static int mi0283qt_init(struct mipi_dbi *mipi)
+static void mi0283qt_enable(struct drm_simple_display_pipe *pipe,
+   struct drm_crtc_state *crtc_state)
 {
-   struct tinydrm_device *tdev = &mipi->tinydrm;
+   struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
+   struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
struct device *dev = tdev->drm.dev;
u8 addr_mode;
int ret;
@@ -31,20 +33,19 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
 
ret = regulator_enable(mipi->regulator);
if (ret) {
-   dev_err(dev, "Failed to enable regulator %d\n", ret);
-   return ret;
+   dev_err(dev, "Failed to enable regulator (%d)\n", ret);
+   return;
}
 
-   /* Avoid flicker by skipping setup if the bootloader has done it */
if (mipi_dbi_display_is_on(mipi))
-   return 0;
+   goto out_enable;
 
mipi_dbi_hw_reset(mipi);
ret = mipi_dbi_command(mipi, MIPI_DCS_SOFT_RESET);
if (ret) {
-   dev_err(dev, "Error sending command %d\n", ret);
+   dev_err(dev, "Error sending command (%d)\n", ret);
regulator_disable(mipi->regulator);
-   return ret;
+   return;
}
 
msleep(20);
@@ -110,19 +111,12 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON);
msleep(100);
 
-   return 0;
-}
-
-static void mi0283qt_fini(void *data)
-{
-   struct mipi_dbi *mipi = data;
-
-   DRM_DEBUG_KMS("\n");
-   regulator_disable(mipi->regulator);
+out_enable:
+   mipi_dbi_pipe_enable(pipe, crtc_state);
 }
 
 static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
-   .enable = mipi_dbi_pipe_enable,
+   .enable = mi0283qt_enable,
.disable = mipi_dbi_pipe_disable,
.update = tinydrm_display_pipe_update,
.prepare_fb = tinydrm_display_pipe_prepare_fb,
@@ -206,17 +200,6 @@ static int mi0283qt_probe(struct spi_device *spi)
return ret;
}
 
-   ret = mi0283qt_init(mipi);
-   if (ret)
-   return ret;
-
-   /* use devres to fini after drm unregister (drv->remove is before) */
-   ret = devm_add_action(dev, mi0283qt_fini, mipi);
-   if (ret) {
-   mi0283qt_fini(mipi);
-   return ret;
-   }
-
spi_set_drvdata(spi, mipi);
 
return devm_tinydrm_register(&mipi->tinydrm);
@@ -232,25 +215,13 @@ static void mi0283qt_shutdown(struct spi_device *spi)
 static int __maybe_unused mi0283qt_pm_suspend(struct device *dev)
 {
struct mipi_dbi *mipi = dev_get_drvdata(dev);
-   int ret;
-
-   ret = tinydrm_suspend(&mipi->tinydrm);
-   if (ret)
-   return ret;
 
-   mi0283qt_fini(mipi);
-
-   return 0;
+   return tinydrm_suspend(&mipi->tinydrm);
 }
 
 static int __maybe_unused mi0283qt_pm_resume(struct device *dev)
 {
struct mipi_dbi *mipi = dev_get_drvdata(dev);
-   int ret;
-
-   ret = mi0283qt_init(mipi);
-   if (ret)
-   return ret;
 
return tinydrm_resume(&mipi->tinydrm);
 }
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index ec8f001..8498b49 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -263,8 +263,9 @@ static const struct drm_framebuffer_funcs mipi_dbi_fb_funcs 
= {
  * @pipe: Display pipe
  * @crtc_state: CRTC state
  *
- * This function enables backlight. Drivers can use this as their
- * &drm_simple_display_pipe_funcs->enable callback.
+ * This function flushes the whole framebuffer and enables the backlight.
+ * Drivers can use this in their &drm_simple_display_pipe_funcs->enable
+ * callback.
  */
 void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
  struct drm_crtc_state *crtc_state)
@@ -273,8 +274,6 @@ void mipi_dbi_pipe_enable(struct drm_simple_display_pipe 
*pipe,
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
struct drm_framebuffer *fb = pipe->plane.fb;
 
-   DRM_DEBUG_KMS("\n");
-
mipi->enabled = true;
if (fb)
fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
@@ -321,6 +320,9 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pip

[PATCH v2 11/11] drm/tinydrm: Support device unplug in drivers

2017-09-08 Thread Noralf Trønnes
Protect device resource by adding drm_dev_enter() and drm_dev_exit().

Cc: David Lechner 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/mi0283qt.c | 11 ---
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 18 +-
 drivers/gpu/drm/tinydrm/repaper.c  | 30 +++---
 drivers/gpu/drm/tinydrm/st7586.c   | 23 +++
 4 files changed, 67 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 9495c9a..f85a404 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -27,14 +27,17 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
struct device *dev = tdev->drm.dev;
u8 addr_mode;
-   int ret;
+   int ret, idx;
+
+   if (!drm_dev_enter(&tdev->drm, &idx))
+   return;
 
DRM_DEBUG_KMS("\n");
 
ret = regulator_enable(mipi->regulator);
if (ret) {
dev_err(dev, "Failed to enable regulator (%d)\n", ret);
-   return;
+   goto exit;
}
 
if (mipi_dbi_display_is_on(mipi))
@@ -45,7 +48,7 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
if (ret) {
dev_err(dev, "Error sending command (%d)\n", ret);
regulator_disable(mipi->regulator);
-   return;
+   goto exit;
}
 
msleep(20);
@@ -113,6 +116,8 @@ static void mi0283qt_enable(struct drm_simple_display_pipe 
*pipe,
 
 out_enable:
mipi_dbi_pipe_enable(pipe, crtc_state);
+exit:
+   drm_dev_exit(idx);
 }
 
 static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index 8498b49..8b72cfb 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -203,10 +203,13 @@ static int mipi_dbi_fb_dirty(struct drm_framebuffer *fb,
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
bool swap = mipi->swap_bytes;
struct drm_clip_rect clip;
-   int ret = 0;
+   int ret = 0, idx;
bool full;
void *tr;
 
+   if (!drm_dev_enter(fb->dev, &idx))
+   return -ENODEV;
+
mutex_lock(&tdev->dirty_lock);
 
if (!mipi->enabled)
@@ -244,6 +247,7 @@ static int mipi_dbi_fb_dirty(struct drm_framebuffer *fb,
 
 out_unlock:
mutex_unlock(&tdev->dirty_lock);
+   drm_dev_exit(idx);
 
if (ret)
dev_err_once(fb->dev->dev, "Failed to update display %d\n",
@@ -273,12 +277,18 @@ void mipi_dbi_pipe_enable(struct drm_simple_display_pipe 
*pipe,
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
struct drm_framebuffer *fb = pipe->plane.fb;
+   int idx;
+
+   if (!drm_dev_enter(&tdev->drm, &idx))
+   return;
 
mipi->enabled = true;
if (fb)
fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
 
tinydrm_enable_backlight(mipi->backlight);
+
+   drm_dev_exit(idx);
 }
 EXPORT_SYMBOL(mipi_dbi_pipe_enable);
 
@@ -311,6 +321,10 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe 
*pipe)
 {
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
+   int idx;
+
+   if (!drm_dev_enter(&tdev->drm, &idx))
+   return;
 
DRM_DEBUG_KMS("\n");
 
@@ -323,6 +337,8 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe 
*pipe)
 
if (mipi->regulator)
regulator_disable(mipi->regulator);
+
+   drm_dev_exit(idx);
 }
 EXPORT_SYMBOL(mipi_dbi_pipe_disable);
 
diff --git a/drivers/gpu/drm/tinydrm/repaper.c 
b/drivers/gpu/drm/tinydrm/repaper.c
index 9236efb..207a031 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -531,8 +531,11 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
struct tinydrm_device *tdev = drm_to_tinydrm(fb->dev);
struct repaper_epd *epd = epd_from_tinydrm(tdev);
struct drm_clip_rect clip;
+   int ret = 0, idx;
u8 *buf = NULL;
-   int ret = 0;
+
+   if (!drm_dev_enter(fb->dev, &idx))
+   return -ENODEV;
 
/* repaper can't do partial updates */
clip.x1 = 0;
@@ -632,6 +635,8 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
dev_err(fb->dev->dev, "Failed to update display (%d)\n", ret);
kfree(buf);
 
+   drm_dev_exit(idx);
+
return ret;
 }
 
@@ -666,7 +671,10 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
struct spi_device *spi = epd->spi;
struct device *dev = &spi->dev;
bool dc_ok = false;
-   int i, ret;
+   int i, ret, idx;
+
+   if (!drm_

[PATCH] MAINTAINERS: Add dri-devel as a mailing list for anything fbdev

2017-09-08 Thread Daniel Vetter
fbdev is in maintenance only, except that it's still used by drm
through the drm fbdev emulation, to be able to use fbcon. And people
might want to sometimes extend fbcon to enable new features for drm
drivers, e.g. Hans' panel orientation work.

The problem is that when those patches only touch fbdev code they'll
never show up on drm developer's radar, which means we end up with
designs that don't really fit whell into the full stack. That happened
a bit with the panel orientation work, where an fbcon patch made it
into 4.14, implementing a design that won't really work on the drm
side. Which means we now have to redo things, and on top coordinate 2
subsystem trees.

Since fbdev is super low-volume we can prevent this in the future by
simply adding the dri-devel mailing list to the fbdev subsystem.

Cc: Hans de Goede 
Cc: Bartlomiej Zolnierkiewicz 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Sean Paul 
Cc: David Airlie 
Signed-off-by: Daniel Vetter 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ba51d0906955..af9766a32949 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5391,6 +5391,7 @@ F:drivers/net/wan/sdla.c
 
 FRAMEBUFFER LAYER
 M: Bartlomiej Zolnierkiewicz 
+L: dri-devel@lists.freedesktop.org
 L: linux-fb...@vger.kernel.org
 T: git git://github.com/bzolnier/linux.git
 Q: http://patchwork.kernel.org/project/linux-fbdev/list/
-- 
2.14.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] MAINTAINERS: Add dri-devel as a mailing list for anything fbdev

2017-09-08 Thread Sean Paul
On Fri, Sep 8, 2017 at 11:35 AM, Daniel Vetter  wrote:
> fbdev is in maintenance only, except that it's still used by drm
> through the drm fbdev emulation, to be able to use fbcon. And people
> might want to sometimes extend fbcon to enable new features for drm
> drivers, e.g. Hans' panel orientation work.
>
> The problem is that when those patches only touch fbdev code they'll
> never show up on drm developer's radar, which means we end up with
> designs that don't really fit whell into the full stack. That happened
> a bit with the panel orientation work, where an fbcon patch made it
> into 4.14, implementing a design that won't really work on the drm
> side. Which means we now have to redo things, and on top coordinate 2
> subsystem trees.
>
> Since fbdev is super low-volume we can prevent this in the future by
> simply adding the dri-devel mailing list to the fbdev subsystem.
>
> Cc: Hans de Goede 
> Cc: Bartlomiej Zolnierkiewicz 
> Cc: linux-fb...@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: Sean Paul 

Acked-by: Sean Paul 

> Cc: David Airlie 
> Signed-off-by: Daniel Vetter 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ba51d0906955..af9766a32949 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5391,6 +5391,7 @@ F:drivers/net/wan/sdla.c
>
>  FRAMEBUFFER LAYER
>  M: Bartlomiej Zolnierkiewicz 
> +L: dri-devel@lists.freedesktop.org
>  L: linux-fb...@vger.kernel.org
>  T: git git://github.com/bzolnier/linux.git
>  Q: http://patchwork.kernel.org/project/linux-fbdev/list/
> --
> 2.14.1
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/todo: Add s/dev_*/DRM_DEV_*/ coversion to TODO

2017-09-08 Thread Daniel Vetter
On Fri, Sep 08, 2017 at 10:32:07AM -0400, Sean Paul wrote:
> Now that we have the DRM_DEV_* variants, we should use them.
> 
> Signed-off-by: Sean Paul 

I think that's fairly ideal fodder for outreachy, assume we make sure the
driver maintainer is ok with the resulting torrent of patches first :-)
-Daniel

> ---
>  Documentation/gpu/todo.rst | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 22af55d06ab8..e3b622094bf4 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -177,6 +177,17 @@ following drivers still use ``struct_mutex``: ``msm``, 
> ``omapdrm`` and
>  
>  Contact: Daniel Vetter, respective driver maintainers
>  
> +Convert instances of dev_info/dev_err/dev_warn to their DRM_DEV_* equivalent
> +
> +
> +For drivers which could have multiple instances, it is necessary to
> +differentiate between which is which in the logs. Since DRM_INFO/WARN/ERROR
> +don't do this, drivers used dev_info/warn/err to make this differentiation. 
> We
> +now have DRM_DEV_* variants of the drm print macros, so we can start to 
> convert
> +those drivers back to using drm-formwatted specific log messages.
> +
> +Contact: Sean Paul, Maintainer of the driver you plan to convert
> +
>  Core refactorings
>  =
>  
> -- 
> 2.14.1.581.gf28d330327-goog
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-doc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 102500] [polaris10, vega10][amd-staging-4.12, amd-staging-drm-next] GPU fault detected, somethimes lockup

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102500

--- Comment #16 from Arek Ruśniak  ---
Patch fixes issue.
I've tried both staging-4.12 and staging-drm-next branches.
Thanks Christian

PS. It will be nice if Vedran could confirmed this for Vega before we close.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/todo: Add s/dev_*/DRM_DEV_*/ coversion to TODO

2017-09-08 Thread Sean Paul
On Fri, Sep 8, 2017 at 11:44 AM, Daniel Vetter  wrote:
> On Fri, Sep 08, 2017 at 10:32:07AM -0400, Sean Paul wrote:
>> Now that we have the DRM_DEV_* variants, we should use them.
>>
>> Signed-off-by: Sean Paul 
>
> I think that's fairly ideal fodder for outreachy, assume we make sure the
> driver maintainer is ok with the resulting torrent of patches first :-)

I'll happily review patches that convert rockchip.

Sean

> -Daniel
>
>> ---
>>  Documentation/gpu/todo.rst | 11 +++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
>> index 22af55d06ab8..e3b622094bf4 100644
>> --- a/Documentation/gpu/todo.rst
>> +++ b/Documentation/gpu/todo.rst
>> @@ -177,6 +177,17 @@ following drivers still use ``struct_mutex``: ``msm``, 
>> ``omapdrm`` and
>>
>>  Contact: Daniel Vetter, respective driver maintainers
>>
>> +Convert instances of dev_info/dev_err/dev_warn to their DRM_DEV_* equivalent
>> +
>> +
>> +For drivers which could have multiple instances, it is necessary to
>> +differentiate between which is which in the logs. Since DRM_INFO/WARN/ERROR
>> +don't do this, drivers used dev_info/warn/err to make this differentiation. 
>> We
>> +now have DRM_DEV_* variants of the drm print macros, so we can start to 
>> convert
>> +those drivers back to using drm-formwatted specific log messages.
>> +
>> +Contact: Sean Paul, Maintainer of the driver you plan to convert
>> +
>>  Core refactorings
>>  =
>>
>> --
>> 2.14.1.581.gf28d330327-goog
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-doc" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 99710] [amdgpu R9 390] GPU hang when playing Hearthstone in Wine

2017-09-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99710

--- Comment #10 from Sandeep  ---
I tried the 4.11.0 kernel since I suspected that the buggy change might also be
present in the point releases, but that also caused a hang whenplaying Left 4
Dead 2. Will try older kernels and see if they work correctly (which they
should since this hang definitely wasn't present 2 months ago).

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] libdrm: add drm syncobj create/destroy/import/export

2017-09-08 Thread Marek Olšák
What's the difference between HandleToFD and ExportSyncFile?

Thanks,
Marek

On Sat, Jun 17, 2017 at 3:06 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> These ioctls are now in drm next so add the first set of libdrm APIs.
>
> Signed-off-by: Dave Airlie 
> ---
>  include/drm/drm.h | 26 ++
>  xf86drm.c | 81 
> +++
>  xf86drm.h |  8 ++
>  3 files changed, 115 insertions(+)
>
> diff --git a/include/drm/drm.h b/include/drm/drm.h
> index 1e7a4bc..bf3674a 100644
> --- a/include/drm/drm.h
> +++ b/include/drm/drm.h
> @@ -642,6 +642,7 @@ struct drm_gem_open {
>  #define DRM_CAP_ADDFB2_MODIFIERS   0x10
>  #define DRM_CAP_PAGE_FLIP_TARGET   0x11
>  #define DRM_CAP_CRTC_IN_VBLANK_EVENT   0x12
> +#define DRM_CAP_SYNCOBJ0x13
>
>  /** DRM_IOCTL_GET_CAP ioctl argument type */
>  struct drm_get_cap {
> @@ -691,6 +692,26 @@ struct drm_prime_handle {
> __s32 fd;
>  };
>
> +struct drm_syncobj_create {
> +   __u32 handle;
> +   __u32 flags;
> +};
> +
> +struct drm_syncobj_destroy {
> +   __u32 handle;
> +   __u32 pad;
> +};
> +
> +#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
> +#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
> +struct drm_syncobj_handle {
> +   __u32 handle;
> +   __u32 flags;
> +
> +   __s32 fd;
> +   __u32 pad;
> +};
> +
>  #if defined(__cplusplus)
>  }
>  #endif
> @@ -809,6 +830,11 @@ extern "C" {
>  #define DRM_IOCTL_MODE_CREATEPROPBLOB  DRM_IOWR(0xBD, struct 
> drm_mode_create_blob)
>  #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct 
> drm_mode_destroy_blob)
>
> +#define DRM_IOCTL_SYNCOBJ_CREATE   DRM_IOWR(0xBF, struct 
> drm_syncobj_create)
> +#define DRM_IOCTL_SYNCOBJ_DESTROY  DRM_IOWR(0xC0, struct 
> drm_syncobj_destroy)
> +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct 
> drm_syncobj_handle)
> +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct 
> drm_syncobj_handle)
> +
>  /**
>   * Device specific ioctls should only be in their respective headers
>   * The device specific ioctl range is from 0x40 to 0x9f.
> diff --git a/xf86drm.c b/xf86drm.c
> index 728ac78..2ac3f26 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
>  return strdup(node);
>  #endif
>  }
> +
> +int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
> +{
> +struct drm_syncobj_create args;
> +int ret;
> +
> +memclear(args);
> +args.flags = flags;
> +args.handle = 0;
> +ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
> +if (ret)
> +   return ret;
> +*handle = args.handle;
> +return 0;
> +}
> +
> +int drmSyncobjDestroy(int fd, uint32_t handle)
> +{
> +struct drm_syncobj_destroy args;
> +
> +memclear(args);
> +args.handle = handle;
> +return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
> +}
> +
> +int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
> +{
> +struct drm_syncobj_handle args;
> +int ret;
> +
> +memclear(args);
> +args.fd = -1;
> +args.handle = handle;
> +ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> +if (ret)
> +   return ret;
> +*obj_fd = args.fd;
> +return 0;
> +}
> +
> +int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
> +{
> +struct drm_syncobj_handle args;
> +int ret;
> +
> +memclear(args);
> +args.fd = obj_fd;
> +args.handle = 0;
> +ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> +if (ret)
> +   return ret;
> +*handle = args.handle;
> +return 0;
> +}
> +
> +int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
> +{
> +struct drm_syncobj_handle args;
> +
> +memclear(args);
> +args.fd = sync_file_fd;
> +args.handle = handle;
> +args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
> +return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
> +}
> +
> +int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
> +{
> +struct drm_syncobj_handle args;
> +int ret;
> +
> +memclear(args);
> +args.fd = -1;
> +args.handle = handle;
> +args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
> +ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
> +if (ret)
> +   return ret;
> +*sync_file_fd = args.fd;
> +return 0;
> +}
> diff --git a/xf86drm.h b/xf86drm.h
> index 74f54f1..2855a3e 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr 
> devices[], int max_device
>
>  extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
>
> +extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
> +extern int drmSyncobjDestroy(int fd, uint32_t handle);
> +extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
> +extern int drmSyncobjF

  1   2   >