[PATCH] drm/amd/pm: remove duplicate include in 'arcturus_ppt.c'

2022-01-27 Thread cgel . zte
From: Changcheng Deng 

'amdgpu_dpm.h' included in 'arcturus_ppt.c' is duplicated.

Reported-by: Zeal Robot 
Signed-off-by: Changcheng Deng 
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
index ee296441c5bc..709c32063ef7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
@@ -46,7 +46,6 @@
 #include 
 #include "amdgpu_ras.h"
 #include "smu_cmn.h"
-#include "amdgpu_dpm.h"

 /*
  * DO NOT use these for err/warn/info/debug messages.
--
2.25.1



Re: [PATCH 2/5] staging: fbtft: Deduplicate driver registration macros

2022-01-27 Thread Greg Kroah-Hartman
On Thu, Jan 27, 2022 at 10:36:07PM +0100, Uwe Kleine-König wrote:
> Hello Greg,
> 
> On Sun, Jan 23, 2022 at 06:51:58PM +0100, Uwe Kleine-König wrote:
> > The two macros FBTFT_REGISTER_DRIVER and FBTFT_REGISTER_SPI_DRIVER
> > contain quite some duplication: Both define an spi driver and an of device
> > table and the differences are quite subtle.
> > 
> > So create two new macros and use both twice.
> > 
> > Link: 
> > https://lore.kernel.org/r/20220118181338.207943-2-u.kleine-koe...@pengutronix.de
> > Signed-off-by: Uwe Kleine-König 
> 
> You picked this patch into your staging-next branch, I guess from the
> original submission. Not sure how Mark wants to continue with the series
> from this thread, but at least my plan was that he will create an
> immutable branch on top of 5.17-rc2 (assuming 5.17-rc2 will contain
> "staging: fbtft: Fix error path in fbtft_driver_module_init()") with the
> remaining 4 patches in this series.

That's fine, I can pull from that.

> In a private mail you agreed to this procedure, but this didn't stop you
> taking this patch?! What is your plan here? The obvious (to me) options
> are:
> 
>  - Delay this series until after the next merge window.
>  - You back out this patch from staging-next and ack here for Mark to
>apply it to an immutable branch.
>  - You keep this patch in staging-next and still ack here for Mark to
>apply it to an immutable branch. Then the patch would be included
>twice.

Included twice is fine, or I can revert it in the staging tree.

Don't let staging tree issues prevent you from doing real work in the
other part of the kernel, I can manage merges and other issues like this
very easily.

thanks,

greg k-h


Re: [PATCH v4 00/10] Add MEMORY_DEVICE_COHERENT for coherent device memory mapping

2022-01-27 Thread Andrew Morton
On Thu, 27 Jan 2022 17:20:40 -0600 "Sierra Guiza, Alejandro (Alex)" 
 wrote:

> Andrew,
> We're somehow new on this procedure. Are you referring to rebase this 
> patch series to
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
> <5.17-rc1 tag>?

No, against current Linus mainline, please.


[PATCH] drm/amdgpu: remove duplicate include in 'amdgpu_device.c'

2022-01-27 Thread cgel . zte
From: Changcheng Deng 

'linux/pci.h' included in 'amdgpu_device.c' is duplicated.

Reported-by: Zeal Robot 
Signed-off-by: Changcheng Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index dd5979098e63..289c5c626324 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -56,7 +56,6 @@
 #include "soc15.h"
 #include "nv.h"
 #include "bif/bif_4_1_d.h"
-#include 
 #include 
 #include "amdgpu_vf_error.h"

--
2.25.1



Re: [RFC PATCH 2/2] drm/mediatek: add mtk8195 hdmi display driver

2022-01-27 Thread CK Hu
Hi, Guillaume:

On Mon, 2021-11-08 at 01:08 +0100, Guillaume Ranquet wrote:
> Signed-off-by: Guillaume Ranquet 
> Change-Id: I6399dec26cfe56a338c2ca96989cb7cbd14e292b
> ---
>  drivers/gpu/drm/mediatek/Kconfig  |9 +
>  drivers/gpu/drm/mediatek/Makefile |2 +
>  drivers/gpu/drm/mediatek/mtk_hdmi_common.c|  219 +-
>  drivers/gpu/drm/mediatek/mtk_hdmi_common.h|   24 +-
>  drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c| 1835
> +
>  drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.h|   26 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.c|  530 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.h|   20 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_regs.h   |  329 +++
>  9 files changed, 2932 insertions(+), 62 deletions(-)
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_regs.h
> 
> diff --git a/drivers/gpu/drm/mediatek/Kconfig
> b/drivers/gpu/drm/mediatek/Kconfig
> index 0df75bceb74e..76cc402cbd75 100644
> --- a/drivers/gpu/drm/mediatek/Kconfig
> +++ b/drivers/gpu/drm/mediatek/Kconfig
> @@ -31,3 +31,12 @@ config DRM_MEDIATEK_HDMI
>   help
> DRM/KMS HDMI driver for Mediatek SoCs

[snip]

> +
> +static int mtk_hdmi_ddc_xfer(struct i2c_adapter *adapter, struct
> i2c_msg *msgs,
> +  int num)
> +{
> + struct mtk_hdmi_ddc *ddc = adapter->algo_data;
> + struct device *dev = adapter->dev.parent;
> + int ret;
> + int i;
> +
> + if (!ddc)
> + return -EINVAL;
> +
> + for (i = 0; i < num; i++) {
> + struct i2c_msg *msg = [i];
> +
> + if (msg->flags & I2C_M_RD)
> + ret = fg_ddc_data_read(ddc, msg->addr, msg-
> >buf[0],
> + (msg->len), >buf[0]);
> + else
> + ret = fg_ddc_data_write(ddc, msg->addr, msg-
> >buf[0],
> +  (msg->len - 1), 
> >buf[1]);

Why do you use msg->buf[1]? In mt8173 hdmi ddc driver,
mtk_hdmi_ddc_write_msg() just use msg->buf[0]. If using msg->buf[1] is
advance function, separate this advance function to another patch.

Regards,
CK

> +
> + if (ret <= 0)
> + goto xfer_end;
> + }
> +
> + return i;
> +
> +xfer_end:
> + dev_err(dev, "ddc failed! : %d\n", ret);
> + return ret;
> +}
> +



Re: [PATCH] drm/exynos: Search for TE-gpio in DSI panel's node

2022-01-27 Thread Inki Dae
Hi,

22. 1. 25. 00:22에 Henrik Grimler 이(가) 쓴 글:
> Hi Marek,
> 
> On Mon, Jan 24, 2022 at 02:52:46PM +0100, Marek Szyprowski wrote:
>> TE-gpio, if defined, is placed in the panel's node, not the parent DSI
>> node. Change the devm_gpiod_get_optional() to gpiod_get_optional() and
>> pass proper device node to it. The code already has a proper cleanup
>> path, so it looks that the devm_* variant has been applied assidentally
>  
> Small observation: the spelling above should probably be"accidentally".
> 

I can fix it. Thanks.

>> during the conversion to gpiod API.
> 
> Best regards,
> Henrik Grimler
> 


[RFC PATCH v6 3/3] drm: remove allow_fb_modifiers

2022-01-27 Thread Tomohito Esaki
The allow_fb_modifiers flag is unnecessary since it has been replaced
with fb_modifiers_not_supported flag.

v3:
 - change the order as follows:
   1. add fb_modifiers_not_supported flag
   2. add default modifiers
   3. remove allow_fb_modifiers flag

v5:
 - keep a sanity check in plane init func

Signed-off-by: Tomohito Esaki 
Reviewed-by: Andy Shevchenko 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/selftests/test-drm_framebuffer.c |  1 -
 include/drm/drm_mode_config.h| 16 
 2 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c 
b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
index 61b44d3a6a61..f6d66285c5fc 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
@@ -323,7 +323,6 @@ static struct drm_device mock_drm_device = {
.max_width = MAX_WIDTH,
.min_height = MIN_HEIGHT,
.max_height = MAX_HEIGHT,
-   .allow_fb_modifiers = true,
.funcs = _config_funcs,
},
 };
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 4a93dac91cf9..6b5e01295348 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -917,22 +917,6 @@ struct drm_mode_config {
 */
bool async_page_flip;
 
-   /**
-* @allow_fb_modifiers:
-*
-* Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
-* Note that drivers should not set this directly, it is automatically
-* set in drm_universal_plane_init().
-*
-* IMPORTANT:
-*
-* If this is set the driver must fill out the full implicit modifier
-* information in their _mode_config_funcs.fb_create hook for legacy
-* userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
-* broken for modifier aware userspace.
-*/
-   bool allow_fb_modifiers;
-
/**
 * @fb_modifiers_not_supported:
 *
-- 
2.25.1



[RFC PATCH v6 2/3] drm: add support modifiers for drivers whose planes only support linear layout

2022-01-27 Thread Tomohito Esaki
The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers.

v2:
 - rebase to the latest master branch (5.16.0+)
+ "drm/plane: Make format_mod_supported truly optional" patch [1]
   [1] https://patchwork.freedesktop.org/patch/467940/?series=98255=3

v3:
 - change the order as follows:
   1. add fb_modifiers_not_supported flag
   2. add default modifiers
   3. remove allow_fb_modifiers flag

v5:
 - change default_modifiers array from non-static to static
 - remove terminator in default_modifiers array
 - use ARRAY_SIZE to get the format_modifier_count
 - update sanity check in plane init func to use the
   fb_modifiers_not_supported
 - modify kernel docs

Signed-off-by: Tomohito Esaki 
Reviewed-by: Andy Shevchenko 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/drm_plane.c | 23 +--
 include/drm/drm_plane.h |  3 +++
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index deeec60a3315..bf0daa8d9bbd 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -237,6 +237,9 @@ static int __drm_universal_plane_init(struct drm_device 
*dev,
  const char *name, va_list ap)
 {
struct drm_mode_config *config = >mode_config;
+   static const uint64_t default_modifiers[] = {
+   DRM_FORMAT_MOD_LINEAR,
+   };
unsigned int format_modifier_count = 0;
int ret;
 
@@ -277,16 +280,16 @@ static int __drm_universal_plane_init(struct drm_device 
*dev,
 
while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
format_modifier_count++;
+   } else {
+   if (!dev->mode_config.fb_modifiers_not_supported) {
+   format_modifiers = default_modifiers;
+   format_modifier_count = ARRAY_SIZE(default_modifiers);
+   }
}
 
/* autoset the cap and check for consistency across all planes */
-   if (format_modifier_count) {
-   drm_WARN_ON(dev, !config->allow_fb_modifiers &&
-   !list_empty(>plane_list));
-   config->allow_fb_modifiers = true;
-   } else {
-   drm_WARN_ON(dev, config->allow_fb_modifiers);
-   }
+   drm_WARN_ON(dev, config->fb_modifiers_not_supported &&
+   format_modifier_count);
 
