USB altmodes code would send OOB notifications to the drm_connector specified in the device tree. However as the MSM DP driver uses drm_bridge_connector, there is no way to receive these event directly. Implement a bridge between oob_hotplug_event and drm_bridge's hpd_notify and use it to deliver altmode messages to the MSM DP driver.
Note, I left the original 'bool connected' field to be used by the notifiers. However I think that it should be replaced in favour of using the dp->hpd_state properly.
Bjorn Andersson (2): drm: Add HPD state to drm_connector_oob_hotplug_event() drm/msm/dp: Implement hpd_notify()
Dmitry Baryshkov (3): drm/bridge_connector: stop filtering events in drm_bridge_connector_hpd_cb() drm/bridge_connector: implement oob_hotplug_event drm/msm/dp: remove most of usbpd-related remains
drivers/gpu/drm/drm_bridge_connector.c | 17 +++-- drivers/gpu/drm/drm_connector.c | 6 +- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++- drivers/gpu/drm/i915/i915_drv.h | 3 + drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_debug.c | 6 +- drivers/gpu/drm/msm/dp/dp_debug.h | 4 +- drivers/gpu/drm/msm/dp/dp_display.c | 81 +++++++++++------------- drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 + drivers/gpu/drm/msm/dp/dp_drm.h | 2 + drivers/gpu/drm/msm/dp/dp_hpd.c | 67 -------------------- drivers/gpu/drm/msm/dp/dp_hpd.h | 78 ----------------------- drivers/gpu/drm/msm/dp/dp_panel.h | 1 - drivers/gpu/drm/msm/dp/dp_power.c | 2 +- drivers/gpu/drm/msm/dp/dp_power.h | 3 +- drivers/usb/typec/altmodes/displayport.c | 10 +-- include/drm/drm_connector.h | 6 +- 19 files changed, 88 insertions(+), 221 deletions(-) delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.c delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.h
From: Dmitry Baryshkov dmitry.baryshkov@linaro.org
In some cases the bridge drivers would like to receive hotplug events even in the case new status is equal to the old status. In the DP case this is used to deliver "attention" messages to the DP host. Stop filtering the events in the drm_bridge_connector_hpd_cb() and let drivers decide whether they would like to receive the event or not.
Signed-off-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org ---
Changes since v3: - New patch, needed due to the move to drm_bridge_connector
drivers/gpu/drm/drm_bridge_connector.c | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 6b3dad03d77d..0f6f3f653f65 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -113,16 +113,11 @@ static void drm_bridge_connector_hpd_cb(void *cb_data, struct drm_bridge_connector *drm_bridge_connector = cb_data; struct drm_connector *connector = &drm_bridge_connector->base; struct drm_device *dev = connector->dev; - enum drm_connector_status old_status;
mutex_lock(&dev->mode_config.mutex); - old_status = connector->status; connector->status = status; mutex_unlock(&dev->mode_config.mutex);
- if (old_status == status) - return; - drm_bridge_connector_hpd_notify(connector, status);
drm_kms_helper_hotplug_event(dev);
In some implementations, such as the Qualcomm platforms, the display driver has no way to query the current HPD state and as such it's impossible to distinguish between disconnect and attention events.
Add a parameter to drm_connector_oob_hotplug_event() to pass the HPD state.
Also push the test for unchanged state in the displayport altmode driver into the i915 driver, to allow other drivers to act upon each update.
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org ---
Changes since v3: - Transition to drm_connector_status instead of custom hpd_state
drivers/gpu/drm/drm_connector.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/usb/typec/altmodes/displayport.c | 10 +++------- include/drm/drm_connector.h | 6 ++++-- 5 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..e86c69f0640f 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2794,6 +2794,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) /** * drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector * @connector_fwnode: fwnode_handle to report the event on + * @status: hot plug detect logical state * * On some hardware a hotplug event notification may come from outside the display * driver / device. An example of this is some USB Type-C setups where the hardware @@ -2803,7 +2804,8 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) * This function can be used to report these out-of-band events after obtaining * a drm_connector reference through calling drm_connector_find_by_fwnode(). */ -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, + enum drm_connector_status status) { struct drm_connector *connector;
@@ -2812,7 +2814,7 @@ void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) return;
if (connector->funcs->oob_hotplug_event) - connector->funcs->oob_hotplug_event(connector); + connector->funcs->oob_hotplug_event(connector, status);
drm_connector_put(connector); } diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index e4a79c11fd25..56cc023f7bbd 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4951,15 +4951,26 @@ static int intel_dp_connector_atomic_check(struct drm_connector *conn, return intel_modeset_synced_crtcs(state, conn); }
-static void intel_dp_oob_hotplug_event(struct drm_connector *connector) +static void intel_dp_oob_hotplug_event(struct drm_connector *connector, + enum drm_connector_status hpd_state) { struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); struct drm_i915_private *i915 = to_i915(connector->dev); + bool hpd_high = hpd_state == connector_status_connected; + unsigned int hpd_pin = encoder->hpd_pin; + bool need_work = false;
spin_lock_irq(&i915->irq_lock); - i915->hotplug.event_bits |= BIT(encoder->hpd_pin); + if (hpd_high != test_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state)) { + i915->hotplug.event_bits |= BIT(hpd_pin); + + __assign_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state, hpd_high); + need_work = true; + } spin_unlock_irq(&i915->irq_lock); - queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0); + + if (need_work) + queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0); }
static const struct drm_connector_funcs intel_dp_connector_funcs = { diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 24111bf42ce0..96c088bb5522 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -135,6 +135,9 @@ struct i915_hotplug { /* Whether or not to count short HPD IRQs in HPD storms */ u8 hpd_short_storm_enabled;
+ /* Last state reported by oob_hotplug_event for each encoder */ + unsigned long oob_hotplug_last_state; + /* * if we get a HPD irq from DP and a HPD irq from non-DP * the non-DP HPD could block the workqueue on a mode config diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index c1d8c23baa39..9360ca177c7d 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -59,7 +59,6 @@ struct dp_altmode { struct typec_displayport_data data;
enum dp_state state; - bool hpd;
struct mutex lock; /* device lock */ struct work_struct work; @@ -143,10 +142,8 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (!ret) dp->state = DP_STATE_CONFIGURE; } else { - if (dp->hpd != hpd) { - drm_connector_oob_hotplug_event(dp->connector_fwnode); - dp->hpd = hpd; - } + drm_connector_oob_hotplug_event(dp->connector_fwnode, + hpd ? connector_status_connected : connector_status_disconnected); }
return ret; @@ -573,8 +570,7 @@ void dp_altmode_remove(struct typec_altmode *alt) cancel_work_sync(&dp->work);
if (dp->connector_fwnode) { - if (dp->hpd) - drm_connector_oob_hotplug_event(dp->connector_fwnode); + drm_connector_oob_hotplug_event(dp->connector_fwnode, connector_status_disconnected);
fwnode_handle_put(dp->connector_fwnode); } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..886aa1861ed9 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1141,7 +1141,8 @@ struct drm_connector_funcs { * This will get called when a hotplug-event for a drm-connector * has been received from a source outside the display driver / device. */ - void (*oob_hotplug_event)(struct drm_connector *connector); + void (*oob_hotplug_event)(struct drm_connector *connector, + enum drm_connector_status status);
/** * @debugfs_init: @@ -1749,7 +1750,8 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; }
-void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode); +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, + enum drm_connector_status status); const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order);
+Hans
Hans, do you have any comments?
On Mon, May 02, 2022 at 09:53:13AM -0700, Bjorn Andersson wrote:
In some implementations, such as the Qualcomm platforms, the display driver has no way to query the current HPD state and as such it's impossible to distinguish between disconnect and attention events.
Add a parameter to drm_connector_oob_hotplug_event() to pass the HPD state.
Also push the test for unchanged state in the displayport altmode driver into the i915 driver, to allow other drivers to act upon each update.
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
- Transition to drm_connector_status instead of custom hpd_state
drivers/gpu/drm/drm_connector.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/usb/typec/altmodes/displayport.c | 10 +++------- include/drm/drm_connector.h | 6 ++++-- 5 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..e86c69f0640f 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2794,6 +2794,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) /**
- drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector
- @connector_fwnode: fwnode_handle to report the event on
- @status: hot plug detect logical state
- On some hardware a hotplug event notification may come from outside the display
- driver / device. An example of this is some USB Type-C setups where the hardware
@@ -2803,7 +2804,8 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
- This function can be used to report these out-of-band events after obtaining
- a drm_connector reference through calling drm_connector_find_by_fwnode().
*/ -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status)
{ struct drm_connector *connector;
@@ -2812,7 +2814,7 @@ void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) return;
if (connector->funcs->oob_hotplug_event)
connector->funcs->oob_hotplug_event(connector);
connector->funcs->oob_hotplug_event(connector, status);
drm_connector_put(connector);
} diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index e4a79c11fd25..56cc023f7bbd 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4951,15 +4951,26 @@ static int intel_dp_connector_atomic_check(struct drm_connector *conn, return intel_modeset_synced_crtcs(state, conn); }
-static void intel_dp_oob_hotplug_event(struct drm_connector *connector) +static void intel_dp_oob_hotplug_event(struct drm_connector *connector,
enum drm_connector_status hpd_state)
{ struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); struct drm_i915_private *i915 = to_i915(connector->dev);
bool hpd_high = hpd_state == connector_status_connected;
unsigned int hpd_pin = encoder->hpd_pin;
bool need_work = false;
spin_lock_irq(&i915->irq_lock);
- i915->hotplug.event_bits |= BIT(encoder->hpd_pin);
- if (hpd_high != test_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state)) {
i915->hotplug.event_bits |= BIT(hpd_pin);
__assign_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state, hpd_high);
need_work = true;
- } spin_unlock_irq(&i915->irq_lock);
- queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
- if (need_work)
queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
}
static const struct drm_connector_funcs intel_dp_connector_funcs = { diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 24111bf42ce0..96c088bb5522 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -135,6 +135,9 @@ struct i915_hotplug { /* Whether or not to count short HPD IRQs in HPD storms */ u8 hpd_short_storm_enabled;
- /* Last state reported by oob_hotplug_event for each encoder */
- unsigned long oob_hotplug_last_state;
- /*
- if we get a HPD irq from DP and a HPD irq from non-DP
- the non-DP HPD could block the workqueue on a mode config
diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index c1d8c23baa39..9360ca177c7d 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -59,7 +59,6 @@ struct dp_altmode { struct typec_displayport_data data;
enum dp_state state;
bool hpd;
struct mutex lock; /* device lock */ struct work_struct work;
@@ -143,10 +142,8 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (!ret) dp->state = DP_STATE_CONFIGURE; } else {
if (dp->hpd != hpd) {
drm_connector_oob_hotplug_event(dp->connector_fwnode);
dp->hpd = hpd;
}
drm_connector_oob_hotplug_event(dp->connector_fwnode,
hpd ? connector_status_connected : connector_status_disconnected);
}
return ret;
@@ -573,8 +570,7 @@ void dp_altmode_remove(struct typec_altmode *alt) cancel_work_sync(&dp->work);
if (dp->connector_fwnode) {
if (dp->hpd)
drm_connector_oob_hotplug_event(dp->connector_fwnode);
drm_connector_oob_hotplug_event(dp->connector_fwnode, connector_status_disconnected);
fwnode_handle_put(dp->connector_fwnode); }
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..886aa1861ed9 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1141,7 +1141,8 @@ struct drm_connector_funcs { * This will get called when a hotplug-event for a drm-connector * has been received from a source outside the display driver / device. */
- void (*oob_hotplug_event)(struct drm_connector *connector);
void (*oob_hotplug_event)(struct drm_connector *connector,
enum drm_connector_status status);
/**
- @debugfs_init:
@@ -1749,7 +1750,8 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; }
-void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode); +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status);
const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order); -- 2.35.1
Hi,
On 5/16/22 13:25, Heikki Krogerus wrote:
+Hans
Hans, do you have any comments?
Thanks for the ping, this looks good to me:
Reviewed-by: Hans de Goede hdegoede@redhat.com
Regards,
Hans
On Mon, May 02, 2022 at 09:53:13AM -0700, Bjorn Andersson wrote:
In some implementations, such as the Qualcomm platforms, the display driver has no way to query the current HPD state and as such it's impossible to distinguish between disconnect and attention events.
Add a parameter to drm_connector_oob_hotplug_event() to pass the HPD state.
Also push the test for unchanged state in the displayport altmode driver into the i915 driver, to allow other drivers to act upon each update.
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
- Transition to drm_connector_status instead of custom hpd_state
drivers/gpu/drm/drm_connector.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/usb/typec/altmodes/displayport.c | 10 +++------- include/drm/drm_connector.h | 6 ++++-- 5 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..e86c69f0640f 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2794,6 +2794,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) /**
- drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector
- @connector_fwnode: fwnode_handle to report the event on
- @status: hot plug detect logical state
- On some hardware a hotplug event notification may come from outside the display
- driver / device. An example of this is some USB Type-C setups where the hardware
@@ -2803,7 +2804,8 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
- This function can be used to report these out-of-band events after obtaining
- a drm_connector reference through calling drm_connector_find_by_fwnode().
*/ -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status)
{ struct drm_connector *connector;
@@ -2812,7 +2814,7 @@ void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) return;
if (connector->funcs->oob_hotplug_event)
connector->funcs->oob_hotplug_event(connector);
connector->funcs->oob_hotplug_event(connector, status);
drm_connector_put(connector);
} diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index e4a79c11fd25..56cc023f7bbd 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4951,15 +4951,26 @@ static int intel_dp_connector_atomic_check(struct drm_connector *conn, return intel_modeset_synced_crtcs(state, conn); }
-static void intel_dp_oob_hotplug_event(struct drm_connector *connector) +static void intel_dp_oob_hotplug_event(struct drm_connector *connector,
enum drm_connector_status hpd_state)
{ struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); struct drm_i915_private *i915 = to_i915(connector->dev);
bool hpd_high = hpd_state == connector_status_connected;
unsigned int hpd_pin = encoder->hpd_pin;
bool need_work = false;
spin_lock_irq(&i915->irq_lock);
- i915->hotplug.event_bits |= BIT(encoder->hpd_pin);
- if (hpd_high != test_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state)) {
i915->hotplug.event_bits |= BIT(hpd_pin);
__assign_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state, hpd_high);
need_work = true;
- } spin_unlock_irq(&i915->irq_lock);
- queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
- if (need_work)
queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
}
static const struct drm_connector_funcs intel_dp_connector_funcs = { diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 24111bf42ce0..96c088bb5522 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -135,6 +135,9 @@ struct i915_hotplug { /* Whether or not to count short HPD IRQs in HPD storms */ u8 hpd_short_storm_enabled;
- /* Last state reported by oob_hotplug_event for each encoder */
- unsigned long oob_hotplug_last_state;
- /*
- if we get a HPD irq from DP and a HPD irq from non-DP
- the non-DP HPD could block the workqueue on a mode config
diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index c1d8c23baa39..9360ca177c7d 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -59,7 +59,6 @@ struct dp_altmode { struct typec_displayport_data data;
enum dp_state state;
bool hpd;
struct mutex lock; /* device lock */ struct work_struct work;
@@ -143,10 +142,8 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (!ret) dp->state = DP_STATE_CONFIGURE; } else {
if (dp->hpd != hpd) {
drm_connector_oob_hotplug_event(dp->connector_fwnode);
dp->hpd = hpd;
}
drm_connector_oob_hotplug_event(dp->connector_fwnode,
hpd ? connector_status_connected : connector_status_disconnected);
}
return ret;
@@ -573,8 +570,7 @@ void dp_altmode_remove(struct typec_altmode *alt) cancel_work_sync(&dp->work);
if (dp->connector_fwnode) {
if (dp->hpd)
drm_connector_oob_hotplug_event(dp->connector_fwnode);
drm_connector_oob_hotplug_event(dp->connector_fwnode, connector_status_disconnected);
fwnode_handle_put(dp->connector_fwnode); }
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..886aa1861ed9 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1141,7 +1141,8 @@ struct drm_connector_funcs { * This will get called when a hotplug-event for a drm-connector * has been received from a source outside the display driver / device. */
- void (*oob_hotplug_event)(struct drm_connector *connector);
void (*oob_hotplug_event)(struct drm_connector *connector,
enum drm_connector_status status);
/**
- @debugfs_init:
@@ -1749,7 +1750,8 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; }
-void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode); +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status);
const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order); -- 2.35.1
On Mon, May 02, 2022 at 09:53:13AM -0700, Bjorn Andersson wrote:
In some implementations, such as the Qualcomm platforms, the display driver has no way to query the current HPD state and as such it's impossible to distinguish between disconnect and attention events.
Add a parameter to drm_connector_oob_hotplug_event() to pass the HPD state.
Also push the test for unchanged state in the displayport altmode driver into the i915 driver, to allow other drivers to act upon each update.
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Acked-by: Heikki Krogerus heikki.krogerus@linux.intel.com
Changes since v3:
- Transition to drm_connector_status instead of custom hpd_state
drivers/gpu/drm/drm_connector.c | 6 ++++-- drivers/gpu/drm/i915/display/intel_dp.c | 17 ++++++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/usb/typec/altmodes/displayport.c | 10 +++------- include/drm/drm_connector.h | 6 ++++-- 5 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..e86c69f0640f 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2794,6 +2794,7 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode) /**
- drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector
- @connector_fwnode: fwnode_handle to report the event on
- @status: hot plug detect logical state
- On some hardware a hotplug event notification may come from outside the display
- driver / device. An example of this is some USB Type-C setups where the hardware
@@ -2803,7 +2804,8 @@ struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
- This function can be used to report these out-of-band events after obtaining
- a drm_connector reference through calling drm_connector_find_by_fwnode().
*/ -void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status)
{ struct drm_connector *connector;
@@ -2812,7 +2814,7 @@ void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode) return;
if (connector->funcs->oob_hotplug_event)
connector->funcs->oob_hotplug_event(connector);
connector->funcs->oob_hotplug_event(connector, status);
drm_connector_put(connector);
} diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index e4a79c11fd25..56cc023f7bbd 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4951,15 +4951,26 @@ static int intel_dp_connector_atomic_check(struct drm_connector *conn, return intel_modeset_synced_crtcs(state, conn); }
-static void intel_dp_oob_hotplug_event(struct drm_connector *connector) +static void intel_dp_oob_hotplug_event(struct drm_connector *connector,
enum drm_connector_status hpd_state)
{ struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); struct drm_i915_private *i915 = to_i915(connector->dev);
bool hpd_high = hpd_state == connector_status_connected;
unsigned int hpd_pin = encoder->hpd_pin;
bool need_work = false;
spin_lock_irq(&i915->irq_lock);
- i915->hotplug.event_bits |= BIT(encoder->hpd_pin);
- if (hpd_high != test_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state)) {
i915->hotplug.event_bits |= BIT(hpd_pin);
__assign_bit(hpd_pin, &i915->hotplug.oob_hotplug_last_state, hpd_high);
need_work = true;
- } spin_unlock_irq(&i915->irq_lock);
- queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
- if (need_work)
queue_delayed_work(system_wq, &i915->hotplug.hotplug_work, 0);
}
static const struct drm_connector_funcs intel_dp_connector_funcs = { diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 24111bf42ce0..96c088bb5522 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -135,6 +135,9 @@ struct i915_hotplug { /* Whether or not to count short HPD IRQs in HPD storms */ u8 hpd_short_storm_enabled;
- /* Last state reported by oob_hotplug_event for each encoder */
- unsigned long oob_hotplug_last_state;
- /*
- if we get a HPD irq from DP and a HPD irq from non-DP
- the non-DP HPD could block the workqueue on a mode config
diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index c1d8c23baa39..9360ca177c7d 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -59,7 +59,6 @@ struct dp_altmode { struct typec_displayport_data data;
enum dp_state state;
bool hpd;
struct mutex lock; /* device lock */ struct work_struct work;
@@ -143,10 +142,8 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (!ret) dp->state = DP_STATE_CONFIGURE; } else {
if (dp->hpd != hpd) {
drm_connector_oob_hotplug_event(dp->connector_fwnode);
dp->hpd = hpd;
}
drm_connector_oob_hotplug_event(dp->connector_fwnode,
hpd ? connector_status_connected : connector_status_disconnected);
}
return ret;
@@ -573,8 +570,7 @@ void dp_altmode_remove(struct typec_altmode *alt) cancel_work_sync(&dp->work);
if (dp->connector_fwnode) {
if (dp->hpd)
drm_connector_oob_hotplug_event(dp->connector_fwnode);
drm_connector_oob_hotplug_event(dp->connector_fwnode, connector_status_disconnected);
fwnode_handle_put(dp->connector_fwnode); }
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..886aa1861ed9 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1141,7 +1141,8 @@ struct drm_connector_funcs { * This will get called when a hotplug-event for a drm-connector * has been received from a source outside the display driver / device. */
- void (*oob_hotplug_event)(struct drm_connector *connector);
void (*oob_hotplug_event)(struct drm_connector *connector,
enum drm_connector_status status);
/**
- @debugfs_init:
@@ -1749,7 +1750,8 @@ drm_connector_is_unregistered(struct drm_connector *connector) DRM_CONNECTOR_UNREGISTERED; }
-void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode); +void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
enum drm_connector_status status);
const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order); -- 2.35.1
thanks,
From: Dmitry Baryshkov dmitry.baryshkov@linaro.org
Implement the oob_hotplug_event() callback. Translate it to the HPD notification sent to the HPD bridge in the chain.
Signed-off-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org ---
Changes since v3: - New patch
drivers/gpu/drm/drm_bridge_connector.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 0f6f3f653f65..6a0a6b14360a 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -123,6 +123,17 @@ static void drm_bridge_connector_hpd_cb(void *cb_data, drm_kms_helper_hotplug_event(dev); }
+static void drm_bridge_connector_oob_hotplug_event(struct drm_connector *connector, + enum drm_connector_status status) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *hpd = bridge_connector->bridge_hpd; + + if (hpd) + drm_bridge_hpd_notify(hpd, status); +} + /** * drm_bridge_connector_enable_hpd - Enable hot-plug detection for the connector * @connector: The DRM bridge connector @@ -233,6 +244,7 @@ static const struct drm_connector_funcs drm_bridge_connector_funcs = { .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .debugfs_init = drm_bridge_connector_debugfs_init, + .oob_hotplug_event = drm_bridge_connector_oob_hotplug_event, };
/* -----------------------------------------------------------------------------
From: Dmitry Baryshkov dmitry.baryshkov@linaro.org
Remove most of remains of downstream usbpd code. Mainline kernel uses different approach for managing Type-C / USB-PD, so this remains unused. Do not touch usbpd callbacks for now, since they look useful enough as an example of how to handle connect/disconnect (to be rewritten into .
Signed-off-by: Dmitry Baryshkov dmitry.baryshkov@linaro.org [bjorn: Cleaned up dp_display_usbpd_attention() prototype as well] Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org ---
Changes since v3: - New patch
drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_debug.c | 6 +-- drivers/gpu/drm/msm/dp/dp_debug.h | 4 +- drivers/gpu/drm/msm/dp/dp_display.c | 55 ++++---------------- drivers/gpu/drm/msm/dp/dp_hpd.c | 67 ------------------------- drivers/gpu/drm/msm/dp/dp_hpd.h | 78 ----------------------------- drivers/gpu/drm/msm/dp/dp_panel.h | 1 - drivers/gpu/drm/msm/dp/dp_power.c | 2 +- drivers/gpu/drm/msm/dp/dp_power.h | 3 +- 10 files changed, 16 insertions(+), 202 deletions(-) delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.c delete mode 100644 drivers/gpu/drm/msm/dp/dp_hpd.h
diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index 66395ee0862a..c417443168f6 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -123,7 +123,6 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \ dp/dp_ctrl.o \ dp/dp_display.o \ dp/dp_drm.o \ - dp/dp_hpd.o \ dp/dp_link.o \ dp/dp_panel.o \ dp/dp_parser.o \ diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index 0745fde01b45..52648b56f54b 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -14,7 +14,6 @@ #include "dp_catalog.h"
struct dp_ctrl { - bool orientation; atomic_t aborted; u32 pixel_rate; bool wide_bus_en; diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c index 075969da9418..25ea2d3e3e12 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.c +++ b/drivers/gpu/drm/msm/dp/dp_debug.c @@ -21,7 +21,6 @@ struct dp_debug_private { struct dentry *root;
- struct dp_usbpd *usbpd; struct dp_link *link; struct dp_panel *panel; struct drm_connector *connector; @@ -234,14 +233,14 @@ static void dp_debug_init(struct dp_debug *dp_debug, struct drm_minor *minor) }
struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor) { struct dp_debug_private *debug; struct dp_debug *dp_debug; int rc;
- if (!dev || !panel || !usbpd || !link) { + if (!dev || !panel || !link) { DRM_ERROR("invalid input\n"); rc = -EINVAL; goto error; @@ -254,7 +253,6 @@ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, }
debug->dp_debug.debug_en = false; - debug->usbpd = usbpd; debug->link = link; debug->panel = panel; debug->dev = dev; diff --git a/drivers/gpu/drm/msm/dp/dp_debug.h b/drivers/gpu/drm/msm/dp/dp_debug.h index 8c0d0b5178fd..be350cb393ee 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.h +++ b/drivers/gpu/drm/msm/dp/dp_debug.h @@ -42,7 +42,7 @@ struct dp_debug { * for debugfs input to be communicated with existing modules */ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor);
@@ -59,7 +59,7 @@ void dp_debug_put(struct dp_debug *dp_debug);
static inline struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel, - struct dp_usbpd *usbpd, struct dp_link *link, + struct dp_link *link, struct drm_connector *connector, struct drm_minor *minor) { return ERR_PTR(-EINVAL); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index c68d6007c2c6..b447446d75e9 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -14,7 +14,6 @@
#include "msm_drv.h" #include "msm_kms.h" -#include "dp_hpd.h" #include "dp_parser.h" #include "dp_power.h" #include "dp_catalog.h" @@ -88,7 +87,6 @@ struct dp_display_private { struct platform_device *pdev; struct dentry *root;
- struct dp_usbpd *usbpd; struct dp_parser *parser; struct dp_power *power; struct dp_catalog *catalog; @@ -98,7 +96,6 @@ struct dp_display_private { struct dp_ctrl *ctrl; struct dp_debug *debug;
- struct dp_usbpd_cb usbpd_cb; struct dp_display_mode dp_mode; struct msm_dp dp_display;
@@ -442,7 +439,7 @@ static void dp_display_host_init(struct dp_display_private *dp) dp->dp_display.connector_type, dp->core_initialized, dp->phy_initialized);
- dp_power_init(dp->power, false); + dp_power_init(dp->power); dp_ctrl_reset_irq_ctrl(dp->ctrl, true); dp_aux_init(dp->aux); dp->core_initialized = true; @@ -460,24 +457,15 @@ static void dp_display_host_deinit(struct dp_display_private *dp) dp->core_initialized = false; }
-static int dp_display_usbpd_configure_cb(struct device *dev) +static int dp_display_usbpd_configure(struct dp_display_private *dp) { - struct dp_display_private *dp = dev_get_dp_display_private(dev); - dp_display_host_phy_init(dp);
return dp_display_process_hpd_high(dp); }
-static int dp_display_usbpd_disconnect_cb(struct device *dev) -{ - return 0; -} - -static int dp_display_notify_disconnect(struct device *dev) +static int dp_display_notify_disconnect(struct dp_display_private *dp) { - struct dp_display_private *dp = dev_get_dp_display_private(dev); - dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
return 0; @@ -535,11 +523,10 @@ static int dp_display_handle_irq_hpd(struct dp_display_private *dp) return 0; }
-static int dp_display_usbpd_attention_cb(struct device *dev) +static int dp_display_usbpd_attention(struct dp_display_private *dp) { int rc = 0; u32 sink_request; - struct dp_display_private *dp = dev_get_dp_display_private(dev);
/* check for any test request issued by sink */ rc = dp_link_process_request(dp->link); @@ -558,13 +545,9 @@ static int dp_display_usbpd_attention_cb(struct device *dev)
static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) { - struct dp_usbpd *hpd = dp->usbpd; u32 state; int ret;
- if (!hpd) - return 0; - mutex_lock(&dp->event_mutex);
state = dp->hpd_state; @@ -588,7 +571,7 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data) return 0; }
- ret = dp_display_usbpd_configure_cb(&dp->pdev->dev); + ret = dp_display_usbpd_configure(dp); if (ret) { /* link train failed */ dp->hpd_state = ST_DISCONNECTED; } else { @@ -632,12 +615,8 @@ static void dp_display_handle_plugged_change(struct msm_dp *dp_display,
static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) { - struct dp_usbpd *hpd = dp->usbpd; u32 state;
- if (!hpd) - return 0; - mutex_lock(&dp->event_mutex);
state = dp->hpd_state; @@ -657,7 +636,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) if (dp->link->sink_count == 0) { dp_display_host_phy_exit(dp); } - dp_display_notify_disconnect(&dp->pdev->dev); + dp_display_notify_disconnect(dp); mutex_unlock(&dp->event_mutex); return 0; } else if (state == ST_DISCONNECT_PENDING) { @@ -667,7 +646,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) dp_ctrl_off_link(dp->ctrl); dp_display_host_phy_exit(dp); dp->hpd_state = ST_DISCONNECTED; - dp_display_notify_disconnect(&dp->pdev->dev); + dp_display_notify_disconnect(dp); mutex_unlock(&dp->event_mutex); return 0; } @@ -679,7 +658,7 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data) * We don't need separate work for disconnect as * connect/attention interrupts are disabled */ - dp_display_notify_disconnect(&dp->pdev->dev); + dp_display_notify_disconnect(dp);
if (state == ST_DISPLAY_OFF) { dp->hpd_state = ST_DISCONNECTED; @@ -725,7 +704,7 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data) return 0; }
- dp_display_usbpd_attention_cb(&dp->pdev->dev); + dp_display_usbpd_attention(dp);
drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n", dp->dp_display.connector_type, state); @@ -747,24 +726,10 @@ static int dp_init_sub_modules(struct dp_display_private *dp) { int rc = 0; struct device *dev = &dp->pdev->dev; - struct dp_usbpd_cb *cb = &dp->usbpd_cb; struct dp_panel_in panel_in = { .dev = dev, };
- /* Callback APIs used for cable status change event */ - cb->configure = dp_display_usbpd_configure_cb; - cb->disconnect = dp_display_usbpd_disconnect_cb; - cb->attention = dp_display_usbpd_attention_cb; - - dp->usbpd = dp_hpd_get(dev, cb); - if (IS_ERR(dp->usbpd)) { - rc = PTR_ERR(dp->usbpd); - DRM_ERROR("failed to initialize hpd, rc = %d\n", rc); - dp->usbpd = NULL; - goto error; - } - dp->parser = dp_parser_get(dp->pdev); if (IS_ERR(dp->parser)) { rc = PTR_ERR(dp->parser); @@ -1533,7 +1498,7 @@ void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor) dp = container_of(dp_display, struct dp_display_private, dp_display); dev = &dp->pdev->dev;
- dp->debug = dp_debug_get(dev, dp->panel, dp->usbpd, + dp->debug = dp_debug_get(dev, dp->panel, dp->link, dp->dp_display.connector, minor); if (IS_ERR(dp->debug)) { diff --git a/drivers/gpu/drm/msm/dp/dp_hpd.c b/drivers/gpu/drm/msm/dp/dp_hpd.c deleted file mode 100644 index db98a1d431eb..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_hpd.c +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#define pr_fmt(fmt) "[drm-dp] %s: " fmt, __func__ - -#include <linux/slab.h> -#include <linux/device.h> - -#include "dp_hpd.h" - -/* DP specific VDM commands */ -#define DP_USBPD_VDM_STATUS 0x10 -#define DP_USBPD_VDM_CONFIGURE 0x11 - -/* USBPD-TypeC specific Macros */ -#define VDM_VERSION 0x0 -#define USB_C_DP_SID 0xFF01 - -struct dp_hpd_private { - struct device *dev; - struct dp_usbpd_cb *dp_cb; - struct dp_usbpd dp_usbpd; -}; - -int dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd) -{ - int rc = 0; - struct dp_hpd_private *hpd_priv; - - hpd_priv = container_of(dp_usbpd, struct dp_hpd_private, - dp_usbpd); - - if (!hpd_priv->dp_cb || !hpd_priv->dp_cb->configure - || !hpd_priv->dp_cb->disconnect) { - pr_err("hpd dp_cb not initialized\n"); - return -EINVAL; - } - if (hpd) - hpd_priv->dp_cb->configure(hpd_priv->dev); - else - hpd_priv->dp_cb->disconnect(hpd_priv->dev); - - return rc; -} - -struct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb) -{ - struct dp_hpd_private *dp_hpd; - - if (!cb) { - pr_err("invalid cb data\n"); - return ERR_PTR(-EINVAL); - } - - dp_hpd = devm_kzalloc(dev, sizeof(*dp_hpd), GFP_KERNEL); - if (!dp_hpd) - return ERR_PTR(-ENOMEM); - - dp_hpd->dev = dev; - dp_hpd->dp_cb = cb; - - dp_hpd->dp_usbpd.connect = dp_hpd_connect; - - return &dp_hpd->dp_usbpd; -} diff --git a/drivers/gpu/drm/msm/dp/dp_hpd.h b/drivers/gpu/drm/msm/dp/dp_hpd.h deleted file mode 100644 index 8feec5aa5027..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_hpd.h +++ /dev/null @@ -1,78 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#ifndef _DP_HPD_H_ -#define _DP_HPD_H_ - -//#include <linux/usb/usbpd.h> - -#include <linux/types.h> -#include <linux/device.h> - -enum plug_orientation { - ORIENTATION_NONE, - ORIENTATION_CC1, - ORIENTATION_CC2, -}; - -/** - * struct dp_usbpd - DisplayPort status - * - * @orientation: plug orientation configuration - * @low_pow_st: low power state - * @adaptor_dp_en: adaptor functionality enabled - * @multi_func: multi-function preferred - * @usb_config_req: request to switch to usb - * @exit_dp_mode: request exit from displayport mode - * @hpd_irq: Change in the status since last message - * @alt_mode_cfg_done: bool to specify alt mode status - * @debug_en: bool to specify debug mode - * @connect: simulate disconnect or connect for debug mode - */ -struct dp_usbpd { - enum plug_orientation orientation; - bool low_pow_st; - bool adaptor_dp_en; - bool multi_func; - bool usb_config_req; - bool exit_dp_mode; - bool hpd_irq; - bool alt_mode_cfg_done; - bool debug_en; - - int (*connect)(struct dp_usbpd *dp_usbpd, bool hpd); -}; - -/** - * struct dp_usbpd_cb - callback functions provided by the client - * - * @configure: called by usbpd module when PD communication has - * been completed and the usb peripheral has been configured on - * dp mode. - * @disconnect: notify the cable disconnect issued by usb. - * @attention: notify any attention message issued by usb. - */ -struct dp_usbpd_cb { - int (*configure)(struct device *dev); - int (*disconnect)(struct device *dev); - int (*attention)(struct device *dev); -}; - -/** - * dp_hpd_get() - setup hpd module - * - * @dev: device instance of the caller - * @cb: struct containing callback function pointers. - * - * This function allows the client to initialize the usbpd - * module. The module will communicate with HPD module. - */ -struct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb); - -int dp_hpd_register(struct dp_usbpd *dp_usbpd); -void dp_hpd_unregister(struct dp_usbpd *dp_usbpd); -int dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd); - -#endif /* _DP_HPD_H_ */ diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h b/drivers/gpu/drm/msm/dp/dp_panel.h index acb1987fa45f..d55e28f1000f 100644 --- a/drivers/gpu/drm/msm/dp/dp_panel.h +++ b/drivers/gpu/drm/msm/dp/dp_panel.h @@ -10,7 +10,6 @@
#include "dp_aux.h" #include "dp_link.h" -#include "dp_hpd.h"
struct edid;
diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c index d9e011775ad8..faa3bfbccc9e 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.c +++ b/drivers/gpu/drm/msm/dp/dp_power.c @@ -352,7 +352,7 @@ void dp_power_client_deinit(struct dp_power *dp_power)
}
-int dp_power_init(struct dp_power *dp_power, bool flip) +int dp_power_init(struct dp_power *dp_power) { int rc = 0; struct dp_power_private *power = NULL; diff --git a/drivers/gpu/drm/msm/dp/dp_power.h b/drivers/gpu/drm/msm/dp/dp_power.h index e3f959ffae12..a3dec200785e 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.h +++ b/drivers/gpu/drm/msm/dp/dp_power.h @@ -26,13 +26,12 @@ struct dp_power { * dp_power_init() - enable power supplies for display controller * * @power: instance of power module - * @flip: bool for flipping gpio direction * return: 0 if success or error if failure. * * This API will turn on the regulators and configures gpio's * aux/hpd. */ -int dp_power_init(struct dp_power *power, bool flip); +int dp_power_init(struct dp_power *power);
/** * dp_power_deinit() - turn off regulators and gpios.
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org ---
Changes since v3: - Implements hpd_notify instead of oob_hotplug_event - Rebased on new cleanup patch from Dmitry - Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
+ bool connected; + struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root; @@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
+ dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type; @@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); } + +void dp_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status) +{ + struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge); + struct msm_dp *dp = dp_bridge->dp_display; + struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display); + int ret; + + drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected); + + if (!dp_display->connected && status == connector_status_connected) { + dp_display->connected = true; + ret = dp_display_usbpd_configure(dp_display); + if (!ret) + dp_display->hpd_state = ST_MAINLINK_READY; + } else if (status != connector_status_connected) { + dp_display->connected = false; + dp_display_notify_disconnect(dp_display); + } else { + dp_display_usbpd_attention(dp_display); + } +} diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h"
struct msm_dp { + struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge; diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect, + .hpd_notify = dp_bridge_hpd_notify, };
struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev, @@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
+ connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev)); + drm_connector_attach_encoder(connector, dp_display->encoder);
return connector; diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge, + enum drm_connector_status status);
#endif /* _DP_DRM_H_ */
On 5/2/2022 9:53 AM, Bjorn Andersson wrote:
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
Implements hpd_notify instead of oob_hotplug_event
Rebased on new cleanup patch from Dmitry
Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
- bool connected;
- struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root;
@@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
- dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type;
@@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); }
+void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
+{
- struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
- struct msm_dp *dp = dp_bridge->dp_display;
- struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display);
- int ret;
- drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected);
- if (!dp_display->connected && status == connector_status_connected) {
dp_display->connected = true;
ret = dp_display_usbpd_configure(dp_display);
if (!ret)
dp_display->hpd_state = ST_MAINLINK_READY;
- } else if (status != connector_status_connected) {
dp_display->connected = false;
dp_display_notify_disconnect(dp_display);
- } else {
dp_display_usbpd_attention(dp_display);
- }
+}
I would assume dp_bridge_hpd_notify() will server same purpose as dp_display_irq_handler() if hpd_notification is enabled.
In that case, should dp_bridge_hpd_notify() add EV_HPD_PLUG_INT/EV_IRQ_HPD_INT/EV_HPD_UNPLUG_INT
into event q to kick off corresponding dp_hpd_plug_handle()/dp_irq_hpd_handle()/dp_hpd_unplug_handle()?
By the way, I am going to test this patch out.
Any patches I have to pull in before apply this serial patches?
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h"
struct msm_dp {
- struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect,
.hpd_notify = dp_bridge_hpd_notify, };
struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
@@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev));
drm_connector_attach_encoder(connector, dp_display->encoder);
return connector;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status);
#endif /* _DP_DRM_H_ */
On Mon 02 May 13:59 PDT 2022, Kuogee Hsieh wrote:
On 5/2/2022 9:53 AM, Bjorn Andersson wrote:
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
Implements hpd_notify instead of oob_hotplug_event
Rebased on new cleanup patch from Dmitry
Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
- bool connected;
- struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root;
@@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
- dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type;
@@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); }
+void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
+{
- struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
- struct msm_dp *dp = dp_bridge->dp_display;
- struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display);
- int ret;
- drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected);
- if (!dp_display->connected && status == connector_status_connected) {
dp_display->connected = true;
ret = dp_display_usbpd_configure(dp_display);
if (!ret)
dp_display->hpd_state = ST_MAINLINK_READY;
- } else if (status != connector_status_connected) {
dp_display->connected = false;
dp_display_notify_disconnect(dp_display);
- } else {
dp_display_usbpd_attention(dp_display);
- }
+}
I would assume dp_bridge_hpd_notify() will server same purpose as dp_display_irq_handler() if hpd_notification is enabled.
I agree with this statement.
In that case, should dp_bridge_hpd_notify() add EV_HPD_PLUG_INT/EV_IRQ_HPD_INT/EV_HPD_UNPLUG_INT
I tried this originally, but couldn't get it to work and expected that as the downstream driver doesn't do this, there was some good reason for me not to do it either.
into event q to kick off corresponding dp_hpd_plug_handle()/dp_irq_hpd_handle()/dp_hpd_unplug_handle()?
But since then the driver has been cleaned up significantly, so I decided to give it a test again. Unfortunately it still doesn't work, but now it's easier to trace.
Replacing the 3 cases with relevant calls to dp_add_event() results in us inserting a EV_HPD_UNPLUG_INT event really early, before things has been brought up. This will result in dp_hpd_unplug_handle() trying to disable the dp_catalog_hpd_config_intr(), which will crash as the hardware isn't yet clocked up.
Further more, this points out the main difference between the normal HPD code and the USB HPD code; dp_catalog_hpd_config_intr() will enable the plug/unplug interrupts, which it shouldn't do for USB-controlled.
So it seems we need two code paths after all.
By the way, I am going to test this patch out.
Any patches I have to pull in before apply this serial patches?
The patches applies on Dmitry's msm-next-staging, which I've merged on top of linux-next together with a number of pending patches to get the DPU up on SM8350 and a pmic_glink driver which I'm about to post.
But to validate that it doesn't affect your non-USB case, Dmitry's branch should be sufficient.
Thanks, Bjorn
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h" struct msm_dp {
- struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect,
- .hpd_notify = dp_bridge_hpd_notify, }; struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
@@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
- connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev));
- drm_connector_attach_encoder(connector, dp_display->encoder); return connector;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge,
#endif /* _DP_DRM_H_ */enum drm_connector_status status);
On 5/2/2022 3:29 PM, Bjorn Andersson wrote:
On Mon 02 May 13:59 PDT 2022, Kuogee Hsieh wrote:
On 5/2/2022 9:53 AM, Bjorn Andersson wrote:
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
Implements hpd_notify instead of oob_hotplug_event
Rebased on new cleanup patch from Dmitry
Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
- bool connected;
- struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root;
@@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
- dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type;
@@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); }
+void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
+{
- struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
- struct msm_dp *dp = dp_bridge->dp_display;
- struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display);
- int ret;
- drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected);
- if (!dp_display->connected && status == connector_status_connected) {
dp_display->connected = true;
ret = dp_display_usbpd_configure(dp_display);
if (!ret)
dp_display->hpd_state = ST_MAINLINK_READY;
- } else if (status != connector_status_connected) {
dp_display->connected = false;
dp_display_notify_disconnect(dp_display);
- } else {
dp_display_usbpd_attention(dp_display);
- }
+}
I would assume dp_bridge_hpd_notify() will server same purpose as dp_display_irq_handler() if hpd_notification is enabled.
I agree with this statement.
In that case, should dp_bridge_hpd_notify() add EV_HPD_PLUG_INT/EV_IRQ_HPD_INT/EV_HPD_UNPLUG_INT
I tried this originally, but couldn't get it to work and expected that as the downstream driver doesn't do this, there was some good reason for me not to do it either.
into event q to kick off corresponding dp_hpd_plug_handle()/dp_irq_hpd_handle()/dp_hpd_unplug_handle()?
But since then the driver has been cleaned up significantly, so I decided to give it a test again. Unfortunately it still doesn't work, but now it's easier to trace.
Replacing the 3 cases with relevant calls to dp_add_event() results in us inserting a EV_HPD_UNPLUG_INT event really early, before things has been brought up. This will result in dp_hpd_unplug_handle() trying to disable the dp_catalog_hpd_config_intr(), which will crash as the hardware isn't yet clocked up.
Further more, this points out the main difference between the normal HPD code and the USB HPD code; dp_catalog_hpd_config_intr() will enable the plug/unplug interrupts, which it shouldn't do for USB-controlled.
So it seems we need two code paths after all.
By the way, I am going to test this patch out.
Any patches I have to pull in before apply this serial patches?
The patches applies on Dmitry's msm-next-staging, which I've merged on top of linux-next together with a number of pending patches to get the DPU up on SM8350 and a pmic_glink driver which I'm about to post.
But to validate that it doesn't affect your non-USB case, Dmitry's branch should be sufficient.
Thanks, Bjorn
Hi Bjorn,
Which release image you had flashed?
I have ChromeOS-test-R100-14526.69.0-trogdor.tar flashed.
1) Is this will work?
2) how about EC? do I need to upgrade EC image?
Thanks,
kuogee
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h" struct msm_dp {
- struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect,
- .hpd_notify = dp_bridge_hpd_notify, }; struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
@@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
- connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev));
- drm_connector_attach_encoder(connector, dp_display->encoder); return connector;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge,
#endif /* _DP_DRM_H_ */enum drm_connector_status status);
On Mon 02 May 15:49 PDT 2022, Kuogee Hsieh wrote:
On 5/2/2022 3:29 PM, Bjorn Andersson wrote:
On Mon 02 May 13:59 PDT 2022, Kuogee Hsieh wrote:
On 5/2/2022 9:53 AM, Bjorn Andersson wrote:
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
Implements hpd_notify instead of oob_hotplug_event
Rebased on new cleanup patch from Dmitry
Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
- bool connected;
- struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root;
@@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
- dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type;
@@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); }
+void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
+{
- struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
- struct msm_dp *dp = dp_bridge->dp_display;
- struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display);
- int ret;
- drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected);
- if (!dp_display->connected && status == connector_status_connected) {
dp_display->connected = true;
ret = dp_display_usbpd_configure(dp_display);
if (!ret)
dp_display->hpd_state = ST_MAINLINK_READY;
- } else if (status != connector_status_connected) {
dp_display->connected = false;
dp_display_notify_disconnect(dp_display);
- } else {
dp_display_usbpd_attention(dp_display);
- }
+}
I would assume dp_bridge_hpd_notify() will server same purpose as dp_display_irq_handler() if hpd_notification is enabled.
I agree with this statement.
In that case, should dp_bridge_hpd_notify() add EV_HPD_PLUG_INT/EV_IRQ_HPD_INT/EV_HPD_UNPLUG_INT
I tried this originally, but couldn't get it to work and expected that as the downstream driver doesn't do this, there was some good reason for me not to do it either.
into event q to kick off corresponding dp_hpd_plug_handle()/dp_irq_hpd_handle()/dp_hpd_unplug_handle()?
But since then the driver has been cleaned up significantly, so I decided to give it a test again. Unfortunately it still doesn't work, but now it's easier to trace.
Replacing the 3 cases with relevant calls to dp_add_event() results in us inserting a EV_HPD_UNPLUG_INT event really early, before things has been brought up. This will result in dp_hpd_unplug_handle() trying to disable the dp_catalog_hpd_config_intr(), which will crash as the hardware isn't yet clocked up.
Further more, this points out the main difference between the normal HPD code and the USB HPD code; dp_catalog_hpd_config_intr() will enable the plug/unplug interrupts, which it shouldn't do for USB-controlled.
So it seems we need two code paths after all.
By the way, I am going to test this patch out.
Any patches I have to pull in before apply this serial patches?
The patches applies on Dmitry's msm-next-staging, which I've merged on top of linux-next together with a number of pending patches to get the DPU up on SM8350 and a pmic_glink driver which I'm about to post.
But to validate that it doesn't affect your non-USB case, Dmitry's branch should be sufficient.
Thanks, Bjorn
Hi Bjorn,
Which release image you had flashed?
I have ChromeOS-test-R100-14526.69.0-trogdor.tar flashed.
Is this will work?
how about EC? do I need to upgrade EC image?
I'm not aware of the state of EC firmware for Trogdor for invoking the USB Type-C code path. As of today Trogdor relies on the EC signalling HPD using a GPIO.
I'm testing this on SM8350 and SC8180X using pmic_glink. Also, going forward we will have to continue supporting both hardware IRQ and this oob based HPD interrupts (as both combinations are valid).
Regards, Bjorn
Thanks,
kuogee
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h" struct msm_dp {
- struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect,
- .hpd_notify = dp_bridge_hpd_notify, }; struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
@@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
- connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev));
- drm_connector_attach_encoder(connector, dp_display->encoder); return connector;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge,
#endif /* _DP_DRM_H_ */enum drm_connector_status status);
On Mon 02 May 15:29 PDT 2022, Bjorn Andersson wrote:
On Mon 02 May 13:59 PDT 2022, Kuogee Hsieh wrote:
On 5/2/2022 9:53 AM, Bjorn Andersson wrote:
The Qualcomm DisplayPort driver contains traces of the necessary plumbing to hook up USB HPD, in the form of the dp_hpd module and the dp_usbpd_cb struct. Use this as basis for implementing the hpd_notify() callback, by amending the dp_hpd module with the missing logic.
Overall the solution is similar to what's done downstream, but upstream all the code to disect the HPD notification lives on the calling side of drm_connector_oob_hotplug_event().
drm_connector_oob_hotplug_event() performs the lookup of the drm_connector based on fwnode, hence the need to assign the fwnode in dp_drm_connector_init().
Signed-off-by: Bjorn Andersson bjorn.andersson@linaro.org
Changes since v3:
Implements hpd_notify instead of oob_hotplug_event
Rebased on new cleanup patch from Dmitry
Set hpd_state to ST_MAINLINK_READY when dp_display_usbpd_configure() succeeds
drivers/gpu/drm/msm/dp/dp_display.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_display.h | 1 + drivers/gpu/drm/msm/dp/dp_drm.c | 3 +++ drivers/gpu/drm/msm/dp/dp_drm.h | 2 ++ 4 files changed, 32 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b447446d75e9..080294ac6144 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -83,6 +83,8 @@ struct dp_display_private { bool hpd_irq_on; bool audio_supported;
- bool connected;
- struct drm_device *drm_dev; struct platform_device *pdev; struct dentry *root;
@@ -1271,6 +1273,7 @@ static int dp_display_probe(struct platform_device *pdev) if (!desc) return -EINVAL;
- dp->dp_display.dev = &pdev->dev; dp->pdev = pdev; dp->name = "drm_dp"; dp->dp_display.connector_type = desc->connector_type;
@@ -1760,3 +1763,26 @@ void dp_bridge_mode_set(struct drm_bridge *drm_bridge, dp_display->dp_mode.h_active_low = !!(dp_display->dp_mode.drm_mode.flags & DRM_MODE_FLAG_NHSYNC); }
+void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
+{
- struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
- struct msm_dp *dp = dp_bridge->dp_display;
- struct dp_display_private *dp_display = container_of(dp, struct dp_display_private, dp_display);
- int ret;
- drm_dbg_dp(dp_display->drm_dev, "status: %d connected: %d\n", status, dp_display->connected);
- if (!dp_display->connected && status == connector_status_connected) {
dp_display->connected = true;
ret = dp_display_usbpd_configure(dp_display);
if (!ret)
dp_display->hpd_state = ST_MAINLINK_READY;
- } else if (status != connector_status_connected) {
dp_display->connected = false;
dp_display_notify_disconnect(dp_display);
- } else {
dp_display_usbpd_attention(dp_display);
- }
+}
I would assume dp_bridge_hpd_notify() will server same purpose as dp_display_irq_handler() if hpd_notification is enabled.
I agree with this statement.
In that case, should dp_bridge_hpd_notify() add EV_HPD_PLUG_INT/EV_IRQ_HPD_INT/EV_HPD_UNPLUG_INT
I tried this originally, but couldn't get it to work and expected that as the downstream driver doesn't do this, there was some good reason for me not to do it either.
into event q to kick off corresponding dp_hpd_plug_handle()/dp_irq_hpd_handle()/dp_hpd_unplug_handle()?
But since then the driver has been cleaned up significantly, so I decided to give it a test again. Unfortunately it still doesn't work, but now it's easier to trace.
Replacing the 3 cases with relevant calls to dp_add_event() results in us inserting a EV_HPD_UNPLUG_INT event really early, before things has been brought up. This will result in dp_hpd_unplug_handle() trying to disable the dp_catalog_hpd_config_intr(), which will crash as the hardware isn't yet clocked up.
As I sent that I realized and have now confirmed that if I get a HPD connect before dp_display_host_init() things will not be in an appropriate state to either and the board will crash...
I will dig a little bit more to see what we can do about this.
Regards, Bjorn
Further more, this points out the main difference between the normal HPD code and the USB HPD code; dp_catalog_hpd_config_intr() will enable the plug/unplug interrupts, which it shouldn't do for USB-controlled.
So it seems we need two code paths after all.
By the way, I am going to test this patch out.
Any patches I have to pull in before apply this serial patches?
The patches applies on Dmitry's msm-next-staging, which I've merged on top of linux-next together with a number of pending patches to get the DPU up on SM8350 and a pmic_glink driver which I'm about to post.
But to validate that it doesn't affect your non-USB case, Dmitry's branch should be sufficient.
Thanks, Bjorn
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 4f9fe4d7610b..2d2614bc5a14 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -11,6 +11,7 @@ #include "disp/msm_disp_snapshot.h" struct msm_dp {
- struct device *dev; struct drm_device *drm_dev; struct device *codec_dev; struct drm_bridge *bridge;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index 62d58b9c4647..821cfd37b1fb 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -68,6 +68,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = { .mode_valid = dp_bridge_mode_valid, .get_modes = dp_bridge_get_modes, .detect = dp_bridge_detect,
- .hpd_notify = dp_bridge_hpd_notify, }; struct drm_bridge *dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
@@ -138,6 +139,8 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display) if (IS_ERR(connector)) return connector;
- connector->fwnode = fwnode_handle_get(dev_fwnode(dp_display->dev));
- drm_connector_attach_encoder(connector, dp_display->encoder); return connector;
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.h b/drivers/gpu/drm/msm/dp/dp_drm.h index f4b1ed1e24f7..3b7480a86844 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.h +++ b/drivers/gpu/drm/msm/dp/dp_drm.h @@ -32,5 +32,7 @@ enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge, void dp_bridge_mode_set(struct drm_bridge *drm_bridge, const struct drm_display_mode *mode, const struct drm_display_mode *adjusted_mode); +void dp_bridge_hpd_notify(struct drm_bridge *bridge,
#endif /* _DP_DRM_H_ */enum drm_connector_status status);
dri-devel@lists.freedesktop.org