All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add method for triggering Sanitize command
@ 2013-03-20 11:58 Yaniv Gardi
  2013-03-22 10:10 ` Subhash Jadavani
  2013-05-26 17:27 ` Chris Ball
  0 siblings, 2 replies; 5+ messages in thread
From: Yaniv Gardi @ 2013-03-20 11:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: ygardi, linux-arm-msm

This patch adds a method to trigger Sanitize command to MMC.
The Sanitize command is used for deleting the unmapped memory region
of the MMC device.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>

diff --git a/mmc.c b/mmc.c
index a2de863..174d9a4 100644
--- a/mmc.c
+++ b/mmc.c
@@ -90,6 +90,11 @@ static struct Command commands[] = {
 		"Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE!  This is a one-time programmable (unreversible) change.",
 	  NULL
 	},
+	{ do_sanitize, -1,
+	  "sanitize", "<device>\n"
+		"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device",
+	  NULL
+	},
 	{ 0, 0, 0, 0 }
 };
 
diff --git a/mmc.h b/mmc.h
index c863751..5173d34 100644
--- a/mmc.h
+++ b/mmc.h
@@ -38,6 +38,7 @@
 #define EXT_CSD_PART_CONFIG		179
 #define EXT_CSD_BOOT_WP			173
 #define EXT_CSD_WR_REL_PARAM		166
+#define EXT_CSD_SANITIZE_START		165
 #define EXT_CSD_BKOPS_EN		163	/* R/W */
 #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
 #define EXT_CSD_NATIVE_SECTOR_SIZE	63 /* R */
diff --git a/mmc_cmds.c b/mmc_cmds.c
index b407f65..5473a20 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
 out_free:
 	return ret;
 }
+
+int do_sanitize(int nargs, char **argv)
+{
+	int fd, ret;
+	char *device;
+
+	CHECK(nargs != 2, "Usage: mmc sanitize </path/to/mmcblkX>\n",
+			exit(1));
+
+	device = argv[1];
+
+	fd = open(device, O_RDWR);
+	if (fd < 0) {
+		perror("open");
+		exit(1);
+	}
+
+	ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1);
+	if (ret) {
+		fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
+			1, EXT_CSD_SANITIZE_START, device);
+		exit(1);
+	}
+
+	return ret;
+
+}
+
diff --git a/mmc_cmds.h b/mmc_cmds.h
index e52d622..ec22eee 100644
--- a/mmc_cmds.h
+++ b/mmc_cmds.h
@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);
 int do_write_bkops_en(int nargs, char **argv);
 int do_hwreset_en(int nargs, char **argv);
 int do_hwreset_dis(int nargs, char **argv);
+int do_sanitize(int nargs, char **argv);
-- 
1.7.6
-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add method for triggering Sanitize command
  2013-03-20 11:58 [PATCH] Add method for triggering Sanitize command Yaniv Gardi
@ 2013-03-22 10:10 ` Subhash Jadavani
  2013-03-22 17:12   ` Chris Ball
  2013-05-26 17:27 ` Chris Ball
  1 sibling, 1 reply; 5+ messages in thread
From: Subhash Jadavani @ 2013-03-22 10:10 UTC (permalink / raw)
  To: Yaniv Gardi; +Cc: linux-mmc, linux-arm-msm

On 3/20/2013 5:28 PM, Yaniv Gardi wrote:
> This patch adds a method to trigger Sanitize command to MMC.
> The Sanitize command is used for deleting the unmapped memory region
> of the MMC device.
>
> Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
>
> diff --git a/mmc.c b/mmc.c
> index a2de863..174d9a4 100644
> --- a/mmc.c
> +++ b/mmc.c
> @@ -90,6 +90,11 @@ static struct Command commands[] = {
>   		"Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE!  This is a one-time programmable (unreversible) change.",
>   	  NULL
>   	},
> +	{ do_sanitize, -1,
> +	  "sanitize", "<device>\n"
> +		"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device",
> +	  NULL
> +	},
>   	{ 0, 0, 0, 0 }
>   };
>   
> diff --git a/mmc.h b/mmc.h
> index c863751..5173d34 100644
> --- a/mmc.h
> +++ b/mmc.h
> @@ -38,6 +38,7 @@
>   #define EXT_CSD_PART_CONFIG		179
>   #define EXT_CSD_BOOT_WP			173
>   #define EXT_CSD_WR_REL_PARAM		166
> +#define EXT_CSD_SANITIZE_START		165
>   #define EXT_CSD_BKOPS_EN		163	/* R/W */
>   #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
>   #define EXT_CSD_NATIVE_SECTOR_SIZE	63 /* R */
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index b407f65..5473a20 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
>   out_free:
>   	return ret;
>   }
> +
> +int do_sanitize(int nargs, char **argv)
> +{
> +	int fd, ret;
> +	char *device;
> +
> +	CHECK(nargs != 2, "Usage: mmc sanitize </path/to/mmcblkX>\n",
> +			exit(1));
> +
> +	device = argv[1];
> +
> +	fd = open(device, O_RDWR);
> +	if (fd < 0) {
> +		perror("open");
> +		exit(1);
> +	}
> +
> +	ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1);
> +	if (ret) {
> +		fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
> +			1, EXT_CSD_SANITIZE_START, device);
> +		exit(1);
> +	}
> +

don't we need to close the opened blkdev file here? or is it done 
somewhere else?

> +	return ret;
> +
> +}
> +
> diff --git a/mmc_cmds.h b/mmc_cmds.h
> index e52d622..ec22eee 100644
> --- a/mmc_cmds.h
> +++ b/mmc_cmds.h
> @@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);
>   int do_write_bkops_en(int nargs, char **argv);
>   int do_hwreset_en(int nargs, char **argv);
>   int do_hwreset_dis(int nargs, char **argv);
> +int do_sanitize(int nargs, char **argv);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add method for triggering Sanitize command
  2013-03-22 10:10 ` Subhash Jadavani
