Re: [PATCH 4/6] drm/i915/psr: Silence period and lfps half cycle

2024-02-18 Thread Dan Carpenter
Hi Jouni,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Jouni-H-gander/drm-display-Add-missing-aux-less-alpm-wake-related-bits/20240215-185209
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:
https://lore.kernel.org/r/20240215104934.2395239-5-jouni.hogander%40intel.com
patch subject: [PATCH 4/6] drm/i915/psr: Silence period and lfps half cycle
config: i386-randconfig-141-20240217 
(https://download.01.org/0day-ci/archive/20240217/202402171830.n4hwr2id-...@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 
6009708b4367171ccdbf4b5905cb6a803753fe18)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Reported-by: Dan Carpenter 
| Closes: https://lore.kernel.org/r/202402171830.n4hwr2id-...@intel.com/

smatch warnings:
drivers/gpu/drm/i915/display/intel_psr.c:1253 
_lnl_compute_aux_less_alpm_params() error: uninitialized symbol 
'silence_period'.

vim +/silence_period +1253 drivers/gpu/drm/i915/display/intel_psr.c

e4870a4a3cd051 Jouni Högander 2024-02-15  1235  static int 
_lnl_compute_aux_less_alpm_params(struct intel_dp *intel_dp,
e4870a4a3cd051 Jouni Högander 2024-02-15  1236  
 struct intel_crtc_state *crtc_state)
