amd, mediatek, exynos and hdlcd fixes.

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJYN7+wAAoJEAx081l5xIa++uYQAKPoS2yg+EQytgBmAVJxQ0Vi
 Z8O+z6rPOubHvXHqdAswNbZaxYxiL1RGyn1nYYNpLMTNOF2md8KrYvxc7irikcnC
 qxTCtZCkWRsUjzprxea+koaq3m6wBT4ToK+jl+mxVsSo/vCtYVWu/zgPnW9Drqiy
 Z9XfrwESDwMYK/tVCorucBNmzHvleJ+AngpsAyE6KZHy2eOyDiunIDMnAyPi9S2C
 KdC6jaHTv3p7Z/xyEw7gGvyqPFrX50kmphLY8O3+KBJfosifMuXLJV/p41iX0aI8
 8P3lwQpb3h9Fv9urCXjXU+i8F3L7A6y4RuKCvZtKNGpas6jRrOGojkQJhD17EdvT
 N7D5ijIskCeoMFwaJ2kUMupY06rzt1CaNJAXpGbryR1bLUvyJysMWNDKHgPC5jUS
 MZIhqArUqht1DzFup25fx54CAAbb+4zOBiX9Jgq5zqqiq8i2XAWRoMT+fvJ6H5BL
 T819KKneKpS/uK61m8xPhopdOB1wU0rNvsOVYjXMxT4xTrbXODllO+Mm1eAuAPwh
 qfyCdhwspoDlaXwDFtkG9EyJpSeq6+A8DZS8DYz9wdcAhbHuy4kuMIYCeXCEfhsf
 xclxRVrzG3cWsu6QeEXdVjfVyN9fuhyzOJxkVzFVyfesiY0OHYoOY1AAouuO36q+
 X2avUsWc8qtG6ap/rgWJ
 =N8S/
 -----END PGP SIGNATURE-----

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.
This commit is contained in:
Linus Torvalds 2016-11-25 10:51:35 -08:00
commit 6006d6e719
8 changed files with 87 additions and 37 deletions

View file

@ -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)
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,
*/ */
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)
} }
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;
} }

View file

@ -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;

View file

@ -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);
} }

View file

@ -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)
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;

View file

@ -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)
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);

View file

@ -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);
} }

View file

@ -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 @@
#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)
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)
{ {
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) {
* data_rate = (pixel_clock / 1000) * pixel_dipth * mipi_ratio; case MIPI_DSI_FMT_RGB565:
* pixel_clock unit is Khz, data_rata unit is MHz, so need divide 1000. bit_per_pixel = 16;
* mipi_ratio is mipi clk coefficient for balance the pixel clk in mipi. break;
* we set mipi_ratio is 1.05. case MIPI_DSI_FMT_RGB666_PACKED:
*/ bit_per_pixel = 18;
dsi->data_rate = dsi->vm.pixelclock * 3 * 21 / (1 * 1000 * 10); break;
case MIPI_DSI_FMT_RGB666:
case MIPI_DSI_FMT_RGB888:
default:
bit_per_pixel = 24;
break;
}
ret = clk_set_rate(dsi->hs_clk, dsi->data_rate * 1000000); /**
* vm.pixelclock is in kHz, pixel_clock unit is Hz, so multiply by 1000
* htotal_time = htotal * byte_per_pixel / num_lanes
* overhead_time = lpx + hs_prepare + hs_zero + hs_trail + hs_exit
* mipi_ratio = (htotal_time + overhead_time) / htotal_time
* data_rate = pixel_clock * bit_per_pixel * mipi_ratio / num_lanes;
*/
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);
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;

View file

@ -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)
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,
*/ */
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)
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;
} }