mbox series

[v6,00/11] Clean up "mediatek,larb"

Message ID 20210714025626.5528-1-yong.wu@mediatek.com (mailing list archive)
Headers show
Series Clean up "mediatek,larb" | expand

Message

Yong Wu (吴勇) July 14, 2021, 2:56 a.m. UTC
MediaTek IOMMU block diagram always like below:

        M4U
         |
    smi-common
         |
  -------------
  |         |  ...
  |         |
larb1     larb2
  |         |
vdec       venc

All the consumer connect with smi-larb, then connect with smi-common.

When the consumer works, it should enable the smi-larb's power which also
need enable the smi-common's power firstly.

Thus, Firstly, use the device link connect the consumer and the
smi-larbs. then add device link between the smi-larb and smi-common.

After adding the device_link, then "mediatek,larb" property can be removed.
the iommu consumer don't need call the mtk_smi_larb_get/put to enable
the power and clock of smi-larb and smi-common.

About the MM dt-binding/dtsi patches, I guess they should go together, thus
I don't split them for each a MM module and each a SoC.

Base on v5.14-rc1, and a jpeg[1] and mdp[2] patchset.

[1] https://lore.kernel.org/linux-mediatek/20210702102304.3346429-1-hsinyi@chromium.org/
[2] https://lore.kernel.org/linux-mediatek/20210709022324.1607884-1-eizan@chromium.org/

Change notes:
v6: 1) rebase on v5.14-rc1.
    2) Fix the issue commented in v5 from Dafna and Hsin-Yi.
    3) Remove the patches about using pm_runtime_resume_and_get since they have
       already been merged by other patches.

v5: https://lore.kernel.org/linux-mediatek/20210410091128.31823-1-yong.wu@mediatek.com/
    1) Base v5.12-rc2.
    2) Remove changing the mtk-iommu to module_platform_driver patch, It have already been a
    independent patch.

v4: https://lore.kernel.org/linux-mediatek/1590826218-23653-1-git-send-email-yong.wu@mediatek.com/ 
    base on v5.7-rc1.
  1) Move drm PM patch before smi patchs.
  2) Change builtin_platform_driver to module_platform_driver since we may need
     build as module.
  3) Rebase many patchset as above.

v3: https://lore.kernel.org/linux-iommu/1567503456-24725-1-git-send-email-yong.wu@mediatek.com/
    1) rebase on v5.3-rc1 and the latest mt8183 patchset.
    2) Use device_is_bound to check whether the driver is ready from Matthias.    
    3) Add DL_FLAG_STATELESS flag when calling device_link_add and explain the
   reason in the commit message[3/14].
    4) Add a display patch[12/14] into this series. otherwise it may affect
   display HW fastlogo even though it don't happen in mt8183.
   
v2: https://lore.kernel.org/linux-iommu/1560171313-28299-1-git-send-email-yong.wu@mediatek.com/
   1) rebase on v5.2-rc1.
   2) Move adding device_link between the consumer and smi-larb into
iommu_add_device from Robin.
   3) add DL_FLAG_AUTOREMOVE_CONSUMER even though the smi is built-in from Evan.
   4) Remove the shutdown callback in iommu.   

v1: https://lore.kernel.org/linux-iommu/1546318276-18993-1-git-send-email-yong.wu@mediatek.com/

Yong Wu (10):
  dt-binding: mediatek: Get rid of mediatek,larb for multimedia HW
  iommu/mediatek: Add probe_defer for smi-larb
  iommu/mediatek: Add device_link between the consumer and the larb
    devices
  media: mtk-jpeg: Get rid of mtk_smi_larb_get/put
  media: mtk-mdp: Get rid of mtk_smi_larb_get/put
  drm/mediatek: Get rid of mtk_smi_larb_get/put
  media: mtk-vcodec: Get rid of mtk_smi_larb_get/put
  memory: mtk-smi: Get rid of mtk_smi_larb_get/put
  arm: dts: mediatek: Get rid of mediatek,larb for MM nodes
  arm64: dts: mediatek: Get rid of mediatek,larb for MM nodes

Yongqiang Niu (1):
  drm/mediatek: Add pm runtime support for ovl and rdma

 .../display/mediatek/mediatek,disp.txt        |  9 ----
 .../bindings/media/mediatek-jpeg-decoder.yaml |  9 ----
 .../bindings/media/mediatek-jpeg-encoder.yaml |  9 ----
 .../bindings/media/mediatek-mdp.txt           |  8 ----
 .../bindings/media/mediatek-vcodec.txt        |  4 --
 arch/arm/boot/dts/mt2701.dtsi                 |  2 -
 arch/arm/boot/dts/mt7623n.dtsi                |  5 --
 arch/arm64/boot/dts/mediatek/mt8173.dtsi      | 16 -------
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  6 ---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c       |  9 +++-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c      |  9 +++-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c       | 19 ++++----
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   | 36 +--------------
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h   |  1 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c        |  5 +-
 drivers/iommu/mtk_iommu.c                     | 24 +++++++++-
 drivers/iommu/mtk_iommu_v1.c                  | 22 ++++++++-
 .../media/platform/mtk-jpeg/mtk_jpeg_core.c   | 45 +-----------------
 .../media/platform/mtk-jpeg/mtk_jpeg_core.h   |  2 -
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 46 +------------------
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |  2 -
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  1 -
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 37 ++-------------
 .../platform/mtk-vcodec/mtk_vcodec_drv.h      |  3 --
 .../platform/mtk-vcodec/mtk_vcodec_enc.c      |  1 -
 .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   | 44 ++----------------
 drivers/memory/mtk-smi.c                      | 14 ------
 include/soc/mediatek/smi.h                    | 20 --------
 28 files changed, 85 insertions(+), 323 deletions(-)

Comments

Dafna Hirschfeld July 14, 2021, 8:56 a.m. UTC | #1
Hi

Thanks for the patchset.

I tested it on mt8173 (elm) with chromeos userspace.
Before that patchset, the test:

tast -verbose run -build=false 10.42.0.175 video.DecodeAccel.h264

sometimes passed and sometimes failed with 'context deadline exceeded'.
With this patchset it seems that the test always passes so I added tested-by:

Tested-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>

Thanks,
Dafna




On 14.07.21 04:56, Yong Wu wrote:
> MediaTek IOMMU block diagram always like below:
> 
>          M4U
>           |
>      smi-common
>           |
>    -------------
>    |         |  ...
>    |         |
> larb1     larb2
>    |         |
> vdec       venc
> 
> All the consumer connect with smi-larb, then connect with smi-common.
> 
> When the consumer works, it should enable the smi-larb's power which also
> need enable the smi-common's power firstly.
> 
> Thus, Firstly, use the device link connect the consumer and the
> smi-larbs. then add device link between the smi-larb and smi-common.
> 
> After adding the device_link, then "mediatek,larb" property can be removed.
> the iommu consumer don't need call the mtk_smi_larb_get/put to enable
> the power and clock of smi-larb and smi-common.
> 
> About the MM dt-binding/dtsi patches, I guess they should go together, thus
> I don't split them for each a MM module and each a SoC.
> 
> Base on v5.14-rc1, and a jpeg[1] and mdp[2] patchset.
> 
> [1] https://lore.kernel.org/linux-mediatek/20210702102304.3346429-1-hsinyi@chromium.org/
> [2] https://lore.kernel.org/linux-mediatek/20210709022324.1607884-1-eizan@chromium.org/
> 
> Change notes:
> v6: 1) rebase on v5.14-rc1.
>      2) Fix the issue commented in v5 from Dafna and Hsin-Yi.
>      3) Remove the patches about using pm_runtime_resume_and_get since they have
>         already been merged by other patches.
> 
> v5: https://lore.kernel.org/linux-mediatek/20210410091128.31823-1-yong.wu@mediatek.com/
>      1) Base v5.12-rc2.
>      2) Remove changing the mtk-iommu to module_platform_driver patch, It have already been a
>      independent patch.
> 
> v4: https://lore.kernel.org/linux-mediatek/1590826218-23653-1-git-send-email-yong.wu@mediatek.com/
>      base on v5.7-rc1.
>    1) Move drm PM patch before smi patchs.
>    2) Change builtin_platform_driver to module_platform_driver since we may need
>       build as module.
>    3) Rebase many patchset as above.
> 
> v3: https://lore.kernel.org/linux-iommu/1567503456-24725-1-git-send-email-yong.wu@mediatek.com/
>      1) rebase on v5.3-rc1 and the latest mt8183 patchset.
>      2) Use device_is_bound to check whether the driver is ready from Matthias.
>      3) Add DL_FLAG_STATELESS flag when calling device_link_add and explain the
>     reason in the commit message[3/14].
>      4) Add a display patch[12/14] into this series. otherwise it may affect
>     display HW fastlogo even though it don't happen in mt8183.
>     
> v2: https://lore.kernel.org/linux-iommu/1560171313-28299-1-git-send-email-yong.wu@mediatek.com/
>     1) rebase on v5.2-rc1.
>     2) Move adding device_link between the consumer and smi-larb into
> iommu_add_device from Robin.
>     3) add DL_FLAG_AUTOREMOVE_CONSUMER even though the smi is built-in from Evan.
>     4) Remove the shutdown callback in iommu.
> 
> v1: https://lore.kernel.org/linux-iommu/1546318276-18993-1-git-send-email-yong.wu@mediatek.com/
> 
> Yong Wu (10):
>    dt-binding: mediatek: Get rid of mediatek,larb for multimedia HW
>    iommu/mediatek: Add probe_defer for smi-larb
>    iommu/mediatek: Add device_link between the consumer and the larb
>      devices
>    media: mtk-jpeg: Get rid of mtk_smi_larb_get/put
>    media: mtk-mdp: Get rid of mtk_smi_larb_get/put
>    drm/mediatek: Get rid of mtk_smi_larb_get/put
>    media: mtk-vcodec: Get rid of mtk_smi_larb_get/put
>    memory: mtk-smi: Get rid of mtk_smi_larb_get/put
>    arm: dts: mediatek: Get rid of mediatek,larb for MM nodes
>    arm64: dts: mediatek: Get rid of mediatek,larb for MM nodes
> 
> Yongqiang Niu (1):
>    drm/mediatek: Add pm runtime support for ovl and rdma
> 
>   .../display/mediatek/mediatek,disp.txt        |  9 ----
>   .../bindings/media/mediatek-jpeg-decoder.yaml |  9 ----
>   .../bindings/media/mediatek-jpeg-encoder.yaml |  9 ----
>   .../bindings/media/mediatek-mdp.txt           |  8 ----
>   .../bindings/media/mediatek-vcodec.txt        |  4 --
>   arch/arm/boot/dts/mt2701.dtsi                 |  2 -
>   arch/arm/boot/dts/mt7623n.dtsi                |  5 --
>   arch/arm64/boot/dts/mediatek/mt8173.dtsi      | 16 -------
>   arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  6 ---
>   drivers/gpu/drm/mediatek/mtk_disp_ovl.c       |  9 +++-
>   drivers/gpu/drm/mediatek/mtk_disp_rdma.c      |  9 +++-
>   drivers/gpu/drm/mediatek/mtk_drm_crtc.c       | 19 ++++----
>   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   | 36 +--------------
>   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h   |  1 -
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c        |  5 +-
>   drivers/iommu/mtk_iommu.c                     | 24 +++++++++-
>   drivers/iommu/mtk_iommu_v1.c                  | 22 ++++++++-
>   .../media/platform/mtk-jpeg/mtk_jpeg_core.c   | 45 +-----------------
>   .../media/platform/mtk-jpeg/mtk_jpeg_core.h   |  2 -
>   drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 46 +------------------
>   drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |  2 -
>   drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  1 -
>   .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 37 ++-------------
>   .../platform/mtk-vcodec/mtk_vcodec_drv.h      |  3 --
>   .../platform/mtk-vcodec/mtk_vcodec_enc.c      |  1 -
>   .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   | 44 ++----------------
>   drivers/memory/mtk-smi.c                      | 14 ------
>   include/soc/mediatek/smi.h                    | 20 --------
>   28 files changed, 85 insertions(+), 323 deletions(-)
>
Frank Wunderlich July 14, 2021, 8:59 a.m. UTC | #2
Hi,

sorry this (or the 2 depency-series) cause a NULL Pointer deref in iommu_group_remove_device on mt7623/bpi-r2

i wonder why on bootup a cleanup is run, but have no hint about this.

since "dts: mtk-mdp: remove mediatek, vpu property from primary MDP device" all is good, i guess problem comes up while removing larb with DT

this is backtrace

[    6.274465] PC is at iommu_group_remove_device+0x28/0x148
[    6.279877] LR is at iommu_release_device+0x4c/0x70

[    6.674347] Backtrace:
[    6.676797] [<c0c9c37c>] (iommu_group_remove_device) from [<c06bf028>] (iomm)
[    6.686221]  r7:00000000 r6:c06bf04c r5:c0d7a1ac r4:c21fc010
[    6.691883] [<c06befdc>] (iommu_release_device) from [<c06bf064>] (remove_io)
[    6.700689]  r5:00000000 r4:00000000
[    6.704265] [<c06bf04c>] (remove_iommu_group) from [<c0733434>] (bus_for_eac)
[    6.712725] [<c07333ac>] (bus_for_each_dev) from [<c06bf658>] (bus_set_iommu)
[    6.720753]  r6:c331f440 r5:c1406f58 r4:ffffffea
[    6.725370] [<c06bf5a0>] (bus_set_iommu) from [<c06c1e88>] (mtk_iommu_probe+)
[    6.733484]  r7:c32db0b8 r6:c21f9c00 r5:c331f1c0 r4:00000000
[    6.739145] [<c06c1bfc>] (mtk_iommu_probe) from [<c0738c14>] (platform_probe)
[    6.747176]  r10:c21f9c10 r9:c2496f54 r8:c14623b8 r7:c14623b8 r6:c1405b90 r50
[    6.755012]  r4:00000000
[    6.757544] [<c0738ba8>] (platform_probe) from [<c0735968>] (really_probe.pa)
[    6.766006]  r7:c14623b8 r6:c1405b90 r5:00000000 r4:c21f9c10
[    6.771667] [<c07358a0>] (really_probe.part.0) from [<c0735cec>] (really_pro)
[    6.779866]  r7:c21f9c10 r6:c2549e74 r5:c1405b90 r4:c21f9c10
[    6.785527] [<c0735ca4>] (really_probe) from [<c0735de0>] (__driver_probe_de)
[    6.793984]  r5:c1405b90 r4:c21f9c10
[    6.797560] [<c0735d30>] (__driver_probe_device) from [<c0735fa0>] (driver_p)
[    6.806543]  r9:c2496f54 r8:00000008 r7:c21f9c10 r6:c2549e74 r5:c14c6ec8 r4:4
[    6.814291] [<c0735f5c>] (driver_probe_device) from [<c0736410>] (__device_a)
[    6.823448]  r9:c2496f54 r8:00000000 r7:c21f9c10 r6:c2549e74 r5:c1405b90 r4:1
[    6.831196] [<c073635c>] (__device_attach_driver) from [<c0733540>] (bus_for)
[    6.840007]  r7:c14623b8 r6:c073635c r5:c2549e74 r4:00000000
[    6.845669] [<c07334ac>] (bus_for_each_drv) from [<c07357e8>] (__device_atta)
[    6.854044]  r6:00000001 r5:c21f9c54 r4:c21f9c10
[    6.858662] [<c07356e4>] (__device_attach) from [<c073662c>] (device_initial)
[    6.867207]  r6:c21f9c10 r5:c1406f58 r4:c1406ca0
[    6.871825] [<c0736610>] (device_initial_probe) from [<c07346dc>] (bus_probe)
[    6.880454] [<c0734648>] (bus_probe_device) from [<c0734cc8>] (deferred_prob)


bisect shows this commit as breaking:

Author: Yong Wu <yong.wu@mediatek.com>
Date:   Wed Jul 14 10:56:17 2021 +0800

    iommu/mediatek: Add probe_defer for smi-larb

    Prepare for adding device_link.

regards Frank
Yong Wu (吴勇) July 14, 2021, 11:18 a.m. UTC | #3
On Wed, 2021-07-14 at 10:56 +0200, Dafna Hirschfeld wrote:
> Hi
> 
> Thanks for the patchset.
> 
> I tested it on mt8173 (elm) with chromeos userspace.
> Before that patchset, the test:
> 
> tast -verbose run -build=false 10.42.0.175 video.DecodeAccel.h264
> 
> sometimes passed and sometimes failed with 'context deadline exceeded'.
> With this patchset it seems that the test always passes so I added tested-by:
> 
> Tested-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>

Thanks very much for your quick review and testing:)

> 
> Thanks,
> Dafna
> 
> 
> 
> 
> On 14.07.21 04:56, Yong Wu wrote:
> > MediaTek IOMMU block diagram always like below:
> > 
> >          M4U
> >           |
> >      smi-common
> >           |
> >    -------------
> >    |         |  ...
> >    |         |
> > larb1     larb2
> >    |         |
> > vdec       venc
> > 
> > All the consumer connect with smi-larb, then connect with smi-common.
> > 
> > When the consumer works, it should enable the smi-larb's power which also
> > need enable the smi-common's power firstly.
> > 
> > Thus, Firstly, use the device link connect the consumer and the
> > smi-larbs. then add device link between the smi-larb and smi-common.
> > 
> > After adding the device_link, then "mediatek,larb" property can be removed.
> > the iommu consumer don't need call the mtk_smi_larb_get/put to enable
> > the power and clock of smi-larb and smi-common.
> > 
> > About the MM dt-binding/dtsi patches, I guess they should go together, thus
> > I don't split them for each a MM module and each a SoC.
> > 
> > Base on v5.14-rc1, and a jpeg[1] and mdp[2] patchset.
> > 
> > [1] https://lore.kernel.org/linux-mediatek/20210702102304.3346429-1-hsinyi@chromium.org/
> > [2] https://lore.kernel.org/linux-mediatek/20210709022324.1607884-1-eizan@chromium.org/
> > 
> > Change notes:
> > v6: 1) rebase on v5.14-rc1.
> >      2) Fix the issue commented in v5 from Dafna and Hsin-Yi.
> >      3) Remove the patches about using pm_runtime_resume_and_get since they have
> >         already been merged by other patches.
> > 
> > v5: https://lore.kernel.org/linux-mediatek/20210410091128.31823-1-yong.wu@mediatek.com/
> >      1) Base v5.12-rc2.
> >      2) Remove changing the mtk-iommu to module_platform_driver patch, It have already been a
> >      independent patch.
> > 
> > v4: https://lore.kernel.org/linux-mediatek/1590826218-23653-1-git-send-email-yong.wu@mediatek.com/
> >      base on v5.7-rc1.
> >    1) Move drm PM patch before smi patchs.
> >    2) Change builtin_platform_driver to module_platform_driver since we may need
> >       build as module.
> >    3) Rebase many patchset as above.
> > 
> > v3: https://lore.kernel.org/linux-iommu/1567503456-24725-1-git-send-email-yong.wu@mediatek.com/
> >      1) rebase on v5.3-rc1 and the latest mt8183 patchset.
> >      2) Use device_is_bound to check whether the driver is ready from Matthias.
> >      3) Add DL_FLAG_STATELESS flag when calling device_link_add and explain the
> >     reason in the commit message[3/14].
> >      4) Add a display patch[12/14] into this series. otherwise it may affect
> >     display HW fastlogo even though it don't happen in mt8183.
> >     
> > v2: https://lore.kernel.org/linux-iommu/1560171313-28299-1-git-send-email-yong.wu@mediatek.com/
> >     1) rebase on v5.2-rc1.
> >     2) Move adding device_link between the consumer and smi-larb into
> > iommu_add_device from Robin.
> >     3) add DL_FLAG_AUTOREMOVE_CONSUMER even though the smi is built-in from Evan.
> >     4) Remove the shutdown callback in iommu.
> > 
> > v1: https://lore.kernel.org/linux-iommu/1546318276-18993-1-git-send-email-yong.wu@mediatek.com/
> > 
> > Yong Wu (10):
> >    dt-binding: mediatek: Get rid of mediatek,larb for multimedia HW
> >    iommu/mediatek: Add probe_defer for smi-larb
> >    iommu/mediatek: Add device_link between the consumer and the larb
> >      devices
> >    media: mtk-jpeg: Get rid of mtk_smi_larb_get/put
> >    media: mtk-mdp: Get rid of mtk_smi_larb_get/put
> >    drm/mediatek: Get rid of mtk_smi_larb_get/put
> >    media: mtk-vcodec: Get rid of mtk_smi_larb_get/put
> >    memory: mtk-smi: Get rid of mtk_smi_larb_get/put
> >    arm: dts: mediatek: Get rid of mediatek,larb for MM nodes
> >    arm64: dts: mediatek: Get rid of mediatek,larb for MM nodes
> > 
> > Yongqiang Niu (1):
> >    drm/mediatek: Add pm runtime support for ovl and rdma
> > 
> >   .../display/mediatek/mediatek,disp.txt        |  9 ----
> >   .../bindings/media/mediatek-jpeg-decoder.yaml |  9 ----
> >   .../bindings/media/mediatek-jpeg-encoder.yaml |  9 ----
> >   .../bindings/media/mediatek-mdp.txt           |  8 ----
> >   .../bindings/media/mediatek-vcodec.txt        |  4 --
> >   arch/arm/boot/dts/mt2701.dtsi                 |  2 -
> >   arch/arm/boot/dts/mt7623n.dtsi                |  5 --
> >   arch/arm64/boot/dts/mediatek/mt8173.dtsi      | 16 -------
> >   arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  6 ---
> >   drivers/gpu/drm/mediatek/mtk_disp_ovl.c       |  9 +++-
> >   drivers/gpu/drm/mediatek/mtk_disp_rdma.c      |  9 +++-
> >   drivers/gpu/drm/mediatek/mtk_drm_crtc.c       | 19 ++++----
> >   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c   | 36 +--------------
> >   drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h   |  1 -
> >   drivers/gpu/drm/mediatek/mtk_drm_drv.c        |  5 +-
> >   drivers/iommu/mtk_iommu.c                     | 24 +++++++++-
> >   drivers/iommu/mtk_iommu_v1.c                  | 22 ++++++++-
> >   .../media/platform/mtk-jpeg/mtk_jpeg_core.c   | 45 +-----------------
> >   .../media/platform/mtk-jpeg/mtk_jpeg_core.h   |  2 -
> >   drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 46 +------------------
> >   drivers/media/platform/mtk-mdp/mtk_mdp_comp.h |  2 -
> >   drivers/media/platform/mtk-mdp/mtk_mdp_core.c |  1 -
> >   .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 37 ++-------------
> >   .../platform/mtk-vcodec/mtk_vcodec_drv.h      |  3 --
> >   .../platform/mtk-vcodec/mtk_vcodec_enc.c      |  1 -
> >   .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   | 44 ++----------------
> >   drivers/memory/mtk-smi.c                      | 14 ------
> >   include/soc/mediatek/smi.h                    | 20 --------
> >   28 files changed, 85 insertions(+), 323 deletions(-)
> >
Yong Wu (吴勇) July 14, 2021, 11:18 a.m. UTC | #4
On Wed, 2021-07-14 at 10:59 +0200, Frank Wunderlich wrote:
> Hi,
> 
> sorry this (or the 2 depency-series) cause a NULL Pointer deref in iommu_group_remove_device on mt7623/bpi-r2

Hi Frank,

Thanks for your report. mt7623 use mtk_iommu_v1.c.

I will try to reproduce this locally.

> 
> i wonder why on bootup a cleanup is run, but have no hint about this.
> 
> since "dts: mtk-mdp: remove mediatek, vpu property from primary MDP device" all is good, i guess problem comes up while removing larb with DT
> 
> this is backtrace
> 
> [    6.274465] PC is at iommu_group_remove_device+0x28/0x148
> [    6.279877] LR is at iommu_release_device+0x4c/0x70
> 
> [    6.674347] Backtrace:
> [    6.676797] [<c0c9c37c>] (iommu_group_remove_device) from [<c06bf028>] (iomm)
> [    6.686221]  r7:00000000 r6:c06bf04c r5:c0d7a1ac r4:c21fc010
> [    6.691883] [<c06befdc>] (iommu_release_device) from [<c06bf064>] (remove_io)
> [    6.700689]  r5:00000000 r4:00000000
> [    6.704265] [<c06bf04c>] (remove_iommu_group) from [<c0733434>] (bus_for_eac)
> [    6.712725] [<c07333ac>] (bus_for_each_dev) from [<c06bf658>] (bus_set_iommu)
> [    6.720753]  r6:c331f440 r5:c1406f58 r4:ffffffea
> [    6.725370] [<c06bf5a0>] (bus_set_iommu) from [<c06c1e88>] (mtk_iommu_probe+)
> [    6.733484]  r7:c32db0b8 r6:c21f9c00 r5:c331f1c0 r4:00000000
> [    6.739145] [<c06c1bfc>] (mtk_iommu_probe) from [<c0738c14>] (platform_probe)
> [    6.747176]  r10:c21f9c10 r9:c2496f54 r8:c14623b8 r7:c14623b8 r6:c1405b90 r50
> [    6.755012]  r4:00000000
> [    6.757544] [<c0738ba8>] (platform_probe) from [<c0735968>] (really_probe.pa)
> [    6.766006]  r7:c14623b8 r6:c1405b90 r5:00000000 r4:c21f9c10
> [    6.771667] [<c07358a0>] (really_probe.part.0) from [<c0735cec>] (really_pro)
> [    6.779866]  r7:c21f9c10 r6:c2549e74 r5:c1405b90 r4:c21f9c10
> [    6.785527] [<c0735ca4>] (really_probe) from [<c0735de0>] (__driver_probe_de)
> [    6.793984]  r5:c1405b90 r4:c21f9c10
> [    6.797560] [<c0735d30>] (__driver_probe_device) from [<c0735fa0>] (driver_p)
> [    6.806543]  r9:c2496f54 r8:00000008 r7:c21f9c10 r6:c2549e74 r5:c14c6ec8 r4:4
> [    6.814291] [<c0735f5c>] (driver_probe_device) from [<c0736410>] (__device_a)
> [    6.823448]  r9:c2496f54 r8:00000000 r7:c21f9c10 r6:c2549e74 r5:c1405b90 r4:1
> [    6.831196] [<c073635c>] (__device_attach_driver) from [<c0733540>] (bus_for)
> [    6.840007]  r7:c14623b8 r6:c073635c r5:c2549e74 r4:00000000
> [    6.845669] [<c07334ac>] (bus_for_each_drv) from [<c07357e8>] (__device_atta)
> [    6.854044]  r6:00000001 r5:c21f9c54 r4:c21f9c10
> [    6.858662] [<c07356e4>] (__device_attach) from [<c073662c>] (device_initial)
> [    6.867207]  r6:c21f9c10 r5:c1406f58 r4:c1406ca0
> [    6.871825] [<c0736610>] (device_initial_probe) from [<c07346dc>] (bus_probe)
> [    6.880454] [<c0734648>] (bus_probe_device) from [<c0734cc8>] (deferred_prob)
> 
> 
> bisect shows this commit as breaking:
> 
> Author: Yong Wu <yong.wu@mediatek.com>
> Date:   Wed Jul 14 10:56:17 2021 +0800
> 
>     iommu/mediatek: Add probe_defer for smi-larb
> 
>     Prepare for adding device_link.
> 
> regards Frank
Frank Wunderlich July 14, 2021, 11:23 a.m. UTC | #5
> Gesendet: Mittwoch, 14. Juli 2021 um 13:18 Uhr
> Von: "Yong Wu" <yong.wu@mediatek.com>
> Hi Frank,
>
> Thanks for your report. mt7623 use mtk_iommu_v1.c.
>
> I will try to reproduce this locally.

Hi,

as far as i have debugged it dev->iommu_group is NULL, so it crashes on first access (dev_info)

drivers/iommu/iommu.c:

 923 void iommu_group_remove_device(struct device *dev)
 924 {
 925 printk(KERN_ALERT "DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
 926     struct iommu_group *group = dev->iommu_group;
 927     struct group_device *tmp_device, *device = NULL;
 928
 929 printk(KERN_ALERT "DEBUG: Passed %s %d 0x%08x\n",__FUNCTION__,__LINE__,(unsigned int)group);
 930     dev_info(dev, "Removing from iommu group %d\n", group->id);


regards Frank