@ 2013-03-22 17:12   ` Chris Ball
  2013-03-22 17:34     ` Subhash Jadavani
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Ball @ 2013-03-22 17:12 UTC (permalink / raw)
  To: Subhash Jadavani; +Cc: Yaniv Gardi, linux-mmc, linux-arm-msm

Hi,

On Fri, Mar 22 2013, Subhash Jadavani wrote:
> On 3/20/2013 5:28 PM, Yaniv Gardi wrote:
>> This patch adds a method to trigger Sanitize command to MMC.
>> The Sanitize command is used for deleting the unmapped memory region
>> of the MMC device.
>>
>> Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
>>
>> diff --git a/mmc.c b/mmc.c
>> index a2de863..174d9a4 100644
>> --- a/mmc.c
>> +++ b/mmc.c
>> @@ -90,6 +90,11 @@ static struct Command commands[] = {
>>   		"Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE!  This is a one-time programmable (unreversible) change.",
>>   	  NULL
>>   	},
>> +	{ do_sanitize, -1,
>> +	  "sanitize", "<device>\n"
>> +		"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device",
>> +	  NULL
>> +	},
>>   	{ 0, 0, 0, 0 }
>>   };
>>   diff --git a/mmc.h b/mmc.h
>> index c863751..5173d34 100644
>> --- a/mmc.h
>> +++ b/mmc.h
>> @@ -38,6 +38,7 @@
>>   #define EXT_CSD_PART_CONFIG		179
>>   #define EXT_CSD_BOOT_WP			173
>>   #define EXT_CSD_WR_REL_PARAM		166
>> +#define EXT_CSD_SANITIZE_START		165
>>   #define EXT_CSD_BKOPS_EN		163	/* R/W */
>>   #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
>>   #define EXT_CSD_NATIVE_SECTOR_SIZE	63 /* R */
>> diff --git a/mmc_cmds.c b/mmc_cmds.c
>> index b407f65..5473a20 100644
>> --- a/mmc_cmds.c
>> +++ b/mmc_cmds.c
>> @@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
>>   out_free:
>>   	return ret;
>>   }
>> +
>> +int do_sanitize(int nargs, char **argv)
>> +{
>> +	int fd, ret;
>> +	char *device;
>> +
>> +	CHECK(nargs != 2, "Usage: mmc sanitize </path/to/mmcblkX>\n",
>> +			exit(1));
>> +
>> +	device = argv[1];
>> +
>> +	fd = open(device, O_RDWR);
>> +	if (fd < 0) {
>> +		perror("open");
>> +		exit(1);
>> +	}
>> +
>> +	ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1);
>> +	if (ret) {
>> +		fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
>> +			1, EXT_CSD_SANITIZE_START, device);
>> +		exit(1);
>> +	}
>> +
>
> don't we need to close the opened blkdev file here? or is it done
> somewhere else?

