Skip to content

Commit 6006d6e

Browse files
committed
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.
2 parents 16ae16c + 9704668 commit 6006d6e

File tree

8 files changed

+85
-35
lines changed

8 files changed

+85
-35
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct amdgpu_atpx {
3434

3535
static struct amdgpu_atpx_priv {
3636
bool atpx_detected;
37+
bool bridge_pm_usable;
3738
/* handle for device - and atpx */
3839
acpi_handle dhandle;
3940
acpi_handle other_handle;
@@ -205,7 +206,11 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
205206
atpx->is_hybrid = false;
206207
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
207208
printk("ATPX Hybrid Graphics\n");
208-
atpx->functions.power_cntl = false;
209+
/*
210+
* Disable legacy PM methods only when pcie port PM is usable,
211+
* otherwise the device might fail to power off or power on.
212+
*/
213+
atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable;
209214
atpx->is_hybrid = true;
210215
}
211216

@@ -480,6 +485,7 @@ static int amdgpu_atpx_power_state(enum vga_switcheroo_client_id id,
480485
*/
481486
static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
482487
{
488+
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
483489
acpi_handle dhandle, atpx_handle;
484490
acpi_status status;
485491

@@ -494,6 +500,7 @@ static bool amdgpu_atpx_pci_probe_handle(struct pci_dev *pdev)
494500
}
495501
amdgpu_atpx_priv.dhandle = dhandle;
496502
amdgpu_atpx_priv.atpx.handle = atpx_handle;
503+
amdgpu_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
497504
return true;
498505
}
499506

drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,19 +2984,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
29842984
if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
29852985
data->highest_mclk = memory_clock;
29862986

2987-
performance_level = &(ps->performance_levels
2988-
[ps->performance_level_count++]);
2989-
29902987
PP_ASSERT_WITH_CODE(
29912988
(ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
29922989
"Performance levels exceeds SMC limit!",
29932990
return -EINVAL);
29942991

29952992
PP_ASSERT_WITH_CODE(
2996-
(ps->performance_level_count <=
2993+
(ps->performance_level_count <
29972994
hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
2998-
"Performance levels exceeds Driver limit!",
2999-
return -EINVAL);
2995+
"Performance levels exceeds Driver limit, Skip!",
2996+
return 0);
2997+
2998+
performance_level = &(ps->performance_levels
2999+
[ps->performance_level_count++]);
30003000

30013001
/* Performance levels are arranged from low to high. */
30023002
performance_level->memory_clock = memory_clock;

drivers/gpu/drm/arm/hdlcd_crtc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,14 @@ static void hdlcd_crtc_enable(struct drm_crtc *crtc)
150150
clk_prepare_enable(hdlcd->clk);
151151
hdlcd_crtc_mode_set_nofb(crtc);
152152
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 1);
153+
drm_crtc_vblank_on(crtc);
153154
}
154155

155156
static void hdlcd_crtc_disable(struct drm_crtc *crtc)
156157
{
157158
struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
158159

159-
if (!crtc->state->active)
160-
return;
161-
160+
drm_crtc_vblank_off(crtc);
162161
hdlcd_write(hdlcd, HDLCD_REG_COMMAND, 0);
163162
clk_disable_unprepare(hdlcd->clk);
164163
}

drivers/gpu/drm/exynos/exynos_hdmi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,8 @@ static int hdmi_probe(struct platform_device *pdev)
19071907
err_hdmiphy:
19081908
if (hdata->hdmiphy_port)
19091909
put_device(&hdata->hdmiphy_port->dev);
1910+
if (hdata->regs_hdmiphy)
1911+
iounmap(hdata->regs_hdmiphy);
19101912
err_ddc:
19111913
put_device(&hdata->ddc_adpt->dev);
19121914

@@ -1929,6 +1931,9 @@ static int hdmi_remove(struct platform_device *pdev)
19291931
if (hdata->hdmiphy_port)
19301932
put_device(&hdata->hdmiphy_port->dev);
19311933

1934+
if (hdata->regs_hdmiphy)
1935+
iounmap(hdata->regs_hdmiphy);
1936+
19321937
put_device(&hdata->ddc_adpt->dev);
19331938

19341939
return 0;

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
251251
if (irq < 0)
252252
return irq;
253253

254-
ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
255-
IRQF_TRIGGER_NONE, dev_name(dev), priv);
256-
if (ret < 0) {
257-
dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
258-
return ret;
259-
}
260-
261254
comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL);
262255
if (comp_id < 0) {
263256
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)
273266

