Skip to content

Commit ea99697

Browse files
committed
Merge branch 'drm-fixes-4.6' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
A few fixes for 4.6. - revert amdgpu PX commit that was previously reverted on the radeon side - cleaned up version of the NI+ MC update display fix for radeon - TTM kref fix * 'drm-fixes-4.6' of git://people.freedesktop.org/~agd5f/linux: drm/amdgpu: disable vm interrupts with vm_fault_stop=2 drm/amdgpu: print a message if ATPX dGPU power control is missing Revert "drm/amdgpu: disable runtime pm on PX laptops without dGPU power control" drm/radeon: fix vertical bars appear on monitor (v2) drm/ttm: fix kref count mess in ttm_bo_move_to_lru_tail
2 parents d8ba5d6 + afc4542 commit ea99697

File tree

7 files changed

+219
-27
lines changed

7 files changed

+219
-27
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ bool amdgpu_has_atpx(void) {
6363
return amdgpu_atpx_priv.atpx_detected;
6464
}
6565

66-
bool amdgpu_has_atpx_dgpu_power_cntl(void) {
67-
return amdgpu_atpx_priv.atpx.functions.power_cntl;
68-
}
69-
7066
/**
7167
* amdgpu_atpx_call - call an ATPX method
7268
*
@@ -146,6 +142,13 @@ static void amdgpu_atpx_parse_functions(struct amdgpu_atpx_functions *f, u32 mas
146142
*/
147143
static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx)
148144
{
145+
/* make sure required functions are enabled */
146+
/* dGPU power control is required */
147+
if (atpx->functions.power_cntl == false) {
148+
printk("ATPX dGPU power cntl not present, forcing\n");
149+
atpx->functions.power_cntl = true;
150+
}
151+
149152
if (atpx->functions.px_params) {
150153
union acpi_object *info;
151154
struct atpx_px_params output;

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ static const char *amdgpu_asic_name[] = {
6262
"LAST",
6363
};
6464

65-
#if defined(CONFIG_VGA_SWITCHEROO)
66-
bool amdgpu_has_atpx_dgpu_power_cntl(void);
67-
#else
68-
static inline bool amdgpu_has_atpx_dgpu_power_cntl(void) { return false; }
69-
#endif
70-
7165
bool amdgpu_device_is_px(struct drm_device *dev)
7266
{
7367
struct amdgpu_device *adev = dev->dev_private;
@@ -1485,7 +1479,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
14851479

14861480
if (amdgpu_runtime_pm == 1)
14871481
runtime = true;
1488-
if (amdgpu_device_is_px(ddev) && amdgpu_has_atpx_dgpu_power_cntl())
1482+
if (amdgpu_device_is_px(ddev))
14891483
runtime = true;
14901484
vga_switcheroo_register_client(adev->pdev, &amdgpu_switcheroo_ops, runtime);
14911485
if (runtime)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,10 @@ static int gmc_v7_0_late_init(void *handle)
910910
{
911911
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
912912

913-
return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
913+
if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
914+
return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
915+
else
916+
return 0;
914917
}
915918

916919
static int gmc_v7_0_sw_init(void *handle)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,10 @@ static int gmc_v8_0_late_init(void *handle)
870870
{
871871
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
872872

873-
return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
873+
if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
874+
return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
875+
else
876+
return 0;
874877
}
875878

876879
#define mmMC_SEQ_MISC0_FIJI 0xA71

drivers/gpu/drm/radeon/evergreen.c

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2608,10 +2608,152 @@ static void evergreen_agp_enable(struct radeon_device *rdev)
26082608
WREG32(VM_CONTEXT1_CNTL, 0);
26092609
}
26102610

2611+
static const unsigned ni_dig_offsets[] =
2612+
{
2613+
NI_DIG0_REGISTER_OFFSET,
2614+
NI_DIG1_REGISTER_OFFSET,
2615+
NI_DIG2_REGISTER_OFFSET,
2616+
NI_DIG3_REGISTER_OFFSET,
2617+
NI_DIG4_REGISTER_OFFSET,
2618+
NI_DIG5_REGISTER_OFFSET
2619+
};
2620+
2621+
static const unsigned ni_tx_offsets[] =
2622+
{
2623+
NI_DCIO_UNIPHY0_UNIPHY_TX_CONTROL1,
2624+
NI_DCIO_UNIPHY1_UNIPHY_TX_CONTROL1,
2625+
NI_DCIO_UNIPHY2_UNIPHY_TX_CONTROL1,
2626+
NI_DCIO_UNIPHY3_UNIPHY_TX_CONTROL1,
2627+
NI_DCIO_UNIPHY4_UNIPHY_TX_CONTROL1,
2628+
NI_DCIO_UNIPHY5_UNIPHY_TX_CONTROL1
2629+
};
2630+
2631+
static const unsigned evergreen_dp_offsets[] =
2632+
{
2633+
EVERGREEN_DP0_REGISTER_OFFSET,
2634+
EVERGREEN_DP1_REGISTER_OFFSET,
2635+
EVERGREEN_DP2_REGISTER_OFFSET,
2636+
EVERGREEN_DP3_REGISTER_OFFSET,
2637+
EVERGREEN_DP4_REGISTER_OFFSET,
2638+
EVERGREEN_DP5_REGISTER_OFFSET
2639+
};
2640+
2641+
2642+
/*
2643+
* Assumption is that EVERGREEN_CRTC_MASTER_EN enable for requested crtc
2644+
* We go from crtc to connector and it is not relible since it
2645+
* should be an opposite direction .If crtc is enable then
2646+
* find the dig_fe which selects this crtc and insure that it enable.
2647+
* if such dig_fe is found then find dig_be which selects found dig_be and
2648+
* insure that it enable and in DP_SST mode.
2649+
* if UNIPHY_PLL_CONTROL1.enable then we should disconnect timing
2650+
* from dp symbols clocks .
2651+
*/
2652+
static bool evergreen_is_dp_sst_stream_enabled(struct radeon_device *rdev,
2653+
unsigned crtc_id, unsigned *ret_dig_fe)
2654+
{
2655+
unsigned i;
2656+
unsigned dig_fe;
2657+
unsigned dig_be;
2658+
unsigned dig_en_be;
2659+
unsigned uniphy_pll;
2660+
unsigned digs_fe_selected;
2661+
unsigned dig_be_mode;
2662+
unsigned dig_fe_mask;
2663+
bool is_enabled = false;
2664+
bool found_crtc = false;
2665+
2666+
/* loop through all running dig_fe to find selected crtc */
2667+
for (i = 0; i < ARRAY_SIZE(ni_dig_offsets); i++) {
2668+
dig_fe = RREG32(NI_DIG_FE_CNTL + ni_dig_offsets[i]);
2669+
if (dig_fe & NI_DIG_FE_CNTL_SYMCLK_FE_ON &&
2670+
crtc_id == NI_DIG_FE_CNTL_SOURCE_SELECT(dig_fe)) {
2671+
/* found running pipe */
2672+
found_crtc = true;
2673+
dig_fe_mask = 1 << i;
2674+
dig_fe = i;
2675+
break;
2676+
}
2677+
}
2678+
2679+
if (found_crtc) {
2680+
/* loop through all running dig_be to find selected dig_fe */
2681+
for (i = 0; i < ARRAY_SIZE(ni_dig_offsets); i++) {
2682+
dig_be = RREG32(NI_DIG_BE_CNTL + ni_dig_offsets[i]);
2683+
/* if dig_fe_selected by dig_be? */
2684+
digs_fe_selected = NI_DIG_BE_CNTL_FE_SOURCE_SELECT(dig_be);
2685+
dig_be_mode = NI_DIG_FE_CNTL_MODE(dig_be);
2686+
if (dig_fe_mask & digs_fe_selected &&
2687+
/* if dig_be in sst mode? */
2688+
dig_be_mode == NI_DIG_BE_DPSST) {
2689+
dig_en_be = RREG32(NI_DIG_BE_EN_CNTL +
2690+
ni_dig_offsets[i]);
2691+
uniphy_pll = RREG32(NI_DCIO_UNIPHY0_PLL_CONTROL1 +
2692+
ni_tx_offsets[i]);
2693+
/* dig_be enable and tx is running */
2694+
if (dig_en_be & NI_DIG_BE_EN_CNTL_ENABLE &&
2695+
dig_en_be & NI_DIG_BE_EN_CNTL_SYMBCLK_ON &&
2696+
uniphy_pll & NI_DCIO_UNIPHY0_PLL_CONTROL1_ENABLE) {
2697+
is_enabled = true;
2698+
*ret_dig_fe = dig_fe;
2699+
break;
2700+
}
2701+
}
2702+
}
2703+
}
2704+
2705+
return is_enabled;
2706+
}
2707+
2708+
/*
2709+
* Blank dig when in dp sst mode
2710+
* Dig ignores crtc timing
2711+
*/
2712+
static void evergreen_blank_dp_output(struct radeon_device *rdev,
2713+
unsigned dig_fe)
2714+
{
2715+
unsigned stream_ctrl;
2716+
unsigned fifo_ctrl;
2717+
unsigned counter = 0;
2718+
2719+
if (dig_fe >= ARRAY_SIZE(evergreen_dp_offsets)) {
2720+
DRM_ERROR("invalid dig_fe %d\n", dig_fe);
2721+
return;
2722+
}
2723+
2724+
stream_ctrl = RREG32(EVERGREEN_DP_VID_STREAM_CNTL +
2725+
evergreen_dp_offsets[dig_fe]);
2726+
if (!(stream_ctrl & EVERGREEN_DP_VID_STREAM_CNTL_ENABLE)) {
2727+
DRM_ERROR("dig %d , should be enable\n", dig_fe);
2728+
return;
2729+
}
2730+
2731+
stream_ctrl &=~EVERGREEN_DP_VID_STREAM_CNTL_ENABLE;
2732+
WREG32(EVERGREEN_DP_VID_STREAM_CNTL +
2733+
evergreen_dp_offsets[dig_fe], stream_ctrl);
2734+
2735+
stream_ctrl = RREG32(EVERGREEN_DP_VID_STREAM_CNTL +
2736+
evergreen_dp_offsets[dig_fe]);
2737+
while (counter < 32 && stream_ctrl & EVERGREEN_DP_VID_STREAM_STATUS) {
2738+
msleep(1);
2739+
counter++;
2740+
stream_ctrl = RREG32(EVERGREEN_DP_VID_STREAM_CNTL +
2741+
evergreen_dp_offsets[dig_fe]);
2742+
}
2743+
if (counter >= 32 )
2744+
DRM_ERROR("counter exceeds %d\n", counter);
2745+
2746+
fifo_ctrl = RREG32(EVERGREEN_DP_STEER_FIFO + evergreen_dp_offsets[dig_fe]);
2747+
fifo_ctrl |= EVERGREEN_DP_STEER_FIFO_RESET;
2748+
WREG32(EVERGREEN_DP_STEER_FIFO + evergreen_dp_offsets[dig_fe], fifo_ctrl);
2749+
2750+
}
2751+
26112752
void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save)
26122753
{
26132754
u32 crtc_enabled, tmp, frame_count, blackout;
26142755
int i, j;
2756+
unsigned dig_fe;
26152757

26162758
if (!ASIC_IS_NODCE(rdev)) {
26172759
save->vga_render_control = RREG32(VGA_RENDER_CONTROL);
@@ -2651,7 +2793,17 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
26512793
break;
26522794
udelay(1);
26532795
}
2654-
2796+
/*we should disable dig if it drives dp sst*/
2797+
/*but we are in radeon_device_init and the topology is unknown*/
2798+
/*and it is available after radeon_modeset_init*/
2799+
/*the following method radeon_atom_encoder_dpms_dig*/
2800+
/*does the job if we initialize it properly*/
2801+
/*for now we do it this manually*/
2802+
/**/
2803+
if (ASIC_IS_DCE5(rdev) &&
2804+
evergreen_is_dp_sst_stream_enabled(rdev, i ,&dig_fe))
2805+
evergreen_blank_dp_output(rdev, dig_fe);
2806+
/*we could remove 6 lines below*/
26552807
/* XXX this is a hack to avoid strange behavior with EFI on certain systems */
26562808
WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
26572809
tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]);

