2020-04-06 05:12:46

by Hsin-Yi Wang

[permalink] [raw]
Subject: [PATCH] drm: mediatek: fix device passed to cmdq

drm device is now probed from mmsys. We need to use mmsys device to get gce
nodes. Fix following errors:

[ 0.740068] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
[ 0.748721] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
...
[ 2.659645] mediatek-drm mediatek-drm.1.auto: failed to request channel
[ 2.666270] mediatek-drm mediatek-drm.1.auto: failed to request channel

Fixes: 1d367541aded ("soc / drm: mediatek: Fix mediatek-drm device probing")
Signed-off-by: Hsin-Yi Wang <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 ++++--
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 615a54e60fe2..8621f0289399 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -822,14 +822,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,

#if IS_REACHABLE(CONFIG_MTK_CMDQ)
mtk_crtc->cmdq_client =
- cmdq_mbox_create(dev, drm_crtc_index(&mtk_crtc->base),
+ cmdq_mbox_create(mtk_crtc->mmsys_dev,
+ drm_crtc_index(&mtk_crtc->base),
2000);
if (IS_ERR(mtk_crtc->cmdq_client)) {
dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n",
drm_crtc_index(&mtk_crtc->base));
mtk_crtc->cmdq_client = NULL;
}
- ret = of_property_read_u32_index(dev->of_node, "mediatek,gce-events",
+ ret = of_property_read_u32_index(mtk_crtc->mmsys_dev->of_node,
+ "mediatek,gce-events",
drm_crtc_index(&mtk_crtc->base),
&mtk_crtc->cmdq_event);
if (ret)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index e2bb0d19ef99..dc78e86bccc0 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -517,7 +517,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
goto err_node;
}

- ret = mtk_ddp_comp_init(dev, node, comp, comp_id, NULL);
+ ret = mtk_ddp_comp_init(dev->parent, node, comp,
+ comp_id, NULL);
if (ret) {
of_node_put(node);
goto err_node;
--
2.26.0.292.g33ef6b2f38-goog


2020-04-06 07:14:38

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] drm: mediatek: fix device passed to cmdq