274267
platform_set_drvdata(pdev, priv);
275268

269+
ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
270+
IRQF_TRIGGER_NONE, dev_name(dev), priv);
271+
if (ret < 0) {
272+
dev_err(dev, "Failed to request irq %d: %d\n", irq, ret);
273+
return ret;
274+
}
275+
276276
ret = component_add(dev, &mtk_disp_ovl_component_ops);
277277
if (ret)
278278
dev_err(dev, "Failed to add component: %d\n", ret);

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void mtk_od_config(struct mtk_ddp_comp *comp, unsigned int w,
123123
unsigned int bpc)
124124
{
125125
writel(w << 16 | h, comp->regs + DISP_OD_SIZE);
126-
writel(OD_RELAYMODE, comp->regs + OD_RELAYMODE);
126+
writel(OD_RELAYMODE, comp->regs + DISP_OD_CFG);
127127
mtk_dither_set(comp, bpc, DISP_OD_CFG);
128128
}
129129

drivers/gpu/drm/mediatek/mtk_dsi.c

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
#define DSI_PHY_TIMECON0 0x110
8888
#define LPX (0xff << 0)
89-
#define HS_PRPR (0xff << 8)
89+
#define HS_PREP (0xff << 8)
9090
#define HS_ZERO (0xff << 16)
9191
#define HS_TRAIL (0xff << 24)
9292

@@ -102,10 +102,16 @@
102102
#define CLK_TRAIL (0xff << 24)
103103

104104
#define DSI_PHY_TIMECON3 0x11c
105-
#define CLK_HS_PRPR (0xff << 0)
105+
#define CLK_HS_PREP (0xff << 0)
106106
#define CLK_HS_POST (0xff << 8)
107107
#define CLK_HS_EXIT (0xff << 16)
108108

109+
#define T_LPX 5
110+
#define T_HS_PREP 6
111+
#define T_HS_TRAIL 8
112+
#define T_HS_EXIT 7
113+
#define T_HS_ZERO 10
114+
109115
#define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0))
110116