drivers/gpu/drm/radeon/evergreen_reg.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,43 @@
250250

251251
/* HDMI blocks at 0x7030, 0x7c30, 0x10830, 0x11430, 0x12030, 0x12c30 */
252252
#define EVERGREEN_HDMI_BASE 0x7030
253+
/*DIG block*/
254+
#define NI_DIG0_REGISTER_OFFSET (0x7000 - 0x7000)
255+
#define NI_DIG1_REGISTER_OFFSET (0x7C00 - 0x7000)
256+
#define NI_DIG2_REGISTER_OFFSET (0x10800 - 0x7000)
257+
#define NI_DIG3_REGISTER_OFFSET (0x11400 - 0x7000)
258+
#define NI_DIG4_REGISTER_OFFSET (0x12000 - 0x7000)
259+
#define NI_DIG5_REGISTER_OFFSET (0x12C00 - 0x7000)
260+
261+
262+
#define NI_DIG_FE_CNTL 0x7000
263+
# define NI_DIG_FE_CNTL_SOURCE_SELECT(x) ((x) & 0x3)
264+
# define NI_DIG_FE_CNTL_SYMCLK_FE_ON (1<<24)
265+
266+
267+
#define NI_DIG_BE_CNTL 0x7140
268+
# define NI_DIG_BE_CNTL_FE_SOURCE_SELECT(x) (((x) >> 8 ) & 0x3F)
269+
# define NI_DIG_FE_CNTL_MODE(x) (((x) >> 16) & 0x7 )
270+
271+
#define NI_DIG_BE_EN_CNTL 0x7144
272+
# define NI_DIG_BE_EN_CNTL_ENABLE (1 << 0)
273+
# define NI_DIG_BE_EN_CNTL_SYMBCLK_ON (1 << 8)
274+
# define NI_DIG_BE_DPSST 0
253275

