rk3399 support ddr frequency scaling
Subsystems (7)
v10 cover rk3399 support ddr frequency scaling
rk3399 platform have dfi controller can monitor ddr load, and dcf controller to handle ddr register so we can get the right ddr frequency and make ddr controller happy work(which will implement in bl31). So we do ddr frequency scaling with following flow:
kernel bl31
monitor ddr load
|
|
get_target_rate
|
| pass rate to bl31
clk_set_rate(ddr) --------------------->run dcf flow
| |
| |
wait dcf interrupt<-------------------trigger dcf interrupt
|
|
returnLin Huang (5):
Documentation: bindings: add dt documentation for dfi controller PM / devfreq: event: support rockchip dfi controller
Documentation: bindings: add dt documentation for rk3399 dmc PM / devfreq: rockchip: add devfreq driver for rk3399 dmc drm/rockchip: Add dmc notifier in vop driver
Following patch:
clk: rockchip: add new clock-type for the ddrclk
clk: rockchip: rk3399: add SCLK_DDRCLK ID for ddrc
clk: rockchip: rk3399: add ddrc clock support have applied to:
http://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git/v4.9-clk/next
.../bindings/devfreq/event/rockchip-dfi.txt | 19 + .../devicetree/bindings/devfreq/rk3399_dmc.txt | 210 +++++++++ drivers/devfreq/Kconfig | 11 + drivers/devfreq/Makefile | 1 + drivers/devfreq/event/Kconfig | 7 + drivers/devfreq/event/Makefile | 1 + drivers/devfreq/event/rockchip-dfi.c | 256 +++++++++++ drivers/devfreq/rk3399_dmc.c | 480 +++++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 +++++ 9 files changed, 1101 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt create mode 100644 Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt create mode 100644 drivers/devfreq/event/rockchip-dfi.c create mode 100644 drivers/devfreq/rk3399_dmc.c
Signature · 1 line
2.6.6
PATCH v10 1/5 Documentation: bindings: add dt documentation for dfi controller
This patch adds the documentation for rockchip dfi devfreq-event driver.
---
Changes in v10:
- None
Changes in v9:
- reorder compatible and reg
Changes in v8:
- delete a unuse blank line
Changes in v7:
- None
Changes in v6:
- None
Changes in v5:
- None
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None
Changes in v1:
- None
.../bindings/devfreq/event/rockchip-dfi.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt
Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt new file +19 -0
@@ -0,0 +1,19 @@ + +* Rockchip rk3399 DFI device + +Required properties: +- compatible: Must be "rockchip,rk3399-dfi". +- reg: physical base address of each DFI and length of memory mapped region +- rockchip,pmu: phandle to the syscon managing the "pmu general register files" +- clocks: phandles for clock specified in "clock-names" property +- clock-names : the name of clock used by the DFI, must be "pclk_ddr_mon"; + +Example: + dfi: dfi@0xff630000 { + compatible = "rockchip,rk3399-dfi"; + reg = <0x00 0xff630000 0x00 0x4000>; + rockchip,pmu = <&pmugrf>; + clocks = <&cru PCLK_DDR_MON>; + clock-names = "pclk_ddr_mon"; + status = "disabled"; + };
Signature · 1 line
2.6.6
Re: [PATCH v10 1/5] Documentation: bindings: add dt documentation for dfi controller
Quoted 47 lines · Lin Huang
This patch adds the documentation for rockchip dfi devfreq-event driver.
Signed-off-by Lin Huang <[email protected]>Acked-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- reorder compatible and regChanges in v8:
- delete a unuse blank lineChanges in v7:
- NoneChanges in v6:
- NoneChanges in v5:
- NoneChanges in v4:
- NoneChanges in v3:
- NoneChanges in v2:
- NoneChanges in v1:
- None.../bindings/devfreq/event/rockchip-dfi.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txtDocumentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt new file +2
-0@@ -0,0 +1,19 @@ + +* Rockchip rk3399 DFI device
Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt line 12
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt new file +10
-0+ +Required properties: +- compatible: Must be "rockchip,rk3399-dfi". +- reg: physical base address of each DFI and length of memory mapped region +- rockchip,pmu: phandle to the syscon managing the "pmu general register files" +- clocks: phandles for clock specified in "clock-names" property +- clock-names : the name of clock used by the DFI, must be "pclk_ddr_mon"; + +Example: + dfi: dfi at 0xff630000 {
Drop the '0x'. With that,
Quoted 14 lines
Documentation/devicetree/bindings/devfreq/event/rockchip-dfi.txt new file +7
-0+ compatible = "rockchip,rk3399-dfi"; + reg = <0x00 0xff630000 0x00 0x4000>; + rockchip,pmu = <&pmugrf>; + clocks = <&cru PCLK_DDR_MON>; + clock-names = "pclk_ddr_mon"; + status = "disabled"; + };Signature · 6 lines
2.6.6 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v10 2/5 PM / devfreq: event: support rockchip dfi controller
In reply to Lin Huangon rk3399 platform, there is dfi conroller can monitor ddr load, base on this result, we can do ddr freqency scaling.
---
Changes in v10:
-None
Changes in v9:
-None
Changes in v8:
-None
Changes in v7:
-access need to *4 to get right DDR loading
Changes in v6:
-None
Changes in v5:
-None
Changes in v4:
-None
Changes in v3:
-None
Changes in v2:
-None
Changes in v1:
-None
drivers/devfreq/event/Kconfig | 7 + drivers/devfreq/event/Makefile | 1 + drivers/devfreq/event/rockchip-dfi.c | 256 +++++++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 drivers/devfreq/event/rockchip-dfi.c
drivers/devfreq/event/Kconfig +7 -0
@@ -30,4 +30,11 @@ config DEVFREQ_EVENT_EXYNOS_PPMU (Platform Performance Monitoring Unit) counters to estimate the utilization of each module. +config DEVFREQ_EVENT_ROCKCHIP_DFI + tristate "ROCKCHIP DFI DEVFREQ event Driver" + depends on ARCH_ROCKCHIP + help + This add the devfreq-event driver for Rockchip SoC. It provides DFI + (DDR Monitor Module) driver to count ddr load. + endif # PM_DEVFREQ_EVENT
drivers/devfreq/event/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_NOCP) += exynos-nocp.o obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_PPMU) += exynos-ppmu.o +obj-$(CONFIG_DEVFREQ_EVENT_ROCKCHIP_DFI) += rockchip-dfi.o
drivers/devfreq/event/rockchip-dfi.c new file +256 -0
256 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v10 3/5 Documentation: bindings: add dt documentation for rk3399 dmc
In reply to Lin HuangThis patch adds the documentation for rockchip rk3399 dmc driver.
---
Changes in v10:
- add rockchip prefix in property describe
Changes in v9:
- add ddr timing property to node
Changes in v8:
- add ddr timing properties
Changes in v7:
- None
Changes in v6:
-Add more detail in Documentation
Changes in v5:
-None
Changes in v4:
-None
Changes in v3:
-None
Changes in v2:
-None
Changes in v1:
-None
.../devicetree/bindings/devfreq/rk3399_dmc.txt | 202 +++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +210 -0
@@ -0,0 +1,210 @@ +* Rockchip rk3399 DMC(Dynamic Memory Controller) device + +Required properties: +- compatible: Must be "rockchip,rk3399-dmc". +- devfreq-events: Node to get DDR loading, Refer to + Documentation/devicetree/bindings/devfreq/ + rockchip-dfi.txt +- interrupts: The interrupt number to the CPU. The interrupt + specifier format depends on the interrupt controller. + It should be DCF interrupts, when DDR dvfs finish, + it will happen. +- clocks: Phandles for clock specified in "clock-names" property +- clock-names : The name of clock used by the DFI, must be + "pclk_ddr_mon"; +- operating-points-v2: Refer to Documentation/devicetree/bindings/power/opp.txt + for details. +- center-supply: DMC supply node. +- status: Marks the node enabled/disabled. + +Following properties are ddr timing: + +- rockchip,dram_speed_bin : Value reference include/dt-bindings/clock/ddr.h, + it select ddr3 cl-trp-trcd type, default value + "DDR3_DEFAULT".it must selected according to + "Speed Bin" in ddr3 datasheet, DO NOT use + smaller "Speed Bin" than ddr3 exactly is. + +- rockchip,pd_idle : Config the PD_IDLE value, defined the power-down + idle period, memories are places into power-down + mode if bus is idle for PD_IDLE DFI clocks. + +- rockchip,sr_idle : Configure the SR_IDLE value, defined the + selfrefresh idle period, memories are places + into self-refresh mode if bus is idle for + SR_IDLE*1024 DFI clocks (DFI clocks freq is + half of dram's clocks), defaule value is "0". + +- rockchip,sr_mc_gate_idle : Defined the self-refresh with memory and + controller clock gating idle period, memories + are places into self-refresh mode and memory + controller clock arg gating if bus is idle for + sr_mc_gate_idle*1024 DFI clocks. + +- rockchip,srpd_lite_idle : Defined the self-refresh power down idle + period, memories are places into self-refresh + power down mode if bus is idle for + srpd_lite_idle*1024 DFI clocks. This parameter + is for LPDDR4 only. + +- rockchip,standby_idle : Defined the standby idle period, memories are + places into self-refresh than controller, pi, + phy and dram clock will gating if bus is idle + for standby_idle * DFI clocks. + +- rockchip,dram_dll_disb_freq : It's defined the DDR3 dll bypass frequency in + MHz, when ddr freq less than DRAM_DLL_DISB_FREQ, + ddr3 dll will bypssed note: if dll was bypassed, + the odt also stop working. + +- rockchip,phy_dll_disb_freq : Defined the PHY dll bypass frequency in + MHz (Mega Hz), when ddr freq less than + DRAM_DLL_DISB_FREQ, phy dll will bypssed. + note: phy dll and phy odt are independent. + +- rockchip,ddr3_odt_disb_freq : When dram type is DDR3, this parameter defined + the odt disable frequency in MHz (Mega Hz), + when ddr frequency less then ddr3_odt_disb_freq, + the odt on dram side and controller side are + both disabled. + +- rockchip,ddr3_drv : When dram type is DDR3, this parameter define + the dram side driver stength in ohm, default + value is DDR3_DS_40ohm. + +- rockchip,ddr3_odt : When dram type is DDR3, this parameter define + the dram side ODT stength in ohm, default value + is DDR3_ODT_120ohm. + +- rockchip,phy_ddr3_ca_drv : When dram type is DDR3, this parameter define + the phy side CA line(incluing command line, + address line and clock line) driver strength. + Default value is PHY_DRV_ODT_40. + +- rockchip,phy_ddr3_dq_drv : When dram type is DDR3, this parameter define + the phy side DQ line(incluing DQS/DQ/DM line) + driver strength. default value is PHY_DRV_ODT_40. + +- rockchip,phy_ddr3_odt : When dram type is DDR3, this parameter define the + phy side odt strength, default value is + PHY_DRV_ODT_240. + +- rockchip,lpddr3_odt_disb_freq : When dram type is LPDDR3, this parameter defined + then odt disable frequency in MHz (Mega Hz), + when ddr frequency less then ddr3_odt_disb_freq, + the odt on dram side and controller side are + both disabled. + +- rockchip,lpddr3_drv : When dram type is LPDDR3, this parameter define + the dram side driver stength in ohm, default + value is LP3_DS_34ohm. + +- rockchip,lpddr3_odt : When dram type is LPDDR3, this parameter define + the dram side ODT stength in ohm, default value + is LP3_ODT_240ohm. + +- rockchip,phy_lpddr3_ca_drv : When dram type is LPDDR3, this parameter define + the phy side CA line(incluing command line, + address line and clock line) driver strength. + default value is PHY_DRV_ODT_40. + +- rockchip,phy_lpddr3_dq_drv : When dram type is LPDDR3, this parameter define + the phy side DQ line(incluing DQS/DQ/DM line) + driver strength. default value is + PHY_DRV_ODT_40. + +- rockchip,phy_lpddr3_odt : When dram type is LPDDR3, this parameter define + the phy side odt strength, default value is + PHY_DRV_ODT_240. + +- rockchip,lpddr4_odt_disb_freq : When dram type is LPDDR4, this parameter + defined the odt disable frequency in + MHz (Mega Hz), when ddr frequency less then + ddr3_odt_disb_freq, the odt on dram side and + controller side are both disabled. + +- rockchip,lpddr4_drv : When dram type is LPDDR4, this parameter define + the dram side driver stength in ohm, default + value is LP4_PDDS_60ohm. + +- rockchip,lpddr4_dq_odt : When dram type is LPDDR4, this parameter define + the dram side ODT on dqs/dq line stength in ohm, + default value is LP4_DQ_ODT_40ohm. + +- rockchip,lpddr4_ca_odt : When dram type is LPDDR4, this parameter define + the dram side ODT on ca line stength in ohm, + default value is LP4_CA_ODT_40ohm. + +- rockchip,phy_lpddr4_ca_drv : When dram type is LPDDR4, this parameter define + the phy side CA line(incluing command address + line) driver strength. default value is + PHY_DRV_ODT_40. + +- rockchip,phy_lpddr4_ck_cs_drv : When dram type is LPDDR4, this parameter define + the phy side clock line and cs line driver + strength. default value is PHY_DRV_ODT_80. + +- rockchip,phy_lpddr4_dq_drv : When dram type is LPDDR4, this parameter define + the phy side DQ line(incluing DQS/DQ/DM line) + driver strength. default value is PHY_DRV_ODT_80. + +- rockchip,phy_lpddr4_odt : When dram type is LPDDR4, this parameter define + the phy side odt strength, default value is + PHY_DRV_ODT_60. + +Example: + dmc_opp_table: dmc_opp_table { + compatible = "operating-points-v2"; + + opp00 { + opp-hz = /bits/ 64 <300000000>; + opp-microvolt = <900000>; + }; + opp01 { + opp-hz = /bits/ 64 <666000000>; + opp-microvolt = <900000>; + }; + }; + + dmc: dmc { + compatible = "rockchip,rk3399-dmc"; + devfreq-events = <&dfi>; + interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru SCLK_DDRCLK>; + clock-names = "dmc_clk"; + operating-points-v2 = <&dmc_opp_table>; + center-supply = <&ppvar_centerlogic>; + upthreshold = <15>; + downdifferential = <10>; + rockchip,ddr3_speed_bin = <21>; + rockchip,pd_idle = <0x40>; + rockchip,sr_idle = <0x2>; + rockchip,sr_mc_gate_idle = <0x3>; + rockchip,srpd_lite_idle = <0x4>; + rockchip,standby_idle = <0x2000>; + rockchip,dram_dll_dis_freq = <300>; + rockchip,phy_dll_dis_freq = <125>; + rockchip,auto_pd_dis_freq = <666>; + rockchip,ddr3_odt_dis_freq = <333>; + rockchip,ddr3_drv = <DDR3_DS_40ohm>; + rockchip,ddr3_odt = <DDR3_ODT_120ohm>; + rockchip,phy_ddr3_ca_drv = <PHY_DRV_ODT_40>; + rockchip,phy_ddr3_dq_drv = <PHY_DRV_ODT_40>; + rockchip,phy_ddr3_odt = <PHY_DRV_ODT_240>; + rockchip,lpddr3_odt_dis_freq = <333>; + rockchip,lpddr3_drv = <LP3_DS_34ohm>; + rockchip,lpddr3_odt = <LP3_ODT_240ohm>; + rockchip,phy_lpddr3_ca_drv = <PHY_DRV_ODT_40>; + rockchip,phy_lpddr3_dq_drv = <PHY_DRV_ODT_40>; + rockchip,phy_lpddr3_odt = <PHY_DRV_ODT_240>; + rockchip,lpddr4_odt_dis_freq = <333>; + rockchip,lpddr4_drv = <LP4_PDDS_60ohm>; + rockchip,lpddr4_dq_odt = <LP4_DQ_ODT_40ohm>; + rockchip,lpddr4_ca_odt = <LP4_CA_ODT_40ohm>; + rockchip,phy_lpddr4_ca_drv = <PHY_DRV_ODT_40>; + rockchip,phy_lpddr4_ck_cs_drv = <PHY_DRV_ODT_80>; + rockchip,phy_lpddr4_dq_drv = <PHY_DRV_ODT_80>; + rockchip,phy_lpddr4_odt = <PHY_DRV_ODT_60>; + status = "disabled"; + }; +
Signature · 1 line
2.6.6
Rob Herring
maintainerRe: [PATCH v10 3/5] Documentation: bindings: add dt documentation for rk3399 dmc
Quoted 6 lines · Lin Huang
This patch adds the documentation for rockchip rk3399 dmc driver.
Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
And this is the first I see it?
Quoted 46 lines
- add rockchip prefix in property describe
Changes in v9:
- add ddr timing property to nodeChanges in v8:
- add ddr timing propertiesChanges in v7:
- NoneChanges in v6:
-Add more detail in DocumentationChanges in v5:
-NoneChanges in v4:
-NoneChanges in v3:
-NoneChanges in v2:
-NoneChanges in v1:
(quoted diff) +0
-1-None .../devicetree/bindings/devfreq/rk3399_dmc.txt | 202 +++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 Documentation/devicetree/bindings/devfreq/rk3399_dmc.txtDocumentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +8
-0@@ -0,0 +1,210 @@ +* Rockchip rk3399 DMC(Dynamic Memory Controller) device + +Required properties: +- compatible: Must be "rockchip,rk3399-dmc". +- devfreq-events: Node to get DDR loading, Refer to + Documentation/devicetree/bindings/devfreq/ + rockchip-dfi.txt +- interrupts: The interrupt number to the CPU. The interrupt
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 18
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +10
-0+ specifier format depends on the interrupt controller. + It should be DCF interrupts, when DDR dvfs finish, + it will happen. +- clocks: Phandles for clock specified in "clock-names" property +- clock-names : The name of clock used by the DFI, must be + "pclk_ddr_mon"; +- operating-points-v2: Refer to Documentation/devicetree/bindings/power/opp.txt + for details. +- center-supply: DMC supply node. +- status: Marks the node enabled/disabled.
No need to document this.
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 20
Quoted 2 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +2
-0+ +Following properties are ddr timing:
This is a lot of properties. I would prefer to see SPD data embedded into DT if there are overlap in what SPD data defines for settings.
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 22
Quoted 2 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +2
-0+ +- rockchip,dram_speed_bin : Value reference include/dt-bindings/clock/ddr.h,
Use '-', not '_' throughout.
Quoted 33 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +33
-0+ it select ddr3 cl-trp-trcd type, default value + "DDR3_DEFAULT".it must selected according to + "Speed Bin" in ddr3 datasheet, DO NOT use + smaller "Speed Bin" than ddr3 exactly is. + +- rockchip,pd_idle : Config the PD_IDLE value, defined the power-down + idle period, memories are places into power-down + mode if bus is idle for PD_IDLE DFI clocks. + +- rockchip,sr_idle : Configure the SR_IDLE value, defined the + selfrefresh idle period, memories are places + into self-refresh mode if bus is idle for + SR_IDLE*1024 DFI clocks (DFI clocks freq is + half of dram's clocks), defaule value is "0". + +- rockchip,sr_mc_gate_idle : Defined the self-refresh with memory and + controller clock gating idle period, memories + are places into self-refresh mode and memory + controller clock arg gating if bus is idle for + sr_mc_gate_idle*1024 DFI clocks. + +- rockchip,srpd_lite_idle : Defined the self-refresh power down idle + period, memories are places into self-refresh + power down mode if bus is idle for + srpd_lite_idle*1024 DFI clocks. This parameter + is for LPDDR4 only. + +- rockchip,standby_idle : Defined the standby idle period, memories are + places into self-refresh than controller, pi, + phy and dram clock will gating if bus is idle + for standby_idle * DFI clocks. + +- rockchip,dram_dll_disb_freq : It's defined the DDR3 dll bypass frequency in
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 65
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +10
-0+ MHz, when ddr freq less than DRAM_DLL_DISB_FREQ, + ddr3 dll will bypssed note: if dll was bypassed, + the odt also stop working. + +- rockchip,phy_dll_disb_freq : Defined the PHY dll bypass frequency in + MHz (Mega Hz), when ddr freq less than + DRAM_DLL_DISB_FREQ, phy dll will bypssed. + note: phy dll and phy odt are independent. + +- rockchip,ddr3_odt_disb_freq : When dram type is DDR3, this parameter defined
Please group properties that are required and optional, and also group by common, DDR3 only, DDR4L only, etc.
Quoted 11 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +11
-0+ the odt disable frequency in MHz (Mega Hz), + when ddr frequency less then ddr3_odt_disb_freq, + the odt on dram side and controller side are + both disabled. + +- rockchip,ddr3_drv : When dram type is DDR3, this parameter define + the dram side driver stength in ohm, default + value is DDR3_DS_40ohm. + +- rockchip,ddr3_odt : When dram type is DDR3, this parameter define + the dram side ODT stength in ohm, default value
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 86
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +10
-0+ is DDR3_ODT_120ohm. + +- rockchip,phy_ddr3_ca_drv : When dram type is DDR3, this parameter define + the phy side CA line(incluing command line, + address line and clock line) driver strength. + Default value is PHY_DRV_ODT_40. + +- rockchip,phy_ddr3_dq_drv : When dram type is DDR3, this parameter define + the phy side DQ line(incluing DQS/DQ/DM line) + driver strength. default value is PHY_DRV_ODT_40.
You have the same properties, but they just vary by DDR type. Make the property names common.
Quoted 8 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +8
-0+ +- rockchip,phy_ddr3_odt : When dram type is DDR3, this parameter define the + phy side odt strength, default value is + PHY_DRV_ODT_240. + +- rockchip,lpddr3_odt_disb_freq : When dram type is LPDDR3, this parameter defined + then odt disable frequency in MHz (Mega Hz), + when ddr frequency less then ddr3_odt_disb_freq,
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 104
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +10
-0+ the odt on dram side and controller side are + both disabled. + +- rockchip,lpddr3_drv : When dram type is LPDDR3, this parameter define + the dram side driver stength in ohm, default + value is LP3_DS_34ohm. + +- rockchip,lpddr3_odt : When dram type is LPDDR3, this parameter define + the dram side ODT stength in ohm, default value + is LP3_ODT_240ohm.
Is this in ohms or a register value? Please make it in ohms and add a -ohms suffix.
Quoted 43 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +43
-0+Example: + dmc_opp_table: dmc_opp_table { + compatible = "operating-points-v2"; + + opp00 { + opp-hz = /bits/ 64 <300000000>; + opp-microvolt = <900000>; + }; + opp01 { + opp-hz = /bits/ 64 <666000000>; + opp-microvolt = <900000>; + }; + }; + + dmc: dmc { + compatible = "rockchip,rk3399-dmc"; + devfreq-events = <&dfi>; + interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru SCLK_DDRCLK>; + clock-names = "dmc_clk"; + operating-points-v2 = <&dmc_opp_table>; + center-supply = <&ppvar_centerlogic>; + upthreshold = <15>; + downdifferential = <10>; + rockchip,ddr3_speed_bin = <21>; + rockchip,pd_idle = <0x40>; + rockchip,sr_idle = <0x2>; + rockchip,sr_mc_gate_idle = <0x3>; + rockchip,srpd_lite_idle = <0x4>; + rockchip,standby_idle = <0x2000>; + rockchip,dram_dll_dis_freq = <300>; + rockchip,phy_dll_dis_freq = <125>; + rockchip,auto_pd_dis_freq = <666>; + rockchip,ddr3_odt_dis_freq = <333>; + rockchip,ddr3_drv = <DDR3_DS_40ohm>; + rockchip,ddr3_odt = <DDR3_ODT_120ohm>; + rockchip,phy_ddr3_ca_drv = <PHY_DRV_ODT_40>; + rockchip,phy_ddr3_dq_drv = <PHY_DRV_ODT_40>; + rockchip,phy_ddr3_odt = <PHY_DRV_ODT_240>; + rockchip,lpddr3_odt_dis_freq = <333>; + rockchip,lpddr3_drv = <LP3_DS_34ohm>; + rockchip,lpddr3_odt = <LP3_ODT_240ohm>; + rockchip,phy_lpddr3_ca_drv = <PHY_DRV_ODT_40>;
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt line 207
Quoted 10 lines
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt new file +10
-0+ rockchip,phy_lpddr3_dq_drv = <PHY_DRV_ODT_40>; + rockchip,phy_lpddr3_odt = <PHY_DRV_ODT_240>; + rockchip,lpddr4_odt_dis_freq = <333>; + rockchip,lpddr4_drv = <LP4_PDDS_60ohm>; + rockchip,lpddr4_dq_odt = <LP4_DQ_ODT_40ohm>; + rockchip,lpddr4_ca_odt = <LP4_CA_ODT_40ohm>; + rockchip,phy_lpddr4_ca_drv = <PHY_DRV_ODT_40>; + rockchip,phy_lpddr4_ck_cs_drv = <PHY_DRV_ODT_80>; + rockchip,phy_lpddr4_dq_drv = <PHY_DRV_ODT_80>; + rockchip,phy_lpddr4_odt = <PHY_DRV_ODT_60>;
You have DDR3, LPDDR3 and LPDDR4 all populated at the same time? It should be one set at a time.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v10 4/5 PM / devfreq: rockchip: add devfreq driver for rk3399 dmc
In reply to Lin Huangbase on dfi result, we do ddr frequency scaling, register dmc driver to devfreq framework, and use simple-ondemand policy.
---
Changes in v10:
- None
Changes in v9:
- None
Changes in v8:
- None
Changes in v8:
- do not use ddr_timing node, get ddr timing directly
Changes in v7:
- remove a blank line
Changes in v6:
- fix some nit suggest by Chanwoo Choi
Changes in v5:
- improve dmc driver suggest by Chanwoo Choi
Changes in v4:
- use arm_smccc_smc() function talk to bl31
- delete rockchip_dmc.c file and config
- delete dmc_notify
- adjust probe order
Changes in v3:
- operate dram setting through sip call
- imporve set rate flow
Changes in v2:
- None
Changes in v1:
- move dfi controller to event
- fix set voltage sequence when set rate fail
- change Kconfig type from tristate to bool
- move unuse EXPORT_SYMBOL_GPL()
drivers/devfreq/Kconfig | 11 + drivers/devfreq/Makefile | 1 + drivers/devfreq/rk3399_dmc.c | 480 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 492 insertions(+) create mode 100644 drivers/devfreq/rk3399_dmc.c
drivers/devfreq/Kconfig +11 -0
@@ -100,6 +100,17 @@ config ARM_TEGRA_DEVFREQ It reads ACTMON counters of memory controllers and adjusts the operating frequencies and voltages with OPP support. +config ARM_RK3399_DMC_DEVFREQ + tristate "ARM RK3399 DMC DEVFREQ Driver" + depends on ARCH_ROCKCHIP + select DEVFREQ_EVENT_ROCKCHIP_DFI + select DEVFREQ_GOV_SIMPLE_ONDEMAND + select PM_OPP + help + This adds the DEVFREQ driver for the RK3399 DMC(Dynamic Memory Controller). + It sets the frequency for the memory controller and reads the usage counts + from hardware. + source "drivers/devfreq/event/Kconfig" endif # PM_DEVFREQ
drivers/devfreq/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_DEVFREQ_GOV_PASSIVE) += governor_passive.o # DEVFREQ Drivers obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ) += exynos-bus.o +obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o obj-$(CONFIG_ARM_TEGRA_DEVFREQ) += tegra-devfreq.o # DEVFREQ Event Drivers
drivers/devfreq/rk3399_dmc.c new file +480 -0
480 lines not on this page · raw message
Signature · 1 line
2.6.6
PATCH v10 5/5 drm/rockchip: Add dmc notifier in vop driver
In reply to Lin Huangwhen in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.
---
Changes in v10:
- None
Changes in v9:
- None
Changes in v8:
- None
Changes in v7:
- None
Changes in v6:
- fix a build error
Changes in v5:
- improve some nits
Changes in v4:
- register notifier to devfreq_register_notifier
- use DEVFREQ_PRECHANGE and DEVFREQ_POSTCHANGE to get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmc
Changes in v3:
- when do vop eanble/disable, dmc will wait until it finish
Changes in v2:
- None
Changes in v1:
- use wait_event instead usleep
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +116 -0
@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h>
@@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;
@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret; +/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); + + vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);
@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }return 0 ; err_disable_aclk:
@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later.
@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }
@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;
@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; }
Signature · 1 line
2.6.6
kbuild test robot
build botRe: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
url: https://github.com/0day-ci/linux/commits/Lin-Huang/rk3399-support-ddr-frequency-scaling/20160905-131110 config: arm-multi_v7_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc…
Hi Lin,
[auto build test ERROR on next-20160825]
[cannot apply to rockchip/for-next devfreq/for-rafael linus/master v4.8-rc5 v4.8-rc4 v4.8-rc3 v4.8-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Lin-Huang/rk3399-support-ddr-frequency-scaling/20160905-131110
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All errors (new ones prefixed by >>):
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1124:16: note: (near initialization for 'vop_crtc_helper_funcs.mode_fixup') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1125:18: error: initializer element is not constant
.atomic_flush = vop_crtc_atomic_flush,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1125:18: note: (near initialization for 'vop_crtc_helper_funcs.atomic_flush') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1126:18: error: initializer element is not constant
.atomic_begin = vop_crtc_atomic_begin,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1126:18: note: (near initialization for 'vop_crtc_helper_funcs.atomic_begin') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1129:13: error: invalid storage class for function 'vop_crtc_destroy'
static void vop_crtc_destroy(struct drm_crtc *crtc)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1134:13: error: invalid storage class for function 'vop_crtc_reset'
static void vop_crtc_reset(struct drm_crtc *crtc)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1145:31: error: invalid storage class for function 'vop_crtc_duplicate_state'
static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1157:13: error: invalid storage class for function 'vop_crtc_destroy_state'
static void vop_crtc_destroy_state(struct drm_crtc *crtc,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1169:13: error: initializer element is not constant
.destroy = vop_crtc_destroy,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1169:13: note: (near initialization for 'vop_crtc_funcs.destroy') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1170:11: error: initializer element is not constant
.reset = vop_crtc_reset,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1170:11: note: (near initialization for 'vop_crtc_funcs.reset') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1171:28: error: initializer element is not constant
.atomic_duplicate_state = vop_crtc_duplicate_state,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1171:28: note: (near initialization for 'vop_crtc_funcs.atomic_duplicate_state') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1172:26: error: initializer element is not constant
.atomic_destroy_state = vop_crtc_destroy_state,
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1172:26: note: (near initialization for 'vop_crtc_funcs.atomic_destroy_state') drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1175:13: error: invalid storage class for function 'vop_win_pending_is_complete'
static bool vop_win_pending_is_complete(struct vop_win *vop_win)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1187:13: error: invalid storage class for function 'vop_handle_vblank'
static void vop_handle_vblank(struct vop *vop)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1213:20: error: invalid storage class for function 'vop_isr'
static irqreturn_t vop_isr(int irq, void *data)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1259:12: error: invalid storage class for function 'vop_create_crtc'
static int vop_create_crtc(struct vop *vop)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1359:13: error: invalid storage class for function 'vop_destroy_crtc'
static void vop_destroy_crtc(struct vop *vop)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1387:12: error: invalid storage class for function 'vop_initial'
static int vop_initial(struct vop *vop)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1487:13: error: invalid storage class for function 'vop_win_init'
static void vop_win_init(struct vop *vop)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1501:12: error: invalid storage class for function 'vop_bind'
static int vop_bind(struct device *dev, struct device *master, void *data)
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1596:13: error: invalid storage class for function 'vop_unbind'
static void vop_unbind(struct device *dev, struct device *master, void *data)
^
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/linux/list.h:8,
from include/linux/agp_backend.h:33,
from include/drm/drmP.h:35,
from drivers/gpu/drm/rockchip/rockchip_drm_vop.c:16:
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:19: error: extern declaration of 'vop_component_ops' follows declaration with no linkage
EXPORT_SYMBOL_GPL(vop_component_ops);
^
include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1604:28: note: previous definition of 'vop_component_ops' was here
const struct component_ops vop_component_ops = {
^
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/linux/list.h:8,
from include/linux/agp_backend.h:33,
from include/drm/drmP.h:35,
from drivers/gpu/drm/rockchip/rockchip_drm_vop.c:16:
include/linux/export.h:63:25: warning: '__used__' attribute ignored [-Wattributes]
__visible const struct kernel_symbol __ksymtab_##sym \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
>> include/linux/export.h:63:39: error: section attribute cannot be specified for local variables
__visible const struct kernel_symbol __ksymtab_##sym \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
include/linux/export.h:63:25: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
__visible const struct kernel_symbol __ksymtab_##sym \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
include/linux/export.h:63:39: error: declaration of '__ksymtab_vop_component_ops' with no linkage follows extern declaration
__visible const struct kernel_symbol __ksymtab_##sym \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
include/linux/export.h:62:36: note: previous declaration of '__ksymtab_vop_component_ops' was here
extern const struct kernel_symbol __ksymtab_##sym; \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^
>> include/linux/export.h:63:25: error: expected declaration or statement at end of input
__visible const struct kernel_symbol __ksymtab_##sym \
^
include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
#define __EXPORT_SYMBOL ___EXPORT_SYMBOL
^
include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
__EXPORT_SYMBOL(sym, "_gpl")
^
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:1608:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(vop_component_ops);
^ drivers/gpu/drm/rockchip/rockchip_drm_vop.c: At top level:
drivers/gpu/drm/rockchip/rockchip_drm_vop.c:557:13: warning: 'vop_crtc_disable' defined but not used [-Wunused-function]
static void vop_crtc_disable(struct drm_crtc *crtc)
^
vim +63 include/linux/export.h
f5016932 Paul Gortmaker 2011-05-23 57 extern typeof(sym) sym; \
f5016932 Paul Gortmaker 2011-05-23 58 __CRC_SYMBOL(sym, sec) \
f5016932 Paul Gortmaker 2011-05-23 59 static const char __kstrtab_##sym[] \
f5016932 Paul Gortmaker 2011-05-23 60 __attribute__((section("__ksymtab_strings"), aligned(1))) \
b92021b0 Rusty Russell 2013-03-15 61 = VMLINUX_SYMBOL_STR(sym); \
7b4ec8dd Johannes Berg 2014-01-16 62 extern const struct kernel_symbol __ksymtab_##sym; \
e0f244c6 Andi Kleen 2013-10-23 @63 __visible const struct kernel_symbol __ksymtab_##sym \
f5016932 Paul Gortmaker 2011-05-23 64 __used \
f5016932 Paul Gortmaker 2011-05-23 65 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
f5016932 Paul Gortmaker 2011-05-23 66 = { (unsigned long)&sym, __kstrtab_##sym }
f5016932 Paul Gortmaker 2011-05-23 67
c1a95fda Nicolas Pitre 2016-01-22 68 #if defined(__KSYM_DEPS__)
c1a95fda Nicolas Pitre 2016-01-22 69
c1a95fda Nicolas Pitre 2016-01-22 70 /*
c1a95fda Nicolas Pitre 2016-01-22 71 * For fine grained build dependencies, we want to tell the build system
c1a95fda Nicolas Pitre 2016-01-22 72 * about each possible exported symbol even if they're not actually exported.
c1a95fda Nicolas Pitre 2016-01-22 73 * We use a string pattern that is unlikely to be valid code that the build
c1a95fda Nicolas Pitre 2016-01-22 74 * system filters out from the preprocessor output (see ksym_dep_filter
c1a95fda Nicolas Pitre 2016-01-22 75 * in scripts/Kbuild.include).
c1a95fda Nicolas Pitre 2016-01-22 76 */
c1a95fda Nicolas Pitre 2016-01-22 77 #define __EXPORT_SYMBOL(sym, sec) === __KSYM_##sym ===
c1a95fda Nicolas Pitre 2016-01-22 78
c1a95fda Nicolas Pitre 2016-01-22 79 #elif defined(CONFIG_TRIM_UNUSED_KSYMS)
f2355416 Nicolas Pitre 2016-01-22 80
f2355416 Nicolas Pitre 2016-01-22 81 #include <linux/kconfig.h>
f2355416 Nicolas Pitre 2016-01-22 82 #include <generated/autoksyms.h>
f2355416 Nicolas Pitre 2016-01-22 83
f2355416 Nicolas Pitre 2016-01-22 84 #define __EXPORT_SYMBOL(sym, sec) \
6023d236 Masahiro Yamada 2016-06-14 85 __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym))
f2355416 Nicolas Pitre 2016-01-22 86 #define __cond_export_sym(sym, sec, conf) \
f2355416 Nicolas Pitre 2016-01-22 87 ___cond_export_sym(sym, sec, conf)
f2355416 Nicolas Pitre 2016-01-22 88 #define ___cond_export_sym(sym, sec, enabled) \
f2355416 Nicolas Pitre 2016-01-22 89 __cond_export_sym_##enabled(sym, sec)
f2355416 Nicolas Pitre 2016-01-22 90 #define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec)
f2355416 Nicolas Pitre 2016-01-22 91 #define __cond_export_sym_0(sym, sec) /* nothing */
f2355416 Nicolas Pitre 2016-01-22 92
f2355416 Nicolas Pitre 2016-01-22 93 #else
f2355416 Nicolas Pitre 2016-01-22 @94 #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
f2355416 Nicolas Pitre 2016-01-22 95 #endif
f2355416 Nicolas Pitre 2016-01-22 96
f5016932 Paul Gortmaker 2011-05-23 97 #define EXPORT_SYMBOL(sym) \:::::: The code at line 63 was first introduced by commit
:::::: e0f244c63fc9d192dfd399cc2677bbdca61994b1 asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible
:::::: TO: Andi Kleen <[email protected]>
:::::: CC: Rusty Russell <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 38827 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160906/a4c3cb58/attachment-0001.obj>
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
In reply to Lin HuangQuoted 114 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +
This wait_event_timeout code is terribly racey (same goes above and below).
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)
I think you really want to check active, instead of enable.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }
This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 101 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +56
-1return 0 ; err_disable_aclk:@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; } --2.6.6
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Hi Sean,
Quoted 116 lines · Sean Paul
Quoted 115 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;
Quoted 11 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).
No i use the vop_switch_status and dmc_in_progress to handle the vop
and dmc racey,
I assume this can fix the racey now. I do not better a idea now.
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);
Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 123 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 101 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +56
-1return 0 ; err_disable_aclk:@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; } --2.6.6
Signature · 1 line
Lin Huang
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 141 lines · hl
Hi Sean,
Quoted 123 lines · Sean Paul
Quoted 121 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable
vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n"); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).
Quoted 2 lines
No i use the
vop_switch_statusanddmc_in_progressto handle the vop and
dmc racey,
So what happens if dmc_in_progress becomes 1 right here, or anywhere during vop_enable()?
Sean
Quoted 150 lines
I assume this can fix the racey now. I do not better a idea now.
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n",ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 125 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 11 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 103 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0return 0 ;
err_disable_aclk:drivers/gpu/drm/rockchip/rockchip_drm_vop.c +14
-0@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed
* buffer later.drivers/gpu/drm/rockchip/rockchip_drm_vop.c +42
-0@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ;}
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
--
2.6.6--
Lin Huang
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Hi
Quoted 138 lines · Sean Paul
Quoted 137 lines · hl
Hi Sean,
Quoted 133 lines · Sean Paul
Quoted 119 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable
vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n"); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct · line 480
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).
Quoted 5 lines
Quoted 2 lines
No i use the
vop_switch_statusanddmc_in_progressto handle the vop and
dmc racey,So what happens if
dmc_in_progressbecomes 1 right here, or anywhere duringvop_enable()?
In dmc_notify(), i will check the vop_switch_status, so in the vop_enable() and vop_crtc_disable(), the dmc_in_progress can not change value.
Quoted 160 lines
Sean
Quoted 153 lines
I assume this can fix the racey now. I do not better a idea now.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n",ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 123 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 103 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0return 0 ;
err_disable_aclk:drivers/gpu/drm/rockchip/rockchip_drm_vop.c +14
-0@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed
* buffer later.drivers/gpu/drm/rockchip/rockchip_drm_vop.c +42
-0@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ;}Quoted 4 lines
Quoted 3 lines
--
2.6.6--
Lin Huang
Signature · 8 lines
Lin Huang _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 154 lines · hl
Hi
Quoted 150 lines · Sean Paul
Quoted 146 lines · hl
Hi Sean,
Quoted 124 lines · Sean Paul
Quoted 122 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable
vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n"); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).No i use the
vop_switch_statusanddmc_in_progressto handle the vop
and
dmc racey,
Quoted 7 lines
Quoted 2 lines
So what happens if
dmc_in_progressbecomes 1 right here, or anywhere duringvop_enable()?In
dmc_notify(), i will check thevop_switch_status, so in thevop_enable()andvop_crtc_disable(),
thedmc_in_progresscan not change value.
THREAD 1 - wait_event_timeout (vop_switch_status) THREAD 2 - wait_event_timeout(wait_dmc_queue) THREAD 2 - vop_switch_status = 1
THREAD 1 - dmc_in_progress = 1
Sean
Quoted 167 lines
Quoted 166 lines
Sean
Quoted 159 lines
I assume this can fix the racey now. I do not better a idea now.
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; +ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n",ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 126 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 105 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0return 0 ;
err_disable_aclk:drivers/gpu/drm/rockchip/rockchip_drm_vop.c +14
-0@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we
* disable that crtc. Otherwise we might try to scan from a
destroyed
* buffer later.drivers/gpu/drm/rockchip/rockchip_drm_vop.c +18
-0@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); }}drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24
-0@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ;}Quoted 4 lines
Quoted 3 lines
--
2.6.6--
Lin Huang
Quoted 4 lines
--
Lin Huang
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 164 lines · Sean Paul
Quoted 154 lines · hl
Hi
Quoted 150 lines · Sean Paul
Quoted 146 lines · hl
Hi Sean,
Quoted 124 lines · Sean Paul
Quoted 122 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable
vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n"); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).No i use the
vop_switch_statusanddmc_in_progressto handle the vop
and
dmc racey,Quoted 7 lines
Quoted 2 lines
So what happens if
dmc_in_progressbecomes 1 right here, or anywhere duringvop_enable()?In
dmc_notify(), i will check thevop_switch_status, so in thevop_enable()andvop_crtc_disable(),
thedmc_in_progresscan not change value.
Quoted 7 lines
THREAD 1 -
wait_event_timeout(vop_switch_status) THREAD 2 -wait_event_timeout(wait_dmc_queue)THREAD 2 -vop_switch_status= 1
THREAD 1 -dmc_in_progress= 1Sean
I've thought about how to handle these timeout conditions, and it might be best to get rid of them. These would actually be error conditions, and we don't plan to hit them.
Also, if something goes wrong with DMC frequency transitions, we are likely out of luck and going to panic anyways.
Quoted 172 lines
Quoted 172 lines
Quoted 167 lines
Sean
Quoted 159 lines
I assume this can fix the racey now. I do not better a idea now.
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; +ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n",ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 126 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 105 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0return 0 ;
err_disable_aclk:drivers/gpu/drm/rockchip/rockchip_drm_vop.c +14
-0@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we
* disable that crtc. Otherwise we might try to scan from a
destroyed
* buffer later.drivers/gpu/drm/rockchip/rockchip_drm_vop.c +18
-0@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); }}drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24
-0@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ;}Quoted 4 lines
Quoted 3 lines
--
2.6.6--
Lin Huang--
Lin Huang
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 173 lines · dbasehore .
Quoted 164 lines · Sean Paul
Quoted 154 lines · hl
Hi
Quoted 150 lines · Sean Paul
Quoted 146 lines · hl
Hi Sean,
Quoted 124 lines · Sean Paul
Quoted 122 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable
vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop) spin_unlock_irqrestore(&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n"); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct · line 481
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).No i use the
vop_switch_statusanddmc_in_progressto handle the vop
and
dmc racey,Quoted 7 lines
Quoted 2 lines
So what happens if
dmc_in_progressbecomes 1 right here, or anywhere duringvop_enable()?In
dmc_notify(), i will check thevop_switch_status, so in thevop_enable()andvop_crtc_disable(),
thedmc_in_progresscan not change value.Quoted 7 lines
THREAD 1 -
wait_event_timeout(vop_switch_status) THREAD 2 -wait_event_timeout(wait_dmc_queue)THREAD 2 -vop_switch_status= 1
THREAD 1 -dmc_in_progress= 1Sean
Quoted 6 lines
I've thought about how to handle these timeout conditions, and it might be best to get rid of them. These would actually be error conditions, and we don't plan to hit them.
Also, if something goes wrong with DMC frequency transitions, we are likely out of luck and going to panic anyways.
Yeah, I'm not sure if the timeouts are recoverable (makes sense that they're not), but this code has several different variations of the race I described above.
I'm working on something a little more buttoned down to hopefully sync things up better.
Sean
Quoted 173 lines
Quoted 173 lines
Quoted 173 lines
Quoted 168 lines
Sean
Quoted 159 lines
I assume this can fix the racey now. I do not better a idea now.
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; +ret = pm_runtime_get_sync(vop->dev); if (ret < 0) { dev_err(vop->dev, "failed to get pm runtime: %d\n",ret);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc);Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0+ vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
Okay, i will check it, thanks.
Quoted 126 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 542
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
Quoted 105 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0
-0return 0 ;
err_disable_aclk:drivers/gpu/drm/rockchip/rockchip_drm_vop.c +14
-0@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we
* disable that crtc. Otherwise we might try to scan from a
destroyed
* buffer later.drivers/gpu/drm/rockchip/rockchip_drm_vop.c +18
-0@@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); }}drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24
-0@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ;}Quoted 4 lines
Quoted 3 lines
--
2.6.6--
Lin Huang--
Lin Huang
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
In reply to Sean PaulQuoted 163 lines · Sean Paul
Quoted 114 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Quoted 4 lines
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
DMC transitions can't happen when there is more than one display. You would have to synchronize with more than one vblank on the DCF (which actually changes the DDR frequency), and that's probably not going to happen.
If this code should be done somewhere else, it needs to still be able to check the number of displays and avoid race conditions with displays getting enabled or disabled. I don't know enough about DRM to know if that's possible outside of this code.
Quoted 99 lines
Quoted 99 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +56
-0return 0 ; err_disable_aclk:@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; }
Quoted 3 lines
Quoted 3 lines
--
2.6.6
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 174 lines · dbasehore .
Quoted 163 lines · Sean Paul
Quoted 114 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Quoted 4 lines
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
DMC transitions can't happen when there is more than one display. You would have to synchronize with more than one vblank on the DCF (which actually changes the DDR frequency), and that's probably not going to happen.
Quoted 5 lines
If this code should be done somewhere else, it needs to still be able to check the number of displays and avoid race conditions with displays getting enabled or disabled. I don't know enough about DRM to know if that's possible outside of this code.
Yeah, so I suppose that's another race, since we aren't necessarily guaranteed to be enabling/disabling the crtcs in the order this patch assumes.
I think we can probably handle this better by doing this up a level where we have a more global view of which vops are enabled/disabled and the order in which they will be processed.
I'm working on this now, stay tuned.
Sean
Quoted 102 lines
Quoted 102 lines
Quoted 102 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +56
-1return 0 ; err_disable_aclk:@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } + +/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq); } }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; } --2.6.6
Re: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 185 lines · Sean Paul
Quoted 174 lines · dbasehore .
Quoted 163 lines · Sean Paul
Quoted 114 lines · Lin Huang
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +34
-0@@ -19,6 +19,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -118,6 +120,13 @@ struct vop {const struct vop_data *data; +struct devfreq *devfreq; +struct devfreq_event_dev *devfreq_event_dev; +struct notifier_block dmc_nb; +int dmc_in_process; +int vop_switch_status; +wait_queue_head_t wait_dmc_queue; +wait_queue_head_t wait_vop_switch_queue;uint32_t *regsbak;void __iomem *regs;@@ -428,11 +437,47 @@ static void vop_dsp_hold_valid_irq_disable(struct vop *vop)spin_unlock_irqrestore (&vop->irq_lock, flags); } +static int dmc_notify (struct notifier_block *nb,unsigned long event, +void *data) +{ + struct vop *vop = container_of(nb, struct vop, dmc_nb); + +if (event ==DEVFREQ_PRECHANGE ) { +/* +* check if vop in enable or disable process, +* if yes, wait until it finishes, use 200ms as +* timeout. +*/ +if (!wait_event_timeout (vop->wait_vop_switch_queue, + !vop->vop_switch_status,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for vop swtich status\n" ); + vop->dmc_in_process =1 ; + }else if (event ==DEVFREQ_POSTCHANGE ) { + vop->dmc_in_process =0 ; +wake_up (&vop->wait_dmc_queue); + } + +return NOTIFY_OK ; +} +static int vop_enable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int ret;drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_dsp_hold_valid_irq_disable(struct vop *vop) · line 478
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+/* +* if in dmc scaling frequency process, wait until it finishes +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop enable\n" ); +This
wait_event_timeoutcode is terribly racey (same goes above and below).Quoted 6 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +2
-0+ vop->vop_switch_status =1 ; + ret =pm_runtime_get_sync (vop->dev);if (ret <0 ) {dev_err (vop->dev,"failed to get pm runtime: %d\n" , ret);drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 532
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +6
-0@@ -479,6 +524,21 @@ static int vop_enable(struct drm_crtc *crtc)drm_crtc_vblank_on (crtc); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable)I think you really want to check active, instead of enable.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_enable(struct drm_crtc *crtc) · line 541
Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-0+ num_enabled_crtc++; + } + +/* if enable two vop, need to disable dmc */ +if ((num_enabled_crtc >1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_disable_edev (vop->devfreq_event_dev); +devfreq_suspend_device (vop->devfreq); + }This really feels like something that should be handled somewhere else. I don't fully understand how this works, but it seems like this dependency should be handled where it actually matters, rather than building in a seemingly arbitrary restriction in the vop driver.
Quoted 4 lines
Even if this is the best place for it, this needs to be refactored to eliminate the races that exist now.
Sean
DMC transitions can't happen when there is more than one display. You would have to synchronize with more than one vblank on the DCF (which actually changes the DDR frequency), and that's probably not going to happen.
Quoted 5 lines
If this code should be done somewhere else, it needs to still be able to check the number of displays and avoid race conditions with displays getting enabled or disabled. I don't know enough about DRM to know if that's possible outside of this code.
Yeah, so I suppose that's another race, since we aren't necessarily guaranteed to be enabling/disabling the crtcs in the order this patch assumes.
Quoted 8 lines
I think we can probably handle this better by doing this up a level where we have a more global view of which vops are enabled/disabled and the order in which they will be processed.
I'm working on this now, stay tuned.
Sean
Can there be concurrent calls to vop enable/disable for different displays? If so, we could also hit a race between calculating num_enabled_crtc and calling devfreq_suspend_device. That section might have to be protected by a lock.
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24
-0return 0 ; err_disable_aclk:@@ -489,17 +549,31 @@ err_disable_hclk:clk_disable (vop->hclk); err_put_pm_runtime:pm_runtime_put_sync (vop->dev); + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue);return ret; }static void vop_crtc_disable (struct drm_crtc *crtc) {struct vop *vop =to_vop (crtc); +int num_enabled_crtc =0 ;int i;WARN_ON (vop->event);/* +* if in dmc scaling frequency process, wait until it finish +* use 200ms as timeout time. +*/ +if (!wait_event_timeout (vop->wait_dmc_queue, + !vop->dmc_in_process,HZ /5 )) +dev_warn (vop->dev, +"Timeout waiting for dmc when vop disable\n" ); + + vop->vop_switch_status =1 ; + +/* * We need to make sure that all windows are disabled before we * disable that crtc. Otherwise we might try to scan from a destroyed * buffer later. @@ -555,6 +629,24 @@ static void vop_crtc_disable(struct drm_crtc *crtc)spin_unlock_irq (&crtc->dev->event_lock); crtc->state->event =NULL ; + + vop->vop_switch_status =0 ; +wake_up (&vop->wait_vop_switch_queue); + +/* check how many VOPs in use now */ +drm_for_each_crtc (crtc, vop->drm_dev) { +if (crtc->state->enable) + num_enabled_crtc++; + } +
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_crtc_disable(struct drm_crtc *crtc) · line 649
Quoted 8 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +8
-0+/* +* if num_enabled_crtc = 1 now, it means 2 vop enabled +* change to 1 vop enabled need to enable dmc again. +*/ +if ((num_enabled_crtc ==1 ) && vop->devfreq) { +if (vop->devfreq_event_dev) +devfreq_event_enable_edev (vop->devfreq_event_dev); +devfreq_resume_device (vop->devfreq);
This is the section I'm referring to.
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24
-0} }@@ -1413,6 +1505,8 @@ static int vop_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm_dev = data;struct vop *vop;struct resource *res; +struct devfreq *devfreq; +struct devfreq_event_dev *event_dev;size_t alloc_size;int ret, irq;@@ -1474,6 +1568,28 @@ static int vop_bind(struct device *dev, struct device *master, void *data)return ret;pm_runtime_enable (&pdev->dev); + +init_waitqueue_head (&vop->wait_vop_switch_queue); + vop->vop_switch_status =0 ; +init_waitqueue_head (&vop->wait_dmc_queue); + vop->dmc_in_process =0 ; + + devfreq =devfreq_get_devfreq_by_phandle (dev,0 ); +if (IS_ERR (devfreq)) + goto out; + + vop->devfreq = devfreq; + vop->dmc_nb.notifier_call = dmc_notify; +devfreq_register_notifier (vop->devfreq, &vop->dmc_nb, +DEVFREQ_TRANSITION_NOTIFIER ); + + event_dev =devfreq_event_get_edev_by_phandle (vop->devfreq->dev.parent, +0 ); +if (IS_ERR (event_dev)) + goto out; + + vop->devfreq_event_dev = event_dev; +out:return 0 ; }
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
--
2.6.6
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CGME20160905050631epcas1p4ebe75a5f119132f583a5020187382026@epcas1p4.samsung.com
RE: [PATCH v10 5/5] drm/rockchip: Add dmc notifier in vop driver
Quoted 15 lines
when in ddr frequency scaling process, vop can not do enable or disable operation, since in dcf we check vop clock to see whether vop work. If vop work, dcf do ddr frequency scaling when vop
in vblank status, and we need to read vop register to check whether vop go into vblank status. If vop not work, dcf can do ddr frequency any time. So when do ddr frequency scaling, you disabled or enable vop, there may two bad thing happen: 1, the panel flicker(when vop from disable status change to enable). 2, kernel hang (when vop from enable status change to disable, dcf need to read vblank status, but if you disable vop clock, it can not get the status, it will lead soc dead) So we need register to devfreq notifier, and we can get the dmc status. Also, when there have two vop enabled, we need to disable dmc, since dcf only base on one vop vblank time, so the other panel will flicker when do ddr frequency scaling.
Quoted 2 lines
Signed-off-by Lin Huang <[email protected]>Reviewed-by Chanwoo Choi <[email protected]>
The code looks fine, but I've just found that I cannot merge this code as I am not handling drivers/gpu/drm.
Please try to merge this piece into drivers/gpu/drm tree.
For the other 4 piecies (1/5 to 4/5) I'm ok with them. I'm merging them now.
Quoted 37 lines
---
Changes in v10:
- NoneChanges in v9:
- NoneChanges in v8:
- NoneChanges in v7:
- NoneChanges in v6:
- fix a build errorChanges in v5:
- improve some nitsChanges in v4:
- register notifier todevfreq_register_notifier
- useDEVFREQ_PRECHANGEandDEVFREQ_POSTCHANGEto get dmc status
- when two vop enable, disable dmc
- when two vop back to one vop, enable dmcChanges in v3:
- when do vop eanble/disable, dmc will wait until it finishChanges in v2:
- NoneChanges in v1:
- usewait_eventinstead usleepdrivers/gpu/drm/rockchip/rockchip_drm_vop.c | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)