Fix drm RAD print
Subsystems (2)
v3 cover Fix drm RAD print
This is v3 of [1], with the following changes:
- Modify description "drm_dp_mst_topology_mgr::mst_primary" to "&drm_dp_mst_topology_mgr.mst_primary" so kdoc formats it properly (Lyude)
- Ajust code format (Lyude)
[1] https://patchwork.freedesktop.org/series/141832/
Wayne Lin (2):
drm/dp_mst: Fix drm RAD print
drm/dp_mst: Add helper to get port number at specific LCT from RAD
drivers/gpu/drm/display/drm_dp_mst_topology.c | 31 +++++++++++++------ include/drm/display/drm_dp_mst_helper.h | 7 +++++ 2 files changed, 28 insertions(+), 10 deletions(-)
Signature · 1 line
2.37.3
PATCH v3 1/2 drm/dp_mst: Fix drm RAD print
[Why]
The RAD of sideband message printed today is incorrect.
For RAD stored within MST branch
- If MST branch LCT is 1, it's RAD array is untouched and remained as 0.
- If MST branch LCT is larger than 1, use nibble to store the up facing port number in cascaded sequence as illustrated below:
u8 RAD[0] = (LCT_2_UFP << 4) | LCT_3_UFP
RAD[1] = (LCT_4_UFP << 4) | LCT_5_UFP
...In drm_dp_mst_rad_to_str(), it wrongly to use BIT_MASK(4) to fetch the port number of one nibble.
[How]
Adjust the code by:
- RAD array items are valuable only for LCT >= 1.
- Use 0xF as the mask to replace BIT_MASK(4)
V2:
- Document how RAD is constructed (Imre)
V3:
- Adjust the comment for rad[] so kdoc formats it properly (Lyude)
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 8 ++++---- include/drm/display/drm_dp_mst_helper.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +4 -4
@@ -175,13 +175,13 @@ static int drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len) { int i; -u8 unpacked_rad[16 ]; +u8 unpacked_rad[16 ] = {}; -for (i =0 ; i < lct; i++) { +for (i =1 ; i < lct; i++) {if (i %2 ) - unpacked_rad[i] = rad[i /2 ] >>4 ; + unpacked_rad[i] = rad[(i -1 ) /2 ] >>4 ;else - unpacked_rad[i] = rad[i /2 ] &BIT_MASK (4 ); + unpacked_rad[i] = rad[(i -1 ) /2 ] &0xF ; }/* TODO: Eventually add something to printk so we can format the rad
include/drm/display/drm_dp_mst_helper.h +7 -0
@@ -222,6 +222,13 @@ struct drm_dp_mst_branch {*/ struct list_head destroy_next; +/** +* @rad: Relative Address of the MST branch. +* For &drm_dp_mst_topology_mgr.mst_primary, it's rad[8] are all 0, +* unset and unused. For MST branches connected after mst_primary, +* in each element of rad[] the nibbles are ordered by the most +* signifcant 4 bits first and the least significant 4 bits second. +*/ u8 rad[8 ];u8 lct;int num_ports;
Signature · 1 line
2.37.3
PATCH v3 2/2 drm/dp_mst: Add helper to get port number at specific LCT from RAD
In reply to Wayne LinAdd a helper drm_dp_mst_get_ufp_num_at_lct_from_rad() to extract the up facing port number at specific link count from the RAD. Use the added helper in drm_dp_mst_rad_to_str() & drm_dp_get_mst_branch_device() to unify the implementation.
V2:
- Adjust the code format (Lyude)
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +20 -9
@@ -171,18 +171,30 @@ static const char *drm_dp_mst_sideband_tx_state_str(int state)return sideband_reason_str[state]; } +static inline u8 +drm_dp_mst_get_ufp_num_at_lct_from_rad (u8 lct,u8 *rad) +{ +int idx = (lct /2 ) -1 ; +int shift = (lct %2 ) ?0 :4 ; +u8 ufp_num; + +/* mst_primary, it's rad is unset*/ +if (lct ==1 ) +return 0 ; + + ufp_num = (rad[idx] >> shift) &0xf ; + +return ufp_num; +} +static int drm_dp_mst_rad_to_str (const u8 rad[8 ],u8 lct,char *out,size_t len) {int i;u8 unpacked_rad[16 ] = {}; -for (i =1 ; i < lct; i++) { -if (i %2 ) - unpacked_rad[i] = rad[(i -1 ) /2 ] >>4 ; -else - unpacked_rad[i] = rad[(i -1 ) /2 ] &0xF ; - } +for (i =0 ; i < lct; i++) + unpacked_rad[i] =drm_dp_mst_get_ufp_num_at_lct_from_rad (i +1 , rad);/* TODO: Eventually add something to printk so we can format the rad * like this: 1.2.3
@@ -2544,9 +2556,8 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_if (!mstb) goto out; -for (i =0 ; i < lct -1 ; i++) { -int shift = (i %2 ) ?0 :4 ; -int port_num = (rad[i /2 ] >> shift) &0xf ; +for (i =1 ; i < lct; i++) { +int port_num =drm_dp_mst_get_ufp_num_at_lct_from_rad (i +1 , rad);list_for_each_entry (port, &mstb->ports, next) {if (port->port_num == port_num) {
Signature · 1 line
2.37.3
kernel test robot
build botRe: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD
kernel test robot noticed the following build errors:
Hi Wayne,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-exynos/exynos-drm-next linus/master v6.13-rc6 next-20250110] [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/Wayne-Lin/drm-dp_mst-Fix-drm-RAD-print/20250110-103837 base: git://anongit.freedesktop.org/drm/drm drm-next patch link: https://lore.kernel.org/r/20250110023618.66401-3-Wayne.Lin%40amd.com patch subject: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD config: hexagon-randconfig-001-20250111 (https://download.01.org/0day-ci/archive/20250111/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project f5cd181ffbb7cb61d582fe130d46580d5969d47a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/display/drm_dp_mst_topology.c:26:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/gpu/drm/display/drm_dp_mst_topology.c:26:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/gpu/drm/display/drm_dp_mst_topology.c:26:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
In file included from drivers/gpu/drm/display/drm_dp_mst_topology.c:26:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> drivers/gpu/drm/display/drm_dp_mst_topology.c:201:67: error: passing 'const u8 *' (aka 'const unsigned char *') to parameter of type 'u8 *' (aka 'unsigned char *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
201 | unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad);
| ^~~
drivers/gpu/drm/display/drm_dp_mst_topology.c:179:52: note: passing argument to parameter 'rad' here
179 | drm_dp_mst_get_ufp_num_at_lct_from_rad(u8 lct, u8 *rad)
| ^7 warnings and 1 error generated.
vim +201 drivers/gpu/drm/display/drm_dp_mst_topology.c
193
194 static int
195 drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len)
196 {
197 int i;
198 u8 unpacked_rad[16] = {};
199
200 for (i = 0; i < lct; i++)
> 201 unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad);
202
203 /* TODO: Eventually add something to printk so we can format the rad
204 * like this: 1.2.3
205 */
206 return snprintf(out, len, "%*phC", lct, unpacked_rad);
207 }
208
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD
In reply to Wayne Linkernel test robot noticed the following build warnings:
Hi Wayne,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm/drm-next]
[also build test WARNING on drm-exynos/exynos-drm-next linus/master drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-misc/drm-misc-next drm-tip/drm-tip v6.13-rc6 next-20250110] [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/Wayne-Lin/drm-dp_mst-Fix-drm-RAD-print/20250110-103837 base: git://anongit.freedesktop.org/drm/drm drm-next patch link: https://lore.kernel.org/r/20250110023618.66401-3-Wayne.Lin%40amd.com patch subject: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD config: csky-randconfig-002-20250111 (https://download.01.org/0day-ci/archive/20250111/[email protected]/config) compiler: csky-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/display/drm_dp_mst_topology.c: In function 'drm_dp_mst_rad_to_str':
>> drivers/gpu/drm/display/drm_dp_mst_topology.c:201:81: warning: passing argument 2 of 'drm_dp_mst_get_ufp_num_at_lct_from_rad' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
201 | unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad);
| ^~~
drivers/gpu/drm/display/drm_dp_mst_topology.c:179:52: note: expected 'u8 *' {aka 'unsigned char *'} but argument is of type 'const u8 *' {aka 'const unsigned char *'}
179 | drm_dp_mst_get_ufp_num_at_lct_from_rad(u8 lct, u8 *rad)
| ~~~~^~~vim +201 drivers/gpu/drm/display/drm_dp_mst_topology.c
193
194 static int
195 drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len)
196 {
197 int i;
198 u8 unpacked_rad[16] = {};
199
200 for (i = 0; i < lct; i++)
> 201 unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad);
202
203 /* TODO: Eventually add something to printk so we can format the rad
204 * like this: 1.2.3
205 */
206 return snprintf(out, len, "%*phC", lct, unpacked_rad);
207 }
208
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD
In reply to Wayne Linkernel test robot noticed the following build warnings:
Hi Wayne,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm/drm-next]
[also build test WARNING on drm-exynos/exynos-drm-next linus/master v6.13-rc6 next-20250110] [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/Wayne-Lin/drm-dp_mst-Fix-drm-RAD-print/20250110-103837 base: git://anongit.freedesktop.org/drm/drm drm-next patch link: https://lore.kernel.org/r/20250110023618.66401-3-Wayne.Lin%40amd.com patch subject: [Patch v3 2/2] drm/dp_mst: Add helper to get port number at specific LCT from RAD config: x86_64-randconfig-121-20250111 (https://download.01.org/0day-ci/archive/20250111/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250111/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/display/drm_dp_mst_topology.c:201:81: sparse: sparse: incorrect type in argument 2 (different modifiers) @@ expected unsigned char [usertype] *rad @@ got unsigned char const [usertype] *rad @@
drivers/gpu/drm/display/drm_dp_mst_topology.c:201:81: sparse: expected unsigned char [usertype] *rad
drivers/gpu/drm/display/drm_dp_mst_topology.c:201:81: sparse: got unsigned char const [usertype] *rad
drivers/gpu/drm/display/drm_dp_mst_topology.c: note: in included file (through include/linux/smp.h, include/linux/lockdep.h, include/linux/spinlock.h, ...):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
vim +201 drivers/gpu/drm/display/drm_dp_mst_topology.c
193
194 static int
195 drm_dp_mst_rad_to_str(const u8 rad[8], u8 lct, char *out, size_t len)
196 {
197 int i;
198 u8 unpacked_rad[16] = {};
199
200 for (i = 0; i < lct; i++)
> 201 unpacked_rad[i] = drm_dp_mst_get_ufp_num_at_lct_from_rad(i + 1, rad);
202
203 /* TODO: Eventually add something to printk so we can format the rad
204 * like this: 1.2.3
205 */
206 return snprintf(out, len, "%*phC", lct, unpacked_rad);
207 }
208
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
[Public]
Hi Lyude,
Could you help to merge if patches are ready to go? Thanks!
Regards,
Wayne
Quoted 32 lines
-----Original Message-----
From: Wayne Lin <[email protected]>
Sent: Friday, January 10, 2025 10:36 AM
To: [email protected]
Cc: [email protected]; Wentland, Harry <[email protected]>; [email protected]; [email protected]; Lin, Wayne <[email protected]>; Wentland, Harry <[email protected]>
Subject: [Patch v3 0/2] Fix drm RAD printThis is v3 of [1], with the following changes:
- Modify description "
drm_dp_mst_topology_mgr::mst_primary" to "&drm_dp_mst_topology_mgr.mst_primary" so kdoc formats it properly (Lyude)
- Ajust code format (Lyude)Cc Imre Deak <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Harry Wentland <[email protected]>Cc Lyude Paul <[email protected]>[1] https://patchwork.freedesktop.org/series/141832/
Wayne Lin (2):
drm/dp_mst: Fix drm RAD print
drm/dp_mst: Add helper to get port number at specific LCT from RADdrivers/gpu/drm/display/drm_dp_mst_topology.c | 31 +++++++++++++------ include/drm/display/drm_dp_mst_helper.h | 7 +++++ 2 files changed, 28 insertions(+), 10 deletions(-)--
2.37.3