@@ -173,7 +173,10 @@ static int i915_getparam(struct drm_device *dev, void *data,
value = 1;
break;
case I915_PARAM_CREATE_VERSION:
- value = 2;
+ if (dev_priv->mm.volatile_stolen)
+ value = 1;
+ else
+ value = 2;
break;
default:
DRM_DEBUG("Unknown parameter %d\n", param->param);
@@ -1301,6 +1301,16 @@ struct i915_gem_mm {
*/
bool busy;
+ /**
+ * Stolen will be lost upon hibernate (as the memory is unpowered).
+ * Across resume, we expect stolen to be intact - however, it may
+ * also be utililised by third parties (e.g. Intel RapidStart
+ * Technology) and if so we have to assume that any data stored in
+ * stolen across resume is lost and we set this flag to indicate that
+ * the stolen memory is volatile.
+ */
+ bool volatile_stolen;
+
/* the indicator for dispatch video commands on two BSD rings */
unsigned int bsd_ring_dispatch_index;
@@ -3427,6 +3437,7 @@ intel_opregion_notify_adapter(struct drm_device *dev, pci_power_t state)
#endif
/* intel_acpi.c */
+bool intel_detect_acpi_rst(void);
#ifdef CONFIG_ACPI
extern void intel_register_dsm_handler(void);
extern void intel_unregister_dsm_handler(void);
@@ -396,8 +396,16 @@ static struct drm_i915_gem_object *
i915_gem_alloc_object_stolen(struct drm_device *dev, size_t size)
{
struct drm_i915_gem_object *obj;
+ struct drm_i915_private *dev_priv = dev->dev_private;
int ret;
+ if (dev_priv->mm.volatile_stolen) {
+ /* Stolen may be overwritten by external parties
+ * so unsuitable for persistent user data.
+ */
+ return ERR_PTR(-ENODEV);
+ }
+
mutex_lock(&dev->struct_mutex);
obj = i915_gem_object_create_stolen(dev, size);
if (IS_ERR(obj))
@@ -485,6 +485,18 @@ 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.volatile_stolen = false;
+ if (IS_ENABLED(CONFIG_SUSPEND)) {
+ /* BIOSes using RapidStart Technology have been reported
+ * to overwrite stolen across S3, not just S4.
+ */
+ dev_priv->mm.volatile_stolen = intel_detect_acpi_rst();
+ }
+
return 0;
}
@@ -23,6 +23,8 @@ static const u8 intel_dsm_guid[] = {
0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c
};
+static const char *irst_id = "INT3392";
+
static char *intel_dsm_port_name(u8 id)
{
switch (id) {
@@ -162,3 +164,8 @@ void intel_register_dsm_handler(void)
void intel_unregister_dsm_handler(void)
{
}
+
+bool intel_detect_acpi_rst(void)
+{
+ return acpi_dev_present(irst_id);
+}