drm: zynqmp_dp: IRQ cleanups and debugfs support
Subsystems (5)
v6 cover drm: zynqmp_dp: IRQ cleanups and debugfs support
This series cleans up the zyqnmp_dp IRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.
Previously, I discussed converting the HPD work(s) to a threaded IRQ. I did not end up doing that for this series since the steps would be
- Add locking
- Move link retraining to a work function
- Harden the IRQ
- Merge the works into a threaded IRQ (omitted)
Which with the exception of the final step is the same as leaving those works as-is. Conversion to a threaded IRQ can be done as a follow-up.
Changes in v6:
- Unplug DRM device before removal
- Fix hang upon driver removal
- Rebase onto drm-misc/drm-misc-next
Changes in v5:
- Rebase onto drm-misc/drm-misc-next
Changes in v4:
- Rebase onto drm/drm-next
Changes in v3:
- Convert to a hard IRQ
- Use AUX IRQs instead of polling
- Take dp->lock in zynqmp_dp_hpd_work_func
Changes in v2:
- Split off the HPD IRQ work into another commit
- Expand the commit message
- Document hpd_irq_work
- Document debugfs files
- Add ignore_aux_errors and ignore_hpd debugfs files to replace earlier implicit functionality
- Attempt to fix unreproducable, spurious build warning
- Drop "Optionally ignore DPCD errors" in favor of a debugfs file directly affecting zynqmp_dp_aux_transfer.
Sean Anderson (8):
drm: zynqmp_kms: Unplug DRM device before removal
drm: zynqmp_dp: Add locking
drm: zynqmp_dp: Don't retrain the link in our IRQ
drm: zynqmp_dp: Convert to a hard IRQ
drm: zynqmp_dp: Use AUX IRQs instead of polling
drm: zynqmp_dp: Split off several helper functions
drm: zynqmp_dp: Take dp->lock in zynqmp_dp_hpd_work_func
drm: zynqmp_dp: Add debugfs interface for compliance testing
Documentation/gpu/drivers.rst | 1 + Documentation/gpu/zynqmp.rst | 149 ++++++ MAINTAINERS | 1 + drivers/gpu/drm/xlnx/zynqmp_dp.c | 846 ++++++++++++++++++++++++++++-- drivers/gpu/drm/xlnx/zynqmp_kms.c | 2 +- 5 files changed, 951 insertions(+), 48 deletions(-) create mode 100644 Documentation/gpu/zynqmp.rst
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 1/8 drm: zynqmp_kms: Unplug DRM device before removal
Prevent userspace accesses to the DRM device from causing use-after-frees by unplugging the device before we remove it. This causes any further userspace accesses to result in an error without further calls into this driver's internals.
---
Thanks to Maxime for pointing out the correct function to use here.
Changes in v6:
- New
drivers/gpu/drm/xlnx/zynqmp_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xlnx/zynqmp_kms.c +1 -1
@@ -536,7 +536,7 @@ void zynqmp_dpsub_drm_cleanup(struct zynqmp_dpsub *dpsub) {struct drm_device *drm = &dpsub->drm->dev; -drm_dev_unregister (drm); +drm_dev_unplug (drm);drm_atomic_helper_shutdown (drm);drm_encoder_cleanup (&dpsub->drm->encoder);drm_kms_helper_poll_fini (drm);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 2/8 drm: zynqmp_dp: Add locking
In reply to Sean AndersonAdd some locking to prevent the IRQ/workers/bridge API calls from stepping on each other's toes. This lock protects:
- Non-atomic registers configuring the link. That is, everything but the IRQ registers (since these are accessed in an atomic fashion), and the DP AUX registers (since these don't affect the link). We also access AUX while holding this lock, so it would be very tricky to support.
- Link configuration. This is effectively everything in zynqmp_dp which isn't read-only after probe time. So from next_bridge onward.
This lock is designed to protect configuration changes so we don't have to do anything tricky. Configuration should never be in the hot path, so I'm not worried about performance.
---
(no changes since v2)
Changes in v2:
- Split off the HPD IRQ work into another commit
- Expand the commit message
drivers/gpu/drm/xlnx/zynqmp_dp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/xlnx/zynqmp_dp.c +18 -0
@@ -280,6 +280,7 @@ struct zynqmp_dp_config {* @dpsub: Display subsystem * @iomem: device I/O memory for register access * @reset: reset controller +* @lock: Mutex protecting this struct and register access (but not AUX) * @irq: irq * @bridge: DRM bridge for the DP encoder * @next_bridge: The downstream bridge
@@ -294,11 +295,16 @@ struct zynqmp_dp_config {* @link_config: common link configuration between IP core and sink device * @mode: current mode between IP core and sink device * @train_set: set of training data +* +* @lock covers the link configuration in this struct and the device's +* registers. It does not cover @aux. It is not strictly required for any of +* the members which are only modified at probe/remove time (e.g. @dev). */ struct zynqmp_dp {struct drm_dp_aux aux;struct drm_bridge bridge;struct work_struct hpd_work; +struct mutex lock;struct drm_bridge *next_bridge;struct device *dev;
@@ -1386,8 +1392,10 @@ zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge, }/* Check with link rate and lane count */ +mutex_lock (&dp->lock); rate =zynqmp_dp_max_rate (dp->link_config.max_rate, dp->link_config.max_lanes, dp->config.bpp); +mutex_unlock (&dp->lock);if (mode->clock > rate) {dev_dbg (dp->dev,"filtered mode %s for high pixel rate\n" , mode->name);
@@ -1414,6 +1422,7 @@ static void zynqmp_dp_bridge_atomic_enable(struct drm_bridge *bridge,pm_runtime_get_sync (dp->dev); +mutex_lock (&dp->lock);zynqmp_dp_disp_enable (dp, old_bridge_state);/*
@@ -1474,6 +1483,7 @@ static void zynqmp_dp_bridge_atomic_enable(struct drm_bridge *bridge,zynqmp_dp_write (dp,ZYNQMP_DP_SOFTWARE_RESET ,ZYNQMP_DP_SOFTWARE_RESET_ALL );zynqmp_dp_write (dp,ZYNQMP_DP_MAIN_STREAM_ENABLE ,1 ); +mutex_unlock (&dp->lock); } static void zynqmp_dp_bridge_atomic_disable(struct drm_bridge *bridge,
@@ -1481,6 +1491,7 @@ static void zynqmp_dp_bridge_atomic_disable(struct drm_bridge *bridge, {struct zynqmp_dp *dp =bridge_to_dp (bridge); +mutex_lock (&dp->lock); dp->enabled = false;cancel_work (&dp->hpd_work);zynqmp_dp_write (dp,ZYNQMP_DP_MAIN_STREAM_ENABLE ,0 );
@@ -1491,6 +1502,7 @@ static void zynqmp_dp_bridge_atomic_disable(struct drm_bridge *bridge,zynqmp_dp_write (dp,ZYNQMP_DP_TX_AUDIO_CONTROL ,0 );zynqmp_dp_disp_disable (dp, old_bridge_state); +mutex_unlock (&dp->lock);pm_runtime_put_sync (dp->dev); }
@@ -1533,6 +1545,8 @@ static enum drm_connector_status zynqmp_dp_bridge_detect(struct drm_bridge *bridu32 state, i;int ret; +mutex_lock (&dp->lock); +/* * This is from heuristic. It takes some delay (ex, 100 ~ 500 msec) to * get the HPD signal with some monitors.
@@ -1560,11 +1574,13 @@ static enum drm_connector_status zynqmp_dp_bridge_detect(struct drm_bridge *brid dp->num_lanes); dp->status = connector_status_connected; +mutex_unlock (&dp->lock);return connector_status_connected; } disconnected: dp->status = connector_status_disconnected; +mutex_unlock (&dp->lock);return connector_status_disconnected; }
@@ -1725,6 +1741,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) dp->dev = &pdev->dev; dp->dpsub = dpsub; dp->status = connector_status_disconnected; +mutex_init (&dp->lock);INIT_WORK (&dp->hpd_work, zynqmp_dp_hpd_work_func);
@@ -1838,4 +1855,5 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)zynqmp_dp_phy_exit (dp);zynqmp_dp_reset (dp, true); +mutex_destroy (&dp->lock); }
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 3/8 drm: zynqmp_dp: Don't retrain the link in our IRQ
In reply to Sean AndersonRetraining the link can take a while, and might involve waiting for DPCD reads/writes to complete. In preparation for unthreading the IRQ handler, move this into its own work function.
---
(no changes since v2)
Changes in v2:
- Document hpd_irq_work
- Split this off from the locking changes
drivers/gpu/drm/xlnx/zynqmp_dp.c | 45 ++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +29 -16
@@ -289,6 +289,7 @@ struct zynqmp_dp_config {* @phy: PHY handles for DP lanes * @num_lanes: number of enabled phy lanes * @hpd_work: hot plug detection worker +* @hpd_irq_work: hot plug detection IRQ worker * @status: connection status * @enabled: flag to indicate if the device is enabled * @dpcd: DP configuration data from currently connected sink device
@@ -304,6 +305,7 @@ struct zynqmp_dp {struct drm_dp_aux aux;struct drm_bridge bridge;struct work_struct hpd_work; +struct work_struct hpd_irq_work;struct mutex lock;struct drm_bridge *next_bridge;
@@ -1671,6 +1673,29 @@ static void zynqmp_dp_hpd_work_func(struct work_struct *work)drm_bridge_hpd_notify (&dp->bridge, status); } +static void zynqmp_dp_hpd_irq_work_func (struct work_struct *work) +{ + struct zynqmp_dp *dp = container_of(work, struct zynqmp_dp, + hpd_irq_work); +u8 status[DP_LINK_STATUS_SIZE +2 ]; +int err; + +mutex_lock (&dp->lock); + err =drm_dp_dpcd_read (&dp->aux,DP_SINK_COUNT , status, +DP_LINK_STATUS_SIZE +2 ); +if (err <0 ) { +dev_dbg_ratelimited (dp->dev, +"could not read sink status: %d\n" , err); + }else { +if (status[4 ] &DP_LINK_STATUS_UPDATED || + !drm_dp_clock_recovery_ok (&status[2 ], dp->mode.lane_cnt) || + !drm_dp_channel_eq_ok (&status[2 ], dp->mode.lane_cnt)) { +zynqmp_dp_train_loop (dp); + } + } +mutex_unlock (&dp->lock); +} +static irqreturn_t zynqmp_dp_irq_handler (int irq,void *data) {struct zynqmp_dp *dp = (struct zynqmp_dp *)data;
@@ -1702,23 +1727,9 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data)if (status &ZYNQMP_DP_INT_HPD_EVENT )schedule_work (&dp->hpd_work); -if (status &ZYNQMP_DP_INT_HPD_IRQ ) { -int ret; -u8 status[DP_LINK_STATUS_SIZE +2 ]; +if (status &ZYNQMP_DP_INT_HPD_IRQ ) +schedule_work (&dp->hpd_irq_work); - ret =drm_dp_dpcd_read (&dp->aux,DP_SINK_COUNT , status, -DP_LINK_STATUS_SIZE +2 ); -if (ret <0 ) - goto handled; - -if (status[4 ] &DP_LINK_STATUS_UPDATED || - !drm_dp_clock_recovery_ok (&status[2 ], dp->mode.lane_cnt) || - !drm_dp_channel_eq_ok (&status[2 ], dp->mode.lane_cnt)) { -zynqmp_dp_train_loop (dp); - } - } - -handled:return IRQ_HANDLED ; }
@@ -1744,6 +1755,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)mutex_init (&dp->lock);INIT_WORK (&dp->hpd_work, zynqmp_dp_hpd_work_func); +INIT_WORK (&dp->hpd_irq_work, zynqmp_dp_hpd_irq_work_func);/* Acquire all resources (IOMEM, IRQ and PHYs). */ res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dp" );
@@ -1848,6 +1860,7 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)zynqmp_dp_write (dp,ZYNQMP_DP_INT_DS ,ZYNQMP_DP_INT_ALL );disable_irq (dp->irq); +cancel_work_sync (&dp->hpd_irq_work);cancel_work_sync (&dp->hpd_work);zynqmp_dp_write (dp,ZYNQMP_DP_TRANSMITTER_ENABLE ,0 );
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 4/8 drm: zynqmp_dp: Convert to a hard IRQ
In reply to Sean AndersonNow that all of the sleeping work is done outside of the IRQ, we can convert it to a hard IRQ. Shared IRQs may be triggered even after calling disable_irq, so use free_irq instead which removes our callback altogether.
---
Changes in v6:
- Fix hang upon driver removal
Changes in v3:
- New
drivers/gpu/drm/xlnx/zynqmp_dp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +3 -4
@@ -1831,9 +1831,8 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)* Now that the hardware is initialized and won't generate spurious * interrupts, request the IRQ. */ - ret =devm_request_threaded_irq (dp->dev, dp->irq,NULL , - zynqmp_dp_irq_handler,IRQF_ONESHOT , -dev_name (dp->dev), dp); + ret =devm_request_irq (dp->dev, dp->irq, zynqmp_dp_irq_handler, +IRQF_SHARED ,dev_name (dp->dev), dp);if (ret <0 ) goto err_phy_exit;
@@ -1858,7 +1857,7 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)struct zynqmp_dp *dp = dpsub->dp;zynqmp_dp_write (dp,ZYNQMP_DP_INT_DS ,ZYNQMP_DP_INT_ALL ); -disable_irq (dp->irq); +devm_free_irq (dp->dev, dp->irq, dp);cancel_work_sync (&dp->hpd_irq_work);cancel_work_sync (&dp->hpd_work);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Re: [PATCH v6 4/8] drm: zynqmp_dp: Convert to a hard IRQ
Hi,
Quoted 34 lines · Sean Anderson
Now that all of the sleeping work is done outside of the IRQ, we can convert it to a hard IRQ. Shared IRQs may be triggered even after calling
disable_irq, so usefree_irqinstead which removes our callback altogether.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Fix hang upon driver removalChanges in v3:
- Newdrivers/gpu/drm/xlnx/zynqmp_dp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/gpu/drm/xlnx/zynqmp_dp.c +2
-3@@ -1831,9 +1831,8 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)* Now that the hardware is initialized and won't generate spurious * interrupts, request the IRQ. */ - ret =devm_request_threaded_irq (dp->dev, dp->irq,NULL , - zynqmp_dp_irq_handler,IRQF_ONESHOT , -dev_name (dp->dev), dp); + ret =devm_request_irq (dp->dev, dp->irq, zynqmp_dp_irq_handler, +IRQF_SHARED ,dev_name (dp->dev), dp);if (ret <0 ) goto err_phy_exit;
drivers/gpu/drm/xlnx/zynqmp_dp.c void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub) · line 1863
Quoted 8 lines
drivers/gpu/drm/xlnx/zynqmp_dp.c +1
-1@@ -1858,7 +1857,7 @@ void zynqmp_dp_remove(struct zynqmp_dpsub *dpsub)struct zynqmp_dp *dp = dpsub->dp;zynqmp_dp_write (dp,ZYNQMP_DP_INT_DS ,ZYNQMP_DP_INT_ALL ); -disable_irq (dp->irq); +devm_free_irq (dp->dev, dp->irq, dp);cancel_work_sync (&dp->hpd_irq_work);cancel_work_sync (&dp->hpd_work);
Not much point using devm for request irq, I think, as it's manually freed.
Another thing, which I think is not an issue at the moment nor related to this series as such, is that we use IRQF_SHARED and zynqmp_dp_irq_handler() will read a DP register right away. This means that if the DP is runtime suspended and we get an interrupt, the driver accesses a register on a suspended IP, which often leads to crash/hang.
Here I think we enable all necessary clocks at probe time, so the DP is always enabled and the above is not an issue.
In any case, even with the current devm:
Tomi
PATCH v6 5/8 drm: zynqmp_dp: Use AUX IRQs instead of polling
In reply to Sean AndersonInstead of polling the status register for the AUX status, just enable the IRQs and signal a completion.
---
(no changes since v3)
Changes in v3:
- New
drivers/gpu/drm/xlnx/zynqmp_dp.c | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +25 -10
@@ -286,6 +286,7 @@ struct zynqmp_dp_config {* @next_bridge: The downstream bridge * @config: IP core configuration from DTS * @aux: aux channel +* @aux_done: Completed when we get an AUX reply or timeout * @phy: PHY handles for DP lanes * @num_lanes: number of enabled phy lanes * @hpd_work: hot plug detection worker
@@ -306,6 +307,7 @@ struct zynqmp_dp {struct drm_bridge bridge;struct work_struct hpd_work;struct work_struct hpd_irq_work; +struct completion aux_done;struct mutex lock;struct drm_bridge *next_bridge;
@@ -942,12 +944,15 @@ static int zynqmp_dp_aux_cmd_submit(struct zynqmp_dp *dp, u32 cmd, u16 addr, u8 *buf, u8 bytes, u8 *reply) { bool is_read = (cmd & AUX_READ_BIT) ? true : false; +unsigned long time_left;u32 reg, i; reg =zynqmp_dp_read (dp,ZYNQMP_DP_INTERRUPT_SIGNAL_STATE );if (reg &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REQUEST )return -EBUSY ; +reinit_completion (&dp->aux_done); +zynqmp_dp_write (dp,ZYNQMP_DP_AUX_ADDRESS , addr);if (!is_read)for (i =0 ; i < bytes; i++)
@@ -962,17 +967,14 @@ static int zynqmp_dp_aux_cmd_submit(struct zynqmp_dp *dp, u32 cmd, u16 addr,zynqmp_dp_write (dp,ZYNQMP_DP_AUX_COMMAND , reg);/* Wait for reply to be delivered upto 2ms */ -for (i =0 ; ; i++) { - reg =zynqmp_dp_read (dp,ZYNQMP_DP_INTERRUPT_SIGNAL_STATE ); -if (reg &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY ) -break ; + time_left =wait_for_completion_timeout (&dp->aux_done, +msecs_to_jiffies (2 )); +if (!time_left) +return -ETIMEDOUT ; -if (reg &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT || - i ==2 ) -return -ETIMEDOUT ; - -usleep_range (1000 ,1100 ); - } + reg =zynqmp_dp_read (dp,ZYNQMP_DP_INTERRUPT_SIGNAL_STATE ); +if (reg &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT ) +return -ETIMEDOUT ; reg =zynqmp_dp_read (dp,ZYNQMP_DP_AUX_REPLY_CODE );if (reply)
@@ -1056,6 +1058,9 @@ static int zynqmp_dp_aux_init(struct zynqmp_dp *dp) (w <<ZYNQMP_DP_AUX_CLK_DIVIDER_AUX_FILTER_SHIFT ) | (rate / (1000 * 1000))); +zynqmp_dp_write (dp,ZYNQMP_DP_INT_EN ,ZYNQMP_DP_INT_REPLY_RECEIVED | +ZYNQMP_DP_INT_REPLY_TIMEOUT ); + dp->aux.name ="ZynqMP DP AUX" ; dp->aux.dev = dp->dev; dp->aux.drm_dev = dp->bridge.dev;
@@ -1073,6 +1078,9 @@ static int zynqmp_dp_aux_init(struct zynqmp_dp *dp)static void zynqmp_dp_aux_cleanup (struct zynqmp_dp *dp) {drm_dp_aux_unregister (&dp->aux); + +zynqmp_dp_write (dp,ZYNQMP_DP_INT_DS ,ZYNQMP_DP_INT_REPLY_RECEIVED | +ZYNQMP_DP_INT_REPLY_TIMEOUT ); }/* -----------------------------------------------------------------------------
@@ -1730,6 +1738,12 @@ static irqreturn_t zynqmp_dp_irq_handler(int irq, void *data)if (status &ZYNQMP_DP_INT_HPD_IRQ )schedule_work (&dp->hpd_irq_work); +if (status &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY ) +complete (&dp->aux_done); + +if (status &ZYNQMP_DP_INTERRUPT_SIGNAL_STATE_REPLY_TIMEOUT ) +complete (&dp->aux_done); +return IRQ_HANDLED ; }
@@ -1753,6 +1767,7 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) dp->dpsub = dpsub; dp->status = connector_status_disconnected;mutex_init (&dp->lock); +init_completion (&dp->aux_done);INIT_WORK (&dp->hpd_work, zynqmp_dp_hpd_work_func);INIT_WORK (&dp->hpd_irq_work, zynqmp_dp_hpd_irq_work_func);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 6/8 drm: zynqmp_dp: Split off several helper functions
In reply to Sean AndersonIn preparation for supporting compliance testing, split off several helper functions. No functional change intended.
---
(no changes since v1)
drivers/gpu/drm/xlnx/zynqmp_dp.c | 49 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 15 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +34 -15
@@ -636,6 +636,7 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,/** * zynqmp_dp_update_vs_emph - Update the training values * @dp: DisplayPort IP core structure +* @train_set: A set of training values * * Update the training values based on the request from sink. The mapped values * are predefined, and values(vs, pe, pc) are from the device manual.
@@ -643,12 +644,12 @@ static void zynqmp_dp_adjust_train(struct zynqmp_dp *dp,* Return: 0 if vs and emph are updated successfully, or the error code returned * by drm_dp_dpcd_write(). */ -static int zynqmp_dp_update_vs_emph (struct zynqmp_dp *dp) +static int zynqmp_dp_update_vs_emph (struct zynqmp_dp *dp,u8 *train_set) {unsigned int i;int ret; - ret =drm_dp_dpcd_write (&dp->aux,DP_TRAINING_LANE0_SET , dp->train_set, + ret =drm_dp_dpcd_write (&dp->aux,DP_TRAINING_LANE0_SET , train_set, dp->mode.lane_cnt);if (ret <0 )return ret;
@@ -656,7 +657,7 @@ static int zynqmp_dp_update_vs_emph(struct zynqmp_dp *dp)for (i =0 ; i < dp->mode.lane_cnt; i++) {u32 reg =ZYNQMP_DP_SUB_TX_PHY_PRECURSOR_LANE_0 + i *4 ;union phy_configure_opts opts = {0 }; -u8 train = dp->train_set[i]; +u8 train = train_set[i]; opts.dp.voltage[0 ] = (train &DP_TRAIN_VOLTAGE_SWING_MASK ) >>DP_TRAIN_VOLTAGE_SWING_SHIFT ;
@@ -700,7 +701,7 @@ static int zynqmp_dp_link_train_cr(struct zynqmp_dp *dp)* So, This loop should exit before 512 iterations */ for (max_tries =0 ; max_tries <512 ; max_tries++) { - ret =zynqmp_dp_update_vs_emph (dp); + ret =zynqmp_dp_update_vs_emph (dp, dp->train_set);if (ret)return ret;
@@ -765,7 +766,7 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp)return ret;for (tries =0 ; tries <DP_MAX_TRAINING_TRIES ; tries++) { - ret =zynqmp_dp_update_vs_emph (dp); + ret =zynqmp_dp_update_vs_emph (dp, dp->train_set);if (ret)return ret;
@@ -788,28 +789,29 @@ static int zynqmp_dp_link_train_ce(struct zynqmp_dp *dp) }/** -* zynqmp_dp_train - Train the link +* zynqmp_dp_setup() - Set up major link parameters * @dp: DisplayPort IP core structure +* @bw_code: The link bandwidth as a multiple of 270 MHz +* @lane_cnt: The number of lanes to use +* @enhanced: Use enhanced framing +* @downspread: Enable spread-spectrum clocking * -* Return: 0 if all trains are done successfully, or corresponding error code. +* Return: 0 on success, or -errno on failure */ -static int zynqmp_dp_train (struct zynqmp_dp *dp) +static int zynqmp_dp_setup (struct zynqmp_dp *dp,u8 bw_code,u8 lane_cnt, +bool enhanced,bool downspread) {u32 reg; -u8 bw_code = dp->mode.bw_code; -u8 lane_cnt = dp->mode.lane_cnt;u8 aux_lane_cnt = lane_cnt; -bool enhanced;int ret;zynqmp_dp_write (dp,ZYNQMP_DP_LANE_COUNT_SET , lane_cnt); - enhanced =drm_dp_enhanced_frame_cap (dp->dpcd);if (enhanced) {zynqmp_dp_write (dp,ZYNQMP_DP_ENHANCED_FRAME_EN ,1 ); aux_lane_cnt |=DP_LANE_COUNT_ENHANCED_FRAME_EN ; } -if (dp->dpcd[3 ] &0x1 ) { +if (downspread) {zynqmp_dp_write (dp,ZYNQMP_DP_DOWNSPREAD_CTL ,1 );drm_dp_dpcd_writeb (&dp->aux,DP_DOWNSPREAD_CTRL ,DP_SPREAD_AMP_0_5 );
@@ -852,8 +854,25 @@ static int zynqmp_dp_train(struct zynqmp_dp *dp) }zynqmp_dp_write (dp,ZYNQMP_DP_PHY_CLOCK_SELECT , reg); - ret =zynqmp_dp_phy_ready (dp); -if (ret <0 ) +return zynqmp_dp_phy_ready (dp); +} + + +/** +* zynqmp_dp_train - Train the link +* @dp: DisplayPort IP core structure +* +* Return: 0 if all trains are done successfully, or corresponding error code. +*/ +static int zynqmp_dp_train (struct zynqmp_dp *dp) +{ +int ret; + + ret =zynqmp_dp_setup (dp, dp->mode.bw_code, dp->mode.lane_cnt, +drm_dp_enhanced_frame_cap (dp->dpcd), + dp->dpcd[DP_MAX_DOWNSPREAD ] & +DP_MAX_DOWNSPREAD_0_5 ); +if (ret)return ret;zynqmp_dp_write (dp,ZYNQMP_DP_SCRAMBLING_DISABLE ,1 );
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 7/8 drm: zynqmp_dp: Take dp->lock in zynqmp_dp_hpd_work_func
In reply to Sean AndersonAdd a non-locking version of zynqmp_dp_bridge_detect and use it in zynqmp_dp_hpd_work_func so we can take the lock explicitly. This will make it easier to check for hpd_ignore when we add debugfs support.
---
(no changes since v3)
Changes in v3:
- New
drivers/gpu/drm/xlnx/zynqmp_dp.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +18 -6
@@ -1567,14 +1567,13 @@ static int zynqmp_dp_bridge_atomic_check(struct drm_bridge *bridge,return 0 ; } -static enum drm_connector_status zynqmp_dp_bridge_detect (struct drm_bridge *bridge) +static enum drm_connector_status __zynqmp_dp_bridge_detect (struct zynqmp_dp *dp) { -struct zynqmp_dp *dp =bridge_to_dp (bridge);struct zynqmp_dp_link_config *link_config = &dp->link_config;u32 state, i;int ret; -mutex_lock (&dp->lock); +lockdep_assert_held (&dp->lock);/* * This is from heuristic. It takes some delay (ex, 100 ~ 500 msec) to
@@ -1603,16 +1602,26 @@ static enum drm_connector_status zynqmp_dp_bridge_detect(struct drm_bridge *brid dp->num_lanes); dp->status = connector_status_connected; -mutex_unlock (&dp->lock);return connector_status_connected; } disconnected: dp->status = connector_status_disconnected; -mutex_unlock (&dp->lock);return connector_status_disconnected; } +static enum drm_connector_status zynqmp_dp_bridge_detect (struct drm_bridge *bridge) +{ +struct zynqmp_dp *dp =bridge_to_dp (bridge); +enum drm_connector_status ret; + +mutex_lock (&dp->lock); + ret =__zynqmp_dp_bridge_detect (dp); +mutex_unlock (&dp->lock); + +return ret; +} +static const struct drm_edid *zynqmp_dp_bridge_edid_read (struct drm_bridge *bridge,struct drm_connector *connector) {
@@ -1696,7 +1705,10 @@ static void zynqmp_dp_hpd_work_func(struct work_struct *work) struct zynqmp_dp *dp = container_of(work, struct zynqmp_dp, hpd_work);enum drm_connector_status status; - status =zynqmp_dp_bridge_detect (&dp->bridge); +mutex_lock (&dp->lock); + status =__zynqmp_dp_bridge_detect (dp); +mutex_unlock (&dp->lock); +drm_bridge_hpd_notify (&dp->bridge, status); }
Signature · 1 line
2.35.1.1320.gc452695387.dirty
PATCH v6 8/8 drm: zynqmp_dp: Add debugfs interface for compliance testing
In reply to Sean AndersonAdd a debugfs interface for exercising the various test modes supported by the DisplayPort controller. This allows performing compliance testing, or performing signal integrity measurements on a failing link. At the moment, we do not support sink-driven link quality testing, although such support would be fairly easy to add.
Additionally, add some debugfs files for ignoring AUX errors and HPD events, as this can allow testing with equipment that cannot emulate a DPRX.
---
(no changes since v2)
Changes in v2:
- Document debugfs files
- Add ignore_aux_errors and ignore_hpd debugfs files to replace earlier implicit functionality
- Attempt to fix unreproducable, spurious build warning
Documentation/gpu/drivers.rst | 1 + Documentation/gpu/zynqmp.rst | 149 +++++++ MAINTAINERS | 1 + drivers/gpu/drm/xlnx/zynqmp_dp.c | 682 ++++++++++++++++++++++++++++++- 4 files changed, 830 insertions(+), 3 deletions(-) create mode 100644 Documentation/gpu/zynqmp.rst
Documentation/gpu/drivers.rst +1 -0
@@ -22,6 +22,7 @@ GPU Driver Documentation afbc komeda-kms panfrost + zynqmp .. only:: subproject and html
Documentation/gpu/zynqmp.rst new file +149 -0
149 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -7570,6 +7570,7 @@ L: [email protected] S: Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/display/xlnx/ +F: Documentation/gpu/zynqmp.rst F: drivers/gpu/drm/xlnx/ DRM GPU SCHEDULER
drivers/gpu/drm/xlnx/zynqmp_dp.c +679 -3
779 lines not on this page · raw message
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Quoted 52 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.Previously, I discussed converting the HPD work(s) to a threaded IRQ. I did not end up doing that for this series since the steps would be
- Add locking
- Move link retraining to a work function
- Harden the IRQ
- Merge the works into a threaded IRQ (omitted)Which with the exception of the final step is the same as leaving those works as-is. Conversion to a threaded IRQ can be done as a follow-up.
Changes in v6:
- Unplug DRM device before removal
- Fix hang upon driver removal
- Rebase onto drm-misc/drm-misc-nextChanges in v5:
- Rebase onto drm-misc/drm-misc-nextChanges in v4:
- Rebase onto drm/drm-nextChanges in v3:
- Convert to a hard IRQ
- Use AUX IRQs instead of polling
- Takedp->lockinzynqmp_dp_hpd_work_funcChanges in v2:
- Split off the HPD IRQ work into another commit
- Expand the commit message
- Documenthpd_irq_work
- Document debugfs files
- Addignore_aux_errorsandignore_hpddebugfs files to replace earlier implicit functionality
- Attempt to fix unreproducable, spurious build warning
- Drop "Optionally ignore DPCD errors" in favor of a debugfs file directly affectingzynqmp_dp_aux_transfer.Sean Anderson (8):
drm:zynqmp_kms: Unplug DRM device before removal
drm:zynqmp_dp: Add locking
drm:zynqmp_dp: Don't retrain the link in our IRQ
drm:zynqmp_dp: Convert to a hard IRQ
drm:zynqmp_dp: Use AUX IRQs instead of polling
drm:zynqmp_dp: Split off several helper functions
drm:zynqmp_dp: Takedp->lockinzynqmp_dp_hpd_work_func
drm:zynqmp_dp: Add debugfs interface for compliance testing
Quoted 8 lines
Documentation/gpu/drivers.rst | 1 + Documentation/gpu/zynqmp.rst | 149 ++++++ MAINTAINERS | 1 + drivers/gpu/drm/xlnx/zynqmp_dp.c | 846 ++++++++++++++++++++++++++++-- drivers/gpu/drm/xlnx/zynqmp_kms.c | 2 +- 5 files changed, 951 insertions(+), 48 deletions(-) create mode 100644 Documentation/gpu/zynqmp.rst
ping
--Sean
Tomi Valkeinen
maintainerHi,
Quoted 4 lines · Sean Anderson
Quoted 3 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.
I think the patches 1-7 look fine, and I think I can pick those already to drm-misc if you're ok with that.
I'm a bit unsure about patch 8, probably mainly because I don't have experience with the compliance testing.
How have you tested this? With some DP analyzer/tester, I presume?
I think none of this (patch 8) is needed by almost anybody. Even among zynqmp_dp developers I assume it's very rare to have the hardware for this. I wonder if it would make sense to have the debugfs and related code behind a compile option (which would be nice as the code wouldn't even compiled in), or maybe a module parameter (which would be nice as then "anyone" can easily enable it for compliance testing). What do you think?
I also somehow recall that there was some discussion earlier about how/if other drivers support compliance testing. But I can't find the discussion. Do you remember if there was such discussion, and what was the conclusion? With a quick look, everything in the debugfs looks generic, not xilinx specific.
Tomi
Quoted 8 lines · Tomi Valkeinen
Hi,
Quoted 4 lines · Sean Anderson
Quoted 3 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.
Quoted 5 lines
I think the patches 1-7 look fine, and I think I can pick those already to drm-misc if you're ok with that.
I'm a bit unsure about patch 8, probably mainly because I don't have experience with the compliance testing.
How have you tested this? With some DP analyzer/tester, I presume?
For my test setup I used an oscilloscope hooked up to the displayport output using a fixture that broke the signals out to SMA. Since the oscilloscope cannot emulate a sink, I first had the output connected to a monitor. Then I disabled HPD and reconnected the output to my fixture. This process is described in more detail in the documentation.
Quoted 1 line
I think none of this (patch 8) is needed by almost anybody.
Well, I found it very useful for debugging a signal integrity issue I was having. Once I could have a look at the signals it was very clear what the problem was.
Quoted 6 lines
Even among
zynqmp_dpdevelopers I assume it's very rare to have the hardware for this. I wonder if it would make sense to have the debugfs and related code behind a compile option (which would be nice as the code wouldn't even compiled in), or maybe a module parameter (which would be nice as then "anyone" can easily enable it for compliance testing). What do you think?
Other drivers with these features just enabled it unconditionally, so I didn't bother with any special config.
Quoted 5 lines
I also somehow recall that there was some discussion earlier about how/if other drivers support compliance testing. But I can't find the discussion. Do you remember if there was such discussion, and what was the conclusion? With a quick look, everything in the debugfs looks generic, not xilinx specific.
The last it got discussed was back in [1], but I never got any further response. I agree that some of this is generic, and could probably be reworked into some internal helpers. But I don't have the bandwidth at the moment to do that work.
--Sean
Hi Tomi,
Quoted 43 lines · Sean Anderson
Quoted 8 lines · Tomi Valkeinen
Hi,
Quoted 4 lines · Sean Anderson
Quoted 3 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.Quoted 5 lines
I think the patches 1-7 look fine, and I think I can pick those already to drm-misc if you're ok with that.
I'm a bit unsure about patch 8, probably mainly because I don't have experience with the compliance testing.
How have you tested this? With some DP analyzer/tester, I presume?
For my test setup I used an oscilloscope hooked up to the displayport output using a fixture that broke the signals out to SMA. Since the oscilloscope cannot emulate a sink, I first had the output connected to a monitor. Then I disabled HPD and reconnected the output to my fixture. This process is described in more detail in the documentation.
Quoted 1 line
I think none of this (patch 8) is needed by almost anybody.
Well, I found it very useful for debugging a signal integrity issue I was having. Once I could have a look at the signals it was very clear what the problem was.
Quoted 6 lines
Even among
zynqmp_dpdevelopers I assume it's very rare to have the hardware for this. I wonder if it would make sense to have the debugfs and related code behind a compile option (which would be nice as the code wouldn't even compiled in), or maybe a module parameter (which would be nice as then "anyone" can easily enable it for compliance testing). What do you think?Other drivers with these features just enabled it unconditionally, so I didn't bother with any special config.
Quoted 5 lines
I also somehow recall that there was some discussion earlier about how/if other drivers support compliance testing. But I can't find the discussion. Do you remember if there was such discussion, and what was the conclusion? With a quick look, everything in the debugfs looks generic, not xilinx specific.
Quoted 8 lines
The last it got discussed was back in [1], but I never got any further response. I agree that some of this is generic, and could probably be reworked into some internal helpers. But I don't have the bandwidth at the moment to do that work.
--Sean
Does this all make sense to you? At the moment I don't believe I have any changes I need to resend for (although this series is archived in patchwork [1] for some reason).
--Sean
[1] https://patchwork.kernel.org/project/dri-devel/list/?series=878338&archive=both
Tomi Valkeinen
maintainerHi,
Quoted 55 lines · Sean Anderson
Hi Tomi,
Quoted 43 lines · Sean Anderson
Quoted 8 lines · Tomi Valkeinen
Hi,
Quoted 4 lines · Sean Anderson
Quoted 3 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.Quoted 5 lines
I think the patches 1-7 look fine, and I think I can pick those already to drm-misc if you're ok with that.
I'm a bit unsure about patch 8, probably mainly because I don't have experience with the compliance testing.
How have you tested this? With some DP analyzer/tester, I presume?
For my test setup I used an oscilloscope hooked up to the displayport output using a fixture that broke the signals out to SMA. Since the oscilloscope cannot emulate a sink, I first had the output connected to a monitor. Then I disabled HPD and reconnected the output to my fixture. This process is described in more detail in the documentation.
Quoted 1 line
I think none of this (patch 8) is needed by almost anybody.
Well, I found it very useful for debugging a signal integrity issue I was having. Once I could have a look at the signals it was very clear what the problem was.
Quoted 6 lines
Even among
zynqmp_dpdevelopers I assume it's very rare to have the hardware for this. I wonder if it would make sense to have the debugfs and related code behind a compile option (which would be nice as the code wouldn't even compiled in), or maybe a module parameter (which would be nice as then "anyone" can easily enable it for compliance testing). What do you think?Other drivers with these features just enabled it unconditionally, so I didn't bother with any special config.
Quoted 5 lines
I also somehow recall that there was some discussion earlier about how/if other drivers support compliance testing. But I can't find the discussion. Do you remember if there was such discussion, and what was the conclusion? With a quick look, everything in the debugfs looks generic, not xilinx specific.
Quoted 8 lines
The last it got discussed was back in [1], but I never got any further response. I agree that some of this is generic, and could probably be reworked into some internal helpers. But I don't have the bandwidth at the moment to do that work.
--Sean
Quoted 7 lines
Does this all make sense to you? At the moment I don't believe I have any changes I need to resend for (although this series is archived in patchwork [1] for some reason).
--Sean
[1] https://patchwork.kernel.org/project/dri-devel/list/?series=878338&archive=both
I was hoping to get tested-by from amd, as I can't test this properly, but it's probably pointless to wait.
The biggest hesitation I have is what I mentioned earlier: this adds a lot of code which is not for normal use. It would be nice to split this into a separate file, maybe behind a compile option, but I fear that'll require a more restructuring of the driver.
So, I think it's fine, I'll apply this tomorrow.
Tomi
Tomi Valkeinen
maintainerHi Sean,
Quoted 66 lines · Tomi Valkeinen
Hi,
Quoted 55 lines · Sean Anderson
Hi Tomi,
Quoted 43 lines · Sean Anderson
Quoted 8 lines · Tomi Valkeinen
Hi,
Quoted 4 lines · Sean Anderson
Quoted 3 lines · Sean Anderson
This series cleans up the
zyqnmp_dpIRQ and locking situation. Once that's done, it adds debugfs support. The intent is to enable compliance testing or to help debug signal-integrity issues.Quoted 5 lines
I think the patches 1-7 look fine, and I think I can pick those already to drm-misc if you're ok with that.
I'm a bit unsure about patch 8, probably mainly because I don't have experience with the compliance testing.
How have you tested this? With some DP analyzer/tester, I presume?
For my test setup I used an oscilloscope hooked up to the displayport output using a fixture that broke the signals out to SMA. Since the oscilloscope cannot emulate a sink, I first had the output connected to a monitor. Then I disabled HPD and reconnected the output to my fixture. This process is described in more detail in the documentation.
Quoted 1 line
I think none of this (patch 8) is needed by almost anybody.
Well, I found it very useful for debugging a signal integrity issue I was having. Once I could have a look at the signals it was very clear what the problem was.
Quoted 6 lines
Even among
zynqmp_dpdevelopers I assume it's very rare to have the hardware for this. I wonder if it would make sense to have the debugfs and related code behind a compile option (which would be nice as the code wouldn't even compiled in), or maybe a module parameter (which would be nice as then "anyone" can easily enable it for compliance testing). What do you think?Other drivers with these features just enabled it unconditionally, so I didn't bother with any special config.
Quoted 5 lines
I also somehow recall that there was some discussion earlier about how/if other drivers support compliance testing. But I can't find the discussion. Do you remember if there was such discussion, and what was the conclusion? With a quick look, everything in the debugfs looks generic, not xilinx specific.
Quoted 8 lines
The last it got discussed was back in [1], but I never got any further response. I agree that some of this is generic, and could probably be reworked into some internal helpers. But I don't have the bandwidth at the moment to do that work.
--Sean
Quoted 7 lines
Does this all make sense to you? At the moment I don't believe I have any changes I need to resend for (although this series is archived in patchwork [1] for some reason).
--Sean
[1] https://patchwork.kernel.org/project/dri-devel/list/? series=878338&archive=both
Quoted 8 lines
I was hoping to get tested-by from amd, as I can't test this properly, but it's probably pointless to wait.
The biggest hesitation I have is what I mentioned earlier: this adds a lot of code which is not for normal use. It would be nice to split this into a separate file, maybe behind a compile option, but I fear that'll require a more restructuring of the driver.
So, I think it's fine, I'll apply this tomorrow.
Tomi
Thanks, pushed.
Tomi