Linux closes open file descriptors on process exit, no?

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add method for triggering Sanitize command
  2013-03-22 17:12   ` Chris Ball
@ 2013-03-22 17:34     ` Subhash Jadavani
  0 siblings, 0 replies; 5+ messages in thread
From: Subhash Jadavani @ 2013-03-22 17:34 UTC (permalink / raw)
  To: Chris Ball; +Cc: Yaniv Gardi, linux-mmc, linux-arm-msm

On 3/22/2013 10:42 PM, Chris Ball wrote:
> Hi,
>
> On Fri, Mar 22 2013, Subhash Jadavani wrote:
>> On 3/20/2013 5:28 PM, Yaniv Gardi wrote:
>>> This patch adds a method to trigger Sanitize command to MMC.
>>> The Sanitize command is used for deleting the unmapped memory region
>>> of the MMC device.
>>>
>>> Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
>>>
>>> diff --git a/mmc.c b/mmc.c
>>> index a2de863..174d9a4 100644
>>> --- a/mmc.c
>>> +++ b/mmc.c
>>> @@ -90,6 +90,11 @@ static struct Command commands[] = {
>>>    		"Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE!  This is a one-time programmable (unreversible) change.",
>>>    	  NULL
>>>    	},
>>> +	{ do_sanitize, -1,
>>> +	  "sanitize", "<device>\n"
>>> +		"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device",
>>> +	  NULL
>>> +	},
>>>    	{ 0, 0, 0, 0 }
>>>    };
>>>    diff --git a/mmc.h b/mmc.h
>>> index c863751..5173d34 100644
>>> --- a/mmc.h
>>> +++ b/mmc.h
>>> @@ -38,6 +38,7 @@
>>>    #define EXT_CSD_PART_CONFIG		179
>>>    #define EXT_CSD_BOOT_WP			173
>>>    #define EXT_CSD_WR_REL_PARAM		166
>>> +#define EXT_CSD_SANITIZE_START		165
>>>    #define EXT_CSD_BKOPS_EN		163	/* R/W */
>>>    #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
>>>    #define EXT_CSD_NATIVE_SECTOR_SIZE	63 /* R */
>>> diff --git a/mmc_cmds.c b/mmc_cmds.c
>>> index b407f65..5473a20 100644
>>> --- a/mmc_cmds.c
>>> +++ b/mmc_cmds.c
>>> @@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
>>>    out_free:
>>>    	return ret;
>>>    }
>>> +
>>> +int do_sanitize(int nargs, char **argv)
>>> +{
>>> +	int fd, ret;
>>> +	char *device;
>>> +
>>> +	CHECK(nargs != 2, "Usage: mmc sanitize </path/to/mmcblkX>\n",
>>> +			exit(1));
>>> +
>>> +	device = argv[1];
>>> +
>>> +	fd = open(device, O_RDWR);
>>> +	if (fd < 0) {
>>> +		perror("open");
>>> +		exit(1);
>>> +	}
>>> +
>>> +	ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1);
>>> +	if (ret) {
>>> +		fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
>>> +			1, EXT_CSD_SANITIZE_START, device);
>>> +		exit(1);
>>> +	}
>>> +
>> don't we need to close the opened blkdev file here? or is it done
>> somewhere else?
> Linux closes open file descriptors on process exit, no?
ok then it looks good to me.

Acked-by: Subhash Jadavani <subhashj@codeaurora.org>

Thanks,
Subhash
>
> - Chris.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add method for triggering Sanitize command
  2013-03-20 11:58 [PATCH] Add method for triggering Sanitize command Yaniv Gardi
  2013-03-22 10:10 ` Subhash Jadavani
@ 2013-05-26 17:27 ` Chris Ball
  1 sibling, 0 replies; 5+ messages in thread
From: Chris Ball @ 2013-05-26 17:27 UTC (permalink / raw)
  To: Yaniv Gardi; +Cc: linux-mmc, linux-arm-msm

Hi,

On Wed, Mar 20 2013, Yaniv Gardi wrote:
> This patch adds a method to trigger Sanitize command to MMC.
> The Sanitize command is used for deleting the unmapped memory region
> of the MMC device.
>
> Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>

Thanks, pushed to mmc-utils.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-26 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 11:58 [PATCH] Add method for triggering Sanitize command Yaniv Gardi
2013-03-22 10:10 ` Subhash Jadavani
2013-03-22 17:12   ` Chris Ball
2013-03-22 17:34     ` Subhash Jadavani
2013-05-26 17:27 ` Chris Ball

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.