Re: [Intel-gfx] [PATCH v10 5/6] drm/i915/mtl: Add function to send command to GSC CS
> -Original Message- > From: Shankar, Uma > Sent: Monday, March 6, 2023 6:03 PM > To: Kandpal, Suraj ; intel- > g...@lists.freedesktop.org > Cc: Nautiyal, Ankit K ; Ceraolo Spurio, Daniele > ; Teres Alexis, Alan Previn > ; Gupta, Anshuman > > Subject: RE: [PATCH v10 5/6] drm/i915/mtl: Add function to send command > to GSC CS > > > > > -Original Message- > > From: Kandpal, Suraj > > Sent: Wednesday, February 1, 2023 2:38 PM > > To: intel-gfx@lists.freedesktop.org > > Cc: Nautiyal, Ankit K ; Kandpal, Suraj > > ; Ceraolo Spurio, Daniele > > ; Teres Alexis, Alan Previn > > ; Shankar, Uma > > ; Gupta, Anshuman > > > Subject: [PATCH v10 5/6] drm/i915/mtl: Add function to send command to > > GSC CS > > > > Add function that takes care of sending command to gsc cs. We start of > > with allocation of memory for our command intel_hdcp_gsc_message that > > contains gsc cs memory header as directed in specs followed by the > > actual payload hdcp message that we want to send. > > Spec states that we need to poll pending bit of response header around > > 20 times each try being 50ms apart hence adding that to current > > gsc_msg_send function Also we use the same function to take care of > > both sending and receiving hence no separate function to get the response. > > > > --v4 > > -Create common function to fill in gsc_mtl_header [Alan] -define host > > session bitmask [Alan] > > > > --v5 > > -use i915 directly instead of gt->i915 [Alan] -No need to make fields > > NULL as we are already using kzalloc [Alan] > > > > --v8 > > -change mechanism to reuse the same memory for one hdcp session[Alan] > > -fix header ordering -add comments to explain flags and host session > > mask [Alan] > > > > --v9 > > -remove gem obj from hdcp message as we can use > > i915_vma_unpin_and_release [Alan] -move hdcp message allocation and > > deallocation from hdcp2_enable and hdcp2_disable to init and teardown > > of HDCP [Alan] > > > > --v10 > > -remove unnecessary i915_vma_unpin [Alan] > > > > Cc: Ankit Nautiyal > > Cc: Daniele Ceraolo Spurio > > Cc: Alan Pervin Teres > > Cc: Uma Shankar > > Cc: Anshuman Gupta > > Signed-off-by: Suraj Kandpal > > Reviewed-by: Alan Previn > > --- > > drivers/gpu/drm/i915/Makefile | 1 + > > .../gpu/drm/i915/display/intel_display_core.h | 5 + > > drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 198 > > ++ drivers/gpu/drm/i915/display/intel_hdcp_gsc.h | 23 > > ++ .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.c | 15 ++ > > .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.h | 16 ++ > > 6 files changed, 258 insertions(+) > > create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > > create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h > > > > diff --git a/drivers/gpu/drm/i915/Makefile > > b/drivers/gpu/drm/i915/Makefile index 482928cffb1c..ba76bec715af > > 100644 > > --- a/drivers/gpu/drm/i915/Makefile > > +++ b/drivers/gpu/drm/i915/Makefile > > @@ -255,6 +255,7 @@ i915-y += \ > > display/intel_frontbuffer.o \ > > display/intel_global_state.o \ > > display/intel_hdcp.o \ > > + display/intel_hdcp_gsc.o \ > > display/intel_hotplug.o \ > > display/intel_hti.o \ > > display/intel_lpe_audio.o \ > > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h > > b/drivers/gpu/drm/i915/display/intel_display_core.h > > index 139100fe2383..20d2a79a5d05 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display_core.h > > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h > > @@ -382,6 +382,11 @@ struct intel_display { > > struct i915_hdcp_master *master; > > bool comp_added; > > > > + /*HDCP message struct for allocation of memory which can > be > > reused > > Fix Comment style. Sure > > > +* when sending message to gsc cs > > +* this is only populated post Meteorlake > > +*/ > > + struct intel_hdcp_gsc_message *hdcp_message; > > /* Mutex to protect the above hdcp component related > values. */ > > struct mutex comp_mutex; > > } hdcp; > > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > > b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > > new file mode 100644 > > index ..8e3b5e6733d7 > > --- /dev/null > > +++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > > @@ -0,0 +1,198 @@ > > +// SPDX-License-Identifier: MIT > > +/* > > + * Copyright 2023, Intel Corporation. > > + */ > > + > > +#include "display/intel_hdcp_gsc.h" > > +#include "gem/i915_gem_region.h" > > +#include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" > > +#include "i915_drv.h" > > +#include "i915_utils.h" > > + > > +/*This function helps allocate memory for the command that we will > > +send to gsc cs */ static int intel_hdcp_gsc_initialize_message(struct > > +drm_i915_private > > *i915, > > +struct intel_hdcp_gsc_message > > *hdcp_message) { > > + struct
Re: [Intel-gfx] [PATCH v10 5/6] drm/i915/mtl: Add function to send command to GSC CS
> -Original Message- > From: Kandpal, Suraj > Sent: Wednesday, February 1, 2023 2:38 PM > To: intel-gfx@lists.freedesktop.org > Cc: Nautiyal, Ankit K ; Kandpal, Suraj > ; Ceraolo Spurio, Daniele > ; Teres Alexis, Alan Previn > ; Shankar, Uma ; > Gupta, Anshuman > Subject: [PATCH v10 5/6] drm/i915/mtl: Add function to send command to GSC CS > > Add function that takes care of sending command to gsc cs. We start of with > allocation of memory for our command intel_hdcp_gsc_message that contains gsc > cs memory header as directed in specs followed by the actual payload hdcp > message > that we want to send. > Spec states that we need to poll pending bit of response header around > 20 times each try being 50ms apart hence adding that to current gsc_msg_send > function Also we use the same function to take care of both sending and > receiving > hence no separate function to get the response. > > --v4 > -Create common function to fill in gsc_mtl_header [Alan] -define host session > bitmask [Alan] > > --v5 > -use i915 directly instead of gt->i915 [Alan] -No need to make fields NULL as > we are > already using kzalloc [Alan] > > --v8 > -change mechanism to reuse the same memory for one hdcp session[Alan] -fix > header ordering -add comments to explain flags and host session mask [Alan] > > --v9 > -remove gem obj from hdcp message as we can use i915_vma_unpin_and_release > [Alan] -move hdcp message allocation and deallocation from hdcp2_enable and > hdcp2_disable to init and teardown of HDCP [Alan] > > --v10 > -remove unnecessary i915_vma_unpin [Alan] > > Cc: Ankit Nautiyal > Cc: Daniele Ceraolo Spurio > Cc: Alan Pervin Teres > Cc: Uma Shankar > Cc: Anshuman Gupta > Signed-off-by: Suraj Kandpal > Reviewed-by: Alan Previn > --- > drivers/gpu/drm/i915/Makefile | 1 + > .../gpu/drm/i915/display/intel_display_core.h | 5 + > drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 198 ++ > drivers/gpu/drm/i915/display/intel_hdcp_gsc.h | 23 ++ > .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.c | 15 ++ > .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.h | 16 ++ > 6 files changed, 258 insertions(+) > create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h > > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile > index > 482928cffb1c..ba76bec715af 100644 > --- a/drivers/gpu/drm/i915/Makefile > +++ b/drivers/gpu/drm/i915/Makefile > @@ -255,6 +255,7 @@ i915-y += \ > display/intel_frontbuffer.o \ > display/intel_global_state.o \ > display/intel_hdcp.o \ > + display/intel_hdcp_gsc.o \ > display/intel_hotplug.o \ > display/intel_hti.o \ > display/intel_lpe_audio.o \ > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h > b/drivers/gpu/drm/i915/display/intel_display_core.h > index 139100fe2383..20d2a79a5d05 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_core.h > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h > @@ -382,6 +382,11 @@ struct intel_display { > struct i915_hdcp_master *master; > bool comp_added; > > + /*HDCP message struct for allocation of memory which can be > reused Fix Comment style. > + * when sending message to gsc cs > + * this is only populated post Meteorlake > + */ > + struct intel_hdcp_gsc_message *hdcp_message; > /* Mutex to protect the above hdcp component related values. */ > struct mutex comp_mutex; > } hdcp; > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > new file mode 100644 > index ..8e3b5e6733d7 > --- /dev/null > +++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c > @@ -0,0 +1,198 @@ > +// SPDX-License-Identifier: MIT > +/* > + * Copyright 2023, Intel Corporation. > + */ > + > +#include "display/intel_hdcp_gsc.h" > +#include "gem/i915_gem_region.h" > +#include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" > +#include "i915_drv.h" > +#include "i915_utils.h" > + > +/*This function helps allocate memory for the command that we will send > +to gsc cs */ static int intel_hdcp_gsc_initialize_message(struct > drm_i915_private > *i915, > + struct intel_hdcp_gsc_message > *hdcp_message) { > + struct intel_gt *gt = i915->media_gt; > + struct drm_i915_gem_object *obj = NULL; > + struct i915_vma *vma = NULL; > + void *cmd; > + int err; > + > + /* allocate object of one page for HDCP command memory and store it */ > + obj = i915_gem_object_create_shmem(i915, PAGE_SIZE); > + > + if (IS_ERR(obj)) { > + drm_err(>drm, "Failed to allocate HDCP streaming > command!\n"); > + return PTR_ERR(obj); > + } > + > + cmd = i915_gem_object_pin_map_unlocked(obj, > i915_coherent_map_type(i915, obj, true));
[Intel-gfx] [PATCH v10 5/6] drm/i915/mtl: Add function to send command to GSC CS
Add function that takes care of sending command to gsc cs. We start of with allocation of memory for our command intel_hdcp_gsc_message that contains gsc cs memory header as directed in specs followed by the actual payload hdcp message that we want to send. Spec states that we need to poll pending bit of response header around 20 times each try being 50ms apart hence adding that to current gsc_msg_send function Also we use the same function to take care of both sending and receiving hence no separate function to get the response. --v4 -Create common function to fill in gsc_mtl_header [Alan] -define host session bitmask [Alan] --v5 -use i915 directly instead of gt->i915 [Alan] -No need to make fields NULL as we are already using kzalloc [Alan] --v8 -change mechanism to reuse the same memory for one hdcp session[Alan] -fix header ordering -add comments to explain flags and host session mask [Alan] --v9 -remove gem obj from hdcp message as we can use i915_vma_unpin_and_release [Alan] -move hdcp message allocation and deallocation from hdcp2_enable and hdcp2_disable to init and teardown of HDCP [Alan] --v10 -remove unnecessary i915_vma_unpin [Alan] Cc: Ankit Nautiyal Cc: Daniele Ceraolo Spurio Cc: Alan Pervin Teres Cc: Uma Shankar Cc: Anshuman Gupta Signed-off-by: Suraj Kandpal Reviewed-by: Alan Previn --- drivers/gpu/drm/i915/Makefile | 1 + .../gpu/drm/i915/display/intel_display_core.h | 5 + drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 198 ++ drivers/gpu/drm/i915/display/intel_hdcp_gsc.h | 23 ++ .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.c | 15 ++ .../i915/gt/uc/intel_gsc_uc_heci_cmd_submit.h | 16 ++ 6 files changed, 258 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 482928cffb1c..ba76bec715af 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -255,6 +255,7 @@ i915-y += \ display/intel_frontbuffer.o \ display/intel_global_state.o \ display/intel_hdcp.o \ + display/intel_hdcp_gsc.o \ display/intel_hotplug.o \ display/intel_hti.o \ display/intel_lpe_audio.o \ diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h index 139100fe2383..20d2a79a5d05 100644 --- a/drivers/gpu/drm/i915/display/intel_display_core.h +++ b/drivers/gpu/drm/i915/display/intel_display_core.h @@ -382,6 +382,11 @@ struct intel_display { struct i915_hdcp_master *master; bool comp_added; + /*HDCP message struct for allocation of memory which can be reused +* when sending message to gsc cs +* this is only populated post Meteorlake +*/ + struct intel_hdcp_gsc_message *hdcp_message; /* Mutex to protect the above hdcp component related values. */ struct mutex comp_mutex; } hdcp; diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c new file mode 100644 index ..8e3b5e6733d7 --- /dev/null +++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2023, Intel Corporation. + */ + +#include "display/intel_hdcp_gsc.h" +#include "gem/i915_gem_region.h" +#include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" +#include "i915_drv.h" +#include "i915_utils.h" + +/*This function helps allocate memory for the command that we will send to gsc cs */ +static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915, +struct intel_hdcp_gsc_message *hdcp_message) +{ + struct intel_gt *gt = i915->media_gt; + struct drm_i915_gem_object *obj = NULL; + struct i915_vma *vma = NULL; + void *cmd; + int err; + + /* allocate object of one page for HDCP command memory and store it */ + obj = i915_gem_object_create_shmem(i915, PAGE_SIZE); + + if (IS_ERR(obj)) { + drm_err(>drm, "Failed to allocate HDCP streaming command!\n"); + return PTR_ERR(obj); + } + + cmd = i915_gem_object_pin_map_unlocked(obj, i915_coherent_map_type(i915, obj, true)); + if (IS_ERR(cmd)) { + drm_err(>drm, "Failed to map gsc message page!\n"); + err = PTR_ERR(cmd); + goto out_unpin; + } + + vma = i915_vma_instance(obj, >ggtt->vm, NULL); + if (IS_ERR(vma)) { + err = PTR_ERR(vma); + goto out_unmap; + } + + err = i915_vma_pin(vma, 0, 0, PIN_GLOBAL); + if (err) + goto out_unmap; + + memset(cmd, 0, obj->base.size); + + hdcp_message->hdcp_cmd = cmd; + hdcp_message->vma = vma; + +