Re: [Freedreno] [PATCH] drm/msm: another fix for the headless Adreno GPU

2023-01-04 Thread Dan Carpenter
Hi Dmitry,

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

url:
https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/drm-msm-another-fix-for-the-headless-Adreno-GPU/20221231-103022
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:
https://lore.kernel.org/r/20221231022937.286491-1-dmitry.baryshkov%40linaro.org
patch subject: [PATCH] drm/msm: another fix for the headless Adreno GPU
config: loongarch-randconfig-m031-20230101
compiler: loongarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Reported-by: Dan Carpenter 

smatch warnings:
drivers/gpu/drm/msm/msm_atomic.c:194 msm_atomic_commit_tail() error: 
uninitialized symbol 'async'.

vim +/async +194 drivers/gpu/drm/msm/msm_atomic.c

d4d2c60497cfc5 Rob Clark2019-08-29  181  
d14659f5de7d28 Sean Paul2018-02-28  182  void 
msm_atomic_commit_tail(struct drm_atomic_state *state)
cf3a7e4ce08e68 Rob Clark2014-11-08  183  {
cf3a7e4ce08e68 Rob Clark2014-11-08  184 struct drm_device *dev 
= state->dev;
0b776d457b9476 Rob Clark2015-01-30  185 struct msm_drm_private 
*priv = dev->dev_private;
0b776d457b9476 Rob Clark2015-01-30  186 struct msm_kms *kms = 
priv->kms;
2d99ced787e3d0 Rob Clark2019-08-29  187 struct drm_crtc 
*async_crtc = NULL;
d4d2c60497cfc5 Rob Clark2019-08-29  188 unsigned crtc_mask = 
get_crtc_mask(state);
91a514e50f1157 Dmitry Baryshkov 2022-12-31  189 bool async;
^^^
91a514e50f1157 Dmitry Baryshkov 2022-12-31  190  
91a514e50f1157 Dmitry Baryshkov 2022-12-31  191 if (!kms)
91a514e50f1157 Dmitry Baryshkov 2022-12-31  192 return;
0b776d457b9476 Rob Clark2015-01-30  193  
d934a712c5e6a3 Rob Clark2019-08-29 @194 
trace_msm_atomic_commit_tail_start(async, crtc_mask);

   ^
Unitialized.

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp



[Freedreno] [PATCH] drm/msm: another fix for the headless Adreno GPU

2022-12-30 Thread Dmitry Baryshkov
Fix another oops reproducible when rebooting the board with the Adreno
GPU wokring in the headless mode (e.g. iMX platforms).

Unable to handle kernel NULL pointer dereference at virtual address  
when read
[] *pgd=74936831, *pte=, *ppte=
Internal error: Oops: 17 [#1] ARM
CPU: 0 PID: 51 Comm: reboot Not tainted 6.2.0-rc1-dirty #11
Hardware name: Freescale i.MX53 (Device Tree Support)
PC is at msm_atomic_commit_tail+0x50/0x970
LR is at commit_tail+0x9c/0x188
pc : []lr : []psr: 600e0013
sp : e0851d30  ip : ee4eb7eb  fp : 00090acc
r10: 0058  r9 : c2193014  r8 : c431
r7 : c4759380  r6 : 07bef61d  r5 :   r4 : 
r3 : c44cc440  r2 :   r1 :   r0 : 
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 74910019  DAC: 0051
Register r0 information: NULL pointer
Register r1 information: NULL pointer
Register r2 information: NULL pointer
Register r3 information: slab kmalloc-1k start c44cc400 pointer offset 64 size 
1024
Register r4 information: NULL pointer
Register r5 information: NULL pointer
Register r6 information: non-paged memory
Register r7 information: slab kmalloc-128 start c4759380 pointer offset 0 size 
128
Register r8 information: slab kmalloc-2k start c431 pointer offset 0 size 
2048
Register r9 information: non-slab/vmalloc memory
Register r10 information: non-paged memory
Register r11 information: non-paged memory
Register r12 information: non-paged memory
Process reboot (pid: 51, stack limit = 0xc80046d9)
Stack: (0xe0851d30 to 0xe0852000)
1d20: c4759380 fbd77200 05ff 002b9c70
1d40: c4759380 c4759380  07bef61d 0600 c0d6fe7c c2193014 0058
1d60: 00090acc c067a214  c4759380 c431  c44cc854 c067a89c
1d80:    c4310468  c4759380 c431 c4310468
1da0: c4310470 c0643258 c4759380   c0c4ee24  c44cc810
1dc0:  c0c4ee24  c44cc810  0347d2a8 e0851e00 e0851e00
1de0: c4759380 c067ad20 c431  c44cc810 c27f8718 c44cc854 c067adb8
1e00: c4933000 0002 0001   c2130850  c2130854
1e20: c25fc488  c0ff162c  0001 0002  
1e40: c43102c0 c43102c0  0347d2a8 c44cc810 c44cc814 c2133da8 c06d1a60
1e60:   00079028 c2012f24 fee1dead c4933000 0058 c01431e4
1e80: 01234567 c0143a20      
1ea0:        
1ec0:        
1ee0:        
1f00:        
1f20:        
1f40:        
1f60:        
1f80:    0347d2a8 0002 0004 0078 0058
1fa0: c010028c c0100060 0002 0004 fee1dead 28121969 01234567 00079028
1fc0: 0002 0004 0078 0058 0002fdc5   00090acc
1fe0: 0058 becc9c64 b6e97e05 b6e0e5f6 600e0030 fee1dead  
 msm_atomic_commit_tail from commit_tail+0x9c/0x188
 commit_tail from drm_atomic_helper_commit+0x160/0x188
 drm_atomic_helper_commit from drm_atomic_commit+0xac/0xe0
 drm_atomic_commit from drm_atomic_helper_disable_all+0x1b0/0x1c0
 drm_atomic_helper_disable_all from drm_atomic_helper_shutdown+0x88/0x140
 drm_atomic_helper_shutdown from device_shutdown+0x16c/0x240
 device_shutdown from kernel_restart+0x38/0x90
 kernel_restart from __do_sys_reboot+0x174/0x224
 __do_sys_reboot from ret_fast_syscall+0x0/0x1c
Exception stack(0xe0851fa8 to 0xe0851ff0)
1fa0:   0002 0004 fee1dead 28121969 01234567 00079028
1fc0: 0002 0004 0078 0058 0002fdc5   00090acc
1fe0: 0058 becc9c64 b6e97e05 b6e0e5f6
Code: 15922088 1184421c e153 1af8 (e5953000)
---[ end trace  ]---

Fixes: 0a58d2ae572a ("drm/msm: Make .remove and .shutdown HW shutdown 
consistent")
Signed-off-by: Dmitry Baryshkov 
---

As can be seen from the backtrace, the error is generated because
msm_atomic_commit_tail is called in the shutdown path. I've fixed the
particular issue. Maybe we should consider shortcutting all mode_config
initialization in case of headless Adreno chip? This would be more
intrusive, so I haven't followed that path. However if you think that
this should be a proper way to fix the issue, I'll try doing it.

---
 drivers/gpu/drm/msm/msm_atomic.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index 1686fbb611fd..98c526246ff1 100644
---