Commit 6006d6e7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'drm-fixes-for-v4.9-rc7' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "Seems to be quietening down nicely, a few mediatek, one exynos and one
  hdlcd fix, along with two amd fixes"

* tag 'drm-fixes-for-v4.9-rc7' of git://people.freedesktop.org/~airlied/linux:
  gpu/drm/exynos/exynos_hdmi - Unmap region obtained by of_iomap
  drm/mediatek: fix null pointer dereference
  drm/mediatek: fixed the calc method of data rate per lane
  drm/mediatek: fix a typo of DISP_OD_CFG to OD_RELAYMODE
  drm/radeon: fix power state when port pm is unavailable (v2)
  drm/amdgpu: fix power state when port pm is unavailable
  drm/arm: hdlcd: fix plane base address update
  drm/amd/powerplay: avoid out of bounds access on array ps.
parents 16ae16c6 9704668e
...@@ -34,6 +34,7 @@ struct amdgpu_atpx { ...@@ -34,6 +34,7 @@ struct amdgpu_atpx {
static struct amdgpu_atpx_priv { static struct amdgpu_atpx_priv {
bool atpx_detected; bool atpx_detected;
bool bridge_pm_usable;
/* handle for device - and atpx */ /* handle for device - and atpx */
acpi_handle dhandle; acpi_handle dhandle;
acpi_handle other_handle; acpi_handle other_handle;
...@@ -205,7 +206,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx) ...@@ -205,7 +206,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
atpx->is_hybrid = false; atpx->is_hybrid = false;
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
printk("ATPX Hybrid Graphics\n"); printk("ATPX Hybrid Graphics\n");
atpx->functions.power_cntl = false; /*
* Disable legacy PM methods only when pcie port PM is usable,
* otherwise the device might fail to power off or power on.
*/
atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
atpx->is_hybrid = true; atpx->is_hybrid = true;
} }
...@@ -480,6 +485,7 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id, ...@@ -480,6 +485,7 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id,
*/ */
static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev) static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
{ {
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
acpi_handle dhandle, atpx_handle; acpi_handle dhandle, atpx_handle;
acpi_status status; acpi_status status;
...@@ -494,6 +500,7 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev) ...@@ -494,6 +500,7 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
} }
amdgpu_atpx_priv.dhandle = dhandle; amdgpu_atpx_priv.dhandle = dhandle;
amdgpu_atpx_priv.atpx.handle = atpx_handle; amdgpu_atpx_priv.atpx.handle = atpx_handle;
amdgpu_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
return true; return true;
} }
......
...@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr, ...@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk) if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
data->highest_mclk = memory_clock; data->highest_mclk = memory_clock;
performance_level = &(ps->performance_levels
[ps->performance_level_count++]);
PP_ASSERT_WITH_CODE( PP_ASSERT_WITH_CODE(
(ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)), (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
"Performance levels exceeds SMC limit!", "Performance levels exceeds SMC limit!",
return -EINVAL); return -EINVAL);
PP_ASSERT_WITH_CODE( PP_ASSERT_WITH_CODE(
(ps->performance_level_count <= (ps->performance_level_count <
hwmgr->platform_descriptor.hardwareActivityPerformanceLevels), hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
"Performance levels exceeds Driver limit!", "Performance levels exceeds Driver limit, Skip!",
return -EINVAL); return 0);
performance_level = &(ps->performance_levels
[ps->performance_level_count++]);
/* Performance levels are arranged from low to high. */ /* Performance levels are arranged from low to high. */
performance_level->memory_clock = memory_clock; performance_level->memory_clock = memory_clock;
......
...@@ -150,15 +150,14 @@ static void hdlcd_crtc_enable(struct drm_crtc *crtc) ...@@ -150,15 +150,14 @@ static void hdlcd_crtc_enable(struct drm_crtc *crtc)
clk_prepare_enable(hdlcd->clk); clk_prepare_enable(hdlcd->clk);
hdlcd_crtc_mode_set_nofb(crtc); hdlcd_crtc_mode_set_nofb(crtc);
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1); hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1);
drm_crtc_vblank_on(crtc);
} }
static void hdlcd_crtc_disable(struct drm_crtc *crtc) static void hdlcd_crtc_disable(struct drm_crtc *crtc)
{ {
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
if (!crtc->state->active) drm_crtc_vblank_off(crtc);
return;
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0); hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0);
clk_disable_unprepare(hdlcd->clk); clk_disable_unprepare(hdlcd->clk);
} }
......
...@@ -1907,6 +1907,8 @@ static int hdmi_probe(struct platform_device *pdev) ...@@ -1907,6 +1907,8 @@ static int hdmi_probe(struct platform_device *pdev)
err_hdmiphy: err_hdmiphy:
if (hdata->hdmiphy_port) if (hdata->hdmiphy_port)
put_device(&hdata->hdmiphy_port->dev); put_device(&hdata->hdmiphy_port->dev);
if (hdata->regs_hdmiphy)
iounmap(hdata->regs_hdmiphy);
err_ddc: err_ddc:
put_device(&hdata->ddc_adpt->dev); put_device(&hdata->ddc_adpt->dev);
...@@ -1929,6 +1931,9 @@ static int hdmi_remove(struct platform_device *pdev) ...@@ -1929,6 +1931,9 @@ static int hdmi_remove(struct platform_device *pdev)
if (hdata->hdmiphy_port) if (hdata->hdmiphy_port)
put_device(&hdata->hdmiphy_port->dev); put_device(&hdata->hdmiphy_port->dev);
if (hdata->regs_hdmiphy)
iounmap(hdata->regs_hdmiphy);
put_device(&hdata->ddc_adpt->dev); put_device(&hdata->ddc_adpt->dev);
return 0; return 0;
......
...@@ -251,13 +251,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) ...@@ -251,13 +251,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
IRQF_TRIGGER_NONE, dev_name(dev), priv);
if (ret < 0) {
dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
return ret;
}
comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL); comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL);
if (comp_id < 0) { if (comp_id < 0) {
dev_err(dev, "Failed to identify by alias: %d\n", comp_id); dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
...@@ -273,6 +266,13 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) ...@@ -273,6 +266,13 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
IRQF_TRIGGER_NONE, dev_name(dev), priv);
if (ret < 0) {
dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
return ret;
}
ret = component_add(dev, &mtk_disp_ovl_component_ops); ret = component_add(dev, &mtk_disp_ovl_component_ops);
if (ret) if (ret)
dev_err(dev, "Failed to add component: %d\n", ret); dev_err(dev, "Failed to add component: %d\n", ret);
......
...@@ -123,7 +123,7 @@ static void mtk_od_config(struct mtk_ddp_comp *comp, unsigned int w, ...@@ -123,7 +123,7 @@ static void mtk_od_config(struct mtk_ddp_comp *comp, unsigned int w,
unsigned int bpc) unsigned int bpc)
{ {
writel(w << 16 | h, comp->regs + DISP_OD_SIZE); writel(w << 16 | h, comp->regs + DISP_OD_SIZE);
writel(OD_RELAYMODE, comp->regs + OD_RELAYMODE); writel(OD_RELAYMODE, comp->regs + DISP_OD_CFG);
mtk_dither_set(comp, bpc, DISP_OD_CFG); mtk_dither_set(comp, bpc, DISP_OD_CFG);
} }
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
#define DSI_PHY_TIMECON0 0x110 #define DSI_PHY_TIMECON0 0x110
#define LPX (0xff << 0) #define LPX (0xff << 0)
#define HS_PRPR (0xff << 8) #define HS_PREP (0xff << 8)
#define HS_ZERO (0xff << 16) #define HS_ZERO (0xff << 16)
#define HS_TRAIL (0xff << 24) #define HS_TRAIL (0xff << 24)
...@@ -102,10 +102,16 @@ ...@@ -102,10 +102,16 @@
#define CLK_TRAIL (0xff << 24) #define CLK_TRAIL (0xff << 24)
#define DSI_PHY_TIMECON3 0x11c #define DSI_PHY_TIMECON3 0x11c
#define CLK_HS_PRPR (0xff << 0) #define CLK_HS_PREP (0xff << 0)
#define CLK_HS_POST (0xff << 8) #define CLK_HS_POST (0xff << 8)
#define CLK_HS_EXIT (0xff << 16) #define CLK_HS_EXIT (0xff << 16)
#define T_LPX 5
#define T_HS_PREP 6
#define T_HS_TRAIL 8
#define T_HS_EXIT 7
#define T_HS_ZERO 10
#define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0)) #define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0))
struct phy; struct phy;
...@@ -161,20 +167,18 @@ static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data) ...@@ -161,20 +167,18 @@ static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data)
static void dsi_phy_timconfig(struct mtk_dsi *dsi) static void dsi_phy_timconfig(struct mtk_dsi *dsi)
{ {
u32 timcon0, timcon1, timcon2, timcon3; u32 timcon0, timcon1, timcon2, timcon3;
unsigned int ui, cycle_time; u32 ui, cycle_time;
unsigned int lpx;
ui = 1000 / dsi->data_rate + 0x01; ui = 1000 / dsi->data_rate + 0x01;
cycle_time = 8000 / dsi->data_rate + 0x01; cycle_time = 8000 / dsi->data_rate + 0x01;
lpx = 5;
timcon0 = (8 << 24) | (0xa << 16) | (0x6 << 8) | lpx; timcon0 = T_LPX | T_HS_PREP << 8 | T_HS_ZERO << 16 | T_HS_TRAIL << 24;
timcon1 = (7 << 24) | (5 * lpx << 16) | ((3 * lpx) / 2) << 8 | timcon1 = 4 * T_LPX | (3 * T_LPX / 2) << 8 | 5 * T_LPX << 16 |
(4 * lpx); T_HS_EXIT << 24;
timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) | timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) |
(NS_TO_CYCLE(0x150, cycle_time) << 16); (NS_TO_CYCLE(0x150, cycle_time) << 16);
timcon3 = (2 * lpx) << 16 | NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8 | timcon3 = NS_TO_CYCLE(0x40, cycle_time) | (2 * T_LPX) << 16 |
NS_TO_CYCLE(0x40, cycle_time); NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8;
writel(timcon0, dsi->regs + DSI_PHY_TIMECON0); writel(timcon0, dsi->regs + DSI_PHY_TIMECON0);
writel(timcon1, dsi->regs + DSI_PHY_TIMECON1); writel(timcon1, dsi->regs + DSI_PHY_TIMECON1);
...@@ -202,19 +206,47 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi) ...@@ -202,19 +206,47 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
{ {
struct device *dev = dsi->dev; struct device *dev = dsi->dev;
int ret; int ret;
u64 pixel_clock, total_bits;
u32 htotal, htotal_bits, bit_per_pixel, overhead_cycles, overhead_bits;
if (++dsi->refcount != 1) if (++dsi->refcount != 1)
return 0; return 0;
switch (dsi->format) {
case MIPI_DSI_FMT_RGB565:
bit_per_pixel = 16;
break;
case MIPI_DSI_FMT_RGB666_PACKED:
bit_per_pixel = 18;
break;
case MIPI_DSI_FMT_RGB666:
case MIPI_DSI_FMT_RGB888:
default:
bit_per_pixel = 24;
break;
}
/** /**
* data_rate = (pixel_clock / 1000) * pixel_dipth * mipi_ratio; * vm.pixelclock is in kHz, pixel_clock unit is Hz, so multiply by 1000
* pixel_clock unit is Khz, data_rata unit is MHz, so need divide 1000. * htotal_time = htotal * byte_per_pixel / num_lanes
* mipi_ratio is mipi clk coefficient for balance the pixel clk in mipi. * overhead_time = lpx + hs_prepare + hs_zero + hs_trail + hs_exit
* we set mipi_ratio is 1.05. * mipi_ratio = (htotal_time + overhead_time) / htotal_time
* data_rate = pixel_clock * bit_per_pixel * mipi_ratio / num_lanes;
*/ */
dsi->data_rate = dsi->vm.pixelclock * 3 * 21 / (1 * 1000 * 10); pixel_clock = dsi->vm.pixelclock * 1000;
htotal = dsi->vm.hactive + dsi->vm.hback_porch + dsi->vm.hfront_porch +
dsi->vm.hsync_len;
htotal_bits = htotal * bit_per_pixel;
overhead_cycles = T_LPX + T_HS_PREP + T_HS_ZERO + T_HS_TRAIL +
T_HS_EXIT;
overhead_bits = overhead_cycles * dsi->lanes * 8;
total_bits = htotal_bits + overhead_bits;
dsi->data_rate = DIV_ROUND_UP_ULL(pixel_clock * total_bits,
htotal * dsi->lanes);
ret = clk_set_rate(dsi->hs_clk, dsi->data_rate * 1000000); ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to set data rate: %d\n", ret); dev_err(dev, "Failed to set data rate: %d\n", ret);
goto err_refcount; goto err_refcount;
......
...@@ -34,6 +34,7 @@ struct radeon_atpx { ...@@ -34,6 +34,7 @@ struct radeon_atpx {
static struct radeon_atpx_priv { static struct radeon_atpx_priv {
bool atpx_detected; bool atpx_detected;
bool bridge_pm_usable;
/* handle for device - and atpx */ /* handle for device - and atpx */
acpi_handle dhandle; acpi_handle dhandle;
struct radeon_atpx atpx; struct radeon_atpx atpx;
...@@ -203,7 +204,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx) ...@@ -203,7 +204,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
atpx->is_hybrid = false; atpx->is_hybrid = false;
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
printk("ATPX Hybrid Graphics\n"); printk("ATPX Hybrid Graphics\n");
atpx->functions.power_cntl = false; /*
* Disable legacy PM methods only when pcie port PM is usable,
* otherwise the device might fail to power off or power on.
*/
atpx->functions.power_cntl = !radeon_atpx_priv.bridge_pm_usable;
atpx->is_hybrid = true; atpx->is_hybrid = true;
} }
...@@ -474,6 +479,7 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id, ...@@ -474,6 +479,7 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id,
*/ */
static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
{ {
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
acpi_handle dhandle, atpx_handle; acpi_handle dhandle, atpx_handle;
acpi_status status; acpi_status status;
...@@ -487,6 +493,7 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) ...@@ -487,6 +493,7 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
radeon_atpx_priv.dhandle = dhandle; radeon_atpx_priv.dhandle = dhandle;
radeon_atpx_priv.atpx.handle = atpx_handle; radeon_atpx_priv.atpx.handle = atpx_handle;
radeon_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment