All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/59] devm_drm_dev_alloc, v2
@ 2020-04-15  7:39 ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

Hi all,

Here's the next round of devm_drm_dev_alloc. Big changes:

- lots of acks, reviews and some testing tags. Very much appreciated!

- I dropped the core driver patch, and hence also the patches for vgem,
  vkms and i915-selftests. That needs more discussions first.

- I started to convert some of the other drivers that still used
  drm_dev_alloc to the shiny new world, with a pile of cleanups on top. So
  lots more patches to test and review.

Looking at git grep output for drm_dev_alloc() I think there's enough room
for another few similarly sized patch series. I'm kinda using that also to
survey the state of drivers, so I have a good idea what drmm_ versions for
various modeset objects should look like. Atm still not sure how to best
approach this, with the mix of drivers we do have: Some use devm_kzalloc,
some explicit kzalloc + kfree in cleanup code, some embedded it somewhere
else.

As usual, review, testing and comments very much appreciated.

Cheers, Daniel

Daniel Vetter (59):
  drm: Add devm_drm_dev_alloc macro
  drm/vboxvideo: drop DRM_MTRR_WC #define
  drm/vboxvideo: Use devm_drm_dev_alloc
  drm/vboxvideo: Stop using drm_device->dev_private
  drm/vboxvidoe: use managed pci functions
  drm/vboxvideo: Use devm_gen_pool_create
  drm/v3d: Don't set drm_device->dev_private
  drm/v3d: Use devm_drm_dev_alloc
  drm/v3d: Delete v3d_dev->dev
  drm/v3d: Delete v3d_dev->pdev
  drm/udl: Use devm_drm_dev_alloc
  drm/udl: don't set drm_device->dev_private
  drm/st7735r: Use devm_drm_dev_alloc
  drm/st7586: Use devm_drm_dev_alloc
  drm/repaper: Use devm_drm_dev_alloc
  drm/mi0283qt: Use devm_drm_dev_alloc
  drm/ili9486: Use devm_drm_dev_alloc
  drm/ili9341: Use devm_drm_dev_alloc
  drm/ili9225: Use devm_drm_dev_alloc
  drm/hx8357d: Use devm_drm_dev_alloc
  drm/gm12u320: Use devm_drm_dev_alloc
  drm/gm12u320: Don't use drm_device->dev_private
  drm/tidss: Use devm_drm_dev_alloc
  drm/tidss: Don't use drm_device->dev_private
  drm/tidss: Delete tidss->saved_state
  drm/qxl: Use devm_drm_dev_alloc
  drm/qxl: Don't use drm_device->dev_private
  drm/mcde: Use devm_drm_dev_alloc
  drm/mcde: Don't use drm_device->dev_private
  drm/ingenic: Use devm_drm_dev_alloc
  drm/ingenic: Don't set drm_device->dev_private
  drm/komeda: use devm_drm_dev_alloc
  drm/armada: Use devm_drm_dev_alloc
  drm/armada: Don't use drm_device->dev_private
  drm/cirrus: Use devm_drm_dev_alloc
  drm/cirrus: Don't use drm_device->dev_private
  drm/cirrus: Move to drm/tiny
  drm/i915: Use devm_drm_dev_alloc
  drm/arcpgu: Switch to devm_drm_dev_alloc
  drm/arcpgu: Stop using drm_device->dev_private
  drm/arcpgu: Delete arcpgu_priv->fb
  drm/arc: Embedded a drm_simple_display_pipe
  drm/arc: Embedd a drm_connector for sim case
  drm/arc: Drop surplus connector registration
  drm/arc: Use drmm_mode_config_cleanup
  drm/arc: Align with simple pipe helpers
  drm/arc: Convert to drm_simple_kms_pipe_helper
  drm/arc: Drop fb/crtc check in arc_pgu_update
  drm/arc: Inline arcpgu_crtc.c
  drm/arc: Inline arcpgu_drm_hdmi_init
  drm/arc: Inline remaining files
  drm/arc: Initialize sim connector before display pipe
  drm/arc: Move to drm/tiny
  drm/aspeed: Drop aspeed_gfx->fbdev
  drm/aspeed: Use devm_drm_dev_alloc
  drm/aspeed: Use managed drmm_mode_config_cleanup
  drm/ast: Use managed pci functions
  drm/ast: Drop explicit connector register/unregister
  drm/bochs: Remove explicit drm_connector_register

 MAINTAINERS                                   |   4 +-
 drivers/gpu/drm/Kconfig                       |   4 -
 drivers/gpu/drm/Makefile                      |   2 -
 drivers/gpu/drm/arc/Kconfig                   |  10 -
 drivers/gpu/drm/arc/Makefile                  |   3 -
 drivers/gpu/drm/arc/arcpgu.h                  |  37 --
 drivers/gpu/drm/arc/arcpgu_crtc.c             | 222 ---------
 drivers/gpu/drm/arc/arcpgu_drv.c              | 234 ---------
 drivers/gpu/drm/arc/arcpgu_hdmi.c             |  48 --
 drivers/gpu/drm/arc/arcpgu_regs.h             |  31 --
 drivers/gpu/drm/arc/arcpgu_sim.c              | 108 -----
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |  16 +-
 drivers/gpu/drm/armada/armada_crtc.c          |   4 +-
 drivers/gpu/drm/armada/armada_debugfs.c       |   2 +-
 drivers/gpu/drm/armada/armada_drm.h           |   2 +
 drivers/gpu/drm/armada/armada_drv.c           |  30 +-
 drivers/gpu/drm/armada/armada_fbdev.c         |   4 +-
 drivers/gpu/drm/armada/armada_gem.c           |   4 +-
 drivers/gpu/drm/armada/armada_overlay.c       |   8 +-
 drivers/gpu/drm/aspeed/aspeed_gfx.h           |   3 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c      |   2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c       |  42 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c       |   2 +-
 drivers/gpu/drm/ast/ast_drv.c                 |  10 +-
 drivers/gpu/drm/ast/ast_main.c                |   3 -
 drivers/gpu/drm/ast/ast_mode.c                |   3 -
 drivers/gpu/drm/bochs/bochs_kms.c             |   1 -
 drivers/gpu/drm/cirrus/Kconfig                |  19 -
 drivers/gpu/drm/cirrus/Makefile               |   2 -
 drivers/gpu/drm/drm_drv.c                     |  23 +
 drivers/gpu/drm/i915/i915_drv.c               |  17 +-
 drivers/gpu/drm/i915/i915_pci.c               |   2 -
 drivers/gpu/drm/ingenic/ingenic-drm.c         |  15 +-
 drivers/gpu/drm/mcde/mcde_display.c           |  10 +-
 drivers/gpu/drm/mcde/mcde_drm.h               |   2 +
 drivers/gpu/drm/mcde/mcde_drv.c               |  21 +-
 drivers/gpu/drm/mcde/mcde_dsi.c               |   2 +-
 drivers/gpu/drm/qxl/qxl_debugfs.c             |   7 +-
 drivers/gpu/drm/qxl/qxl_display.c             |  32 +-
 drivers/gpu/drm/qxl/qxl_drv.c                 |  23 +-
 drivers/gpu/drm/qxl/qxl_drv.h                 |   7 +-
 drivers/gpu/drm/qxl/qxl_dumb.c                |   2 +-
 drivers/gpu/drm/qxl/qxl_gem.c                 |   2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c               |  14 +-
 drivers/gpu/drm/qxl/qxl_irq.c                 |   2 +-
 drivers/gpu/drm/qxl/qxl_kms.c                 |  13 +-
 drivers/gpu/drm/qxl/qxl_object.c              |   2 +-
 drivers/gpu/drm/qxl/qxl_release.c             |   2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c                 |   2 +-
 drivers/gpu/drm/tidss/tidss_crtc.c            |  16 +-
 drivers/gpu/drm/tidss/tidss_drv.c             |  17 +-
 drivers/gpu/drm/tidss/tidss_drv.h             |   4 +-
 drivers/gpu/drm/tidss/tidss_irq.c             |  12 +-
 drivers/gpu/drm/tidss/tidss_kms.c             |   2 +-
 drivers/gpu/drm/tidss/tidss_plane.c           |   6 +-
 drivers/gpu/drm/tiny/Kconfig                  |  29 ++
 drivers/gpu/drm/tiny/Makefile                 |   2 +
 drivers/gpu/drm/tiny/arcpgu.c                 | 450 ++++++++++++++++++
 drivers/gpu/drm/{cirrus => tiny}/cirrus.c     |  22 +-
 drivers/gpu/drm/tiny/gm12u320.c               |  24 +-
 drivers/gpu/drm/tiny/hx8357d.c                |  13 +-
 drivers/gpu/drm/tiny/ili9225.c                |  13 +-
 drivers/gpu/drm/tiny/ili9341.c                |  13 +-
 drivers/gpu/drm/tiny/ili9486.c                |  13 +-
 drivers/gpu/drm/tiny/mi0283qt.c               |  13 +-
 drivers/gpu/drm/tiny/repaper.c                |  14 +-
 drivers/gpu/drm/tiny/st7586.c                 |  13 +-
 drivers/gpu/drm/tiny/st7735r.c                |  13 +-
 drivers/gpu/drm/udl/udl_connector.c           |   4 +-
 drivers/gpu/drm/udl/udl_drv.c                 |  27 +-
 drivers/gpu/drm/udl/udl_modeset.c             |   6 +-
 drivers/gpu/drm/v3d/v3d_debugfs.c             |  12 +-
 drivers/gpu/drm/v3d/v3d_drv.c                 |  47 +-
 drivers/gpu/drm/v3d/v3d_drv.h                 |   7 +-
 drivers/gpu/drm/v3d/v3d_gem.c                 |  17 +-
 drivers/gpu/drm/v3d/v3d_irq.c                 |  16 +-
 drivers/gpu/drm/v3d/v3d_mmu.c                 |  10 +-
 drivers/gpu/drm/v3d/v3d_sched.c               |  10 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.c          |  26 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.h          |   1 +
 drivers/gpu/drm/vboxvideo/vbox_irq.c          |   2 +-
 drivers/gpu/drm/vboxvideo/vbox_main.c         |  29 +-
 drivers/gpu/drm/vboxvideo/vbox_mode.c         |  10 +-
 drivers/gpu/drm/vboxvideo/vbox_ttm.c          |  12 -
 include/drm/drm_drv.h                         |  33 ++
 85 files changed, 822 insertions(+), 1196 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/Kconfig
 delete mode 100644 drivers/gpu/drm/arc/Makefile
 delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_drv.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c
 delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
 delete mode 100644 drivers/gpu/drm/cirrus/Makefile
 create mode 100644 drivers/gpu/drm/tiny/arcpgu.c
 rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (97%)

-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 00/59] devm_drm_dev_alloc, v2
@ 2020-04-15  7:39 ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

Hi all,

Here's the next round of devm_drm_dev_alloc. Big changes:

- lots of acks, reviews and some testing tags. Very much appreciated!

- I dropped the core driver patch, and hence also the patches for vgem,
  vkms and i915-selftests. That needs more discussions first.

- I started to convert some of the other drivers that still used
  drm_dev_alloc to the shiny new world, with a pile of cleanups on top. So
  lots more patches to test and review.

Looking at git grep output for drm_dev_alloc() I think there's enough room
for another few similarly sized patch series. I'm kinda using that also to
survey the state of drivers, so I have a good idea what drmm_ versions for
various modeset objects should look like. Atm still not sure how to best
approach this, with the mix of drivers we do have: Some use devm_kzalloc,
some explicit kzalloc + kfree in cleanup code, some embedded it somewhere
else.

As usual, review, testing and comments very much appreciated.

Cheers, Daniel

Daniel Vetter (59):
  drm: Add devm_drm_dev_alloc macro
  drm/vboxvideo: drop DRM_MTRR_WC #define
  drm/vboxvideo: Use devm_drm_dev_alloc
  drm/vboxvideo: Stop using drm_device->dev_private
  drm/vboxvidoe: use managed pci functions
  drm/vboxvideo: Use devm_gen_pool_create
  drm/v3d: Don't set drm_device->dev_private
  drm/v3d: Use devm_drm_dev_alloc
  drm/v3d: Delete v3d_dev->dev
  drm/v3d: Delete v3d_dev->pdev
  drm/udl: Use devm_drm_dev_alloc
  drm/udl: don't set drm_device->dev_private
  drm/st7735r: Use devm_drm_dev_alloc
  drm/st7586: Use devm_drm_dev_alloc
  drm/repaper: Use devm_drm_dev_alloc
  drm/mi0283qt: Use devm_drm_dev_alloc
  drm/ili9486: Use devm_drm_dev_alloc
  drm/ili9341: Use devm_drm_dev_alloc
  drm/ili9225: Use devm_drm_dev_alloc
  drm/hx8357d: Use devm_drm_dev_alloc
  drm/gm12u320: Use devm_drm_dev_alloc
  drm/gm12u320: Don't use drm_device->dev_private
  drm/tidss: Use devm_drm_dev_alloc
  drm/tidss: Don't use drm_device->dev_private
  drm/tidss: Delete tidss->saved_state
  drm/qxl: Use devm_drm_dev_alloc
  drm/qxl: Don't use drm_device->dev_private
  drm/mcde: Use devm_drm_dev_alloc
  drm/mcde: Don't use drm_device->dev_private
  drm/ingenic: Use devm_drm_dev_alloc
  drm/ingenic: Don't set drm_device->dev_private
  drm/komeda: use devm_drm_dev_alloc
  drm/armada: Use devm_drm_dev_alloc
  drm/armada: Don't use drm_device->dev_private
  drm/cirrus: Use devm_drm_dev_alloc
  drm/cirrus: Don't use drm_device->dev_private
  drm/cirrus: Move to drm/tiny
  drm/i915: Use devm_drm_dev_alloc
  drm/arcpgu: Switch to devm_drm_dev_alloc
  drm/arcpgu: Stop using drm_device->dev_private
  drm/arcpgu: Delete arcpgu_priv->fb
  drm/arc: Embedded a drm_simple_display_pipe
  drm/arc: Embedd a drm_connector for sim case
  drm/arc: Drop surplus connector registration
  drm/arc: Use drmm_mode_config_cleanup
  drm/arc: Align with simple pipe helpers
  drm/arc: Convert to drm_simple_kms_pipe_helper
  drm/arc: Drop fb/crtc check in arc_pgu_update
  drm/arc: Inline arcpgu_crtc.c
  drm/arc: Inline arcpgu_drm_hdmi_init
  drm/arc: Inline remaining files
  drm/arc: Initialize sim connector before display pipe
  drm/arc: Move to drm/tiny
  drm/aspeed: Drop aspeed_gfx->fbdev
  drm/aspeed: Use devm_drm_dev_alloc
  drm/aspeed: Use managed drmm_mode_config_cleanup
  drm/ast: Use managed pci functions
  drm/ast: Drop explicit connector register/unregister
  drm/bochs: Remove explicit drm_connector_register

 MAINTAINERS                                   |   4 +-
 drivers/gpu/drm/Kconfig                       |   4 -
 drivers/gpu/drm/Makefile                      |   2 -
 drivers/gpu/drm/arc/Kconfig                   |  10 -
 drivers/gpu/drm/arc/Makefile                  |   3 -
 drivers/gpu/drm/arc/arcpgu.h                  |  37 --
 drivers/gpu/drm/arc/arcpgu_crtc.c             | 222 ---------
 drivers/gpu/drm/arc/arcpgu_drv.c              | 234 ---------
 drivers/gpu/drm/arc/arcpgu_hdmi.c             |  48 --
 drivers/gpu/drm/arc/arcpgu_regs.h             |  31 --
 drivers/gpu/drm/arc/arcpgu_sim.c              | 108 -----
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |  16 +-
 drivers/gpu/drm/armada/armada_crtc.c          |   4 +-
 drivers/gpu/drm/armada/armada_debugfs.c       |   2 +-
 drivers/gpu/drm/armada/armada_drm.h           |   2 +
 drivers/gpu/drm/armada/armada_drv.c           |  30 +-
 drivers/gpu/drm/armada/armada_fbdev.c         |   4 +-
 drivers/gpu/drm/armada/armada_gem.c           |   4 +-
 drivers/gpu/drm/armada/armada_overlay.c       |   8 +-
 drivers/gpu/drm/aspeed/aspeed_gfx.h           |   3 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c      |   2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c       |  42 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c       |   2 +-
 drivers/gpu/drm/ast/ast_drv.c                 |  10 +-
 drivers/gpu/drm/ast/ast_main.c                |   3 -
 drivers/gpu/drm/ast/ast_mode.c                |   3 -
 drivers/gpu/drm/bochs/bochs_kms.c             |   1 -
 drivers/gpu/drm/cirrus/Kconfig                |  19 -
 drivers/gpu/drm/cirrus/Makefile               |   2 -
 drivers/gpu/drm/drm_drv.c                     |  23 +
 drivers/gpu/drm/i915/i915_drv.c               |  17 +-
 drivers/gpu/drm/i915/i915_pci.c               |   2 -
 drivers/gpu/drm/ingenic/ingenic-drm.c         |  15 +-
 drivers/gpu/drm/mcde/mcde_display.c           |  10 +-
 drivers/gpu/drm/mcde/mcde_drm.h               |   2 +
 drivers/gpu/drm/mcde/mcde_drv.c               |  21 +-
 drivers/gpu/drm/mcde/mcde_dsi.c               |   2 +-
 drivers/gpu/drm/qxl/qxl_debugfs.c             |   7 +-
 drivers/gpu/drm/qxl/qxl_display.c             |  32 +-
 drivers/gpu/drm/qxl/qxl_drv.c                 |  23 +-
 drivers/gpu/drm/qxl/qxl_drv.h                 |   7 +-
 drivers/gpu/drm/qxl/qxl_dumb.c                |   2 +-
 drivers/gpu/drm/qxl/qxl_gem.c                 |   2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c               |  14 +-
 drivers/gpu/drm/qxl/qxl_irq.c                 |   2 +-
 drivers/gpu/drm/qxl/qxl_kms.c                 |  13 +-
 drivers/gpu/drm/qxl/qxl_object.c              |   2 +-
 drivers/gpu/drm/qxl/qxl_release.c             |   2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c                 |   2 +-
 drivers/gpu/drm/tidss/tidss_crtc.c            |  16 +-
 drivers/gpu/drm/tidss/tidss_drv.c             |  17 +-
 drivers/gpu/drm/tidss/tidss_drv.h             |   4 +-
 drivers/gpu/drm/tidss/tidss_irq.c             |  12 +-
 drivers/gpu/drm/tidss/tidss_kms.c             |   2 +-
 drivers/gpu/drm/tidss/tidss_plane.c           |   6 +-
 drivers/gpu/drm/tiny/Kconfig                  |  29 ++
 drivers/gpu/drm/tiny/Makefile                 |   2 +
 drivers/gpu/drm/tiny/arcpgu.c                 | 450 ++++++++++++++++++
 drivers/gpu/drm/{cirrus => tiny}/cirrus.c     |  22 +-
 drivers/gpu/drm/tiny/gm12u320.c               |  24 +-
 drivers/gpu/drm/tiny/hx8357d.c                |  13 +-
 drivers/gpu/drm/tiny/ili9225.c                |  13 +-
 drivers/gpu/drm/tiny/ili9341.c                |  13 +-
 drivers/gpu/drm/tiny/ili9486.c                |  13 +-
 drivers/gpu/drm/tiny/mi0283qt.c               |  13 +-
 drivers/gpu/drm/tiny/repaper.c                |  14 +-
 drivers/gpu/drm/tiny/st7586.c                 |  13 +-
 drivers/gpu/drm/tiny/st7735r.c                |  13 +-
 drivers/gpu/drm/udl/udl_connector.c           |   4 +-
 drivers/gpu/drm/udl/udl_drv.c                 |  27 +-
 drivers/gpu/drm/udl/udl_modeset.c             |   6 +-
 drivers/gpu/drm/v3d/v3d_debugfs.c             |  12 +-
 drivers/gpu/drm/v3d/v3d_drv.c                 |  47 +-
 drivers/gpu/drm/v3d/v3d_drv.h                 |   7 +-
 drivers/gpu/drm/v3d/v3d_gem.c                 |  17 +-
 drivers/gpu/drm/v3d/v3d_irq.c                 |  16 +-
 drivers/gpu/drm/v3d/v3d_mmu.c                 |  10 +-
 drivers/gpu/drm/v3d/v3d_sched.c               |  10 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.c          |  26 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.h          |   1 +
 drivers/gpu/drm/vboxvideo/vbox_irq.c          |   2 +-
 drivers/gpu/drm/vboxvideo/vbox_main.c         |  29 +-
 drivers/gpu/drm/vboxvideo/vbox_mode.c         |  10 +-
 drivers/gpu/drm/vboxvideo/vbox_ttm.c          |  12 -
 include/drm/drm_drv.h                         |  33 ++
 85 files changed, 822 insertions(+), 1196 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/Kconfig
 delete mode 100644 drivers/gpu/drm/arc/Makefile
 delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_drv.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c
 delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
 delete mode 100644 drivers/gpu/drm/cirrus/Makefile
 create mode 100644 drivers/gpu/drm/tiny/arcpgu.c
 rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (97%)

-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Paul Kocialkowski,
	Laurent Pinchart, Daniel Vetter, Sam Ravnborg

Add a new macro helper to combine the usual init sequence in drivers,
consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
triplet. This allows us to remove the rather unsightly
drmm_add_final_kfree from all currently merged drivers.

The kerneldoc is only added for this new function. Existing kerneldoc
and examples will be udated at the very end, since once all drivers
are converted over to devm_drm_dev_alloc we can unexport a lot of
interim functions and make the documentation for driver authors a lot
cleaner and less confusing. There will be only one true way to
initialize a drm_device at the end of this, which is going to be
devm_drm_dev_alloc.

v2:
- Actually explain what this is for in the commit message (Sam)
- Fix checkpatch issues (Sam)

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
 include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1bb4f636b83c..8e1813d2a12e 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
 }
 EXPORT_SYMBOL(devm_drm_dev_init);
 
+void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
+			   size_t size, size_t offset)
+{
+	void *container;
+	struct drm_device *drm;
+	int ret;
+
+	container = kzalloc(size, GFP_KERNEL);
+	if (!container)
+		return ERR_PTR(-ENOMEM);
+
+	drm = container + offset;
+	ret = devm_drm_dev_init(parent, drm, driver);
+	if (ret) {
+		kfree(container);
+		return ERR_PTR(ret);
+	}
+	drmm_add_final_kfree(drm, container);
+
+	return container;
+}
+EXPORT_SYMBOL(__devm_drm_dev_alloc);
+
 /**
  * drm_dev_alloc - Allocate new DRM device
  * @driver: DRM driver to allocate device for
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index e7c6ea261ed1..f07f15721254 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
 		      struct drm_device *dev,
 		      struct drm_driver *driver);
 
+void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
+			   size_t size, size_t offset);
+
+/**
+ * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
+ * @parent: Parent device object
+ * @driver: DRM driver
+ * @type: the type of the struct which contains struct &drm_device
+ * @member: the name of the &drm_device within @type.
+ *
+ * This allocates and initialize a new DRM device. No device registration is done.
+ * Call drm_dev_register() to advertice the device to user space and register it
+ * with other core subsystems. This should be done last in the device
+ * initialization sequence to make sure userspace can't access an inconsistent
+ * state.
+ *
+ * The initial ref-count of the object is 1. Use drm_dev_get() and
+ * drm_dev_put() to take and drop further ref-counts.
+ *
+ * It is recommended that drivers embed &struct drm_device into their own device
+ * structure.
+ *
+ * Note that this manages the lifetime of the resulting &drm_device
+ * automatically using devres. The DRM device initialized with this function is
+ * automatically put on driver detach using drm_dev_put().
+ *
+ * RETURNS:
+ * Pointer to new DRM device, or ERR_PTR on failure.
+ */
+#define devm_drm_dev_alloc(parent, driver, type, member) \
+	((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
+				       offsetof(type, member)))
+
 struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 				 struct device *parent);
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Paul Kocialkowski,
	Noralf Trønnes, Laurent Pinchart, Daniel Vetter,
	Sam Ravnborg

Add a new macro helper to combine the usual init sequence in drivers,
consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
triplet. This allows us to remove the rather unsightly
drmm_add_final_kfree from all currently merged drivers.

The kerneldoc is only added for this new function. Existing kerneldoc
and examples will be udated at the very end, since once all drivers
are converted over to devm_drm_dev_alloc we can unexport a lot of
interim functions and make the documentation for driver authors a lot
cleaner and less confusing. There will be only one true way to
initialize a drm_device at the end of this, which is going to be
devm_drm_dev_alloc.

v2:
- Actually explain what this is for in the commit message (Sam)
- Fix checkpatch issues (Sam)

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
 include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1bb4f636b83c..8e1813d2a12e 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
 }
 EXPORT_SYMBOL(devm_drm_dev_init);
 
+void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
+			   size_t size, size_t offset)
+{
+	void *container;
+	struct drm_device *drm;
+	int ret;
+
+	container = kzalloc(size, GFP_KERNEL);
+	if (!container)
+		return ERR_PTR(-ENOMEM);
+
+	drm = container + offset;
+	ret = devm_drm_dev_init(parent, drm, driver);
+	if (ret) {
+		kfree(container);
+		return ERR_PTR(ret);
+	}
+	drmm_add_final_kfree(drm, container);
+
+	return container;
+}
+EXPORT_SYMBOL(__devm_drm_dev_alloc);
+
 /**
  * drm_dev_alloc - Allocate new DRM device
  * @driver: DRM driver to allocate device for
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index e7c6ea261ed1..f07f15721254 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
 		      struct drm_device *dev,
 		      struct drm_driver *driver);
 
+void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
+			   size_t size, size_t offset);
+
+/**
+ * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
+ * @parent: Parent device object
+ * @driver: DRM driver
+ * @type: the type of the struct which contains struct &drm_device
+ * @member: the name of the &drm_device within @type.
+ *
+ * This allocates and initialize a new DRM device. No device registration is done.
+ * Call drm_dev_register() to advertice the device to user space and register it
+ * with other core subsystems. This should be done last in the device
+ * initialization sequence to make sure userspace can't access an inconsistent
+ * state.
+ *
+ * The initial ref-count of the object is 1. Use drm_dev_get() and
+ * drm_dev_put() to take and drop further ref-counts.
+ *
+ * It is recommended that drivers embed &struct drm_device into their own device
+ * structure.
+ *
+ * Note that this manages the lifetime of the resulting &drm_device
+ * automatically using devres. The DRM device initialized with this function is
+ * automatically put on driver detach using drm_dev_put().
+ *
+ * RETURNS:
+ * Pointer to new DRM device, or ERR_PTR on failure.
+ */
+#define devm_drm_dev_alloc(parent, driver, type, member) \
+	((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
+				       offsetof(type, member)))
+
 struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 				 struct device *parent);
 int drm_dev_register(struct drm_device *dev, unsigned long flags);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, Sam Ravnborg, DRI Development,
	Daniel Vetter

Doesn't apply to upstream kernels since a rather long time.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_ttm.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_ttm.c b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
index 976423d0c3cc..f5a06675da43 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_ttm.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
@@ -24,25 +24,13 @@ int vbox_mm_init(struct vbox_private *vbox)
 		return ret;
 	}
 
-#ifdef DRM_MTRR_WC
-	vbox->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
-				     pci_resource_len(dev->pdev, 0),
-				     DRM_MTRR_WC);
-#else
 	vbox->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
 					 pci_resource_len(dev->pdev, 0));
-#endif
 	return 0;
 }
 
 void vbox_mm_fini(struct vbox_private *vbox)
 {
-#ifdef DRM_MTRR_WC
-	drm_mtrr_del(vbox->fb_mtrr,
-		     pci_resource_start(vbox->ddev.pdev, 0),
-		     pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
-#else
 	arch_phys_wc_del(vbox->fb_mtrr);
-#endif
 	drm_vram_helper_release_mm(&vbox->ddev);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Doesn't apply to upstream kernels since a rather long time.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_ttm.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_ttm.c b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
index 976423d0c3cc..f5a06675da43 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_ttm.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
@@ -24,25 +24,13 @@ int vbox_mm_init(struct vbox_private *vbox)
 		return ret;
 	}
 
-#ifdef DRM_MTRR_WC
-	vbox->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
-				     pci_resource_len(dev->pdev, 0),
-				     DRM_MTRR_WC);
-#else
 	vbox->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
 					 pci_resource_len(dev->pdev, 0));
-#endif
 	return 0;
 }
 
 void vbox_mm_fini(struct vbox_private *vbox)
 {
-#ifdef DRM_MTRR_WC
-	drm_mtrr_del(vbox->fb_mtrr,
-		     pci_resource_start(vbox->ddev.pdev, 0),
-		     pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
-#else
 	arch_phys_wc_del(vbox->fb_mtrr);
-#endif
 	drm_vram_helper_release_mm(&vbox->ddev);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, DRI Development, Daniel Vetter

Straightforward conversion.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index 282348e071fe..7dd25c7a3768 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		return ret;
 
-	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
-	if (!vbox)
-		return -ENOMEM;
-
-	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
-	if (ret) {
-		kfree(vbox);
-		return ret;
-	}
+	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
+				  struct vbox_private, ddev);
+	if (IS_ERR(vbox))
+		return PTR_ERR(vbox);
 
 	vbox->ddev.pdev = pdev;
 	vbox->ddev.dev_private = vbox;
 	pci_set_drvdata(pdev, vbox);
-	drmm_add_final_kfree(&vbox->ddev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
 	ret = pci_enable_device(pdev);
 	if (ret)
-		goto err_dev_put;
+		return ret;
 
 	ret = vbox_hw_init(vbox);
 	if (ret)
@@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	vbox_hw_fini(vbox);
 err_pci_disable:
 	pci_disable_device(pdev);
-err_dev_put:
-	drm_dev_put(&vbox->ddev);
 	return ret;
 }
 
@@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
 	vbox_mode_fini(vbox);
 	vbox_mm_fini(vbox);
 	vbox_hw_fini(vbox);
-	drm_dev_put(&vbox->ddev);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Straightforward conversion.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index 282348e071fe..7dd25c7a3768 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		return ret;
 
-	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
-	if (!vbox)
-		return -ENOMEM;
-
-	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
-	if (ret) {
-		kfree(vbox);
-		return ret;
-	}
+	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
+				  struct vbox_private, ddev);
+	if (IS_ERR(vbox))
+		return PTR_ERR(vbox);
 
 	vbox->ddev.pdev = pdev;
 	vbox->ddev.dev_private = vbox;
 	pci_set_drvdata(pdev, vbox);
-	drmm_add_final_kfree(&vbox->ddev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
 	ret = pci_enable_device(pdev);
 	if (ret)
-		goto err_dev_put;
+		return ret;
 
 	ret = vbox_hw_init(vbox);
 	if (ret)
@@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	vbox_hw_fini(vbox);
 err_pci_disable:
 	pci_disable_device(pdev);
-err_dev_put:
-	drm_dev_put(&vbox->ddev);
 	return ret;
 }
 
@@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
 	vbox_mode_fini(vbox);
 	vbox_mm_fini(vbox);
 	vbox_hw_fini(vbox);
-	drm_dev_put(&vbox->ddev);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Hans de Goede, Thomas Zimmermann,
	Daniel Vetter, Sam Ravnborg

We use the baseclass pattern here, so lets to the proper (and more
typesafe) upcasting.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c  |  1 -
 drivers/gpu/drm/vboxvideo/vbox_drv.h  |  1 +
 drivers/gpu/drm/vboxvideo/vbox_irq.c  |  2 +-
 drivers/gpu/drm/vboxvideo/vbox_mode.c | 10 +++++-----
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index 7dd25c7a3768..cfa4639c5142 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -52,7 +52,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return PTR_ERR(vbox);
 
 	vbox->ddev.pdev = pdev;
-	vbox->ddev.dev_private = vbox;
 	pci_set_drvdata(pdev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.h b/drivers/gpu/drm/vboxvideo/vbox_drv.h
index 87421903816c..ac7c2effc46f 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.h
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.h
@@ -127,6 +127,7 @@ struct vbox_encoder {
 #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
 #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
 #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
+#define to_vbox_dev(x) container_of(x, struct vbox_private, ddev)
 
 bool vbox_check_supported(u16 id);
 int vbox_hw_init(struct vbox_private *vbox);
diff --git a/drivers/gpu/drm/vboxvideo/vbox_irq.c b/drivers/gpu/drm/vboxvideo/vbox_irq.c
index 16a1e29f5292..631657fa554f 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_irq.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_irq.c
@@ -34,7 +34,7 @@ void vbox_report_hotplug(struct vbox_private *vbox)
 irqreturn_t vbox_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *)arg;
-	struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(dev);
 	u32 host_flags = vbox_get_flags(vbox);
 
 	if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
index 0883a435e62b..d9a5af62af89 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
@@ -36,7 +36,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 	u16 flags;
 	s32 x_offset, y_offset;
 
-	vbox = crtc->dev->dev_private;
+	vbox = to_vbox_dev(crtc->dev);
 	width = vbox_crtc->width ? vbox_crtc->width : 640;
 	height = vbox_crtc->height ? vbox_crtc->height : 480;
 	bpp = fb ? fb->format->cpp[0] * 8 : 32;
@@ -77,7 +77,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 static int vbox_set_view(struct drm_crtc *crtc)
 {
 	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-	struct vbox_private *vbox = crtc->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
 	struct vbva_infoview *p;
 
 	/*
@@ -174,7 +174,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
 					int x, int y)
 {
 	struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
-	struct vbox_private *vbox = crtc->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
 	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
 	bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
@@ -272,7 +272,7 @@ static void vbox_primary_atomic_update(struct drm_plane *plane,
 {
 	struct drm_crtc *crtc = plane->state->crtc;
 	struct drm_framebuffer *fb = plane->state->fb;
-	struct vbox_private *vbox = fb->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(fb->dev);
 	struct drm_mode_rect *clips;
 	uint32_t num_clips, i;
 
@@ -704,7 +704,7 @@ static int vbox_get_modes(struct drm_connector *connector)
 	int preferred_width, preferred_height;
 
 	vbox_connector = to_vbox_connector(connector);
-	vbox = connector->dev->dev_private;
+	vbox = to_vbox_dev(connector->dev);
 
 	hgsmi_report_flags_location(vbox->guest_pool, GUEST_HEAP_OFFSET(vbox) +
 				    HOST_FLAGS_OFFSET);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Thomas Zimmermann, Daniel Vetter,
	Sam Ravnborg

We use the baseclass pattern here, so lets to the proper (and more
typesafe) upcasting.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c  |  1 -
 drivers/gpu/drm/vboxvideo/vbox_drv.h  |  1 +
 drivers/gpu/drm/vboxvideo/vbox_irq.c  |  2 +-
 drivers/gpu/drm/vboxvideo/vbox_mode.c | 10 +++++-----
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index 7dd25c7a3768..cfa4639c5142 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -52,7 +52,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return PTR_ERR(vbox);
 
 	vbox->ddev.pdev = pdev;
-	vbox->ddev.dev_private = vbox;
 	pci_set_drvdata(pdev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.h b/drivers/gpu/drm/vboxvideo/vbox_drv.h
index 87421903816c..ac7c2effc46f 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.h
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.h
@@ -127,6 +127,7 @@ struct vbox_encoder {
 #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
 #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
 #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
+#define to_vbox_dev(x) container_of(x, struct vbox_private, ddev)
 
 bool vbox_check_supported(u16 id);
 int vbox_hw_init(struct vbox_private *vbox);
diff --git a/drivers/gpu/drm/vboxvideo/vbox_irq.c b/drivers/gpu/drm/vboxvideo/vbox_irq.c
index 16a1e29f5292..631657fa554f 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_irq.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_irq.c
@@ -34,7 +34,7 @@ void vbox_report_hotplug(struct vbox_private *vbox)
 irqreturn_t vbox_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *)arg;
-	struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(dev);
 	u32 host_flags = vbox_get_flags(vbox);
 
 	if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
index 0883a435e62b..d9a5af62af89 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
@@ -36,7 +36,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 	u16 flags;
 	s32 x_offset, y_offset;
 
-	vbox = crtc->dev->dev_private;
+	vbox = to_vbox_dev(crtc->dev);
 	width = vbox_crtc->width ? vbox_crtc->width : 640;
 	height = vbox_crtc->height ? vbox_crtc->height : 480;
 	bpp = fb ? fb->format->cpp[0] * 8 : 32;
@@ -77,7 +77,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 static int vbox_set_view(struct drm_crtc *crtc)
 {
 	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-	struct vbox_private *vbox = crtc->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
 	struct vbva_infoview *p;
 
 	/*
@@ -174,7 +174,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
 					int x, int y)
 {
 	struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
-	struct vbox_private *vbox = crtc->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
 	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
 	bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
@@ -272,7 +272,7 @@ static void vbox_primary_atomic_update(struct drm_plane *plane,
 {
 	struct drm_crtc *crtc = plane->state->crtc;
 	struct drm_framebuffer *fb = plane->state->fb;
-	struct vbox_private *vbox = fb->dev->dev_private;
+	struct vbox_private *vbox = to_vbox_dev(fb->dev);
 	struct drm_mode_rect *clips;
 	uint32_t num_clips, i;
 
@@ -704,7 +704,7 @@ static int vbox_get_modes(struct drm_connector *connector)
 	int preferred_width, preferred_height;
 
 	vbox_connector = to_vbox_connector(connector);
-	vbox = connector->dev->dev_private;
+	vbox = to_vbox_dev(connector->dev);
 
 	hgsmi_report_flags_location(vbox->guest_pool, GUEST_HEAP_OFFSET(vbox) +
 				    HOST_FLAGS_OFFSET);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 05/59] drm/vboxvidoe: use managed pci functions
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, Sam Ravnborg, DRI Development,
	Daniel Vetter

Allows us to drop the cleanup code on the floor.

Sam noticed in his review:
> With this change we avoid calling pci_disable_device()
> twise in case vbox_mm_init() fails.
> Once in vbox_hw_fini() and once in the error path.

v2: Include Sam's review remarks

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
 drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index cfa4639c5142..cf2e3e6a2388 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_set_drvdata(pdev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
 
 	ret = vbox_hw_init(vbox);
 	if (ret)
-		goto err_pci_disable;
+		return ret;
 
 	ret = vbox_mm_init(vbox);
 	if (ret)
@@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	vbox_mm_fini(vbox);
 err_hw_fini:
 	vbox_hw_fini(vbox);
-err_pci_disable:
-	pci_disable_device(pdev);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
index 9dcab115a261..1336ab9795fc 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_main.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
@@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
 
 	for (i = 0; i < vbox->num_crtcs; ++i)
 		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
-
-	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
 }
 
 /* Do we support the 4.3 plus mode hint reporting interface? */
@@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
 	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
 	vbox->guest_pool = gen_pool_create(4, -1);
 	if (!vbox->guest_pool)
-		goto err_unmap_guest_heap;
+		return -ENOMEM;
 
 	ret = gen_pool_add_virt(vbox->guest_pool,
 				(unsigned long)vbox->guest_heap,
@@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
 
 err_destroy_guest_pool:
 	gen_pool_destroy(vbox->guest_pool);
-err_unmap_guest_heap:
-	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
 	return ret;
 }
 
@@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
 {
 	vbox_accel_fini(vbox);
 	gen_pool_destroy(vbox->guest_pool);
-	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 05/59] drm/vboxvidoe: use managed pci functions
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Allows us to drop the cleanup code on the floor.

Sam noticed in his review:
> With this change we avoid calling pci_disable_device()
> twise in case vbox_mm_init() fails.
> Once in vbox_hw_fini() and once in the error path.

v2: Include Sam's review remarks

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
 drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
index cfa4639c5142..cf2e3e6a2388 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
@@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_set_drvdata(pdev, vbox);
 	mutex_init(&vbox->hw_mutex);
 
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
 
 	ret = vbox_hw_init(vbox);
 	if (ret)
-		goto err_pci_disable;
+		return ret;
 
 	ret = vbox_mm_init(vbox);
 	if (ret)
@@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	vbox_mm_fini(vbox);
 err_hw_fini:
 	vbox_hw_fini(vbox);
-err_pci_disable:
-	pci_disable_device(pdev);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
index 9dcab115a261..1336ab9795fc 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_main.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
@@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
 
 	for (i = 0; i < vbox->num_crtcs; ++i)
 		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
-
-	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
 }
 
 /* Do we support the 4.3 plus mode hint reporting interface? */
@@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
 	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
 	vbox->guest_pool = gen_pool_create(4, -1);
 	if (!vbox->guest_pool)
-		goto err_unmap_guest_heap;
+		return -ENOMEM;
 
 	ret = gen_pool_add_virt(vbox->guest_pool,
 				(unsigned long)vbox->guest_heap,
@@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
 
 err_destroy_guest_pool:
 	gen_pool_destroy(vbox->guest_pool);
-err_unmap_guest_heap:
-	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
 	return ret;
 }
 
@@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
 {
 	vbox_accel_fini(vbox);
 	gen_pool_destroy(vbox->guest_pool);
-	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, Sam Ravnborg, DRI Development,
	Daniel Vetter

Aside from deleting all the cleanup code we're now also setting a name
for the pool

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
index 1336ab9795fc..d68d9bad7674 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_main.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
@@ -121,7 +121,8 @@ int vbox_hw_init(struct vbox_private *vbox)
 		return -ENOMEM;
 
 	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
-	vbox->guest_pool = gen_pool_create(4, -1);
+	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
+						"vboxvideo-accel");
 	if (!vbox->guest_pool)
 		return -ENOMEM;
 
@@ -130,12 +131,12 @@ int vbox_hw_init(struct vbox_private *vbox)
 				GUEST_HEAP_OFFSET(vbox),
 				GUEST_HEAP_USABLE_SIZE, -1);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	ret = hgsmi_test_query_conf(vbox->guest_pool);
 	if (ret) {
 		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	/* Reduce available VRAM size to reflect the guest heap. */
@@ -147,30 +148,23 @@ int vbox_hw_init(struct vbox_private *vbox)
 
 	if (!have_hgsmi_mode_hints(vbox)) {
 		ret = -ENOTSUPP;
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
 					     sizeof(struct vbva_modehint),
 					     GFP_KERNEL);
-	if (!vbox->last_mode_hints) {
-		ret = -ENOMEM;
-		goto err_destroy_guest_pool;
-	}
+	if (!vbox->last_mode_hints)
+		return -ENOMEM;
 
 	ret = vbox_accel_init(vbox);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	return 0;
-
-err_destroy_guest_pool:
-	gen_pool_destroy(vbox->guest_pool);
-	return ret;
 }
 
 void vbox_hw_fini(struct vbox_private *vbox)
 {
 	vbox_accel_fini(vbox);
-	gen_pool_destroy(vbox->guest_pool);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Aside from deleting all the cleanup code we're now also setting a name
for the pool

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
index 1336ab9795fc..d68d9bad7674 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_main.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
@@ -121,7 +121,8 @@ int vbox_hw_init(struct vbox_private *vbox)
 		return -ENOMEM;
 
 	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
-	vbox->guest_pool = gen_pool_create(4, -1);
+	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
+						"vboxvideo-accel");
 	if (!vbox->guest_pool)
 		return -ENOMEM;
 
@@ -130,12 +131,12 @@ int vbox_hw_init(struct vbox_private *vbox)
 				GUEST_HEAP_OFFSET(vbox),
 				GUEST_HEAP_USABLE_SIZE, -1);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	ret = hgsmi_test_query_conf(vbox->guest_pool);
 	if (ret) {
 		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	/* Reduce available VRAM size to reflect the guest heap. */
@@ -147,30 +148,23 @@ int vbox_hw_init(struct vbox_private *vbox)
 
 	if (!have_hgsmi_mode_hints(vbox)) {
 		ret = -ENOTSUPP;
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
 					     sizeof(struct vbva_modehint),
 					     GFP_KERNEL);
-	if (!vbox->last_mode_hints) {
-		ret = -ENOMEM;
-		goto err_destroy_guest_pool;
-	}
+	if (!vbox->last_mode_hints)
+		return -ENOMEM;
 
 	ret = vbox_accel_init(vbox);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	return 0;
-
-err_destroy_guest_pool:
-	gen_pool_destroy(vbox->guest_pool);
-	return ret;
 }
 
 void vbox_hw_fini(struct vbox_private *vbox)
 {
 	vbox_accel_fini(vbox);
-	gen_pool_destroy(vbox->guest_pool);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 07/59] drm/v3d: Don't set drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter, DRI Development

And switch the helper over to container_of, which is a bunch faster
than chasing a pointer. Plus allows gcc to see through this maze.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 1 -
 drivers/gpu/drm/v3d/v3d_drv.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 8d0c0daaac81..ead62a15d48f 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -265,7 +265,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, drm);
-	drm->dev_private = v3d;
 	drmm_add_final_kfree(drm, v3d);
 
 	ret = map_regs(v3d, &v3d->hub_regs, "hub");
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index e0775c884553..112d80aed5f6 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -121,7 +121,7 @@ struct v3d_dev {
 static inline struct v3d_dev *
 to_v3d_dev(struct drm_device *dev)
 {
-	return (struct v3d_dev *)dev->dev_private;
+	return container_of(dev, struct v3d_dev, drm);
 }
 
 static inline bool
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 07/59] drm/v3d: Don't set drm_device->dev_private
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, DRI Development, Eric Anholt

And switch the helper over to container_of, which is a bunch faster
than chasing a pointer. Plus allows gcc to see through this maze.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 1 -
 drivers/gpu/drm/v3d/v3d_drv.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 8d0c0daaac81..ead62a15d48f 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -265,7 +265,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, drm);
-	drm->dev_private = v3d;
 	drmm_add_final_kfree(drm, v3d);
 
 	ret = map_regs(v3d, &v3d->hub_regs, "hub");
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index e0775c884553..112d80aed5f6 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -121,7 +121,7 @@ struct v3d_dev {
 static inline struct v3d_dev *
 to_v3d_dev(struct drm_device *dev)
 {
-	return (struct v3d_dev *)dev->dev_private;
+	return container_of(dev, struct v3d_dev, drm);
 }
 
 static inline bool
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 08/59] drm/v3d: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter, DRI Development

Also allows us to simplify the unroll code since the drm_dev_put
disappears.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index ead62a15d48f..f57d408ef371 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -251,29 +251,23 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	u32 ident1;
 
 
-	v3d = kzalloc(sizeof(*v3d), GFP_KERNEL);
-	if (!v3d)
-		return -ENOMEM;
+	v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
+	if (IS_ERR(v3d))
+		return PTR_ERR(v3d);
+
 	v3d->dev = dev;
 	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
-	ret = drm_dev_init(&v3d->drm, &v3d_drm_driver, dev);
-	if (ret) {
-		kfree(v3d);
-		return ret;
-	}
-
 	platform_set_drvdata(pdev, drm);
-	drmm_add_final_kfree(drm, v3d);
 
 	ret = map_regs(v3d, &v3d->hub_regs, "hub");
 	if (ret)
-		goto dev_destroy;
+		return ret;
 
 	ret = map_regs(v3d, &v3d->core_regs[0], "core0");
 	if (ret)
-		goto dev_destroy;
+		return ret;
 
 	mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO);
 	dev->coherent_dma_mask =
@@ -291,29 +285,28 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 		ret = PTR_ERR(v3d->reset);
 
 		if (ret == -EPROBE_DEFER)
-			goto dev_destroy;
+			return ret;
 
 		v3d->reset = NULL;
 		ret = map_regs(v3d, &v3d->bridge_regs, "bridge");
 		if (ret) {
 			dev_err(dev,
 				"Failed to get reset control or bridge regs\n");
-			goto dev_destroy;
+			return ret;
 		}
 	}
 
 	if (v3d->ver < 41) {
 		ret = map_regs(v3d, &v3d->gca_regs, "gca");
 		if (ret)
-			goto dev_destroy;
+			return ret;
 	}
 
 	v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr,
 					GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
 	if (!v3d->mmu_scratch) {
 		dev_err(dev, "Failed to allocate MMU scratch page\n");
-		ret = -ENOMEM;
-		goto dev_destroy;
+		return -ENOMEM;
 	}
 
 	pm_runtime_use_autosuspend(dev);
@@ -340,8 +333,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	v3d_gem_destroy(drm);
 dma_free:
 	dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
-dev_destroy:
-	drm_dev_put(drm);
 	return ret;
 }
 
@@ -354,8 +345,6 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
 
 	v3d_gem_destroy(drm);
 
-	drm_dev_put(drm);
-
 	dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
 
 	return 0;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 08/59] drm/v3d: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, DRI Development, Eric Anholt

Also allows us to simplify the unroll code since the drm_dev_put
disappears.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index ead62a15d48f..f57d408ef371 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -251,29 +251,23 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	u32 ident1;
 
 
-	v3d = kzalloc(sizeof(*v3d), GFP_KERNEL);
-	if (!v3d)
-		return -ENOMEM;
+	v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
+	if (IS_ERR(v3d))
+		return PTR_ERR(v3d);
+
 	v3d->dev = dev;
 	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
-	ret = drm_dev_init(&v3d->drm, &v3d_drm_driver, dev);
-	if (ret) {
-		kfree(v3d);
-		return ret;
-	}
-
 	platform_set_drvdata(pdev, drm);
-	drmm_add_final_kfree(drm, v3d);
 
 	ret = map_regs(v3d, &v3d->hub_regs, "hub");
 	if (ret)
-		goto dev_destroy;
+		return ret;
 
 	ret = map_regs(v3d, &v3d->core_regs[0], "core0");
 	if (ret)
-		goto dev_destroy;
+		return ret;
 
 	mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO);
 	dev->coherent_dma_mask =
@@ -291,29 +285,28 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 		ret = PTR_ERR(v3d->reset);
 
 		if (ret == -EPROBE_DEFER)
-			goto dev_destroy;
+			return ret;
 
 		v3d->reset = NULL;
 		ret = map_regs(v3d, &v3d->bridge_regs, "bridge");
 		if (ret) {
 			dev_err(dev,
 				"Failed to get reset control or bridge regs\n");
-			goto dev_destroy;
+			return ret;
 		}
 	}
 
 	if (v3d->ver < 41) {
 		ret = map_regs(v3d, &v3d->gca_regs, "gca");
 		if (ret)
-			goto dev_destroy;
+			return ret;
 	}
 
 	v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr,
 					GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
 	if (!v3d->mmu_scratch) {
 		dev_err(dev, "Failed to allocate MMU scratch page\n");
-		ret = -ENOMEM;
-		goto dev_destroy;
+		return -ENOMEM;
 	}
 
 	pm_runtime_use_autosuspend(dev);
@@ -340,8 +333,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	v3d_gem_destroy(drm);
 dma_free:
 	dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
-dev_destroy:
-	drm_dev_put(drm);
 	return ret;
 }
 
@@ -354,8 +345,6 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
 
 	v3d_gem_destroy(drm);
 
-	drm_dev_put(drm);
-
 	dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
 
 	return 0;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 09/59] drm/v3d: Delete v3d_dev->dev
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter, DRI Development

We already have it in v3d_dev->drm.dev with zero additional pointer
chasing. Personally I don't like duplicated pointers like this
because:
- reviewers need to check whether the pointer is for the same or
  different objects if there's multiple
- compilers have an easier time too

But also a bit a bikeshed, so feel free to ignore.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_debugfs.c | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_drv.c     | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_drv.h     |  2 --
 drivers/gpu/drm/v3d/v3d_gem.c     | 17 +++++++++--------
 drivers/gpu/drm/v3d/v3d_irq.c     | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_mmu.c     | 10 +++++-----
 drivers/gpu/drm/v3d/v3d_sched.c   | 10 +++++-----
 7 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c b/drivers/gpu/drm/v3d/v3d_debugfs.c
index 2b0ea5f8febd..e76b24bb8828 100644
--- a/drivers/gpu/drm/v3d/v3d_debugfs.c
+++ b/drivers/gpu/drm/v3d/v3d_debugfs.c
@@ -132,7 +132,7 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)
 	u32 ident0, ident1, ident2, ident3, cores;
 	int ret, core;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -187,8 +187,8 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)
 			   (misccfg & V3D_MISCCFG_OVRTMUOUT) != 0);
 	}
 
-	pm_runtime_mark_last_busy(v3d->dev);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_mark_last_busy(v3d->drm.dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 
 	return 0;
 }
@@ -219,7 +219,7 @@ static int v3d_measure_clock(struct seq_file *m, void *unused)
 	int measure_ms = 1000;
 	int ret;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -245,8 +245,8 @@ static int v3d_measure_clock(struct seq_file *m, void *unused)
 		   cycles / (measure_ms * 1000),
 		   (cycles / (measure_ms * 100)) % 10);
 
-	pm_runtime_mark_last_busy(v3d->dev);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_mark_last_busy(v3d->drm.dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index f57d408ef371..37cb880f2826 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -105,7 +105,7 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
 		if (args->value != 0)
 			return -EINVAL;
 
-		ret = pm_runtime_get_sync(v3d->dev);
+		ret = pm_runtime_get_sync(v3d->drm.dev);
 		if (ret < 0)
 			return ret;
 		if (args->param >= DRM_V3D_PARAM_V3D_CORE0_IDENT0 &&
@@ -114,8 +114,8 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
 		} else {
 			args->value = V3D_READ(offset);
 		}
-		pm_runtime_mark_last_busy(v3d->dev);
-		pm_runtime_put_autosuspend(v3d->dev);
+		pm_runtime_mark_last_busy(v3d->drm.dev);
+		pm_runtime_put_autosuspend(v3d->drm.dev);
 		return 0;
 	}
 
@@ -237,7 +237,7 @@ map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
 	struct resource *res =
 		platform_get_resource_byname(v3d->pdev, IORESOURCE_MEM, name);
 
-	*regs = devm_ioremap_resource(v3d->dev, res);
+	*regs = devm_ioremap_resource(v3d->drm.dev, res);
 	return PTR_ERR_OR_ZERO(*regs);
 }
 
@@ -255,7 +255,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	if (IS_ERR(v3d))
 		return PTR_ERR(v3d);
 
-	v3d->dev = dev;
 	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
@@ -345,7 +344,8 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
 
 	v3d_gem_destroy(drm);
 
-	dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
+	dma_free_wc(v3d->drm.dev, 4096, v3d->mmu_scratch,
+		    v3d->mmu_scratch_paddr);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 112d80aed5f6..4d2d1f2fe1af 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -14,7 +14,6 @@
 #include "uapi/drm/v3d_drm.h"
 
 struct clk;
-struct device;
 struct platform_device;
 struct reset_control;
 
@@ -47,7 +46,6 @@ struct v3d_dev {
 	int ver;
 	bool single_irq_line;
 
-	struct device *dev;
 	struct platform_device *pdev;
 	void __iomem *hub_regs;
 	void __iomem *core_regs[3];
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 549dde83408b..09a7639cf161 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -370,8 +370,8 @@ v3d_job_free(struct kref *ref)
 	dma_fence_put(job->irq_fence);
 	dma_fence_put(job->done_fence);
 
-	pm_runtime_mark_last_busy(job->v3d->dev);
-	pm_runtime_put_autosuspend(job->v3d->dev);
+	pm_runtime_mark_last_busy(job->v3d->drm.dev);
+	pm_runtime_put_autosuspend(job->v3d->drm.dev);
 
 	kfree(job);
 }
@@ -439,7 +439,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 	job->v3d = v3d;
 	job->free = free;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -458,7 +458,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 	return 0;
 fail:
 	xa_destroy(&job->deps);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 	return ret;
 }
 
@@ -886,12 +886,12 @@ v3d_gem_init(struct drm_device *dev)
 	 */
 	drm_mm_init(&v3d->mm, 1, pt_size / sizeof(u32) - 1);
 
-	v3d->pt = dma_alloc_wc(v3d->dev, pt_size,
+	v3d->pt = dma_alloc_wc(v3d->drm.dev, pt_size,
 			       &v3d->pt_paddr,
 			       GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
 	if (!v3d->pt) {
 		drm_mm_takedown(&v3d->mm);
-		dev_err(v3d->dev,
+		dev_err(v3d->drm.dev,
 			"Failed to allocate page tables. "
 			"Please ensure you have CMA enabled.\n");
 		return -ENOMEM;
@@ -903,7 +903,7 @@ v3d_gem_init(struct drm_device *dev)
 	ret = v3d_sched_init(v3d);
 	if (ret) {
 		drm_mm_takedown(&v3d->mm);
-		dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt,
+		dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt,
 				  v3d->pt_paddr);
 	}
 
@@ -925,5 +925,6 @@ v3d_gem_destroy(struct drm_device *dev)
 
 	drm_mm_takedown(&v3d->mm);
 
-	dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt, v3d->pt_paddr);
+	dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt,
+			  v3d->pt_paddr);
 }
diff --git a/drivers/gpu/drm/v3d/v3d_irq.c b/drivers/gpu/drm/v3d/v3d_irq.c
index 662e67279a7b..f4ce6d057c90 100644
--- a/drivers/gpu/drm/v3d/v3d_irq.c
+++ b/drivers/gpu/drm/v3d/v3d_irq.c
@@ -128,7 +128,7 @@ v3d_irq(int irq, void *arg)
 	 * always-allowed mode.
 	 */
 	if (intsts & V3D_INT_GMPV)
-		dev_err(v3d->dev, "GMP violation\n");
+		dev_err(v3d->drm.dev, "GMP violation\n");
 
 	/* V3D 4.2 wires the hub and core IRQs together, so if we &
 	 * didn't see the common one then check hub for MMU IRQs.
@@ -189,7 +189,7 @@ v3d_hub_irq(int irq, void *arg)
 				client = v3d41_axi_ids[axi_id];
 		}
 
-		dev_err(v3d->dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n",
+		dev_err(v3d->drm.dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n",
 			client, axi_id, (long long)vio_addr,
 			((intsts & V3D_HUB_INT_MMU_WRV) ?
 			 ", write violation" : ""),
@@ -221,12 +221,12 @@ v3d_irq_init(struct v3d_dev *v3d)
 	if (irq1 == -EPROBE_DEFER)
 		return irq1;
 	if (irq1 > 0) {
-		ret = devm_request_irq(v3d->dev, irq1,
+		ret = devm_request_irq(v3d->drm.dev, irq1,
 				       v3d_irq, IRQF_SHARED,
 				       "v3d_core0", v3d);
 		if (ret)
 			goto fail;
-		ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
 				       v3d_hub_irq, IRQF_SHARED,
 				       "v3d_hub", v3d);
 		if (ret)
@@ -234,7 +234,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 	} else {
 		v3d->single_irq_line = true;
 
-		ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
 				       v3d_irq, IRQF_SHARED,
 				       "v3d", v3d);
 		if (ret)
@@ -246,7 +246,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 
 fail:
 	if (ret != -EPROBE_DEFER)
-		dev_err(v3d->dev, "IRQ setup failed: %d\n", ret);
+		dev_err(v3d->drm.dev, "IRQ setup failed: %d\n", ret);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/v3d/v3d_mmu.c b/drivers/gpu/drm/v3d/v3d_mmu.c
index 395e81d97163..3b81ea28c0bb 100644
--- a/drivers/gpu/drm/v3d/v3d_mmu.c
+++ b/drivers/gpu/drm/v3d/v3d_mmu.c
@@ -40,7 +40,7 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d)
 	ret = wait_for(!(V3D_READ(V3D_MMU_CTL) &
 			 V3D_MMU_CTL_TLB_CLEARING), 100);
 	if (ret)
-		dev_err(v3d->dev, "TLB clear wait idle pre-wait failed\n");
+		dev_err(v3d->drm.dev, "TLB clear wait idle pre-wait failed\n");
 
 	V3D_WRITE(V3D_MMU_CTL, V3D_READ(V3D_MMU_CTL) |
 		  V3D_MMU_CTL_TLB_CLEAR);
@@ -52,14 +52,14 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d)
 	ret = wait_for(!(V3D_READ(V3D_MMU_CTL) &
 			 V3D_MMU_CTL_TLB_CLEARING), 100);
 	if (ret) {
-		dev_err(v3d->dev, "TLB clear wait idle failed\n");
+		dev_err(v3d->drm.dev, "TLB clear wait idle failed\n");
 		return ret;
 	}
 
 	ret = wait_for(!(V3D_READ(V3D_MMUC_CONTROL) &
 			 V3D_MMUC_CONTROL_FLUSHING), 100);
 	if (ret)
-		dev_err(v3d->dev, "MMUC flush wait idle failed\n");
+		dev_err(v3d->drm.dev, "MMUC flush wait idle failed\n");
 
 	return ret;
 }
@@ -109,7 +109,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *bo)
 		     shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);
 
 	if (v3d_mmu_flush_all(v3d))
-		dev_err(v3d->dev, "MMU flush timeout\n");
+		dev_err(v3d->drm.dev, "MMU flush timeout\n");
 }
 
 void v3d_mmu_remove_ptes(struct v3d_bo *bo)
@@ -122,5 +122,5 @@ void v3d_mmu_remove_ptes(struct v3d_bo *bo)
 		v3d->pt[page] = 0;
 
 	if (v3d_mmu_flush_all(v3d))
-		dev_err(v3d->dev, "MMU flush timeout\n");
+		dev_err(v3d->drm.dev, "MMU flush timeout\n");
 }
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 8c2df6d95283..0747614a78f0 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -403,7 +403,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_bin");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create bin scheduler: %d.", ret);
+		dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret);
 		return ret;
 	}
 
@@ -413,7 +413,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_render");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create render scheduler: %d.",
+		dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.",
 			ret);
 		v3d_sched_fini(v3d);
 		return ret;
@@ -425,7 +425,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_tfu");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create TFU scheduler: %d.",
+		dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.",
 			ret);
 		v3d_sched_fini(v3d);
 		return ret;
@@ -438,7 +438,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 				     msecs_to_jiffies(hang_limit_ms),
 				     "v3d_csd");
 		if (ret) {
-			dev_err(v3d->dev, "Failed to create CSD scheduler: %d.",
+			dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.",
 				ret);
 			v3d_sched_fini(v3d);
 			return ret;
@@ -450,7 +450,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 				     msecs_to_jiffies(hang_limit_ms),
 				     "v3d_cache_clean");
 		if (ret) {
-			dev_err(v3d->dev, "Failed to create CACHE_CLEAN scheduler: %d.",
+			dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.",
 				ret);
 			v3d_sched_fini(v3d);
 			return ret;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 09/59] drm/v3d: Delete v3d_dev->dev
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, DRI Development, Eric Anholt

We already have it in v3d_dev->drm.dev with zero additional pointer
chasing. Personally I don't like duplicated pointers like this
because:
- reviewers need to check whether the pointer is for the same or
  different objects if there's multiple
- compilers have an easier time too

But also a bit a bikeshed, so feel free to ignore.

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_debugfs.c | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_drv.c     | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_drv.h     |  2 --
 drivers/gpu/drm/v3d/v3d_gem.c     | 17 +++++++++--------
 drivers/gpu/drm/v3d/v3d_irq.c     | 12 ++++++------
 drivers/gpu/drm/v3d/v3d_mmu.c     | 10 +++++-----
 drivers/gpu/drm/v3d/v3d_sched.c   | 10 +++++-----
 7 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c b/drivers/gpu/drm/v3d/v3d_debugfs.c
index 2b0ea5f8febd..e76b24bb8828 100644
--- a/drivers/gpu/drm/v3d/v3d_debugfs.c
+++ b/drivers/gpu/drm/v3d/v3d_debugfs.c
@@ -132,7 +132,7 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)
 	u32 ident0, ident1, ident2, ident3, cores;
 	int ret, core;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -187,8 +187,8 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused)
 			   (misccfg & V3D_MISCCFG_OVRTMUOUT) != 0);
 	}
 
-	pm_runtime_mark_last_busy(v3d->dev);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_mark_last_busy(v3d->drm.dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 
 	return 0;
 }
@@ -219,7 +219,7 @@ static int v3d_measure_clock(struct seq_file *m, void *unused)
 	int measure_ms = 1000;
 	int ret;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -245,8 +245,8 @@ static int v3d_measure_clock(struct seq_file *m, void *unused)
 		   cycles / (measure_ms * 1000),
 		   (cycles / (measure_ms * 100)) % 10);
 
-	pm_runtime_mark_last_busy(v3d->dev);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_mark_last_busy(v3d->drm.dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index f57d408ef371..37cb880f2826 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -105,7 +105,7 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
 		if (args->value != 0)
 			return -EINVAL;
 
-		ret = pm_runtime_get_sync(v3d->dev);
+		ret = pm_runtime_get_sync(v3d->drm.dev);
 		if (ret < 0)
 			return ret;
 		if (args->param >= DRM_V3D_PARAM_V3D_CORE0_IDENT0 &&
@@ -114,8 +114,8 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
 		} else {
 			args->value = V3D_READ(offset);
 		}
-		pm_runtime_mark_last_busy(v3d->dev);
-		pm_runtime_put_autosuspend(v3d->dev);
+		pm_runtime_mark_last_busy(v3d->drm.dev);
+		pm_runtime_put_autosuspend(v3d->drm.dev);
 		return 0;
 	}
 
@@ -237,7 +237,7 @@ map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
 	struct resource *res =
 		platform_get_resource_byname(v3d->pdev, IORESOURCE_MEM, name);
 
-	*regs = devm_ioremap_resource(v3d->dev, res);
+	*regs = devm_ioremap_resource(v3d->drm.dev, res);
 	return PTR_ERR_OR_ZERO(*regs);
 }
 
@@ -255,7 +255,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	if (IS_ERR(v3d))
 		return PTR_ERR(v3d);
 
-	v3d->dev = dev;
 	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
@@ -345,7 +344,8 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)
 
 	v3d_gem_destroy(drm);
 
-	dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr);
+	dma_free_wc(v3d->drm.dev, 4096, v3d->mmu_scratch,
+		    v3d->mmu_scratch_paddr);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 112d80aed5f6..4d2d1f2fe1af 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -14,7 +14,6 @@
 #include "uapi/drm/v3d_drm.h"
 
 struct clk;
-struct device;
 struct platform_device;
 struct reset_control;
 
@@ -47,7 +46,6 @@ struct v3d_dev {
 	int ver;
 	bool single_irq_line;
 
-	struct device *dev;
 	struct platform_device *pdev;
 	void __iomem *hub_regs;
 	void __iomem *core_regs[3];
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 549dde83408b..09a7639cf161 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -370,8 +370,8 @@ v3d_job_free(struct kref *ref)
 	dma_fence_put(job->irq_fence);
 	dma_fence_put(job->done_fence);
 
-	pm_runtime_mark_last_busy(job->v3d->dev);
-	pm_runtime_put_autosuspend(job->v3d->dev);
+	pm_runtime_mark_last_busy(job->v3d->drm.dev);
+	pm_runtime_put_autosuspend(job->v3d->drm.dev);
 
 	kfree(job);
 }
@@ -439,7 +439,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 	job->v3d = v3d;
 	job->free = free;
 
-	ret = pm_runtime_get_sync(v3d->dev);
+	ret = pm_runtime_get_sync(v3d->drm.dev);
 	if (ret < 0)
 		return ret;
 
@@ -458,7 +458,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
 	return 0;
 fail:
 	xa_destroy(&job->deps);
-	pm_runtime_put_autosuspend(v3d->dev);
+	pm_runtime_put_autosuspend(v3d->drm.dev);
 	return ret;
 }
 
@@ -886,12 +886,12 @@ v3d_gem_init(struct drm_device *dev)
 	 */
 	drm_mm_init(&v3d->mm, 1, pt_size / sizeof(u32) - 1);
 
-	v3d->pt = dma_alloc_wc(v3d->dev, pt_size,
+	v3d->pt = dma_alloc_wc(v3d->drm.dev, pt_size,
 			       &v3d->pt_paddr,
 			       GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
 	if (!v3d->pt) {
 		drm_mm_takedown(&v3d->mm);
-		dev_err(v3d->dev,
+		dev_err(v3d->drm.dev,
 			"Failed to allocate page tables. "
 			"Please ensure you have CMA enabled.\n");
 		return -ENOMEM;
@@ -903,7 +903,7 @@ v3d_gem_init(struct drm_device *dev)
 	ret = v3d_sched_init(v3d);
 	if (ret) {
 		drm_mm_takedown(&v3d->mm);
-		dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt,
+		dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt,
 				  v3d->pt_paddr);
 	}
 
@@ -925,5 +925,6 @@ v3d_gem_destroy(struct drm_device *dev)
 
 	drm_mm_takedown(&v3d->mm);
 
-	dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt, v3d->pt_paddr);
+	dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt,
+			  v3d->pt_paddr);
 }
diff --git a/drivers/gpu/drm/v3d/v3d_irq.c b/drivers/gpu/drm/v3d/v3d_irq.c
index 662e67279a7b..f4ce6d057c90 100644
--- a/drivers/gpu/drm/v3d/v3d_irq.c
+++ b/drivers/gpu/drm/v3d/v3d_irq.c
@@ -128,7 +128,7 @@ v3d_irq(int irq, void *arg)
 	 * always-allowed mode.
 	 */
 	if (intsts & V3D_INT_GMPV)
-		dev_err(v3d->dev, "GMP violation\n");
+		dev_err(v3d->drm.dev, "GMP violation\n");
 
 	/* V3D 4.2 wires the hub and core IRQs together, so if we &
 	 * didn't see the common one then check hub for MMU IRQs.
@@ -189,7 +189,7 @@ v3d_hub_irq(int irq, void *arg)
 				client = v3d41_axi_ids[axi_id];
 		}
 
-		dev_err(v3d->dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n",
+		dev_err(v3d->drm.dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n",
 			client, axi_id, (long long)vio_addr,
 			((intsts & V3D_HUB_INT_MMU_WRV) ?
 			 ", write violation" : ""),
@@ -221,12 +221,12 @@ v3d_irq_init(struct v3d_dev *v3d)
 	if (irq1 == -EPROBE_DEFER)
 		return irq1;
 	if (irq1 > 0) {
-		ret = devm_request_irq(v3d->dev, irq1,
+		ret = devm_request_irq(v3d->drm.dev, irq1,
 				       v3d_irq, IRQF_SHARED,
 				       "v3d_core0", v3d);
 		if (ret)
 			goto fail;
-		ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
 				       v3d_hub_irq, IRQF_SHARED,
 				       "v3d_hub", v3d);
 		if (ret)
@@ -234,7 +234,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 	} else {
 		v3d->single_irq_line = true;
 
-		ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
 				       v3d_irq, IRQF_SHARED,
 				       "v3d", v3d);
 		if (ret)
@@ -246,7 +246,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 
 fail:
 	if (ret != -EPROBE_DEFER)
-		dev_err(v3d->dev, "IRQ setup failed: %d\n", ret);
+		dev_err(v3d->drm.dev, "IRQ setup failed: %d\n", ret);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/v3d/v3d_mmu.c b/drivers/gpu/drm/v3d/v3d_mmu.c
index 395e81d97163..3b81ea28c0bb 100644
--- a/drivers/gpu/drm/v3d/v3d_mmu.c
+++ b/drivers/gpu/drm/v3d/v3d_mmu.c
@@ -40,7 +40,7 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d)
 	ret = wait_for(!(V3D_READ(V3D_MMU_CTL) &
 			 V3D_MMU_CTL_TLB_CLEARING), 100);
 	if (ret)
-		dev_err(v3d->dev, "TLB clear wait idle pre-wait failed\n");
+		dev_err(v3d->drm.dev, "TLB clear wait idle pre-wait failed\n");
 
 	V3D_WRITE(V3D_MMU_CTL, V3D_READ(V3D_MMU_CTL) |
 		  V3D_MMU_CTL_TLB_CLEAR);
@@ -52,14 +52,14 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d)
 	ret = wait_for(!(V3D_READ(V3D_MMU_CTL) &
 			 V3D_MMU_CTL_TLB_CLEARING), 100);
 	if (ret) {
-		dev_err(v3d->dev, "TLB clear wait idle failed\n");
+		dev_err(v3d->drm.dev, "TLB clear wait idle failed\n");
 		return ret;
 	}
 
 	ret = wait_for(!(V3D_READ(V3D_MMUC_CONTROL) &
 			 V3D_MMUC_CONTROL_FLUSHING), 100);
 	if (ret)
-		dev_err(v3d->dev, "MMUC flush wait idle failed\n");
+		dev_err(v3d->drm.dev, "MMUC flush wait idle failed\n");
 
 	return ret;
 }
@@ -109,7 +109,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *bo)
 		     shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);
 
 	if (v3d_mmu_flush_all(v3d))
-		dev_err(v3d->dev, "MMU flush timeout\n");
+		dev_err(v3d->drm.dev, "MMU flush timeout\n");
 }
 
 void v3d_mmu_remove_ptes(struct v3d_bo *bo)
@@ -122,5 +122,5 @@ void v3d_mmu_remove_ptes(struct v3d_bo *bo)
 		v3d->pt[page] = 0;
 
 	if (v3d_mmu_flush_all(v3d))
-		dev_err(v3d->dev, "MMU flush timeout\n");
+		dev_err(v3d->drm.dev, "MMU flush timeout\n");
 }
diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c
index 8c2df6d95283..0747614a78f0 100644
--- a/drivers/gpu/drm/v3d/v3d_sched.c
+++ b/drivers/gpu/drm/v3d/v3d_sched.c
@@ -403,7 +403,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_bin");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create bin scheduler: %d.", ret);
+		dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret);
 		return ret;
 	}
 
@@ -413,7 +413,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_render");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create render scheduler: %d.",
+		dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.",
 			ret);
 		v3d_sched_fini(v3d);
 		return ret;
@@ -425,7 +425,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 			     msecs_to_jiffies(hang_limit_ms),
 			     "v3d_tfu");
 	if (ret) {
-		dev_err(v3d->dev, "Failed to create TFU scheduler: %d.",
+		dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.",
 			ret);
 		v3d_sched_fini(v3d);
 		return ret;
@@ -438,7 +438,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 				     msecs_to_jiffies(hang_limit_ms),
 				     "v3d_csd");
 		if (ret) {
-			dev_err(v3d->dev, "Failed to create CSD scheduler: %d.",
+			dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.",
 				ret);
 			v3d_sched_fini(v3d);
 			return ret;
@@ -450,7 +450,7 @@ v3d_sched_init(struct v3d_dev *v3d)
 				     msecs_to_jiffies(hang_limit_ms),
 				     "v3d_cache_clean");
 		if (ret) {
-			dev_err(v3d->dev, "Failed to create CACHE_CLEAN scheduler: %d.",
+			dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.",
 				ret);
 			v3d_sched_fini(v3d);
 			return ret;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 10/59] drm/v3d: Delete v3d_dev->pdev
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Daniel Vetter, DRI Development

We already have it in v3d_dev->drm.dev with zero additional pointer
chasing. Personally I don't like duplicated pointers like this
because:
- reviewers need to check whether the pointer is for the same or
different objects if there's multiple
- compilers have an easier time too

To avoid having to pull in some big headers I implemented the casting
function as a macro instead of a static inline. Typechecking thanks to
container_of still assured.

But also a bit a bikeshed, so feel free to ignore.

v2: More parens for v3d_to_pdev macro (checkpatch)

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 3 +--
 drivers/gpu/drm/v3d/v3d_drv.h | 3 ++-
 drivers/gpu/drm/v3d/v3d_irq.c | 8 +++++---
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 37cb880f2826..82a7dfdd14c2 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -235,7 +235,7 @@ static int
 map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
 {
 	struct resource *res =
-		platform_get_resource_byname(v3d->pdev, IORESOURCE_MEM, name);
+		platform_get_resource_byname(v3d_to_pdev(v3d), IORESOURCE_MEM, name);
 
 	*regs = devm_ioremap_resource(v3d->drm.dev, res);
 	return PTR_ERR_OR_ZERO(*regs);
@@ -255,7 +255,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	if (IS_ERR(v3d))
 		return PTR_ERR(v3d);
 
-	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
 	platform_set_drvdata(pdev, drm);
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 4d2d1f2fe1af..8a390738d65b 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -46,7 +46,6 @@ struct v3d_dev {
 	int ver;
 	bool single_irq_line;
 
-	struct platform_device *pdev;
 	void __iomem *hub_regs;
 	void __iomem *core_regs[3];
 	void __iomem *bridge_regs;
@@ -128,6 +127,8 @@ v3d_has_csd(struct v3d_dev *v3d)
 	return v3d->ver >= 41;
 }
 
+#define v3d_to_pdev(v3d) to_platform_device((v3d)->drm.dev)
+
 /* The per-fd struct, which tracks the MMU mappings. */
 struct v3d_file_priv {
 	struct v3d_dev *v3d;
diff --git a/drivers/gpu/drm/v3d/v3d_irq.c b/drivers/gpu/drm/v3d/v3d_irq.c
index f4ce6d057c90..51b65263c657 100644
--- a/drivers/gpu/drm/v3d/v3d_irq.c
+++ b/drivers/gpu/drm/v3d/v3d_irq.c
@@ -217,7 +217,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 		V3D_CORE_WRITE(core, V3D_CTL_INT_CLR, V3D_CORE_IRQS);
 	V3D_WRITE(V3D_HUB_INT_CLR, V3D_HUB_IRQS);
 
-	irq1 = platform_get_irq(v3d->pdev, 1);
+	irq1 = platform_get_irq(v3d_to_pdev(v3d), 1);
 	if (irq1 == -EPROBE_DEFER)
 		return irq1;
 	if (irq1 > 0) {
@@ -226,7 +226,8 @@ v3d_irq_init(struct v3d_dev *v3d)
 				       "v3d_core0", v3d);
 		if (ret)
 			goto fail;
-		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev,
+				       platform_get_irq(v3d_to_pdev(v3d), 0),
 				       v3d_hub_irq, IRQF_SHARED,
 				       "v3d_hub", v3d);
 		if (ret)
@@ -234,7 +235,8 @@ v3d_irq_init(struct v3d_dev *v3d)
 	} else {
 		v3d->single_irq_line = true;
 
-		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev,
+				       platform_get_irq(v3d_to_pdev(v3d), 0),
 				       v3d_irq, IRQF_SHARED,
 				       "v3d", v3d);
 		if (ret)
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 10/59] drm/v3d: Delete v3d_dev->pdev
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, DRI Development, Eric Anholt

We already have it in v3d_dev->drm.dev with zero additional pointer
chasing. Personally I don't like duplicated pointers like this
because:
- reviewers need to check whether the pointer is for the same or
different objects if there's multiple
- compilers have an easier time too

To avoid having to pull in some big headers I implemented the casting
function as a macro instead of a static inline. Typechecking thanks to
container_of still assured.

But also a bit a bikeshed, so feel free to ignore.

v2: More parens for v3d_to_pdev macro (checkpatch)

Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/v3d/v3d_drv.c | 3 +--
 drivers/gpu/drm/v3d/v3d_drv.h | 3 ++-
 drivers/gpu/drm/v3d/v3d_irq.c | 8 +++++---
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c
index 37cb880f2826..82a7dfdd14c2 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.c
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
@@ -235,7 +235,7 @@ static int
 map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name)
 {
 	struct resource *res =
-		platform_get_resource_byname(v3d->pdev, IORESOURCE_MEM, name);
+		platform_get_resource_byname(v3d_to_pdev(v3d), IORESOURCE_MEM, name);
 
 	*regs = devm_ioremap_resource(v3d->drm.dev, res);
 	return PTR_ERR_OR_ZERO(*regs);
@@ -255,7 +255,6 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	if (IS_ERR(v3d))
 		return PTR_ERR(v3d);
 
-	v3d->pdev = pdev;
 	drm = &v3d->drm;
 
 	platform_set_drvdata(pdev, drm);
diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h
index 4d2d1f2fe1af..8a390738d65b 100644
--- a/drivers/gpu/drm/v3d/v3d_drv.h
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
@@ -46,7 +46,6 @@ struct v3d_dev {
 	int ver;
 	bool single_irq_line;
 
-	struct platform_device *pdev;
 	void __iomem *hub_regs;
 	void __iomem *core_regs[3];
 	void __iomem *bridge_regs;
@@ -128,6 +127,8 @@ v3d_has_csd(struct v3d_dev *v3d)
 	return v3d->ver >= 41;
 }
 
+#define v3d_to_pdev(v3d) to_platform_device((v3d)->drm.dev)
+
 /* The per-fd struct, which tracks the MMU mappings. */
 struct v3d_file_priv {
 	struct v3d_dev *v3d;
diff --git a/drivers/gpu/drm/v3d/v3d_irq.c b/drivers/gpu/drm/v3d/v3d_irq.c
index f4ce6d057c90..51b65263c657 100644
--- a/drivers/gpu/drm/v3d/v3d_irq.c
+++ b/drivers/gpu/drm/v3d/v3d_irq.c
@@ -217,7 +217,7 @@ v3d_irq_init(struct v3d_dev *v3d)
 		V3D_CORE_WRITE(core, V3D_CTL_INT_CLR, V3D_CORE_IRQS);
 	V3D_WRITE(V3D_HUB_INT_CLR, V3D_HUB_IRQS);
 
-	irq1 = platform_get_irq(v3d->pdev, 1);
+	irq1 = platform_get_irq(v3d_to_pdev(v3d), 1);
 	if (irq1 == -EPROBE_DEFER)
 		return irq1;
 	if (irq1 > 0) {
@@ -226,7 +226,8 @@ v3d_irq_init(struct v3d_dev *v3d)
 				       "v3d_core0", v3d);
 		if (ret)
 			goto fail;
-		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev,
+				       platform_get_irq(v3d_to_pdev(v3d), 0),
 				       v3d_hub_irq, IRQF_SHARED,
 				       "v3d_hub", v3d);
 		if (ret)
@@ -234,7 +235,8 @@ v3d_irq_init(struct v3d_dev *v3d)
 	} else {
 		v3d->single_irq_line = true;
 
-		ret = devm_request_irq(v3d->drm.dev, platform_get_irq(v3d->pdev, 0),
+		ret = devm_request_irq(v3d->drm.dev,
+				       platform_get_irq(v3d_to_pdev(v3d), 0),
 				       v3d_irq, IRQF_SHARED,
 				       "v3d", v3d);
 		if (ret)
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Sam Ravnborg, Daniel Vetter, Emil Velikov, DRI Development,
	Thomas Zimmermann, Daniel Vetter, Dave Airlie, Thomas Gleixner,
	Sean Paul

Also init the fbdev emulation before we register the device, that way
we can rely on the auto-cleanup and simplify the probe error code even
more.

v2: Rebase on top of Thomas' patches to remove the return value from
drm_fbdev_generic_setup()

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 9cc6d075cb40..523f60e02a85 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
 	struct udl_device *udl;
 	int r;
 
-	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
-	if (!udl)
-		return ERR_PTR(-ENOMEM);
-
-	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
-	if (r) {
-		kfree(udl);
-		return ERR_PTR(r);
-	}
+	udl = devm_drm_dev_alloc(&interface->dev, &driver,
+				 struct udl_device, drm);
+	if (IS_ERR(udl))
+		return udl;
 
 	udl->udev = udev;
 	udl->drm.dev_private = udl;
-	drmm_add_final_kfree(&udl->drm, udl);
 
 	r = udl_init(udl);
-	if (r) {
-		drm_dev_put(&udl->drm);
+	if (r)
 		return ERR_PTR(r);
-	}
 
 	usb_set_intfdata(interface, udl);
+
 	return udl;
 }
 
@@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
 
 	r = drm_dev_register(&udl->drm, 0);
 	if (r)
-		goto err_free;
+		return r;
 
 	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
 
 	drm_fbdev_generic_setup(&udl->drm, 0);
 
 	return 0;
-
-err_free:
-	drm_dev_put(&udl->drm);
-	return r;
 }
 
 static void udl_usb_disconnect(struct usb_interface *interface)
@@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 	drm_kms_helper_poll_fini(dev);
 	udl_drop_usb(dev);
 	drm_dev_unplug(dev);
-	drm_dev_put(dev);
 }
 
 /*
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Sam Ravnborg, Daniel Vetter, DRI Development,
	Noralf Trønnes, Thomas Zimmermann, Daniel Vetter,
	Dave Airlie, Thomas Gleixner

Also init the fbdev emulation before we register the device, that way
we can rely on the auto-cleanup and simplify the probe error code even
more.

v2: Rebase on top of Thomas' patches to remove the return value from
drm_fbdev_generic_setup()

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 9cc6d075cb40..523f60e02a85 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
 	struct udl_device *udl;
 	int r;
 
-	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
-	if (!udl)
-		return ERR_PTR(-ENOMEM);
-
-	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
-	if (r) {
-		kfree(udl);
-		return ERR_PTR(r);
-	}
+	udl = devm_drm_dev_alloc(&interface->dev, &driver,
+				 struct udl_device, drm);
+	if (IS_ERR(udl))
+		return udl;
 
 	udl->udev = udev;
 	udl->drm.dev_private = udl;
-	drmm_add_final_kfree(&udl->drm, udl);
 
 	r = udl_init(udl);
-	if (r) {
-		drm_dev_put(&udl->drm);
+	if (r)
 		return ERR_PTR(r);
-	}
 
 	usb_set_intfdata(interface, udl);
+
 	return udl;
 }
 
@@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
 
 	r = drm_dev_register(&udl->drm, 0);
 	if (r)
-		goto err_free;
+		return r;
 
 	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
 
 	drm_fbdev_generic_setup(&udl->drm, 0);
 
 	return 0;
-
-err_free:
-	drm_dev_put(&udl->drm);
-	return r;
 }
 
 static void udl_usb_disconnect(struct usb_interface *interface)
@@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 	drm_kms_helper_poll_fini(dev);
 	udl_drop_usb(dev);
 	drm_dev_unplug(dev);
-	drm_dev_put(dev);
 }
 
 /*
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 12/59] drm/udl: don't set drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Sean Paul, Daniel Vetter, Emil Velikov, DRI Development,
	Alexios Zavras, Laurent Pinchart, Thomas Zimmermann,
	Daniel Vetter, José Roberto de Souza, Dave Airlie,
	Thomas Gleixner, Sam Ravnborg, Allison Randal, Gerd Hoffmann

We're mostly there already, just a handful of places that didn't use
the to_udl container_of cast. To make sure no new appear, don't set
->dev_private.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "José Roberto de Souza" <jose.souza@intel.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Allison Randal <allison@lohutok.net>
---
 drivers/gpu/drm/udl/udl_connector.c | 4 ++--
 drivers/gpu/drm/udl/udl_drv.c       | 1 -
 drivers/gpu/drm/udl/udl_modeset.c   | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index 0afdfb0d1fe1..cdc1c42e1669 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -59,7 +59,7 @@ static int udl_get_modes(struct drm_connector *connector)
 static enum drm_mode_status udl_mode_valid(struct drm_connector *connector,
 			  struct drm_display_mode *mode)
 {
-	struct udl_device *udl = connector->dev->dev_private;
+	struct udl_device *udl = to_udl(connector->dev);
 	if (!udl->sku_pixel_limit)
 		return 0;
 
@@ -72,7 +72,7 @@ static enum drm_mode_status udl_mode_valid(struct drm_connector *connector,
 static enum drm_connector_status
 udl_detect(struct drm_connector *connector, bool force)
 {
-	struct udl_device *udl = connector->dev->dev_private;
+	struct udl_device *udl = to_udl(connector->dev);
 	struct udl_drm_connector *udl_connector =
 					container_of(connector,
 					struct udl_drm_connector,
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 523f60e02a85..d1aa50fd6d65 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -63,7 +63,6 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
 		return udl;
 
 	udl->udev = udev;
-	udl->drm.dev_private = udl;
 
 	r = udl_init(udl);
 	if (r)
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 8cad01f3d163..99518a826435 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -215,7 +215,7 @@ static char *udl_dummy_render(char *wrptr)
 static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct urb *urb;
 	char *buf;
 	int retval;
@@ -369,7 +369,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *dev = crtc->dev;
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct drm_display_mode *mode = &crtc_state->mode;
 	char *buf;
 	char *wrptr;
@@ -464,7 +464,7 @@ static const struct drm_mode_config_funcs udl_mode_funcs = {
 int udl_modeset_init(struct drm_device *dev)
 {
 	size_t format_count = ARRAY_SIZE(udl_simple_display_pipe_formats);
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct drm_connector *connector;
 	int ret;
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 12/59] drm/udl: don't set drm_device->dev_private
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Alexios Zavras, Laurent Pinchart,
	Thomas Zimmermann, Daniel Vetter, Dave Airlie, Thomas Gleixner,
	Sam Ravnborg, Allison Randal, Gerd Hoffmann

We're mostly there already, just a handful of places that didn't use
the to_udl container_of cast. To make sure no new appear, don't set
->dev_private.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "José Roberto de Souza" <jose.souza@intel.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Allison Randal <allison@lohutok.net>
---
 drivers/gpu/drm/udl/udl_connector.c | 4 ++--
 drivers/gpu/drm/udl/udl_drv.c       | 1 -
 drivers/gpu/drm/udl/udl_modeset.c   | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index 0afdfb0d1fe1..cdc1c42e1669 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -59,7 +59,7 @@ static int udl_get_modes(struct drm_connector *connector)
 static enum drm_mode_status udl_mode_valid(struct drm_connector *connector,
 			  struct drm_display_mode *mode)
 {
-	struct udl_device *udl = connector->dev->dev_private;
+	struct udl_device *udl = to_udl(connector->dev);
 	if (!udl->sku_pixel_limit)
 		return 0;
 
@@ -72,7 +72,7 @@ static enum drm_mode_status udl_mode_valid(struct drm_connector *connector,
 static enum drm_connector_status
 udl_detect(struct drm_connector *connector, bool force)
 {
-	struct udl_device *udl = connector->dev->dev_private;
+	struct udl_device *udl = to_udl(connector->dev);
 	struct udl_drm_connector *udl_connector =
 					container_of(connector,
 					struct udl_drm_connector,
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 523f60e02a85..d1aa50fd6d65 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -63,7 +63,6 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
 		return udl;
 
 	udl->udev = udev;
-	udl->drm.dev_private = udl;
 
 	r = udl_init(udl);
 	if (r)
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 8cad01f3d163..99518a826435 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -215,7 +215,7 @@ static char *udl_dummy_render(char *wrptr)
 static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct urb *urb;
 	char *buf;
 	int retval;
@@ -369,7 +369,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *dev = crtc->dev;
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct drm_display_mode *mode = &crtc_state->mode;
 	char *buf;
 	char *wrptr;
@@ -464,7 +464,7 @@ static const struct drm_mode_config_funcs udl_mode_funcs = {
 int udl_modeset_init(struct drm_device *dev)
 {
 	size_t format_count = ARRAY_SIZE(udl_simple_display_pipe_formats);
-	struct udl_device *udl = dev->dev_private;
+	struct udl_device *udl = to_udl(dev);
 	struct drm_connector *connector;
 	int ret;
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 13/59] drm/st7735r: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Aside: There was an oddity in the old code, we allocated priv but in
the error path we've freed priv->dbidev ...

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/st7735r.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/st7735r.c b/drivers/gpu/drm/tiny/st7735r.c
index 631801c36f46..ccbf49a53202 100644
--- a/drivers/gpu/drm/tiny/st7735r.c
+++ b/drivers/gpu/drm/tiny/st7735r.c
@@ -195,21 +195,16 @@ static int st7735r_probe(struct spi_device *spi)
 	if (!cfg)
 		cfg = (void *)spi_get_device_id(spi)->driver_data;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	priv = devm_drm_dev_alloc(dev, &st7735r_driver,
+				  struct st7735r_priv, dbidev.drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
 	dbidev = &priv->dbidev;
 	priv->cfg = cfg;
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &st7735r_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 13/59] drm/st7735r: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Aside: There was an oddity in the old code, we allocated priv but in
the error path we've freed priv->dbidev ...

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/st7735r.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/st7735r.c b/drivers/gpu/drm/tiny/st7735r.c
index 631801c36f46..ccbf49a53202 100644
--- a/drivers/gpu/drm/tiny/st7735r.c
+++ b/drivers/gpu/drm/tiny/st7735r.c
@@ -195,21 +195,16 @@ static int st7735r_probe(struct spi_device *spi)
 	if (!cfg)
 		cfg = (void *)spi_get_device_id(spi)->driver_data;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	priv = devm_drm_dev_alloc(dev, &st7735r_driver,
+				  struct st7735r_priv, dbidev.drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
 	dbidev = &priv->dbidev;
 	priv->cfg = cfg;
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &st7735r_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 14/59] drm/st7586: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/st7586.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index c3295c717ba6..2a1fae422f7a 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -317,18 +317,13 @@ static int st7586_probe(struct spi_device *spi)
 	size_t bufsize;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &st7586_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &st7586_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	bufsize = (st7586_mode.vdisplay + 2) / 3 * st7586_mode.hdisplay;
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 14/59] drm/st7586: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/st7586.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index c3295c717ba6..2a1fae422f7a 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -317,18 +317,13 @@ static int st7586_probe(struct spi_device *spi)
 	size_t bufsize;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &st7586_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &st7586_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	bufsize = (st7586_mode.vdisplay + 2) / 3 * st7586_mode.hdisplay;
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 15/59] drm/repaper: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
---
 drivers/gpu/drm/tiny/repaper.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 862c3ee6055d..1c0e7169545b 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -1002,19 +1002,13 @@ static int repaper_probe(struct spi_device *spi)
 		}
 	}
 
-	epd = kzalloc(sizeof(*epd), GFP_KERNEL);
-	if (!epd)
-		return -ENOMEM;
+	epd = devm_drm_dev_alloc(dev, &repaper_driver,
+				 struct repaper_epd, drm);
+	if (IS_ERR(epd))
+		return PTR_ERR(epd);
 
 	drm = &epd->drm;
 
-	ret = devm_drm_dev_init(dev, drm, &repaper_driver);
-	if (ret) {
-		kfree(epd);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, epd);
-
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 15/59] drm/repaper: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Noralf Trønnes, Sam Ravnborg,
	DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
---
 drivers/gpu/drm/tiny/repaper.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 862c3ee6055d..1c0e7169545b 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -1002,19 +1002,13 @@ static int repaper_probe(struct spi_device *spi)
 		}
 	}
 
-	epd = kzalloc(sizeof(*epd), GFP_KERNEL);
-	if (!epd)
-		return -ENOMEM;
+	epd = devm_drm_dev_alloc(dev, &repaper_driver,
+				 struct repaper_epd, drm);
+	if (IS_ERR(epd))
+		return PTR_ERR(epd);
 
 	drm = &epd->drm;
 
-	ret = devm_drm_dev_init(dev, drm, &repaper_driver);
-	if (ret) {
-		kfree(epd);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, epd);
-
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 16/59] drm/mi0283qt: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
---
 drivers/gpu/drm/tiny/mi0283qt.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index decaf57053ff..08ac549ab0f7 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -187,18 +187,13 @@ static int mi0283qt_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &mi0283qt_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 16/59] drm/mi0283qt: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Noralf Trønnes, Sam Ravnborg,
	DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
---
 drivers/gpu/drm/tiny/mi0283qt.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index decaf57053ff..08ac549ab0f7 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -187,18 +187,13 @@ static int mi0283qt_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &mi0283qt_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 17/59] drm/ili9486: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Daniel Vetter,
	Kamlesh Gurudasani, Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Kamlesh Gurudasani <kamlesh.gurudasani@gmail.com>
---
 drivers/gpu/drm/tiny/ili9486.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index c4079bf9e2c8..2702ea557d29 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -197,18 +197,13 @@ static int ili9486_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9486_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9486_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 17/59] drm/ili9486: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Noralf Trønnes,
	Daniel Vetter, Kamlesh Gurudasani, Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Kamlesh Gurudasani <kamlesh.gurudasani@gmail.com>
---
 drivers/gpu/drm/tiny/ili9486.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index c4079bf9e2c8..2702ea557d29 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -197,18 +197,13 @@ static int ili9486_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9486_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9486_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 18/59] drm/ili9341: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: David Lechner, Daniel Vetter, DRI Development, Daniel Vetter,
	Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Eric Anholt <eric@anholt.net>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/ili9341.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index e152de369019..bb819f45a5d3 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -183,18 +183,13 @@ static int ili9341_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9341_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9341_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 18/59] drm/ili9341: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: David Lechner, Daniel Vetter, DRI Development, Eric Anholt,
	Noralf Trønnes, Daniel Vetter, Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Eric Anholt <eric@anholt.net>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/ili9341.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index e152de369019..bb819f45a5d3 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -183,18 +183,13 @@ static int ili9341_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9341_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9341_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 19/59] drm/ili9225: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/ili9225.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index 118477af4491..d1a5ab6747d5 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -376,18 +376,13 @@ static int ili9225_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9225_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9225_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 19/59] drm/ili9225: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, David Lechner, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: David Lechner <david@lechnology.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: David Lechner <david@lechnology.com>
---
 drivers/gpu/drm/tiny/ili9225.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index 118477af4491..d1a5ab6747d5 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -376,18 +376,13 @@ static int ili9225_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &ili9225_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	dbi = &dbidev->dbi;
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &ili9225_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dbi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(dbi->reset)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 20/59] drm/hx8357d: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, Sam Ravnborg, DRI Development

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/tiny/hx8357d.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index af7f3d10aac3..b4bc358a3269 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -226,17 +226,12 @@ static int hx8357d_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &hx8357d_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &hx8357d_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
 	if (IS_ERR(dc)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 20/59] drm/hx8357d: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Daniel Vetter, Sam Ravnborg, DRI Development, Eric Anholt

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/tiny/hx8357d.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index af7f3d10aac3..b4bc358a3269 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -226,17 +226,12 @@ static int hx8357d_probe(struct spi_device *spi)
 	u32 rotation = 0;
 	int ret;
 
-	dbidev = kzalloc(sizeof(*dbidev), GFP_KERNEL);
-	if (!dbidev)
-		return -ENOMEM;
+	dbidev = devm_drm_dev_alloc(dev, &hx8357d_driver,
+				    struct mipi_dbi_dev, drm);
+	if (IS_ERR(dbidev))
+		return PTR_ERR(dbidev);
 
 	drm = &dbidev->drm;
-	ret = devm_drm_dev_init(dev, drm, &hx8357d_driver);
-	if (ret) {
-		kfree(dbidev);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, dbidev);
 
 	dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
 	if (IS_ERR(dc)) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 21/59] drm/gm12u320: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, Sam Ravnborg, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 6f0ea2827d62..907739a67bf6 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -631,22 +631,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
 	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
-	if (gm12u320 == NULL)
-		return -ENOMEM;
+	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
+				      struct gm12u320_device, dev);
+	if (IS_ERR(gm12u320))
+		return PTR_ERR(gm12u320);
 
 	gm12u320->udev = interface_to_usbdev(interface);
 	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
 	mutex_init(&gm12u320->fb_update.lock);
 
 	dev = &gm12u320->dev;
-	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
-	if (ret) {
-		kfree(gm12u320);
-		return ret;
-	}
 	dev->dev_private = gm12u320;
-	drmm_add_final_kfree(dev, gm12u320);
 
 	ret = drmm_mode_config_init(dev);
 	if (ret)
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 21/59] drm/gm12u320: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 6f0ea2827d62..907739a67bf6 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -631,22 +631,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
 	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
-	if (gm12u320 == NULL)
-		return -ENOMEM;
+	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
+				      struct gm12u320_device, dev);
+	if (IS_ERR(gm12u320))
+		return PTR_ERR(gm12u320);
 
 	gm12u320->udev = interface_to_usbdev(interface);
 	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
 	mutex_init(&gm12u320->fb_update.lock);
 
 	dev = &gm12u320->dev;
-	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
-	if (ret) {
-		kfree(gm12u320);
-		return ret;
-	}
 	dev->dev_private = gm12u320;
-	drmm_add_final_kfree(dev, gm12u320);
 
 	ret = drmm_mode_config_init(dev);
 	if (ret)
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Hans de Goede, Sam Ravnborg, DRI Development,
	Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/tiny/gm12u320.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 907739a67bf6..cc397671f689 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -98,6 +98,8 @@ struct gm12u320_device {
 	} fb_update;
 };
 
+#define to_gm12u320(__dev) container_of(__dev, struct gm12u320_device, dev)
+
 static const char cmd_data[CMD_SIZE] = {
 	0x55, 0x53, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00,
 	0x68, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff,
@@ -408,7 +410,7 @@ static void gm12u320_fb_update_work(struct work_struct *work)
 static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
 				   struct drm_rect *dirty)
 {
-	struct gm12u320_device *gm12u320 = fb->dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
 	struct drm_framebuffer *old_fb = NULL;
 	bool wakeup = false;
 
@@ -558,7 +560,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
 				 struct drm_plane_state *plane_state)
 {
 	struct drm_rect rect = { 0, 0, GM12U320_USER_WIDTH, GM12U320_HEIGHT };
-	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
 
 	gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT;
 	gm12u320_fb_mark_dirty(plane_state->fb, &rect);
@@ -566,7 +568,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
 
 static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
 
 	gm12u320_stop_fb_update(gm12u320);
 }
@@ -641,7 +643,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
 	mutex_init(&gm12u320->fb_update.lock);
 
 	dev = &gm12u320->dev;
-	dev->dev_private = gm12u320;
 
 	ret = drmm_mode_config_init(dev);
 	if (ret)
@@ -706,7 +707,7 @@ static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
 static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
 {
 	struct drm_device *dev = usb_get_intfdata(interface);
-	struct gm12u320_device *gm12u320 = dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(dev);
 
 	gm12u320_set_ecomode(gm12u320);
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/tiny/gm12u320.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 907739a67bf6..cc397671f689 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -98,6 +98,8 @@ struct gm12u320_device {
 	} fb_update;
 };
 
+#define to_gm12u320(__dev) container_of(__dev, struct gm12u320_device, dev)
+
 static const char cmd_data[CMD_SIZE] = {
 	0x55, 0x53, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00,
 	0x68, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff,
@@ -408,7 +410,7 @@ static void gm12u320_fb_update_work(struct work_struct *work)
 static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
 				   struct drm_rect *dirty)
 {
-	struct gm12u320_device *gm12u320 = fb->dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
 	struct drm_framebuffer *old_fb = NULL;
 	bool wakeup = false;
 
@@ -558,7 +560,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
 				 struct drm_plane_state *plane_state)
 {
 	struct drm_rect rect = { 0, 0, GM12U320_USER_WIDTH, GM12U320_HEIGHT };
-	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
 
 	gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT;
 	gm12u320_fb_mark_dirty(plane_state->fb, &rect);
@@ -566,7 +568,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
 
 static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
 
 	gm12u320_stop_fb_update(gm12u320);
 }
@@ -641,7 +643,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
 	mutex_init(&gm12u320->fb_update.lock);
 
 	dev = &gm12u320->dev;
-	dev->dev_private = gm12u320;
 
 	ret = drmm_mode_config_init(dev);
 	if (ret)
@@ -706,7 +707,7 @@ static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
 static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
 {
 	struct drm_device *dev = usb_get_intfdata(interface);
-	struct gm12u320_device *gm12u320 = dev->dev_private;
+	struct gm12u320_device *gm12u320 = to_gm12u320(dev);
 
 	gm12u320_set_ecomode(gm12u320);
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index ad449d104306..7d4465d58be8 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -135,20 +135,13 @@ static int tidss_probe(struct platform_device *pdev)
 
 	dev_dbg(dev, "%s\n", __func__);
 
-	/* Can't use devm_* since drm_device's lifetime may exceed dev's */
-	tidss = kzalloc(sizeof(*tidss), GFP_KERNEL);
-	if (!tidss)
-		return -ENOMEM;
+	tidss = devm_drm_dev_alloc(&pdev->dev, &tidss_driver,
+				   struct tidss_device, ddev);
+	if (IS_ERR(tidss))
+		return PTR_ERR(tidss);
 
 	ddev = &tidss->ddev;
 
-	ret = devm_drm_dev_init(&pdev->dev, ddev, &tidss_driver);
-	if (ret) {
-		kfree(ddev);
-		return ret;
-	}
-	drmm_add_final_kfree(ddev, tidss);
-
 	tidss->dev = dev;
 	tidss->feat = of_device_get_match_data(dev);
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Already using devm_drm_dev_init, so very simple replacment.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index ad449d104306..7d4465d58be8 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -135,20 +135,13 @@ static int tidss_probe(struct platform_device *pdev)
 
 	dev_dbg(dev, "%s\n", __func__);
 
-	/* Can't use devm_* since drm_device's lifetime may exceed dev's */
-	tidss = kzalloc(sizeof(*tidss), GFP_KERNEL);
-	if (!tidss)
-		return -ENOMEM;
+	tidss = devm_drm_dev_alloc(&pdev->dev, &tidss_driver,
+				   struct tidss_device, ddev);
+	if (IS_ERR(tidss))
+		return PTR_ERR(tidss);
 
 	ddev = &tidss->ddev;
 
-	ret = devm_drm_dev_init(&pdev->dev, ddev, &tidss_driver);
-	if (ret) {
-		kfree(ddev);
-		return ret;
-	}
-	drmm_add_final_kfree(ddev, tidss);
-
 	tidss->dev = dev;
 	tidss->feat = of_device_get_match_data(dev);
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:39   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_crtc.c  | 16 ++++++++--------
 drivers/gpu/drm/tidss/tidss_drv.c   |  2 --
 drivers/gpu/drm/tidss/tidss_drv.h   |  2 ++
 drivers/gpu/drm/tidss/tidss_irq.c   | 12 ++++++------
 drivers/gpu/drm/tidss/tidss_kms.c   |  2 +-
 drivers/gpu/drm/tidss/tidss_plane.c |  6 +++---
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c b/drivers/gpu/drm/tidss/tidss_crtc.c
index d4ce9bab8c7e..2396262c09e4 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -24,7 +24,7 @@
 static void tidss_crtc_finish_page_flip(struct tidss_crtc *tcrtc)
 {
 	struct drm_device *ddev = tcrtc->crtc.dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct drm_pending_vblank_event *event;
 	unsigned long flags;
 	bool busy;
@@ -88,7 +88,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
 				   struct drm_crtc_state *state)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct dispc_device *dispc = tidss->dispc;
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
@@ -165,7 +165,7 @@ static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 
 	dev_dbg(ddev->dev,
@@ -216,7 +216,7 @@ static void tidss_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 	unsigned long flags;
 	int r;
@@ -259,7 +259,7 @@ static void tidss_crtc_atomic_disable(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 
 	dev_dbg(ddev->dev, "%s, event %p\n", __func__, crtc->state->event);
@@ -295,7 +295,7 @@ enum drm_mode_status tidss_crtc_mode_valid(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	return dispc_vp_mode_valid(tidss->dispc, tcrtc->hw_videoport, mode);
 }
@@ -314,7 +314,7 @@ static const struct drm_crtc_helper_funcs tidss_crtc_helper_funcs = {
 static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
@@ -328,7 +328,7 @@ static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 static void tidss_crtc_disable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index 7d4465d58be8..99edc66ebdef 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -147,8 +147,6 @@ static int tidss_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, tidss);
 
-	ddev->dev_private = tidss;
-
 	ret = dispc_init(tidss);
 	if (ret) {
 		dev_err(dev, "failed to initialize dispc: %d\n", ret);
diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
index e2aa6436ad18..b23cd95c8d78 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.h
+++ b/drivers/gpu/drm/tidss/tidss_drv.h
@@ -33,6 +33,8 @@ struct tidss_device {
 	struct drm_atomic_state *saved_state;
 };
 
+#define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
+
 int tidss_runtime_get(struct tidss_device *tidss);
 void tidss_runtime_put(struct tidss_device *tidss);
 
diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c
index 612c046738e5..1b80f2d62e0a 100644
--- a/drivers/gpu/drm/tidss/tidss_irq.c
+++ b/drivers/gpu/drm/tidss/tidss_irq.c
@@ -23,7 +23,7 @@ static void tidss_irq_update(struct tidss_device *tidss)
 void tidss_irq_enable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
 	unsigned long flags;
@@ -38,7 +38,7 @@ void tidss_irq_enable_vblank(struct drm_crtc *crtc)
 void tidss_irq_disable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
 	unsigned long flags;
@@ -53,7 +53,7 @@ void tidss_irq_disable_vblank(struct drm_crtc *crtc)
 irqreturn_t tidss_irq_handler(int irq, void *arg)
 {
 	struct drm_device *ddev = (struct drm_device *)arg;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned int id;
 	dispc_irq_t irqstatus;
 
@@ -95,7 +95,7 @@ void tidss_irq_resume(struct tidss_device *tidss)
 
 void tidss_irq_preinstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	spin_lock_init(&tidss->wait_lock);
 
@@ -109,7 +109,7 @@ void tidss_irq_preinstall(struct drm_device *ddev)
 
 int tidss_irq_postinstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 	unsigned int i;
 
@@ -138,7 +138,7 @@ int tidss_irq_postinstall(struct drm_device *ddev)
 
 void tidss_irq_uninstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	tidss_runtime_get(tidss);
 	dispc_set_irqenable(tidss->dispc, 0);
diff --git a/drivers/gpu/drm/tidss/tidss_kms.c b/drivers/gpu/drm/tidss/tidss_kms.c
index 4bd339a467a4..4b99e9fa84a5 100644
--- a/drivers/gpu/drm/tidss/tidss_kms.c
+++ b/drivers/gpu/drm/tidss/tidss_kms.c
@@ -25,7 +25,7 @@
 static void tidss_atomic_commit_tail(struct drm_atomic_state *old_state)
 {
 	struct drm_device *ddev = old_state->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
diff --git a/drivers/gpu/drm/tidss/tidss_plane.c b/drivers/gpu/drm/tidss/tidss_plane.c
index ff99b2dd4a17..23bb3e59504b 100644
--- a/drivers/gpu/drm/tidss/tidss_plane.c
+++ b/drivers/gpu/drm/tidss/tidss_plane.c
@@ -22,7 +22,7 @@ static int tidss_plane_atomic_check(struct drm_plane *plane,
 				    struct drm_plane_state *state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 	const struct drm_format_info *finfo;
 	struct drm_crtc_state *crtc_state;
@@ -101,7 +101,7 @@ static void tidss_plane_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 	struct drm_plane_state *state = plane->state;
 	u32 hw_videoport;
@@ -133,7 +133,7 @@ static void tidss_plane_atomic_disable(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private
@ 2020-04-15  7:39   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:39 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_crtc.c  | 16 ++++++++--------
 drivers/gpu/drm/tidss/tidss_drv.c   |  2 --
 drivers/gpu/drm/tidss/tidss_drv.h   |  2 ++
 drivers/gpu/drm/tidss/tidss_irq.c   | 12 ++++++------
 drivers/gpu/drm/tidss/tidss_kms.c   |  2 +-
 drivers/gpu/drm/tidss/tidss_plane.c |  6 +++---
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c b/drivers/gpu/drm/tidss/tidss_crtc.c
index d4ce9bab8c7e..2396262c09e4 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -24,7 +24,7 @@
 static void tidss_crtc_finish_page_flip(struct tidss_crtc *tcrtc)
 {
 	struct drm_device *ddev = tcrtc->crtc.dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct drm_pending_vblank_event *event;
 	unsigned long flags;
 	bool busy;
@@ -88,7 +88,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
 				   struct drm_crtc_state *state)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct dispc_device *dispc = tidss->dispc;
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
@@ -165,7 +165,7 @@ static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 
 	dev_dbg(ddev->dev,
@@ -216,7 +216,7 @@ static void tidss_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 	unsigned long flags;
 	int r;
@@ -259,7 +259,7 @@ static void tidss_crtc_atomic_disable(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 
 	dev_dbg(ddev->dev, "%s, event %p\n", __func__, crtc->state->event);
@@ -295,7 +295,7 @@ enum drm_mode_status tidss_crtc_mode_valid(struct drm_crtc *crtc,
 {
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	return dispc_vp_mode_valid(tidss->dispc, tcrtc->hw_videoport, mode);
 }
@@ -314,7 +314,7 @@ static const struct drm_crtc_helper_funcs tidss_crtc_helper_funcs = {
 static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
@@ -328,7 +328,7 @@ static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 static void tidss_crtc_disable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c
index 7d4465d58be8..99edc66ebdef 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -147,8 +147,6 @@ static int tidss_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, tidss);
 
-	ddev->dev_private = tidss;
-
 	ret = dispc_init(tidss);
 	if (ret) {
 		dev_err(dev, "failed to initialize dispc: %d\n", ret);
diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
index e2aa6436ad18..b23cd95c8d78 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.h
+++ b/drivers/gpu/drm/tidss/tidss_drv.h
@@ -33,6 +33,8 @@ struct tidss_device {
 	struct drm_atomic_state *saved_state;
 };
 
+#define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
+
 int tidss_runtime_get(struct tidss_device *tidss);
 void tidss_runtime_put(struct tidss_device *tidss);
 
diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c
index 612c046738e5..1b80f2d62e0a 100644
--- a/drivers/gpu/drm/tidss/tidss_irq.c
+++ b/drivers/gpu/drm/tidss/tidss_irq.c
@@ -23,7 +23,7 @@ static void tidss_irq_update(struct tidss_device *tidss)
 void tidss_irq_enable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
 	unsigned long flags;
@@ -38,7 +38,7 @@ void tidss_irq_enable_vblank(struct drm_crtc *crtc)
 void tidss_irq_disable_vblank(struct drm_crtc *crtc)
 {
 	struct drm_device *ddev = crtc->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 	u32 hw_videoport = tcrtc->hw_videoport;
 	unsigned long flags;
@@ -53,7 +53,7 @@ void tidss_irq_disable_vblank(struct drm_crtc *crtc)
 irqreturn_t tidss_irq_handler(int irq, void *arg)
 {
 	struct drm_device *ddev = (struct drm_device *)arg;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned int id;
 	dispc_irq_t irqstatus;
 
@@ -95,7 +95,7 @@ void tidss_irq_resume(struct tidss_device *tidss)
 
 void tidss_irq_preinstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	spin_lock_init(&tidss->wait_lock);
 
@@ -109,7 +109,7 @@ void tidss_irq_preinstall(struct drm_device *ddev)
 
 int tidss_irq_postinstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	unsigned long flags;
 	unsigned int i;
 
@@ -138,7 +138,7 @@ int tidss_irq_postinstall(struct drm_device *ddev)
 
 void tidss_irq_uninstall(struct drm_device *ddev)
 {
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	tidss_runtime_get(tidss);
 	dispc_set_irqenable(tidss->dispc, 0);
diff --git a/drivers/gpu/drm/tidss/tidss_kms.c b/drivers/gpu/drm/tidss/tidss_kms.c
index 4bd339a467a4..4b99e9fa84a5 100644
--- a/drivers/gpu/drm/tidss/tidss_kms.c
+++ b/drivers/gpu/drm/tidss/tidss_kms.c
@@ -25,7 +25,7 @@
 static void tidss_atomic_commit_tail(struct drm_atomic_state *old_state)
 {
 	struct drm_device *ddev = old_state->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
 
diff --git a/drivers/gpu/drm/tidss/tidss_plane.c b/drivers/gpu/drm/tidss/tidss_plane.c
index ff99b2dd4a17..23bb3e59504b 100644
--- a/drivers/gpu/drm/tidss/tidss_plane.c
+++ b/drivers/gpu/drm/tidss/tidss_plane.c
@@ -22,7 +22,7 @@ static int tidss_plane_atomic_check(struct drm_plane *plane,
 				    struct drm_plane_state *state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 	const struct drm_format_info *finfo;
 	struct drm_crtc_state *crtc_state;
@@ -101,7 +101,7 @@ static void tidss_plane_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 	struct drm_plane_state *state = plane->state;
 	u32 hw_videoport;
@@ -133,7 +133,7 @@ static void tidss_plane_atomic_disable(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
 	struct drm_device *ddev = plane->dev;
-	struct tidss_device *tidss = ddev->dev_private;
+	struct tidss_device *tidss = to_tidss(ddev);
 	struct tidss_plane *tplane = to_tidss_plane(plane);
 
 	dev_dbg(ddev->dev, "%s\n", __func__);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 25/59] drm/tidss: Delete tidss->saved_state
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Not used anymore since the switch to suspend/resume helpers.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_drv.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
index b23cd95c8d78..3b0a3d87b7c4 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.h
+++ b/drivers/gpu/drm/tidss/tidss_drv.h
@@ -29,8 +29,6 @@ struct tidss_device {
 
 	spinlock_t wait_lock;	/* protects the irq masks */
 	dispc_irq_t irq_mask;	/* enabled irqs in addition to wait_list */
-
-	struct drm_atomic_state *saved_state;
 };
 
 #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 25/59] drm/tidss: Delete tidss->saved_state
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Jyri Sarha, Tomi Valkeinen, DRI Development,
	Daniel Vetter, Sam Ravnborg

Not used anymore since the switch to suspend/resume helpers.

Tested-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/tidss/tidss_drv.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
index b23cd95c8d78..3b0a3d87b7c4 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.h
+++ b/drivers/gpu/drm/tidss/tidss_drv.h
@@ -29,8 +29,6 @@ struct tidss_device {
 
 	spinlock_t wait_lock;	/* protects the irq masks */
 	dispc_irq_t irq_mask;	/* enabled irqs in addition to wait_list */
-
-	struct drm_atomic_state *saved_state;
 };
 
 #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Daniel Vetter, Dave Airlie

Also need to remove the drm_dev_put from the remove hook.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
 drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
 drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 09102e2efabc..6b4ae4c5fb76 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -EINVAL; /* TODO: ENODEV ? */
 	}
 
-	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
-	if (!qdev)
+	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
+				  struct qxl_device, ddev);
+	if (IS_ERR(qdev)) {
+		pr_err("Unable to init drm dev");
 		return -ENOMEM;
+	}
 
 	ret = pci_enable_device(pdev);
 	if (ret)
-		goto free_dev;
+		return ret;
 
 	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
 	if (ret)
@@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		}
 	}
 
-	ret = qxl_device_init(qdev, &qxl_driver, pdev);
+	ret = qxl_device_init(qdev, pdev);
 	if (ret)
 		goto put_vga;
 
@@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
 disable_pci:
 	pci_disable_device(pdev);
-free_dev:
-	kfree(qdev);
+
 	return ret;
 }
 
@@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
 	drm_atomic_helper_shutdown(dev);
 	if (is_vga(pdev))
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
-	drm_dev_put(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(qxl_fops);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 435126facc9b..86ac191d9205 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -276,8 +276,7 @@ struct qxl_device {
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
-int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
-		    struct pci_dev *pdev);
+int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
 void qxl_device_fini(struct qxl_device *qdev);
 
 int qxl_modeset_init(struct qxl_device *qdev);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 9eed1a375f24..91a34dd835d7 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
 }
 
 int qxl_device_init(struct qxl_device *qdev,
-		    struct drm_driver *drv,
 		    struct pci_dev *pdev)
 {
 	int r, sb;
 
-	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
-	if (r) {
-		pr_err("Unable to init drm dev");
-		goto error;
-	}
-
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
 	qdev->ddev.dev_private = qdev;
-	drmm_add_final_kfree(&qdev->ddev, qdev);
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
@@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
 	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
 	if (!qdev->vram_mapping) {
 		pr_err("Unable to create vram_mapping");
-		r = -ENOMEM;
-		goto error;
+		return -ENOMEM;
 	}
 
 	if (pci_resource_len(pdev, 4) > 0) {
@@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
 	io_mapping_free(qdev->surface_mapping);
 vram_mapping_free:
 	io_mapping_free(qdev->vram_mapping);
-error:
 	return r;
 }
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie

Also need to remove the drm_dev_put from the remove hook.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
 drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
 drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 09102e2efabc..6b4ae4c5fb76 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -EINVAL; /* TODO: ENODEV ? */
 	}
 
-	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
-	if (!qdev)
+	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
+				  struct qxl_device, ddev);
+	if (IS_ERR(qdev)) {
+		pr_err("Unable to init drm dev");
 		return -ENOMEM;
+	}
 
 	ret = pci_enable_device(pdev);
 	if (ret)
-		goto free_dev;
+		return ret;
 
 	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
 	if (ret)
@@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		}
 	}
 
-	ret = qxl_device_init(qdev, &qxl_driver, pdev);
+	ret = qxl_device_init(qdev, pdev);
 	if (ret)
 		goto put_vga;
 
@@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
 disable_pci:
 	pci_disable_device(pdev);
-free_dev:
-	kfree(qdev);
+
 	return ret;
 }
 
@@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
 	drm_atomic_helper_shutdown(dev);
 	if (is_vga(pdev))
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
-	drm_dev_put(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(qxl_fops);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 435126facc9b..86ac191d9205 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -276,8 +276,7 @@ struct qxl_device {
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
-int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
-		    struct pci_dev *pdev);
+int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
 void qxl_device_fini(struct qxl_device *qdev);
 
 int qxl_modeset_init(struct qxl_device *qdev);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 9eed1a375f24..91a34dd835d7 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
 }
 
 int qxl_device_init(struct qxl_device *qdev,
-		    struct drm_driver *drv,
 		    struct pci_dev *pdev)
 {
 	int r, sb;
 
-	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
-	if (r) {
-		pr_err("Unable to init drm dev");
-		goto error;
-	}
-
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
 	qdev->ddev.dev_private = qdev;
-	drmm_add_final_kfree(&qdev->ddev, qdev);
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
@@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
 	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
 	if (!qdev->vram_mapping) {
 		pr_err("Unable to create vram_mapping");
-		r = -ENOMEM;
-		goto error;
+		return -ENOMEM;
 	}
 
 	if (pci_resource_len(pdev, 4) > 0) {
@@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
 	io_mapping_free(qdev->surface_mapping);
 vram_mapping_free:
 	io_mapping_free(qdev->vram_mapping);
-error:
 	return r;
 }
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie

Also need to remove the drm_dev_put from the remove hook.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
 drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
 drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 09102e2efabc..6b4ae4c5fb76 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -EINVAL; /* TODO: ENODEV ? */
 	}
 
-	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
-	if (!qdev)
+	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
+				  struct qxl_device, ddev);
+	if (IS_ERR(qdev)) {
+		pr_err("Unable to init drm dev");
 		return -ENOMEM;
+	}
 
 	ret = pci_enable_device(pdev);
 	if (ret)
-		goto free_dev;
+		return ret;
 
 	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
 	if (ret)
@@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		}
 	}
 
-	ret = qxl_device_init(qdev, &qxl_driver, pdev);
+	ret = qxl_device_init(qdev, pdev);
 	if (ret)
 		goto put_vga;
 
@@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
 disable_pci:
 	pci_disable_device(pdev);
-free_dev:
-	kfree(qdev);
+
 	return ret;
 }
 
@@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
 	drm_atomic_helper_shutdown(dev);
 	if (is_vga(pdev))
 		vga_put(pdev, VGA_RSRC_LEGACY_IO);
-	drm_dev_put(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(qxl_fops);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 435126facc9b..86ac191d9205 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -276,8 +276,7 @@ struct qxl_device {
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
-int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
-		    struct pci_dev *pdev);
+int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
 void qxl_device_fini(struct qxl_device *qdev);
 
 int qxl_modeset_init(struct qxl_device *qdev);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 9eed1a375f24..91a34dd835d7 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
 }
 
 int qxl_device_init(struct qxl_device *qdev,
-		    struct drm_driver *drv,
 		    struct pci_dev *pdev)
 {
 	int r, sb;
 
-	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
-	if (r) {
-		pr_err("Unable to init drm dev");
-		goto error;
-	}
-
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
 	qdev->ddev.dev_private = qdev;
-	drmm_add_final_kfree(&qdev->ddev, qdev);
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
@@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
 	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
 	if (!qdev->vram_mapping) {
 		pr_err("Unable to create vram_mapping");
-		r = -ENOMEM;
-		goto error;
+		return -ENOMEM;
 	}
 
 	if (pci_resource_len(pdev, 4) > 0) {
@@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
 	io_mapping_free(qdev->surface_mapping);
 vram_mapping_free:
 	io_mapping_free(qdev->vram_mapping);
-error:
 	return r;
 }
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Daniel Vetter, Dave Airlie

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
 drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
 drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
 drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
 drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
 drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
 drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
 drivers/gpu/drm/qxl/qxl_release.c |  2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
 12 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
index 88123047fdd4..524d35b648d8 100644
--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
@@ -39,7 +39,7 @@ static int
 qxl_debugfs_irq_received(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
@@ -53,7 +53,7 @@ static int
 qxl_debugfs_buffers_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 	struct qxl_bo *bo;
 
 	list_for_each_entry(bo, &qdev->gem.objects, list) {
@@ -83,8 +83,7 @@ void
 qxl_debugfs_init(struct drm_minor *minor)
 {
 #if defined(CONFIG_DEBUG_FS)
-	struct qxl_device *dev =
-		(struct qxl_device *) minor->dev->dev_private;
+	struct qxl_device *dev = to_qxl(minor->dev);
 
 	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
 				 minor->debugfs_root, minor);
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 09583a08e141..1082cd5d2fd4 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 			bool preferred)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_display_mode *mode = NULL;
 	int rc;
 
@@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 static int qxl_add_monitors_config_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	int h = output->index;
 	struct qxl_head *head;
@@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 					    const char *reason)
 {
 	struct drm_device *dev = crtc->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
 	struct qxl_head head;
 	int oldcount, i = qcrtc->index;
@@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 					 unsigned int num_clips)
 {
 	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
-	struct qxl_device *qdev = fb->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(fb->dev);
 	struct drm_clip_rect norect;
 	struct qxl_bo *qobj;
 	bool is_primary;
@@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
 static int qxl_primary_atomic_check(struct drm_plane *plane,
 				    struct drm_plane_state *state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo;
 
 	if (!state->crtc || !state->fb)
@@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
 static int qxl_primary_apply_cursor(struct drm_plane *plane)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_cursor_cmd *cmd;
@@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
 static void qxl_primary_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
 	struct qxl_bo *primary;
 	struct drm_clip_rect norect = {
@@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
 static void qxl_primary_atomic_disable(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 
 	if (old_state->fb) {
 		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
@@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 				     struct drm_plane_state *old_state)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_release *release;
@@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 static void qxl_cursor_atomic_disable(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_release *release;
 	struct qxl_cursor_cmd *cmd;
 	int ret;
@@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
 static int qxl_plane_prepare_fb(struct drm_plane *plane,
 				struct drm_plane_state *new_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct drm_gem_object *obj;
 	struct qxl_bo *user_bo;
 	struct qxl_surface surf;
@@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 {
 	struct qxl_crtc *qxl_crtc;
 	struct drm_plane *primary, *cursor;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int r;
 
 	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
@@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	unsigned int pwidth = 1024;
 	unsigned int pheight = 768;
@@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
 			       struct drm_display_mode *mode)
 {
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 
 	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
 		return MODE_BAD;
@@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
 	struct qxl_output *output =
 		drm_connector_to_qxl_output(connector);
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 	bool connected = false;
 
 	/* The first monitor is always connected */
@@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
 
 static int qdev_output_init(struct drm_device *dev, int num_output)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *qxl_output;
 	struct drm_connector *connector;
 	struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 6b4ae4c5fb76..13872b882775 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 static void qxl_drm_release(struct drm_device *dev)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	/*
 	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
@@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
 static int qxl_drm_freeze(struct drm_device *dev)
 {
 	struct pci_dev *pdev = dev->pdev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int ret;
 
 	ret = drm_mode_config_helper_suspend(dev);
@@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
 
 static int qxl_drm_resume(struct drm_device *dev, bool thaw)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
 	if (!thaw) {
@@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct qxl_device *qdev = drm_dev->dev_private;
+	struct qxl_device *qdev = to_qxl(drm_dev);
 
 	qxl_io_reset(qdev);
 	return qxl_drm_resume(drm_dev, false);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 86ac191d9205..31e35f787df2 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -192,8 +192,6 @@ struct qxl_debugfs {
 
 int qxl_debugfs_fence_init(struct qxl_device *rdev);
 
-struct qxl_device;
-
 struct qxl_device {
 	struct drm_device ddev;
 
@@ -273,6 +271,8 @@ struct qxl_device {
 	int monitors_config_height;
 };
 
+#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
+
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 272d19b677d8..24e903383aa1 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
 			    struct drm_device *dev,
 			    struct drm_mode_create_dumb *args)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_bo *qobj;
 	uint32_t handle;
 	int r;
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index 69f37db1027a..5ff6fa9b799c 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
 	struct qxl_device *qdev;
 	struct ttm_buffer_object *tbo;
 
-	qdev = (struct qxl_device *)gobj->dev->dev_private;
+	qdev = to_qxl(gobj->dev);
 
 	qxl_surface_evict(qdev, qobj, false);
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 8117a45b3610..d9a583966949 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -36,7 +36,7 @@
 static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc *qxl_alloc = data;
 	int ret;
 	struct qxl_bo *qobj;
@@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 static int qxl_map_ioctl(struct drm_device *dev, void *data,
 			 struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_map *qxl_map = data;
 
 	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
@@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
 static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_execbuffer *execbuffer = data;
 	struct drm_qxl_command user_cmd;
 	int cmd_num;
@@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 				 struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_update_area *update_area = data;
 	struct qxl_rect area = {.left = update_area->left,
 				.top = update_area->top,
@@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_getparam *param = data;
 
 	switch (param->param) {
@@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_clientcap *param = data;
 	int byte, idx;
 
@@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc_surf *param = data;
 	struct qxl_bo *qobj;
 	int handle;
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 8435af108632..1ba5a702d763 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -32,7 +32,7 @@
 irqreturn_t qxl_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
-	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	uint32_t pending;
 
 	pending = xchg(&qdev->ram_header->int_pending, 0);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 91a34dd835d7..a6d873052cd4 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
 
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
-	qdev->ddev.dev_private = qdev;
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index ab72dc3476e9..edc8a9916872 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 	struct qxl_device *qdev;
 
 	bo = to_qxl_bo(tbo);
-	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
+	qdev = to_qxl(bo->tbo.base.dev);
 
 	qxl_surface_evict(qdev, bo, false);
 	WARN_ON_ONCE(bo->map_count > 0);
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 2feca734c7b1..4fae3e393da1 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
 		return ret;
 
 	/* allocate a surface for reserved + validated buffers */
-	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
+	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
 	if (ret)
 		return ret;
 	return 0;
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 93a2eb14844b..f09a712b1ed2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
 	if (!qxl_ttm_bo_is_qxl_bo(bo))
 		return;
 	qbo = to_qxl_bo(bo);
-	qdev = qbo->tbo.base.dev->dev_private;
+	qdev = to_qxl(qbo->tbo.base.dev);
 
 	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
 		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
 drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
 drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
 drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
 drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
 drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
 drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
 drivers/gpu/drm/qxl/qxl_release.c |  2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
 12 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
index 88123047fdd4..524d35b648d8 100644
--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
@@ -39,7 +39,7 @@ static int
 qxl_debugfs_irq_received(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
@@ -53,7 +53,7 @@ static int
 qxl_debugfs_buffers_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 	struct qxl_bo *bo;
 
 	list_for_each_entry(bo, &qdev->gem.objects, list) {
@@ -83,8 +83,7 @@ void
 qxl_debugfs_init(struct drm_minor *minor)
 {
 #if defined(CONFIG_DEBUG_FS)
-	struct qxl_device *dev =
-		(struct qxl_device *) minor->dev->dev_private;
+	struct qxl_device *dev = to_qxl(minor->dev);
 
 	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
 				 minor->debugfs_root, minor);
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 09583a08e141..1082cd5d2fd4 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 			bool preferred)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_display_mode *mode = NULL;
 	int rc;
 
@@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 static int qxl_add_monitors_config_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	int h = output->index;
 	struct qxl_head *head;
@@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 					    const char *reason)
 {
 	struct drm_device *dev = crtc->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
 	struct qxl_head head;
 	int oldcount, i = qcrtc->index;
@@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 					 unsigned int num_clips)
 {
 	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
-	struct qxl_device *qdev = fb->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(fb->dev);
 	struct drm_clip_rect norect;
 	struct qxl_bo *qobj;
 	bool is_primary;
@@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
 static int qxl_primary_atomic_check(struct drm_plane *plane,
 				    struct drm_plane_state *state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo;
 
 	if (!state->crtc || !state->fb)
@@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
 static int qxl_primary_apply_cursor(struct drm_plane *plane)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_cursor_cmd *cmd;
@@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
 static void qxl_primary_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
 	struct qxl_bo *primary;
 	struct drm_clip_rect norect = {
@@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
 static void qxl_primary_atomic_disable(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 
 	if (old_state->fb) {
 		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
@@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 				     struct drm_plane_state *old_state)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_release *release;
@@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 static void qxl_cursor_atomic_disable(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_release *release;
 	struct qxl_cursor_cmd *cmd;
 	int ret;
@@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
 static int qxl_plane_prepare_fb(struct drm_plane *plane,
 				struct drm_plane_state *new_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct drm_gem_object *obj;
 	struct qxl_bo *user_bo;
 	struct qxl_surface surf;
@@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 {
 	struct qxl_crtc *qxl_crtc;
 	struct drm_plane *primary, *cursor;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int r;
 
 	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
@@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	unsigned int pwidth = 1024;
 	unsigned int pheight = 768;
@@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
 			       struct drm_display_mode *mode)
 {
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 
 	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
 		return MODE_BAD;
@@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
 	struct qxl_output *output =
 		drm_connector_to_qxl_output(connector);
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 	bool connected = false;
 
 	/* The first monitor is always connected */
@@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
 
 static int qdev_output_init(struct drm_device *dev, int num_output)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *qxl_output;
 	struct drm_connector *connector;
 	struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 6b4ae4c5fb76..13872b882775 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 static void qxl_drm_release(struct drm_device *dev)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	/*
 	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
@@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
 static int qxl_drm_freeze(struct drm_device *dev)
 {
 	struct pci_dev *pdev = dev->pdev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int ret;
 
 	ret = drm_mode_config_helper_suspend(dev);
@@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
 
 static int qxl_drm_resume(struct drm_device *dev, bool thaw)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
 	if (!thaw) {
@@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct qxl_device *qdev = drm_dev->dev_private;
+	struct qxl_device *qdev = to_qxl(drm_dev);
 
 	qxl_io_reset(qdev);
 	return qxl_drm_resume(drm_dev, false);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 86ac191d9205..31e35f787df2 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -192,8 +192,6 @@ struct qxl_debugfs {
 
 int qxl_debugfs_fence_init(struct qxl_device *rdev);
 
-struct qxl_device;
-
 struct qxl_device {
 	struct drm_device ddev;
 
@@ -273,6 +271,8 @@ struct qxl_device {
 	int monitors_config_height;
 };
 
+#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
+
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 272d19b677d8..24e903383aa1 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
 			    struct drm_device *dev,
 			    struct drm_mode_create_dumb *args)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_bo *qobj;
 	uint32_t handle;
 	int r;
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index 69f37db1027a..5ff6fa9b799c 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
 	struct qxl_device *qdev;
 	struct ttm_buffer_object *tbo;
 
-	qdev = (struct qxl_device *)gobj->dev->dev_private;
+	qdev = to_qxl(gobj->dev);
 
 	qxl_surface_evict(qdev, qobj, false);
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 8117a45b3610..d9a583966949 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -36,7 +36,7 @@
 static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc *qxl_alloc = data;
 	int ret;
 	struct qxl_bo *qobj;
@@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 static int qxl_map_ioctl(struct drm_device *dev, void *data,
 			 struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_map *qxl_map = data;
 
 	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
@@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
 static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_execbuffer *execbuffer = data;
 	struct drm_qxl_command user_cmd;
 	int cmd_num;
@@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 				 struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_update_area *update_area = data;
 	struct qxl_rect area = {.left = update_area->left,
 				.top = update_area->top,
@@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_getparam *param = data;
 
 	switch (param->param) {
@@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_clientcap *param = data;
 	int byte, idx;
 
@@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc_surf *param = data;
 	struct qxl_bo *qobj;
 	int handle;
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 8435af108632..1ba5a702d763 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -32,7 +32,7 @@
 irqreturn_t qxl_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
-	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	uint32_t pending;
 
 	pending = xchg(&qdev->ram_header->int_pending, 0);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 91a34dd835d7..a6d873052cd4 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
 
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
-	qdev->ddev.dev_private = qdev;
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index ab72dc3476e9..edc8a9916872 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 	struct qxl_device *qdev;
 
 	bo = to_qxl_bo(tbo);
-	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
+	qdev = to_qxl(bo->tbo.base.dev);
 
 	qxl_surface_evict(qdev, bo, false);
 	WARN_ON_ONCE(bo->map_count > 0);
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 2feca734c7b1..4fae3e393da1 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
 		return ret;
 
 	/* allocate a surface for reserved + validated buffers */
-	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
+	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
 	if (ret)
 		return ret;
 	return 0;
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 93a2eb14844b..f09a712b1ed2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
 	if (!qxl_ttm_bo_is_qxl_bo(bo))
 		return;
 	qbo = to_qxl_bo(bo);
-	qdev = qbo->tbo.base.dev->dev_private;
+	qdev = to_qxl(qbo->tbo.base.dev);
 
 	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
 		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: spice-devel, Daniel Vetter, DRI Development, virtualization,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: spice-devel@lists.freedesktop.org
---
 drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
 drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
 drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
 drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
 drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
 drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
 drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
 drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
 drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
 drivers/gpu/drm/qxl/qxl_release.c |  2 +-
 drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
 12 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
index 88123047fdd4..524d35b648d8 100644
--- a/drivers/gpu/drm/qxl/qxl_debugfs.c
+++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
@@ -39,7 +39,7 @@ static int
 qxl_debugfs_irq_received(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
@@ -53,7 +53,7 @@ static int
 qxl_debugfs_buffers_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = node->minor->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(node->minor->dev);
 	struct qxl_bo *bo;
 
 	list_for_each_entry(bo, &qdev->gem.objects, list) {
@@ -83,8 +83,7 @@ void
 qxl_debugfs_init(struct drm_minor *minor)
 {
 #if defined(CONFIG_DEBUG_FS)
-	struct qxl_device *dev =
-		(struct qxl_device *) minor->dev->dev_private;
+	struct qxl_device *dev = to_qxl(minor->dev);
 
 	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
 				 minor->debugfs_root, minor);
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 09583a08e141..1082cd5d2fd4 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 			bool preferred)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_display_mode *mode = NULL;
 	int rc;
 
@@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
 static int qxl_add_monitors_config_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	int h = output->index;
 	struct qxl_head *head;
@@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 					    const char *reason)
 {
 	struct drm_device *dev = crtc->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
 	struct qxl_head head;
 	int oldcount, i = qcrtc->index;
@@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 					 unsigned int num_clips)
 {
 	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
-	struct qxl_device *qdev = fb->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(fb->dev);
 	struct drm_clip_rect norect;
 	struct qxl_bo *qobj;
 	bool is_primary;
@@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
 static int qxl_primary_atomic_check(struct drm_plane *plane,
 				    struct drm_plane_state *state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo;
 
 	if (!state->crtc || !state->fb)
@@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
 static int qxl_primary_apply_cursor(struct drm_plane *plane)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_cursor_cmd *cmd;
@@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
 static void qxl_primary_atomic_update(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
 	struct qxl_bo *primary;
 	struct drm_clip_rect norect = {
@@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
 static void qxl_primary_atomic_disable(struct drm_plane *plane,
 				       struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 
 	if (old_state->fb) {
 		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
@@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 				     struct drm_plane_state *old_state)
 {
 	struct drm_device *dev = plane->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_framebuffer *fb = plane->state->fb;
 	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
 	struct qxl_release *release;
@@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
 static void qxl_cursor_atomic_disable(struct drm_plane *plane,
 				      struct drm_plane_state *old_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct qxl_release *release;
 	struct qxl_cursor_cmd *cmd;
 	int ret;
@@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
 static int qxl_plane_prepare_fb(struct drm_plane *plane,
 				struct drm_plane_state *new_state)
 {
-	struct qxl_device *qdev = plane->dev->dev_private;
+	struct qxl_device *qdev = to_qxl(plane->dev);
 	struct drm_gem_object *obj;
 	struct qxl_bo *user_bo;
 	struct qxl_surface surf;
@@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 {
 	struct qxl_crtc *qxl_crtc;
 	struct drm_plane *primary, *cursor;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int r;
 
 	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
@@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
 	struct drm_device *dev = connector->dev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *output = drm_connector_to_qxl_output(connector);
 	unsigned int pwidth = 1024;
 	unsigned int pheight = 768;
@@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
 			       struct drm_display_mode *mode)
 {
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 
 	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
 		return MODE_BAD;
@@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
 	struct qxl_output *output =
 		drm_connector_to_qxl_output(connector);
 	struct drm_device *ddev = connector->dev;
-	struct qxl_device *qdev = ddev->dev_private;
+	struct qxl_device *qdev = to_qxl(ddev);
 	bool connected = false;
 
 	/* The first monitor is always connected */
@@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
 
 static int qdev_output_init(struct drm_device *dev, int num_output)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_output *qxl_output;
 	struct drm_connector *connector;
 	struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 6b4ae4c5fb76..13872b882775 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 static void qxl_drm_release(struct drm_device *dev)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	/*
 	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
@@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
 static int qxl_drm_freeze(struct drm_device *dev)
 {
 	struct pci_dev *pdev = dev->pdev;
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	int ret;
 
 	ret = drm_mode_config_helper_suspend(dev);
@@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
 
 static int qxl_drm_resume(struct drm_device *dev, bool thaw)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 
 	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
 	if (!thaw) {
@@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct qxl_device *qdev = drm_dev->dev_private;
+	struct qxl_device *qdev = to_qxl(drm_dev);
 
 	qxl_io_reset(qdev);
 	return qxl_drm_resume(drm_dev, false);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 86ac191d9205..31e35f787df2 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -192,8 +192,6 @@ struct qxl_debugfs {
 
 int qxl_debugfs_fence_init(struct qxl_device *rdev);
 
-struct qxl_device;
-
 struct qxl_device {
 	struct drm_device ddev;
 
@@ -273,6 +271,8 @@ struct qxl_device {
 	int monitors_config_height;
 };
 
+#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
+
 extern const struct drm_ioctl_desc qxl_ioctls[];
 extern int qxl_max_ioctl;
 
diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 272d19b677d8..24e903383aa1 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
 			    struct drm_device *dev,
 			    struct drm_mode_create_dumb *args)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct qxl_bo *qobj;
 	uint32_t handle;
 	int r;
diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
index 69f37db1027a..5ff6fa9b799c 100644
--- a/drivers/gpu/drm/qxl/qxl_gem.c
+++ b/drivers/gpu/drm/qxl/qxl_gem.c
@@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
 	struct qxl_device *qdev;
 	struct ttm_buffer_object *tbo;
 
-	qdev = (struct qxl_device *)gobj->dev->dev_private;
+	qdev = to_qxl(gobj->dev);
 
 	qxl_surface_evict(qdev, qobj, false);
 
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 8117a45b3610..d9a583966949 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -36,7 +36,7 @@
 static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc *qxl_alloc = data;
 	int ret;
 	struct qxl_bo *qobj;
@@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
 static int qxl_map_ioctl(struct drm_device *dev, void *data,
 			 struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_map *qxl_map = data;
 
 	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
@@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
 static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_execbuffer *execbuffer = data;
 	struct drm_qxl_command user_cmd;
 	int cmd_num;
@@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 				 struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_update_area *update_area = data;
 	struct qxl_rect area = {.left = update_area->left,
 				.top = update_area->top,
@@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
 static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_getparam *param = data;
 
 	switch (param->param) {
@@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
 static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file_priv)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_clientcap *param = data;
 	int byte, idx;
 
@@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
 static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *file)
 {
-	struct qxl_device *qdev = dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	struct drm_qxl_alloc_surf *param = data;
 	struct qxl_bo *qobj;
 	int handle;
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 8435af108632..1ba5a702d763 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -32,7 +32,7 @@
 irqreturn_t qxl_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
-	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
+	struct qxl_device *qdev = to_qxl(dev);
 	uint32_t pending;
 
 	pending = xchg(&qdev->ram_header->int_pending, 0);
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
index 91a34dd835d7..a6d873052cd4 100644
--- a/drivers/gpu/drm/qxl/qxl_kms.c
+++ b/drivers/gpu/drm/qxl/qxl_kms.c
@@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
 
 	qdev->ddev.pdev = pdev;
 	pci_set_drvdata(pdev, &qdev->ddev);
-	qdev->ddev.dev_private = qdev;
 
 	mutex_init(&qdev->gem.mutex);
 	mutex_init(&qdev->update_area_mutex);
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index ab72dc3476e9..edc8a9916872 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 	struct qxl_device *qdev;
 
 	bo = to_qxl_bo(tbo);
-	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
+	qdev = to_qxl(bo->tbo.base.dev);
 
 	qxl_surface_evict(qdev, bo, false);
 	WARN_ON_ONCE(bo->map_count > 0);
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 2feca734c7b1..4fae3e393da1 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
 		return ret;
 
 	/* allocate a surface for reserved + validated buffers */
-	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
+	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
 	if (ret)
 		return ret;
 	return 0;
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 93a2eb14844b..f09a712b1ed2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
 	if (!qxl_ttm_bo_is_qxl_bo(bo))
 		return;
 	qbo = to_qxl_bo(bo);
-	qdev = qbo->tbo.base.dev->dev_private;
+	qdev = to_qxl(qbo->tbo.base.dev);
 
 	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
 		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

v2: Move misplaced double-assignement to next patch (Sam)

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_drv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 88cc6b4a7a64..22003478db2c 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -307,19 +307,12 @@ static int mcde_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	mcde = kzalloc(sizeof(*mcde), GFP_KERNEL);
-	if (!mcde)
-		return -ENOMEM;
-	mcde->dev = dev;
-
-	ret = devm_drm_dev_init(dev, &mcde->drm, &mcde_drm_driver);
-	if (ret) {
-		kfree(mcde);
-		return ret;
-	}
+	mcde = devm_drm_dev_alloc(dev, &mcde_drm_driver, struct mcde, drm);
+	if (IS_ERR(mcde))
+		return PTR_ERR(mcde);
 	drm = &mcde->drm;
 	drm->dev_private = mcde;
-	drmm_add_final_kfree(drm, mcde);
+	mcde->dev = dev;
 	platform_set_drvdata(pdev, drm);
 
 	/* Enable continuous updates: this is what Linux' framebuffer expects */
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Linus Walleij, Sam Ravnborg, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

v2: Move misplaced double-assignement to next patch (Sam)

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_drv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 88cc6b4a7a64..22003478db2c 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -307,19 +307,12 @@ static int mcde_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	mcde = kzalloc(sizeof(*mcde), GFP_KERNEL);
-	if (!mcde)
-		return -ENOMEM;
-	mcde->dev = dev;
-
-	ret = devm_drm_dev_init(dev, &mcde->drm, &mcde_drm_driver);
-	if (ret) {
-		kfree(mcde);
-		return ret;
-	}
+	mcde = devm_drm_dev_alloc(dev, &mcde_drm_driver, struct mcde, drm);
+	if (IS_ERR(mcde))
+		return PTR_ERR(mcde);
 	drm = &mcde->drm;
 	drm->dev_private = mcde;
-	drmm_add_final_kfree(drm, mcde);
+	mcde->dev = dev;
 	platform_set_drvdata(pdev, drm);
 
 	/* Enable continuous updates: this is what Linux' framebuffer expects */
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 29/59] drm/mcde: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

v2: Move misplaced removal of double-assignment to this patch (Sam)

Reviewed-by: Linus Walleij <linus.walleij@linaro.org> (v1)
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_display.c | 10 +++++-----
 drivers/gpu/drm/mcde/mcde_drm.h     |  2 ++
 drivers/gpu/drm/mcde/mcde_drv.c     |  6 ++----
 drivers/gpu/drm/mcde/mcde_dsi.c     |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_display.c b/drivers/gpu/drm/mcde/mcde_display.c
index e59907e68854..04e1d38d41f7 100644
--- a/drivers/gpu/drm/mcde/mcde_display.c
+++ b/drivers/gpu/drm/mcde/mcde_display.c
@@ -948,7 +948,7 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct drm_pending_vblank_event *event;
 
 	drm_crtc_vblank_off(crtc);
@@ -1020,7 +1020,7 @@ static void mcde_display_update(struct drm_simple_display_pipe *pipe,
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct drm_pending_vblank_event *event = crtc->state->event;
 	struct drm_plane *plane = &pipe->plane;
 	struct drm_plane_state *pstate = plane->state;
@@ -1078,7 +1078,7 @@ static int mcde_display_enable_vblank(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	u32 val;
 
 	/* Enable all VBLANK IRQs */
@@ -1097,7 +1097,7 @@ static void mcde_display_disable_vblank(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 
 	/* Disable all VBLANK IRQs */
 	writel(0, mcde->regs + MCDE_IMSCPP);
@@ -1117,7 +1117,7 @@ static struct drm_simple_display_pipe_funcs mcde_display_funcs = {
 
 int mcde_display_init(struct drm_device *drm)
 {
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	int ret;
 	static const u32 formats[] = {
 		DRM_FORMAT_ARGB8888,
diff --git a/drivers/gpu/drm/mcde/mcde_drm.h b/drivers/gpu/drm/mcde/mcde_drm.h
index 80edd6628979..679c2c4e6d9d 100644
--- a/drivers/gpu/drm/mcde/mcde_drm.h
+++ b/drivers/gpu/drm/mcde/mcde_drm.h
@@ -34,6 +34,8 @@ struct mcde {
 	struct regulator *vana;
 };
 
+#define to_mcde(dev) container_of(dev, struct mcde, drm)
+
 bool mcde_dsi_irq(struct mipi_dsi_device *mdsi);
 void mcde_dsi_te_request(struct mipi_dsi_device *mdsi);
 extern struct platform_driver mcde_dsi_driver;
diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 22003478db2c..84f3e2dbd77b 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -164,7 +164,7 @@ static irqreturn_t mcde_irq(int irq, void *data)
 static int mcde_modeset_init(struct drm_device *drm)
 {
 	struct drm_mode_config *mode_config;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	int ret;
 
 	if (!mcde->bridge) {
@@ -311,13 +311,11 @@ static int mcde_probe(struct platform_device *pdev)
 	if (IS_ERR(mcde))
 		return PTR_ERR(mcde);
 	drm = &mcde->drm;
-	drm->dev_private = mcde;
 	mcde->dev = dev;
 	platform_set_drvdata(pdev, drm);
 
 	/* Enable continuous updates: this is what Linux' framebuffer expects */
 	mcde->oneshot_mode = false;
-	drm->dev_private = mcde;
 
 	/* First obtain and turn on the main power */
 	mcde->epod = devm_regulator_get(dev, "epod");
@@ -487,7 +485,7 @@ static int mcde_probe(struct platform_device *pdev)
 static int mcde_remove(struct platform_device *pdev)
 {
 	struct drm_device *drm = platform_get_drvdata(pdev);
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 
 	component_master_del(&pdev->dev, &mcde_drm_comp_ops);
 	clk_disable_unprepare(mcde->mcde_clk);
diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 7af5ebb0c436..1baa2324cdb9 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1020,7 +1020,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 			 void *data)
 {
 	struct drm_device *drm = data;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct mcde_dsi *d = dev_get_drvdata(dev);
 	struct device_node *child;
 	struct drm_panel *panel = NULL;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 29/59] drm/mcde: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Linus Walleij, Sam Ravnborg, DRI Development,
	Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

v2: Move misplaced removal of double-assignment to this patch (Sam)

Reviewed-by: Linus Walleij <linus.walleij@linaro.org> (v1)
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpu/drm/mcde/mcde_display.c | 10 +++++-----
 drivers/gpu/drm/mcde/mcde_drm.h     |  2 ++
 drivers/gpu/drm/mcde/mcde_drv.c     |  6 ++----
 drivers/gpu/drm/mcde/mcde_dsi.c     |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_display.c b/drivers/gpu/drm/mcde/mcde_display.c
index e59907e68854..04e1d38d41f7 100644
--- a/drivers/gpu/drm/mcde/mcde_display.c
+++ b/drivers/gpu/drm/mcde/mcde_display.c
@@ -948,7 +948,7 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct drm_pending_vblank_event *event;
 
 	drm_crtc_vblank_off(crtc);
@@ -1020,7 +1020,7 @@ static void mcde_display_update(struct drm_simple_display_pipe *pipe,
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct drm_pending_vblank_event *event = crtc->state->event;
 	struct drm_plane *plane = &pipe->plane;
 	struct drm_plane_state *pstate = plane->state;
@@ -1078,7 +1078,7 @@ static int mcde_display_enable_vblank(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	u32 val;
 
 	/* Enable all VBLANK IRQs */
@@ -1097,7 +1097,7 @@ static void mcde_display_disable_vblank(struct drm_simple_display_pipe *pipe)
 {
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_device *drm = crtc->dev;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 
 	/* Disable all VBLANK IRQs */
 	writel(0, mcde->regs + MCDE_IMSCPP);
@@ -1117,7 +1117,7 @@ static struct drm_simple_display_pipe_funcs mcde_display_funcs = {
 
 int mcde_display_init(struct drm_device *drm)
 {
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	int ret;
 	static const u32 formats[] = {
 		DRM_FORMAT_ARGB8888,
diff --git a/drivers/gpu/drm/mcde/mcde_drm.h b/drivers/gpu/drm/mcde/mcde_drm.h
index 80edd6628979..679c2c4e6d9d 100644
--- a/drivers/gpu/drm/mcde/mcde_drm.h
+++ b/drivers/gpu/drm/mcde/mcde_drm.h
@@ -34,6 +34,8 @@ struct mcde {
 	struct regulator *vana;
 };
 
+#define to_mcde(dev) container_of(dev, struct mcde, drm)
+
 bool mcde_dsi_irq(struct mipi_dsi_device *mdsi);
 void mcde_dsi_te_request(struct mipi_dsi_device *mdsi);
 extern struct platform_driver mcde_dsi_driver;
diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 22003478db2c..84f3e2dbd77b 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -164,7 +164,7 @@ static irqreturn_t mcde_irq(int irq, void *data)
 static int mcde_modeset_init(struct drm_device *drm)
 {
 	struct drm_mode_config *mode_config;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	int ret;
 
 	if (!mcde->bridge) {
@@ -311,13 +311,11 @@ static int mcde_probe(struct platform_device *pdev)
 	if (IS_ERR(mcde))
 		return PTR_ERR(mcde);
 	drm = &mcde->drm;
-	drm->dev_private = mcde;
 	mcde->dev = dev;
 	platform_set_drvdata(pdev, drm);
 
 	/* Enable continuous updates: this is what Linux' framebuffer expects */
 	mcde->oneshot_mode = false;
-	drm->dev_private = mcde;
 
 	/* First obtain and turn on the main power */
 	mcde->epod = devm_regulator_get(dev, "epod");
@@ -487,7 +485,7 @@ static int mcde_probe(struct platform_device *pdev)
 static int mcde_remove(struct platform_device *pdev)
 {
 	struct drm_device *drm = platform_get_drvdata(pdev);
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 
 	component_master_del(&pdev->dev, &mcde_drm_comp_ops);
 	clk_disable_unprepare(mcde->mcde_clk);
diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 7af5ebb0c436..1baa2324cdb9 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1020,7 +1020,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 			 void *data)
 {
 	struct drm_device *drm = data;
-	struct mcde *mcde = drm->dev_private;
+	struct mcde *mcde = to_mcde(drm);
 	struct mcde_dsi *d = dev_get_drvdata(dev);
 	struct device_node *child;
 	struct drm_panel *panel = NULL;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 30/59] drm/ingenic: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Paul Cercueil, Daniel Vetter, Sam Ravnborg, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 24cc3587cea5..2dd1f3020fcb 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -611,9 +611,10 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	priv = devm_drm_dev_alloc(dev, &ingenic_drm_driver_data,
+				  struct ingenic_drm, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
 	priv->soc_info = soc_info;
 	priv->dev = dev;
@@ -622,13 +623,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	ret = devm_drm_dev_init(dev, drm, &ingenic_drm_driver_data);
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, priv);
-
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 30/59] drm/ingenic: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Paul Cercueil, Daniel Vetter, Sam Ravnborg, DRI Development,
	Daniel Vetter

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 24cc3587cea5..2dd1f3020fcb 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -611,9 +611,10 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
+	priv = devm_drm_dev_alloc(dev, &ingenic_drm_driver_data,
+				  struct ingenic_drm, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
 	priv->soc_info = soc_info;
 	priv->dev = dev;
@@ -622,13 +623,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	ret = devm_drm_dev_init(dev, drm, &ingenic_drm_driver_data);
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-	drmm_add_final_kfree(drm, priv);
-
 	ret = drmm_mode_config_init(drm);
 	if (ret)
 		return ret;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 31/59] drm/ingenic: Don't set drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Paul Cercueil, Daniel Vetter, Sam Ravnborg, DRI Development,
	Daniel Vetter

Entirely not used, just copypasta.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 2dd1f3020fcb..632d72177123 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -619,7 +619,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 	priv->soc_info = soc_info;
 	priv->dev = dev;
 	drm = &priv->drm;
-	drm->dev_private = priv;
 
 	platform_set_drvdata(pdev, priv);
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 31/59] drm/ingenic: Don't set drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Paul Cercueil, Daniel Vetter, Sam Ravnborg, DRI Development,
	Daniel Vetter

Entirely not used, just copypasta.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index 2dd1f3020fcb..632d72177123 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -619,7 +619,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 	priv->soc_info = soc_info;
 	priv->dev = dev;
 	drm = &priv->drm;
-	drm->dev_private = priv;
 
 	platform_set_drvdata(pdev, priv);
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 32/59] drm/komeda: use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Liviu Dudau, DRI Development, James Qian Wang,
	Daniel Vetter, Mihail Atanassov

Komeda uses the component framework, which does open/close a new
devres group around all the bind callbacks. Which means we can use
devm_ functions for managing the drm_device cleanup, with leaking
stuff in case of deferred probes or other reasons to unbind
components, or the component_master.

Also note that this fixes a double-free in the probe unroll code, bot
drm_dev_put and kfree(kms) result in the kms allocation getting freed.

Aside: komeda_bind could be cleaned up a lot, devm_kfree is a bit
redundant. Plus I'm not clear on why there's suballocations for
mdrv->mdev and mdrv->kms. Plus I'm not sure the lifetimes are correct
with all that devm_kzalloc usage ... That structure layout is also the
reason why komeda still uses drm_device->dev_private and can't easily
be replaced with a proper container_of upcasting. I'm pretty sure that
there's endless amounts of hotunplug/hotremove bugs in there with all
the unprotected dereferencing of drm_device->dev_private.

Reviewed-by: James Qian Wang <james.qian.wang@arm.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 16dfd5cdb66c..6b85d5f4caa8 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -261,18 +261,16 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
 
 struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 {
-	struct komeda_kms_dev *kms = kzalloc(sizeof(*kms), GFP_KERNEL);
+	struct komeda_kms_dev *kms;
 	struct drm_device *drm;
 	int err;
 
-	if (!kms)
-		return ERR_PTR(-ENOMEM);
+	kms = devm_drm_dev_alloc(mdev->dev, &komeda_kms_driver,
+				 struct komeda_kms_dev, base);
+	if (IS_ERR(kms))
+		return kms;
 
 	drm = &kms->base;
-	err = drm_dev_init(drm, &komeda_kms_driver, mdev->dev);
-	if (err)
-		goto free_kms;
-	drmm_add_final_kfree(drm, kms);
 
 	drm->dev_private = mdev;
 
@@ -329,9 +327,6 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
 	drm->dev_private = NULL;
-	drm_dev_put(drm);
-free_kms:
-	kfree(kms);
 	return ERR_PTR(err);
 }
 
@@ -348,5 +343,4 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
 	drm->dev_private = NULL;
-	drm_dev_put(drm);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 32/59] drm/komeda: use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, James Qian Wang, Daniel Vetter,
	Mihail Atanassov

Komeda uses the component framework, which does open/close a new
devres group around all the bind callbacks. Which means we can use
devm_ functions for managing the drm_device cleanup, with leaking
stuff in case of deferred probes or other reasons to unbind
components, or the component_master.

Also note that this fixes a double-free in the probe unroll code, bot
drm_dev_put and kfree(kms) result in the kms allocation getting freed.

Aside: komeda_bind could be cleaned up a lot, devm_kfree is a bit
redundant. Plus I'm not clear on why there's suballocations for
mdrv->mdev and mdrv->kms. Plus I'm not sure the lifetimes are correct
with all that devm_kzalloc usage ... That structure layout is also the
reason why komeda still uses drm_device->dev_private and can't easily
be replaced with a proper container_of upcasting. I'm pretty sure that
there's endless amounts of hotunplug/hotremove bugs in there with all
the unprotected dereferencing of drm_device->dev_private.

Reviewed-by: James Qian Wang <james.qian.wang@arm.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 16dfd5cdb66c..6b85d5f4caa8 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -261,18 +261,16 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
 
 struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 {
-	struct komeda_kms_dev *kms = kzalloc(sizeof(*kms), GFP_KERNEL);
+	struct komeda_kms_dev *kms;
 	struct drm_device *drm;
 	int err;
 
-	if (!kms)
-		return ERR_PTR(-ENOMEM);
+	kms = devm_drm_dev_alloc(mdev->dev, &komeda_kms_driver,
+				 struct komeda_kms_dev, base);
+	if (IS_ERR(kms))
+		return kms;
 
 	drm = &kms->base;
-	err = drm_dev_init(drm, &komeda_kms_driver, mdev->dev);
-	if (err)
-		goto free_kms;
-	drmm_add_final_kfree(drm, kms);
 
 	drm->dev_private = mdev;
 
@@ -329,9 +327,6 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
 	drm->dev_private = NULL;
-	drm_dev_put(drm);
-free_kms:
-	kfree(kms);
 	return ERR_PTR(err);
 }
 
@@ -348,5 +343,4 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
 	drm->dev_private = NULL;
-	drm_dev_put(drm);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 33/59] drm/armada: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Russell King, DRI Development, Daniel Vetter

Also remove the now no longer needed build bug on since that's already
not needed anymore with drmm_add_final_kfree. Conversion to managed
drm_device cleanup is easy, the final drm_dev_put() is already the
last thing in both the bind unbind as in the unbind flow.

Also, this relies on component.c correctly wrapping bind&unbind in
separate devres groups, which it does.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_drv.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index dd9ed71ed942..2546ff9d1c92 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -87,24 +87,13 @@ static int armada_drm_bind(struct device *dev)
 				     "armada-drm"))
 		return -EBUSY;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	/*
-	 * The drm_device structure must be at the start of
-	 * armada_private for drm_dev_put() to work correctly.
-	 */
-	BUILD_BUG_ON(offsetof(struct armada_private, drm) != 0);
-
-	ret = drm_dev_init(&priv->drm, &armada_drm_driver, dev);
-	if (ret) {
-		dev_err(dev, "[" DRM_NAME ":%s] drm_dev_init failed: %d\n",
-			__func__, ret);
-		kfree(priv);
-		return ret;
+	priv = devm_drm_dev_alloc(dev, &armada_drm_driver,
+				  struct armada_private, drm);
+	if (IS_ERR(priv)) {
+		dev_err(dev, "[" DRM_NAME ":%s] devm_drm_dev_alloc failed: %li\n",
+			__func__, PTR_ERR(priv));
+		return PTR_ERR(priv);
 	}
-	drmm_add_final_kfree(&priv->drm, priv);
 
 	/* Remove early framebuffers */
 	ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
@@ -174,7 +163,6 @@ static int armada_drm_bind(struct device *dev)
  err_kms:
 	drm_mode_config_cleanup(&priv->drm);
 	drm_mm_takedown(&priv->linear);
-	drm_dev_put(&priv->drm);
 	return ret;
 }
 
@@ -194,8 +182,6 @@ static void armada_drm_unbind(struct device *dev)
 
 	drm_mode_config_cleanup(&priv->drm);
 	drm_mm_takedown(&priv->linear);
-
-	drm_dev_put(&priv->drm);
 }
 
 static int compare_of(struct device *dev, void *data)
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 33/59] drm/armada: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Russell King, DRI Development, Daniel Vetter

Also remove the now no longer needed build bug on since that's already
not needed anymore with drmm_add_final_kfree. Conversion to managed
drm_device cleanup is easy, the final drm_dev_put() is already the
last thing in both the bind unbind as in the unbind flow.

Also, this relies on component.c correctly wrapping bind&unbind in
separate devres groups, which it does.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_drv.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index dd9ed71ed942..2546ff9d1c92 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -87,24 +87,13 @@ static int armada_drm_bind(struct device *dev)
 				     "armada-drm"))
 		return -EBUSY;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	/*
-	 * The drm_device structure must be at the start of
-	 * armada_private for drm_dev_put() to work correctly.
-	 */
-	BUILD_BUG_ON(offsetof(struct armada_private, drm) != 0);
-
-	ret = drm_dev_init(&priv->drm, &armada_drm_driver, dev);
-	if (ret) {
-		dev_err(dev, "[" DRM_NAME ":%s] drm_dev_init failed: %d\n",
-			__func__, ret);
-		kfree(priv);
-		return ret;
+	priv = devm_drm_dev_alloc(dev, &armada_drm_driver,
+				  struct armada_private, drm);
+	if (IS_ERR(priv)) {
+		dev_err(dev, "[" DRM_NAME ":%s] devm_drm_dev_alloc failed: %li\n",
+			__func__, PTR_ERR(priv));
+		return PTR_ERR(priv);
 	}
-	drmm_add_final_kfree(&priv->drm, priv);
 
 	/* Remove early framebuffers */
 	ret = drm_fb_helper_remove_conflicting_framebuffers(NULL,
@@ -174,7 +163,6 @@ static int armada_drm_bind(struct device *dev)
  err_kms:
 	drm_mode_config_cleanup(&priv->drm);
 	drm_mm_takedown(&priv->linear);
-	drm_dev_put(&priv->drm);
 	return ret;
 }
 
@@ -194,8 +182,6 @@ static void armada_drm_unbind(struct device *dev)
 
 	drm_mode_config_cleanup(&priv->drm);
 	drm_mm_takedown(&priv->linear);
-
-	drm_dev_put(&priv->drm);
 }
 
 static int compare_of(struct device *dev, void *data)
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 34/59] drm/armada: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Russell King, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_crtc.c    | 4 ++--
 drivers/gpu/drm/armada/armada_debugfs.c | 2 +-
 drivers/gpu/drm/armada/armada_drm.h     | 2 ++
 drivers/gpu/drm/armada/armada_drv.c     | 4 +---
 drivers/gpu/drm/armada/armada_fbdev.c   | 4 ++--
 drivers/gpu/drm/armada/armada_gem.c     | 4 ++--
 drivers/gpu/drm/armada/armada_overlay.c | 8 ++++----
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index c2b92acd1e9a..8686e50226a5 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -757,7 +757,7 @@ static int armada_drm_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 static void armada_drm_crtc_destroy(struct drm_crtc *crtc)
 {
 	struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
-	struct armada_private *priv = crtc->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(crtc->dev);
 
 	if (dcrtc->cursor_obj)
 		drm_gem_object_put_unlocked(&dcrtc->cursor_obj->obj);
@@ -901,7 +901,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
 	struct resource *res, int irq, const struct armada_variant *variant,
 	struct device_node *port)
 {
-	struct armada_private *priv = drm->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(drm);
 	struct armada_crtc *dcrtc;
 	struct drm_plane *primary;
 	void __iomem *base;
diff --git a/drivers/gpu/drm/armada/armada_debugfs.c b/drivers/gpu/drm/armada/armada_debugfs.c
index c6fc2f1d58e9..29f4b52e3c8d 100644
--- a/drivers/gpu/drm/armada/armada_debugfs.c
+++ b/drivers/gpu/drm/armada/armada_debugfs.c
@@ -19,7 +19,7 @@ static int armada_debugfs_gem_linear_show(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = m->private;
 	struct drm_device *dev = node->minor->dev;
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	mutex_lock(&priv->linear_lock);
diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h
index a11bdaccbb33..6a5a87932576 100644
--- a/drivers/gpu/drm/armada/armada_drm.h
+++ b/drivers/gpu/drm/armada/armada_drm.h
@@ -73,6 +73,8 @@ struct armada_private {
 #endif
 };
 
+#define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
+
 int armada_fbdev_init(struct drm_device *);
 void armada_fbdev_fini(struct drm_device *);
 
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 2546ff9d1c92..2a9ee76ee585 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -106,8 +106,6 @@ static int armada_drm_bind(struct device *dev)
 		return ret;
 	}
 
-	priv->drm.dev_private = priv;
-
 	dev_set_drvdata(dev, &priv->drm);
 
 	/* Mode setting support */
@@ -169,7 +167,7 @@ static int armada_drm_bind(struct device *dev)
 static void armada_drm_unbind(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct armada_private *priv = drm->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(drm);
 
 	drm_kms_helper_poll_fini(&priv->drm);
 	armada_fbdev_fini(&priv->drm);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index f2dc371bd8e5..c9a414b3a8c4 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -117,7 +117,7 @@ static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
 
 int armada_fbdev_init(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_fb_helper *fbh;
 	int ret;
 
@@ -151,7 +151,7 @@ int armada_fbdev_init(struct drm_device *dev)
 
 void armada_fbdev_fini(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_fb_helper *fbh = priv->fbdev;
 
 	if (fbh) {
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c
index 976685f2939e..2c7d5f71e715 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -39,7 +39,7 @@ static size_t roundup_gem_size(size_t size)
 void armada_gem_free_object(struct drm_gem_object *obj)
 {
 	struct armada_gem_object *dobj = drm_to_armada_gem(obj);
-	struct armada_private *priv = obj->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(obj->dev);
 
 	DRM_DEBUG_DRIVER("release obj %p\n", dobj);
 
@@ -77,7 +77,7 @@ void armada_gem_free_object(struct drm_gem_object *obj)
 int
 armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	size_t size = obj->obj.size;
 
 	if (obj->page || obj->linear)
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 07f0da4d9ba1..30e01101f59e 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -344,7 +344,7 @@ static int armada_overlay_set_property(struct drm_plane *plane,
 	struct drm_plane_state *state, struct drm_property *property,
 	uint64_t val)
 {
-	struct armada_private *priv = plane->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(plane->dev);
 
 #define K2R(val) (((val) >> 0) & 0xff)
 #define K2G(val) (((val) >> 8) & 0xff)
@@ -412,7 +412,7 @@ static int armada_overlay_get_property(struct drm_plane *plane,
 	const struct drm_plane_state *state, struct drm_property *property,
 	uint64_t *val)
 {
-	struct armada_private *priv = plane->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(plane->dev);
 
 #define C2K(c,s)	(((c) >> (s)) & 0xff)
 #define R2BGR(r,g,b,s)	(C2K(r,s) << 0 | C2K(g,s) << 8 | C2K(b,s) << 16)
@@ -505,7 +505,7 @@ static const struct drm_prop_enum_list armada_drm_colorkey_enum_list[] = {
 
 static int armada_overlay_create_properties(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 
 	if (priv->colorkey_prop)
 		return 0;
@@ -539,7 +539,7 @@ static int armada_overlay_create_properties(struct drm_device *dev)
 
 int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_mode_object *mobj;
 	struct drm_plane *overlay;
 	int ret;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 34/59] drm/armada: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Russell King, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_crtc.c    | 4 ++--
 drivers/gpu/drm/armada/armada_debugfs.c | 2 +-
 drivers/gpu/drm/armada/armada_drm.h     | 2 ++
 drivers/gpu/drm/armada/armada_drv.c     | 4 +---
 drivers/gpu/drm/armada/armada_fbdev.c   | 4 ++--
 drivers/gpu/drm/armada/armada_gem.c     | 4 ++--
 drivers/gpu/drm/armada/armada_overlay.c | 8 ++++----
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index c2b92acd1e9a..8686e50226a5 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -757,7 +757,7 @@ static int armada_drm_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 static void armada_drm_crtc_destroy(struct drm_crtc *crtc)
 {
 	struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
-	struct armada_private *priv = crtc->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(crtc->dev);
 
 	if (dcrtc->cursor_obj)
 		drm_gem_object_put_unlocked(&dcrtc->cursor_obj->obj);
@@ -901,7 +901,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
 	struct resource *res, int irq, const struct armada_variant *variant,
 	struct device_node *port)
 {
-	struct armada_private *priv = drm->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(drm);
 	struct armada_crtc *dcrtc;
 	struct drm_plane *primary;
 	void __iomem *base;
diff --git a/drivers/gpu/drm/armada/armada_debugfs.c b/drivers/gpu/drm/armada/armada_debugfs.c
index c6fc2f1d58e9..29f4b52e3c8d 100644
--- a/drivers/gpu/drm/armada/armada_debugfs.c
+++ b/drivers/gpu/drm/armada/armada_debugfs.c
@@ -19,7 +19,7 @@ static int armada_debugfs_gem_linear_show(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = m->private;
 	struct drm_device *dev = node->minor->dev;
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	mutex_lock(&priv->linear_lock);
diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h
index a11bdaccbb33..6a5a87932576 100644
--- a/drivers/gpu/drm/armada/armada_drm.h
+++ b/drivers/gpu/drm/armada/armada_drm.h
@@ -73,6 +73,8 @@ struct armada_private {
 #endif
 };
 
+#define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
+
 int armada_fbdev_init(struct drm_device *);
 void armada_fbdev_fini(struct drm_device *);
 
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 2546ff9d1c92..2a9ee76ee585 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -106,8 +106,6 @@ static int armada_drm_bind(struct device *dev)
 		return ret;
 	}
 
-	priv->drm.dev_private = priv;
-
 	dev_set_drvdata(dev, &priv->drm);
 
 	/* Mode setting support */
@@ -169,7 +167,7 @@ static int armada_drm_bind(struct device *dev)
 static void armada_drm_unbind(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
-	struct armada_private *priv = drm->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(drm);
 
 	drm_kms_helper_poll_fini(&priv->drm);
 	armada_fbdev_fini(&priv->drm);
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c
index f2dc371bd8e5..c9a414b3a8c4 100644
--- a/drivers/gpu/drm/armada/armada_fbdev.c
+++ b/drivers/gpu/drm/armada/armada_fbdev.c
@@ -117,7 +117,7 @@ static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
 
 int armada_fbdev_init(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_fb_helper *fbh;
 	int ret;
 
@@ -151,7 +151,7 @@ int armada_fbdev_init(struct drm_device *dev)
 
 void armada_fbdev_fini(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_fb_helper *fbh = priv->fbdev;
 
 	if (fbh) {
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c
index 976685f2939e..2c7d5f71e715 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -39,7 +39,7 @@ static size_t roundup_gem_size(size_t size)
 void armada_gem_free_object(struct drm_gem_object *obj)
 {
 	struct armada_gem_object *dobj = drm_to_armada_gem(obj);
-	struct armada_private *priv = obj->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(obj->dev);
 
 	DRM_DEBUG_DRIVER("release obj %p\n", dobj);
 
@@ -77,7 +77,7 @@ void armada_gem_free_object(struct drm_gem_object *obj)
 int
 armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	size_t size = obj->obj.size;
 
 	if (obj->page || obj->linear)
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 07f0da4d9ba1..30e01101f59e 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -344,7 +344,7 @@ static int armada_overlay_set_property(struct drm_plane *plane,
 	struct drm_plane_state *state, struct drm_property *property,
 	uint64_t val)
 {
-	struct armada_private *priv = plane->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(plane->dev);
 
 #define K2R(val) (((val) >> 0) & 0xff)
 #define K2G(val) (((val) >> 8) & 0xff)
@@ -412,7 +412,7 @@ static int armada_overlay_get_property(struct drm_plane *plane,
 	const struct drm_plane_state *state, struct drm_property *property,
 	uint64_t *val)
 {
-	struct armada_private *priv = plane->dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(plane->dev);
 
 #define C2K(c,s)	(((c) >> (s)) & 0xff)
 #define R2BGR(r,g,b,s)	(C2K(r,s) << 0 | C2K(g,s) << 8 | C2K(b,s) << 16)
@@ -505,7 +505,7 @@ static const struct drm_prop_enum_list armada_drm_colorkey_enum_list[] = {
 
 static int armada_overlay_create_properties(struct drm_device *dev)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 
 	if (priv->colorkey_prop)
 		return 0;
@@ -539,7 +539,7 @@ static int armada_overlay_create_properties(struct drm_device *dev)
 
 int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
 {
-	struct armada_private *priv = dev->dev_private;
+	struct armada_private *priv = drm_to_armada_dev(dev);
 	struct drm_mode_object *mobj;
 	struct drm_plane *overlay;
 	int ret;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 35/59] drm/cirrus: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Rob Herring, Daniel Vetter, DRI Development, virtualization,
	Noralf Trønnes, Thomas Zimmermann, Daniel Vetter,
	Dave Airlie, Sam Ravnborg, Emil Velikov

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
Cc: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/cirrus/cirrus.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index a36269717c3b..4b65637147ba 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -567,18 +567,13 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return ret;
 
 	ret = -ENOMEM;
-	cirrus = kzalloc(sizeof(*cirrus), GFP_KERNEL);
-	if (cirrus == NULL)
-		return ret;
+	cirrus = devm_drm_dev_alloc(&pdev->dev, &cirrus_driver,
+				    struct cirrus_device, dev);
+	if (IS_ERR(cirrus))
+		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	ret = devm_drm_dev_init(&pdev->dev, dev, &cirrus_driver);
-	if (ret) {
-		kfree(cirrus);
-		return ret;
-	}
 	dev->dev_private = cirrus;
-	drmm_add_final_kfree(dev, cirrus);
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 35/59] drm/cirrus: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Gerd Hoffmann,
	Thomas Zimmermann, Daniel Vetter, Dave Airlie, Sam Ravnborg,
	Emil Velikov

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
Cc: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/cirrus/cirrus.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index a36269717c3b..4b65637147ba 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -567,18 +567,13 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return ret;
 
 	ret = -ENOMEM;
-	cirrus = kzalloc(sizeof(*cirrus), GFP_KERNEL);
-	if (cirrus == NULL)
-		return ret;
+	cirrus = devm_drm_dev_alloc(&pdev->dev, &cirrus_driver,
+				    struct cirrus_device, dev);
+	if (IS_ERR(cirrus))
+		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	ret = devm_drm_dev_init(&pdev->dev, dev, &cirrus_driver);
-	if (ret) {
-		kfree(cirrus);
-		return ret;
-	}
 	dev->dev_private = cirrus;
-	drmm_add_final_kfree(dev, cirrus);
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 35/59] drm/cirrus: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Rob Herring, Daniel Vetter, DRI Development, virtualization,
	Noralf Trønnes, Gerd Hoffmann, Thomas Zimmermann,
	Daniel Vetter, Dave Airlie, Sam Ravnborg, Emil Velikov

Already using devm_drm_dev_init, so very simple replacment.

Acked-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
Cc: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/cirrus/cirrus.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index a36269717c3b..4b65637147ba 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -567,18 +567,13 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return ret;
 
 	ret = -ENOMEM;
-	cirrus = kzalloc(sizeof(*cirrus), GFP_KERNEL);
-	if (cirrus == NULL)
-		return ret;
+	cirrus = devm_drm_dev_alloc(&pdev->dev, &cirrus_driver,
+				    struct cirrus_device, dev);
+	if (IS_ERR(cirrus))
+		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	ret = devm_drm_dev_init(&pdev->dev, dev, &cirrus_driver);
-	if (ret) {
-		kfree(cirrus);
-		return ret;
-	}
 	dev->dev_private = cirrus;
-	drmm_add_final_kfree(dev, cirrus);
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 36/59] drm/cirrus: Don't use drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Eric Anholt,
	Noralf Trønnes, Thomas Zimmermann, Dave Airlie,
	Daniel Vetter, Sam Ravnborg

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 4b65637147ba..744a8e337e41 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -59,6 +59,8 @@ struct cirrus_device {
 	void __iomem		       *mmio;
 };
 
+#define to_cirrus(_dev) container_of(_dev, struct cirrus_device, dev)
+
 /* ------------------------------------------------------------------ */
 /*
  * The meat of this driver. The core passes us a mode and we have to program
@@ -311,7 +313,7 @@ static int cirrus_mode_set(struct cirrus_device *cirrus,
 static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
 			       struct drm_rect *rect)
 {
-	struct cirrus_device *cirrus = fb->dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(fb->dev);
 	void *vmap;
 	int idx, ret;
 
@@ -436,7 +438,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 			       struct drm_crtc_state *crtc_state,
 			       struct drm_plane_state *plane_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
@@ -445,7 +447,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 			       struct drm_plane_state *old_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 	struct drm_plane_state *state = pipe->plane.state;
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_rect rect;
@@ -573,7 +575,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	dev->dev_private = cirrus;
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 36/59] drm/cirrus: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Gerd Hoffmann,
	Thomas Zimmermann, Dave Airlie, Daniel Vetter, Sam Ravnborg

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 4b65637147ba..744a8e337e41 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -59,6 +59,8 @@ struct cirrus_device {
 	void __iomem		       *mmio;
 };
 
+#define to_cirrus(_dev) container_of(_dev, struct cirrus_device, dev)
+
 /* ------------------------------------------------------------------ */
 /*
  * The meat of this driver. The core passes us a mode and we have to program
@@ -311,7 +313,7 @@ static int cirrus_mode_set(struct cirrus_device *cirrus,
 static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
 			       struct drm_rect *rect)
 {
-	struct cirrus_device *cirrus = fb->dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(fb->dev);
 	void *vmap;
 	int idx, ret;
 
@@ -436,7 +438,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 			       struct drm_crtc_state *crtc_state,
 			       struct drm_plane_state *plane_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
@@ -445,7 +447,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 			       struct drm_plane_state *old_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 	struct drm_plane_state *state = pipe->plane.state;
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_rect rect;
@@ -573,7 +575,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	dev->dev_private = cirrus;
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 36/59] drm/cirrus: Don't use drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Eric Anholt,
	Noralf Trønnes, Gerd Hoffmann, Thomas Zimmermann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/cirrus/cirrus.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 4b65637147ba..744a8e337e41 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -59,6 +59,8 @@ struct cirrus_device {
 	void __iomem		       *mmio;
 };
 
+#define to_cirrus(_dev) container_of(_dev, struct cirrus_device, dev)
+
 /* ------------------------------------------------------------------ */
 /*
  * The meat of this driver. The core passes us a mode and we have to program
@@ -311,7 +313,7 @@ static int cirrus_mode_set(struct cirrus_device *cirrus,
 static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
 			       struct drm_rect *rect)
 {
-	struct cirrus_device *cirrus = fb->dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(fb->dev);
 	void *vmap;
 	int idx, ret;
 
@@ -436,7 +438,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 			       struct drm_crtc_state *crtc_state,
 			       struct drm_plane_state *plane_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 
 	cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb);
 	cirrus_fb_blit_fullscreen(plane_state->fb);
@@ -445,7 +447,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe,
 static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe,
 			       struct drm_plane_state *old_state)
 {
-	struct cirrus_device *cirrus = pipe->crtc.dev->dev_private;
+	struct cirrus_device *cirrus = to_cirrus(pipe->crtc.dev);
 	struct drm_plane_state *state = pipe->plane.state;
 	struct drm_crtc *crtc = &pipe->crtc;
 	struct drm_rect rect;
@@ -573,7 +575,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
 		return PTR_ERR(cirrus);
 
 	dev = &cirrus->dev;
-	dev->dev_private = cirrus;
 
 	cirrus->vram = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
 				    pci_resource_len(pdev, 0));
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Daniel Vetter,
	Dave Airlie

Because it is. Huge congrats to everyone who made this kind of
refactoring happen!

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 MAINTAINERS                               |  2 +-
 drivers/gpu/drm/Kconfig                   |  2 --
 drivers/gpu/drm/Makefile                  |  1 -
 drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
 drivers/gpu/drm/cirrus/Makefile           |  2 --
 drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
 drivers/gpu/drm/tiny/Makefile             |  1 +
 drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
 8 files changed, 21 insertions(+), 25 deletions(-)
 delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
 delete mode 100644 drivers/gpu/drm/cirrus/Makefile
 rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7b3255d96d1d..0a5cf105ee37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
 S:	Obsolete
 W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
 T:	git git://anongit.freedesktop.org/drm/drm-misc
-F:	drivers/gpu/drm/cirrus/
+F:	drivers/gpu/drm/tiny/cirrus.c
 
 DRM DRIVER FOR QXL VIRTUAL GPU
 M:	Dave Airlie <airlied@redhat.com>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 43594978958e..4f4e7fa001c1 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
 
 source "drivers/gpu/drm/mgag200/Kconfig"
 
-source "drivers/gpu/drm/cirrus/Kconfig"
-
 source "drivers/gpu/drm/armada/Kconfig"
 
 source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index f34d08c83485..2c0e5a7e5953 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
deleted file mode 100644
index c6bbd988b0e5..000000000000
--- a/drivers/gpu/drm/cirrus/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config DRM_CIRRUS_QEMU
-	tristate "Cirrus driver for QEMU emulated device"
-	depends on DRM && PCI && MMU
-	select DRM_KMS_HELPER
-	select DRM_GEM_SHMEM_HELPER
-	help
-	 This is a KMS driver for emulated cirrus device in qemu.
-	 It is *NOT* intended for real cirrus devices. This requires
-	 the modesetting userspace X.org driver.
-
-	 Cirrus is obsolete, the hardware was designed in the 90ies
-	 and can't keep up with todays needs.  More background:
-	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
-
-	 Better alternatives are:
-	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
-	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
-	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
deleted file mode 100644
index 0c1ed3f99725..000000000000
--- a/drivers/gpu/drm/cirrus/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
index 4160e74e4751..2b6414f0fa75 100644
--- a/drivers/gpu/drm/tiny/Kconfig
+++ b/drivers/gpu/drm/tiny/Kconfig
@@ -1,5 +1,24 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config DRM_CIRRUS_QEMU
+	tristate "Cirrus driver for QEMU emulated device"
+	depends on DRM && PCI && MMU
+	select DRM_KMS_HELPER
+	select DRM_GEM_SHMEM_HELPER
+	help
+	 This is a KMS driver for emulated cirrus device in qemu.
+	 It is *NOT* intended for real cirrus devices. This requires
+	 the modesetting userspace X.org driver.
+
+	 Cirrus is obsolete, the hardware was designed in the 90ies
+	 and can't keep up with todays needs.  More background:
+	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
+
+	 Better alternatives are:
+	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
+	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
+	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
+
 config DRM_GM12U320
 	tristate "GM12U320 driver for USB projectors"
 	depends on DRM && USB
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
index c96ceee71453..6ae4e9e5a35f 100644
--- a/drivers/gpu/drm/tiny/Makefile
+++ b/drivers/gpu/drm/tiny/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
 obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
 obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
similarity index 100%
rename from drivers/gpu/drm/cirrus/cirrus.c
rename to drivers/gpu/drm/tiny/cirrus.c
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Gerd Hoffmann,
	Daniel Vetter, Dave Airlie

Because it is. Huge congrats to everyone who made this kind of
refactoring happen!

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 MAINTAINERS                               |  2 +-
 drivers/gpu/drm/Kconfig                   |  2 --
 drivers/gpu/drm/Makefile                  |  1 -
 drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
 drivers/gpu/drm/cirrus/Makefile           |  2 --
 drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
 drivers/gpu/drm/tiny/Makefile             |  1 +
 drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
 8 files changed, 21 insertions(+), 25 deletions(-)
 delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
 delete mode 100644 drivers/gpu/drm/cirrus/Makefile
 rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7b3255d96d1d..0a5cf105ee37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
 S:	Obsolete
 W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
 T:	git git://anongit.freedesktop.org/drm/drm-misc
-F:	drivers/gpu/drm/cirrus/
+F:	drivers/gpu/drm/tiny/cirrus.c
 
 DRM DRIVER FOR QXL VIRTUAL GPU
 M:	Dave Airlie <airlied@redhat.com>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 43594978958e..4f4e7fa001c1 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
 
 source "drivers/gpu/drm/mgag200/Kconfig"
 
-source "drivers/gpu/drm/cirrus/Kconfig"
-
 source "drivers/gpu/drm/armada/Kconfig"
 
 source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index f34d08c83485..2c0e5a7e5953 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
deleted file mode 100644
index c6bbd988b0e5..000000000000
--- a/drivers/gpu/drm/cirrus/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config DRM_CIRRUS_QEMU
-	tristate "Cirrus driver for QEMU emulated device"
-	depends on DRM && PCI && MMU
-	select DRM_KMS_HELPER
-	select DRM_GEM_SHMEM_HELPER
-	help
-	 This is a KMS driver for emulated cirrus device in qemu.
-	 It is *NOT* intended for real cirrus devices. This requires
-	 the modesetting userspace X.org driver.
-
-	 Cirrus is obsolete, the hardware was designed in the 90ies
-	 and can't keep up with todays needs.  More background:
-	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
-
-	 Better alternatives are:
-	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
-	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
-	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
deleted file mode 100644
index 0c1ed3f99725..000000000000
--- a/drivers/gpu/drm/cirrus/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
index 4160e74e4751..2b6414f0fa75 100644
--- a/drivers/gpu/drm/tiny/Kconfig
+++ b/drivers/gpu/drm/tiny/Kconfig
@@ -1,5 +1,24 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config DRM_CIRRUS_QEMU
+	tristate "Cirrus driver for QEMU emulated device"
+	depends on DRM && PCI && MMU
+	select DRM_KMS_HELPER
+	select DRM_GEM_SHMEM_HELPER
+	help
+	 This is a KMS driver for emulated cirrus device in qemu.
+	 It is *NOT* intended for real cirrus devices. This requires
+	 the modesetting userspace X.org driver.
+
+	 Cirrus is obsolete, the hardware was designed in the 90ies
+	 and can't keep up with todays needs.  More background:
+	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
+
+	 Better alternatives are:
+	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
+	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
+	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
+
 config DRM_GM12U320
 	tristate "GM12U320 driver for USB projectors"
 	depends on DRM && USB
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
index c96ceee71453..6ae4e9e5a35f 100644
--- a/drivers/gpu/drm/tiny/Makefile
+++ b/drivers/gpu/drm/tiny/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
 obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
 obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
similarity index 100%
rename from drivers/gpu/drm/cirrus/cirrus.c
rename to drivers/gpu/drm/tiny/cirrus.c
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, virtualization, Gerd Hoffmann,
	Daniel Vetter, Dave Airlie

Because it is. Huge congrats to everyone who made this kind of
refactoring happen!

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 MAINTAINERS                               |  2 +-
 drivers/gpu/drm/Kconfig                   |  2 --
 drivers/gpu/drm/Makefile                  |  1 -
 drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
 drivers/gpu/drm/cirrus/Makefile           |  2 --
 drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
 drivers/gpu/drm/tiny/Makefile             |  1 +
 drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
 8 files changed, 21 insertions(+), 25 deletions(-)
 delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
 delete mode 100644 drivers/gpu/drm/cirrus/Makefile
 rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7b3255d96d1d..0a5cf105ee37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
 S:	Obsolete
 W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
 T:	git git://anongit.freedesktop.org/drm/drm-misc
-F:	drivers/gpu/drm/cirrus/
+F:	drivers/gpu/drm/tiny/cirrus.c
 
 DRM DRIVER FOR QXL VIRTUAL GPU
 M:	Dave Airlie <airlied@redhat.com>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 43594978958e..4f4e7fa001c1 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
 
 source "drivers/gpu/drm/mgag200/Kconfig"
 
-source "drivers/gpu/drm/cirrus/Kconfig"
-
 source "drivers/gpu/drm/armada/Kconfig"
 
 source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index f34d08c83485..2c0e5a7e5953 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
deleted file mode 100644
index c6bbd988b0e5..000000000000
--- a/drivers/gpu/drm/cirrus/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config DRM_CIRRUS_QEMU
-	tristate "Cirrus driver for QEMU emulated device"
-	depends on DRM && PCI && MMU
-	select DRM_KMS_HELPER
-	select DRM_GEM_SHMEM_HELPER
-	help
-	 This is a KMS driver for emulated cirrus device in qemu.
-	 It is *NOT* intended for real cirrus devices. This requires
-	 the modesetting userspace X.org driver.
-
-	 Cirrus is obsolete, the hardware was designed in the 90ies
-	 and can't keep up with todays needs.  More background:
-	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
-
-	 Better alternatives are:
-	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
-	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
-	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
deleted file mode 100644
index 0c1ed3f99725..000000000000
--- a/drivers/gpu/drm/cirrus/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
index 4160e74e4751..2b6414f0fa75 100644
--- a/drivers/gpu/drm/tiny/Kconfig
+++ b/drivers/gpu/drm/tiny/Kconfig
@@ -1,5 +1,24 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config DRM_CIRRUS_QEMU
+	tristate "Cirrus driver for QEMU emulated device"
+	depends on DRM && PCI && MMU
+	select DRM_KMS_HELPER
+	select DRM_GEM_SHMEM_HELPER
+	help
+	 This is a KMS driver for emulated cirrus device in qemu.
+	 It is *NOT* intended for real cirrus devices. This requires
+	 the modesetting userspace X.org driver.
+
+	 Cirrus is obsolete, the hardware was designed in the 90ies
+	 and can't keep up with todays needs.  More background:
+	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
+
+	 Better alternatives are:
+	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
+	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
+	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
+
 config DRM_GM12U320
 	tristate "GM12U320 driver for USB projectors"
 	depends on DRM && USB
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
index c96ceee71453..6ae4e9e5a35f 100644
--- a/drivers/gpu/drm/tiny/Makefile
+++ b/drivers/gpu/drm/tiny/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
 obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
 obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
similarity index 100%
rename from drivers/gpu/drm/cirrus/cirrus.c
rename to drivers/gpu/drm/tiny/cirrus.c
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Luckily we're already well set up in the main driver, with
drm_dev_put() being the last thing in both the unload error case and
the pci remove function.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 17 ++++-------------
 drivers/gpu/drm/i915/i915_pci.c |  2 --
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 641f5e03b661..ff9a5b1b4c6d 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
 		(struct intel_device_info *)ent->driver_data;
 	struct intel_device_info *device_info;
 	struct drm_i915_private *i915;
-	int err;
 
-	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
-	if (!i915)
-		return ERR_PTR(-ENOMEM);
-
-	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
-	if (err) {
-		kfree(i915);
-		return ERR_PTR(err);
-	}
-
-	drmm_add_final_kfree(&i915->drm, i915);
+	i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
+				  struct drm_i915_private, drm);
+	if (IS_ERR(i915))
+		return i915;
 
 	i915->drm.pdev = pdev;
 	pci_set_drvdata(pdev, i915);
@@ -1006,7 +998,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_disable_device(pdev);
 out_fini:
 	i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
-	drm_dev_put(&i915->drm);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 66738f2c4f28..2741fb3e30cb 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -941,8 +941,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
 
 	i915_driver_remove(i915);
 	pci_set_drvdata(pdev, NULL);
-
-	drm_dev_put(&i915->drm);
 }
 
 /* is device_id present in comma separated list of ids */
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Luckily we're already well set up in the main driver, with
drm_dev_put() being the last thing in both the unload error case and
the pci remove function.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 17 ++++-------------
 drivers/gpu/drm/i915/i915_pci.c |  2 --
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 641f5e03b661..ff9a5b1b4c6d 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
 		(struct intel_device_info *)ent->driver_data;
 	struct intel_device_info *device_info;
 	struct drm_i915_private *i915;
-	int err;
 
-	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
-	if (!i915)
-		return ERR_PTR(-ENOMEM);
-
-	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
-	if (err) {
-		kfree(i915);
-		return ERR_PTR(err);
-	}
-
-	drmm_add_final_kfree(&i915->drm, i915);
+	i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
+				  struct drm_i915_private, drm);
+	if (IS_ERR(i915))
+		return i915;
 
 	i915->drm.pdev = pdev;
 	pci_set_drvdata(pdev, i915);
@@ -1006,7 +998,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_disable_device(pdev);
 out_fini:
 	i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
-	drm_dev_put(&i915->drm);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 66738f2c4f28..2741fb3e30cb 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -941,8 +941,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
 
 	i915_driver_remove(i915);
 	pci_set_drvdata(pdev, NULL);
-
-	drm_dev_put(&i915->drm);
 }
 
 /* is device_id present in comma separated list of ids */
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

- Need to embedded the drm_device, but for now we keep the usual
  pointer chasing.
- No more devm_kzalloc, which fixes a lifetime issues on driver
  remove.
- No more drm_dev_put, that's done by devm_ now.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h     |  1 +
 drivers/gpu/drm/arc/arcpgu_drv.c | 33 +++++++++++++-------------------
 2 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 6aac44b953ad..cd9e932f501e 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -9,6 +9,7 @@
 #define _ARCPGU_H_
 
 struct arcpgu_drm_private {
+	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
 	struct drm_framebuffer	*fb;
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index c05d001163e0..bbd7acb150f3 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -42,18 +42,14 @@ static void arcpgu_setup_mode_config(struct drm_device *drm)
 
 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
 
-static int arcpgu_load(struct drm_device *drm)
+static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 {
-	struct platform_device *pdev = to_platform_device(drm->dev);
-	struct arcpgu_drm_private *arcpgu;
+	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
 	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
+	struct drm_device *drm = &arcpgu->drm;
 	struct resource *res;
 	int ret;
 
-	arcpgu = devm_kzalloc(&pdev->dev, sizeof(*arcpgu), GFP_KERNEL);
-	if (arcpgu == NULL)
-		return -ENOMEM;
-
 	drm->dev_private = arcpgu;
 
 	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
@@ -172,30 +168,28 @@ static struct drm_driver arcpgu_drm_driver = {
 
 static int arcpgu_probe(struct platform_device *pdev)
 {
-	struct drm_device *drm;
+	struct arcpgu_drm_private *arcpgu;
 	int ret;
 
-	drm = drm_dev_alloc(&arcpgu_drm_driver, &pdev->dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	arcpgu = devm_drm_dev_alloc(&pdev->dev, &arcpgu_drm_driver,
+				    struct arcpgu_drm_private, drm);
+	if (IS_ERR(arcpgu))
+		return PTR_ERR(arcpgu);
 
-	ret = arcpgu_load(drm);
+	ret = arcpgu_load(arcpgu);
 	if (ret)
-		goto err_unref;
+		return ret;
 
-	ret = drm_dev_register(drm, 0);
+	ret = drm_dev_register(&arcpgu->drm, 0);
 	if (ret)
 		goto err_unload;
 
-	drm_fbdev_generic_setup(drm, 16);
+	drm_fbdev_generic_setup(&arcpgu->drm, 16);
 
 	return 0;
 
 err_unload:
-	arcpgu_unload(drm);
-
-err_unref:
-	drm_dev_put(drm);
+	arcpgu_unload(&arcpgu->drm);
 
 	return ret;
 }
@@ -206,7 +200,6 @@ static int arcpgu_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(drm);
 	arcpgu_unload(drm);
-	drm_dev_put(drm);
 
 	return 0;
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

- Need to embedded the drm_device, but for now we keep the usual
  pointer chasing.
- No more devm_kzalloc, which fixes a lifetime issues on driver
  remove.
- No more drm_dev_put, that's done by devm_ now.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h     |  1 +
 drivers/gpu/drm/arc/arcpgu_drv.c | 33 +++++++++++++-------------------
 2 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 6aac44b953ad..cd9e932f501e 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -9,6 +9,7 @@
 #define _ARCPGU_H_
 
 struct arcpgu_drm_private {
+	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
 	struct drm_framebuffer	*fb;
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index c05d001163e0..bbd7acb150f3 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -42,18 +42,14 @@ static void arcpgu_setup_mode_config(struct drm_device *drm)
 
 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
 
-static int arcpgu_load(struct drm_device *drm)
+static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 {
-	struct platform_device *pdev = to_platform_device(drm->dev);
-	struct arcpgu_drm_private *arcpgu;
+	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
 	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
+	struct drm_device *drm = &arcpgu->drm;
 	struct resource *res;
 	int ret;
 
-	arcpgu = devm_kzalloc(&pdev->dev, sizeof(*arcpgu), GFP_KERNEL);
-	if (arcpgu == NULL)
-		return -ENOMEM;
-
 	drm->dev_private = arcpgu;
 
 	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
@@ -172,30 +168,28 @@ static struct drm_driver arcpgu_drm_driver = {
 
 static int arcpgu_probe(struct platform_device *pdev)
 {
-	struct drm_device *drm;
+	struct arcpgu_drm_private *arcpgu;
 	int ret;
 
-	drm = drm_dev_alloc(&arcpgu_drm_driver, &pdev->dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	arcpgu = devm_drm_dev_alloc(&pdev->dev, &arcpgu_drm_driver,
+				    struct arcpgu_drm_private, drm);
+	if (IS_ERR(arcpgu))
+		return PTR_ERR(arcpgu);
 
-	ret = arcpgu_load(drm);
+	ret = arcpgu_load(arcpgu);
 	if (ret)
-		goto err_unref;
+		return ret;
 
-	ret = drm_dev_register(drm, 0);
+	ret = drm_dev_register(&arcpgu->drm, 0);
 	if (ret)
 		goto err_unload;
 
-	drm_fbdev_generic_setup(drm, 16);
+	drm_fbdev_generic_setup(&arcpgu->drm, 16);
 
 	return 0;
 
 err_unload:
-	arcpgu_unload(drm);
-
-err_unref:
-	drm_dev_put(drm);
+	arcpgu_unload(&arcpgu->drm);
 
 	return ret;
 }
@@ -206,7 +200,6 @@ static int arcpgu_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(drm);
 	arcpgu_unload(drm);
-	drm_dev_put(drm);
 
 	return 0;
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      | 2 ++
 drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
 drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index cd9e932f501e..87821c91a00c 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -17,6 +17,8 @@ struct arcpgu_drm_private {
 	struct drm_plane	*plane;
 };
 
+#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
+
 #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index be7c29cec318..ba796a216244 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
 
 static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 {
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_plane *plane = NULL;
 	int ret;
 
@@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 
 int arc_pgu_setup_crtc(struct drm_device *drm)
 {
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_plane *primary;
 	int ret;
 
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index bbd7acb150f3..81b8d7ae6623 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	struct resource *res;
 	int ret;
 
-	drm->dev_private = arcpgu;
-
 	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
 	if (IS_ERR(arcpgu->clk))
 		return PTR_ERR(arcpgu->clk);
@@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	unsigned long clkrate = clk_get_rate(arcpgu->clk);
 	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Upcasting using a container_of macro is more typesafe, faster and
easier for the compiler to optimize.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      | 2 ++
 drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
 drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index cd9e932f501e..87821c91a00c 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -17,6 +17,8 @@ struct arcpgu_drm_private {
 	struct drm_plane	*plane;
 };
 
+#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
+
 #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index be7c29cec318..ba796a216244 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
 
 static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 {
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_plane *plane = NULL;
 	int ret;
 
@@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 
 int arc_pgu_setup_crtc(struct drm_device *drm)
 {
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_plane *primary;
 	int ret;
 
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index bbd7acb150f3..81b8d7ae6623 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	struct resource *res;
 	int ret;
 
-	drm->dev_private = arcpgu;
-
 	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
 	if (IS_ERR(arcpgu->clk))
 		return PTR_ERR(arcpgu->clk);
@@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *)m->private;
 	struct drm_device *drm = node->minor->dev;
-	struct arcpgu_drm_private *arcpgu = drm->dev_private;
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	unsigned long clkrate = clk_get_rate(arcpgu->clk);
 	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Alexey Brodkin, DRI Development

Leftover from the conversion to the generic fbdev emulation.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 87821c91a00c..ed77dd5dd5cb 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -12,7 +12,6 @@ struct arcpgu_drm_private {
 	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
-	struct drm_framebuffer	*fb;
 	struct drm_crtc		crtc;
 	struct drm_plane	*plane;
 };
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Alexey Brodkin, DRI Development

Leftover from the conversion to the generic fbdev emulation.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 87821c91a00c..ed77dd5dd5cb 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -12,7 +12,6 @@ struct arcpgu_drm_private {
 	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
-	struct drm_framebuffer	*fb;
 	struct drm_crtc		crtc;
 	struct drm_plane	*plane;
 };
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

This is a prep step to convert arc over to the simple kms helpers, for
now we just use this as an embedding container to drop all the various
allocations. Big change is the removal of the various devm_kzalloc,
which have the wrong lifetimes anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      | 7 ++++---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 9 +++------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 2 +-
 drivers/gpu/drm/arc/arcpgu_hdmi.c | 5 ++---
 drivers/gpu/drm/arc/arcpgu_sim.c  | 5 ++---
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index ed77dd5dd5cb..52afd638a4d2 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -8,17 +8,18 @@
 #ifndef _ARCPGU_H_
 #define _ARCPGU_H_
 
+#include <drm/drm_simple_kms_helper.h>
+
 struct arcpgu_drm_private {
 	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
-	struct drm_crtc		crtc;
-	struct drm_plane	*plane;
+	struct drm_simple_display_pipe pipe;
 };
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
 
-#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
+#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
 				 unsigned int reg, u32 value)
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index ba796a216244..88ba2e284fc0 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -182,9 +182,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 	struct drm_plane *plane = NULL;
 	int ret;
 
-	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
+	plane = &arcpgu->pipe.plane;
 
 	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
 				       arc_pgu_supported_formats,
@@ -195,7 +193,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 		return ERR_PTR(ret);
 
 	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
-	arcpgu->plane = plane;
 
 	return plane;
 }
@@ -210,13 +207,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
 	if (IS_ERR(primary))
 		return PTR_ERR(primary);
 
-	ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL,
+	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
 					&arc_pgu_crtc_funcs, NULL);
 	if (ret) {
 		arc_pgu_plane_destroy(primary);
 		return ret;
 	}
 
-	drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs);
+	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
 	return 0;
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 81b8d7ae6623..a419f279e129 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 	struct drm_device *drm = node->minor->dev;
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	unsigned long clkrate = clk_get_rate(arcpgu->clk);
-	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
+	unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
 
 	seq_printf(m, "hw  : %lu\n", clkrate);
 	seq_printf(m, "mode: %lu\n", mode_clock);
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index 52839934f2fb..dbad2c9237fe 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 {
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_encoder *encoder;
 	struct drm_bridge *bridge;
 
 	int ret = 0;
 
-	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
-	if (encoder == NULL)
-		return -ENOMEM;
+	encoder = &arcpgu->pipe.encoder;
 
 	/* Locate drm bridge from the hdmi encoder DT node */
 	bridge = of_drm_find_bridge(np);
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 37d961668dfe..134afb9fa625 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct arcpgu_drm_connector *arcpgu_connector;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	int ret;
 
-	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
-	if (encoder == NULL)
-		return -ENOMEM;
+	encoder = &arcpgu->pipe.encoder;
 
 	encoder->possible_crtcs = 1;
 	encoder->possible_clones = 0;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

This is a prep step to convert arc over to the simple kms helpers, for
now we just use this as an embedding container to drop all the various
allocations. Big change is the removal of the various devm_kzalloc,
which have the wrong lifetimes anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      | 7 ++++---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 9 +++------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 2 +-
 drivers/gpu/drm/arc/arcpgu_hdmi.c | 5 ++---
 drivers/gpu/drm/arc/arcpgu_sim.c  | 5 ++---
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index ed77dd5dd5cb..52afd638a4d2 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -8,17 +8,18 @@
 #ifndef _ARCPGU_H_
 #define _ARCPGU_H_
 
+#include <drm/drm_simple_kms_helper.h>
+
 struct arcpgu_drm_private {
 	struct drm_device	drm;
 	void __iomem		*regs;
 	struct clk		*clk;
-	struct drm_crtc		crtc;
-	struct drm_plane	*plane;
+	struct drm_simple_display_pipe pipe;
 };
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
 
-#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
+#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
 				 unsigned int reg, u32 value)
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index ba796a216244..88ba2e284fc0 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -182,9 +182,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 	struct drm_plane *plane = NULL;
 	int ret;
 
-	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
-	if (!plane)
-		return ERR_PTR(-ENOMEM);
+	plane = &arcpgu->pipe.plane;
 
 	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
 				       arc_pgu_supported_formats,
@@ -195,7 +193,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
 		return ERR_PTR(ret);
 
 	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
-	arcpgu->plane = plane;
 
 	return plane;
 }
@@ -210,13 +207,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
 	if (IS_ERR(primary))
 		return PTR_ERR(primary);
 
-	ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL,
+	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
 					&arc_pgu_crtc_funcs, NULL);
 	if (ret) {
 		arc_pgu_plane_destroy(primary);
 		return ret;
 	}
 
-	drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs);
+	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
 	return 0;
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 81b8d7ae6623..a419f279e129 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 	struct drm_device *drm = node->minor->dev;
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	unsigned long clkrate = clk_get_rate(arcpgu->clk);
-	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
+	unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
 
 	seq_printf(m, "hw  : %lu\n", clkrate);
 	seq_printf(m, "mode: %lu\n", mode_clock);
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index 52839934f2fb..dbad2c9237fe 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 {
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct drm_encoder *encoder;
 	struct drm_bridge *bridge;
 
 	int ret = 0;
 
-	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
-	if (encoder == NULL)
-		return -ENOMEM;
+	encoder = &arcpgu->pipe.encoder;
 
 	/* Locate drm bridge from the hdmi encoder DT node */
 	bridge = of_drm_find_bridge(np);
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 37d961668dfe..134afb9fa625 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	struct arcpgu_drm_connector *arcpgu_connector;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	int ret;
 
-	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
-	if (encoder == NULL)
-		return -ENOMEM;
+	encoder = &arcpgu->pipe.encoder;
 
 	encoder->possible_crtcs = 1;
 	encoder->possible_clones = 0;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Removes the last devm_kzalloc, which means we're now prepared to use
drmm_mode_config_cleanup!

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h     |  1 +
 drivers/gpu/drm/arc/arcpgu_sim.c | 14 +-------------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 52afd638a4d2..c52cdd2274e1 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -15,6 +15,7 @@ struct arcpgu_drm_private {
 	void __iomem		*regs;
 	struct clk		*clk;
 	struct drm_simple_display_pipe pipe;
+	struct drm_connector	sim_conn;
 };
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 134afb9fa625..e42fe5d05a3d 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -18,10 +18,6 @@
 #define YRES_MAX	8192
 
 
-struct arcpgu_drm_connector {
-	struct drm_connector connector;
-};
-
 static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
 {
 	int count;
@@ -57,7 +53,6 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct arcpgu_drm_connector *arcpgu_connector;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	int ret;
@@ -72,14 +67,7 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 	if (ret)
 		return ret;
 
-	arcpgu_connector = devm_kzalloc(drm->dev, sizeof(*arcpgu_connector),
-					GFP_KERNEL);
-	if (!arcpgu_connector) {
-		ret = -ENOMEM;
-		goto error_encoder_cleanup;
-	}
-
-	connector = &arcpgu_connector->connector;
+	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
 
 	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Removes the last devm_kzalloc, which means we're now prepared to use
drmm_mode_config_cleanup!

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h     |  1 +
 drivers/gpu/drm/arc/arcpgu_sim.c | 14 +-------------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index 52afd638a4d2..c52cdd2274e1 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -15,6 +15,7 @@ struct arcpgu_drm_private {
 	void __iomem		*regs;
 	struct clk		*clk;
 	struct drm_simple_display_pipe pipe;
+	struct drm_connector	sim_conn;
 };
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 134afb9fa625..e42fe5d05a3d 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -18,10 +18,6 @@
 #define YRES_MAX	8192
 
 
-struct arcpgu_drm_connector {
-	struct drm_connector connector;
-};
-
 static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
 {
 	int count;
@@ -57,7 +53,6 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct arcpgu_drm_connector *arcpgu_connector;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	int ret;
@@ -72,14 +67,7 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 	if (ret)
 		return ret;
 
-	arcpgu_connector = devm_kzalloc(drm->dev, sizeof(*arcpgu_connector),
-					GFP_KERNEL);
-	if (!arcpgu_connector) {
-		ret = -ENOMEM;
-		goto error_encoder_cleanup;
-	}
-
-	connector = &arcpgu_connector->connector;
+	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
 
 	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 44/59] drm/arc: Drop surplus connector registration
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

drm_connector_register does nothing before drm_dev_register(), it
is meant for hotpluggable connectors only. Same for the unregister side.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/arc/arcpgu_sim.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index e42fe5d05a3d..3772df1647aa 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -29,7 +29,6 @@ static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
 
 static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
 {
-	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 }
 
@@ -80,7 +79,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret < 0) {
 		dev_err(drm->dev, "could not attach connector to encoder\n");
-		drm_connector_unregister(connector);
 		goto error_connector_cleanup;
 	}
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 44/59] drm/arc: Drop surplus connector registration
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

drm_connector_register does nothing before drm_dev_register(), it
is meant for hotpluggable connectors only. Same for the unregister side.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/arc/arcpgu_sim.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index e42fe5d05a3d..3772df1647aa 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -29,7 +29,6 @@ static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
 
 static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
 {
-	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 }
 
@@ -80,7 +79,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret < 0) {
 		dev_err(drm->dev, "could not attach connector to encoder\n");
-		drm_connector_unregister(connector);
 		goto error_connector_cleanup;
 	}
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

With autocleanup through drm_device management we can delete all the
code. Possible now that there's no confusion against devm_kzalloc'ed
structures anymore.

I inlined arcpgu_setup_mode_config because it's tiny and the newly
needed return value handling would have been more ...

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c |  4 +---
 drivers/gpu/drm/arc/arcpgu_drv.c  | 21 +++++++++------------
 drivers/gpu/drm/arc/arcpgu_hdmi.c |  6 +-----
 drivers/gpu/drm/arc/arcpgu_sim.c  | 11 ++---------
 4 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 88ba2e284fc0..72719556debb 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -209,10 +209,8 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
 
 	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
 					&arc_pgu_crtc_funcs, NULL);
-	if (ret) {
-		arc_pgu_plane_destroy(primary);
+	if (ret)
 		return ret;
-	}
 
 	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
 	return 0;
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index a419f279e129..40c9fc12d515 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -30,16 +30,6 @@ static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void arcpgu_setup_mode_config(struct drm_device *drm)
-{
-	drm_mode_config_init(drm);
-	drm->mode_config.min_width = 0;
-	drm->mode_config.min_height = 0;
-	drm->mode_config.max_width = 1920;
-	drm->mode_config.max_height = 1080;
-	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
-}
-
 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
 
 static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
@@ -54,7 +44,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (IS_ERR(arcpgu->clk))
 		return PTR_ERR(arcpgu->clk);
 
-	arcpgu_setup_mode_config(drm);
+	ret = drmm_mode_config_init(drm);
+	if (ret)
+		return ret;
+
+	drm->mode_config.min_width = 0;
+	drm->mode_config.min_height = 0;
+	drm->mode_config.max_width = 1920;
+	drm->mode_config.max_height = 1080;
+	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -108,7 +106,6 @@ static int arcpgu_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
 	drm_atomic_helper_shutdown(drm);
-	drm_mode_config_cleanup(drm);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index dbad2c9237fe..925d6d31bb78 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -39,9 +39,5 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 		return ret;
 
 	/* Link drm_bridge to encoder */
-	ret = drm_bridge_attach(encoder, bridge, NULL, 0);
-	if (ret)
-		drm_encoder_cleanup(encoder);
-
-	return ret;
+	return drm_bridge_attach(encoder, bridge, NULL, 0);
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 3772df1647aa..afc34f8b4de0 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -73,21 +73,14 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 			DRM_MODE_CONNECTOR_VIRTUAL);
 	if (ret < 0) {
 		dev_err(drm->dev, "failed to initialize drm connector\n");
-		goto error_encoder_cleanup;
+		return ret;
 	}
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret < 0) {
 		dev_err(drm->dev, "could not attach connector to encoder\n");
-		goto error_connector_cleanup;
+		return ret;
 	}
 
 	return 0;
-
-error_connector_cleanup:
-	drm_connector_cleanup(connector);
-
-error_encoder_cleanup:
-	drm_encoder_cleanup(encoder);
-	return ret;
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

With autocleanup through drm_device management we can delete all the
code. Possible now that there's no confusion against devm_kzalloc'ed
structures anymore.

I inlined arcpgu_setup_mode_config because it's tiny and the newly
needed return value handling would have been more ...

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c |  4 +---
 drivers/gpu/drm/arc/arcpgu_drv.c  | 21 +++++++++------------
 drivers/gpu/drm/arc/arcpgu_hdmi.c |  6 +-----
 drivers/gpu/drm/arc/arcpgu_sim.c  | 11 ++---------
 4 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 88ba2e284fc0..72719556debb 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -209,10 +209,8 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
 
 	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
 					&arc_pgu_crtc_funcs, NULL);
-	if (ret) {
-		arc_pgu_plane_destroy(primary);
+	if (ret)
 		return ret;
-	}
 
 	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
 	return 0;
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index a419f279e129..40c9fc12d515 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -30,16 +30,6 @@ static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
-static void arcpgu_setup_mode_config(struct drm_device *drm)
-{
-	drm_mode_config_init(drm);
-	drm->mode_config.min_width = 0;
-	drm->mode_config.min_height = 0;
-	drm->mode_config.max_width = 1920;
-	drm->mode_config.max_height = 1080;
-	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
-}
-
 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
 
 static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
@@ -54,7 +44,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (IS_ERR(arcpgu->clk))
 		return PTR_ERR(arcpgu->clk);
 
-	arcpgu_setup_mode_config(drm);
+	ret = drmm_mode_config_init(drm);
+	if (ret)
+		return ret;
+
+	drm->mode_config.min_width = 0;
+	drm->mode_config.min_height = 0;
+	drm->mode_config.max_width = 1920;
+	drm->mode_config.max_height = 1080;
+	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -108,7 +106,6 @@ static int arcpgu_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
 	drm_atomic_helper_shutdown(drm);
-	drm_mode_config_cleanup(drm);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index dbad2c9237fe..925d6d31bb78 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -39,9 +39,5 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 		return ret;
 
 	/* Link drm_bridge to encoder */
-	ret = drm_bridge_attach(encoder, bridge, NULL, 0);
-	if (ret)
-		drm_encoder_cleanup(encoder);
-
-	return ret;
+	return drm_bridge_attach(encoder, bridge, NULL, 0);
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index 3772df1647aa..afc34f8b4de0 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -73,21 +73,14 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 			DRM_MODE_CONNECTOR_VIRTUAL);
 	if (ret < 0) {
 		dev_err(drm->dev, "failed to initialize drm connector\n");
-		goto error_encoder_cleanup;
+		return ret;
 	}
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret < 0) {
 		dev_err(drm->dev, "could not attach connector to encoder\n");
-		goto error_connector_cleanup;
+		return ret;
 	}
 
 	return 0;
-
-error_connector_cleanup:
-	drm_connector_cleanup(connector);
-
-error_encoder_cleanup:
-	drm_encoder_cleanup(encoder);
-	return ret;
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 46/59] drm/arc: Align with simple pipe helpers
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Simple pipe helpers only have an enable and disable hook, no more
mode_set_nofb. Call it from our enable hook to align with that
conversions.

Atomic helpers always call mode_set_nofb and enable together, so
there's no functional change here.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 72719556debb..c7769edeefdf 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -73,10 +73,9 @@ static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
 	return MODE_NOCLOCK;
 }
 
-static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
+static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	struct drm_display_mode *m = &crtc->state->adjusted_mode;
+	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
 	u32 val;
 
 	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
@@ -110,7 +109,7 @@ static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
 
-	arc_pgu_set_pxl_fmt(crtc);
+	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
 
 	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
 }
@@ -120,6 +119,8 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
 
+	arc_pgu_mode_set(arcpgu);
+
 	clk_prepare_enable(arcpgu->clk);
 	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
 		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
@@ -139,7 +140,6 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
 	.mode_valid	= arc_pgu_crtc_mode_valid,
-	.mode_set_nofb	= arc_pgu_crtc_mode_set_nofb,
 	.atomic_enable	= arc_pgu_crtc_atomic_enable,
 	.atomic_disable	= arc_pgu_crtc_atomic_disable,
 };
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 46/59] drm/arc: Align with simple pipe helpers
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Simple pipe helpers only have an enable and disable hook, no more
mode_set_nofb. Call it from our enable hook to align with that
conversions.

Atomic helpers always call mode_set_nofb and enable together, so
there's no functional change here.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 72719556debb..c7769edeefdf 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -73,10 +73,9 @@ static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
 	return MODE_NOCLOCK;
 }
 
-static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
+static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	struct drm_display_mode *m = &crtc->state->adjusted_mode;
+	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
 	u32 val;
 
 	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
@@ -110,7 +109,7 @@ static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
 
-	arc_pgu_set_pxl_fmt(crtc);
+	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
 
 	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
 }
@@ -120,6 +119,8 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
 
+	arc_pgu_mode_set(arcpgu);
+
 	clk_prepare_enable(arcpgu->clk);
 	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
 		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
@@ -139,7 +140,6 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
 	.mode_valid	= arc_pgu_crtc_mode_valid,
-	.mode_set_nofb	= arc_pgu_crtc_mode_set_nofb,
 	.atomic_enable	= arc_pgu_crtc_atomic_enable,
 	.atomic_disable	= arc_pgu_crtc_atomic_disable,
 };
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Really straighforward, only slight issue is that the sim connector is
created after the pipe is set up, so can't use the helpers perfectly
yet. Subsequent patches will fix that.

Aside from lots of deleting code no functional changes in here.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      |   4 +-
 drivers/gpu/drm/arc/arcpgu_crtc.c | 102 ++++++++----------------------
 drivers/gpu/drm/arc/arcpgu_drv.c  |   2 +-
 drivers/gpu/drm/arc/arcpgu_hdmi.c |  18 +-----
 4 files changed, 31 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index c52cdd2274e1..b5c699d14f27 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -20,7 +20,7 @@ struct arcpgu_drm_private {
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
 
-#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
+#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
 				 unsigned int reg, u32 value)
@@ -34,7 +34,7 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arc_pgu_setup_crtc(struct drm_device *dev);
+int arc_pgu_setup_pipe(struct drm_device *dev);
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index c7769edeefdf..5c6d7e34ca73 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -25,10 +25,9 @@ static const u32 arc_pgu_supported_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
-static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
+static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	const struct drm_framebuffer *fb = crtc->primary->state->fb;
+	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
 	uint32_t pixel_format = fb->format->format;
 	u32 format = DRM_FORMAT_INVALID;
 	int i;
@@ -59,10 +58,10 @@ static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
-static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
-						    const struct drm_display_mode *mode)
+static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
+					       const struct drm_display_mode *mode)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 	long rate, clk_rate = mode->clock * 1000;
 	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
 
@@ -109,15 +108,16 @@ static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
 	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
 
-	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
+	arc_pgu_set_pxl_fmt(arcpgu);
 
 	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
 }
 
-static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
-				       struct drm_crtc_state *old_state)
+static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
+			   struct drm_crtc_state *crtc_state,
+			   struct drm_plane_state *plane_state)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 
 	arc_pgu_mode_set(arcpgu);
 
@@ -127,10 +127,9 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
 		      ARCPGU_CTRL_ENABLE_MASK);
 }
 
-static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
-					struct drm_crtc_state *old_state)
+static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 
 	clk_disable_unprepare(arcpgu->clk);
 	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
@@ -138,80 +137,33 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
 			      ~ARCPGU_CTRL_ENABLE_MASK);
 }
 
-static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
-	.mode_valid	= arc_pgu_crtc_mode_valid,
-	.atomic_enable	= arc_pgu_crtc_atomic_enable,
-	.atomic_disable	= arc_pgu_crtc_atomic_disable,
-};
-
-static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
-					struct drm_plane_state *state)
+static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
+			   struct drm_plane_state *state)
 {
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
-	if (!plane->state->crtc || !plane->state->fb)
+	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
 		return;
 
-	arcpgu = crtc_to_arcpgu_priv(plane->state->crtc);
-	gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
+	arcpgu = pipe_to_arcpgu_priv(pipe);
+	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
 }
 
-static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = {
-	.atomic_update = arc_pgu_plane_atomic_update,
+static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
+	.update = arc_pgu_update,
+	.mode_valid = arc_pgu_mode_valid,
+	.enable	= arc_pgu_enable,
+	.disable = arc_pgu_disable,
 };
 
-static void arc_pgu_plane_destroy(struct drm_plane *plane)
-{
-	drm_plane_cleanup(plane);
-}
-
-static const struct drm_plane_funcs arc_pgu_plane_funcs = {
-	.update_plane		= drm_atomic_helper_update_plane,
-	.disable_plane		= drm_atomic_helper_disable_plane,
-	.destroy		= arc_pgu_plane_destroy,
-	.reset			= drm_atomic_helper_plane_reset,
-	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
-	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
-};
-
-static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
+int arc_pgu_setup_pipe(struct drm_device *drm)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_plane *plane = NULL;
-	int ret;
-
-	plane = &arcpgu->pipe.plane;
-
-	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
-				       arc_pgu_supported_formats,
-				       ARRAY_SIZE(arc_pgu_supported_formats),
-				       NULL,
-				       DRM_PLANE_TYPE_PRIMARY, NULL);
-	if (ret)
-		return ERR_PTR(ret);
-
-	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
-
-	return plane;
-}
-
-int arc_pgu_setup_crtc(struct drm_device *drm)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_plane *primary;
-	int ret;
-
-	primary = arc_pgu_plane_init(drm);
-	if (IS_ERR(primary))
-		return PTR_ERR(primary);
-
-	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
-					&arc_pgu_crtc_funcs, NULL);
-	if (ret)
-		return ret;
 
-	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
-	return 0;
+	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					    arc_pgu_supported_formats,
+					    ARRAY_SIZE(arc_pgu_supported_formats),
+					    NULL, NULL);
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 40c9fc12d515..bf03eda532bc 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -70,7 +70,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	if (arc_pgu_setup_crtc(drm) < 0)
+	if (arc_pgu_setup_pipe(drm) < 0)
 		return -ENODEV;
 
 	/*
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index 925d6d31bb78..d430af686cbc 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -12,32 +12,16 @@
 
 #include "arcpgu.h"
 
-static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
 	struct drm_bridge *bridge;
 
-	int ret = 0;
-
-	encoder = &arcpgu->pipe.encoder;
-
 	/* Locate drm bridge from the hdmi encoder DT node */
 	bridge = of_drm_find_bridge(np);
 	if (!bridge)
 		return -EPROBE_DEFER;
 
-	encoder->possible_crtcs = 1;
-	encoder->possible_clones = 0;
-	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
-			       DRM_MODE_ENCODER_TMDS, NULL);
-	if (ret)
-		return ret;
-
 	/* Link drm_bridge to encoder */
-	return drm_bridge_attach(encoder, bridge, NULL, 0);
+	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Really straighforward, only slight issue is that the sim connector is
created after the pipe is set up, so can't use the helpers perfectly
yet. Subsequent patches will fix that.

Aside from lots of deleting code no functional changes in here.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu.h      |   4 +-
 drivers/gpu/drm/arc/arcpgu_crtc.c | 102 ++++++++----------------------
 drivers/gpu/drm/arc/arcpgu_drv.c  |   2 +-
 drivers/gpu/drm/arc/arcpgu_hdmi.c |  18 +-----
 4 files changed, 31 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index c52cdd2274e1..b5c699d14f27 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -20,7 +20,7 @@ struct arcpgu_drm_private {
 
 #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
 
-#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
+#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
 
 static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
 				 unsigned int reg, u32 value)
@@ -34,7 +34,7 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arc_pgu_setup_crtc(struct drm_device *dev);
+int arc_pgu_setup_pipe(struct drm_device *dev);
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index c7769edeefdf..5c6d7e34ca73 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -25,10 +25,9 @@ static const u32 arc_pgu_supported_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
-static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
+static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
-	const struct drm_framebuffer *fb = crtc->primary->state->fb;
+	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
 	uint32_t pixel_format = fb->format->format;
 	u32 format = DRM_FORMAT_INVALID;
 	int i;
@@ -59,10 +58,10 @@ static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
-static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
-						    const struct drm_display_mode *mode)
+static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
+					       const struct drm_display_mode *mode)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 	long rate, clk_rate = mode->clock * 1000;
 	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
 
@@ -109,15 +108,16 @@ static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
 	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
 
-	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
+	arc_pgu_set_pxl_fmt(arcpgu);
 
 	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
 }
 
-static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
-				       struct drm_crtc_state *old_state)
+static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
+			   struct drm_crtc_state *crtc_state,
+			   struct drm_plane_state *plane_state)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 
 	arc_pgu_mode_set(arcpgu);
 
@@ -127,10 +127,9 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
 		      ARCPGU_CTRL_ENABLE_MASK);
 }
 
-static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
-					struct drm_crtc_state *old_state)
+static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
 {
-	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
 
 	clk_disable_unprepare(arcpgu->clk);
 	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
@@ -138,80 +137,33 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
 			      ~ARCPGU_CTRL_ENABLE_MASK);
 }
 
-static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
-	.mode_valid	= arc_pgu_crtc_mode_valid,
-	.atomic_enable	= arc_pgu_crtc_atomic_enable,
-	.atomic_disable	= arc_pgu_crtc_atomic_disable,
-};
-
-static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
-					struct drm_plane_state *state)
+static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
+			   struct drm_plane_state *state)
 {
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
-	if (!plane->state->crtc || !plane->state->fb)
+	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
 		return;
 
-	arcpgu = crtc_to_arcpgu_priv(plane->state->crtc);
-	gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
+	arcpgu = pipe_to_arcpgu_priv(pipe);
+	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
 }
 
-static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = {
-	.atomic_update = arc_pgu_plane_atomic_update,
+static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
+	.update = arc_pgu_update,
+	.mode_valid = arc_pgu_mode_valid,
+	.enable	= arc_pgu_enable,
+	.disable = arc_pgu_disable,
 };
 
-static void arc_pgu_plane_destroy(struct drm_plane *plane)
-{
-	drm_plane_cleanup(plane);
-}
-
-static const struct drm_plane_funcs arc_pgu_plane_funcs = {
-	.update_plane		= drm_atomic_helper_update_plane,
-	.disable_plane		= drm_atomic_helper_disable_plane,
-	.destroy		= arc_pgu_plane_destroy,
-	.reset			= drm_atomic_helper_plane_reset,
-	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
-	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
-};
-
-static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
+int arc_pgu_setup_pipe(struct drm_device *drm)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_plane *plane = NULL;
-	int ret;
-
-	plane = &arcpgu->pipe.plane;
-
-	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
-				       arc_pgu_supported_formats,
-				       ARRAY_SIZE(arc_pgu_supported_formats),
-				       NULL,
-				       DRM_PLANE_TYPE_PRIMARY, NULL);
-	if (ret)
-		return ERR_PTR(ret);
-
-	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
-
-	return plane;
-}
-
-int arc_pgu_setup_crtc(struct drm_device *drm)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_plane *primary;
-	int ret;
-
-	primary = arc_pgu_plane_init(drm);
-	if (IS_ERR(primary))
-		return PTR_ERR(primary);
-
-	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
-					&arc_pgu_crtc_funcs, NULL);
-	if (ret)
-		return ret;
 
-	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
-	return 0;
+	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					    arc_pgu_supported_formats,
+					    ARRAY_SIZE(arc_pgu_supported_formats),
+					    NULL, NULL);
 }
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 40c9fc12d515..bf03eda532bc 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -70,7 +70,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	if (arc_pgu_setup_crtc(drm) < 0)
+	if (arc_pgu_setup_pipe(drm) < 0)
 		return -ENODEV;
 
 	/*
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index 925d6d31bb78..d430af686cbc 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -12,32 +12,16 @@
 
 #include "arcpgu.h"
 
-static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
 	struct drm_bridge *bridge;
 
-	int ret = 0;
-
-	encoder = &arcpgu->pipe.encoder;
-
 	/* Locate drm bridge from the hdmi encoder DT node */
 	bridge = of_drm_find_bridge(np);
 	if (!bridge)
 		return -EPROBE_DEFER;
 
-	encoder->possible_crtcs = 1;
-	encoder->possible_clones = 0;
-	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
-			       DRM_MODE_ENCODER_TMDS, NULL);
-	if (ret)
-		return ret;
-
 	/* Link drm_bridge to encoder */
-	return drm_bridge_attach(encoder, bridge, NULL, 0);
+	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

First it's redundant, fb and crtc are only ever both set or not set.
2nd, the atomic_check code in simple display pipe helpers guarantees
that this never happens. So nice bugfix for arcpgu driver here, since
it was lacking a call to drm_atomic_helper_check_plane_state().

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 5c6d7e34ca73..4655f03e37f1 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -143,9 +143,6 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
-	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
-		return;
-
 	arcpgu = pipe_to_arcpgu_priv(pipe);
 	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

First it's redundant, fb and crtc are only ever both set or not set.
2nd, the atomic_check code in simple display pipe helpers guarantees
that this never happens. So nice bugfix for arcpgu driver here, since
it was lacking a call to drm_atomic_helper_check_plane_state().

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
index 5c6d7e34ca73..4655f03e37f1 100644
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
@@ -143,9 +143,6 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
-	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
-		return;
-
 	arcpgu = pipe_to_arcpgu_priv(pipe);
 	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Really not big anymore.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |   2 +-
 drivers/gpu/drm/arc/arcpgu.h      |   1 -
 drivers/gpu/drm/arc/arcpgu_crtc.c | 166 ------------------------------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 147 +++++++++++++++++++++++++-
 drivers/gpu/drm/arc/arcpgu_sim.c  |  12 ---
 5 files changed, 146 insertions(+), 182 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index c7028b7427b3..c686e0287a71 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_crtc.o arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index b5c699d14f27..cee2448a07d6 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arc_pgu_setup_pipe(struct drm_device *dev);
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
deleted file mode 100644
index 4655f03e37f1..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ /dev/null
@@ -1,166 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_device.h>
-#include <drm/drm_fb_cma_helper.h>
-#include <drm/drm_gem_cma_helper.h>
-#include <drm/drm_plane_helper.h>
-#include <drm/drm_probe_helper.h>
-#include <linux/clk.h>
-#include <linux/platform_data/simplefb.h>
-
-#include "arcpgu.h"
-#include "arcpgu_regs.h"
-
-#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
-
-static const u32 arc_pgu_supported_formats[] = {
-	DRM_FORMAT_RGB565,
-	DRM_FORMAT_XRGB8888,
-	DRM_FORMAT_ARGB8888,
-};
-
-static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
-{
-	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
-	uint32_t pixel_format = fb->format->format;
-	u32 format = DRM_FORMAT_INVALID;
-	int i;
-	u32 reg_ctrl;
-
-	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
-		if (arc_pgu_supported_formats[i] == pixel_format)
-			format = arc_pgu_supported_formats[i];
-	}
-
-	if (WARN_ON(format == DRM_FORMAT_INVALID))
-		return;
-
-	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
-	if (format == DRM_FORMAT_RGB565)
-		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
-	else
-		reg_ctrl |= ARCPGU_MODE_XRGB8888;
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
-}
-
-static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
-	.destroy = drm_crtc_cleanup,
-	.set_config = drm_atomic_helper_set_config,
-	.page_flip = drm_atomic_helper_page_flip,
-	.reset = drm_atomic_helper_crtc_reset,
-	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
-};
-
-static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
-					       const struct drm_display_mode *mode)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-	long rate, clk_rate = mode->clock * 1000;
-	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
-
-	rate = clk_round_rate(arcpgu->clk, clk_rate);
-	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
-		return MODE_OK;
-
-	return MODE_NOCLOCK;
-}
-
-static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
-{
-	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
-	u32 val;
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
-		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
-		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
-				    m->crtc_hsync_end - m->crtc_hdisplay));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
-		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
-				    m->crtc_vsync_end - m->crtc_vdisplay));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
-		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
-				    m->crtc_vblank_end - m->crtc_vblank_start));
-
-	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
-
-	if (m->flags & DRM_MODE_FLAG_PVSYNC)
-		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
-	else
-		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
-
-	if (m->flags & DRM_MODE_FLAG_PHSYNC)
-		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
-	else
-		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
-	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
-	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
-
-	arc_pgu_set_pxl_fmt(arcpgu);
-
-	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
-}
-
-static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
-			   struct drm_crtc_state *crtc_state,
-			   struct drm_plane_state *plane_state)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-
-	arc_pgu_mode_set(arcpgu);
-
-	clk_prepare_enable(arcpgu->clk);
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
-		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
-		      ARCPGU_CTRL_ENABLE_MASK);
-}
-
-static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-
-	clk_disable_unprepare(arcpgu->clk);
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
-			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
-			      ~ARCPGU_CTRL_ENABLE_MASK);
-}
-
-static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
-			   struct drm_plane_state *state)
-{
-	struct arcpgu_drm_private *arcpgu;
-	struct drm_gem_cma_object *gem;
-
-	arcpgu = pipe_to_arcpgu_priv(pipe);
-	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
-	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-}
-
-static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
-	.update = arc_pgu_update,
-	.mode_valid = arc_pgu_mode_valid,
-	.enable	= arc_pgu_enable,
-	.disable = arc_pgu_disable,
-};
-
-int arc_pgu_setup_pipe(struct drm_device *drm)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-
-	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
-					    arc_pgu_supported_formats,
-					    ARRAY_SIZE(arc_pgu_supported_formats),
-					    NULL, NULL);
-}
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index bf03eda532bc..2443e3c78a76 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -12,6 +12,7 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_fourcc.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_of.h>
@@ -24,6 +25,144 @@
 #include "arcpgu.h"
 #include "arcpgu_regs.h"
 
+#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
+
+static const u32 arc_pgu_supported_formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_ARGB8888,
+};
+
+static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
+{
+	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
+	uint32_t pixel_format = fb->format->format;
+	u32 format = DRM_FORMAT_INVALID;
+	int i;
+	u32 reg_ctrl;
+
+	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
+		if (arc_pgu_supported_formats[i] == pixel_format)
+			format = arc_pgu_supported_formats[i];
+	}
+
+	if (WARN_ON(format == DRM_FORMAT_INVALID))
+		return;
+
+	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
+	if (format == DRM_FORMAT_RGB565)
+		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
+	else
+		reg_ctrl |= ARCPGU_MODE_XRGB8888;
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
+}
+
+static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_atomic_helper_set_config,
+	.page_flip = drm_atomic_helper_page_flip,
+	.reset = drm_atomic_helper_crtc_reset,
+	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+};
+
+static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
+					       const struct drm_display_mode *mode)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+	long rate, clk_rate = mode->clock * 1000;
+	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
+
+	rate = clk_round_rate(arcpgu->clk, clk_rate);
+	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
+		return MODE_OK;
+
+	return MODE_NOCLOCK;
+}
+
+static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
+{
+	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
+	u32 val;
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
+		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
+		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
+				    m->crtc_hsync_end - m->crtc_hdisplay));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
+		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
+				    m->crtc_vsync_end - m->crtc_vdisplay));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
+		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
+				    m->crtc_vblank_end - m->crtc_vblank_start));
+
+	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
+
+	if (m->flags & DRM_MODE_FLAG_PVSYNC)
+		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
+	else
+		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
+
+	if (m->flags & DRM_MODE_FLAG_PHSYNC)
+		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
+	else
+		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
+	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
+	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
+
+	arc_pgu_set_pxl_fmt(arcpgu);
+
+	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
+}
+
+static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
+			   struct drm_crtc_state *crtc_state,
+			   struct drm_plane_state *plane_state)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+
+	arc_pgu_mode_set(arcpgu);
+
+	clk_prepare_enable(arcpgu->clk);
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
+		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
+		      ARCPGU_CTRL_ENABLE_MASK);
+}
+
+static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+
+	clk_disable_unprepare(arcpgu->clk);
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
+			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
+			      ~ARCPGU_CTRL_ENABLE_MASK);
+}
+
+static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
+			   struct drm_plane_state *state)
+{
+	struct arcpgu_drm_private *arcpgu;
+	struct drm_gem_cma_object *gem;
+
+	arcpgu = pipe_to_arcpgu_priv(pipe);
+	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
+	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
+}
+
+static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
+	.update = arc_pgu_update,
+	.mode_valid = arc_pgu_mode_valid,
+	.enable	= arc_pgu_enable,
+	.disable = arc_pgu_disable,
+};
+
 static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
 	.fb_create  = drm_gem_fb_create,
 	.atomic_check = drm_atomic_helper_check,
@@ -70,8 +209,12 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	if (arc_pgu_setup_pipe(drm) < 0)
-		return -ENODEV;
+	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					   arc_pgu_supported_formats,
+					   ARRAY_SIZE(arc_pgu_supported_formats),
+					   NULL, NULL);
+	if (ret)
+		return ret;
 
 	/*
 	 * There is only one output port inside each device. It is linked with
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index afc34f8b4de0..1a63f0868504 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -45,10 +45,6 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
@@ -58,14 +54,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 
 	encoder = &arcpgu->pipe.encoder;
 
-	encoder->possible_crtcs = 1;
-	encoder->possible_clones = 0;
-
-	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
-			       DRM_MODE_ENCODER_VIRTUAL, NULL);
-	if (ret)
-		return ret;
-
 	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Really not big anymore.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |   2 +-
 drivers/gpu/drm/arc/arcpgu.h      |   1 -
 drivers/gpu/drm/arc/arcpgu_crtc.c | 166 ------------------------------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 147 +++++++++++++++++++++++++-
 drivers/gpu/drm/arc/arcpgu_sim.c  |  12 ---
 5 files changed, 146 insertions(+), 182 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index c7028b7427b3..c686e0287a71 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_crtc.o arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index b5c699d14f27..cee2448a07d6 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arc_pgu_setup_pipe(struct drm_device *dev);
 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
deleted file mode 100644
index 4655f03e37f1..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_crtc.c
+++ /dev/null
@@ -1,166 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_device.h>
-#include <drm/drm_fb_cma_helper.h>
-#include <drm/drm_gem_cma_helper.h>
-#include <drm/drm_plane_helper.h>
-#include <drm/drm_probe_helper.h>
-#include <linux/clk.h>
-#include <linux/platform_data/simplefb.h>
-
-#include "arcpgu.h"
-#include "arcpgu_regs.h"
-
-#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
-
-static const u32 arc_pgu_supported_formats[] = {
-	DRM_FORMAT_RGB565,
-	DRM_FORMAT_XRGB8888,
-	DRM_FORMAT_ARGB8888,
-};
-
-static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
-{
-	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
-	uint32_t pixel_format = fb->format->format;
-	u32 format = DRM_FORMAT_INVALID;
-	int i;
-	u32 reg_ctrl;
-
-	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
-		if (arc_pgu_supported_formats[i] == pixel_format)
-			format = arc_pgu_supported_formats[i];
-	}
-
-	if (WARN_ON(format == DRM_FORMAT_INVALID))
-		return;
-
-	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
-	if (format == DRM_FORMAT_RGB565)
-		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
-	else
-		reg_ctrl |= ARCPGU_MODE_XRGB8888;
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
-}
-
-static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
-	.destroy = drm_crtc_cleanup,
-	.set_config = drm_atomic_helper_set_config,
-	.page_flip = drm_atomic_helper_page_flip,
-	.reset = drm_atomic_helper_crtc_reset,
-	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
-};
-
-static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
-					       const struct drm_display_mode *mode)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-	long rate, clk_rate = mode->clock * 1000;
-	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
-
-	rate = clk_round_rate(arcpgu->clk, clk_rate);
-	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
-		return MODE_OK;
-
-	return MODE_NOCLOCK;
-}
-
-static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
-{
-	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
-	u32 val;
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
-		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
-		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
-				    m->crtc_hsync_end - m->crtc_hdisplay));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
-		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
-				    m->crtc_vsync_end - m->crtc_vdisplay));
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
-		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
-				    m->crtc_vblank_end - m->crtc_vblank_start));
-
-	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
-
-	if (m->flags & DRM_MODE_FLAG_PVSYNC)
-		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
-	else
-		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
-
-	if (m->flags & DRM_MODE_FLAG_PHSYNC)
-		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
-	else
-		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
-
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
-	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
-	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
-
-	arc_pgu_set_pxl_fmt(arcpgu);
-
-	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
-}
-
-static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
-			   struct drm_crtc_state *crtc_state,
-			   struct drm_plane_state *plane_state)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-
-	arc_pgu_mode_set(arcpgu);
-
-	clk_prepare_enable(arcpgu->clk);
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
-		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
-		      ARCPGU_CTRL_ENABLE_MASK);
-}
-
-static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
-{
-	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
-
-	clk_disable_unprepare(arcpgu->clk);
-	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
-			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
-			      ~ARCPGU_CTRL_ENABLE_MASK);
-}
-
-static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
-			   struct drm_plane_state *state)
-{
-	struct arcpgu_drm_private *arcpgu;
-	struct drm_gem_cma_object *gem;
-
-	arcpgu = pipe_to_arcpgu_priv(pipe);
-	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
-	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-}
-
-static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
-	.update = arc_pgu_update,
-	.mode_valid = arc_pgu_mode_valid,
-	.enable	= arc_pgu_enable,
-	.disable = arc_pgu_disable,
-};
-
-int arc_pgu_setup_pipe(struct drm_device *drm)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-
-	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
-					    arc_pgu_supported_formats,
-					    ARRAY_SIZE(arc_pgu_supported_formats),
-					    NULL, NULL);
-}
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index bf03eda532bc..2443e3c78a76 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -12,6 +12,7 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_fourcc.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_of.h>
@@ -24,6 +25,144 @@
 #include "arcpgu.h"
 #include "arcpgu_regs.h"
 
+#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
+
+static const u32 arc_pgu_supported_formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_ARGB8888,
+};
+
+static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
+{
+	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
+	uint32_t pixel_format = fb->format->format;
+	u32 format = DRM_FORMAT_INVALID;
+	int i;
+	u32 reg_ctrl;
+
+	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
+		if (arc_pgu_supported_formats[i] == pixel_format)
+			format = arc_pgu_supported_formats[i];
+	}
+
+	if (WARN_ON(format == DRM_FORMAT_INVALID))
+		return;
+
+	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
+	if (format == DRM_FORMAT_RGB565)
+		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
+	else
+		reg_ctrl |= ARCPGU_MODE_XRGB8888;
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
+}
+
+static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_atomic_helper_set_config,
+	.page_flip = drm_atomic_helper_page_flip,
+	.reset = drm_atomic_helper_crtc_reset,
+	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+};
+
+static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
+					       const struct drm_display_mode *mode)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+	long rate, clk_rate = mode->clock * 1000;
+	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
+
+	rate = clk_round_rate(arcpgu->clk, clk_rate);
+	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
+		return MODE_OK;
+
+	return MODE_NOCLOCK;
+}
+
+static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
+{
+	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
+	u32 val;
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
+		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
+		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
+				    m->crtc_hsync_end - m->crtc_hdisplay));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
+		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
+				    m->crtc_vsync_end - m->crtc_vdisplay));
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
+		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
+				    m->crtc_vblank_end - m->crtc_vblank_start));
+
+	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
+
+	if (m->flags & DRM_MODE_FLAG_PVSYNC)
+		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
+	else
+		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
+
+	if (m->flags & DRM_MODE_FLAG_PHSYNC)
+		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
+	else
+		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
+
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
+	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
+	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
+
+	arc_pgu_set_pxl_fmt(arcpgu);
+
+	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
+}
+
+static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
+			   struct drm_crtc_state *crtc_state,
+			   struct drm_plane_state *plane_state)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+
+	arc_pgu_mode_set(arcpgu);
+
+	clk_prepare_enable(arcpgu->clk);
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
+		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
+		      ARCPGU_CTRL_ENABLE_MASK);
+}
+
+static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
+{
+	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
+
+	clk_disable_unprepare(arcpgu->clk);
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
+			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
+			      ~ARCPGU_CTRL_ENABLE_MASK);
+}
+
+static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
+			   struct drm_plane_state *state)
+{
+	struct arcpgu_drm_private *arcpgu;
+	struct drm_gem_cma_object *gem;
+
+	arcpgu = pipe_to_arcpgu_priv(pipe);
+	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
+	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
+}
+
+static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
+	.update = arc_pgu_update,
+	.mode_valid = arc_pgu_mode_valid,
+	.enable	= arc_pgu_enable,
+	.disable = arc_pgu_disable,
+};
+
 static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
 	.fb_create  = drm_gem_fb_create,
 	.atomic_check = drm_atomic_helper_check,
@@ -70,8 +209,12 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	if (arc_pgu_setup_pipe(drm) < 0)
-		return -ENODEV;
+	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					   arc_pgu_supported_formats,
+					   ARRAY_SIZE(arc_pgu_supported_formats),
+					   NULL, NULL);
+	if (ret)
+		return ret;
 
 	/*
 	 * There is only one output port inside each device. It is linked with
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
index afc34f8b4de0..1a63f0868504 100644
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ b/drivers/gpu/drm/arc/arcpgu_sim.c
@@ -45,10 +45,6 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 {
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
@@ -58,14 +54,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
 
 	encoder = &arcpgu->pipe.encoder;
 
-	encoder->possible_crtcs = 1;
-	encoder->possible_clones = 0;
-
-	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
-			       DRM_MODE_ENCODER_VIRTUAL, NULL);
-	if (ret)
-		return ret;
-
 	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
 
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Really not worth the function, much less the separate file now that
almost all the code is gone.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |  2 +-
 drivers/gpu/drm/arc/arcpgu.h      |  1 -
 drivers/gpu/drm/arc/arcpgu_drv.c  | 12 +++++++++---
 drivers/gpu/drm/arc/arcpgu_hdmi.c | 27 ---------------------------
 4 files changed, 10 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index c686e0287a71..379a1145bc2f 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_sim.o arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index cee2448a07d6..7dce0c2313ba 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
 #endif
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 2443e3c78a76..8fbfd956de0a 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -227,9 +227,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	}
 
 	if (encoder_node) {
-		ret = arcpgu_drm_hdmi_init(drm, encoder_node);
-		of_node_put(encoder_node);
-		if (ret < 0)
+		struct drm_bridge *bridge;
+
+		/* Locate drm bridge from the hdmi encoder DT node */
+		bridge = of_drm_find_bridge(encoder_node);
+		if (!bridge)
+			return -EPROBE_DEFER;
+
+		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
+		if (ret)
 			return ret;
 	} else {
 		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
deleted file mode 100644
index d430af686cbc..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_bridge.h>
-#include <drm/drm_crtc.h>
-#include <drm/drm_encoder.h>
-#include <drm/drm_device.h>
-
-#include "arcpgu.h"
-
-int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_bridge *bridge;
-
-	/* Locate drm bridge from the hdmi encoder DT node */
-	bridge = of_drm_find_bridge(np);
-	if (!bridge)
-		return -EPROBE_DEFER;
-
-	/* Link drm_bridge to encoder */
-	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
-}
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

Really not worth the function, much less the separate file now that
almost all the code is gone.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |  2 +-
 drivers/gpu/drm/arc/arcpgu.h      |  1 -
 drivers/gpu/drm/arc/arcpgu_drv.c  | 12 +++++++++---
 drivers/gpu/drm/arc/arcpgu_hdmi.c | 27 ---------------------------
 4 files changed, 10 insertions(+), 32 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index c686e0287a71..379a1145bc2f 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_sim.o arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
index cee2448a07d6..7dce0c2313ba 100644
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ b/drivers/gpu/drm/arc/arcpgu.h
@@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
 	return ioread32(arcpgu->regs + reg);
 }
 
-int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
 
 #endif
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 2443e3c78a76..8fbfd956de0a 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -227,9 +227,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	}
 
 	if (encoder_node) {
-		ret = arcpgu_drm_hdmi_init(drm, encoder_node);
-		of_node_put(encoder_node);
-		if (ret < 0)
+		struct drm_bridge *bridge;
+
+		/* Locate drm bridge from the hdmi encoder DT node */
+		bridge = of_drm_find_bridge(encoder_node);
+		if (!bridge)
+			return -EPROBE_DEFER;
+
+		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
+		if (ret)
 			return ret;
 	} else {
 		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
deleted file mode 100644
index d430af686cbc..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_bridge.h>
-#include <drm/drm_crtc.h>
-#include <drm/drm_encoder.h>
-#include <drm/drm_device.h>
-
-#include "arcpgu.h"
-
-int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_bridge *bridge;
-
-	/* Locate drm bridge from the hdmi encoder DT node */
-	bridge = of_drm_find_bridge(np);
-	if (!bridge)
-		return -EPROBE_DEFER;
-
-	/* Link drm_bridge to encoder */
-	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
-}
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 51/59] drm/arc: Inline remaining files
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

At less than 500 lines total feels like the right thing to do.

Also noticed that the simple wrapper around drm_connector_cleanup can
be dropped.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |   2 +-
 drivers/gpu/drm/arc/arcpgu.h      |  39 ------------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 102 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/arc/arcpgu_regs.h |  31 ---------
 drivers/gpu/drm/arc/arcpgu_sim.c  |  74 ----------------------
 5 files changed, 101 insertions(+), 147 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index 379a1145bc2f..b26f2495c532 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
deleted file mode 100644
index 7dce0c2313ba..000000000000
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#ifndef _ARCPGU_H_
-#define _ARCPGU_H_
-
-#include <drm/drm_simple_kms_helper.h>
-
-struct arcpgu_drm_private {
-	struct drm_device	drm;
-	void __iomem		*regs;
-	struct clk		*clk;
-	struct drm_simple_display_pipe pipe;
-	struct drm_connector	sim_conn;
-};
-
-#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
-
-#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
-
-static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
-				 unsigned int reg, u32 value)
-{
-	iowrite32(value, arcpgu->regs + reg);
-}
-
-static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
-			       unsigned int reg)
-{
-	return ioread32(arcpgu->regs + reg);
-}
-
-int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
-
-#endif
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 8fbfd956de0a..b0c941d91545 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -17,13 +17,111 @@
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_of.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 
-#include "arcpgu.h"
-#include "arcpgu_regs.h"
+#define ARCPGU_REG_CTRL		0x00
+#define ARCPGU_REG_STAT		0x04
+#define ARCPGU_REG_FMT		0x10
+#define ARCPGU_REG_HSYNC	0x14
+#define ARCPGU_REG_VSYNC	0x18
+#define ARCPGU_REG_ACTIVE	0x1c
+#define ARCPGU_REG_BUF0_ADDR	0x40
+#define ARCPGU_REG_STRIDE	0x50
+#define ARCPGU_REG_START_SET	0x84
+
+#define ARCPGU_REG_ID		0x3FC
+
+#define ARCPGU_CTRL_ENABLE_MASK	0x02
+#define ARCPGU_CTRL_VS_POL_MASK	0x1
+#define ARCPGU_CTRL_VS_POL_OFST	0x3
+#define ARCPGU_CTRL_HS_POL_MASK	0x1
+#define ARCPGU_CTRL_HS_POL_OFST	0x4
+#define ARCPGU_MODE_XRGB8888	BIT(2)
+#define ARCPGU_STAT_BUSY_MASK	0x02
+
+struct arcpgu_drm_private {
+	struct drm_device	drm;
+	void __iomem		*regs;
+	struct clk		*clk;
+	struct drm_simple_display_pipe pipe;
+	struct drm_connector	sim_conn;
+};
+
+#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
+
+#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
+
+static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
+				 unsigned int reg, u32 value)
+{
+	iowrite32(value, arcpgu->regs + reg);
+}
+
+static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
+			       unsigned int reg)
+{
+	return ioread32(arcpgu->regs + reg);
+}
+
+#define XRES_DEF	640
+#define YRES_DEF	480
+
+#define XRES_MAX	8192
+#define YRES_MAX	8192
+
+static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
+{
+	int count;
+
+	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
+	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+	return count;
+}
+
+static const struct drm_connector_helper_funcs
+arcpgu_drm_connector_helper_funcs = {
+	.get_modes = arcpgu_drm_connector_get_modes,
+};
+
+static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
+	.reset = drm_atomic_helper_connector_reset,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = drm_connector_cleanup,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
+{
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
+	struct drm_encoder *encoder;
+	struct drm_connector *connector;
+	int ret;
+
+	encoder = &arcpgu->pipe.encoder;
+
+	connector = &arcpgu->sim_conn;
+	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
+
+	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
+			DRM_MODE_CONNECTOR_VIRTUAL);
+	if (ret < 0) {
+		dev_err(drm->dev, "failed to initialize drm connector\n");
+		return ret;
+	}
+
+	ret = drm_connector_attach_encoder(connector, encoder);
+	if (ret < 0) {
+		dev_err(drm->dev, "could not attach connector to encoder\n");
+		return ret;
+	}
+
+	return 0;
+}
 
 #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
 
diff --git a/drivers/gpu/drm/arc/arcpgu_regs.h b/drivers/gpu/drm/arc/arcpgu_regs.h
deleted file mode 100644
index b689a382d556..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_regs.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#ifndef _ARC_PGU_REGS_H_
-#define _ARC_PGU_REGS_H_
-
-#define ARCPGU_REG_CTRL		0x00
-#define ARCPGU_REG_STAT		0x04
-#define ARCPGU_REG_FMT		0x10
-#define ARCPGU_REG_HSYNC	0x14
-#define ARCPGU_REG_VSYNC	0x18
-#define ARCPGU_REG_ACTIVE	0x1c
-#define ARCPGU_REG_BUF0_ADDR	0x40
-#define ARCPGU_REG_STRIDE	0x50
-#define ARCPGU_REG_START_SET	0x84
-
-#define ARCPGU_REG_ID		0x3FC
-
-#define ARCPGU_CTRL_ENABLE_MASK	0x02
-#define ARCPGU_CTRL_VS_POL_MASK	0x1
-#define ARCPGU_CTRL_VS_POL_OFST	0x3
-#define ARCPGU_CTRL_HS_POL_MASK	0x1
-#define ARCPGU_CTRL_HS_POL_OFST	0x4
-#define ARCPGU_MODE_XRGB8888	BIT(2)
-#define ARCPGU_STAT_BUSY_MASK	0x02
-
-#endif
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
deleted file mode 100644
index 1a63f0868504..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ /dev/null
@@ -1,74 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_device.h>
-#include <drm/drm_probe_helper.h>
-
-#include "arcpgu.h"
-
-#define XRES_DEF	640
-#define YRES_DEF	480
-
-#define XRES_MAX	8192
-#define YRES_MAX	8192
-
-
-static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
-{
-	int count;
-
-	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
-	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
-	return count;
-}
-
-static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
-{
-	drm_connector_cleanup(connector);
-}
-
-static const struct drm_connector_helper_funcs
-arcpgu_drm_connector_helper_funcs = {
-	.get_modes = arcpgu_drm_connector_get_modes,
-};
-
-static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
-	.reset = drm_atomic_helper_connector_reset,
-	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = arcpgu_drm_connector_destroy,
-	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int ret;
-
-	encoder = &arcpgu->pipe.encoder;
-
-	connector = &arcpgu->sim_conn;
-	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
-
-	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
-			DRM_MODE_CONNECTOR_VIRTUAL);
-	if (ret < 0) {
-		dev_err(drm->dev, "failed to initialize drm connector\n");
-		return ret;
-	}
-
-	ret = drm_connector_attach_encoder(connector, encoder);
-	if (ret < 0) {
-		dev_err(drm->dev, "could not attach connector to encoder\n");
-		return ret;
-	}
-
-	return 0;
-}
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 51/59] drm/arc: Inline remaining files
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

At less than 500 lines total feels like the right thing to do.

Also noticed that the simple wrapper around drm_connector_cleanup can
be dropped.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/arc/Makefile      |   2 +-
 drivers/gpu/drm/arc/arcpgu.h      |  39 ------------
 drivers/gpu/drm/arc/arcpgu_drv.c  | 102 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/arc/arcpgu_regs.h |  31 ---------
 drivers/gpu/drm/arc/arcpgu_sim.c  |  74 ----------------------
 5 files changed, 101 insertions(+), 147 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
 delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c

diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
index 379a1145bc2f..b26f2495c532 100644
--- a/drivers/gpu/drm/arc/Makefile
+++ b/drivers/gpu/drm/arc/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_sim.o arcpgu_drv.o
+arcpgu-y := arcpgu_drv.o
 obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
deleted file mode 100644
index 7dce0c2313ba..000000000000
--- a/drivers/gpu/drm/arc/arcpgu.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#ifndef _ARCPGU_H_
-#define _ARCPGU_H_
-
-#include <drm/drm_simple_kms_helper.h>
-
-struct arcpgu_drm_private {
-	struct drm_device	drm;
-	void __iomem		*regs;
-	struct clk		*clk;
-	struct drm_simple_display_pipe pipe;
-	struct drm_connector	sim_conn;
-};
-
-#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
-
-#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
-
-static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
-				 unsigned int reg, u32 value)
-{
-	iowrite32(value, arcpgu->regs + reg);
-}
-
-static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
-			       unsigned int reg)
-{
-	return ioread32(arcpgu->regs + reg);
-}
-
-int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
-
-#endif
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 8fbfd956de0a..b0c941d91545 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -17,13 +17,111 @@
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_of.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 
-#include "arcpgu.h"
-#include "arcpgu_regs.h"
+#define ARCPGU_REG_CTRL		0x00
+#define ARCPGU_REG_STAT		0x04
+#define ARCPGU_REG_FMT		0x10
+#define ARCPGU_REG_HSYNC	0x14
+#define ARCPGU_REG_VSYNC	0x18
+#define ARCPGU_REG_ACTIVE	0x1c
+#define ARCPGU_REG_BUF0_ADDR	0x40
+#define ARCPGU_REG_STRIDE	0x50
+#define ARCPGU_REG_START_SET	0x84
+
+#define ARCPGU_REG_ID		0x3FC
+
+#define ARCPGU_CTRL_ENABLE_MASK	0x02
+#define ARCPGU_CTRL_VS_POL_MASK	0x1
+#define ARCPGU_CTRL_VS_POL_OFST	0x3
+#define ARCPGU_CTRL_HS_POL_MASK	0x1
+#define ARCPGU_CTRL_HS_POL_OFST	0x4
+#define ARCPGU_MODE_XRGB8888	BIT(2)
+#define ARCPGU_STAT_BUSY_MASK	0x02
+
+struct arcpgu_drm_private {
+	struct drm_device	drm;
+	void __iomem		*regs;
+	struct clk		*clk;
+	struct drm_simple_display_pipe pipe;
+	struct drm_connector	sim_conn;
+};
+
+#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
+
+#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
+
+static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
+				 unsigned int reg, u32 value)
+{
+	iowrite32(value, arcpgu->regs + reg);
+}
+
+static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
+			       unsigned int reg)
+{
+	return ioread32(arcpgu->regs + reg);
+}
+
+#define XRES_DEF	640
+#define YRES_DEF	480
+
+#define XRES_MAX	8192
+#define YRES_MAX	8192
+
+static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
+{
+	int count;
+
+	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
+	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+	return count;
+}
+
+static const struct drm_connector_helper_funcs
+arcpgu_drm_connector_helper_funcs = {
+	.get_modes = arcpgu_drm_connector_get_modes,
+};
+
+static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
+	.reset = drm_atomic_helper_connector_reset,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = drm_connector_cleanup,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
+{
+	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
+	struct drm_encoder *encoder;
+	struct drm_connector *connector;
+	int ret;
+
+	encoder = &arcpgu->pipe.encoder;
+
+	connector = &arcpgu->sim_conn;
+	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
+
+	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
+			DRM_MODE_CONNECTOR_VIRTUAL);
+	if (ret < 0) {
+		dev_err(drm->dev, "failed to initialize drm connector\n");
+		return ret;
+	}
+
+	ret = drm_connector_attach_encoder(connector, encoder);
+	if (ret < 0) {
+		dev_err(drm->dev, "could not attach connector to encoder\n");
+		return ret;
+	}
+
+	return 0;
+}
 
 #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
 
diff --git a/drivers/gpu/drm/arc/arcpgu_regs.h b/drivers/gpu/drm/arc/arcpgu_regs.h
deleted file mode 100644
index b689a382d556..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_regs.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#ifndef _ARC_PGU_REGS_H_
-#define _ARC_PGU_REGS_H_
-
-#define ARCPGU_REG_CTRL		0x00
-#define ARCPGU_REG_STAT		0x04
-#define ARCPGU_REG_FMT		0x10
-#define ARCPGU_REG_HSYNC	0x14
-#define ARCPGU_REG_VSYNC	0x18
-#define ARCPGU_REG_ACTIVE	0x1c
-#define ARCPGU_REG_BUF0_ADDR	0x40
-#define ARCPGU_REG_STRIDE	0x50
-#define ARCPGU_REG_START_SET	0x84
-
-#define ARCPGU_REG_ID		0x3FC
-
-#define ARCPGU_CTRL_ENABLE_MASK	0x02
-#define ARCPGU_CTRL_VS_POL_MASK	0x1
-#define ARCPGU_CTRL_VS_POL_OFST	0x3
-#define ARCPGU_CTRL_HS_POL_MASK	0x1
-#define ARCPGU_CTRL_HS_POL_OFST	0x4
-#define ARCPGU_MODE_XRGB8888	BIT(2)
-#define ARCPGU_STAT_BUSY_MASK	0x02
-
-#endif
diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
deleted file mode 100644
index 1a63f0868504..000000000000
--- a/drivers/gpu/drm/arc/arcpgu_sim.c
+++ /dev/null
@@ -1,74 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * ARC PGU DRM driver.
- *
- * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
- */
-
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_device.h>
-#include <drm/drm_probe_helper.h>
-
-#include "arcpgu.h"
-
-#define XRES_DEF	640
-#define YRES_DEF	480
-
-#define XRES_MAX	8192
-#define YRES_MAX	8192
-
-
-static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
-{
-	int count;
-
-	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
-	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
-	return count;
-}
-
-static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
-{
-	drm_connector_cleanup(connector);
-}
-
-static const struct drm_connector_helper_funcs
-arcpgu_drm_connector_helper_funcs = {
-	.get_modes = arcpgu_drm_connector_get_modes,
-};
-
-static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
-	.reset = drm_atomic_helper_connector_reset,
-	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = arcpgu_drm_connector_destroy,
-	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
-{
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int ret;
-
-	encoder = &arcpgu->pipe.encoder;
-
-	connector = &arcpgu->sim_conn;
-	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
-
-	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
-			DRM_MODE_CONNECTOR_VIRTUAL);
-	if (ret < 0) {
-		dev_err(drm->dev, "failed to initialize drm connector\n");
-		return ret;
-	}
-
-	ret = drm_connector_attach_encoder(connector, encoder);
-	if (ret < 0) {
-		dev_err(drm->dev, "could not attach connector to encoder\n");
-		return ret;
-	}
-
-	return 0;
-}
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 52/59] drm/arc: Initialize sim connector before display pipe
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

That way we can get rid of this final piece of init code, and use the
simple pipe helpers as intended.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++----------------------
 1 file changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index b0c941d91545..857812f25bec 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
+static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector)
 {
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int ret;
-
-	encoder = &arcpgu->pipe.encoder;
-
-	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
-
-	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
+	return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
 			DRM_MODE_CONNECTOR_VIRTUAL);
-	if (ret < 0) {
-		dev_err(drm->dev, "failed to initialize drm connector\n");
-		return ret;
-	}
-
-	ret = drm_connector_attach_encoder(connector, encoder);
-	if (ret < 0) {
-		dev_err(drm->dev, "could not attach connector to encoder\n");
-		return ret;
-	}
-
-	return 0;
 }
 
 #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
@@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 {
 	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
 	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
+	struct drm_connector *connector = NULL;
 	struct drm_device *drm = &arcpgu->drm;
 	struct resource *res;
 	int ret;
@@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
-					   arc_pgu_supported_formats,
-					   ARRAY_SIZE(arc_pgu_supported_formats),
-					   NULL, NULL);
-	if (ret)
-		return ret;
-
 	/*
 	 * There is only one output port inside each device. It is linked with
 	 * encoder endpoint.
@@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (endpoint_node) {
 		encoder_node = of_graph_get_remote_port_parent(endpoint_node);
 		of_node_put(endpoint_node);
+	} else {
+		connector = &arcpgu->sim_conn;
+		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
+		ret = arcpgu_drm_sim_init(drm, connector);
+		if (ret < 0)
+			return ret;
 	}
 
+	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					   arc_pgu_supported_formats,
+					   ARRAY_SIZE(arc_pgu_supported_formats),
+					   NULL, connector);
+	if (ret)
+		return ret;
+
 	if (encoder_node) {
 		struct drm_bridge *bridge;
 
@@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
 		if (ret)
 			return ret;
-	} else {
-		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
-		ret = arcpgu_drm_sim_init(drm, NULL);
-		if (ret < 0)
-			return ret;
 	}
 
 	drm_mode_config_reset(drm);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 52/59] drm/arc: Initialize sim connector before display pipe
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

That way we can get rid of this final piece of init code, and use the
simple pipe helpers as intended.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++----------------------
 1 file changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index b0c941d91545..857812f25bec 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
+static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector)
 {
-	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int ret;
-
-	encoder = &arcpgu->pipe.encoder;
-
-	connector = &arcpgu->sim_conn;
 	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
-
-	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
+	return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
 			DRM_MODE_CONNECTOR_VIRTUAL);
-	if (ret < 0) {
-		dev_err(drm->dev, "failed to initialize drm connector\n");
-		return ret;
-	}
-
-	ret = drm_connector_attach_encoder(connector, encoder);
-	if (ret < 0) {
-		dev_err(drm->dev, "could not attach connector to encoder\n");
-		return ret;
-	}
-
-	return 0;
 }
 
 #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
@@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 {
 	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
 	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
+	struct drm_connector *connector = NULL;
 	struct drm_device *drm = &arcpgu->drm;
 	struct resource *res;
 	int ret;
@@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
 		return -ENODEV;
 
-	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
-					   arc_pgu_supported_formats,
-					   ARRAY_SIZE(arc_pgu_supported_formats),
-					   NULL, NULL);
-	if (ret)
-		return ret;
-
 	/*
 	 * There is only one output port inside each device. It is linked with
 	 * encoder endpoint.
@@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	if (endpoint_node) {
 		encoder_node = of_graph_get_remote_port_parent(endpoint_node);
 		of_node_put(endpoint_node);
+	} else {
+		connector = &arcpgu->sim_conn;
+		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
+		ret = arcpgu_drm_sim_init(drm, connector);
+		if (ret < 0)
+			return ret;
 	}
 
+	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
+					   arc_pgu_supported_formats,
+					   ARRAY_SIZE(arc_pgu_supported_formats),
+					   NULL, connector);
+	if (ret)
+		return ret;
+
 	if (encoder_node) {
 		struct drm_bridge *bridge;
 
@@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
 		if (ret)
 			return ret;
-	} else {
-		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
-		ret = arcpgu_drm_sim_init(drm, NULL);
-		if (ret < 0)
-			return ret;
 	}
 
 	drm_mode_config_reset(drm);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Because it is.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 MAINTAINERS                                         |  2 +-
 drivers/gpu/drm/Kconfig                             |  2 --
 drivers/gpu/drm/Makefile                            |  1 -
 drivers/gpu/drm/arc/Kconfig                         | 10 ----------
 drivers/gpu/drm/arc/Makefile                        |  3 ---
 drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
 drivers/gpu/drm/tiny/Makefile                       |  1 +
 drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
 8 files changed, 12 insertions(+), 17 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/Kconfig
 delete mode 100644 drivers/gpu/drm/arc/Makefile
 rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a5cf105ee37..748244b1625b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
 M:	Alexey Brodkin <abrodkin@synopsys.com>
 S:	Supported
 F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
-F:	drivers/gpu/drm/arc/
+F:	drivers/gpu/drm/tiny/arcpgu.c
 
 ARCNET NETWORK LAYER
 M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 4f4e7fa001c1..a0a89025d6fa 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
 
 source "drivers/gpu/drm/etnaviv/Kconfig"
 
-source "drivers/gpu/drm/arc/Kconfig"
-
 source "drivers/gpu/drm/hisilicon/Kconfig"
 
 source "drivers/gpu/drm/mediatek/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 2c0e5a7e5953..e69eafbf9e39 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -109,7 +109,6 @@ obj-y			+= panel/
 obj-y			+= bridge/
 obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
 obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
-obj-$(CONFIG_DRM_ARCPGU)+= arc/
 obj-y			+= hisilicon/
 obj-$(CONFIG_DRM_ZTE)	+= zte/
 obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
deleted file mode 100644
index e8f3d63e0b91..000000000000
--- a/drivers/gpu/drm/arc/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config DRM_ARCPGU
-	tristate "ARC PGU"
-	depends on DRM && OF
-	select DRM_KMS_CMA_HELPER
-	select DRM_KMS_HELPER
-	help
-	  Choose this option if you have an ARC PGU controller.
-
-	  If M is selected the module will be called arcpgu.
diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
deleted file mode 100644
index b26f2495c532..000000000000
--- a/drivers/gpu/drm/arc/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_drv.o
-obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
index 2b6414f0fa75..9bbaa1a69050 100644
--- a/drivers/gpu/drm/tiny/Kconfig
+++ b/drivers/gpu/drm/tiny/Kconfig
@@ -1,5 +1,15 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config DRM_ARCPGU
+	tristate "ARC PGU"
+	depends on DRM && OF
+	select DRM_KMS_CMA_HELPER
+	select DRM_KMS_HELPER
+	help
+	  Choose this option if you have an ARC PGU controller.
+
+	  If M is selected the module will be called arcpgu.
+
 config DRM_CIRRUS_QEMU
 	tristate "Cirrus driver for QEMU emulated device"
 	depends on DRM && PCI && MMU
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
index 6ae4e9e5a35f..bef6780bdd6f 100644
--- a/drivers/gpu/drm/tiny/Makefile
+++ b/drivers/gpu/drm/tiny/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
 obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
 obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
similarity index 100%
rename from drivers/gpu/drm/arc/arcpgu_drv.c
rename to drivers/gpu/drm/tiny/arcpgu.c
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development, Daniel Vetter

Because it is.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
---
 MAINTAINERS                                         |  2 +-
 drivers/gpu/drm/Kconfig                             |  2 --
 drivers/gpu/drm/Makefile                            |  1 -
 drivers/gpu/drm/arc/Kconfig                         | 10 ----------
 drivers/gpu/drm/arc/Makefile                        |  3 ---
 drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
 drivers/gpu/drm/tiny/Makefile                       |  1 +
 drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
 8 files changed, 12 insertions(+), 17 deletions(-)
 delete mode 100644 drivers/gpu/drm/arc/Kconfig
 delete mode 100644 drivers/gpu/drm/arc/Makefile
 rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a5cf105ee37..748244b1625b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
 M:	Alexey Brodkin <abrodkin@synopsys.com>
 S:	Supported
 F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
-F:	drivers/gpu/drm/arc/
+F:	drivers/gpu/drm/tiny/arcpgu.c
 
 ARCNET NETWORK LAYER
 M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 4f4e7fa001c1..a0a89025d6fa 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
 
 source "drivers/gpu/drm/etnaviv/Kconfig"
 
-source "drivers/gpu/drm/arc/Kconfig"
-
 source "drivers/gpu/drm/hisilicon/Kconfig"
 
 source "drivers/gpu/drm/mediatek/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 2c0e5a7e5953..e69eafbf9e39 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -109,7 +109,6 @@ obj-y			+= panel/
 obj-y			+= bridge/
 obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
 obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
-obj-$(CONFIG_DRM_ARCPGU)+= arc/
 obj-y			+= hisilicon/
 obj-$(CONFIG_DRM_ZTE)	+= zte/
 obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
deleted file mode 100644
index e8f3d63e0b91..000000000000
--- a/drivers/gpu/drm/arc/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config DRM_ARCPGU
-	tristate "ARC PGU"
-	depends on DRM && OF
-	select DRM_KMS_CMA_HELPER
-	select DRM_KMS_HELPER
-	help
-	  Choose this option if you have an ARC PGU controller.
-
-	  If M is selected the module will be called arcpgu.
diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
deleted file mode 100644
index b26f2495c532..000000000000
--- a/drivers/gpu/drm/arc/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-arcpgu-y := arcpgu_drv.o
-obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
index 2b6414f0fa75..9bbaa1a69050 100644
--- a/drivers/gpu/drm/tiny/Kconfig
+++ b/drivers/gpu/drm/tiny/Kconfig
@@ -1,5 +1,15 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config DRM_ARCPGU
+	tristate "ARC PGU"
+	depends on DRM && OF
+	select DRM_KMS_CMA_HELPER
+	select DRM_KMS_HELPER
+	help
+	  Choose this option if you have an ARC PGU controller.
+
+	  If M is selected the module will be called arcpgu.
+
 config DRM_CIRRUS_QEMU
 	tristate "Cirrus driver for QEMU emulated device"
 	depends on DRM && PCI && MMU
diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
index 6ae4e9e5a35f..bef6780bdd6f 100644
--- a/drivers/gpu/drm/tiny/Makefile
+++ b/drivers/gpu/drm/tiny/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
 obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
 obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
 obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
similarity index 100%
rename from drivers/gpu/drm/arc/arcpgu_drv.c
rename to drivers/gpu/drm/tiny/arcpgu.c
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

No longer used since the conversion to generic fbdev.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index a10358bb61ec..adc02940de6f 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -12,7 +12,6 @@ struct aspeed_gfx {
 
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
-	struct drm_fbdev_cma		*fbdev;
 };
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

No longer used since the conversion to generic fbdev.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index a10358bb61ec..adc02940de6f 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -12,7 +12,6 @@ struct aspeed_gfx {
 
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
-	struct drm_fbdev_cma		*fbdev;
 };
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

No longer used since the conversion to generic fbdev.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index a10358bb61ec..adc02940de6f 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -12,7 +12,6 @@ struct aspeed_gfx {
 
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
-	struct drm_fbdev_cma		*fbdev;
 };
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

As usual, we can drop the drm_dev_put() and need to embed the
drm_device. Since it's so few, also go right ahead and leave
drm_device->dev_private set to NULL, so that we always use the
container_of() upcast, which is faster anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index adc02940de6f..e7ca95827ae8 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -5,6 +5,7 @@
 #include <drm/drm_simple_kms_helper.h>
 
 struct aspeed_gfx {
+	struct drm_device		drm;
 	void __iomem			*base;
 	struct clk			*clk;
 	struct reset_control		*rst;
@@ -13,6 +14,7 @@ struct aspeed_gfx {
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 };
+#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
 int aspeed_gfx_create_output(struct drm_device *drm);
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
index 2184b8be6fd4..e54686c31a90 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
@@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
 
 int aspeed_gfx_create_pipe(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 
 	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
 					    aspeed_gfx_formats,
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index ada2f6aca906..6b27242b9ee3 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 {
 	struct drm_device *drm = data;
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	u32 reg;
 
 	reg = readl(priv->base + CRT_CTRL1);
@@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 static int aspeed_gfx_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
-	struct aspeed_gfx *priv;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	struct resource *res;
 	int ret;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-	drm->dev_private = priv;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->base = devm_ioremap_resource(drm->dev, res);
 	if (IS_ERR(priv->base))
@@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
-
-	drm->dev_private = NULL;
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
@@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
 
 static int aspeed_gfx_probe(struct platform_device *pdev)
 {
-	struct drm_device *drm;
+	struct aspeed_gfx *priv;
 	int ret;
 
-	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
+				  struct aspeed_gfx, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
-	ret = aspeed_gfx_load(drm);
+	ret = aspeed_gfx_load(&priv->drm);
 	if (ret)
-		goto err_free;
+		return ret;
 
-	ret = drm_dev_register(drm, 0);
+	ret = drm_dev_register(&priv->drm, 0);
 	if (ret)
 		goto err_unload;
 
 	return 0;
 
 err_unload:
-	aspeed_gfx_unload(drm);
-err_free:
-	drm_dev_put(drm);
+	aspeed_gfx_unload(&priv->drm);
 
 	return ret;
 }
@@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(drm);
 	aspeed_gfx_unload(drm);
-	drm_dev_put(drm);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
index 67ee5fa10055..6759cb88415a 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
@@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
 
 int aspeed_gfx_create_output(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	int ret;
 
 	priv->connector.dpms = DRM_MODE_DPMS_OFF;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

As usual, we can drop the drm_dev_put() and need to embed the
drm_device. Since it's so few, also go right ahead and leave
drm_device->dev_private set to NULL, so that we always use the
container_of() upcast, which is faster anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index adc02940de6f..e7ca95827ae8 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -5,6 +5,7 @@
 #include <drm/drm_simple_kms_helper.h>
 
 struct aspeed_gfx {
+	struct drm_device		drm;
 	void __iomem			*base;
 	struct clk			*clk;
 	struct reset_control		*rst;
@@ -13,6 +14,7 @@ struct aspeed_gfx {
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 };
+#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
 int aspeed_gfx_create_output(struct drm_device *drm);
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
index 2184b8be6fd4..e54686c31a90 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
@@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
 
 int aspeed_gfx_create_pipe(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 
 	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
 					    aspeed_gfx_formats,
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index ada2f6aca906..6b27242b9ee3 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 {
 	struct drm_device *drm = data;
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	u32 reg;
 
 	reg = readl(priv->base + CRT_CTRL1);
@@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 static int aspeed_gfx_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
-	struct aspeed_gfx *priv;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	struct resource *res;
 	int ret;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-	drm->dev_private = priv;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->base = devm_ioremap_resource(drm->dev, res);
 	if (IS_ERR(priv->base))
@@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
-
-	drm->dev_private = NULL;
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
@@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
 
 static int aspeed_gfx_probe(struct platform_device *pdev)
 {
-	struct drm_device *drm;
+	struct aspeed_gfx *priv;
 	int ret;
 
-	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
+				  struct aspeed_gfx, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
-	ret = aspeed_gfx_load(drm);
+	ret = aspeed_gfx_load(&priv->drm);
 	if (ret)
-		goto err_free;
+		return ret;
 
-	ret = drm_dev_register(drm, 0);
+	ret = drm_dev_register(&priv->drm, 0);
 	if (ret)
 		goto err_unload;
 
 	return 0;
 
 err_unload:
-	aspeed_gfx_unload(drm);
-err_free:
-	drm_dev_put(drm);
+	aspeed_gfx_unload(&priv->drm);
 
 	return ret;
 }
@@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(drm);
 	aspeed_gfx_unload(drm);
-	drm_dev_put(drm);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
index 67ee5fa10055..6759cb88415a 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
@@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
 
 int aspeed_gfx_create_output(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	int ret;
 
 	priv->connector.dpms = DRM_MODE_DPMS_OFF;
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

As usual, we can drop the drm_dev_put() and need to embed the
drm_device. Since it's so few, also go right ahead and leave
drm_device->dev_private set to NULL, so that we always use the
container_of() upcast, which is faster anyway.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
index adc02940de6f..e7ca95827ae8 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
@@ -5,6 +5,7 @@
 #include <drm/drm_simple_kms_helper.h>
 
 struct aspeed_gfx {
+	struct drm_device		drm;
 	void __iomem			*base;
 	struct clk			*clk;
 	struct reset_control		*rst;
@@ -13,6 +14,7 @@ struct aspeed_gfx {
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 };
+#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
 int aspeed_gfx_create_output(struct drm_device *drm);
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
index 2184b8be6fd4..e54686c31a90 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
@@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
 
 int aspeed_gfx_create_pipe(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 
 	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
 					    aspeed_gfx_formats,
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index ada2f6aca906..6b27242b9ee3 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 {
 	struct drm_device *drm = data;
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	u32 reg;
 
 	reg = readl(priv->base + CRT_CTRL1);
@@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
 static int aspeed_gfx_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
-	struct aspeed_gfx *priv;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	struct resource *res;
 	int ret;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-	drm->dev_private = priv;
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->base = devm_ioremap_resource(drm->dev, res);
 	if (IS_ERR(priv->base))
@@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
 	drm_mode_config_cleanup(drm);
-
-	drm->dev_private = NULL;
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
@@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
 
 static int aspeed_gfx_probe(struct platform_device *pdev)
 {
-	struct drm_device *drm;
+	struct aspeed_gfx *priv;
 	int ret;
 
-	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
-	if (IS_ERR(drm))
-		return PTR_ERR(drm);
+	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
+				  struct aspeed_gfx, drm);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
 
-	ret = aspeed_gfx_load(drm);
+	ret = aspeed_gfx_load(&priv->drm);
 	if (ret)
-		goto err_free;
+		return ret;
 
-	ret = drm_dev_register(drm, 0);
+	ret = drm_dev_register(&priv->drm, 0);
 	if (ret)
 		goto err_unload;
 
 	return 0;
 
 err_unload:
-	aspeed_gfx_unload(drm);
-err_free:
-	drm_dev_put(drm);
+	aspeed_gfx_unload(&priv->drm);
 
 	return ret;
 }
@@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(drm);
 	aspeed_gfx_unload(drm);
-	drm_dev_put(drm);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
index 67ee5fa10055..6759cb88415a 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
@@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
 
 int aspeed_gfx_create_output(struct drm_device *drm)
 {
-	struct aspeed_gfx *priv = drm->dev_private;
+	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	int ret;
 
 	priv->connector.dpms = DRM_MODE_DPMS_OFF;
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

Since aspeed doesn't use devm_kzalloc anymore we can use the managed
mode config cleanup.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index 6b27242b9ee3..6e464b84a256 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
 	.atomic_commit		= drm_atomic_helper_commit,
 };
 
-static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
+static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
 {
-	drm_mode_config_init(drm);
-
 	drm->mode_config.min_width = 0;
 	drm->mode_config.min_height = 0;
 	drm->mode_config.max_width = 800;
 	drm->mode_config.max_height = 600;
 	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
+
+	return drmm_mode_config_init(drm);
 }
 
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
@@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	writel(0, priv->base + CRT_CTRL1);
 	writel(0, priv->base + CRT_CTRL2);
 
-	aspeed_gfx_setup_mode_config(drm);
+	ret = aspeed_gfx_setup_mode_config(drm);
+	if (ret < 0)
+		return ret;
 
 	ret = drm_vblank_init(drm, 1);
 	if (ret < 0) {
@@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
 static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
-	drm_mode_config_cleanup(drm);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

Since aspeed doesn't use devm_kzalloc anymore we can use the managed
mode config cleanup.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index 6b27242b9ee3..6e464b84a256 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
 	.atomic_commit		= drm_atomic_helper_commit,
 };
 
-static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
+static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
 {
-	drm_mode_config_init(drm);
-
 	drm->mode_config.min_width = 0;
 	drm->mode_config.min_height = 0;
 	drm->mode_config.max_width = 800;
 	drm->mode_config.max_height = 600;
 	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
+
+	return drmm_mode_config_init(drm);
 }
 
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
@@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	writel(0, priv->base + CRT_CTRL1);
 	writel(0, priv->base + CRT_CTRL2);
 
-	aspeed_gfx_setup_mode_config(drm);
+	ret = aspeed_gfx_setup_mode_config(drm);
+	if (ret < 0)
+		return ret;
 
 	ret = drm_vblank_init(drm, 1);
 	if (ret < 0) {
@@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
 static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
-	drm_mode_config_cleanup(drm);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter, DRI Development,
	Joel Stanley, Daniel Vetter, linux-arm-kernel

Since aspeed doesn't use devm_kzalloc anymore we can use the managed
mode config cleanup.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-aspeed@lists.ozlabs.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index 6b27242b9ee3..6e464b84a256 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
 	.atomic_commit		= drm_atomic_helper_commit,
 };
 
-static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
+static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
 {
-	drm_mode_config_init(drm);
-
 	drm->mode_config.min_width = 0;
 	drm->mode_config.min_height = 0;
 	drm->mode_config.max_width = 800;
 	drm->mode_config.max_height = 600;
 	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
+
+	return drmm_mode_config_init(drm);
 }
 
 static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
@@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	writel(0, priv->base + CRT_CTRL1);
 	writel(0, priv->base + CRT_CTRL2);
 
-	aspeed_gfx_setup_mode_config(drm);
+	ret = aspeed_gfx_setup_mode_config(drm);
+	if (ret < 0)
+		return ret;
 
 	ret = drm_vblank_init(drm, 1);
 	if (ret < 0) {
@@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
 static void aspeed_gfx_unload(struct drm_device *drm)
 {
 	drm_kms_helper_poll_fini(drm);
-	drm_mode_config_cleanup(drm);
 }
 
 DEFINE_DRM_GEM_CMA_FOPS(fops);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Gerd Hoffmann, Thomas Zimmermann,
	Daniel Vetter, Dave Airlie, Sam Ravnborg, Christian König,
	Emil Velikov

Allows us to remove a bit of cleanup code.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
 drivers/gpu/drm/ast/ast_main.c |  3 ---
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index b7ba22dddcad..48a9cc4e080a 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	ast_kick_out_firmware_fb(pdev);
 
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
 
 	dev = drm_dev_alloc(&driver, &pdev->dev);
-	if (IS_ERR(dev)) {
-		ret = PTR_ERR(dev);
-		goto err_pci_disable_device;
-	}
+	if (IS_ERR(dev))
+		return  PTR_ERR(dev);
 
 	dev->pdev = pdev;
 	pci_set_drvdata(pdev, dev);
@@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	ast_driver_unload(dev);
 err_drm_dev_put:
 	drm_dev_put(dev);
-err_pci_disable_device:
-	pci_disable_device(pdev);
 	return ret;
 
 }
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index e5398e3dabe7..1b35728ad871 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
 	drm_mode_config_cleanup(dev);
 
 	ast_mm_fini(ast);
-	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
-		pci_iounmap(dev->pdev, ast->ioregs);
-	pci_iounmap(dev->pdev, ast->regs);
 	kfree(ast);
 }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Y.C. Chen, Daniel Vetter, DRI Development, Noralf Trønnes,
	Gerd Hoffmann, Thomas Zimmermann, Daniel Vetter, Dave Airlie,
	Sam Ravnborg, Christian König, Emil Velikov

Allows us to remove a bit of cleanup code.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
 drivers/gpu/drm/ast/ast_main.c |  3 ---
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index b7ba22dddcad..48a9cc4e080a 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	ast_kick_out_firmware_fb(pdev);
 
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
 
 	dev = drm_dev_alloc(&driver, &pdev->dev);
-	if (IS_ERR(dev)) {
-		ret = PTR_ERR(dev);
-		goto err_pci_disable_device;
-	}
+	if (IS_ERR(dev))
+		return  PTR_ERR(dev);
 
 	dev->pdev = pdev;
 	pci_set_drvdata(pdev, dev);
@@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	ast_driver_unload(dev);
 err_drm_dev_put:
 	drm_dev_put(dev);
-err_pci_disable_device:
-	pci_disable_device(pdev);
 	return ret;
 
 }
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index e5398e3dabe7..1b35728ad871 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
 	drm_mode_config_cleanup(dev);
 
 	ast_mm_fini(ast);
-	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
-		pci_iounmap(dev->pdev, ast->ioregs);
-	pci_iounmap(dev->pdev, ast->regs);
 	kfree(ast);
 }
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Gerd Hoffmann, Thomas Zimmermann,
	Daniel Vetter, Dave Airlie, Sam Ravnborg, Emil Velikov

This is only needed for hotpluggable connectors set up after
drm_dev_register().

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index cdd6c46d6557..84b1d1fea41f 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
 {
 	struct ast_connector *ast_connector = to_ast_connector(connector);
 	ast_i2c_destroy(ast_connector->i2c);
-	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
 }
@@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
 	connector->interlace_allowed = 0;
 	connector->doublescan_allowed = 0;
 
-	drm_connector_register(connector);
-
 	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
 
 	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, DRI Development, Gerd Hoffmann, Thomas Zimmermann,
	Daniel Vetter, Dave Airlie, Sam Ravnborg, Emil Velikov

This is only needed for hotpluggable connectors set up after
drm_dev_register().

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index cdd6c46d6557..84b1d1fea41f 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
 {
 	struct ast_connector *ast_connector = to_ast_connector(connector);
 	ast_i2c_destroy(ast_connector->i2c);
-	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(connector);
 }
@@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
 	connector->interlace_allowed = 0;
 	connector->doublescan_allowed = 0;
 
-	drm_connector_register(connector);
-
 	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
 
 	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
  (?)
@ 2020-04-15  7:40   ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, virtualization, DRI Development, Daniel Vetter

This is leftovers from the old drm_driver->load callback
upside-down issues. It doesn't do anything for not-hotplugged
connectors since drm_dev_register takes care of that.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 7f4bcfad87e9..05d8373888e8 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
 			   DRM_MODE_CONNECTOR_VIRTUAL);
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
-	drm_connector_register(connector);
 
 	bochs_hw_load_edid(bochs);
 	if (bochs->edid) {
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, virtualization, Gerd Hoffmann, DRI Development,
	Daniel Vetter

This is leftovers from the old drm_driver->load callback
upside-down issues. It doesn't do anything for not-hotplugged
connectors since drm_dev_register takes care of that.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 7f4bcfad87e9..05d8373888e8 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
 			   DRM_MODE_CONNECTOR_VIRTUAL);
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
-	drm_connector_register(connector);
 
 	bochs_hw_load_edid(bochs);
 	if (bochs->edid) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-15  7:40   ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  7:40 UTC (permalink / raw)
  To: Intel Graphics Development
  Cc: Daniel Vetter, virtualization, Gerd Hoffmann, DRI Development,
	Daniel Vetter

This is leftovers from the old drm_driver->load callback
upside-down issues. It doesn't do anything for not-hotplugged
connectors since drm_dev_register takes care of that.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: virtualization@lists.linux-foundation.org
---
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 7f4bcfad87e9..05d8373888e8 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
 			   DRM_MODE_CONNECTOR_VIRTUAL);
 	drm_connector_helper_add(connector,
 				 &bochs_connector_connector_helper_funcs);
-	drm_connector_register(connector);
 
 	bochs_hw_load_edid(bochs);
 	if (bochs->edid) {
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:52     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:52 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Christian König, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 2572 bytes --]

Hi Daniel

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Allows us to remove a bit of cleanup code.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: "Noralf Trønnes" <noralf@tronnes.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> ---
>  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
>  drivers/gpu/drm/ast/ast_main.c |  3 ---
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index b7ba22dddcad..48a9cc4e080a 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	ast_kick_out_firmware_fb(pdev);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	dev = drm_dev_alloc(&driver, &pdev->dev);
> -	if (IS_ERR(dev)) {
> -		ret = PTR_ERR(dev);
> -		goto err_pci_disable_device;
> -	}
> +	if (IS_ERR(dev))
> +		return  PTR_ERR(dev);
>  
>  	dev->pdev = pdev;
>  	pci_set_drvdata(pdev, dev);
> @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	ast_driver_unload(dev);
>  err_drm_dev_put:
>  	drm_dev_put(dev);
> -err_pci_disable_device:
> -	pci_disable_device(pdev);
>  	return ret;
>  
>  }
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index e5398e3dabe7..1b35728ad871 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
>  	drm_mode_config_cleanup(dev);
>  
>  	ast_mm_fini(ast);
> -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> -		pci_iounmap(dev->pdev, ast->ioregs);
> -	pci_iounmap(dev->pdev, ast->regs);

This gets unmapped as part of the automatic pci_disable_device(), I guess?

Do we need drm_dev_enter()/_exit() to make I/O work reliably?

Best regards
Thomas

>  	kfree(ast);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-04-15  7:52     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:52 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Christian König, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 2572 bytes --]

Hi Daniel

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Allows us to remove a bit of cleanup code.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: "Noralf Trønnes" <noralf@tronnes.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> ---
>  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
>  drivers/gpu/drm/ast/ast_main.c |  3 ---
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index b7ba22dddcad..48a9cc4e080a 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	ast_kick_out_firmware_fb(pdev);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	dev = drm_dev_alloc(&driver, &pdev->dev);
> -	if (IS_ERR(dev)) {
> -		ret = PTR_ERR(dev);
> -		goto err_pci_disable_device;
> -	}
> +	if (IS_ERR(dev))
> +		return  PTR_ERR(dev);
>  
>  	dev->pdev = pdev;
>  	pci_set_drvdata(pdev, dev);
> @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	ast_driver_unload(dev);
>  err_drm_dev_put:
>  	drm_dev_put(dev);
> -err_pci_disable_device:
> -	pci_disable_device(pdev);
>  	return ret;
>  
>  }
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index e5398e3dabe7..1b35728ad871 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
>  	drm_mode_config_cleanup(dev);
>  
>  	ast_mm_fini(ast);
> -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> -		pci_iounmap(dev->pdev, ast->ioregs);
> -	pci_iounmap(dev->pdev, ast->regs);

This gets unmapped as part of the automatic pci_disable_device(), I guess?

Do we need drm_dev_enter()/_exit() to make I/O work reliably?

Best regards
Thomas

>  	kfree(ast);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:53     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:53 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 1693 bytes --]



Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> This is only needed for hotpluggable connectors set up after
> drm_dev_register().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Emil Velikov <emil.velikov@collabora.com>

Reviewed-by: Thomas Zimemrmann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/ast/ast_mode.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index cdd6c46d6557..84b1d1fea41f 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
>  {
>  	struct ast_connector *ast_connector = to_ast_connector(connector);
>  	ast_i2c_destroy(ast_connector->i2c);
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  	kfree(connector);
>  }
> @@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
>  	connector->interlace_allowed = 0;
>  	connector->doublescan_allowed = 0;
>  
> -	drm_connector_register(connector);
> -
>  	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
>  
>  	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
@ 2020-04-15  7:53     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:53 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 1693 bytes --]



Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> This is only needed for hotpluggable connectors set up after
> drm_dev_register().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Emil Velikov <emil.velikov@collabora.com>

Reviewed-by: Thomas Zimemrmann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/ast/ast_mode.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index cdd6c46d6557..84b1d1fea41f 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
>  {
>  	struct ast_connector *ast_connector = to_ast_connector(connector);
>  	ast_i2c_destroy(ast_connector->i2c);
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  	kfree(connector);
>  }
> @@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
>  	connector->interlace_allowed = 0;
>  	connector->doublescan_allowed = 0;
>  
> -	drm_connector_register(connector);
> -
>  	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
>  
>  	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  7:55     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:55 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Sam Ravnborg, Emil Velikov, DRI Development, Dave Airlie,
	Daniel Vetter, Thomas Gleixner, Sean Paul


[-- Attachment #1.1.1: Type: text/plain, Size: 2779 bytes --]



Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Also init the fbdev emulation before we register the device, that way
> we can rely on the auto-cleanup and simplify the probe error code even
> more.
> 
> v2: Rebase on top of Thomas' patches to remove the return value from
> drm_fbdev_generic_setup()
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 9cc6d075cb40..523f60e02a85 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
>  	struct udl_device *udl;
>  	int r;
>  
> -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> -	if (!udl)
> -		return ERR_PTR(-ENOMEM);
> -
> -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> -	if (r) {
> -		kfree(udl);
> -		return ERR_PTR(r);
> -	}
> +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> +				 struct udl_device, drm);
> +	if (IS_ERR(udl))
> +		return udl;
>  
>  	udl->udev = udev;
>  	udl->drm.dev_private = udl;
> -	drmm_add_final_kfree(&udl->drm, udl);
>  
>  	r = udl_init(udl);
> -	if (r) {
> -		drm_dev_put(&udl->drm);
> +	if (r)
>  		return ERR_PTR(r);
> -	}
>  
>  	usb_set_intfdata(interface, udl);
> +
>  	return udl;
>  }
>  
> @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
>  
>  	r = drm_dev_register(&udl->drm, 0);
>  	if (r)
> -		goto err_free;
> +		return r;
>  
>  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
>  
>  	drm_fbdev_generic_setup(&udl->drm, 0);
>  
>  	return 0;
> -
> -err_free:
> -	drm_dev_put(&udl->drm);
> -	return r;
>  }
>  
>  static void udl_usb_disconnect(struct usb_interface *interface)
> @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
>  	drm_kms_helper_poll_fini(dev);
>  	udl_drop_usb(dev);
>  	drm_dev_unplug(dev);
> -	drm_dev_put(dev);
>  }
>  
>  /*
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
@ 2020-04-15  7:55     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  7:55 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Sam Ravnborg, DRI Development, Noralf Trønnes, Dave Airlie,
	Daniel Vetter, Thomas Gleixner


[-- Attachment #1.1.1: Type: text/plain, Size: 2779 bytes --]



Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Also init the fbdev emulation before we register the device, that way
> we can rely on the auto-cleanup and simplify the probe error code even
> more.
> 
> v2: Rebase on top of Thomas' patches to remove the return value from
> drm_fbdev_generic_setup()
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 9cc6d075cb40..523f60e02a85 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
>  	struct udl_device *udl;
>  	int r;
>  
> -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> -	if (!udl)
> -		return ERR_PTR(-ENOMEM);
> -
> -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> -	if (r) {
> -		kfree(udl);
> -		return ERR_PTR(r);
> -	}
> +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> +				 struct udl_device, drm);
> +	if (IS_ERR(udl))
> +		return udl;
>  
>  	udl->udev = udev;
>  	udl->drm.dev_private = udl;
> -	drmm_add_final_kfree(&udl->drm, udl);
>  
>  	r = udl_init(udl);
> -	if (r) {
> -		drm_dev_put(&udl->drm);
> +	if (r)
>  		return ERR_PTR(r);
> -	}
>  
>  	usb_set_intfdata(interface, udl);
> +
>  	return udl;
>  }
>  
> @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
>  
>  	r = drm_dev_register(&udl->drm, 0);
>  	if (r)
> -		goto err_free;
> +		return r;
>  
>  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
>  
>  	drm_fbdev_generic_setup(&udl->drm, 0);
>  
>  	return 0;
> -
> -err_free:
> -	drm_dev_put(&udl->drm);
> -	return r;
>  }
>  
>  static void udl_usb_disconnect(struct usb_interface *interface)
> @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
>  	drm_kms_helper_poll_fini(dev);
>  	udl_drop_usb(dev);
>  	drm_dev_unplug(dev);
> -	drm_dev_put(dev);
>  }
>  
>  /*
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-15  8:01     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:01 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Dave Airlie, Gerd Hoffmann, DRI Development,
	virtualization


[-- Attachment #1.1.1: Type: text/plain, Size: 6152 bytes --]



Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!

Every other week, I felt an urge to send out this patch. Thank you so
much, Daniel! There are more candidates for tiny/. They are all <20k
LOCs and all we'd have to do is to move their code into a single file.
bochs or arc come into my mind.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:01     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:01 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Dave Airlie, Gerd Hoffmann, DRI Development,
	virtualization


[-- Attachment #1.1.1: Type: text/plain, Size: 6152 bytes --]



Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!

Every other week, I felt an urge to send out this patch. Thank you so
much, Daniel! There are more candidates for tiny/. They are all <20k
LOCs and all we'd have to do is to move their code into a single file.
bochs or arc come into my mind.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:01     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:01 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Dave Airlie, Gerd Hoffmann, DRI Development,
	virtualization


[-- Attachment #1.1.1: Type: text/plain, Size: 6152 bytes --]



Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!

Every other week, I felt an urge to send out this patch. Thank you so
much, Daniel! There are more candidates for tiny/. They are all <20k
LOCs and all we'd have to do is to move their code into a single file.
bochs or arc come into my mind.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for devm_drm_dev_alloc, v2
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (59 preceding siblings ...)
  (?)
@ 2020-04-15  8:04 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-04-15  8:04 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2
URL   : https://patchwork.freedesktop.org/series/75956/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
fd3a020f5d57 drm: Add devm_drm_dev_alloc macro
-:106: CHECK:SPACING: No space is necessary after a cast
#106: FILE: include/drm/drm_drv.h:656:
+	((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \

-:111: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 1 checks, 68 lines checked
af384be87720 drm/vboxvideo: drop DRM_MTRR_WC #define
-:41: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 25 lines checked
ce363797615d drm/vboxvideo: Use devm_drm_dev_alloc
-:62: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 45 lines checked
e45a792091aa drm/vboxvideo: Stop using drm_device->dev_private
-:99: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 62 lines checked
6d12b395c7e7 drm/vboxvidoe: use managed pci functions
-:84: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 52 lines checked
69867766512b drm/vboxvideo: Use devm_gen_pool_create
-:76: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 57 lines checked
7b30b404310a drm/v3d: Don't set drm_device->dev_private
-:37: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 15 lines checked
d756210a5cc5 drm/v3d: Use devm_drm_dev_alloc
-:104: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 84 lines checked
dfc0b2d39bc5 drm/v3d: Delete v3d_dev->dev
-:348: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 271 lines checked
a6e0a1a5655e drm/v3d: Delete v3d_dev->pdev
-:99: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 56 lines checked
45112a7418df drm/udl: Use devm_drm_dev_alloc
-:91: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 58 lines checked
a365a06b3054 drm/udl: don't set drm_device->dev_private
-:93: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 47 lines checked
02f85c25a833 drm/st7735r: Use devm_drm_dev_alloc
-:45: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 25 lines checked
3e61c483b099 drm/st7586: Use devm_drm_dev_alloc
-:39: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
d213eca2bf88 drm/repaper: Use devm_drm_dev_alloc
-:43: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 23 lines checked
1f6a7e1e8955 drm/mi0283qt: Use devm_drm_dev_alloc
-:42: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
e3ca7bc5481b drm/ili9486: Use devm_drm_dev_alloc
-:42: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
af4d8bdcb3a4 drm/ili9341: Use devm_drm_dev_alloc
-:46: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
3c13fd8a4e69 drm/ili9225: Use devm_drm_dev_alloc
-:39: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
e20dddecfd5b drm/hx8357d: Use devm_drm_dev_alloc
-:38: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 21 lines checked
bfc68a9fc2e2 drm/gm12u320: Use devm_drm_dev_alloc
-:42: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 26 lines checked
63ff767c2c59 drm/gm12u320: Don't use drm_device->dev_private
-:69: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 47 lines checked
33f567e43a49 drm/tidss: Use devm_drm_dev_alloc
-:42: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 24 lines checked
9bf56784ead7 drm/tidss: Don't use drm_device->dev_private
-:218: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 160 lines checked
1014cec142a5 drm/tidss: Delete tidss->saved_state
-:26: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 8 lines checked
b2fbca315892 drm/qxl: Use devm_drm_dev_alloc
-:123: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 89 lines checked
0411f1a69999 drm/qxl: Don't use drm_device->dev_private
-:414: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 312 lines checked
35f8852356ee drm/mcde: Use devm_drm_dev_alloc
-:41: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 23 lines checked
bdb467714cbb drm/mcde: Don't use drm_device->dev_private
-:126: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 85 lines checked
31bf3d7b111c drm/ingenic: Use devm_drm_dev_alloc
-:43: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 26 lines checked
8e70e1e615f0 drm/ingenic: Don't set drm_device->dev_private
-:23: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 7 lines checked
02237e74a9a8 drm/komeda: use devm_drm_dev_alloc
-:73: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 37 lines checked
83f5dd60daf3 drm/armada: Use devm_drm_dev_alloc
-:68: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 45 lines checked
5355459380ce drm/armada: Don't use drm_device->dev_private
-:165: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 112 lines checked
8ed39ba52c56 drm/cirrus: Use devm_drm_dev_alloc
-:50: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 22 lines checked
802aadc99e55 drm/cirrus: Don't use drm_device->dev_private
-:71: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 39 lines checked
2b17747b4b28 drm/cirrus: Move to drm/tiny
-:53: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#53: 
deleted file mode 100644

-:125: WARNING:OBSOLETE: drivers/gpu/drm/tiny/cirrus.c is marked as 'obsolete' in the MAINTAINERS hierarchy.  No unnecessary modifications please.

-:128: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 3 warnings, 0 checks, 53 lines checked
7d245271e60f drm/i915: Use devm_drm_dev_alloc
-:60: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 38 lines checked
39f1c0136f6e drm/arcpgu: Switch to devm_drm_dev_alloc
-:101: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 75 lines checked
e70ff1199986 drm/arcpgu: Stop using drm_device->dev_private
-:68: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 40 lines checked
fd487d20d96f drm/arcpgu: Delete arcpgu_priv->fb
92d815db6627 drm/arc: Embedded a drm_simple_display_pipe
-:133: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 93 lines checked
81aa508f4aac drm/arc: Embedd a drm_connector for sim case
-:62: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 39 lines checked
e44e078a706c drm/arc: Drop surplus connector registration
53609c098023 drm/arc: Use drmm_mode_config_cleanup
-:120: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 83 lines checked
3bf4add3b139 drm/arc: Align with simple pipe helpers
-:58: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 35 lines checked
9bafee34adc8 drm/arc: Convert to drm_simple_kms_pipe_helper
-:248: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 209 lines checked
eb0ac9ba6f3a drm/arc: Drop fb/crtc check in arc_pgu_update
-:27: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 9 lines checked
e52c65463632 drm/arc: Inline arcpgu_crtc.c
-:32: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#32: 
deleted file mode 100644

-:230: CHECK:PREFER_KERNEL_TYPES: Prefer kernel type 'u32' over 'uint32_t'
#230: FILE: drivers/gpu/drm/arc/arcpgu_drv.c:39:
+	uint32_t pixel_format = fb->format->format;

-:268: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'rate > 0'
#268: FILE: drivers/gpu/drm/arc/arcpgu_drv.c:77:
+	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))

-:335: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#335: FILE: drivers/gpu/drm/arc/arcpgu_drv.c:144:
+	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
+			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &

-:404: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 2 warnings, 3 checks, 200 lines checked
7343df9f4b2a drm/arc: Inline arcpgu_drm_hdmi_init
-:56: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#56: 
deleted file mode 100644

-:87: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 2 warnings, 0 checks, 29 lines checked
4fa14bd8ec30 drm/arc: Inline remaining files
-:23: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#23: 
deleted file mode 100644

-:168: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#168: FILE: drivers/gpu/drm/arc/arcpgu_drv.c:111:
+	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
+			DRM_MODE_CONNECTOR_VIRTUAL);

-:301: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 2 warnings, 1 checks, 117 lines checked
e8d0970f7144 drm/arc: Initialize sim connector before display pipe
-:106: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 86 lines checked
7c2ba0190489 drm/arc: Move to drm/tiny
-:50: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#50: 
deleted file mode 100644

-:81: WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully
#81: FILE: drivers/gpu/drm/tiny/Kconfig:3:
+config DRM_ARCPGU

-:108: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 3 warnings, 0 checks, 44 lines checked
a56dd08b28f5 drm/aspeed: Drop aspeed_gfx->fbdev
-:25: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 7 lines checked
b523f58b0844 drm/aspeed: Use devm_drm_dev_alloc
-:33: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations
#33: FILE: drivers/gpu/drm/aspeed/aspeed_gfx.h:17:
 };
+#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)

-:146: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 1 checks, 105 lines checked
61684dca07fb drm/aspeed: Use managed drmm_mode_config_cleanup
-:56: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 35 lines checked
212b8f6dd792 drm/ast: Use managed pci functions
-:66: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 34 lines checked
5952709c16e7 drm/ast: Drop explicit connector register/unregister
-:38: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 15 lines checked
6b267f98398f drm/bochs: Remove explicit drm_connector_register
-:25: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <daniel.vetter@ffwll.ch>'

total: 0 errors, 1 warnings, 0 checks, 7 lines checked

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  8:04     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development


[-- Attachment #1.1.1: Type: text/plain, Size: 4796 bytes --]

Hi

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Because it is.

Yes.

OTOH, as much as I appreciate the simplification, I think it should be
in a separate series.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  MAINTAINERS                                         |  2 +-
>  drivers/gpu/drm/Kconfig                             |  2 --
>  drivers/gpu/drm/Makefile                            |  1 -
>  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
>  drivers/gpu/drm/arc/Makefile                        |  3 ---
>  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
>  drivers/gpu/drm/tiny/Makefile                       |  1 +
>  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
>  8 files changed, 12 insertions(+), 17 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/Kconfig
>  delete mode 100644 drivers/gpu/drm/arc/Makefile
>  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0a5cf105ee37..748244b1625b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
>  M:	Alexey Brodkin <abrodkin@synopsys.com>
>  S:	Supported
>  F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
> -F:	drivers/gpu/drm/arc/
> +F:	drivers/gpu/drm/tiny/arcpgu.c
>  
>  ARCNET NETWORK LAYER
>  M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 4f4e7fa001c1..a0a89025d6fa 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
>  
>  source "drivers/gpu/drm/etnaviv/Kconfig"
>  
> -source "drivers/gpu/drm/arc/Kconfig"
> -
>  source "drivers/gpu/drm/hisilicon/Kconfig"
>  
>  source "drivers/gpu/drm/mediatek/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 2c0e5a7e5953..e69eafbf9e39 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -109,7 +109,6 @@ obj-y			+= panel/
>  obj-y			+= bridge/
>  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
>  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> -obj-$(CONFIG_DRM_ARCPGU)+= arc/
>  obj-y			+= hisilicon/
>  obj-$(CONFIG_DRM_ZTE)	+= zte/
>  obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
> diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> deleted file mode 100644
> index e8f3d63e0b91..000000000000
> --- a/drivers/gpu/drm/arc/Kconfig
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_ARCPGU
> -	tristate "ARC PGU"
> -	depends on DRM && OF
> -	select DRM_KMS_CMA_HELPER
> -	select DRM_KMS_HELPER
> -	help
> -	  Choose this option if you have an ARC PGU controller.
> -
> -	  If M is selected the module will be called arcpgu.
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> deleted file mode 100644
> index b26f2495c532..000000000000
> --- a/drivers/gpu/drm/arc/Makefile
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_drv.o
> -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 2b6414f0fa75..9bbaa1a69050 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,15 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_ARCPGU
> +	tristate "ARC PGU"
> +	depends on DRM && OF
> +	select DRM_KMS_CMA_HELPER
> +	select DRM_KMS_HELPER
> +	help
> +	  Choose this option if you have an ARC PGU controller.
> +
> +	  If M is selected the module will be called arcpgu.
> +
>  config DRM_CIRRUS_QEMU
>  	tristate "Cirrus driver for QEMU emulated device"
>  	depends on DRM && PCI && MMU
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index 6ae4e9e5a35f..bef6780bdd6f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
>  obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> similarity index 100%
> rename from drivers/gpu/drm/arc/arcpgu_drv.c
> rename to drivers/gpu/drm/tiny/arcpgu.c
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15  8:04     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Alexey Brodkin, DRI Development


[-- Attachment #1.1.1: Type: text/plain, Size: 4796 bytes --]

Hi

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Because it is.

Yes.

OTOH, as much as I appreciate the simplification, I think it should be
in a separate series.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  MAINTAINERS                                         |  2 +-
>  drivers/gpu/drm/Kconfig                             |  2 --
>  drivers/gpu/drm/Makefile                            |  1 -
>  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
>  drivers/gpu/drm/arc/Makefile                        |  3 ---
>  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
>  drivers/gpu/drm/tiny/Makefile                       |  1 +
>  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
>  8 files changed, 12 insertions(+), 17 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/Kconfig
>  delete mode 100644 drivers/gpu/drm/arc/Makefile
>  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0a5cf105ee37..748244b1625b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
>  M:	Alexey Brodkin <abrodkin@synopsys.com>
>  S:	Supported
>  F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
> -F:	drivers/gpu/drm/arc/
> +F:	drivers/gpu/drm/tiny/arcpgu.c
>  
>  ARCNET NETWORK LAYER
>  M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 4f4e7fa001c1..a0a89025d6fa 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
>  
>  source "drivers/gpu/drm/etnaviv/Kconfig"
>  
> -source "drivers/gpu/drm/arc/Kconfig"
> -
>  source "drivers/gpu/drm/hisilicon/Kconfig"
>  
>  source "drivers/gpu/drm/mediatek/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 2c0e5a7e5953..e69eafbf9e39 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -109,7 +109,6 @@ obj-y			+= panel/
>  obj-y			+= bridge/
>  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
>  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> -obj-$(CONFIG_DRM_ARCPGU)+= arc/
>  obj-y			+= hisilicon/
>  obj-$(CONFIG_DRM_ZTE)	+= zte/
>  obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
> diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> deleted file mode 100644
> index e8f3d63e0b91..000000000000
> --- a/drivers/gpu/drm/arc/Kconfig
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_ARCPGU
> -	tristate "ARC PGU"
> -	depends on DRM && OF
> -	select DRM_KMS_CMA_HELPER
> -	select DRM_KMS_HELPER
> -	help
> -	  Choose this option if you have an ARC PGU controller.
> -
> -	  If M is selected the module will be called arcpgu.
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> deleted file mode 100644
> index b26f2495c532..000000000000
> --- a/drivers/gpu/drm/arc/Makefile
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_drv.o
> -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 2b6414f0fa75..9bbaa1a69050 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,15 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_ARCPGU
> +	tristate "ARC PGU"
> +	depends on DRM && OF
> +	select DRM_KMS_CMA_HELPER
> +	select DRM_KMS_HELPER
> +	help
> +	  Choose this option if you have an ARC PGU controller.
> +
> +	  If M is selected the module will be called arcpgu.
> +
>  config DRM_CIRRUS_QEMU
>  	tristate "Cirrus driver for QEMU emulated device"
>  	depends on DRM && PCI && MMU
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index 6ae4e9e5a35f..bef6780bdd6f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
>  obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> similarity index 100%
> rename from drivers/gpu/drm/arc/arcpgu_drv.c
> rename to drivers/gpu/drm/tiny/arcpgu.c
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  7:52     ` [Intel-gfx] " Thomas Zimmermann
@ 2020-04-15  8:09       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:09 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi Daniel
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Allows us to remove a bit of cleanup code.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.velikov@collabora.com>
> > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > ---
> >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> >  2 files changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > index b7ba22dddcad..48a9cc4e080a 100644
> > --- a/drivers/gpu/drm/ast/ast_drv.c
> > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >
> >       ast_kick_out_firmware_fb(pdev);
> >
> > -     ret = pci_enable_device(pdev);
> > +     ret = pcim_enable_device(pdev);
> >       if (ret)
> >               return ret;
> >
> >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > -     if (IS_ERR(dev)) {
> > -             ret = PTR_ERR(dev);
> > -             goto err_pci_disable_device;
> > -     }
> > +     if (IS_ERR(dev))
> > +             return  PTR_ERR(dev);
> >
> >       dev->pdev = pdev;
> >       pci_set_drvdata(pdev, dev);
> > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >       ast_driver_unload(dev);
> >  err_drm_dev_put:
> >       drm_dev_put(dev);
> > -err_pci_disable_device:
> > -     pci_disable_device(pdev);
> >       return ret;
> >
> >  }
> > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > index e5398e3dabe7..1b35728ad871 100644
> > --- a/drivers/gpu/drm/ast/ast_main.c
> > +++ b/drivers/gpu/drm/ast/ast_main.c
> > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> >       drm_mode_config_cleanup(dev);
> >
> >       ast_mm_fini(ast);
> > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > -             pci_iounmap(dev->pdev, ast->ioregs);
> > -     pci_iounmap(dev->pdev, ast->regs);
>
> This gets unmapped as part of the automatic pci_disable_device(), I guess?

Yup, once you go with pcim_enable_device all pci_ functions on that
device become manged and auto-cleanup.

> Do we need drm_dev_enter()/_exit() to make I/O work reliably?

That does nothing without drm_dev_unplug(), which has the annoying
side effect that it also shuts up stuff like
drm_atomic_helper_shutdown for module unload. And developers really
want their devices to be shut off on driver unload. So yeah
unfortunately we currently can decide between "correct for hotunplug"
and "convenient for driver unload for driver authors". I'm not sure
what to best do here, since all options are kinda not great for one
use-case or the other.
-Daniel

> Best regards
> Thomas
>
> >       kfree(ast);
> >  }
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-04-15  8:09       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:09 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi Daniel
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Allows us to remove a bit of cleanup code.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.velikov@collabora.com>
> > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > ---
> >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> >  2 files changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > index b7ba22dddcad..48a9cc4e080a 100644
> > --- a/drivers/gpu/drm/ast/ast_drv.c
> > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >
> >       ast_kick_out_firmware_fb(pdev);
> >
> > -     ret = pci_enable_device(pdev);
> > +     ret = pcim_enable_device(pdev);
> >       if (ret)
> >               return ret;
> >
> >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > -     if (IS_ERR(dev)) {
> > -             ret = PTR_ERR(dev);
> > -             goto err_pci_disable_device;
> > -     }
> > +     if (IS_ERR(dev))
> > +             return  PTR_ERR(dev);
> >
> >       dev->pdev = pdev;
> >       pci_set_drvdata(pdev, dev);
> > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >       ast_driver_unload(dev);
> >  err_drm_dev_put:
> >       drm_dev_put(dev);
> > -err_pci_disable_device:
> > -     pci_disable_device(pdev);
> >       return ret;
> >
> >  }
> > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > index e5398e3dabe7..1b35728ad871 100644
> > --- a/drivers/gpu/drm/ast/ast_main.c
> > +++ b/drivers/gpu/drm/ast/ast_main.c
> > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> >       drm_mode_config_cleanup(dev);
> >
> >       ast_mm_fini(ast);
> > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > -             pci_iounmap(dev->pdev, ast->ioregs);
> > -     pci_iounmap(dev->pdev, ast->regs);
>
> This gets unmapped as part of the automatic pci_disable_device(), I guess?

Yup, once you go with pcim_enable_device all pci_ functions on that
device become manged and auto-cleanup.

> Do we need drm_dev_enter()/_exit() to make I/O work reliably?

That does nothing without drm_dev_unplug(), which has the annoying
side effect that it also shuts up stuff like
drm_atomic_helper_shutdown for module unload. And developers really
want their devices to be shut off on driver unload. So yeah
unfortunately we currently can decide between "correct for hotunplug"
and "convenient for driver unload for driver authors". I'm not sure
what to best do here, since all options are kinda not great for one
use-case or the other.
-Daniel

> Best regards
> Thomas
>
> >       kfree(ast);
> >  }
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  8:09       ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  8:17         ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:17 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 10:09 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >
> > Hi Daniel
> >
> > Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > > Allows us to remove a bit of cleanup code.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Dave Airlie <airlied@redhat.com>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Emil Velikov <emil.velikov@collabora.com>
> > > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > > Cc: Sam Ravnborg <sam@ravnborg.org>
> > > Cc: "Christian König" <christian.koenig@amd.com>
> > > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > > ---
> > >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> > >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> > >  2 files changed, 3 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > > index b7ba22dddcad..48a9cc4e080a 100644
> > > --- a/drivers/gpu/drm/ast/ast_drv.c
> > > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >
> > >       ast_kick_out_firmware_fb(pdev);
> > >
> > > -     ret = pci_enable_device(pdev);
> > > +     ret = pcim_enable_device(pdev);
> > >       if (ret)
> > >               return ret;
> > >
> > >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > > -     if (IS_ERR(dev)) {
> > > -             ret = PTR_ERR(dev);
> > > -             goto err_pci_disable_device;
> > > -     }
> > > +     if (IS_ERR(dev))
> > > +             return  PTR_ERR(dev);
> > >
> > >       dev->pdev = pdev;
> > >       pci_set_drvdata(pdev, dev);
> > > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >       ast_driver_unload(dev);
> > >  err_drm_dev_put:
> > >       drm_dev_put(dev);
> > > -err_pci_disable_device:
> > > -     pci_disable_device(pdev);
> > >       return ret;
> > >
> > >  }
> > > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > > index e5398e3dabe7..1b35728ad871 100644
> > > --- a/drivers/gpu/drm/ast/ast_main.c
> > > +++ b/drivers/gpu/drm/ast/ast_main.c
> > > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> > >       drm_mode_config_cleanup(dev);
> > >
> > >       ast_mm_fini(ast);
> > > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > > -             pci_iounmap(dev->pdev, ast->ioregs);
> > > -     pci_iounmap(dev->pdev, ast->regs);
> >
> > This gets unmapped as part of the automatic pci_disable_device(), I guess?
>
> Yup, once you go with pcim_enable_device all pci_ functions on that
> device become manged and auto-cleanup.
>
> > Do we need drm_dev_enter()/_exit() to make I/O work reliably?
>
> That does nothing without drm_dev_unplug(), which has the annoying
> side effect that it also shuts up stuff like
> drm_atomic_helper_shutdown for module unload. And developers really
> want their devices to be shut off on driver unload. So yeah
> unfortunately we currently can decide between "correct for hotunplug"
> and "convenient for driver unload for driver authors". I'm not sure
> what to best do here, since all options are kinda not great for one
> use-case or the other.

So if we'd split up drm_dev_unplug into drm_dev_unregister +
drm_dev_mark_unplugged or whatever the options would be:

drm_atomic_helper_shutdown(); /* and other hw shut down */
drm_dev_unregister();
drm_dev_mark_unplugged();

Kinda annoying since userspace might race with us, so we might still
have an active fb (in sw tracking at least) that we need to clean up
again later on. Plus shutting down hw before we unregister is going to
make the hotunplug confusion for userspace even more a mess.

Next option:
drm_dev_unregster();
/* shut down hw */
drm_dev_mark_unplugged();

This just wastes time since if we're really unplugged we'll do lots of
io attempts that go nowhere because the device is gone already.
They'll all time out (if the bus subsystem/hw for our driver works
correctly at least). Plus userspace can still sneak in and do stupid
stuff I think while we're not looking.

Next up:
drm_dev_unregister();
drm_dev_mark_unplugged();
drm_atomic_helper_shutdown();

This is a bit silly since all the shutdown code now does is shut down
sw state, and never touches hw (if the driver is fully annotated with
drm_dev_enter/exit).

One option might be that we slap a lot more drm_dev_enter/exit around
the top-level ioctls (to at least stop the userspace races with driver
unload), and allow drivers to still shut down stuff internally.

tldr; it's all still a bit a mess.
-Daniel

> -Daniel
>
> > Best regards
> > Thomas
> >
> > >       kfree(ast);
> > >  }
> > >
> >
> > --
> > Thomas Zimmermann
> > Graphics Driver Developer
> > SUSE Software Solutions Germany GmbH
> > Maxfeldstr. 5, 90409 Nürnberg, Germany
> > (HRB 36809, AG Nürnberg)
> > Geschäftsführer: Felix Imendörffer
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-04-15  8:17         ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:17 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 10:09 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >
> > Hi Daniel
> >
> > Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > > Allows us to remove a bit of cleanup code.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Dave Airlie <airlied@redhat.com>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Emil Velikov <emil.velikov@collabora.com>
> > > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > > Cc: Sam Ravnborg <sam@ravnborg.org>
> > > Cc: "Christian König" <christian.koenig@amd.com>
> > > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > > ---
> > >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> > >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> > >  2 files changed, 3 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > > index b7ba22dddcad..48a9cc4e080a 100644
> > > --- a/drivers/gpu/drm/ast/ast_drv.c
> > > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >
> > >       ast_kick_out_firmware_fb(pdev);
> > >
> > > -     ret = pci_enable_device(pdev);
> > > +     ret = pcim_enable_device(pdev);
> > >       if (ret)
> > >               return ret;
> > >
> > >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > > -     if (IS_ERR(dev)) {
> > > -             ret = PTR_ERR(dev);
> > > -             goto err_pci_disable_device;
> > > -     }
> > > +     if (IS_ERR(dev))
> > > +             return  PTR_ERR(dev);
> > >
> > >       dev->pdev = pdev;
> > >       pci_set_drvdata(pdev, dev);
> > > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >       ast_driver_unload(dev);
> > >  err_drm_dev_put:
> > >       drm_dev_put(dev);
> > > -err_pci_disable_device:
> > > -     pci_disable_device(pdev);
> > >       return ret;
> > >
> > >  }
> > > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > > index e5398e3dabe7..1b35728ad871 100644
> > > --- a/drivers/gpu/drm/ast/ast_main.c
> > > +++ b/drivers/gpu/drm/ast/ast_main.c
> > > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> > >       drm_mode_config_cleanup(dev);
> > >
> > >       ast_mm_fini(ast);
> > > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > > -             pci_iounmap(dev->pdev, ast->ioregs);
> > > -     pci_iounmap(dev->pdev, ast->regs);
> >
> > This gets unmapped as part of the automatic pci_disable_device(), I guess?
>
> Yup, once you go with pcim_enable_device all pci_ functions on that
> device become manged and auto-cleanup.
>
> > Do we need drm_dev_enter()/_exit() to make I/O work reliably?
>
> That does nothing without drm_dev_unplug(), which has the annoying
> side effect that it also shuts up stuff like
> drm_atomic_helper_shutdown for module unload. And developers really
> want their devices to be shut off on driver unload. So yeah
> unfortunately we currently can decide between "correct for hotunplug"
> and "convenient for driver unload for driver authors". I'm not sure
> what to best do here, since all options are kinda not great for one
> use-case or the other.

So if we'd split up drm_dev_unplug into drm_dev_unregister +
drm_dev_mark_unplugged or whatever the options would be:

drm_atomic_helper_shutdown(); /* and other hw shut down */
drm_dev_unregister();
drm_dev_mark_unplugged();

Kinda annoying since userspace might race with us, so we might still
have an active fb (in sw tracking at least) that we need to clean up
again later on. Plus shutting down hw before we unregister is going to
make the hotunplug confusion for userspace even more a mess.

Next option:
drm_dev_unregster();
/* shut down hw */
drm_dev_mark_unplugged();

This just wastes time since if we're really unplugged we'll do lots of
io attempts that go nowhere because the device is gone already.
They'll all time out (if the bus subsystem/hw for our driver works
correctly at least). Plus userspace can still sneak in and do stupid
stuff I think while we're not looking.

Next up:
drm_dev_unregister();
drm_dev_mark_unplugged();
drm_atomic_helper_shutdown();

This is a bit silly since all the shutdown code now does is shut down
sw state, and never touches hw (if the driver is fully annotated with
drm_dev_enter/exit).

One option might be that we slap a lot more drm_dev_enter/exit around
the top-level ioctls (to at least stop the userspace races with driver
unload), and allow drivers to still shut down stuff internally.

tldr; it's all still a bit a mess.
-Daniel

> -Daniel
>
> > Best regards
> > Thomas
> >
> > >       kfree(ast);
> > >  }
> > >
> >
> > --
> > Thomas Zimmermann
> > Graphics Driver Developer
> > SUSE Software Solutions Germany GmbH
> > Maxfeldstr. 5, 90409 Nürnberg, Germany
> > (HRB 36809, AG Nürnberg)
> > Geschäftsführer: Felix Imendörffer
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  8:01     ` Thomas Zimmermann
  (?)
@ 2020-04-15  8:19       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:19 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Because it is. Huge congrats to everyone who made this kind of
> > refactoring happen!
>
> Every other week, I felt an urge to send out this patch. Thank you so
> much, Daniel! There are more candidates for tiny/. They are all <20k
> LOCs and all we'd have to do is to move their code into a single file.
> bochs or arc come into my mind.

arc I have (later in the series), bochs I feel like is maybe a bit too
big. I'd put the limit for tiny well below 1kloc including whitespace
and all that. bochs might be a candidate once we've helperized a few
more things perhaps.

btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
-Daniel

>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> > ---
> >  MAINTAINERS                               |  2 +-
> >  drivers/gpu/drm/Kconfig                   |  2 --
> >  drivers/gpu/drm/Makefile                  |  1 -
> >  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >  drivers/gpu/drm/tiny/Makefile             |  1 +
> >  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >  8 files changed, 21 insertions(+), 25 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 7b3255d96d1d..0a5cf105ee37 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >  S:   Obsolete
> >  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >  T:   git git://anongit.freedesktop.org/drm/drm-misc
> > -F:   drivers/gpu/drm/cirrus/
> > +F:   drivers/gpu/drm/tiny/cirrus.c
> >
> >  DRM DRIVER FOR QXL VIRTUAL GPU
> >  M:   Dave Airlie <airlied@redhat.com>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 43594978958e..4f4e7fa001c1 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >
> >  source "drivers/gpu/drm/mgag200/Kconfig"
> >
> > -source "drivers/gpu/drm/cirrus/Kconfig"
> > -
> >  source "drivers/gpu/drm/armada/Kconfig"
> >
> >  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index f34d08c83485..2c0e5a7e5953 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >  obj-$(CONFIG_DRM_V3D)  += v3d/
> >  obj-$(CONFIG_DRM_VC4)  += vc4/
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >  obj-$(CONFIG_DRM_SIS)   += sis/
> >  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> > diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> > deleted file mode 100644
> > index c6bbd988b0e5..000000000000
> > --- a/drivers/gpu/drm/cirrus/Kconfig
> > +++ /dev/null
> > @@ -1,19 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -config DRM_CIRRUS_QEMU
> > -     tristate "Cirrus driver for QEMU emulated device"
> > -     depends on DRM && PCI && MMU
> > -     select DRM_KMS_HELPER
> > -     select DRM_GEM_SHMEM_HELPER
> > -     help
> > -      This is a KMS driver for emulated cirrus device in qemu.
> > -      It is *NOT* intended for real cirrus devices. This requires
> > -      the modesetting userspace X.org driver.
> > -
> > -      Cirrus is obsolete, the hardware was designed in the 90ies
> > -      and can't keep up with todays needs.  More background:
> > -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > -
> > -      Better alternatives are:
> > -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> > deleted file mode 100644
> > index 0c1ed3f99725..000000000000
> > --- a/drivers/gpu/drm/cirrus/Makefile
> > +++ /dev/null
> > @@ -1,2 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > index 4160e74e4751..2b6414f0fa75 100644
> > --- a/drivers/gpu/drm/tiny/Kconfig
> > +++ b/drivers/gpu/drm/tiny/Kconfig
> > @@ -1,5 +1,24 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +config DRM_CIRRUS_QEMU
> > +     tristate "Cirrus driver for QEMU emulated device"
> > +     depends on DRM && PCI && MMU
> > +     select DRM_KMS_HELPER
> > +     select DRM_GEM_SHMEM_HELPER
> > +     help
> > +      This is a KMS driver for emulated cirrus device in qemu.
> > +      It is *NOT* intended for real cirrus devices. This requires
> > +      the modesetting userspace X.org driver.
> > +
> > +      Cirrus is obsolete, the hardware was designed in the 90ies
> > +      and can't keep up with todays needs.  More background:
> > +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > +
> > +      Better alternatives are:
> > +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > +
> >  config DRM_GM12U320
> >       tristate "GM12U320 driver for USB projectors"
> >       depends on DRM && USB
> > diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> > index c96ceee71453..6ae4e9e5a35f 100644
> > --- a/drivers/gpu/drm/tiny/Makefile
> > +++ b/drivers/gpu/drm/tiny/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> > diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> > similarity index 100%
> > rename from drivers/gpu/drm/cirrus/cirrus.c
> > rename to drivers/gpu/drm/tiny/cirrus.c
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:19       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:19 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Because it is. Huge congrats to everyone who made this kind of
> > refactoring happen!
>
> Every other week, I felt an urge to send out this patch. Thank you so
> much, Daniel! There are more candidates for tiny/. They are all <20k
> LOCs and all we'd have to do is to move their code into a single file.
> bochs or arc come into my mind.

arc I have (later in the series), bochs I feel like is maybe a bit too
big. I'd put the limit for tiny well below 1kloc including whitespace
and all that. bochs might be a candidate once we've helperized a few
more things perhaps.

btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
-Daniel

>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> > ---
> >  MAINTAINERS                               |  2 +-
> >  drivers/gpu/drm/Kconfig                   |  2 --
> >  drivers/gpu/drm/Makefile                  |  1 -
> >  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >  drivers/gpu/drm/tiny/Makefile             |  1 +
> >  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >  8 files changed, 21 insertions(+), 25 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 7b3255d96d1d..0a5cf105ee37 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >  S:   Obsolete
> >  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >  T:   git git://anongit.freedesktop.org/drm/drm-misc
> > -F:   drivers/gpu/drm/cirrus/
> > +F:   drivers/gpu/drm/tiny/cirrus.c
> >
> >  DRM DRIVER FOR QXL VIRTUAL GPU
> >  M:   Dave Airlie <airlied@redhat.com>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 43594978958e..4f4e7fa001c1 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >
> >  source "drivers/gpu/drm/mgag200/Kconfig"
> >
> > -source "drivers/gpu/drm/cirrus/Kconfig"
> > -
> >  source "drivers/gpu/drm/armada/Kconfig"
> >
> >  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index f34d08c83485..2c0e5a7e5953 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >  obj-$(CONFIG_DRM_V3D)  += v3d/
> >  obj-$(CONFIG_DRM_VC4)  += vc4/
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >  obj-$(CONFIG_DRM_SIS)   += sis/
> >  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> > diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> > deleted file mode 100644
> > index c6bbd988b0e5..000000000000
> > --- a/drivers/gpu/drm/cirrus/Kconfig
> > +++ /dev/null
> > @@ -1,19 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -config DRM_CIRRUS_QEMU
> > -     tristate "Cirrus driver for QEMU emulated device"
> > -     depends on DRM && PCI && MMU
> > -     select DRM_KMS_HELPER
> > -     select DRM_GEM_SHMEM_HELPER
> > -     help
> > -      This is a KMS driver for emulated cirrus device in qemu.
> > -      It is *NOT* intended for real cirrus devices. This requires
> > -      the modesetting userspace X.org driver.
> > -
> > -      Cirrus is obsolete, the hardware was designed in the 90ies
> > -      and can't keep up with todays needs.  More background:
> > -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > -
> > -      Better alternatives are:
> > -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> > deleted file mode 100644
> > index 0c1ed3f99725..000000000000
> > --- a/drivers/gpu/drm/cirrus/Makefile
> > +++ /dev/null
> > @@ -1,2 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > index 4160e74e4751..2b6414f0fa75 100644
> > --- a/drivers/gpu/drm/tiny/Kconfig
> > +++ b/drivers/gpu/drm/tiny/Kconfig
> > @@ -1,5 +1,24 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +config DRM_CIRRUS_QEMU
> > +     tristate "Cirrus driver for QEMU emulated device"
> > +     depends on DRM && PCI && MMU
> > +     select DRM_KMS_HELPER
> > +     select DRM_GEM_SHMEM_HELPER
> > +     help
> > +      This is a KMS driver for emulated cirrus device in qemu.
> > +      It is *NOT* intended for real cirrus devices. This requires
> > +      the modesetting userspace X.org driver.
> > +
> > +      Cirrus is obsolete, the hardware was designed in the 90ies
> > +      and can't keep up with todays needs.  More background:
> > +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > +
> > +      Better alternatives are:
> > +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > +
> >  config DRM_GM12U320
> >       tristate "GM12U320 driver for USB projectors"
> >       depends on DRM && USB
> > diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> > index c96ceee71453..6ae4e9e5a35f 100644
> > --- a/drivers/gpu/drm/tiny/Makefile
> > +++ b/drivers/gpu/drm/tiny/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> > diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> > similarity index 100%
> > rename from drivers/gpu/drm/cirrus/cirrus.c
> > rename to drivers/gpu/drm/tiny/cirrus.c
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:19       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:19 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Because it is. Huge congrats to everyone who made this kind of
> > refactoring happen!
>
> Every other week, I felt an urge to send out this patch. Thank you so
> much, Daniel! There are more candidates for tiny/. They are all <20k
> LOCs and all we'd have to do is to move their code into a single file.
> bochs or arc come into my mind.

arc I have (later in the series), bochs I feel like is maybe a bit too
big. I'd put the limit for tiny well below 1kloc including whitespace
and all that. bochs might be a candidate once we've helperized a few
more things perhaps.

btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
-Daniel

>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> > ---
> >  MAINTAINERS                               |  2 +-
> >  drivers/gpu/drm/Kconfig                   |  2 --
> >  drivers/gpu/drm/Makefile                  |  1 -
> >  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >  drivers/gpu/drm/tiny/Makefile             |  1 +
> >  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >  8 files changed, 21 insertions(+), 25 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 7b3255d96d1d..0a5cf105ee37 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >  S:   Obsolete
> >  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >  T:   git git://anongit.freedesktop.org/drm/drm-misc
> > -F:   drivers/gpu/drm/cirrus/
> > +F:   drivers/gpu/drm/tiny/cirrus.c
> >
> >  DRM DRIVER FOR QXL VIRTUAL GPU
> >  M:   Dave Airlie <airlied@redhat.com>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 43594978958e..4f4e7fa001c1 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >
> >  source "drivers/gpu/drm/mgag200/Kconfig"
> >
> > -source "drivers/gpu/drm/cirrus/Kconfig"
> > -
> >  source "drivers/gpu/drm/armada/Kconfig"
> >
> >  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index f34d08c83485..2c0e5a7e5953 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >  obj-$(CONFIG_DRM_V3D)  += v3d/
> >  obj-$(CONFIG_DRM_VC4)  += vc4/
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >  obj-$(CONFIG_DRM_SIS)   += sis/
> >  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> > diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> > deleted file mode 100644
> > index c6bbd988b0e5..000000000000
> > --- a/drivers/gpu/drm/cirrus/Kconfig
> > +++ /dev/null
> > @@ -1,19 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -config DRM_CIRRUS_QEMU
> > -     tristate "Cirrus driver for QEMU emulated device"
> > -     depends on DRM && PCI && MMU
> > -     select DRM_KMS_HELPER
> > -     select DRM_GEM_SHMEM_HELPER
> > -     help
> > -      This is a KMS driver for emulated cirrus device in qemu.
> > -      It is *NOT* intended for real cirrus devices. This requires
> > -      the modesetting userspace X.org driver.
> > -
> > -      Cirrus is obsolete, the hardware was designed in the 90ies
> > -      and can't keep up with todays needs.  More background:
> > -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > -
> > -      Better alternatives are:
> > -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> > deleted file mode 100644
> > index 0c1ed3f99725..000000000000
> > --- a/drivers/gpu/drm/cirrus/Makefile
> > +++ /dev/null
> > @@ -1,2 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > index 4160e74e4751..2b6414f0fa75 100644
> > --- a/drivers/gpu/drm/tiny/Kconfig
> > +++ b/drivers/gpu/drm/tiny/Kconfig
> > @@ -1,5 +1,24 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +config DRM_CIRRUS_QEMU
> > +     tristate "Cirrus driver for QEMU emulated device"
> > +     depends on DRM && PCI && MMU
> > +     select DRM_KMS_HELPER
> > +     select DRM_GEM_SHMEM_HELPER
> > +     help
> > +      This is a KMS driver for emulated cirrus device in qemu.
> > +      It is *NOT* intended for real cirrus devices. This requires
> > +      the modesetting userspace X.org driver.
> > +
> > +      Cirrus is obsolete, the hardware was designed in the 90ies
> > +      and can't keep up with todays needs.  More background:
> > +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> > +
> > +      Better alternatives are:
> > +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> > +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> > +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> > +
> >  config DRM_GM12U320
> >       tristate "GM12U320 driver for USB projectors"
> >       depends on DRM && USB
> > diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> > index c96ceee71453..6ae4e9e5a35f 100644
> > --- a/drivers/gpu/drm/tiny/Makefile
> > +++ b/drivers/gpu/drm/tiny/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> > diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> > similarity index 100%
> > rename from drivers/gpu/drm/cirrus/cirrus.c
> > rename to drivers/gpu/drm/tiny/cirrus.c
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15  8:04     ` [Intel-gfx] " Thomas Zimmermann
@ 2020-04-15  8:22       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:22 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 10:04 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Because it is.
>
> Yes.
>
> OTOH, as much as I appreciate the simplification, I think it should be
> in a separate series.

Right now they all still need to be here because of the
devm_drm_dev_alloc patch 1 adds. After that I guess I can split up,
but it's kinda more work. The series is really "clean up driver
load/unload code around drm_device", and for some of the older drivers
there's a _lot_ that can be done.
-Daniel

>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> > ---
> >  MAINTAINERS                                         |  2 +-
> >  drivers/gpu/drm/Kconfig                             |  2 --
> >  drivers/gpu/drm/Makefile                            |  1 -
> >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> >  8 files changed, 12 insertions(+), 17 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 0a5cf105ee37..748244b1625b 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
> >  M:   Alexey Brodkin <abrodkin@synopsys.com>
> >  S:   Supported
> >  F:   Documentation/devicetree/bindings/display/snps,arcpgu.txt
> > -F:   drivers/gpu/drm/arc/
> > +F:   drivers/gpu/drm/tiny/arcpgu.c
> >
> >  ARCNET NETWORK LAYER
> >  M:   Michael Grzeschik <m.grzeschik@pengutronix.de>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 4f4e7fa001c1..a0a89025d6fa 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
> >
> >  source "drivers/gpu/drm/etnaviv/Kconfig"
> >
> > -source "drivers/gpu/drm/arc/Kconfig"
> > -
> >  source "drivers/gpu/drm/hisilicon/Kconfig"
> >
> >  source "drivers/gpu/drm/mediatek/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index 2c0e5a7e5953..e69eafbf9e39 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -109,7 +109,6 @@ obj-y                     += panel/
> >  obj-y                        += bridge/
> >  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
> >  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> > -obj-$(CONFIG_DRM_ARCPGU)+= arc/
> >  obj-y                        += hisilicon/
> >  obj-$(CONFIG_DRM_ZTE)        += zte/
> >  obj-$(CONFIG_DRM_MXSFB)      += mxsfb/
> > diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> > deleted file mode 100644
> > index e8f3d63e0b91..000000000000
> > --- a/drivers/gpu/drm/arc/Kconfig
> > +++ /dev/null
> > @@ -1,10 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -config DRM_ARCPGU
> > -     tristate "ARC PGU"
> > -     depends on DRM && OF
> > -     select DRM_KMS_CMA_HELPER
> > -     select DRM_KMS_HELPER
> > -     help
> > -       Choose this option if you have an ARC PGU controller.
> > -
> > -       If M is selected the module will be called arcpgu.
> > diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> > deleted file mode 100644
> > index b26f2495c532..000000000000
> > --- a/drivers/gpu/drm/arc/Makefile
> > +++ /dev/null
> > @@ -1,3 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -arcpgu-y := arcpgu_drv.o
> > -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > index 2b6414f0fa75..9bbaa1a69050 100644
> > --- a/drivers/gpu/drm/tiny/Kconfig
> > +++ b/drivers/gpu/drm/tiny/Kconfig
> > @@ -1,5 +1,15 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +config DRM_ARCPGU
> > +     tristate "ARC PGU"
> > +     depends on DRM && OF
> > +     select DRM_KMS_CMA_HELPER
> > +     select DRM_KMS_HELPER
> > +     help
> > +       Choose this option if you have an ARC PGU controller.
> > +
> > +       If M is selected the module will be called arcpgu.
> > +
> >  config DRM_CIRRUS_QEMU
> >       tristate "Cirrus driver for QEMU emulated device"
> >       depends on DRM && PCI && MMU
> > diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> > index 6ae4e9e5a35f..bef6780bdd6f 100644
> > --- a/drivers/gpu/drm/tiny/Makefile
> > +++ b/drivers/gpu/drm/tiny/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +obj-$(CONFIG_DRM_ARCPGU)             += arcpgu.o
> >  obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> > similarity index 100%
> > rename from drivers/gpu/drm/arc/arcpgu_drv.c
> > rename to drivers/gpu/drm/tiny/arcpgu.c
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15  8:22       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  8:22 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 10:04 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Because it is.
>
> Yes.
>
> OTOH, as much as I appreciate the simplification, I think it should be
> in a separate series.

Right now they all still need to be here because of the
devm_drm_dev_alloc patch 1 adds. After that I guess I can split up,
but it's kinda more work. The series is really "clean up driver
load/unload code around drm_device", and for some of the older drivers
there's a _lot_ that can be done.
-Daniel

>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> > ---
> >  MAINTAINERS                                         |  2 +-
> >  drivers/gpu/drm/Kconfig                             |  2 --
> >  drivers/gpu/drm/Makefile                            |  1 -
> >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> >  8 files changed, 12 insertions(+), 17 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 0a5cf105ee37..748244b1625b 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
> >  M:   Alexey Brodkin <abrodkin@synopsys.com>
> >  S:   Supported
> >  F:   Documentation/devicetree/bindings/display/snps,arcpgu.txt
> > -F:   drivers/gpu/drm/arc/
> > +F:   drivers/gpu/drm/tiny/arcpgu.c
> >
> >  ARCNET NETWORK LAYER
> >  M:   Michael Grzeschik <m.grzeschik@pengutronix.de>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index 4f4e7fa001c1..a0a89025d6fa 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
> >
> >  source "drivers/gpu/drm/etnaviv/Kconfig"
> >
> > -source "drivers/gpu/drm/arc/Kconfig"
> > -
> >  source "drivers/gpu/drm/hisilicon/Kconfig"
> >
> >  source "drivers/gpu/drm/mediatek/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index 2c0e5a7e5953..e69eafbf9e39 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -109,7 +109,6 @@ obj-y                     += panel/
> >  obj-y                        += bridge/
> >  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
> >  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> > -obj-$(CONFIG_DRM_ARCPGU)+= arc/
> >  obj-y                        += hisilicon/
> >  obj-$(CONFIG_DRM_ZTE)        += zte/
> >  obj-$(CONFIG_DRM_MXSFB)      += mxsfb/
> > diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> > deleted file mode 100644
> > index e8f3d63e0b91..000000000000
> > --- a/drivers/gpu/drm/arc/Kconfig
> > +++ /dev/null
> > @@ -1,10 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -config DRM_ARCPGU
> > -     tristate "ARC PGU"
> > -     depends on DRM && OF
> > -     select DRM_KMS_CMA_HELPER
> > -     select DRM_KMS_HELPER
> > -     help
> > -       Choose this option if you have an ARC PGU controller.
> > -
> > -       If M is selected the module will be called arcpgu.
> > diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> > deleted file mode 100644
> > index b26f2495c532..000000000000
> > --- a/drivers/gpu/drm/arc/Makefile
> > +++ /dev/null
> > @@ -1,3 +0,0 @@
> > -# SPDX-License-Identifier: GPL-2.0-only
> > -arcpgu-y := arcpgu_drv.o
> > -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> > diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> > index 2b6414f0fa75..9bbaa1a69050 100644
> > --- a/drivers/gpu/drm/tiny/Kconfig
> > +++ b/drivers/gpu/drm/tiny/Kconfig
> > @@ -1,5 +1,15 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +config DRM_ARCPGU
> > +     tristate "ARC PGU"
> > +     depends on DRM && OF
> > +     select DRM_KMS_CMA_HELPER
> > +     select DRM_KMS_HELPER
> > +     help
> > +       Choose this option if you have an ARC PGU controller.
> > +
> > +       If M is selected the module will be called arcpgu.
> > +
> >  config DRM_CIRRUS_QEMU
> >       tristate "Cirrus driver for QEMU emulated device"
> >       depends on DRM && PCI && MMU
> > diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> > index 6ae4e9e5a35f..bef6780bdd6f 100644
> > --- a/drivers/gpu/drm/tiny/Makefile
> > +++ b/drivers/gpu/drm/tiny/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >
> > +obj-$(CONFIG_DRM_ARCPGU)             += arcpgu.o
> >  obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> > similarity index 100%
> > rename from drivers/gpu/drm/arc/arcpgu_drv.c
> > rename to drivers/gpu/drm/tiny/arcpgu.c
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✗ Fi.CI.DOCS: warning for devm_drm_dev_alloc, v2
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (60 preceding siblings ...)
  (?)
@ 2020-04-15  8:23 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-04-15  8:23 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2
URL   : https://patchwork.freedesktop.org/series/75956/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
/home/cidrm/kernel/Documentation/gpu/i915.rst:610: WARNING: duplicate label gpu/i915:layout, other instance in /home/cidrm/kernel/Documentation/gpu/i915.rst

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for devm_drm_dev_alloc, v2
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (61 preceding siblings ...)
  (?)
@ 2020-04-15  8:26 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-04-15  8:26 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2
URL   : https://patchwork.freedesktop.org/series/75956/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8298 -> Patchwork_17304
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/index.html

Known issues
------------

  Here are the changes found in Patchwork_17304 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live@execlists:
    - fi-cml-s:           [PASS][1] -> [DMESG-FAIL][2] ([i915#1314])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/fi-cml-s/igt@i915_selftest@live@execlists.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/fi-cml-s/igt@i915_selftest@live@execlists.html

  
  [i915#1314]: https://gitlab.freedesktop.org/drm/intel/issues/1314


Participating hosts (48 -> 44)
------------------------------

  Missing    (4): fi-byt-clapper fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8298 -> Patchwork_17304

  CI-20190529: 20190529
  CI_DRM_8298: 17f82f0c2857d0b442adbdb62eb44b61d0f5b775 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5589: 31962324ac86f029e2841e56e97c42cf9d572956 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17304: 6b267f98398f217419dc7403a953f518eec588bb @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

6b267f98398f drm/bochs: Remove explicit drm_connector_register
5952709c16e7 drm/ast: Drop explicit connector register/unregister
212b8f6dd792 drm/ast: Use managed pci functions
61684dca07fb drm/aspeed: Use managed drmm_mode_config_cleanup
b523f58b0844 drm/aspeed: Use devm_drm_dev_alloc
a56dd08b28f5 drm/aspeed: Drop aspeed_gfx->fbdev
7c2ba0190489 drm/arc: Move to drm/tiny
e8d0970f7144 drm/arc: Initialize sim connector before display pipe
4fa14bd8ec30 drm/arc: Inline remaining files
7343df9f4b2a drm/arc: Inline arcpgu_drm_hdmi_init
e52c65463632 drm/arc: Inline arcpgu_crtc.c
eb0ac9ba6f3a drm/arc: Drop fb/crtc check in arc_pgu_update
9bafee34adc8 drm/arc: Convert to drm_simple_kms_pipe_helper
3bf4add3b139 drm/arc: Align with simple pipe helpers
53609c098023 drm/arc: Use drmm_mode_config_cleanup
e44e078a706c drm/arc: Drop surplus connector registration
81aa508f4aac drm/arc: Embedd a drm_connector for sim case
92d815db6627 drm/arc: Embedded a drm_simple_display_pipe
fd487d20d96f drm/arcpgu: Delete arcpgu_priv->fb
e70ff1199986 drm/arcpgu: Stop using drm_device->dev_private
39f1c0136f6e drm/arcpgu: Switch to devm_drm_dev_alloc
7d245271e60f drm/i915: Use devm_drm_dev_alloc
2b17747b4b28 drm/cirrus: Move to drm/tiny
802aadc99e55 drm/cirrus: Don't use drm_device->dev_private
8ed39ba52c56 drm/cirrus: Use devm_drm_dev_alloc
5355459380ce drm/armada: Don't use drm_device->dev_private
83f5dd60daf3 drm/armada: Use devm_drm_dev_alloc
02237e74a9a8 drm/komeda: use devm_drm_dev_alloc
8e70e1e615f0 drm/ingenic: Don't set drm_device->dev_private
31bf3d7b111c drm/ingenic: Use devm_drm_dev_alloc
bdb467714cbb drm/mcde: Don't use drm_device->dev_private
35f8852356ee drm/mcde: Use devm_drm_dev_alloc
0411f1a69999 drm/qxl: Don't use drm_device->dev_private
b2fbca315892 drm/qxl: Use devm_drm_dev_alloc
1014cec142a5 drm/tidss: Delete tidss->saved_state
9bf56784ead7 drm/tidss: Don't use drm_device->dev_private
33f567e43a49 drm/tidss: Use devm_drm_dev_alloc
63ff767c2c59 drm/gm12u320: Don't use drm_device->dev_private
bfc68a9fc2e2 drm/gm12u320: Use devm_drm_dev_alloc
e20dddecfd5b drm/hx8357d: Use devm_drm_dev_alloc
3c13fd8a4e69 drm/ili9225: Use devm_drm_dev_alloc
af4d8bdcb3a4 drm/ili9341: Use devm_drm_dev_alloc
e3ca7bc5481b drm/ili9486: Use devm_drm_dev_alloc
1f6a7e1e8955 drm/mi0283qt: Use devm_drm_dev_alloc
d213eca2bf88 drm/repaper: Use devm_drm_dev_alloc
3e61c483b099 drm/st7586: Use devm_drm_dev_alloc
02f85c25a833 drm/st7735r: Use devm_drm_dev_alloc
a365a06b3054 drm/udl: don't set drm_device->dev_private
45112a7418df drm/udl: Use devm_drm_dev_alloc
a6e0a1a5655e drm/v3d: Delete v3d_dev->pdev
dfc0b2d39bc5 drm/v3d: Delete v3d_dev->dev
d756210a5cc5 drm/v3d: Use devm_drm_dev_alloc
7b30b404310a drm/v3d: Don't set drm_device->dev_private
69867766512b drm/vboxvideo: Use devm_gen_pool_create
6d12b395c7e7 drm/vboxvidoe: use managed pci functions
e45a792091aa drm/vboxvideo: Stop using drm_device->dev_private
ce363797615d drm/vboxvideo: Use devm_drm_dev_alloc
af384be87720 drm/vboxvideo: drop DRM_MTRR_WC #define
fd3a020f5d57 drm: Add devm_drm_dev_alloc macro

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  8:19       ` Daniel Vetter
  (?)
@ 2020-04-15  8:46         ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:46 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 7571 bytes --]



Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>>
>>
>> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
>>> Because it is. Huge congrats to everyone who made this kind of
>>> refactoring happen!
>>
>> Every other week, I felt an urge to send out this patch. Thank you so
>> much, Daniel! There are more candidates for tiny/. They are all <20k
>> LOCs and all we'd have to do is to move their code into a single file.

I meant <20k file size, not LOCs.

>> bochs or arc come into my mind.
> 
> arc I have (later in the series), bochs I feel like is maybe a bit too
> big. I'd put the limit for tiny well below 1kloc including whitespace
> and all that. bochs might be a candidate once we've helperized a few
> more things perhaps.

True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
code, it seems like it has reached an upper bound of what is feasible.

Best regards
Thomas

> 
> btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> -Daniel
> 
>>
>>>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Dave Airlie <airlied@redhat.com>
>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>> Cc: virtualization@lists.linux-foundation.org
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>>
>>> ---
>>>  MAINTAINERS                               |  2 +-
>>>  drivers/gpu/drm/Kconfig                   |  2 --
>>>  drivers/gpu/drm/Makefile                  |  1 -
>>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>>>  drivers/gpu/drm/tiny/Makefile             |  1 +
>>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>>>  8 files changed, 21 insertions(+), 25 deletions(-)
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index 7b3255d96d1d..0a5cf105ee37 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
>>>  S:   Obsolete
>>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
>>> -F:   drivers/gpu/drm/cirrus/
>>> +F:   drivers/gpu/drm/tiny/cirrus.c
>>>
>>>  DRM DRIVER FOR QXL VIRTUAL GPU
>>>  M:   Dave Airlie <airlied@redhat.com>
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 43594978958e..4f4e7fa001c1 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>>>
>>>  source "drivers/gpu/drm/mgag200/Kconfig"
>>>
>>> -source "drivers/gpu/drm/cirrus/Kconfig"
>>> -
>>>  source "drivers/gpu/drm/armada/Kconfig"
>>>
>>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
>>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
>>> index f34d08c83485..2c0e5a7e5953 100644
>>> --- a/drivers/gpu/drm/Makefile
>>> +++ b/drivers/gpu/drm/Makefile
>>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
>>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>>>  obj-$(CONFIG_DRM_V3D)  += v3d/
>>>  obj-$(CONFIG_DRM_VC4)  += vc4/
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>>>  obj-$(CONFIG_DRM_SIS)   += sis/
>>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
>>> deleted file mode 100644
>>> index c6bbd988b0e5..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Kconfig
>>> +++ /dev/null
>>> @@ -1,19 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -config DRM_CIRRUS_QEMU
>>> -     tristate "Cirrus driver for QEMU emulated device"
>>> -     depends on DRM && PCI && MMU
>>> -     select DRM_KMS_HELPER
>>> -     select DRM_GEM_SHMEM_HELPER
>>> -     help
>>> -      This is a KMS driver for emulated cirrus device in qemu.
>>> -      It is *NOT* intended for real cirrus devices. This requires
>>> -      the modesetting userspace X.org driver.
>>> -
>>> -      Cirrus is obsolete, the hardware was designed in the 90ies
>>> -      and can't keep up with todays needs.  More background:
>>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> -
>>> -      Better alternatives are:
>>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
>>> deleted file mode 100644
>>> index 0c1ed3f99725..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Makefile
>>> +++ /dev/null
>>> @@ -1,2 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
>>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
>>> index 4160e74e4751..2b6414f0fa75 100644
>>> --- a/drivers/gpu/drm/tiny/Kconfig
>>> +++ b/drivers/gpu/drm/tiny/Kconfig
>>> @@ -1,5 +1,24 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +config DRM_CIRRUS_QEMU
>>> +     tristate "Cirrus driver for QEMU emulated device"
>>> +     depends on DRM && PCI && MMU
>>> +     select DRM_KMS_HELPER
>>> +     select DRM_GEM_SHMEM_HELPER
>>> +     help
>>> +      This is a KMS driver for emulated cirrus device in qemu.
>>> +      It is *NOT* intended for real cirrus devices. This requires
>>> +      the modesetting userspace X.org driver.
>>> +
>>> +      Cirrus is obsolete, the hardware was designed in the 90ies
>>> +      and can't keep up with todays needs.  More background:
>>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> +
>>> +      Better alternatives are:
>>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> +
>>>  config DRM_GM12U320
>>>       tristate "GM12U320 driver for USB projectors"
>>>       depends on DRM && USB
>>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
>>> index c96ceee71453..6ae4e9e5a35f 100644
>>> --- a/drivers/gpu/drm/tiny/Makefile
>>> +++ b/drivers/gpu/drm/tiny/Makefile
>>> @@ -1,5 +1,6 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
>>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
>>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
>>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
>>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
>>> similarity index 100%
>>> rename from drivers/gpu/drm/cirrus/cirrus.c
>>> rename to drivers/gpu/drm/tiny/cirrus.c
>>>
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:46         ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:46 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 7571 bytes --]



Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>>
>>
>> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
>>> Because it is. Huge congrats to everyone who made this kind of
>>> refactoring happen!
>>
>> Every other week, I felt an urge to send out this patch. Thank you so
>> much, Daniel! There are more candidates for tiny/. They are all <20k
>> LOCs and all we'd have to do is to move their code into a single file.

I meant <20k file size, not LOCs.

>> bochs or arc come into my mind.
> 
> arc I have (later in the series), bochs I feel like is maybe a bit too
> big. I'd put the limit for tiny well below 1kloc including whitespace
> and all that. bochs might be a candidate once we've helperized a few
> more things perhaps.

True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
code, it seems like it has reached an upper bound of what is feasible.

Best regards
Thomas

> 
> btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> -Daniel
> 
>>
>>>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Dave Airlie <airlied@redhat.com>
>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>> Cc: virtualization@lists.linux-foundation.org
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>>
>>> ---
>>>  MAINTAINERS                               |  2 +-
>>>  drivers/gpu/drm/Kconfig                   |  2 --
>>>  drivers/gpu/drm/Makefile                  |  1 -
>>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>>>  drivers/gpu/drm/tiny/Makefile             |  1 +
>>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>>>  8 files changed, 21 insertions(+), 25 deletions(-)
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index 7b3255d96d1d..0a5cf105ee37 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
>>>  S:   Obsolete
>>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
>>> -F:   drivers/gpu/drm/cirrus/
>>> +F:   drivers/gpu/drm/tiny/cirrus.c
>>>
>>>  DRM DRIVER FOR QXL VIRTUAL GPU
>>>  M:   Dave Airlie <airlied@redhat.com>
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 43594978958e..4f4e7fa001c1 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>>>
>>>  source "drivers/gpu/drm/mgag200/Kconfig"
>>>
>>> -source "drivers/gpu/drm/cirrus/Kconfig"
>>> -
>>>  source "drivers/gpu/drm/armada/Kconfig"
>>>
>>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
>>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
>>> index f34d08c83485..2c0e5a7e5953 100644
>>> --- a/drivers/gpu/drm/Makefile
>>> +++ b/drivers/gpu/drm/Makefile
>>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
>>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>>>  obj-$(CONFIG_DRM_V3D)  += v3d/
>>>  obj-$(CONFIG_DRM_VC4)  += vc4/
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>>>  obj-$(CONFIG_DRM_SIS)   += sis/
>>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
>>> deleted file mode 100644
>>> index c6bbd988b0e5..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Kconfig
>>> +++ /dev/null
>>> @@ -1,19 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -config DRM_CIRRUS_QEMU
>>> -     tristate "Cirrus driver for QEMU emulated device"
>>> -     depends on DRM && PCI && MMU
>>> -     select DRM_KMS_HELPER
>>> -     select DRM_GEM_SHMEM_HELPER
>>> -     help
>>> -      This is a KMS driver for emulated cirrus device in qemu.
>>> -      It is *NOT* intended for real cirrus devices. This requires
>>> -      the modesetting userspace X.org driver.
>>> -
>>> -      Cirrus is obsolete, the hardware was designed in the 90ies
>>> -      and can't keep up with todays needs.  More background:
>>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> -
>>> -      Better alternatives are:
>>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
>>> deleted file mode 100644
>>> index 0c1ed3f99725..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Makefile
>>> +++ /dev/null
>>> @@ -1,2 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
>>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
>>> index 4160e74e4751..2b6414f0fa75 100644
>>> --- a/drivers/gpu/drm/tiny/Kconfig
>>> +++ b/drivers/gpu/drm/tiny/Kconfig
>>> @@ -1,5 +1,24 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +config DRM_CIRRUS_QEMU
>>> +     tristate "Cirrus driver for QEMU emulated device"
>>> +     depends on DRM && PCI && MMU
>>> +     select DRM_KMS_HELPER
>>> +     select DRM_GEM_SHMEM_HELPER
>>> +     help
>>> +      This is a KMS driver for emulated cirrus device in qemu.
>>> +      It is *NOT* intended for real cirrus devices. This requires
>>> +      the modesetting userspace X.org driver.
>>> +
>>> +      Cirrus is obsolete, the hardware was designed in the 90ies
>>> +      and can't keep up with todays needs.  More background:
>>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> +
>>> +      Better alternatives are:
>>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> +
>>>  config DRM_GM12U320
>>>       tristate "GM12U320 driver for USB projectors"
>>>       depends on DRM && USB
>>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
>>> index c96ceee71453..6ae4e9e5a35f 100644
>>> --- a/drivers/gpu/drm/tiny/Makefile
>>> +++ b/drivers/gpu/drm/tiny/Makefile
>>> @@ -1,5 +1,6 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
>>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
>>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
>>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
>>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
>>> similarity index 100%
>>> rename from drivers/gpu/drm/cirrus/cirrus.c
>>> rename to drivers/gpu/drm/tiny/cirrus.c
>>>
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  8:46         ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15  8:46 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 7571 bytes --]



Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>>
>>
>> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
>>> Because it is. Huge congrats to everyone who made this kind of
>>> refactoring happen!
>>
>> Every other week, I felt an urge to send out this patch. Thank you so
>> much, Daniel! There are more candidates for tiny/. They are all <20k
>> LOCs and all we'd have to do is to move their code into a single file.

I meant <20k file size, not LOCs.

>> bochs or arc come into my mind.
> 
> arc I have (later in the series), bochs I feel like is maybe a bit too
> big. I'd put the limit for tiny well below 1kloc including whitespace
> and all that. bochs might be a candidate once we've helperized a few
> more things perhaps.

True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
code, it seems like it has reached an upper bound of what is feasible.

Best regards
Thomas

> 
> btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> -Daniel
> 
>>
>>>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Dave Airlie <airlied@redhat.com>
>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>> Cc: virtualization@lists.linux-foundation.org
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>>
>>> ---
>>>  MAINTAINERS                               |  2 +-
>>>  drivers/gpu/drm/Kconfig                   |  2 --
>>>  drivers/gpu/drm/Makefile                  |  1 -
>>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>>>  drivers/gpu/drm/tiny/Makefile             |  1 +
>>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>>>  8 files changed, 21 insertions(+), 25 deletions(-)
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index 7b3255d96d1d..0a5cf105ee37 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
>>>  S:   Obsolete
>>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
>>> -F:   drivers/gpu/drm/cirrus/
>>> +F:   drivers/gpu/drm/tiny/cirrus.c
>>>
>>>  DRM DRIVER FOR QXL VIRTUAL GPU
>>>  M:   Dave Airlie <airlied@redhat.com>
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 43594978958e..4f4e7fa001c1 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>>>
>>>  source "drivers/gpu/drm/mgag200/Kconfig"
>>>
>>> -source "drivers/gpu/drm/cirrus/Kconfig"
>>> -
>>>  source "drivers/gpu/drm/armada/Kconfig"
>>>
>>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
>>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
>>> index f34d08c83485..2c0e5a7e5953 100644
>>> --- a/drivers/gpu/drm/Makefile
>>> +++ b/drivers/gpu/drm/Makefile
>>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
>>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>>>  obj-$(CONFIG_DRM_V3D)  += v3d/
>>>  obj-$(CONFIG_DRM_VC4)  += vc4/
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>>>  obj-$(CONFIG_DRM_SIS)   += sis/
>>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
>>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
>>> deleted file mode 100644
>>> index c6bbd988b0e5..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Kconfig
>>> +++ /dev/null
>>> @@ -1,19 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -config DRM_CIRRUS_QEMU
>>> -     tristate "Cirrus driver for QEMU emulated device"
>>> -     depends on DRM && PCI && MMU
>>> -     select DRM_KMS_HELPER
>>> -     select DRM_GEM_SHMEM_HELPER
>>> -     help
>>> -      This is a KMS driver for emulated cirrus device in qemu.
>>> -      It is *NOT* intended for real cirrus devices. This requires
>>> -      the modesetting userspace X.org driver.
>>> -
>>> -      Cirrus is obsolete, the hardware was designed in the 90ies
>>> -      and can't keep up with todays needs.  More background:
>>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> -
>>> -      Better alternatives are:
>>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
>>> deleted file mode 100644
>>> index 0c1ed3f99725..000000000000
>>> --- a/drivers/gpu/drm/cirrus/Makefile
>>> +++ /dev/null
>>> @@ -1,2 +0,0 @@
>>> -# SPDX-License-Identifier: GPL-2.0-only
>>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
>>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
>>> index 4160e74e4751..2b6414f0fa75 100644
>>> --- a/drivers/gpu/drm/tiny/Kconfig
>>> +++ b/drivers/gpu/drm/tiny/Kconfig
>>> @@ -1,5 +1,24 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +config DRM_CIRRUS_QEMU
>>> +     tristate "Cirrus driver for QEMU emulated device"
>>> +     depends on DRM && PCI && MMU
>>> +     select DRM_KMS_HELPER
>>> +     select DRM_GEM_SHMEM_HELPER
>>> +     help
>>> +      This is a KMS driver for emulated cirrus device in qemu.
>>> +      It is *NOT* intended for real cirrus devices. This requires
>>> +      the modesetting userspace X.org driver.
>>> +
>>> +      Cirrus is obsolete, the hardware was designed in the 90ies
>>> +      and can't keep up with todays needs.  More background:
>>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>>> +
>>> +      Better alternatives are:
>>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
>>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
>>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
>>> +
>>>  config DRM_GM12U320
>>>       tristate "GM12U320 driver for USB projectors"
>>>       depends on DRM && USB
>>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
>>> index c96ceee71453..6ae4e9e5a35f 100644
>>> --- a/drivers/gpu/drm/tiny/Makefile
>>> +++ b/drivers/gpu/drm/tiny/Makefile
>>> @@ -1,5 +1,6 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>
>>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
>>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
>>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
>>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
>>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
>>> similarity index 100%
>>> rename from drivers/gpu/drm/cirrus/cirrus.c
>>> rename to drivers/gpu/drm/tiny/cirrus.c
>>>
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  8:46         ` Thomas Zimmermann
  (?)
@ 2020-04-15  9:31           ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  9:31 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:46 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> > On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >>
> >>
> >>
> >> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> >>> Because it is. Huge congrats to everyone who made this kind of
> >>> refactoring happen!
> >>
> >> Every other week, I felt an urge to send out this patch. Thank you so
> >> much, Daniel! There are more candidates for tiny/. They are all <20k
> >> LOCs and all we'd have to do is to move their code into a single file.
>
> I meant <20k file size, not LOCs.
>
> >> bochs or arc come into my mind.
> >
> > arc I have (later in the series), bochs I feel like is maybe a bit too
> > big. I'd put the limit for tiny well below 1kloc including whitespace
> > and all that. bochs might be a candidate once we've helperized a few
> > more things perhaps.
>
> True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
> code, it seems like it has reached an upper bound of what is feasible.

Yeah, and I think the trouble there is that it contains an
epaper-specific panel abstraction. I think that's pushing it over the
edge. I think we've talked about subclassing drm_panel with
bus/device-specific stuff, that might be an option if this gets out of
hand.

Also I think we should be much stricter with putting drivers into
tiny/ than moving them out. Just so we avoid endless ping-pong, e.g.
for drivers that I can't make really tiny I wont bother with moving
them to tiny/
-Daniel

>
> Best regards
> Thomas
>
> >
> > btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> > -Daniel
> >
> >>
> >>>
> >>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> >>> Cc: Dave Airlie <airlied@redhat.com>
> >>> Cc: Gerd Hoffmann <kraxel@redhat.com>
> >>> Cc: virtualization@lists.linux-foundation.org
> >>
> >> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> >>
> >>> ---
> >>>  MAINTAINERS                               |  2 +-
> >>>  drivers/gpu/drm/Kconfig                   |  2 --
> >>>  drivers/gpu/drm/Makefile                  |  1 -
> >>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >>>  drivers/gpu/drm/tiny/Makefile             |  1 +
> >>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >>>  8 files changed, 21 insertions(+), 25 deletions(-)
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >>>
> >>> diff --git a/MAINTAINERS b/MAINTAINERS
> >>> index 7b3255d96d1d..0a5cf105ee37 100644
> >>> --- a/MAINTAINERS
> >>> +++ b/MAINTAINERS
> >>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >>>  S:   Obsolete
> >>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
> >>> -F:   drivers/gpu/drm/cirrus/
> >>> +F:   drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>>  DRM DRIVER FOR QXL VIRTUAL GPU
> >>>  M:   Dave Airlie <airlied@redhat.com>
> >>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> >>> index 43594978958e..4f4e7fa001c1 100644
> >>> --- a/drivers/gpu/drm/Kconfig
> >>> +++ b/drivers/gpu/drm/Kconfig
> >>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/mgag200/Kconfig"
> >>>
> >>> -source "drivers/gpu/drm/cirrus/Kconfig"
> >>> -
> >>>  source "drivers/gpu/drm/armada/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> >>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> >>> index f34d08c83485..2c0e5a7e5953 100644
> >>> --- a/drivers/gpu/drm/Makefile
> >>> +++ b/drivers/gpu/drm/Makefile
> >>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >>>  obj-$(CONFIG_DRM_V3D)  += v3d/
> >>>  obj-$(CONFIG_DRM_VC4)  += vc4/
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >>>  obj-$(CONFIG_DRM_SIS)   += sis/
> >>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> >>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> >>> deleted file mode 100644
> >>> index c6bbd988b0e5..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Kconfig
> >>> +++ /dev/null
> >>> @@ -1,19 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -config DRM_CIRRUS_QEMU
> >>> -     tristate "Cirrus driver for QEMU emulated device"
> >>> -     depends on DRM && PCI && MMU
> >>> -     select DRM_KMS_HELPER
> >>> -     select DRM_GEM_SHMEM_HELPER
> >>> -     help
> >>> -      This is a KMS driver for emulated cirrus device in qemu.
> >>> -      It is *NOT* intended for real cirrus devices. This requires
> >>> -      the modesetting userspace X.org driver.
> >>> -
> >>> -      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> -      and can't keep up with todays needs.  More background:
> >>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> -
> >>> -      Better alternatives are:
> >>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> >>> deleted file mode 100644
> >>> index 0c1ed3f99725..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Makefile
> >>> +++ /dev/null
> >>> @@ -1,2 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> >>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> >>> index 4160e74e4751..2b6414f0fa75 100644
> >>> --- a/drivers/gpu/drm/tiny/Kconfig
> >>> +++ b/drivers/gpu/drm/tiny/Kconfig
> >>> @@ -1,5 +1,24 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +config DRM_CIRRUS_QEMU
> >>> +     tristate "Cirrus driver for QEMU emulated device"
> >>> +     depends on DRM && PCI && MMU
> >>> +     select DRM_KMS_HELPER
> >>> +     select DRM_GEM_SHMEM_HELPER
> >>> +     help
> >>> +      This is a KMS driver for emulated cirrus device in qemu.
> >>> +      It is *NOT* intended for real cirrus devices. This requires
> >>> +      the modesetting userspace X.org driver.
> >>> +
> >>> +      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> +      and can't keep up with todays needs.  More background:
> >>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> +
> >>> +      Better alternatives are:
> >>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> +
> >>>  config DRM_GM12U320
> >>>       tristate "GM12U320 driver for USB projectors"
> >>>       depends on DRM && USB
> >>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> >>> index c96ceee71453..6ae4e9e5a35f 100644
> >>> --- a/drivers/gpu/drm/tiny/Makefile
> >>> +++ b/drivers/gpu/drm/tiny/Makefile
> >>> @@ -1,5 +1,6 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> >>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> >>> similarity index 100%
> >>> rename from drivers/gpu/drm/cirrus/cirrus.c
> >>> rename to drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>
> >> --
> >> Thomas Zimmermann
> >> Graphics Driver Developer
> >> SUSE Software Solutions Germany GmbH
> >> Maxfeldstr. 5, 90409 Nürnberg, Germany
> >> (HRB 36809, AG Nürnberg)
> >> Geschäftsführer: Felix Imendörffer
> >>
> >
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  9:31           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  9:31 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:46 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> > On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >>
> >>
> >>
> >> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> >>> Because it is. Huge congrats to everyone who made this kind of
> >>> refactoring happen!
> >>
> >> Every other week, I felt an urge to send out this patch. Thank you so
> >> much, Daniel! There are more candidates for tiny/. They are all <20k
> >> LOCs and all we'd have to do is to move their code into a single file.
>
> I meant <20k file size, not LOCs.
>
> >> bochs or arc come into my mind.
> >
> > arc I have (later in the series), bochs I feel like is maybe a bit too
> > big. I'd put the limit for tiny well below 1kloc including whitespace
> > and all that. bochs might be a candidate once we've helperized a few
> > more things perhaps.
>
> True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
> code, it seems like it has reached an upper bound of what is feasible.

Yeah, and I think the trouble there is that it contains an
epaper-specific panel abstraction. I think that's pushing it over the
edge. I think we've talked about subclassing drm_panel with
bus/device-specific stuff, that might be an option if this gets out of
hand.

Also I think we should be much stricter with putting drivers into
tiny/ than moving them out. Just so we avoid endless ping-pong, e.g.
for drivers that I can't make really tiny I wont bother with moving
them to tiny/
-Daniel

>
> Best regards
> Thomas
>
> >
> > btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> > -Daniel
> >
> >>
> >>>
> >>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> >>> Cc: Dave Airlie <airlied@redhat.com>
> >>> Cc: Gerd Hoffmann <kraxel@redhat.com>
> >>> Cc: virtualization@lists.linux-foundation.org
> >>
> >> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> >>
> >>> ---
> >>>  MAINTAINERS                               |  2 +-
> >>>  drivers/gpu/drm/Kconfig                   |  2 --
> >>>  drivers/gpu/drm/Makefile                  |  1 -
> >>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >>>  drivers/gpu/drm/tiny/Makefile             |  1 +
> >>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >>>  8 files changed, 21 insertions(+), 25 deletions(-)
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >>>
> >>> diff --git a/MAINTAINERS b/MAINTAINERS
> >>> index 7b3255d96d1d..0a5cf105ee37 100644
> >>> --- a/MAINTAINERS
> >>> +++ b/MAINTAINERS
> >>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >>>  S:   Obsolete
> >>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
> >>> -F:   drivers/gpu/drm/cirrus/
> >>> +F:   drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>>  DRM DRIVER FOR QXL VIRTUAL GPU
> >>>  M:   Dave Airlie <airlied@redhat.com>
> >>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> >>> index 43594978958e..4f4e7fa001c1 100644
> >>> --- a/drivers/gpu/drm/Kconfig
> >>> +++ b/drivers/gpu/drm/Kconfig
> >>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/mgag200/Kconfig"
> >>>
> >>> -source "drivers/gpu/drm/cirrus/Kconfig"
> >>> -
> >>>  source "drivers/gpu/drm/armada/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> >>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> >>> index f34d08c83485..2c0e5a7e5953 100644
> >>> --- a/drivers/gpu/drm/Makefile
> >>> +++ b/drivers/gpu/drm/Makefile
> >>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >>>  obj-$(CONFIG_DRM_V3D)  += v3d/
> >>>  obj-$(CONFIG_DRM_VC4)  += vc4/
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >>>  obj-$(CONFIG_DRM_SIS)   += sis/
> >>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> >>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> >>> deleted file mode 100644
> >>> index c6bbd988b0e5..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Kconfig
> >>> +++ /dev/null
> >>> @@ -1,19 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -config DRM_CIRRUS_QEMU
> >>> -     tristate "Cirrus driver for QEMU emulated device"
> >>> -     depends on DRM && PCI && MMU
> >>> -     select DRM_KMS_HELPER
> >>> -     select DRM_GEM_SHMEM_HELPER
> >>> -     help
> >>> -      This is a KMS driver for emulated cirrus device in qemu.
> >>> -      It is *NOT* intended for real cirrus devices. This requires
> >>> -      the modesetting userspace X.org driver.
> >>> -
> >>> -      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> -      and can't keep up with todays needs.  More background:
> >>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> -
> >>> -      Better alternatives are:
> >>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> >>> deleted file mode 100644
> >>> index 0c1ed3f99725..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Makefile
> >>> +++ /dev/null
> >>> @@ -1,2 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> >>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> >>> index 4160e74e4751..2b6414f0fa75 100644
> >>> --- a/drivers/gpu/drm/tiny/Kconfig
> >>> +++ b/drivers/gpu/drm/tiny/Kconfig
> >>> @@ -1,5 +1,24 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +config DRM_CIRRUS_QEMU
> >>> +     tristate "Cirrus driver for QEMU emulated device"
> >>> +     depends on DRM && PCI && MMU
> >>> +     select DRM_KMS_HELPER
> >>> +     select DRM_GEM_SHMEM_HELPER
> >>> +     help
> >>> +      This is a KMS driver for emulated cirrus device in qemu.
> >>> +      It is *NOT* intended for real cirrus devices. This requires
> >>> +      the modesetting userspace X.org driver.
> >>> +
> >>> +      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> +      and can't keep up with todays needs.  More background:
> >>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> +
> >>> +      Better alternatives are:
> >>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> +
> >>>  config DRM_GM12U320
> >>>       tristate "GM12U320 driver for USB projectors"
> >>>       depends on DRM && USB
> >>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> >>> index c96ceee71453..6ae4e9e5a35f 100644
> >>> --- a/drivers/gpu/drm/tiny/Makefile
> >>> +++ b/drivers/gpu/drm/tiny/Makefile
> >>> @@ -1,5 +1,6 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> >>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> >>> similarity index 100%
> >>> rename from drivers/gpu/drm/cirrus/cirrus.c
> >>> rename to drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>
> >> --
> >> Thomas Zimmermann
> >> Graphics Driver Developer
> >> SUSE Software Solutions Germany GmbH
> >> Maxfeldstr. 5, 90409 Nürnberg, Germany
> >> (HRB 36809, AG Nürnberg)
> >> Geschäftsführer: Felix Imendörffer
> >>
> >
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-15  9:31           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15  9:31 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development,
	open list:VIRTIO CORE, NET...,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 10:46 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
>
>
> Am 15.04.20 um 10:19 schrieb Daniel Vetter:
> > On Wed, Apr 15, 2020 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >>
> >>
> >>
> >> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> >>> Because it is. Huge congrats to everyone who made this kind of
> >>> refactoring happen!
> >>
> >> Every other week, I felt an urge to send out this patch. Thank you so
> >> much, Daniel! There are more candidates for tiny/. They are all <20k
> >> LOCs and all we'd have to do is to move their code into a single file.
>
> I meant <20k file size, not LOCs.
>
> >> bochs or arc come into my mind.
> >
> > arc I have (later in the series), bochs I feel like is maybe a bit too
> > big. I'd put the limit for tiny well below 1kloc including whitespace
> > and all that. bochs might be a candidate once we've helperized a few
> > more things perhaps.
>
> True. The largest tiny driver is repaper with ~1.1k LOCS. Reading this
> code, it seems like it has reached an upper bound of what is feasible.

Yeah, and I think the trouble there is that it contains an
epaper-specific panel abstraction. I think that's pushing it over the
edge. I think we've talked about subclassing drm_panel with
bus/device-specific stuff, that might be an option if this gets out of
hand.

Also I think we should be much stricter with putting drivers into
tiny/ than moving them out. Just so we avoid endless ping-pong, e.g.
for drivers that I can't make really tiny I wont bother with moving
them to tiny/
-Daniel

>
> Best regards
> Thomas
>
> >
> > btw I drmm_ version of vram helpers would help a bunch of these drivers I think.
> > -Daniel
> >
> >>
> >>>
> >>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> >>> Cc: Dave Airlie <airlied@redhat.com>
> >>> Cc: Gerd Hoffmann <kraxel@redhat.com>
> >>> Cc: virtualization@lists.linux-foundation.org
> >>
> >> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> >>
> >>> ---
> >>>  MAINTAINERS                               |  2 +-
> >>>  drivers/gpu/drm/Kconfig                   |  2 --
> >>>  drivers/gpu/drm/Makefile                  |  1 -
> >>>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
> >>>  drivers/gpu/drm/cirrus/Makefile           |  2 --
> >>>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
> >>>  drivers/gpu/drm/tiny/Makefile             |  1 +
> >>>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
> >>>  8 files changed, 21 insertions(+), 25 deletions(-)
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
> >>>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
> >>>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> >>>
> >>> diff --git a/MAINTAINERS b/MAINTAINERS
> >>> index 7b3255d96d1d..0a5cf105ee37 100644
> >>> --- a/MAINTAINERS
> >>> +++ b/MAINTAINERS
> >>> @@ -5397,7 +5397,7 @@ L:      virtualization@lists.linux-foundation.org
> >>>  S:   Obsolete
> >>>  W:   https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>>  T:   git git://anongit.freedesktop.org/drm/drm-misc
> >>> -F:   drivers/gpu/drm/cirrus/
> >>> +F:   drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>>  DRM DRIVER FOR QXL VIRTUAL GPU
> >>>  M:   Dave Airlie <airlied@redhat.com>
> >>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> >>> index 43594978958e..4f4e7fa001c1 100644
> >>> --- a/drivers/gpu/drm/Kconfig
> >>> +++ b/drivers/gpu/drm/Kconfig
> >>> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/mgag200/Kconfig"
> >>>
> >>> -source "drivers/gpu/drm/cirrus/Kconfig"
> >>> -
> >>>  source "drivers/gpu/drm/armada/Kconfig"
> >>>
> >>>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> >>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> >>> index f34d08c83485..2c0e5a7e5953 100644
> >>> --- a/drivers/gpu/drm/Makefile
> >>> +++ b/drivers/gpu/drm/Makefile
> >>> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)      += i915/
> >>>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
> >>>  obj-$(CONFIG_DRM_V3D)  += v3d/
> >>>  obj-$(CONFIG_DRM_VC4)  += vc4/
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
> >>>  obj-$(CONFIG_DRM_SIS)   += sis/
> >>>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
> >>>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> >>> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> >>> deleted file mode 100644
> >>> index c6bbd988b0e5..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Kconfig
> >>> +++ /dev/null
> >>> @@ -1,19 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -config DRM_CIRRUS_QEMU
> >>> -     tristate "Cirrus driver for QEMU emulated device"
> >>> -     depends on DRM && PCI && MMU
> >>> -     select DRM_KMS_HELPER
> >>> -     select DRM_GEM_SHMEM_HELPER
> >>> -     help
> >>> -      This is a KMS driver for emulated cirrus device in qemu.
> >>> -      It is *NOT* intended for real cirrus devices. This requires
> >>> -      the modesetting userspace X.org driver.
> >>> -
> >>> -      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> -      and can't keep up with todays needs.  More background:
> >>> -      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> -
> >>> -      Better alternatives are:
> >>> -        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> -        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> -        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> >>> deleted file mode 100644
> >>> index 0c1ed3f99725..000000000000
> >>> --- a/drivers/gpu/drm/cirrus/Makefile
> >>> +++ /dev/null
> >>> @@ -1,2 +0,0 @@
> >>> -# SPDX-License-Identifier: GPL-2.0-only
> >>> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> >>> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> >>> index 4160e74e4751..2b6414f0fa75 100644
> >>> --- a/drivers/gpu/drm/tiny/Kconfig
> >>> +++ b/drivers/gpu/drm/tiny/Kconfig
> >>> @@ -1,5 +1,24 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +config DRM_CIRRUS_QEMU
> >>> +     tristate "Cirrus driver for QEMU emulated device"
> >>> +     depends on DRM && PCI && MMU
> >>> +     select DRM_KMS_HELPER
> >>> +     select DRM_GEM_SHMEM_HELPER
> >>> +     help
> >>> +      This is a KMS driver for emulated cirrus device in qemu.
> >>> +      It is *NOT* intended for real cirrus devices. This requires
> >>> +      the modesetting userspace X.org driver.
> >>> +
> >>> +      Cirrus is obsolete, the hardware was designed in the 90ies
> >>> +      and can't keep up with todays needs.  More background:
> >>> +      https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> >>> +
> >>> +      Better alternatives are:
> >>> +        - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> >>> +        - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> >>> +        - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> >>> +
> >>>  config DRM_GM12U320
> >>>       tristate "GM12U320 driver for USB projectors"
> >>>       depends on DRM && USB
> >>> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> >>> index c96ceee71453..6ae4e9e5a35f 100644
> >>> --- a/drivers/gpu/drm/tiny/Makefile
> >>> +++ b/drivers/gpu/drm/tiny/Makefile
> >>> @@ -1,5 +1,6 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>
> >>> +obj-$(CONFIG_DRM_CIRRUS_QEMU)                += cirrus.o
> >>>  obj-$(CONFIG_DRM_GM12U320)           += gm12u320.o
> >>>  obj-$(CONFIG_TINYDRM_HX8357D)                += hx8357d.o
> >>>  obj-$(CONFIG_TINYDRM_ILI9225)                += ili9225.o
> >>> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> >>> similarity index 100%
> >>> rename from drivers/gpu/drm/cirrus/cirrus.c
> >>> rename to drivers/gpu/drm/tiny/cirrus.c
> >>>
> >>
> >> --
> >> Thomas Zimmermann
> >> Graphics Driver Developer
> >> SUSE Software Solutions Germany GmbH
> >> Maxfeldstr. 5, 90409 Nürnberg, Germany
> >> (HRB 36809, AG Nürnberg)
> >> Geschäftsführer: Felix Imendörffer
> >>
> >
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15  9:45     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-15  9:45 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.
On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> Because it is.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> ---
>  MAINTAINERS                                         |  2 +-
>  drivers/gpu/drm/Kconfig                             |  2 --
>  drivers/gpu/drm/Makefile                            |  1 -
>  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
>  drivers/gpu/drm/arc/Makefile                        |  3 ---
>  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
>  drivers/gpu/drm/tiny/Makefile                       |  1 +
>  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
>  8 files changed, 12 insertions(+), 17 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/Kconfig
>  delete mode 100644 drivers/gpu/drm/arc/Makefile
>  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)

We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
adds another platform driver to drm/arc/
This speaks against the move to tiny IMO

	Sam

> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0a5cf105ee37..748244b1625b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
>  M:	Alexey Brodkin <abrodkin@synopsys.com>
>  S:	Supported
>  F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
> -F:	drivers/gpu/drm/arc/
> +F:	drivers/gpu/drm/tiny/arcpgu.c
>  
>  ARCNET NETWORK LAYER
>  M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 4f4e7fa001c1..a0a89025d6fa 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
>  
>  source "drivers/gpu/drm/etnaviv/Kconfig"
>  
> -source "drivers/gpu/drm/arc/Kconfig"
> -
>  source "drivers/gpu/drm/hisilicon/Kconfig"
>  
>  source "drivers/gpu/drm/mediatek/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 2c0e5a7e5953..e69eafbf9e39 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -109,7 +109,6 @@ obj-y			+= panel/
>  obj-y			+= bridge/
>  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
>  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> -obj-$(CONFIG_DRM_ARCPGU)+= arc/
>  obj-y			+= hisilicon/
>  obj-$(CONFIG_DRM_ZTE)	+= zte/
>  obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
> diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> deleted file mode 100644
> index e8f3d63e0b91..000000000000
> --- a/drivers/gpu/drm/arc/Kconfig
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_ARCPGU
> -	tristate "ARC PGU"
> -	depends on DRM && OF
> -	select DRM_KMS_CMA_HELPER
> -	select DRM_KMS_HELPER
> -	help
> -	  Choose this option if you have an ARC PGU controller.
> -
> -	  If M is selected the module will be called arcpgu.
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> deleted file mode 100644
> index b26f2495c532..000000000000
> --- a/drivers/gpu/drm/arc/Makefile
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_drv.o
> -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 2b6414f0fa75..9bbaa1a69050 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,15 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_ARCPGU
> +	tristate "ARC PGU"
> +	depends on DRM && OF
> +	select DRM_KMS_CMA_HELPER
> +	select DRM_KMS_HELPER
> +	help
> +	  Choose this option if you have an ARC PGU controller.
> +
> +	  If M is selected the module will be called arcpgu.
> +
>  config DRM_CIRRUS_QEMU
>  	tristate "Cirrus driver for QEMU emulated device"
>  	depends on DRM && PCI && MMU
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index 6ae4e9e5a35f..bef6780bdd6f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
>  obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> similarity index 100%
> rename from drivers/gpu/drm/arc/arcpgu_drv.c
> rename to drivers/gpu/drm/tiny/arcpgu.c
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15  9:45     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-15  9:45 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.
On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> Because it is.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> ---
>  MAINTAINERS                                         |  2 +-
>  drivers/gpu/drm/Kconfig                             |  2 --
>  drivers/gpu/drm/Makefile                            |  1 -
>  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
>  drivers/gpu/drm/arc/Makefile                        |  3 ---
>  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
>  drivers/gpu/drm/tiny/Makefile                       |  1 +
>  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
>  8 files changed, 12 insertions(+), 17 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/Kconfig
>  delete mode 100644 drivers/gpu/drm/arc/Makefile
>  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)

We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
adds another platform driver to drm/arc/
This speaks against the move to tiny IMO

	Sam

> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0a5cf105ee37..748244b1625b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1295,7 +1295,7 @@ ARC PGU DRM DRIVER
>  M:	Alexey Brodkin <abrodkin@synopsys.com>
>  S:	Supported
>  F:	Documentation/devicetree/bindings/display/snps,arcpgu.txt
> -F:	drivers/gpu/drm/arc/
> +F:	drivers/gpu/drm/tiny/arcpgu.c
>  
>  ARCNET NETWORK LAYER
>  M:	Michael Grzeschik <m.grzeschik@pengutronix.de>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 4f4e7fa001c1..a0a89025d6fa 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -354,8 +354,6 @@ source "drivers/gpu/drm/vc4/Kconfig"
>  
>  source "drivers/gpu/drm/etnaviv/Kconfig"
>  
> -source "drivers/gpu/drm/arc/Kconfig"
> -
>  source "drivers/gpu/drm/hisilicon/Kconfig"
>  
>  source "drivers/gpu/drm/mediatek/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 2c0e5a7e5953..e69eafbf9e39 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -109,7 +109,6 @@ obj-y			+= panel/
>  obj-y			+= bridge/
>  obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
>  obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
> -obj-$(CONFIG_DRM_ARCPGU)+= arc/
>  obj-y			+= hisilicon/
>  obj-$(CONFIG_DRM_ZTE)	+= zte/
>  obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
> diff --git a/drivers/gpu/drm/arc/Kconfig b/drivers/gpu/drm/arc/Kconfig
> deleted file mode 100644
> index e8f3d63e0b91..000000000000
> --- a/drivers/gpu/drm/arc/Kconfig
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_ARCPGU
> -	tristate "ARC PGU"
> -	depends on DRM && OF
> -	select DRM_KMS_CMA_HELPER
> -	select DRM_KMS_HELPER
> -	help
> -	  Choose this option if you have an ARC PGU controller.
> -
> -	  If M is selected the module will be called arcpgu.
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> deleted file mode 100644
> index b26f2495c532..000000000000
> --- a/drivers/gpu/drm/arc/Makefile
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_drv.o
> -obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 2b6414f0fa75..9bbaa1a69050 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,15 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_ARCPGU
> +	tristate "ARC PGU"
> +	depends on DRM && OF
> +	select DRM_KMS_CMA_HELPER
> +	select DRM_KMS_HELPER
> +	help
> +	  Choose this option if you have an ARC PGU controller.
> +
> +	  If M is selected the module will be called arcpgu.
> +
>  config DRM_CIRRUS_QEMU
>  	tristate "Cirrus driver for QEMU emulated device"
>  	depends on DRM && PCI && MMU
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index 6ae4e9e5a35f..bef6780bdd6f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_ARCPGU)		+= arcpgu.o
>  obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/tiny/arcpgu.c
> similarity index 100%
> rename from drivers/gpu/drm/arc/arcpgu_drv.c
> rename to drivers/gpu/drm/tiny/arcpgu.c
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* RE: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15  9:45     ` [Intel-gfx] " Sam Ravnborg
@ 2020-04-15 12:02       ` Alexey Brodkin
  -1 siblings, 0 replies; 317+ messages in thread
From: Alexey Brodkin @ 2020-04-15 12:02 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

Hi Daniel,

> -----Original Message-----
> From: Sam Ravnborg <sam@ravnborg.org>
> Sent: Wednesday, April 15, 2020 12:45 PM
> To: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> <daniel.vetter@intel.com>
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> 
> Hi Daniel.
> On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > Because it is.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > ---
> >  MAINTAINERS                                         |  2 +-
> >  drivers/gpu/drm/Kconfig                             |  2 --
> >  drivers/gpu/drm/Makefile                            |  1 -
> >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> >  8 files changed, 12 insertions(+), 17 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> 
> We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> adds another platform driver to drm/arc/
> This speaks against the move to tiny IMO

Indeed that's an interesting question, see v3 series here:
https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html

BTW should I pull that series in my tree and send you a pull-request
or that kind of change needs to go through another tree?

Also I'd like to test the change we discuss here to make sure stuff
still works. Once we do that I'll send an update. Any hint on
when that change needs to be acked/nacked?

-Alexey 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15 12:02       ` Alexey Brodkin
  0 siblings, 0 replies; 317+ messages in thread
From: Alexey Brodkin @ 2020-04-15 12:02 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

Hi Daniel,

> -----Original Message-----
> From: Sam Ravnborg <sam@ravnborg.org>
> Sent: Wednesday, April 15, 2020 12:45 PM
> To: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> <daniel.vetter@intel.com>
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> 
> Hi Daniel.
> On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > Because it is.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > ---
> >  MAINTAINERS                                         |  2 +-
> >  drivers/gpu/drm/Kconfig                             |  2 --
> >  drivers/gpu/drm/Makefile                            |  1 -
> >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> >  8 files changed, 12 insertions(+), 17 deletions(-)
> >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> 
> We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> adds another platform driver to drm/arc/
> This speaks against the move to tiny IMO

Indeed that's an interesting question, see v3 series here:
https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html

BTW should I pull that series in my tree and send you a pull-request
or that kind of change needs to go through another tree?

Also I'd like to test the change we discuss here to make sure stuff
still works. Once we do that I'll send an update. Any hint on
when that change needs to be acked/nacked?

-Alexey 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15 12:02       ` [Intel-gfx] " Alexey Brodkin
@ 2020-04-15 12:20         ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 12:20 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Wed, Apr 15, 2020 at 2:03 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Daniel,
>
> > -----Original Message-----
> > From: Sam Ravnborg <sam@ravnborg.org>
> > Sent: Wednesday, April 15, 2020 12:45 PM
> > To: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> > <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> > <daniel.vetter@intel.com>
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Daniel.
> > On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > > Because it is.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > ---
> > >  MAINTAINERS                                         |  2 +-
> > >  drivers/gpu/drm/Kconfig                             |  2 --
> > >  drivers/gpu/drm/Makefile                            |  1 -
> > >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> > >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> > >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> > >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> > >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> > >  8 files changed, 12 insertions(+), 17 deletions(-)
> > >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> > >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> > >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> >
> > We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> > adds another platform driver to drm/arc/
> > This speaks against the move to tiny IMO
>
> Indeed that's an interesting question, see v3 series here:
> https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html

Looking at this patch series, feels a bit like hand-rolling of bridge
code, badly. We should get away from that.

Once you have that I think the end result is tiny enough that it can
stay, bridges intergrate quite well into simple display pipe drivers.

> BTW should I pull that series in my tree and send you a pull-request
> or that kind of change needs to go through another tree?
>
> Also I'd like to test the change we discuss here to make sure stuff
> still works. Once we do that I'll send an update. Any hint on
> when that change needs to be acked/nacked?

Simplest is if this can all land through drm-misc, is arc not
maintained in there? And there's plenty of time for testing, I'm just
slowly crawling through the tree to get everything polished and
cleaned up in this area.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-15 12:20         ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 12:20 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Wed, Apr 15, 2020 at 2:03 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Daniel,
>
> > -----Original Message-----
> > From: Sam Ravnborg <sam@ravnborg.org>
> > Sent: Wednesday, April 15, 2020 12:45 PM
> > To: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> > <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> > <daniel.vetter@intel.com>
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Daniel.
> > On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > > Because it is.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > ---
> > >  MAINTAINERS                                         |  2 +-
> > >  drivers/gpu/drm/Kconfig                             |  2 --
> > >  drivers/gpu/drm/Makefile                            |  1 -
> > >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> > >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> > >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> > >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> > >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> > >  8 files changed, 12 insertions(+), 17 deletions(-)
> > >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> > >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> > >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> >
> > We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> > adds another platform driver to drm/arc/
> > This speaks against the move to tiny IMO
>
> Indeed that's an interesting question, see v3 series here:
> https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html

Looking at this patch series, feels a bit like hand-rolling of bridge
code, badly. We should get away from that.

Once you have that I think the end result is tiny enough that it can
stay, bridges intergrate quite well into simple display pipe drivers.

> BTW should I pull that series in my tree and send you a pull-request
> or that kind of change needs to go through another tree?
>
> Also I'd like to test the change we discuss here to make sure stuff
> still works. Once we do that I'll send an update. Any hint on
> when that change needs to be acked/nacked?

Simplest is if this can all land through drm-misc, is arc not
maintained in there? And there's plenty of time for testing, I'm just
slowly crawling through the tree to get everything polished and
cleaned up in this area.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 12:20     ` Linus Walleij
  -1 siblings, 0 replies; 317+ messages in thread
From: Linus Walleij @ 2020-04-15 12:20 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg, DRI Development

On Wed, Apr 15, 2020 at 9:41 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

> Already using devm_drm_dev_init, so very simple replacment.
>
> v2: Move misplaced double-assignement to next patch (Sam)
>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc
@ 2020-04-15 12:20     ` Linus Walleij
  0 siblings, 0 replies; 317+ messages in thread
From: Linus Walleij @ 2020-04-15 12:20 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg, DRI Development

On Wed, Apr 15, 2020 at 9:41 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

> Already using devm_drm_dev_init, so very simple replacment.
>
> v2: Move misplaced double-assignement to next patch (Sam)
>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  8:17         ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 12:23           ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 12:23 UTC (permalink / raw)
  To: Thomas Zimmermann, Laurent Pinchart
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 10:17 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Wed, Apr 15, 2020 at 10:09 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> >
> > On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> > >
> > > Hi Daniel
> > >
> > > Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > > > Allows us to remove a bit of cleanup code.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Emil Velikov <emil.velikov@collabora.com>
> > > > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > > > Cc: Sam Ravnborg <sam@ravnborg.org>
> > > > Cc: "Christian König" <christian.koenig@amd.com>
> > > > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > > > ---
> > > >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> > > >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> > > >  2 files changed, 3 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > > > index b7ba22dddcad..48a9cc4e080a 100644
> > > > --- a/drivers/gpu/drm/ast/ast_drv.c
> > > > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > > > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >
> > > >       ast_kick_out_firmware_fb(pdev);
> > > >
> > > > -     ret = pci_enable_device(pdev);
> > > > +     ret = pcim_enable_device(pdev);
> > > >       if (ret)
> > > >               return ret;
> > > >
> > > >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > > > -     if (IS_ERR(dev)) {
> > > > -             ret = PTR_ERR(dev);
> > > > -             goto err_pci_disable_device;
> > > > -     }
> > > > +     if (IS_ERR(dev))
> > > > +             return  PTR_ERR(dev);
> > > >
> > > >       dev->pdev = pdev;
> > > >       pci_set_drvdata(pdev, dev);
> > > > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >       ast_driver_unload(dev);
> > > >  err_drm_dev_put:
> > > >       drm_dev_put(dev);
> > > > -err_pci_disable_device:
> > > > -     pci_disable_device(pdev);
> > > >       return ret;
> > > >
> > > >  }
> > > > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > > > index e5398e3dabe7..1b35728ad871 100644
> > > > --- a/drivers/gpu/drm/ast/ast_main.c
> > > > +++ b/drivers/gpu/drm/ast/ast_main.c
> > > > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> > > >       drm_mode_config_cleanup(dev);
> > > >
> > > >       ast_mm_fini(ast);
> > > > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > > > -             pci_iounmap(dev->pdev, ast->ioregs);
> > > > -     pci_iounmap(dev->pdev, ast->regs);
> > >
> > > This gets unmapped as part of the automatic pci_disable_device(), I guess?
> >
> > Yup, once you go with pcim_enable_device all pci_ functions on that
> > device become manged and auto-cleanup.
> >
> > > Do we need drm_dev_enter()/_exit() to make I/O work reliably?
> >
> > That does nothing without drm_dev_unplug(), which has the annoying
> > side effect that it also shuts up stuff like
> > drm_atomic_helper_shutdown for module unload. And developers really
> > want their devices to be shut off on driver unload. So yeah
> > unfortunately we currently can decide between "correct for hotunplug"
> > and "convenient for driver unload for driver authors". I'm not sure
> > what to best do here, since all options are kinda not great for one
> > use-case or the other.
>
> So if we'd split up drm_dev_unplug into drm_dev_unregister +
> drm_dev_mark_unplugged or whatever the options would be:
>
> drm_atomic_helper_shutdown(); /* and other hw shut down */
> drm_dev_unregister();
> drm_dev_mark_unplugged();
>
> Kinda annoying since userspace might race with us, so we might still
> have an active fb (in sw tracking at least) that we need to clean up
> again later on. Plus shutting down hw before we unregister is going to
> make the hotunplug confusion for userspace even more a mess.
>
> Next option:
> drm_dev_unregster();
> /* shut down hw */
> drm_dev_mark_unplugged();
>
> This just wastes time since if we're really unplugged we'll do lots of
> io attempts that go nowhere because the device is gone already.
> They'll all time out (if the bus subsystem/hw for our driver works
> correctly at least). Plus userspace can still sneak in and do stupid
> stuff I think while we're not looking.
>
> Next up:
> drm_dev_unregister();
> drm_dev_mark_unplugged();
> drm_atomic_helper_shutdown();
>
> This is a bit silly since all the shutdown code now does is shut down
> sw state, and never touches hw (if the driver is fully annotated with
> drm_dev_enter/exit).
>
> One option might be that we slap a lot more drm_dev_enter/exit around
> the top-level ioctls (to at least stop the userspace races with driver
> unload), and allow drivers to still shut down stuff internally.
>
> tldr; it's all still a bit a mess.

Adding Laurent, I just discussed this a bit with him on irc.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-04-15 12:23           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 12:23 UTC (permalink / raw)
  To: Thomas Zimmermann, Laurent Pinchart
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Dave Airlie, Daniel Vetter, Sam Ravnborg, Christian König,
	Emil Velikov

On Wed, Apr 15, 2020 at 10:17 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Wed, Apr 15, 2020 at 10:09 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> >
> > On Wed, Apr 15, 2020 at 9:52 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
> > >
> > > Hi Daniel
> > >
> > > Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > > > Allows us to remove a bit of cleanup code.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Emil Velikov <emil.velikov@collabora.com>
> > > > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > > > Cc: Sam Ravnborg <sam@ravnborg.org>
> > > > Cc: "Christian König" <christian.koenig@amd.com>
> > > > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> > > > ---
> > > >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> > > >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> > > >  2 files changed, 3 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > > > index b7ba22dddcad..48a9cc4e080a 100644
> > > > --- a/drivers/gpu/drm/ast/ast_drv.c
> > > > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > > > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >
> > > >       ast_kick_out_firmware_fb(pdev);
> > > >
> > > > -     ret = pci_enable_device(pdev);
> > > > +     ret = pcim_enable_device(pdev);
> > > >       if (ret)
> > > >               return ret;
> > > >
> > > >       dev = drm_dev_alloc(&driver, &pdev->dev);
> > > > -     if (IS_ERR(dev)) {
> > > > -             ret = PTR_ERR(dev);
> > > > -             goto err_pci_disable_device;
> > > > -     }
> > > > +     if (IS_ERR(dev))
> > > > +             return  PTR_ERR(dev);
> > > >
> > > >       dev->pdev = pdev;
> > > >       pci_set_drvdata(pdev, dev);
> > > > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >       ast_driver_unload(dev);
> > > >  err_drm_dev_put:
> > > >       drm_dev_put(dev);
> > > > -err_pci_disable_device:
> > > > -     pci_disable_device(pdev);
> > > >       return ret;
> > > >
> > > >  }
> > > > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > > > index e5398e3dabe7..1b35728ad871 100644
> > > > --- a/drivers/gpu/drm/ast/ast_main.c
> > > > +++ b/drivers/gpu/drm/ast/ast_main.c
> > > > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> > > >       drm_mode_config_cleanup(dev);
> > > >
> > > >       ast_mm_fini(ast);
> > > > -     if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > > > -             pci_iounmap(dev->pdev, ast->ioregs);
> > > > -     pci_iounmap(dev->pdev, ast->regs);
> > >
> > > This gets unmapped as part of the automatic pci_disable_device(), I guess?
> >
> > Yup, once you go with pcim_enable_device all pci_ functions on that
> > device become manged and auto-cleanup.
> >
> > > Do we need drm_dev_enter()/_exit() to make I/O work reliably?
> >
> > That does nothing without drm_dev_unplug(), which has the annoying
> > side effect that it also shuts up stuff like
> > drm_atomic_helper_shutdown for module unload. And developers really
> > want their devices to be shut off on driver unload. So yeah
> > unfortunately we currently can decide between "correct for hotunplug"
> > and "convenient for driver unload for driver authors". I'm not sure
> > what to best do here, since all options are kinda not great for one
> > use-case or the other.
>
> So if we'd split up drm_dev_unplug into drm_dev_unregister +
> drm_dev_mark_unplugged or whatever the options would be:
>
> drm_atomic_helper_shutdown(); /* and other hw shut down */
> drm_dev_unregister();
> drm_dev_mark_unplugged();
>
> Kinda annoying since userspace might race with us, so we might still
> have an active fb (in sw tracking at least) that we need to clean up
> again later on. Plus shutting down hw before we unregister is going to
> make the hotunplug confusion for userspace even more a mess.
>
> Next option:
> drm_dev_unregster();
> /* shut down hw */
> drm_dev_mark_unplugged();
>
> This just wastes time since if we're really unplugged we'll do lots of
> io attempts that go nowhere because the device is gone already.
> They'll all time out (if the bus subsystem/hw for our driver works
> correctly at least). Plus userspace can still sneak in and do stupid
> stuff I think while we're not looking.
>
> Next up:
> drm_dev_unregister();
> drm_dev_mark_unplugged();
> drm_atomic_helper_shutdown();
>
> This is a bit silly since all the shutdown code now does is shut down
> sw state, and never touches hw (if the driver is fully annotated with
> drm_dev_enter/exit).
>
> One option might be that we slap a lot more drm_dev_enter/exit around
> the top-level ioctls (to at least stop the userspace races with driver
> unload), and allow drivers to still shut down stuff internally.
>
> tldr; it's all still a bit a mess.

Adding Laurent, I just discussed this a bit with him on irc.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:01     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:01 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Doesn't apply to upstream kernels since a rather long time.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>   drivers/gpu/drm/vboxvideo/vbox_ttm.c | 12 ------------
>   1 file changed, 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_ttm.c b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> index 976423d0c3cc..f5a06675da43 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> @@ -24,25 +24,13 @@ int vbox_mm_init(struct vbox_private *vbox)
>   		return ret;
>   	}
>   
> -#ifdef DRM_MTRR_WC
> -	vbox->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
> -				     pci_resource_len(dev->pdev, 0),
> -				     DRM_MTRR_WC);
> -#else
>   	vbox->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
>   					 pci_resource_len(dev->pdev, 0));
> -#endif
>   	return 0;
>   }
>   
>   void vbox_mm_fini(struct vbox_private *vbox)
>   {
> -#ifdef DRM_MTRR_WC
> -	drm_mtrr_del(vbox->fb_mtrr,
> -		     pci_resource_start(vbox->ddev.pdev, 0),
> -		     pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
> -#else
>   	arch_phys_wc_del(vbox->fb_mtrr);
> -#endif
>   	drm_vram_helper_release_mm(&vbox->ddev);
>   }
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define
@ 2020-04-15 15:01     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:01 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Doesn't apply to upstream kernels since a rather long time.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>   drivers/gpu/drm/vboxvideo/vbox_ttm.c | 12 ------------
>   1 file changed, 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_ttm.c b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> index 976423d0c3cc..f5a06675da43 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_ttm.c
> @@ -24,25 +24,13 @@ int vbox_mm_init(struct vbox_private *vbox)
>   		return ret;
>   	}
>   
> -#ifdef DRM_MTRR_WC
> -	vbox->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
> -				     pci_resource_len(dev->pdev, 0),
> -				     DRM_MTRR_WC);
> -#else
>   	vbox->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
>   					 pci_resource_len(dev->pdev, 0));
> -#endif
>   	return 0;
>   }
>   
>   void vbox_mm_fini(struct vbox_private *vbox)
>   {
> -#ifdef DRM_MTRR_WC
> -	drm_mtrr_del(vbox->fb_mtrr,
> -		     pci_resource_start(vbox->ddev.pdev, 0),
> -		     pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
> -#else
>   	arch_phys_wc_del(vbox->fb_mtrr);
> -#endif
>   	drm_vram_helper_release_mm(&vbox->ddev);
>   }
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:02     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:02 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Straightforward conversion.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
>   1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 282348e071fe..7dd25c7a3768 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	if (ret)
>   		return ret;
>   
> -	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
> -	if (!vbox)
> -		return -ENOMEM;
> -
> -	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
> -	if (ret) {
> -		kfree(vbox);
> -		return ret;
> -	}
> +	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct vbox_private, ddev);
> +	if (IS_ERR(vbox))
> +		return PTR_ERR(vbox);
>   
>   	vbox->ddev.pdev = pdev;
>   	vbox->ddev.dev_private = vbox;
>   	pci_set_drvdata(pdev, vbox);
> -	drmm_add_final_kfree(&vbox->ddev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
>   	ret = pci_enable_device(pdev);
>   	if (ret)
> -		goto err_dev_put;
> +		return ret;
>   
>   	ret = vbox_hw_init(vbox);
>   	if (ret)
> @@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	vbox_hw_fini(vbox);
>   err_pci_disable:
>   	pci_disable_device(pdev);
> -err_dev_put:
> -	drm_dev_put(&vbox->ddev);
>   	return ret;
>   }
>   
> @@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
>   	vbox_mode_fini(vbox);
>   	vbox_mm_fini(vbox);
>   	vbox_hw_fini(vbox);
> -	drm_dev_put(&vbox->ddev);
>   }
>   
>   #ifdef CONFIG_PM_SLEEP
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
@ 2020-04-15 15:02     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:02 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development; +Cc: Daniel Vetter, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Straightforward conversion.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
>   1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 282348e071fe..7dd25c7a3768 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	if (ret)
>   		return ret;
>   
> -	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
> -	if (!vbox)
> -		return -ENOMEM;
> -
> -	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
> -	if (ret) {
> -		kfree(vbox);
> -		return ret;
> -	}
> +	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct vbox_private, ddev);
> +	if (IS_ERR(vbox))
> +		return PTR_ERR(vbox);
>   
>   	vbox->ddev.pdev = pdev;
>   	vbox->ddev.dev_private = vbox;
>   	pci_set_drvdata(pdev, vbox);
> -	drmm_add_final_kfree(&vbox->ddev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
>   	ret = pci_enable_device(pdev);
>   	if (ret)
> -		goto err_dev_put;
> +		return ret;
>   
>   	ret = vbox_hw_init(vbox);
>   	if (ret)
> @@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	vbox_hw_fini(vbox);
>   err_pci_disable:
>   	pci_disable_device(pdev);
> -err_dev_put:
> -	drm_dev_put(&vbox->ddev);
>   	return ret;
>   }
>   
> @@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
>   	vbox_mode_fini(vbox);
>   	vbox_mm_fini(vbox);
>   	vbox_hw_fini(vbox);
> -	drm_dev_put(&vbox->ddev);
>   }
>   
>   #ifdef CONFIG_PM_SLEEP
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:02     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:02 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Thomas Zimmermann, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> We use the baseclass pattern here, so lets to the proper (and more
> typesafe) upcasting.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c  |  1 -
>   drivers/gpu/drm/vboxvideo/vbox_drv.h  |  1 +
>   drivers/gpu/drm/vboxvideo/vbox_irq.c  |  2 +-
>   drivers/gpu/drm/vboxvideo/vbox_mode.c | 10 +++++-----
>   4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 7dd25c7a3768..cfa4639c5142 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -52,7 +52,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   		return PTR_ERR(vbox);
>   
>   	vbox->ddev.pdev = pdev;
> -	vbox->ddev.dev_private = vbox;
>   	pci_set_drvdata(pdev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.h b/drivers/gpu/drm/vboxvideo/vbox_drv.h
> index 87421903816c..ac7c2effc46f 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.h
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.h
> @@ -127,6 +127,7 @@ struct vbox_encoder {
>   #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
>   #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
>   #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
> +#define to_vbox_dev(x) container_of(x, struct vbox_private, ddev)
>   
>   bool vbox_check_supported(u16 id);
>   int vbox_hw_init(struct vbox_private *vbox);
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_irq.c b/drivers/gpu/drm/vboxvideo/vbox_irq.c
> index 16a1e29f5292..631657fa554f 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_irq.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_irq.c
> @@ -34,7 +34,7 @@ void vbox_report_hotplug(struct vbox_private *vbox)
>   irqreturn_t vbox_irq_handler(int irq, void *arg)
>   {
>   	struct drm_device *dev = (struct drm_device *)arg;
> -	struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(dev);
>   	u32 host_flags = vbox_get_flags(vbox);
>   
>   	if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> index 0883a435e62b..d9a5af62af89 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> @@ -36,7 +36,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
>   	u16 flags;
>   	s32 x_offset, y_offset;
>   
> -	vbox = crtc->dev->dev_private;
> +	vbox = to_vbox_dev(crtc->dev);
>   	width = vbox_crtc->width ? vbox_crtc->width : 640;
>   	height = vbox_crtc->height ? vbox_crtc->height : 480;
>   	bpp = fb ? fb->format->cpp[0] * 8 : 32;
> @@ -77,7 +77,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
>   static int vbox_set_view(struct drm_crtc *crtc)
>   {
>   	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
> -	struct vbox_private *vbox = crtc->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
>   	struct vbva_infoview *p;
>   
>   	/*
> @@ -174,7 +174,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
>   					int x, int y)
>   {
>   	struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
> -	struct vbox_private *vbox = crtc->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
>   	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
>   	bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
>   
> @@ -272,7 +272,7 @@ static void vbox_primary_atomic_update(struct drm_plane *plane,
>   {
>   	struct drm_crtc *crtc = plane->state->crtc;
>   	struct drm_framebuffer *fb = plane->state->fb;
> -	struct vbox_private *vbox = fb->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(fb->dev);
>   	struct drm_mode_rect *clips;
>   	uint32_t num_clips, i;
>   
> @@ -704,7 +704,7 @@ static int vbox_get_modes(struct drm_connector *connector)
>   	int preferred_width, preferred_height;
>   
>   	vbox_connector = to_vbox_connector(connector);
> -	vbox = connector->dev->dev_private;
> +	vbox = to_vbox_dev(connector->dev);
>   
>   	hgsmi_report_flags_location(vbox->guest_pool, GUEST_HEAP_OFFSET(vbox) +
>   				    HOST_FLAGS_OFFSET);
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private
@ 2020-04-15 15:02     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:02 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Thomas Zimmermann, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> We use the baseclass pattern here, so lets to the proper (and more
> typesafe) upcasting.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c  |  1 -
>   drivers/gpu/drm/vboxvideo/vbox_drv.h  |  1 +
>   drivers/gpu/drm/vboxvideo/vbox_irq.c  |  2 +-
>   drivers/gpu/drm/vboxvideo/vbox_mode.c | 10 +++++-----
>   4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 7dd25c7a3768..cfa4639c5142 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -52,7 +52,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   		return PTR_ERR(vbox);
>   
>   	vbox->ddev.pdev = pdev;
> -	vbox->ddev.dev_private = vbox;
>   	pci_set_drvdata(pdev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.h b/drivers/gpu/drm/vboxvideo/vbox_drv.h
> index 87421903816c..ac7c2effc46f 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.h
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.h
> @@ -127,6 +127,7 @@ struct vbox_encoder {
>   #define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
>   #define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
>   #define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
> +#define to_vbox_dev(x) container_of(x, struct vbox_private, ddev)
>   
>   bool vbox_check_supported(u16 id);
>   int vbox_hw_init(struct vbox_private *vbox);
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_irq.c b/drivers/gpu/drm/vboxvideo/vbox_irq.c
> index 16a1e29f5292..631657fa554f 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_irq.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_irq.c
> @@ -34,7 +34,7 @@ void vbox_report_hotplug(struct vbox_private *vbox)
>   irqreturn_t vbox_irq_handler(int irq, void *arg)
>   {
>   	struct drm_device *dev = (struct drm_device *)arg;
> -	struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(dev);
>   	u32 host_flags = vbox_get_flags(vbox);
>   
>   	if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> index 0883a435e62b..d9a5af62af89 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> @@ -36,7 +36,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
>   	u16 flags;
>   	s32 x_offset, y_offset;
>   
> -	vbox = crtc->dev->dev_private;
> +	vbox = to_vbox_dev(crtc->dev);
>   	width = vbox_crtc->width ? vbox_crtc->width : 640;
>   	height = vbox_crtc->height ? vbox_crtc->height : 480;
>   	bpp = fb ? fb->format->cpp[0] * 8 : 32;
> @@ -77,7 +77,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
>   static int vbox_set_view(struct drm_crtc *crtc)
>   {
>   	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
> -	struct vbox_private *vbox = crtc->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
>   	struct vbva_infoview *p;
>   
>   	/*
> @@ -174,7 +174,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
>   					int x, int y)
>   {
>   	struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
> -	struct vbox_private *vbox = crtc->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(crtc->dev);
>   	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
>   	bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
>   
> @@ -272,7 +272,7 @@ static void vbox_primary_atomic_update(struct drm_plane *plane,
>   {
>   	struct drm_crtc *crtc = plane->state->crtc;
>   	struct drm_framebuffer *fb = plane->state->fb;
> -	struct vbox_private *vbox = fb->dev->dev_private;
> +	struct vbox_private *vbox = to_vbox_dev(fb->dev);
>   	struct drm_mode_rect *clips;
>   	uint32_t num_clips, i;
>   
> @@ -704,7 +704,7 @@ static int vbox_get_modes(struct drm_connector *connector)
>   	int preferred_width, preferred_height;
>   
>   	vbox_connector = to_vbox_connector(connector);
> -	vbox = connector->dev->dev_private;
> +	vbox = to_vbox_dev(connector->dev);
>   
>   	hgsmi_report_flags_location(vbox->guest_pool, GUEST_HEAP_OFFSET(vbox) +
>   				    HOST_FLAGS_OFFSET);
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 05/59] drm/vboxvidoe: use managed pci functions
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:03     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:03 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Allows us to drop the cleanup code on the floor.
> 
> Sam noticed in his review:
>> With this change we avoid calling pci_disable_device()
>> twise in case vbox_mm_init() fails.
>> Once in vbox_hw_fini() and once in the error path.
> 
> v2: Include Sam's review remarks
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>   drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>   2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index cfa4639c5142..cf2e3e6a2388 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	pci_set_drvdata(pdev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>   	if (ret)
>   		return ret;
>   
>   	ret = vbox_hw_init(vbox);
>   	if (ret)
> -		goto err_pci_disable;
> +		return ret;
>   
>   	ret = vbox_mm_init(vbox);
>   	if (ret)
> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	vbox_mm_fini(vbox);
>   err_hw_fini:
>   	vbox_hw_fini(vbox);
> -err_pci_disable:
> -	pci_disable_device(pdev);
>   	return ret;
>   }
>   
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 9dcab115a261..1336ab9795fc 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>   
>   	for (i = 0; i < vbox->num_crtcs; ++i)
>   		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> -
> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>   }
>   
>   /* Do we support the 4.3 plus mode hint reporting interface? */

This seems to be missing the conversion of the iomap_range call to
the devm equivalent ?   :

drivers/gpu/drm/vboxvideo/vbox_main.c
44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...

Regards,

Hans





> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>   	vbox->guest_pool = gen_pool_create(4, -1);
>   	if (!vbox->guest_pool)
> -		goto err_unmap_guest_heap;
> +		return -ENOMEM;
>   
>   	ret = gen_pool_add_virt(vbox->guest_pool,
>   				(unsigned long)vbox->guest_heap,
> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>   
>   err_destroy_guest_pool:
>   	gen_pool_destroy(vbox->guest_pool);
> -err_unmap_guest_heap:
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>   	return ret;
>   }
>   
> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>   {
>   	vbox_accel_fini(vbox);
>   	gen_pool_destroy(vbox->guest_pool);
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>   }
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 05/59] drm/vboxvidoe: use managed pci functions
@ 2020-04-15 15:03     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:03 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Allows us to drop the cleanup code on the floor.
> 
> Sam noticed in his review:
>> With this change we avoid calling pci_disable_device()
>> twise in case vbox_mm_init() fails.
>> Once in vbox_hw_fini() and once in the error path.
> 
> v2: Include Sam's review remarks
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
>   drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>   drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>   2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index cfa4639c5142..cf2e3e6a2388 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	pci_set_drvdata(pdev, vbox);
>   	mutex_init(&vbox->hw_mutex);
>   
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>   	if (ret)
>   		return ret;
>   
>   	ret = vbox_hw_init(vbox);
>   	if (ret)
> -		goto err_pci_disable;
> +		return ret;
>   
>   	ret = vbox_mm_init(vbox);
>   	if (ret)
> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	vbox_mm_fini(vbox);
>   err_hw_fini:
>   	vbox_hw_fini(vbox);
> -err_pci_disable:
> -	pci_disable_device(pdev);
>   	return ret;
>   }
>   
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 9dcab115a261..1336ab9795fc 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>   
>   	for (i = 0; i < vbox->num_crtcs; ++i)
>   		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> -
> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>   }
>   
>   /* Do we support the 4.3 plus mode hint reporting interface? */

This seems to be missing the conversion of the iomap_range call to
the devm equivalent ?   :

drivers/gpu/drm/vboxvideo/vbox_main.c
44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...

Regards,

Hans





> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>   	vbox->guest_pool = gen_pool_create(4, -1);
>   	if (!vbox->guest_pool)
> -		goto err_unmap_guest_heap;
> +		return -ENOMEM;
>   
>   	ret = gen_pool_add_virt(vbox->guest_pool,
>   				(unsigned long)vbox->guest_heap,
> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>   
>   err_destroy_guest_pool:
>   	gen_pool_destroy(vbox->guest_pool);
> -err_unmap_guest_heap:
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>   	return ret;
>   }
>   
> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>   {
>   	vbox_accel_fini(vbox);
>   	gen_pool_destroy(vbox->guest_pool);
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>   }
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:04     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Aside from deleting all the cleanup code we're now also setting a name
> for the pool
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
>   1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 1336ab9795fc..d68d9bad7674 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -121,7 +121,8 @@ int vbox_hw_init(struct vbox_private *vbox)
>   		return -ENOMEM;
>   
>   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
> -	vbox->guest_pool = gen_pool_create(4, -1);
> +	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
> +						"vboxvideo-accel");
>   	if (!vbox->guest_pool)
>   		return -ENOMEM;
>   
> @@ -130,12 +131,12 @@ int vbox_hw_init(struct vbox_private *vbox)
>   				GUEST_HEAP_OFFSET(vbox),
>   				GUEST_HEAP_USABLE_SIZE, -1);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	ret = hgsmi_test_query_conf(vbox->guest_pool);
>   	if (ret) {
>   		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	/* Reduce available VRAM size to reflect the guest heap. */
> @@ -147,30 +148,23 @@ int vbox_hw_init(struct vbox_private *vbox)
>   
>   	if (!have_hgsmi_mode_hints(vbox)) {
>   		ret = -ENOTSUPP;
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
>   					     sizeof(struct vbva_modehint),
>   					     GFP_KERNEL);
> -	if (!vbox->last_mode_hints) {
> -		ret = -ENOMEM;
> -		goto err_destroy_guest_pool;
> -	}
> +	if (!vbox->last_mode_hints)
> +		return -ENOMEM;
>   
>   	ret = vbox_accel_init(vbox);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	return 0;
> -
> -err_destroy_guest_pool:
> -	gen_pool_destroy(vbox->guest_pool);
> -	return ret;
>   }
>   
>   void vbox_hw_fini(struct vbox_private *vbox)
>   {
>   	vbox_accel_fini(vbox);
> -	gen_pool_destroy(vbox->guest_pool);
>   }
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create
@ 2020-04-15 15:04     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Aside from deleting all the cleanup code we're now also setting a name
> for the pool
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
>   1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 1336ab9795fc..d68d9bad7674 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -121,7 +121,8 @@ int vbox_hw_init(struct vbox_private *vbox)
>   		return -ENOMEM;
>   
>   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
> -	vbox->guest_pool = gen_pool_create(4, -1);
> +	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
> +						"vboxvideo-accel");
>   	if (!vbox->guest_pool)
>   		return -ENOMEM;
>   
> @@ -130,12 +131,12 @@ int vbox_hw_init(struct vbox_private *vbox)
>   				GUEST_HEAP_OFFSET(vbox),
>   				GUEST_HEAP_USABLE_SIZE, -1);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	ret = hgsmi_test_query_conf(vbox->guest_pool);
>   	if (ret) {
>   		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	/* Reduce available VRAM size to reflect the guest heap. */
> @@ -147,30 +148,23 @@ int vbox_hw_init(struct vbox_private *vbox)
>   
>   	if (!have_hgsmi_mode_hints(vbox)) {
>   		ret = -ENOTSUPP;
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
>   					     sizeof(struct vbva_modehint),
>   					     GFP_KERNEL);
> -	if (!vbox->last_mode_hints) {
> -		ret = -ENOMEM;
> -		goto err_destroy_guest_pool;
> -	}
> +	if (!vbox->last_mode_hints)
> +		return -ENOMEM;
>   
>   	ret = vbox_accel_init(vbox);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	return 0;
> -
> -err_destroy_guest_pool:
> -	gen_pool_destroy(vbox->guest_pool);
> -	return ret;
>   }
>   
>   void vbox_hw_fini(struct vbox_private *vbox)
>   {
>   	vbox_accel_fini(vbox);
> -	gen_pool_destroy(vbox->guest_pool);
>   }
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 21/59] drm/gm12u320: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:04     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
> index 6f0ea2827d62..907739a67bf6 100644
> --- a/drivers/gpu/drm/tiny/gm12u320.c
> +++ b/drivers/gpu/drm/tiny/gm12u320.c
> @@ -631,22 +631,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
>   	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
>   		return -ENODEV;
>   
> -	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
> -	if (gm12u320 == NULL)
> -		return -ENOMEM;
> +	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
> +				      struct gm12u320_device, dev);
> +	if (IS_ERR(gm12u320))
> +		return PTR_ERR(gm12u320);
>   
>   	gm12u320->udev = interface_to_usbdev(interface);
>   	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
>   	mutex_init(&gm12u320->fb_update.lock);
>   
>   	dev = &gm12u320->dev;
> -	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
> -	if (ret) {
> -		kfree(gm12u320);
> -		return ret;
> -	}
>   	dev->dev_private = gm12u320;
> -	drmm_add_final_kfree(dev, gm12u320);
>   
>   	ret = drmm_mode_config_init(dev);
>   	if (ret)
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 21/59] drm/gm12u320: Use devm_drm_dev_alloc
@ 2020-04-15 15:04     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/tiny/gm12u320.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
> index 6f0ea2827d62..907739a67bf6 100644
> --- a/drivers/gpu/drm/tiny/gm12u320.c
> +++ b/drivers/gpu/drm/tiny/gm12u320.c
> @@ -631,22 +631,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
>   	if (interface->cur_altsetting->desc.bInterfaceNumber != 0)
>   		return -ENODEV;
>   
> -	gm12u320 = kzalloc(sizeof(*gm12u320), GFP_KERNEL);
> -	if (gm12u320 == NULL)
> -		return -ENOMEM;
> +	gm12u320 = devm_drm_dev_alloc(&interface->dev, &gm12u320_drm_driver,
> +				      struct gm12u320_device, dev);
> +	if (IS_ERR(gm12u320))
> +		return PTR_ERR(gm12u320);
>   
>   	gm12u320->udev = interface_to_usbdev(interface);
>   	INIT_DELAYED_WORK(&gm12u320->fb_update.work, gm12u320_fb_update_work);
>   	mutex_init(&gm12u320->fb_update.lock);
>   
>   	dev = &gm12u320->dev;
> -	ret = devm_drm_dev_init(&interface->dev, dev, &gm12u320_drm_driver);
> -	if (ret) {
> -		kfree(gm12u320);
> -		return ret;
> -	}
>   	dev->dev_private = gm12u320;
> -	drmm_add_final_kfree(dev, gm12u320);
>   
>   	ret = drmm_mode_config_init(dev);
>   	if (ret)
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 15:05     ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/tiny/gm12u320.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
> index 907739a67bf6..cc397671f689 100644
> --- a/drivers/gpu/drm/tiny/gm12u320.c
> +++ b/drivers/gpu/drm/tiny/gm12u320.c
> @@ -98,6 +98,8 @@ struct gm12u320_device {
>   	} fb_update;
>   };
>   
> +#define to_gm12u320(__dev) container_of(__dev, struct gm12u320_device, dev)
> +
>   static const char cmd_data[CMD_SIZE] = {
>   	0x55, 0x53, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00,
>   	0x68, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff,
> @@ -408,7 +410,7 @@ static void gm12u320_fb_update_work(struct work_struct *work)
>   static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
>   				   struct drm_rect *dirty)
>   {
> -	struct gm12u320_device *gm12u320 = fb->dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
>   	struct drm_framebuffer *old_fb = NULL;
>   	bool wakeup = false;
>   
> @@ -558,7 +560,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
>   				 struct drm_plane_state *plane_state)
>   {
>   	struct drm_rect rect = { 0, 0, GM12U320_USER_WIDTH, GM12U320_HEIGHT };
> -	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
>   
>   	gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT;
>   	gm12u320_fb_mark_dirty(plane_state->fb, &rect);
> @@ -566,7 +568,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
>   
>   static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
>   {
> -	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
>   
>   	gm12u320_stop_fb_update(gm12u320);
>   }
> @@ -641,7 +643,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
>   	mutex_init(&gm12u320->fb_update.lock);
>   
>   	dev = &gm12u320->dev;
> -	dev->dev_private = gm12u320;
>   
>   	ret = drmm_mode_config_init(dev);
>   	if (ret)
> @@ -706,7 +707,7 @@ static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
>   static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
>   {
>   	struct drm_device *dev = usb_get_intfdata(interface);
> -	struct gm12u320_device *gm12u320 = dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(dev);
>   
>   	gm12u320_set_ecomode(gm12u320);
>   
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private
@ 2020-04-15 15:05     ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-15 15:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, DRI Development

Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/tiny/gm12u320.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
> index 907739a67bf6..cc397671f689 100644
> --- a/drivers/gpu/drm/tiny/gm12u320.c
> +++ b/drivers/gpu/drm/tiny/gm12u320.c
> @@ -98,6 +98,8 @@ struct gm12u320_device {
>   	} fb_update;
>   };
>   
> +#define to_gm12u320(__dev) container_of(__dev, struct gm12u320_device, dev)
> +
>   static const char cmd_data[CMD_SIZE] = {
>   	0x55, 0x53, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00,
>   	0x68, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff,
> @@ -408,7 +410,7 @@ static void gm12u320_fb_update_work(struct work_struct *work)
>   static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
>   				   struct drm_rect *dirty)
>   {
> -	struct gm12u320_device *gm12u320 = fb->dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
>   	struct drm_framebuffer *old_fb = NULL;
>   	bool wakeup = false;
>   
> @@ -558,7 +560,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
>   				 struct drm_plane_state *plane_state)
>   {
>   	struct drm_rect rect = { 0, 0, GM12U320_USER_WIDTH, GM12U320_HEIGHT };
> -	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
>   
>   	gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT;
>   	gm12u320_fb_mark_dirty(plane_state->fb, &rect);
> @@ -566,7 +568,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
>   
>   static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
>   {
> -	struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
>   
>   	gm12u320_stop_fb_update(gm12u320);
>   }
> @@ -641,7 +643,6 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
>   	mutex_init(&gm12u320->fb_update.lock);
>   
>   	dev = &gm12u320->dev;
> -	dev->dev_private = gm12u320;
>   
>   	ret = drmm_mode_config_init(dev);
>   	if (ret)
> @@ -706,7 +707,7 @@ static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
>   static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
>   {
>   	struct drm_device *dev = usb_get_intfdata(interface);
> -	struct gm12u320_device *gm12u320 = dev->dev_private;
> +	struct gm12u320_device *gm12u320 = to_gm12u320(dev);
>   
>   	gm12u320_set_ecomode(gm12u320);
>   
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 05/59] drm/vboxvidoe: use managed pci functions
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-15 17:32     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15 17:32 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Hans de Goede, Sam Ravnborg, DRI Development, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 3158 bytes --]

The commit's headline says 'vboxvidoe'.

Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Allows us to drop the cleanup code on the floor.
> 
> Sam noticed in his review:
>> With this change we avoid calling pci_disable_device()
>> twise in case vbox_mm_init() fails.
>> Once in vbox_hw_fini() and once in the error path.
> 
> v2: Include Sam's review remarks
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>  drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index cfa4639c5142..cf2e3e6a2388 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_set_drvdata(pdev, vbox);
>  	mutex_init(&vbox->hw_mutex);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	ret = vbox_hw_init(vbox);
>  	if (ret)
> -		goto err_pci_disable;
> +		return ret;
>  
>  	ret = vbox_mm_init(vbox);
>  	if (ret)
> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	vbox_mm_fini(vbox);
>  err_hw_fini:
>  	vbox_hw_fini(vbox);
> -err_pci_disable:
> -	pci_disable_device(pdev);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 9dcab115a261..1336ab9795fc 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>  
>  	for (i = 0; i < vbox->num_crtcs; ++i)
>  		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> -
> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>  }
>  
>  /* Do we support the 4.3 plus mode hint reporting interface? */
> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>  	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>  	vbox->guest_pool = gen_pool_create(4, -1);
>  	if (!vbox->guest_pool)
> -		goto err_unmap_guest_heap;
> +		return -ENOMEM;
>  
>  	ret = gen_pool_add_virt(vbox->guest_pool,
>  				(unsigned long)vbox->guest_heap,
> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>  
>  err_destroy_guest_pool:
>  	gen_pool_destroy(vbox->guest_pool);
> -err_unmap_guest_heap:
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>  	return ret;
>  }
>  
> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>  {
>  	vbox_accel_fini(vbox);
>  	gen_pool_destroy(vbox->guest_pool);
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 05/59] drm/vboxvidoe: use managed pci functions
@ 2020-04-15 17:32     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-15 17:32 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Sam Ravnborg, DRI Development, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 3158 bytes --]

The commit's headline says 'vboxvidoe'.

Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Allows us to drop the cleanup code on the floor.
> 
> Sam noticed in his review:
>> With this change we avoid calling pci_disable_device()
>> twise in case vbox_mm_init() fails.
>> Once in vbox_hw_fini() and once in the error path.
> 
> v2: Include Sam's review remarks
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>  drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index cfa4639c5142..cf2e3e6a2388 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_set_drvdata(pdev, vbox);
>  	mutex_init(&vbox->hw_mutex);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	ret = vbox_hw_init(vbox);
>  	if (ret)
> -		goto err_pci_disable;
> +		return ret;
>  
>  	ret = vbox_mm_init(vbox);
>  	if (ret)
> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	vbox_mm_fini(vbox);
>  err_hw_fini:
>  	vbox_hw_fini(vbox);
> -err_pci_disable:
> -	pci_disable_device(pdev);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 9dcab115a261..1336ab9795fc 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>  
>  	for (i = 0; i < vbox->num_crtcs; ++i)
>  		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> -
> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>  }
>  
>  /* Do we support the 4.3 plus mode hint reporting interface? */
> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>  	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>  	vbox->guest_pool = gen_pool_create(4, -1);
>  	if (!vbox->guest_pool)
> -		goto err_unmap_guest_heap;
> +		return -ENOMEM;
>  
>  	ret = gen_pool_add_virt(vbox->guest_pool,
>  				(unsigned long)vbox->guest_heap,
> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>  
>  err_destroy_guest_pool:
>  	gen_pool_destroy(vbox->guest_pool);
> -err_unmap_guest_heap:
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>  	return ret;
>  }
>  
> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>  {
>  	vbox_accel_fini(vbox);
>  	gen_pool_destroy(vbox->guest_pool);
> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 05/59] drm/vboxvidoe: use managed pci functions
  2020-04-15 15:03     ` [Intel-gfx] " Hans de Goede
@ 2020-04-15 17:44       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 17:44 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg,
	DRI Development, Daniel Vetter

On Wed, Apr 15, 2020 at 05:03:55PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 4/15/20 9:39 AM, Daniel Vetter wrote:
> > Allows us to drop the cleanup code on the floor.
> > 
> > Sam noticed in his review:
> > > With this change we avoid calling pci_disable_device()
> > > twise in case vbox_mm_init() fails.
> > > Once in vbox_hw_fini() and once in the error path.
> > 
> > v2: Include Sam's review remarks
> > 
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > ---
> >   drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
> >   drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
> >   2 files changed, 3 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > index cfa4639c5142..cf2e3e6a2388 100644
> > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >   	pci_set_drvdata(pdev, vbox);
> >   	mutex_init(&vbox->hw_mutex);
> > -	ret = pci_enable_device(pdev);
> > +	ret = pcim_enable_device(pdev);
> >   	if (ret)
> >   		return ret;
> >   	ret = vbox_hw_init(vbox);
> >   	if (ret)
> > -		goto err_pci_disable;
> > +		return ret;
> >   	ret = vbox_mm_init(vbox);
> >   	if (ret)
> > @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >   	vbox_mm_fini(vbox);
> >   err_hw_fini:
> >   	vbox_hw_fini(vbox);
> > -err_pci_disable:
> > -	pci_disable_device(pdev);
> >   	return ret;
> >   }
> > diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> > index 9dcab115a261..1336ab9795fc 100644
> > --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> > +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> > @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
> >   	for (i = 0; i < vbox->num_crtcs; ++i)
> >   		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> > -
> > -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
> >   }
> >   /* Do we support the 4.3 plus mode hint reporting interface? */
> 
> This seems to be missing the conversion of the iomap_range call to
> the devm equivalent ?   :
> 
> drivers/gpu/drm/vboxvideo/vbox_main.c
> 44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...

pcim_enable_device is pure magic, it converts _all_ pci_ calls on that
device to the managed version. There's no other manged pci_ functions (ok
1-2 more, but they're rather special).
-Daniel

> 
> Regards,
> 
> Hans
> 
> 
> 
> 
> 
> > @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
> >   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
> >   	vbox->guest_pool = gen_pool_create(4, -1);
> >   	if (!vbox->guest_pool)
> > -		goto err_unmap_guest_heap;
> > +		return -ENOMEM;
> >   	ret = gen_pool_add_virt(vbox->guest_pool,
> >   				(unsigned long)vbox->guest_heap,
> > @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
> >   err_destroy_guest_pool:
> >   	gen_pool_destroy(vbox->guest_pool);
> > -err_unmap_guest_heap:
> > -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
> >   	return ret;
> >   }
> > @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
> >   {
> >   	vbox_accel_fini(vbox);
> >   	gen_pool_destroy(vbox->guest_pool);
> > -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
> >   }
> > 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 05/59] drm/vboxvidoe: use managed pci functions
@ 2020-04-15 17:44       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-15 17:44 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg,
	DRI Development, Daniel Vetter

On Wed, Apr 15, 2020 at 05:03:55PM +0200, Hans de Goede wrote:
> Hi,
> 
> On 4/15/20 9:39 AM, Daniel Vetter wrote:
> > Allows us to drop the cleanup code on the floor.
> > 
> > Sam noticed in his review:
> > > With this change we avoid calling pci_disable_device()
> > > twise in case vbox_mm_init() fails.
> > > Once in vbox_hw_fini() and once in the error path.
> > 
> > v2: Include Sam's review remarks
> > 
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > ---
> >   drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
> >   drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
> >   2 files changed, 3 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > index cfa4639c5142..cf2e3e6a2388 100644
> > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> > @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >   	pci_set_drvdata(pdev, vbox);
> >   	mutex_init(&vbox->hw_mutex);
> > -	ret = pci_enable_device(pdev);
> > +	ret = pcim_enable_device(pdev);
> >   	if (ret)
> >   		return ret;
> >   	ret = vbox_hw_init(vbox);
> >   	if (ret)
> > -		goto err_pci_disable;
> > +		return ret;
> >   	ret = vbox_mm_init(vbox);
> >   	if (ret)
> > @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >   	vbox_mm_fini(vbox);
> >   err_hw_fini:
> >   	vbox_hw_fini(vbox);
> > -err_pci_disable:
> > -	pci_disable_device(pdev);
> >   	return ret;
> >   }
> > diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> > index 9dcab115a261..1336ab9795fc 100644
> > --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> > +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> > @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
> >   	for (i = 0; i < vbox->num_crtcs; ++i)
> >   		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
> > -
> > -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
> >   }
> >   /* Do we support the 4.3 plus mode hint reporting interface? */
> 
> This seems to be missing the conversion of the iomap_range call to
> the devm equivalent ?   :
> 
> drivers/gpu/drm/vboxvideo/vbox_main.c
> 44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...

pcim_enable_device is pure magic, it converts _all_ pci_ calls on that
device to the managed version. There's no other manged pci_ functions (ok
1-2 more, but they're rather special).
-Daniel

> 
> Regards,
> 
> Hans
> 
> 
> 
> 
> 
> > @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
> >   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
> >   	vbox->guest_pool = gen_pool_create(4, -1);
> >   	if (!vbox->guest_pool)
> > -		goto err_unmap_guest_heap;
> > +		return -ENOMEM;
> >   	ret = gen_pool_add_virt(vbox->guest_pool,
> >   				(unsigned long)vbox->guest_heap,
> > @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
> >   err_destroy_guest_pool:
> >   	gen_pool_destroy(vbox->guest_pool);
> > -err_unmap_guest_heap:
> > -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
> >   	return ret;
> >   }
> > @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
> >   {
> >   	vbox_accel_fini(vbox);
> >   	gen_pool_destroy(vbox->guest_pool);
> > -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
> >   }
> > 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✓ Fi.CI.IGT: success for devm_drm_dev_alloc, v2
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (62 preceding siblings ...)
  (?)
@ 2020-04-15 23:45 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-04-15 23:45 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2
URL   : https://patchwork.freedesktop.org/series/75956/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8298_full -> Patchwork_17304_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

New tests
---------

  New tests have been introduced between CI_DRM_8298_full and Patchwork_17304_full:

### New IGT tests (27) ###

  * igt@kms_plane_cursor@pipe-a-overlay-size-128:
    - Statuses : 8 pass(s)
    - Exec time: [1.65, 3.69] s

  * igt@kms_plane_cursor@pipe-a-overlay-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [1.64, 3.68] s

  * igt@kms_plane_cursor@pipe-a-overlay-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [1.65, 3.68] s

  * igt@kms_plane_cursor@pipe-a-primary-size-128:
    - Statuses : 8 pass(s)
    - Exec time: [1.64, 3.43] s

  * igt@kms_plane_cursor@pipe-a-primary-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [1.63, 3.43] s

  * igt@kms_plane_cursor@pipe-a-primary-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [1.63, 3.50] s

  * igt@kms_plane_cursor@pipe-a-viewport-size-128:
    - Statuses : 8 pass(s)
    - Exec time: [1.65, 3.65] s

  * igt@kms_plane_cursor@pipe-a-viewport-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [1.64, 3.68] s

  * igt@kms_plane_cursor@pipe-a-viewport-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [1.65, 3.69] s

  * igt@kms_plane_cursor@pipe-b-overlay-size-128:
    - Statuses : 8 pass(s)
    - Exec time: [2.21, 4.80] s

  * igt@kms_plane_cursor@pipe-b-overlay-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [2.24, 4.84] s

  * igt@kms_plane_cursor@pipe-b-overlay-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [2.21, 4.86] s

  * igt@kms_plane_cursor@pipe-b-primary-size-128:
    - Statuses : 8 pass(s)
    - Exec time: [2.20, 4.62] s

  * igt@kms_plane_cursor@pipe-b-primary-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [2.21, 4.58] s

  * igt@kms_plane_cursor@pipe-b-primary-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [2.21, 4.62] s

  * igt@kms_plane_cursor@pipe-b-viewport-size-128:
    - Statuses :
    - Exec time: [None] s

  * igt@kms_plane_cursor@pipe-b-viewport-size-256:
    - Statuses : 8 pass(s)
    - Exec time: [2.23, 4.86] s

  * igt@kms_plane_cursor@pipe-b-viewport-size-64:
    - Statuses : 8 pass(s)
    - Exec time: [2.28, 4.82] s

  * igt@kms_plane_cursor@pipe-c-overlay-size-128:
    - Statuses : 6 pass(s) 1 skip(s)
    - Exec time: [0.0, 3.59] s

  * igt@kms_plane_cursor@pipe-c-overlay-size-256:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.87] s

  * igt@kms_plane_cursor@pipe-c-overlay-size-64:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.87] s

  * igt@kms_plane_cursor@pipe-c-primary-size-128:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.62] s

  * igt@kms_plane_cursor@pipe-c-primary-size-256:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.62] s

  * igt@kms_plane_cursor@pipe-c-primary-size-64:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.71] s

  * igt@kms_plane_cursor@pipe-c-viewport-size-128:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.86] s

  * igt@kms_plane_cursor@pipe-c-viewport-size-256:
    - Statuses : 7 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.85] s

  * igt@kms_plane_cursor@pipe-c-viewport-size-64:
    - Statuses : 6 pass(s) 1 skip(s)
    - Exec time: [0.0, 4.90] s

  

Known issues
------------

  Here are the changes found in Patchwork_17304_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_mmap_wc@bad-object:
    - shard-hsw:          [PASS][1] -> [INCOMPLETE][2] ([i915#61])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-hsw1/igt@gem_mmap_wc@bad-object.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-hsw4/igt@gem_mmap_wc@bad-object.html

  * igt@gem_workarounds@suspend-resume-context:
    - shard-apl:          [PASS][3] -> [DMESG-WARN][4] ([i915#180]) +1 similar issue
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl1/igt@gem_workarounds@suspend-resume-context.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-apl4/igt@gem_workarounds@suspend-resume-context.html

  * igt@i915_pm_rc6_residency@rc6-idle:
    - shard-snb:          [PASS][5] -> [FAIL][6] ([i915#1066])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-snb2/igt@i915_pm_rc6_residency@rc6-idle.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-snb5/igt@i915_pm_rc6_residency@rc6-idle.html

  * igt@i915_selftest@live@requests:
    - shard-tglb:         [PASS][7] -> [INCOMPLETE][8] ([i915#1531] / [i915#1658])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-tglb1/igt@i915_selftest@live@requests.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-tglb3/igt@i915_selftest@live@requests.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
    - shard-kbl:          [PASS][9] -> [DMESG-WARN][10] ([i915#180]) +1 similar issue
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-kbl3/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-kbl2/igt@kms_cursor_crc@pipe-c-cursor-suspend.html

  * igt@kms_draw_crc@draw-method-xrgb8888-blt-untiled:
    - shard-snb:          [PASS][11] -> [SKIP][12] ([fdo#109271]) +1 similar issue
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-snb6/igt@kms_draw_crc@draw-method-xrgb8888-blt-untiled.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-snb6/igt@kms_draw_crc@draw-method-xrgb8888-blt-untiled.html

  * igt@kms_flip@flip-vs-expired-vblank-interruptible:
    - shard-skl:          [PASS][13] -> [FAIL][14] ([i915#79])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl7/igt@kms_flip@flip-vs-expired-vblank-interruptible.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl3/igt@kms_flip@flip-vs-expired-vblank-interruptible.html

  * igt@kms_flip@flip-vs-suspend:
    - shard-skl:          [PASS][15] -> [INCOMPLETE][16] ([i915#221])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl4/igt@kms_flip@flip-vs-suspend.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl8/igt@kms_flip@flip-vs-suspend.html

  * igt@kms_flip@plain-flip-ts-check-interruptible:
    - shard-skl:          [PASS][17] -> [FAIL][18] ([i915#34])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl6/igt@kms_flip@plain-flip-ts-check-interruptible.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl1/igt@kms_flip@plain-flip-ts-check-interruptible.html

  * igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
    - shard-skl:          [PASS][19] -> [FAIL][20] ([fdo#108145] / [i915#265]) +1 similar issue
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl3/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl3/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html

  * igt@kms_psr@psr2_primary_page_flip:
    - shard-iclb:         [PASS][21] -> [SKIP][22] ([fdo#109441])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-iclb7/igt@kms_psr@psr2_primary_page_flip.html

  
#### Possible fixes ####

  * {igt@gem_wait@write-wait@all}:
    - shard-skl:          [FAIL][23] ([i915#1676]) -> [PASS][24]
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl2/igt@gem_wait@write-wait@all.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl2/igt@gem_wait@write-wait@all.html

  * igt@gen9_exec_parse@allowed-all:
    - shard-apl:          [DMESG-WARN][25] ([i915#716]) -> [PASS][26]
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl3/igt@gen9_exec_parse@allowed-all.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-apl8/igt@gen9_exec_parse@allowed-all.html

  * igt@kms_hdr@bpc-switch-dpms:
    - shard-skl:          [FAIL][27] ([i915#1188]) -> [PASS][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl10/igt@kms_hdr@bpc-switch-dpms.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl6/igt@kms_hdr@bpc-switch-dpms.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
    - shard-kbl:          [DMESG-WARN][29] ([i915#180]) -> [PASS][30] +2 similar issues
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-kbl7/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-kbl2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [SKIP][31] ([fdo#109441]) -> [PASS][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-iclb1/igt@kms_psr@psr2_primary_mmap_cpu.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@kms_vblank@pipe-b-ts-continuation-suspend:
    - shard-apl:          [DMESG-WARN][33] ([i915#180]) -> [PASS][34] +3 similar issues
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl4/igt@kms_vblank@pipe-b-ts-continuation-suspend.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-apl1/igt@kms_vblank@pipe-b-ts-continuation-suspend.html

  * {igt@perf@polling-parameterized}:
    - shard-hsw:          [FAIL][35] ([i915#1542]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-hsw6/igt@perf@polling-parameterized.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-hsw7/igt@perf@polling-parameterized.html

  * {igt@sysfs_heartbeat_interval@mixed@vcs0}:
    - shard-skl:          [INCOMPLETE][37] ([i915#198]) -> [PASS][38]
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-skl7/igt@sysfs_heartbeat_interval@mixed@vcs0.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-skl5/igt@sysfs_heartbeat_interval@mixed@vcs0.html

  
#### Warnings ####

  * igt@kms_fbcon_fbt@fbc-suspend:
    - shard-kbl:          [DMESG-FAIL][39] ([i915#180] / [i915#95]) -> [FAIL][40] ([i915#93] / [i915#95])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-kbl6/igt@kms_fbcon_fbt@fbc-suspend.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-kbl6/igt@kms_fbcon_fbt@fbc-suspend.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-7efc:
    - shard-apl:          [FAIL][41] ([fdo#108145] / [i915#265] / [i915#95]) -> [FAIL][42] ([fdo#108145] / [i915#265])
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl4/igt@kms_plane_alpha_blend@pipe-c-alpha-7efc.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-apl2/igt@kms_plane_alpha_blend@pipe-c-alpha-7efc.html

  * igt@runner@aborted:
    - shard-apl:          ([FAIL][43], [FAIL][44]) ([i915#1423] / [i915#716]) -> [FAIL][45] ([i915#1423])
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl3/igt@runner@aborted.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8298/shard-apl3/igt@runner@aborted.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/shard-apl4/igt@runner@aborted.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [i915#1066]: https://gitlab.freedesktop.org/drm/intel/issues/1066
  [i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
  [i915#1423]: https://gitlab.freedesktop.org/drm/intel/issues/1423
  [i915#1531]: https://gitlab.freedesktop.org/drm/intel/issues/1531
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#1658]: https://gitlab.freedesktop.org/drm/intel/issues/1658
  [i915#1676]: https://gitlab.freedesktop.org/drm/intel/issues/1676
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
  [i915#221]: https://gitlab.freedesktop.org/drm/intel/issues/221
  [i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
  [i915#34]: https://gitlab.freedesktop.org/drm/intel/issues/34
  [i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
  [i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95


Participating hosts (10 -> 10)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8298 -> Patchwork_17304

  CI-20190529: 20190529
  CI_DRM_8298: 17f82f0c2857d0b442adbdb62eb44b61d0f5b775 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5589: 31962324ac86f029e2841e56e97c42cf9d572956 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17304: 6b267f98398f217419dc7403a953f518eec588bb @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17304/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 05/59] drm/vboxvidoe: use managed pci functions
  2020-04-15 17:44       ` [Intel-gfx] " Daniel Vetter
@ 2020-04-20 13:16         ` Hans de Goede
  -1 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-20 13:16 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg,
	DRI Development, Daniel Vetter

Hi,

On 4/15/20 7:44 PM, Daniel Vetter wrote:
> On Wed, Apr 15, 2020 at 05:03:55PM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 4/15/20 9:39 AM, Daniel Vetter wrote:
>>> Allows us to drop the cleanup code on the floor.
>>>
>>> Sam noticed in his review:
>>>> With this change we avoid calling pci_disable_device()
>>>> twise in case vbox_mm_init() fails.
>>>> Once in vbox_hw_fini() and once in the error path.
>>>
>>> v2: Include Sam's review remarks
>>>
>>> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>    drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>>>    drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>>>    2 files changed, 3 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> index cfa4639c5142..cf2e3e6a2388 100644
>>> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>    	pci_set_drvdata(pdev, vbox);
>>>    	mutex_init(&vbox->hw_mutex);
>>> -	ret = pci_enable_device(pdev);
>>> +	ret = pcim_enable_device(pdev);
>>>    	if (ret)
>>>    		return ret;
>>>    	ret = vbox_hw_init(vbox);
>>>    	if (ret)
>>> -		goto err_pci_disable;
>>> +		return ret;
>>>    	ret = vbox_mm_init(vbox);
>>>    	if (ret)
>>> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>    	vbox_mm_fini(vbox);
>>>    err_hw_fini:
>>>    	vbox_hw_fini(vbox);
>>> -err_pci_disable:
>>> -	pci_disable_device(pdev);
>>>    	return ret;
>>>    }
>>> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> index 9dcab115a261..1336ab9795fc 100644
>>> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>>>    	for (i = 0; i < vbox->num_crtcs; ++i)
>>>    		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
>>> -
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>>>    }
>>>    /* Do we support the 4.3 plus mode hint reporting interface? */
>>
>> This seems to be missing the conversion of the iomap_range call to
>> the devm equivalent ?   :
>>
>> drivers/gpu/drm/vboxvideo/vbox_main.c
>> 44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...
> 
> pcim_enable_device is pure magic, it converts _all_ pci_ calls on that
> device to the managed version. There's no other manged pci_ functions (ok
> 1-2 more, but they're rather special).

Ah I see, magic indeed.

Well with that explained, this is:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



>>> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>>>    	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>>>    	vbox->guest_pool = gen_pool_create(4, -1);
>>>    	if (!vbox->guest_pool)
>>> -		goto err_unmap_guest_heap;
>>> +		return -ENOMEM;
>>>    	ret = gen_pool_add_virt(vbox->guest_pool,
>>>    				(unsigned long)vbox->guest_heap,
>>> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>>>    err_destroy_guest_pool:
>>>    	gen_pool_destroy(vbox->guest_pool);
>>> -err_unmap_guest_heap:
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>>>    	return ret;
>>>    }
>>> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>>>    {
>>>    	vbox_accel_fini(vbox);
>>>    	gen_pool_destroy(vbox->guest_pool);
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>>>    }
>>>
>>
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 05/59] drm/vboxvidoe: use managed pci functions
@ 2020-04-20 13:16         ` Hans de Goede
  0 siblings, 0 replies; 317+ messages in thread
From: Hans de Goede @ 2020-04-20 13:16 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Sam Ravnborg,
	DRI Development, Daniel Vetter

Hi,

On 4/15/20 7:44 PM, Daniel Vetter wrote:
> On Wed, Apr 15, 2020 at 05:03:55PM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 4/15/20 9:39 AM, Daniel Vetter wrote:
>>> Allows us to drop the cleanup code on the floor.
>>>
>>> Sam noticed in his review:
>>>> With this change we avoid calling pci_disable_device()
>>>> twise in case vbox_mm_init() fails.
>>>> Once in vbox_hw_fini() and once in the error path.
>>>
>>> v2: Include Sam's review remarks
>>>
>>> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>    drivers/gpu/drm/vboxvideo/vbox_drv.c  | 6 ++----
>>>    drivers/gpu/drm/vboxvideo/vbox_main.c | 7 +------
>>>    2 files changed, 3 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> index cfa4639c5142..cf2e3e6a2388 100644
>>> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
>>> @@ -55,13 +55,13 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>    	pci_set_drvdata(pdev, vbox);
>>>    	mutex_init(&vbox->hw_mutex);
>>> -	ret = pci_enable_device(pdev);
>>> +	ret = pcim_enable_device(pdev);
>>>    	if (ret)
>>>    		return ret;
>>>    	ret = vbox_hw_init(vbox);
>>>    	if (ret)
>>> -		goto err_pci_disable;
>>> +		return ret;
>>>    	ret = vbox_mm_init(vbox);
>>>    	if (ret)
>>> @@ -91,8 +91,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>>    	vbox_mm_fini(vbox);
>>>    err_hw_fini:
>>>    	vbox_hw_fini(vbox);
>>> -err_pci_disable:
>>> -	pci_disable_device(pdev);
>>>    	return ret;
>>>    }
>>> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> index 9dcab115a261..1336ab9795fc 100644
>>> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
>>> @@ -71,8 +71,6 @@ static void vbox_accel_fini(struct vbox_private *vbox)
>>>    	for (i = 0; i < vbox->num_crtcs; ++i)
>>>    		vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i);
>>> -
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
>>>    }
>>>    /* Do we support the 4.3 plus mode hint reporting interface? */
>>
>> This seems to be missing the conversion of the iomap_range call to
>> the devm equivalent ?   :
>>
>> drivers/gpu/drm/vboxvideo/vbox_main.c
>> 44:     vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, ...
> 
> pcim_enable_device is pure magic, it converts _all_ pci_ calls on that
> device to the managed version. There's no other manged pci_ functions (ok
> 1-2 more, but they're rather special).

Ah I see, magic indeed.

Well with that explained, this is:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



>>> @@ -125,7 +123,7 @@ int vbox_hw_init(struct vbox_private *vbox)
>>>    	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
>>>    	vbox->guest_pool = gen_pool_create(4, -1);
>>>    	if (!vbox->guest_pool)
>>> -		goto err_unmap_guest_heap;
>>> +		return -ENOMEM;
>>>    	ret = gen_pool_add_virt(vbox->guest_pool,
>>>    				(unsigned long)vbox->guest_heap,
>>> @@ -168,8 +166,6 @@ int vbox_hw_init(struct vbox_private *vbox)
>>>    err_destroy_guest_pool:
>>>    	gen_pool_destroy(vbox->guest_pool);
>>> -err_unmap_guest_heap:
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>>>    	return ret;
>>>    }
>>> @@ -177,5 +173,4 @@ void vbox_hw_fini(struct vbox_private *vbox)
>>>    {
>>>    	vbox_accel_fini(vbox);
>>>    	gen_pool_destroy(vbox->guest_pool);
>>> -	pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
>>>    }
>>>
>>
> 

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-20 13:36     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-20 13:36 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Paul Kocialkowski, Daniel Vetter, Sam Ravnborg, Laurent Pinchart,
	DRI Development


[-- Attachment #1.1.1: Type: text/plain, Size: 5037 bytes --]

Hi

Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Add a new macro helper to combine the usual init sequence in drivers,
> consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
> triplet. This allows us to remove the rather unsightly
> drmm_add_final_kfree from all currently merged drivers.
> 
> The kerneldoc is only added for this new function. Existing kerneldoc
> and examples will be udated at the very end, since once all drivers
> are converted over to devm_drm_dev_alloc we can unexport a lot of
> interim functions and make the documentation for driver authors a lot
> cleaner and less confusing. There will be only one true way to
> initialize a drm_device at the end of this, which is going to be
> devm_drm_dev_alloc.
> 
> v2:
> - Actually explain what this is for in the commit message (Sam)
> - Fix checkpatch issues (Sam)
> 
> Acked-by: Noralf Trønnes <noralf@tronnes.org>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Sorry for being late. A number of nits are listed below. In any case:

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Best regards
Thomas

> ---
>  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
>  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 1bb4f636b83c..8e1813d2a12e 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
>  }
>  EXPORT_SYMBOL(devm_drm_dev_init);
>  
> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> +			   size_t size, size_t offset)

Maybe rename 'offset' of 'dev_offset' to make the relationship clear.

> +{
> +	void *container;
> +	struct drm_device *drm;
> +	int ret;
> +
> +	container = kzalloc(size, GFP_KERNEL);
> +	if (!container)
> +		return ERR_PTR(-ENOMEM);
> +
> +	drm = container + offset;

While convenient, I somewhat dislike the use of void* variables. I'd use
unsigned char* for container and do an explicit cast to struct
drm_device* here.

> +	ret = devm_drm_dev_init(parent, drm, driver);
> +	if (ret) {
> +		kfree(container);
> +		return ERR_PTR(ret);
> +	}
> +	drmm_add_final_kfree(drm, container);
> +
> +	return container;
> +}
> +EXPORT_SYMBOL(__devm_drm_dev_alloc);
> +
>  /**
>   * drm_dev_alloc - Allocate new DRM device
>   * @driver: DRM driver to allocate device for
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index e7c6ea261ed1..f07f15721254 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
>  		      struct drm_device *dev,
>  		      struct drm_driver *driver);
>  
> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> +			   size_t size, size_t offset);
> +
> +/**
> + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
> + * @parent: Parent device object
> + * @driver: DRM driver
> + * @type: the type of the struct which contains struct &drm_device
> + * @member: the name of the &drm_device within @type.
> + *
> + * This allocates and initialize a new DRM device. No device registration is done.
> + * Call drm_dev_register() to advertice the device to user space and register it
> + * with other core subsystems. This should be done last in the device
> + * initialization sequence to make sure userspace can't access an inconsistent
> + * state.
> + *
> + * The initial ref-count of the object is 1. Use drm_dev_get() and
> + * drm_dev_put() to take and drop further ref-counts.
> + *
> + * It is recommended that drivers embed &struct drm_device into their own device
> + * structure.
> + *
> + * Note that this manages the lifetime of the resulting &drm_device
> + * automatically using devres. The DRM device initialized with this function is
> + * automatically put on driver detach using drm_dev_put().
> + *
> + * RETURNS:
> + * Pointer to new DRM device, or ERR_PTR on failure.
> + */
> +#define devm_drm_dev_alloc(parent, driver, type, member) \

I'd replace 'member' with 'dev_field' to make the relation ship clear.

> +	((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
> +				       offsetof(type, member)))
> +
>  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
>  				 struct device *parent);
>  int drm_dev_register(struct drm_device *dev, unsigned long flags);
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-20 13:36     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-20 13:36 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Paul Kocialkowski, Daniel Vetter, Sam Ravnborg, Laurent Pinchart,
	DRI Development


[-- Attachment #1.1.1: Type: text/plain, Size: 5037 bytes --]

Hi

Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> Add a new macro helper to combine the usual init sequence in drivers,
> consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
> triplet. This allows us to remove the rather unsightly
> drmm_add_final_kfree from all currently merged drivers.
> 
> The kerneldoc is only added for this new function. Existing kerneldoc
> and examples will be udated at the very end, since once all drivers
> are converted over to devm_drm_dev_alloc we can unexport a lot of
> interim functions and make the documentation for driver authors a lot
> cleaner and less confusing. There will be only one true way to
> initialize a drm_device at the end of this, which is going to be
> devm_drm_dev_alloc.
> 
> v2:
> - Actually explain what this is for in the commit message (Sam)
> - Fix checkpatch issues (Sam)
> 
> Acked-by: Noralf Trønnes <noralf@tronnes.org>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Sorry for being late. A number of nits are listed below. In any case:

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Best regards
Thomas

> ---
>  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
>  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 1bb4f636b83c..8e1813d2a12e 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
>  }
>  EXPORT_SYMBOL(devm_drm_dev_init);
>  
> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> +			   size_t size, size_t offset)

Maybe rename 'offset' of 'dev_offset' to make the relationship clear.

> +{
> +	void *container;
> +	struct drm_device *drm;
> +	int ret;
> +
> +	container = kzalloc(size, GFP_KERNEL);
> +	if (!container)
> +		return ERR_PTR(-ENOMEM);
> +
> +	drm = container + offset;

While convenient, I somewhat dislike the use of void* variables. I'd use
unsigned char* for container and do an explicit cast to struct
drm_device* here.

> +	ret = devm_drm_dev_init(parent, drm, driver);
> +	if (ret) {
> +		kfree(container);
> +		return ERR_PTR(ret);
> +	}
> +	drmm_add_final_kfree(drm, container);
> +
> +	return container;
> +}
> +EXPORT_SYMBOL(__devm_drm_dev_alloc);
> +
>  /**
>   * drm_dev_alloc - Allocate new DRM device
>   * @driver: DRM driver to allocate device for
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index e7c6ea261ed1..f07f15721254 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
>  		      struct drm_device *dev,
>  		      struct drm_driver *driver);
>  
> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> +			   size_t size, size_t offset);
> +
> +/**
> + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
> + * @parent: Parent device object
> + * @driver: DRM driver
> + * @type: the type of the struct which contains struct &drm_device
> + * @member: the name of the &drm_device within @type.
> + *
> + * This allocates and initialize a new DRM device. No device registration is done.
> + * Call drm_dev_register() to advertice the device to user space and register it
> + * with other core subsystems. This should be done last in the device
> + * initialization sequence to make sure userspace can't access an inconsistent
> + * state.
> + *
> + * The initial ref-count of the object is 1. Use drm_dev_get() and
> + * drm_dev_put() to take and drop further ref-counts.
> + *
> + * It is recommended that drivers embed &struct drm_device into their own device
> + * structure.
> + *
> + * Note that this manages the lifetime of the resulting &drm_device
> + * automatically using devres. The DRM device initialized with this function is
> + * automatically put on driver detach using drm_dev_put().
> + *
> + * RETURNS:
> + * Pointer to new DRM device, or ERR_PTR on failure.
> + */
> +#define devm_drm_dev_alloc(parent, driver, type, member) \

I'd replace 'member' with 'dev_field' to make the relation ship clear.

> +	((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
> +				       offsetof(type, member)))
> +
>  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
>  				 struct device *parent);
>  int drm_dev_register(struct drm_device *dev, unsigned long flags);
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-21  7:37     ` Gerd Hoffmann
  -1 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, virtualization,
	DRI Development, Dave Airlie

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is.

Indeed.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

take care,
  Gerd

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-21  7:37     ` Gerd Hoffmann
  0 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, virtualization,
	DRI Development, Dave Airlie

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is.

Indeed.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

take care,
  Gerd

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-21  7:37     ` Gerd Hoffmann
  0 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, virtualization,
	DRI Development, Dave Airlie

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is.

Indeed.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

take care,
  Gerd

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-21  7:39     ` Gerd Hoffmann
  -1 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:39 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-21  7:39     ` Gerd Hoffmann
  0 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:39 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-21  7:39     ` Gerd Hoffmann
  0 siblings, 0 replies; 317+ messages in thread
From: Gerd Hoffmann @ 2020-04-21  7:39 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-20 13:36     ` [Intel-gfx] " Thomas Zimmermann
@ 2020-04-21 10:45       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-21 10:45 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Paul Kocialkowski,
	Laurent Pinchart, Daniel Vetter, Sam Ravnborg

On Mon, Apr 20, 2020 at 3:37 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> > Add a new macro helper to combine the usual init sequence in drivers,
> > consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
> > triplet. This allows us to remove the rather unsightly
> > drmm_add_final_kfree from all currently merged drivers.
> >
> > The kerneldoc is only added for this new function. Existing kerneldoc
> > and examples will be udated at the very end, since once all drivers
> > are converted over to devm_drm_dev_alloc we can unexport a lot of
> > interim functions and make the documentation for driver authors a lot
> > cleaner and less confusing. There will be only one true way to
> > initialize a drm_device at the end of this, which is going to be
> > devm_drm_dev_alloc.
> >
> > v2:
> > - Actually explain what this is for in the commit message (Sam)
> > - Fix checkpatch issues (Sam)
> >
> > Acked-by: Noralf Trønnes <noralf@tronnes.org>
> > Cc: Noralf Trønnes <noralf@tronnes.org>
> > Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Thanks for taking a look, some questions on your suggestions below.

> Sorry for being late. A number of nits are listed below. In any case:
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> Best regards
> Thomas
>
> > ---
> >  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
> >  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
> >  2 files changed, 56 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 1bb4f636b83c..8e1813d2a12e 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
> >  }
> >  EXPORT_SYMBOL(devm_drm_dev_init);
> >
> > +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> > +                        size_t size, size_t offset)
>
> Maybe rename 'offset' of 'dev_offset' to make the relationship clear.

Hm, I see the point of this (and the dev_field below, although I'd go
with dev_member there for some consistency with other macros using
offset_of or container_of), but I'm not sure about the dev_ prefix.
Drivers use that sometimes for the struct device *, and usage for
struct drm_device * is also very inconsistent. I've seen ddev, drm,
dev and base (that one only for embedded structs ofc). So not sure
which prefix to pick, aside from dev_ seems the most confusing. Got
ideas?

> > +{
> > +     void *container;
> > +     struct drm_device *drm;
> > +     int ret;
> > +
> > +     container = kzalloc(size, GFP_KERNEL);
> > +     if (!container)
> > +             return ERR_PTR(-ENOMEM);
> > +
> > +     drm = container + offset;
>
> While convenient, I somewhat dislike the use of void* variables. I'd use
> unsigned char* for container and do an explicit cast to struct
> drm_device* here.

I thought ever since C89 the explicit recommendation for untyped
pointer math has been void *, and no longer char *, with the spec
being explicit that void * pointer math works exactly like char *. So
not clear on why you think char * is preferred here. I'm also not
aware of any other kernel code that casts to char * for untyped
pointer math. So unless you have some supporting evidence, I'll skip
this one, ok?

Thanks, Daniel

> > +     ret = devm_drm_dev_init(parent, drm, driver);
> > +     if (ret) {
> > +             kfree(container);
> > +             return ERR_PTR(ret);
> > +     }
> > +     drmm_add_final_kfree(drm, container);
> > +
> > +     return container;
> > +}
> > +EXPORT_SYMBOL(__devm_drm_dev_alloc);
> > +
> >  /**
> >   * drm_dev_alloc - Allocate new DRM device
> >   * @driver: DRM driver to allocate device for
> > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > index e7c6ea261ed1..f07f15721254 100644
> > --- a/include/drm/drm_drv.h
> > +++ b/include/drm/drm_drv.h
> > @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
> >                     struct drm_device *dev,
> >                     struct drm_driver *driver);
> >
> > +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> > +                        size_t size, size_t offset);
> > +
> > +/**
> > + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
> > + * @parent: Parent device object
> > + * @driver: DRM driver
> > + * @type: the type of the struct which contains struct &drm_device
> > + * @member: the name of the &drm_device within @type.
> > + *
> > + * This allocates and initialize a new DRM device. No device registration is done.
> > + * Call drm_dev_register() to advertice the device to user space and register it
> > + * with other core subsystems. This should be done last in the device
> > + * initialization sequence to make sure userspace can't access an inconsistent
> > + * state.
> > + *
> > + * The initial ref-count of the object is 1. Use drm_dev_get() and
> > + * drm_dev_put() to take and drop further ref-counts.
> > + *
> > + * It is recommended that drivers embed &struct drm_device into their own device
> > + * structure.
> > + *
> > + * Note that this manages the lifetime of the resulting &drm_device
> > + * automatically using devres. The DRM device initialized with this function is
> > + * automatically put on driver detach using drm_dev_put().
> > + *
> > + * RETURNS:
> > + * Pointer to new DRM device, or ERR_PTR on failure.
> > + */
> > +#define devm_drm_dev_alloc(parent, driver, type, member) \
>
> I'd replace 'member' with 'dev_field' to make the relation ship clear.
>
> > +     ((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
> > +                                    offsetof(type, member)))
> > +
> >  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
> >                                struct device *parent);
> >  int drm_dev_register(struct drm_device *dev, unsigned long flags);
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-21 10:45       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-21 10:45 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Intel Graphics Development, DRI Development, Paul Kocialkowski,
	Laurent Pinchart, Daniel Vetter, Sam Ravnborg

On Mon, Apr 20, 2020 at 3:37 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 15.04.20 um 09:39 schrieb Daniel Vetter:
> > Add a new macro helper to combine the usual init sequence in drivers,
> > consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
> > triplet. This allows us to remove the rather unsightly
> > drmm_add_final_kfree from all currently merged drivers.
> >
> > The kerneldoc is only added for this new function. Existing kerneldoc
> > and examples will be udated at the very end, since once all drivers
> > are converted over to devm_drm_dev_alloc we can unexport a lot of
> > interim functions and make the documentation for driver authors a lot
> > cleaner and less confusing. There will be only one true way to
> > initialize a drm_device at the end of this, which is going to be
> > devm_drm_dev_alloc.
> >
> > v2:
> > - Actually explain what this is for in the commit message (Sam)
> > - Fix checkpatch issues (Sam)
> >
> > Acked-by: Noralf Trønnes <noralf@tronnes.org>
> > Cc: Noralf Trønnes <noralf@tronnes.org>
> > Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Thanks for taking a look, some questions on your suggestions below.

> Sorry for being late. A number of nits are listed below. In any case:
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> Best regards
> Thomas
>
> > ---
> >  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
> >  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
> >  2 files changed, 56 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 1bb4f636b83c..8e1813d2a12e 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
> >  }
> >  EXPORT_SYMBOL(devm_drm_dev_init);
> >
> > +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> > +                        size_t size, size_t offset)
>
> Maybe rename 'offset' of 'dev_offset' to make the relationship clear.

Hm, I see the point of this (and the dev_field below, although I'd go
with dev_member there for some consistency with other macros using
offset_of or container_of), but I'm not sure about the dev_ prefix.
Drivers use that sometimes for the struct device *, and usage for
struct drm_device * is also very inconsistent. I've seen ddev, drm,
dev and base (that one only for embedded structs ofc). So not sure
which prefix to pick, aside from dev_ seems the most confusing. Got
ideas?

> > +{
> > +     void *container;
> > +     struct drm_device *drm;
> > +     int ret;
> > +
> > +     container = kzalloc(size, GFP_KERNEL);
> > +     if (!container)
> > +             return ERR_PTR(-ENOMEM);
> > +
> > +     drm = container + offset;
>
> While convenient, I somewhat dislike the use of void* variables. I'd use
> unsigned char* for container and do an explicit cast to struct
> drm_device* here.

I thought ever since C89 the explicit recommendation for untyped
pointer math has been void *, and no longer char *, with the spec
being explicit that void * pointer math works exactly like char *. So
not clear on why you think char * is preferred here. I'm also not
aware of any other kernel code that casts to char * for untyped
pointer math. So unless you have some supporting evidence, I'll skip
this one, ok?

Thanks, Daniel

> > +     ret = devm_drm_dev_init(parent, drm, driver);
> > +     if (ret) {
> > +             kfree(container);
> > +             return ERR_PTR(ret);
> > +     }
> > +     drmm_add_final_kfree(drm, container);
> > +
> > +     return container;
> > +}
> > +EXPORT_SYMBOL(__devm_drm_dev_alloc);
> > +
> >  /**
> >   * drm_dev_alloc - Allocate new DRM device
> >   * @driver: DRM driver to allocate device for
> > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> > index e7c6ea261ed1..f07f15721254 100644
> > --- a/include/drm/drm_drv.h
> > +++ b/include/drm/drm_drv.h
> > @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
> >                     struct drm_device *dev,
> >                     struct drm_driver *driver);
> >
> > +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
> > +                        size_t size, size_t offset);
> > +
> > +/**
> > + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
> > + * @parent: Parent device object
> > + * @driver: DRM driver
> > + * @type: the type of the struct which contains struct &drm_device
> > + * @member: the name of the &drm_device within @type.
> > + *
> > + * This allocates and initialize a new DRM device. No device registration is done.
> > + * Call drm_dev_register() to advertice the device to user space and register it
> > + * with other core subsystems. This should be done last in the device
> > + * initialization sequence to make sure userspace can't access an inconsistent
> > + * state.
> > + *
> > + * The initial ref-count of the object is 1. Use drm_dev_get() and
> > + * drm_dev_put() to take and drop further ref-counts.
> > + *
> > + * It is recommended that drivers embed &struct drm_device into their own device
> > + * structure.
> > + *
> > + * Note that this manages the lifetime of the resulting &drm_device
> > + * automatically using devres. The DRM device initialized with this function is
> > + * automatically put on driver detach using drm_dev_put().
> > + *
> > + * RETURNS:
> > + * Pointer to new DRM device, or ERR_PTR on failure.
> > + */
> > +#define devm_drm_dev_alloc(parent, driver, type, member) \
>
> I'd replace 'member' with 'dev_field' to make the relation ship clear.
>
> > +     ((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
> > +                                    offsetof(type, member)))
> > +
> >  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
> >                                struct device *parent);
> >  int drm_dev_register(struct drm_device *dev, unsigned long flags);
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-21 11:03     ` Tomi Valkeinen
  -1 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:03 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:39, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
>   1 file changed, 4 insertions(+), 11 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc
@ 2020-04-21 11:03     ` Tomi Valkeinen
  0 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:03 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:39, Daniel Vetter wrote:
> Already using devm_drm_dev_init, so very simple replacment.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_drv.c | 15 ++++-----------
>   1 file changed, 4 insertions(+), 11 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-21 11:05     ` Tomi Valkeinen
  -1 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:39, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_crtc.c  | 16 ++++++++--------
>   drivers/gpu/drm/tidss/tidss_drv.c   |  2 --
>   drivers/gpu/drm/tidss/tidss_drv.h   |  2 ++
>   drivers/gpu/drm/tidss/tidss_irq.c   | 12 ++++++------
>   drivers/gpu/drm/tidss/tidss_kms.c   |  2 +-
>   drivers/gpu/drm/tidss/tidss_plane.c |  6 +++---
>   6 files changed, 20 insertions(+), 20 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private
@ 2020-04-21 11:05     ` Tomi Valkeinen
  0 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:39, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_crtc.c  | 16 ++++++++--------
>   drivers/gpu/drm/tidss/tidss_drv.c   |  2 --
>   drivers/gpu/drm/tidss/tidss_drv.h   |  2 ++
>   drivers/gpu/drm/tidss/tidss_irq.c   | 12 ++++++------
>   drivers/gpu/drm/tidss/tidss_kms.c   |  2 +-
>   drivers/gpu/drm/tidss/tidss_plane.c |  6 +++---
>   6 files changed, 20 insertions(+), 20 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 25/59] drm/tidss: Delete tidss->saved_state
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-21 11:05     ` Tomi Valkeinen
  -1 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:40, Daniel Vetter wrote:
> Not used anymore since the switch to suspend/resume helpers.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_drv.h | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
> index b23cd95c8d78..3b0a3d87b7c4 100644
> --- a/drivers/gpu/drm/tidss/tidss_drv.h
> +++ b/drivers/gpu/drm/tidss/tidss_drv.h
> @@ -29,8 +29,6 @@ struct tidss_device {
>   
>   	spinlock_t wait_lock;	/* protects the irq masks */
>   	dispc_irq_t irq_mask;	/* enabled irqs in addition to wait_list */
> -
> -	struct drm_atomic_state *saved_state;
>   };
>   
>   #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
> 

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 25/59] drm/tidss: Delete tidss->saved_state
@ 2020-04-21 11:05     ` Tomi Valkeinen
  0 siblings, 0 replies; 317+ messages in thread
From: Tomi Valkeinen @ 2020-04-21 11:05 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: Daniel Vetter, Sam Ravnborg, Jyri Sarha, DRI Development

On 15/04/2020 10:40, Daniel Vetter wrote:
> Not used anymore since the switch to suspend/resume helpers.
> 
> Tested-by: Jyri Sarha <jsarha@ti.com>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/tidss/tidss_drv.h | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h
> index b23cd95c8d78..3b0a3d87b7c4 100644
> --- a/drivers/gpu/drm/tidss/tidss_drv.h
> +++ b/drivers/gpu/drm/tidss/tidss_drv.h
> @@ -29,8 +29,6 @@ struct tidss_device {
>   
>   	spinlock_t wait_lock;	/* protects the irq masks */
>   	dispc_irq_t irq_mask;	/* enabled irqs in addition to wait_list */
> -
> -	struct drm_atomic_state *saved_state;
>   };
>   
>   #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev)
> 

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-21 10:45       ` [Intel-gfx] " Daniel Vetter
@ 2020-04-21 14:03         ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-21 14:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, Paul Kocialkowski,
	Laurent Pinchart, Daniel Vetter, Sam Ravnborg


[-- Attachment #1.1.1: Type: text/plain, Size: 8033 bytes --]

Hi

Am 21.04.20 um 12:45 schrieb Daniel Vetter:
> On Mon, Apr 20, 2020 at 3:37 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> Hi
>>
>> Am 15.04.20 um 09:39 schrieb Daniel Vetter:
>>> Add a new macro helper to combine the usual init sequence in drivers,
>>> consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
>>> triplet. This allows us to remove the rather unsightly
>>> drmm_add_final_kfree from all currently merged drivers.
>>>
>>> The kerneldoc is only added for this new function. Existing kerneldoc
>>> and examples will be udated at the very end, since once all drivers
>>> are converted over to devm_drm_dev_alloc we can unexport a lot of
>>> interim functions and make the documentation for driver authors a lot
>>> cleaner and less confusing. There will be only one true way to
>>> initialize a drm_device at the end of this, which is going to be
>>> devm_drm_dev_alloc.
>>>
>>> v2:
>>> - Actually explain what this is for in the commit message (Sam)
>>> - Fix checkpatch issues (Sam)
>>>
>>> Acked-by: Noralf Trønnes <noralf@tronnes.org>
>>> Cc: Noralf Trønnes <noralf@tronnes.org>
>>> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
>>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Thanks for taking a look, some questions on your suggestions below.
> 
>> Sorry for being late. A number of nits are listed below. In any case:
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>>
>> Best regards
>> Thomas
>>
>>> ---
>>>  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
>>>  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
>>>  2 files changed, 56 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 1bb4f636b83c..8e1813d2a12e 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
>>>  }
>>>  EXPORT_SYMBOL(devm_drm_dev_init);
>>>
>>> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
>>> +                        size_t size, size_t offset)
>>
>> Maybe rename 'offset' of 'dev_offset' to make the relationship clear.
> 
> Hm, I see the point of this (and the dev_field below, although I'd go
> with dev_member there for some consistency with other macros using
> offset_of or container_of), but I'm not sure about the dev_ prefix.
> Drivers use that sometimes for the struct device *, and usage for
> struct drm_device * is also very inconsistent. I've seen ddev, drm,
> dev and base (that one only for embedded structs ofc). So not sure
> which prefix to pick, aside from dev_ seems the most confusing. Got
> ideas?

We have pdev for the PCI device, dev for the abstract device, and things
like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
like drm, because it could be anything in DRM. I guess struct drm_driver
is more 'drm' than struct drm_device.

But all of this is bikeshedding. It's probably best to keep the patch
as-is, and maybe rename variables later if we ever find consent on the
naming.

> 
>>> +{
>>> +     void *container;
>>> +     struct drm_device *drm;
>>> +     int ret;
>>> +
>>> +     container = kzalloc(size, GFP_KERNEL);
>>> +     if (!container)
>>> +             return ERR_PTR(-ENOMEM);
>>> +
>>> +     drm = container + offset;
>>
>> While convenient, I somewhat dislike the use of void* variables. I'd use
>> unsigned char* for container and do an explicit cast to struct
>> drm_device* here.
> 
> I thought ever since C89 the explicit recommendation for untyped
> pointer math has been void *, and no longer char *, with the spec
> being explicit that void * pointer math works exactly like char *. So

From how I understand the C spec, I think it's the other way around. I
had to look up the sections from the C11 spec:

Sec 6.5.6 Additive operators

 2 For addition, either both operands shall have arithmetic type, or
   one operand shall be a pointer to a complete object type and the
   other shall have integer type. (Incrementing is equivalent to adding
   1.)

About void it says that it's not a complete type.

Sec 6.2.5 Types

 19 The void type comprises an empty set of values; it is an incomplete
    object type that cannot be completed.

Arithmetic on void* is a gcc extension AFAIK.

> not clear on why you think char * is preferred here. I'm also not
> aware of any other kernel code that casts to char * for untyped
> pointer math. So unless you have some supporting evidence, I'll skip
> this one, ok?

I'm really just bikeshedding on things I'd have done differently.

Best regards
Thomas

> 
> Thanks, Daniel
> 
>>> +     ret = devm_drm_dev_init(parent, drm, driver);
>>> +     if (ret) {
>>> +             kfree(container);
>>> +             return ERR_PTR(ret);
>>> +     }
>>> +     drmm_add_final_kfree(drm, container);
>>> +
>>> +     return container;
>>> +}
>>> +EXPORT_SYMBOL(__devm_drm_dev_alloc);
>>> +
>>>  /**
>>>   * drm_dev_alloc - Allocate new DRM device
>>>   * @driver: DRM driver to allocate device for
>>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>>> index e7c6ea261ed1..f07f15721254 100644
>>> --- a/include/drm/drm_drv.h
>>> +++ b/include/drm/drm_drv.h
>>> @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
>>>                     struct drm_device *dev,
>>>                     struct drm_driver *driver);
>>>
>>> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
>>> +                        size_t size, size_t offset);
>>> +
>>> +/**
>>> + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
>>> + * @parent: Parent device object
>>> + * @driver: DRM driver
>>> + * @type: the type of the struct which contains struct &drm_device
>>> + * @member: the name of the &drm_device within @type.
>>> + *
>>> + * This allocates and initialize a new DRM device. No device registration is done.
>>> + * Call drm_dev_register() to advertice the device to user space and register it
>>> + * with other core subsystems. This should be done last in the device
>>> + * initialization sequence to make sure userspace can't access an inconsistent
>>> + * state.
>>> + *
>>> + * The initial ref-count of the object is 1. Use drm_dev_get() and
>>> + * drm_dev_put() to take and drop further ref-counts.
>>> + *
>>> + * It is recommended that drivers embed &struct drm_device into their own device
>>> + * structure.
>>> + *
>>> + * Note that this manages the lifetime of the resulting &drm_device
>>> + * automatically using devres. The DRM device initialized with this function is
>>> + * automatically put on driver detach using drm_dev_put().
>>> + *
>>> + * RETURNS:
>>> + * Pointer to new DRM device, or ERR_PTR on failure.
>>> + */
>>> +#define devm_drm_dev_alloc(parent, driver, type, member) \
>>
>> I'd replace 'member' with 'dev_field' to make the relation ship clear.
>>
>>> +     ((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
>>> +                                    offsetof(type, member)))
>>> +
>>>  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
>>>                                struct device *parent);
>>>  int drm_dev_register(struct drm_device *dev, unsigned long flags);
>>>
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-21 14:03         ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-04-21 14:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, Paul Kocialkowski,
	Laurent Pinchart, Daniel Vetter, Sam Ravnborg


[-- Attachment #1.1.1: Type: text/plain, Size: 8033 bytes --]

Hi

Am 21.04.20 um 12:45 schrieb Daniel Vetter:
> On Mon, Apr 20, 2020 at 3:37 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>> Hi
>>
>> Am 15.04.20 um 09:39 schrieb Daniel Vetter:
>>> Add a new macro helper to combine the usual init sequence in drivers,
>>> consisting of a kzalloc + devm_drm_dev_init + drmm_add_final_kfree
>>> triplet. This allows us to remove the rather unsightly
>>> drmm_add_final_kfree from all currently merged drivers.
>>>
>>> The kerneldoc is only added for this new function. Existing kerneldoc
>>> and examples will be udated at the very end, since once all drivers
>>> are converted over to devm_drm_dev_alloc we can unexport a lot of
>>> interim functions and make the documentation for driver authors a lot
>>> cleaner and less confusing. There will be only one true way to
>>> initialize a drm_device at the end of this, which is going to be
>>> devm_drm_dev_alloc.
>>>
>>> v2:
>>> - Actually explain what this is for in the commit message (Sam)
>>> - Fix checkpatch issues (Sam)
>>>
>>> Acked-by: Noralf Trønnes <noralf@tronnes.org>
>>> Cc: Noralf Trønnes <noralf@tronnes.org>
>>> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
>>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> Thanks for taking a look, some questions on your suggestions below.
> 
>> Sorry for being late. A number of nits are listed below. In any case:
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>>
>> Best regards
>> Thomas
>>
>>> ---
>>>  drivers/gpu/drm/drm_drv.c | 23 +++++++++++++++++++++++
>>>  include/drm/drm_drv.h     | 33 +++++++++++++++++++++++++++++++++
>>>  2 files changed, 56 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 1bb4f636b83c..8e1813d2a12e 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -739,6 +739,29 @@ int devm_drm_dev_init(struct device *parent,
>>>  }
>>>  EXPORT_SYMBOL(devm_drm_dev_init);
>>>
>>> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
>>> +                        size_t size, size_t offset)
>>
>> Maybe rename 'offset' of 'dev_offset' to make the relationship clear.
> 
> Hm, I see the point of this (and the dev_field below, although I'd go
> with dev_member there for some consistency with other macros using
> offset_of or container_of), but I'm not sure about the dev_ prefix.
> Drivers use that sometimes for the struct device *, and usage for
> struct drm_device * is also very inconsistent. I've seen ddev, drm,
> dev and base (that one only for embedded structs ofc). So not sure
> which prefix to pick, aside from dev_ seems the most confusing. Got
> ideas?

We have pdev for the PCI device, dev for the abstract device, and things
like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
like drm, because it could be anything in DRM. I guess struct drm_driver
is more 'drm' than struct drm_device.

But all of this is bikeshedding. It's probably best to keep the patch
as-is, and maybe rename variables later if we ever find consent on the
naming.

> 
>>> +{
>>> +     void *container;
>>> +     struct drm_device *drm;
>>> +     int ret;
>>> +
>>> +     container = kzalloc(size, GFP_KERNEL);
>>> +     if (!container)
>>> +             return ERR_PTR(-ENOMEM);
>>> +
>>> +     drm = container + offset;
>>
>> While convenient, I somewhat dislike the use of void* variables. I'd use
>> unsigned char* for container and do an explicit cast to struct
>> drm_device* here.
> 
> I thought ever since C89 the explicit recommendation for untyped
> pointer math has been void *, and no longer char *, with the spec
> being explicit that void * pointer math works exactly like char *. So

From how I understand the C spec, I think it's the other way around. I
had to look up the sections from the C11 spec:

Sec 6.5.6 Additive operators

 2 For addition, either both operands shall have arithmetic type, or
   one operand shall be a pointer to a complete object type and the
   other shall have integer type. (Incrementing is equivalent to adding
   1.)

About void it says that it's not a complete type.

Sec 6.2.5 Types

 19 The void type comprises an empty set of values; it is an incomplete
    object type that cannot be completed.

Arithmetic on void* is a gcc extension AFAIK.

> not clear on why you think char * is preferred here. I'm also not
> aware of any other kernel code that casts to char * for untyped
> pointer math. So unless you have some supporting evidence, I'll skip
> this one, ok?

I'm really just bikeshedding on things I'd have done differently.

Best regards
Thomas

> 
> Thanks, Daniel
> 
>>> +     ret = devm_drm_dev_init(parent, drm, driver);
>>> +     if (ret) {
>>> +             kfree(container);
>>> +             return ERR_PTR(ret);
>>> +     }
>>> +     drmm_add_final_kfree(drm, container);
>>> +
>>> +     return container;
>>> +}
>>> +EXPORT_SYMBOL(__devm_drm_dev_alloc);
>>> +
>>>  /**
>>>   * drm_dev_alloc - Allocate new DRM device
>>>   * @driver: DRM driver to allocate device for
>>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
>>> index e7c6ea261ed1..f07f15721254 100644
>>> --- a/include/drm/drm_drv.h
>>> +++ b/include/drm/drm_drv.h
>>> @@ -626,6 +626,39 @@ int devm_drm_dev_init(struct device *parent,
>>>                     struct drm_device *dev,
>>>                     struct drm_driver *driver);
>>>
>>> +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver,
>>> +                        size_t size, size_t offset);
>>> +
>>> +/**
>>> + * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
>>> + * @parent: Parent device object
>>> + * @driver: DRM driver
>>> + * @type: the type of the struct which contains struct &drm_device
>>> + * @member: the name of the &drm_device within @type.
>>> + *
>>> + * This allocates and initialize a new DRM device. No device registration is done.
>>> + * Call drm_dev_register() to advertice the device to user space and register it
>>> + * with other core subsystems. This should be done last in the device
>>> + * initialization sequence to make sure userspace can't access an inconsistent
>>> + * state.
>>> + *
>>> + * The initial ref-count of the object is 1. Use drm_dev_get() and
>>> + * drm_dev_put() to take and drop further ref-counts.
>>> + *
>>> + * It is recommended that drivers embed &struct drm_device into their own device
>>> + * structure.
>>> + *
>>> + * Note that this manages the lifetime of the resulting &drm_device
>>> + * automatically using devres. The DRM device initialized with this function is
>>> + * automatically put on driver detach using drm_dev_put().
>>> + *
>>> + * RETURNS:
>>> + * Pointer to new DRM device, or ERR_PTR on failure.
>>> + */
>>> +#define devm_drm_dev_alloc(parent, driver, type, member) \
>>
>> I'd replace 'member' with 'dev_field' to make the relation ship clear.
>>
>>> +     ((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
>>> +                                    offsetof(type, member)))
>>> +
>>>  struct drm_device *drm_dev_alloc(struct drm_driver *driver,
>>>                                struct device *parent);
>>>  int drm_dev_register(struct drm_device *dev, unsigned long flags);
>>>
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-21 14:03         ` [Intel-gfx] " Thomas Zimmermann
@ 2020-04-21 20:32           ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-21 20:32 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Paul Kocialkowski, Laurent Pinchart, Daniel Vetter

Hi

> > Hm, I see the point of this (and the dev_field below, although I'd go
> > with dev_member there for some consistency with other macros using
> > offset_of or container_of), but I'm not sure about the dev_ prefix.
> > Drivers use that sometimes for the struct device *, and usage for
> > struct drm_device * is also very inconsistent. I've seen ddev, drm,
> > dev and base (that one only for embedded structs ofc). So not sure
> > which prefix to pick, aside from dev_ seems the most confusing. Got
> > ideas?
> 
> We have pdev for the PCI device, dev for the abstract device, and things
> like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
> like drm, because it could be anything in DRM. I guess struct drm_driver
> is more 'drm' than struct drm_device.
> 
> But all of this is bikeshedding. It's probably best to keep the patch
> as-is, and maybe rename variables later if we ever find consent on the
> naming.

bikeshedding - I know.
But reading code is is quite natural for me that drm equals the central
drm_device data structure. Maybe thats because this was is in the code
I started looking at.

So as an example:

	drm_err(drm, "bla bla\n");

This parses nicely and is easy to type and get right.
And matches nicely that drm_device => drm.
But bikeshedding  - I will go to bed...
(Whatever is the conclusion we should not hold back the patch in
questions).

	Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-21 20:32           ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-21 20:32 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Paul Kocialkowski, Laurent Pinchart, Daniel Vetter

Hi

> > Hm, I see the point of this (and the dev_field below, although I'd go
> > with dev_member there for some consistency with other macros using
> > offset_of or container_of), but I'm not sure about the dev_ prefix.
> > Drivers use that sometimes for the struct device *, and usage for
> > struct drm_device * is also very inconsistent. I've seen ddev, drm,
> > dev and base (that one only for embedded structs ofc). So not sure
> > which prefix to pick, aside from dev_ seems the most confusing. Got
> > ideas?
> 
> We have pdev for the PCI device, dev for the abstract device, and things
> like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
> like drm, because it could be anything in DRM. I guess struct drm_driver
> is more 'drm' than struct drm_device.
> 
> But all of this is bikeshedding. It's probably best to keep the patch
> as-is, and maybe rename variables later if we ever find consent on the
> naming.

bikeshedding - I know.
But reading code is is quite natural for me that drm equals the central
drm_device data structure. Maybe thats because this was is in the code
I started looking at.

So as an example:

	drm_err(drm, "bla bla\n");

This parses nicely and is easy to type and get right.
And matches nicely that drm_device => drm.
But bikeshedding  - I will go to bed...
(Whatever is the conclusion we should not hold back the patch in
questions).

	Sam
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 14:55     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 14:55 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Emil Velikov, DRI Development,
	Thomas Zimmermann, Dave Airlie, Daniel Vetter, Thomas Gleixner,
	Sean Paul

Hi Daniel.

On Wed, Apr 15, 2020 at 09:39:46AM +0200, Daniel Vetter wrote:
> Also init the fbdev emulation before we register the device, that way
> we can rely on the auto-cleanup and simplify the probe error code even
> more.
> 
> v2: Rebase on top of Thomas' patches to remove the return value from
> drm_fbdev_generic_setup()

with the rebase the changelog in confusing as this patch does nothing of
what is described in the changelog.
Only the title (that is in convinently not available when replying to
email) describes what this patch does.

With the changelog properly adjusted:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
>  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 9cc6d075cb40..523f60e02a85 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
>  	struct udl_device *udl;
>  	int r;
>  
> -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> -	if (!udl)
> -		return ERR_PTR(-ENOMEM);
> -
> -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> -	if (r) {
> -		kfree(udl);
> -		return ERR_PTR(r);
> -	}
> +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> +				 struct udl_device, drm);
> +	if (IS_ERR(udl))
> +		return udl;
>  
>  	udl->udev = udev;
>  	udl->drm.dev_private = udl;
> -	drmm_add_final_kfree(&udl->drm, udl);
>  
>  	r = udl_init(udl);
> -	if (r) {
> -		drm_dev_put(&udl->drm);
> +	if (r)
>  		return ERR_PTR(r);
> -	}
>  
>  	usb_set_intfdata(interface, udl);
> +
>  	return udl;
>  }
>  
> @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
>  
>  	r = drm_dev_register(&udl->drm, 0);
>  	if (r)
> -		goto err_free;
> +		return r;
>  
>  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
>  
>  	drm_fbdev_generic_setup(&udl->drm, 0);
>  
>  	return 0;
> -
> -err_free:
> -	drm_dev_put(&udl->drm);
> -	return r;
>  }
>  
>  static void udl_usb_disconnect(struct usb_interface *interface)
> @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
>  	drm_kms_helper_poll_fini(dev);
>  	udl_drop_usb(dev);
>  	drm_dev_unplug(dev);
> -	drm_dev_put(dev);
>  }
>  
>  /*
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
@ 2020-04-24 14:55     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 14:55 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, Thomas Zimmermann,
	Dave Airlie, Daniel Vetter, Thomas Gleixner

Hi Daniel.

On Wed, Apr 15, 2020 at 09:39:46AM +0200, Daniel Vetter wrote:
> Also init the fbdev emulation before we register the device, that way
> we can rely on the auto-cleanup and simplify the probe error code even
> more.
> 
> v2: Rebase on top of Thomas' patches to remove the return value from
> drm_fbdev_generic_setup()

with the rebase the changelog in confusing as this patch does nothing of
what is described in the changelog.
Only the title (that is in convinently not available when replying to
email) describes what this patch does.

With the changelog properly adjusted:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Noralf Trønnes <noralf@tronnes.org>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
>  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 9cc6d075cb40..523f60e02a85 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
>  	struct udl_device *udl;
>  	int r;
>  
> -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> -	if (!udl)
> -		return ERR_PTR(-ENOMEM);
> -
> -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> -	if (r) {
> -		kfree(udl);
> -		return ERR_PTR(r);
> -	}
> +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> +				 struct udl_device, drm);
> +	if (IS_ERR(udl))
> +		return udl;
>  
>  	udl->udev = udev;
>  	udl->drm.dev_private = udl;
> -	drmm_add_final_kfree(&udl->drm, udl);
>  
>  	r = udl_init(udl);
> -	if (r) {
> -		drm_dev_put(&udl->drm);
> +	if (r)
>  		return ERR_PTR(r);
> -	}
>  
>  	usb_set_intfdata(interface, udl);
> +
>  	return udl;
>  }
>  
> @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
>  
>  	r = drm_dev_register(&udl->drm, 0);
>  	if (r)
> -		goto err_free;
> +		return r;
>  
>  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
>  
>  	drm_fbdev_generic_setup(&udl->drm, 0);
>  
>  	return 0;
> -
> -err_free:
> -	drm_dev_put(&udl->drm);
> -	return r;
>  }
>  
>  static void udl_usb_disconnect(struct usb_interface *interface)
> @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
>  	drm_kms_helper_poll_fini(dev);
>  	udl_drop_usb(dev);
>  	drm_dev_unplug(dev);
> -	drm_dev_put(dev);
>  }
>  
>  /*
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 15:09     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:09 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

Hi Daniel

On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> Also need to remove the drm_dev_put from the remove hook.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
>  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
>  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
>  3 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 09102e2efabc..6b4ae4c5fb76 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		return -EINVAL; /* TODO: ENODEV ? */
>  	}
>  
> -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> -	if (!qdev)
> +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> +				  struct qxl_device, ddev);
> +	if (IS_ERR(qdev)) {
> +		pr_err("Unable to init drm dev");
>  		return -ENOMEM;
> +	}

The other patches do not add any error message when devm_drm_dev_alloc()
fails and driver core will log that driver init failed.

So the pr_err() above should be dropped.
I know it comes from qxl_device_init() but that does not make it a good
idea.

With this fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

>  
>  	ret = pci_enable_device(pdev);
>  	if (ret)
> -		goto free_dev;
> +		return ret;
>  
>  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
>  	if (ret)
> @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		}
>  	}
>  
> -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> +	ret = qxl_device_init(qdev, pdev);
>  	if (ret)
>  		goto put_vga;
>  
> @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
>  disable_pci:
>  	pci_disable_device(pdev);
> -free_dev:
> -	kfree(qdev);
> +
>  	return ret;
>  }
>  
> @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
>  	drm_atomic_helper_shutdown(dev);
>  	if (is_vga(pdev))
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> -	drm_dev_put(dev);
>  }
>  
>  DEFINE_DRM_GEM_FOPS(qxl_fops);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 435126facc9b..86ac191d9205 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -276,8 +276,7 @@ struct qxl_device {
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> -		    struct pci_dev *pdev);
> +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
>  void qxl_device_fini(struct qxl_device *qdev);
>  
>  int qxl_modeset_init(struct qxl_device *qdev);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 9eed1a375f24..91a34dd835d7 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
>  }
>  
>  int qxl_device_init(struct qxl_device *qdev,
> -		    struct drm_driver *drv,
>  		    struct pci_dev *pdev)
>  {
>  	int r, sb;
>  
> -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> -	if (r) {
> -		pr_err("Unable to init drm dev");
> -		goto error;
> -	}
> -
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
>  	qdev->ddev.dev_private = qdev;
> -	drmm_add_final_kfree(&qdev->ddev, qdev);
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
>  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
>  	if (!qdev->vram_mapping) {
>  		pr_err("Unable to create vram_mapping");
> -		r = -ENOMEM;
> -		goto error;
> +		return -ENOMEM;
>  	}
>  
>  	if (pci_resource_len(pdev, 4) > 0) {
> @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  	io_mapping_free(qdev->surface_mapping);
>  vram_mapping_free:
>  	io_mapping_free(qdev->vram_mapping);
> -error:
>  	return r;
>  }
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-24 15:09     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:09 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

Hi Daniel

On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> Also need to remove the drm_dev_put from the remove hook.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
>  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
>  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
>  3 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 09102e2efabc..6b4ae4c5fb76 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		return -EINVAL; /* TODO: ENODEV ? */
>  	}
>  
> -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> -	if (!qdev)
> +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> +				  struct qxl_device, ddev);
> +	if (IS_ERR(qdev)) {
> +		pr_err("Unable to init drm dev");
>  		return -ENOMEM;
> +	}

The other patches do not add any error message when devm_drm_dev_alloc()
fails and driver core will log that driver init failed.

So the pr_err() above should be dropped.
I know it comes from qxl_device_init() but that does not make it a good
idea.

With this fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

>  
>  	ret = pci_enable_device(pdev);
>  	if (ret)
> -		goto free_dev;
> +		return ret;
>  
>  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
>  	if (ret)
> @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		}
>  	}
>  
> -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> +	ret = qxl_device_init(qdev, pdev);
>  	if (ret)
>  		goto put_vga;
>  
> @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
>  disable_pci:
>  	pci_disable_device(pdev);
> -free_dev:
> -	kfree(qdev);
> +
>  	return ret;
>  }
>  
> @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
>  	drm_atomic_helper_shutdown(dev);
>  	if (is_vga(pdev))
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> -	drm_dev_put(dev);
>  }
>  
>  DEFINE_DRM_GEM_FOPS(qxl_fops);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 435126facc9b..86ac191d9205 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -276,8 +276,7 @@ struct qxl_device {
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> -		    struct pci_dev *pdev);
> +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
>  void qxl_device_fini(struct qxl_device *qdev);
>  
>  int qxl_modeset_init(struct qxl_device *qdev);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 9eed1a375f24..91a34dd835d7 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
>  }
>  
>  int qxl_device_init(struct qxl_device *qdev,
> -		    struct drm_driver *drv,
>  		    struct pci_dev *pdev)
>  {
>  	int r, sb;
>  
> -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> -	if (r) {
> -		pr_err("Unable to init drm dev");
> -		goto error;
> -	}
> -
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
>  	qdev->ddev.dev_private = qdev;
> -	drmm_add_final_kfree(&qdev->ddev, qdev);
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
>  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
>  	if (!qdev->vram_mapping) {
>  		pr_err("Unable to create vram_mapping");
> -		r = -ENOMEM;
> -		goto error;
> +		return -ENOMEM;
>  	}
>  
>  	if (pci_resource_len(pdev, 4) > 0) {
> @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  	io_mapping_free(qdev->surface_mapping);
>  vram_mapping_free:
>  	io_mapping_free(qdev->vram_mapping);
> -error:
>  	return r;
>  }
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-24 15:09     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:09 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

Hi Daniel

On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> Also need to remove the drm_dev_put from the remove hook.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
>  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
>  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
>  3 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 09102e2efabc..6b4ae4c5fb76 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		return -EINVAL; /* TODO: ENODEV ? */
>  	}
>  
> -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> -	if (!qdev)
> +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> +				  struct qxl_device, ddev);
> +	if (IS_ERR(qdev)) {
> +		pr_err("Unable to init drm dev");
>  		return -ENOMEM;
> +	}

The other patches do not add any error message when devm_drm_dev_alloc()
fails and driver core will log that driver init failed.

So the pr_err() above should be dropped.
I know it comes from qxl_device_init() but that does not make it a good
idea.

With this fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

>  
>  	ret = pci_enable_device(pdev);
>  	if (ret)
> -		goto free_dev;
> +		return ret;
>  
>  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
>  	if (ret)
> @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		}
>  	}
>  
> -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> +	ret = qxl_device_init(qdev, pdev);
>  	if (ret)
>  		goto put_vga;
>  
> @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
>  disable_pci:
>  	pci_disable_device(pdev);
> -free_dev:
> -	kfree(qdev);
> +
>  	return ret;
>  }
>  
> @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
>  	drm_atomic_helper_shutdown(dev);
>  	if (is_vga(pdev))
>  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> -	drm_dev_put(dev);
>  }
>  
>  DEFINE_DRM_GEM_FOPS(qxl_fops);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 435126facc9b..86ac191d9205 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -276,8 +276,7 @@ struct qxl_device {
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> -		    struct pci_dev *pdev);
> +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
>  void qxl_device_fini(struct qxl_device *qdev);
>  
>  int qxl_modeset_init(struct qxl_device *qdev);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 9eed1a375f24..91a34dd835d7 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
>  }
>  
>  int qxl_device_init(struct qxl_device *qdev,
> -		    struct drm_driver *drv,
>  		    struct pci_dev *pdev)
>  {
>  	int r, sb;
>  
> -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> -	if (r) {
> -		pr_err("Unable to init drm dev");
> -		goto error;
> -	}
> -
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
>  	qdev->ddev.dev_private = qdev;
> -	drmm_add_final_kfree(&qdev->ddev, qdev);
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
>  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
>  	if (!qdev->vram_mapping) {
>  		pr_err("Unable to create vram_mapping");
> -		r = -ENOMEM;
> -		goto error;
> +		return -ENOMEM;
>  	}
>  
>  	if (pci_resource_len(pdev, 4) > 0) {
> @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  	io_mapping_free(qdev->surface_mapping);
>  vram_mapping_free:
>  	io_mapping_free(qdev->vram_mapping);
> -error:
>  	return r;
>  }
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 15:12     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:12 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:02AM +0200, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
>  drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
>  drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
>  drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
>  drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
>  drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
>  drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
>  drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
>  drivers/gpu/drm/qxl/qxl_release.c |  2 +-
>  drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
>  12 files changed, 38 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
> index 88123047fdd4..524d35b648d8 100644
> --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
> +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
> @@ -39,7 +39,7 @@ static int
>  qxl_debugfs_irq_received(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
> @@ -53,7 +53,7 @@ static int
>  qxl_debugfs_buffers_info(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  	struct qxl_bo *bo;
>  
>  	list_for_each_entry(bo, &qdev->gem.objects, list) {
> @@ -83,8 +83,7 @@ void
>  qxl_debugfs_init(struct drm_minor *minor)
>  {
>  #if defined(CONFIG_DEBUG_FS)
> -	struct qxl_device *dev =
> -		(struct qxl_device *) minor->dev->dev_private;
> +	struct qxl_device *dev = to_qxl(minor->dev);
>  
>  	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
>  				 minor->debugfs_root, minor);
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 09583a08e141..1082cd5d2fd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  			bool preferred)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_display_mode *mode = NULL;
>  	int rc;
>  
> @@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  static int qxl_add_monitors_config_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	int h = output->index;
>  	struct qxl_head *head;
> @@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
>  					    const char *reason)
>  {
>  	struct drm_device *dev = crtc->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
>  	struct qxl_head head;
>  	int oldcount, i = qcrtc->index;
> @@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
>  					 unsigned int num_clips)
>  {
>  	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
> -	struct qxl_device *qdev = fb->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(fb->dev);
>  	struct drm_clip_rect norect;
>  	struct qxl_bo *qobj;
>  	bool is_primary;
> @@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
>  static int qxl_primary_atomic_check(struct drm_plane *plane,
>  				    struct drm_plane_state *state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo;
>  
>  	if (!state->crtc || !state->fb)
> @@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
>  static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_cursor_cmd *cmd;
> @@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  static void qxl_primary_atomic_update(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
>  	struct qxl_bo *primary;
>  	struct drm_clip_rect norect = {
> @@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
>  static void qxl_primary_atomic_disable(struct drm_plane *plane,
>  				       struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  
>  	if (old_state->fb) {
>  		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
> @@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  				     struct drm_plane_state *old_state)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_release *release;
> @@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  static void qxl_cursor_atomic_disable(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_release *release;
>  	struct qxl_cursor_cmd *cmd;
>  	int ret;
> @@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
>  static int qxl_plane_prepare_fb(struct drm_plane *plane,
>  				struct drm_plane_state *new_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct drm_gem_object *obj;
>  	struct qxl_bo *user_bo;
>  	struct qxl_surface surf;
> @@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  {
>  	struct qxl_crtc *qxl_crtc;
>  	struct drm_plane *primary, *cursor;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int r;
>  
>  	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
> @@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  static int qxl_conn_get_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	unsigned int pwidth = 1024;
>  	unsigned int pheight = 768;
> @@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
>  			       struct drm_display_mode *mode)
>  {
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  
>  	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
>  		return MODE_BAD;
> @@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
>  	struct qxl_output *output =
>  		drm_connector_to_qxl_output(connector);
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  	bool connected = false;
>  
>  	/* The first monitor is always connected */
> @@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
>  
>  static int qdev_output_init(struct drm_device *dev, int num_output)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *qxl_output;
>  	struct drm_connector *connector;
>  	struct drm_encoder *encoder;
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 6b4ae4c5fb76..13872b882775 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  static void qxl_drm_release(struct drm_device *dev)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	/*
>  	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
> @@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
>  static int qxl_drm_freeze(struct drm_device *dev)
>  {
>  	struct pci_dev *pdev = dev->pdev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int ret;
>  
>  	ret = drm_mode_config_helper_suspend(dev);
> @@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
>  
>  static int qxl_drm_resume(struct drm_device *dev, bool thaw)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
>  	if (!thaw) {
> @@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
>  	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	struct qxl_device *qdev = drm_dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(drm_dev);
>  
>  	qxl_io_reset(qdev);
>  	return qxl_drm_resume(drm_dev, false);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 86ac191d9205..31e35f787df2 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -192,8 +192,6 @@ struct qxl_debugfs {
>  
>  int qxl_debugfs_fence_init(struct qxl_device *rdev);
>  
> -struct qxl_device;
> -
>  struct qxl_device {
>  	struct drm_device ddev;
>  
> @@ -273,6 +271,8 @@ struct qxl_device {
>  	int monitors_config_height;
>  };
>  
> +#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
> +
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
> index 272d19b677d8..24e903383aa1 100644
> --- a/drivers/gpu/drm/qxl/qxl_dumb.c
> +++ b/drivers/gpu/drm/qxl/qxl_dumb.c
> @@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
>  			    struct drm_device *dev,
>  			    struct drm_mode_create_dumb *args)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_bo *qobj;
>  	uint32_t handle;
>  	int r;
> diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
> index 69f37db1027a..5ff6fa9b799c 100644
> --- a/drivers/gpu/drm/qxl/qxl_gem.c
> +++ b/drivers/gpu/drm/qxl/qxl_gem.c
> @@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
>  	struct qxl_device *qdev;
>  	struct ttm_buffer_object *tbo;
>  
> -	qdev = (struct qxl_device *)gobj->dev->dev_private;
> +	qdev = to_qxl(gobj->dev);
>  
>  	qxl_surface_evict(qdev, qobj, false);
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
> index 8117a45b3610..d9a583966949 100644
> --- a/drivers/gpu/drm/qxl/qxl_ioctl.c
> +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
> @@ -36,7 +36,7 @@
>  static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  			   struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc *qxl_alloc = data;
>  	int ret;
>  	struct qxl_bo *qobj;
> @@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  static int qxl_map_ioctl(struct drm_device *dev, void *data,
>  			 struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_map *qxl_map = data;
>  
>  	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
> @@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
>  static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_execbuffer *execbuffer = data;
>  	struct drm_qxl_command user_cmd;
>  	int cmd_num;
> @@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  				 struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_update_area *update_area = data;
>  	struct qxl_rect area = {.left = update_area->left,
>  				.top = update_area->top,
> @@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  		       struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_getparam *param = data;
>  
>  	switch (param->param) {
> @@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  				  struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_clientcap *param = data;
>  	int byte, idx;
>  
> @@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc_surf *param = data;
>  	struct qxl_bo *qobj;
>  	int handle;
> diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
> index 8435af108632..1ba5a702d763 100644
> --- a/drivers/gpu/drm/qxl/qxl_irq.c
> +++ b/drivers/gpu/drm/qxl/qxl_irq.c
> @@ -32,7 +32,7 @@
>  irqreturn_t qxl_irq_handler(int irq, void *arg)
>  {
>  	struct drm_device *dev = (struct drm_device *) arg;
> -	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	uint32_t pending;
>  
>  	pending = xchg(&qdev->ram_header->int_pending, 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 91a34dd835d7..a6d873052cd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
> -	qdev->ddev.dev_private = qdev;
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
> index ab72dc3476e9..edc8a9916872 100644
> --- a/drivers/gpu/drm/qxl/qxl_object.c
> +++ b/drivers/gpu/drm/qxl/qxl_object.c
> @@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
>  	struct qxl_device *qdev;
>  
>  	bo = to_qxl_bo(tbo);
> -	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(bo->tbo.base.dev);
>  
>  	qxl_surface_evict(qdev, bo, false);
>  	WARN_ON_ONCE(bo->map_count > 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 2feca734c7b1..4fae3e393da1 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
>  		return ret;
>  
>  	/* allocate a surface for reserved + validated buffers */
> -	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
> +	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
>  	if (ret)
>  		return ret;
>  	return 0;
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 93a2eb14844b..f09a712b1ed2 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
>  	if (!qxl_ttm_bo_is_qxl_bo(bo))
>  		return;
>  	qbo = to_qxl_bo(bo);
> -	qdev = qbo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(qbo->tbo.base.dev);
>  
>  	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
>  		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
@ 2020-04-24 15:12     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:12 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:02AM +0200, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
>  drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
>  drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
>  drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
>  drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
>  drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
>  drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
>  drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
>  drivers/gpu/drm/qxl/qxl_release.c |  2 +-
>  drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
>  12 files changed, 38 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
> index 88123047fdd4..524d35b648d8 100644
> --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
> +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
> @@ -39,7 +39,7 @@ static int
>  qxl_debugfs_irq_received(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
> @@ -53,7 +53,7 @@ static int
>  qxl_debugfs_buffers_info(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  	struct qxl_bo *bo;
>  
>  	list_for_each_entry(bo, &qdev->gem.objects, list) {
> @@ -83,8 +83,7 @@ void
>  qxl_debugfs_init(struct drm_minor *minor)
>  {
>  #if defined(CONFIG_DEBUG_FS)
> -	struct qxl_device *dev =
> -		(struct qxl_device *) minor->dev->dev_private;
> +	struct qxl_device *dev = to_qxl(minor->dev);
>  
>  	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
>  				 minor->debugfs_root, minor);
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 09583a08e141..1082cd5d2fd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  			bool preferred)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_display_mode *mode = NULL;
>  	int rc;
>  
> @@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  static int qxl_add_monitors_config_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	int h = output->index;
>  	struct qxl_head *head;
> @@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
>  					    const char *reason)
>  {
>  	struct drm_device *dev = crtc->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
>  	struct qxl_head head;
>  	int oldcount, i = qcrtc->index;
> @@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
>  					 unsigned int num_clips)
>  {
>  	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
> -	struct qxl_device *qdev = fb->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(fb->dev);
>  	struct drm_clip_rect norect;
>  	struct qxl_bo *qobj;
>  	bool is_primary;
> @@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
>  static int qxl_primary_atomic_check(struct drm_plane *plane,
>  				    struct drm_plane_state *state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo;
>  
>  	if (!state->crtc || !state->fb)
> @@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
>  static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_cursor_cmd *cmd;
> @@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  static void qxl_primary_atomic_update(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
>  	struct qxl_bo *primary;
>  	struct drm_clip_rect norect = {
> @@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
>  static void qxl_primary_atomic_disable(struct drm_plane *plane,
>  				       struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  
>  	if (old_state->fb) {
>  		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
> @@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  				     struct drm_plane_state *old_state)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_release *release;
> @@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  static void qxl_cursor_atomic_disable(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_release *release;
>  	struct qxl_cursor_cmd *cmd;
>  	int ret;
> @@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
>  static int qxl_plane_prepare_fb(struct drm_plane *plane,
>  				struct drm_plane_state *new_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct drm_gem_object *obj;
>  	struct qxl_bo *user_bo;
>  	struct qxl_surface surf;
> @@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  {
>  	struct qxl_crtc *qxl_crtc;
>  	struct drm_plane *primary, *cursor;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int r;
>  
>  	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
> @@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  static int qxl_conn_get_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	unsigned int pwidth = 1024;
>  	unsigned int pheight = 768;
> @@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
>  			       struct drm_display_mode *mode)
>  {
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  
>  	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
>  		return MODE_BAD;
> @@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
>  	struct qxl_output *output =
>  		drm_connector_to_qxl_output(connector);
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  	bool connected = false;
>  
>  	/* The first monitor is always connected */
> @@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
>  
>  static int qdev_output_init(struct drm_device *dev, int num_output)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *qxl_output;
>  	struct drm_connector *connector;
>  	struct drm_encoder *encoder;
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 6b4ae4c5fb76..13872b882775 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  static void qxl_drm_release(struct drm_device *dev)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	/*
>  	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
> @@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
>  static int qxl_drm_freeze(struct drm_device *dev)
>  {
>  	struct pci_dev *pdev = dev->pdev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int ret;
>  
>  	ret = drm_mode_config_helper_suspend(dev);
> @@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
>  
>  static int qxl_drm_resume(struct drm_device *dev, bool thaw)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
>  	if (!thaw) {
> @@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
>  	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	struct qxl_device *qdev = drm_dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(drm_dev);
>  
>  	qxl_io_reset(qdev);
>  	return qxl_drm_resume(drm_dev, false);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 86ac191d9205..31e35f787df2 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -192,8 +192,6 @@ struct qxl_debugfs {
>  
>  int qxl_debugfs_fence_init(struct qxl_device *rdev);
>  
> -struct qxl_device;
> -
>  struct qxl_device {
>  	struct drm_device ddev;
>  
> @@ -273,6 +271,8 @@ struct qxl_device {
>  	int monitors_config_height;
>  };
>  
> +#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
> +
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
> index 272d19b677d8..24e903383aa1 100644
> --- a/drivers/gpu/drm/qxl/qxl_dumb.c
> +++ b/drivers/gpu/drm/qxl/qxl_dumb.c
> @@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
>  			    struct drm_device *dev,
>  			    struct drm_mode_create_dumb *args)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_bo *qobj;
>  	uint32_t handle;
>  	int r;
> diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
> index 69f37db1027a..5ff6fa9b799c 100644
> --- a/drivers/gpu/drm/qxl/qxl_gem.c
> +++ b/drivers/gpu/drm/qxl/qxl_gem.c
> @@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
>  	struct qxl_device *qdev;
>  	struct ttm_buffer_object *tbo;
>  
> -	qdev = (struct qxl_device *)gobj->dev->dev_private;
> +	qdev = to_qxl(gobj->dev);
>  
>  	qxl_surface_evict(qdev, qobj, false);
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
> index 8117a45b3610..d9a583966949 100644
> --- a/drivers/gpu/drm/qxl/qxl_ioctl.c
> +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
> @@ -36,7 +36,7 @@
>  static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  			   struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc *qxl_alloc = data;
>  	int ret;
>  	struct qxl_bo *qobj;
> @@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  static int qxl_map_ioctl(struct drm_device *dev, void *data,
>  			 struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_map *qxl_map = data;
>  
>  	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
> @@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
>  static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_execbuffer *execbuffer = data;
>  	struct drm_qxl_command user_cmd;
>  	int cmd_num;
> @@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  				 struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_update_area *update_area = data;
>  	struct qxl_rect area = {.left = update_area->left,
>  				.top = update_area->top,
> @@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  		       struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_getparam *param = data;
>  
>  	switch (param->param) {
> @@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  				  struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_clientcap *param = data;
>  	int byte, idx;
>  
> @@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc_surf *param = data;
>  	struct qxl_bo *qobj;
>  	int handle;
> diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
> index 8435af108632..1ba5a702d763 100644
> --- a/drivers/gpu/drm/qxl/qxl_irq.c
> +++ b/drivers/gpu/drm/qxl/qxl_irq.c
> @@ -32,7 +32,7 @@
>  irqreturn_t qxl_irq_handler(int irq, void *arg)
>  {
>  	struct drm_device *dev = (struct drm_device *) arg;
> -	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	uint32_t pending;
>  
>  	pending = xchg(&qdev->ram_header->int_pending, 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 91a34dd835d7..a6d873052cd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
> -	qdev->ddev.dev_private = qdev;
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
> index ab72dc3476e9..edc8a9916872 100644
> --- a/drivers/gpu/drm/qxl/qxl_object.c
> +++ b/drivers/gpu/drm/qxl/qxl_object.c
> @@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
>  	struct qxl_device *qdev;
>  
>  	bo = to_qxl_bo(tbo);
> -	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(bo->tbo.base.dev);
>  
>  	qxl_surface_evict(qdev, bo, false);
>  	WARN_ON_ONCE(bo->map_count > 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 2feca734c7b1..4fae3e393da1 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
>  		return ret;
>  
>  	/* allocate a surface for reserved + validated buffers */
> -	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
> +	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
>  	if (ret)
>  		return ret;
>  	return 0;
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 93a2eb14844b..f09a712b1ed2 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
>  	if (!qxl_ttm_bo_is_qxl_bo(bo))
>  		return;
>  	qbo = to_qxl_bo(bo);
> -	qdev = qbo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(qbo->tbo.base.dev);
>  
>  	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
>  		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private
@ 2020-04-24 15:12     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 15:12 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Intel Graphics Development, DRI Development,
	virtualization, Gerd Hoffmann, spice-devel, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:02AM +0200, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: spice-devel@lists.freedesktop.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/qxl/qxl_debugfs.c |  7 +++----
>  drivers/gpu/drm/qxl/qxl_display.c | 32 +++++++++++++++----------------
>  drivers/gpu/drm/qxl/qxl_drv.c     |  8 ++++----
>  drivers/gpu/drm/qxl/qxl_drv.h     |  4 ++--
>  drivers/gpu/drm/qxl/qxl_dumb.c    |  2 +-
>  drivers/gpu/drm/qxl/qxl_gem.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_ioctl.c   | 14 +++++++-------
>  drivers/gpu/drm/qxl/qxl_irq.c     |  2 +-
>  drivers/gpu/drm/qxl/qxl_kms.c     |  1 -
>  drivers/gpu/drm/qxl/qxl_object.c  |  2 +-
>  drivers/gpu/drm/qxl/qxl_release.c |  2 +-
>  drivers/gpu/drm/qxl/qxl_ttm.c     |  2 +-
>  12 files changed, 38 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
> index 88123047fdd4..524d35b648d8 100644
> --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
> +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
> @@ -39,7 +39,7 @@ static int
>  qxl_debugfs_irq_received(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
>  	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
> @@ -53,7 +53,7 @@ static int
>  qxl_debugfs_buffers_info(struct seq_file *m, void *data)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct qxl_device *qdev = node->minor->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(node->minor->dev);
>  	struct qxl_bo *bo;
>  
>  	list_for_each_entry(bo, &qdev->gem.objects, list) {
> @@ -83,8 +83,7 @@ void
>  qxl_debugfs_init(struct drm_minor *minor)
>  {
>  #if defined(CONFIG_DEBUG_FS)
> -	struct qxl_device *dev =
> -		(struct qxl_device *) minor->dev->dev_private;
> +	struct qxl_device *dev = to_qxl(minor->dev);
>  
>  	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
>  				 minor->debugfs_root, minor);
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
> index 09583a08e141..1082cd5d2fd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -221,7 +221,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  			bool preferred)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_display_mode *mode = NULL;
>  	int rc;
>  
> @@ -242,7 +242,7 @@ static int qxl_add_mode(struct drm_connector *connector,
>  static int qxl_add_monitors_config_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	int h = output->index;
>  	struct qxl_head *head;
> @@ -310,7 +310,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
>  					    const char *reason)
>  {
>  	struct drm_device *dev = crtc->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
>  	struct qxl_head head;
>  	int oldcount, i = qcrtc->index;
> @@ -400,7 +400,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
>  					 unsigned int num_clips)
>  {
>  	/* TODO: vmwgfx where this was cribbed from had locking. Why? */
> -	struct qxl_device *qdev = fb->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(fb->dev);
>  	struct drm_clip_rect norect;
>  	struct qxl_bo *qobj;
>  	bool is_primary;
> @@ -462,7 +462,7 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
>  static int qxl_primary_atomic_check(struct drm_plane *plane,
>  				    struct drm_plane_state *state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo;
>  
>  	if (!state->crtc || !state->fb)
> @@ -476,7 +476,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane,
>  static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_cursor_cmd *cmd;
> @@ -523,7 +523,7 @@ static int qxl_primary_apply_cursor(struct drm_plane *plane)
>  static void qxl_primary_atomic_update(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
>  	struct qxl_bo *primary;
>  	struct drm_clip_rect norect = {
> @@ -554,7 +554,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
>  static void qxl_primary_atomic_disable(struct drm_plane *plane,
>  				       struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  
>  	if (old_state->fb) {
>  		struct qxl_bo *bo = gem_to_qxl_bo(old_state->fb->obj[0]);
> @@ -570,7 +570,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  				     struct drm_plane_state *old_state)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_framebuffer *fb = plane->state->fb;
>  	struct qxl_crtc *qcrtc = to_qxl_crtc(plane->state->crtc);
>  	struct qxl_release *release;
> @@ -679,7 +679,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
>  static void qxl_cursor_atomic_disable(struct drm_plane *plane,
>  				      struct drm_plane_state *old_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct qxl_release *release;
>  	struct qxl_cursor_cmd *cmd;
>  	int ret;
> @@ -762,7 +762,7 @@ static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
>  static int qxl_plane_prepare_fb(struct drm_plane *plane,
>  				struct drm_plane_state *new_state)
>  {
> -	struct qxl_device *qdev = plane->dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(plane->dev);
>  	struct drm_gem_object *obj;
>  	struct qxl_bo *user_bo;
>  	struct qxl_surface surf;
> @@ -923,7 +923,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  {
>  	struct qxl_crtc *qxl_crtc;
>  	struct drm_plane *primary, *cursor;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int r;
>  
>  	qxl_crtc = kzalloc(sizeof(struct qxl_crtc), GFP_KERNEL);
> @@ -965,7 +965,7 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)
>  static int qxl_conn_get_modes(struct drm_connector *connector)
>  {
>  	struct drm_device *dev = connector->dev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *output = drm_connector_to_qxl_output(connector);
>  	unsigned int pwidth = 1024;
>  	unsigned int pheight = 768;
> @@ -991,7 +991,7 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector,
>  			       struct drm_display_mode *mode)
>  {
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  
>  	if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
>  		return MODE_BAD;
> @@ -1021,7 +1021,7 @@ static enum drm_connector_status qxl_conn_detect(
>  	struct qxl_output *output =
>  		drm_connector_to_qxl_output(connector);
>  	struct drm_device *ddev = connector->dev;
> -	struct qxl_device *qdev = ddev->dev_private;
> +	struct qxl_device *qdev = to_qxl(ddev);
>  	bool connected = false;
>  
>  	/* The first monitor is always connected */
> @@ -1071,7 +1071,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
>  
>  static int qdev_output_init(struct drm_device *dev, int num_output)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_output *qxl_output;
>  	struct drm_connector *connector;
>  	struct drm_encoder *encoder;
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index 6b4ae4c5fb76..13872b882775 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -137,7 +137,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  static void qxl_drm_release(struct drm_device *dev)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	/*
>  	 * TODO: qxl_device_fini() call should be in qxl_pci_remove(),
> @@ -164,7 +164,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops);
>  static int qxl_drm_freeze(struct drm_device *dev)
>  {
>  	struct pci_dev *pdev = dev->pdev;
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	int ret;
>  
>  	ret = drm_mode_config_helper_suspend(dev);
> @@ -186,7 +186,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
>  
>  static int qxl_drm_resume(struct drm_device *dev, bool thaw)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  
>  	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
>  	if (!thaw) {
> @@ -245,7 +245,7 @@ static int qxl_pm_restore(struct device *dev)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
>  	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	struct qxl_device *qdev = drm_dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(drm_dev);
>  
>  	qxl_io_reset(qdev);
>  	return qxl_drm_resume(drm_dev, false);
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> index 86ac191d9205..31e35f787df2 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.h
> +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> @@ -192,8 +192,6 @@ struct qxl_debugfs {
>  
>  int qxl_debugfs_fence_init(struct qxl_device *rdev);
>  
> -struct qxl_device;
> -
>  struct qxl_device {
>  	struct drm_device ddev;
>  
> @@ -273,6 +271,8 @@ struct qxl_device {
>  	int monitors_config_height;
>  };
>  
> +#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
> +
>  extern const struct drm_ioctl_desc qxl_ioctls[];
>  extern int qxl_max_ioctl;
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
> index 272d19b677d8..24e903383aa1 100644
> --- a/drivers/gpu/drm/qxl/qxl_dumb.c
> +++ b/drivers/gpu/drm/qxl/qxl_dumb.c
> @@ -32,7 +32,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
>  			    struct drm_device *dev,
>  			    struct drm_mode_create_dumb *args)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct qxl_bo *qobj;
>  	uint32_t handle;
>  	int r;
> diff --git a/drivers/gpu/drm/qxl/qxl_gem.c b/drivers/gpu/drm/qxl/qxl_gem.c
> index 69f37db1027a..5ff6fa9b799c 100644
> --- a/drivers/gpu/drm/qxl/qxl_gem.c
> +++ b/drivers/gpu/drm/qxl/qxl_gem.c
> @@ -34,7 +34,7 @@ void qxl_gem_object_free(struct drm_gem_object *gobj)
>  	struct qxl_device *qdev;
>  	struct ttm_buffer_object *tbo;
>  
> -	qdev = (struct qxl_device *)gobj->dev->dev_private;
> +	qdev = to_qxl(gobj->dev);
>  
>  	qxl_surface_evict(qdev, qobj, false);
>  
> diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
> index 8117a45b3610..d9a583966949 100644
> --- a/drivers/gpu/drm/qxl/qxl_ioctl.c
> +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
> @@ -36,7 +36,7 @@
>  static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  			   struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc *qxl_alloc = data;
>  	int ret;
>  	struct qxl_bo *qobj;
> @@ -64,7 +64,7 @@ static int qxl_alloc_ioctl(struct drm_device *dev, void *data,
>  static int qxl_map_ioctl(struct drm_device *dev, void *data,
>  			 struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_map *qxl_map = data;
>  
>  	return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
> @@ -279,7 +279,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
>  static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_execbuffer *execbuffer = data;
>  	struct drm_qxl_command user_cmd;
>  	int cmd_num;
> @@ -304,7 +304,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
>  static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  				 struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_update_area *update_area = data;
>  	struct qxl_rect area = {.left = update_area->left,
>  				.top = update_area->top,
> @@ -354,7 +354,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
>  static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  		       struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_getparam *param = data;
>  
>  	switch (param->param) {
> @@ -373,7 +373,7 @@ static int qxl_getparam_ioctl(struct drm_device *dev, void *data,
>  static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  				  struct drm_file *file_priv)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_clientcap *param = data;
>  	int byte, idx;
>  
> @@ -394,7 +394,7 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data,
>  static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data,
>  				struct drm_file *file)
>  {
> -	struct qxl_device *qdev = dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	struct drm_qxl_alloc_surf *param = data;
>  	struct qxl_bo *qobj;
>  	int handle;
> diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
> index 8435af108632..1ba5a702d763 100644
> --- a/drivers/gpu/drm/qxl/qxl_irq.c
> +++ b/drivers/gpu/drm/qxl/qxl_irq.c
> @@ -32,7 +32,7 @@
>  irqreturn_t qxl_irq_handler(int irq, void *arg)
>  {
>  	struct drm_device *dev = (struct drm_device *) arg;
> -	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
> +	struct qxl_device *qdev = to_qxl(dev);
>  	uint32_t pending;
>  
>  	pending = xchg(&qdev->ram_header->int_pending, 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> index 91a34dd835d7..a6d873052cd4 100644
> --- a/drivers/gpu/drm/qxl/qxl_kms.c
> +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> @@ -114,7 +114,6 @@ int qxl_device_init(struct qxl_device *qdev,
>  
>  	qdev->ddev.pdev = pdev;
>  	pci_set_drvdata(pdev, &qdev->ddev);
> -	qdev->ddev.dev_private = qdev;
>  
>  	mutex_init(&qdev->gem.mutex);
>  	mutex_init(&qdev->update_area_mutex);
> diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
> index ab72dc3476e9..edc8a9916872 100644
> --- a/drivers/gpu/drm/qxl/qxl_object.c
> +++ b/drivers/gpu/drm/qxl/qxl_object.c
> @@ -33,7 +33,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
>  	struct qxl_device *qdev;
>  
>  	bo = to_qxl_bo(tbo);
> -	qdev = (struct qxl_device *)bo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(bo->tbo.base.dev);
>  
>  	qxl_surface_evict(qdev, bo, false);
>  	WARN_ON_ONCE(bo->map_count > 0);
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 2feca734c7b1..4fae3e393da1 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -243,7 +243,7 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
>  		return ret;
>  
>  	/* allocate a surface for reserved + validated buffers */
> -	ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo);
> +	ret = qxl_bo_check_id(to_qxl(bo->tbo.base.dev), bo);
>  	if (ret)
>  		return ret;
>  	return 0;
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 93a2eb14844b..f09a712b1ed2 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -243,7 +243,7 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
>  	if (!qxl_ttm_bo_is_qxl_bo(bo))
>  		return;
>  	qbo = to_qxl_bo(bo);
> -	qdev = qbo->tbo.base.dev->dev_private;
> +	qdev = to_qxl(qbo->tbo.base.dev);
>  
>  	if (bo->mem.mem_type == TTM_PL_PRIV && qbo->surface_id)
>  		qxl_surface_evict(qdev, qbo, new_mem ? true : false);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
  2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 16:33     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:33 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Hans de Goede, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Wed, Apr 15, 2020 at 09:39:38AM +0200, Daniel Vetter wrote:
> Straightforward conversion.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 282348e071fe..7dd25c7a3768 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	if (ret)
>  		return ret;
>  
> -	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
> -	if (!vbox)
> -		return -ENOMEM;
> -
> -	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
> -	if (ret) {
> -		kfree(vbox);
> -		return ret;
> -	}
> +	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct vbox_private, ddev);
> +	if (IS_ERR(vbox))
> +		return PTR_ERR(vbox);
>  
>  	vbox->ddev.pdev = pdev;
>  	vbox->ddev.dev_private = vbox;
>  	pci_set_drvdata(pdev, vbox);
> -	drmm_add_final_kfree(&vbox->ddev, vbox);
>  	mutex_init(&vbox->hw_mutex);
>  
>  	ret = pci_enable_device(pdev);
>  	if (ret)
> -		goto err_dev_put;
> +		return ret;
>  
>  	ret = vbox_hw_init(vbox);
>  	if (ret)
> @@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	vbox_hw_fini(vbox);
>  err_pci_disable:
>  	pci_disable_device(pdev);
> -err_dev_put:
> -	drm_dev_put(&vbox->ddev);
>  	return ret;
>  }
>  
> @@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
>  	vbox_mode_fini(vbox);
>  	vbox_mm_fini(vbox);
>  	vbox_hw_fini(vbox);
> -	drm_dev_put(&vbox->ddev);
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc
@ 2020-04-24 16:33     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:33 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, DRI Development, Daniel Vetter

On Wed, Apr 15, 2020 at 09:39:38AM +0200, Daniel Vetter wrote:
> Straightforward conversion.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/vboxvideo/vbox_drv.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> index 282348e071fe..7dd25c7a3768 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c
> @@ -46,25 +46,19 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	if (ret)
>  		return ret;
>  
> -	vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
> -	if (!vbox)
> -		return -ENOMEM;
> -
> -	ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
> -	if (ret) {
> -		kfree(vbox);
> -		return ret;
> -	}
> +	vbox = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct vbox_private, ddev);
> +	if (IS_ERR(vbox))
> +		return PTR_ERR(vbox);
>  
>  	vbox->ddev.pdev = pdev;
>  	vbox->ddev.dev_private = vbox;
>  	pci_set_drvdata(pdev, vbox);
> -	drmm_add_final_kfree(&vbox->ddev, vbox);
>  	mutex_init(&vbox->hw_mutex);
>  
>  	ret = pci_enable_device(pdev);
>  	if (ret)
> -		goto err_dev_put;
> +		return ret;
>  
>  	ret = vbox_hw_init(vbox);
>  	if (ret)
> @@ -100,8 +94,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	vbox_hw_fini(vbox);
>  err_pci_disable:
>  	pci_disable_device(pdev);
> -err_dev_put:
> -	drm_dev_put(&vbox->ddev);
>  	return ret;
>  }
>  
> @@ -114,7 +106,6 @@ static void vbox_pci_remove(struct pci_dev *pdev)
>  	vbox_mode_fini(vbox);
>  	vbox_mm_fini(vbox);
>  	vbox_hw_fini(vbox);
> -	drm_dev_put(&vbox->ddev);
>  }
>  
>  #ifdef CONFIG_PM_SLEEP
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 16:37     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, virtualization,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-24 16:37     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, virtualization,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 37/59] drm/cirrus: Move to drm/tiny
@ 2020-04-24 16:37     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:37 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, virtualization,
	Gerd Hoffmann, Dave Airlie, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:12AM +0200, Daniel Vetter wrote:
> Because it is. Huge congrats to everyone who made this kind of
> refactoring happen!
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  MAINTAINERS                               |  2 +-
>  drivers/gpu/drm/Kconfig                   |  2 --
>  drivers/gpu/drm/Makefile                  |  1 -
>  drivers/gpu/drm/cirrus/Kconfig            | 19 -------------------
>  drivers/gpu/drm/cirrus/Makefile           |  2 --
>  drivers/gpu/drm/tiny/Kconfig              | 19 +++++++++++++++++++
>  drivers/gpu/drm/tiny/Makefile             |  1 +
>  drivers/gpu/drm/{cirrus => tiny}/cirrus.c |  0
>  8 files changed, 21 insertions(+), 25 deletions(-)
>  delete mode 100644 drivers/gpu/drm/cirrus/Kconfig
>  delete mode 100644 drivers/gpu/drm/cirrus/Makefile
>  rename drivers/gpu/drm/{cirrus => tiny}/cirrus.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7b3255d96d1d..0a5cf105ee37 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5397,7 +5397,7 @@ L:	virtualization@lists.linux-foundation.org
>  S:	Obsolete
>  W:	https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
>  T:	git git://anongit.freedesktop.org/drm/drm-misc
> -F:	drivers/gpu/drm/cirrus/
> +F:	drivers/gpu/drm/tiny/cirrus.c
>  
>  DRM DRIVER FOR QXL VIRTUAL GPU
>  M:	Dave Airlie <airlied@redhat.com>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 43594978958e..4f4e7fa001c1 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -310,8 +310,6 @@ source "drivers/gpu/drm/ast/Kconfig"
>  
>  source "drivers/gpu/drm/mgag200/Kconfig"
>  
> -source "drivers/gpu/drm/cirrus/Kconfig"
> -
>  source "drivers/gpu/drm/armada/Kconfig"
>  
>  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index f34d08c83485..2c0e5a7e5953 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -74,7 +74,6 @@ obj-$(CONFIG_DRM_I915)	+= i915/
>  obj-$(CONFIG_DRM_MGAG200) += mgag200/
>  obj-$(CONFIG_DRM_V3D)  += v3d/
>  obj-$(CONFIG_DRM_VC4)  += vc4/
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
>  obj-$(CONFIG_DRM_SIS)   += sis/
>  obj-$(CONFIG_DRM_SAVAGE)+= savage/
>  obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
> diff --git a/drivers/gpu/drm/cirrus/Kconfig b/drivers/gpu/drm/cirrus/Kconfig
> deleted file mode 100644
> index c6bbd988b0e5..000000000000
> --- a/drivers/gpu/drm/cirrus/Kconfig
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config DRM_CIRRUS_QEMU
> -	tristate "Cirrus driver for QEMU emulated device"
> -	depends on DRM && PCI && MMU
> -	select DRM_KMS_HELPER
> -	select DRM_GEM_SHMEM_HELPER
> -	help
> -	 This is a KMS driver for emulated cirrus device in qemu.
> -	 It is *NOT* intended for real cirrus devices. This requires
> -	 the modesetting userspace X.org driver.
> -
> -	 Cirrus is obsolete, the hardware was designed in the 90ies
> -	 and can't keep up with todays needs.  More background:
> -	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> -
> -	 Better alternatives are:
> -	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> -	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> -	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> diff --git a/drivers/gpu/drm/cirrus/Makefile b/drivers/gpu/drm/cirrus/Makefile
> deleted file mode 100644
> index 0c1ed3f99725..000000000000
> --- a/drivers/gpu/drm/cirrus/Makefile
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
> diff --git a/drivers/gpu/drm/tiny/Kconfig b/drivers/gpu/drm/tiny/Kconfig
> index 4160e74e4751..2b6414f0fa75 100644
> --- a/drivers/gpu/drm/tiny/Kconfig
> +++ b/drivers/gpu/drm/tiny/Kconfig
> @@ -1,5 +1,24 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config DRM_CIRRUS_QEMU
> +	tristate "Cirrus driver for QEMU emulated device"
> +	depends on DRM && PCI && MMU
> +	select DRM_KMS_HELPER
> +	select DRM_GEM_SHMEM_HELPER
> +	help
> +	 This is a KMS driver for emulated cirrus device in qemu.
> +	 It is *NOT* intended for real cirrus devices. This requires
> +	 the modesetting userspace X.org driver.
> +
> +	 Cirrus is obsolete, the hardware was designed in the 90ies
> +	 and can't keep up with todays needs.  More background:
> +	 https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
> +
> +	 Better alternatives are:
> +	   - stdvga (DRM_BOCHS, qemu -vga std, default in qemu 2.2+)
> +	   - qxl (DRM_QXL, qemu -vga qxl, works best with spice)
> +	   - virtio (DRM_VIRTIO_GPU), qemu -vga virtio)
> +
>  config DRM_GM12U320
>  	tristate "GM12U320 driver for USB projectors"
>  	depends on DRM && USB
> diff --git a/drivers/gpu/drm/tiny/Makefile b/drivers/gpu/drm/tiny/Makefile
> index c96ceee71453..6ae4e9e5a35f 100644
> --- a/drivers/gpu/drm/tiny/Makefile
> +++ b/drivers/gpu/drm/tiny/Makefile
> @@ -1,5 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +obj-$(CONFIG_DRM_CIRRUS_QEMU)		+= cirrus.o
>  obj-$(CONFIG_DRM_GM12U320)		+= gm12u320.o
>  obj-$(CONFIG_TINYDRM_HX8357D)		+= hx8357d.o
>  obj-$(CONFIG_TINYDRM_ILI9225)		+= ili9225.o
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> similarity index 100%
> rename from drivers/gpu/drm/cirrus/cirrus.c
> rename to drivers/gpu/drm/tiny/cirrus.c
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 16:43     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:43 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:14AM +0200, Daniel Vetter wrote:
> - Need to embedded the drm_device, but for now we keep the usual
>   pointer chasing.
> - No more devm_kzalloc, which fixes a lifetime issues on driver
>   remove.
> - No more drm_dev_put, that's done by devm_ now.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject needs a small adjustment:

    drm/arc: arcgpu: Switch to devm_drm_dev_alloc

There is no driver named arcgpu - so it should
not be used like in thins patch.
With this detail fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>



> ---
>  drivers/gpu/drm/arc/arcpgu.h     |  1 +
>  drivers/gpu/drm/arc/arcpgu_drv.c | 33 +++++++++++++-------------------
>  2 files changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 6aac44b953ad..cd9e932f501e 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -9,6 +9,7 @@
>  #define _ARCPGU_H_
>  
>  struct arcpgu_drm_private {
> +	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
>  	struct drm_framebuffer	*fb;
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index c05d001163e0..bbd7acb150f3 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -42,18 +42,14 @@ static void arcpgu_setup_mode_config(struct drm_device *drm)
>  
>  DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
>  
> -static int arcpgu_load(struct drm_device *drm)
> +static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct platform_device *pdev = to_platform_device(drm->dev);
> -	struct arcpgu_drm_private *arcpgu;
> +	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
>  	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
> +	struct drm_device *drm = &arcpgu->drm;
>  	struct resource *res;
>  	int ret;
>  
> -	arcpgu = devm_kzalloc(&pdev->dev, sizeof(*arcpgu), GFP_KERNEL);
> -	if (arcpgu == NULL)
> -		return -ENOMEM;
> -
>  	drm->dev_private = arcpgu;
>  
>  	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
> @@ -172,30 +168,28 @@ static struct drm_driver arcpgu_drm_driver = {
>  
>  static int arcpgu_probe(struct platform_device *pdev)
>  {
> -	struct drm_device *drm;
> +	struct arcpgu_drm_private *arcpgu;
>  	int ret;
>  
> -	drm = drm_dev_alloc(&arcpgu_drm_driver, &pdev->dev);
> -	if (IS_ERR(drm))
> -		return PTR_ERR(drm);
> +	arcpgu = devm_drm_dev_alloc(&pdev->dev, &arcpgu_drm_driver,
> +				    struct arcpgu_drm_private, drm);
> +	if (IS_ERR(arcpgu))
> +		return PTR_ERR(arcpgu);
>  
> -	ret = arcpgu_load(drm);
> +	ret = arcpgu_load(arcpgu);
>  	if (ret)
> -		goto err_unref;
> +		return ret;
>  
> -	ret = drm_dev_register(drm, 0);
> +	ret = drm_dev_register(&arcpgu->drm, 0);
>  	if (ret)
>  		goto err_unload;
>  
> -	drm_fbdev_generic_setup(drm, 16);
> +	drm_fbdev_generic_setup(&arcpgu->drm, 16);
>  
>  	return 0;
>  
>  err_unload:
> -	arcpgu_unload(drm);
> -
> -err_unref:
> -	drm_dev_put(drm);
> +	arcpgu_unload(&arcpgu->drm);
>  
>  	return ret;
>  }
> @@ -206,7 +200,6 @@ static int arcpgu_remove(struct platform_device *pdev)
>  
>  	drm_dev_unregister(drm);
>  	arcpgu_unload(drm);
> -	drm_dev_put(drm);
>  
>  	return 0;
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc
@ 2020-04-24 16:43     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:43 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:14AM +0200, Daniel Vetter wrote:
> - Need to embedded the drm_device, but for now we keep the usual
>   pointer chasing.
> - No more devm_kzalloc, which fixes a lifetime issues on driver
>   remove.
> - No more drm_dev_put, that's done by devm_ now.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject needs a small adjustment:

    drm/arc: arcgpu: Switch to devm_drm_dev_alloc

There is no driver named arcgpu - so it should
not be used like in thins patch.
With this detail fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>



> ---
>  drivers/gpu/drm/arc/arcpgu.h     |  1 +
>  drivers/gpu/drm/arc/arcpgu_drv.c | 33 +++++++++++++-------------------
>  2 files changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 6aac44b953ad..cd9e932f501e 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -9,6 +9,7 @@
>  #define _ARCPGU_H_
>  
>  struct arcpgu_drm_private {
> +	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
>  	struct drm_framebuffer	*fb;
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index c05d001163e0..bbd7acb150f3 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -42,18 +42,14 @@ static void arcpgu_setup_mode_config(struct drm_device *drm)
>  
>  DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
>  
> -static int arcpgu_load(struct drm_device *drm)
> +static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct platform_device *pdev = to_platform_device(drm->dev);
> -	struct arcpgu_drm_private *arcpgu;
> +	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
>  	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
> +	struct drm_device *drm = &arcpgu->drm;
>  	struct resource *res;
>  	int ret;
>  
> -	arcpgu = devm_kzalloc(&pdev->dev, sizeof(*arcpgu), GFP_KERNEL);
> -	if (arcpgu == NULL)
> -		return -ENOMEM;
> -
>  	drm->dev_private = arcpgu;
>  
>  	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
> @@ -172,30 +168,28 @@ static struct drm_driver arcpgu_drm_driver = {
>  
>  static int arcpgu_probe(struct platform_device *pdev)
>  {
> -	struct drm_device *drm;
> +	struct arcpgu_drm_private *arcpgu;
>  	int ret;
>  
> -	drm = drm_dev_alloc(&arcpgu_drm_driver, &pdev->dev);
> -	if (IS_ERR(drm))
> -		return PTR_ERR(drm);
> +	arcpgu = devm_drm_dev_alloc(&pdev->dev, &arcpgu_drm_driver,
> +				    struct arcpgu_drm_private, drm);
> +	if (IS_ERR(arcpgu))
> +		return PTR_ERR(arcpgu);
>  
> -	ret = arcpgu_load(drm);
> +	ret = arcpgu_load(arcpgu);
>  	if (ret)
> -		goto err_unref;
> +		return ret;
>  
> -	ret = drm_dev_register(drm, 0);
> +	ret = drm_dev_register(&arcpgu->drm, 0);
>  	if (ret)
>  		goto err_unload;
>  
> -	drm_fbdev_generic_setup(drm, 16);
> +	drm_fbdev_generic_setup(&arcpgu->drm, 16);
>  
>  	return 0;
>  
>  err_unload:
> -	arcpgu_unload(drm);
> -
> -err_unref:
> -	drm_dev_put(drm);
> +	arcpgu_unload(&arcpgu->drm);
>  
>  	return ret;
>  }
> @@ -206,7 +200,6 @@ static int arcpgu_remove(struct platform_device *pdev)
>  
>  	drm_dev_unregister(drm);
>  	arcpgu_unload(drm);
> -	drm_dev_put(drm);
>  
>  	return 0;
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 16:46     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:46 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject: drm/arc: arcpgu: Stop using drm_device->dev_private

And another bikeshedding below.
With this considered:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index cd9e932f501e..87821c91a00c 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
>  	struct drm_plane	*plane;
>  };
>  
> +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> +
Preferred name is to_arcgpu(). There is no device in the name of struct
arcpgu_drm_private. And the general consensus it to use to_<driver> for
the top-level struct.

>  #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index be7c29cec318..ba796a216244 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
>  
>  static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  {
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_plane *plane = NULL;
>  	int ret;
>  
> @@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  
>  int arc_pgu_setup_crtc(struct drm_device *drm)
>  {
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_plane *primary;
>  	int ret;
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index bbd7acb150f3..81b8d7ae6623 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	struct resource *res;
>  	int ret;
>  
> -	drm->dev_private = arcpgu;
> -
>  	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
>  	if (IS_ERR(arcpgu->clk))
>  		return PTR_ERR(arcpgu->clk);
> @@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *)m->private;
>  	struct drm_device *drm = node->minor->dev;
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	unsigned long clkrate = clk_get_rate(arcpgu->clk);
>  	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
@ 2020-04-24 16:46     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:46 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> Upcasting using a container_of macro is more typesafe, faster and
> easier for the compiler to optimize.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject: drm/arc: arcpgu: Stop using drm_device->dev_private

And another bikeshedding below.
With this considered:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index cd9e932f501e..87821c91a00c 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
>  	struct drm_plane	*plane;
>  };
>  
> +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> +
Preferred name is to_arcgpu(). There is no device in the name of struct
arcpgu_drm_private. And the general consensus it to use to_<driver> for
the top-level struct.

>  #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index be7c29cec318..ba796a216244 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
>  
>  static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  {
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_plane *plane = NULL;
>  	int ret;
>  
> @@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  
>  int arc_pgu_setup_crtc(struct drm_device *drm)
>  {
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_plane *primary;
>  	int ret;
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index bbd7acb150f3..81b8d7ae6623 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	struct resource *res;
>  	int ret;
>  
> -	drm->dev_private = arcpgu;
> -
>  	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
>  	if (IS_ERR(arcpgu->clk))
>  		return PTR_ERR(arcpgu->clk);
> @@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *)m->private;
>  	struct drm_device *drm = node->minor->dev;
> -	struct arcpgu_drm_private *arcpgu = drm->dev_private;
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	unsigned long clkrate = clk_get_rate(arcpgu->clk);
>  	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 16:47     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:47 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, Alexey Brodkin, DRI Development

On Wed, Apr 15, 2020 at 09:40:16AM +0200, Daniel Vetter wrote:
> Leftover from the conversion to the generic fbdev emulation.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject: drm/arc: arcpgu: Delete arcpgu_priv->fb

With subject fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

> ---
>  drivers/gpu/drm/arc/arcpgu.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 87821c91a00c..ed77dd5dd5cb 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -12,7 +12,6 @@ struct arcpgu_drm_private {
>  	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
> -	struct drm_framebuffer	*fb;
>  	struct drm_crtc		crtc;
>  	struct drm_plane	*plane;
>  };
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb
@ 2020-04-24 16:47     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:47 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, Alexey Brodkin, DRI Development

On Wed, Apr 15, 2020 at 09:40:16AM +0200, Daniel Vetter wrote:
> Leftover from the conversion to the generic fbdev emulation.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Subject: drm/arc: arcpgu: Delete arcpgu_priv->fb

With subject fixed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

> ---
>  drivers/gpu/drm/arc/arcpgu.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 87821c91a00c..ed77dd5dd5cb 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -12,7 +12,6 @@ struct arcpgu_drm_private {
>  	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
> -	struct drm_framebuffer	*fb;
>  	struct drm_crtc		crtc;
>  	struct drm_plane	*plane;
>  };
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 44/59] drm/arc: Drop surplus connector registration
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 16:51     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:51 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:19AM +0200, Daniel Vetter wrote:
> drm_connector_register does nothing before drm_dev_register(), it
> is meant for hotpluggable connectors only. Same for the unregister side.

Strange changelog for a patch that removes two calls to
drm_connector_unregister() and nothing else.
But it is OK - so
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/arc/arcpgu_sim.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index e42fe5d05a3d..3772df1647aa 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -29,7 +29,6 @@ static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
>  
>  static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
>  {
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  }
>  
> @@ -80,7 +79,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  	ret = drm_connector_attach_encoder(connector, encoder);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		drm_connector_unregister(connector);
>  		goto error_connector_cleanup;
>  	}
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 44/59] drm/arc: Drop surplus connector registration
@ 2020-04-24 16:51     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 16:51 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:19AM +0200, Daniel Vetter wrote:
> drm_connector_register does nothing before drm_dev_register(), it
> is meant for hotpluggable connectors only. Same for the unregister side.

Strange changelog for a patch that removes two calls to
drm_connector_unregister() and nothing else.
But it is OK - so
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/arc/arcpgu_sim.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index e42fe5d05a3d..3772df1647aa 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -29,7 +29,6 @@ static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
>  
>  static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
>  {
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  }
>  
> @@ -80,7 +79,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  	ret = drm_connector_attach_encoder(connector, encoder);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		drm_connector_unregister(connector);
>  		goto error_connector_cleanup;
>  	}
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:34     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:34 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:17AM +0200, Daniel Vetter wrote:
> This is a prep step to convert arc over to the simple kms helpers, for
> now we just use this as an embedding container to drop all the various
> allocations. Big change is the removal of the various devm_kzalloc,
> which have the wrong lifetimes anyway.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu.h      | 7 ++++---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 9 +++------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 2 +-
>  drivers/gpu/drm/arc/arcpgu_hdmi.c | 5 ++---
>  drivers/gpu/drm/arc/arcpgu_sim.c  | 5 ++---
>  5 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index ed77dd5dd5cb..52afd638a4d2 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -8,17 +8,18 @@
>  #ifndef _ARCPGU_H_
>  #define _ARCPGU_H_
>  
> +#include <drm/drm_simple_kms_helper.h>
> +
>  struct arcpgu_drm_private {
>  	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
> -	struct drm_crtc		crtc;
> -	struct drm_plane	*plane;
> +	struct drm_simple_display_pipe pipe;
>  };
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
>  
> -#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
> +#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
>  				 unsigned int reg, u32 value)
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index ba796a216244..88ba2e284fc0 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -182,9 +182,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  	struct drm_plane *plane = NULL;
>  	int ret;
>  
> -	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
> -	if (!plane)
> -		return ERR_PTR(-ENOMEM);
> +	plane = &arcpgu->pipe.plane;
>  
>  	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
>  				       arc_pgu_supported_formats,
> @@ -195,7 +193,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  		return ERR_PTR(ret);
>  
>  	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
> -	arcpgu->plane = plane;
>  
>  	return plane;
>  }
> @@ -210,13 +207,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
>  	if (IS_ERR(primary))
>  		return PTR_ERR(primary);
>  
> -	ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL,
> +	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
>  					&arc_pgu_crtc_funcs, NULL);
>  	if (ret) {
>  		arc_pgu_plane_destroy(primary);
>  		return ret;
>  	}
>  
> -	drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs);
> +	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 81b8d7ae6623..a419f279e129 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
>  	struct drm_device *drm = node->minor->dev;
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	unsigned long clkrate = clk_get_rate(arcpgu->clk);
> -	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
> +	unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
>  
>  	seq_printf(m, "hw  : %lu\n", clkrate);
>  	seq_printf(m, "mode: %lu\n", mode_clock);
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index 52839934f2fb..dbad2c9237fe 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  {
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_encoder *encoder;
>  	struct drm_bridge *bridge;
>  
>  	int ret = 0;
>  
> -	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
> -	if (encoder == NULL)
> -		return -ENOMEM;
> +	encoder = &arcpgu->pipe.encoder;
>  
>  	/* Locate drm bridge from the hdmi encoder DT node */
>  	bridge = of_drm_find_bridge(np);
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 37d961668dfe..134afb9fa625 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct arcpgu_drm_connector *arcpgu_connector;
>  	struct drm_encoder *encoder;
>  	struct drm_connector *connector;
>  	int ret;
>  
> -	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
> -	if (encoder == NULL)
> -		return -ENOMEM;
> +	encoder = &arcpgu->pipe.encoder;
>  
>  	encoder->possible_crtcs = 1;
>  	encoder->possible_clones = 0;
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe
@ 2020-04-24 17:34     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:34 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:17AM +0200, Daniel Vetter wrote:
> This is a prep step to convert arc over to the simple kms helpers, for
> now we just use this as an embedding container to drop all the various
> allocations. Big change is the removal of the various devm_kzalloc,
> which have the wrong lifetimes anyway.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu.h      | 7 ++++---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 9 +++------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 2 +-
>  drivers/gpu/drm/arc/arcpgu_hdmi.c | 5 ++---
>  drivers/gpu/drm/arc/arcpgu_sim.c  | 5 ++---
>  5 files changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index ed77dd5dd5cb..52afd638a4d2 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -8,17 +8,18 @@
>  #ifndef _ARCPGU_H_
>  #define _ARCPGU_H_
>  
> +#include <drm/drm_simple_kms_helper.h>
> +
>  struct arcpgu_drm_private {
>  	struct drm_device	drm;
>  	void __iomem		*regs;
>  	struct clk		*clk;
> -	struct drm_crtc		crtc;
> -	struct drm_plane	*plane;
> +	struct drm_simple_display_pipe pipe;
>  };
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
>  
> -#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
> +#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
>  				 unsigned int reg, u32 value)
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index ba796a216244..88ba2e284fc0 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -182,9 +182,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  	struct drm_plane *plane = NULL;
>  	int ret;
>  
> -	plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
> -	if (!plane)
> -		return ERR_PTR(-ENOMEM);
> +	plane = &arcpgu->pipe.plane;
>  
>  	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
>  				       arc_pgu_supported_formats,
> @@ -195,7 +193,6 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
>  		return ERR_PTR(ret);
>  
>  	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
> -	arcpgu->plane = plane;
>  
>  	return plane;
>  }
> @@ -210,13 +207,13 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
>  	if (IS_ERR(primary))
>  		return PTR_ERR(primary);
>  
> -	ret = drm_crtc_init_with_planes(drm, &arcpgu->crtc, primary, NULL,
> +	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
>  					&arc_pgu_crtc_funcs, NULL);
>  	if (ret) {
>  		arc_pgu_plane_destroy(primary);
>  		return ret;
>  	}
>  
> -	drm_crtc_helper_add(&arcpgu->crtc, &arc_pgu_crtc_helper_funcs);
> +	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 81b8d7ae6623..a419f279e129 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -120,7 +120,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
>  	struct drm_device *drm = node->minor->dev;
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	unsigned long clkrate = clk_get_rate(arcpgu->clk);
> -	unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
> +	unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
>  
>  	seq_printf(m, "hw  : %lu\n", clkrate);
>  	seq_printf(m, "mode: %lu\n", mode_clock);
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index 52839934f2fb..dbad2c9237fe 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -18,14 +18,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  {
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct drm_encoder *encoder;
>  	struct drm_bridge *bridge;
>  
>  	int ret = 0;
>  
> -	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
> -	if (encoder == NULL)
> -		return -ENOMEM;
> +	encoder = &arcpgu->pipe.encoder;
>  
>  	/* Locate drm bridge from the hdmi encoder DT node */
>  	bridge = of_drm_find_bridge(np);
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 37d961668dfe..134afb9fa625 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -56,14 +56,13 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
>  	struct arcpgu_drm_connector *arcpgu_connector;
>  	struct drm_encoder *encoder;
>  	struct drm_connector *connector;
>  	int ret;
>  
> -	encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
> -	if (encoder == NULL)
> -		return -ENOMEM;
> +	encoder = &arcpgu->pipe.encoder;
>  
>  	encoder->possible_crtcs = 1;
>  	encoder->possible_clones = 0;
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:34     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:34 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:18AM +0200, Daniel Vetter wrote:
> Removes the last devm_kzalloc, which means we're now prepared to use
> drmm_mode_config_cleanup!
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu.h     |  1 +
>  drivers/gpu/drm/arc/arcpgu_sim.c | 14 +-------------
>  2 files changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 52afd638a4d2..c52cdd2274e1 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -15,6 +15,7 @@ struct arcpgu_drm_private {
>  	void __iomem		*regs;
>  	struct clk		*clk;
>  	struct drm_simple_display_pipe pipe;
> +	struct drm_connector	sim_conn;
>  };
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 134afb9fa625..e42fe5d05a3d 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -18,10 +18,6 @@
>  #define YRES_MAX	8192
>  
>  
> -struct arcpgu_drm_connector {
> -	struct drm_connector connector;
> -};
> -
>  static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
>  {
>  	int count;
> @@ -57,7 +53,6 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct arcpgu_drm_connector *arcpgu_connector;
>  	struct drm_encoder *encoder;
>  	struct drm_connector *connector;
>  	int ret;
> @@ -72,14 +67,7 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  	if (ret)
>  		return ret;
>  
> -	arcpgu_connector = devm_kzalloc(drm->dev, sizeof(*arcpgu_connector),
> -					GFP_KERNEL);
> -	if (!arcpgu_connector) {
> -		ret = -ENOMEM;
> -		goto error_encoder_cleanup;
> -	}
> -
> -	connector = &arcpgu_connector->connector;
> +	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
>  
>  	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case
@ 2020-04-24 17:34     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:34 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:18AM +0200, Daniel Vetter wrote:
> Removes the last devm_kzalloc, which means we're now prepared to use
> drmm_mode_config_cleanup!
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu.h     |  1 +
>  drivers/gpu/drm/arc/arcpgu_sim.c | 14 +-------------
>  2 files changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index 52afd638a4d2..c52cdd2274e1 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -15,6 +15,7 @@ struct arcpgu_drm_private {
>  	void __iomem		*regs;
>  	struct clk		*clk;
>  	struct drm_simple_display_pipe pipe;
> +	struct drm_connector	sim_conn;
>  };
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 134afb9fa625..e42fe5d05a3d 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -18,10 +18,6 @@
>  #define YRES_MAX	8192
>  
>  
> -struct arcpgu_drm_connector {
> -	struct drm_connector connector;
> -};
> -
>  static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
>  {
>  	int count;
> @@ -57,7 +53,6 @@ static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct arcpgu_drm_connector *arcpgu_connector;
>  	struct drm_encoder *encoder;
>  	struct drm_connector *connector;
>  	int ret;
> @@ -72,14 +67,7 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  	if (ret)
>  		return ret;
>  
> -	arcpgu_connector = devm_kzalloc(drm->dev, sizeof(*arcpgu_connector),
> -					GFP_KERNEL);
> -	if (!arcpgu_connector) {
> -		ret = -ENOMEM;
> -		goto error_encoder_cleanup;
> -	}
> -
> -	connector = &arcpgu_connector->connector;
> +	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
>  
>  	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:36     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:36 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:20AM +0200, Daniel Vetter wrote:
> With autocleanup through drm_device management we can delete all the
> code. Possible now that there's no confusion against devm_kzalloc'ed
> structures anymore.
> 
> I inlined arcpgu_setup_mode_config because it's tiny and the newly
> needed return value handling would have been more ...
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c |  4 +---
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 21 +++++++++------------
>  drivers/gpu/drm/arc/arcpgu_hdmi.c |  6 +-----
>  drivers/gpu/drm/arc/arcpgu_sim.c  | 11 ++---------
>  4 files changed, 13 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 88ba2e284fc0..72719556debb 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -209,10 +209,8 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
>  
>  	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
>  					&arc_pgu_crtc_funcs, NULL);
> -	if (ret) {
> -		arc_pgu_plane_destroy(primary);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
>  	return 0;
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index a419f279e129..40c9fc12d515 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -30,16 +30,6 @@ static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
>  	.atomic_commit = drm_atomic_helper_commit,
>  };
>  
> -static void arcpgu_setup_mode_config(struct drm_device *drm)
> -{
> -	drm_mode_config_init(drm);
> -	drm->mode_config.min_width = 0;
> -	drm->mode_config.min_height = 0;
> -	drm->mode_config.max_width = 1920;
> -	drm->mode_config.max_height = 1080;
> -	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
> -}
> -
>  DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
>  
>  static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> @@ -54,7 +44,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (IS_ERR(arcpgu->clk))
>  		return PTR_ERR(arcpgu->clk);
>  
> -	arcpgu_setup_mode_config(drm);
> +	ret = drmm_mode_config_init(drm);
> +	if (ret)
> +		return ret;
> +
> +	drm->mode_config.min_width = 0;
> +	drm->mode_config.min_height = 0;
> +	drm->mode_config.max_width = 1920;
> +	drm->mode_config.max_height = 1080;
> +	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
> @@ -108,7 +106,6 @@ static int arcpgu_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
>  	drm_atomic_helper_shutdown(drm);
> -	drm_mode_config_cleanup(drm);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index dbad2c9237fe..925d6d31bb78 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -39,9 +39,5 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  		return ret;
>  
>  	/* Link drm_bridge to encoder */
> -	ret = drm_bridge_attach(encoder, bridge, NULL, 0);
> -	if (ret)
> -		drm_encoder_cleanup(encoder);
> -
> -	return ret;
> +	return drm_bridge_attach(encoder, bridge, NULL, 0);
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 3772df1647aa..afc34f8b4de0 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -73,21 +73,14 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  			DRM_MODE_CONNECTOR_VIRTUAL);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		goto error_encoder_cleanup;
> +		return ret;
>  	}
>  
>  	ret = drm_connector_attach_encoder(connector, encoder);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		goto error_connector_cleanup;
> +		return ret;
>  	}
>  
>  	return 0;
> -
> -error_connector_cleanup:
> -	drm_connector_cleanup(connector);
> -
> -error_encoder_cleanup:
> -	drm_encoder_cleanup(encoder);
> -	return ret;
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup
@ 2020-04-24 17:36     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:36 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:20AM +0200, Daniel Vetter wrote:
> With autocleanup through drm_device management we can delete all the
> code. Possible now that there's no confusion against devm_kzalloc'ed
> structures anymore.
> 
> I inlined arcpgu_setup_mode_config because it's tiny and the newly
> needed return value handling would have been more ...
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c |  4 +---
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 21 +++++++++------------
>  drivers/gpu/drm/arc/arcpgu_hdmi.c |  6 +-----
>  drivers/gpu/drm/arc/arcpgu_sim.c  | 11 ++---------
>  4 files changed, 13 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 88ba2e284fc0..72719556debb 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -209,10 +209,8 @@ int arc_pgu_setup_crtc(struct drm_device *drm)
>  
>  	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
>  					&arc_pgu_crtc_funcs, NULL);
> -	if (ret) {
> -		arc_pgu_plane_destroy(primary);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
>  	return 0;
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index a419f279e129..40c9fc12d515 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -30,16 +30,6 @@ static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
>  	.atomic_commit = drm_atomic_helper_commit,
>  };
>  
> -static void arcpgu_setup_mode_config(struct drm_device *drm)
> -{
> -	drm_mode_config_init(drm);
> -	drm->mode_config.min_width = 0;
> -	drm->mode_config.min_height = 0;
> -	drm->mode_config.max_width = 1920;
> -	drm->mode_config.max_height = 1080;
> -	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
> -}
> -
>  DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops);
>  
>  static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> @@ -54,7 +44,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (IS_ERR(arcpgu->clk))
>  		return PTR_ERR(arcpgu->clk);
>  
> -	arcpgu_setup_mode_config(drm);
> +	ret = drmm_mode_config_init(drm);
> +	if (ret)
> +		return ret;
> +
> +	drm->mode_config.min_width = 0;
> +	drm->mode_config.min_height = 0;
> +	drm->mode_config.max_width = 1920;
> +	drm->mode_config.max_height = 1080;
> +	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
> @@ -108,7 +106,6 @@ static int arcpgu_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
>  	drm_atomic_helper_shutdown(drm);
> -	drm_mode_config_cleanup(drm);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index dbad2c9237fe..925d6d31bb78 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -39,9 +39,5 @@ int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  		return ret;
>  
>  	/* Link drm_bridge to encoder */
> -	ret = drm_bridge_attach(encoder, bridge, NULL, 0);
> -	if (ret)
> -		drm_encoder_cleanup(encoder);
> -
> -	return ret;
> +	return drm_bridge_attach(encoder, bridge, NULL, 0);
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index 3772df1647aa..afc34f8b4de0 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -73,21 +73,14 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  			DRM_MODE_CONNECTOR_VIRTUAL);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		goto error_encoder_cleanup;
> +		return ret;
>  	}
>  
>  	ret = drm_connector_attach_encoder(connector, encoder);
>  	if (ret < 0) {
>  		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		goto error_connector_cleanup;
> +		return ret;
>  	}
>  
>  	return 0;
> -
> -error_connector_cleanup:
> -	drm_connector_cleanup(connector);
> -
> -error_encoder_cleanup:
> -	drm_encoder_cleanup(encoder);
> -	return ret;
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:40     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:40 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:22AM +0200, Daniel Vetter wrote:
> Really straighforward, only slight issue is that the sim connector is
> created after the pipe is set up, so can't use the helpers perfectly
> yet. Subsequent patches will fix that.
> 
> Aside from lots of deleting code no functional changes in here.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Lots of simplifications by using drm_simple_* - good.

One open Q below - but if this is OK then
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu.h      |   4 +-
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 102 ++++++++----------------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  |   2 +-
>  drivers/gpu/drm/arc/arcpgu_hdmi.c |  18 +-----
>  4 files changed, 31 insertions(+), 95 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index c52cdd2274e1..b5c699d14f27 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -20,7 +20,7 @@ struct arcpgu_drm_private {
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
>  
> -#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
> +#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
>  				 unsigned int reg, u32 value)
> @@ -34,7 +34,7 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arc_pgu_setup_crtc(struct drm_device *dev);
> +int arc_pgu_setup_pipe(struct drm_device *dev);
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index c7769edeefdf..5c6d7e34ca73 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -25,10 +25,9 @@ static const u32 arc_pgu_supported_formats[] = {
>  	DRM_FORMAT_ARGB8888,
>  };
>  
> -static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
> +static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> -	const struct drm_framebuffer *fb = crtc->primary->state->fb;
> +	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
>  	uint32_t pixel_format = fb->format->format;
>  	u32 format = DRM_FORMAT_INVALID;
>  	int i;
> @@ -59,10 +58,10 @@ static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
>  };
>  
> -static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
> -						    const struct drm_display_mode *mode)
> +static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> +					       const struct drm_display_mode *mode)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  	long rate, clk_rate = mode->clock * 1000;
>  	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
>  
> @@ -109,15 +108,16 @@ static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
>  	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
>  
> -	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
> +	arc_pgu_set_pxl_fmt(arcpgu);
>  
>  	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
>  }
>  
> -static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
> -				       struct drm_crtc_state *old_state)
> +static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> +			   struct drm_crtc_state *crtc_state,
> +			   struct drm_plane_state *plane_state)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  
>  	arc_pgu_mode_set(arcpgu);
>  
> @@ -127,10 +127,9 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
>  		      ARCPGU_CTRL_ENABLE_MASK);
>  }
>  
> -static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
> -					struct drm_crtc_state *old_state)
> +static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  
>  	clk_disable_unprepare(arcpgu->clk);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> @@ -138,80 +137,33 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
>  			      ~ARCPGU_CTRL_ENABLE_MASK);
>  }
>  
> -static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
> -	.mode_valid	= arc_pgu_crtc_mode_valid,
> -	.atomic_enable	= arc_pgu_crtc_atomic_enable,
> -	.atomic_disable	= arc_pgu_crtc_atomic_disable,
> -};
> -
> -static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> +static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> +			   struct drm_plane_state *state)
>  {
>  	struct arcpgu_drm_private *arcpgu;
>  	struct drm_gem_cma_object *gem;
>  
> -	if (!plane->state->crtc || !plane->state->fb)
> +	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
>  		return;
>  
> -	arcpgu = crtc_to_arcpgu_priv(plane->state->crtc);
> -	gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
> +	arcpgu = pipe_to_arcpgu_priv(pipe);
> +	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
>  }
>  
> -static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = {
> -	.atomic_update = arc_pgu_plane_atomic_update,
> +static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> +	.update = arc_pgu_update,
> +	.mode_valid = arc_pgu_mode_valid,
> +	.enable	= arc_pgu_enable,
> +	.disable = arc_pgu_disable,
>  };
>  
> -static void arc_pgu_plane_destroy(struct drm_plane *plane)
> -{
> -	drm_plane_cleanup(plane);
> -}
> -
> -static const struct drm_plane_funcs arc_pgu_plane_funcs = {
> -	.update_plane		= drm_atomic_helper_update_plane,
> -	.disable_plane		= drm_atomic_helper_disable_plane,
> -	.destroy		= arc_pgu_plane_destroy,
> -	.reset			= drm_atomic_helper_plane_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
> -	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
> -};
> -
> -static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> +int arc_pgu_setup_pipe(struct drm_device *drm)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_plane *plane = NULL;
> -	int ret;
> -
> -	plane = &arcpgu->pipe.plane;
> -
> -	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
> -				       arc_pgu_supported_formats,
> -				       ARRAY_SIZE(arc_pgu_supported_formats),
> -				       NULL,
> -				       DRM_PLANE_TYPE_PRIMARY, NULL);
> -	if (ret)
> -		return ERR_PTR(ret);
> -
> -	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
> -
> -	return plane;
> -}
> -
> -int arc_pgu_setup_crtc(struct drm_device *drm)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_plane *primary;
> -	int ret;
> -
> -	primary = arc_pgu_plane_init(drm);
> -	if (IS_ERR(primary))
> -		return PTR_ERR(primary);
> -
> -	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
> -					&arc_pgu_crtc_funcs, NULL);
> -	if (ret)
> -		return ret;
>  
> -	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
> -	return 0;
> +	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					    arc_pgu_supported_formats,
> +					    ARRAY_SIZE(arc_pgu_supported_formats),
> +					    NULL, NULL);
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 40c9fc12d515..bf03eda532bc 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -70,7 +70,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	if (arc_pgu_setup_crtc(drm) < 0)
> +	if (arc_pgu_setup_pipe(drm) < 0)
>  		return -ENODEV;
>  
>  	/*
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index 925d6d31bb78..d430af686cbc 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -12,32 +12,16 @@
>  
>  #include "arcpgu.h"
>  
> -static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
> -	.destroy = drm_encoder_cleanup,
> -};
> -
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
>  	struct drm_bridge *bridge;
>  
> -	int ret = 0;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
>  	/* Locate drm bridge from the hdmi encoder DT node */
>  	bridge = of_drm_find_bridge(np);
>  	if (!bridge)
>  		return -EPROBE_DEFER;
>  
> -	encoder->possible_crtcs = 1;
> -	encoder->possible_clones = 0;
> -	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
> -			       DRM_MODE_ENCODER_TMDS, NULL);

drm_simple_* will create a DRM_MODE_ENCODER_NONE - so the
encoder type will be different.
If this has any practical implications I dunno.

	Sam

> -	if (ret)
> -		return ret;
> -
>  	/* Link drm_bridge to encoder */
> -	return drm_bridge_attach(encoder, bridge, NULL, 0);
> +	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper
@ 2020-04-24 17:40     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:40 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:22AM +0200, Daniel Vetter wrote:
> Really straighforward, only slight issue is that the sim connector is
> created after the pipe is set up, so can't use the helpers perfectly
> yet. Subsequent patches will fix that.
> 
> Aside from lots of deleting code no functional changes in here.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

Lots of simplifications by using drm_simple_* - good.

One open Q below - but if this is OK then
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu.h      |   4 +-
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 102 ++++++++----------------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  |   2 +-
>  drivers/gpu/drm/arc/arcpgu_hdmi.c |  18 +-----
>  4 files changed, 31 insertions(+), 95 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index c52cdd2274e1..b5c699d14f27 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -20,7 +20,7 @@ struct arcpgu_drm_private {
>  
>  #define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
>  
> -#define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe.crtc)
> +#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
>  
>  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
>  				 unsigned int reg, u32 value)
> @@ -34,7 +34,7 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arc_pgu_setup_crtc(struct drm_device *dev);
> +int arc_pgu_setup_pipe(struct drm_device *dev);
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index c7769edeefdf..5c6d7e34ca73 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -25,10 +25,9 @@ static const u32 arc_pgu_supported_formats[] = {
>  	DRM_FORMAT_ARGB8888,
>  };
>  
> -static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
> +static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> -	const struct drm_framebuffer *fb = crtc->primary->state->fb;
> +	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
>  	uint32_t pixel_format = fb->format->format;
>  	u32 format = DRM_FORMAT_INVALID;
>  	int i;
> @@ -59,10 +58,10 @@ static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
>  };
>  
> -static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
> -						    const struct drm_display_mode *mode)
> +static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> +					       const struct drm_display_mode *mode)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  	long rate, clk_rate = mode->clock * 1000;
>  	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
>  
> @@ -109,15 +108,16 @@ static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
>  	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
>  
> -	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
> +	arc_pgu_set_pxl_fmt(arcpgu);
>  
>  	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
>  }
>  
> -static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
> -				       struct drm_crtc_state *old_state)
> +static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> +			   struct drm_crtc_state *crtc_state,
> +			   struct drm_plane_state *plane_state)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  
>  	arc_pgu_mode_set(arcpgu);
>  
> @@ -127,10 +127,9 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
>  		      ARCPGU_CTRL_ENABLE_MASK);
>  }
>  
> -static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
> -					struct drm_crtc_state *old_state)
> +static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
>  
>  	clk_disable_unprepare(arcpgu->clk);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> @@ -138,80 +137,33 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
>  			      ~ARCPGU_CTRL_ENABLE_MASK);
>  }
>  
> -static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
> -	.mode_valid	= arc_pgu_crtc_mode_valid,
> -	.atomic_enable	= arc_pgu_crtc_atomic_enable,
> -	.atomic_disable	= arc_pgu_crtc_atomic_disable,
> -};
> -
> -static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> +static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> +			   struct drm_plane_state *state)
>  {
>  	struct arcpgu_drm_private *arcpgu;
>  	struct drm_gem_cma_object *gem;
>  
> -	if (!plane->state->crtc || !plane->state->fb)
> +	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
>  		return;
>  
> -	arcpgu = crtc_to_arcpgu_priv(plane->state->crtc);
> -	gem = drm_fb_cma_get_gem_obj(plane->state->fb, 0);
> +	arcpgu = pipe_to_arcpgu_priv(pipe);
> +	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
>  }
>  
> -static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = {
> -	.atomic_update = arc_pgu_plane_atomic_update,
> +static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> +	.update = arc_pgu_update,
> +	.mode_valid = arc_pgu_mode_valid,
> +	.enable	= arc_pgu_enable,
> +	.disable = arc_pgu_disable,
>  };
>  
> -static void arc_pgu_plane_destroy(struct drm_plane *plane)
> -{
> -	drm_plane_cleanup(plane);
> -}
> -
> -static const struct drm_plane_funcs arc_pgu_plane_funcs = {
> -	.update_plane		= drm_atomic_helper_update_plane,
> -	.disable_plane		= drm_atomic_helper_disable_plane,
> -	.destroy		= arc_pgu_plane_destroy,
> -	.reset			= drm_atomic_helper_plane_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
> -	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
> -};
> -
> -static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> +int arc_pgu_setup_pipe(struct drm_device *drm)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_plane *plane = NULL;
> -	int ret;
> -
> -	plane = &arcpgu->pipe.plane;
> -
> -	ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
> -				       arc_pgu_supported_formats,
> -				       ARRAY_SIZE(arc_pgu_supported_formats),
> -				       NULL,
> -				       DRM_PLANE_TYPE_PRIMARY, NULL);
> -	if (ret)
> -		return ERR_PTR(ret);
> -
> -	drm_plane_helper_add(plane, &arc_pgu_plane_helper_funcs);
> -
> -	return plane;
> -}
> -
> -int arc_pgu_setup_crtc(struct drm_device *drm)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_plane *primary;
> -	int ret;
> -
> -	primary = arc_pgu_plane_init(drm);
> -	if (IS_ERR(primary))
> -		return PTR_ERR(primary);
> -
> -	ret = drm_crtc_init_with_planes(drm, &arcpgu->pipe.crtc, primary, NULL,
> -					&arc_pgu_crtc_funcs, NULL);
> -	if (ret)
> -		return ret;
>  
> -	drm_crtc_helper_add(&arcpgu->pipe.crtc, &arc_pgu_crtc_helper_funcs);
> -	return 0;
> +	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					    arc_pgu_supported_formats,
> +					    ARRAY_SIZE(arc_pgu_supported_formats),
> +					    NULL, NULL);
>  }
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 40c9fc12d515..bf03eda532bc 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -70,7 +70,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	if (arc_pgu_setup_crtc(drm) < 0)
> +	if (arc_pgu_setup_pipe(drm) < 0)
>  		return -ENODEV;
>  
>  	/*
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> index 925d6d31bb78..d430af686cbc 100644
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> @@ -12,32 +12,16 @@
>  
>  #include "arcpgu.h"
>  
> -static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
> -	.destroy = drm_encoder_cleanup,
> -};
> -
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
>  	struct drm_bridge *bridge;
>  
> -	int ret = 0;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
>  	/* Locate drm bridge from the hdmi encoder DT node */
>  	bridge = of_drm_find_bridge(np);
>  	if (!bridge)
>  		return -EPROBE_DEFER;
>  
> -	encoder->possible_crtcs = 1;
> -	encoder->possible_clones = 0;
> -	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
> -			       DRM_MODE_ENCODER_TMDS, NULL);

drm_simple_* will create a DRM_MODE_ENCODER_NONE - so the
encoder type will be different.
If this has any practical implications I dunno.

	Sam

> -	if (ret)
> -		return ret;
> -
>  	/* Link drm_bridge to encoder */
> -	return drm_bridge_attach(encoder, bridge, NULL, 0);
> +	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
>  }
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:45     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:45 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:23AM +0200, Daniel Vetter wrote:
> First it's redundant, fb and crtc are only ever both set or not set.


> 2nd, the atomic_check code in simple display pipe helpers guarantees
> that this never happens.
I looked at drm_simple_kms_plane_atomic_check() - which I assume you
refer to. And I see no code that will guarantee both.

What have I missed?

	Sam


So nice bugfix for arcpgu driver here, since
> it was lacking a call to drm_atomic_helper_check_plane_state().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 5c6d7e34ca73..4655f03e37f1 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -143,9 +143,6 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>  	struct arcpgu_drm_private *arcpgu;
>  	struct drm_gem_cma_object *gem;
>  
> -	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
> -		return;
> -
>  	arcpgu = pipe_to_arcpgu_priv(pipe);
>  	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update
@ 2020-04-24 17:45     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:45 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:23AM +0200, Daniel Vetter wrote:
> First it's redundant, fb and crtc are only ever both set or not set.


> 2nd, the atomic_check code in simple display pipe helpers guarantees
> that this never happens.
I looked at drm_simple_kms_plane_atomic_check() - which I assume you
refer to. And I see no code that will guarantee both.

What have I missed?

	Sam


So nice bugfix for arcpgu driver here, since
> it was lacking a call to drm_atomic_helper_check_plane_state().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 5c6d7e34ca73..4655f03e37f1 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -143,9 +143,6 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>  	struct arcpgu_drm_private *arcpgu;
>  	struct drm_gem_cma_object *gem;
>  
> -	if (!pipe->plane.state->crtc || !pipe->plane.state->fb)
> -		return;
> -
>  	arcpgu = pipe_to_arcpgu_priv(pipe);
>  	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:51     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:51 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:24AM +0200, Daniel Vetter wrote:
> Really not big anymore.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

A few things below that maybe should be addressed. Otherwise:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/Makefile      |   2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |   1 -
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 166 ------------------------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 147 +++++++++++++++++++++++++-
>  drivers/gpu/drm/arc/arcpgu_sim.c  |  12 ---
>  5 files changed, 146 insertions(+), 182 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index c7028b7427b3..c686e0287a71 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_crtc.o arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index b5c699d14f27..cee2448a07d6 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arc_pgu_setup_pipe(struct drm_device *dev);
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> deleted file mode 100644
> index 4655f03e37f1..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ /dev/null
> @@ -1,166 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_atomic_helper.h>
> -#include <drm/drm_device.h>
> -#include <drm/drm_fb_cma_helper.h>
> -#include <drm/drm_gem_cma_helper.h>
> -#include <drm/drm_plane_helper.h>
> -#include <drm/drm_probe_helper.h>
> -#include <linux/clk.h>
> -#include <linux/platform_data/simplefb.h>
> -
> -#include "arcpgu.h"
> -#include "arcpgu_regs.h"
> -
> -#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> -
> -static const u32 arc_pgu_supported_formats[] = {
> -	DRM_FORMAT_RGB565,
> -	DRM_FORMAT_XRGB8888,
> -	DRM_FORMAT_ARGB8888,
> -};
> -
> -static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
> -{
> -	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
> -	uint32_t pixel_format = fb->format->format;
> -	u32 format = DRM_FORMAT_INVALID;
> -	int i;
> -	u32 reg_ctrl;
> -
> -	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
> -		if (arc_pgu_supported_formats[i] == pixel_format)
> -			format = arc_pgu_supported_formats[i];
> -	}
> -
> -	if (WARN_ON(format == DRM_FORMAT_INVALID))
> -		return;
> -
> -	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> -	if (format == DRM_FORMAT_RGB565)
> -		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
> -	else
> -		reg_ctrl |= ARCPGU_MODE_XRGB8888;
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
> -}
> -
> -static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
> -	.destroy = drm_crtc_cleanup,
> -	.set_config = drm_atomic_helper_set_config,
> -	.page_flip = drm_atomic_helper_page_flip,
> -	.reset = drm_atomic_helper_crtc_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> -};
> -
> -static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> -					       const struct drm_display_mode *mode)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -	long rate, clk_rate = mode->clock * 1000;
> -	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
> -
> -	rate = clk_round_rate(arcpgu->clk, clk_rate);
> -	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
> -		return MODE_OK;
> -
> -	return MODE_NOCLOCK;
> -}
> -
> -static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
> -{
> -	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
> -	u32 val;
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> -		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
> -		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
> -				    m->crtc_hsync_end - m->crtc_hdisplay));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
> -		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
> -				    m->crtc_vsync_end - m->crtc_vdisplay));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
> -		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
> -				    m->crtc_vblank_end - m->crtc_vblank_start));
> -
> -	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> -
> -	if (m->flags & DRM_MODE_FLAG_PVSYNC)
> -		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
> -	else
> -		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
> -
> -	if (m->flags & DRM_MODE_FLAG_PHSYNC)
> -		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
> -	else
> -		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
> -
> -	arc_pgu_set_pxl_fmt(arcpgu);
> -
> -	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
> -}
> -
> -static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> -			   struct drm_crtc_state *crtc_state,
> -			   struct drm_plane_state *plane_state)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -
> -	arc_pgu_mode_set(arcpgu);
> -
> -	clk_prepare_enable(arcpgu->clk);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> -		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> -		      ARCPGU_CTRL_ENABLE_MASK);
> -}
> -
> -static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -
> -	clk_disable_unprepare(arcpgu->clk);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> -			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
> -			      ~ARCPGU_CTRL_ENABLE_MASK);
> -}
> -
> -static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> -			   struct drm_plane_state *state)
> -{
> -	struct arcpgu_drm_private *arcpgu;
> -	struct drm_gem_cma_object *gem;
> -
> -	arcpgu = pipe_to_arcpgu_priv(pipe);
> -	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> -}
> -
> -static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> -	.update = arc_pgu_update,
> -	.mode_valid = arc_pgu_mode_valid,
> -	.enable	= arc_pgu_enable,
> -	.disable = arc_pgu_disable,
> -};
> -
> -int arc_pgu_setup_pipe(struct drm_device *drm)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -
> -	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> -					    arc_pgu_supported_formats,
> -					    ARRAY_SIZE(arc_pgu_supported_formats),
> -					    NULL, NULL);
> -}
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index bf03eda532bc..2443e3c78a76 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -12,6 +12,7 @@
>  #include <drm/drm_drv.h>
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_fourcc.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_of.h>
> @@ -24,6 +25,144 @@
>  #include "arcpgu.h"
>  #include "arcpgu_regs.h"
>  
> +#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> +
> +static const u32 arc_pgu_supported_formats[] = {
> +	DRM_FORMAT_RGB565,
> +	DRM_FORMAT_XRGB8888,
> +	DRM_FORMAT_ARGB8888,
> +};
> +
> +static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
> +{
> +	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
> +	uint32_t pixel_format = fb->format->format;
> +	u32 format = DRM_FORMAT_INVALID;
> +	int i;
> +	u32 reg_ctrl;
> +
> +	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
> +		if (arc_pgu_supported_formats[i] == pixel_format)
> +			format = arc_pgu_supported_formats[i];
> +	}
> +
> +	if (WARN_ON(format == DRM_FORMAT_INVALID))
> +		return;
> +
> +	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> +	if (format == DRM_FORMAT_RGB565)
> +		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
> +	else
> +		reg_ctrl |= ARCPGU_MODE_XRGB8888;
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
> +}
> +
> +static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
> +	.destroy = drm_crtc_cleanup,
> +	.set_config = drm_atomic_helper_set_config,
> +	.page_flip = drm_atomic_helper_page_flip,
> +	.reset = drm_atomic_helper_crtc_reset,
> +	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> +};
> +
> +static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> +					       const struct drm_display_mode *mode)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +	long rate, clk_rate = mode->clock * 1000;
> +	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
> +
> +	rate = clk_round_rate(arcpgu->clk, clk_rate);
> +	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
> +		return MODE_OK;
> +
> +	return MODE_NOCLOCK;
> +}
> +
> +static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
> +{
> +	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
> +	u32 val;
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> +		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
> +		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
> +				    m->crtc_hsync_end - m->crtc_hdisplay));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
> +		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
> +				    m->crtc_vsync_end - m->crtc_vdisplay));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
> +		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
> +				    m->crtc_vblank_end - m->crtc_vblank_start));
> +
> +	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> +
> +	if (m->flags & DRM_MODE_FLAG_PVSYNC)
> +		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
> +	else
> +		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
> +
> +	if (m->flags & DRM_MODE_FLAG_PHSYNC)
> +		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
> +	else
> +		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
> +
> +	arc_pgu_set_pxl_fmt(arcpgu);
> +
> +	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
> +}
> +
> +static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> +			   struct drm_crtc_state *crtc_state,
> +			   struct drm_plane_state *plane_state)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +
> +	arc_pgu_mode_set(arcpgu);
> +
> +	clk_prepare_enable(arcpgu->clk);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> +		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> +		      ARCPGU_CTRL_ENABLE_MASK);
> +}
> +
> +static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +
> +	clk_disable_unprepare(arcpgu->clk);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> +			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
> +			      ~ARCPGU_CTRL_ENABLE_MASK);
> +}
> +
> +static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> +			   struct drm_plane_state *state)
> +{
> +	struct arcpgu_drm_private *arcpgu;
> +	struct drm_gem_cma_object *gem;
> +
> +	arcpgu = pipe_to_arcpgu_priv(pipe);
> +	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> +}
> +
> +static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> +	.update = arc_pgu_update,
> +	.mode_valid = arc_pgu_mode_valid,
> +	.enable	= arc_pgu_enable,
> +	.disable = arc_pgu_disable,
> +};
> +
>  static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
>  	.fb_create  = drm_gem_fb_create,
>  	.atomic_check = drm_atomic_helper_check,
> @@ -70,8 +209,12 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	if (arc_pgu_setup_pipe(drm) < 0)
> -		return -ENODEV;
> +	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					   arc_pgu_supported_formats,
> +					   ARRAY_SIZE(arc_pgu_supported_formats),
> +					   NULL, NULL);
> +	if (ret)
> +		return ret;

Detail. In the old code ant error was converted to -ENODEV.
The new code let the error code bubble up - which is better.
But this is a small change that is not in the changelog.


>  
>  	/*
>  	 * There is only one output port inside each device. It is linked with
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index afc34f8b4de0..1a63f0868504 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -45,10 +45,6 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>  
> -static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
> -	.destroy = drm_encoder_cleanup,
> -};
> -
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> @@ -58,14 +54,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  
>  	encoder = &arcpgu->pipe.encoder;
>  
> -	encoder->possible_crtcs = 1;
> -	encoder->possible_clones = 0;
> -
> -	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
> -			       DRM_MODE_ENCODER_VIRTUAL, NULL);
> -	if (ret)
> -		return ret;
> -

This looks like code that belongs in one of the former patches.
Not that it matters much but anyway.

	Sam

>  	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c
@ 2020-04-24 17:51     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:51 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:24AM +0200, Daniel Vetter wrote:
> Really not big anymore.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

A few things below that maybe should be addressed. Otherwise:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/Makefile      |   2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |   1 -
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 166 ------------------------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 147 +++++++++++++++++++++++++-
>  drivers/gpu/drm/arc/arcpgu_sim.c  |  12 ---
>  5 files changed, 146 insertions(+), 182 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_crtc.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index c7028b7427b3..c686e0287a71 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_crtc.o arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index b5c699d14f27..cee2448a07d6 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arc_pgu_setup_pipe(struct drm_device *dev);
>  int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> deleted file mode 100644
> index 4655f03e37f1..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ /dev/null
> @@ -1,166 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_atomic_helper.h>
> -#include <drm/drm_device.h>
> -#include <drm/drm_fb_cma_helper.h>
> -#include <drm/drm_gem_cma_helper.h>
> -#include <drm/drm_plane_helper.h>
> -#include <drm/drm_probe_helper.h>
> -#include <linux/clk.h>
> -#include <linux/platform_data/simplefb.h>
> -
> -#include "arcpgu.h"
> -#include "arcpgu_regs.h"
> -
> -#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> -
> -static const u32 arc_pgu_supported_formats[] = {
> -	DRM_FORMAT_RGB565,
> -	DRM_FORMAT_XRGB8888,
> -	DRM_FORMAT_ARGB8888,
> -};
> -
> -static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
> -{
> -	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
> -	uint32_t pixel_format = fb->format->format;
> -	u32 format = DRM_FORMAT_INVALID;
> -	int i;
> -	u32 reg_ctrl;
> -
> -	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
> -		if (arc_pgu_supported_formats[i] == pixel_format)
> -			format = arc_pgu_supported_formats[i];
> -	}
> -
> -	if (WARN_ON(format == DRM_FORMAT_INVALID))
> -		return;
> -
> -	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> -	if (format == DRM_FORMAT_RGB565)
> -		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
> -	else
> -		reg_ctrl |= ARCPGU_MODE_XRGB8888;
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
> -}
> -
> -static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
> -	.destroy = drm_crtc_cleanup,
> -	.set_config = drm_atomic_helper_set_config,
> -	.page_flip = drm_atomic_helper_page_flip,
> -	.reset = drm_atomic_helper_crtc_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> -};
> -
> -static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> -					       const struct drm_display_mode *mode)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -	long rate, clk_rate = mode->clock * 1000;
> -	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
> -
> -	rate = clk_round_rate(arcpgu->clk, clk_rate);
> -	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
> -		return MODE_OK;
> -
> -	return MODE_NOCLOCK;
> -}
> -
> -static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
> -{
> -	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
> -	u32 val;
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> -		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
> -		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
> -				    m->crtc_hsync_end - m->crtc_hdisplay));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
> -		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
> -				    m->crtc_vsync_end - m->crtc_vdisplay));
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
> -		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
> -				    m->crtc_vblank_end - m->crtc_vblank_start));
> -
> -	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> -
> -	if (m->flags & DRM_MODE_FLAG_PVSYNC)
> -		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
> -	else
> -		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
> -
> -	if (m->flags & DRM_MODE_FLAG_PHSYNC)
> -		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
> -	else
> -		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
> -
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
> -
> -	arc_pgu_set_pxl_fmt(arcpgu);
> -
> -	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
> -}
> -
> -static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> -			   struct drm_crtc_state *crtc_state,
> -			   struct drm_plane_state *plane_state)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -
> -	arc_pgu_mode_set(arcpgu);
> -
> -	clk_prepare_enable(arcpgu->clk);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> -		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> -		      ARCPGU_CTRL_ENABLE_MASK);
> -}
> -
> -static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
> -{
> -	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> -
> -	clk_disable_unprepare(arcpgu->clk);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> -			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
> -			      ~ARCPGU_CTRL_ENABLE_MASK);
> -}
> -
> -static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> -			   struct drm_plane_state *state)
> -{
> -	struct arcpgu_drm_private *arcpgu;
> -	struct drm_gem_cma_object *gem;
> -
> -	arcpgu = pipe_to_arcpgu_priv(pipe);
> -	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> -	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> -}
> -
> -static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> -	.update = arc_pgu_update,
> -	.mode_valid = arc_pgu_mode_valid,
> -	.enable	= arc_pgu_enable,
> -	.disable = arc_pgu_disable,
> -};
> -
> -int arc_pgu_setup_pipe(struct drm_device *drm)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -
> -	return drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> -					    arc_pgu_supported_formats,
> -					    ARRAY_SIZE(arc_pgu_supported_formats),
> -					    NULL, NULL);
> -}
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index bf03eda532bc..2443e3c78a76 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -12,6 +12,7 @@
>  #include <drm/drm_drv.h>
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_fourcc.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_of.h>
> @@ -24,6 +25,144 @@
>  #include "arcpgu.h"
>  #include "arcpgu_regs.h"
>  
> +#define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> +
> +static const u32 arc_pgu_supported_formats[] = {
> +	DRM_FORMAT_RGB565,
> +	DRM_FORMAT_XRGB8888,
> +	DRM_FORMAT_ARGB8888,
> +};
> +
> +static void arc_pgu_set_pxl_fmt(struct arcpgu_drm_private *arcpgu)
> +{
> +	const struct drm_framebuffer *fb = arcpgu->pipe.plane.state->fb;
> +	uint32_t pixel_format = fb->format->format;
> +	u32 format = DRM_FORMAT_INVALID;
> +	int i;
> +	u32 reg_ctrl;
> +
> +	for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
> +		if (arc_pgu_supported_formats[i] == pixel_format)
> +			format = arc_pgu_supported_formats[i];
> +	}
> +
> +	if (WARN_ON(format == DRM_FORMAT_INVALID))
> +		return;
> +
> +	reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> +	if (format == DRM_FORMAT_RGB565)
> +		reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
> +	else
> +		reg_ctrl |= ARCPGU_MODE_XRGB8888;
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
> +}
> +
> +static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
> +	.destroy = drm_crtc_cleanup,
> +	.set_config = drm_atomic_helper_set_config,
> +	.page_flip = drm_atomic_helper_page_flip,
> +	.reset = drm_atomic_helper_crtc_reset,
> +	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> +};
> +
> +static enum drm_mode_status arc_pgu_mode_valid(struct drm_simple_display_pipe *pipe,
> +					       const struct drm_display_mode *mode)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +	long rate, clk_rate = mode->clock * 1000;
> +	long diff = clk_rate / 200; /* +-0.5% allowed by HDMI spec */
> +
> +	rate = clk_round_rate(arcpgu->clk, clk_rate);
> +	if ((max(rate, clk_rate) - min(rate, clk_rate) < diff) && (rate > 0))
> +		return MODE_OK;
> +
> +	return MODE_NOCLOCK;
> +}
> +
> +static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
> +{
> +	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
> +	u32 val;
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> +		      ENCODE_PGU_XY(m->crtc_htotal, m->crtc_vtotal));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_HSYNC,
> +		      ENCODE_PGU_XY(m->crtc_hsync_start - m->crtc_hdisplay,
> +				    m->crtc_hsync_end - m->crtc_hdisplay));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_VSYNC,
> +		      ENCODE_PGU_XY(m->crtc_vsync_start - m->crtc_vdisplay,
> +				    m->crtc_vsync_end - m->crtc_vdisplay));
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_ACTIVE,
> +		      ENCODE_PGU_XY(m->crtc_hblank_end - m->crtc_hblank_start,
> +				    m->crtc_vblank_end - m->crtc_vblank_start));
> +
> +	val = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
> +
> +	if (m->flags & DRM_MODE_FLAG_PVSYNC)
> +		val |= ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST;
> +	else
> +		val &= ~(ARCPGU_CTRL_VS_POL_MASK << ARCPGU_CTRL_VS_POL_OFST);
> +
> +	if (m->flags & DRM_MODE_FLAG_PHSYNC)
> +		val |= ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST;
> +	else
> +		val &= ~(ARCPGU_CTRL_HS_POL_MASK << ARCPGU_CTRL_HS_POL_OFST);
> +
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, val);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
> +
> +	arc_pgu_set_pxl_fmt(arcpgu);
> +
> +	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
> +}
> +
> +static void arc_pgu_enable(struct drm_simple_display_pipe *pipe,
> +			   struct drm_crtc_state *crtc_state,
> +			   struct drm_plane_state *plane_state)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +
> +	arc_pgu_mode_set(arcpgu);
> +
> +	clk_prepare_enable(arcpgu->clk);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> +		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> +		      ARCPGU_CTRL_ENABLE_MASK);
> +}
> +
> +static void arc_pgu_disable(struct drm_simple_display_pipe *pipe)
> +{
> +	struct arcpgu_drm_private *arcpgu = pipe_to_arcpgu_priv(pipe);
> +
> +	clk_disable_unprepare(arcpgu->clk);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
> +			      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) &
> +			      ~ARCPGU_CTRL_ENABLE_MASK);
> +}
> +
> +static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> +			   struct drm_plane_state *state)
> +{
> +	struct arcpgu_drm_private *arcpgu;
> +	struct drm_gem_cma_object *gem;
> +
> +	arcpgu = pipe_to_arcpgu_priv(pipe);
> +	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> +	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> +}
> +
> +static const struct drm_simple_display_pipe_funcs arc_pgu_pipe_funcs = {
> +	.update = arc_pgu_update,
> +	.mode_valid = arc_pgu_mode_valid,
> +	.enable	= arc_pgu_enable,
> +	.disable = arc_pgu_disable,
> +};
> +
>  static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = {
>  	.fb_create  = drm_gem_fb_create,
>  	.atomic_check = drm_atomic_helper_check,
> @@ -70,8 +209,12 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	if (arc_pgu_setup_pipe(drm) < 0)
> -		return -ENODEV;
> +	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					   arc_pgu_supported_formats,
> +					   ARRAY_SIZE(arc_pgu_supported_formats),
> +					   NULL, NULL);
> +	if (ret)
> +		return ret;

Detail. In the old code ant error was converted to -ENODEV.
The new code let the error code bubble up - which is better.
But this is a small change that is not in the changelog.


>  
>  	/*
>  	 * There is only one output port inside each device. It is linked with
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> index afc34f8b4de0..1a63f0868504 100644
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ b/drivers/gpu/drm/arc/arcpgu_sim.c
> @@ -45,10 +45,6 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>  
> -static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
> -	.destroy = drm_encoder_cleanup,
> -};
> -
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  {
>  	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> @@ -58,14 +54,6 @@ int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
>  
>  	encoder = &arcpgu->pipe.encoder;
>  
> -	encoder->possible_crtcs = 1;
> -	encoder->possible_clones = 0;
> -
> -	ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
> -			       DRM_MODE_ENCODER_VIRTUAL, NULL);
> -	if (ret)
> -		return ret;
> -

This looks like code that belongs in one of the former patches.
Not that it matters much but anyway.

	Sam

>  	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:54     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:54 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:25AM +0200, Daniel Vetter wrote:
> Really not worth the function, much less the separate file now that
> almost all the code is gone.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/arc/Makefile      |  2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |  1 -
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 12 +++++++++---
>  drivers/gpu/drm/arc/arcpgu_hdmi.c | 27 ---------------------------
>  4 files changed, 10 insertions(+), 32 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index c686e0287a71..379a1145bc2f 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_sim.o arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index cee2448a07d6..7dce0c2313ba 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
>  #endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 2443e3c78a76..8fbfd956de0a 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -227,9 +227,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	}
>  
>  	if (encoder_node) {
> -		ret = arcpgu_drm_hdmi_init(drm, encoder_node);
> -		of_node_put(encoder_node);
This put is missing when arcpgu_drm_hdmi_init() was inlined.
At least in the (!bridge) case - I did not look at the surrounding code.

	Sam

> -		if (ret < 0)
> +		struct drm_bridge *bridge;
> +
> +		/* Locate drm bridge from the hdmi encoder DT node */
> +		bridge = of_drm_find_bridge(encoder_node);
> +		if (!bridge)
> +			return -EPROBE_DEFER;
> +
> +		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
> +		if (ret)
>  			return ret;
>  	} else {
>  		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> deleted file mode 100644
> index d430af686cbc..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_bridge.h>
> -#include <drm/drm_crtc.h>
> -#include <drm/drm_encoder.h>
> -#include <drm/drm_device.h>
> -
> -#include "arcpgu.h"
> -
> -int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_bridge *bridge;
> -
> -	/* Locate drm bridge from the hdmi encoder DT node */
> -	bridge = of_drm_find_bridge(np);
> -	if (!bridge)
> -		return -EPROBE_DEFER;
> -
> -	/* Link drm_bridge to encoder */
> -	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
> -}
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init
@ 2020-04-24 17:54     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:54 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:25AM +0200, Daniel Vetter wrote:
> Really not worth the function, much less the separate file now that
> almost all the code is gone.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/arc/Makefile      |  2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |  1 -
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 12 +++++++++---
>  drivers/gpu/drm/arc/arcpgu_hdmi.c | 27 ---------------------------
>  4 files changed, 10 insertions(+), 32 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_hdmi.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index c686e0287a71..379a1145bc2f 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_hdmi.o arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_sim.o arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> index cee2448a07d6..7dce0c2313ba 100644
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ b/drivers/gpu/drm/arc/arcpgu.h
> @@ -34,7 +34,6 @@ static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
>  	return ioread32(arcpgu->regs + reg);
>  }
>  
> -int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np);
>  int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
>  
>  #endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 2443e3c78a76..8fbfd956de0a 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -227,9 +227,15 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	}
>  
>  	if (encoder_node) {
> -		ret = arcpgu_drm_hdmi_init(drm, encoder_node);
> -		of_node_put(encoder_node);
This put is missing when arcpgu_drm_hdmi_init() was inlined.
At least in the (!bridge) case - I did not look at the surrounding code.

	Sam

> -		if (ret < 0)
> +		struct drm_bridge *bridge;
> +
> +		/* Locate drm bridge from the hdmi encoder DT node */
> +		bridge = of_drm_find_bridge(encoder_node);
> +		if (!bridge)
> +			return -EPROBE_DEFER;
> +
> +		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
> +		if (ret)
>  			return ret;
>  	} else {
>  		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c b/drivers/gpu/drm/arc/arcpgu_hdmi.c
> deleted file mode 100644
> index d430af686cbc..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_bridge.h>
> -#include <drm/drm_crtc.h>
> -#include <drm/drm_encoder.h>
> -#include <drm/drm_device.h>
> -
> -#include "arcpgu.h"
> -
> -int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_bridge *bridge;
> -
> -	/* Locate drm bridge from the hdmi encoder DT node */
> -	bridge = of_drm_find_bridge(np);
> -	if (!bridge)
> -		return -EPROBE_DEFER;
> -
> -	/* Link drm_bridge to encoder */
> -	return drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
> -}
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 51/59] drm/arc: Inline remaining files
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:56     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:56 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Apr 15, 2020 at 09:40:26AM +0200, Daniel Vetter wrote:
> At less than 500 lines total feels like the right thing to do.
> 
> Also noticed that the simple wrapper around drm_connector_cleanup can
> be dropped.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/Makefile      |   2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |  39 ------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 102 +++++++++++++++++++++++++++++-
>  drivers/gpu/drm/arc/arcpgu_regs.h |  31 ---------
>  drivers/gpu/drm/arc/arcpgu_sim.c  |  74 ----------------------
>  5 files changed, 101 insertions(+), 147 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index 379a1145bc2f..b26f2495c532 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> deleted file mode 100644
> index 7dce0c2313ba..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#ifndef _ARCPGU_H_
> -#define _ARCPGU_H_
> -
> -#include <drm/drm_simple_kms_helper.h>
> -
> -struct arcpgu_drm_private {
> -	struct drm_device	drm;
> -	void __iomem		*regs;
> -	struct clk		*clk;
> -	struct drm_simple_display_pipe pipe;
> -	struct drm_connector	sim_conn;
> -};
> -
> -#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> -
> -#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
> -
> -static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> -				 unsigned int reg, u32 value)
> -{
> -	iowrite32(value, arcpgu->regs + reg);
> -}
> -
> -static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
> -			       unsigned int reg)
> -{
> -	return ioread32(arcpgu->regs + reg);
> -}
> -
> -int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
> -
> -#endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 8fbfd956de0a..b0c941d91545 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -17,13 +17,111 @@
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_of.h>
>  #include <drm/drm_probe_helper.h>
> +#include <drm/drm_simple_kms_helper.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/module.h>
>  #include <linux/of_reserved_mem.h>
>  #include <linux/platform_device.h>
>  
> -#include "arcpgu.h"
> -#include "arcpgu_regs.h"
> +#define ARCPGU_REG_CTRL		0x00
> +#define ARCPGU_REG_STAT		0x04
> +#define ARCPGU_REG_FMT		0x10
> +#define ARCPGU_REG_HSYNC	0x14
> +#define ARCPGU_REG_VSYNC	0x18
> +#define ARCPGU_REG_ACTIVE	0x1c
> +#define ARCPGU_REG_BUF0_ADDR	0x40
> +#define ARCPGU_REG_STRIDE	0x50
> +#define ARCPGU_REG_START_SET	0x84
> +
> +#define ARCPGU_REG_ID		0x3FC
> +
> +#define ARCPGU_CTRL_ENABLE_MASK	0x02
> +#define ARCPGU_CTRL_VS_POL_MASK	0x1
> +#define ARCPGU_CTRL_VS_POL_OFST	0x3
> +#define ARCPGU_CTRL_HS_POL_MASK	0x1
> +#define ARCPGU_CTRL_HS_POL_OFST	0x4
> +#define ARCPGU_MODE_XRGB8888	BIT(2)
> +#define ARCPGU_STAT_BUSY_MASK	0x02
> +
> +struct arcpgu_drm_private {
> +	struct drm_device	drm;
> +	void __iomem		*regs;
> +	struct clk		*clk;
> +	struct drm_simple_display_pipe pipe;
> +	struct drm_connector	sim_conn;
> +};
> +
> +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> +
> +#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
> +
> +static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> +				 unsigned int reg, u32 value)
> +{
> +	iowrite32(value, arcpgu->regs + reg);
> +}
> +
> +static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
> +			       unsigned int reg)
> +{
> +	return ioread32(arcpgu->regs + reg);
> +}
> +
> +#define XRES_DEF	640
> +#define YRES_DEF	480
> +
> +#define XRES_MAX	8192
> +#define YRES_MAX	8192
> +
> +static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
> +{
> +	int count;
> +
> +	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
> +	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
> +	return count;
> +}
> +
> +static const struct drm_connector_helper_funcs
> +arcpgu_drm_connector_helper_funcs = {
> +	.get_modes = arcpgu_drm_connector_get_modes,
> +};
> +
> +static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
> +	.reset = drm_atomic_helper_connector_reset,
> +	.fill_modes = drm_helper_probe_single_connector_modes,
> +	.destroy = drm_connector_cleanup,
> +	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> +{
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> +	struct drm_encoder *encoder;
> +	struct drm_connector *connector;
> +	int ret;
> +
> +	encoder = &arcpgu->pipe.encoder;
> +
> +	connector = &arcpgu->sim_conn;
> +	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> +
> +	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> +			DRM_MODE_CONNECTOR_VIRTUAL);
> +	if (ret < 0) {
> +		dev_err(drm->dev, "failed to initialize drm connector\n");
> +		return ret;
> +	}
> +
> +	ret = drm_connector_attach_encoder(connector, encoder);
> +	if (ret < 0) {
> +		dev_err(drm->dev, "could not attach connector to encoder\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
>  
>  #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_regs.h b/drivers/gpu/drm/arc/arcpgu_regs.h
> deleted file mode 100644
> index b689a382d556..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_regs.h
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#ifndef _ARC_PGU_REGS_H_
> -#define _ARC_PGU_REGS_H_
> -
> -#define ARCPGU_REG_CTRL		0x00
> -#define ARCPGU_REG_STAT		0x04
> -#define ARCPGU_REG_FMT		0x10
> -#define ARCPGU_REG_HSYNC	0x14
> -#define ARCPGU_REG_VSYNC	0x18
> -#define ARCPGU_REG_ACTIVE	0x1c
> -#define ARCPGU_REG_BUF0_ADDR	0x40
> -#define ARCPGU_REG_STRIDE	0x50
> -#define ARCPGU_REG_START_SET	0x84
> -
> -#define ARCPGU_REG_ID		0x3FC
> -
> -#define ARCPGU_CTRL_ENABLE_MASK	0x02
> -#define ARCPGU_CTRL_VS_POL_MASK	0x1
> -#define ARCPGU_CTRL_VS_POL_OFST	0x3
> -#define ARCPGU_CTRL_HS_POL_MASK	0x1
> -#define ARCPGU_CTRL_HS_POL_OFST	0x4
> -#define ARCPGU_MODE_XRGB8888	BIT(2)
> -#define ARCPGU_STAT_BUSY_MASK	0x02
> -
> -#endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> deleted file mode 100644
> index 1a63f0868504..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ /dev/null
> @@ -1,74 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_atomic_helper.h>
> -#include <drm/drm_device.h>
> -#include <drm/drm_probe_helper.h>
> -
> -#include "arcpgu.h"
> -
> -#define XRES_DEF	640
> -#define YRES_DEF	480
> -
> -#define XRES_MAX	8192
> -#define YRES_MAX	8192
> -
> -
> -static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
> -{
> -	int count;
> -
> -	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
> -	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
> -	return count;
> -}
> -
> -static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
> -{
> -	drm_connector_cleanup(connector);
> -}
> -
> -static const struct drm_connector_helper_funcs
> -arcpgu_drm_connector_helper_funcs = {
> -	.get_modes = arcpgu_drm_connector_get_modes,
> -};
> -
> -static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
> -	.reset = drm_atomic_helper_connector_reset,
> -	.fill_modes = drm_helper_probe_single_connector_modes,
> -	.destroy = arcpgu_drm_connector_destroy,
> -	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> -};
> -
> -int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
> -	int ret;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
> -	connector = &arcpgu->sim_conn;
> -	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> -
> -	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> -			DRM_MODE_CONNECTOR_VIRTUAL);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		return ret;
> -	}
> -
> -	ret = drm_connector_attach_encoder(connector, encoder);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		return ret;
> -	}
> -
> -	return 0;
> -}
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 51/59] drm/arc: Inline remaining files
@ 2020-04-24 17:56     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:56 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, DRI Development

On Wed, Apr 15, 2020 at 09:40:26AM +0200, Daniel Vetter wrote:
> At less than 500 lines total feels like the right thing to do.
> 
> Also noticed that the simple wrapper around drm_connector_cleanup can
> be dropped.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/arc/Makefile      |   2 +-
>  drivers/gpu/drm/arc/arcpgu.h      |  39 ------------
>  drivers/gpu/drm/arc/arcpgu_drv.c  | 102 +++++++++++++++++++++++++++++-
>  drivers/gpu/drm/arc/arcpgu_regs.h |  31 ---------
>  drivers/gpu/drm/arc/arcpgu_sim.c  |  74 ----------------------
>  5 files changed, 101 insertions(+), 147 deletions(-)
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu.h
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_regs.h
>  delete mode 100644 drivers/gpu/drm/arc/arcpgu_sim.c
> 
> diff --git a/drivers/gpu/drm/arc/Makefile b/drivers/gpu/drm/arc/Makefile
> index 379a1145bc2f..b26f2495c532 100644
> --- a/drivers/gpu/drm/arc/Makefile
> +++ b/drivers/gpu/drm/arc/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> -arcpgu-y := arcpgu_sim.o arcpgu_drv.o
> +arcpgu-y := arcpgu_drv.o
>  obj-$(CONFIG_DRM_ARCPGU) += arcpgu.o
> diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> deleted file mode 100644
> index 7dce0c2313ba..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu.h
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#ifndef _ARCPGU_H_
> -#define _ARCPGU_H_
> -
> -#include <drm/drm_simple_kms_helper.h>
> -
> -struct arcpgu_drm_private {
> -	struct drm_device	drm;
> -	void __iomem		*regs;
> -	struct clk		*clk;
> -	struct drm_simple_display_pipe pipe;
> -	struct drm_connector	sim_conn;
> -};
> -
> -#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> -
> -#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
> -
> -static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> -				 unsigned int reg, u32 value)
> -{
> -	iowrite32(value, arcpgu->regs + reg);
> -}
> -
> -static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
> -			       unsigned int reg)
> -{
> -	return ioread32(arcpgu->regs + reg);
> -}
> -
> -int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np);
> -
> -#endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index 8fbfd956de0a..b0c941d91545 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -17,13 +17,111 @@
>  #include <drm/drm_gem_framebuffer_helper.h>
>  #include <drm/drm_of.h>
>  #include <drm/drm_probe_helper.h>
> +#include <drm/drm_simple_kms_helper.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/module.h>
>  #include <linux/of_reserved_mem.h>
>  #include <linux/platform_device.h>
>  
> -#include "arcpgu.h"
> -#include "arcpgu_regs.h"
> +#define ARCPGU_REG_CTRL		0x00
> +#define ARCPGU_REG_STAT		0x04
> +#define ARCPGU_REG_FMT		0x10
> +#define ARCPGU_REG_HSYNC	0x14
> +#define ARCPGU_REG_VSYNC	0x18
> +#define ARCPGU_REG_ACTIVE	0x1c
> +#define ARCPGU_REG_BUF0_ADDR	0x40
> +#define ARCPGU_REG_STRIDE	0x50
> +#define ARCPGU_REG_START_SET	0x84
> +
> +#define ARCPGU_REG_ID		0x3FC
> +
> +#define ARCPGU_CTRL_ENABLE_MASK	0x02
> +#define ARCPGU_CTRL_VS_POL_MASK	0x1
> +#define ARCPGU_CTRL_VS_POL_OFST	0x3
> +#define ARCPGU_CTRL_HS_POL_MASK	0x1
> +#define ARCPGU_CTRL_HS_POL_OFST	0x4
> +#define ARCPGU_MODE_XRGB8888	BIT(2)
> +#define ARCPGU_STAT_BUSY_MASK	0x02
> +
> +struct arcpgu_drm_private {
> +	struct drm_device	drm;
> +	void __iomem		*regs;
> +	struct clk		*clk;
> +	struct drm_simple_display_pipe pipe;
> +	struct drm_connector	sim_conn;
> +};
> +
> +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> +
> +#define pipe_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, pipe)
> +
> +static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> +				 unsigned int reg, u32 value)
> +{
> +	iowrite32(value, arcpgu->regs + reg);
> +}
> +
> +static inline u32 arc_pgu_read(struct arcpgu_drm_private *arcpgu,
> +			       unsigned int reg)
> +{
> +	return ioread32(arcpgu->regs + reg);
> +}
> +
> +#define XRES_DEF	640
> +#define YRES_DEF	480
> +
> +#define XRES_MAX	8192
> +#define YRES_MAX	8192
> +
> +static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
> +{
> +	int count;
> +
> +	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
> +	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
> +	return count;
> +}
> +
> +static const struct drm_connector_helper_funcs
> +arcpgu_drm_connector_helper_funcs = {
> +	.get_modes = arcpgu_drm_connector_get_modes,
> +};
> +
> +static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
> +	.reset = drm_atomic_helper_connector_reset,
> +	.fill_modes = drm_helper_probe_single_connector_modes,
> +	.destroy = drm_connector_cleanup,
> +	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> +{
> +	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> +	struct drm_encoder *encoder;
> +	struct drm_connector *connector;
> +	int ret;
> +
> +	encoder = &arcpgu->pipe.encoder;
> +
> +	connector = &arcpgu->sim_conn;
> +	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> +
> +	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> +			DRM_MODE_CONNECTOR_VIRTUAL);
> +	if (ret < 0) {
> +		dev_err(drm->dev, "failed to initialize drm connector\n");
> +		return ret;
> +	}
> +
> +	ret = drm_connector_attach_encoder(connector, encoder);
> +	if (ret < 0) {
> +		dev_err(drm->dev, "could not attach connector to encoder\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
>  
>  #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
>  
> diff --git a/drivers/gpu/drm/arc/arcpgu_regs.h b/drivers/gpu/drm/arc/arcpgu_regs.h
> deleted file mode 100644
> index b689a382d556..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_regs.h
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#ifndef _ARC_PGU_REGS_H_
> -#define _ARC_PGU_REGS_H_
> -
> -#define ARCPGU_REG_CTRL		0x00
> -#define ARCPGU_REG_STAT		0x04
> -#define ARCPGU_REG_FMT		0x10
> -#define ARCPGU_REG_HSYNC	0x14
> -#define ARCPGU_REG_VSYNC	0x18
> -#define ARCPGU_REG_ACTIVE	0x1c
> -#define ARCPGU_REG_BUF0_ADDR	0x40
> -#define ARCPGU_REG_STRIDE	0x50
> -#define ARCPGU_REG_START_SET	0x84
> -
> -#define ARCPGU_REG_ID		0x3FC
> -
> -#define ARCPGU_CTRL_ENABLE_MASK	0x02
> -#define ARCPGU_CTRL_VS_POL_MASK	0x1
> -#define ARCPGU_CTRL_VS_POL_OFST	0x3
> -#define ARCPGU_CTRL_HS_POL_MASK	0x1
> -#define ARCPGU_CTRL_HS_POL_OFST	0x4
> -#define ARCPGU_MODE_XRGB8888	BIT(2)
> -#define ARCPGU_STAT_BUSY_MASK	0x02
> -
> -#endif
> diff --git a/drivers/gpu/drm/arc/arcpgu_sim.c b/drivers/gpu/drm/arc/arcpgu_sim.c
> deleted file mode 100644
> index 1a63f0868504..000000000000
> --- a/drivers/gpu/drm/arc/arcpgu_sim.c
> +++ /dev/null
> @@ -1,74 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * ARC PGU DRM driver.
> - *
> - * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
> - */
> -
> -#include <drm/drm_atomic_helper.h>
> -#include <drm/drm_device.h>
> -#include <drm/drm_probe_helper.h>
> -
> -#include "arcpgu.h"
> -
> -#define XRES_DEF	640
> -#define YRES_DEF	480
> -
> -#define XRES_MAX	8192
> -#define YRES_MAX	8192
> -
> -
> -static int arcpgu_drm_connector_get_modes(struct drm_connector *connector)
> -{
> -	int count;
> -
> -	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
> -	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
> -	return count;
> -}
> -
> -static void arcpgu_drm_connector_destroy(struct drm_connector *connector)
> -{
> -	drm_connector_cleanup(connector);
> -}
> -
> -static const struct drm_connector_helper_funcs
> -arcpgu_drm_connector_helper_funcs = {
> -	.get_modes = arcpgu_drm_connector_get_modes,
> -};
> -
> -static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
> -	.reset = drm_atomic_helper_connector_reset,
> -	.fill_modes = drm_helper_probe_single_connector_modes,
> -	.destroy = arcpgu_drm_connector_destroy,
> -	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> -};
> -
> -int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> -{
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
> -	int ret;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
> -	connector = &arcpgu->sim_conn;
> -	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> -
> -	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> -			DRM_MODE_CONNECTOR_VIRTUAL);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		return ret;
> -	}
> -
> -	ret = drm_connector_attach_encoder(connector, encoder);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		return ret;
> -	}
> -
> -	return 0;
> -}
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 52/59] drm/arc: Initialize sim connector before display pipe
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 17:58     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:58 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:27AM +0200, Daniel Vetter wrote:
> That way we can get rid of this final piece of init code, and use the
> simple pipe helpers as intended.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

One nit below, with this addressed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++----------------------
>  1 file changed, 16 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index b0c941d91545..857812f25bec 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>  
> -static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> +static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector)
>  {
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
> -	int ret;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
> -	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> -
> -	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> +	return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
>  			DRM_MODE_CONNECTOR_VIRTUAL);

Please fix indent.

> -	if (ret < 0) {
> -		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		return ret;
> -	}
> -
> -	ret = drm_connector_attach_encoder(connector, encoder);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		return ret;
> -	}
> -
> -	return 0;
>  }
>  
>  #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> @@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  {
>  	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
>  	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
> +	struct drm_connector *connector = NULL;
>  	struct drm_device *drm = &arcpgu->drm;
>  	struct resource *res;
>  	int ret;
> @@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> -					   arc_pgu_supported_formats,
> -					   ARRAY_SIZE(arc_pgu_supported_formats),
> -					   NULL, NULL);
> -	if (ret)
> -		return ret;
> -
>  	/*
>  	 * There is only one output port inside each device. It is linked with
>  	 * encoder endpoint.
> @@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (endpoint_node) {
>  		encoder_node = of_graph_get_remote_port_parent(endpoint_node);
>  		of_node_put(endpoint_node);
> +	} else {
> +		connector = &arcpgu->sim_conn;
> +		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> +		ret = arcpgu_drm_sim_init(drm, connector);
> +		if (ret < 0)
> +			return ret;
>  	}
>  
> +	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					   arc_pgu_supported_formats,
> +					   ARRAY_SIZE(arc_pgu_supported_formats),
> +					   NULL, connector);
> +	if (ret)
> +		return ret;
> +
>  	if (encoder_node) {
>  		struct drm_bridge *bridge;
>  
> @@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
>  		if (ret)
>  			return ret;
> -	} else {
> -		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> -		ret = arcpgu_drm_sim_init(drm, NULL);
> -		if (ret < 0)
> -			return ret;
>  	}
>  
>  	drm_mode_config_reset(drm);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 52/59] drm/arc: Initialize sim connector before display pipe
@ 2020-04-24 17:58     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 17:58 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Wed, Apr 15, 2020 at 09:40:27AM +0200, Daniel Vetter wrote:
> That way we can get rid of this final piece of init code, and use the
> simple pipe helpers as intended.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>

One nit below, with this addressed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/arc/arcpgu_drv.c | 51 ++++++++++----------------------
>  1 file changed, 16 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> index b0c941d91545..857812f25bec 100644
> --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> @@ -95,32 +95,11 @@ static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>  
> -static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np)
> +static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector)
>  {
> -	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> -	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
> -	int ret;
> -
> -	encoder = &arcpgu->pipe.encoder;
> -
> -	connector = &arcpgu->sim_conn;
>  	drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs);
> -
> -	ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
> +	return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs,
>  			DRM_MODE_CONNECTOR_VIRTUAL);

Please fix indent.

> -	if (ret < 0) {
> -		dev_err(drm->dev, "failed to initialize drm connector\n");
> -		return ret;
> -	}
> -
> -	ret = drm_connector_attach_encoder(connector, encoder);
> -	if (ret < 0) {
> -		dev_err(drm->dev, "could not attach connector to encoder\n");
> -		return ret;
> -	}
> -
> -	return 0;
>  }
>  
>  #define ENCODE_PGU_XY(x, y)	((((x) - 1) << 16) | ((y) - 1))
> @@ -273,6 +252,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  {
>  	struct platform_device *pdev = to_platform_device(arcpgu->drm.dev);
>  	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
> +	struct drm_connector *connector = NULL;
>  	struct drm_device *drm = &arcpgu->drm;
>  	struct resource *res;
>  	int ret;
> @@ -307,13 +287,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)))
>  		return -ENODEV;
>  
> -	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> -					   arc_pgu_supported_formats,
> -					   ARRAY_SIZE(arc_pgu_supported_formats),
> -					   NULL, NULL);
> -	if (ret)
> -		return ret;
> -
>  	/*
>  	 * There is only one output port inside each device. It is linked with
>  	 * encoder endpoint.
> @@ -322,8 +295,21 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  	if (endpoint_node) {
>  		encoder_node = of_graph_get_remote_port_parent(endpoint_node);
>  		of_node_put(endpoint_node);
> +	} else {
> +		connector = &arcpgu->sim_conn;
> +		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> +		ret = arcpgu_drm_sim_init(drm, connector);
> +		if (ret < 0)
> +			return ret;
>  	}
>  
> +	ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs,
> +					   arc_pgu_supported_formats,
> +					   ARRAY_SIZE(arc_pgu_supported_formats),
> +					   NULL, connector);
> +	if (ret)
> +		return ret;
> +
>  	if (encoder_node) {
>  		struct drm_bridge *bridge;
>  
> @@ -335,11 +321,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
>  		ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge);
>  		if (ret)
>  			return ret;
> -	} else {
> -		dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n");
> -		ret = arcpgu_drm_sim_init(drm, NULL);
> -		if (ret < 0)
> -			return ret;
>  	}
>  
>  	drm_mode_config_reset(drm);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 18:00     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:29AM +0200, Daniel Vetter wrote:
> No longer used since the conversion to generic fbdev.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index a10358bb61ec..adc02940de6f 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -12,7 +12,6 @@ struct aspeed_gfx {
>  
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
> -	struct drm_fbdev_cma		*fbdev;
>  };
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
@ 2020-04-24 18:00     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:29AM +0200, Daniel Vetter wrote:
> No longer used since the conversion to generic fbdev.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index a10358bb61ec..adc02940de6f 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -12,7 +12,6 @@ struct aspeed_gfx {
>  
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
> -	struct drm_fbdev_cma		*fbdev;
>  };
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev
@ 2020-04-24 18:00     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:29AM +0200, Daniel Vetter wrote:
> No longer used since the conversion to generic fbdev.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index a10358bb61ec..adc02940de6f 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -12,7 +12,6 @@ struct aspeed_gfx {
>  
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
> -	struct drm_fbdev_cma		*fbdev;
>  };
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 18:02     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:02 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:30AM +0200, Daniel Vetter wrote:
> As usual, we can drop the drm_dev_put() and need to embed the
> drm_device. Since it's so few, also go right ahead and leave
> drm_device->dev_private set to NULL, so that we always use the
> container_of() upcast, which is faster anyway.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
>  drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
>  drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
>  4 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index adc02940de6f..e7ca95827ae8 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -5,6 +5,7 @@
>  #include <drm/drm_simple_kms_helper.h>
>  
>  struct aspeed_gfx {
> +	struct drm_device		drm;
>  	void __iomem			*base;
>  	struct clk			*clk;
>  	struct reset_control		*rst;
> @@ -13,6 +14,7 @@ struct aspeed_gfx {
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
>  };
> +#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
>  int aspeed_gfx_create_output(struct drm_device *drm);
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> index 2184b8be6fd4..e54686c31a90 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> @@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  
>  	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
>  					    aspeed_gfx_formats,
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index ada2f6aca906..6b27242b9ee3 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  {
>  	struct drm_device *drm = data;
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	u32 reg;
>  
>  	reg = readl(priv->base + CRT_CTRL1);
> @@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  static int aspeed_gfx_load(struct drm_device *drm)
>  {
>  	struct platform_device *pdev = to_platform_device(drm->dev);
> -	struct aspeed_gfx *priv;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	struct resource *res;
>  	int ret;
>  
> -	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -	drm->dev_private = priv;
> -
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	priv->base = devm_ioremap_resource(drm->dev, res);
>  	if (IS_ERR(priv->base))
> @@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
>  	drm_mode_config_cleanup(drm);
> -
> -	drm->dev_private = NULL;
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> @@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
>  
>  static int aspeed_gfx_probe(struct platform_device *pdev)
>  {
> -	struct drm_device *drm;
> +	struct aspeed_gfx *priv;
>  	int ret;
>  
> -	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
> -	if (IS_ERR(drm))
> -		return PTR_ERR(drm);
> +	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
> +				  struct aspeed_gfx, drm);
> +	if (IS_ERR(priv))
> +		return PTR_ERR(priv);
>  
> -	ret = aspeed_gfx_load(drm);
> +	ret = aspeed_gfx_load(&priv->drm);
>  	if (ret)
> -		goto err_free;
> +		return ret;
>  
> -	ret = drm_dev_register(drm, 0);
> +	ret = drm_dev_register(&priv->drm, 0);
>  	if (ret)
>  		goto err_unload;
>  
>  	return 0;
>  
>  err_unload:
> -	aspeed_gfx_unload(drm);
> -err_free:
> -	drm_dev_put(drm);
> +	aspeed_gfx_unload(&priv->drm);
>  
>  	return ret;
>  }
> @@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
>  
>  	drm_dev_unregister(drm);
>  	aspeed_gfx_unload(drm);
> -	drm_dev_put(drm);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> index 67ee5fa10055..6759cb88415a 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> @@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
>  
>  int aspeed_gfx_create_output(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	int ret;
>  
>  	priv->connector.dpms = DRM_MODE_DPMS_OFF;
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
@ 2020-04-24 18:02     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:02 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:30AM +0200, Daniel Vetter wrote:
> As usual, we can drop the drm_dev_put() and need to embed the
> drm_device. Since it's so few, also go right ahead and leave
> drm_device->dev_private set to NULL, so that we always use the
> container_of() upcast, which is faster anyway.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
>  drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
>  drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
>  4 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index adc02940de6f..e7ca95827ae8 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -5,6 +5,7 @@
>  #include <drm/drm_simple_kms_helper.h>
>  
>  struct aspeed_gfx {
> +	struct drm_device		drm;
>  	void __iomem			*base;
>  	struct clk			*clk;
>  	struct reset_control		*rst;
> @@ -13,6 +14,7 @@ struct aspeed_gfx {
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
>  };
> +#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
>  int aspeed_gfx_create_output(struct drm_device *drm);
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> index 2184b8be6fd4..e54686c31a90 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> @@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  
>  	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
>  					    aspeed_gfx_formats,
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index ada2f6aca906..6b27242b9ee3 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  {
>  	struct drm_device *drm = data;
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	u32 reg;
>  
>  	reg = readl(priv->base + CRT_CTRL1);
> @@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  static int aspeed_gfx_load(struct drm_device *drm)
>  {
>  	struct platform_device *pdev = to_platform_device(drm->dev);
> -	struct aspeed_gfx *priv;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	struct resource *res;
>  	int ret;
>  
> -	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -	drm->dev_private = priv;
> -
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	priv->base = devm_ioremap_resource(drm->dev, res);
>  	if (IS_ERR(priv->base))
> @@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
>  	drm_mode_config_cleanup(drm);
> -
> -	drm->dev_private = NULL;
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> @@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
>  
>  static int aspeed_gfx_probe(struct platform_device *pdev)
>  {
> -	struct drm_device *drm;
> +	struct aspeed_gfx *priv;
>  	int ret;
>  
> -	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
> -	if (IS_ERR(drm))
> -		return PTR_ERR(drm);
> +	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
> +				  struct aspeed_gfx, drm);
> +	if (IS_ERR(priv))
> +		return PTR_ERR(priv);
>  
> -	ret = aspeed_gfx_load(drm);
> +	ret = aspeed_gfx_load(&priv->drm);
>  	if (ret)
> -		goto err_free;
> +		return ret;
>  
> -	ret = drm_dev_register(drm, 0);
> +	ret = drm_dev_register(&priv->drm, 0);
>  	if (ret)
>  		goto err_unload;
>  
>  	return 0;
>  
>  err_unload:
> -	aspeed_gfx_unload(drm);
> -err_free:
> -	drm_dev_put(drm);
> +	aspeed_gfx_unload(&priv->drm);
>  
>  	return ret;
>  }
> @@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
>  
>  	drm_dev_unregister(drm);
>  	aspeed_gfx_unload(drm);
> -	drm_dev_put(drm);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> index 67ee5fa10055..6759cb88415a 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> @@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
>  
>  int aspeed_gfx_create_output(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	int ret;
>  
>  	priv->connector.dpms = DRM_MODE_DPMS_OFF;
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc
@ 2020-04-24 18:02     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:02 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:30AM +0200, Daniel Vetter wrote:
> As usual, we can drop the drm_dev_put() and need to embed the
> drm_device. Since it's so few, also go right ahead and leave
> drm_device->dev_private set to NULL, so that we always use the
> container_of() upcast, which is faster anyway.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx.h      |  2 ++
>  drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c |  2 +-
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 31 +++++++++---------------
>  drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  2 +-
>  4 files changed, 15 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> index adc02940de6f..e7ca95827ae8 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h
> @@ -5,6 +5,7 @@
>  #include <drm/drm_simple_kms_helper.h>
>  
>  struct aspeed_gfx {
> +	struct drm_device		drm;
>  	void __iomem			*base;
>  	struct clk			*clk;
>  	struct reset_control		*rst;
> @@ -13,6 +14,7 @@ struct aspeed_gfx {
>  	struct drm_simple_display_pipe	pipe;
>  	struct drm_connector		connector;
>  };
> +#define to_aspeed_gfx(x) container_of(x, struct aspeed_gfx, drm)
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm);
>  int aspeed_gfx_create_output(struct drm_device *drm);
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> index 2184b8be6fd4..e54686c31a90 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
> @@ -231,7 +231,7 @@ static const uint32_t aspeed_gfx_formats[] = {
>  
>  int aspeed_gfx_create_pipe(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  
>  	return drm_simple_display_pipe_init(drm, &priv->pipe, &aspeed_gfx_funcs,
>  					    aspeed_gfx_formats,
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index ada2f6aca906..6b27242b9ee3 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -77,7 +77,7 @@ static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  {
>  	struct drm_device *drm = data;
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	u32 reg;
>  
>  	reg = readl(priv->base + CRT_CTRL1);
> @@ -96,15 +96,10 @@ static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
>  static int aspeed_gfx_load(struct drm_device *drm)
>  {
>  	struct platform_device *pdev = to_platform_device(drm->dev);
> -	struct aspeed_gfx *priv;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	struct resource *res;
>  	int ret;
>  
> -	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -	drm->dev_private = priv;
> -
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	priv->base = devm_ioremap_resource(drm->dev, res);
>  	if (IS_ERR(priv->base))
> @@ -187,8 +182,6 @@ static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
>  	drm_mode_config_cleanup(drm);
> -
> -	drm->dev_private = NULL;
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> @@ -216,27 +209,26 @@ static const struct of_device_id aspeed_gfx_match[] = {
>  
>  static int aspeed_gfx_probe(struct platform_device *pdev)
>  {
> -	struct drm_device *drm;
> +	struct aspeed_gfx *priv;
>  	int ret;
>  
> -	drm = drm_dev_alloc(&aspeed_gfx_driver, &pdev->dev);
> -	if (IS_ERR(drm))
> -		return PTR_ERR(drm);
> +	priv = devm_drm_dev_alloc(&pdev->dev, &aspeed_gfx_driver,
> +				  struct aspeed_gfx, drm);
> +	if (IS_ERR(priv))
> +		return PTR_ERR(priv);
>  
> -	ret = aspeed_gfx_load(drm);
> +	ret = aspeed_gfx_load(&priv->drm);
>  	if (ret)
> -		goto err_free;
> +		return ret;
>  
> -	ret = drm_dev_register(drm, 0);
> +	ret = drm_dev_register(&priv->drm, 0);
>  	if (ret)
>  		goto err_unload;
>  
>  	return 0;
>  
>  err_unload:
> -	aspeed_gfx_unload(drm);
> -err_free:
> -	drm_dev_put(drm);
> +	aspeed_gfx_unload(&priv->drm);
>  
>  	return ret;
>  }
> @@ -247,7 +239,6 @@ static int aspeed_gfx_remove(struct platform_device *pdev)
>  
>  	drm_dev_unregister(drm);
>  	aspeed_gfx_unload(drm);
> -	drm_dev_put(drm);
>  
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> index 67ee5fa10055..6759cb88415a 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_out.c
> @@ -28,7 +28,7 @@ static const struct drm_connector_funcs aspeed_gfx_connector_funcs = {
>  
>  int aspeed_gfx_create_output(struct drm_device *drm)
>  {
> -	struct aspeed_gfx *priv = drm->dev_private;
> +	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
>  	int ret;
>  
>  	priv->connector.dpms = DRM_MODE_DPMS_OFF;
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 18:10     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:10 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> mode config cleanup.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org

Hmm, the helper function makes no sense, maybe embed it?

One Q below. Whith Q addressed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index 6b27242b9ee3..6e464b84a256 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
>  	.atomic_commit		= drm_atomic_helper_commit,
>  };
>  
> -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  {
> -	drm_mode_config_init(drm);
> -
>  	drm->mode_config.min_width = 0;
>  	drm->mode_config.min_height = 0;
>  	drm->mode_config.max_width = 800;
>  	drm->mode_config.max_height = 600;
>  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> +
> +	return drmm_mode_config_init(drm);

I do not see anything that documents that it is OK to init min/max
width/heigh not funcs before drmm_mode_config_init() is called.
Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
and we loose all the assingments from before the call to init().

Also most (all?) other users of drmm_mode_config_init()
set them after the call to drmm_mode_config_init().
So re-order here and then embed while you are touching the code again.

	Sam

>  }
>  
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  	writel(0, priv->base + CRT_CTRL1);
>  	writel(0, priv->base + CRT_CTRL2);
>  
> -	aspeed_gfx_setup_mode_config(drm);
> +	ret = aspeed_gfx_setup_mode_config(drm);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = drm_vblank_init(drm, 1);
>  	if (ret < 0) {
> @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
> -	drm_mode_config_cleanup(drm);
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-24 18:10     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:10 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> mode config cleanup.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org

Hmm, the helper function makes no sense, maybe embed it?

One Q below. Whith Q addressed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index 6b27242b9ee3..6e464b84a256 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
>  	.atomic_commit		= drm_atomic_helper_commit,
>  };
>  
> -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  {
> -	drm_mode_config_init(drm);
> -
>  	drm->mode_config.min_width = 0;
>  	drm->mode_config.min_height = 0;
>  	drm->mode_config.max_width = 800;
>  	drm->mode_config.max_height = 600;
>  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> +
> +	return drmm_mode_config_init(drm);

I do not see anything that documents that it is OK to init min/max
width/heigh not funcs before drmm_mode_config_init() is called.
Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
and we loose all the assingments from before the call to init().

Also most (all?) other users of drmm_mode_config_init()
set them after the call to drmm_mode_config_init().
So re-order here and then embed while you are touching the code again.

	Sam

>  }
>  
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  	writel(0, priv->base + CRT_CTRL1);
>  	writel(0, priv->base + CRT_CTRL2);
>  
> -	aspeed_gfx_setup_mode_config(drm);
> +	ret = aspeed_gfx_setup_mode_config(drm);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = drm_vblank_init(drm, 1);
>  	if (ret < 0) {
> @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
> -	drm_mode_config_cleanup(drm);
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-24 18:10     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:10 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Intel Graphics Development,
	DRI Development, Joel Stanley, Daniel Vetter, linux-arm-kernel

On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> mode config cleanup.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-arm-kernel@lists.infradead.org

Hmm, the helper function makes no sense, maybe embed it?

One Q below. Whith Q addressed:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index 6b27242b9ee3..6e464b84a256 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
>  	.atomic_commit		= drm_atomic_helper_commit,
>  };
>  
> -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
>  {
> -	drm_mode_config_init(drm);
> -
>  	drm->mode_config.min_width = 0;
>  	drm->mode_config.min_height = 0;
>  	drm->mode_config.max_width = 800;
>  	drm->mode_config.max_height = 600;
>  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> +
> +	return drmm_mode_config_init(drm);

I do not see anything that documents that it is OK to init min/max
width/heigh not funcs before drmm_mode_config_init() is called.
Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
and we loose all the assingments from before the call to init().

Also most (all?) other users of drmm_mode_config_init()
set them after the call to drmm_mode_config_init().
So re-order here and then embed while you are touching the code again.

	Sam

>  }
>  
>  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  	writel(0, priv->base + CRT_CTRL1);
>  	writel(0, priv->base + CRT_CTRL2);
>  
> -	aspeed_gfx_setup_mode_config(drm);
> +	ret = aspeed_gfx_setup_mode_config(drm);
> +	if (ret < 0)
> +		return ret;
>  
>  	ret = drm_vblank_init(drm, 1);
>  	if (ret < 0) {
> @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
>  static void aspeed_gfx_unload(struct drm_device *drm)
>  {
>  	drm_kms_helper_poll_fini(drm);
> -	drm_mode_config_cleanup(drm);
>  }
>  
>  DEFINE_DRM_GEM_CMA_FOPS(fops);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-24 18:11     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:11 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Thomas Zimmermann, Daniel Vetter, Dave Airlie, Emil Velikov

On Wed, Apr 15, 2020 at 09:40:33AM +0200, Daniel Vetter wrote:
> This is only needed for hotpluggable connectors set up after
> drm_dev_register().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/ast/ast_mode.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index cdd6c46d6557..84b1d1fea41f 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
>  {
>  	struct ast_connector *ast_connector = to_ast_connector(connector);
>  	ast_i2c_destroy(ast_connector->i2c);
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  	kfree(connector);
>  }
> @@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
>  	connector->interlace_allowed = 0;
>  	connector->doublescan_allowed = 0;
>  
> -	drm_connector_register(connector);
> -
>  	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
>  
>  	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 58/59] drm/ast: Drop explicit connector register/unregister
@ 2020-04-24 18:11     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:11 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, DRI Development, Gerd Hoffmann,
	Thomas Zimmermann, Daniel Vetter, Dave Airlie, Emil Velikov

On Wed, Apr 15, 2020 at 09:40:33AM +0200, Daniel Vetter wrote:
> This is only needed for hotpluggable connectors set up after
> drm_dev_register().
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/ast/ast_mode.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index cdd6c46d6557..84b1d1fea41f 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1069,7 +1069,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
>  {
>  	struct ast_connector *ast_connector = to_ast_connector(connector);
>  	ast_i2c_destroy(ast_connector->i2c);
> -	drm_connector_unregister(connector);
>  	drm_connector_cleanup(connector);
>  	kfree(connector);
>  }
> @@ -1112,8 +1111,6 @@ static int ast_connector_init(struct drm_device *dev)
>  	connector->interlace_allowed = 0;
>  	connector->doublescan_allowed = 0;
>  
> -	drm_connector_register(connector);
> -
>  	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
>  
>  	encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
  2020-04-15  7:40   ` Daniel Vetter
  (?)
@ 2020-04-24 18:11     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:11 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Gerd Hoffmann,
	DRI Development, virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/bochs/bochs_kms.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 7f4bcfad87e9..05d8373888e8 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
>  			   DRM_MODE_CONNECTOR_VIRTUAL);
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
> -	drm_connector_register(connector);
>  
>  	bochs_hw_load_edid(bochs);
>  	if (bochs->edid) {
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-24 18:11     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:11 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Gerd Hoffmann,
	DRI Development, virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/bochs/bochs_kms.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 7f4bcfad87e9..05d8373888e8 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
>  			   DRM_MODE_CONNECTOR_VIRTUAL);
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
> -	drm_connector_register(connector);
>  
>  	bochs_hw_load_edid(bochs);
>  	if (bochs->edid) {
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register
@ 2020-04-24 18:11     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-24 18:11 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Gerd Hoffmann,
	DRI Development, virtualization

On Wed, Apr 15, 2020 at 09:40:34AM +0200, Daniel Vetter wrote:
> This is leftovers from the old drm_driver->load callback
> upside-down issues. It doesn't do anything for not-hotplugged
> connectors since drm_dev_register takes care of that.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/bochs/bochs_kms.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 7f4bcfad87e9..05d8373888e8 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -104,7 +104,6 @@ static void bochs_connector_init(struct drm_device *dev)
>  			   DRM_MODE_CONNECTOR_VIRTUAL);
>  	drm_connector_helper_add(connector,
>  				 &bochs_connector_connector_helper_funcs);
> -	drm_connector_register(connector);
>  
>  	bochs_hw_load_edid(bochs);
>  	if (bochs->edid) {
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 46/59] drm/arc: Align with simple pipe helpers
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-25 12:24     ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-25 12:24 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:21AM +0200, Daniel Vetter wrote:
> Simple pipe helpers only have an enable and disable hook, no more
> mode_set_nofb. Call it from our enable hook to align with that
> conversions.
> 
> Atomic helpers always call mode_set_nofb and enable together, so
> there's no functional change here.
Hmmm....

mode_set_nofb() is only called from drm_atomic_helper - crtc_set_mode()
crtc_set_mode() is only called from drm_atomic_helper_commit_modeset_disables()
drm_atomic_helper_commit_modeset_disables() is called from drm_atomic_helper_commit_tail()

So it seems you are right.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>


> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 72719556debb..c7769edeefdf 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -73,10 +73,9 @@ static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
>  	return MODE_NOCLOCK;
>  }
>  
> -static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
> +static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> -	struct drm_display_mode *m = &crtc->state->adjusted_mode;
> +	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
>  	u32 val;
>  
>  	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> @@ -110,7 +109,7 @@ static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
>  	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
>  
> -	arc_pgu_set_pxl_fmt(crtc);
> +	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
>  
>  	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
>  }
> @@ -120,6 +119,8 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
>  {
>  	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
>  
> +	arc_pgu_mode_set(arcpgu);
> +
>  	clk_prepare_enable(arcpgu->clk);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
>  		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> @@ -139,7 +140,6 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
>  
>  static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
>  	.mode_valid	= arc_pgu_crtc_mode_valid,
> -	.mode_set_nofb	= arc_pgu_crtc_mode_set_nofb,
>  	.atomic_enable	= arc_pgu_crtc_atomic_enable,
>  	.atomic_disable	= arc_pgu_crtc_atomic_disable,
>  };
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 46/59] drm/arc: Align with simple pipe helpers
@ 2020-04-25 12:24     ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-25 12:24 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Wed, Apr 15, 2020 at 09:40:21AM +0200, Daniel Vetter wrote:
> Simple pipe helpers only have an enable and disable hook, no more
> mode_set_nofb. Call it from our enable hook to align with that
> conversions.
> 
> Atomic helpers always call mode_set_nofb and enable together, so
> there's no functional change here.
Hmmm....

mode_set_nofb() is only called from drm_atomic_helper - crtc_set_mode()
crtc_set_mode() is only called from drm_atomic_helper_commit_modeset_disables()
drm_atomic_helper_commit_modeset_disables() is called from drm_atomic_helper_commit_tail()

So it seems you are right.

> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Alexey Brodkin <abrodkin@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>


> ---
>  drivers/gpu/drm/arc/arcpgu_crtc.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> index 72719556debb..c7769edeefdf 100644
> --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> @@ -73,10 +73,9 @@ static enum drm_mode_status arc_pgu_crtc_mode_valid(struct drm_crtc *crtc,
>  	return MODE_NOCLOCK;
>  }
>  
> -static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
> +static void arc_pgu_mode_set(struct arcpgu_drm_private *arcpgu)
>  {
> -	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
> -	struct drm_display_mode *m = &crtc->state->adjusted_mode;
> +	struct drm_display_mode *m = &arcpgu->pipe.crtc.state->adjusted_mode;
>  	u32 val;
>  
>  	arc_pgu_write(arcpgu, ARCPGU_REG_FMT,
> @@ -110,7 +109,7 @@ static void arc_pgu_crtc_mode_set_nofb(struct drm_crtc *crtc)
>  	arc_pgu_write(arcpgu, ARCPGU_REG_STRIDE, 0);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_START_SET, 1);
>  
> -	arc_pgu_set_pxl_fmt(crtc);
> +	arc_pgu_set_pxl_fmt(&arcpgu->pipe.crtc);
>  
>  	clk_set_rate(arcpgu->clk, m->crtc_clock * 1000);
>  }
> @@ -120,6 +119,8 @@ static void arc_pgu_crtc_atomic_enable(struct drm_crtc *crtc,
>  {
>  	struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
>  
> +	arc_pgu_mode_set(arcpgu);
> +
>  	clk_prepare_enable(arcpgu->clk);
>  	arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
>  		      arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
> @@ -139,7 +140,6 @@ static void arc_pgu_crtc_atomic_disable(struct drm_crtc *crtc,
>  
>  static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
>  	.mode_valid	= arc_pgu_crtc_mode_valid,
> -	.mode_set_nofb	= arc_pgu_crtc_mode_set_nofb,
>  	.atomic_enable	= arc_pgu_crtc_atomic_enable,
>  	.atomic_disable	= arc_pgu_crtc_atomic_disable,
>  };
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
  2020-04-21 20:32           ` [Intel-gfx] " Sam Ravnborg
@ 2020-04-28 13:06             ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 13:06 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Paul Kocialkowski, Laurent Pinchart, Thomas Zimmermann,
	Daniel Vetter

On Tue, Apr 21, 2020 at 10:32:45PM +0200, Sam Ravnborg wrote:
> Hi
> 
> > > Hm, I see the point of this (and the dev_field below, although I'd go
> > > with dev_member there for some consistency with other macros using
> > > offset_of or container_of), but I'm not sure about the dev_ prefix.
> > > Drivers use that sometimes for the struct device *, and usage for
> > > struct drm_device * is also very inconsistent. I've seen ddev, drm,
> > > dev and base (that one only for embedded structs ofc). So not sure
> > > which prefix to pick, aside from dev_ seems the most confusing. Got
> > > ideas?
> > 
> > We have pdev for the PCI device, dev for the abstract device, and things
> > like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
> > like drm, because it could be anything in DRM. I guess struct drm_driver
> > is more 'drm' than struct drm_device.
> > 
> > But all of this is bikeshedding. It's probably best to keep the patch
> > as-is, and maybe rename variables later if we ever find consent on the
> > naming.
> 
> bikeshedding - I know.
> But reading code is is quite natural for me that drm equals the central
> drm_device data structure. Maybe thats because this was is in the code
> I started looking at.
> 
> So as an example:
> 
> 	drm_err(drm, "bla bla\n");
> 
> This parses nicely and is easy to type and get right.
> And matches nicely that drm_device => drm.
> But bikeshedding  - I will go to bed...
> (Whatever is the conclusion we should not hold back the patch in
> questions).

Ok, since we can't agree on dev vs ddev vs drm vs something else I just
left it as-is. We can always repaint this later on.

Thanks everyone for comments and review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 01/59] drm: Add devm_drm_dev_alloc macro
@ 2020-04-28 13:06             ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 13:06 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Paul Kocialkowski, Laurent Pinchart, Thomas Zimmermann,
	Daniel Vetter

On Tue, Apr 21, 2020 at 10:32:45PM +0200, Sam Ravnborg wrote:
> Hi
> 
> > > Hm, I see the point of this (and the dev_field below, although I'd go
> > > with dev_member there for some consistency with other macros using
> > > offset_of or container_of), but I'm not sure about the dev_ prefix.
> > > Drivers use that sometimes for the struct device *, and usage for
> > > struct drm_device * is also very inconsistent. I've seen ddev, drm,
> > > dev and base (that one only for embedded structs ofc). So not sure
> > > which prefix to pick, aside from dev_ seems the most confusing. Got
> > > ideas?
> > 
> > We have pdev for the PCI device, dev for the abstract device, and things
> > like mdev for struct mga_device in mgag200. So I'd go with ddev. I don't
> > like drm, because it could be anything in DRM. I guess struct drm_driver
> > is more 'drm' than struct drm_device.
> > 
> > But all of this is bikeshedding. It's probably best to keep the patch
> > as-is, and maybe rename variables later if we ever find consent on the
> > naming.
> 
> bikeshedding - I know.
> But reading code is is quite natural for me that drm equals the central
> drm_device data structure. Maybe thats because this was is in the code
> I started looking at.
> 
> So as an example:
> 
> 	drm_err(drm, "bla bla\n");
> 
> This parses nicely and is easy to type and get right.
> And matches nicely that drm_device => drm.
> But bikeshedding  - I will go to bed...
> (Whatever is the conclusion we should not hold back the patch in
> questions).

Ok, since we can't agree on dev vs ddev vs drm vs something else I just
left it as-is. We can always repaint this later on.

Thanks everyone for comments and review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
  2020-04-24 14:55     ` [Intel-gfx] " Sam Ravnborg
@ 2020-04-28 13:18       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 13:18 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, Emil Velikov,
	DRI Development, Thomas Zimmermann, Dave Airlie, Daniel Vetter,
	Thomas Gleixner, Sean Paul

On Fri, Apr 24, 2020 at 04:55:56PM +0200, Sam Ravnborg wrote:
> Hi Daniel.
> 
> On Wed, Apr 15, 2020 at 09:39:46AM +0200, Daniel Vetter wrote:
> > Also init the fbdev emulation before we register the device, that way
> > we can rely on the auto-cleanup and simplify the probe error code even
> > more.
> > 
> > v2: Rebase on top of Thomas' patches to remove the return value from
> > drm_fbdev_generic_setup()
> 
> with the rebase the changelog in confusing as this patch does nothing of
> what is described in the changelog.
> Only the title (that is in convinently not available when replying to
> email) describes what this patch does.

Good point, I fixed that up while applying, thanks for taking a look.
-Daniel

> 
> With the changelog properly adjusted:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Noralf Trønnes <noralf@tronnes.org>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Sean Paul <sean@poorly.run>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.l.velikov@gmail.com>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > ---
> >  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
> >  1 file changed, 7 insertions(+), 19 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> > index 9cc6d075cb40..523f60e02a85 100644
> > --- a/drivers/gpu/drm/udl/udl_drv.c
> > +++ b/drivers/gpu/drm/udl/udl_drv.c
> > @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
> >  	struct udl_device *udl;
> >  	int r;
> >  
> > -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> > -	if (!udl)
> > -		return ERR_PTR(-ENOMEM);
> > -
> > -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> > -	if (r) {
> > -		kfree(udl);
> > -		return ERR_PTR(r);
> > -	}
> > +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> > +				 struct udl_device, drm);
> > +	if (IS_ERR(udl))
> > +		return udl;
> >  
> >  	udl->udev = udev;
> >  	udl->drm.dev_private = udl;
> > -	drmm_add_final_kfree(&udl->drm, udl);
> >  
> >  	r = udl_init(udl);
> > -	if (r) {
> > -		drm_dev_put(&udl->drm);
> > +	if (r)
> >  		return ERR_PTR(r);
> > -	}
> >  
> >  	usb_set_intfdata(interface, udl);
> > +
> >  	return udl;
> >  }
> >  
> > @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
> >  
> >  	r = drm_dev_register(&udl->drm, 0);
> >  	if (r)
> > -		goto err_free;
> > +		return r;
> >  
> >  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
> >  
> >  	drm_fbdev_generic_setup(&udl->drm, 0);
> >  
> >  	return 0;
> > -
> > -err_free:
> > -	drm_dev_put(&udl->drm);
> > -	return r;
> >  }
> >  
> >  static void udl_usb_disconnect(struct usb_interface *interface)
> > @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
> >  	drm_kms_helper_poll_fini(dev);
> >  	udl_drop_usb(dev);
> >  	drm_dev_unplug(dev);
> > -	drm_dev_put(dev);
> >  }
> >  
> >  /*
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc
@ 2020-04-28 13:18       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 13:18 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Thomas Zimmermann, Dave Airlie, Daniel Vetter, Thomas Gleixner

On Fri, Apr 24, 2020 at 04:55:56PM +0200, Sam Ravnborg wrote:
> Hi Daniel.
> 
> On Wed, Apr 15, 2020 at 09:39:46AM +0200, Daniel Vetter wrote:
> > Also init the fbdev emulation before we register the device, that way
> > we can rely on the auto-cleanup and simplify the probe error code even
> > more.
> > 
> > v2: Rebase on top of Thomas' patches to remove the return value from
> > drm_fbdev_generic_setup()
> 
> with the rebase the changelog in confusing as this patch does nothing of
> what is described in the changelog.
> Only the title (that is in convinently not available when replying to
> email) describes what this patch does.

Good point, I fixed that up while applying, thanks for taking a look.
-Daniel

> 
> With the changelog properly adjusted:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Noralf Trønnes <noralf@tronnes.org>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Sean Paul <sean@poorly.run>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.l.velikov@gmail.com>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > ---
> >  drivers/gpu/drm/udl/udl_drv.c | 26 +++++++-------------------
> >  1 file changed, 7 insertions(+), 19 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> > index 9cc6d075cb40..523f60e02a85 100644
> > --- a/drivers/gpu/drm/udl/udl_drv.c
> > +++ b/drivers/gpu/drm/udl/udl_drv.c
> > @@ -57,27 +57,20 @@ static struct udl_device *udl_driver_create(struct usb_interface *interface)
> >  	struct udl_device *udl;
> >  	int r;
> >  
> > -	udl = kzalloc(sizeof(*udl), GFP_KERNEL);
> > -	if (!udl)
> > -		return ERR_PTR(-ENOMEM);
> > -
> > -	r = drm_dev_init(&udl->drm, &driver, &interface->dev);
> > -	if (r) {
> > -		kfree(udl);
> > -		return ERR_PTR(r);
> > -	}
> > +	udl = devm_drm_dev_alloc(&interface->dev, &driver,
> > +				 struct udl_device, drm);
> > +	if (IS_ERR(udl))
> > +		return udl;
> >  
> >  	udl->udev = udev;
> >  	udl->drm.dev_private = udl;
> > -	drmm_add_final_kfree(&udl->drm, udl);
> >  
> >  	r = udl_init(udl);
> > -	if (r) {
> > -		drm_dev_put(&udl->drm);
> > +	if (r)
> >  		return ERR_PTR(r);
> > -	}
> >  
> >  	usb_set_intfdata(interface, udl);
> > +
> >  	return udl;
> >  }
> >  
> > @@ -93,17 +86,13 @@ static int udl_usb_probe(struct usb_interface *interface,
> >  
> >  	r = drm_dev_register(&udl->drm, 0);
> >  	if (r)
> > -		goto err_free;
> > +		return r;
> >  
> >  	DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
> >  
> >  	drm_fbdev_generic_setup(&udl->drm, 0);
> >  
> >  	return 0;
> > -
> > -err_free:
> > -	drm_dev_put(&udl->drm);
> > -	return r;
> >  }
> >  
> >  static void udl_usb_disconnect(struct usb_interface *interface)
> > @@ -113,7 +102,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
> >  	drm_kms_helper_poll_fini(dev);
> >  	udl_drop_usb(dev);
> >  	drm_dev_unplug(dev);
> > -	drm_dev_put(dev);
> >  }
> >  
> >  /*
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
  2020-04-24 15:09     ` Sam Ravnborg
  (?)
@ 2020-04-28 14:00       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:00 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> Hi Daniel
> 
> On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > Also need to remove the drm_dev_put from the remove hook.
> > 
> > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
> > Cc: spice-devel@lists.freedesktop.org
> > ---
> >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> >  3 files changed, 10 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > index 09102e2efabc..6b4ae4c5fb76 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		return -EINVAL; /* TODO: ENODEV ? */
> >  	}
> >  
> > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > -	if (!qdev)
> > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > +				  struct qxl_device, ddev);
> > +	if (IS_ERR(qdev)) {
> > +		pr_err("Unable to init drm dev");
> >  		return -ENOMEM;
> > +	}
> 
> The other patches do not add any error message when devm_drm_dev_alloc()
> fails and driver core will log that driver init failed.
> 
> So the pr_err() above should be dropped.
> I know it comes from qxl_device_init() but that does not make it a good
> idea.

Hm I know we're inconsistent here, but some drivers have error logging on
all branches, some dont. I'm just trying to go with the prevailing style.

> With this fixed:

Insisting on this or ok as-is?
-Daniel

> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> >  
> >  	ret = pci_enable_device(pdev);
> >  	if (ret)
> > -		goto free_dev;
> > +		return ret;
> >  
> >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> >  	if (ret)
> > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		}
> >  	}
> >  
> > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > +	ret = qxl_device_init(qdev, pdev);
> >  	if (ret)
> >  		goto put_vga;
> >  
> > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> >  disable_pci:
> >  	pci_disable_device(pdev);
> > -free_dev:
> > -	kfree(qdev);
> > +
> >  	return ret;
> >  }
> >  
> > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> >  	drm_atomic_helper_shutdown(dev);
> >  	if (is_vga(pdev))
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > -	drm_dev_put(dev);
> >  }
> >  
> >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > index 435126facc9b..86ac191d9205 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > @@ -276,8 +276,7 @@ struct qxl_device {
> >  extern const struct drm_ioctl_desc qxl_ioctls[];
> >  extern int qxl_max_ioctl;
> >  
> > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > -		    struct pci_dev *pdev);
> > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> >  void qxl_device_fini(struct qxl_device *qdev);
> >  
> >  int qxl_modeset_init(struct qxl_device *qdev);
> > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > index 9eed1a375f24..91a34dd835d7 100644
> > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> >  }
> >  
> >  int qxl_device_init(struct qxl_device *qdev,
> > -		    struct drm_driver *drv,
> >  		    struct pci_dev *pdev)
> >  {
> >  	int r, sb;
> >  
> > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > -	if (r) {
> > -		pr_err("Unable to init drm dev");
> > -		goto error;
> > -	}
> > -
> >  	qdev->ddev.pdev = pdev;
> >  	pci_set_drvdata(pdev, &qdev->ddev);
> >  	qdev->ddev.dev_private = qdev;
> > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> >  
> >  	mutex_init(&qdev->gem.mutex);
> >  	mutex_init(&qdev->update_area_mutex);
> > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> >  	if (!qdev->vram_mapping) {
> >  		pr_err("Unable to create vram_mapping");
> > -		r = -ENOMEM;
> > -		goto error;
> > +		return -ENOMEM;
> >  	}
> >  
> >  	if (pci_resource_len(pdev, 4) > 0) {
> > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	io_mapping_free(qdev->surface_mapping);
> >  vram_mapping_free:
> >  	io_mapping_free(qdev->vram_mapping);
> > -error:
> >  	return r;
> >  }
> >  
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 14:00       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:00 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> Hi Daniel
> 
> On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > Also need to remove the drm_dev_put from the remove hook.
> > 
> > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
> > Cc: spice-devel@lists.freedesktop.org
> > ---
> >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> >  3 files changed, 10 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > index 09102e2efabc..6b4ae4c5fb76 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		return -EINVAL; /* TODO: ENODEV ? */
> >  	}
> >  
> > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > -	if (!qdev)
> > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > +				  struct qxl_device, ddev);
> > +	if (IS_ERR(qdev)) {
> > +		pr_err("Unable to init drm dev");
> >  		return -ENOMEM;
> > +	}
> 
> The other patches do not add any error message when devm_drm_dev_alloc()
> fails and driver core will log that driver init failed.
> 
> So the pr_err() above should be dropped.
> I know it comes from qxl_device_init() but that does not make it a good
> idea.

Hm I know we're inconsistent here, but some drivers have error logging on
all branches, some dont. I'm just trying to go with the prevailing style.

> With this fixed:

Insisting on this or ok as-is?
-Daniel

> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> >  
> >  	ret = pci_enable_device(pdev);
> >  	if (ret)
> > -		goto free_dev;
> > +		return ret;
> >  
> >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> >  	if (ret)
> > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		}
> >  	}
> >  
> > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > +	ret = qxl_device_init(qdev, pdev);
> >  	if (ret)
> >  		goto put_vga;
> >  
> > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> >  disable_pci:
> >  	pci_disable_device(pdev);
> > -free_dev:
> > -	kfree(qdev);
> > +
> >  	return ret;
> >  }
> >  
> > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> >  	drm_atomic_helper_shutdown(dev);
> >  	if (is_vga(pdev))
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > -	drm_dev_put(dev);
> >  }
> >  
> >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > index 435126facc9b..86ac191d9205 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > @@ -276,8 +276,7 @@ struct qxl_device {
> >  extern const struct drm_ioctl_desc qxl_ioctls[];
> >  extern int qxl_max_ioctl;
> >  
> > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > -		    struct pci_dev *pdev);
> > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> >  void qxl_device_fini(struct qxl_device *qdev);
> >  
> >  int qxl_modeset_init(struct qxl_device *qdev);
> > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > index 9eed1a375f24..91a34dd835d7 100644
> > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> >  }
> >  
> >  int qxl_device_init(struct qxl_device *qdev,
> > -		    struct drm_driver *drv,
> >  		    struct pci_dev *pdev)
> >  {
> >  	int r, sb;
> >  
> > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > -	if (r) {
> > -		pr_err("Unable to init drm dev");
> > -		goto error;
> > -	}
> > -
> >  	qdev->ddev.pdev = pdev;
> >  	pci_set_drvdata(pdev, &qdev->ddev);
> >  	qdev->ddev.dev_private = qdev;
> > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> >  
> >  	mutex_init(&qdev->gem.mutex);
> >  	mutex_init(&qdev->update_area_mutex);
> > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> >  	if (!qdev->vram_mapping) {
> >  		pr_err("Unable to create vram_mapping");
> > -		r = -ENOMEM;
> > -		goto error;
> > +		return -ENOMEM;
> >  	}
> >  
> >  	if (pci_resource_len(pdev, 4) > 0) {
> > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	io_mapping_free(qdev->surface_mapping);
> >  vram_mapping_free:
> >  	io_mapping_free(qdev->vram_mapping);
> > -error:
> >  	return r;
> >  }
> >  
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 14:00       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:00 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> Hi Daniel
> 
> On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > Also need to remove the drm_dev_put from the remove hook.
> > 
> > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: virtualization@lists.linux-foundation.org
> > Cc: spice-devel@lists.freedesktop.org
> > ---
> >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> >  3 files changed, 10 insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > index 09102e2efabc..6b4ae4c5fb76 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		return -EINVAL; /* TODO: ENODEV ? */
> >  	}
> >  
> > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > -	if (!qdev)
> > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > +				  struct qxl_device, ddev);
> > +	if (IS_ERR(qdev)) {
> > +		pr_err("Unable to init drm dev");
> >  		return -ENOMEM;
> > +	}
> 
> The other patches do not add any error message when devm_drm_dev_alloc()
> fails and driver core will log that driver init failed.
> 
> So the pr_err() above should be dropped.
> I know it comes from qxl_device_init() but that does not make it a good
> idea.

Hm I know we're inconsistent here, but some drivers have error logging on
all branches, some dont. I'm just trying to go with the prevailing style.

> With this fixed:

Insisting on this or ok as-is?
-Daniel

> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> >  
> >  	ret = pci_enable_device(pdev);
> >  	if (ret)
> > -		goto free_dev;
> > +		return ret;
> >  
> >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> >  	if (ret)
> > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		}
> >  	}
> >  
> > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > +	ret = qxl_device_init(qdev, pdev);
> >  	if (ret)
> >  		goto put_vga;
> >  
> > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> >  disable_pci:
> >  	pci_disable_device(pdev);
> > -free_dev:
> > -	kfree(qdev);
> > +
> >  	return ret;
> >  }
> >  
> > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> >  	drm_atomic_helper_shutdown(dev);
> >  	if (is_vga(pdev))
> >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > -	drm_dev_put(dev);
> >  }
> >  
> >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > index 435126facc9b..86ac191d9205 100644
> > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > @@ -276,8 +276,7 @@ struct qxl_device {
> >  extern const struct drm_ioctl_desc qxl_ioctls[];
> >  extern int qxl_max_ioctl;
> >  
> > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > -		    struct pci_dev *pdev);
> > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> >  void qxl_device_fini(struct qxl_device *qdev);
> >  
> >  int qxl_modeset_init(struct qxl_device *qdev);
> > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > index 9eed1a375f24..91a34dd835d7 100644
> > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> >  }
> >  
> >  int qxl_device_init(struct qxl_device *qdev,
> > -		    struct drm_driver *drv,
> >  		    struct pci_dev *pdev)
> >  {
> >  	int r, sb;
> >  
> > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > -	if (r) {
> > -		pr_err("Unable to init drm dev");
> > -		goto error;
> > -	}
> > -
> >  	qdev->ddev.pdev = pdev;
> >  	pci_set_drvdata(pdev, &qdev->ddev);
> >  	qdev->ddev.dev_private = qdev;
> > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> >  
> >  	mutex_init(&qdev->gem.mutex);
> >  	mutex_init(&qdev->update_area_mutex);
> > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> >  	if (!qdev->vram_mapping) {
> >  		pr_err("Unable to create vram_mapping");
> > -		r = -ENOMEM;
> > -		goto error;
> > +		return -ENOMEM;
> >  	}
> >  
> >  	if (pci_resource_len(pdev, 4) > 0) {
> > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> >  	io_mapping_free(qdev->surface_mapping);
> >  vram_mapping_free:
> >  	io_mapping_free(qdev->vram_mapping);
> > -error:
> >  	return r;
> >  }
> >  
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-15 12:20         ` [Intel-gfx] " Daniel Vetter
@ 2020-04-28 14:08           ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:08 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Wed, Apr 15, 2020 at 02:20:35PM +0200, Daniel Vetter wrote:
> On Wed, Apr 15, 2020 at 2:03 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > -----Original Message-----
> > > From: Sam Ravnborg <sam@ravnborg.org>
> > > Sent: Wednesday, April 15, 2020 12:45 PM
> > > To: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> > > <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> > > <daniel.vetter@intel.com>
> > > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> > >
> > > Hi Daniel.
> > > On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > > > Because it is.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > ---
> > > >  MAINTAINERS                                         |  2 +-
> > > >  drivers/gpu/drm/Kconfig                             |  2 --
> > > >  drivers/gpu/drm/Makefile                            |  1 -
> > > >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> > > >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> > > >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> > > >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> > > >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> > > >  8 files changed, 12 insertions(+), 17 deletions(-)
> > > >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> > > >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> > > >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> > >
> > > We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> > > adds another platform driver to drm/arc/
> > > This speaks against the move to tiny IMO
> >
> > Indeed that's an interesting question, see v3 series here:
> > https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html
> 
> Looking at this patch series, feels a bit like hand-rolling of bridge
> code, badly. We should get away from that.
> 
> Once you have that I think the end result is tiny enough that it can
> stay, bridges intergrate quite well into simple display pipe drivers.
> 
> > BTW should I pull that series in my tree and send you a pull-request
> > or that kind of change needs to go through another tree?
> >
> > Also I'd like to test the change we discuss here to make sure stuff
> > still works. Once we do that I'll send an update. Any hint on
> > when that change needs to be acked/nacked?
> 
> Simplest is if this can all land through drm-misc, is arc not
> maintained in there? And there's plenty of time for testing, I'm just
> slowly crawling through the tree to get everything polished and
> cleaned up in this area.

Any updates on testing this pile here? First patch landed now, and I've
started to push driver patches. So would be good to get this sorted out
too.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-04-28 14:08           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:08 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Wed, Apr 15, 2020 at 02:20:35PM +0200, Daniel Vetter wrote:
> On Wed, Apr 15, 2020 at 2:03 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > -----Original Message-----
> > > From: Sam Ravnborg <sam@ravnborg.org>
> > > Sent: Wednesday, April 15, 2020 12:45 PM
> > > To: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Alexey Brodkin
> > > <abrodkin@synopsys.com>; DRI Development <dri-devel@lists.freedesktop.org>; Daniel Vetter
> > > <daniel.vetter@intel.com>
> > > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> > >
> > > Hi Daniel.
> > > On Wed, Apr 15, 2020 at 09:40:28AM +0200, Daniel Vetter wrote:
> > > > Because it is.
> > > >
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > > ---
> > > >  MAINTAINERS                                         |  2 +-
> > > >  drivers/gpu/drm/Kconfig                             |  2 --
> > > >  drivers/gpu/drm/Makefile                            |  1 -
> > > >  drivers/gpu/drm/arc/Kconfig                         | 10 ----------
> > > >  drivers/gpu/drm/arc/Makefile                        |  3 ---
> > > >  drivers/gpu/drm/tiny/Kconfig                        | 10 ++++++++++
> > > >  drivers/gpu/drm/tiny/Makefile                       |  1 +
> > > >  drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} |  0
> > > >  8 files changed, 12 insertions(+), 17 deletions(-)
> > > >  delete mode 100644 drivers/gpu/drm/arc/Kconfig
> > > >  delete mode 100644 drivers/gpu/drm/arc/Makefile
> > > >  rename drivers/gpu/drm/{arc/arcpgu_drv.c => tiny/arcpgu.c} (100%)
> > >
> > > We have "DRM: ARC: add HDMI 2.0 TX encoder support" which
> > > adds another platform driver to drm/arc/
> > > This speaks against the move to tiny IMO
> >
> > Indeed that's an interesting question, see v3 series here:
> > https://lists.freedesktop.org/archives/dri-devel/2020-April/262352.html
> 
> Looking at this patch series, feels a bit like hand-rolling of bridge
> code, badly. We should get away from that.
> 
> Once you have that I think the end result is tiny enough that it can
> stay, bridges intergrate quite well into simple display pipe drivers.
> 
> > BTW should I pull that series in my tree and send you a pull-request
> > or that kind of change needs to go through another tree?
> >
> > Also I'd like to test the change we discuss here to make sure stuff
> > still works. Once we do that I'll send an update. Any hint on
> > when that change needs to be acked/nacked?
> 
> Simplest is if this can all land through drm-misc, is arc not
> maintained in there? And there's plenty of time for testing, I'm just
> slowly crawling through the tree to get everything polished and
> cleaned up in this area.

Any updates on testing this pile here? First patch landed now, and I've
started to push driver patches. So would be good to get this sorted out
too.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
  2020-04-24 18:10     ` Sam Ravnborg
  (?)
@ 2020-04-28 14:12       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:12 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > mode config cleanup.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Andrew Jeffery <andrew@aj.id.au>
> > Cc: linux-aspeed@lists.ozlabs.org
> > Cc: linux-arm-kernel@lists.infradead.org
> 
> Hmm, the helper function makes no sense, maybe embed it?
> 
> One Q below. Whith Q addressed:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > ---
> >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > index 6b27242b9ee3..6e464b84a256 100644
> > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> >  	.atomic_commit		= drm_atomic_helper_commit,
> >  };
> >  
> > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> >  {
> > -	drm_mode_config_init(drm);
> > -
> >  	drm->mode_config.min_width = 0;
> >  	drm->mode_config.min_height = 0;
> >  	drm->mode_config.max_width = 800;
> >  	drm->mode_config.max_height = 600;
> >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > +
> > +	return drmm_mode_config_init(drm);
> 
> I do not see anything that documents that it is OK to init min/max
> width/heigh not funcs before drmm_mode_config_init() is called.
> Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> and we loose all the assingments from before the call to init().
> 
> Also most (all?) other users of drmm_mode_config_init()
> set them after the call to drmm_mode_config_init().
> So re-order here and then embed while you are touching the code again.

Only reason I've done it like this is that it saves a few lines of diff
compared to other options.

Wrt calling stuff the wrong way round: We pretty much assume throughout
that structures are allocated with kzalloc, none of our _init() functions
in drm have a memset. We'd break the world if we start doing memset() in
random _init() functions I think.

Also the main aspeed_gfx_load() function is quite long already, smashing
more random stuff in there won't help it's readability.

Anyway I don't care, if you insist I'm happy to repaint this in whatever
color choice you deem best :-)

Cheers, Daniel

> 
> 	Sam
> 
> >  }
> >  
> >  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> > @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  	writel(0, priv->base + CRT_CTRL1);
> >  	writel(0, priv->base + CRT_CTRL2);
> >  
> > -	aspeed_gfx_setup_mode_config(drm);
> > +	ret = aspeed_gfx_setup_mode_config(drm);
> > +	if (ret < 0)
> > +		return ret;
> >  
> >  	ret = drm_vblank_init(drm, 1);
> >  	if (ret < 0) {
> > @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  static void aspeed_gfx_unload(struct drm_device *drm)
> >  {
> >  	drm_kms_helper_poll_fini(drm);
> > -	drm_mode_config_cleanup(drm);
> >  }
> >  
> >  DEFINE_DRM_GEM_CMA_FOPS(fops);
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-28 14:12       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:12 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > mode config cleanup.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Andrew Jeffery <andrew@aj.id.au>
> > Cc: linux-aspeed@lists.ozlabs.org
> > Cc: linux-arm-kernel@lists.infradead.org
> 
> Hmm, the helper function makes no sense, maybe embed it?
> 
> One Q below. Whith Q addressed:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > ---
> >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > index 6b27242b9ee3..6e464b84a256 100644
> > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> >  	.atomic_commit		= drm_atomic_helper_commit,
> >  };
> >  
> > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> >  {
> > -	drm_mode_config_init(drm);
> > -
> >  	drm->mode_config.min_width = 0;
> >  	drm->mode_config.min_height = 0;
> >  	drm->mode_config.max_width = 800;
> >  	drm->mode_config.max_height = 600;
> >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > +
> > +	return drmm_mode_config_init(drm);
> 
> I do not see anything that documents that it is OK to init min/max
> width/heigh not funcs before drmm_mode_config_init() is called.
> Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> and we loose all the assingments from before the call to init().
> 
> Also most (all?) other users of drmm_mode_config_init()
> set them after the call to drmm_mode_config_init().
> So re-order here and then embed while you are touching the code again.

Only reason I've done it like this is that it saves a few lines of diff
compared to other options.

Wrt calling stuff the wrong way round: We pretty much assume throughout
that structures are allocated with kzalloc, none of our _init() functions
in drm have a memset. We'd break the world if we start doing memset() in
random _init() functions I think.

Also the main aspeed_gfx_load() function is quite long already, smashing
more random stuff in there won't help it's readability.

Anyway I don't care, if you insist I'm happy to repaint this in whatever
color choice you deem best :-)

Cheers, Daniel

> 
> 	Sam
> 
> >  }
> >  
> >  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> > @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  	writel(0, priv->base + CRT_CTRL1);
> >  	writel(0, priv->base + CRT_CTRL2);
> >  
> > -	aspeed_gfx_setup_mode_config(drm);
> > +	ret = aspeed_gfx_setup_mode_config(drm);
> > +	if (ret < 0)
> > +		return ret;
> >  
> >  	ret = drm_vblank_init(drm, 1);
> >  	if (ret < 0) {
> > @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  static void aspeed_gfx_unload(struct drm_device *drm)
> >  {
> >  	drm_kms_helper_poll_fini(drm);
> > -	drm_mode_config_cleanup(drm);
> >  }
> >  
> >  DEFINE_DRM_GEM_CMA_FOPS(fops);
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-28 14:12       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 14:12 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > mode config cleanup.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Andrew Jeffery <andrew@aj.id.au>
> > Cc: linux-aspeed@lists.ozlabs.org
> > Cc: linux-arm-kernel@lists.infradead.org
> 
> Hmm, the helper function makes no sense, maybe embed it?
> 
> One Q below. Whith Q addressed:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > ---
> >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > index 6b27242b9ee3..6e464b84a256 100644
> > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> >  	.atomic_commit		= drm_atomic_helper_commit,
> >  };
> >  
> > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> >  {
> > -	drm_mode_config_init(drm);
> > -
> >  	drm->mode_config.min_width = 0;
> >  	drm->mode_config.min_height = 0;
> >  	drm->mode_config.max_width = 800;
> >  	drm->mode_config.max_height = 600;
> >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > +
> > +	return drmm_mode_config_init(drm);
> 
> I do not see anything that documents that it is OK to init min/max
> width/heigh not funcs before drmm_mode_config_init() is called.
> Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> and we loose all the assingments from before the call to init().
> 
> Also most (all?) other users of drmm_mode_config_init()
> set them after the call to drmm_mode_config_init().
> So re-order here and then embed while you are touching the code again.

Only reason I've done it like this is that it saves a few lines of diff
compared to other options.

Wrt calling stuff the wrong way round: We pretty much assume throughout
that structures are allocated with kzalloc, none of our _init() functions
in drm have a memset. We'd break the world if we start doing memset() in
random _init() functions I think.

Also the main aspeed_gfx_load() function is quite long already, smashing
more random stuff in there won't help it's readability.

Anyway I don't care, if you insist I'm happy to repaint this in whatever
color choice you deem best :-)

Cheers, Daniel

> 
> 	Sam
> 
> >  }
> >  
> >  static irqreturn_t aspeed_gfx_irq_handler(int irq, void *data)
> > @@ -144,7 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  	writel(0, priv->base + CRT_CTRL1);
> >  	writel(0, priv->base + CRT_CTRL2);
> >  
> > -	aspeed_gfx_setup_mode_config(drm);
> > +	ret = aspeed_gfx_setup_mode_config(drm);
> > +	if (ret < 0)
> > +		return ret;
> >  
> >  	ret = drm_vblank_init(drm, 1);
> >  	if (ret < 0) {
> > @@ -181,7 +183,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
> >  static void aspeed_gfx_unload(struct drm_device *drm)
> >  {
> >  	drm_kms_helper_poll_fini(drm);
> > -	drm_mode_config_cleanup(drm);
> >  }
> >  
> >  DEFINE_DRM_GEM_CMA_FOPS(fops);
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
  2020-04-28 14:00       ` Daniel Vetter
  (?)
@ 2020-04-28 17:00         ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > Hi Daniel
> > 
> > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > Also need to remove the drm_dev_put from the remove hook.
> > > 
> > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Dave Airlie <airlied@redhat.com>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: virtualization@lists.linux-foundation.org
> > > Cc: spice-devel@lists.freedesktop.org
> > > ---
> > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		return -EINVAL; /* TODO: ENODEV ? */
> > >  	}
> > >  
> > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > -	if (!qdev)
> > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > +				  struct qxl_device, ddev);
> > > +	if (IS_ERR(qdev)) {
> > > +		pr_err("Unable to init drm dev");
> > >  		return -ENOMEM;
> > > +	}
> > 
> > The other patches do not add any error message when devm_drm_dev_alloc()
> > fails and driver core will log that driver init failed.
> > 
> > So the pr_err() above should be dropped.
> > I know it comes from qxl_device_init() but that does not make it a good
> > idea.
> 
> Hm I know we're inconsistent here, but some drivers have error logging on
> all branches, some dont. I'm just trying to go with the prevailing style.
> 
> > With this fixed:
> 
> Insisting on this or ok as-is?
OK as-is.

	Sam

> -Daniel
> 
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > >  
> > >  	ret = pci_enable_device(pdev);
> > >  	if (ret)
> > > -		goto free_dev;
> > > +		return ret;
> > >  
> > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > >  	if (ret)
> > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		}
> > >  	}
> > >  
> > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > +	ret = qxl_device_init(qdev, pdev);
> > >  	if (ret)
> > >  		goto put_vga;
> > >  
> > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > >  disable_pci:
> > >  	pci_disable_device(pdev);
> > > -free_dev:
> > > -	kfree(qdev);
> > > +
> > >  	return ret;
> > >  }
> > >  
> > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > >  	drm_atomic_helper_shutdown(dev);
> > >  	if (is_vga(pdev))
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > -	drm_dev_put(dev);
> > >  }
> > >  
> > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > index 435126facc9b..86ac191d9205 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > @@ -276,8 +276,7 @@ struct qxl_device {
> > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > >  extern int qxl_max_ioctl;
> > >  
> > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > -		    struct pci_dev *pdev);
> > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > >  void qxl_device_fini(struct qxl_device *qdev);
> > >  
> > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > index 9eed1a375f24..91a34dd835d7 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > >  }
> > >  
> > >  int qxl_device_init(struct qxl_device *qdev,
> > > -		    struct drm_driver *drv,
> > >  		    struct pci_dev *pdev)
> > >  {
> > >  	int r, sb;
> > >  
> > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > -	if (r) {
> > > -		pr_err("Unable to init drm dev");
> > > -		goto error;
> > > -	}
> > > -
> > >  	qdev->ddev.pdev = pdev;
> > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > >  	qdev->ddev.dev_private = qdev;
> > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > >  
> > >  	mutex_init(&qdev->gem.mutex);
> > >  	mutex_init(&qdev->update_area_mutex);
> > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > >  	if (!qdev->vram_mapping) {
> > >  		pr_err("Unable to create vram_mapping");
> > > -		r = -ENOMEM;
> > > -		goto error;
> > > +		return -ENOMEM;
> > >  	}
> > >  
> > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	io_mapping_free(qdev->surface_mapping);
> > >  vram_mapping_free:
> > >  	io_mapping_free(qdev->vram_mapping);
> > > -error:
> > >  	return r;
> > >  }
> > >  
> > > -- 
> > > 2.25.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 17:00         ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > Hi Daniel
> > 
> > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > Also need to remove the drm_dev_put from the remove hook.
> > > 
> > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Dave Airlie <airlied@redhat.com>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: virtualization@lists.linux-foundation.org
> > > Cc: spice-devel@lists.freedesktop.org
> > > ---
> > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		return -EINVAL; /* TODO: ENODEV ? */
> > >  	}
> > >  
> > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > -	if (!qdev)
> > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > +				  struct qxl_device, ddev);
> > > +	if (IS_ERR(qdev)) {
> > > +		pr_err("Unable to init drm dev");
> > >  		return -ENOMEM;
> > > +	}
> > 
> > The other patches do not add any error message when devm_drm_dev_alloc()
> > fails and driver core will log that driver init failed.
> > 
> > So the pr_err() above should be dropped.
> > I know it comes from qxl_device_init() but that does not make it a good
> > idea.
> 
> Hm I know we're inconsistent here, but some drivers have error logging on
> all branches, some dont. I'm just trying to go with the prevailing style.
> 
> > With this fixed:
> 
> Insisting on this or ok as-is?
OK as-is.

	Sam

> -Daniel
> 
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > >  
> > >  	ret = pci_enable_device(pdev);
> > >  	if (ret)
> > > -		goto free_dev;
> > > +		return ret;
> > >  
> > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > >  	if (ret)
> > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		}
> > >  	}
> > >  
> > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > +	ret = qxl_device_init(qdev, pdev);
> > >  	if (ret)
> > >  		goto put_vga;
> > >  
> > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > >  disable_pci:
> > >  	pci_disable_device(pdev);
> > > -free_dev:
> > > -	kfree(qdev);
> > > +
> > >  	return ret;
> > >  }
> > >  
> > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > >  	drm_atomic_helper_shutdown(dev);
> > >  	if (is_vga(pdev))
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > -	drm_dev_put(dev);
> > >  }
> > >  
> > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > index 435126facc9b..86ac191d9205 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > @@ -276,8 +276,7 @@ struct qxl_device {
> > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > >  extern int qxl_max_ioctl;
> > >  
> > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > -		    struct pci_dev *pdev);
> > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > >  void qxl_device_fini(struct qxl_device *qdev);
> > >  
> > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > index 9eed1a375f24..91a34dd835d7 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > >  }
> > >  
> > >  int qxl_device_init(struct qxl_device *qdev,
> > > -		    struct drm_driver *drv,
> > >  		    struct pci_dev *pdev)
> > >  {
> > >  	int r, sb;
> > >  
> > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > -	if (r) {
> > > -		pr_err("Unable to init drm dev");
> > > -		goto error;
> > > -	}
> > > -
> > >  	qdev->ddev.pdev = pdev;
> > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > >  	qdev->ddev.dev_private = qdev;
> > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > >  
> > >  	mutex_init(&qdev->gem.mutex);
> > >  	mutex_init(&qdev->update_area_mutex);
> > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > >  	if (!qdev->vram_mapping) {
> > >  		pr_err("Unable to create vram_mapping");
> > > -		r = -ENOMEM;
> > > -		goto error;
> > > +		return -ENOMEM;
> > >  	}
> > >  
> > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	io_mapping_free(qdev->surface_mapping);
> > >  vram_mapping_free:
> > >  	io_mapping_free(qdev->vram_mapping);
> > > -error:
> > >  	return r;
> > >  }
> > >  
> > > -- 
> > > 2.25.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 17:00         ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > Hi Daniel
> > 
> > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > Also need to remove the drm_dev_put from the remove hook.
> > > 
> > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Dave Airlie <airlied@redhat.com>
> > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > Cc: virtualization@lists.linux-foundation.org
> > > Cc: spice-devel@lists.freedesktop.org
> > > ---
> > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		return -EINVAL; /* TODO: ENODEV ? */
> > >  	}
> > >  
> > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > -	if (!qdev)
> > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > +				  struct qxl_device, ddev);
> > > +	if (IS_ERR(qdev)) {
> > > +		pr_err("Unable to init drm dev");
> > >  		return -ENOMEM;
> > > +	}
> > 
> > The other patches do not add any error message when devm_drm_dev_alloc()
> > fails and driver core will log that driver init failed.
> > 
> > So the pr_err() above should be dropped.
> > I know it comes from qxl_device_init() but that does not make it a good
> > idea.
> 
> Hm I know we're inconsistent here, but some drivers have error logging on
> all branches, some dont. I'm just trying to go with the prevailing style.
> 
> > With this fixed:
> 
> Insisting on this or ok as-is?
OK as-is.

	Sam

> -Daniel
> 
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > >  
> > >  	ret = pci_enable_device(pdev);
> > >  	if (ret)
> > > -		goto free_dev;
> > > +		return ret;
> > >  
> > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > >  	if (ret)
> > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		}
> > >  	}
> > >  
> > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > +	ret = qxl_device_init(qdev, pdev);
> > >  	if (ret)
> > >  		goto put_vga;
> > >  
> > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > >  disable_pci:
> > >  	pci_disable_device(pdev);
> > > -free_dev:
> > > -	kfree(qdev);
> > > +
> > >  	return ret;
> > >  }
> > >  
> > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > >  	drm_atomic_helper_shutdown(dev);
> > >  	if (is_vga(pdev))
> > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > -	drm_dev_put(dev);
> > >  }
> > >  
> > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > index 435126facc9b..86ac191d9205 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > @@ -276,8 +276,7 @@ struct qxl_device {
> > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > >  extern int qxl_max_ioctl;
> > >  
> > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > -		    struct pci_dev *pdev);
> > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > >  void qxl_device_fini(struct qxl_device *qdev);
> > >  
> > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > index 9eed1a375f24..91a34dd835d7 100644
> > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > >  }
> > >  
> > >  int qxl_device_init(struct qxl_device *qdev,
> > > -		    struct drm_driver *drv,
> > >  		    struct pci_dev *pdev)
> > >  {
> > >  	int r, sb;
> > >  
> > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > -	if (r) {
> > > -		pr_err("Unable to init drm dev");
> > > -		goto error;
> > > -	}
> > > -
> > >  	qdev->ddev.pdev = pdev;
> > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > >  	qdev->ddev.dev_private = qdev;
> > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > >  
> > >  	mutex_init(&qdev->gem.mutex);
> > >  	mutex_init(&qdev->update_area_mutex);
> > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > >  	if (!qdev->vram_mapping) {
> > >  		pr_err("Unable to create vram_mapping");
> > > -		r = -ENOMEM;
> > > -		goto error;
> > > +		return -ENOMEM;
> > >  	}
> > >  
> > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > >  	io_mapping_free(qdev->surface_mapping);
> > >  vram_mapping_free:
> > >  	io_mapping_free(qdev->vram_mapping);
> > > -error:
> > >  	return r;
> > >  }
> > >  
> > > -- 
> > > 2.25.1
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
  2020-04-28 14:12       ` Daniel Vetter
  (?)
@ 2020-04-28 17:03         ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Tue, Apr 28, 2020 at 04:12:21PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> > On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > > mode config cleanup.
> > > 
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Joel Stanley <joel@jms.id.au>
> > > Cc: Andrew Jeffery <andrew@aj.id.au>
> > > Cc: linux-aspeed@lists.ozlabs.org
> > > Cc: linux-arm-kernel@lists.infradead.org
> > 
> > Hmm, the helper function makes no sense, maybe embed it?
> > 
> > One Q below. Whith Q addressed:
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > > ---
> > >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> > >  1 file changed, 6 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > index 6b27242b9ee3..6e464b84a256 100644
> > > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> > >  	.atomic_commit		= drm_atomic_helper_commit,
> > >  };
> > >  
> > > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > >  {
> > > -	drm_mode_config_init(drm);
> > > -
> > >  	drm->mode_config.min_width = 0;
> > >  	drm->mode_config.min_height = 0;
> > >  	drm->mode_config.max_width = 800;
> > >  	drm->mode_config.max_height = 600;
> > >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > > +
> > > +	return drmm_mode_config_init(drm);
> > 
> > I do not see anything that documents that it is OK to init min/max
> > width/heigh not funcs before drmm_mode_config_init() is called.
> > Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> > and we loose all the assingments from before the call to init().
> > 
> > Also most (all?) other users of drmm_mode_config_init()
> > set them after the call to drmm_mode_config_init().
> > So re-order here and then embed while you are touching the code again.
> 
> Only reason I've done it like this is that it saves a few lines of diff
> compared to other options.
> 
> Wrt calling stuff the wrong way round: We pretty much assume throughout
> that structures are allocated with kzalloc, none of our _init() functions
> in drm have a memset. We'd break the world if we start doing memset() in
> random _init() functions I think.
> 
> Also the main aspeed_gfx_load() function is quite long already, smashing
> more random stuff in there won't help it's readability.
> 
> Anyway I don't care, if you insist I'm happy to repaint this in whatever
> color choice you deem best :-)

From the principle of least suprises, you should at least call init and
then set min_width and friends.
This is easy to do in the helper, so easy to avoid the inlining I
suggested.

	Sam

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-28 17:03         ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Tue, Apr 28, 2020 at 04:12:21PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> > On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > > mode config cleanup.
> > > 
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Joel Stanley <joel@jms.id.au>
> > > Cc: Andrew Jeffery <andrew@aj.id.au>
> > > Cc: linux-aspeed@lists.ozlabs.org
> > > Cc: linux-arm-kernel@lists.infradead.org
> > 
> > Hmm, the helper function makes no sense, maybe embed it?
> > 
> > One Q below. Whith Q addressed:
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > > ---
> > >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> > >  1 file changed, 6 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > index 6b27242b9ee3..6e464b84a256 100644
> > > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> > >  	.atomic_commit		= drm_atomic_helper_commit,
> > >  };
> > >  
> > > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > >  {
> > > -	drm_mode_config_init(drm);
> > > -
> > >  	drm->mode_config.min_width = 0;
> > >  	drm->mode_config.min_height = 0;
> > >  	drm->mode_config.max_width = 800;
> > >  	drm->mode_config.max_height = 600;
> > >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > > +
> > > +	return drmm_mode_config_init(drm);
> > 
> > I do not see anything that documents that it is OK to init min/max
> > width/heigh not funcs before drmm_mode_config_init() is called.
> > Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> > and we loose all the assingments from before the call to init().
> > 
> > Also most (all?) other users of drmm_mode_config_init()
> > set them after the call to drmm_mode_config_init().
> > So re-order here and then embed while you are touching the code again.
> 
> Only reason I've done it like this is that it saves a few lines of diff
> compared to other options.
> 
> Wrt calling stuff the wrong way round: We pretty much assume throughout
> that structures are allocated with kzalloc, none of our _init() functions
> in drm have a memset. We'd break the world if we start doing memset() in
> random _init() functions I think.
> 
> Also the main aspeed_gfx_load() function is quite long already, smashing
> more random stuff in there won't help it's readability.
> 
> Anyway I don't care, if you insist I'm happy to repaint this in whatever
> color choice you deem best :-)

From the principle of least suprises, you should at least call init and
then set min_width and friends.
This is easy to do in the helper, so easy to avoid the inlining I
suggested.

	Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup
@ 2020-04-28 17:03         ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-04-28 17:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: linux-aspeed, Andrew Jeffery, Daniel Vetter,
	Intel Graphics Development, DRI Development, Joel Stanley,
	Daniel Vetter, linux-arm-kernel

On Tue, Apr 28, 2020 at 04:12:21PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 08:10:02PM +0200, Sam Ravnborg wrote:
> > On Wed, Apr 15, 2020 at 09:40:31AM +0200, Daniel Vetter wrote:
> > > Since aspeed doesn't use devm_kzalloc anymore we can use the managed
> > > mode config cleanup.
> > > 
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Joel Stanley <joel@jms.id.au>
> > > Cc: Andrew Jeffery <andrew@aj.id.au>
> > > Cc: linux-aspeed@lists.ozlabs.org
> > > Cc: linux-arm-kernel@lists.infradead.org
> > 
> > Hmm, the helper function makes no sense, maybe embed it?
> > 
> > One Q below. Whith Q addressed:
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > > ---
> > >  drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 11 ++++++-----
> > >  1 file changed, 6 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > index 6b27242b9ee3..6e464b84a256 100644
> > > --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> > > @@ -63,15 +63,15 @@ static const struct drm_mode_config_funcs aspeed_gfx_mode_config_funcs = {
> > >  	.atomic_commit		= drm_atomic_helper_commit,
> > >  };
> > >  
> > > -static void aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > > +static int aspeed_gfx_setup_mode_config(struct drm_device *drm)
> > >  {
> > > -	drm_mode_config_init(drm);
> > > -
> > >  	drm->mode_config.min_width = 0;
> > >  	drm->mode_config.min_height = 0;
> > >  	drm->mode_config.max_width = 800;
> > >  	drm->mode_config.max_height = 600;
> > >  	drm->mode_config.funcs = &aspeed_gfx_mode_config_funcs;
> > > +
> > > +	return drmm_mode_config_init(drm);
> > 
> > I do not see anything that documents that it is OK to init min/max
> > width/heigh not funcs before drmm_mode_config_init() is called.
> > Maybe drmm_mode_config_init() gain an memset(drm->mode_config),
> > and we loose all the assingments from before the call to init().
> > 
> > Also most (all?) other users of drmm_mode_config_init()
> > set them after the call to drmm_mode_config_init().
> > So re-order here and then embed while you are touching the code again.
> 
> Only reason I've done it like this is that it saves a few lines of diff
> compared to other options.
> 
> Wrt calling stuff the wrong way round: We pretty much assume throughout
> that structures are allocated with kzalloc, none of our _init() functions
> in drm have a memset. We'd break the world if we start doing memset() in
> random _init() functions I think.
> 
> Also the main aspeed_gfx_load() function is quite long already, smashing
> more random stuff in there won't help it's readability.
> 
> Anyway I don't care, if you insist I'm happy to repaint this in whatever
> color choice you deem best :-)

From the principle of least suprises, you should at least call init and
then set min_width and friends.
This is easy to do in the helper, so easy to avoid the inlining I
suggested.

	Sam
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
  2020-04-28 17:00         ` Sam Ravnborg
  (?)
@ 2020-04-28 18:04           ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 18:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 07:00:26PM +0200, Sam Ravnborg wrote:
> On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> > On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > > Hi Daniel
> > > 
> > > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > > Also need to remove the drm_dev_put from the remove hook.
> > > > 
> > > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: virtualization@lists.linux-foundation.org
> > > > Cc: spice-devel@lists.freedesktop.org
> > > > ---
> > > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		return -EINVAL; /* TODO: ENODEV ? */
> > > >  	}
> > > >  
> > > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > > -	if (!qdev)
> > > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > > +				  struct qxl_device, ddev);
> > > > +	if (IS_ERR(qdev)) {
> > > > +		pr_err("Unable to init drm dev");
> > > >  		return -ENOMEM;
> > > > +	}
> > > 
> > > The other patches do not add any error message when devm_drm_dev_alloc()
> > > fails and driver core will log that driver init failed.
> > > 
> > > So the pr_err() above should be dropped.
> > > I know it comes from qxl_device_init() but that does not make it a good
> > > idea.
> > 
> > Hm I know we're inconsistent here, but some drivers have error logging on
> > all branches, some dont. I'm just trying to go with the prevailing style.
> > 
> > > With this fixed:
> > 
> > Insisting on this or ok as-is?
> OK as-is.

Ok, merged the two qxl patches too, plus a lot of the driver conversions.

Thanks a lot to everyone who commented, reviewed and tested thus far.
-Daniel

> 
> 	Sam
> 
> > -Daniel
> > 
> > > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > > 
> > > >  
> > > >  	ret = pci_enable_device(pdev);
> > > >  	if (ret)
> > > > -		goto free_dev;
> > > > +		return ret;
> > > >  
> > > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > > >  	if (ret)
> > > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		}
> > > >  	}
> > > >  
> > > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > > +	ret = qxl_device_init(qdev, pdev);
> > > >  	if (ret)
> > > >  		goto put_vga;
> > > >  
> > > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > >  disable_pci:
> > > >  	pci_disable_device(pdev);
> > > > -free_dev:
> > > > -	kfree(qdev);
> > > > +
> > > >  	return ret;
> > > >  }
> > > >  
> > > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > > >  	drm_atomic_helper_shutdown(dev);
> > > >  	if (is_vga(pdev))
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > > -	drm_dev_put(dev);
> > > >  }
> > > >  
> > > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > index 435126facc9b..86ac191d9205 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > @@ -276,8 +276,7 @@ struct qxl_device {
> > > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > > >  extern int qxl_max_ioctl;
> > > >  
> > > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > > -		    struct pci_dev *pdev);
> > > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > > >  void qxl_device_fini(struct qxl_device *qdev);
> > > >  
> > > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > index 9eed1a375f24..91a34dd835d7 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > > >  }
> > > >  
> > > >  int qxl_device_init(struct qxl_device *qdev,
> > > > -		    struct drm_driver *drv,
> > > >  		    struct pci_dev *pdev)
> > > >  {
> > > >  	int r, sb;
> > > >  
> > > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > > -	if (r) {
> > > > -		pr_err("Unable to init drm dev");
> > > > -		goto error;
> > > > -	}
> > > > -
> > > >  	qdev->ddev.pdev = pdev;
> > > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > > >  	qdev->ddev.dev_private = qdev;
> > > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > > >  
> > > >  	mutex_init(&qdev->gem.mutex);
> > > >  	mutex_init(&qdev->update_area_mutex);
> > > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > > >  	if (!qdev->vram_mapping) {
> > > >  		pr_err("Unable to create vram_mapping");
> > > > -		r = -ENOMEM;
> > > > -		goto error;
> > > > +		return -ENOMEM;
> > > >  	}
> > > >  
> > > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	io_mapping_free(qdev->surface_mapping);
> > > >  vram_mapping_free:
> > > >  	io_mapping_free(qdev->vram_mapping);
> > > > -error:
> > > >  	return r;
> > > >  }
> > > >  
> > > > -- 
> > > > 2.25.1
> > > > 
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 18:04           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 18:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 07:00:26PM +0200, Sam Ravnborg wrote:
> On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> > On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > > Hi Daniel
> > > 
> > > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > > Also need to remove the drm_dev_put from the remove hook.
> > > > 
> > > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: virtualization@lists.linux-foundation.org
> > > > Cc: spice-devel@lists.freedesktop.org
> > > > ---
> > > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		return -EINVAL; /* TODO: ENODEV ? */
> > > >  	}
> > > >  
> > > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > > -	if (!qdev)
> > > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > > +				  struct qxl_device, ddev);
> > > > +	if (IS_ERR(qdev)) {
> > > > +		pr_err("Unable to init drm dev");
> > > >  		return -ENOMEM;
> > > > +	}
> > > 
> > > The other patches do not add any error message when devm_drm_dev_alloc()
> > > fails and driver core will log that driver init failed.
> > > 
> > > So the pr_err() above should be dropped.
> > > I know it comes from qxl_device_init() but that does not make it a good
> > > idea.
> > 
> > Hm I know we're inconsistent here, but some drivers have error logging on
> > all branches, some dont. I'm just trying to go with the prevailing style.
> > 
> > > With this fixed:
> > 
> > Insisting on this or ok as-is?
> OK as-is.

Ok, merged the two qxl patches too, plus a lot of the driver conversions.

Thanks a lot to everyone who commented, reviewed and tested thus far.
-Daniel

> 
> 	Sam
> 
> > -Daniel
> > 
> > > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > > 
> > > >  
> > > >  	ret = pci_enable_device(pdev);
> > > >  	if (ret)
> > > > -		goto free_dev;
> > > > +		return ret;
> > > >  
> > > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > > >  	if (ret)
> > > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		}
> > > >  	}
> > > >  
> > > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > > +	ret = qxl_device_init(qdev, pdev);
> > > >  	if (ret)
> > > >  		goto put_vga;
> > > >  
> > > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > >  disable_pci:
> > > >  	pci_disable_device(pdev);
> > > > -free_dev:
> > > > -	kfree(qdev);
> > > > +
> > > >  	return ret;
> > > >  }
> > > >  
> > > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > > >  	drm_atomic_helper_shutdown(dev);
> > > >  	if (is_vga(pdev))
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > > -	drm_dev_put(dev);
> > > >  }
> > > >  
> > > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > index 435126facc9b..86ac191d9205 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > @@ -276,8 +276,7 @@ struct qxl_device {
> > > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > > >  extern int qxl_max_ioctl;
> > > >  
> > > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > > -		    struct pci_dev *pdev);
> > > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > > >  void qxl_device_fini(struct qxl_device *qdev);
> > > >  
> > > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > index 9eed1a375f24..91a34dd835d7 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > > >  }
> > > >  
> > > >  int qxl_device_init(struct qxl_device *qdev,
> > > > -		    struct drm_driver *drv,
> > > >  		    struct pci_dev *pdev)
> > > >  {
> > > >  	int r, sb;
> > > >  
> > > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > > -	if (r) {
> > > > -		pr_err("Unable to init drm dev");
> > > > -		goto error;
> > > > -	}
> > > > -
> > > >  	qdev->ddev.pdev = pdev;
> > > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > > >  	qdev->ddev.dev_private = qdev;
> > > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > > >  
> > > >  	mutex_init(&qdev->gem.mutex);
> > > >  	mutex_init(&qdev->update_area_mutex);
> > > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > > >  	if (!qdev->vram_mapping) {
> > > >  		pr_err("Unable to create vram_mapping");
> > > > -		r = -ENOMEM;
> > > > -		goto error;
> > > > +		return -ENOMEM;
> > > >  	}
> > > >  
> > > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	io_mapping_free(qdev->surface_mapping);
> > > >  vram_mapping_free:
> > > >  	io_mapping_free(qdev->vram_mapping);
> > > > -error:
> > > >  	return r;
> > > >  }
> > > >  
> > > > -- 
> > > > 2.25.1
> > > > 
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc
@ 2020-04-28 18:04           ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 18:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Dave Airlie, Daniel Vetter, Intel Graphics Development,
	DRI Development, virtualization, Gerd Hoffmann, Daniel Vetter,
	spice-devel

On Tue, Apr 28, 2020 at 07:00:26PM +0200, Sam Ravnborg wrote:
> On Tue, Apr 28, 2020 at 04:00:11PM +0200, Daniel Vetter wrote:
> > On Fri, Apr 24, 2020 at 05:09:11PM +0200, Sam Ravnborg wrote:
> > > Hi Daniel
> > > 
> > > On Wed, Apr 15, 2020 at 09:40:01AM +0200, Daniel Vetter wrote:
> > > > Also need to remove the drm_dev_put from the remove hook.
> > > > 
> > > > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > > > Cc: virtualization@lists.linux-foundation.org
> > > > Cc: spice-devel@lists.freedesktop.org
> > > > ---
> > > >  drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++++++-------
> > > >  drivers/gpu/drm/qxl/qxl_drv.h |  3 +--
> > > >  drivers/gpu/drm/qxl/qxl_kms.c | 12 +-----------
> > > >  3 files changed, 10 insertions(+), 20 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > index 09102e2efabc..6b4ae4c5fb76 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> > > > @@ -81,13 +81,16 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		return -EINVAL; /* TODO: ENODEV ? */
> > > >  	}
> > > >  
> > > > -	qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
> > > > -	if (!qdev)
> > > > +	qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
> > > > +				  struct qxl_device, ddev);
> > > > +	if (IS_ERR(qdev)) {
> > > > +		pr_err("Unable to init drm dev");
> > > >  		return -ENOMEM;
> > > > +	}
> > > 
> > > The other patches do not add any error message when devm_drm_dev_alloc()
> > > fails and driver core will log that driver init failed.
> > > 
> > > So the pr_err() above should be dropped.
> > > I know it comes from qxl_device_init() but that does not make it a good
> > > idea.
> > 
> > Hm I know we're inconsistent here, but some drivers have error logging on
> > all branches, some dont. I'm just trying to go with the prevailing style.
> > 
> > > With this fixed:
> > 
> > Insisting on this or ok as-is?
> OK as-is.

Ok, merged the two qxl patches too, plus a lot of the driver conversions.

Thanks a lot to everyone who commented, reviewed and tested thus far.
-Daniel

> 
> 	Sam
> 
> > -Daniel
> > 
> > > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > > 
> > > >  
> > > >  	ret = pci_enable_device(pdev);
> > > >  	if (ret)
> > > > -		goto free_dev;
> > > > +		return ret;
> > > >  
> > > >  	ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl");
> > > >  	if (ret)
> > > > @@ -101,7 +104,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		}
> > > >  	}
> > > >  
> > > > -	ret = qxl_device_init(qdev, &qxl_driver, pdev);
> > > > +	ret = qxl_device_init(qdev, pdev);
> > > >  	if (ret)
> > > >  		goto put_vga;
> > > >  
> > > > @@ -128,8 +131,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > >  disable_pci:
> > > >  	pci_disable_device(pdev);
> > > > -free_dev:
> > > > -	kfree(qdev);
> > > > +
> > > >  	return ret;
> > > >  }
> > > >  
> > > > @@ -155,7 +157,6 @@ qxl_pci_remove(struct pci_dev *pdev)
> > > >  	drm_atomic_helper_shutdown(dev);
> > > >  	if (is_vga(pdev))
> > > >  		vga_put(pdev, VGA_RSRC_LEGACY_IO);
> > > > -	drm_dev_put(dev);
> > > >  }
> > > >  
> > > >  DEFINE_DRM_GEM_FOPS(qxl_fops);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > index 435126facc9b..86ac191d9205 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_drv.h
> > > > +++ b/drivers/gpu/drm/qxl/qxl_drv.h
> > > > @@ -276,8 +276,7 @@ struct qxl_device {
> > > >  extern const struct drm_ioctl_desc qxl_ioctls[];
> > > >  extern int qxl_max_ioctl;
> > > >  
> > > > -int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
> > > > -		    struct pci_dev *pdev);
> > > > +int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
> > > >  void qxl_device_fini(struct qxl_device *qdev);
> > > >  
> > > >  int qxl_modeset_init(struct qxl_device *qdev);
> > > > diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > index 9eed1a375f24..91a34dd835d7 100644
> > > > --- a/drivers/gpu/drm/qxl/qxl_kms.c
> > > > +++ b/drivers/gpu/drm/qxl/qxl_kms.c
> > > > @@ -108,21 +108,13 @@ static void qxl_gc_work(struct work_struct *work)
> > > >  }
> > > >  
> > > >  int qxl_device_init(struct qxl_device *qdev,
> > > > -		    struct drm_driver *drv,
> > > >  		    struct pci_dev *pdev)
> > > >  {
> > > >  	int r, sb;
> > > >  
> > > > -	r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
> > > > -	if (r) {
> > > > -		pr_err("Unable to init drm dev");
> > > > -		goto error;
> > > > -	}
> > > > -
> > > >  	qdev->ddev.pdev = pdev;
> > > >  	pci_set_drvdata(pdev, &qdev->ddev);
> > > >  	qdev->ddev.dev_private = qdev;
> > > > -	drmm_add_final_kfree(&qdev->ddev, qdev);
> > > >  
> > > >  	mutex_init(&qdev->gem.mutex);
> > > >  	mutex_init(&qdev->update_area_mutex);
> > > > @@ -138,8 +130,7 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	qdev->vram_mapping = io_mapping_create_wc(qdev->vram_base, pci_resource_len(pdev, 0));
> > > >  	if (!qdev->vram_mapping) {
> > > >  		pr_err("Unable to create vram_mapping");
> > > > -		r = -ENOMEM;
> > > > -		goto error;
> > > > +		return -ENOMEM;
> > > >  	}
> > > >  
> > > >  	if (pci_resource_len(pdev, 4) > 0) {
> > > > @@ -293,7 +284,6 @@ int qxl_device_init(struct qxl_device *qdev,
> > > >  	io_mapping_free(qdev->surface_mapping);
> > > >  vram_mapping_free:
> > > >  	io_mapping_free(qdev->vram_mapping);
> > > > -error:
> > > >  	return r;
> > > >  }
> > > >  
> > > > -- 
> > > > 2.25.1
> > > > 
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-04-28 18:52     ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 18:52 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:13AM +0200, Daniel Vetter wrote:
> Luckily we're already well set up in the main driver, with
> drm_dev_put() being the last thing in both the unload error case and
> the pci remove function.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Pushed to drm-misc-next with Jani's irc-ack.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 17 ++++-------------
>  drivers/gpu/drm/i915/i915_pci.c |  2 --
>  2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 641f5e03b661..ff9a5b1b4c6d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		(struct intel_device_info *)ent->driver_data;
>  	struct intel_device_info *device_info;
>  	struct drm_i915_private *i915;
> -	int err;
>  
> -	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
> -	if (!i915)
> -		return ERR_PTR(-ENOMEM);
> -
> -	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
> -	if (err) {
> -		kfree(i915);
> -		return ERR_PTR(err);
> -	}
> -
> -	drmm_add_final_kfree(&i915->drm, i915);
> +	i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct drm_i915_private, drm);
> +	if (IS_ERR(i915))
> +		return i915;
>  
>  	i915->drm.pdev = pdev;
>  	pci_set_drvdata(pdev, i915);
> @@ -1006,7 +998,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_disable_device(pdev);
>  out_fini:
>  	i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
> -	drm_dev_put(&i915->drm);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 66738f2c4f28..2741fb3e30cb 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -941,8 +941,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
>  
>  	i915_driver_remove(i915);
>  	pci_set_drvdata(pdev, NULL);
> -
> -	drm_dev_put(&i915->drm);
>  }
>  
>  /* is device_id present in comma separated list of ids */
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc
@ 2020-04-28 18:52     ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-04-28 18:52 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter

On Wed, Apr 15, 2020 at 09:40:13AM +0200, Daniel Vetter wrote:
> Luckily we're already well set up in the main driver, with
> drm_dev_put() being the last thing in both the unload error case and
> the pci remove function.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Pushed to drm-misc-next with Jani's irc-ack.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 17 ++++-------------
>  drivers/gpu/drm/i915/i915_pci.c |  2 --
>  2 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 641f5e03b661..ff9a5b1b4c6d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -877,19 +877,11 @@ i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		(struct intel_device_info *)ent->driver_data;
>  	struct intel_device_info *device_info;
>  	struct drm_i915_private *i915;
> -	int err;
>  
> -	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
> -	if (!i915)
> -		return ERR_PTR(-ENOMEM);
> -
> -	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
> -	if (err) {
> -		kfree(i915);
> -		return ERR_PTR(err);
> -	}
> -
> -	drmm_add_final_kfree(&i915->drm, i915);
> +	i915 = devm_drm_dev_alloc(&pdev->dev, &driver,
> +				  struct drm_i915_private, drm);
> +	if (IS_ERR(i915))
> +		return i915;
>  
>  	i915->drm.pdev = pdev;
>  	pci_set_drvdata(pdev, i915);
> @@ -1006,7 +998,6 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_disable_device(pdev);
>  out_fini:
>  	i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
> -	drm_dev_put(&i915->drm);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 66738f2c4f28..2741fb3e30cb 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -941,8 +941,6 @@ static void i915_pci_remove(struct pci_dev *pdev)
>  
>  	i915_driver_remove(i915);
>  	pci_set_drvdata(pdev, NULL);
> -
> -	drm_dev_put(&i915->drm);
>  }
>  
>  /* is device_id present in comma separated list of ids */
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* RE: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-04-28 14:08           ` [Intel-gfx] " Daniel Vetter
@ 2020-05-08 13:56             ` Alexey Brodkin
  -1 siblings, 0 replies; 317+ messages in thread
From: Alexey Brodkin @ 2020-05-08 13:56 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

Hi Daniel,

> > Looking at this patch series, feels a bit like hand-rolling of bridge
> > code, badly. We should get away from that.
> >
> > Once you have that I think the end result is tiny enough that it can
> > stay, bridges intergrate quite well into simple display pipe drivers.
> >
> > > BTW should I pull that series in my tree and send you a pull-request
> > > or that kind of change needs to go through another tree?
> > >
> > > Also I'd like to test the change we discuss here to make sure stuff
> > > still works. Once we do that I'll send an update. Any hint on
> > > when that change needs to be acked/nacked?
> >
> > Simplest is if this can all land through drm-misc, is arc not
> > maintained in there? And there's plenty of time for testing, I'm just
> > slowly crawling through the tree to get everything polished and
> > cleaned up in this area.
> 
> Any updates on testing this pile here? First patch landed now, and I've
> started to push driver patches. So would be good to get this sorted out
> too.

Sorry we're in the middle of 2 long weekends so missed this one.
I guess we'll be able to test it in a week or two from now.

Is that OK?

-Alexey


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-05-08 13:56             ` Alexey Brodkin
  0 siblings, 0 replies; 317+ messages in thread
From: Alexey Brodkin @ 2020-05-08 13:56 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

Hi Daniel,

> > Looking at this patch series, feels a bit like hand-rolling of bridge
> > code, badly. We should get away from that.
> >
> > Once you have that I think the end result is tiny enough that it can
> > stay, bridges intergrate quite well into simple display pipe drivers.
> >
> > > BTW should I pull that series in my tree and send you a pull-request
> > > or that kind of change needs to go through another tree?
> > >
> > > Also I'd like to test the change we discuss here to make sure stuff
> > > still works. Once we do that I'll send an update. Any hint on
> > > when that change needs to be acked/nacked?
> >
> > Simplest is if this can all land through drm-misc, is arc not
> > maintained in there? And there's plenty of time for testing, I'm just
> > slowly crawling through the tree to get everything polished and
> > cleaned up in this area.
> 
> Any updates on testing this pile here? First patch landed now, and I've
> started to push driver patches. So would be good to get this sorted out
> too.

Sorry we're in the middle of 2 long weekends so missed this one.
I guess we'll be able to test it in a week or two from now.

Is that OK?

-Alexey


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-05-08 13:56             ` [Intel-gfx] " Alexey Brodkin
@ 2020-05-08 18:07               ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-05-08 18:07 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Daniel,
>
> > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > code, badly. We should get away from that.
> > >
> > > Once you have that I think the end result is tiny enough that it can
> > > stay, bridges intergrate quite well into simple display pipe drivers.
> > >
> > > > BTW should I pull that series in my tree and send you a pull-request
> > > > or that kind of change needs to go through another tree?
> > > >
> > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > still works. Once we do that I'll send an update. Any hint on
> > > > when that change needs to be acked/nacked?
> > >
> > > Simplest is if this can all land through drm-misc, is arc not
> > > maintained in there? And there's plenty of time for testing, I'm just
> > > slowly crawling through the tree to get everything polished and
> > > cleaned up in this area.
> >
> > Any updates on testing this pile here? First patch landed now, and I've
> > started to push driver patches. So would be good to get this sorted out
> > too.
>
> Sorry we're in the middle of 2 long weekends so missed this one.
> I guess we'll be able to test it in a week or two from now.
>
> Is that OK?

This aren't high-priority, so totally ok. As long as you don't land a
driver rewrite and I have to rebase everything :-)
-Daniel

>
> -Alexey
>
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-05-08 18:07               ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-05-08 18:07 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Daniel,
>
> > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > code, badly. We should get away from that.
> > >
> > > Once you have that I think the end result is tiny enough that it can
> > > stay, bridges intergrate quite well into simple display pipe drivers.
> > >
> > > > BTW should I pull that series in my tree and send you a pull-request
> > > > or that kind of change needs to go through another tree?
> > > >
> > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > still works. Once we do that I'll send an update. Any hint on
> > > > when that change needs to be acked/nacked?
> > >
> > > Simplest is if this can all land through drm-misc, is arc not
> > > maintained in there? And there's plenty of time for testing, I'm just
> > > slowly crawling through the tree to get everything polished and
> > > cleaned up in this area.
> >
> > Any updates on testing this pile here? First patch landed now, and I've
> > started to push driver patches. So would be good to get this sorted out
> > too.
>
> Sorry we're in the middle of 2 long weekends so missed this one.
> I guess we'll be able to test it in a week or two from now.
>
> Is that OK?

This aren't high-priority, so totally ok. As long as you don't land a
driver rewrite and I have to rebase everything :-)
-Daniel

>
> -Alexey
>
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-05-08 18:07               ` [Intel-gfx] " Daniel Vetter
@ 2020-06-04  8:05                 ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-04  8:05 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Fri, May 08, 2020 at 08:07:41PM +0200, Daniel Vetter wrote:
> On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > > code, badly. We should get away from that.
> > > >
> > > > Once you have that I think the end result is tiny enough that it can
> > > > stay, bridges intergrate quite well into simple display pipe drivers.
> > > >
> > > > > BTW should I pull that series in my tree and send you a pull-request
> > > > > or that kind of change needs to go through another tree?
> > > > >
> > > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > > still works. Once we do that I'll send an update. Any hint on
> > > > > when that change needs to be acked/nacked?
> > > >
> > > > Simplest is if this can all land through drm-misc, is arc not
> > > > maintained in there? And there's plenty of time for testing, I'm just
> > > > slowly crawling through the tree to get everything polished and
> > > > cleaned up in this area.
> > >
> > > Any updates on testing this pile here? First patch landed now, and I've
> > > started to push driver patches. So would be good to get this sorted out
> > > too.
> >
> > Sorry we're in the middle of 2 long weekends so missed this one.
> > I guess we'll be able to test it in a week or two from now.
> >
> > Is that OK?
> 
> This aren't high-priority, so totally ok. As long as you don't land a
> driver rewrite and I have to rebase everything :-)

Ping for a bit of testing on this stuff ...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-04  8:05                 ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-04  8:05 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Sam Ravnborg, Daniel Vetter, Intel Graphics Development,
	Eugeniy Paltsev, DRI Development

On Fri, May 08, 2020 at 08:07:41PM +0200, Daniel Vetter wrote:
> On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > > code, badly. We should get away from that.
> > > >
> > > > Once you have that I think the end result is tiny enough that it can
> > > > stay, bridges intergrate quite well into simple display pipe drivers.
> > > >
> > > > > BTW should I pull that series in my tree and send you a pull-request
> > > > > or that kind of change needs to go through another tree?
> > > > >
> > > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > > still works. Once we do that I'll send an update. Any hint on
> > > > > when that change needs to be acked/nacked?
> > > >
> > > > Simplest is if this can all land through drm-misc, is arc not
> > > > maintained in there? And there's plenty of time for testing, I'm just
> > > > slowly crawling through the tree to get everything polished and
> > > > cleaned up in this area.
> > >
> > > Any updates on testing this pile here? First patch landed now, and I've
> > > started to push driver patches. So would be good to get this sorted out
> > > too.
> >
> > Sorry we're in the middle of 2 long weekends so missed this one.
> > I guess we'll be able to test it in a week or two from now.
> >
> > Is that OK?
> 
> This aren't high-priority, so totally ok. As long as you don't land a
> driver rewrite and I have to rebase everything :-)

Ping for a bit of testing on this stuff ...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-04  8:05                 ` [Intel-gfx] " Daniel Vetter
@ 2020-06-04 10:38                   ` Eugeniy Paltsev
  -1 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-04 10:38 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	Sam Ravnborg, DRI Development

Hi Daniel,

I've already tested it (and found several issues), so please check my reply here:
https://www.mail-archive.com/linux-snps-arc@lists.infradead.org/msg07403.html

Not sure why you didn't receive my reply (probably the reason is because it was sent to your @ffwll.ch mail instead of @intel.com one).

________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Thursday, June 4, 2020 11:05
To: Alexey Brodkin
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Eugeniy Paltsev; Sam Ravnborg
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

On Fri, May 08, 2020 at 08:07:41PM +0200, Daniel Vetter wrote:
> On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > > code, badly. We should get away from that.
> > > >
> > > > Once you have that I think the end result is tiny enough that it can
> > > > stay, bridges intergrate quite well into simple display pipe drivers.
> > > >
> > > > > BTW should I pull that series in my tree and send you a pull-request
> > > > > or that kind of change needs to go through another tree?
> > > > >
> > > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > > still works. Once we do that I'll send an update. Any hint on
> > > > > when that change needs to be acked/nacked?
> > > >
> > > > Simplest is if this can all land through drm-misc, is arc not
> > > > maintained in there? And there's plenty of time for testing, I'm just
> > > > slowly crawling through the tree to get everything polished and
> > > > cleaned up in this area.
> > >
> > > Any updates on testing this pile here? First patch landed now, and I've
> > > started to push driver patches. So would be good to get this sorted out
> > > too.
> >
> > Sorry we're in the middle of 2 long weekends so missed this one.
> > I guess we'll be able to test it in a week or two from now.
> >
> > Is that OK?
>
> This aren't high-priority, so totally ok. As long as you don't land a
> driver rewrite and I have to rebase everything :-)

Ping for a bit of testing on this stuff ...
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!Ncpf9M5g5wUEicELHfzz8syA0c0KogYc2E0tdnXGHGmUwGbROv-vwMDISCh7u6w58Dgs-ws$
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-04 10:38                   ` Eugeniy Paltsev
  0 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-04 10:38 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	Sam Ravnborg, DRI Development

Hi Daniel,

I've already tested it (and found several issues), so please check my reply here:
https://www.mail-archive.com/linux-snps-arc@lists.infradead.org/msg07403.html

Not sure why you didn't receive my reply (probably the reason is because it was sent to your @ffwll.ch mail instead of @intel.com one).

________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Thursday, June 4, 2020 11:05
To: Alexey Brodkin
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Eugeniy Paltsev; Sam Ravnborg
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

On Fri, May 08, 2020 at 08:07:41PM +0200, Daniel Vetter wrote:
> On Fri, May 8, 2020 at 3:56 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > > > Looking at this patch series, feels a bit like hand-rolling of bridge
> > > > code, badly. We should get away from that.
> > > >
> > > > Once you have that I think the end result is tiny enough that it can
> > > > stay, bridges intergrate quite well into simple display pipe drivers.
> > > >
> > > > > BTW should I pull that series in my tree and send you a pull-request
> > > > > or that kind of change needs to go through another tree?
> > > > >
> > > > > Also I'd like to test the change we discuss here to make sure stuff
> > > > > still works. Once we do that I'll send an update. Any hint on
> > > > > when that change needs to be acked/nacked?
> > > >
> > > > Simplest is if this can all land through drm-misc, is arc not
> > > > maintained in there? And there's plenty of time for testing, I'm just
> > > > slowly crawling through the tree to get everything polished and
> > > > cleaned up in this area.
> > >
> > > Any updates on testing this pile here? First patch landed now, and I've
> > > started to push driver patches. So would be good to get this sorted out
> > > too.
> >
> > Sorry we're in the middle of 2 long weekends so missed this one.
> > I guess we'll be able to test it in a week or two from now.
> >
> > Is that OK?
>
> This aren't high-priority, so totally ok. As long as you don't land a
> driver rewrite and I have to rebase everything :-)

Ping for a bit of testing on this stuff ...
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!Ncpf9M5g5wUEicELHfzz8syA0c0KogYc2E0tdnXGHGmUwGbROv-vwMDISCh7u6w58Dgs-ws$
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-04 10:38                   ` [Intel-gfx] " Eugeniy Paltsev
@ 2020-06-04 11:19                     ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-04 11:19 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	Sam Ravnborg, DRI Development

Hi Eugeniy,

Apologies, somehow I missed your mail. I looked at the code again, and I
think I fumbled something. Does the below diff help to prevent the issues?

Thanks, Daniel


diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 857812f25bec..33d812a5ad7f 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
+	if (!pipe->plane.state->fb)
+		return;
+
 	arcpgu = pipe_to_arcpgu_priv(pipe);
 	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-04 11:19                     ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-04 11:19 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	Sam Ravnborg, DRI Development

Hi Eugeniy,

Apologies, somehow I missed your mail. I looked at the code again, and I
think I fumbled something. Does the below diff help to prevent the issues?

Thanks, Daniel


diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 857812f25bec..33d812a5ad7f 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
 	struct arcpgu_drm_private *arcpgu;
 	struct drm_gem_cma_object *gem;
 
+	if (!pipe->plane.state->fb)
+		return;
+
 	arcpgu = pipe_to_arcpgu_priv(pipe);
 	gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
 	arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BUILD: failure for devm_drm_dev_alloc, v2 (rev2)
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (63 preceding siblings ...)
  (?)
@ 2020-06-04 11:58 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-06-04 11:58 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2 (rev2)
URL   : https://patchwork.freedesktop.org/series/75956/
State : failure

== Summary ==

Applying: drm: Add devm_drm_dev_alloc macro
error: sha1 information is lacking or useless (drivers/gpu/drm/drm_drv.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm: Add devm_drm_dev_alloc macro
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-04 11:19                     ` [Intel-gfx] " Daniel Vetter
@ 2020-06-04 19:00                       ` Eugeniy Paltsev
  -1 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-04 19:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

I've tested your change and one issue gone.

However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
----------------------------------->8-------------------------------------------
Oops
Path: (null)
CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
Workqueue: events drm_mode_rmfb_work_fn
Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
BLK: drm_gem_fb_destroy+0xc0/0x130
 SP: 0x9f055ea4  FP: 0x00000000
LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
r12: 0x813b9b04

Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_framebuffer_remove+0x1d2/0x358
  drm_mode_rmfb_work_fn+0x28/0x38
  process_one_work+0x19a/0x358
  worker_thread+0x2c4/0x494
  kthread+0xec/0x100
  ret_from_fork+0x18/0x1c
----------------------------------->8-------------------------------------------


The stack traces may vary but always end in drm_gem_fb_destroy:
----------------------------------->8-------------------------------------------
Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_mode_rmfb+0x10e/0x148
  drm_ioctl_kernel+0x70/0xa0
  drm_ioctl+0x284/0x410
  ksys_ioctl+0xea/0xa3c
  EV_Trap+0xcc/0xd0
----------------------------------->8-------------------------------------------
Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_fb_release+0x66/0xb0
  drm_file_free.part.11+0x112/0x1bc
  drm_release+0x80/0x120
  __fput+0x98/0x1bc
  task_work_run+0x6e/0xa8
  do_exit+0x2b4/0x7fc
  do_group_exit+0x2a/0x8c
  get_signal+0x9a/0x5f0
  do_signal+0x86/0x23c
  resume_user_mode_begin+0x88/0xd0
----------------------------------->8-------------------------------------------


---
 Eugeniy Paltsev


________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Thursday, June 4, 2020 14:19
To: Eugeniy Paltsev
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

Hi Eugeniy,

Apologies, somehow I missed your mail. I looked at the code again, and I
think I fumbled something. Does the below diff help to prevent the issues?

Thanks, Daniel


diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 857812f25bec..33d812a5ad7f 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
        struct arcpgu_drm_private *arcpgu;
        struct drm_gem_cma_object *gem;

+       if (!pipe->plane.state->fb)
+               return;
+
        arcpgu = pipe_to_arcpgu_priv(pipe);
        gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
        arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-04 19:00                       ` Eugeniy Paltsev
  0 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-04 19:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

I've tested your change and one issue gone.

However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
----------------------------------->8-------------------------------------------
Oops
Path: (null)
CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
Workqueue: events drm_mode_rmfb_work_fn
Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
BLK: drm_gem_fb_destroy+0xc0/0x130
 SP: 0x9f055ea4  FP: 0x00000000
LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
r12: 0x813b9b04

Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_framebuffer_remove+0x1d2/0x358
  drm_mode_rmfb_work_fn+0x28/0x38
  process_one_work+0x19a/0x358
  worker_thread+0x2c4/0x494
  kthread+0xec/0x100
  ret_from_fork+0x18/0x1c
----------------------------------->8-------------------------------------------


The stack traces may vary but always end in drm_gem_fb_destroy:
----------------------------------->8-------------------------------------------
Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_mode_rmfb+0x10e/0x148
  drm_ioctl_kernel+0x70/0xa0
  drm_ioctl+0x284/0x410
  ksys_ioctl+0xea/0xa3c
  EV_Trap+0xcc/0xd0
----------------------------------->8-------------------------------------------
Stack Trace:
  drm_gem_fb_destroy+0x32/0x130
  drm_fb_release+0x66/0xb0
  drm_file_free.part.11+0x112/0x1bc
  drm_release+0x80/0x120
  __fput+0x98/0x1bc
  task_work_run+0x6e/0xa8
  do_exit+0x2b4/0x7fc
  do_group_exit+0x2a/0x8c
  get_signal+0x9a/0x5f0
  do_signal+0x86/0x23c
  resume_user_mode_begin+0x88/0xd0
----------------------------------->8-------------------------------------------


---
 Eugeniy Paltsev


________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Thursday, June 4, 2020 14:19
To: Eugeniy Paltsev
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

Hi Eugeniy,

Apologies, somehow I missed your mail. I looked at the code again, and I
think I fumbled something. Does the below diff help to prevent the issues?

Thanks, Daniel


diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 857812f25bec..33d812a5ad7f 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
        struct arcpgu_drm_private *arcpgu;
        struct drm_gem_cma_object *gem;

+       if (!pipe->plane.state->fb)
+               return;
+
        arcpgu = pipe_to_arcpgu_priv(pipe);
        gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
        arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 317+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BUILD: failure for devm_drm_dev_alloc, v2 (rev3)
  2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
                   ` (64 preceding siblings ...)
  (?)
@ 2020-06-04 19:36 ` Patchwork
  -1 siblings, 0 replies; 317+ messages in thread
From: Patchwork @ 2020-06-04 19:36 UTC (permalink / raw)
  To: Eugeniy Paltsev; +Cc: intel-gfx

== Series Details ==

Series: devm_drm_dev_alloc, v2 (rev3)
URL   : https://patchwork.freedesktop.org/series/75956/
State : failure

== Summary ==

Applying: drm: Add devm_drm_dev_alloc macro
error: sha1 information is lacking or useless (drivers/gpu/drm/drm_drv.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm: Add devm_drm_dev_alloc macro
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-04 19:00                       ` [Intel-gfx] " Eugeniy Paltsev
@ 2020-06-05 19:55                         ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-05 19:55 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Eugeniy,

Thanks for testing. I looked at the second one (I hoped it would just
magically disappear) and I still don't understand what's going on
there. My patch series isn't touching that area at all, so really
confused.

I squashed in the bugfix from the previous round into the right
patches, and pushed a branch with just the arcpgu changes here:
https://cgit.freedesktop.org/~danvet/drm/log/?h=for-eugeniy

Maybe it's something in my pile of not-so-tested stuff :-)

Can you pls test this? And if it still fails, try to bisect where it breaks?

Thanks, Daniel

On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> I've tested your change and one issue gone.
>
> However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> ----------------------------------->8-------------------------------------------
> Oops
> Path: (null)
> CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> Workqueue: events drm_mode_rmfb_work_fn
> Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> BLK: drm_gem_fb_destroy+0xc0/0x130
>  SP: 0x9f055ea4  FP: 0x00000000
> LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> r12: 0x813b9b04
>
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_framebuffer_remove+0x1d2/0x358
>   drm_mode_rmfb_work_fn+0x28/0x38
>   process_one_work+0x19a/0x358
>   worker_thread+0x2c4/0x494
>   kthread+0xec/0x100
>   ret_from_fork+0x18/0x1c
> ----------------------------------->8-------------------------------------------
>
>
> The stack traces may vary but always end in drm_gem_fb_destroy:
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_mode_rmfb+0x10e/0x148
>   drm_ioctl_kernel+0x70/0xa0
>   drm_ioctl+0x284/0x410
>   ksys_ioctl+0xea/0xa3c
>   EV_Trap+0xcc/0xd0
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_fb_release+0x66/0xb0
>   drm_file_free.part.11+0x112/0x1bc
>   drm_release+0x80/0x120
>   __fput+0x98/0x1bc
>   task_work_run+0x6e/0xa8
>   do_exit+0x2b4/0x7fc
>   do_group_exit+0x2a/0x8c
>   get_signal+0x9a/0x5f0
>   do_signal+0x86/0x23c
>   resume_user_mode_begin+0x88/0xd0
> ----------------------------------->8-------------------------------------------
>
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Thursday, June 4, 2020 14:19
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Apologies, somehow I missed your mail. I looked at the code again, and I
> think I fumbled something. Does the below diff help to prevent the issues?
>
> Thanks, Daniel
>
>
> diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> index 857812f25bec..33d812a5ad7f 100644
> --- a/drivers/gpu/drm/tiny/arcpgu.c
> +++ b/drivers/gpu/drm/tiny/arcpgu.c
> @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>         struct arcpgu_drm_private *arcpgu;
>         struct drm_gem_cma_object *gem;
>
> +       if (!pipe->plane.state->fb)
> +               return;
> +
>         arcpgu = pipe_to_arcpgu_priv(pipe);
>         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-05 19:55                         ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-05 19:55 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Eugeniy,

Thanks for testing. I looked at the second one (I hoped it would just
magically disappear) and I still don't understand what's going on
there. My patch series isn't touching that area at all, so really
confused.

I squashed in the bugfix from the previous round into the right
patches, and pushed a branch with just the arcpgu changes here:
https://cgit.freedesktop.org/~danvet/drm/log/?h=for-eugeniy

Maybe it's something in my pile of not-so-tested stuff :-)

Can you pls test this? And if it still fails, try to bisect where it breaks?

Thanks, Daniel

On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> I've tested your change and one issue gone.
>
> However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> ----------------------------------->8-------------------------------------------
> Oops
> Path: (null)
> CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> Workqueue: events drm_mode_rmfb_work_fn
> Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> BLK: drm_gem_fb_destroy+0xc0/0x130
>  SP: 0x9f055ea4  FP: 0x00000000
> LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> r12: 0x813b9b04
>
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_framebuffer_remove+0x1d2/0x358
>   drm_mode_rmfb_work_fn+0x28/0x38
>   process_one_work+0x19a/0x358
>   worker_thread+0x2c4/0x494
>   kthread+0xec/0x100
>   ret_from_fork+0x18/0x1c
> ----------------------------------->8-------------------------------------------
>
>
> The stack traces may vary but always end in drm_gem_fb_destroy:
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_mode_rmfb+0x10e/0x148
>   drm_ioctl_kernel+0x70/0xa0
>   drm_ioctl+0x284/0x410
>   ksys_ioctl+0xea/0xa3c
>   EV_Trap+0xcc/0xd0
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_fb_release+0x66/0xb0
>   drm_file_free.part.11+0x112/0x1bc
>   drm_release+0x80/0x120
>   __fput+0x98/0x1bc
>   task_work_run+0x6e/0xa8
>   do_exit+0x2b4/0x7fc
>   do_group_exit+0x2a/0x8c
>   get_signal+0x9a/0x5f0
>   do_signal+0x86/0x23c
>   resume_user_mode_begin+0x88/0xd0
> ----------------------------------->8-------------------------------------------
>
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Thursday, June 4, 2020 14:19
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Apologies, somehow I missed your mail. I looked at the code again, and I
> think I fumbled something. Does the below diff help to prevent the issues?
>
> Thanks, Daniel
>
>
> diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> index 857812f25bec..33d812a5ad7f 100644
> --- a/drivers/gpu/drm/tiny/arcpgu.c
> +++ b/drivers/gpu/drm/tiny/arcpgu.c
> @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>         struct arcpgu_drm_private *arcpgu;
>         struct drm_gem_cma_object *gem;
>
> +       if (!pipe->plane.state->fb)
> +               return;
> +
>         arcpgu = pipe_to_arcpgu_priv(pipe);
>         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-05 19:55                         ` [Intel-gfx] " Daniel Vetter
@ 2020-06-09 12:08                           ` Eugeniy Paltsev
  -1 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-09 12:08 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Daniel,

I've got pretty strange results so I need some time to investigate it and probably retest.
I'll send you update in a few days.

---
 Eugeniy Paltsev


________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Friday, June 5, 2020 22:55
To: Eugeniy Paltsev
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

Hi Eugeniy,

Thanks for testing. I looked at the second one (I hoped it would just
magically disappear) and I still don't understand what's going on
there. My patch series isn't touching that area at all, so really
confused.

I squashed in the bugfix from the previous round into the right
patches, and pushed a branch with just the arcpgu changes here:
https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$

Maybe it's something in my pile of not-so-tested stuff :-)

Can you pls test this? And if it still fails, try to bisect where it breaks?

Thanks, Daniel

On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> I've tested your change and one issue gone.
>
> However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> ----------------------------------->8-------------------------------------------
> Oops
> Path: (null)
> CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> Workqueue: events drm_mode_rmfb_work_fn
> Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> BLK: drm_gem_fb_destroy+0xc0/0x130
>  SP: 0x9f055ea4  FP: 0x00000000
> LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> r12: 0x813b9b04
>
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_framebuffer_remove+0x1d2/0x358
>   drm_mode_rmfb_work_fn+0x28/0x38
>   process_one_work+0x19a/0x358
>   worker_thread+0x2c4/0x494
>   kthread+0xec/0x100
>   ret_from_fork+0x18/0x1c
> ----------------------------------->8-------------------------------------------
>
>
> The stack traces may vary but always end in drm_gem_fb_destroy:
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_mode_rmfb+0x10e/0x148
>   drm_ioctl_kernel+0x70/0xa0
>   drm_ioctl+0x284/0x410
>   ksys_ioctl+0xea/0xa3c
>   EV_Trap+0xcc/0xd0
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_fb_release+0x66/0xb0
>   drm_file_free.part.11+0x112/0x1bc
>   drm_release+0x80/0x120
>   __fput+0x98/0x1bc
>   task_work_run+0x6e/0xa8
>   do_exit+0x2b4/0x7fc
>   do_group_exit+0x2a/0x8c
>   get_signal+0x9a/0x5f0
>   do_signal+0x86/0x23c
>   resume_user_mode_begin+0x88/0xd0
> ----------------------------------->8-------------------------------------------
>
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Thursday, June 4, 2020 14:19
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Apologies, somehow I missed your mail. I looked at the code again, and I
> think I fumbled something. Does the below diff help to prevent the issues?
>
> Thanks, Daniel
>
>
> diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> index 857812f25bec..33d812a5ad7f 100644
> --- a/drivers/gpu/drm/tiny/arcpgu.c
> +++ b/drivers/gpu/drm/tiny/arcpgu.c
> @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>         struct arcpgu_drm_private *arcpgu;
>         struct drm_gem_cma_object *gem;
>
> +       if (!pipe->plane.state->fb)
> +               return;
> +
>         arcpgu = pipe_to_arcpgu_priv(pipe);
>         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$



--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-09 12:08                           ` Eugeniy Paltsev
  0 siblings, 0 replies; 317+ messages in thread
From: Eugeniy Paltsev @ 2020-06-09 12:08 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Daniel,

I've got pretty strange results so I need some time to investigate it and probably retest.
I'll send you update in a few days.

---
 Eugeniy Paltsev


________________________________________
From: Daniel Vetter <daniel@ffwll.ch>
Sent: Friday, June 5, 2020 22:55
To: Eugeniy Paltsev
Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny

Hi Eugeniy,

Thanks for testing. I looked at the second one (I hoped it would just
magically disappear) and I still don't understand what's going on
there. My patch series isn't touching that area at all, so really
confused.

I squashed in the bugfix from the previous round into the right
patches, and pushed a branch with just the arcpgu changes here:
https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$

Maybe it's something in my pile of not-so-tested stuff :-)

Can you pls test this? And if it still fails, try to bisect where it breaks?

Thanks, Daniel

On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> I've tested your change and one issue gone.
>
> However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> ----------------------------------->8-------------------------------------------
> Oops
> Path: (null)
> CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> Workqueue: events drm_mode_rmfb_work_fn
> Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> BLK: drm_gem_fb_destroy+0xc0/0x130
>  SP: 0x9f055ea4  FP: 0x00000000
> LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> r12: 0x813b9b04
>
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_framebuffer_remove+0x1d2/0x358
>   drm_mode_rmfb_work_fn+0x28/0x38
>   process_one_work+0x19a/0x358
>   worker_thread+0x2c4/0x494
>   kthread+0xec/0x100
>   ret_from_fork+0x18/0x1c
> ----------------------------------->8-------------------------------------------
>
>
> The stack traces may vary but always end in drm_gem_fb_destroy:
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_mode_rmfb+0x10e/0x148
>   drm_ioctl_kernel+0x70/0xa0
>   drm_ioctl+0x284/0x410
>   ksys_ioctl+0xea/0xa3c
>   EV_Trap+0xcc/0xd0
> ----------------------------------->8-------------------------------------------
> Stack Trace:
>   drm_gem_fb_destroy+0x32/0x130
>   drm_fb_release+0x66/0xb0
>   drm_file_free.part.11+0x112/0x1bc
>   drm_release+0x80/0x120
>   __fput+0x98/0x1bc
>   task_work_run+0x6e/0xa8
>   do_exit+0x2b4/0x7fc
>   do_group_exit+0x2a/0x8c
>   get_signal+0x9a/0x5f0
>   do_signal+0x86/0x23c
>   resume_user_mode_begin+0x88/0xd0
> ----------------------------------->8-------------------------------------------
>
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Thursday, June 4, 2020 14:19
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Apologies, somehow I missed your mail. I looked at the code again, and I
> think I fumbled something. Does the below diff help to prevent the issues?
>
> Thanks, Daniel
>
>
> diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> index 857812f25bec..33d812a5ad7f 100644
> --- a/drivers/gpu/drm/tiny/arcpgu.c
> +++ b/drivers/gpu/drm/tiny/arcpgu.c
> @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
>         struct arcpgu_drm_private *arcpgu;
>         struct drm_gem_cma_object *gem;
>
> +       if (!pipe->plane.state->fb)
> +               return;
> +
>         arcpgu = pipe_to_arcpgu_priv(pipe);
>         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
>         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$



--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-09 12:08                           ` [Intel-gfx] " Eugeniy Paltsev
@ 2020-06-09 13:02                             ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-09 13:02 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Eugeniy,

Very much appreciated, and kinda expected. That 2nd backtrace really
confuses me, so "something strange is going on" and the bisect looks
funny is within expectations. Hopefully we can track down what's going
on.

Thanks, Daniel

On Tue, Jun 9, 2020 at 2:08 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> Hi Daniel,
>
> I've got pretty strange results so I need some time to investigate it and probably retest.
> I'll send you update in a few days.
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Friday, June 5, 2020 22:55
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Thanks for testing. I looked at the second one (I hoped it would just
> magically disappear) and I still don't understand what's going on
> there. My patch series isn't touching that area at all, so really
> confused.
>
> I squashed in the bugfix from the previous round into the right
> patches, and pushed a branch with just the arcpgu changes here:
> https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$
>
> Maybe it's something in my pile of not-so-tested stuff :-)
>
> Can you pls test this? And if it still fails, try to bisect where it breaks?
>
> Thanks, Daniel
>
> On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
> <Eugeniy.Paltsev@synopsys.com> wrote:
> >
> > I've tested your change and one issue gone.
> >
> > However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> > ----------------------------------->8-------------------------------------------
> > Oops
> > Path: (null)
> > CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> > Workqueue: events drm_mode_rmfb_work_fn
> > Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> > ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> > STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> > BLK: drm_gem_fb_destroy+0xc0/0x130
> >  SP: 0x9f055ea4  FP: 0x00000000
> > LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> > r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> > r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> > r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> > r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> > r12: 0x813b9b04
> >
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_framebuffer_remove+0x1d2/0x358
> >   drm_mode_rmfb_work_fn+0x28/0x38
> >   process_one_work+0x19a/0x358
> >   worker_thread+0x2c4/0x494
> >   kthread+0xec/0x100
> >   ret_from_fork+0x18/0x1c
> > ----------------------------------->8-------------------------------------------
> >
> >
> > The stack traces may vary but always end in drm_gem_fb_destroy:
> > ----------------------------------->8-------------------------------------------
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_mode_rmfb+0x10e/0x148
> >   drm_ioctl_kernel+0x70/0xa0
> >   drm_ioctl+0x284/0x410
> >   ksys_ioctl+0xea/0xa3c
> >   EV_Trap+0xcc/0xd0
> > ----------------------------------->8-------------------------------------------
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_fb_release+0x66/0xb0
> >   drm_file_free.part.11+0x112/0x1bc
> >   drm_release+0x80/0x120
> >   __fput+0x98/0x1bc
> >   task_work_run+0x6e/0xa8
> >   do_exit+0x2b4/0x7fc
> >   do_group_exit+0x2a/0x8c
> >   get_signal+0x9a/0x5f0
> >   do_signal+0x86/0x23c
> >   resume_user_mode_begin+0x88/0xd0
> > ----------------------------------->8-------------------------------------------
> >
> >
> > ---
> >  Eugeniy Paltsev
> >
> >
> > ________________________________________
> > From: Daniel Vetter <daniel@ffwll.ch>
> > Sent: Thursday, June 4, 2020 14:19
> > To: Eugeniy Paltsev
> > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Eugeniy,
> >
> > Apologies, somehow I missed your mail. I looked at the code again, and I
> > think I fumbled something. Does the below diff help to prevent the issues?
> >
> > Thanks, Daniel
> >
> >
> > diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> > index 857812f25bec..33d812a5ad7f 100644
> > --- a/drivers/gpu/drm/tiny/arcpgu.c
> > +++ b/drivers/gpu/drm/tiny/arcpgu.c
> > @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> >         struct arcpgu_drm_private *arcpgu;
> >         struct drm_gem_cma_object *gem;
> >
> > +       if (!pipe->plane.state->fb)
> > +               return;
> > +
> >         arcpgu = pipe_to_arcpgu_priv(pipe);
> >         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> >         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-06-09 13:02                             ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-09 13:02 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

Hi Eugeniy,

Very much appreciated, and kinda expected. That 2nd backtrace really
confuses me, so "something strange is going on" and the bisect looks
funny is within expectations. Hopefully we can track down what's going
on.

Thanks, Daniel

On Tue, Jun 9, 2020 at 2:08 PM Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> Hi Daniel,
>
> I've got pretty strange results so I need some time to investigate it and probably retest.
> I'll send you update in a few days.
>
> ---
>  Eugeniy Paltsev
>
>
> ________________________________________
> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Friday, June 5, 2020 22:55
> To: Eugeniy Paltsev
> Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
> Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
>
> Hi Eugeniy,
>
> Thanks for testing. I looked at the second one (I hoped it would just
> magically disappear) and I still don't understand what's going on
> there. My patch series isn't touching that area at all, so really
> confused.
>
> I squashed in the bugfix from the previous round into the right
> patches, and pushed a branch with just the arcpgu changes here:
> https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$
>
> Maybe it's something in my pile of not-so-tested stuff :-)
>
> Can you pls test this? And if it still fails, try to bisect where it breaks?
>
> Thanks, Daniel
>
> On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
> <Eugeniy.Paltsev@synopsys.com> wrote:
> >
> > I've tested your change and one issue gone.
> >
> > However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> > ----------------------------------->8-------------------------------------------
> > Oops
> > Path: (null)
> > CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> > Workqueue: events drm_mode_rmfb_work_fn
> > Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> > ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> > STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> > BLK: drm_gem_fb_destroy+0xc0/0x130
> >  SP: 0x9f055ea4  FP: 0x00000000
> > LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> > r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> > r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> > r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> > r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> > r12: 0x813b9b04
> >
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_framebuffer_remove+0x1d2/0x358
> >   drm_mode_rmfb_work_fn+0x28/0x38
> >   process_one_work+0x19a/0x358
> >   worker_thread+0x2c4/0x494
> >   kthread+0xec/0x100
> >   ret_from_fork+0x18/0x1c
> > ----------------------------------->8-------------------------------------------
> >
> >
> > The stack traces may vary but always end in drm_gem_fb_destroy:
> > ----------------------------------->8-------------------------------------------
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_mode_rmfb+0x10e/0x148
> >   drm_ioctl_kernel+0x70/0xa0
> >   drm_ioctl+0x284/0x410
> >   ksys_ioctl+0xea/0xa3c
> >   EV_Trap+0xcc/0xd0
> > ----------------------------------->8-------------------------------------------
> > Stack Trace:
> >   drm_gem_fb_destroy+0x32/0x130
> >   drm_fb_release+0x66/0xb0
> >   drm_file_free.part.11+0x112/0x1bc
> >   drm_release+0x80/0x120
> >   __fput+0x98/0x1bc
> >   task_work_run+0x6e/0xa8
> >   do_exit+0x2b4/0x7fc
> >   do_group_exit+0x2a/0x8c
> >   get_signal+0x9a/0x5f0
> >   do_signal+0x86/0x23c
> >   resume_user_mode_begin+0x88/0xd0
> > ----------------------------------->8-------------------------------------------
> >
> >
> > ---
> >  Eugeniy Paltsev
> >
> >
> > ________________________________________
> > From: Daniel Vetter <daniel@ffwll.ch>
> > Sent: Thursday, June 4, 2020 14:19
> > To: Eugeniy Paltsev
> > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Eugeniy,
> >
> > Apologies, somehow I missed your mail. I looked at the code again, and I
> > think I fumbled something. Does the below diff help to prevent the issues?
> >
> > Thanks, Daniel
> >
> >
> > diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> > index 857812f25bec..33d812a5ad7f 100644
> > --- a/drivers/gpu/drm/tiny/arcpgu.c
> > +++ b/drivers/gpu/drm/tiny/arcpgu.c
> > @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> >         struct arcpgu_drm_private *arcpgu;
> >         struct drm_gem_cma_object *gem;
> >
> > +       if (!pipe->plane.state->fb)
> > +               return;
> > +
> >         arcpgu = pipe_to_arcpgu_priv(pipe);
> >         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> >         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
@ 2020-06-11 12:04     ` Thomas Zimmermann
  -1 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-06-11 12:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Christian König, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 2552 bytes --]

Hi

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Allows us to remove a bit of cleanup code.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: "Noralf Trønnes" <noralf@tronnes.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for answering my questions. Sorry for never getting back to it.

Best regards
Thomas

> ---
>  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
>  drivers/gpu/drm/ast/ast_main.c |  3 ---
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index b7ba22dddcad..48a9cc4e080a 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	ast_kick_out_firmware_fb(pdev);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	dev = drm_dev_alloc(&driver, &pdev->dev);
> -	if (IS_ERR(dev)) {
> -		ret = PTR_ERR(dev);
> -		goto err_pci_disable_device;
> -	}
> +	if (IS_ERR(dev))
> +		return  PTR_ERR(dev);
>  
>  	dev->pdev = pdev;
>  	pci_set_drvdata(pdev, dev);
> @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	ast_driver_unload(dev);
>  err_drm_dev_put:
>  	drm_dev_put(dev);
> -err_pci_disable_device:
> -	pci_disable_device(pdev);
>  	return ret;
>  
>  }
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index e5398e3dabe7..1b35728ad871 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
>  	drm_mode_config_cleanup(dev);
>  
>  	ast_mm_fini(ast);
> -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> -		pci_iounmap(dev->pdev, ast->ioregs);
> -	pci_iounmap(dev->pdev, ast->regs);
>  	kfree(ast);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-06-11 12:04     ` Thomas Zimmermann
  0 siblings, 0 replies; 317+ messages in thread
From: Thomas Zimmermann @ 2020-06-11 12:04 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development
  Cc: DRI Development, Gerd Hoffmann, Dave Airlie, Daniel Vetter,
	Sam Ravnborg, Christian König, Emil Velikov


[-- Attachment #1.1.1: Type: text/plain, Size: 2552 bytes --]

Hi

Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> Allows us to remove a bit of cleanup code.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: "Noralf Trønnes" <noralf@tronnes.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Christian König" <christian.koenig@amd.com>
> Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for answering my questions. Sorry for never getting back to it.

Best regards
Thomas

> ---
>  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
>  drivers/gpu/drm/ast/ast_main.c |  3 ---
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index b7ba22dddcad..48a9cc4e080a 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	ast_kick_out_firmware_fb(pdev);
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
>  	dev = drm_dev_alloc(&driver, &pdev->dev);
> -	if (IS_ERR(dev)) {
> -		ret = PTR_ERR(dev);
> -		goto err_pci_disable_device;
> -	}
> +	if (IS_ERR(dev))
> +		return  PTR_ERR(dev);
>  
>  	dev->pdev = pdev;
>  	pci_set_drvdata(pdev, dev);
> @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	ast_driver_unload(dev);
>  err_drm_dev_put:
>  	drm_dev_put(dev);
> -err_pci_disable_device:
> -	pci_disable_device(pdev);
>  	return ret;
>  
>  }
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index e5398e3dabe7..1b35728ad871 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
>  	drm_mode_config_cleanup(dev);
>  
>  	ast_mm_fini(ast);
> -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> -		pci_iounmap(dev->pdev, ast->ioregs);
> -	pci_iounmap(dev->pdev, ast->regs);
>  	kfree(ast);
>  }
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 57/59] drm/ast: Use managed pci functions
  2020-06-11 12:04     ` [Intel-gfx] " Thomas Zimmermann
@ 2020-06-16 11:55       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-16 11:55 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie, Sam Ravnborg,
	Christian König, Emil Velikov

On Thu, Jun 11, 2020 at 02:04:03PM +0200, Thomas Zimmermann wrote:
> Hi
> 
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Allows us to remove a bit of cleanup code.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.velikov@collabora.com>
> > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> Thanks for answering my questions. Sorry for never getting back to it.

Nw, patch applied now, thanks for your review.
-Daniel

> 
> Best regards
> Thomas
> 
> > ---
> >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> >  2 files changed, 3 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > index b7ba22dddcad..48a9cc4e080a 100644
> > --- a/drivers/gpu/drm/ast/ast_drv.c
> > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  
> >  	ast_kick_out_firmware_fb(pdev);
> >  
> > -	ret = pci_enable_device(pdev);
> > +	ret = pcim_enable_device(pdev);
> >  	if (ret)
> >  		return ret;
> >  
> >  	dev = drm_dev_alloc(&driver, &pdev->dev);
> > -	if (IS_ERR(dev)) {
> > -		ret = PTR_ERR(dev);
> > -		goto err_pci_disable_device;
> > -	}
> > +	if (IS_ERR(dev))
> > +		return  PTR_ERR(dev);
> >  
> >  	dev->pdev = pdev;
> >  	pci_set_drvdata(pdev, dev);
> > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  	ast_driver_unload(dev);
> >  err_drm_dev_put:
> >  	drm_dev_put(dev);
> > -err_pci_disable_device:
> > -	pci_disable_device(pdev);
> >  	return ret;
> >  
> >  }
> > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > index e5398e3dabe7..1b35728ad871 100644
> > --- a/drivers/gpu/drm/ast/ast_main.c
> > +++ b/drivers/gpu/drm/ast/ast_main.c
> > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> >  	drm_mode_config_cleanup(dev);
> >  
> >  	ast_mm_fini(ast);
> > -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > -		pci_iounmap(dev->pdev, ast->ioregs);
> > -	pci_iounmap(dev->pdev, ast->regs);
> >  	kfree(ast);
> >  }
> > 
> 
> -- 
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
> 




-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 57/59] drm/ast: Use managed pci functions
@ 2020-06-16 11:55       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-06-16 11:55 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Gerd Hoffmann, Daniel Vetter, Dave Airlie, Sam Ravnborg,
	Christian König, Emil Velikov

On Thu, Jun 11, 2020 at 02:04:03PM +0200, Thomas Zimmermann wrote:
> Hi
> 
> Am 15.04.20 um 09:40 schrieb Daniel Vetter:
> > Allows us to remove a bit of cleanup code.
> > 
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Dave Airlie <airlied@redhat.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.velikov@collabora.com>
> > Cc: "Noralf Trønnes" <noralf@tronnes.org>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: "Christian König" <christian.koenig@amd.com>
> > Cc: "Y.C. Chen" <yc_chen@aspeedtech.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> Thanks for answering my questions. Sorry for never getting back to it.

Nw, patch applied now, thanks for your review.
-Daniel

> 
> Best regards
> Thomas
> 
> > ---
> >  drivers/gpu/drm/ast/ast_drv.c  | 10 +++-------
> >  drivers/gpu/drm/ast/ast_main.c |  3 ---
> >  2 files changed, 3 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> > index b7ba22dddcad..48a9cc4e080a 100644
> > --- a/drivers/gpu/drm/ast/ast_drv.c
> > +++ b/drivers/gpu/drm/ast/ast_drv.c
> > @@ -91,15 +91,13 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  
> >  	ast_kick_out_firmware_fb(pdev);
> >  
> > -	ret = pci_enable_device(pdev);
> > +	ret = pcim_enable_device(pdev);
> >  	if (ret)
> >  		return ret;
> >  
> >  	dev = drm_dev_alloc(&driver, &pdev->dev);
> > -	if (IS_ERR(dev)) {
> > -		ret = PTR_ERR(dev);
> > -		goto err_pci_disable_device;
> > -	}
> > +	if (IS_ERR(dev))
> > +		return  PTR_ERR(dev);
> >  
> >  	dev->pdev = pdev;
> >  	pci_set_drvdata(pdev, dev);
> > @@ -120,8 +118,6 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >  	ast_driver_unload(dev);
> >  err_drm_dev_put:
> >  	drm_dev_put(dev);
> > -err_pci_disable_device:
> > -	pci_disable_device(pdev);
> >  	return ret;
> >  
> >  }
> > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> > index e5398e3dabe7..1b35728ad871 100644
> > --- a/drivers/gpu/drm/ast/ast_main.c
> > +++ b/drivers/gpu/drm/ast/ast_main.c
> > @@ -531,8 +531,5 @@ void ast_driver_unload(struct drm_device *dev)
> >  	drm_mode_config_cleanup(dev);
> >  
> >  	ast_mm_fini(ast);
> > -	if (ast->ioregs != ast->regs + AST_IO_MM_OFFSET)
> > -		pci_iounmap(dev->pdev, ast->ioregs);
> > -	pci_iounmap(dev->pdev, ast->regs);
> >  	kfree(ast);
> >  }
> > 
> 
> -- 
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
> 




-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 53/59] drm/arc: Move to drm/tiny
  2020-06-09 13:02                             ` [Intel-gfx] " Daniel Vetter
@ 2020-07-17  9:04                               ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-07-17  9:04 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

On Tue, Jun 09, 2020 at 03:02:14PM +0200, Daniel Vetter wrote:
> Hi Eugeniy,
> 
> Very much appreciated, and kinda expected. That 2nd backtrace really
> confuses me, so "something strange is going on" and the bisect looks
> funny is within expectations. Hopefully we can track down what's going
> on.

I'm going to resend the entire pile with the bugfix below and all rebased,
I think retesting it all is probably a good idea now, since quite some
time passed.

Cheers, Daniel

> 
> Thanks, Daniel
> 
> On Tue, Jun 9, 2020 at 2:08 PM Eugeniy Paltsev
> <Eugeniy.Paltsev@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > I've got pretty strange results so I need some time to investigate it and probably retest.
> > I'll send you update in a few days.
> >
> > ---
> >  Eugeniy Paltsev
> >
> >
> > ________________________________________
> > From: Daniel Vetter <daniel@ffwll.ch>
> > Sent: Friday, June 5, 2020 22:55
> > To: Eugeniy Paltsev
> > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Eugeniy,
> >
> > Thanks for testing. I looked at the second one (I hoped it would just
> > magically disappear) and I still don't understand what's going on
> > there. My patch series isn't touching that area at all, so really
> > confused.
> >
> > I squashed in the bugfix from the previous round into the right
> > patches, and pushed a branch with just the arcpgu changes here:
> > https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$
> >
> > Maybe it's something in my pile of not-so-tested stuff :-)
> >
> > Can you pls test this? And if it still fails, try to bisect where it breaks?
> >
> > Thanks, Daniel
> >
> > On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
> > <Eugeniy.Paltsev@synopsys.com> wrote:
> > >
> > > I've tested your change and one issue gone.
> > >
> > > However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> > > ----------------------------------->8-------------------------------------------
> > > Oops
> > > Path: (null)
> > > CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> > > Workqueue: events drm_mode_rmfb_work_fn
> > > Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> > > ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> > > STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> > > BLK: drm_gem_fb_destroy+0xc0/0x130
> > >  SP: 0x9f055ea4  FP: 0x00000000
> > > LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> > > r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> > > r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> > > r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> > > r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> > > r12: 0x813b9b04
> > >
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_framebuffer_remove+0x1d2/0x358
> > >   drm_mode_rmfb_work_fn+0x28/0x38
> > >   process_one_work+0x19a/0x358
> > >   worker_thread+0x2c4/0x494
> > >   kthread+0xec/0x100
> > >   ret_from_fork+0x18/0x1c
> > > ----------------------------------->8-------------------------------------------
> > >
> > >
> > > The stack traces may vary but always end in drm_gem_fb_destroy:
> > > ----------------------------------->8-------------------------------------------
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_mode_rmfb+0x10e/0x148
> > >   drm_ioctl_kernel+0x70/0xa0
> > >   drm_ioctl+0x284/0x410
> > >   ksys_ioctl+0xea/0xa3c
> > >   EV_Trap+0xcc/0xd0
> > > ----------------------------------->8-------------------------------------------
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_fb_release+0x66/0xb0
> > >   drm_file_free.part.11+0x112/0x1bc
> > >   drm_release+0x80/0x120
> > >   __fput+0x98/0x1bc
> > >   task_work_run+0x6e/0xa8
> > >   do_exit+0x2b4/0x7fc
> > >   do_group_exit+0x2a/0x8c
> > >   get_signal+0x9a/0x5f0
> > >   do_signal+0x86/0x23c
> > >   resume_user_mode_begin+0x88/0xd0
> > > ----------------------------------->8-------------------------------------------
> > >
> > >
> > > ---
> > >  Eugeniy Paltsev
> > >
> > >
> > > ________________________________________
> > > From: Daniel Vetter <daniel@ffwll.ch>
> > > Sent: Thursday, June 4, 2020 14:19
> > > To: Eugeniy Paltsev
> > > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> > > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> > >
> > > Hi Eugeniy,
> > >
> > > Apologies, somehow I missed your mail. I looked at the code again, and I
> > > think I fumbled something. Does the below diff help to prevent the issues?
> > >
> > > Thanks, Daniel
> > >
> > >
> > > diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> > > index 857812f25bec..33d812a5ad7f 100644
> > > --- a/drivers/gpu/drm/tiny/arcpgu.c
> > > +++ b/drivers/gpu/drm/tiny/arcpgu.c
> > > @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> > >         struct arcpgu_drm_private *arcpgu;
> > >         struct drm_gem_cma_object *gem;
> > >
> > > +       if (!pipe->plane.state->fb)
> > > +               return;
> > > +
> > >         arcpgu = pipe_to_arcpgu_priv(pipe);
> > >         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> > >         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> > > --
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
> >
> >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$
> 
> 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 53/59] drm/arc: Move to drm/tiny
@ 2020-07-17  9:04                               ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-07-17  9:04 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Intel Graphics Development, Alexey Brodkin, DRI Development,
	Daniel Vetter, Sam Ravnborg, snps-arc

On Tue, Jun 09, 2020 at 03:02:14PM +0200, Daniel Vetter wrote:
> Hi Eugeniy,
> 
> Very much appreciated, and kinda expected. That 2nd backtrace really
> confuses me, so "something strange is going on" and the bisect looks
> funny is within expectations. Hopefully we can track down what's going
> on.

I'm going to resend the entire pile with the bugfix below and all rebased,
I think retesting it all is probably a good idea now, since quite some
time passed.

Cheers, Daniel

> 
> Thanks, Daniel
> 
> On Tue, Jun 9, 2020 at 2:08 PM Eugeniy Paltsev
> <Eugeniy.Paltsev@synopsys.com> wrote:
> >
> > Hi Daniel,
> >
> > I've got pretty strange results so I need some time to investigate it and probably retest.
> > I'll send you update in a few days.
> >
> > ---
> >  Eugeniy Paltsev
> >
> >
> > ________________________________________
> > From: Daniel Vetter <daniel@ffwll.ch>
> > Sent: Friday, June 5, 2020 22:55
> > To: Eugeniy Paltsev
> > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin; snps-arc@lists.infradead.org
> > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> >
> > Hi Eugeniy,
> >
> > Thanks for testing. I looked at the second one (I hoped it would just
> > magically disappear) and I still don't understand what's going on
> > there. My patch series isn't touching that area at all, so really
> > confused.
> >
> > I squashed in the bugfix from the previous round into the right
> > patches, and pushed a branch with just the arcpgu changes here:
> > https://urldefense.com/v3/__https://cgit.freedesktop.org/*danvet/drm/log/?h=for-eugeniy__;fg!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXIVqH5pM$
> >
> > Maybe it's something in my pile of not-so-tested stuff :-)
> >
> > Can you pls test this? And if it still fails, try to bisect where it breaks?
> >
> > Thanks, Daniel
> >
> > On Thu, Jun 4, 2020 at 9:00 PM Eugeniy Paltsev
> > <Eugeniy.Paltsev@synopsys.com> wrote:
> > >
> > > I've tested your change and one issue gone.
> > >
> > > However I still see kernel crash (due to invalid read in kernel mode by 0x0 address) on weston stop:
> > > ----------------------------------->8-------------------------------------------
> > > Oops
> > > Path: (null)
> > > CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.7.0-rc6-01594-g4ceda91a4176-dirty #6
> > > Workqueue: events drm_mode_rmfb_work_fn
> > > Invalid Read @ 0x00000000 by insn @ drm_gem_fb_destroy+0x32/0x130
> > > ECR: 0x00050100 EFA: 0x00000000 ERET: 0x813b9a76
> > > STAT32: 0x80080602 [IE K     ]  BTA: 0x813b9a72
> > > BLK: drm_gem_fb_destroy+0xc0/0x130
> > >  SP: 0x9f055ea4  FP: 0x00000000
> > > LPS: 0x813560ec LPE: 0x813560f0 LPC: 0x00000000
> > > r00: 0x00000000 r01: 0x9f6a6100 r02: 0x00000001
> > > r03: 0x9fd5dde8 r04: 0x810f5de8 r05: 0x00000000
> > > r06: 0x00000000 r07: 0x00000000 r08: 0x000000e1
> > > r09: 0x00000000 r10: 0x00000000 r11: 0x000000e1
> > > r12: 0x813b9b04
> > >
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_framebuffer_remove+0x1d2/0x358
> > >   drm_mode_rmfb_work_fn+0x28/0x38
> > >   process_one_work+0x19a/0x358
> > >   worker_thread+0x2c4/0x494
> > >   kthread+0xec/0x100
> > >   ret_from_fork+0x18/0x1c
> > > ----------------------------------->8-------------------------------------------
> > >
> > >
> > > The stack traces may vary but always end in drm_gem_fb_destroy:
> > > ----------------------------------->8-------------------------------------------
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_mode_rmfb+0x10e/0x148
> > >   drm_ioctl_kernel+0x70/0xa0
> > >   drm_ioctl+0x284/0x410
> > >   ksys_ioctl+0xea/0xa3c
> > >   EV_Trap+0xcc/0xd0
> > > ----------------------------------->8-------------------------------------------
> > > Stack Trace:
> > >   drm_gem_fb_destroy+0x32/0x130
> > >   drm_fb_release+0x66/0xb0
> > >   drm_file_free.part.11+0x112/0x1bc
> > >   drm_release+0x80/0x120
> > >   __fput+0x98/0x1bc
> > >   task_work_run+0x6e/0xa8
> > >   do_exit+0x2b4/0x7fc
> > >   do_group_exit+0x2a/0x8c
> > >   get_signal+0x9a/0x5f0
> > >   do_signal+0x86/0x23c
> > >   resume_user_mode_begin+0x88/0xd0
> > > ----------------------------------->8-------------------------------------------
> > >
> > >
> > > ---
> > >  Eugeniy Paltsev
> > >
> > >
> > > ________________________________________
> > > From: Daniel Vetter <daniel@ffwll.ch>
> > > Sent: Thursday, June 4, 2020 14:19
> > > To: Eugeniy Paltsev
> > > Cc: Intel Graphics Development; DRI Development; Daniel Vetter; Sam Ravnborg; Alexey Brodkin
> > > Subject: Re: [PATCH 53/59] drm/arc: Move to drm/tiny
> > >
> > > Hi Eugeniy,
> > >
> > > Apologies, somehow I missed your mail. I looked at the code again, and I
> > > think I fumbled something. Does the below diff help to prevent the issues?
> > >
> > > Thanks, Daniel
> > >
> > >
> > > diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
> > > index 857812f25bec..33d812a5ad7f 100644
> > > --- a/drivers/gpu/drm/tiny/arcpgu.c
> > > +++ b/drivers/gpu/drm/tiny/arcpgu.c
> > > @@ -228,6 +228,9 @@ static void arc_pgu_update(struct drm_simple_display_pipe *pipe,
> > >         struct arcpgu_drm_private *arcpgu;
> > >         struct drm_gem_cma_object *gem;
> > >
> > > +       if (!pipe->plane.state->fb)
> > > +               return;
> > > +
> > >         arcpgu = pipe_to_arcpgu_priv(pipe);
> > >         gem = drm_fb_cma_get_gem_obj(pipe->plane.state->fb, 0);
> > >         arc_pgu_write(arcpgu, ARCPGU_REG_BUF0_ADDR, gem->paddr);
> > > --
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!P0EvyJfMuDwqbeZmHZM5S9po30QWr4KgGrggRirNfgo7wrRXfnUO-8iq0AA4fQCW2WGPlDc$
> >
> >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > +41 (0) 79 365 57 48 - https://urldefense.com/v3/__http://blog.ffwll.ch__;!!A4F2R9G_pg!IJ1o4XiXVdStPu--Q-SCTUpRbsbqrjX255R34nuD7L7ptPywOy4SKr21dwSpfOkXpn86Q20$
> 
> 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
  2020-04-24 16:46     ` [Intel-gfx] " Sam Ravnborg
@ 2020-09-04 13:42       ` Daniel Vetter
  -1 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-09-04 13:42 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Fri, Apr 24, 2020 at 6:46 PM Sam Ravnborg <sam@ravnborg.org> wrote:
>
> Hi Daniel.
>
> On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> > Upcasting using a container_of macro is more typesafe, faster and
> > easier for the compiler to optimize.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
>
> Subject: drm/arc: arcpgu: Stop using drm_device->dev_private
>
> And another bikeshedding below.
> With this considered:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>
> > ---
> >  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
> >  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
> >  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
> >  3 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> > index cd9e932f501e..87821c91a00c 100644
> > --- a/drivers/gpu/drm/arc/arcpgu.h
> > +++ b/drivers/gpu/drm/arc/arcpgu.h
> > @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
> >       struct drm_plane        *plane;
> >  };
> >
> > +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> > +
> Preferred name is to_arcgpu(). There is no device in the name of struct
> arcpgu_drm_private. And the general consensus it to use to_<driver> for
> the top-level struct.

[Sorry just realized I never replied on-list for this here]

drm_device very much has a dev_  and there's some other drivders with
this pattern too. Plus I think it's more consistent with the other
macros in here. For simple drivers where there's only 1 structure I
agree though, so if you insist I can follow up with a patch. Fixing
this in-series is imo too much trouble for the benefit, every single
patch would need to be redone ...

Cheers, Daniel

>
> >  #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
> >
> >  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> > diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > index be7c29cec318..ba796a216244 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > @@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
> >
> >  static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> >  {
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       struct drm_plane *plane = NULL;
> >       int ret;
> >
> > @@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> >
> >  int arc_pgu_setup_crtc(struct drm_device *drm)
> >  {
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       struct drm_plane *primary;
> >       int ret;
> >
> > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> > index bbd7acb150f3..81b8d7ae6623 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> > @@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> >       struct resource *res;
> >       int ret;
> >
> > -     drm->dev_private = arcpgu;
> > -
> >       arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
> >       if (IS_ERR(arcpgu->clk))
> >               return PTR_ERR(arcpgu->clk);
> > @@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
> >  {
> >       struct drm_info_node *node = (struct drm_info_node *)m->private;
> >       struct drm_device *drm = node->minor->dev;
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       unsigned long clkrate = clk_get_rate(arcpgu->clk);
> >       unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
> >
> > --
> > 2.25.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
@ 2020-09-04 13:42       ` Daniel Vetter
  0 siblings, 0 replies; 317+ messages in thread
From: Daniel Vetter @ 2020-09-04 13:42 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

On Fri, Apr 24, 2020 at 6:46 PM Sam Ravnborg <sam@ravnborg.org> wrote:
>
> Hi Daniel.
>
> On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> > Upcasting using a container_of macro is more typesafe, faster and
> > easier for the compiler to optimize.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Alexey Brodkin <abrodkin@synopsys.com>
>
> Subject: drm/arc: arcpgu: Stop using drm_device->dev_private
>
> And another bikeshedding below.
> With this considered:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>
> > ---
> >  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
> >  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
> >  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
> >  3 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> > index cd9e932f501e..87821c91a00c 100644
> > --- a/drivers/gpu/drm/arc/arcpgu.h
> > +++ b/drivers/gpu/drm/arc/arcpgu.h
> > @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
> >       struct drm_plane        *plane;
> >  };
> >
> > +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> > +
> Preferred name is to_arcgpu(). There is no device in the name of struct
> arcpgu_drm_private. And the general consensus it to use to_<driver> for
> the top-level struct.

[Sorry just realized I never replied on-list for this here]

drm_device very much has a dev_  and there's some other drivders with
this pattern too. Plus I think it's more consistent with the other
macros in here. For simple drivers where there's only 1 structure I
agree though, so if you insist I can follow up with a patch. Fixing
this in-series is imo too much trouble for the benefit, every single
patch would need to be redone ...

Cheers, Daniel

>
> >  #define crtc_to_arcpgu_priv(x) container_of(x, struct arcpgu_drm_private, crtc)
> >
> >  static inline void arc_pgu_write(struct arcpgu_drm_private *arcpgu,
> > diff --git a/drivers/gpu/drm/arc/arcpgu_crtc.c b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > index be7c29cec318..ba796a216244 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_crtc.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_crtc.c
> > @@ -178,7 +178,7 @@ static const struct drm_plane_funcs arc_pgu_plane_funcs = {
> >
> >  static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> >  {
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       struct drm_plane *plane = NULL;
> >       int ret;
> >
> > @@ -202,7 +202,7 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
> >
> >  int arc_pgu_setup_crtc(struct drm_device *drm)
> >  {
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       struct drm_plane *primary;
> >       int ret;
> >
> > diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
> > index bbd7acb150f3..81b8d7ae6623 100644
> > --- a/drivers/gpu/drm/arc/arcpgu_drv.c
> > +++ b/drivers/gpu/drm/arc/arcpgu_drv.c
> > @@ -50,8 +50,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
> >       struct resource *res;
> >       int ret;
> >
> > -     drm->dev_private = arcpgu;
> > -
> >       arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
> >       if (IS_ERR(arcpgu->clk))
> >               return PTR_ERR(arcpgu->clk);
> > @@ -120,7 +118,7 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
> >  {
> >       struct drm_info_node *node = (struct drm_info_node *)m->private;
> >       struct drm_device *drm = node->minor->dev;
> > -     struct arcpgu_drm_private *arcpgu = drm->dev_private;
> > +     struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
> >       unsigned long clkrate = clk_get_rate(arcpgu->clk);
> >       unsigned long mode_clock = arcpgu->crtc.mode.crtc_clock * 1000;
> >
> > --
> > 2.25.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
  2020-09-04 13:42       ` [Intel-gfx] " Daniel Vetter
@ 2020-09-04 14:42         ` Sam Ravnborg
  -1 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-09-04 14:42 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Fri, Sep 04, 2020 at 03:42:44PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 6:46 PM Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > Hi Daniel.
> >
> > On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> > > Upcasting using a container_of macro is more typesafe, faster and
> > > easier for the compiler to optimize.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> >
> > Subject: drm/arc: arcpgu: Stop using drm_device->dev_private
> >
> > And another bikeshedding below.
> > With this considered:
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> >
> > > ---
> > >  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
> > >  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
> > >  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
> > >  3 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> > > index cd9e932f501e..87821c91a00c 100644
> > > --- a/drivers/gpu/drm/arc/arcpgu.h
> > > +++ b/drivers/gpu/drm/arc/arcpgu.h
> > > @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
> > >       struct drm_plane        *plane;
> > >  };
> > >
> > > +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> > > +
> > Preferred name is to_arcgpu(). There is no device in the name of struct
> > arcpgu_drm_private. And the general consensus it to use to_<driver> for
> > the top-level struct.
> 
> [Sorry just realized I never replied on-list for this here]
> 
> drm_device very much has a dev_  and there's some other drivders with
> this pattern too. Plus I think it's more consistent with the other
> macros in here. For simple drivers where there's only 1 structure I
> agree though, so if you insist I can follow up with a patch. Fixing
> this in-series is imo too much trouble for the benefit, every single
> patch would need to be redone ...

The naming is my personal choice - others have different opinions.
And since we did not universially agree on dev_to_* versus to_* for the
main driver structure there is no need to adjust.

For me it is just that the main driver structure is more than a device
thingy and I like the short naming. But it seems you, Thomas + more
prefer dev_to_* so maybe I should adjust so we are a little more
aligned.

So it is considered so the patch is obviously:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 317+ messages in thread

* Re: [Intel-gfx] [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private
@ 2020-09-04 14:42         ` Sam Ravnborg
  0 siblings, 0 replies; 317+ messages in thread
From: Sam Ravnborg @ 2020-09-04 14:42 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, Intel Graphics Development, Alexey Brodkin,
	DRI Development

Hi Daniel.

On Fri, Sep 04, 2020 at 03:42:44PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 6:46 PM Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > Hi Daniel.
> >
> > On Wed, Apr 15, 2020 at 09:40:15AM +0200, Daniel Vetter wrote:
> > > Upcasting using a container_of macro is more typesafe, faster and
> > > easier for the compiler to optimize.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> >
> > Subject: drm/arc: arcpgu: Stop using drm_device->dev_private
> >
> > And another bikeshedding below.
> > With this considered:
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> >
> > > ---
> > >  drivers/gpu/drm/arc/arcpgu.h      | 2 ++
> > >  drivers/gpu/drm/arc/arcpgu_crtc.c | 4 ++--
> > >  drivers/gpu/drm/arc/arcpgu_drv.c  | 4 +---
> > >  3 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/arc/arcpgu.h b/drivers/gpu/drm/arc/arcpgu.h
> > > index cd9e932f501e..87821c91a00c 100644
> > > --- a/drivers/gpu/drm/arc/arcpgu.h
> > > +++ b/drivers/gpu/drm/arc/arcpgu.h
> > > @@ -17,6 +17,8 @@ struct arcpgu_drm_private {
> > >       struct drm_plane        *plane;
> > >  };
> > >
> > > +#define dev_to_arcpgu(x) container_of(x, struct arcpgu_drm_private, drm)
> > > +
> > Preferred name is to_arcgpu(). There is no device in the name of struct
> > arcpgu_drm_private. And the general consensus it to use to_<driver> for
> > the top-level struct.
> 
> [Sorry just realized I never replied on-list for this here]
> 
> drm_device very much has a dev_  and there's some other drivders with
> this pattern too. Plus I think it's more consistent with the other
> macros in here. For simple drivers where there's only 1 structure I
> agree though, so if you insist I can follow up with a patch. Fixing
> this in-series is imo too much trouble for the benefit, every single
> patch would need to be redone ...

The naming is my personal choice - others have different opinions.
And since we did not universially agree on dev_to_* versus to_* for the
main driver structure there is no need to adjust.

For me it is just that the main driver structure is more than a device
thingy and I like the short naming. But it seems you, Thomas + more
prefer dev_to_* so maybe I should adjust so we are a little more
aligned.

So it is considered so the patch is obviously:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 317+ messages in thread

end of thread, other threads:[~2020-09-04 14:42 UTC | newest]

Thread overview: 317+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15  7:39 [PATCH 00/59] devm_drm_dev_alloc, v2 Daniel Vetter
2020-04-15  7:39 ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 01/59] drm: Add devm_drm_dev_alloc macro Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-20 13:36   ` Thomas Zimmermann
2020-04-20 13:36     ` [Intel-gfx] " Thomas Zimmermann
2020-04-21 10:45     ` Daniel Vetter
2020-04-21 10:45       ` [Intel-gfx] " Daniel Vetter
2020-04-21 14:03       ` Thomas Zimmermann
2020-04-21 14:03         ` [Intel-gfx] " Thomas Zimmermann
2020-04-21 20:32         ` Sam Ravnborg
2020-04-21 20:32           ` [Intel-gfx] " Sam Ravnborg
2020-04-28 13:06           ` Daniel Vetter
2020-04-28 13:06             ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 02/59] drm/vboxvideo: drop DRM_MTRR_WC #define Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:01   ` Hans de Goede
2020-04-15 15:01     ` [Intel-gfx] " Hans de Goede
2020-04-15  7:39 ` [PATCH 03/59] drm/vboxvideo: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:02   ` Hans de Goede
2020-04-15 15:02     ` [Intel-gfx] " Hans de Goede
2020-04-24 16:33   ` Sam Ravnborg
2020-04-24 16:33     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:39 ` [PATCH 04/59] drm/vboxvideo: Stop using drm_device->dev_private Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:02   ` Hans de Goede
2020-04-15 15:02     ` [Intel-gfx] " Hans de Goede
2020-04-15  7:39 ` [PATCH 05/59] drm/vboxvidoe: use managed pci functions Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:03   ` Hans de Goede
2020-04-15 15:03     ` [Intel-gfx] " Hans de Goede
2020-04-15 17:44     ` Daniel Vetter
2020-04-15 17:44       ` [Intel-gfx] " Daniel Vetter
2020-04-20 13:16       ` Hans de Goede
2020-04-20 13:16         ` [Intel-gfx] " Hans de Goede
2020-04-15 17:32   ` Thomas Zimmermann
2020-04-15 17:32     ` [Intel-gfx] " Thomas Zimmermann
2020-04-15  7:39 ` [PATCH 06/59] drm/vboxvideo: Use devm_gen_pool_create Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:04   ` Hans de Goede
2020-04-15 15:04     ` [Intel-gfx] " Hans de Goede
2020-04-15  7:39 ` [PATCH 07/59] drm/v3d: Don't set drm_device->dev_private Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 08/59] drm/v3d: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 09/59] drm/v3d: Delete v3d_dev->dev Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 10/59] drm/v3d: Delete v3d_dev->pdev Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 11/59] drm/udl: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:55   ` Thomas Zimmermann
2020-04-15  7:55     ` [Intel-gfx] " Thomas Zimmermann
2020-04-24 14:55   ` Sam Ravnborg
2020-04-24 14:55     ` [Intel-gfx] " Sam Ravnborg
2020-04-28 13:18     ` Daniel Vetter
2020-04-28 13:18       ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 12/59] drm/udl: don't set drm_device->dev_private Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 13/59] drm/st7735r: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 14/59] drm/st7586: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 15/59] drm/repaper: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 16/59] drm/mi0283qt: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 17/59] drm/ili9486: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 18/59] drm/ili9341: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 19/59] drm/ili9225: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 20/59] drm/hx8357d: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:39 ` [PATCH 21/59] drm/gm12u320: " Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:04   ` Hans de Goede
2020-04-15 15:04     ` [Intel-gfx] " Hans de Goede
2020-04-15  7:39 ` [PATCH 22/59] drm/gm12u320: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-15 15:05   ` Hans de Goede
2020-04-15 15:05     ` [Intel-gfx] " Hans de Goede
2020-04-15  7:39 ` [PATCH 23/59] drm/tidss: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-21 11:03   ` Tomi Valkeinen
2020-04-21 11:03     ` [Intel-gfx] " Tomi Valkeinen
2020-04-15  7:39 ` [PATCH 24/59] drm/tidss: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:39   ` [Intel-gfx] " Daniel Vetter
2020-04-21 11:05   ` Tomi Valkeinen
2020-04-21 11:05     ` [Intel-gfx] " Tomi Valkeinen
2020-04-15  7:40 ` [PATCH 25/59] drm/tidss: Delete tidss->saved_state Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-21 11:05   ` Tomi Valkeinen
2020-04-21 11:05     ` [Intel-gfx] " Tomi Valkeinen
2020-04-15  7:40 ` [PATCH 26/59] drm/qxl: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-24 15:09   ` Sam Ravnborg
2020-04-24 15:09     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 15:09     ` Sam Ravnborg
2020-04-28 14:00     ` Daniel Vetter
2020-04-28 14:00       ` [Intel-gfx] " Daniel Vetter
2020-04-28 14:00       ` Daniel Vetter
2020-04-28 17:00       ` Sam Ravnborg
2020-04-28 17:00         ` [Intel-gfx] " Sam Ravnborg
2020-04-28 17:00         ` Sam Ravnborg
2020-04-28 18:04         ` Daniel Vetter
2020-04-28 18:04           ` [Intel-gfx] " Daniel Vetter
2020-04-28 18:04           ` Daniel Vetter
2020-04-15  7:40 ` [PATCH 27/59] drm/qxl: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-24 15:12   ` Sam Ravnborg
2020-04-24 15:12     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 15:12     ` Sam Ravnborg
2020-04-15  7:40 ` [PATCH 28/59] drm/mcde: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15 12:20   ` Linus Walleij
2020-04-15 12:20     ` [Intel-gfx] " Linus Walleij
2020-04-15  7:40 ` [PATCH 29/59] drm/mcde: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 30/59] drm/ingenic: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 31/59] drm/ingenic: Don't set drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 32/59] drm/komeda: use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 33/59] drm/armada: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 34/59] drm/armada: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 35/59] drm/cirrus: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-15  7:40 ` [PATCH 36/59] drm/cirrus: Don't use drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-15  7:40 ` [PATCH 37/59] drm/cirrus: Move to drm/tiny Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-15  8:01   ` Thomas Zimmermann
2020-04-15  8:01     ` [Intel-gfx] " Thomas Zimmermann
2020-04-15  8:01     ` Thomas Zimmermann
2020-04-15  8:19     ` Daniel Vetter
2020-04-15  8:19       ` [Intel-gfx] " Daniel Vetter
2020-04-15  8:19       ` Daniel Vetter
2020-04-15  8:46       ` Thomas Zimmermann
2020-04-15  8:46         ` [Intel-gfx] " Thomas Zimmermann
2020-04-15  8:46         ` Thomas Zimmermann
2020-04-15  9:31         ` Daniel Vetter
2020-04-15  9:31           ` [Intel-gfx] " Daniel Vetter
2020-04-15  9:31           ` Daniel Vetter
2020-04-21  7:37   ` Gerd Hoffmann
2020-04-21  7:37     ` [Intel-gfx] " Gerd Hoffmann
2020-04-21  7:37     ` Gerd Hoffmann
2020-04-24 16:37   ` Sam Ravnborg
2020-04-24 16:37     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 16:37     ` Sam Ravnborg
2020-04-15  7:40 ` [PATCH 38/59] drm/i915: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-28 18:52   ` Daniel Vetter
2020-04-28 18:52     ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 39/59] drm/arcpgu: Switch to devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 16:43   ` Sam Ravnborg
2020-04-24 16:43     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 40/59] drm/arcpgu: Stop using drm_device->dev_private Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 16:46   ` Sam Ravnborg
2020-04-24 16:46     ` [Intel-gfx] " Sam Ravnborg
2020-09-04 13:42     ` Daniel Vetter
2020-09-04 13:42       ` [Intel-gfx] " Daniel Vetter
2020-09-04 14:42       ` Sam Ravnborg
2020-09-04 14:42         ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 41/59] drm/arcpgu: Delete arcpgu_priv->fb Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 16:47   ` Sam Ravnborg
2020-04-24 16:47     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 42/59] drm/arc: Embedded a drm_simple_display_pipe Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:34   ` Sam Ravnborg
2020-04-24 17:34     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 43/59] drm/arc: Embedd a drm_connector for sim case Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:34   ` Sam Ravnborg
2020-04-24 17:34     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 44/59] drm/arc: Drop surplus connector registration Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 16:51   ` Sam Ravnborg
2020-04-24 16:51     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 45/59] drm/arc: Use drmm_mode_config_cleanup Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:36   ` Sam Ravnborg
2020-04-24 17:36     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 46/59] drm/arc: Align with simple pipe helpers Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-25 12:24   ` Sam Ravnborg
2020-04-25 12:24     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 47/59] drm/arc: Convert to drm_simple_kms_pipe_helper Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:40   ` Sam Ravnborg
2020-04-24 17:40     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 48/59] drm/arc: Drop fb/crtc check in arc_pgu_update Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:45   ` Sam Ravnborg
2020-04-24 17:45     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 49/59] drm/arc: Inline arcpgu_crtc.c Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:51   ` Sam Ravnborg
2020-04-24 17:51     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 50/59] drm/arc: Inline arcpgu_drm_hdmi_init Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:54   ` Sam Ravnborg
2020-04-24 17:54     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 51/59] drm/arc: Inline remaining files Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:56   ` Sam Ravnborg
2020-04-24 17:56     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 52/59] drm/arc: Initialize sim connector before display pipe Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-24 17:58   ` Sam Ravnborg
2020-04-24 17:58     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 53/59] drm/arc: Move to drm/tiny Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  8:04   ` Thomas Zimmermann
2020-04-15  8:04     ` [Intel-gfx] " Thomas Zimmermann
2020-04-15  8:22     ` Daniel Vetter
2020-04-15  8:22       ` [Intel-gfx] " Daniel Vetter
2020-04-15  9:45   ` Sam Ravnborg
2020-04-15  9:45     ` [Intel-gfx] " Sam Ravnborg
2020-04-15 12:02     ` Alexey Brodkin
2020-04-15 12:02       ` [Intel-gfx] " Alexey Brodkin
2020-04-15 12:20       ` Daniel Vetter
2020-04-15 12:20         ` [Intel-gfx] " Daniel Vetter
2020-04-28 14:08         ` Daniel Vetter
2020-04-28 14:08           ` [Intel-gfx] " Daniel Vetter
2020-05-08 13:56           ` Alexey Brodkin
2020-05-08 13:56             ` [Intel-gfx] " Alexey Brodkin
2020-05-08 18:07             ` Daniel Vetter
2020-05-08 18:07               ` [Intel-gfx] " Daniel Vetter
2020-06-04  8:05               ` Daniel Vetter
2020-06-04  8:05                 ` [Intel-gfx] " Daniel Vetter
2020-06-04 10:38                 ` Eugeniy Paltsev
2020-06-04 10:38                   ` [Intel-gfx] " Eugeniy Paltsev
2020-06-04 11:19                   ` Daniel Vetter
2020-06-04 11:19                     ` [Intel-gfx] " Daniel Vetter
2020-06-04 19:00                     ` Eugeniy Paltsev
2020-06-04 19:00                       ` [Intel-gfx] " Eugeniy Paltsev
2020-06-05 19:55                       ` Daniel Vetter
2020-06-05 19:55                         ` [Intel-gfx] " Daniel Vetter
2020-06-09 12:08                         ` Eugeniy Paltsev
2020-06-09 12:08                           ` [Intel-gfx] " Eugeniy Paltsev
2020-06-09 13:02                           ` Daniel Vetter
2020-06-09 13:02                             ` [Intel-gfx] " Daniel Vetter
2020-07-17  9:04                             ` Daniel Vetter
2020-07-17  9:04                               ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 54/59] drm/aspeed: Drop aspeed_gfx->fbdev Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-24 18:00   ` Sam Ravnborg
2020-04-24 18:00     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 18:00     ` Sam Ravnborg
2020-04-15  7:40 ` [PATCH 55/59] drm/aspeed: Use devm_drm_dev_alloc Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-24 18:02   ` Sam Ravnborg
2020-04-24 18:02     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 18:02     ` Sam Ravnborg
2020-04-15  7:40 ` [PATCH 56/59] drm/aspeed: Use managed drmm_mode_config_cleanup Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-24 18:10   ` Sam Ravnborg
2020-04-24 18:10     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 18:10     ` Sam Ravnborg
2020-04-28 14:12     ` Daniel Vetter
2020-04-28 14:12       ` [Intel-gfx] " Daniel Vetter
2020-04-28 14:12       ` Daniel Vetter
2020-04-28 17:03       ` Sam Ravnborg
2020-04-28 17:03         ` [Intel-gfx] " Sam Ravnborg
2020-04-28 17:03         ` Sam Ravnborg
2020-04-15  7:40 ` [PATCH 57/59] drm/ast: Use managed pci functions Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:52   ` Thomas Zimmermann
2020-04-15  7:52     ` [Intel-gfx] " Thomas Zimmermann
2020-04-15  8:09     ` Daniel Vetter
2020-04-15  8:09       ` [Intel-gfx] " Daniel Vetter
2020-04-15  8:17       ` Daniel Vetter
2020-04-15  8:17         ` [Intel-gfx] " Daniel Vetter
2020-04-15 12:23         ` Daniel Vetter
2020-04-15 12:23           ` [Intel-gfx] " Daniel Vetter
2020-06-11 12:04   ` Thomas Zimmermann
2020-06-11 12:04     ` [Intel-gfx] " Thomas Zimmermann
2020-06-16 11:55     ` Daniel Vetter
2020-06-16 11:55       ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40 ` [PATCH 58/59] drm/ast: Drop explicit connector register/unregister Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:53   ` Thomas Zimmermann
2020-04-15  7:53     ` [Intel-gfx] " Thomas Zimmermann
2020-04-24 18:11   ` Sam Ravnborg
2020-04-24 18:11     ` [Intel-gfx] " Sam Ravnborg
2020-04-15  7:40 ` [PATCH 59/59] drm/bochs: Remove explicit drm_connector_register Daniel Vetter
2020-04-15  7:40   ` [Intel-gfx] " Daniel Vetter
2020-04-15  7:40   ` Daniel Vetter
2020-04-21  7:39   ` Gerd Hoffmann
2020-04-21  7:39     ` [Intel-gfx] " Gerd Hoffmann
2020-04-21  7:39     ` Gerd Hoffmann
2020-04-24 18:11   ` Sam Ravnborg
2020-04-24 18:11     ` [Intel-gfx] " Sam Ravnborg
2020-04-24 18:11     ` Sam Ravnborg
2020-04-15  8:04 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for devm_drm_dev_alloc, v2 Patchwork
2020-04-15  8:23 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2020-04-15  8:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-04-15 23:45 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-06-04 11:58 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for devm_drm_dev_alloc, v2 (rev2) Patchwork
2020-06-04 19:36 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for devm_drm_dev_alloc, v2 (rev3) Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.