Re: [Intel-gfx] [PATCH v2 03/13] drm/hdcp: Update property value on content type and user changes

2021-09-16 Thread kernel test robot
Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip robh/for-next linus/master 
v5.15-rc1 next-20210916]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Sean-Paul/drm-hdcp-Pull-HDCP-auth-exchange-check-into-helpers/20210916-044145
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-m001-20210916 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

smatch warnings:
drivers/gpu/drm/drm_hdcp.c:509 drm_hdcp_atomic_check() warn: inconsistent 
indenting

vim +509 drivers/gpu/drm/drm_hdcp.c

a46c52c65fdbf76 Sean Paul 2021-09-15  425  
a46c52c65fdbf76 Sean Paul 2021-09-15  426  /**
a46c52c65fdbf76 Sean Paul 2021-09-15  427   * drm_hdcp_atomic_check - Helper 
for drivers to call during connector->atomic_check
a46c52c65fdbf76 Sean Paul 2021-09-15  428   *
a46c52c65fdbf76 Sean Paul 2021-09-15  429   * @state: pointer to the atomic 
state being checked
a46c52c65fdbf76 Sean Paul 2021-09-15  430   * @connector: drm_connector on 
which content protection state needs an update
a46c52c65fdbf76 Sean Paul 2021-09-15  431   *
a46c52c65fdbf76 Sean Paul 2021-09-15  432   * This function can be used by 
display drivers to perform an atomic check on the
d0cdceca77739a6 Sean Paul 2021-09-15  433   * hdcp state elements. If hdcp 
state has changed in a manner which requires the
d0cdceca77739a6 Sean Paul 2021-09-15  434   * driver to enable or disable 
content protection, this function will return
d0cdceca77739a6 Sean Paul 2021-09-15  435   * true.
d0cdceca77739a6 Sean Paul 2021-09-15  436   *
d0cdceca77739a6 Sean Paul 2021-09-15  437   * Returns:
d0cdceca77739a6 Sean Paul 2021-09-15  438   * true if the driver must 
enable/disable hdcp, false otherwise
a46c52c65fdbf76 Sean Paul 2021-09-15  439   */
d0cdceca77739a6 Sean Paul 2021-09-15  440  bool drm_hdcp_atomic_check(struct 
drm_connector *connector,
a46c52c65fdbf76 Sean Paul 2021-09-15  441  struct 
drm_atomic_state *state)
a46c52c65fdbf76 Sean Paul 2021-09-15  442  {
a46c52c65fdbf76 Sean Paul 2021-09-15  443   struct drm_connector_state 
*new_conn_state, *old_conn_state;
a46c52c65fdbf76 Sean Paul 2021-09-15  444   struct drm_crtc_state 
*new_crtc_state;
a46c52c65fdbf76 Sean Paul 2021-09-15  445   u64 old_hdcp, new_hdcp;
a46c52c65fdbf76 Sean Paul 2021-09-15  446  
a46c52c65fdbf76 Sean Paul 2021-09-15  447   old_conn_state = 
drm_atomic_get_old_connector_state(state, connector);
a46c52c65fdbf76 Sean Paul 2021-09-15  448   old_hdcp = 
old_conn_state->content_protection;
a46c52c65fdbf76 Sean Paul 2021-09-15  449  
a46c52c65fdbf76 Sean Paul 2021-09-15  450   new_conn_state = 
drm_atomic_get_new_connector_state(state, connector);
a46c52c65fdbf76 Sean Paul 2021-09-15  451   new_hdcp = 
new_conn_state->content_protection;
a46c52c65fdbf76 Sean Paul 2021-09-15  452  
a46c52c65fdbf76 Sean Paul 2021-09-15  453   if (!new_conn_state->crtc) {
a46c52c65fdbf76 Sean Paul 2021-09-15  454   /*
a46c52c65fdbf76 Sean Paul 2021-09-15  455* If the connector is 
being disabled with CP enabled, mark it
a46c52c65fdbf76 Sean Paul 2021-09-15  456* desired so it's 
re-enabled when the connector is brought back
a46c52c65fdbf76 Sean Paul 2021-09-15  457*/
d0cdceca77739a6 Sean Paul 2021-09-15  458   if (old_hdcp == 
DRM_MODE_CONTENT_PROTECTION_ENABLED) {
a46c52c65fdbf76 Sean Paul 2021-09-15  459   
new_conn_state->content_protection =
a46c52c65fdbf76 Sean Paul 2021-09-15  460   
DRM_MODE_CONTENT_PROTECTION_DESIRED;
d0cdceca77739a6 Sean Paul 2021-09-15  461   return true;
d0cdceca77739a6 Sean Paul 2021-09-15  462   }
d0cdceca77739a6 Sean Paul 2021-09-15  463   return false;
a46c52c65fdbf76 Sean Paul 2021-09-15  464   }
a46c52c65fdbf76 Sean Paul 2021-09-15  465  
a46c52c65fdbf76 Sean Paul 2021-09-15  466   new_crtc_state = 
drm_atomic_get_new_crtc_state(state,
a46c52c65fdbf76 Sean Paul 2021-09-15  467   
   new_conn_state->crtc);
a46c52c65fdbf76 Sean Paul 2021-09-15  468   /*
a46c52c65fdbf76 Sean Paul 2021-09-15  469   * Fix the HDCP uapi content 
protection state in case of modeset.
a46c52c65fdbf76 Sean Paul 2021-09-15  470   * FIXME: As per HDCP content 
protection property uapi doc, an uevent()
a46c52c65fdbf76 Sean Paul 2021-09-15  471   * need to be sent if there is 
transition from ENABLED->DESIRED.
a46c52c65fdbf76 Sean Paul 2021-09-15  472   */
a46c52c65fdbf76 Sean Paul 2021-09-15  473

[Intel-gfx] [PATCH v2 03/13] drm/hdcp: Update property value on content type and user changes

2021-09-15 Thread Sean Paul
From: Sean Paul 

This patch updates the connector's property value in 2 cases which were
previously missed:

1- Content type changes. The value should revert back to DESIRED from
   ENABLED in case the driver must re-authenticate the link due to the
   new content type.

2- Userspace sets value to DESIRED while ENABLED. In this case, the
   value should be reset immediately to ENABLED since the link is
   actively being encrypted.

To accommodate these changes, I've split up the conditionals to make
things a bit more clear (as much as one can with this mess of state).

Signed-off-by: Sean Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20210913175747.47456-4-s...@poorly.run
 #v1

Changes in v2:
-None
---
 drivers/gpu/drm/drm_hdcp.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c
index dd8fa91c51d6..742313ce8f6f 100644
--- a/drivers/gpu/drm/drm_hdcp.c
+++ b/drivers/gpu/drm/drm_hdcp.c
@@ -487,21 +487,29 @@ bool drm_hdcp_atomic_check(struct drm_connector 
*connector,
return true;
 
/*
-* Nothing to do if content type is unchanged and one of:
-*  - state didn't change
+* Content type changes require an HDCP disable/enable cycle.
+*/
+   if (new_conn_state->hdcp_content_type != 
old_conn_state->hdcp_content_type) {
+   new_conn_state->content_protection =
+   DRM_MODE_CONTENT_PROTECTION_DESIRED;
+   return true;
+   }
+
+   /*
+* Ignore meaningless state changes:
 *  - HDCP was activated since the last commit
-*  - attempting to set to desired while already enabled
+*  - Attempting to set to desired while already enabled
 */
-   if (old_hdcp == new_hdcp ||
-   (old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED &&
+   if ((old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED &&
 new_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) ||
(old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
 new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED)) {
-   if (old_conn_state->hdcp_content_type ==
-   new_conn_state->hdcp_content_type)
-   return false;
+   new_conn_state->content_protection =
+   DRM_MODE_CONTENT_PROTECTION_ENABLED;
+return false;
}
 
-   return true;
+   /* Finally, if state changes, we need action */
+   return old_hdcp != new_hdcp;
 }
 EXPORT_SYMBOL(drm_hdcp_atomic_check);
-- 
Sean Paul, Software Engineer, Google / Chromium OS