Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,7 @@ void dcp_platform_shutdown(struct platform_device *pdev);
void dcp_disable_typec_work(struct apple_dcp *dcp, bool release_cable);
void dcp_enable_typec_work(struct apple_dcp *dcp);
void dcp_swap_watchdog(struct work_struct *work);
void disconnected_hpd_event(struct apple_connector *con);
void iomfb_scanout_put_h17p(struct apple_dcp *dcp, struct iomfb_scanout_h17p *scanout);
#endif

Expand Down
12 changes: 10 additions & 2 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ static int dcp_desktop_shmem_setup(struct apple_dcp *dcp,
return 0;
}

static void disconnected_hpd_event(struct apple_connector *connector);
VISIBLE_IF_KUNIT void disconnected_hpd_event(struct apple_connector *con);

bool dcp_is_external_h17p(struct apple_dcp *dcp)
{
Expand Down Expand Up @@ -4181,7 +4181,7 @@ static void dcp_typec_relink_work(struct work_struct *work)
spin_unlock_irqrestore(&dcp->relink_lock, flags);
}

static void disconnected_hpd_event(struct apple_connector *con)
VISIBLE_IF_KUNIT void disconnected_hpd_event(struct apple_connector *con)
{
struct platform_device *pdev;

Expand All @@ -4192,6 +4192,14 @@ static void disconnected_hpd_event(struct apple_connector *con)
if (pdev) {
struct apple_dcp *dcp = platform_get_drvdata(pdev);

/*
* Userspace can disable the CRTC from the hotplug notification
* below before the firmware finishes tearing down the link and
* reports cb_hotplug(0). Invalidate the mode now so the CRTC
* power-off leaves the unplugged pipe to the firmware instead
* of submitting a clear swap that gets swallowed.
*/
dcp_mode_invalidate(&dcp->mode_state);
WRITE_ONCE(dcp->ext_backlight, false);
/* Nothing else reports an HDMI unplug to the firmware metadata. */
if (dcp_sink_metadata(dcp))
Expand Down
34 changes: 34 additions & 0 deletions drivers/gpu/drm/apple/hotplug-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,45 @@ static void hotplug_coalesced_ready(struct kunit *test)
KUNIT_EXPECT_EQ(test, fixture->notifications, 2U);
}

static void hotplug_disconnected_hpd_invalidates_mode(struct kunit *test)
{
struct hotplug_fixture *fixture = test->priv;

fixture->connector.base.status = connector_status_connected;
fixture->connector.connected = true;
fixture->dcp.mode_state.valid = true;
/* Hold hotplug_wq so we inspect state before userspace is notified. */
disable_work_sync(&fixture->connector.hotplug_wq);
disconnected_hpd_event(&fixture->connector);
KUNIT_EXPECT_FALSE(test, READ_ONCE(fixture->connector.connected));
KUNIT_EXPECT_FALSE(test, READ_ONCE(fixture->dcp.mode_state.valid));
enable_work(&fixture->connector.hotplug_wq);
schedule_work(&fixture->connector.hotplug_wq);
flush_work(&fixture->connector.hotplug_wq);
hotplug_expect_notification(test, connector_status_disconnected);
}

static void hotplug_disconnected_hpd_invalidates_inflight_modeset(struct kunit *test)
{
struct hotplug_fixture *fixture = test->priv;

fixture->connector.base.status = connector_status_connected;
fixture->connector.connected = true;
dcp_mode_begin(&fixture->dcp.mode_state);
disconnected_hpd_event(&fixture->connector);
dcp_mode_finish(&fixture->dcp.mode_state, true, &fixture->connector.connected);
KUNIT_EXPECT_FALSE(test, READ_ONCE(fixture->dcp.mode_state.valid));
flush_work(&fixture->connector.hotplug_wq);
hotplug_expect_notification(test, connector_status_disconnected);
}

static struct kunit_case hotplug_test_cases[] = {
KUNIT_CASE(hotplug_route_failure_notify),
KUNIT_CASE(hotplug_coalesced_ready),
KUNIT_CASE(hotplug_connected),
KUNIT_CASE(hotplug_disconnected),
KUNIT_CASE(hotplug_disconnected_hpd_invalidates_mode),
KUNIT_CASE(hotplug_disconnected_hpd_invalidates_inflight_modeset),
KUNIT_CASE(hotplug_retrain),
KUNIT_CASE(hotplug_unrouted),
KUNIT_CASE(hotplug_forced_on),
Expand Down
Loading