From: Jani Nikula <jani.nikula@intel.com>
To: Gustavo Sousa <gustavo.sousa@intel.com>,
intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 09/10] drm/i915/hdcp: migrate away from kdev_to_i915() in GSC messaging
Date: Tue, 06 Aug 2024 17:14:00 +0300 [thread overview]
Message-ID: <875xsd68nr.fsf@intel.com> (raw)
In-Reply-To: <878qx9695l.fsf@intel.com>
On Tue, 06 Aug 2024, Jani Nikula <jani.nikula@intel.com> wrote:
> On Thu, 01 Aug 2024, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
>> Quoting Jani Nikula (2024-07-29 11:30:10-03:00)
>>>Use to_intel_display() instead of kdev_to_i915() in the HDCP component
>>>API hooks. Avoid further drive-by changes at this point, and just
>>>convert the display pointer to i915, and leave the struct intel_display
>>>conversion for later.
>>>
>>>The NULL error checking in the hooks make this a bit cumbersome. I'm not
>>>actually sure they're really required, but don't go down that rabbit
>>>hole just now.
>>>
>>>Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>>>---
>>> .../drm/i915/display/intel_hdcp_gsc_message.c | 67 +++++++++++++------
>>> 1 file changed, 45 insertions(+), 22 deletions(-)
>>>
>>>diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c b/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
>>>index 6548e71b4c49..35bdb532bbb3 100644
>>>--- a/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
>>>+++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
>>>@@ -7,6 +7,7 @@
>>> #include <drm/intel/i915_hdcp_interface.h>
>>>
>>> #include "i915_drv.h"
>>>+#include "intel_display_types.h"
>>> #include "intel_hdcp_gsc_message.h"
>>>
>>> int
>>>@@ -15,17 +16,19 @@ intel_hdcp_gsc_initiate_session(struct device *dev, struct hdcp_port_data *data,
>>> {
>>> struct wired_cmd_initiate_hdcp2_session_in session_init_in = {};
>>> struct wired_cmd_initiate_hdcp2_session_out session_init_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !ake_data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>
>> Hm... I'm afraid that wouldn't really work if drvdata was NULL, would
>> it?
>>
>> With a NULL drvdata, I believe we would probably get a non-zero offset
>> here.
>
> Right, good catch. Not sure I want to add that check to everything in
> to_intel_display() macro, because in most cases the passed in value
> can't be NULL. Driver data is a bit different, though I don't think it
> should really be NULL either.
Decided to fix this in __drm_device_to_intel_display() like this:
#define __drm_device_to_intel_display(p) \
- (&to_i915(p)->display)
+ ((p) ? &to_i915(p)->display : NULL)
That'll have to change anyway when we can no longer use struct
drm_i915_private when going from drm_device to intel_display.
BR,
Jani.
>
> BR,
> Jani.
>
>
>
>>
>> --
>> Gustavo Sousa
>>
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> session_init_in.header.api_version = HDCP_API_VERSION;
>>> session_init_in.header.command_id = WIRED_INITIATE_HDCP2_SESSION;
>>>@@ -72,17 +75,19 @@ intel_hdcp_gsc_verify_receiver_cert_prepare_km(struct device *dev,
>>> {
>>> struct wired_cmd_verify_receiver_cert_in verify_rxcert_in = {};
>>> struct wired_cmd_verify_receiver_cert_out verify_rxcert_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !rx_cert || !km_stored || !ek_pub_km || !msg_sz)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> verify_rxcert_in.header.api_version = HDCP_API_VERSION;
>>> verify_rxcert_in.header.command_id = WIRED_VERIFY_RECEIVER_CERT;
>>>@@ -135,17 +140,19 @@ intel_hdcp_gsc_verify_hprime(struct device *dev, struct hdcp_port_data *data,
>>> {
>>> struct wired_cmd_ake_send_hprime_in send_hprime_in = {};
>>> struct wired_cmd_ake_send_hprime_out send_hprime_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !rx_hprime)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> send_hprime_in.header.api_version = HDCP_API_VERSION;
>>> send_hprime_in.header.command_id = WIRED_AKE_SEND_HPRIME;
>>>@@ -183,17 +190,19 @@ intel_hdcp_gsc_store_pairing_info(struct device *dev, struct hdcp_port_data *dat
>>> {
>>> struct wired_cmd_ake_send_pairing_info_in pairing_info_in = {};
>>> struct wired_cmd_ake_send_pairing_info_out pairing_info_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !pairing_info)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> pairing_info_in.header.api_version = HDCP_API_VERSION;
>>> pairing_info_in.header.command_id = WIRED_AKE_SEND_PAIRING_INFO;
>>>@@ -234,17 +243,19 @@ intel_hdcp_gsc_initiate_locality_check(struct device *dev,
>>> {
>>> struct wired_cmd_init_locality_check_in lc_init_in = {};
>>> struct wired_cmd_init_locality_check_out lc_init_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !lc_init_data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> lc_init_in.header.api_version = HDCP_API_VERSION;
>>> lc_init_in.header.command_id = WIRED_INIT_LOCALITY_CHECK;
>>>@@ -280,17 +291,19 @@ intel_hdcp_gsc_verify_lprime(struct device *dev, struct hdcp_port_data *data,
>>> {
>>> struct wired_cmd_validate_locality_in verify_lprime_in = {};
>>> struct wired_cmd_validate_locality_out verify_lprime_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !rx_lprime)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> verify_lprime_in.header.api_version = HDCP_API_VERSION;
>>> verify_lprime_in.header.command_id = WIRED_VALIDATE_LOCALITY;
>>>@@ -330,17 +343,19 @@ int intel_hdcp_gsc_get_session_key(struct device *dev,
>>> {
>>> struct wired_cmd_get_session_key_in get_skey_in = {};
>>> struct wired_cmd_get_session_key_out get_skey_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data || !ske_data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> get_skey_in.header.api_version = HDCP_API_VERSION;
>>> get_skey_in.header.command_id = WIRED_GET_SESSION_KEY;
>>>@@ -382,17 +397,19 @@ intel_hdcp_gsc_repeater_check_flow_prepare_ack(struct device *dev,
>>> {
>>> struct wired_cmd_verify_repeater_in verify_repeater_in = {};
>>> struct wired_cmd_verify_repeater_out verify_repeater_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !rep_topology || !rep_send_ack || !data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> verify_repeater_in.header.api_version = HDCP_API_VERSION;
>>> verify_repeater_in.header.command_id = WIRED_VERIFY_REPEATER;
>>>@@ -442,6 +459,7 @@ int intel_hdcp_gsc_verify_mprime(struct device *dev,
>>> {
>>> struct wired_cmd_repeater_auth_stream_req_in *verify_mprime_in;
>>> struct wired_cmd_repeater_auth_stream_req_out verify_mprime_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>> size_t cmd_size;
>>>@@ -449,11 +467,12 @@ int intel_hdcp_gsc_verify_mprime(struct device *dev,
>>> if (!dev || !stream_ready || !data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> cmd_size = struct_size(verify_mprime_in, streams, data->k);
>>> if (cmd_size == SIZE_MAX)
>>>@@ -504,17 +523,19 @@ int intel_hdcp_gsc_enable_authentication(struct device *dev,
>>> {
>>> struct wired_cmd_enable_auth_in enable_auth_in = {};
>>> struct wired_cmd_enable_auth_out enable_auth_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> enable_auth_in.header.api_version = HDCP_API_VERSION;
>>> enable_auth_in.header.command_id = WIRED_ENABLE_AUTH;
>>>@@ -549,17 +570,19 @@ intel_hdcp_gsc_close_session(struct device *dev, struct hdcp_port_data *data)
>>> {
>>> struct wired_cmd_close_session_in session_close_in = {};
>>> struct wired_cmd_close_session_out session_close_out = {};
>>>+ struct intel_display *display;
>>> struct drm_i915_private *i915;
>>> ssize_t byte;
>>>
>>> if (!dev || !data)
>>> return -EINVAL;
>>>
>>>- i915 = kdev_to_i915(dev);
>>>- if (!i915) {
>>>+ display = to_intel_display(dev);
>>>+ if (!display) {
>>> dev_err(dev, "DRM not initialized, aborting HDCP.\n");
>>> return -ENODEV;
>>> }
>>>+ i915 = to_i915(display->drm);
>>>
>>> session_close_in.header.api_version = HDCP_API_VERSION;
>>> session_close_in.header.command_id = WIRED_CLOSE_SESSION;
>>>--
>>>2.39.2
>>>
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-08-06 14:14 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 14:30 [PATCH 00/10] drm/xe & drm/i915: drvdata usage changes Jani Nikula
2024-07-29 14:30 ` [PATCH 01/10] drm/xe: use pdev_to_xe_device() instead of pci_get_drvdata() directly Jani Nikula
2024-08-01 16:31 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 02/10] drm/xe: add kdev_to_xe_device() helper and use it Jani Nikula
2024-08-01 16:41 ` Gustavo Sousa
2024-08-06 12:10 ` Jani Nikula
2024-07-29 14:30 ` [PATCH 03/10] drm/xe/tests: fix drvdata usage Jani Nikula
2024-08-01 16:57 ` Gustavo Sousa
2024-08-06 12:13 ` Jani Nikula
2024-08-06 12:14 ` Jani Nikula
2024-08-07 16:52 ` Lucas De Marchi
2024-07-29 14:30 ` [PATCH 04/10] drm/i915: use pdev_to_i915() instead of pci_get_drvdata() directly Jani Nikula
2024-08-01 17:03 ` Gustavo Sousa
2024-08-01 17:27 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 05/10] drm/i915 & drm/xe: save struct drm_device to drvdata Jani Nikula
2024-08-01 17:38 ` Gustavo Sousa
2024-08-02 8:18 ` Jani Nikula
2024-08-02 12:08 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 06/10] drm/i915: support struct device and pci_dev in to_intel_display() Jani Nikula
2024-08-01 17:46 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 07/10] drm/i915/audio: migrate away from kdev_to_i915() Jani Nikula
2024-08-01 18:03 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 08/10] drm/i915/hdcp: migrate away from kdev_to_i915() in bind/unbind Jani Nikula
2024-08-01 18:03 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 09/10] drm/i915/hdcp: migrate away from kdev_to_i915() in GSC messaging Jani Nikula
2024-08-01 18:09 ` Gustavo Sousa
2024-08-06 14:03 ` Jani Nikula
2024-08-06 14:14 ` Jani Nikula [this message]
2024-08-07 19:03 ` Gustavo Sousa
2024-07-29 14:30 ` [PATCH 10/10] drm/xe/display: remove unused compat kdev_to_i915() and pdev_to_i915() Jani Nikula
2024-08-01 18:11 ` Gustavo Sousa
2024-07-29 14:43 ` ✓ CI.Patch_applied: success for drm/xe & drm/i915: drvdata usage changes Patchwork
2024-07-29 14:44 ` ✓ CI.checkpatch: " Patchwork
2024-07-29 14:45 ` ✓ CI.KUnit: " Patchwork
2024-07-29 14:57 ` ✓ CI.Build: " Patchwork
2024-07-29 14:59 ` ✓ CI.Hooks: " Patchwork
2024-07-29 15:00 ` ✗ CI.checksparse: warning " Patchwork
2024-07-29 15:20 ` ✓ CI.BAT: success " Patchwork
2024-07-29 19:51 ` ✗ CI.FULL: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875xsd68nr.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=gustavo.sousa@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).