Hi Hsin-Yi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on clk/clk-next]
[cannot apply to arm-soc/for-next xlnx/master linus/master v5.6 next-20200405]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Hsin-Yi-Wang/drm-mediatek-fix-device-passed-to-cmdq/20200406-132804
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: arm64-randconfig-a001-20200406 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/gpu/drm/mediatek/mtk_drm_crtc.c: In function 'mtk_drm_crtc_create':
>> drivers/gpu/drm/mediatek/mtk_drm_crtc.c:824:29: error: 'struct mtk_drm_crtc' has no member named 'mmsys_dev'
824 | cmdq_mbox_create(mtk_crtc->mmsys_dev,
| ^~
drivers/gpu/drm/mediatek/mtk_drm_crtc.c:832:43: error: 'struct mtk_drm_crtc' has no member named 'mmsys_dev'
832 | ret = of_property_read_u32_index(mtk_crtc->mmsys_dev->of_node,
| ^~

vim +824 drivers/gpu/drm/mediatek/mtk_drm_crtc.c

724
725 int mtk_drm_crtc_create(struct drm_device *drm_dev,
726 const enum mtk_ddp_comp_id *path, unsigned int path_len)
727 {
728 struct mtk_drm_private *priv = drm_dev->dev_private;
729 struct device *dev = drm_dev->dev;
730 struct mtk_drm_crtc *mtk_crtc;
731 unsigned int num_comp_planes = 0;
732 int pipe = priv->num_pipes;
733 int ret;
734 int i;
735 bool has_ctm = false;
736 uint gamma_lut_size = 0;
737
738 if (!path)
739 return 0;
740
741 for (i = 0; i < path_len; i++) {
742 enum mtk_ddp_comp_id comp_id = path[i];
743 struct device_node *node;
744
745 node = priv->comp_node[comp_id];
746 if (!node) {
747 dev_info(dev,
748 "Not creating crtc %d because component %d is disabled or missing\n",
749 pipe, comp_id);
750 return 0;
751 }
752 }
753
754 mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
755 if (!mtk_crtc)
756 return -ENOMEM;
757
758 mtk_crtc->config_regs = priv->config_regs;
759 mtk_crtc->ddp_comp_nr = path_len;
760 mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
761 sizeof(*mtk_crtc->ddp_comp),
762 GFP_KERNEL);
763 if (!mtk_crtc->ddp_comp)
764 return -ENOMEM;
765
766 mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe);
767 if (IS_ERR(mtk_crtc->mutex)) {
768 ret = PTR_ERR(mtk_crtc->mutex);
769 dev_err(dev, "Failed to get mutex: %d\n", ret);
770 return ret;
771 }
772
773 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
774 enum mtk_ddp_comp_id comp_id = path[i];
775 struct mtk_ddp_comp *comp;
776 struct device_node *node;
777
778 node = priv->comp_node[comp_id];
779 comp = priv->ddp_comp[comp_id];
780 if (!comp) {
781 dev_err(dev, "Component %pOF not initialized\n", node);
782 ret = -ENODEV;
783 return ret;
784 }
785
786 mtk_crtc->ddp_comp[i] = comp;
787
788 if (comp->funcs) {
789 if (comp->funcs->gamma_set)
790 gamma_lut_size = MTK_LUT_SIZE;
791
792 if (comp->funcs->ctm_set)
793 has_ctm = true;
794 }
795 }
796
797 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
798 num_comp_planes += mtk_drm_crtc_num_comp_planes(mtk_crtc, i);
799
800 mtk_crtc->planes = devm_kcalloc(dev, num_comp_planes,
801 sizeof(struct drm_plane), GFP_KERNEL);
802
803 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
804 ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i,
805 pipe);
806 if (ret)
807 return ret;
808 }
809
810 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
811 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
812 NULL, pipe);
813 if (ret < 0)
814 return ret;
815
816 if (gamma_lut_size)
817 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, gamma_lut_size);
818 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm, gamma_lut_size);
819 priv->num_pipes++;
820 mutex_init(&mtk_crtc->hw_lock);
821
822 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
823 mtk_crtc->cmdq_client =
> 824 cmdq_mbox_create(mtk_crtc->mmsys_dev,

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (5.11 kB)
.config.gz (42.60 kB)
Download all attachments

2020-04-06 07:18:42

by Hsin-Yi Wang

[permalink] [raw]
Subject: Re: [PATCH] drm: mediatek: fix device passed to cmdq

The patch depends on
https://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux.git
branch v5.6-next/soc

On Mon, Apr 6, 2020 at 3:12 PM kbuild test robot <[email protected]> wrote:
>
> Hi Hsin-Yi,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on clk/clk-next]
> [cannot apply to arm-soc/for-next xlnx/master linus/master v5.6 next-20200405]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url: https://github.com/0day-ci/linux/commits/Hsin-Yi-Wang/drm-mediatek-fix-device-passed-to-cmdq/20200406-132804
> base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
> config: arm64-randconfig-a001-20200406 (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 9.3.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> GCC_VERSION=9.3.0 make.cross ARCH=arm64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kbuild test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c: In function 'mtk_drm_crtc_create':
> >> drivers/gpu/drm/mediatek/mtk_drm_crtc.c:824:29: error: 'struct mtk_drm_crtc' has no member named 'mmsys_dev'
> 824 | cmdq_mbox_create(mtk_crtc->mmsys_dev,
> | ^~
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c:832:43: error: 'struct mtk_drm_crtc' has no member named 'mmsys_dev'
> 832 | ret = of_property_read_u32_index(mtk_crtc->mmsys_dev->of_node,
> | ^~
>
> vim +824 drivers/gpu/drm/mediatek/mtk_drm_crtc.c
>
> 724
> 725 int mtk_drm_crtc_create(struct drm_device *drm_dev,
> 726 const enum mtk_ddp_comp_id *path, unsigned int path_len)
> 727 {
> 728 struct mtk_drm_private *priv = drm_dev->dev_private;
> 729 struct device *dev = drm_dev->dev;
> 730 struct mtk_drm_crtc *mtk_crtc;
> 731 unsigned int num_comp_planes = 0;
> 732 int pipe = priv->num_pipes;
> 733 int ret;
> 734 int i;
> 735 bool has_ctm = false;
> 736 uint gamma_lut_size = 0;
> 737
> 738 if (!path)
> 739 return 0;
> 740
> 741 for (i = 0; i < path_len; i++) {
> 742 enum mtk_ddp_comp_id comp_id = path[i];
> 743 struct device_node *node;
> 744
> 745 node = priv->comp_node[comp_id];
> 746 if (!node) {
> 747 dev_info(dev,
> 748 "Not creating crtc %d because component %d is disabled or missing\n",
> 749 pipe, comp_id);
> 750 return 0;
> 751 }
> 752 }
> 753
> 754 mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
> 755 if (!mtk_crtc)
> 756 return -ENOMEM;
> 757
> 758 mtk_crtc->config_regs = priv->config_regs;
> 759 mtk_crtc->ddp_comp_nr = path_len;
> 760 mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
> 761 sizeof(*mtk_crtc->ddp_comp),
> 762 GFP_KERNEL);
> 763 if (!mtk_crtc->ddp_comp)
> 764 return -ENOMEM;
> 765
> 766 mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe);
> 767 if (IS_ERR(mtk_crtc->mutex)) {
> 768 ret = PTR_ERR(mtk_crtc->mutex);
> 769 dev_err(dev, "Failed to get mutex: %d\n", ret);
> 770 return ret;
> 771 }
> 772
> 773 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> 774 enum mtk_ddp_comp_id comp_id = path[i];
> 775 struct mtk_ddp_comp *comp;
> 776 struct device_node *node;
> 777
> 778 node = priv->comp_node[comp_id];
> 779 comp = priv->ddp_comp[comp_id];
> 780 if (!comp) {
> 781 dev_err(dev, "Component %pOF not initialized\n", node);
> 782 ret = -ENODEV;
> 783 return ret;
> 784 }
> 785
> 786 mtk_crtc->ddp_comp[i] = comp;
> 787
> 788 if (comp->funcs) {
> 789 if (comp->funcs->gamma_set)
> 790 gamma_lut_size = MTK_LUT_SIZE;
> 791
> 792 if (comp->funcs->ctm_set)
> 793 has_ctm = true;
> 794 }
> 795 }
> 796
> 797 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
> 798 num_comp_planes += mtk_drm_crtc_num_comp_planes(mtk_crtc, i);
> 799
> 800 mtk_crtc->planes = devm_kcalloc(dev, num_comp_planes,
> 801 sizeof(struct drm_plane), GFP_KERNEL);
> 802
> 803 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> 804 ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i,
> 805 pipe);
> 806 if (ret)
> 807 return ret;
> 808 }
> 809
> 810 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> 811 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> 812 NULL, pipe);
> 813 if (ret < 0)
> 814 return ret;
> 815
> 816 if (gamma_lut_size)
> 817 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, gamma_lut_size);
> 818 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm, gamma_lut_size);
> 819 priv->num_pipes++;
> 820 mutex_init(&mtk_crtc->hw_lock);
> 821
> 822 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
> 823 mtk_crtc->cmdq_client =
> > 824 cmdq_mbox_create(mtk_crtc->mmsys_dev,
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/[email protected]

2020-04-06 15:26:03

by Enric Balletbo i Serra

[permalink] [raw]
Subject: Re: [PATCH] drm: mediatek: fix device passed to cmdq

Hi Hsin-Yi

Thanks for sending the patch upstream

On 6/4/20 7:11, Hsin-Yi Wang wrote:
> drm device is now probed from mmsys. We need to use mmsys device to get gce
> nodes. Fix following errors:
>
> [ 0.740068] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
> [ 0.748721] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
> ...
> [ 2.659645] mediatek-drm mediatek-drm.1.auto: failed to request channel
> [ 2.666270] mediatek-drm mediatek-drm.1.auto: failed to request channel
>
> Fixes: 1d367541aded ("soc / drm: mediatek: Fix mediatek-drm device probing")
> Signed-off-by: Hsin-Yi Wang <[email protected]>

Right, the mmsys device is now the parent of the drm device.

Reviewed-by: Enric Balletbo i Serra <[email protected]>

Also I tested drm with the patch applied and adding the gce client register to
my device-tree.

Tested-by: Enric Balletbo i Serra <[email protected]>

Thanks,
Enric

> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 ++++--
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 615a54e60fe2..8621f0289399 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -822,14 +822,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>
> #if IS_REACHABLE(CONFIG_MTK_CMDQ)
> mtk_crtc->cmdq_client =
> - cmdq_mbox_create(dev, drm_crtc_index(&mtk_crtc->base),
> + cmdq_mbox_create(mtk_crtc->mmsys_dev,
> + drm_crtc_index(&mtk_crtc->base),
> 2000);
> if (IS_ERR(mtk_crtc->cmdq_client)) {
> dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n",
> drm_crtc_index(&mtk_crtc->base));
> mtk_crtc->cmdq_client = NULL;
> }
> - ret = of_property_read_u32_index(dev->of_node, "mediatek,gce-events",
> + ret = of_property_read_u32_index(mtk_crtc->mmsys_dev->of_node,
> + "mediatek,gce-events",
> drm_crtc_index(&mtk_crtc->base),
> &mtk_crtc->cmdq_event);
> if (ret)
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index e2bb0d19ef99..dc78e86bccc0 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -517,7 +517,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
> goto err_node;
> }
>
> - ret = mtk_ddp_comp_init(dev, node, comp, comp_id, NULL);
> + ret = mtk_ddp_comp_init(dev->parent, node, comp,
> + comp_id, NULL);
> if (ret) {
> of_node_put(node);
> goto err_node;
>

2020-04-06 17:44:28

by Chun-Kuang Hu

[permalink] [raw]
Subject: Re: [PATCH] drm: mediatek: fix device passed to cmdq

Hi, Hsin-Yi:

Hsin-Yi Wang <[email protected]> 於 2020年4月6日 週一 下午1:12寫道:
>
> drm device is now probed from mmsys. We need to use mmsys device to get gce
> nodes. Fix following errors:
>
> [ 0.740068] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
> [ 0.748721] mediatek-drm mediatek-drm.1.auto: error -2 can't parse gce-client-reg property (0)
> ...
> [ 2.659645] mediatek-drm mediatek-drm.1.auto: failed to request channel
> [ 2.666270] mediatek-drm mediatek-drm.1.auto: failed to request channel

Reviewed-by: Chun-Kuang Hu <[email protected]>

>
> Fixes: 1d367541aded ("soc / drm: mediatek: Fix mediatek-drm device probing")
> Signed-off-by: Hsin-Yi Wang <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 ++++--
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 615a54e60fe2..8621f0289399 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -822,14 +822,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>
> #if IS_REACHABLE(CONFIG_MTK_CMDQ)
> mtk_crtc->cmdq_client =
> - cmdq_mbox_create(dev, drm_crtc_index(&mtk_crtc->base),
> + cmdq_mbox_create(mtk_crtc->mmsys_dev,
> + drm_crtc_index(&mtk_crtc->base),
> 2000);
> if (IS_ERR(mtk_crtc->cmdq_client)) {
> dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n",
> drm_crtc_index(&mtk_crtc->base));
> mtk_crtc->cmdq_client = NULL;
> }
> - ret = of_property_read_u32_index(dev->of_node, "mediatek,gce-events",
> + ret = of_property_read_u32_index(mtk_crtc->mmsys_dev->of_node,
> + "mediatek,gce-events",
> drm_crtc_index(&mtk_crtc->base),
> &mtk_crtc->cmdq_event);
> if (ret)
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index e2bb0d19ef99..dc78e86bccc0 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -517,7 +517,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
> goto err_node;
> }
>
> - ret = mtk_ddp_comp_init(dev, node, comp, comp_id, NULL);
> + ret = mtk_ddp_comp_init(dev->parent, node, comp,
> + comp_id, NULL);
> if (ret) {
> of_node_put(node);
> goto err_node;
> --
> 2.26.0.292.g33ef6b2f38-goog
>
>
> _______________________________________________
> Linux-mediatek mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-mediatek