Skip to content

Commit 7ef64ed

Browse files
committed
drm/gm12u320: Use helpers for shutdown/suspend/resume
Also there's a race in the disconnect implemenation. First shut down, then unplug, leaves a window where userspace could sneak in and restart the entire machinery. With this we can also delete the very un-atomic global pipe_enabled tracking. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: "Noralf Trønnes" <noralf@tronnes.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-45-daniel.vetter@ffwll.ch
1 parent 993f5b1 commit 7ef64ed

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

‎drivers/gpu/drm/tiny/gm12u320.c‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct gm12u320_device {
8888
struct usb_device *udev;
8989
unsigned char *cmd_buf;
9090
unsigned char *data_buf[GM12U320_BLOCK_COUNT];
91-
bool pipe_enabled;
9291
struct {
9392
bool run;
9493
struct workqueue_struct *workq;
@@ -589,15 +588,13 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe,
589588

590589
gm12u320_fb_mark_dirty(plane_state->fb, &rect);
591590
gm12u320_start_fb_update(gm12u320);
592-
gm12u320->pipe_enabled = true;
593591
}
594592

595593
static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
596594
{
597595
struct gm12u320_device *gm12u320 = pipe->crtc.dev->dev_private;
598596

599597
gm12u320_stop_fb_update(gm12u320);
600-
gm12u320->pipe_enabled = false;
601598
}
602599

603600
static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -733,22 +730,17 @@ static int gm12u320_usb_probe(struct usb_interface *interface,
733730
static void gm12u320_usb_disconnect(struct usb_interface *interface)
734731
{
735732
struct drm_device *dev = usb_get_intfdata(interface);
736-
struct gm12u320_device *gm12u320 = dev->dev_private;
737733

738-
gm12u320_stop_fb_update(gm12u320);
739734
drm_dev_unplug(dev);
735+
drm_atomic_helper_shutdown(dev);
740736
}
741737

742738
static __maybe_unused int gm12u320_suspend(struct usb_interface *interface,
743739
pm_message_t message)
744740
{
745741
struct drm_device *dev = usb_get_intfdata(interface);
746-
struct gm12u320_device *gm12u320 = dev->dev_private;
747742

748-
if (gm12u320->pipe_enabled)
749-
gm12u320_stop_fb_update(gm12u320);
750-
751-
return 0;
743+
return drm_mode_config_helper_suspend(dev);
752744
}
753745

754746
static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
@@ -757,10 +749,8 @@ static __maybe_unused int gm12u320_resume(struct usb_interface *interface)
757749
struct gm12u320_device *gm12u320 = dev->dev_private;
758750

759751
gm12u320_set_ecomode(gm12u320);
760-
if (gm12u320->pipe_enabled)
761-
gm12u320_start_fb_update(gm12u320);
762752

763-
return 0;
753+
return drm_mode_config_helper_resume(dev);
764754
}
765755

766756
static const struct usb_device_id id_table[] = {

0 commit comments

Comments
 (0)