All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: ankitprasad.r.sharma@intel.com
Cc: intel-gfx@lists.freedesktop.org, akash.goel@intel.com,
	shashidhar.hiremath@intel.com
Subject: Re: [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present
Date: Wed, 6 Jan 2016 08:52:32 +0100	[thread overview]
Message-ID: <20160106075232.GA8076@phenom.ffwll.local> (raw)
In-Reply-To: <1450765253-32104-11-git-send-email-ankitprasad.r.sharma@intel.com>

On Tue, Dec 22, 2015 at 11:50:53AM +0530, ankitprasad.r.sharma@intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
> 
> The BIOS RapidStartTechnology may corrupt the stolen memory across S3
> suspend due to unalarmed hibernation, in which case we will not be able
> to preserve the User data stored in the stolen region. Hence this patch
> tries to identify presence of the RST device on the ACPI bus, and
> disables use of stolen memory (for persistent data) if found.
> 
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>

Hm, could be that acpi mainatainers want to encapsulate this logic within
the acpi subsystem, and only expose a simple helper to drivers like i915.
Please add the same Cc: list to this patch as to the acpi one when
resending, so that acpi maintainers have the full context.

Thanks, Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.h        |  7 +++++++
>  drivers/gpu/drm/i915/i915_gem.c        |  8 ++++++++
>  drivers/gpu/drm/i915/i915_gem_stolen.c | 14 ++++++++++++++
>  drivers/gpu/drm/i915/intel_acpi.c      | 20 ++++++++++++++++++++
>  4 files changed, 49 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 492878a..d26a8f1 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1309,6 +1309,9 @@ struct i915_gem_mm {
>  	 */
>  	bool busy;
>  
> +	/* Intel RapidStart Technology info */
> +	bool nonvolatile_stolen;
> +
>  	/* the indicator for dispatch video commands on two BSD rings */
>  	int bsd_ring_dispatch_index;
>  
> @@ -3417,9 +3420,13 @@ intel_opregion_notify_adapter(struct drm_device *dev, pci_power_t state)
>  #ifdef CONFIG_ACPI
>  extern void intel_register_dsm_handler(void);
>  extern void intel_unregister_dsm_handler(void);
> +extern bool intel_detect_acpi_rst(void);
> +extern int match_device(struct device *dev, void* ids);
>  #else
>  static inline void intel_register_dsm_handler(void) { return; }
>  static inline void intel_unregister_dsm_handler(void) { return; }
> +static inline bool intel_detect_acpi_rst(void) { return false; }
> +static int match_device(struct device *dev, void* ids) { return 0; }
>  #endif /* CONFIG_ACPI */
>  
>  /* modesetting */
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index d27a41e..daca05f 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -399,6 +399,7 @@ i915_gem_create(struct drm_file *file,
>  		uint32_t *handle_p)
>  {
>  	struct drm_i915_gem_object *obj;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
>  	int ret;
>  	u32 handle;
>  
> @@ -411,6 +412,13 @@ i915_gem_create(struct drm_file *file,
>  
>  	/* Allocate the new object */
>  	if (flags & I915_CREATE_PLACEMENT_STOLEN) {
> +		if (!dev_priv->mm.nonvolatile_stolen) {
> +			/* Stolen may be overwritten by external parties
> +			 * so unsuitable for persistent user data.
> +			 */
> +			return -ENODEV;
> +		}
> +
>  		mutex_lock(&dev->struct_mutex);
>  		obj = i915_gem_object_create_stolen(dev, size);
>  		if (IS_ERR(obj)) {
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index 6d1af9d..98b4998 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -482,6 +482,20 @@ int i915_gem_init_stolen(struct drm_device *dev)
>  	 */
>  	drm_mm_init(&dev_priv->mm.stolen, 0, dev_priv->gtt.stolen_usable_size);
>  
> +	/* If the stolen region can be modified behind our backs upon suspend,
> +	 * then we cannot use it to store nonvolatile contents (i.e user data)
> +	 * as it will be corrupted upon resume.
> +	 */
> +	dev_priv->mm.nonvolatile_stolen = true;
> +#ifdef CONFIG_SUSPEND
> +	if (intel_detect_acpi_rst()) {
> +		/* BIOSes using RapidStart Technology have been reported
> +		 * to overwrite stolen across S3, not just S4.
> +		 */
> +		dev_priv->mm.nonvolatile_stolen = false;
> +	}
> +#endif
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c
> index eb638a1..5f7713d 100644
> --- a/drivers/gpu/drm/i915/intel_acpi.c
> +++ b/drivers/gpu/drm/i915/intel_acpi.c
> @@ -23,6 +23,11 @@ static const u8 intel_dsm_guid[] = {
>  	0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c
>  };
>  
> +static const struct acpi_device_id irst_ids[] = {
> +	{"INT3392", 0},
> +	{"", 0}
> +};
> +
>  static char *intel_dsm_port_name(u8 id)
>  {
>  	switch (id) {
> @@ -162,3 +167,18 @@ void intel_register_dsm_handler(void)
>  void intel_unregister_dsm_handler(void)
>  {
>  }
> +
> +int match_device(struct device *dev, void* ids)
> +{
> +	if (acpi_match_device(irst_ids, dev))
> +		return 1;
> +
> +	return 0;
> +}
> +bool intel_detect_acpi_rst(void)
> +{
> +	if (bus_for_each_dev(&acpi_bus_type, NULL, NULL, match_device))
> +		return true;;
> +
> +	return false;
> +}
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-01-06  7:52 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22  6:20 [PATCH v13 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2015-12-22  6:20 ` [PATCH 01/10] drm/i915: Allow use of get_dma_address for stolen " ankitprasad.r.sharma
2015-12-22 10:23   ` Tvrtko Ursulin
2015-12-22 10:39     ` Chris Wilson
2016-01-05 16:47       ` Daniel Vetter
2015-12-22  6:20 ` [PATCH 02/10] drm/i915: Use insert_page for pwrite_fast ankitprasad.r.sharma
2015-12-22  6:55   ` kbuild test robot
2015-12-22 10:44   ` Tvrtko Ursulin
2015-12-22 11:15     ` Ankitprasad Sharma
2015-12-22 11:52       ` Chris Wilson
2015-12-22 12:03         ` Tvrtko Ursulin
2015-12-22 13:38           ` Chris Wilson
2015-12-22  6:20 ` [PATCH 03/10] drm/i915: Clearing buffer objects via CPU/GTT ankitprasad.r.sharma
2015-12-22 11:09   ` Tvrtko Ursulin
2015-12-22  6:20 ` [PATCH 04/10] drm/i915: Support for creating Stolen memory backed objects ankitprasad.r.sharma
2016-01-12 12:45   ` Chris Wilson
2015-12-22  6:20 ` [PATCH 05/10] drm/i915: Propagating correct error codes to the userspace ankitprasad.r.sharma
2015-12-22 11:20   ` Tvrtko Ursulin
2015-12-22 11:29     ` Ankitprasad Sharma
2015-12-22 12:02       ` Tvrtko Ursulin
2016-01-06  7:45         ` Daniel Vetter
2015-12-22  6:20 ` [PATCH 06/10] drm/i915: Add support for stealing purgable stolen pages ankitprasad.r.sharma
2015-12-22 11:22   ` Tvrtko Ursulin
2015-12-22  6:20 ` [PATCH 07/10] drm/i915: Support for pread/pwrite from/to non shmem backed objects ankitprasad.r.sharma
2015-12-22 11:58   ` Tvrtko Ursulin
2015-12-22 17:40     ` Chris Wilson
2016-01-11 14:21       ` Tvrtko Ursulin
2016-01-11 14:45         ` Chris Wilson
2016-01-11 15:11           ` Tvrtko Ursulin
2016-01-11 17:03             ` Chris Wilson
2016-01-11 17:15               ` Tvrtko Ursulin
2016-01-11 21:29                 ` Chris Wilson
2016-01-12  7:50                   ` Ankitprasad Sharma
2015-12-22  6:20 ` [PATCH 08/10] drm/i915: Migrate stolen objects before hibernation ankitprasad.r.sharma
2015-12-22 12:33   ` Tvrtko Ursulin
2015-12-22 17:02     ` Chris Wilson
2015-12-22 17:14       ` Tvrtko Ursulin
2016-01-06  7:48         ` Daniel Vetter
2015-12-22 17:23     ` Tvrtko Ursulin
2015-12-22  6:20 ` [PATCH 09/10] acpi: Export acpi_bus_type ankitprasad.r.sharma
2015-12-22 16:41   ` Tvrtko Ursulin
2016-01-06  7:51     ` Daniel Vetter
2015-12-22  6:20 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2015-12-22 12:44   ` Tvrtko Ursulin
2015-12-22 13:14   ` Chris Wilson
2016-01-06  7:52   ` Daniel Vetter [this message]
2016-01-25 19:43 [PATCH v15 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-01-25 19:43 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2016-01-26 11:36   ` Chris Wilson
2016-02-04  9:30 [PATCH v16 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-04  9:30 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2016-02-04 15:46   ` Lukas Wunner
2016-02-04 16:05     ` Chris Wilson
2016-02-04 16:43       ` Lukas Wunner
2016-02-11 19:08         ` Lukas Wunner
2016-02-11 11:54   ` Tvrtko Ursulin
2016-02-19  6:51 [PATCH v17 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-19  6:51 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2016-02-19 10:34   ` Tvrtko Ursulin
2016-02-29  7:39 [PATCH v1 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-29  7:39 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2016-03-18  6:22 [PATCH v19 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-03-18  6:22 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma

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=20160106075232.GA8076@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=akash.goel@intel.com \
    --cc=ankitprasad.r.sharma@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=shashidhar.hiremath@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.