254276
/* Display Port block */
277+
#define EVERGREEN_DP0_REGISTER_OFFSET (0x730C - 0x730C)
278+
#define EVERGREEN_DP1_REGISTER_OFFSET (0x7F0C - 0x730C)
279+
#define EVERGREEN_DP2_REGISTER_OFFSET (0x10B0C - 0x730C)
280+
#define EVERGREEN_DP3_REGISTER_OFFSET (0x1170C - 0x730C)
281+
#define EVERGREEN_DP4_REGISTER_OFFSET (0x1230C - 0x730C)
282+
#define EVERGREEN_DP5_REGISTER_OFFSET (0x12F0C - 0x730C)
283+
284+
285+
#define EVERGREEN_DP_VID_STREAM_CNTL 0x730C
286+
# define EVERGREEN_DP_VID_STREAM_CNTL_ENABLE (1 << 0)
287+
# define EVERGREEN_DP_VID_STREAM_STATUS (1 <<16)
288+
#define EVERGREEN_DP_STEER_FIFO 0x7310
289+
# define EVERGREEN_DP_STEER_FIFO_RESET (1 << 0)
255290
#define EVERGREEN_DP_SEC_CNTL 0x7280
256291
# define EVERGREEN_DP_SEC_STREAM_ENABLE (1 << 0)
257292
# define EVERGREEN_DP_SEC_ASP_ENABLE (1 << 4)
@@ -266,4 +301,15 @@
266301
# define EVERGREEN_DP_SEC_N_BASE_MULTIPLE(x) (((x) & 0xf) << 24)
267302
# define EVERGREEN_DP_SEC_SS_EN (1 << 28)
268303

