From ff939b693d96348fba55be878345fa9071aa25e8 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Sat, 27 Aug 2022 13:24:07 +0800 Subject: [PATCH] rockchip: fix vop2 driver build Fixes: a2f87aaf533b9c ("rockchip: backport rk3568 support to kernel 5.15") Signed-off-by: Tianling Shen --- ...ckchip-Refactor-IOMMU-initialisation.patch | 203 ++++++++++++++++++ ...d-drm_encoder-into-rockchip_decoder.patch} | 0 ...rtc_endpoint_id-to-rockchip_encoder.patch} | 0 ...ename-vpll-clock-to-reference-clock.patch} | 0 ...rockchip-dw_hdmi-add-rk3568-support.patch} | 0 ...kchip-dw_hdmi-add-regulator-support.patch} | 0 ...m-rockchip-Make-VOP-driver-optional.patch} | 0 ...-v5.19-drm-rockchip-Add-VOP2-driver.patch} | 0 ...chip-dwc-Reset-core-at-driver-probe.patch} | 0 ...ip-dwc-Add-legacy-interrupt-support.patch} | 0 ...ckchip-vop2-unlock-on-error-path-in.patch} | 0 ...ntro-Add-support-for-RK356x-encoder.patch} | 0 ...o-usb2-Ignore-OTG-IRQs-in-host-mode.patch} | 0 ...Fix-RK3399-H.264-format-advertising.patch} | 0 ...b2-Prevent-incorrect-error-on-probe.patch} | 0 ...ip-inno-usb2-Sync-initial-otg-state.patch} | 0 16 files changed, 203 insertions(+) create mode 100644 target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Refactor-IOMMU-initialisation.patch rename target/linux/rockchip/patches-5.15/{008-0026-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch => 008-0027-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0027-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch => 008-0028-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0028-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch => 008-0029-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0029-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch => 008-0030-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0030-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch => 008-0031-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0031-v5.19-drm-rockchip-Make-VOP-driver-optional.patch => 008-0032-v5.19-drm-rockchip-Make-VOP-driver-optional.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0032-v5.19-drm-rockchip-Add-VOP2-driver.patch => 008-0033-v5.19-drm-rockchip-Add-VOP2-driver.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0033-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch => 008-0034-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0034-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch => 008-0035-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0035-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch => 008-0036-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0036-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch => 008-0037-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0037-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch => 008-0038-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0038-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch => 008-0039-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0039-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch => 008-0040-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch} (100%) rename target/linux/rockchip/patches-5.15/{008-0040-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch => 008-0041-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch} (100%) diff --git a/target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Refactor-IOMMU-initialisation.patch b/target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Refactor-IOMMU-initialisation.patch new file mode 100644 index 0000000000..a200928867 --- /dev/null +++ b/target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Refactor-IOMMU-initialisation.patch @@ -0,0 +1,203 @@ +From 421be3ee36a497949a4b564cd1e4f7f9fe755f57 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Tue, 5 Apr 2022 15:32:50 +0100 +Subject: [PATCH] drm/rockchip: Refactor IOMMU initialisation + +Defer the IOMMU domain setup until after successfully binding +components, so we can figure out IOMMU support directly from the VOP +devices themselves, rather than manually inferring it from the DT (which +also fails to account for whether the IOMMU driver is actually loaded). +Although this is somewhat of a logical cleanup, the main motivation is +to prepare for a change in the iommu_domain_alloc() interface. + +Signed-off-by: Robin Murphy +Signed-off-by: Heiko Stuebner +Link: https://patchwork.freedesktop.org/patch/msgid/94eee7ab434fe11eb0787f691e9f1ab03a2e91be.1649168685.git.robin.murphy@arm.com +--- + drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 60 +++++++++------------ + drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 3 ++ + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 2 + + 3 files changed, 31 insertions(+), 34 deletions(-) + +--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c ++++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +@@ -7,7 +7,6 @@ + */ + + #include +-#include + #include + #include + #include +@@ -35,7 +34,6 @@ + #define DRIVER_MAJOR 1 + #define DRIVER_MINOR 0 + +-static bool is_support_iommu = true; + static const struct drm_driver rockchip_drm_driver; + + /* +@@ -49,7 +47,7 @@ int rockchip_drm_dma_attach_device(struc + struct rockchip_drm_private *private = drm_dev->dev_private; + int ret; + +- if (!is_support_iommu) ++ if (!private->domain) + return 0; + + ret = iommu_attach_device(private->domain, dev); +@@ -65,12 +63,22 @@ void rockchip_drm_dma_detach_device(stru + struct device *dev) + { + struct rockchip_drm_private *private = drm_dev->dev_private; +- struct iommu_domain *domain = private->domain; + +- if (!is_support_iommu) ++ if (!private->domain) + return; + +- iommu_detach_device(domain, dev); ++ iommu_detach_device(private->domain, dev); ++} ++ ++void rockchip_drm_dma_init_device(struct drm_device *drm_dev, ++ struct device *dev) ++{ ++ struct rockchip_drm_private *private = drm_dev->dev_private; ++ ++ if (!device_iommu_mapped(dev)) ++ private->iommu_dev = ERR_PTR(-ENODEV); ++ else if (!private->iommu_dev) ++ private->iommu_dev = dev; + } + + static int rockchip_drm_init_iommu(struct drm_device *drm_dev) +@@ -79,10 +87,10 @@ static int rockchip_drm_init_iommu(struc + struct iommu_domain_geometry *geometry; + u64 start, end; + +- if (!is_support_iommu) ++ if (IS_ERR_OR_NULL(private->iommu_dev)) + return 0; + +- private->domain = iommu_domain_alloc(&platform_bus_type); ++ private->domain = iommu_domain_alloc(private->iommu_dev->bus); + if (!private->domain) + return -ENOMEM; + +@@ -102,7 +110,7 @@ static void rockchip_iommu_cleanup(struc + { + struct rockchip_drm_private *private = drm_dev->dev_private; + +- if (!is_support_iommu) ++ if (!private->domain) + return; + + drm_mm_takedown(&private->mm); +@@ -141,25 +149,25 @@ static int rockchip_drm_bind(struct devi + INIT_LIST_HEAD(&private->psr_list); + mutex_init(&private->psr_list_lock); + +- ret = rockchip_drm_init_iommu(drm_dev); +- if (ret) +- goto err_free; +- + ret = drmm_mode_config_init(drm_dev); + if (ret) +- goto err_iommu_cleanup; ++ goto err_free; + + rockchip_drm_mode_config_init(drm_dev); + + /* Try to bind all sub drivers. */ + ret = component_bind_all(dev, drm_dev); + if (ret) +- goto err_iommu_cleanup; ++ goto err_free; + +- ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc); ++ ret = rockchip_drm_init_iommu(drm_dev); + if (ret) + goto err_unbind_all; + ++ ret = drm_vblank_init(drm_dev, drm_dev->mode_config.num_crtc); ++ if (ret) ++ goto err_iommu_cleanup; ++ + drm_mode_config_reset(drm_dev); + + ret = rockchip_drm_fbdev_init(drm_dev); +@@ -177,10 +185,10 @@ static int rockchip_drm_bind(struct devi + err_kms_helper_poll_fini: + drm_kms_helper_poll_fini(drm_dev); + rockchip_drm_fbdev_fini(drm_dev); +-err_unbind_all: +- component_unbind_all(dev, drm_dev); + err_iommu_cleanup: + rockchip_iommu_cleanup(drm_dev); ++err_unbind_all: ++ component_unbind_all(dev, drm_dev); + err_free: + drm_dev_put(drm_dev); + return ret; +@@ -358,8 +366,6 @@ static int rockchip_drm_platform_of_prob + return -ENODEV; + + for (i = 0;; i++) { +- struct device_node *iommu; +- + port = of_parse_phandle(np, "ports", i); + if (!port) + break; +@@ -369,21 +375,7 @@ static int rockchip_drm_platform_of_prob + continue; + } + +- iommu = of_parse_phandle(port->parent, "iommus", 0); +- if (!iommu || !of_device_is_available(iommu->parent)) { +- DRM_DEV_DEBUG(dev, +- "no iommu attached for %pOF, using non-iommu buffers\n", +- port->parent); +- /* +- * if there is a crtc not support iommu, force set all +- * crtc use non-iommu buffer. +- */ +- is_support_iommu = false; +- } +- + found = true; +- +- of_node_put(iommu); + of_node_put(port); + } + +--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h ++++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +@@ -46,6 +46,7 @@ struct rockchip_drm_private { + struct drm_fb_helper fbdev_helper; + struct drm_gem_object *fbdev_bo; + struct iommu_domain *domain; ++ struct device *iommu_dev; + struct mutex mm_lock; + struct drm_mm mm; + struct list_head psr_list; +@@ -56,6 +57,8 @@ int rockchip_drm_dma_attach_device(struc + struct device *dev); + void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, + struct device *dev); ++void rockchip_drm_dma_init_device(struct drm_device *drm_dev, ++ struct device *dev); + int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout); + + int rockchip_drm_endpoint_is_subdriver(struct device_node *ep); +--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c ++++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +@@ -2176,6 +2176,8 @@ static int vop_bind(struct device *dev, + } + } + ++ rockchip_drm_dma_init_device(drm_dev, dev); ++ + return 0; + + err_disable_pm_runtime: diff --git a/target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch b/target/linux/rockchip/patches-5.15/008-0027-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0026-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch rename to target/linux/rockchip/patches-5.15/008-0027-v5.19-drm-rockchip-Embed-drm_encoder-into-rockchip_decoder.patch diff --git a/target/linux/rockchip/patches-5.15/008-0027-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch b/target/linux/rockchip/patches-5.15/008-0028-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0027-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch rename to target/linux/rockchip/patches-5.15/008-0028-v5.19-drm-rockchip-Add-crtc_endpoint_id-to-rockchip_encoder.patch diff --git a/target/linux/rockchip/patches-5.15/008-0028-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch b/target/linux/rockchip/patches-5.15/008-0029-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0028-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch rename to target/linux/rockchip/patches-5.15/008-0029-v5.19-drm-rockchip-dw_hdmi-rename-vpll-clock-to-reference-clock.patch diff --git a/target/linux/rockchip/patches-5.15/008-0029-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch b/target/linux/rockchip/patches-5.15/008-0030-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0029-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch rename to target/linux/rockchip/patches-5.15/008-0030-v5.19-drm-rockchip-dw_hdmi-add-rk3568-support.patch diff --git a/target/linux/rockchip/patches-5.15/008-0030-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch b/target/linux/rockchip/patches-5.15/008-0031-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0030-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch rename to target/linux/rockchip/patches-5.15/008-0031-v5.19-drm-rockchip-dw_hdmi-add-regulator-support.patch diff --git a/target/linux/rockchip/patches-5.15/008-0031-v5.19-drm-rockchip-Make-VOP-driver-optional.patch b/target/linux/rockchip/patches-5.15/008-0032-v5.19-drm-rockchip-Make-VOP-driver-optional.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0031-v5.19-drm-rockchip-Make-VOP-driver-optional.patch rename to target/linux/rockchip/patches-5.15/008-0032-v5.19-drm-rockchip-Make-VOP-driver-optional.patch diff --git a/target/linux/rockchip/patches-5.15/008-0032-v5.19-drm-rockchip-Add-VOP2-driver.patch b/target/linux/rockchip/patches-5.15/008-0033-v5.19-drm-rockchip-Add-VOP2-driver.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0032-v5.19-drm-rockchip-Add-VOP2-driver.patch rename to target/linux/rockchip/patches-5.15/008-0033-v5.19-drm-rockchip-Add-VOP2-driver.patch diff --git a/target/linux/rockchip/patches-5.15/008-0033-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch b/target/linux/rockchip/patches-5.15/008-0034-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0033-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch rename to target/linux/rockchip/patches-5.15/008-0034-v5.19-PCI-rockchip-dwc-Reset-core-at-driver-probe.patch diff --git a/target/linux/rockchip/patches-5.15/008-0034-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch b/target/linux/rockchip/patches-5.15/008-0035-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0034-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch rename to target/linux/rockchip/patches-5.15/008-0035-v5.19-PCI-rockchip-dwc-Add-legacy-interrupt-support.patch diff --git a/target/linux/rockchip/patches-5.15/008-0035-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch b/target/linux/rockchip/patches-5.15/008-0036-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0035-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch rename to target/linux/rockchip/patches-5.15/008-0036-v6.0-drm-rockchip-vop2-unlock-on-error-path-in.patch diff --git a/target/linux/rockchip/patches-5.15/008-0036-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch b/target/linux/rockchip/patches-5.15/008-0037-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0036-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch rename to target/linux/rockchip/patches-5.15/008-0037-v6.0-media-hantro-Add-support-for-RK356x-encoder.patch diff --git a/target/linux/rockchip/patches-5.15/008-0037-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch b/target/linux/rockchip/patches-5.15/008-0038-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0037-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch rename to target/linux/rockchip/patches-5.15/008-0038-v6.0-phy-rockchip-inno-usb2-Ignore-OTG-IRQs-in-host-mode.patch diff --git a/target/linux/rockchip/patches-5.15/008-0038-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch b/target/linux/rockchip/patches-5.15/008-0039-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0038-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch rename to target/linux/rockchip/patches-5.15/008-0039-v6.0-media-hantro-Fix-RK3399-H.264-format-advertising.patch diff --git a/target/linux/rockchip/patches-5.15/008-0039-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch b/target/linux/rockchip/patches-5.15/008-0040-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0039-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch rename to target/linux/rockchip/patches-5.15/008-0040-v6.0-phy-rockchip-inno-usb2-Prevent-incorrect-error-on-probe.patch diff --git a/target/linux/rockchip/patches-5.15/008-0040-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch b/target/linux/rockchip/patches-5.15/008-0041-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch similarity index 100% rename from target/linux/rockchip/patches-5.15/008-0040-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch rename to target/linux/rockchip/patches-5.15/008-0041-v6.0-phy-rockchip-inno-usb2-Sync-initial-otg-state.patch