e4870a4a3cd051 Jouni Högander 2024-02-15  1237  {
e4870a4a3cd051 Jouni Högander 2024-02-15  1238  struct drm_i915_private 
*i915 = dp_to_i915(intel_dp);
410818227325ec Jouni Högander 2024-02-15  1239  int aux_less_wake_time, 
aux_less_wake_lines, switch_to_active_lines,
410818227325ec Jouni Högander 2024-02-15  1240  silence_period, 
lfps_half_cycle;
e4870a4a3cd051 Jouni Högander 2024-02-15  1241  
e4870a4a3cd051 Jouni Högander 2024-02-15  1242  aux_less_wake_time =
e4870a4a3cd051 Jouni Högander 2024-02-15  1243  
_lnl_compute_aux_less_wake_time(crtc_state->port_clock / 1000);
e4870a4a3cd051 Jouni Högander 2024-02-15  1244  aux_less_wake_lines = 
intel_usecs_to_scanlines(_state->hw.adjusted_mode,
e4870a4a3cd051 Jouni Högander 2024-02-15  1245  
   aux_less_wake_time);
e4870a4a3cd051 Jouni Högander 2024-02-15  1246  
e31171d1611687 Jouni Högander 2024-02-15  1247  switch_to_active_lines =
e31171d1611687 Jouni Högander 2024-02-15  1248  
intel_usecs_to_scanlines(
e31171d1611687 Jouni Högander 2024-02-15  1249  
_state->hw.adjusted_mode,
e31171d1611687 Jouni Högander 2024-02-15  1250  
_lnl_compute_switch_to_active_time(crtc_state->port_clock / 1000));
e31171d1611687 Jouni Högander 2024-02-15  1251  
410818227325ec Jouni Högander 2024-02-15  1252  if (aux_less_wake_lines 
> 32 || switch_to_active_lines > 32 ||
410818227325ec Jouni Högander 2024-02-15 @1253  silence_period > 
256 || silence_period < 0 ||
^^  
^^
Uninitialized

410818227325ec Jouni Högander 2024-02-15  1254  
!_lnl_get_silence_period_and_lfps_half_cycle(intel_dp->link_rate,
410818227325ec Jouni Högander 2024-02-15  1255  
 _period,
410818227325ec Jouni Högander 2024-02-15  1256  
 _half_cycle))
e4870a4a3cd051 Jouni Högander 2024-02-15  1257  return false;
e4870a4a3cd051 Jouni Högander 2024-02-15  1258  
e31171d1611687 Jouni Högander 2024-02-15  1259  if 
(i915->display.params.psr_safest_params) {
e4870a4a3cd051 Jouni Högander 2024-02-15  1260  
aux_less_wake_lines = 32;
e31171d1611687 Jouni Högander 2024-02-15  1261  
switch_to_active_lines = 32;
e31171d1611687 Jouni Högander 2024-02-15  1262  }
e4870a4a3cd051 Jouni Högander 2024-02-15  1263  
e4870a4a3cd051 Jouni Högander 2024-02-15  1264  
intel_dp->psr.alpm_parameters.aux_less_wake_lines = aux_less_wake_lines;
e31171d1611687 Jouni Högander 2024-02-15  1265  
intel_dp->psr.alpm_parameters.switch_to_active_lines = switch_to_active_lines;
410818227325ec Jouni Högander 2024-02-15  1266  
intel_dp->psr.alpm_parameters.silence_period_sym_clocks = silence_period;
410818227325ec Jouni Högander 2024-02-15  1267  
intel_dp->psr.alpm_parameters.lfps_half_cycle_num_of_syms = lfps_half_cycle;
e4870a4a3cd051 Jouni Högander 2024-02-15  1268  
e4870a4a3cd051 Jouni Högander 2024-02-15  1269  return true;
e4870a4a3cd051 Jouni Högander 2024-02-15  1270  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



Re: [PATCH 4/6] drm/i915/psr: Silence period and lfps half cycle

2024-02-15 Thread kernel test robot
Hi Jouni,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip next-20240215]
[cannot apply to drm-intel/for-linux-next-fixes drm/drm-next linus/master 
v6.8-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Jouni-H-gander/drm-display-Add-missing-aux-less-alpm-wake-related-bits/20240215-185209
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:
https://lore.kernel.org/r/20240215104934.2395239-5-jouni.hogander%40intel.com
patch subject: [PATCH 4/6] drm/i915/psr: Silence period and lfps half cycle
config: i386-buildonly-randconfig-004-20240215 
(https://download.01.org/0day-ci/archive/20240216/202402161056.o7ey8uvv-...@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 
6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240216/202402161056.o7ey8uvv-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202402161056.o7ey8uvv-...@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/display/intel_psr.c:1253:6: warning: variable 
>> 'silence_period' is uninitialized when used here [-Wuninitialized]
1253 | silence_period > 256 || silence_period < 0 ||
 | ^~
   drivers/gpu/drm/i915/display/intel_psr.c:1240:17: note: initialize the 
variable 'silence_period' to silence this warning
1240 | silence_period, lfps_half_cycle;
 |   ^
 |= 0
   1 warning generated.


vim +/silence_period +1253 drivers/gpu/drm/i915/display/intel_psr.c

  1234  
  1235  static int _lnl_compute_aux_less_alpm_params(struct intel_dp *intel_dp,
  1236   struct intel_crtc_state 
*crtc_state)
  1237  {
  1238  struct drm_i915_private *i915 = dp_to_i915(intel_dp);
  1239  int aux_less_wake_time, aux_less_wake_lines, 
switch_to_active_lines,
  1240  silence_period, lfps_half_cycle;
  1241  
  1242  aux_less_wake_time =
  1243  _lnl_compute_aux_less_wake_time(crtc_state->port_clock 
/ 1000);
  1244  aux_less_wake_lines = 
intel_usecs_to_scanlines(_state->hw.adjusted_mode,
  1245 
aux_less_wake_time);
  1246  
  1247  switch_to_active_lines =
  1248  intel_usecs_to_scanlines(
  1249  _state->hw.adjusted_mode,
  1250  
_lnl_compute_switch_to_active_time(crtc_state->port_clock / 1000));
  1251  
  1252  if (aux_less_wake_lines > 32 || switch_to_active_lines > 32 ||
> 1253  silence_period > 256 || silence_period < 0 ||
  1254  
!_lnl_get_silence_period_and_lfps_half_cycle(intel_dp->link_rate,
  1255   
_period,
  1256   
_half_cycle))
  1257  return false;
  1258  
  1259  if (i915->display.params.psr_safest_params) {
  1260  aux_less_wake_lines = 32;
  1261  switch_to_active_lines = 32;
  1262  }
  1263  
  1264  intel_dp->psr.alpm_parameters.aux_less_wake_lines = 
aux_less_wake_lines;
  1265  intel_dp->psr.alpm_parameters.switch_to_active_lines = 
switch_to_active_lines;
  1266  intel_dp->psr.alpm_parameters.silence_period_sym_clocks = 
silence_period;
  1267  intel_dp->psr.alpm_parameters.lfps_half_cycle_num_of_syms = 
lfps_half_cycle;
  1268  
  1269  return true;
  1270  }
  1271  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


[PATCH 4/6] drm/i915/psr: Silence period and lfps half cycle

2024-02-15 Thread Jouni Högander
Add get function for silence period and lfps half cycle. Values are taken
from the tables in bspec.

Bspec: 71632

Signed-off-by: Jouni Högander 
---
 .../drm/i915/display/intel_display_types.h|  2 +
 drivers/gpu/drm/i915/display/intel_psr.c  | 77 ++-
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h 
b/drivers/gpu/drm/i915/display/intel_display_types.h
index df82551a3f42..1bb72e606367 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1723,6 +1723,8 @@ struct intel_psr {
u8 check_entry_lines;
u8 aux_less_wake_lines;
u8 switch_to_active_lines;
+   u8 silence_period_sym_clocks;
+   u8 lfps_half_cycle_num_of_syms;
} alpm_parameters;
 
ktime_t last_entry_attempt;
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c 
b/drivers/gpu/drm/i915/display/intel_psr.c
index 4cefb9ada5db..8385d8172b27 100644
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -1126,6 +1126,72 @@ static bool 
_compute_psr2_sdp_prior_scanline_indication(struct intel_dp *intel_d
return true;
 }
 
+/*
+ * See Bspec: 71632 for the table
+ *
+ * Silence_period = tSilence,Min + ((tSilence,Max - tSilence,Min) / 2)
+ *
+ * Half cycle duration:
+ *
+ * Link rates 1.62 - 4.32 and tLFPS = 70 ns
+ * FLOOR( (Link Rate * tLFPS_Cycle) / (2 * 10) )
+ *
+ * Link rates 5.4 - 8.1
+ * FLOOR( LFPS Period in Symbol clocks /
+ * (2 * PORT_ALPM_LFPS_CTL[ LFPS Cycle Count ]) )
+ */
+static bool _lnl_get_silence_period_and_lfps_half_cycle(int link_rate,
+   int *silence_period,
+   int *lfps_half_cycle)
+{
+   switch (link_rate) {
+   case 162000:
+   *silence_period = 20;
+   *lfps_half_cycle = 5;
+   break;
+   case 216000:
+   *silence_period = 27;
+   *lfps_half_cycle = 7;
+   break;
+   case 243000:
+   *silence_period = 31;
+   *lfps_half_cycle = 8;
+   break;
+   case 27:
+   *silence_period = 34;
+   *lfps_half_cycle = 9;
+   break;
+   case 324000:
+   *silence_period = 41;
+   *lfps_half_cycle = 11;
+   break;
+   case 432000:
+   *silence_period = 56;
+   *lfps_half_cycle = 15;
+   break;
+   case 54:
+   *silence_period = 69;
+   *lfps_half_cycle = 12;
+   break;
+   case 648000:
+   *silence_period = 84;
+   *lfps_half_cycle = 15;
+   break;
+   case 675000:
+   *silence_period = 87;
+   *lfps_half_cycle = 15;
+   break;
+   case 81:
+   *silence_period = 104;
+   *lfps_half_cycle = 19;
+   break;
+   default:
+   *silence_period = *lfps_half_cycle = -1;
+   return false;
+   }
+   return true;
+}
+
 /*
  * AUX-Less Wake Time = CEILING( ((PHY P2 to P0) + tLFPS_Period, Max+
  * tSilence, Max+ tPHY Establishment + tCDS) / tline)
@@ -1170,7 +1236,8 @@ static int _lnl_compute_aux_less_alpm_params(struct 
intel_dp *intel_dp,
 struct intel_crtc_state 
*crtc_state)
 {
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
-   int aux_less_wake_time, aux_less_wake_lines, switch_to_active_lines;
+   int aux_less_wake_time, aux_less_wake_lines, switch_to_active_lines,
+   silence_period, lfps_half_cycle;
 
aux_less_wake_time =
_lnl_compute_aux_less_wake_time(crtc_state->port_clock / 1000);
@@ -1182,7 +1249,11 @@ static int _lnl_compute_aux_less_alpm_params(struct 
intel_dp *intel_dp,
_state->hw.adjusted_mode,

_lnl_compute_switch_to_active_time(crtc_state->port_clock / 1000));
 
-   if (aux_less_wake_lines > 32 || switch_to_active_lines > 32)
+   if (aux_less_wake_lines > 32 || switch_to_active_lines > 32 ||
+   silence_period > 256 || silence_period < 0 ||
+   !_lnl_get_silence_period_and_lfps_half_cycle(intel_dp->link_rate,
+_period,
+_half_cycle))
return false;
 
if (i915->display.params.psr_safest_params) {
@@ -1192,6 +1263,8 @@ static int _lnl_compute_aux_less_alpm_params(struct 
intel_dp *intel_dp,
 
intel_dp->psr.alpm_parameters.aux_less_wake_lines = aux_less_wake_lines;
intel_dp->psr.alpm_parameters.switch_to_active_lines = 
switch_to_active_lines;
+