diff --git a/drivers/base/firmware_class-dbg.c b/drivers/base/firmware_class-dbg.c
new file mode 100644
index 0000000..102a4cd
--- /dev/null
+++ b/drivers/base/firmware_class-dbg.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017 by Yi Li <yi1.li@linux.intel.com>
+ *
+ */
+/* This is part of firmware_class.c for testing firmware cache */
+
+#ifndef CONFIG_TEST_DRIVER_DATA
+static inline void create_debug_files(struct firmware_cache *cache) { }
+static inline void remove_debug_files(struct firmware_cache *cache) { }
+#else
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+static int debug_cache_show(struct seq_file *s, void *v)
+{
+	struct firmware_cache *cache = s->private;
+	unsigned long flags;
+	struct fw_cache_entry *cache_entry;
+
+	spin_lock_irqsave(&cache->lock, flags);
+
+	list_for_each_entry(cache_entry, &cache->fw_names, list)
+		seq_printf(s, "cached %s\n", cache_entry->name);
+
+	spin_unlock_irqrestore(&cache->lock, flags);
+
+	return 0;
+}
+
+static int debug_cache_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, debug_cache_show, inode->i_private);
+}
+
+#define MAX_LEN	16
+/**
+ * test_cache - set value in the 'cache' control file
+ *
+ *	The relevant values are:
+ *
+ *	 1: Test the suspend and start the cache
+ *	 0: Test the resume and clear the cache.
+ **/
+static ssize_t test_cache(struct file *fp, const char __user *user_buffer,
+			  size_t size, loff_t *ppos)
+{
+	char buf[MAX_LEN];
+	size_t len;
+	long cmd;
+
+	len = min(size, (size_t)(MAX_LEN - 1));
+	if (copy_from_user(buf, user_buffer, len))
+		return -EFAULT;
+	buf[len] = 0;
+	if (kstrtol(buf, 10, &cmd))
+		return -EFAULT;
+
+#ifdef CONFIG_PM_SLEEP
+	switch (cmd) {
+	/* Simulate PM suspend prepare and start to cache */
+	case 1:
+		kill_pending_fw_fallback_reqs(true);
+		device_cache_fw_images();
+		disable_firmware();
+		break;
+	/* Simulate PM resume and un-cache */
+	case 0:
+		mutex_lock(&fw_lock);
+		fw_cache.state = FW_LOADER_NO_CACHE;
+		mutex_unlock(&fw_lock);
+		enable_firmware();
+		device_uncache_fw_images_delay(10);
+		break;
+	default:
+		pr_err("unexpected cmd\n");
+	}
+#endif
+	return size;
+}
+
+static const struct file_operations debug_cache_fops = {
+	.open = debug_cache_open,
+	.read = seq_read,
+	.write = test_cache,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static void create_debug_files(struct firmware_cache *cache)
+{
+	cache->debug = debugfs_create_dir("firmware", NULL);
+	if (!cache->debug)
+		return;
+	if (!debugfs_create_file("cache", 0644, cache->debug,
+				 cache, &debug_cache_fops))
+		goto failed_create;
+	return;
+
+failed_create:
+	debugfs_remove_recursive(cache->debug);
+}
+
+static void remove_debug_files(struct firmware_cache *cache)
+{
+	debugfs_remove_recursive(cache->debug);
+	cache->debug = NULL;
+}
+#endif
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 7af430a..a70a2a7 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -72,14 +72,10 @@ enum driver_data_mode {
  * 	issue a uevent to userspace. Userspace in turn is expected to be
  * 	monitoring for uevents for the firmware_class and will use the
  * 	exposted sysfs interface to upload the driver data for the caller.
- * @DRIVER_DATA_PRIV_REQ_NO_CACHE: indicates that the driver data request
- * 	should not set up and use the internal caching mechanism to assist
- * 	drivers from fetching driver data at resume time after suspend.
  */
 enum driver_data_priv_reqs {
 	DRIVER_DATA_PRIV_REQ_FALLBACK			= 1 << 0,
 	DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT		= 1 << 1,
-	DRIVER_DATA_PRIV_REQ_NO_CACHE			= 1 << 2,
 };
 
 /**
@@ -151,10 +147,12 @@ struct driver_data_params {
 	}
 
 #define __DATA_REQ_FIRMWARE_BUF(buf, size)				\
+	.req_params = {							\
+		.reqs = DRIVER_DATA_REQ_NO_CACHE,			\
+	},								\
 	.priv_params = {						\
 		.priv_reqs = DRIVER_DATA_PRIV_REQ_FALLBACK |		\
-			     DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT |	\
-			     DRIVER_DATA_PRIV_REQ_NO_CACHE,		\
+			     DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT,	\
 		.alloc_buf = buf,					\
 		.alloc_buf_size = size,					\
 	}
@@ -186,7 +184,7 @@ struct driver_data_params {
 #define driver_data_param_uevent(params)	\
 	(!!((params)->priv_reqs & DRIVER_DATA_PRIV_REQ_FALLBACK_UEVENT))
 #define driver_data_param_nocache(params)	\
-	(!!((params)->priv_reqs & DRIVER_DATA_PRIV_REQ_NO_CACHE))
+	(!!((params)->reqs & DRIVER_DATA_REQ_NO_CACHE))
 
 #define driver_data_param_optional(params)	\
 	(!!((params)->reqs & DRIVER_DATA_REQ_OPTIONAL))
@@ -424,6 +422,8 @@ struct firmware_cache {
 	struct delayed_work work;
 
 	struct notifier_block   pm_notify;
+
+	struct dentry *debug;
 #endif
 };
 
@@ -790,17 +790,17 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
 	 * device may has been deleted already, but the problem
 	 * should be fixed in devres or driver core.
 	 */
-	/* don't cache firmware handled without uevent */
+	/* don't cache without uevent for legacy API */
 	if (device &&
-	    driver_data_param_uevent(&data_params->priv_params) &&
-	    !driver_data_param_nocache(&data_params->priv_params))
+	    (driver_data_param_uevent(&data_params->priv_params) ||
+	    !driver_data_param_nocache(&data_params->req_params)))
 		fw_add_devm_name(device, buf->fw_id);
 
 	/*
 	 * After caching firmware image is started, let it piggyback
 	 * on request firmware.
 	 */
-	if (!driver_data_param_nocache(&data_params->priv_params) &&
+	if (!driver_data_param_nocache(&data_params->req_params) &&
 	    buf->fwc->state == FW_LOADER_START_CACHE) {
 		if (fw_cache_piggyback_on_request(buf->fw_id))
 			kref_get(&buf->ref);
@@ -2437,6 +2437,8 @@ static int fw_cache_piggyback_on_request(const char *name)
 }
 #endif
 
+#include "firmware_class-dbg.c"
+
 static void __init fw_cache_init(void)
 {
 	spin_lock_init(&fw_cache.lock);
@@ -2454,6 +2456,7 @@ static void __init fw_cache_init(void)
 	register_pm_notifier(&fw_cache.pm_notify);
 
 	register_syscore_ops(&fw_syscore_ops);
+	create_debug_files(&fw_cache);
 #endif
 }
 
@@ -2492,6 +2495,7 @@ static void __exit firmware_class_exit(void)
 #ifdef CONFIG_PM_SLEEP
 	unregister_syscore_ops(&fw_syscore_ops);
 	unregister_pm_notifier(&fw_cache.pm_notify);
+	remove_debug_files(&fw_cache);
 #endif
 	unregister_reboot_notifier(&fw_shutdown_nb);
 #ifdef CONFIG_FW_LOADER_USER_HELPER
diff --git a/include/linux/driver_data.h b/include/linux/driver_data.h
index 2cb999e..4d5f9d1 100644
--- a/include/linux/driver_data.h
+++ b/include/linux/driver_data.h
@@ -124,11 +124,15 @@ union driver_data_cbs {
  *	file to be present given the API range, it is only required for one
  *	file in the API range to be present.  If the %DRIVER_DATA_REQ_OPTIONAL
  *	flag is also enabled then all files are treated as optional.
+ * @DRIVER_DATA_REQ_NO_CACHE: indicates that the driver data request
+ *	should not set up and use the internal caching mechanism to assist
+ *	drivers from fetching driver data at resume time after suspend.
  */
 enum driver_data_reqs {
 	DRIVER_DATA_REQ_OPTIONAL			= 1 << 0,
 	DRIVER_DATA_REQ_KEEP				= 1 << 1,
 	DRIVER_DATA_REQ_USE_API_VERSIONING		= 1 << 2,
+	DRIVER_DATA_REQ_NO_CACHE			= 1 << 3,
 };
 
 /**