plane->modifier_count = format_modifier_count;
plane->modifiers = kmalloc_array(format_modifier_count,
@@ -341,7 +344,7 @@ static int __drm_universal_plane_init(struct drm_device 
*dev,
drm_object_attach_property(>base, config->prop_src_h, 0);
}
 
-   if (config->allow_fb_modifiers)
+   if (format_modifier_count)
create_in_format_blob(dev, plane);
 
return 0;
@@ -368,8 +371,8 @@ static int __drm_universal_plane_init(struct drm_device 
*dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
- * Drivers supporting modifiers must set @format_modifiers on all their planes,
- * even those that only support DRM_FORMAT_MOD_LINEAR.
+ * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
+ * @format_modifiers to NULL. The plane will advertise the linear modifier.
  *
  * Returns:
  * Zero on success, error code on failure.
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 0c1102dc4d88..a0390b6ad3b4 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
  *
  * The @drm_plane_funcs.destroy hook must be NULL.
  *
+ * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
+ * @format_modifiers to NULL. The plane will advertise the linear modifier.
+ *
  * Returns:
  * Pointer to new plane, or ERR_PTR on failure.
  */
-- 
2.25.1



[RFC PATCH v6 0/3] Add support modifiers for drivers whose planes only support linear layout

2022-01-27 Thread Tomohito Esaki
Some drivers whose planes only support linear layout fb do not support format
modifiers.
These drivers should support modifiers, however the DRM core should handle this
rather than open-coding in every driver.

In this patch series, these drivers expose format modifiers based on the
following suggestion[1].

On Thu, Nov 18, 2021 at 01:02:11PM +, Daniel Stone wrote:
> I think the best way forward here is:
>   - add a new mode_config.cannot_support_modifiers flag, and enable
> this in radeon (plus any other drivers in the same boat)
>   - change drm_universal_plane_init() to advertise the LINEAR modifier
> when NULL is passed as the modifier list (including installing a
> default .format_mod_supported hook)
>   - remove the mode_config.allow_fb_modifiers hook and always
> advertise modifier support, unless
> mode_config.cannot_support_modifiers is set


[1] 
https://patchwork.kernel.org/project/linux-renesas-soc/patch/20190509054518.10781-1-e...@igel.co.jp/#24602575

v6:
* add Reviewed-by and Acked-by
* add a changelog per-patch

v5: https://www.spinics.net/lists/dri-devel/msg330860.html
* rebase to the latest master branch (5.17-rc1+)
+ "drm/plane: Make format_mod_supported truly optional" patch [2]
  [2] https://patchwork.freedesktop.org/patch/467940/?series=98255=3

* change default_modifiers array from non-static to static
* remove terminator in default_modifiers array
* use ARRAY_SIZE to get the format_modifier_count
* keep a sanity check in plane init func
* modify several kerneldocs

v4: https://www.spinics.net/lists/dri-devel/msg329508.html
* modify documentation for fb_modifiers_not_supported flag in kerneldoc

v3: https://www.spinics.net/lists/dri-devel/msg329102.html
* change the order as follows:
   1. add fb_modifiers_not_supported flag
   2. add default modifiers
   3. remove allow_fb_modifiers flag
* add a conditional disable in amdgpu_dm_plane_init()

v2: https://www.spinics.net/lists/dri-devel/msg328939.html
* rebase to the latest master branch (5.16.0+)
  + "drm/plane: Make format_mod_supported truly optional" patch [2]

v1: https://www.spinics.net/lists/dri-devel/msg327352.html
* The initial patch set

Tomohito Esaki (3):
  drm: introduce fb_modifiers_not_supported flag in mode_config
  drm: add support modifiers for drivers whose planes only support
linear layout
  drm: remove allow_fb_modifiers

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 ++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  2 ++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  3 +++
 drivers/gpu/drm/drm_framebuffer.c |  6 ++---
 drivers/gpu/drm/drm_ioctl.c   |  2 +-
 drivers/gpu/drm/drm_plane.c   | 23 +++
 drivers/gpu/drm/nouveau/nouveau_display.c |  6 +++--
 drivers/gpu/drm/radeon/radeon_display.c   |  2 ++
 .../gpu/drm/selftests/test-drm_framebuffer.c  |  1 -
 include/drm/drm_mode_config.h | 18 +--
 include/drm/drm_plane.h   |  3 +++
 14 files changed, 45 insertions(+), 32 deletions(-)

-- 
2.25.1



[RFC PATCH v6 1/3] drm: introduce fb_modifiers_not_supported flag in mode_config

2022-01-27 Thread Tomohito Esaki
If only linear modifier is advertised, since there are many drivers that
only linear supported, the DRM core should handle this rather than
open-coding in every driver. However, there are legacy drivers such as
radeon that do not support modifiers but infer the actual layout of the
underlying buffer. Therefore, a new flag fb_modifiers_not_supported is
introduced for these legacy drivers, and allow_fb_modifiers is replaced
with this new flag.

v3:
 - change the order as follows:
   1. add fb_modifiers_not_supported flag
   2. add default modifiers
   3. remove allow_fb_modifiers flag
 - add a conditional disable in amdgpu_dm_plane_init()

v4:
 - modify kernel docs

v5:
 - modify kernel docs

Signed-off-by: Tomohito Esaki 
Acked-by: Harry Wentland 
Reviewed-by: Andy Shevchenko 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c|  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c|  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c |  2 ++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  3 +++
 drivers/gpu/drm/drm_framebuffer.c |  6 +++---
 drivers/gpu/drm/drm_ioctl.c   |  2 +-
 drivers/gpu/drm/nouveau/nouveau_display.c |  6 --
 drivers/gpu/drm/radeon/radeon_display.c   |  2 ++
 include/drm/drm_mode_config.h | 10 ++
 11 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 82011e75ed85..edbb30d47b8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -954,7 +954,7 @@ static int amdgpu_display_verify_sizes(struct 
amdgpu_framebuffer *rfb)
int ret;
unsigned int i, block_width, block_height, block_size_log2;
 
-   if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+   if (rfb->base.dev->mode_config.fb_modifiers_not_supported)
return 0;
 
for (i = 0; i < format_info->num_planes; ++i) {
@@ -1141,7 +1141,7 @@ int amdgpu_display_framebuffer_init(struct drm_device 
*dev,
if (ret)
return ret;
 
-   if (!dev->mode_config.allow_fb_modifiers) {
+   if (dev->mode_config.fb_modifiers_not_supported) {
drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
  "GFX9+ requires FB check based on format 
modifier\n");
ret = check_tiling_flags_gfx6(rfb);
@@ -1149,7 +1149,7 @@ int amdgpu_display_framebuffer_init(struct drm_device 
*dev,
return ret;
}
 
-   if (dev->mode_config.allow_fb_modifiers &&
+   if (!dev->mode_config.fb_modifiers_not_supported &&
!(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
ret = convert_tiling_flags_to_modifier(rfb);
if (ret) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index d1570a462a51..fb61c0814115 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2798,6 +2798,8 @@ static int dce_v10_0_sw_init(void *handle)
adev_to_drm(adev)->mode_config.preferred_depth = 24;
adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+   adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 18a7b3bd633b..17942a11366d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2916,6 +2916,8 @@ static int dce_v11_0_sw_init(void *handle)
adev_to_drm(adev)->mode_config.preferred_depth = 24;
adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+   adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c7803dc2b2d5..2ec99ec8e1a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2674,6 +2674,7 @@ static int dce_v6_0_sw_init(void *handle)
adev_to_drm(adev)->mode_config.max_height = 16384;
adev_to_drm(adev)->mode_config.preferred_depth = 24;
adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+   adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c

[git pull] drm fixes for 5.17-rc2

2022-01-27 Thread Dave Airlie
Hi Linus,

This week's regular normal fixes. amdgpu and msm make up the bulk of
it, with a scattering of fixes elsewhere.

Dave.

drm-fixes-2022-01-28:
drm fixes for 5.17-rc2

atomic:
- fix CRTC handling during modeset

privacy-screen:
- honor acpi=off

ttm:
- build fix for um

panel:
- add orientation quirk for 1NetBook OneXPlayer

amdgpu:
- Proper fix for otg synchronization logic regression
- DCN3.01 fixes
- Filter out secondary radeon PCI IDs
- udelay fixes
- Fix a memory leak in an error path

msm:
- parameter check fixes
- put_device balancing
- idle/suspend fixes

etnaviv:
- relax submit size checks

vc4:
- fix potential deadlock in DSI code

ast:
- revert 1600x900 mode change
The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07:

  Linux 5.17-rc1 (2022-01-23 10:12:53 +0200)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm tags/drm-fixes-2022-01-28

for you to fetch changes up to db5aa1497d02e7770e40dd0d1bfcb4ea0b0d3906:

  Merge tag 'amd-drm-fixes-5.17-2022-01-26' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes (2022-01-28
14:59:44 +1000)


drm fixes for 5.17-rc2

atomic:
- fix CRTC handling during modeset

privcy-screen:
- honor acpi=off

ttm:
- build fix for um

panel:
- add oreientation quirk for 1NetBook OneXPlayer

amdgpu:
- Proper fix for otg synchronization logic regression
- DCN3.01 fixes
- Filter out secondary radeon PCI IDs
- udelay fixes
- Fix a memory leak in an error path

msm:
- parameter check fixes
- put_device balancing
- idle/suspend fixes

etnaviv:
- relax submit size checks

vc4:
- fix potential deadlock in DSI code

ast:
- revert 1600x900 mode change


Alex Deucher (3):
  drm/amdgpu: filter out radeon secondary ids as well
  drm/amdgpu/display: adjust msleep limit in
dp_wait_for_training_aux_rd_interval
  drm/amdgpu/display: use msleep rather than udelay for long delays

Bas Nieuwenhuizen (3):
  drm/amd/display: Fix FP start/end for dcn30_internal_validate_bw.
  drm/amd/display: Wrap dcn301_calculate_wm_and_dlg for FPU.
  drm/amdgpu/display: Remove t_srx_delay_us.

Dave Airlie (6):
  Revert "drm/ast: Support 1600x900 with 108MHz PCLK"
  Merge tag 'drm-misc-next-fixes-2022-01-21' of
git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
  Merge tag 'drm-misc-fixes-2022-01-27' of
git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
  Merge tag 'drm-msm-fixes-2022-01-25' of
https://gitlab.freedesktop.org/drm/msm into drm-fixes
  Merge branch 'etnaviv/fixes' of
https://git.pengutronix.de/git/lst/linux into drm-fixes
  Merge tag 'amd-drm-fixes-5.17-2022-01-26' of
https://gitlab.freedesktop.org/agd5f/linux into drm-fixes

José Expósito (2):
  drm/msm/dpu: invalid parameter check in dpu_setup_dspp_pcc
  drm/msm/dsi: invalid parameter check in msm_dsi_phy_enable

Lucas Stach (1):
  drm/etnaviv: relax submit size limits

Manasi Navare (1):
  drm/atomic: Add the crtc to affected crtc only if uapi.enable = true

Meenakshikumar Somasundaram (1):
  drm/amd/display: Fix for otg synchronization logic

Miaoqian Lin (2):
  drm/msm/dsi: Fix missing put_device() call in dsi_get_phy
  drm/msm/hdmi: Fix missing put_device() call in msm_hdmi_get_phy

Padmanabha Srinivasaiah (1):
  drm/vc4: Fix deadlock on DSI device attach error

Raymond Jay Golo (1):
  drm: panel-orientation-quirks: Add quirk for the 1Netbook OneXPlayer

Rob Clark (3):
  drm/msm/a6xx: Add missing suspend_count increment
  drm/msm/gpu: Wait for idle before suspending
  drm/msm/gpu: Cancel idle/boost work on suspend

Thomas Zimmermann (1):
  Merge drm/drm-fixes into drm-misc-fixes

Tong Zhang (1):
  drm/privacy-screen: honor acpi=off in detect_thinkpad_privacy_screen

Xianting Tian (1):
  drm/msm: Fix wrong size calculation

Yang Li (1):
  drm/msm: remove variable set but not used

Zhan Liu (2):
  drm/amd/display: Correct MPC split policy for DCN301
  drm/amd/display: change FIFO reset condition to embedded display only

Zhou Qingyang (1):
  drm/amd/display/dc/calcs/dce_calcs: Fix a memleak in calculate_bandwidth()

 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 81 ++
 drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c   |  4 +-
 drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c   |  1 -
 drivers/gpu/drm/amd/display/dc/core/dc.c   | 40 +++
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c   |  6 +-
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c  | 54 +++
 drivers/gpu/drm/amd/display/dc/dc.h|  1 +
 .../amd/display/dc/dce110/dce110_hw_sequencer.c| 10 ++-
 .../gpu/drm/amd/display/dc/dcn30/dcn30_resource.c  |  4 +-
 .../drm/amd/display/dc/dcn301/dcn301_resource.c| 13 +++-
 .../gpu/drm/amd/display/dc/dcn31/dcn31_resource.c  |  3 +
 

Re: [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API

2022-01-27 Thread kernel test robot
Hi Zhi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20220127]
[cannot apply to drm-intel/for-linux-next hch-configfs/for-next v5.17-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-rhel-8.3-kselftests 
(https://download.01.org/0day-ci/archive/20220128/202201281209.mnhckgpp-...@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# 
https://github.com/0day-ci/linux/commit/533f92651a7a56481a053f1e04dc5a5ec024ffb9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
git checkout 533f92651a7a56481a053f1e04dc5a5ec024ffb9
# save the config file to linux build tree
mkdir build_dir
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir 
ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/i915/gvt/handlers.c:45:6: sparse: sparse: symbol 
>> 'intel_gvt_match_device' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [v1,2/3] drm/mediatek: Add mt8186 dsi compatible to mtk_dsi.c

2022-01-27 Thread CK Hu
Hi, Xinlei:

On Thu, 2022-01-27 at 19:42 +0800, xinlei@mediatek.com wrote:
> From: xinlei lee 
> 
> Add the compatible of mt8186-dsi because we use different cmdq
> addresses in mt8186.

Reviewed-by: CK Hu 

> 
> Signed-off-by: Xinlei Lee 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index e91b3ff..62af60d 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -1151,6 +1151,12 @@ static const struct mtk_dsi_driver_data
> mt8183_dsi_driver_data = {
>   .has_size_ctl = true,
>  };
>  
> +static const struct mtk_dsi_driver_data mt8186_dsi_driver_data = {
> + .reg_cmdq_off = 0xd00,
> + .has_shadow_ctl = true,
> + .has_size_ctl = true,
> +};
> +
>  static const struct of_device_id mtk_dsi_of_match[] = {
>   { .compatible = "mediatek,mt2701-dsi",
> .data = _dsi_driver_data },
> @@ -1158,6 +1164,8 @@ static const struct of_device_id
> mtk_dsi_of_match[] = {
> .data = _dsi_driver_data },
>   { .compatible = "mediatek,mt8183-dsi",
> .data = _dsi_driver_data },
> + { .compatible = "mediatek,mt8186-dsi",
> +   .data = _dsi_driver_data },
>   { },
>  };
>  MODULE_DEVICE_TABLE(of, mtk_dsi_of_match);



Re: [v1, 1/3] dt-bindings: display: mediatek: dsi: add documentation for MT8186 SoC

2022-01-27 Thread CK Hu
Hi, Xinlei:

On Thu, 2022-01-27 at 19:42 +0800, xinlei@mediatek.com wrote:
> From: xinlei lee 
> 
> Add binding documentation for the MT8186 SoC.

DPI has a yaml format document, so I would like DSI also has a yaml
format document.
Please send a patch to transfer DSI document to yaml, and then apply
this patch to yaml document.

Regards,
CK

> 
> Signed-off-by: Xinlei Lee 
> ---
>  Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git
> a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> index 36b0145..c82b8b2 100644
> ---
> a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> +++
> b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> @@ -7,7 +7,7 @@ channel output.
>  
>  Required properties:
>  - compatible: "mediatek,-dsi"
> -- the supported chips are mt2701, mt7623, mt8167, mt8173 and mt8183.
> +- the supported chips are mt2701, mt7623, mt8167, mt8173, mt8183 and
> mt8186.
>  - reg: Physical base address and length of the controller's
> registers
>  - interrupts: The interrupt signal from the function block.
>  - clocks: device clocks



Re: [v1, 3/3] drm/mediatek: Move the getting bridge node function to mtk_dsi_bind

2022-01-27 Thread CK Hu
Hi, Xinlei:

On Thu, 2022-01-27 at 19:42 +0800, xinlei@mediatek.com wrote:
> From: xinlei lee 
> 
> The order of probe function for bridge drivers and dsi drivers is
> uncertain.
> To avoid the dsi probe cannot be executed, we place getting bridge
> node function in
> mtk_dsi_bind.

It seems this patch want to fix the same problem as [1]. Does [1] fix
your problem? If so, let's ignore this patch.

[1] 
https://patchwork.kernel.org/project/linux-mediatek/patch/20220127143623.123025-1-angelogioacchino.delre...@collabora.com/

Regards,
CK

> 
> Signed-off-by:Xinlei Lee 
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 29 +++-
> -
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 62af60d..a390f26 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -991,6 +991,21 @@ static int mtk_dsi_bind(struct device *dev,
> struct device *master, void *data)
>   int ret;
>   struct drm_device *drm = data;
>   struct mtk_dsi *dsi = dev_get_drvdata(dev);
> + struct drm_panel *panel;
> +
> + ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> +   , >next_bridge);
> + if (ret)
> + return ret;
> +
> + if (panel) {
> + dsi->next_bridge = devm_drm_panel_bridge_add(dev,
> panel);
> + if (IS_ERR(dsi->next_bridge)) {
> + ret = PTR_ERR(dsi->next_bridge);
> + dev_err(dev, "failed to add bridge: %d\n",
> ret);
> + return ret;
> + }
> + }
>  
>   ret = mtk_dsi_encoder_init(drm, dsi);
>   if (ret)
> @@ -1016,7 +1031,6 @@ static int mtk_dsi_probe(struct platform_device
> *pdev)
>  {
>   struct mtk_dsi *dsi;
>   struct device *dev = >dev;
> - struct drm_panel *panel;
>   struct resource *regs;
>   int irq_num;
>   int ret;
> @@ -1033,19 +1047,6 @@ static int mtk_dsi_probe(struct
> platform_device *pdev)
>   return ret;
>   }
>  
> - ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> -   , >next_bridge);
> - if (ret)
> - goto err_unregister_host;
> -
> - if (panel) {
> - dsi->next_bridge = devm_drm_panel_bridge_add(dev,
> panel);
> - if (IS_ERR(dsi->next_bridge)) {
> - ret = PTR_ERR(dsi->next_bridge);
> - goto err_unregister_host;
> - }
> - }
> -
>   dsi->driver_data = of_device_get_match_data(dev);
>  
>   dsi->engine_clk = devm_clk_get(dev, "engine");



[RFC PATCH] i915/gvt: intel_gvt_match_device() can be static

2022-01-27 Thread kernel test robot
drivers/gpu/drm/i915/gvt/handlers.c:45:6: warning: symbol 
'intel_gvt_match_device' was not declared. Should it be static?

Reported-by: kernel test robot 
Signed-off-by: kernel test robot 
---
 handlers.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gvt/handlers.c 
b/drivers/gpu/drm/i915/gvt/handlers.c
index dad31ad074a03..459f0d902f64f 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -42,7 +42,7 @@
 #include "display/intel_display_types.h"
 #include "display/intel_fbc.h"
 
-bool intel_gvt_match_device(struct intel_gvt *gvt,
+static bool intel_gvt_match_device(struct intel_gvt *gvt,
unsigned long device)
 {
return intel_gvt_get_device_type(gvt->gt->i915) & device;


Re: [PATCH v4 08/10] lib: add support for device coherent type in test_hmm

2022-01-27 Thread Alistair Popple
I haven't tested the change which checks that pages migrated back to sysmem,
but it looks ok so:

Reviewed-by: Alistair Popple 

On Thursday, 27 January 2022 2:09:47 PM AEDT Alex Sierra wrote:
> Device Coherent type uses device memory that is coherently accesible by
> the CPU. This could be shown as SP (special purpose) memory range
> at the BIOS-e820 memory enumeration. If no SP memory is supported in
> system, this could be faked by setting CONFIG_EFI_FAKE_MEMMAP.
> 
> Currently, test_hmm only supports two different SP ranges of at least
> 256MB size. This could be specified in the kernel parameter variable
> efi_fake_mem. Ex. Two SP ranges of 1GB starting at 0x1 &
> 0x14000 physical address. Ex.
> efi_fake_mem=1G@0x1:0x4,1G@0x14000:0x4
> 
> Private and coherent device mirror instances can be created in the same
> probed. This is done by passing the module parameters spm_addr_dev0 &
> spm_addr_dev1. In this case, it will create four instances of
> device_mirror. The first two correspond to private device type, the
> last two to coherent type. Then, they can be easily accessed from user
> space through /dev/hmm_mirror. Usually num_device 0 and 1
> are for private, and 2 and 3 for coherent types. If no module
> parameters are passed, two instances of private type device_mirror will
> be created only.
> 
> Signed-off-by: Alex Sierra 
> ---
> v4:
> Return number of coherent device pages successfully migrated to system.
> This is returned at cmd->cpages.
> ---
>  lib/test_hmm.c  | 260 +---
>  lib/test_hmm_uapi.h |  15 ++-
>  2 files changed, 205 insertions(+), 70 deletions(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 6f068f7c4ee3..850d5331e370 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -29,11 +29,22 @@
>  
>  #include "test_hmm_uapi.h"
>  
> -#define DMIRROR_NDEVICES 2
> +#define DMIRROR_NDEVICES 4
>  #define DMIRROR_RANGE_FAULT_TIMEOUT  1000
>  #define DEVMEM_CHUNK_SIZE(256 * 1024 * 1024U)
>  #define DEVMEM_CHUNKS_RESERVE16
>  
> +/*
> + * For device_private pages, dpage is just a dummy struct page
> + * representing a piece of device memory. dmirror_devmem_alloc_page
> + * allocates a real system memory page as backing storage to fake a
> + * real device. zone_device_data points to that backing page. But
> + * for device_coherent memory, the struct page represents real
> + * physical CPU-accessible memory that we can use directly.
> + */
> +#define BACKING_PAGE(page) (is_device_private_page((page)) ? \
> +(page)->zone_device_data : (page))
> +
>  static unsigned long spm_addr_dev0;
>  module_param(spm_addr_dev0, long, 0644);
>  MODULE_PARM_DESC(spm_addr_dev0,
> @@ -122,6 +133,21 @@ static int dmirror_bounce_init(struct dmirror_bounce 
> *bounce,
>   return 0;
>  }
>  
> +static bool dmirror_is_private_zone(struct dmirror_device *mdevice)
> +{
> + return (mdevice->zone_device_type ==
> + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE) ? true : false;
> +}
> +
> +static enum migrate_vma_direction
> + dmirror_select_device(struct dmirror *dmirror)
> +{
> + return (dmirror->mdevice->zone_device_type ==
> + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE) ?
> + MIGRATE_VMA_SELECT_DEVICE_PRIVATE :
> + MIGRATE_VMA_SELECT_DEVICE_COHERENT;
> +}
> +
>  static void dmirror_bounce_fini(struct dmirror_bounce *bounce)
>  {
>   vfree(bounce->ptr);
> @@ -572,16 +598,19 @@ static int dmirror_allocate_chunk(struct dmirror_device 
> *mdevice,
>  static struct page *dmirror_devmem_alloc_page(struct dmirror_device *mdevice)
>  {
>   struct page *dpage = NULL;
> - struct page *rpage;
> + struct page *rpage = NULL;
>  
>   /*
> -  * This is a fake device so we alloc real system memory to store
> -  * our device memory.
> +  * For ZONE_DEVICE private type, this is a fake device so we alloc real
> +  * system memory to store our device memory.
> +  * For ZONE_DEVICE coherent type we use the actual dpage to store the 
> data
> +  * and ignore rpage.
>*/
> - rpage = alloc_page(GFP_HIGHUSER);
> - if (!rpage)
> - return NULL;
> -
> + if (dmirror_is_private_zone(mdevice)) {
> + rpage = alloc_page(GFP_HIGHUSER);
> + if (!rpage)
> + return NULL;
> + }
>   spin_lock(>lock);
>  
>   if (mdevice->free_pages) {
> @@ -601,7 +630,8 @@ static struct page *dmirror_devmem_alloc_page(struct 
> dmirror_device *mdevice)
>   return dpage;
>  
>  error:
> - __free_page(rpage);
> + if (rpage)
> + __free_page(rpage);
>   return NULL;
>  }
>  
> @@ -627,12 +657,16 @@ static void dmirror_migrate_alloc_and_copy(struct 
> migrate_vma *args,
>* unallocated pte_none() or read-only zero page.
>*/
>   spage = migrate_pfn_to_page(*src);
> +   

Re: [PATCH v4 07/10] lib: test_hmm add module param for zone device type

2022-01-27 Thread Alistair Popple
Thanks for the updates, looks good now.

Reviewed-by: Alistair Popple 

On Thursday, 27 January 2022 2:09:46 PM AEDT Alex Sierra wrote:
> In order to configure device coherent in test_hmm, two module parameters
> should be passed, which correspond to the SP start address of each
> device (2) spm_addr_dev0 & spm_addr_dev1. If no parameters are passed,
> private device type is configured.
> 
> Signed-off-by: Alex Sierra 
> ---
>  lib/test_hmm.c  | 73 -
>  lib/test_hmm_uapi.h |  1 +
>  2 files changed, 53 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index fb1fa7c6fa98..6f068f7c4ee3 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -34,6 +34,16 @@
>  #define DEVMEM_CHUNK_SIZE(256 * 1024 * 1024U)
>  #define DEVMEM_CHUNKS_RESERVE16
>  
> +static unsigned long spm_addr_dev0;
> +module_param(spm_addr_dev0, long, 0644);
> +MODULE_PARM_DESC(spm_addr_dev0,
> + "Specify start address for SPM (special purpose memory) used 
> for device 0. By setting this Coherent device type will be used. Make sure 
> spm_addr_dev1 is set too. Minimum SPM size should be DEVMEM_CHUNK_SIZE.");
> +
> +static unsigned long spm_addr_dev1;
> +module_param(spm_addr_dev1, long, 0644);
> +MODULE_PARM_DESC(spm_addr_dev1,
> + "Specify start address for SPM (special purpose memory) used 
> for device 1. By setting this Coherent device type will be used. Make sure 
> spm_addr_dev0 is set too. Minimum SPM size should be DEVMEM_CHUNK_SIZE.");
> +
>  static const struct dev_pagemap_ops dmirror_devmem_ops;
>  static const struct mmu_interval_notifier_ops dmirror_min_ops;
>  static dev_t dmirror_dev;
> @@ -452,28 +462,44 @@ static int dmirror_write(struct dmirror *dmirror, 
> struct hmm_dmirror_cmd *cmd)
>   return ret;
>  }
>  
> -static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
> +static int dmirror_allocate_chunk(struct dmirror_device *mdevice,
>  struct page **ppage)
>  {
>   struct dmirror_chunk *devmem;
> - struct resource *res;
> + struct resource *res = NULL;
>   unsigned long pfn;
>   unsigned long pfn_first;
>   unsigned long pfn_last;
>   void *ptr;
> + int ret = -ENOMEM;
>  
>   devmem = kzalloc(sizeof(*devmem), GFP_KERNEL);
>   if (!devmem)
> - return false;
> + return ret;
>  
> - res = request_free_mem_region(_resource, DEVMEM_CHUNK_SIZE,
> -   "hmm_dmirror");
> - if (IS_ERR(res))
> + switch (mdevice->zone_device_type) {
> + case HMM_DMIRROR_MEMORY_DEVICE_PRIVATE:
> + res = request_free_mem_region(_resource, 
> DEVMEM_CHUNK_SIZE,
> +   "hmm_dmirror");
> + if (IS_ERR_OR_NULL(res))
> + goto err_devmem;
> + devmem->pagemap.range.start = res->start;
> + devmem->pagemap.range.end = res->end;
> + devmem->pagemap.type = MEMORY_DEVICE_PRIVATE;
> + break;
> + case HMM_DMIRROR_MEMORY_DEVICE_COHERENT:
> + devmem->pagemap.range.start = (MINOR(mdevice->cdevice.dev) - 2) 
> ?
> + spm_addr_dev0 :
> + spm_addr_dev1;
> + devmem->pagemap.range.end = devmem->pagemap.range.start +
> + DEVMEM_CHUNK_SIZE - 1;
> + devmem->pagemap.type = MEMORY_DEVICE_COHERENT;
> + break;
> + default:
> + ret = -EINVAL;
>   goto err_devmem;
> + }
>  
> - devmem->pagemap.type = MEMORY_DEVICE_PRIVATE;
> - devmem->pagemap.range.start = res->start;
> - devmem->pagemap.range.end = res->end;
>   devmem->pagemap.nr_range = 1;
>   devmem->pagemap.ops = _devmem_ops;
>   devmem->pagemap.owner = mdevice;
> @@ -494,10 +520,14 @@ static bool dmirror_allocate_chunk(struct 
> dmirror_device *mdevice,
>   mdevice->devmem_capacity = new_capacity;
>   mdevice->devmem_chunks = new_chunks;
>   }
> -
>   ptr = memremap_pages(>pagemap, numa_node_id());
> - if (IS_ERR(ptr))
> + if (IS_ERR_OR_NULL(ptr)) {
> + if (ptr)
> + ret = PTR_ERR(ptr);
> + else
> + ret = -EFAULT;
>   goto err_release;
> + }
>  
>   devmem->mdevice = mdevice;
>   pfn_first = devmem->pagemap.range.start >> PAGE_SHIFT;
> @@ -526,15 +556,17 @@ static bool dmirror_allocate_chunk(struct 
> dmirror_device *mdevice,
>   }
>   spin_unlock(>lock);
>  
> - return true;
> + return 0;
>  
>  err_release:
>   mutex_unlock(>devmem_lock);
> - release_mem_region(devmem->pagemap.range.start, 
> range_len(>pagemap.range));
> + if (res && devmem->pagemap.type == MEMORY_DEVICE_PRIVATE)
> + 

Re: [PATCH v4 06/10] lib: test_hmm add ioctl to get zone device type

2022-01-27 Thread Alistair Popple
Reviewed-by: Alistair Popple 

On Thursday, 27 January 2022 2:09:45 PM AEDT Alex Sierra wrote:
> new ioctl cmd added to query zone device type. This will be
> used once the test_hmm adds zone device coherent type.
> 
> Signed-off-by: Alex Sierra 
> ---
>  lib/test_hmm.c  | 23 +--
>  lib/test_hmm_uapi.h |  8 
>  2 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index c259842f6d44..fb1fa7c6fa98 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -84,6 +84,7 @@ struct dmirror_chunk {
>  struct dmirror_device {
>   struct cdev cdevice;
>   struct hmm_devmem   *devmem;
> + unsigned intzone_device_type;
>  
>   unsigned intdevmem_capacity;
>   unsigned intdevmem_count;
> @@ -1025,6 +1026,15 @@ static int dmirror_snapshot(struct dmirror *dmirror,
>   return ret;
>  }
>  
> +static int dmirror_get_device_type(struct dmirror *dmirror,
> + struct hmm_dmirror_cmd *cmd)
> +{
> + mutex_lock(>mutex);
> + cmd->zone_device_type = dmirror->mdevice->zone_device_type;
> + mutex_unlock(>mutex);
> +
> + return 0;
> +}
>  static long dmirror_fops_unlocked_ioctl(struct file *filp,
>   unsigned int command,
>   unsigned long arg)
> @@ -1075,6 +1085,9 @@ static long dmirror_fops_unlocked_ioctl(struct file 
> *filp,
>   ret = dmirror_snapshot(dmirror, );
>   break;
>  
> + case HMM_DMIRROR_GET_MEM_DEV_TYPE:
> + ret = dmirror_get_device_type(dmirror, );
> + break;
>   default:
>   return -EINVAL;
>   }
> @@ -1235,14 +1248,20 @@ static void dmirror_device_remove(struct 
> dmirror_device *mdevice)
>  static int __init hmm_dmirror_init(void)
>  {
>   int ret;
> - int id;
> + int id = 0;
> + int ndevices = 0;
>  
>   ret = alloc_chrdev_region(_dev, 0, DMIRROR_NDEVICES,
> "HMM_DMIRROR");
>   if (ret)
>   goto err_unreg;
>  
> - for (id = 0; id < DMIRROR_NDEVICES; id++) {
> + memset(dmirror_devices, 0, DMIRROR_NDEVICES * 
> sizeof(dmirror_devices[0]));
> + dmirror_devices[ndevices++].zone_device_type =
> + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE;
> + dmirror_devices[ndevices++].zone_device_type =
> + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE;
> + for (id = 0; id < ndevices; id++) {
>   ret = dmirror_device_init(dmirror_devices + id, id);
>   if (ret)
>   goto err_chrdev;
> diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h
> index f14dea5dcd06..17f842f1aa02 100644
> --- a/lib/test_hmm_uapi.h
> +++ b/lib/test_hmm_uapi.h
> @@ -19,6 +19,7 @@
>   * @npages: (in) number of pages to read/write
>   * @cpages: (out) number of pages copied
>   * @faults: (out) number of device page faults seen
> + * @zone_device_type: (out) zone device memory type
>   */
>  struct hmm_dmirror_cmd {
>   __u64   addr;
> @@ -26,6 +27,7 @@ struct hmm_dmirror_cmd {
>   __u64   npages;
>   __u64   cpages;
>   __u64   faults;
> + __u64   zone_device_type;
>  };
>  
>  /* Expose the address space of the calling process through hmm device file */
> @@ -35,6 +37,7 @@ struct hmm_dmirror_cmd {
>  #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd)
>  #define HMM_DMIRROR_EXCLUSIVE_IOWR('H', 0x04, struct 
> hmm_dmirror_cmd)
>  #define HMM_DMIRROR_CHECK_EXCLUSIVE  _IOWR('H', 0x05, struct hmm_dmirror_cmd)
> +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x06, struct hmm_dmirror_cmd)
>  
>  /*
>   * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT.
> @@ -62,4 +65,9 @@ enum {
>   HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30,
>  };
>  
> +enum {
> + /* 0 is reserved to catch uninitialized type fields */
> + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1,
> +};
> +
>  #endif /* _LIB_TEST_HMM_UAPI_H */
> 






[PATCH v2, 5/7] media: mtk-vcodec: Different codec using different capture format

2022-01-27 Thread Yunfei Dong
Vp8 need to use MM21, but vp9 and h264 need to use HyFbc mode
for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 6ad17e69e32d..f2ced0147534 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f,
return NULL;
 }
 
+static bool mtk_vdec_get_cap_fmt(struct mtk_vcodec_ctx *ctx, int format_index)
+{
+   const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
+   const struct mtk_video_fmt *fmt;
+   struct mtk_q_data *q_data;
+   int num_frame_count = 0, i;
+   bool ret = true;
+
+   for (i = 0; i < *dec_pdata->num_formats; i++) {
+   if (dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME)
+   continue;
+
+   num_frame_count++;
+   }
+
+   if (num_frame_count == 1)
+   return true;
+
+   fmt = _pdata->vdec_formats[format_index];
+   q_data = >q_data[MTK_Q_DATA_SRC];
+   switch (q_data->fmt->fourcc) {
+   case V4L2_PIX_FMT_VP8_FRAME:
+   if (fmt->fourcc == V4L2_PIX_FMT_MM21)
+   ret = true;
+   break;
+   case V4L2_PIX_FMT_H264_SLICE:
+   case V4L2_PIX_FMT_VP9_FRAME:
+   if (fmt->fourcc == V4L2_PIX_FMT_MM21)
+   ret = false;
+   break;
+   default:
+   ret = true;
+   break;
+   };
+
+   return ret;
+}
+
 static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_ctx *ctx,
  enum v4l2_buf_type type)
 {
@@ -578,6 +616,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void 
*priv,
dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME)
continue;
 
+   if (!output_queue && !mtk_vdec_get_cap_fmt(ctx, i))
+   continue;
+
if (j == f->index)
break;
++j;
-- 
2.25.1


[PATCH v2, 1/7] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for lat soc

2022-01-27 Thread Yunfei Dong
Adds decoder dt-bindings for compatible "mediatek,mtk-vcodec-lat-soc".

Signed-off-by: Yunfei Dong 
---
 .../media/mediatek,vcodec-subdev-decoder.yaml | 49 +++
 1 file changed, 49 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
index 6415c9f29130..a3c892338ac0 100644
--- 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
+++ 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
@@ -189,6 +189,55 @@ patternProperties:
 
 additionalProperties: false
 
+  '^vcodec-lat-soc@[0-9a-f]+$':
+type: object
+
+properties:
+  compatible:
+const: mediatek,mtk-vcodec-lat-soc
+
+  reg:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  clocks:
+maxItems: 5
+
+  clock-names:
+items:
+  - const: sel
+  - const: soc-vdec
+  - const: soc-lat
+  - const: vdec
+  - const: top
+
+  assigned-clocks:
+maxItems: 1
+
+  assigned-clock-parents:
+maxItems: 1
+
+  power-domains:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - iommus
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+  - power-domains
+
+additionalProperties: false
+
 required:
   - compatible
   - reg
-- 
2.25.1


[PATCH v2, 7/7] media: mtk-vcodec: Add to support H264 inner racing mode

2022-01-27 Thread Yunfei Dong
In order to reduce decoder latency, enable H264 inner racing mode.

Send lat trans buffer information to core when trigger lat to work,
need not to wait until lat decode done.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  4 +++
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 34 +++
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  | 10 ++
 .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c  | 23 ++---
 4 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 938bf14e4e8c..099dc28b7445 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -390,6 +390,10 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
}
 
+   atomic_set(>dec_active_cnt, 0);
+   memset(dev->vdec_racing_info, 0 , sizeof(dev->vdec_racing_info));
+   mutex_init(>dec_racing_info_mutex);
+
if (dev->vdec_pdata->uses_stateless_api) {
dev->mdev_dec.dev = >dev;
strscpy(dev->mdev_dec.model, MTK_VCODEC_DEC_NAME,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 76e1442fc6f9..065d14a3d11f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -173,6 +173,34 @@ static void mtk_vcodec_dec_disable_irq(struct 
mtk_vcodec_dev *vdec_dev, int hw_i
}
 }
 
+static void mtk_vcodec_load_racing_info(struct mtk_vcodec_ctx *ctx)
+{
+   void __iomem *vdec_racing_addr;
+   int j;
+
+   mutex_lock(>dev->dec_racing_info_mutex);
+   if (atomic_inc_return(>dev->dec_active_cnt) == 1) {
+   vdec_racing_addr = ctx->dev->reg_base[VDEC_MISC] + 0x100;
+   for (j = 0; j < 132; j++)
+   writel(ctx->dev->vdec_racing_info[j], vdec_racing_addr 
+ j * 4);
+   }
+   mutex_unlock(>dev->dec_racing_info_mutex);
+}
+
+static void mtk_vcodec_record_racing_info(struct mtk_vcodec_ctx *ctx)
+{
+   void __iomem *vdec_racing_addr;
+   int j;
+
+   mutex_lock(>dev->dec_racing_info_mutex);
+   if (atomic_dec_and_test(>dev->dec_active_cnt)) {
+   vdec_racing_addr = ctx->dev->reg_base[VDEC_MISC] + 0x100;
+   for (j = 0; j < 132; j++)
+   ctx->dev->vdec_racing_info[j] = readl(vdec_racing_addr 
+ j * 4);
+   }
+   mutex_unlock(>dev->dec_racing_info_mutex);
+}
+
 static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev 
*vdec_dev,
   int hw_idx)
 {
@@ -243,11 +271,17 @@ void mtk_vcodec_dec_enable_hardware(struct mtk_vcodec_ctx 
*ctx, int hw_idx)
mtk_vcodec_dec_child_dev_on(ctx->dev, hw_idx);
 
mtk_vcodec_dec_enable_irq(ctx->dev, hw_idx);
+
+   if (IS_VDEC_INNER_RACING(ctx->dev->dec_capability))
+   mtk_vcodec_load_racing_info(ctx);
 }
 EXPORT_SYMBOL_GPL(mtk_vcodec_dec_enable_hardware);
 
 void mtk_vcodec_dec_disable_hardware(struct mtk_vcodec_ctx *ctx, int hw_idx)
 {
+   if (IS_VDEC_INNER_RACING(ctx->dev->dec_capability))
+   mtk_vcodec_record_racing_info(ctx);
+
mtk_vcodec_dec_disable_irq(ctx->dev, hw_idx);
 
mtk_vcodec_dec_child_dev_off(ctx->dev, hw_idx);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 363b999dd709..4d6ace869b5a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -28,6 +28,7 @@
 #define MTK_V4L2_BENCHMARK 0
 #define WAIT_INTR_TIMEOUT_MS   1000
 #define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
+#define IS_VDEC_INNER_RACING(capability) (capability & MTK_VCODEC_INNER_RACING)
 
 /*
  * enum mtk_hw_reg_idx - MTK hw register base index
@@ -360,6 +361,7 @@ enum mtk_vdec_format_types {
MTK_VDEC_FORMAT_H264_SLICE = 0x100,
MTK_VDEC_FORMAT_VP8_FRAME = 0x200,
MTK_VDEC_FORMAT_VP9_FRAME = 0x400,
+   MTK_VCODEC_INNER_RACING = 0x2,
 };
 
 /**
@@ -480,6 +482,10 @@ struct mtk_vcodec_enc_pdata {
  * @subdev_dev: subdev hardware device
  * @subdev_prob_done: check whether all used hw device is prob done
  * @subdev_bitmap: used to record hardware is ready or not
+ *
+ * @dec_active_cnt: used to mark whether need to record register value
+ * @vdec_racing_info: record register value
+ * @dec_racing_info_mutex: mutex lock used for inner racing mode
  */
 struct mtk_vcodec_dev {
struct v4l2_device v4l2_dev;
@@ -525,6 +531,10 @@ struct mtk_vcodec_dev {
void *subdev_dev[MTK_VDEC_HW_MAX];
int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);
DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
+
+   

[PATCH v2, 0/7] support mt8195 decoder

2022-01-27 Thread Yunfei Dong
Firstly, add mt8195 soc lat hardware and compatible, then add documents.
For vp8 only support MM21 mode, H264/vp9 support MT21C, need to separate
them. Lastly, enable H264 inner racing mode to reduce hardware latency.

Patch 1~4 add mt8195 soc lat hardware and compatible, then add documents.
Patch 5 using different format for different codecs.
Patch 6 prevent kernel crash when scp reboot.
Patch 7 enable H264 inner racing mode to reduce hardware latency.
---
This patch depends on "support mt8186 decoder"[1]

[1]  
https://patchwork.kernel.org/project/linux-mediatek/cover/20220122075606.19373-1-yunfei.d...@mediatek.com
---
changed with v1:
- separate "Init VP9 stateless decode params" patch and remove it to another 
one.
- add reviewed-by in patch v3/v4/v6
---
Tinghan Shen (1):
  media: mtk-vcodec: prevent kernel crash when scp ipi timeout

Yunfei Dong (6):
  dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for lat soc
  media: mtk-vcodec: Add to support lat soc hardware
  dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8195
  media: mtk-vcodec: Adds compatible for mt8195
  media: mtk-vcodec: Different codec using different capture format
  media: mtk-vcodec: Add to support H264 inner racing mode

 .../media/mediatek,vcodec-subdev-decoder.yaml | 50 +++
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  | 41 +++
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  8 +++
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   | 12 +++--
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h   |  2 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 50 +++
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  | 11 
 .../mtk-vcodec/vdec/vdec_h264_req_multi_if.c  | 23 +++--
 .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  5 ++
 9 files changed, 194 insertions(+), 8 deletions(-)

-- 
2.25.1



[PATCH v2, 6/7] media: mtk-vcodec: prevent kernel crash when scp ipi timeout

2022-01-27 Thread Yunfei Dong
From: Tinghan Shen 

When SCP timeout during playing video, kernel crashes with following
message. It's caused by accessing NULL pointer in vpu_dec_ipi_handler.
This patch doesn't solve the root cause of NULL pointer, but merely
prevent kernel crashed when encounter the NULL pointer.

After applied this patch, kernel keeps alive, only the video player turns
to green screen.

[67242.065474] pc : vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec]
[67242.065485] [MTK_V4L2] level=0 fops_vcodec_open(),334:
1800.vcodec_dec decoder [135]
[67242.065523] lr : scp_ipi_handler+0x11c/0x244 [mtk_scp]
[67242.065540] sp : ffbb4207fb10
[67242.065557] x29: ffbb4207fb30 x28: ffd00a1d5000
[67242.065592] x27: 1ffa0143aa24 x26: 
[67242.065625] x25: dfd0 x24: ffd0168bfdb0
[67242.065659] x23: 1ff76840ff74 x22: ffbb41fa8a88
[67242.065692] x21: ffbb4207fb9c x20: ffbb4207fba0
[67242.065725] x19: ffbb4207fb98 x18: 
[67242.065758] x17:  x16: ffd042022094
[67242.065791] x15: 1ff77ed4b71a x14: 1ff77ed4b719
[67242.065824] x13:  x12: 
[67242.065857] x11:  x10: dfd1
[67242.065890] x9 :  x8 : 0002
[67242.065923] x7 :  x6 : 003f
[67242.065956] x5 : 0040 x4 : ffe0
[67242.065989] x3 : ffd043b841b8 x2 : 
[67242.066021] x1 : 0010 x0 : 0010
[67242.066055] Call trace:
[67242.066092]  vpu_dec_ipi_handler+0xa0/0xb20 [mtk_vcodec_dec
12220d230d83a7426fc38c56b3e7bc6066955bae]
[67242.066119]  scp_ipi_handler+0x11c/0x244 [mtk_scp
8fb69c2ef141dd3192518b952b65aba35627b8bf]
[67242.066145]  mt8192_scp_irq_handler+0x70/0x128 [mtk_scp
8fb69c2ef141dd3192518b952b65aba35627b8bf]
[67242.066172]  scp_irq_handler+0xa0/0x114 [mtk_scp
8fb69c2ef141dd3192518b952b65aba35627b8bf]
[67242.066200]  irq_thread_fn+0x84/0xf8
[67242.066220]  irq_thread+0x170/0x1ec
[67242.066242]  kthread+0x2f8/0x3b8
[67242.066264]  ret_from_fork+0x10/0x30
[67242.066292] Code: 38f96908 35003628 91004340 d343fc08 (38f96908)

Signed-off-by: Tinghan Shen 
Signed-off-by: Yunfei Dong 
Reviewed-by: Macpaul Lin 
---
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 35f4d5583084..1041dd663e76 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -91,6 +91,11 @@ static void vpu_dec_ipi_handler(void *data, unsigned int 
len, void *priv)
struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
(unsigned long)msg->ap_inst_addr;
 
+   if (!vpu) {
+   mtk_v4l2_err("ap_inst_addr is NULL");
+   return;
+   }
+
mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
 
vpu->failure = msg->status;
-- 
2.25.1



[PATCH v2, 4/7] media: mtk-vcodec: Adds compatible for mt8195

2022-01-27 Thread Yunfei Dong
Adds compatible for mt8195 platform.

Signed-off-by: Yunfei Dong 
Reviewed-by: Macpaul Lin 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 2d21d0010c9c..938bf14e4e8c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -468,6 +468,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
.compatible = "mediatek,mt8186-vcodec-dec",
.data = _vdec_single_core_pdata,
},
+   {
+   .compatible = "mediatek,mt8195-vcodec-dec",
+   .data = _lat_sig_core_pdata,
+   },
{},
 };
 
-- 
2.25.1



[PATCH v2, 2/7] media: mtk-vcodec: Add to support lat soc hardware

2022-01-27 Thread Yunfei Dong
Add lat soc compatible and to support lat soc power/clk helper.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c  | 12 +---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h  |  2 ++
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c  | 16 
 .../media/platform/mtk-vcodec/mtk_vcodec_drv.h   |  1 +
 4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index 7b5da3e4cac2..7374d5a5c156 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -28,6 +28,10 @@ static const struct of_device_id mtk_vdec_hw_match[] = {
.compatible = "mediatek,mtk-vcodec-core",
.data = (void *)MTK_VDEC_CORE,
},
+   {
+   .compatible = "mediatek,mtk-vcodec-lat-soc",
+   .data = (void *)MTK_VDEC_LAT_SOC,
+   },
{},
 };
 MODULE_DEVICE_TABLE(of, mtk_vdec_hw_match);
@@ -166,9 +170,11 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
subdev_dev->reg_base[VDEC_HW_SYS] = main_dev->reg_base[VDEC_HW_SYS];
set_bit(subdev_dev->hw_idx, main_dev->subdev_bitmap);
 
-   ret = mtk_vdec_hw_init_irq(subdev_dev);
-   if (ret)
-   goto err;
+   if (IS_SUPPORT_VDEC_HW_IRQ(hw_idx)) {
+   ret = mtk_vdec_hw_init_irq(subdev_dev);
+   if (ret)
+   goto err;
+   }
 
subdev_dev->reg_base[VDEC_HW_MISC] =
devm_platform_ioremap_resource(pdev, 0);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
index a63e4b1b81c3..b8938c6c3e72 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
@@ -17,6 +17,8 @@
 #define VDEC_IRQ_CLR 0x10
 #define VDEC_IRQ_CFG_REG 0xa4
 
+#define IS_SUPPORT_VDEC_HW_IRQ(hw_idx) (hw_idx != MTK_VDEC_LAT_SOC)
+
 /**
  * enum mtk_vdec_hw_reg_idx - subdev hardware register base index
  * @VDEC_HW_SYS : vdec soc register index
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 1581a1277473..76e1442fc6f9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -203,6 +203,14 @@ static void mtk_vcodec_dec_child_dev_on(struct 
mtk_vcodec_dev *vdec_dev,
mtk_vcodec_dec_pw_on(pm);
mtk_vcodec_dec_clock_on(pm);
}
+
+   if (hw_idx == MTK_VDEC_LAT0) {
+   pm = mtk_vcodec_dec_get_pm(vdec_dev, MTK_VDEC_LAT_SOC);
+   if (pm) {
+   mtk_vcodec_dec_pw_on(pm);
+   mtk_vcodec_dec_clock_on(pm);
+   }
+   }
 }
 
 static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dev *vdec_dev,
@@ -215,6 +223,14 @@ static void mtk_vcodec_dec_child_dev_off(struct 
mtk_vcodec_dev *vdec_dev,
mtk_vcodec_dec_clock_off(pm);
mtk_vcodec_dec_pw_off(pm);
}
+
+   if (hw_idx == MTK_VDEC_LAT0) {
+   pm = mtk_vcodec_dec_get_pm(vdec_dev, MTK_VDEC_LAT_SOC);
+   if (pm) {
+   mtk_vcodec_dec_clock_off(pm);
+   mtk_vcodec_dec_pw_off(pm);
+   }
+   }
 }
 
 void mtk_vcodec_dec_enable_hardware(struct mtk_vcodec_ctx *ctx, int hw_idx)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index cd2939b47790..363b999dd709 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -104,6 +104,7 @@ enum mtk_vdec_hw_id {
MTK_VDEC_CORE,
MTK_VDEC_LAT0,
MTK_VDEC_LAT1,
+   MTK_VDEC_LAT_SOC,
MTK_VDEC_HW_MAX,
 };
 
-- 
2.25.1



[PATCH v2, 3/7] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8195

2022-01-27 Thread Yunfei Dong
Adds decoder dt-bindings for mt8195.

Signed-off-by: Yunfei Dong 
Reviewed-by: Macpaul Lin 
---
 .../bindings/media/mediatek,vcodec-subdev-decoder.yaml   | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
index a3c892338ac0..a2f2db29daed 100644
--- 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
+++ 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
@@ -50,6 +50,7 @@ properties:
 enum:
   - mediatek,mt8192-vcodec-dec
   - mediatek,mt8186-vcodec-dec
+  - mediatek,mt8195-vcodec-dec
 
   reg:
 maxItems: 1
-- 
2.25.1



[PATCH v2 1/28] drm/amdgpu: fix that issue that the number of the crtc of the 3250c is not correct

2022-01-27 Thread RyanLin
v2:
  - remove unnecessary comments and Id

[Why]
External displays take priority over internal display when there are fewer 
display controllers than displays.

[How]
The root cause is because of that number of the crtc is not correct.
The number of the crtc on the 3250c is 3, but on the 3500c is 4.
>From the source code, we can see that number of the crtc has been fixed at 4.
Needs to set the num_crtc to 3 for 3250c platform.

Signed-off-by: RyanLin 

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 40c91b448f7d..455a2c45e8cd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2738,9 +2738,15 @@ static int dm_early_init(void *handle)
break;
 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
case CHIP_RAVEN:
-   adev->mode_info.num_crtc = 4;
-   adev->mode_info.num_hpd = 4;
-   adev->mode_info.num_dig = 4;
+   if (adev->rev_id >= 8) {
+   adev->mode_info.num_crtc = 3;
+   adev->mode_info.num_hpd = 3;
+   adev->mode_info.num_dig = 3;
+   } else {
+   adev->mode_info.num_crtc = 4;
+   adev->mode_info.num_hpd = 4;
+   adev->mode_info.num_dig = 4;
+   }
break;
 #endif
 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
-- 
2.25.1



Re: [PATCH v1, 7/8] media: uapi: Init VP9 stateless decode params

2022-01-27 Thread yunfei.d...@mediatek.com
Hi AngeloGioacchino,

Thanks for your suggestion,

Separate this patch with mt8195 support, and sent it again.
On Thu, 2022-01-27 at 11:35 +0100, AngeloGioacchino Del Regno wrote:
> Il 27/01/22 03:55, Yunfei Dong ha scritto:
> > Init some of VP9 frame decode params to default value.
> > 
> > Signed-off-by: Yunfei Dong 
> 
> Hello Yunfei,
> 
> This patch is not strictly related to MediaTek SoCs, since it's
> modfying v4l2-core.
> Can you please send this patch separately?
> 
> Thanks,
> Angelo
> 
Best Regards,
Yunfei Dong
> > ---
> >   drivers/media/v4l2-core/v4l2-ctrls-core.c | 8 
> >   1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > index 54abe5245dcc..b25c77b8a445 100644
> > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > @@ -112,6 +112,7 @@ static void std_init_compound(const struct
> > v4l2_ctrl *ctrl, u32 idx,
> > struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
> > struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quant;
> > struct v4l2_ctrl_vp8_frame *p_vp8_frame;
> > +   struct v4l2_ctrl_vp9_frame *p_vp9_frame;
> > struct v4l2_ctrl_fwht_params *p_fwht_params;
> > void *p = ptr.p + idx * ctrl->elem_size;
> >   
> > @@ -152,6 +153,13 @@ static void std_init_compound(const struct
> > v4l2_ctrl *ctrl, u32 idx,
> > p_vp8_frame = p;
> > p_vp8_frame->num_dct_parts = 1;
> > break;
> > +   case V4L2_CTRL_TYPE_VP9_FRAME:
> > +   p_vp9_frame = p;
> > +   p_vp9_frame->profile = 0;
> > +   p_vp9_frame->bit_depth = 8;
> > +   p_vp9_frame->flags |= V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING
> > |
> > +   V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING;
> > +   break;
> > case V4L2_CTRL_TYPE_FWHT_PARAMS:
> > p_fwht_params = p;
> > p_fwht_params->version = V4L2_FWHT_VERSION;
> > 
> 
> 



Re: [PATCH v1, 7/8] media: uapi: Init VP9 stateless decode params

2022-01-27 Thread yunfei.d...@mediatek.com
Hi Chen-Yu,

Thanks for your suggestion.
Send this patch again.
On Thu, 2022-01-27 at 17:23 +0800, Chen-Yu Tsai wrote:
> Hi,
> 
> On Thu, Jan 27, 2022 at 10:56 AM Yunfei Dong <
> yunfei.d...@mediatek.com> wrote:
> > 
> > Init some of VP9 frame decode params to default value.
> > 
> > Signed-off-by: Yunfei Dong 
> 
> Maybe add
> 
> Fixes: b88dbe38dca8 ("media: uapi: Add VP9 stateless decoder
> controls")
> 
Best Regards,
Yunfei Dong
> > ---
> >  drivers/media/v4l2-core/v4l2-ctrls-core.c | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > index 54abe5245dcc..b25c77b8a445 100644
> > --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> > @@ -112,6 +112,7 @@ static void std_init_compound(const struct
> > v4l2_ctrl *ctrl, u32 idx,
> > struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
> > struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quant;
> > struct v4l2_ctrl_vp8_frame *p_vp8_frame;
> > +   struct v4l2_ctrl_vp9_frame *p_vp9_frame;
> > struct v4l2_ctrl_fwht_params *p_fwht_params;
> > void *p = ptr.p + idx * ctrl->elem_size;
> > 
> > @@ -152,6 +153,13 @@ static void std_init_compound(const struct
> > v4l2_ctrl *ctrl, u32 idx,
> > p_vp8_frame = p;
> > p_vp8_frame->num_dct_parts = 1;
> > break;
> > +   case V4L2_CTRL_TYPE_VP9_FRAME:
> > +   p_vp9_frame = p;
> > +   p_vp9_frame->profile = 0;
> > +   p_vp9_frame->bit_depth = 8;
> > +   p_vp9_frame->flags |=
> > V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING |
> > +   V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING;
> > +   break;
> > case V4L2_CTRL_TYPE_FWHT_PARAMS:
> > p_fwht_params = p;
> > p_fwht_params->version = V4L2_FWHT_VERSION;
> > --
> > 2.25.1
> > 



Re: [RFC PATCH 2/2] drm/mediatek: add mtk8195 hdmi display driver

2022-01-27 Thread CK Hu
Hi, Guillaume:

On Mon, 2021-11-08 at 01:08 +0100, Guillaume Ranquet wrote:
> Signed-off-by: Guillaume Ranquet 
> Change-Id: I6399dec26cfe56a338c2ca96989cb7cbd14e292b
> ---
>  drivers/gpu/drm/mediatek/Kconfig  |9 +
>  drivers/gpu/drm/mediatek/Makefile |2 +
>  drivers/gpu/drm/mediatek/mtk_hdmi_common.c|  219 +-
>  drivers/gpu/drm/mediatek/mtk_hdmi_common.h|   24 +-
>  drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c| 1835
> +
>  drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.h|   26 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.c|  530 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.h|   20 +
>  .../gpu/drm/mediatek/mtk_mt8195_hdmi_regs.h   |  329 +++
>  9 files changed, 2932 insertions(+), 62 deletions(-)
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.c
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_ddc.h
>  create mode 100644 drivers/gpu/drm/mediatek/mtk_mt8195_hdmi_regs.h
> 
> 

[snip]

>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
> b/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
> index f60b5b8bf99e..a58946d3848b 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
> @@ -25,12 +25,17 @@
>  
>  #include 
>  
> +//TODO: see what can be done here... :-/
> +#include "mtk_mt8195_hdmi_ddc.h"
> +#include "mtk_mt8195_hdmi.h"
>  #include "mtk_cec.h"
>  #include "mtk_hdmi.h"
>  
>  struct mtk_hdmi_conf {
>   bool tz_disabled;
>   bool cea_modes_only;
> + bool is_mt8195;
> + bool low_power;
>   unsigned long max_mode_clock;
>  };
>  
> @@ -127,6 +132,17 @@ enum hdmi_aud_channel_swap_type {
>   HDMI_AUD_SWAP_LR_STATUS,
>  };
>  
> +enum mtk_hdmi_clk_id_mt8195 {
> + MTK_MT8195_HDMI_CLK_UNIVPLL_D6D4,
> + MTK_MT8195_HDMI_CLK_MSDCPLL_D2,
> + MTK_MT8195_HDMI_CLK_HDMI_APB_SEL,
> + MTK_MT8195_HDMI_UNIVPLL_D4D8,
> + MTK_MT8195_HDIM_HDCP_SEL,
> + MTK_MT8195_HDMI_HDCP_24M_SEL,
> + MTK_MT8195_HDMI_VPP_SPLIT_HDMI,
> + MTK_MT8195_HDMI_CLK_COUNT,
> +};
> +
>  enum mtk_hdmi_clk_id_mt8183 {
>   MTK_MT8183_HDMI_CLK_HDMI_PIXEL,
>   MTK_MT8183_HDMI_CLK_HDMI_PLL,
> @@ -136,6 +152,7 @@ enum mtk_hdmi_clk_id_mt8183 {
>  };
>  
>  extern const char *const
> mtk_hdmi_clk_names_mt8183[MTK_MT8183_HDMI_CLK_COUNT];
> +extern const char *const
> mtk_hdmi_clk_names_mt8195[MTK_MT8195_HDMI_CLK_COUNT];
>  
>  enum hdmi_hpd_state {
>   HDMI_PLUG_OUT = 0,
> @@ -160,7 +177,8 @@ struct mtk_hdmi {
>   const struct mtk_hdmi_conf *conf;
>   struct phy *phy;
>   struct i2c_adapter *ddc_adpt;
> - struct clk *clk[MTK_MT8183_HDMI_CLK_COUNT];
> + //TODO: array size is max(MTK_MT8183_HDMI_CLK_COUNT,
> MTK_MT8195_HDMI_CLK_COUNT)... dynamically allocate instead?
> + struct clk *clk[MTK_MT8195_HDMI_CLK_COUNT];
>   struct drm_display_mode mode;
>   bool dvi_mode;
>   struct regmap *sys_regmap;
> @@ -228,9 +246,13 @@ int mtk_drm_hdmi_probe(struct platform_device
> *pdev);
>  int mtk_drm_hdmi_remove(struct platform_device *pdev);
>  
>  //TODO: do better than this? function pointers?
> +extern const struct drm_bridge_funcs mtk_mt8195_hdmi_bridge_funcs;
>  extern const struct drm_bridge_funcs mtk_mt8183_hdmi_bridge_funcs;
>  void mtk_hdmi_output_init_mt8183(struct mtk_hdmi *hdmi);
> +void mtk_hdmi_output_init_mt8195(struct mtk_hdmi *hdmi);
> +void mtk_hdmi_clk_disable_mt8195(struct mtk_hdmi *hdmi);
>  void mtk_hdmi_clk_disable_mt8183(struct mtk_hdmi *hdmi);
> +void set_hdmi_codec_pdata_mt8195(struct hdmi_codec_pdata
> *codec_data);
>  void set_hdmi_codec_pdata_mt8183(struct hdmi_codec_pdata
> *codec_data);
>  
>  #endif //_MTK_HDMI_COMMON_H
> diff --git a/drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c
> b/drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c
> new file mode 100644
> index ..3fa928b79ed2
> --- /dev/null
> +++ b/drivers/gpu/drm/mediatek/mtk_mt8195_hdmi.c
> @@ -0,0 +1,1835 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2021 MediaTek Inc.
> + * Copyright (c) 2021 BayLibre, SAS
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "mtk_drm_crtc.h"
> +#include "mtk_mt8195_hdmi.h"
> +#include "mtk_hdmi_common.h"
> +#include "mtk_mt8195_hdmi_ddc.h"
> +#include "mtk_mt8195_hdmi_regs.h"
> +
> +#define RGB444_8bit BIT(0)
> +#define RGB444_10bit BIT(1)
> +#define RGB444_12bit BIT(2)
> +#define RGB444_16bit BIT(3)
> +
> +#define YCBCR444_8bit BIT(4)
> +#define YCBCR444_10bit BIT(5)
> +#define YCBCR444_12bit BIT(6)
> +#define YCBCR444_16bit BIT(7)
> +
> +#define YCBCR422_8bit_NO_SUPPORT BIT(8)
> +#define 

[PATCH] media: uapi: Init VP9 stateless decode params

2022-01-27 Thread Yunfei Dong
Init some of VP9 frame decode params to default value.

Fixes: b88dbe38dca8 ("media: uapi: Add VP9 stateless decoder controls")
Signed-off-by: Yunfei Dong 
---
 drivers/media/v4l2-core/v4l2-ctrls-core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c 
b/drivers/media/v4l2-core/v4l2-ctrls-core.c
index 54abe5245dcc..b25c77b8a445 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -112,6 +112,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, 
u32 idx,
struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quant;
struct v4l2_ctrl_vp8_frame *p_vp8_frame;
+   struct v4l2_ctrl_vp9_frame *p_vp9_frame;
struct v4l2_ctrl_fwht_params *p_fwht_params;
void *p = ptr.p + idx * ctrl->elem_size;
 
@@ -152,6 +153,13 @@ static void std_init_compound(const struct v4l2_ctrl 
*ctrl, u32 idx,
p_vp8_frame = p;
p_vp8_frame->num_dct_parts = 1;
break;
+   case V4L2_CTRL_TYPE_VP9_FRAME:
+   p_vp9_frame = p;
+   p_vp9_frame->profile = 0;
+   p_vp9_frame->bit_depth = 8;
+   p_vp9_frame->flags |= V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING |
+   V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING;
+   break;
case V4L2_CTRL_TYPE_FWHT_PARAMS:
p_fwht_params = p;
p_fwht_params->version = V4L2_FWHT_VERSION;
-- 
2.25.1



Re: [Intel-gfx] [PATCH v3 2/2] drm/i915/uapi: Add query for hwconfig table

2022-01-27 Thread Jordan Justen
John Harrison  writes:

> On 1/27/2022 16:48, Jordan Justen wrote:
>> john.c.harri...@intel.com writes:
>>
>>> From: Rodrigo Vivi 
>>>
>>> GuC contains a consolidated table with a bunch of information about the
>>> current device.
>>>
>>> Previously, this information was spread and hardcoded to all the components
>>> including GuC, i915 and various UMDs. The goal here is to consolidate
>>> the data into GuC in a way that all interested components can grab the
>>> very latest and synchronized information using a simple query.
>> This "consolidate" goal is not what I was told for the purpose of this.
>> I don't think these paragraphs are the true.
> The intention is to remove multiple hardcoded tables spread across a 
> bunch of different drivers and replace them with a single table 
> retrieved from the hardware itself. That sounds like consolidation to me.

That is not what I was told. That is apparently what someone is trying
to sell here.

Mesa would prefer to "hardcode" info rather than depend on the closed
source guc software.

>>
>>> As per most of the other queries, this one can be called twice.
>>> Once with item.length=0 to determine the exact buffer size, then
>>> allocate the user memory and call it again for to retrieve the
>>> table data. For example:
>>>struct drm_i915_query_item item = {
>>>  .query_id = DRM_I915_QUERY_HWCONCFIG_TABLE;
>>>};
>>>query.items_ptr = (int64_t) 
>>>query.num_items = 1;
>>>
>>>ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));
>>>
>>>if (item.length <= 0)
>>>  return -ENOENT;
>>>
>>>data = malloc(item.length);
>>>item.data_ptr = (int64_t) 
>>>ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));
>>>
>>>// Parse the data as appropriate...
>>>
>>> The returned array is a simple and flexible KLV (Key/Length/Value)
>>> formatted table. For example, it could be just:
>>>enum device_attr {
>>>   ATTR_SOME_VALUE = 0,
>>>   ATTR_SOME_MASK  = 1,
>>>};
>>>
>>>static const u32 hwconfig[] = {
>>>ATTR_SOME_VALUE,
>>>1, // Value Length in DWords
>>>8, // Value
>>>
>>>ATTR_SOME_MASK,
>>>3,
>>>0x00, 0x, 0xFF00,
>>>};
>> You said on 03 Nov 2021 that you would remove the parts of this commit
>> message that document the format. Why? Because i915 will not make any
>> guarantees as to the format of what is returned. Thus, i915 should not
>> comment on the format.
> And you replied that you would prefer to keep it.

No, I did not.

You said, "Sure. Can remove comments." to which, I replied, "Obviously
not what should be done, but apparently all i915 is willing to do."

So, i915 should document and stand behind this blob's format. But, if
they are not willing to, they shouldn't half-heartedly put some text in
a commit message.

>>
>> Can you Cc me on future postings of this patch?
>>
>>> The attribute ids are defined in a hardware spec.
>> As this spec is not published, it's hard to verify or refute this claim.
>>
>> Think this is a more accurate commit message for this patch:
>>
>>  In this interface i915 is returning a currently undocumented blob of
>>  data which it receives from the closed source guc software. The
>>  format of this blob *might* be defined in a hardware spec in the
>>  future.
>>
>> I'm sure you will prefer to replace "might" with "is planned to". I
>> think "might" is more accurate, but I suppose the other would be
>> acceptable.
>>
>> -Jordan
> Getting brand new spec documents published is not a fast process.

Heh.

Have you learned anything new about the status of it in the past 3
months?

> That doesn't mean it isn't going to happen.

It also doesn't mean it is going to happen either. Maybe you want to add
some text wherein Intel guarantees that it will be released in a spec by
some date?

> Also, just because a document is currently confidential and private
> doesn't mean that it doesn't exist.

Should we add "This is documented in a private spec, so it really does
exist!"?

-Jordan


Re: [PATCH v4 04/10] drm/amdkfd: add SPM support for SVM

2022-01-27 Thread Alistair Popple
On Thursday, 27 January 2022 2:09:43 PM AEDT Alex Sierra wrote:

[...]

> @@ -984,3 +990,4 @@ int svm_migrate_init(struct amdgpu_device *adev)
>  
>   return 0;
>  }
> +
> 

git-am complained about this when I applied the series. Given you have to
rebase anyway it would be worth fixing this.





Re: [PATCH v4 03/10] mm/gup: fail get_user_pages for LONGTERM dev coherent type

2022-01-27 Thread Alistair Popple
On Thursday, 27 January 2022 2:09:42 PM AEDT Alex Sierra wrote:
> Avoid long term pinning for Coherent device type pages. This could
> interfere with their own device memory manager. For now, we are just
> returning error for PIN_LONGTERM Coherent device type pages. Eventually,
> these type of pages will get migrated to system memory, once the device
> migration pages support is added.
> 
> Signed-off-by: Alex Sierra 
> ---
>  mm/gup.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 886d6148d3d0..5291d7221826 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1720,6 +1720,12 @@ static long check_and_migrate_movable_pages(unsigned 
> long nr_pages,
>* If we get a movable page, since we are going to be pinning
>* these entries, try to move them out if possible.
>*/
> + if (is_dev_private_or_coherent_page(head)) {
> + WARN_ON_ONCE(is_device_private_page(head));
> + ret = -EFAULT;
> + goto unpin_pages;
> + }
> +
>   if (!is_pinnable_page(head)) {
>   if (PageHuge(head)) {
>   if (!isolate_huge_page(head, 
> _page_list))
> @@ -1750,6 +1756,7 @@ static long check_and_migrate_movable_pages(unsigned 
> long nr_pages,
>   if (list_empty(_page_list) && !isolation_error_count)
>   return nr_pages;
>  
> +unpin_pages:
>   if (gup_flags & FOLL_PIN) {
>   unpin_user_pages(pages, nr_pages);
>   } else {
 
If there is a mix of ZONE_MOVABLE and device pages the return value (ret) will
be subsequently lost here:

if (!list_empty(_page_list)) {
ret = migrate_pages(_page_list, alloc_migration_target,
NULL, (unsigned long), MIGRATE_SYNC,
MR_LONGTERM_PIN, NULL);
if (ret && !list_empty(_page_list))
putback_movable_pages(_page_list);
}

Which won't actually cause any problems, but it will lead to the GUP getting
retried unnecessarily. I do still intend to address this with a series to
migrate pages instead though, so I think this is ok for now as it's an unlikely
corner case anyway. Therefore feel tree to add the below when you repost:

Reviewed-by: Alistair Poppple 





Re: [PATCH v4 02/10] mm: add device coherent vma selection for memory migration

2022-01-27 Thread Alistair Popple
On Thursday, 27 January 2022 2:09:41 PM AEDT Alex Sierra wrote:

[...]

> diff --git a/mm/migrate.c b/mm/migrate.c
> index 277562cd4cf5..2b3375e165b1 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2340,8 +2340,6 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>   if (is_writable_device_private_entry(entry))
>   mpfn |= MIGRATE_PFN_WRITE;
>   } else {
> - if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))
> - goto next;

This isn't correct as it allows zero pfn pages to be selected for migration
when they shouldn't be (ie. because MIGRATE_VMA_SELECT_SYSTEM isn't specified).

>   pfn = pte_pfn(pte);
>   if (is_zero_pfn(pfn)) {
>   mpfn = MIGRATE_PFN_MIGRATE;
> @@ -2349,6 +2347,13 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>   goto next;
>   }
>   page = vm_normal_page(migrate->vma, addr, pte);
> + if (page && !is_zone_device_page(page) &&
> + !(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM))
> + goto next;
> + if (page && is_device_coherent_page(page) &&
> + (!(migrate->flags & 
> MIGRATE_VMA_SELECT_DEVICE_COHERENT) ||
> +  page->pgmap->owner != migrate->pgmap_owner))
> + goto next;
>   mpfn = migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE;
>   mpfn |= pte_write(pte) ? MIGRATE_PFN_WRITE : 0;
>   }
> 






Re: [PATCH v4 01/10] mm: add zone device coherent type memory support

2022-01-27 Thread Alistair Popple
On Thursday, 27 January 2022 2:09:40 PM AEDT Alex Sierra wrote:

[...]

> diff --git a/mm/migrate.c b/mm/migrate.c
> index 1852d787e6ab..277562cd4cf5 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -362,7 +362,7 @@ static int expected_page_refs(struct address_space
> *mapping, struct page *page)> 
>  * Device private pages have an extra refcount as they are
>  * ZONE_DEVICE pages.
>  */
> 
> -   expected_count += is_device_private_page(page);
> +   expected_count += is_dev_private_or_coherent_page(page);
> 
> if (mapping)
> 
> expected_count += thp_nr_pages(page) +
> page_has_private(page);
> 
> @@ -2503,7 +2503,7 @@ static bool migrate_vma_check_page(struct page *page)
> 
>  * FIXME proper solution is to rework migration_entry_wait()
>  so
>  * it does not need to take a reference on page.
>  */
> 
> -   return is_device_private_page(page);
> +   return is_dev_private_or_coherent_page(page);

As Andrew points out this no longer applies due to changes here. I think you
can just drop this hunk though.

[...]

> diff --git a/mm/rmap.c b/mm/rmap.c
> index 6aebd1747251..32dae6839403 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1823,10 +1823,17 @@ static bool try_to_migrate_one(struct page *page, 
> struct vm_area_struct *vma,
>* pteval maps a zone device page and is therefore
>* a swap pte.
>*/
> - if (pte_swp_soft_dirty(pteval))
> - swp_pte = pte_swp_mksoft_dirty(swp_pte);
> - if (pte_swp_uffd_wp(pteval))
> - swp_pte = pte_swp_mkuffd_wp(swp_pte);
> + if (is_device_coherent_page(page)) {
> + if (pte_soft_dirty(pteval))
> + swp_pte = pte_swp_mksoft_dirty(swp_pte);
> + if (pte_uffd_wp(pteval))
> + swp_pte = pte_swp_mkuffd_wp(swp_pte);
> + } else {
> + if (pte_swp_soft_dirty(pteval))
> + swp_pte = pte_swp_mksoft_dirty(swp_pte);
> + if (pte_swp_uffd_wp(pteval))
> + swp_pte = pte_swp_mkuffd_wp(swp_pte);
> + }

As I understand things ptes for device coherent pages don't need special
treatment, therefore rather than special casing here it should just fall
through to the same path as normal pages. For that I think all you need is
something like:

-if (is_zone_device_page(page)) {
+if (is_device_private_page(page)) {

Noting that device private pages are the only zone device pages that could
have been encountered here anyway.

>   set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte);
>   /*
>* No need to invalidate here it will synchronize on
> @@ -1837,7 +1844,7 @@ static bool try_to_migrate_one(struct page *page, 
> struct vm_area_struct *vma,
>* Since only PAGE_SIZE pages can currently be
>* migrated, just set it to page. This will need to be
>* changed when hugepage migrations to device private
> -  * memory are supported.
> +  * or coherent memory are supported.
>*/
>   subpage = page;
>   } else if (PageHWPoison(page)) {
> @@ -1943,7 +1950,8 @@ void try_to_migrate(struct page *page, enum ttu_flags 
> flags)
>   TTU_SYNC)))
>   return;
>  
> - if (is_zone_device_page(page) && !is_device_private_page(page))
> + if (is_zone_device_page(page) &&
> + !is_dev_private_or_coherent_page(page))
>   return;
>  
>   /*
> 






Re: [Intel-gfx] [PATCH v3 2/2] drm/i915/uapi: Add query for hwconfig table

2022-01-27 Thread John Harrison

On 1/27/2022 16:48, Jordan Justen wrote:

john.c.harri...@intel.com writes:


From: Rodrigo Vivi 

GuC contains a consolidated table with a bunch of information about the
current device.

Previously, this information was spread and hardcoded to all the components
including GuC, i915 and various UMDs. The goal here is to consolidate
the data into GuC in a way that all interested components can grab the
very latest and synchronized information using a simple query.

This "consolidate" goal is not what I was told for the purpose of this.
I don't think these paragraphs are the true.
The intention is to remove multiple hardcoded tables spread across a 
bunch of different drivers and replace them with a single table 
retrieved from the hardware itself. That sounds like consolidation to me.





As per most of the other queries, this one can be called twice.
Once with item.length=0 to determine the exact buffer size, then
allocate the user memory and call it again for to retrieve the
table data. For example:
   struct drm_i915_query_item item = {
 .query_id = DRM_I915_QUERY_HWCONCFIG_TABLE;
   };
   query.items_ptr = (int64_t) 
   query.num_items = 1;

   ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));

   if (item.length <= 0)
 return -ENOENT;

   data = malloc(item.length);
   item.data_ptr = (int64_t) 
   ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));

   // Parse the data as appropriate...

The returned array is a simple and flexible KLV (Key/Length/Value)
formatted table. For example, it could be just:
   enum device_attr {
  ATTR_SOME_VALUE = 0,
  ATTR_SOME_MASK  = 1,
   };

   static const u32 hwconfig[] = {
   ATTR_SOME_VALUE,
   1, // Value Length in DWords
   8, // Value

   ATTR_SOME_MASK,
   3,
   0x00, 0x, 0xFF00,
   };

You said on 03 Nov 2021 that you would remove the parts of this commit
message that document the format. Why? Because i915 will not make any
guarantees as to the format of what is returned. Thus, i915 should not
comment on the format.

And you replied that you would prefer to keep it.



Can you Cc me on future postings of this patch?


The attribute ids are defined in a hardware spec.

As this spec is not published, it's hard to verify or refute this claim.

Think this is a more accurate commit message for this patch:

 In this interface i915 is returning a currently undocumented blob of
 data which it receives from the closed source guc software. The
 format of this blob *might* be defined in a hardware spec in the
 future.

I'm sure you will prefer to replace "might" with "is planned to". I
think "might" is more accurate, but I suppose the other would be
acceptable.

-Jordan
Getting brand new spec documents published is not a fast process. That 
doesn't mean it isn't going to happen. Also, just because a document is 
currently confidential and private doesn't mean that it doesn't exist.


John.





Cc: Tvrtko Ursulin 
Cc: Kenneth Graunke 
Cc: Michal Wajdeczko 
Cc: Slawomir Milczarek 
Signed-off-by: Rodrigo Vivi 
Signed-off-by: John Harrison 
Reviewed-by: Matthew Brost 
---
  drivers/gpu/drm/i915/i915_query.c | 23 +++
  include/uapi/drm/i915_drm.h   |  1 +
  2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_query.c 
b/drivers/gpu/drm/i915/i915_query.c
index 2dfbc22857a3..609e64d5f395 100644
--- a/drivers/gpu/drm/i915/i915_query.c
+++ b/drivers/gpu/drm/i915/i915_query.c
@@ -479,12 +479,35 @@ static int query_memregion_info(struct drm_i915_private 
*i915,
return total_length;
  }
  
+static int query_hwconfig_table(struct drm_i915_private *i915,

+   struct drm_i915_query_item *query_item)
+{
+   struct intel_gt *gt = to_gt(i915);
+   struct intel_guc_hwconfig *hwconfig = >uc.guc.hwconfig;
+
+   if (!hwconfig->size || !hwconfig->ptr)
+   return -ENODEV;
+
+   if (query_item->length == 0)
+   return hwconfig->size;
+
+   if (query_item->length < hwconfig->size)
+   return -EINVAL;
+
+   if (copy_to_user(u64_to_user_ptr(query_item->data_ptr),
+hwconfig->ptr, hwconfig->size))
+   return -EFAULT;
+
+   return hwconfig->size;
+}
+
  static int (* const i915_query_funcs[])(struct drm_i915_private *dev_priv,
struct drm_i915_query_item *query_item) 
= {
query_topology_info,
query_engine_info,
query_perf_config,
query_memregion_info,
+   query_hwconfig_table,
  };
  
  int i915_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)

diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 914ebd9290e5..132515199f27 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -2685,6 +2685,7 @@ struct drm_i915_query_item {
  #define DRM_I915_QUERY_ENGINE_INFO2
  

Re: [Intel-gfx] [PATCH v3 2/2] drm/i915/uapi: Add query for hwconfig table

2022-01-27 Thread Jordan Justen
john.c.harri...@intel.com writes:

> From: Rodrigo Vivi 
>
> GuC contains a consolidated table with a bunch of information about the
> current device.
>
> Previously, this information was spread and hardcoded to all the components
> including GuC, i915 and various UMDs. The goal here is to consolidate
> the data into GuC in a way that all interested components can grab the
> very latest and synchronized information using a simple query.

This "consolidate" goal is not what I was told for the purpose of this.
I don't think these paragraphs are the true.

> As per most of the other queries, this one can be called twice.
> Once with item.length=0 to determine the exact buffer size, then
> allocate the user memory and call it again for to retrieve the
> table data. For example:
>   struct drm_i915_query_item item = {
> .query_id = DRM_I915_QUERY_HWCONCFIG_TABLE;
>   };
>   query.items_ptr = (int64_t) 
>   query.num_items = 1;
>
>   ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));
>
>   if (item.length <= 0)
> return -ENOENT;
>
>   data = malloc(item.length);
>   item.data_ptr = (int64_t) 
>   ioctl(fd, DRM_IOCTL_I915_QUERY, query, sizeof(query));
>
>   // Parse the data as appropriate...
>
> The returned array is a simple and flexible KLV (Key/Length/Value)
> formatted table. For example, it could be just:
>   enum device_attr {
>  ATTR_SOME_VALUE = 0,
>  ATTR_SOME_MASK  = 1,
>   };
>
>   static const u32 hwconfig[] = {
>   ATTR_SOME_VALUE,
>   1, // Value Length in DWords
>   8, // Value
>
>   ATTR_SOME_MASK,
>   3,
>   0x00, 0x, 0xFF00,
>   };

You said on 03 Nov 2021 that you would remove the parts of this commit
message that document the format. Why? Because i915 will not make any
guarantees as to the format of what is returned. Thus, i915 should not
comment on the format.

Can you Cc me on future postings of this patch?

> The attribute ids are defined in a hardware spec.

As this spec is not published, it's hard to verify or refute this claim.

Think this is a more accurate commit message for this patch:

In this interface i915 is returning a currently undocumented blob of
data which it receives from the closed source guc software. The
format of this blob *might* be defined in a hardware spec in the
future.

I'm sure you will prefer to replace "might" with "is planned to". I
think "might" is more accurate, but I suppose the other would be
acceptable.

-Jordan

>
> Cc: Tvrtko Ursulin 
> Cc: Kenneth Graunke 
> Cc: Michal Wajdeczko 
> Cc: Slawomir Milczarek 
> Signed-off-by: Rodrigo Vivi 
> Signed-off-by: John Harrison 
> Reviewed-by: Matthew Brost 
> ---
>  drivers/gpu/drm/i915/i915_query.c | 23 +++
>  include/uapi/drm/i915_drm.h   |  1 +
>  2 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_query.c 
> b/drivers/gpu/drm/i915/i915_query.c
> index 2dfbc22857a3..609e64d5f395 100644
> --- a/drivers/gpu/drm/i915/i915_query.c
> +++ b/drivers/gpu/drm/i915/i915_query.c
> @@ -479,12 +479,35 @@ static int query_memregion_info(struct drm_i915_private 
> *i915,
>   return total_length;
>  }
>  
> +static int query_hwconfig_table(struct drm_i915_private *i915,
> + struct drm_i915_query_item *query_item)
> +{
> + struct intel_gt *gt = to_gt(i915);
> + struct intel_guc_hwconfig *hwconfig = >uc.guc.hwconfig;
> +
> + if (!hwconfig->size || !hwconfig->ptr)
> + return -ENODEV;
> +
> + if (query_item->length == 0)
> + return hwconfig->size;
> +
> + if (query_item->length < hwconfig->size)
> + return -EINVAL;
> +
> + if (copy_to_user(u64_to_user_ptr(query_item->data_ptr),
> +  hwconfig->ptr, hwconfig->size))
> + return -EFAULT;
> +
> + return hwconfig->size;
> +}
> +
>  static int (* const i915_query_funcs[])(struct drm_i915_private *dev_priv,
>   struct drm_i915_query_item *query_item) 
> = {
>   query_topology_info,
>   query_engine_info,
>   query_perf_config,
>   query_memregion_info,
> + query_hwconfig_table,
>  };
>  
>  int i915_query_ioctl(struct drm_device *dev, void *data, struct drm_file 
> *file)
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 914ebd9290e5..132515199f27 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -2685,6 +2685,7 @@ struct drm_i915_query_item {
>  #define DRM_I915_QUERY_ENGINE_INFO   2
>  #define DRM_I915_QUERY_PERF_CONFIG  3
>  #define DRM_I915_QUERY_MEMORY_REGIONS   4
> +#define DRM_I915_QUERY_HWCONFIG_TABLE   5
>  /* Must be kept compact -- no holes and well documented */
>  
>   /**
> -- 
> 2.25.1


Re: [PATCH v4 00/10] Add MEMORY_DEVICE_COHERENT for coherent device memory mapping

2022-01-27 Thread Sierra Guiza, Alejandro (Alex)

Andrew,
We're somehow new on this procedure. Are you referring to rebase this 
patch series to
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
<5.17-rc1 tag>?


Regards,
Alex Sierra

Alex Deucher,
Just a quick heads up. This patch series contains changes to the amdgpu 
driver which we're

planning to merge through Andrew's tree, If that's ok with you.

Regards,
Alex Sierra

On 1/27/2022 4:32 PM, Andrew Morton wrote:

On Wed, 26 Jan 2022 21:09:39 -0600 Alex Sierra  wrote:


This patch series introduces MEMORY_DEVICE_COHERENT, a type of memory
owned by a device that can be mapped into CPU page tables like
MEMORY_DEVICE_GENERIC and can also be migrated like
MEMORY_DEVICE_PRIVATE.

Some more reviewer input appears to be desirable here.

I was going to tentatively add it to -mm and -next, but problems.
5.17-rc1's mm/migrate.c:migrate_vma_check_page() is rather different
from the tree you patched.  Please redo, refresh and resend?



RE: [PATCH] drm/kmb: Fix for build errors with Warray-bounds

2022-01-27 Thread Chrisanthus, Anitha
Thanks. Fixed line wrapping and change is pushed to drm-misc-fixes.

> -Original Message-
> From: dri-devel  On Behalf Of Kees
> Cook
> Sent: Thursday, January 27, 2022 1:14 PM
> To: Chrisanthus, Anitha 
> Cc: Dea, Edmund J ; s...@ravnborg.org; dri-
> de...@lists.freedesktop.org; s...@canb.auug.org.au
> Subject: Re: [PATCH] drm/kmb: Fix for build errors with Warray-bounds
> 
> On Thu, Jan 27, 2022 at 11:42:27AM -0800, Anitha Chrisanthus wrote:
> > This fixes the following build error
> >
> > drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
> > drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is
> > above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
> >   165 | kmb->plane_status[plane_id].ctrl =
> >   LCD_CTRL_GL2_ENABLE;
> >   | ~^~
> >   In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
> >   drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing
> >   'plane_status'
> >   61 | struct layer_status
> >   plane_status[KMB_MAX_PLANES];
> 
> This would be better without the line wrapping (to match the actual
> output), but otherwise:
> 
> Reviewed-by: Kees Cook 
> 
> >   | ^~~~
> >   drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array
> >   subscript 2 is above array bounds of 'struct
> >   layer_status[2]' [-Werror=array-bounds]
> >   162 |
> >   kmb->plane_status[plane_id].ctrl =
> >   LCD_CTRL_GL1_ENABLE;
> >   | ~^~
> >   In file included from
> >   drivers/gpu/drm/kmb/kmb_plane.c:17:
> >   drivers/gpu/drm/kmb/kmb_drv.h:61:41: note:
> >   while referencing 'plane_status'
> >   61 | struct layer_status
> >   plane_status[KMB_MAX_PLANES];
> >   |
> >   ^~~~
> >
> > Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
> > Signed-off-by: Anitha Chrisanthus 
> > ---
> >  drivers/gpu/drm/kmb/kmb_plane.c | 6 --
> >  1 file changed, 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/kmb/kmb_plane.c
> b/drivers/gpu/drm/kmb/kmb_plane.c
> > index 00404ba4126d..2735b8eb3537 100644
> > --- a/drivers/gpu/drm/kmb/kmb_plane.c
> > +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> > @@ -158,12 +158,6 @@ static void kmb_plane_atomic_disable(struct
> drm_plane *plane,
> > case LAYER_1:
> > kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;
> > break;
> > -   case LAYER_2:
> > -   kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
> > -   break;
> > -   case LAYER_3:
> > -   kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
> > -   break;
> > }
> >
> > kmb->plane_status[plane_id].disable = true;
> > --
> > 2.25.1
> >
> 
> --
> Kees Cook


Re: [PATCH v4 00/10] Add MEMORY_DEVICE_COHERENT for coherent device memory mapping

2022-01-27 Thread Andrew Morton
On Wed, 26 Jan 2022 21:09:39 -0600 Alex Sierra  wrote:

> This patch series introduces MEMORY_DEVICE_COHERENT, a type of memory
> owned by a device that can be mapped into CPU page tables like
> MEMORY_DEVICE_GENERIC and can also be migrated like
> MEMORY_DEVICE_PRIVATE.

Some more reviewer input appears to be desirable here.

I was going to tentatively add it to -mm and -next, but problems. 
5.17-rc1's mm/migrate.c:migrate_vma_check_page() is rather different
from the tree you patched.  Please redo, refresh and resend?



Re: [PATCH 2/5] staging: fbtft: Deduplicate driver registration macros

2022-01-27 Thread Uwe Kleine-König
Hello Greg,

On Sun, Jan 23, 2022 at 06:51:58PM +0100, Uwe Kleine-König wrote:
> The two macros FBTFT_REGISTER_DRIVER and FBTFT_REGISTER_SPI_DRIVER
> contain quite some duplication: Both define an spi driver and an of device
> table and the differences are quite subtle.
> 
> So create two new macros and use both twice.
> 
> Link: 
> https://lore.kernel.org/r/20220118181338.207943-2-u.kleine-koe...@pengutronix.de
> Signed-off-by: Uwe Kleine-König 

You picked this patch into your staging-next branch, I guess from the
original submission. Not sure how Mark wants to continue with the series
from this thread, but at least my plan was that he will create an
immutable branch on top of 5.17-rc2 (assuming 5.17-rc2 will contain
"staging: fbtft: Fix error path in fbtft_driver_module_init()") with the
remaining 4 patches in this series.

In a private mail you agreed to this procedure, but this didn't stop you
taking this patch?! What is your plan here? The obvious (to me) options
are:

 - Delay this series until after the next merge window.
 - You back out this patch from staging-next and ack here for Mark to
   apply it to an immutable branch.
 - You keep this patch in staging-next and still ack here for Mark to
   apply it to an immutable branch. Then the patch would be included
   twice.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | https://www.pengutronix.de/ |


signature.asc
Description: PGP signature


RE: [PATCH v2] hv: account for packet descriptor in maximum packet size

2022-01-27 Thread Michael Kelley (LINUX)
From: Yanming Liu  Sent: Wednesday, January 19, 2022 12:14 
PM
> 
> On Thu, Jan 20, 2022 at 2:12 AM Michael Kelley (LINUX)
>  wrote:
> >
> > From: Wei Liu  Sent: Friday, January 14, 2022 11:13 AM
> > >
> > > On Mon, Jan 10, 2022 at 01:44:19AM +0100, Andrea Parri wrote:
> > > > (Extending Cc: list,)
> > > >
> > > > On Sun, Jan 09, 2022 at 05:55:16PM +0800, Yanming Liu wrote:
> >
> > The VSS driver in hv_snapshot.c allocates a receive buffer of 8 Kbytes
> > and sets max_pkt_size to 8 Kbytes.  But the received messages are
> > all fixed size and small.  I don't know why the driver uses an 8 Kbyte
> > receive buffer instead of 4 Kbytes, but the current settings are
> > more than sufficient.
> >
> 
> Well, I'm not sure, on August 2021 there was a patch changing
> max_pkt_size to 8 KiB for VSS driver:
> https://lore.kernel.org/linux-hyperv/20210825190217.qh2c6yq5qr3ntum5@liuwe-devbox-debian-v2/T/
> 
> The patch mentioned a 6304 bytes VSS message. Which is part of the
> reason I tried to address the more "general" problem of potentially
> mismatching buffer size.
> 

This is certainly interesting.   The Linux driver is not processing
all those bytes, so I'm not sure what Hyper-V is passing to the
guest.  I'll check with the Hyper-V team to be sure.

Michael


Re: [PATCH] drm/kmb: Fix for build errors with Warray-bounds

2022-01-27 Thread Kees Cook
On Thu, Jan 27, 2022 at 11:42:27AM -0800, Anitha Chrisanthus wrote:
> This fixes the following build error
> 
> drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
> drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is
> above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
>   165 | kmb->plane_status[plane_id].ctrl =
>   LCD_CTRL_GL2_ENABLE;
>   | ~^~
>   In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
>   drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing
>   'plane_status'
>   61 | struct layer_status
>   plane_status[KMB_MAX_PLANES];

This would be better without the line wrapping (to match the actual
output), but otherwise:

Reviewed-by: Kees Cook 

>   | ^~~~
>   drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array
>   subscript 2 is above array bounds of 'struct
>   layer_status[2]' [-Werror=array-bounds]
>   162 |
>   kmb->plane_status[plane_id].ctrl =
>   LCD_CTRL_GL1_ENABLE;
>   | ~^~
>   In file included from
>   drivers/gpu/drm/kmb/kmb_plane.c:17:
>   drivers/gpu/drm/kmb/kmb_drv.h:61:41: note:
>   while referencing 'plane_status'
>   61 | struct layer_status
>   plane_status[KMB_MAX_PLANES];
>   |
>   ^~~~
> 
> Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
> Signed-off-by: Anitha Chrisanthus 
> ---
>  drivers/gpu/drm/kmb/kmb_plane.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index 00404ba4126d..2735b8eb3537 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -158,12 +158,6 @@ static void kmb_plane_atomic_disable(struct drm_plane 
> *plane,
>   case LAYER_1:
>   kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;
>   break;
> - case LAYER_2:
> - kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
> - break;
> - case LAYER_3:
> - kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
> - break;
>   }
>  
>   kmb->plane_status[plane_id].disable = true;
> -- 
> 2.25.1
> 

-- 
Kees Cook


Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels

2022-01-27 Thread Rob Herring
On Thu, Jan 27, 2022 at 3:36 AM Maxime Ripard  wrote:
>
> Hi Rob,
>
> On Mon, Jan 24, 2022 at 10:42:37AM -0600, Rob Herring wrote:
> > On Mon, Jan 24, 2022 at 10:28 AM Noralf Trønnes  wrote:
> > >
> > >
> > >
> > > Den 24.01.2022 17.08, skrev Rob Herring:
> > > > On Sun, Jan 23, 2022 at 11:25 AM Noralf Trønnes  
> > > > wrote:
> > > >>
> > > >> Add binding for MIPI DBI compatible SPI panels.
> > > >
> > > > I'm sure we already have MIPI DBI panels. What's this for?
> > > >
> > >
> > > It aims to use one driver to cover all MIPI DBI panels where the
> > > controller setup is loaded from userspace in a firmware file.
> >
> > What's the solution when the user wants a splash screen in the
> > bootloader and also wants multiple panels supported?
> >
> > Also, 1 driver doesn't dictate 1 compatible. A one to many
> > relationship is fine and makes the decision entirely the OS's.
> >
> > > The cover
> > > letter points to the discussion where Maxime proposed this:
> > >
> > > https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
> >
> > The proposal there is:
> >
> > > compatible = "panel-spi";
> > > model = "panel-from-random-place-42";
> >
> > The same thing can be accomplished with this:
> >
> > compatible = "panel-from-random-place-42", "panel-spi";
> >
> > What's the advantage of hijacking 'model'?
>
> So, the main issue is that a panel is essentially two things: a
> controller and the actual panel.
>
> The controller has an initialization sequence of its own, and part of it
> is parameters to match the panel.
>
> So you can have identical controllers that won't have the same
> initialization sequence because they don't have the same panel.
>
> I was assuming that a compatible would be more about the controller, so
> we needed something else, thus "model"

We already have cases like that which have "foo,some-panel", "bar,a-ctrlr-ic".

Rob


Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread Noralf Trønnes



Den 27.01.2022 20.59, skrev Sam Ravnborg:
> Hi Noralf,
> 
> On Tue, Jan 25, 2022 at 06:57:00PM +0100, Noralf Trønnes wrote:
>> Add a driver that will work with most MIPI DBI compatible SPI panels.
>> This avoids adding a driver for every new MIPI DBI compatible controller
>> that is to be used by Linux. The 'compatible' Device Tree property with
>> a '.bin' suffix will be used to load a firmware file that contains the
>> controller configuration.
> 
> Loading a configuration from a firmware file is very
> elegant - I like.
> This will be very useful in a million cases with a lot of small panels!
> 

Yes I really hope we can find a way to get this accepted.

>> +
>> +/*
>> + * Optional MIPI commands to execute when the display pipeline is 
>> enabled.
>> + * This can be used to configure the display controller.
>> + *
>> + * The commands are stored in a byte array with the format:
>> + * command, num_parameters, [ parameter, ...], command, ...
>> + *
>> + * Some commands require a pause before the next command can be 
>> received.
>> + * Inserting a delay in the command sequence is done by using the NOP 
>> command with one
>> + * parameter: delay in miliseconds (the No Operation command is part of 
>> the MIPI Display
>> + * Command Set where it has no parameters).
>> + *
>> + * Example:
>> + * command 0x11
>> + * sleep 120ms
>> + * command 0xb1 parameters 0x01, 0x2c, 0x2d
>> + * command 0x29
>> + *
>> + * Byte sequence:
>> + * 0x11 0x00
>> + * 0x00 0x01 0x78
>> + * 0xb1 0x03 0x01 0x2c 0x2d
>> + * 0x29 0x00
>> + */
> Using a binary file that is unreadable when it is first created is less
> elegant.
> I am sure you have considered a txt file - and I know parsing a txt file
> in prone for more errros than parsing a binary file.
> 
> 
> But if the text file looked like:
> "
>   # The is a comment
>   cmd 0x11 0x00
> 
>   # We need to sleep
>   sleepms 120
> 
>   # Do something more
>   cmd 0xb1 0x03 0x01 0x2c 0x2d
>   cmd 0x29 0x00
> "
> 
> The file is easier to comment (document) and easier to read and
> modify.
> The suffix could be ".panel" to tell this is something specific for
> a panel.
> Using lib/parser could make the code somewhat simple but I did not try
> to code it myself.
> 
> The code you included below for the binary file is very simple,
> but you shift the burden to the people who have to create binary files.
> And people using obscure displays are not always so good at this stuff.
> 

Parsing text files in the kernel sounds very scary, not something that I
would like to try.

I will make a script that generates and parses the binary representation
(which is big endian so it's somewhat readable with xxd or the like).
There's a wiki link in the MAINTAINERS entry that will have info about
the format including the script. It will also serve as a place to share
config snippets/script incantations for displays.

I will make the script when the file format is decided upon. Here's the
hack I currently use:
https://gist.github.com/notro/3ca61c48e7dcc4a0ef34dbadbc30bfa5

Noralf.


Re: [PATCH] drm/amdgpu: Wrong order for config and counter_id parameters

2022-01-27 Thread Alex Deucher
Applied.  Thanks!

Alex

On Wed, Jan 26, 2022 at 4:48 AM  wrote:
>
> From: huangqu 
>
> Wrong order for config and counter_id parameters was passed, when calling 
> df_v3_6_pmc_set_deferred and df_v3_6_pmc_is_deferred functions.
>
> Signed-off-by: huangqu 
> ---
>  drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c 
> b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
> index 43c5e3ec9..f4dfca013 100644
> --- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
> +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
> @@ -458,7 +458,7 @@ static int df_v3_6_pmc_add_cntr(struct amdgpu_device 
> *adev,
>
>  #define DEFERRED_ARM_MASK  (1 << 31)
>  static int df_v3_6_pmc_set_deferred(struct amdgpu_device *adev,
> -   int counter_idx, uint64_t config,
> +   uint64_t config, int counter_idx,
> bool is_deferred)
>  {
>
> @@ -476,8 +476,8 @@ static int df_v3_6_pmc_set_deferred(struct amdgpu_device 
> *adev,
>  }
>
>  static bool df_v3_6_pmc_is_deferred(struct amdgpu_device *adev,
> -   int counter_idx,
> -   uint64_t config)
> +   uint64_t config,
> +   int counter_idx)
>  {
> return  (df_v3_6_pmc_has_counter(adev, config, counter_idx) &&
> (adev->df_perfmon_config_assign_mask[counter_idx]
> --
> 2.31.1
>


Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread Sam Ravnborg
Hi Noralf,

On Tue, Jan 25, 2022 at 06:57:00PM +0100, Noralf Trønnes wrote:
> Add a driver that will work with most MIPI DBI compatible SPI panels.
> This avoids adding a driver for every new MIPI DBI compatible controller
> that is to be used by Linux. The 'compatible' Device Tree property with
> a '.bin' suffix will be used to load a firmware file that contains the
> controller configuration.

Loading a configuration from a firmware file is very
elegant - I like.
This will be very useful in a million cases with a lot of small panels!

> +
> + /*
> +  * Optional MIPI commands to execute when the display pipeline is 
> enabled.
> +  * This can be used to configure the display controller.
> +  *
> +  * The commands are stored in a byte array with the format:
> +  * command, num_parameters, [ parameter, ...], command, ...
> +  *
> +  * Some commands require a pause before the next command can be 
> received.
> +  * Inserting a delay in the command sequence is done by using the NOP 
> command with one
> +  * parameter: delay in miliseconds (the No Operation command is part of 
> the MIPI Display
> +  * Command Set where it has no parameters).
> +  *
> +  * Example:
> +  * command 0x11
> +  * sleep 120ms
> +  * command 0xb1 parameters 0x01, 0x2c, 0x2d
> +  * command 0x29
> +  *
> +  * Byte sequence:
> +  * 0x11 0x00
> +  * 0x00 0x01 0x78
> +  * 0xb1 0x03 0x01 0x2c 0x2d
> +  * 0x29 0x00
> +  */
Using a binary file that is unreadable when it is first created is less
elegant.
I am sure you have considered a txt file - and I know parsing a txt file
in prone for more errros than parsing a binary file.


But if the text file looked like:
"
# The is a comment
cmd 0x11 0x00

# We need to sleep
sleepms 120

# Do something more
cmd 0xb1 0x03 0x01 0x2c 0x2d
cmd 0x29 0x00
"

The file is easier to comment (document) and easier to read and
modify.
The suffix could be ".panel" to tell this is something specific for
a panel.
Using lib/parser could make the code somewhat simple but I did not try
to code it myself.

The code you included below for the binary file is very simple,
but you shift the burden to the people who have to create binary files.
And people using obscure displays are not always so good at this stuff.

Sorry that I do not include code to do the above, but let me know if
this would help to convince you.

Sam - who has been absent due to house renovation and such


Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread Noralf Trønnes



Den 27.01.2022 18.19, skrev David Lechner:
> On 1/25/22 11:57 AM, Noralf Trønnes wrote:
>> Add a driver that will work with most MIPI DBI compatible SPI panels.
>> This avoids adding a driver for every new MIPI DBI compatible controller
>> that is to be used by Linux. The 'compatible' Device Tree property with
>> a '.bin' suffix will be used to load a firmware file that contains the
>> controller configuration.
>>
>> Example (driver will load sainsmart18.bin):
>>
>> display@0 {
>> compatible = "sainsmart18", "panel-mipi-dbi-spi";
>> reg = <0>;
>> reset-gpios = < 25 0>;
>> dc-gpios = < 24 0>;
>> };
>>
> 
> ...
> 
>> +static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
>> +{
>> +    struct device *dev = >dev;
>> +    struct drm_display_mode mode;
>> +    struct mipi_dbi_dev *dbidev;
>> +    const struct firmware *fw;
>> +    const char *compatible;
>> +    struct drm_device *drm;
>> +    struct property *prop;
>> +    bool fw_found = false;
>> +    struct mipi_dbi *dbi;
>> +    struct gpio_desc *dc;
>> +    char fw_name[40];
>> +    int ret;
>> +
>> +    dbidev = devm_drm_dev_alloc(dev, _mipi_dbi_driver, struct
>> mipi_dbi_dev, drm);
>> +    if (IS_ERR(dbidev))
>> +    return PTR_ERR(dbidev);
>> +
>> +    dbi = >dbi;
>> +    drm = >drm;
>> +
>> +    of_property_for_each_string(dev->of_node, "compatible", prop,
>> compatible) {
>> +    snprintf(fw_name, sizeof(fw_name), "%s.bin", compatible);
>> +
>> +    ret = firmware_request_nowarn(, fw_name, dev);
>> +    if (ret) {
>> +    drm_dbg(drm, "No config file found for compatible: '%s'
>> (error=%d)\n",
>> +    compatible, ret);
>> +    continue;
>> +    }
>> +
> 
> Should we add a directory prefix to the firmware file name to avoid the
> possibility of
> file name clashes with unrelated firmwares?

I did consider this but I think it very unlikely that there would be a
collision between the name of display/panel and some other firmware file
which usually have the product name/model in the filename. And in the
unlikelihood that there is a collision it's possible to choose another
name for the compatible.

Noralf.


Re: [PATCH] drm/amd/amdgpu: fix spelling mistake "disbale" -> "disable"

2022-01-27 Thread Alex Deucher
Applied.  Thanks!

Alex

On Thu, Jan 27, 2022 at 3:45 AM tangmeng  wrote:
>
> There is a spelling mistake. Fix it.
>
> Signed-off-by: tangmeng 
> ---
>  drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c 
> b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
> index aef9d059ae52..a642c04cf17d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
> @@ -544,7 +544,7 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device 
> *adev,
>  {
> int r;
>
> -   /* trigger gpu-reset by hypervisor only if TDR disbaled */
> +   /* trigger gpu-reset by hypervisor only if TDR disabled */
> if (!amdgpu_gpu_recovery) {
> /* see what event we get */
> r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION);
> --
> 2.20.1
>
>
>


Re: [PATCH] drm/msm: Remove spurious IRQF_ONESHOT flags from dsi & hdmi

2022-01-27 Thread Dmitry Baryshkov
On Thu, 27 Jan 2022 at 20:04, Daniel Thompson
 wrote:
>
> Quoting the header comments, IRQF_ONESHOT is "Used by threaded interrupts
> which need to keep the irq line disabled until the threaded handler has
> been run.". When applied to an interrupt that doesn't request a threaded
> irq then IRQF_ONESHOT has a lesser known (undocumented?) side effect,
> which it to disable the forced threading of irqs (and for "normal" kernels
> it is a nop). In this case I can find no evidence that suppressing forced
> threading is intentional. Had it been intentional then a driver must adopt
> the raw_spinlock API in order to avoid deadlocks on PREEMPT_RT kernels
> (and avoid calling any kernel API that uses regular spinlocks).
>
> Fix this by removing the spurious additional flag.
>
> This change is required for my Snapdragon 7cx Gen2 tablet to boot-to-GUI
> with PREEMPT_RT enabled.
>
> Signed-off-by: Daniel Thompson 

Could you please split it into two parts: separate DSI and HDMI patches

> ---
>
> Notes:
> Just in case anybody asks, yes! I did use coccinelle to do a quick scan
> for similar issues. I didn't find any other instances in drivers/drm/ .
>
>  drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
>  drivers/gpu/drm/msm/hdmi/hdmi.c| 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
> b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 6b3ced4aaaf5d..3a3f53f0c8ae1 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1877,7 +1877,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
>
> /* do not autoenable, will be enabled later */
> ret = devm_request_irq(>dev, msm_host->irq, dsi_host_irq,
> -   IRQF_TRIGGER_HIGH | IRQF_ONESHOT | IRQF_NO_AUTOEN,
> +   IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN,
> "dsi_isr", msm_host);
> if (ret < 0) {
> dev_err(>dev, "failed to request IRQ%u: %d\n",
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
> index 3acdeae25caf0..a1bfbc4c74bf7 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
> @@ -301,7 +301,7 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,
> }
>
> ret = devm_request_irq(>dev, hdmi->irq,
> -   msm_hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +   msm_hdmi_irq, IRQF_TRIGGER_HIGH,
> "hdmi_isr", hdmi);
> if (ret < 0) {
> DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n",
>
> base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07
> --
> 2.34.1
>


-- 
With best wishes
Dmitry


[PATCH v6 32/35] usb: typec: port-mapper: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Heikki Krogerus 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/usb/typec/port-mapper.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/port-mapper.c b/drivers/usb/typec/port-mapper.c
index 07d307418b47..33fbebc6a85b 100644
--- a/drivers/usb/typec/port-mapper.c
+++ b/drivers/usb/typec/port-mapper.c
@@ -11,19 +11,27 @@
 
 #include "class.h"
 
-static int typec_aggregate_bind(struct device *dev)
+static int typec_aggregate_probe(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
+
return component_bind_all(dev, NULL);
 }
 
-static void typec_aggregate_unbind(struct device *dev)
+static void typec_aggregate_remove(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
+
component_unbind_all(dev, NULL);
 }
 
-static const struct component_master_ops typec_aggregate_ops = {
-   .bind = typec_aggregate_bind,
-   .unbind = typec_aggregate_unbind,
+static struct aggregate_driver typec_aggregate_driver = {
+   .probe = typec_aggregate_probe,
+   .remove = typec_aggregate_remove,
+   .driver = {
+   .name = "typec_aggregate",
+   .owner = THIS_MODULE,
+   },
 };
 
 struct each_port_arg {
@@ -69,10 +77,10 @@ int typec_link_ports(struct typec_port *con)
 * improvements to the component framework. Right now you can only have
 * one master per device.
 */
-   return component_master_add_with_match(>dev, _aggregate_ops, 
arg.match);
+   return component_aggregate_register(>dev, _aggregate_driver, 
arg.match);
 }
 
 void typec_unlink_ports(struct typec_port *con)
 {
-   component_master_del(>dev, _aggregate_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 }
-- 
https://chromeos.dev



[PATCH v6 33/35] ALSA: hda/realtek: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Stefan Binding 
Cc: Lucas Tanure 
Cc: Takashi Iwai 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 sound/pci/hda/patch_realtek.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 668274e52674..80a2164c99b6 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6547,25 +6547,31 @@ static int find_comp_by_dev_name(struct alc_spec *spec, 
const char *name)
return -ENODEV;
 }
 
-static int comp_bind(struct device *dev)
+static int realtek_aggregate_probe(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct hda_codec *cdc = dev_to_hda_codec(dev);
struct alc_spec *spec = cdc->spec;
 
return component_bind_all(dev, spec->comps);
 }
 
-static void comp_unbind(struct device *dev)
+static void realtek_aggregate_remove(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct hda_codec *cdc = dev_to_hda_codec(dev);
struct alc_spec *spec = cdc->spec;
 
component_unbind_all(dev, spec->comps);
 }
 
-static const struct component_master_ops comp_master_ops = {
-   .bind = comp_bind,
-   .unbind = comp_unbind,
+static struct aggregate_driver realtek_aggregate_driver = {
+   .probe = realtek_aggregate_probe,
+   .remove = realtek_aggregate_remove,
+   .driver = {
+   .name = "realtek_aggregate",
+   .owner = THIS_MODULE,
+   },
 };
 
 static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct 
hda_codec *cdc,
@@ -6597,7 +6603,7 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, 
int action, const char
return;
component_match_add(dev, >match, 
comp_match_dev_name, name);
}
-   ret = component_master_add_with_match(dev, _master_ops, 
spec->match);
+   ret = component_aggregate_register(dev, 
_aggregate_driver, spec->match);
if (ret)
codec_err(cdc, "Fail to register component aggregator 
%d\n", ret);
else
@@ -6648,7 +6654,7 @@ static void alc287_fixup_legion_16achg6_speakers(struct 
hda_codec *cdc, const st
"i2c-CLSA0100:00-cs35l41-hda.0");
component_match_add(dev, >match, comp_match_dev_name,
"i2c-CLSA0100:00-cs35l41-hda.1");
-   ret = component_master_add_with_match(dev, _master_ops, 
spec->match);
+   ret = component_aggregate_register(dev, 
_aggregate_driver, spec->match);
if (ret)
codec_err(cdc, "Fail to register component aggregator 
%d\n", ret);
else
-- 
https://chromeos.dev



[PATCH v6 31/35] drm/sprd: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Orson Zhai 
Cc: Baolin Wang 
Cc: Chunyan Zhang 
Cc: Maarten Lankhorst 
Cc: Kevin Tang 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/sprd/sprd_drm.c | 48 +++--
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_drm.c
index a077e2d4d721..ff39b32b20c0 100644
--- a/drivers/gpu/drm/sprd/sprd_drm.c
+++ b/drivers/gpu/drm/sprd/sprd_drm.c
@@ -65,8 +65,9 @@ static struct drm_driver sprd_drm_drv = {
.minor  = DRIVER_MINOR,
 };
 
-static int sprd_drm_bind(struct device *dev)
+static int sprd_drm_aggregate_probe(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct platform_device *pdev = to_platform_device(dev);
struct drm_device *drm;
struct sprd_drm *sprd;
@@ -118,8 +119,9 @@ static int sprd_drm_bind(struct device *dev)
return ret;
 }
 
-static void sprd_drm_unbind(struct device *dev)
+static void sprd_drm_aggregate_remove(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -129,9 +131,28 @@ static void sprd_drm_unbind(struct device *dev)
component_unbind_all(drm->dev, drm);
 }
 
-static const struct component_master_ops drm_component_ops = {
-   .bind = sprd_drm_bind,
-   .unbind = sprd_drm_unbind,
+static void sprd_drm_aggregate_shutdown(struct aggregate_device *adev)
+{
+   struct device *dev = aggregate_device_parent(adev);
+   struct platform_device *pdev = to_platform_device(dev);
+   struct drm_device *drm = platform_get_drvdata(pdev);
+
+   if (!drm) {
+   drm_warn(drm, "drm device is not available, no shutdown\n");
+   return;
+   }
+
+   drm_atomic_helper_shutdown(drm);
+}
+
+static struct aggregate_driver sprd_drm_aggregate_driver = {
+   .probe = sprd_drm_aggregate_probe,
+   .remove = sprd_drm_aggregate_remove,
+   .shutdown = sprd_drm_aggregate_shutdown,
+   .driver = {
+   .name = "sprd_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int compare_of(struct device *dev, void *data)
@@ -141,27 +162,15 @@ static int compare_of(struct device *dev, void *data)
 
 static int sprd_drm_probe(struct platform_device *pdev)
 {
-   return drm_of_component_probe(>dev, compare_of, 
_component_ops);
+   return drm_of_aggregate_probe(>dev, compare_of, 
_drm_aggregate_driver);
 }
 
 static int sprd_drm_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _component_ops);
+   component_aggregate_unregister(>dev, _drm_aggregate_driver);
return 0;
 }
 
-static void sprd_drm_shutdown(struct platform_device *pdev)
-{
-   struct drm_device *drm = platform_get_drvdata(pdev);
-
-   if (!drm) {
-   drm_warn(drm, "drm device is not available, no shutdown\n");
-   return;
-   }
-
-   drm_atomic_helper_shutdown(drm);
-}
-
 static const struct of_device_id drm_match_table[] = {
{ .compatible = "sprd,display-subsystem", },
{ /* sentinel */ },
@@ -171,7 +180,6 @@ MODULE_DEVICE_TABLE(of, drm_match_table);
 static struct platform_driver sprd_drm_driver = {
.probe = sprd_drm_probe,
.remove = sprd_drm_remove,
-   .shutdown = sprd_drm_shutdown,
.driver = {
.name = "sprd-drm-drv",
.of_match_table = drm_match_table,
-- 
https://chromeos.dev



[PATCH v6 35/35] component: Remove component_master_ops and friends

2022-01-27 Thread Stephen Boyd
The struct is unused now so drop it along with the functions that use
it.

Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/base/component.c  | 149 --
 drivers/gpu/drm/drm_drv.c |   2 +-
 include/linux/component.h |  44 ---
 3 files changed, 17 insertions(+), 178 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 5b91a114786d..c9d17ea64226 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -57,7 +57,6 @@ struct component_match {
 };
 
 struct aggregate_device {
-   const struct component_master_ops *ops;
struct device *parent;
struct device dev;
struct component_match *match;
@@ -154,18 +153,12 @@ static void component_debugfs_del(struct aggregate_device 
*m)
 
 #endif
 
-struct aggregate_bus_find_data {
-   const struct component_master_ops *ops;
-   struct device *parent;
-};
-
 static int aggregate_bus_find_match(struct device *dev, const void *_data)
 {
struct aggregate_device *adev = to_aggregate_device(dev);
-   const struct aggregate_bus_find_data *data = _data;
+   const struct device *parent = _data;
 
-   if (adev->parent == data->parent &&
-   (!data->ops || adev->ops == data->ops))
+   if (adev->parent == parent)
return 1;
 
return 0;
@@ -426,30 +419,15 @@ static int aggregate_device_match(struct device *dev, 
struct device_driver *drv)
return ret;
 }
 
-/* TODO: Remove once all aggregate drivers use component_aggregate_register() 
*/
-static int component_probe_bind(struct aggregate_device *adev)
-{
-   return adev->ops->bind(adev->parent);
-}
-
-static void component_remove_unbind(struct aggregate_device *adev)
-{
-   adev->ops->unbind(adev->parent);
-}
-
 static int aggregate_driver_probe(struct device *dev)
 {
const struct aggregate_driver *adrv = to_aggregate_driver(dev->driver);
struct aggregate_device *adev = to_aggregate_device(dev);
-   bool modern = adrv->probe != component_probe_bind;
int ret;
 
-   /* Only do runtime PM when drivers migrate */
-   if (modern) {
-   pm_runtime_get_noresume(dev);
-   pm_runtime_set_active(dev);
-   pm_runtime_enable(dev);
-   }
+   pm_runtime_get_noresume(dev);
+   pm_runtime_set_active(dev);
+   pm_runtime_enable(dev);
 
mutex_lock(_mutex);
if (devres_open_group(adev->parent, adev, GFP_KERNEL)) {
@@ -462,7 +440,7 @@ static int aggregate_driver_probe(struct device *dev)
devres_close_group(adev->parent, NULL);
mutex_unlock(_mutex);
 
-   if (ret && modern) {
+   if (ret) {
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
pm_runtime_put_noidle(dev);
@@ -475,15 +453,10 @@ static void aggregate_driver_remove(struct device *dev)
 {
const struct aggregate_driver *adrv = to_aggregate_driver(dev->driver);
struct aggregate_device *adev = to_aggregate_device(dev);
-   bool modern = adrv->remove != component_remove_unbind;
 
-   /* Only do runtime PM when drivers migrate */
-   if (modern)
-   pm_runtime_get_sync(dev);
+   pm_runtime_get_sync(dev);
adrv->remove(to_aggregate_device(dev));
devres_release_group(adev->parent, adev);
-   if (!modern)
-   return;
 
pm_runtime_put_noidle(dev);
 
@@ -509,16 +482,11 @@ static struct bus_type aggregate_bus_type = {
 };
 
 /* Callers take ownership of return value, should call put_device() */
-static struct aggregate_device *__aggregate_find(struct device *parent,
-   const struct component_master_ops *ops)
+static struct aggregate_device *__aggregate_find(struct device *parent)
 {
struct device *dev;
-   struct aggregate_bus_find_data data = {
-   .ops = ops,
-   .parent = parent,
-   };
 
-   dev = bus_find_device(_bus_type, NULL, ,
+   dev = bus_find_device(_bus_type, NULL, parent,
  aggregate_bus_find_match);
 
return dev ? to_aggregate_device(dev) : NULL;
@@ -551,7 +519,7 @@ static void aggregate_driver_unregister(struct 
aggregate_driver *adrv)
 }
 
 static struct aggregate_device *aggregate_device_add(struct device *parent,
-   const struct component_master_ops *ops, struct aggregate_driver *adrv,
+   struct aggregate_driver *adrv,
struct component_match *match)
 {
struct aggregate_device *adev;
@@ -576,7 +544,6 @@ static struct aggregate_device *aggregate_device_add(struct 
device *parent,
adev->parent = parent;
adev->dev.bus = _bus_type;
adev->dev.release = aggregate_device_release;
-   adev->ops = ops;
adev->match = match;
adev->adrv = adrv;
dev_set_name(>dev, 

[PATCH v6 34/35] component: Get rid of drm_of_component_probe()

2022-01-27 Thread Stephen Boyd
There aren't any users anymore so drop it.

Cc: Laurent Pinchart 
Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/drm_of.c | 85 +---
 include/drm/drm_of.h | 12 --
 2 files changed, 19 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 0fe822319aae..84e285432d13 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -99,18 +99,30 @@ void drm_of_component_match_add(struct device *master,
 }
 EXPORT_SYMBOL_GPL(drm_of_component_match_add);
 
-static int _drm_of_component_probe(struct device *dev,
+/**
+ * drm_of_aggregate_probe - Generic probe function for a component based 
aggregate host
+ * @dev: device containing the OF node
+ * @compare_of: compare function used for matching components
+ * @adrv: aggregate driver to be used
+ *
+ * Parse the platform device OF node and bind all the components associated
+ * with the aggregate device. Interface ports are added before the encoders in
+ * order to satisfy their .bind_component requirements
+ * See Documentation/devicetree/bindings/graph.txt for the bindings.
+ *
+ * Returns zero if successful, or one of the standard error codes if it fails.
+ */
+int drm_of_aggregate_probe(struct device *dev,
   int (*compare_of)(struct device *, void *),
-  struct component_match **matchptr)
+  struct aggregate_driver *adrv)
 {
struct device_node *ep, *port, *remote;
+   struct component_match *match = NULL;
int i;
 
if (!dev->of_node)
return -EINVAL;
 
-   *matchptr = NULL;
-
/*
 * Bind the crtc's ports first, so that drm_of_find_possible_crtcs()
 * called from encoder's .bind callbacks works as expected
@@ -121,7 +133,7 @@ static int _drm_of_component_probe(struct device *dev,
break;
 
if (of_device_is_available(port->parent))
-   drm_of_component_match_add(dev, matchptr, compare_of,
+   drm_of_component_match_add(dev, , compare_of,
   port);
 
of_node_put(port);
@@ -132,7 +144,7 @@ static int _drm_of_component_probe(struct device *dev,
return -ENODEV;
}
 
-   if (!*matchptr) {
+   if (!match) {
dev_err(dev, "no available port\n");
return -ENODEV;
}
@@ -162,72 +174,13 @@ static int _drm_of_component_probe(struct device *dev,
continue;
}
 
-   drm_of_component_match_add(dev, matchptr, compare_of,
+   drm_of_component_match_add(dev, , compare_of,
   remote);
of_node_put(remote);
}
of_node_put(port);
}
 
-   return 0;
-}
-
-/**
- * drm_of_component_probe - Generic probe function for a component based master
- * @dev: master device containing the OF node
- * @compare_of: compare function used for matching components
- * @m_ops: component master ops to be used
- *
- * Parse the platform device OF node and bind all the components associated
- * with the master. Interface ports are added before the encoders in order to
- * satisfy their .bind requirements
- * See Documentation/devicetree/bindings/graph.txt for the bindings.
- *
- * Deprecated: Use drm_of_aggregate_probe() instead.
- *
- * Returns zero if successful, or one of the standard error codes if it fails.
- */
-int drm_of_component_probe(struct device *dev,
-  int (*compare_of)(struct device *, void *),
-  const struct component_master_ops *m_ops)
-{
-
-   struct component_match *match;
-   int ret;
-
-   ret = _drm_of_component_probe(dev, compare_of, );
-   if (ret)
-   return ret;
-
-   return component_master_add_with_match(dev, m_ops, match);
-}
-EXPORT_SYMBOL(drm_of_component_probe);
-
-
-/**
- * drm_of_aggregate_probe - Generic probe function for a component based 
aggregate host
- * @dev: device containing the OF node
- * @compare_of: compare function used for matching components
- * @adrv: aggregate driver to be used
- *
- * Parse the platform device OF node and bind all the components associated
- * with the aggregate device. Interface ports are added before the encoders in
- * order to satisfy their .bind_component requirements
- * See Documentation/devicetree/bindings/graph.txt for the bindings.
- *
- * Returns zero if successful, or one of the standard error codes if it fails.
- */
-int drm_of_aggregate_probe(struct device *dev,
-  int (*compare_of)(struct device *, void *),
-  struct 

Re: [PATCH v2 0/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread Noralf Trønnes



Den 27.01.2022 18.13, skrev David Lechner:
> On 1/25/22 11:56 AM, Noralf Trønnes wrote:
>> Hi,
>>
>> This patchset adds a driver that will work with most MIPI DBI compatible
>> SPI panels out there.
>>
>> It's a follow up on 'drm/tiny/st7735r: Match up with staging/fbtft
>> driver'[1] which aimed at making the st7735r driver work with all panels
>> adding DT properties.
>>
>> Maxime gave[2] a good overview of the situation with these displays and
>> proposed to make a driver that works with all MIPI DBI compatible
>> controllers and use a firmware file to provide the controller setup for
>> a particular panel.
>>
>> Main change since previous version:
>> - Drop model property and use the compatible property instead (Rob)
>>
>> Noralf.
>>
>> [1]
>> https://lore.kernel.org/dri-devel/20211124150757.17929-1-nor...@tronnes.org/
>>
>> [2]
>> https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
>>
>>
>> Noralf Trønnes (3):
>>    dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
>>    drm/mipi-dbi: Add driver_private member to struct mipi_dbi_dev
>>    drm/panel: Add MIPI DBI compatible SPI driver
>>
>>   .../display/panel/panel-mipi-dbi-spi.yaml |  59 +++
>>   MAINTAINERS   |   8 +
>>   drivers/gpu/drm/panel/Kconfig |  11 +
>>   drivers/gpu/drm/panel/Makefile    |   1 +
>>   drivers/gpu/drm/panel/panel-mipi-dbi.c    | 394 ++
>>   include/drm/drm_mipi_dbi.h    |   2 +
>>   6 files changed, 475 insertions(+)
>>   create mode 100644
>> Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml
>>   create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c
>>
> 
> It would be useful to also include a patch for a tool to create
> these "firmware" files. For example a Python script that takes
> a more human-readable input and generates a .bin file.

I will put a script on the github repo that holds the wiki for the
driver. I haven't made the script yet, just using a hack for now until
the format is decided upon.

Noralf.


[PATCH v6 30/35] ASoC: codecs: wcd938x: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Acked-by: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 sound/soc/codecs/wcd938x.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index eff200a07d9f..6e1c9f93c819 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -4317,8 +4317,9 @@ static struct snd_soc_dai_driver wcd938x_dais[] = {
},
 };
 
-static int wcd938x_bind(struct device *dev)
+static int wcd938x_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct wcd938x_priv *wcd938x = dev_get_drvdata(dev);
int ret;
 
@@ -4401,8 +4402,9 @@ static int wcd938x_bind(struct device *dev)
 
 }
 
-static void wcd938x_unbind(struct device *dev)
+static void wcd938x_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct wcd938x_priv *wcd938x = dev_get_drvdata(dev);
 
device_link_remove(dev, wcd938x->txdev);
@@ -4412,9 +4414,13 @@ static void wcd938x_unbind(struct device *dev)
component_unbind_all(dev, wcd938x);
 }
 
-static const struct component_master_ops wcd938x_comp_ops = {
-   .bind   = wcd938x_bind,
-   .unbind = wcd938x_unbind,
+static struct aggregate_driver wcd938x_aggregate_driver = {
+   .probe  = wcd938x_bind,
+   .remove = wcd938x_unbind,
+   .driver = {
+   .name = "wcd938x_snd",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int wcd938x_compare_of(struct device *dev, void *data)
@@ -4483,7 +4489,7 @@ static int wcd938x_probe(struct platform_device *pdev)
 
wcd938x_reset(wcd938x);
 
-   ret = component_master_add_with_match(dev, _comp_ops, match);
+   ret = component_aggregate_register(dev, _aggregate_driver, 
match);
if (ret)
return ret;
 
@@ -4499,7 +4505,7 @@ static int wcd938x_probe(struct platform_device *pdev)
 
 static int wcd938x_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _comp_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 25/35] iommu/mediatek: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Yong Wu 
Cc: Joerg Roedel 
Cc: Will Deacon 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/iommu/mtk_iommu.c| 14 +-
 drivers/iommu/mtk_iommu.h|  6 --
 drivers/iommu/mtk_iommu_v1.c | 14 +-
 drivers/memory/mtk-smi.c | 10 --
 4 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 25b834104790..8e722898cbe2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -752,9 +752,13 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data 
*data)
return 0;
 }
 
-static const struct component_master_ops mtk_iommu_com_ops = {
-   .bind   = mtk_iommu_bind,
-   .unbind = mtk_iommu_unbind,
+static struct aggregate_driver mtk_iommu_aggregate_driver = {
+   .probe  = mtk_iommu_bind,
+   .remove = mtk_iommu_unbind,
+   .driver = {
+   .name   = "mtk_iommu_agg",
+   .owner  = THIS_MODULE,
+   },
 };
 
 static int mtk_iommu_probe(struct platform_device *pdev)
@@ -895,7 +899,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
goto out_list_del;
}
 
-   ret = component_master_add_with_match(dev, _iommu_com_ops, match);
+   ret = component_aggregate_register(dev, _iommu_aggregate_driver, 
match);
if (ret)
goto out_bus_set_null;
return ret;
@@ -928,7 +932,7 @@ static int mtk_iommu_remove(struct platform_device *pdev)
device_link_remove(data->smicomm_dev, >dev);
pm_runtime_disable(>dev);
devm_free_irq(>dev, data->irq, data);
-   component_master_del(>dev, _iommu_com_ops);
+   component_aggregate_unregister(>dev, _iommu_aggregate_driver);
return 0;
 }
 
diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h
index f81fa8862ed0..125be5819c42 100644
--- a/drivers/iommu/mtk_iommu.h
+++ b/drivers/iommu/mtk_iommu.h
@@ -94,15 +94,17 @@ static inline void release_of(struct device *dev, void 
*data)
of_node_put(data);
 }
 
-static inline int mtk_iommu_bind(struct device *dev)
+static inline int mtk_iommu_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mtk_iommu_data *data = dev_get_drvdata(dev);
 
return component_bind_all(dev, >larb_imu);
 }
 
-static inline void mtk_iommu_unbind(struct device *dev)
+static inline void mtk_iommu_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mtk_iommu_data *data = dev_get_drvdata(dev);
 
component_unbind_all(dev, >larb_imu);
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index be22fcf988ce..5fb29058a165 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -534,9 +534,13 @@ static const struct of_device_id mtk_iommu_of_ids[] = {
{}
 };
 
-static const struct component_master_ops mtk_iommu_com_ops = {
-   .bind   = mtk_iommu_bind,
-   .unbind = mtk_iommu_unbind,
+static struct aggregate_driver mtk_iommu_aggregate_driver = {
+   .probe  = mtk_iommu_bind,
+   .remove = mtk_iommu_unbind,
+   .driver = {
+   .name   = "mtk_iommu_agg",
+   .owner  = THIS_MODULE,
+   },
 };
 
 static int mtk_iommu_probe(struct platform_device *pdev)
@@ -624,7 +628,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
goto out_dev_unreg;
}
 
-   ret = component_master_add_with_match(dev, _iommu_com_ops, match);
+   ret = component_aggregate_register(dev, _iommu_aggregate_driver, 
match);
if (ret)
goto out_bus_set_null;
return ret;
@@ -650,7 +654,7 @@ static int mtk_iommu_remove(struct platform_device *pdev)
 
clk_disable_unprepare(data->bclk);
devm_free_irq(>dev, data->irq, data);
-   component_master_del(>dev, _iommu_com_ops);
+   component_aggregate_unregister(>dev, _iommu_aggregate_driver);
return 0;
 }
 
diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index e201e5976f34..0910fe109f53 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -175,6 +175,8 @@ mtk_smi_larb_bind(struct device *dev, struct device 
*master, void *data)
larb->larbid = i;
larb->mmu = _mmu[i].mmu;
larb->bank = larb_mmu[i].bank;
+
+   pm_runtime_enable(dev);
return 0;
}
}
@@ -450,15 +452,11 @@ static int 

[PATCH v6 27/35] power: supply: ab8500: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Acked-by: Sebastian Reichel 
Tested-by: Linus Walleij 
Cc: 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/power/supply/ab8500_charger.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/power/supply/ab8500_charger.c 
b/drivers/power/supply/ab8500_charger.c
index ce074c018dcb..e3164e8335ca 100644
--- a/drivers/power/supply/ab8500_charger.c
+++ b/drivers/power/supply/ab8500_charger.c
@@ -3335,8 +3335,9 @@ static const struct power_supply_desc ab8500_usb_chg_desc 
= {
.get_property   = ab8500_charger_usb_get_property,
 };
 
-static int ab8500_charger_bind(struct device *dev)
+static int ab8500_charger_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct ab8500_charger *di = dev_get_drvdata(dev);
int ch_stat;
int ret;
@@ -3377,8 +3378,9 @@ static int ab8500_charger_bind(struct device *dev)
return 0;
 }
 
-static void ab8500_charger_unbind(struct device *dev)
+static void ab8500_charger_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct ab8500_charger *di = dev_get_drvdata(dev);
int ret;
 
@@ -3403,9 +3405,13 @@ static void ab8500_charger_unbind(struct device *dev)
component_unbind_all(dev, di);
 }
 
-static const struct component_master_ops ab8500_charger_comp_ops = {
-   .bind = ab8500_charger_bind,
-   .unbind = ab8500_charger_unbind,
+static struct aggregate_driver ab8500_charger_aggregate_driver = {
+   .probe = ab8500_charger_bind,
+   .remove = ab8500_charger_unbind,
+   .driver = {
+   .name = "ab8500_charger_agg",
+   .owner = THIS_MODULE,
+   },
 };
 
 static struct platform_driver *const ab8500_charger_component_drivers[] = {
@@ -3694,9 +3700,7 @@ static int ab8500_charger_probe(struct platform_device 
*pdev)
}
 
 
-   ret = component_master_add_with_match(>dev,
- _charger_comp_ops,
- match);
+   ret = component_aggregate_register(>dev, 
_charger_aggregate_driver, match);
if (ret) {
dev_err(dev, "failed to add component master\n");
goto free_notifier;
@@ -3721,7 +3725,7 @@ static int ab8500_charger_remove(struct platform_device 
*pdev)
 {
struct ab8500_charger *di = platform_get_drvdata(pdev);
 
-   component_master_del(>dev, _charger_comp_ops);
+   component_aggregate_unregister(>dev, 
_charger_aggregate_driver);
 
usb_unregister_notifier(di->usb_phy, >nb);
ab8500_bm_of_remove(di->usb_chg.psy, di->bm);
-- 
https://chromeos.dev



[PATCH v6 26/35] mei: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Tomas Winkler 
Cc: Vitaly Lubart 
Cc: Daniele Ceraolo Spurio 
Cc: Rodrigo Vivi 
Cc: Arnd Bergmann 
Cc: Greg Kroah-Hartman 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Cc: Alexander Usyskin 
Signed-off-by: Stephen Boyd 
---
 drivers/misc/mei/hdcp/mei_hdcp.c | 22 +-
 drivers/misc/mei/pxp/mei_pxp.c   | 22 +-
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c
index ec2a4fce8581..3c6e4e3bf212 100644
--- a/drivers/misc/mei/hdcp/mei_hdcp.c
+++ b/drivers/misc/mei/hdcp/mei_hdcp.c
@@ -732,8 +732,9 @@ static const struct i915_hdcp_component_ops mei_hdcp_ops = {
.close_hdcp_session = mei_hdcp_close_session,
 };
 
-static int mei_component_master_bind(struct device *dev)
+static int mei_hdcp_aggregate_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mei_cl_device *cldev = to_mei_cl_device(dev);
struct i915_hdcp_comp_master *comp_master =
mei_cldev_get_drvdata(cldev);
@@ -749,8 +750,9 @@ static int mei_component_master_bind(struct device *dev)
return 0;
 }
 
-static void mei_component_master_unbind(struct device *dev)
+static void mei_hdcp_aggregate_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mei_cl_device *cldev = to_mei_cl_device(dev);
struct i915_hdcp_comp_master *comp_master =
mei_cldev_get_drvdata(cldev);
@@ -759,9 +761,13 @@ static void mei_component_master_unbind(struct device *dev)
component_unbind_all(dev, comp_master);
 }
 
-static const struct component_master_ops mei_component_master_ops = {
-   .bind = mei_component_master_bind,
-   .unbind = mei_component_master_unbind,
+static struct aggregate_driver mei_aggregate_driver = {
+   .probe = mei_hdcp_aggregate_bind,
+   .remove = mei_hdcp_aggregate_unbind,
+   .driver = {
+   .name = "mei_hdcp_agg",
+   .owner = THIS_MODULE,
+   },
 };
 
 /**
@@ -826,9 +832,7 @@ static int mei_hdcp_probe(struct mei_cl_device *cldev,
}
 
mei_cldev_set_drvdata(cldev, comp_master);
-   ret = component_master_add_with_match(>dev,
- _component_master_ops,
- master_match);
+   ret = component_aggregate_register(>dev, _aggregate_driver, 
master_match);
if (ret < 0) {
dev_err(>dev, "Master comp add failed %d\n", ret);
goto err_exit;
@@ -850,7 +854,7 @@ static void mei_hdcp_remove(struct mei_cl_device *cldev)
mei_cldev_get_drvdata(cldev);
int ret;
 
-   component_master_del(>dev, _component_master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
kfree(comp_master);
mei_cldev_set_drvdata(cldev, NULL);
 
diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c
index f7380d387bab..887e43e6ba5f 100644
--- a/drivers/misc/mei/pxp/mei_pxp.c
+++ b/drivers/misc/mei/pxp/mei_pxp.c
@@ -83,8 +83,9 @@ static const struct i915_pxp_component_ops mei_pxp_ops = {
.recv = mei_pxp_receive_message,
 };
 
-static int mei_component_master_bind(struct device *dev)
+static int mei_pxp_aggregate_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mei_cl_device *cldev = to_mei_cl_device(dev);
struct i915_pxp_component *comp_master = mei_cldev_get_drvdata(cldev);
int ret;
@@ -98,17 +99,22 @@ static int mei_component_master_bind(struct device *dev)
return 0;
 }
 
-static void mei_component_master_unbind(struct device *dev)
+static void mei_pxp_aggregate_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mei_cl_device *cldev = to_mei_cl_device(dev);
struct i915_pxp_component *comp_master = mei_cldev_get_drvdata(cldev);
 
component_unbind_all(dev, comp_master);
 }
 
-static const struct component_master_ops mei_component_master_ops = {
-   .bind = mei_component_master_bind,
-   .unbind = mei_component_master_unbind,
+static struct aggregate_driver mei_aggregate_driver = {
+   .probe = mei_pxp_aggregate_bind,
+   .remove = mei_pxp_aggregate_unbind,
+   .driver = {
+   .name = "mei_pxp_agg",
+   .owner = THIS_MODULE,
+   }
 };
 
 /**
@@ -173,9 +179,7 @@ static int mei_pxp_probe(struct mei_cl_device *cldev,
}
 

[PATCH v6 22/35] drm/sun4i: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Maxime Ripard 
Cc: Chen-Yu Tsai 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index b630614b3d72..9f20c3f0f93e 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -56,8 +56,9 @@ static const struct drm_driver sun4i_drv_driver = {
DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(drm_sun4i_gem_dumb_create),
 };
 
-static int sun4i_drv_bind(struct device *dev)
+static int sun4i_drv_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm;
struct sun4i_drv *drv;
int ret;
@@ -125,8 +126,9 @@ static int sun4i_drv_bind(struct device *dev)
return ret;
 }
 
-static void sun4i_drv_unbind(struct device *dev)
+static void sun4i_drv_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -140,9 +142,13 @@ static void sun4i_drv_unbind(struct device *dev)
drm_dev_put(drm);
 }
 
-static const struct component_master_ops sun4i_drv_master_ops = {
-   .bind   = sun4i_drv_bind,
-   .unbind = sun4i_drv_unbind,
+static struct aggregate_driver sun4i_aggregate_driver = {
+   .probe  = sun4i_drv_bind,
+   .remove = sun4i_drv_unbind,
+   .driver = {
+   .name = "sun4i_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static bool sun4i_drv_node_is_connector(struct device_node *node)
@@ -398,16 +404,14 @@ static int sun4i_drv_probe(struct platform_device *pdev)
}
 
if (count)
-   return component_master_add_with_match(>dev,
-  _drv_master_ops,
-  match);
-   else
-   return 0;
+   return component_aggregate_register(>dev, 
_aggregate_driver, match);
+
+   return 0;
 }
 
 static int sun4i_drv_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drv_master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 28/35] fbdev: omap2: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: 
Cc: 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
index a6b1c1598040..0bdb9f909992 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
@@ -1067,8 +1067,9 @@ static int dss_video_pll_probe(struct platform_device 
*pdev)
 }
 
 /* DSS HW IP initialisation */
-static int dss_bind(struct device *dev)
+static int dss_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct platform_device *pdev = to_platform_device(dev);
struct resource *dss_mem;
u32 rev;
@@ -1167,8 +1168,9 @@ static int dss_bind(struct device *dev)
return r;
 }
 
-static void dss_unbind(struct device *dev)
+static void dss_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct platform_device *pdev = to_platform_device(dev);
 
dss_initialized = false;
@@ -1188,9 +1190,13 @@ static void dss_unbind(struct device *dev)
dss_put_clocks();
 }
 
-static const struct component_master_ops dss_component_ops = {
-   .bind = dss_bind,
-   .unbind = dss_unbind,
+static struct aggregate_driver dss_aggregate_driver = {
+   .probe = dss_bind,
+   .remove = dss_unbind,
+   .driver = {
+   .name = "dss_fbdev",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int dss_component_compare(struct device *dev, void *data)
@@ -1225,7 +1231,7 @@ static int dss_probe(struct platform_device *pdev)
/* add all the child devices as components */
device_for_each_child(>dev, , dss_add_child_component);
 
-   r = component_master_add_with_match(>dev, _component_ops, 
match);
+   r = component_aggregate_register(>dev, _aggregate_driver, 
match);
if (r)
return r;
 
@@ -1234,7 +1240,7 @@ static int dss_probe(struct platform_device *pdev)
 
 static int dss_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _component_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 29/35] sound: hdac: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Kai Vehmanen 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 sound/hda/hdac_component.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c
index bb37e7e0bd79..4ec5d9bf8533 100644
--- a/sound/hda/hdac_component.c
+++ b/sound/hda/hdac_component.c
@@ -181,8 +181,9 @@ int snd_hdac_acomp_get_eld(struct hdac_device *codec, 
hda_nid_t nid, int dev_id,
 }
 EXPORT_SYMBOL_GPL(snd_hdac_acomp_get_eld);
 
-static int hdac_component_master_bind(struct device *dev)
+static int hdac_component_master_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_audio_component *acomp = hdac_get_acomp(dev);
int ret;
 
@@ -222,8 +223,9 @@ static int hdac_component_master_bind(struct device *dev)
return ret;
 }
 
-static void hdac_component_master_unbind(struct device *dev)
+static void hdac_component_master_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_audio_component *acomp = hdac_get_acomp(dev);
 
if (acomp->audio_ops && acomp->audio_ops->master_unbind)
@@ -233,9 +235,13 @@ static void hdac_component_master_unbind(struct device 
*dev)
WARN_ON(acomp->ops || acomp->dev);
 }
 
-static const struct component_master_ops hdac_component_master_ops = {
-   .bind = hdac_component_master_bind,
-   .unbind = hdac_component_master_unbind,
+static struct aggregate_driver hdac_aggregate_driver = {
+   .probe = hdac_component_master_bind,
+   .remove = hdac_component_master_unbind,
+   .driver = {
+   .name = "hdac_agg",
+   .owner = THIS_MODULE,
+   },
 };
 
 /**
@@ -303,8 +309,7 @@ int snd_hdac_acomp_init(struct hdac_bus *bus,
devres_add(dev, acomp);
 
component_match_add_typed(dev, , match_master, bus);
-   ret = component_master_add_with_match(dev, _component_master_ops,
- match);
+   ret = component_aggregate_register(dev, _aggregate_driver, match);
if (ret < 0)
goto out_err;
 
@@ -344,7 +349,7 @@ int snd_hdac_acomp_exit(struct hdac_bus *bus)
bus->display_power_active = 0;
bus->display_power_status = 0;
 
-   component_master_del(dev, _component_master_ops);
+   component_aggregate_unregister(dev, _aggregate_driver);
 
bus->audio_component = NULL;
devres_destroy(dev, hdac_acomp_release, NULL, NULL);
-- 
https://chromeos.dev



[PATCH v6 24/35] drm/vc4: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Emma Anholt 
Cc: Maxime Ripard 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/vc4/vc4_drv.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 16abc3a3d601..297ecddea5fb 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -212,8 +212,9 @@ static void vc4_match_add_drivers(struct device *dev,
}
 }
 
-static int vc4_drm_bind(struct device *dev)
+static int vc4_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct platform_device *pdev = to_platform_device(dev);
struct drm_device *drm;
struct vc4_dev *vc4;
@@ -284,8 +285,9 @@ static int vc4_drm_bind(struct device *dev)
return ret;
 }
 
-static void vc4_drm_unbind(struct device *dev)
+static void vc4_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -293,9 +295,13 @@ static void vc4_drm_unbind(struct device *dev)
drm_atomic_helper_shutdown(drm);
 }
 
-static const struct component_master_ops vc4_drm_ops = {
-   .bind = vc4_drm_bind,
-   .unbind = vc4_drm_unbind,
+static struct aggregate_driver vc4_aggregate_driver = {
+   .probe = vc4_drm_bind,
+   .remove = vc4_drm_unbind,
+   .driver = {
+   .name = "vc4_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 /*
@@ -326,12 +332,12 @@ static int vc4_platform_drm_probe(struct platform_device 
*pdev)
vc4_match_add_drivers(dev, ,
  component_drivers, ARRAY_SIZE(component_drivers));
 
-   return component_master_add_with_match(dev, _drm_ops, match);
+   return component_aggregate_register(dev, _aggregate_driver, match);
 }
 
 static int vc4_platform_drm_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 21/35] drm/sti: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/sti/sti_drv.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index c7efb43b83ee..958db315d547 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -182,8 +182,9 @@ static void sti_cleanup(struct drm_device *ddev)
ddev->dev_private = NULL;
 }
 
-static int sti_bind(struct device *dev)
+static int sti_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *ddev;
int ret;
 
@@ -216,8 +217,9 @@ static int sti_bind(struct device *dev)
return ret;
 }
 
-static void sti_unbind(struct device *dev)
+static void sti_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *ddev = dev_get_drvdata(dev);
 
drm_dev_unregister(ddev);
@@ -225,9 +227,13 @@ static void sti_unbind(struct device *dev)
drm_dev_put(ddev);
 }
 
-static const struct component_master_ops sti_ops = {
-   .bind = sti_bind,
-   .unbind = sti_unbind,
+static struct aggregate_driver sti_aggregate_driver = {
+   .probe = sti_bind,
+   .remove = sti_unbind,
+   .driver = {
+   .name = "sti_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int sti_platform_probe(struct platform_device *pdev)
@@ -249,12 +255,12 @@ static int sti_platform_probe(struct platform_device 
*pdev)
child_np = of_get_next_available_child(node, child_np);
}
 
-   return component_master_add_with_match(dev, _ops, match);
+   return component_aggregate_register(dev, _aggregate_driver, match);
 }
 
 static int sti_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 23/35] drm/tilcdc: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Tested-by: Jyri Sarha 
Cc: Tomi Valkeinen 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3ddb7c710a3d..c12c579ce66f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -529,13 +529,16 @@ static const struct dev_pm_ops tilcdc_pm_ops = {
 /*
  * Platform driver:
  */
-static int tilcdc_bind(struct device *dev)
+static int tilcdc_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
+
return tilcdc_init(_driver, dev);
 }
 
-static void tilcdc_unbind(struct device *dev)
+static void tilcdc_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *ddev = dev_get_drvdata(dev);
 
/* Check if a subcomponent has already triggered the unloading. */
@@ -545,9 +548,13 @@ static void tilcdc_unbind(struct device *dev)
tilcdc_fini(dev_get_drvdata(dev));
 }
 
-static const struct component_master_ops tilcdc_comp_ops = {
-   .bind = tilcdc_bind,
-   .unbind = tilcdc_unbind,
+static struct aggregate_driver tilcdc_aggregate_driver = {
+   .probe = tilcdc_bind,
+   .remove = tilcdc_unbind,
+   .driver = {
+   .name = "tilcdc_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int tilcdc_pdev_probe(struct platform_device *pdev)
@@ -564,12 +571,9 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
ret = tilcdc_get_external_components(>dev, );
if (ret < 0)
return ret;
-   else if (ret == 0)
+   if (ret == 0)
return tilcdc_init(_driver, >dev);
-   else
-   return component_master_add_with_match(>dev,
-  _comp_ops,
-  match);
+   return component_aggregate_register(>dev, 
_aggregate_driver, match);
 }
 
 static int tilcdc_pdev_remove(struct platform_device *pdev)
@@ -579,10 +583,10 @@ static int tilcdc_pdev_remove(struct platform_device 
*pdev)
ret = tilcdc_get_external_components(>dev, NULL);
if (ret < 0)
return ret;
-   else if (ret == 0)
+   if (ret == 0)
tilcdc_fini(platform_get_drvdata(pdev));
else
-   component_master_del(>dev, _comp_ops);
+   component_aggregate_unregister(>dev, 
_aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 20/35] drm/rockchip: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Sandy Huang 
Cc: "Heiko Stübner" 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index bec207de4544..6a6ed293d7a0 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -108,8 +108,9 @@ static void rockchip_iommu_cleanup(struct drm_device 
*drm_dev)
iommu_domain_free(private->domain);
 }
 
-static int rockchip_drm_bind(struct device *dev)
+static int rockchip_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm_dev;
struct rockchip_drm_private *private;
int ret;
@@ -179,8 +180,9 @@ static int rockchip_drm_bind(struct device *dev)
return ret;
 }
 
-static void rockchip_drm_unbind(struct device *dev)
+static void rockchip_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm_dev = dev_get_drvdata(dev);
 
drm_dev_unregister(drm_dev);
@@ -331,9 +333,13 @@ static struct component_match 
*rockchip_drm_match_add(struct device *dev)
return match ?: ERR_PTR(-ENODEV);
 }
 
-static const struct component_master_ops rockchip_drm_ops = {
-   .bind = rockchip_drm_bind,
-   .unbind = rockchip_drm_unbind,
+static struct aggregate_driver rockchip_aggregate_driver = {
+   .probe = rockchip_drm_bind,
+   .remove = rockchip_drm_unbind,
+   .driver = {
+   .name = "rockchip_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int rockchip_drm_platform_of_probe(struct device *dev)
@@ -404,7 +410,7 @@ static int rockchip_drm_platform_probe(struct 
platform_device *pdev)
if (IS_ERR(match))
return PTR_ERR(match);
 
-   ret = component_master_add_with_match(dev, _drm_ops, match);
+   ret = component_aggregate_register(dev, _aggregate_driver, 
match);
if (ret < 0) {
rockchip_drm_match_remove(dev);
return ret;
@@ -415,7 +421,7 @@ static int rockchip_drm_platform_probe(struct 
platform_device *pdev)
 
 static int rockchip_drm_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
rockchip_drm_match_remove(>dev);
 
-- 
https://chromeos.dev



[PATCH v6 19/35] drm/omap: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Tomi Valkeinen 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 69b3e15b9356..96a290a7bd68 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1304,8 +1304,9 @@ static const struct soc_device_attribute 
dss_soc_devices[] = {
{ /* sentinel */ }
 };
 
-static int dss_bind(struct device *dev)
+static int dss_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct dss_device *dss = dev_get_drvdata(dev);
struct platform_device *drm_pdev;
struct dss_pdata pdata;
@@ -1330,8 +1331,9 @@ static int dss_bind(struct device *dev)
return 0;
 }
 
-static void dss_unbind(struct device *dev)
+static void dss_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct dss_device *dss = dev_get_drvdata(dev);
 
platform_device_unregister(dss->drm_pdev);
@@ -1339,9 +1341,13 @@ static void dss_unbind(struct device *dev)
component_unbind_all(dev, NULL);
 }
 
-static const struct component_master_ops dss_component_ops = {
-   .bind = dss_bind,
-   .unbind = dss_unbind,
+static struct aggregate_driver dss_aggregate_driver = {
+   .probe = dss_bind,
+   .remove = dss_unbind,
+   .driver = {
+   .name = "dss_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int dss_component_compare(struct device *dev, void *data)
@@ -1502,7 +1508,7 @@ static int dss_probe(struct platform_device *pdev)
cmatch.match = 
device_for_each_child(>dev, , dss_add_child_component);
 
-   r = component_master_add_with_match(>dev, _component_ops, 
match);
+   r = component_aggregate_register(>dev, _aggregate_driver, 
match);
if (r)
goto err_of_depopulate;
 
@@ -1541,7 +1547,7 @@ static int dss_remove(struct platform_device *pdev)
 
of_platform_depopulate(>dev);
 
-   component_master_del(>dev, _component_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
dss_debugfs_remove_file(dss->debugfs.clk);
dss_debugfs_remove_file(dss->debugfs.dss);
-- 
https://chromeos.dev



[PATCH v6 15/35] drm/ingenic: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

TODO: Move the helpers to PM in aggregate driver hooks.

Acked-by: Paul Cercueil 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 25 +--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index b4943a56be09..c094f9917874 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1317,8 +1317,10 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
return ret;
 }
 
-static int ingenic_drm_bind_with_components(struct device *dev)
+static int ingenic_drm_bind_with_components(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
+
return ingenic_drm_bind(dev, true);
 }
 
@@ -1341,9 +1343,20 @@ static void ingenic_drm_unbind(struct device *dev)
drm_atomic_helper_shutdown(>drm);
 }
 
-static const struct component_master_ops ingenic_master_ops = {
-   .bind = ingenic_drm_bind_with_components,
-   .unbind = ingenic_drm_unbind,
+static void ingenic_aggregate_remove(struct aggregate_device *adev)
+{
+   struct device *dev = aggregate_device_parent(adev);
+
+   ingenic_drm_unbind(dev);
+}
+
+static struct aggregate_driver ingenic_aggregate_driver = {
+   .probe = ingenic_drm_bind_with_components,
+   .remove = ingenic_aggregate_remove,
+   .driver = {
+   .name = "ingenic_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int ingenic_drm_probe(struct platform_device *pdev)
@@ -1363,7 +1376,7 @@ static int ingenic_drm_probe(struct platform_device *pdev)
drm_of_component_match_add(dev, , compare_of, np);
of_node_put(np);
 
-   return component_master_add_with_match(dev, _master_ops, match);
+   return component_aggregate_register(dev, _aggregate_driver, 
match);
 }
 
 static int ingenic_drm_remove(struct platform_device *pdev)
@@ -1373,7 +1386,7 @@ static int ingenic_drm_remove(struct platform_device 
*pdev)
if (!IS_ENABLED(CONFIG_DRM_INGENIC_IPU))
ingenic_drm_unbind(dev);
else
-   component_master_del(dev, _master_ops);
+   component_aggregate_unregister(dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 17/35] drm/mediatek: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Chun-Kuang Hu 
Cc: Philipp Zabel 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 56ff8c57ef8f..b486e98bf8d9 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -374,8 +374,9 @@ static int compare_of(struct device *dev, void *data)
return dev->of_node == data;
 }
 
-static int mtk_drm_bind(struct device *dev)
+static int mtk_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mtk_drm_private *private = dev_get_drvdata(dev);
struct drm_device *drm;
int ret;
@@ -406,8 +407,9 @@ static int mtk_drm_bind(struct device *dev)
return ret;
 }
 
-static void mtk_drm_unbind(struct device *dev)
+static void mtk_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct mtk_drm_private *private = dev_get_drvdata(dev);
 
drm_dev_unregister(private->drm);
@@ -417,9 +419,13 @@ static void mtk_drm_unbind(struct device *dev)
private->drm = NULL;
 }
 
-static const struct component_master_ops mtk_drm_ops = {
-   .bind   = mtk_drm_bind,
-   .unbind = mtk_drm_unbind,
+static struct aggregate_driver mtk_drm_aggregate_driver = {
+   .probe  = mtk_drm_bind,
+   .remove = mtk_drm_unbind,
+   .driver = {
+   .name   = "mtk_drm",
+   .owner  = THIS_MODULE,
+   },
 };
 
 static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
@@ -635,7 +641,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, private);
 
-   ret = component_master_add_with_match(dev, _drm_ops, match);
+   ret = component_aggregate_register(dev, _drm_aggregate_driver, 
match);
if (ret)
goto err_pm;
 
@@ -658,7 +664,7 @@ static int mtk_drm_remove(struct platform_device *pdev)
struct mtk_drm_private *private = platform_get_drvdata(pdev);
int i;
 
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, _drm_aggregate_driver);
pm_runtime_disable(>dev);
of_node_put(private->mutex_node);
for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
-- 
https://chromeos.dev



[PATCH v6 16/35] drm/mcde: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Tested-by: Linus Walleij 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/mcde/mcde_drv.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 5b5afc6aaf8e..b8479355844e 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -215,8 +215,9 @@ static const struct drm_driver mcde_drm_driver = {
DRM_GEM_CMA_DRIVER_OPS,
 };
 
-static int mcde_drm_bind(struct device *dev)
+static int mcde_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
int ret;
 
@@ -247,8 +248,9 @@ static int mcde_drm_bind(struct device *dev)
return ret;
 }
 
-static void mcde_drm_unbind(struct device *dev)
+static void mcde_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -256,9 +258,13 @@ static void mcde_drm_unbind(struct device *dev)
component_unbind_all(drm->dev, drm);
 }
 
-static const struct component_master_ops mcde_drm_comp_ops = {
-   .bind = mcde_drm_bind,
-   .unbind = mcde_drm_unbind,
+static struct aggregate_driver mcde_drm_comp_driver = {
+   .probe = mcde_drm_bind,
+   .remove = mcde_drm_unbind,
+   .driver = {
+   .name = "mcde_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static struct platform_driver *const mcde_component_drivers[] = {
@@ -419,7 +425,7 @@ static int mcde_probe(struct platform_device *pdev)
 * Perform an invasive reset of the MCDE and all blocks by
 * cutting the power to the subsystem, then bring it back up
 * later when we enable the display as a result of
-* component_master_add_with_match().
+* component_aggregate_register().
 */
ret = regulator_disable(mcde->epod);
if (ret) {
@@ -429,8 +435,7 @@ static int mcde_probe(struct platform_device *pdev)
/* Wait 50 ms so we are sure we cut the power */
usleep_range(5, 7);
 
-   ret = component_master_add_with_match(>dev, _drm_comp_ops,
- match);
+   ret = component_aggregate_register(>dev, _drm_comp_driver, 
match);
if (ret) {
dev_err(dev, "failed to add component master\n");
/*
@@ -459,7 +464,7 @@ static int mcde_remove(struct platform_device *pdev)
struct drm_device *drm = platform_get_drvdata(pdev);
struct mcde *mcde = to_mcde(drm);
 
-   component_master_del(>dev, _drm_comp_ops);
+   component_aggregate_unregister(>dev, _drm_comp_driver);
clk_disable_unprepare(mcde->mcde_clk);
regulator_disable(mcde->vana);
regulator_disable(mcde->epod);
-- 
https://chromeos.dev



[PATCH v6 18/35] drm/meson: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Neil Armstrong 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/meson/meson_drv.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index 80f1d439841a..2add29b347a8 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -361,13 +361,16 @@ static int meson_drv_bind_master(struct device *dev, bool 
has_components)
return ret;
 }
 
-static int meson_drv_bind(struct device *dev)
+static int meson_drv_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
+
return meson_drv_bind_master(dev, true);
 }
 
-static void meson_drv_unbind(struct device *dev)
+static void meson_drv_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct meson_drm *priv = dev_get_drvdata(dev);
struct drm_device *drm = priv->drm;
 
@@ -391,9 +394,13 @@ static void meson_drv_unbind(struct device *dev)
}
 }
 
-static const struct component_master_ops meson_drv_master_ops = {
-   .bind   = meson_drv_bind,
-   .unbind = meson_drv_unbind,
+static struct aggregate_driver meson_aggregate_drv = {
+   .probe  = meson_drv_bind,
+   .remove = meson_drv_unbind,
+   .driver = {
+   .name = "meson_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int __maybe_unused meson_drv_pm_suspend(struct device *dev)
@@ -487,9 +494,7 @@ static int meson_drv_probe(struct platform_device *pdev)
if (count) {
dev_info(>dev, "Queued %d outputs on vpu\n", count);
 
-   return component_master_add_with_match(>dev,
-  _drv_master_ops,
-  match);
+   return component_aggregate_register(>dev, 
_aggregate_drv, match);
}
 
/* If no output endpoints were available, simply bail out */
-- 
https://chromeos.dev



[PATCH v6 14/35] drm/imx: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Philipp Zabel 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index cb685fe2039b..82645e42b7d3 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -196,8 +196,9 @@ static int compare_of(struct device *dev, void *data)
return dev->of_node == np;
 }
 
-static int imx_drm_bind(struct device *dev)
+static int imx_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm;
int ret;
 
@@ -264,8 +265,9 @@ static int imx_drm_bind(struct device *dev)
return ret;
 }
 
-static void imx_drm_unbind(struct device *dev)
+static void imx_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -279,14 +281,18 @@ static void imx_drm_unbind(struct device *dev)
dev_set_drvdata(dev, NULL);
 }
 
-static const struct component_master_ops imx_drm_ops = {
-   .bind = imx_drm_bind,
-   .unbind = imx_drm_unbind,
+static struct aggregate_driver imx_drm_aggregate_driver = {
+   .probe = imx_drm_bind,
+   .remove = imx_drm_unbind,
+   .driver = {
+   .name = "imx_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int imx_drm_platform_probe(struct platform_device *pdev)
 {
-   int ret = drm_of_component_probe(>dev, compare_of, _drm_ops);
+   int ret = drm_of_aggregate_probe(>dev, compare_of, 
_drm_aggregate_driver);
 
if (!ret)
ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
@@ -296,7 +302,7 @@ static int imx_drm_platform_probe(struct platform_device 
*pdev)
 
 static int imx_drm_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, _drm_aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 10/35] drm/armada: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Russell King 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/armada/armada_drv.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 8e3e98f13db4..27739cbe2291 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -60,8 +60,9 @@ static const struct drm_mode_config_funcs 
armada_drm_mode_config_funcs = {
.atomic_commit  = drm_atomic_helper_commit,
 };
 
-static int armada_drm_bind(struct device *dev)
+static int armada_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct armada_private *priv;
struct resource *mem = NULL;
int ret, n;
@@ -159,8 +160,9 @@ static int armada_drm_bind(struct device *dev)
return ret;
 }
 
-static void armada_drm_unbind(struct device *dev)
+static void armada_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
struct armada_private *priv = drm_to_armada_dev(drm);
 
@@ -202,9 +204,13 @@ static void armada_add_endpoints(struct device *dev,
}
 }
 
-static const struct component_master_ops armada_master_ops = {
-   .bind = armada_drm_bind,
-   .unbind = armada_drm_unbind,
+static struct aggregate_driver armada_aggregate_driver = {
+   .probe = armada_drm_bind,
+   .remove = armada_drm_unbind,
+   .driver = {
+   .name = "armada_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int armada_drm_probe(struct platform_device *pdev)
@@ -213,7 +219,7 @@ static int armada_drm_probe(struct platform_device *pdev)
struct device *dev = >dev;
int ret;
 
-   ret = drm_of_component_probe(dev, compare_dev_name, _master_ops);
+   ret = drm_of_aggregate_probe(dev, compare_dev_name, 
_aggregate_driver);
if (ret != -EINVAL)
return ret;
 
@@ -240,13 +246,12 @@ static int armada_drm_probe(struct platform_device *pdev)
}
}
 
-   return component_master_add_with_match(>dev, _master_ops,
-  match);
+   return component_aggregate_register(>dev, 
_aggregate_driver, match);
 }
 
 static int armada_drm_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 11/35] drm/etnaviv: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Lucas Stach 
Cc: Russell King 
Cc: Christian Gmeiner 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 0b756ecb1bc2..5d1cc3953204 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -494,8 +494,9 @@ static const struct drm_driver etnaviv_drm_driver = {
 /*
  * Platform driver:
  */
-static int etnaviv_bind(struct device *dev)
+static int etnaviv_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct etnaviv_drm_private *priv;
struct drm_device *drm;
int ret;
@@ -552,8 +553,9 @@ static int etnaviv_bind(struct device *dev)
return ret;
 }
 
-static void etnaviv_unbind(struct device *dev)
+static void etnaviv_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
struct etnaviv_drm_private *priv = drm->dev_private;
 
@@ -569,9 +571,13 @@ static void etnaviv_unbind(struct device *dev)
drm_dev_put(drm);
 }
 
-static const struct component_master_ops etnaviv_master_ops = {
-   .bind = etnaviv_bind,
-   .unbind = etnaviv_unbind,
+static struct aggregate_driver etnaviv_aggregate_driver = {
+   .probe = etnaviv_bind,
+   .remove = etnaviv_unbind,
+   .driver = {
+   .name = "etnaviv_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int compare_of(struct device *dev, void *data)
@@ -639,12 +645,12 @@ static int etnaviv_pdev_probe(struct platform_device 
*pdev)
if (first_node)
of_dma_configure(>dev, first_node, true);
 
-   return component_master_add_with_match(dev, _master_ops, match);
+   return component_aggregate_register(dev, _aggregate_driver, 
match);
 }
 
 static int etnaviv_pdev_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
 
return 0;
 }
-- 
https://chromeos.dev



[PATCH v6 13/35] drm/exynos: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Inki Dae 
Cc: Joonyoung Shim 
Cc: Seung-Woo Kim 
Cc: Kyungmin Park 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 9743b6b17447..f9a3e7041254 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -244,8 +244,9 @@ static struct component_match *exynos_drm_match_add(struct 
device *dev)
return match ?: ERR_PTR(-ENODEV);
 }
 
-static int exynos_drm_bind(struct device *dev)
+static int exynos_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct exynos_drm_private *private;
struct drm_encoder *encoder;
struct drm_device *drm;
@@ -321,8 +322,9 @@ static int exynos_drm_bind(struct device *dev)
return ret;
 }
 
-static void exynos_drm_unbind(struct device *dev)
+static void exynos_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
 
drm_dev_unregister(drm);
@@ -341,9 +343,13 @@ static void exynos_drm_unbind(struct device *dev)
drm_dev_put(drm);
 }
 
-static const struct component_master_ops exynos_drm_ops = {
-   .bind   = exynos_drm_bind,
-   .unbind = exynos_drm_unbind,
+static struct aggregate_driver exynos_drm_aggregate_driver = {
+   .probe  = exynos_drm_bind,
+   .remove = exynos_drm_unbind,
+   .driver = {
+   .name   = "exynos_drm",
+   .owner  = THIS_MODULE,
+   },
 };
 
 static int exynos_drm_platform_probe(struct platform_device *pdev)
@@ -356,13 +362,12 @@ static int exynos_drm_platform_probe(struct 
platform_device *pdev)
if (IS_ERR(match))
return PTR_ERR(match);
 
-   return component_master_add_with_match(>dev, _drm_ops,
-  match);
+   return component_aggregate_register(>dev, 
_drm_aggregate_driver, match);
 }
 
 static int exynos_drm_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, 
_drm_aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 12/35] drm/kirin: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Xinliang Liu 
Cc: Tian Tao 
Cc: John Stultz 
Cc: Xinwei Kong 
Cc: Chen Feng 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c   | 20 ---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 98ae9a48f3fe..338077908177 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -217,8 +217,9 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev)
return 0;
 }
 
-static int kirin_drm_bind(struct device *dev)
+static int kirin_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct kirin_drm_data *driver_data;
struct drm_device *drm_dev;
int ret;
@@ -253,8 +254,9 @@ static int kirin_drm_bind(struct device *dev)
return ret;
 }
 
-static void kirin_drm_unbind(struct device *dev)
+static void kirin_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm_dev = dev_get_drvdata(dev);
 
drm_dev_unregister(drm_dev);
@@ -262,9 +264,13 @@ static void kirin_drm_unbind(struct device *dev)
drm_dev_put(drm_dev);
 }
 
-static const struct component_master_ops kirin_drm_ops = {
-   .bind = kirin_drm_bind,
-   .unbind = kirin_drm_unbind,
+static struct aggregate_driver kirin_drm_aggregate_driver = {
+   .probe = kirin_drm_bind,
+   .remove = kirin_drm_unbind,
+   .driver = {
+   .name = "kirin_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int kirin_drm_platform_probe(struct platform_device *pdev)
@@ -281,12 +287,12 @@ static int kirin_drm_platform_probe(struct 
platform_device *pdev)
drm_of_component_match_add(dev, , compare_of, remote);
of_node_put(remote);
 
-   return component_master_add_with_match(dev, _drm_ops, match);
+   return component_aggregate_register(dev, _drm_aggregate_driver, 
match);
 }
 
 static int kirin_drm_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _drm_ops);
+   component_aggregate_unregister(>dev, _drm_aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 04/35] component: Add {bind, unbind}_component() ops that take aggregate device

2022-01-27 Thread Stephen Boyd
We'd like to get more device model features in the component framework
so let's pass the struct aggregate_device pointer instead of the parent
device pointer to the component binding functions. This will allow
drivers to inspect and control things related to the aggregate device in
case they need it, and they'll always be able to get back to the device
they were using before by using the 'parent' member of the aggregate
device struct.

Suggested-by: Daniel Vetter 
Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: Laurent Pinchart 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/base/component.c  | 14 +++---
 include/linux/component.h | 23 ++-
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 13ac2004a913..5b91a114786d 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -735,8 +735,13 @@ static void component_unbind(struct component *component,
 {
WARN_ON(!component->bound);
 
-   if (component->ops && component->ops->unbind)
-   component->ops->unbind(component->dev, adev->parent, data);
+   if (component->ops) {
+   if (component->ops->unbind)
+   component->ops->unbind(component->dev, adev->parent, 
data);
+   else if (component->ops->unbind_component)
+   component->ops->unbind_component(component->dev, adev, 
data);
+   }
+
component->bound = false;
 
/* Release all resources claimed in the binding of this component */
@@ -801,7 +806,10 @@ static int component_bind(struct component *component, 
struct aggregate_device *
dev_dbg(adev->parent, "binding %s (ops %ps)\n",
dev_name(component->dev), component->ops);
 
-   ret = component->ops->bind(component->dev, adev->parent, data);
+   if (component->ops->bind_component)
+   ret = component->ops->bind_component(component->dev, adev, 
data);
+   else
+   ret = component->ops->bind(component->dev, adev->parent, data);
if (!ret) {
component->bound = true;
 
diff --git a/include/linux/component.h b/include/linux/component.h
index c39dea7824af..073cbe9fea32 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -6,6 +6,7 @@
 #include 
 #include 
 
+struct aggregate_device;
 struct device;
 
 /**
@@ -20,18 +21,39 @@ struct component_ops {
 *
 * Called through component_bind_all() when the aggregate driver is
 * ready to bind the overall driver.
+*
+* Deprecated: Use bind_component() instead.
 */
int (*bind)(struct device *comp, struct device *master,
void *master_data);
+   /**
+* @bind_component:
+*
+* Called through component_bind_all() when the aggregate driver is
+* ready to bind the overall driver.
+*/
+   int (*bind_component)(struct device *comp, struct aggregate_device 
*adev,
+ void *aggregate_data);
/**
 * @unbind:
 *
 * Called through component_unbind_all() when the aggregate driver is
 * ready to bind the overall driver, or when component_bind_all() fails
 * part-ways through and needs to unbind some already bound components.
+*
+* Deprecated: Use unbind_component() instead.
 */
void (*unbind)(struct device *comp, struct device *master,
   void *master_data);
+   /**
+* @unbind_component:
+*
+* Called through component_unbind_all() when the aggregate driver is
+* ready to unbind the overall driver, or when component_bind_all() 
fails
+* part-ways through and needs to unbind some already bound components.
+*/
+   int (*unbind_component)(struct device *comp, struct aggregate_device 
*adev,
+   void *aggregate_data);
 };
 
 int component_add(struct device *, const struct component_ops *);
@@ -42,7 +64,6 @@ void component_del(struct device *, const struct 
component_ops *);
 int component_bind_all(struct device *parent, void *data);
 void component_unbind_all(struct device *parent, void *data);
 
-struct aggregate_device;
 struct device *aggregate_device_parent(const struct aggregate_device *adev);
 
 /**
-- 
https://chromeos.dev



[PATCH v6 08/35] drm/arm/hdlcd: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: Liviu Dudau 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/arm/hdlcd_drv.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 479c2422a2e0..e3ed925797d5 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -270,8 +270,9 @@ static const struct drm_driver hdlcd_driver = {
.minor = 0,
 };
 
-static int hdlcd_drm_bind(struct device *dev)
+static int hdlcd_drm_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm;
struct hdlcd_drm_private *hdlcd;
int ret;
@@ -344,8 +345,9 @@ static int hdlcd_drm_bind(struct device *dev)
return ret;
 }
 
-static void hdlcd_drm_unbind(struct device *dev)
+static void hdlcd_drm_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
struct hdlcd_drm_private *hdlcd = drm->dev_private;
 
@@ -367,9 +369,13 @@ static void hdlcd_drm_unbind(struct device *dev)
drm_dev_put(drm);
 }
 
-static const struct component_master_ops hdlcd_master_ops = {
-   .bind   = hdlcd_drm_bind,
-   .unbind = hdlcd_drm_unbind,
+static struct aggregate_driver hdlcd_aggregate_driver = {
+   .probe  = hdlcd_drm_bind,
+   .remove = hdlcd_drm_unbind,
+   .driver = {
+   .name   = "hdlcd_drm",
+   .owner  = THIS_MODULE,
+   },
 };
 
 static int compare_dev(struct device *dev, void *data)
@@ -390,13 +396,12 @@ static int hdlcd_probe(struct platform_device *pdev)
drm_of_component_match_add(>dev, , compare_dev, port);
of_node_put(port);
 
-   return component_master_add_with_match(>dev, _master_ops,
-  match);
+   return component_aggregate_register(>dev, 
_aggregate_driver, match);
 }
 
 static int hdlcd_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 09/35] drm/malidp: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

TODO: This can be updated to move the drm helper logic into the
aggregate driver shutdown op.

Cc: Laurent Pinchart 
Cc: Liviu Dudau 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/arm/malidp_drv.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 78d15b04b105..7b946b962b22 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -702,8 +702,9 @@ static int malidp_runtime_pm_resume(struct device *dev)
return 0;
 }
 
-static int malidp_bind(struct device *dev)
+static int malidp_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct resource *res;
struct drm_device *drm;
struct malidp_drm *malidp;
@@ -894,8 +895,9 @@ static int malidp_bind(struct device *dev)
return ret;
 }
 
-static void malidp_unbind(struct device *dev)
+static void malidp_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct drm_device *drm = dev_get_drvdata(dev);
struct malidp_drm *malidp = drm->dev_private;
struct malidp_hw_device *hwdev = malidp->dev;
@@ -921,9 +923,13 @@ static void malidp_unbind(struct device *dev)
of_reserved_mem_device_release(dev);
 }
 
-static const struct component_master_ops malidp_master_ops = {
-   .bind = malidp_bind,
-   .unbind = malidp_unbind,
+static struct aggregate_driver malidp_aggregate_driver = {
+   .probe = malidp_bind,
+   .remove = malidp_unbind,
+   .driver = {
+   .name = "malidp_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int malidp_compare_dev(struct device *dev, void *data)
@@ -949,13 +955,12 @@ static int malidp_platform_probe(struct platform_device 
*pdev)
drm_of_component_match_add(>dev, , malidp_compare_dev,
   port);
of_node_put(port);
-   return component_master_add_with_match(>dev, _master_ops,
-  match);
+   return component_aggregate_register(>dev, 
_aggregate_driver, match);
 }
 
 static int malidp_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 06/35] drm/msm: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
The device lists are poorly ordered when the component device code is
used. This is because component_master_add_with_match() returns 0
regardless of component devices calling component_add() first. It can
really only fail if an allocation fails, in which case everything is
going bad and we're out of memory. The driver that registers the
aggregate driver, can succeed at probe and put the attached device on
the DPM lists before any of the component devices are probed and put on
the lists.

Within the component device framework this usually isn't that bad
because the real driver work is done at bind time via
component{,master}_ops::bind(). It becomes a problem when the driver
core, or host driver, wants to operate on the component device outside
of the bind/unbind functions, e.g. via 'remove' or 'shutdown'. The
driver core doesn't understand the relationship between the host device
and the component devices and could possibly try to operate on component
devices when they're already removed from the system or shut down.

Normally, device links or probe defer would reorder the lists and put
devices that depend on other devices in the lists at the correct
location, but with component devices this doesn't happen because this
information isn't expressed anywhere. Drivers simply succeed at
registering their component or the aggregate driver with the component
framework and wait for their bind() callback to be called once the other
components are ready. In summary, the drivers that make up the aggregate
driver can probe in any order.

This ordering problem becomes fairly obvious when shutting down the
device with a DSI controller connected to a DSI bridge that is
controlled via i2c. In this case, the msm display driver wants to tear
down the display pipeline on shutdown via msm_pdev_shutdown() by calling
drm_atomic_helper_shutdown(), and it can't do that unless the whole
display chain is still probed and active in the system. When a display
bridge is on i2c, the i2c device for the bridge will be created whenever
the i2c controller probes, which could be before or after the msm
display driver probes. If the i2c controller probes after the display
driver, then the i2c controller will be shutdown before the display
controller during system wide shutdown and thus i2c transactions will
stop working before the display pipeline is shut down. This means we'll
have the display bridge trying to access an i2c bus that's shut down
because drm_atomic_helper_shutdown() is trying to disable the bridge
after the bridge is off.

The solution is to make the aggregate driver into a real struct driver
that is bound to a device when the other component devices have all
probed. Now that the component driver code is a proper bus, we can
simply register an aggregate driver with that bus via
component_aggregate_register() and then attach the shutdown hook to that
driver to be sure that the shutdown for the display pipeline is called
before any of the component device driver shutdown hooks are called.

Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/msm/msm_drv.c | 48 ---
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index ad35a5d94053..32107e5cb547 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1331,19 +1331,37 @@ static int add_gpu_components(struct device *dev,
return 0;
 }
 
-static int msm_drm_bind(struct device *dev)
+static int msm_drm_bind(struct aggregate_device *adev)
 {
-   return msm_drm_init(dev, _driver);
+   return msm_drm_init(aggregate_device_parent(adev), _driver);
 }
 
-static void msm_drm_unbind(struct device *dev)
+static void msm_drm_unbind(struct aggregate_device *adev)
 {
-   msm_drm_uninit(dev);
+   msm_drm_uninit(aggregate_device_parent(adev));
+}
+
+static void msm_drm_shutdown(struct aggregate_device *adev)
+{
+   const struct device *parent = aggregate_device_parent(adev);
+   const struct platform_device *pdev = to_platform_device(parent);
+   struct msm_drm_private *priv = platform_get_drvdata(pdev);
+   struct drm_device *drm = priv ? priv->dev : NULL;
+
+   if (!priv || !priv->kms)
+   return;
+
+   drm_atomic_helper_shutdown(drm);
 }
 
-static const struct component_master_ops msm_drm_ops = {
-   .bind = msm_drm_bind,
-   .unbind = msm_drm_unbind,
+static struct aggregate_driver msm_drm_aggregate_driver = {
+   .probe = msm_drm_bind,
+   .remove = msm_drm_unbind,
+   .shutdown = msm_drm_shutdown,
+   .driver = {
+   .name   = "msm_drm",
+   .owner  = THIS_MODULE,
+   },
 };
 
 /*
@@ -1395,7 +1413,7 @@ static int msm_pdev_probe(struct platform_device *pdev)
if (ret)
goto fail;
 
-   ret = component_master_add_with_match(>dev, 

[PATCH v6 07/35] drm/komeda: Migrate to aggregate driver

2022-01-27 Thread Stephen Boyd
Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to all
the component devices that make up the aggregate device.

Cc: James Qian Wang (Arm Technology China) 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 20 ---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
index e7933930a657..5fa868cf9825 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
@@ -25,8 +25,9 @@ struct komeda_dev *dev_to_mdev(struct device *dev)
return mdrv ? mdrv->mdev : NULL;
 }
 
-static void komeda_unbind(struct device *dev)
+static void komeda_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct komeda_drv *mdrv = dev_get_drvdata(dev);
 
if (!mdrv)
@@ -45,8 +46,9 @@ static void komeda_unbind(struct device *dev)
devm_kfree(dev, mdrv);
 }
 
-static int komeda_bind(struct device *dev)
+static int komeda_bind(struct aggregate_device *adev)
 {
+   struct device *dev = aggregate_device_parent(adev);
struct komeda_drv *mdrv;
int err;
 
@@ -87,9 +89,13 @@ static int komeda_bind(struct device *dev)
return err;
 }
 
-static const struct component_master_ops komeda_master_ops = {
-   .bind   = komeda_bind,
-   .unbind = komeda_unbind,
+static struct aggregate_driver komeda_aggregate_driver = {
+   .probe  = komeda_bind,
+   .remove = komeda_unbind,
+   .driver = {
+   .name  = "komeda_drm",
+   .owner = THIS_MODULE,
+   },
 };
 
 static int compare_of(struct device *dev, void *data)
@@ -129,12 +135,12 @@ static int komeda_platform_probe(struct platform_device 
*pdev)
komeda_add_slave(dev, , child, KOMEDA_OF_PORT_OUTPUT, 1);
}
 
-   return component_master_add_with_match(dev, _master_ops, match);
+   return component_aggregate_register(dev, _aggregate_driver, 
match);
 }
 
 static int komeda_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(>dev, _master_ops);
+   component_aggregate_unregister(>dev, _aggregate_driver);
return 0;
 }
 
-- 
https://chromeos.dev



[PATCH v6 05/35] drm/of: Add a drm_of_aggregate_probe() API

2022-01-27 Thread Stephen Boyd
Similar to drm_of_component_probe() but using the new API that registers
a driver instead of an ops struct. This allows us to migrate the users
of drm_of_component_probe() to the new way of doing things.

Cc: Laurent Pinchart 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/gpu/drm/drm_of.c | 85 +++-
 include/drm/drm_of.h | 12 ++
 2 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 59d368ea006b..0fe822319aae 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -99,30 +99,18 @@ void drm_of_component_match_add(struct device *master,
 }
 EXPORT_SYMBOL_GPL(drm_of_component_match_add);
 
-/**
- * drm_of_component_probe - Generic probe function for a component based master
- * @dev: master device containing the OF node
- * @compare_of: compare function used for matching components
- * @m_ops: component master ops to be used
- *
- * Parse the platform device OF node and bind all the components associated
- * with the master. Interface ports are added before the encoders in order to
- * satisfy their .bind requirements
- * See Documentation/devicetree/bindings/graph.txt for the bindings.
- *
- * Returns zero if successful, or one of the standard error codes if it fails.
- */
-int drm_of_component_probe(struct device *dev,
+static int _drm_of_component_probe(struct device *dev,
   int (*compare_of)(struct device *, void *),
-  const struct component_master_ops *m_ops)
+  struct component_match **matchptr)
 {
struct device_node *ep, *port, *remote;
-   struct component_match *match = NULL;
int i;
 
if (!dev->of_node)
return -EINVAL;
 
+   *matchptr = NULL;
+
/*
 * Bind the crtc's ports first, so that drm_of_find_possible_crtcs()
 * called from encoder's .bind callbacks works as expected
@@ -133,7 +121,7 @@ int drm_of_component_probe(struct device *dev,
break;
 
if (of_device_is_available(port->parent))
-   drm_of_component_match_add(dev, , compare_of,
+   drm_of_component_match_add(dev, matchptr, compare_of,
   port);
 
of_node_put(port);
@@ -144,7 +132,7 @@ int drm_of_component_probe(struct device *dev,
return -ENODEV;
}
 
-   if (!match) {
+   if (!*matchptr) {
dev_err(dev, "no available port\n");
return -ENODEV;
}
@@ -174,17 +162,76 @@ int drm_of_component_probe(struct device *dev,
continue;
}
 
-   drm_of_component_match_add(dev, , compare_of,
+   drm_of_component_match_add(dev, matchptr, compare_of,
   remote);
of_node_put(remote);
}
of_node_put(port);
}
 
+   return 0;
+}
+
+/**
+ * drm_of_component_probe - Generic probe function for a component based master
+ * @dev: master device containing the OF node
+ * @compare_of: compare function used for matching components
+ * @m_ops: component master ops to be used
+ *
+ * Parse the platform device OF node and bind all the components associated
+ * with the master. Interface ports are added before the encoders in order to
+ * satisfy their .bind requirements
+ * See Documentation/devicetree/bindings/graph.txt for the bindings.
+ *
+ * Deprecated: Use drm_of_aggregate_probe() instead.
+ *
+ * Returns zero if successful, or one of the standard error codes if it fails.
+ */
+int drm_of_component_probe(struct device *dev,
+  int (*compare_of)(struct device *, void *),
+  const struct component_master_ops *m_ops)
+{
+
+   struct component_match *match;
+   int ret;
+
+   ret = _drm_of_component_probe(dev, compare_of, );
+   if (ret)
+   return ret;
+
return component_master_add_with_match(dev, m_ops, match);
 }
 EXPORT_SYMBOL(drm_of_component_probe);
 
+
+/**
+ * drm_of_aggregate_probe - Generic probe function for a component based 
aggregate host
+ * @dev: device containing the OF node
+ * @compare_of: compare function used for matching components
+ * @adrv: aggregate driver to be used
+ *
+ * Parse the platform device OF node and bind all the components associated
+ * with the aggregate device. Interface ports are added before the encoders in
+ * order to satisfy their .bind_component requirements
+ * See Documentation/devicetree/bindings/graph.txt for the bindings.
+ *
+ * Returns zero if successful, or one of the standard error codes if it fails.
+ */
+int drm_of_aggregate_probe(struct device *dev,
+  

[PATCH v6 03/35] component: Add aggregate_device_parent() for driver use

2022-01-27 Thread Stephen Boyd
This allows aggregate driver writers to get the parent of the aggregate
device passed to their probe/remove/shutdown functions.

Suggested-by: Jani Nikula 
Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: Laurent Pinchart 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/base/component.c  | 6 ++
 include/linux/component.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index dc748ef0b23b..13ac2004a913 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -71,6 +71,12 @@ static inline struct aggregate_device 
*to_aggregate_device(struct device *d)
return container_of(d, struct aggregate_device, dev);
 }
 
+struct device *aggregate_device_parent(const struct aggregate_device *adev)
+{
+   return adev->parent;
+}
+EXPORT_SYMBOL_GPL(aggregate_device_parent);
+
 struct component {
struct list_head node;
struct aggregate_device *adev;
diff --git a/include/linux/component.h b/include/linux/component.h
index aa69ea0401d3..c39dea7824af 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -43,6 +43,7 @@ int component_bind_all(struct device *parent, void *data);
 void component_unbind_all(struct device *parent, void *data);
 
 struct aggregate_device;
+struct device *aggregate_device_parent(const struct aggregate_device *adev);
 
 /**
  * struct component_master_ops - callback for the aggregate driver
-- 
https://chromeos.dev



[PATCH v6 02/35] component: Introduce the aggregate bus_type

2022-01-27 Thread Stephen Boyd
The component framework only provides 'bind' and 'unbind' callbacks to
tell the host driver that it is time to assemble the aggregate driver
now that all the components have probed. The component framework doesn't
attempt to resolve runtime PM or suspend/resume ordering, and explicitly
mentions this in the code. This lack of support leads to some pretty
gnarly usages of the 'prepare' and 'complete' power management hooks in
drivers that host the aggregate device, and it fully breaks down when
faced with ordering shutdown between the various components, the
aggregate driver, and the host driver that registers the whole thing.

In a concrete example, the MSM display driver at drivers/gpu/drm/msm is
using 'prepare' and 'complete' to call the drm helpers
drm_mode_config_helper_suspend() and drm_mode_config_helper_resume()
respectively, so that it can move the aggregate driver suspend/resume
callbacks to be before and after the components that make up the drm
device call any suspend/resume hooks they have. This only works as long
as the component devices don't do anything in their own 'prepare' and
'complete' callbacks. If they did, then the ordering would be incorrect
and we would be doing something in the component drivers before the
aggregate driver could do anything. Yuck!

Similarly, when trying to add shutdown support to the MSM driver we run
across a problem where we're trying to shutdown the drm device via
drm_atomic_helper_shutdown(), but some of the devices in the encoder
chain have already been shutdown. This time, the component devices
aren't the problem (although they could be if they did anything in their
shutdown callbacks), but there's a DSI to eDP bridge in the encoder
chain that has already been shutdown before the driver hosting the
aggregate device runs shutdown. The ordering of driver probe is like
this:

 1. msm_pdev_probe() (host driver)
 2. DSI bridge
 3. aggregate bind

When it comes to shutdown we have this order:

 1. DSI bridge
 2. msm_pdev_shutdown() (host driver)

and so the bridge is already off, but we want to communicate to it to
turn things off on the display during msm_pdev_shutdown(). Double yuck!
Unfortunately, this time we can't split shutdown into multiple phases
and swap msm_pdev_shutdown() with the DSI bridge.

Let's make the component_master_ops into an actual device driver that has
probe/remove/shutdown functions. The driver will only be bound to the
aggregate device once all component drivers have called component_add()
to indicate they're ready to assemble the aggregate driver. This allows
us to attach shutdown logic (and in the future runtime PM logic) to the
aggregate driver so that it runs the hooks in the correct order.

Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: Laurent Pinchart 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/base/component.c  | 486 --
 include/linux/component.h |  58 -
 2 files changed, 417 insertions(+), 127 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 34f9e0802719..dc748ef0b23b 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -4,10 +4,14 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
+
+#include "base.h"
 
 /**
  * DOC: overview
@@ -31,8 +35,8 @@
  *
  * Aggregate drivers first assemble a component match list of what they need
  * using component_match_add(). This is then registered as an aggregate driver
- * using component_master_add_with_match(), and unregistered using
- * component_master_del().
+ * using component_aggregate_register(), and unregistered using
+ * component_aggregate_unregister().
  */
 
 struct component;
@@ -53,14 +57,20 @@ struct component_match {
 };
 
 struct aggregate_device {
-   struct list_head node;
-   bool bound;
-
const struct component_master_ops *ops;
struct device *parent;
+   struct device dev;
struct component_match *match;
+   struct aggregate_driver *adrv;
+
+   int id;
 };
 
+static inline struct aggregate_device *to_aggregate_device(struct device *d)
+{
+   return container_of(d, struct aggregate_device, dev);
+}
+
 struct component {
struct list_head node;
struct aggregate_device *adev;
@@ -69,11 +79,12 @@ struct component {
const struct component_ops *ops;
int subcomponent;
struct device *dev;
+   struct device_link *link;
 };
 
 static DEFINE_MUTEX(component_mutex);
 static LIST_HEAD(component_list);
-static LIST_HEAD(aggregate_devices);
+static DEFINE_IDA(aggregate_ida);
 
 #ifdef CONFIG_DEBUG_FS
 
@@ -89,7 +100,7 @@ static int component_devices_show(struct seq_file *s, void 
*data)
seq_printf(s, "%-40s %20s\n", "aggregate_device name", "status");
seq_puts(s, 
"-\n");
seq_printf(s, "%-40s 

[PATCH v6 01/35] component: Replace most references to 'master' with 'aggregate device'

2022-01-27 Thread Stephen Boyd
Remove most references to 'master' in the code and replace them with
some form of 'aggregate device'. This better reflects the reality of
what this code does, i.e. an aggregate device that represents a
device like a GPU card once some set of devices that make up the
aggregate device probe and register with the component framework.

Cc: Daniel Vetter 
Cc: Greg Kroah-Hartman 
Cc: Laurent Pinchart 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---
 drivers/base/component.c  | 242 +++---
 include/linux/component.h |  18 +--
 2 files changed, 128 insertions(+), 132 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 2d25a6416587..34f9e0802719 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -1,11 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Componentized device handling.
- *
- * This is work in progress.  We gather up the component devices into a list,
- * and bind them when instructed.  At the moment, we're specific to the DRM
- * subsystem, and only handles one master device, but this doesn't have to be
- * the case.
  */
 #include 
 #include 
@@ -57,7 +52,7 @@ struct component_match {
struct component_match_array *compare;
 };
 
-struct master {
+struct aggregate_device {
struct list_head node;
bool bound;
 
@@ -68,7 +63,7 @@ struct master {
 
 struct component {
struct list_head node;
-   struct master *master;
+   struct aggregate_device *adev;
bool bound;
 
const struct component_ops *ops;
@@ -78,7 +73,7 @@ struct component {
 
 static DEFINE_MUTEX(component_mutex);
 static LIST_HEAD(component_list);
-static LIST_HEAD(masters);
+static LIST_HEAD(aggregate_devices);
 
 #ifdef CONFIG_DEBUG_FS
 
@@ -86,12 +81,12 @@ static struct dentry *component_debugfs_dir;
 
 static int component_devices_show(struct seq_file *s, void *data)
 {
-   struct master *m = s->private;
+   struct aggregate_device *m = s->private;
struct component_match *match = m->match;
size_t i;
 
mutex_lock(_mutex);
-   seq_printf(s, "%-40s %20s\n", "master name", "status");
+   seq_printf(s, "%-40s %20s\n", "aggregate_device name", "status");
seq_puts(s, 
"-\n");
seq_printf(s, "%-40s %20s\n\n",
   dev_name(m->parent), m->bound ? "bound" : "not bound");
@@ -121,46 +116,46 @@ static int __init component_debug_init(void)
 
 core_initcall(component_debug_init);
 
-static void component_master_debugfs_add(struct master *m)
+static void component_debugfs_add(struct aggregate_device *m)
 {
debugfs_create_file(dev_name(m->parent), 0444, component_debugfs_dir, m,
_devices_fops);
 }
 
-static void component_master_debugfs_del(struct master *m)
+static void component_debugfs_del(struct aggregate_device *m)
 {
debugfs_remove(debugfs_lookup(dev_name(m->parent), 
component_debugfs_dir));
 }
 
 #else
 
-static void component_master_debugfs_add(struct master *m)
+static void component_debugfs_add(struct aggregate_device *m)
 { }
 
-static void component_master_debugfs_del(struct master *m)
+static void component_debugfs_del(struct aggregate_device *m)
 { }
 
 #endif
 
-static struct master *__master_find(struct device *parent,
+static struct aggregate_device *__aggregate_find(struct device *parent,
const struct component_master_ops *ops)
 {
-   struct master *m;
+   struct aggregate_device *m;
 
-   list_for_each_entry(m, , node)
+   list_for_each_entry(m, _devices, node)
if (m->parent == parent && (!ops || m->ops == ops))
return m;
 
return NULL;
 }
 
-static struct component *find_component(struct master *master,
+static struct component *find_component(struct aggregate_device *adev,
struct component_match_array *mc)
 {
struct component *c;
 
list_for_each_entry(c, _list, node) {
-   if (c->master && c->master != master)
+   if (c->adev && c->adev != adev)
continue;
 
if (mc->compare && mc->compare(c->dev, mc->data))
@@ -174,102 +169,103 @@ static struct component *find_component(struct master 
*master,
return NULL;
 }
 
-static int find_components(struct master *master)
+static int find_components(struct aggregate_device *adev)
 {
-   struct component_match *match = master->match;
+   struct component_match *match = adev->match;
size_t i;
int ret = 0;
 
/*
 * Scan the array of match functions and attach
-* any components which are found to this master.
+* any components which are found to this adev.
 */
for (i = 0; i < match->num; i++) {
struct component_match_array *mc = >compare[i];
struct component *c;

[PATCH v6 00/35] component: Make into an aggregate bus

2022-01-27 Thread Stephen Boyd
This series is from discussion we had on reordering the device lists for
drm shutdown paths[1]. I've introduced an 'aggregate' bus that we put
the aggregate device onto and then we probe the aggregate device once
all the components are probed and call component_add(). The probe/remove
hooks are where the bind/unbind calls go, and then a shutdown hook is
added that can be used to shutdown the drm display pipeline at the right
time.

This works for me on my sc7180 board. I no longer get a warning from i2c
at shutdown that we're trying to make an i2c transaction after the i2c
bus has been shutdown. There's more work to do on the msm drm driver to
extract component device resources like clks, regulators, etc. out of
the component bind function into the driver probe but I wanted to move
everything over now in other component drivers before tackling that
problem.

Tested-by tags would be appreciated, and Acked-by/Reviewed-by tags too.

Per Daniel, I've resent this to collect Acks or Review tags from gregkh
and once Greg is happy with the driver core bits it can be merged
through drm-misc tree via dianders (both are on the To line).

Changes since v5 
(https://lore.kernel.org/r/20220106214556.2461363-1-swb...@chromium.org):
 - Refcount the driver registration to support multiple device usage
 - Fix runtime PM in MediaTek iommu patch
 - Rebased to v5.17-rc1 and converted new component uses
 - No longer expose struct aggregate_device in component.h header

Changes since v4 
(https://lore.kernel.org/r/2021120732.2453851-1-swb...@chromium.org):
 - Picked up tags
 - Moved rename patch to first in the series
 - Squashed device and bus type patch together

Changes since v3 
(https://lore.kernel.org/r/2021102644.885195-1-swb...@chromium.org):
 - Picked up tags
 - Rebased to v5.16-rc2
 - Updated component.c for a few new patches there
 - Dropped a conversion patch
 - Added a conversion patch

Changes since v2 
(https://lore.kernel.org/r/20211006193819.2654854-1-swb...@chromium.org):
 - Picked up acks
 - Fixed build warnings/errors
 - Reworked patch series to rename 'master' in a different patch

Changes since v1 
(https://lore.kernel.org/r/20210520002519.3538432-1-swb...@chromium.org):
 - Use devlink to connect components to the aggregate device
 - Don't set the registering device as a parent of the aggregate device
 - New patch for bind_component/unbind_component ops that takes the
   aggregate device
 - Convert all drivers in the tree to use the aggregate driver approach
 - Allow one aggregate driver to be used for multiple aggregate devices

[1] https://lore.kernel.org/r/20210508074118.1621729-1-swb...@chromium.org

Stephen Boyd (35):
  component: Replace most references to 'master' with 'aggregate device'
  component: Introduce the aggregate bus_type
  component: Add aggregate_device_parent() for driver use
  component: Add {bind,unbind}_component() ops that take aggregate
device
  drm/of: Add a drm_of_aggregate_probe() API
  drm/msm: Migrate to aggregate driver
  drm/komeda: Migrate to aggregate driver
  drm/arm/hdlcd: Migrate to aggregate driver
  drm/malidp: Migrate to aggregate driver
  drm/armada: Migrate to aggregate driver
  drm/etnaviv: Migrate to aggregate driver
  drm/kirin: Migrate to aggregate driver
  drm/exynos: Migrate to aggregate driver
  drm/imx: Migrate to aggregate driver
  drm/ingenic: Migrate to aggregate driver
  drm/mcde: Migrate to aggregate driver
  drm/mediatek: Migrate to aggregate driver
  drm/meson: Migrate to aggregate driver
  drm/omap: Migrate to aggregate driver
  drm/rockchip: Migrate to aggregate driver
  drm/sti: Migrate to aggregate driver
  drm/sun4i: Migrate to aggregate driver
  drm/tilcdc: Migrate to aggregate driver
  drm/vc4: Migrate to aggregate driver
  iommu/mediatek: Migrate to aggregate driver
  mei: Migrate to aggregate driver
  power: supply: ab8500: Migrate to aggregate driver
  fbdev: omap2: Migrate to aggregate driver
  sound: hdac: Migrate to aggregate driver
  ASoC: codecs: wcd938x: Migrate to aggregate driver
  drm/sprd: Migrate to aggregate driver
  usb: typec: port-mapper: Migrate to aggregate driver
  ALSA: hda/realtek: Migrate to aggregate driver
  component: Get rid of drm_of_component_probe()
  component: Remove component_master_ops and friends

 drivers/base/component.c  | 571 +++---
 .../gpu/drm/arm/display/komeda/komeda_drv.c   |  20 +-
 drivers/gpu/drm/arm/hdlcd_drv.c   |  21 +-
 drivers/gpu/drm/arm/malidp_drv.c  |  21 +-
 drivers/gpu/drm/armada/armada_drv.c   |  23 +-
 drivers/gpu/drm/drm_drv.c |   2 +-
 drivers/gpu/drm/drm_of.c  |  18 +-
 drivers/gpu/drm/etnaviv/etnaviv_drv.c |  20 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c   |  21 +-
 .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c   |  20 +-
 drivers/gpu/drm/imx/imx-drm-core.c|  20 +-
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c |  25 +-
 

[PATCH] drm/kmb: Fix for build errors with Warray-bounds

2022-01-27 Thread Anitha Chrisanthus
This fixes the following build error

drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is
above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
  165 | kmb->plane_status[plane_id].ctrl =
  LCD_CTRL_GL2_ENABLE;
  | ~^~
  In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
  drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing
  'plane_status'
  61 | struct layer_status
  plane_status[KMB_MAX_PLANES];
  | ^~~~
  drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array
  subscript 2 is above array bounds of 'struct
  layer_status[2]' [-Werror=array-bounds]
  162 |
  kmb->plane_status[plane_id].ctrl =
  LCD_CTRL_GL1_ENABLE;
  | ~^~
  In file included from
  drivers/gpu/drm/kmb/kmb_plane.c:17:
  drivers/gpu/drm/kmb/kmb_drv.h:61:41: note:
  while referencing 'plane_status'
  61 | struct layer_status
  plane_status[KMB_MAX_PLANES];
  |
  ^~~~

Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
Signed-off-by: Anitha Chrisanthus 
---
 drivers/gpu/drm/kmb/kmb_plane.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
index 00404ba4126d..2735b8eb3537 100644
--- a/drivers/gpu/drm/kmb/kmb_plane.c
+++ b/drivers/gpu/drm/kmb/kmb_plane.c
@@ -158,12 +158,6 @@ static void kmb_plane_atomic_disable(struct drm_plane 
*plane,
case LAYER_1:
kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;
break;
-   case LAYER_2:
-   kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
-   break;
-   case LAYER_3:
-   kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
-   break;
}
 
kmb->plane_status[plane_id].disable = true;
-- 
2.25.1



Re: [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API

2022-01-27 Thread kernel test robot
Hi Zhi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20220127]
[cannot apply to drm-intel/for-linux-next v5.17-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-rhel-8.3 
(https://download.01.org/0day-ci/archive/20220128/202201280218.adxamjx6-...@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/533f92651a7a56481a053f1e04dc5a5ec024ffb9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
git checkout 533f92651a7a56481a053f1e04dc5a5ec024ffb9
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gvt/handlers.c:45:6: warning: no previous prototype for 
>> 'intel_gvt_match_device' [-Wmissing-prototypes]
  45 | bool intel_gvt_match_device(struct intel_gvt *gvt,
 |  ^~


vim +/intel_gvt_match_device +45 drivers/gpu/drm/i915/gvt/handlers.c

12d14cc43b3470 Zhi Wang 2016-08-30  44  
12d14cc43b3470 Zhi Wang 2016-08-30 @45  bool intel_gvt_match_device(struct 
intel_gvt *gvt,
12d14cc43b3470 Zhi Wang 2016-08-30  46  unsigned long device)
12d14cc43b3470 Zhi Wang 2016-08-30  47  {
533f92651a7a56 Zhi Wang 2022-01-27  48  return 
intel_gvt_get_device_type(gvt->gt->i915) & device;
12d14cc43b3470 Zhi Wang 2016-08-30  49  }
12d14cc43b3470 Zhi Wang 2016-08-30  50  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [PATCH v2 00/37] drm: Make drivers to honour the nomodeset parameter

2022-01-27 Thread Javier Martinez Canillas
On 12/17/21 01:37, Javier Martinez Canillas wrote:
> The nomodeset kernel command line parameter is used to prevent the KMS/DRM
> drivers to be registered/probed. But only a few drivers implement support
> for this and most DRM drivers just ignore it.
> 
> This patch series is a v2 to make DRM drivers to honour nomodeset. It is
> posted as separate patches to make easier for drivers maintainers to ack
> or pick them independently at their own pace.
> 

Pushed the remaining of the drivers patches from this set to drm-misc-next.

Best regards,
-- 
Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [RFC][PATCH 00/10] drm: Add DRM module helpers for existing PCI drivers

2022-01-27 Thread Javier Martinez Canillas
On 12/17/21 15:46, Thomas Zimmermann wrote:
> This is an RFC patchset to complement the helper macros provided
> in [1]. The module helpers create module init and exit helpers that
> respect the kernel parameters that enable/disable DRM drivers.
> 
> There's one more patch that prepares qxl by moving some code around.
> It's required to make use of the helpers from within qxl.
> 
> Javier, please see if you find anything useful here and cherry-pick
> into your patchset. The driver changes should complement the ones
> in your patchset. The module macros are similar to yours and should
> be easily mergable.
> 
> I tested the macros with ast.
> 
> [1] https://patchwork.freedesktop.org/series/98162/
> 
> Thomas Zimmermann (10):
>   drm: Provide PCI module-init macros
>   drm/ast: Replace module-init boiler-plate code with DRM helpers
>   drm/bochs: Replace module-init boiler-plate code with DRM helpers
>   drm/cirrus: Replace module-init boiler-plate code with DRM helpers
>   drm/hisilicon/hibmc: Replace module initialization with DRM helpers
>   drm/mgag200: Replace module-init boiler-plate code with DRM helpers
>   drm/qxl: Move ioctl array next to its only user
>   drm/qxl: Replace module-init boiler-plate code with DRM helpers
>   drm/vboxvideo: Replace module-init boiler-plate code with DRM helpers
>   drm/vmwgfx: Replace module-init boiler-plate code with DRM helpers
> 

Pushed the remaining of these patches to drm-misc-next. Thanks!

Best regards,
-- 
Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [PATCH 1/3] drm: add writeback pointers to drm_connector

2022-01-27 Thread Abhinav Kumar

Hi Suraj

Thanks for the response.

I was not too worried about the intel driver as I am sure you must have 
validated this change with that :)


My question was more for the other vendor writeback drivers.

Thanks for looking into the others and providing the snippets.
After looking at those, yes I also think it should work.

So, if others do not have any concern with this change,

Reviewed-by: Abhinav Kumar 

On 1/27/2022 1:33 AM, Kandpal, Suraj wrote:


+ laurent on this

Hi Suraj
Jani pointed me to this thread as i had posted something similar here :
https://patchwork.freedesktop.org/patch/470296/ but since this thread was
posted earlier, we can discuss further here.

Overall, its similar to what I had posted in the RFC and your commit text also
covers my concerns too.

One question I have about your change is since you have changed
wb_connector::encoder to be a pointer, i saw the other changes in the series
but they do not allocate an encoder. Would this not affect the other drivers
which are assuming that the encoder in wb_connector is struct drm_encoder
encoder and not struct drm_encoder* encoder.

Your changes fix the compilation issue but wouldnt this crash as encoder
wasnt allocated for other drivers.



Hi Abhinav,
That shouldn't be an issue as normally drivers tend to have their own output
structure which has drm_connector and drm_encoder embedded in it depending
on the level of binding they have decided to give the connector and encoder in
their respective output and the addresses of these are passed to the
drm_connector* and drm_encoder* in drm_writeback_connector structure
which then gets initialized in drm_writeback_connector_init().

In our i915 code we have intel_connector structure with drm_connector base
field and intel_wd with a intel_encoder base which in turn has drm_encoder
field and both intel_connector and intel_wd are initialized not requiring 
explicit
alloc and dealloc for drm_encoder
intel_wd = kzalloc(sizeof(*intel_wd), GFP_KERNEL);

intel_connector = intel_connector_alloc();
wb_conn = _connector->wb_conn;
wb_conn->base = _connector->base;
wb_conn->encoder = _wd->base.base;

Similary for komeda driver has
struct komeda_wb_connector {
 struct drm_connector conn;
 /** @base: _writeback_connector */
 struct drm_writeback_connector base;

 /** @wb_layer: represents associated writeback pipeline of komeda */
 struct komeda_layer *wb_layer;
};

static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
struct komeda_crtc *kcrtc)
{
struct komeda_wb_connector *kwb_conn;
struct drm_writeback_connector *wb_conn;

kwb_conn = kzalloc(sizeof(*kwb_conn), GFP_KERNEL);

wb_conn = _conn->base;
wb_conn->base = _conn->conn;
   
and they do not depend on the encoder binding so changes will work for them

Also in vkms driver we have the
struct vkms_output {
 struct drm_crtc crtc;
 struct drm_encoder encoder;
 struct drm_connector connector;
 struct drm_writeback_connector wb_connector;
 struct hrtimer vblank_hrtimer;
 ktime_t period_ns;
 struct drm_pending_vblank_event *event;
 /* ordered wq for composer_work */
 struct workqueue_struct *composer_workq;
 /* protects concurrent access to composer */
 spinlock_t lock;

 /* protected by @lock */
 bool composer_enabled;
 struct vkms_crtc_state *composer_state;

 spinlock_t composer_lock;
};

Which gets allocated covering for the drm_encoder alloc and dealloc

Regards,
Suraj Kandpal



Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread Noralf Trønnes



Den 27.01.2022 11.04, skrev Maxime Ripard:
> On Tue, Jan 25, 2022 at 06:57:00PM +0100, Noralf Trønnes wrote:
>> Add a driver that will work with most MIPI DBI compatible SPI panels.
>> This avoids adding a driver for every new MIPI DBI compatible controller
>> that is to be used by Linux. The 'compatible' Device Tree property with
>> a '.bin' suffix will be used to load a firmware file that contains the
>> controller configuration.
>>
>> Example (driver will load sainsmart18.bin):
>>
>> display@0 {
>>  compatible = "sainsmart18", "panel-mipi-dbi-spi";
>>  reg = <0>;
>>  reset-gpios = < 25 0>;
>>  dc-gpios = < 24 0>;
>> };
>>
>> v2:
>> - Drop model property and use compatible instead (Rob)
>> - Add wiki entry in MAINTAINERS
>>
>> Signed-off-by: Noralf Trønnes 
>> ---
>>  MAINTAINERS|   8 +
>>  drivers/gpu/drm/panel/Kconfig  |  11 +
>>  drivers/gpu/drm/panel/Makefile |   1 +
>>  drivers/gpu/drm/panel/panel-mipi-dbi.c | 394 +
>>  4 files changed, 414 insertions(+)
>>  create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d03ad8da1f36..8baa98723bdc 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -6047,6 +6047,14 @@ T:git git://anongit.freedesktop.org/drm/drm-misc
>>  F:  Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
>>  F:  drivers/gpu/drm/tiny/mi0283qt.c
>>  
>> +DRM DRIVER FOR MIPI DBI compatible panels
>> +M:  Noralf Trønnes 
>> +S:  Maintained
>> +W:  https://github.com/notro/panel-mipi-dbi/wiki
>> +T:  git git://anongit.freedesktop.org/drm/drm-misc
>> +F:  Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml
>> +F:  drivers/gpu/drm/panel/panel-mipi-dbi.c
>> +
>>  DRM DRIVER FOR MSM ADRENO GPU
>>  M:  Rob Clark 
>>  M:  Sean Paul 
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 434c2861bb40..1851cda5f877 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -274,6 +274,17 @@ config DRM_PANEL_LG_LG4573
>>Say Y here if you want to enable support for LG4573 RGB panel.
>>To compile this driver as a module, choose M here.
>>  
>> +config DRM_PANEL_MIPI_DBI
>> +tristate "MIPI DBI compatible panel"
>> +depends on SPI
>> +depends on BACKLIGHT_CLASS_DEVICE
>> +depends on DRM_KMS_HELPER
>> +select DRM_KMS_CMA_HELPER
>> +select DRM_MIPI_DBI
>> +help
>> +  Say Y here if you want to enable support for MIPI DBI compatible 
>> panels.
>> +  To compile this driver as a module, choose M here.
>> +
>>  config DRM_PANEL_NEC_NL8048HL11
>>  tristate "NEC NL8048HL11 RGB panel"
>>  depends on GPIOLIB && OF && SPI
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index d99fbbce49d1..a90c30459964 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += 
>> panel-leadtek-ltk050h3146w.o
>>  obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o
>>  obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o
>>  obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
>> +obj-$(CONFIG_DRM_PANEL_MIPI_DBI) += panel-mipi-dbi.o
>>  obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o
>>  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
>>  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
>> diff --git a/drivers/gpu/drm/panel/panel-mipi-dbi.c 
>> b/drivers/gpu/drm/panel/panel-mipi-dbi.c
>> new file mode 100644
>> index ..6e3dc2de21d2
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-mipi-dbi.c
>> @@ -0,0 +1,394 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * DRM driver for MIPI DBI compatible display panels
>> + *
>> + * Copyright 2022 Noralf Trønnes
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +static const u8 panel_mipi_dbi_magic[15] = { 'M', 'I', 'P', 'I', ' ', 'D', 
>> 'B', 'I',
>> + 0, 0, 0, 0, 0, 0, 0 };
>> +
>> +/*
>> + * The display panel configuration is stored in a firmware file. The Device 
>> Tree 'compatible'
>> + * property value with a '.bin' suffix is passed to request_firmware() to 
>> fetch this file.
>> + */
>> +struct panel_mipi_dbi_config {
>> +/* Magic string: panel_mipi_dbi_magic */
>> +u8 magic[15];
>> +
>> +/* Config file format version */
>> +u8 file_format_version;
>> +
>> +/* Width in pixels */
>> +__be16 width;
>> +/* Height in pixels */
>> +__be16 height;
>> +
>> +/* Width in millimeters (optional) */
>> +__be16 width_mm;
>> +/* Height in millimeters (optional) */
>> 

Re: [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API

2022-01-27 Thread kernel test robot
Hi Zhi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20220127]
[cannot apply to drm-intel/for-linux-next hch-configfs/for-next v5.17-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-randconfig-a005 
(https://download.01.org/0day-ci/archive/20220128/202201280121.yx5gbodp-...@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
f32dccb9a43b02ce4e540d6ba5dbbdb188f2dc7d)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/533f92651a7a56481a053f1e04dc5a5ec024ffb9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
git checkout 533f92651a7a56481a053f1e04dc5a5ec024ffb9
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 
O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gvt/handlers.c:45:6: warning: no previous prototype for 
>> function 'intel_gvt_match_device' [-Wmissing-prototypes]
   bool intel_gvt_match_device(struct intel_gvt *gvt,
^
   drivers/gpu/drm/i915/gvt/handlers.c:45:1: note: declare 'static' if the 
function is not intended to be used outside of this translation unit
   bool intel_gvt_match_device(struct intel_gvt *gvt,
   ^
   static 
   1 warning generated.


vim +/intel_gvt_match_device +45 drivers/gpu/drm/i915/gvt/handlers.c

12d14cc43b3470 Zhi Wang 2016-08-30  44  
12d14cc43b3470 Zhi Wang 2016-08-30 @45  bool intel_gvt_match_device(struct 
intel_gvt *gvt,
12d14cc43b3470 Zhi Wang 2016-08-30  46  unsigned long device)
12d14cc43b3470 Zhi Wang 2016-08-30  47  {
533f92651a7a56 Zhi Wang 2022-01-27  48  return 
intel_gvt_get_device_type(gvt->gt->i915) & device;
12d14cc43b3470 Zhi Wang 2016-08-30  49  }
12d14cc43b3470 Zhi Wang 2016-08-30  50  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [PATCH v1] gpu: host1x: Fix hang on Tegra186+

2022-01-27 Thread Thierry Reding
On Thu, Dec 23, 2021 at 05:46:50PM +0300, Dmitry Osipenko wrote:
> Tegra186+ hangs if host1x hardware is disabled at a kernel boot time
> because we touch hardware before runtime PM is resumed. Move sync point
> assignment initialization to the RPM-resume callback. Older SoCs were
> unaffected because they skip that sync point initialization.
> 
> Tested-by: Jon Hunter  # T186
> Reported-by: Jon Hunter  # T186
> Fixes: 6b6776e2ab8a ("gpu: host1x: Add initial runtime PM and OPP support")
> Signed-off-by: Dmitry Osipenko 
> ---
>  drivers/gpu/host1x/syncpt.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)

Applied, thanks.

Thierry


signature.asc
Description: PGP signature


Re: [PATCH v2 0/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread David Lechner

On 1/25/22 11:56 AM, Noralf Trønnes wrote:

Hi,

This patchset adds a driver that will work with most MIPI DBI compatible
SPI panels out there.

It's a follow up on 'drm/tiny/st7735r: Match up with staging/fbtft
driver'[1] which aimed at making the st7735r driver work with all panels
adding DT properties.

Maxime gave[2] a good overview of the situation with these displays and
proposed to make a driver that works with all MIPI DBI compatible
controllers and use a firmware file to provide the controller setup for
a particular panel.

Main change since previous version:
- Drop model property and use the compatible property instead (Rob)

Noralf.

[1] https://lore.kernel.org/dri-devel/20211124150757.17929-1-nor...@tronnes.org/
[2] https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/


Noralf Trønnes (3):
   dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
   drm/mipi-dbi: Add driver_private member to struct mipi_dbi_dev
   drm/panel: Add MIPI DBI compatible SPI driver

  .../display/panel/panel-mipi-dbi-spi.yaml |  59 +++
  MAINTAINERS   |   8 +
  drivers/gpu/drm/panel/Kconfig |  11 +
  drivers/gpu/drm/panel/Makefile|   1 +
  drivers/gpu/drm/panel/panel-mipi-dbi.c| 394 ++
  include/drm/drm_mipi_dbi.h|   2 +
  6 files changed, 475 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml
  create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c



It would be useful to also include a patch for a tool to create
these "firmware" files. For example a Python script that takes
a more human-readable input and generates a .bin file.


Re: [PATCH v2 3/3] drm/panel: Add MIPI DBI compatible SPI driver

2022-01-27 Thread David Lechner

On 1/25/22 11:57 AM, Noralf Trønnes wrote:

Add a driver that will work with most MIPI DBI compatible SPI panels.
This avoids adding a driver for every new MIPI DBI compatible controller
that is to be used by Linux. The 'compatible' Device Tree property with
a '.bin' suffix will be used to load a firmware file that contains the
controller configuration.

Example (driver will load sainsmart18.bin):

display@0 {
compatible = "sainsmart18", "panel-mipi-dbi-spi";
reg = <0>;
reset-gpios = < 25 0>;
dc-gpios = < 24 0>;
};



...


+static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
+{
+   struct device *dev = >dev;
+   struct drm_display_mode mode;
+   struct mipi_dbi_dev *dbidev;
+   const struct firmware *fw;
+   const char *compatible;
+   struct drm_device *drm;
+   struct property *prop;
+   bool fw_found = false;
+   struct mipi_dbi *dbi;
+   struct gpio_desc *dc;
+   char fw_name[40];
+   int ret;
+
+   dbidev = devm_drm_dev_alloc(dev, _mipi_dbi_driver, struct 
mipi_dbi_dev, drm);
+   if (IS_ERR(dbidev))
+   return PTR_ERR(dbidev);
+
+   dbi = >dbi;
+   drm = >drm;
+
+   of_property_for_each_string(dev->of_node, "compatible", prop, 
compatible) {
+   snprintf(fw_name, sizeof(fw_name), "%s.bin", compatible);
+
+   ret = firmware_request_nowarn(, fw_name, dev);
+   if (ret) {
+   drm_dbg(drm, "No config file found for compatible: '%s' 
(error=%d)\n",
+   compatible, ret);
+   continue;
+   }
+


Should we add a directory prefix to the firmware file name to avoid the 
possibility of
file name clashes with unrelated firmwares?


Re: [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API

2022-01-27 Thread kernel test robot
Hi Zhi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20220127]
[cannot apply to drm-intel/for-linux-next v5.17-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-allyesconfig 
(https://download.01.org/0day-ci/archive/20220128/202201280125.vultasas-...@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/533f92651a7a56481a053f1e04dc5a5ec024ffb9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Zhi-Wang/i915-gvt-Introduce-the-mmio_table-c-to-support-VFIO-new-mdev-API/20220127-200727
git checkout 533f92651a7a56481a053f1e04dc5a5ec024ffb9
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gvt/mmio_table.c:37: warning: expecting prototype for 
>> intel_gvt_get_init_device_info(). Prototype was for 
>> intel_gvt_init_device_info() instead


vim +37 drivers/gpu/drm/i915/gvt/mmio_table.c

28  
29  /**
30   * intel_gvt_get_init_device_info - Fill a GVT device info
31   * @i915: drm i915 private data
32   * @info: GVT device info
33   *
34   * This function will be called during the initialization of a GVT 
device.
35   */
36  void intel_gvt_init_device_info(struct drm_i915_private *i915, struct 
intel_gvt_device_info *info)
  > 37  {
38  struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
39  
40  info->max_support_vgpus = 8;
41  info->cfg_space_size = PCI_CFG_SPACE_EXP_SIZE;
42  info->mmio_size = 2 * 1024 * 1024;
43  info->mmio_bar = 0;
44  info->gtt_start_offset = 8 * 1024 * 1024;
45  info->gtt_entry_size = 8;
46  info->gtt_entry_size_shift = 3;
47  info->gmadr_bytes_in_cmd = 8;
48  info->max_surface_size = 36 * 1024 * 1024;
49  info->msi_cap_offset = pdev->msi_cap;
50  }
51  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


  1   2   3   >