304+
/*DCIO_UNIPHY block*/
305+
#define NI_DCIO_UNIPHY0_UNIPHY_TX_CONTROL1 (0x6600 -0x6600)
306+
#define NI_DCIO_UNIPHY1_UNIPHY_TX_CONTROL1 (0x6640 -0x6600)
307+
#define NI_DCIO_UNIPHY2_UNIPHY_TX_CONTROL1 (0x6680 - 0x6600)
308+
#define NI_DCIO_UNIPHY3_UNIPHY_TX_CONTROL1 (0x66C0 - 0x6600)
309+
#define NI_DCIO_UNIPHY4_UNIPHY_TX_CONTROL1 (0x6700 - 0x6600)
310+
#define NI_DCIO_UNIPHY5_UNIPHY_TX_CONTROL1 (0x6740 - 0x6600)
311+
312+
#define NI_DCIO_UNIPHY0_PLL_CONTROL1 0x6618
313+
# define NI_DCIO_UNIPHY0_PLL_CONTROL1_ENABLE (1 << 0)
314+
269315
#endif

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,13 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
230230

231231
void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
232232
{
233-
struct ttm_bo_device *bdev = bo->bdev;
234-
struct ttm_mem_type_manager *man;
233+
int put_count = 0;
235234

236235
lockdep_assert_held(&bo->resv->lock.base);
237236

238-
if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
239-
list_del_init(&bo->swap);
240-
list_del_init(&bo->lru);
241-
242-
} else {
243-
if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
244-
list_move_tail(&bo->swap, &bo->glob->swap_lru);
245-
246-
man = &bdev->man[bo->mem.mem_type];
247-
list_move_tail(&bo->lru, &man->lru);
248-
}
237+
put_count = ttm_bo_del_from_lru(bo);
238+
ttm_bo_list_ref_sub(bo, put_count, true);
239+
ttm_bo_add_to_lru(bo);
249240
}
250241
EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
251242

0 commit comments

Comments
 (0)