111117
struct phy;
@@ -161,20 +167,18 @@ static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data)
161167
static void dsi_phy_timconfig(struct mtk_dsi *dsi)
162168
{
163169
u32 timcon0, timcon1, timcon2, timcon3;
164-
unsigned int ui, cycle_time;
165-
unsigned int lpx;
170+
u32 ui, cycle_time;
166171

167172
ui = 1000 / dsi->data_rate + 0x01;
168173
cycle_time = 8000 / dsi->data_rate + 0x01;
169-
lpx = 5;
170174

171-
timcon0 = (8 << 24) | (0xa << 16) | (0x6 << 8) | lpx;
172-
timcon1 = (7 << 24) | (5 * lpx << 16) | ((3 * lpx) / 2) << 8 |
173-
(4 * lpx);
175+
timcon0 = T_LPX | T_HS_PREP << 8 | T_HS_ZERO << 16 | T_HS_TRAIL << 24;
176+
timcon1 = 4 * T_LPX | (3 * T_LPX / 2) << 8 | 5 * T_LPX << 16 |
177+
T_HS_EXIT << 24;
174178
timcon2 = ((NS_TO_CYCLE(0x64, cycle_time) + 0xa) << 24) |
175179
(NS_TO_CYCLE(0x150, cycle_time) << 16);
176-
timcon3 = (2 * lpx) << 16 | NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8 |
177-
NS_TO_CYCLE(0x40, cycle_time);
180+
timcon3 = NS_TO_CYCLE(0x40, cycle_time) | (2 * T_LPX) << 16 |
181+
NS_TO_CYCLE(80 + 52 * ui, cycle_time) << 8;
178182

179183
writel(timcon0, dsi->regs + DSI_PHY_TIMECON0);
180184
writel(timcon1, dsi->regs + DSI_PHY_TIMECON1);
@@ -202,19 +206,47 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
202206
{
203207
struct device *dev = dsi->dev;
204208
int ret;
209+
u64 pixel_clock, total_bits;
210+
u32 htotal, htotal_bits, bit_per_pixel, overhead_cycles, overhead_bits;
205211

206212
if (++dsi->refcount != 1)
207213
return 0;
208214

215+
switch (dsi->format) {
216+
case MIPI_DSI_FMT_RGB565:
217+
bit_per_pixel = 16;
218+
break;
219+
case MIPI_DSI_FMT_RGB666_PACKED:
220+
bit_per_pixel = 18;
221+
break;
222+
case MIPI_DSI_FMT_RGB666:
223+
case MIPI_DSI_FMT_RGB888:
224+
default:
225+
bit_per_pixel = 24;
226+
break;
227+
}
228+
209229
/**
210-
* data_rate = (pixel_clock / 1000) * pixel_dipth * mipi_ratio;
211-
* pixel_clock unit is Khz, data_rata unit is MHz, so need divide 1000.
212-
* mipi_ratio is mipi clk coefficient for balance the pixel clk in mipi.
213-
* we set mipi_ratio is 1.05.
230+
* vm.pixelclock is in kHz, pixel_clock unit is Hz, so multiply by 1000
231+
* htotal_time = htotal * byte_per_pixel / num_lanes
232+
* overhead_time = lpx + hs_prepare + hs_zero + hs_trail + hs_exit
233+
* mipi_ratio = (htotal_time + overhead_time) / htotal_time
234+
* data_rate = pixel_clock * bit_per_pixel * mipi_ratio / num_lanes;
214235
*/
215-
dsi->data_rate = dsi->vm.pixelclock * 3 * 21 / (1 * 1000 * 10);
236+
pixel_clock = dsi->vm.pixelclock * 1000;
237+
htotal = dsi->vm.hactive + dsi->vm.hback_porch + dsi->vm.hfront_porch +
238+
dsi->vm.hsync_len;
239+
htotal_bits = htotal * bit_per_pixel;
240+
241+
overhead_cycles = T_LPX + T_HS_PREP + T_HS_ZERO + T_HS_TRAIL +
242+
T_HS_EXIT;
243+
overhead_bits = overhead_cycles * dsi->lanes * 8;
244+
total_bits = htotal_bits + overhead_bits;
245+
246+
dsi->data_rate = DIV_ROUND_UP_ULL(pixel_clock * total_bits,
247+
htotal * dsi->lanes);
216248

217-
ret = clk_set_rate(dsi->hs_clk, dsi->data_rate * 1000000);
249+
ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
218250
if (ret < 0) {
219251
dev_err(dev, "Failed to set data rate: %d\n", ret);
220252
goto err_refcount;

drivers/gpu/drm/radeon/radeon_atpx_handler.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct radeon_atpx {
3434

3535
static struct radeon_atpx_priv {
3636
bool atpx_detected;
37+
bool bridge_pm_usable;
3738
/* handle for device - and atpx */
3839
acpi_handle dhandle;
3940
struct radeon_atpx atpx;
@@ -203,7 +204,11 @@ static int radeon_atpx_validate(struct radeon_atpx *atpx)
203204
atpx->is_hybrid = false;
204205
if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) {
205206
printk("ATPX Hybrid Graphics\n");
206-
atpx->functions.power_cntl = false;
207+
/*
208+
* Disable legacy PM methods only when pcie port PM is usable,
209+
* otherwise the device might fail to power off or power on.
210+
*/
211+
atpx->functions.power_cntl = !radeon_atpx_priv.bridge_pm_usable;
207212
atpx->is_hybrid = true;
208213
}
209214

@@ -474,6 +479,7 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id,
474479
*/
475480
static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
476481
{
482+
struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
477483
acpi_handle dhandle, atpx_handle;
478484
acpi_status status;
479485

@@ -487,6 +493,7 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
487493

488494
radeon_atpx_priv.dhandle = dhandle;
489495
radeon_atpx_priv.atpx.handle = atpx_handle;
496+
radeon_atpx_priv.bridge_pm_usable = parent_pdev && parent_pdev->bridge_d3;
490497
return true;
491498
}
492499

0 commit comments

Comments
 (0)