*** exposing SANITIZE capability to the user space via a unique IOCTL ***
Subsystems (5)
v3 cover *** exposing SANITIZE capability to the user space via a unique IOCTL ***
*** exposing SANITIZE capability to the user space via a unique IOCTL ***
changes patch v3:
split the patch into 2 commits - block and mmc/card added capability MMC_CAP2_SANITIZE to mmc controller
Yaniv Gardi (2):
block: IOCTL support for Sanitize in eMMC v4.5
mmc: card: Adding support for Sanitize in eMMC v4.5
block/blk-core.c | 15 +++++++++-- block/blk-lib.c | 44 ++++++++++++++++++++++++++++++++++ block/blk-merge.c | 6 ++++ block/elevator.c | 8 +++++- block/ioctl.c | 9 +++++++ drivers/mmc/card/block.c | 58 ++++++++++++++++++++++++++++++++++++++------- drivers/mmc/card/queue.c | 12 ++++++++- include/linux/blk_types.h | 6 +++- include/linux/blkdev.h | 3 ++ include/linux/fs.h | 1 + include/linux/mmc/card.h | 7 +++++ include/linux/mmc/host.h | 1 + kernel/trace/blktrace.c | 2 + 13 files changed, 156 insertions(+), 16 deletions(-)
Signature · 4 lines
1.7.6 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
PATCH v3 1/2 block: IOCTL support for Sanitize in eMMC v4.5
--- block/blk-core.c | 15 ++++++++++++--- block/blk-lib.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ block/blk-merge.c | 6 ++++++ block/elevator.c | 8 +++++++- block/ioctl.c | 9 +++++++++ include/linux/blk_types.h | 6 ++++-- include/linux/blkdev.h | 3 +++ include/linux/fs.h | 1 + kernel/trace/blktrace.c | 2 ++ 9 files changed, 88 insertions(+), 6 deletions(-)
block/blk-core.c +12 -3
@@ -1544,7 +1544,7 @@ generic_make_request_checks(struct bio *bio) goto end_io; } -if (unlikely (!(bio->bi_rw &REQ_DISCARD ) && +if (unlikely (!(bio->bi_rw & (REQ_DISCARD |REQ_SANITIZE )) && nr_sectors >queue_max_hw_sectors (q))) { printk(KERN_ERR "bio too big device %s (%u > %u)\n", bdevname(bio->bi_bdev, b),
@@ -1592,6 +1592,14 @@ generic_make_request_checks(struct bio *bio) goto end_io; } +if ((bio->bi_rw &REQ_SANITIZE ) && + (!blk_queue_sanitize (q))) { +pr_err ("%s - SANITIZE request but queue " +"doesn't support sanitize" , __func__); + err = -EOPNOTSUPP ; + goto end_io; + } +if (blk_throtl_bio (q, bio))return false;/* throttled, will be resubmitted later */
@@ -1697,7 +1705,8 @@ void submit_bio(int rw, struct bio *bio)* If it's a regular read/write or a barrier with data attached, * go through the normal accounting stuff before submission. */ -if (bio_has_data (bio) && !(rw &REQ_DISCARD )) { +if (bio_has_data (bio) && + (!(rw & (REQ_DISCARD |REQ_SANITIZE )))) {if (rw &WRITE ) {count_vm_events (PGPGOUT , count); }else {
@@ -1743,7 +1752,7 @@ EXPORT_SYMBOL(submit_bio);*/ int blk_rq_check_limits (struct request_queue *q,struct request *rq) { -if (rq->cmd_flags &REQ_DISCARD ) +if (rq->cmd_flags & (REQ_DISCARD |REQ_SANITIZE ))return 0 ; if (blk_rq_sectors(rq) > queue_max_sectors(q) ||
block/blk-lib.c +44 -0
50 lines not on this page · raw message
block/blk-merge.c +6 -0
@@ -383,6 +383,12 @@ static int attempt_merge(struct request_queue *q, struct request *req,return 0 ;/* +* Don't merge file system requests and sanitize requests +*/ +if ((req->cmd_flags &REQ_SANITIZE ) != (next->cmd_flags &REQ_SANITIZE )) +return 0 ; + +/* * not contiguous */ if (blk_rq_pos (req) +blk_rq_sectors (req) !=blk_rq_pos (next))
block/elevator.c +7 -1
@@ -88,6 +88,12 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)return 0 ;/* +* Don't merge sanitize requests +*/ +if ((bio->bi_rw &REQ_SANITIZE ) != (rq->bio->bi_rw &REQ_SANITIZE )) +return 0 ; + +/* * different data direction or already started, don't merge */ if (bio_data_dir (bio) !=rq_data_dir (rq))
@@ -647,7 +653,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)if (rq->cmd_flags &REQ_SOFTBARRIER ) {/* barriers are scheduling boundary, update end_sector */ if (rq->cmd_type ==REQ_TYPE_FS || - (rq->cmd_flags &REQ_DISCARD )) { + (rq->cmd_flags & (REQ_DISCARD |REQ_SANITIZE ))) { q->end_sector =rq_end_sector (rq); q->boundary_rq = rq; }
block/ioctl.c +9 -0
@@ -132,6 +132,11 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,return blkdev_issue_discard (bdev, start, len,GFP_KERNEL , flags); } +static int blk_ioctl_sanitize (struct block_device *bdev) +{ +return blkdev_issue_sanitize (bdev,GFP_KERNEL ); +} +static int put_ushort (unsigned long arg,unsigned short val) {return put_user (val, (unsigned short __user *)arg);
@@ -216,6 +221,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,set_device_ro (bdev, n);return 0 ; +case BLKSANITIZE : + ret =blk_ioctl_sanitize (bdev); +break ; +case BLKDISCARD :case BLKSECDISCARD : {uint64_t range[2 ];
include/linux/blk_types.h +4 -2
@@ -150,6 +150,7 @@ enum rq_flag_bits { __REQ_FLUSH_SEQ,/* request for flush sequence */ __REQ_IO_STAT,/* account I/O stat */ __REQ_MIXED_MERGE,/* merge of different types, fail separately */ + __REQ_SANITIZE,/* sanitize */ __REQ_NR_BITS, /* stops here */ };
@@ -161,13 +162,14 @@ enum rq_flag_bits {#define REQ_META (1 << __REQ_META)#define REQ_PRIO (1 << __REQ_PRIO)#define REQ_DISCARD (1 << __REQ_DISCARD) +#define REQ_SANITIZE (1 << __REQ_SANITIZE)#define REQ_NOIDLE (1 << __REQ_NOIDLE)#define REQ_FAILFAST_MASK \ (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)#define REQ_COMMON_MASK \ - (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | \ - REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE) + (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \ + REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE | REQ_SANITIZE)#define REQ_CLONE_MASK REQ_COMMON_MASK#define REQ_RAHEAD (1 << __REQ_RAHEAD)
include/linux/blkdev.h +3 -0
@@ -423,6 +423,7 @@ struct request_queue {#define QUEUE_FLAG_ADD_RANDOM 16/* Contributes to random pool */ #define QUEUE_FLAG_SECDISCARD 17/* supports SECDISCARD */ #define QUEUE_FLAG_SAME_FORCE 18/* force complete on same CPU */ +#define QUEUE_FLAG_SANITIZE 19/* supports SANITIZE */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \
@@ -506,6 +507,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)#define blk_queue_stackable (q) \ test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags)#define blk_queue_discard (q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) +#define blk_queue_sanitize (q) test_bit(QUEUE_FLAG_SANITIZE, &(q)->queue_flags)#define blk_queue_secdiscard (q) (blk_queue_discard(q) && \ test_bit(QUEUE_FLAG_SECDISCARD, &(q)->queue_flags))
@@ -955,6 +957,7 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,extern int blkdev_issue_flush (struct block_device *,gfp_t ,sector_t *);extern int blkdev_issue_discard (struct block_device *bdev,sector_t sector,sector_t nr_sects,gfp_t gfp_mask,unsigned long flags); +extern int blkdev_issue_sanitize (struct block_device *bdev,gfp_t gfp_mask);extern int blkdev_issue_zeroout (struct block_device *bdev,sector_t sector,sector_t nr_sects,gfp_t gfp_mask); static inline int sb_issue_discard(struct super_block *sb, sector_t block,
include/linux/fs.h +1 -0
@@ -319,6 +319,7 @@ struct inodes_stat_t {#define BLKPBSZGET _IO(0x12,123)#define BLKDISCARDZEROES _IO(0x12,124)#define BLKSECDISCARD _IO(0x12,125) +#define BLKSANITIZE _IO(0x12, 126)#define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */
kernel/trace/blktrace.c +2 -0
@@ -1802,6 +1802,8 @@ void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) rwbs[i++] ='W' ; else if (rw & REQ_DISCARD) rwbs[i++] ='D' ; + else if (rw & REQ_SANITIZE) + rwbs[i++] ='Z' ; else if (bytes) rwbs[i++] ='R' ; else
Signature · 4 lines
1.7.6 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
PATCH v3 2/2 mmc: card: Adding support for Sanitize in eMMC v4.5
In reply to Yaniv Gardi--- drivers/mmc/card/block.c | 58 ++++++++++++++++++++++++++++++++++++++------- drivers/mmc/card/queue.c | 12 ++++++++- include/linux/mmc/card.h | 7 +++++ include/linux/mmc/host.h | 1 + 4 files changed, 68 insertions(+), 10 deletions(-)
drivers/mmc/card/block.c +49 -9
@@ -830,6 +830,9 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) from =blk_rq_pos (req); nr =blk_rq_sectors (req); +/* 1ST priority is DISCARD. +2ND is TRIM +3RD is ERASE */ if (mmc_can_discard (card)) arg =MMC_DISCARD_ARG ;else if (mmc_can_trim (card))
@@ -868,18 +871,11 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,unsigned int from, nr, arg;int err =0 , type =MMC_BLK_SECDISCARD ; -if (!(mmc_can_secure_erase_trim (card) ||mmc_can_sanitize (card))) { +if (!(mmc_can_secure_erase_trim (card))) { err = -EOPNOTSUPP ; goto out; } -/* The sanitize operation is supported at v4.5 only */ -if (mmc_can_sanitize (card)) { - err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_SANITIZE_START ,1 ,0 ); - goto out; - } - from =blk_rq_pos (req); nr =blk_rq_sectors (req);
@@ -922,6 +918,44 @@ out:return err ?0 :1 ; } +int mmc_blk_issue_sanitize_rq (struct mmc_queue *mq, +struct request *req) +{ +struct mmc_blk_data *md = mq->data; +struct mmc_card *card = md->queue.card; +int err =0 ; + +if (!(mmc_can_sanitize (card) && (mq->card->host->caps2 &MMC_CAP2_SANITIZE ))) { +pr_err ("%s: SANITIZE is not supported" , __func__); + err = -EOPNOTSUPP ; + goto out; + } + +pr_info ("%s: SANITIZE is supported" , __func__); + +mmc_sd_card_set_sanitize_in_progress (card); + +pr_info ("%s: issueing SANITIZE command..." , __func__); + + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , +EXT_CSD_SANITIZE_START ,1 ,0 ); + +pr_info ("%s: SANITIZE command returned..." , __func__); + +if (err) +pr_err ("%s: mmcblk: mmc_switch() failed. err=%d\n" , + __func__, err); + +mmc_sd_card_set_sanitize_completed (card); + +out: +spin_lock_irq (&md->lock); +__blk_end_request (req, err,blk_rq_bytes (req)); +spin_unlock_irq (&md->lock); + +return err ?0 :1 ; +} +static int mmc_blk_issue_flush (struct mmc_queue *mq,struct request *req) {struct mmc_blk_data *md = mq->data;
@@ -1379,7 +1413,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } -if (req && req->cmd_flags &REQ_DISCARD ) { +if (req && req->cmd_flags &REQ_SANITIZE ) { +/* complete ongoing async transfer before issuing discard */ +if (card->host && card->host->areq) +mmc_blk_issue_rw_rq (mq,NULL ); + ret =mmc_blk_issue_sanitize_rq (mq, req); + }else if (req && req->cmd_flags &REQ_DISCARD ) {/* complete ongoing async transfer before issuing discard */ if (card->host->areq)mmc_blk_issue_rw_rq (mq,NULL );
@@ -1396,6 +1435,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ret =mmc_blk_issue_rw_rq (mq, req); } + out:if (!req)/* release host only when there are no more requests */
drivers/mmc/card/queue.c +11 -1
@@ -140,10 +140,15 @@ static void mmc_queue_setup_discard(struct request_queue *q,/* granularity must not be greater than max. discard */ if (card->pref_erase > max_discard) q->limits.discard_granularity =0 ; -if (mmc_can_secure_erase_trim (card) ||mmc_can_sanitize (card)) +if (mmc_can_secure_erase_trim (card))queue_flag_set_unlocked (QUEUE_FLAG_SECDISCARD , q); } +static void mmc_queue_setup_sanitize (struct request_queue *q) +{ +queue_flag_set_unlocked (QUEUE_FLAG_SANITIZE , q); +} +/** * mmc_init_queue - initialise a queue structure. * @mq: mmc queue
@@ -181,6 +186,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,if (mmc_can_erase (card))mmc_queue_setup_discard (mq->queue, card); +if ((mmc_can_sanitize (card) && (host->caps2 &MMC_CAP2_SANITIZE ))) +mmc_queue_setup_sanitize (mq->queue); +else +pr_info ("%s - card doesn't support sanitize" , __func__); +#ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_segs ==1 ) {unsigned int bouncesz;
include/linux/mmc/card.h +7 -0
@@ -236,6 +236,9 @@ struct mmc_card {#define MMC_POWEROFF_SHORT 2#define MMC_POWEROFF_LONG 3 +/* card is in sanitize progress */ +#define MMC_STATE_SANITIZE_IN_PROGRESS (1<<9) +unsigned int erase_size;/* erase size in sectors */ unsigned int erase_shift;/* if erase unit is power 2 */ unsigned int pref_erase;/* in sectors */
@@ -388,6 +391,10 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_set_ddr_mode (c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR)#define mmc_card_set_uhs (c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)#define mmc_sd_card_set_uhs (c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED) +#define mmc_sd_card_set_sanitize_in_progress (c) ((c)->state |= \ + MMC_STATE_SANITIZE_IN_PROGRESS) +#define mmc_sd_card_set_sanitize_completed (c) ((c)->state &= \ + ~MMC_STATE_SANITIZE_IN_PROGRESS)#define mmc_card_set_ext_capacity (c) ((c)->state |= MMC_CARD_SDXC)#define mmc_card_set_removed (c) ((c)->state |= MMC_CARD_REMOVED)
include/linux/mmc/host.h +1 -0
@@ -242,6 +242,7 @@ struct mmc_host {#define MMC_CAP2_CACHE_CTRL (1 << 1)/* Allow cache control */ #define MMC_CAP2_POWEROFF_NOTIFY (1 << 2)/* Notify poweroff supported */ #define MMC_CAP2_NO_MULTI_READ (1 << 3)/* Multiblock reads don't work */ +#define MMC_CAP2_SANITIZE (1<<4)/* Support Sanitize */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;
Signature · 4 lines
1.7.6 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in eMMC v4.5
Quoted 8 lines · Yaniv Gardi
drivers/mmc/card/block.c +4
-0@@ -922,6 +918,44 @@ out:return err ?0 :1 ; } +int mmc_blk_issue_sanitize_rq (struct mmc_queue *mq, +struct request *req) +{ +struct mmc_blk_data *md = mq->data;
drivers/mmc/card/block.c out: · line 934
Quoted 10 lines
drivers/mmc/card/block.c +10
-0+struct mmc_card *card = md->queue.card; +int err =0 ; + +if (!(mmc_can_sanitize (card) && (mq->card->host->caps2 &MMC_CAP2_SANITIZE ))) { +pr_err ("%s: SANITIZE is not supported" , __func__); + err = -EOPNOTSUPP ; + goto out; + } + +pr_info ("%s: SANITIZE is supported" , __func__);
These look like debug printks. Please remove them.
Quoted 28 lines
drivers/mmc/card/block.c +24
-0+ +mmc_sd_card_set_sanitize_in_progress (card); + +pr_info ("%s: issueing SANITIZE command..." , __func__); + + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , +EXT_CSD_SANITIZE_START ,1 ,0 ); + +pr_info ("%s: SANITIZE command returned..." , __func__); + +if (err) +pr_err ("%s: mmcblk: mmc_switch() failed. err=%d\n" , + __func__, err); + +mmc_sd_card_set_sanitize_completed (card); + +out: +spin_lock_irq (&md->lock); +__blk_end_request (req, err,blk_rq_bytes (req)); +spin_unlock_irq (&md->lock); + +return err ?0 :1 ; +} +static int mmc_blk_issue_flush (struct mmc_queue *mq,struct request *req) {struct mmc_blk_data *md = mq->data;
drivers/mmc/card/block.c int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, · line 192
Quoted 7 lines
drivers/mmc/card/block.c +4
-0@@ -181,6 +186,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,if (mmc_can_erase (card))mmc_queue_setup_discard (mq->queue, card); +if ((mmc_can_sanitize (card) && (host->caps2 &MMC_CAP2_SANITIZE ))) +mmc_queue_setup_sanitize (mq->queue); +else +pr_info ("%s - card doesn't support sanitize" , __func__);
debug printk again?
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
RE: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in eMMC v4.5
= > -----Original Message-----
= > From: Stephen Boyd [mailto:[email protected]]
= > Sent: Tuesday, February 21, 2012 8:05 PM
= > To: Yaniv Gardi
= > Cc: [email protected]; [email protected]; = > [email protected]; open list
= > Subject: Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in = > eMMC v4.5
= >
= > On 02/21/12 06:00, Yaniv Gardi wrote:
= > > @@ -922,6 +918,44 @@ out:
= > > return err ? 0 : 1;
= > > }
= > >
= > > +int mmc_blk_issue_sanitize_rq(struct mmc_queue *mq,
= > > + struct request *req)
= > > +{
= > > + struct mmc_blk_data *md = mq->data;
= > > + struct mmc_card *card = md->queue.card;
= > > + int err = 0;
= > > +
= > > + if (!(mmc_can_sanitize(card) && (mq->card->host->caps2 &
= > MMC_CAP2_SANITIZE))) {
= > > + pr_err("%s: SANITIZE is not supported", __func__);
= > > + err = -EOPNOTSUPP;
= > > + goto out;
= > > + }
= > > +
= > > + pr_info("%s: SANITIZE is supported", __func__);
= >
= > These look like debug printks. Please remove them.
Printout Removed.
= >
= > > +
= > > + mmc_sd_card_set_sanitize_in_progress(card);
= > > +
= > > + pr_info("%s: issueing SANITIZE command...", __func__);
= > > +
= > > + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
= > > + EXT_CSD_SANITIZE_START, 1, 0);
= > > +
= > > + pr_info("%s: SANITIZE command returned...", __func__);
= > > +
= > > + if (err)
= > > + pr_err("%s: mmcblk: mmc_switch() failed. err=%d\n",
= > > + __func__, err);
= > > +
= > > + mmc_sd_card_set_sanitize_completed(card);
= > > +
= > > +out:
= > > + spin_lock_irq(&md->lock);
= > > + __blk_end_request(req, err, blk_rq_bytes(req));
= > > + spin_unlock_irq(&md->lock);
= > > +
= > > + return err ? 0 : 1;
= > > +}
= > > +
= > > static int mmc_blk_issue_flush(struct mmc_queue *mq, struct = > request *req)
= > > {
= > > struct mmc_blk_data *md = mq->data;
= > > @@ -181,6 +186,11 @@ int mmc_init_queue(struct mmc_queue *mq, = > struct mmc_card *card,
= > > if (mmc_can_erase(card))
= > > mmc_queue_setup_discard(mq->queue, card);
= > >
= > > + if ((mmc_can_sanitize(card) && (host->caps2 &
= > MMC_CAP2_SANITIZE)))
= > > + mmc_queue_setup_sanitize(mq->queue);
= > > + else
= > > + pr_info("%s - card doesn't support sanitize", __func__);
= >
= > debug printk again?
Printout removed.
= >
= > Sent by an employee of the Qualcomm Innovation Center, Inc. = > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora = > Forum.
Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in eMMC v4.5
In reply to Yaniv GardiQuoted 45 lines · Yaniv Gardi
Signed-off-by Yaniv Gardi <[email protected]>--- drivers/mmc/card/block.c | 58 ++++++++++++++++++++++++++++++++++++++------- drivers/mmc/card/queue.c | 12 ++++++++- include/linux/mmc/card.h | 7 +++++ include/linux/mmc/host.h | 1 + 4 files changed, 68 insertions(+), 10 deletions(-)drivers/mmc/card/block.c +4
-8@@ -830,6 +830,9 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) from =blk_rq_pos (req); nr =blk_rq_sectors (req); +/* 1ST priority is DISCARD. +2ND is TRIM +3RD is ERASE */ if (mmc_can_discard (card)) arg =MMC_DISCARD_ARG ;else if (mmc_can_trim (card))@@ -868,18 +871,11 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,unsigned int from, nr, arg;int err =0 , type =MMC_BLK_SECDISCARD ; -if (!(mmc_can_secure_erase_trim (card) ||mmc_can_sanitize (card))) { +if (!(mmc_can_secure_erase_trim (card))) { err = -EOPNOTSUPP ; goto out; } -/* The sanitize operation is supported at v4.5 only */ -if (mmc_can_sanitize (card)) { - err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_SANITIZE_START ,1 ,0 ); - goto out; - } - from =blk_rq_pos (req); nr =blk_rq_sectors (req);@@ -922,6 +918,44 @@ out:return err ?0 :1 ;
drivers/mmc/card/block.c out: · line 928
Quoted 10 lines
drivers/mmc/card/block.c +8
-0} +int mmc_blk_issue_sanitize_rq (struct mmc_queue *mq, +struct request *req) +{ +struct mmc_blk_data *md = mq->data; +struct mmc_card *card = md->queue.card; +int err =0 ; + +if (!(mmc_can_sanitize (card) && (mq->card->host->caps2 &MMC_CAP2_SANITIZE ))) {
if (!mmc_can_sanitize(card) && card->host->caps2 & MMC_CAP2_SANITIZE)?
Quoted 5 lines
drivers/mmc/card/block.c +5
-0+pr_err ("%s: SANITIZE is not supported" , __func__); + err = -EOPNOTSUPP ; + goto out; + } +
drivers/mmc/card/block.c out: · line 943
Quoted 10 lines
drivers/mmc/card/block.c +10
-0+pr_info ("%s: SANITIZE is supported" , __func__); + +mmc_sd_card_set_sanitize_in_progress (card); + +pr_info ("%s: issueing SANITIZE command..." , __func__); + + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , +EXT_CSD_SANITIZE_START ,1 ,0 ); + +pr_info ("%s: SANITIZE command returned..." , __func__);
Too many pr_info()..i think that need not the message..
drivers/mmc/card/block.c out: · line 947
Quoted 4 lines
drivers/mmc/card/block.c +4
-0+ +if (err) +pr_err ("%s: mmcblk: mmc_switch() failed. err=%d\n" , + __func__, err);
how about using mmcblkX instead of just mmcblk?
Quoted 15 lines
drivers/mmc/card/block.c +11
-0+ +mmc_sd_card_set_sanitize_completed (card); + +out: +spin_lock_irq (&md->lock); +__blk_end_request (req, err,blk_rq_bytes (req)); +spin_unlock_irq (&md->lock); + +return err ?0 :1 ; +} +static int mmc_blk_issue_flush (struct mmc_queue *mq,struct request *req) {struct mmc_blk_data *md = mq->data;
drivers/mmc/card/block.c static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) · line 1417
Quoted 6 lines
drivers/mmc/card/block.c +2
-1@@ -1379,7 +1413,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } -if (req && req->cmd_flags &REQ_DISCARD ) { +if (req && req->cmd_flags &REQ_SANITIZE ) { +/* complete ongoing async transfer before issuing discard */
Issuing Sanitize, not discard. typo.
Quoted 85 lines
drivers/mmc/card/block.c +5
-0+if (card->host && card->host->areq) +mmc_blk_issue_rw_rq (mq,NULL ); + ret =mmc_blk_issue_sanitize_rq (mq, req); + }else if (req && req->cmd_flags &REQ_DISCARD ) {/* complete ongoing async transfer before issuing discard */ if (card->host->areq)mmc_blk_issue_rw_rq (mq,NULL );@@ -1396,6 +1435,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ret =mmc_blk_issue_rw_rq (mq, req); } + out:if (!req)/* release host only when there are no more requests */ drivers/mmc/card/queue.c +11
-1@@ -140,10 +140,15 @@ static void mmc_queue_setup_discard(struct request_queue *q,/* granularity must not be greater than max. discard */ if (card->pref_erase > max_discard) q->limits.discard_granularity =0 ; -if (mmc_can_secure_erase_trim (card) ||mmc_can_sanitize (card)) +if (mmc_can_secure_erase_trim (card))queue_flag_set_unlocked (QUEUE_FLAG_SECDISCARD , q); } +static void mmc_queue_setup_sanitize (struct request_queue *q) +{ +queue_flag_set_unlocked (QUEUE_FLAG_SANITIZE , q); +} +/** * mmc_init_queue - initialise a queue structure. * @mq: mmc queue @@ -181,6 +186,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,if (mmc_can_erase (card))mmc_queue_setup_discard (mq->queue, card); +if ((mmc_can_sanitize (card) && (host->caps2 &MMC_CAP2_SANITIZE ))) +mmc_queue_setup_sanitize (mq->queue); +else +pr_info ("%s - card doesn't support sanitize" , __func__); +#ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_segs ==1 ) {unsigned int bouncesz;include/linux/mmc/card.h +7
-0@@ -236,6 +236,9 @@ struct mmc_card {#define MMC_POWEROFF_SHORT 2#define MMC_POWEROFF_LONG 3 +/* card is in sanitize progress */ +#define MMC_STATE_SANITIZE_IN_PROGRESS (1<<9) +unsigned int erase_size;/* erase size in sectors */ unsigned int erase_shift;/* if erase unit is power 2 */ unsigned int pref_erase;/* in sectors */ @@ -388,6 +391,10 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_set_ddr_mode (c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR)#define mmc_card_set_uhs (c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)#define mmc_sd_card_set_uhs (c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED) +#define mmc_sd_card_set_sanitize_in_progress (c) ((c)->state |= \ + MMC_STATE_SANITIZE_IN_PROGRESS) +#define mmc_sd_card_set_sanitize_completed (c) ((c)->state &= \ + ~MMC_STATE_SANITIZE_IN_PROGRESS)#define mmc_card_set_ext_capacity (c) ((c)->state |= MMC_CARD_SDXC)#define mmc_card_set_removed (c) ((c)->state |= MMC_CARD_REMOVED)include/linux/mmc/host.h +1
-0@@ -242,6 +242,7 @@ struct mmc_host {#define MMC_CAP2_CACHE_CTRL (1 << 1)/* Allow cache control */ #define MMC_CAP2_POWEROFF_NOTIFY (1 << 2)/* Notify poweroff supported */ #define MMC_CAP2_NO_MULTI_READ (1 << 3)/* Multiblock reads don't work */ +#define MMC_CAP2_SANITIZE (1<<4)/* Support Sanitize */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;
RE: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in eMMC v4.5
= > -----Original Message-----
= > From: Jaehoon Chung [mailto:[email protected]]
= > Sent: Wednesday, February 22, 2012 8:09 AM
= > To: Yaniv Gardi
= > Cc: [email protected]; [email protected]; = > [email protected]; open list
= > Subject: Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in = > eMMC v4.5
= >
= > On 02/21/2012 11:00 PM, Yaniv Gardi wrote:
= >
= > > Signed-off-by: Yaniv Gardi <[email protected]>
= > >
= > > ---
= > > drivers/mmc/card/block.c | 58
= > ++++++++++++++++++++++++++++++++++++++-------
= > > drivers/mmc/card/queue.c | 12 ++++++++- = > > include/linux/mmc/card.h | 7 +++++ = > > include/linux/mmc/host.h | 1 + = > > 4 files changed, 68 insertions(+), 10 deletions(-)
= > >
= > > diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c = > > index 0c959c9..5be77e6 100644
= > > --- a/drivers/mmc/card/block.c
= > > +++ b/drivers/mmc/card/block.c
= > > @@ -830,6 +830,9 @@ static int mmc_blk_issue_discard_rq(struct = > mmc_queue *mq, struct request *req)
= > > from = blk_rq_pos(req);
= > > nr = blk_rq_sectors(req);
= > >
= > > + /* 1ST priority is DISCARD.
= > > + 2ND is TRIM
= > > + 3RD is ERASE */
= > > if (mmc_can_discard(card)) = > > arg = MMC_DISCARD_ARG; = > > else if (mmc_can_trim(card))
= > > @@ -868,18 +871,11 @@ static int mmc_blk_issue_secdiscard_rq(struct = > mmc_queue *mq,
= > > unsigned int from, nr, arg;
= > > int err = 0, type = MMC_BLK_SECDISCARD;
= > >
= > > - if (!(mmc_can_secure_erase_trim(card) ||
= > mmc_can_sanitize(card))) {
= > > + if (!(mmc_can_secure_erase_trim(card))) {
= > > err = -EOPNOTSUPP; = > > goto out; = > > }
= > >
= > > - /* The sanitize operation is supported at v4.5 only */
= > > - if (mmc_can_sanitize(card)) {
= > > - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
= > > - EXT_CSD_SANITIZE_START, 1, 0);
= > > - goto out;
= > > - }
= > > -
= > > from = blk_rq_pos(req);
= > > nr = blk_rq_sectors(req);
= > >
= > > @@ -922,6 +918,44 @@ out:
= > > return err ? 0 : 1;
= > > }
= > >
= > > +int mmc_blk_issue_sanitize_rq(struct mmc_queue *mq,
= > > + struct request *req)
= > > +{
= > > + struct mmc_blk_data *md = mq->data;
= > > + struct mmc_card *card = md->queue.card;
= > > + int err = 0;
= > > +
= > > + if (!(mmc_can_sanitize(card) && (mq->card->host->caps2 &
= > MMC_CAP2_SANITIZE))) {
= >
= > if (!mmc_can_sanitize(card) && card->host->caps2 & = > MMC_CAP2_SANITIZE)?
No. it should be (!(A & B)). Since (A & B) means there is a support in sanitize.
= >
= > > + pr_err("%s: SANITIZE is not supported", __func__);
= > > + err = -EOPNOTSUPP;
= > > + goto out;
= > > + }
= > > +
= > > + pr_info("%s: SANITIZE is supported", __func__);
= > > +
= > > + mmc_sd_card_set_sanitize_in_progress(card);
= > > +
= > > + pr_info("%s: issueing SANITIZE command...", __func__);
= > > +
= > > + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
= > > + EXT_CSD_SANITIZE_START, 1, 0);
= > > +
= > > + pr_info("%s: SANITIZE command returned...", __func__);
= >
= > Too many pr_info()..i think that need not the message..
Printout Removed.
= >
= > > +
= > > + if (err)
= > > + pr_err("%s: mmcblk: mmc_switch() failed. err=%d\n",
= > > + __func__, err);
= >
= > how about using mmcblkX instead of just mmcblk?
Ok. I changed it to mmc%d
= >
= > > +
= > > + mmc_sd_card_set_sanitize_completed(card);
= > > +
= > > +out:
= > > + spin_lock_irq(&md->lock);
= > > + __blk_end_request(req, err, blk_rq_bytes(req));
= > > + spin_unlock_irq(&md->lock);
= > > +
= > > + return err ? 0 : 1;
= > > +}
= > > +
= > > static int mmc_blk_issue_flush(struct mmc_queue *mq, struct = > request *req)
= > > {
= > > struct mmc_blk_data *md = mq->data;
= > > @@ -1379,7 +1413,12 @@ static int mmc_blk_issue_rq(struct mmc_queue = > *mq, struct request *req)
= > > goto out;
= > > }
= > >
= > > - if (req && req->cmd_flags & REQ_DISCARD) {
= > > + if (req && req->cmd_flags & REQ_SANITIZE) {
= > > + /* complete ongoing async transfer before issuing discard
= > */
= >
= > Issuing Sanitize, not discard. typo.
Typo fixed.
= >
= > > + if (card->host && card->host->areq)
= > > + mmc_blk_issue_rw_rq(mq, NULL);
= > > + ret = mmc_blk_issue_sanitize_rq(mq, req);
= > > + } else if (req && req->cmd_flags & REQ_DISCARD) {
= > > /* complete ongoing async transfer before issuing discard
= > */
= > > if (card->host->areq)
= > > mmc_blk_issue_rw_rq(mq, NULL);
= > > @@ -1396,6 +1435,7 @@ static int mmc_blk_issue_rq(struct mmc_queue = > *mq, struct request *req)
= > > ret = mmc_blk_issue_rw_rq(mq, req);
= > > }
= > >
= > > +
= > > out: = > > if (!req) = > > /* release host only when there are no more requests */
= > > diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c = > > index dcad59c..6946ac1 100644
= > > --- a/drivers/mmc/card/queue.c
= > > +++ b/drivers/mmc/card/queue.c
= > > @@ -140,10 +140,15 @@ static void mmc_queue_setup_discard(struct = > request_queue *q,
= > > /* granularity must not be greater than max. discard */ = > > if (card->pref_erase > max_discard) = > > q->limits.discard_granularity = 0;
= > > - if (mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))
= > > + if (mmc_can_secure_erase_trim(card))
= > > queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
= > > }
= > >
= > > +static void mmc_queue_setup_sanitize(struct request_queue *q) = > > +{
= > > + queue_flag_set_unlocked(QUEUE_FLAG_SANITIZE, q);
= > > +}
= > > +
= > > /**
= > > * mmc_init_queue - initialise a queue structure.
= > > * @mq: mmc queue
= > > @@ -181,6 +186,11 @@ int mmc_init_queue(struct mmc_queue *mq, = > struct mmc_card *card,
= > > if (mmc_can_erase(card))
= > > mmc_queue_setup_discard(mq->queue, card);
= > >
= > > + if ((mmc_can_sanitize(card) && (host->caps2 &
= > MMC_CAP2_SANITIZE)))
= > > + mmc_queue_setup_sanitize(mq->queue);
= > > + else
= > > + pr_info("%s - card doesn't support sanitize", __func__);
= > > +
= > > #ifdef CONFIG_MMC_BLOCK_BOUNCE
= > > if (host->max_segs == 1) {
= > > unsigned int bouncesz;= > > diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h = > > index 9478a6b..0890e9c 100644
= > > --- a/include/linux/mmc/card.h
= > > +++ b/include/linux/mmc/card.h
= > > @@ -236,6 +236,9 @@ struct mmc_card {
= > > #define MMC_POWEROFF_SHORT 2
= > > #define MMC_POWEROFF_LONG 3
= > >
= > > +/* card is in sanitize progress */
= > > +#define MMC_STATE_SANITIZE_IN_PROGRESS (1<<9)
= > > +
= > > unsigned int erase_size; /* erase size in sectors */
= > > unsigned int erase_shift; /* if erase unit is
= > power 2 */
= > > unsigned int pref_erase; /* in sectors */
= > > @@ -388,6 +391,10 @@ static inline void __maybe_unused = > remove_quirk(struct mmc_card *card, int data)
= > > #define mmc_card_set_ddr_mode(c) ((c)->state |=
= > MMC_STATE_HIGHSPEED_DDR)
= > > #define mmc_card_set_uhs(c) ((c)->state |=
= > MMC_STATE_ULTRAHIGHSPEED)
= > > #define mmc_sd_card_set_uhs(c) ((c)->state |=
= > MMC_STATE_ULTRAHIGHSPEED)
= > > +#define mmc_sd_card_set_sanitize_in_progress(c) ((c)->state |= \
= > > + MMC_STATE_SANITIZE_IN_PROGRESS)
= > > +#define mmc_sd_card_set_sanitize_completed(c) ((c)->state &= \
= > > + ~MMC_STATE_SANITIZE_IN_PROGRESS)
= > > #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) = > > #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) = > >
= > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h = > > index 9a03d03..93210aa 100644
= > > --- a/include/linux/mmc/host.h
= > > +++ b/include/linux/mmc/host.h
= > > @@ -242,6 +242,7 @@ struct mmc_host {
= > > #define MMC_CAP2_CACHE_CTRL (1 << 1) /* Allow cache
= > control */
= > > #define MMC_CAP2_POWEROFF_NOTIFY (1 << 2) /* Notify poweroff
= > supported */
= > > #define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads
= > don't work */
= > > +#define MMC_CAP2_SANITIZE (1<<4) /* Support Sanitize
= > */
= > >
= > > mmc_pm_flag_t pm_caps; /* supported pm features */
= > > unsigned int power_notify_type;
= >
Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in eMMC v4.5
Quoted 77 lines · Yaniv Gardi
= > -----Original Message-----
= > From: Jaehoon Chung [mailto:[email protected]]
= > Sent: Wednesday, February 22, 2012 8:09 AM
= > To: Yaniv Gardi
= > Cc: [email protected]; [email protected]; = > [email protected]; open list
= > Subject: Re: [PATCH v3 2/2] mmc: card: Adding support for Sanitize in = > eMMC v4.5
= >
= > On 02/21/2012 11:00 PM, Yaniv Gardi wrote:
= >
= > > Signed-off-by: Yaniv Gardi <[email protected]>
= > >
= > > ---
= > >drivers/mmc/card/block.c| 58
= > ++++++++++++++++++++++++++++++++++++++-------= > > drivers/mmc/card/queue.c | 12 ++++++++- = > > include/linux/mmc/card.h | 7 +++++ = > > include/linux/mmc/host.h | 1 + = > > 4 files changed, 68 insertions(+), 10 deletions(-)= > >
= > > diff --gita/drivers/mmc/card/block.cb/drivers/mmc/card/block.c= > > index 0c959c9..5be77e6 100644
= > > ---a/drivers/mmc/card/block.c
= > > +++b/drivers/mmc/card/block.c
= > > @@ -830,6 +830,9 @@ static intmmc_blk_issue_discard_rq(struct = > mmc_queue *mq, struct request *req)
= > > from =blk_rq_pos(req);
= > > nr =blk_rq_sectors(req);
= > >
= > > + /* 1ST priority is DISCARD.
= > > + 2ND is TRIM
= > > + 3RD is ERASE */= > > if (mmc_can_discard(card)) = > > arg = MMC_DISCARD_ARG; = > > else if (mmc_can_trim(card))= > > @@ -868,18 +871,11 @@ static int mmc_blk_issue_secdiscard_rq(struct = >
mmc_queue*mq,
= > > unsigned int from, nr, arg;
= > > int err = 0, type =MMC_BLK_SECDISCARD;
= > >
= > > - if (!(mmc_can_secure_erase_trim(card) ||
= >mmc_can_sanitize(card))) {
= > > + if (!(mmc_can_secure_erase_trim(card))) {= > > err = -EOPNOTSUPP; = > > goto out; = > > }= > >
= > > - /* The sanitize operation is supported at v4.5 only */
= > > - if (mmc_can_sanitize(card)) {
= > > - err = mmc_switch(card,EXT_CSD_CMD_SET_NORMAL,
= > > -EXT_CSD_SANITIZE_START, 1, 0);
= > > - goto out;
= > > - }
= > > -
= > > from =blk_rq_pos(req);
= > > nr =blk_rq_sectors(req);
= > >
= > > @@ -922,6 +918,44 @@ out:
= > > return err ? 0 : 1;
= > > }
= > >
= > > +int mmc_blk_issue_sanitize_rq(structmmc_queue*mq,
= > > + struct request *req)
= > > +{
= > > + structmmc_blk_data*md =mq->data;
= > > + structmmc_card*card =md->queue.card;
= > > + int err = 0;
= > > +
= > > + if (!(mmc_can_sanitize(card) && (mq->card->host->caps2&
= >MMC_CAP2_SANITIZE))) {
= >
= > if (!mmc_can_sanitize(card) &&card->host->caps2& = >MMC_CAP2_SANITIZE)?
Quoted 2 lines
No. it should be (!(A & B)). Since (A & B) means there is a support in sanitize.
You're right. it's typo. my means that use "card->host->caps2" instead of "mq->card->host->caps2".
Best Regards,
Jaehoon Chung
Quoted 168 lines
= >
= > > +pr_err("%s: SANITIZE is not supported", __func__);
= > > + err =-EOPNOTSUPP;
= > > + goto out;
= > > + }
= > > +
= > > +pr_info("%s: SANITIZE is supported", __func__);
= > > +
= > > +mmc_sd_card_set_sanitize_in_progress(card);
= > > +
= > > +pr_info("%s: issueing SANITIZE command...", __func__);
= > > +
= > > + err = mmc_switch(card,EXT_CSD_CMD_SET_NORMAL,
= > > +EXT_CSD_SANITIZE_START, 1, 0);
= > > +
= > > +pr_info("%s: SANITIZE command returned...", __func__);
= >
= > Too many pr_info()..i think that need not the message..Printout Removed.
= >
= > > +
= > > + if (err)
= > > + pr_err("%s: mmcblk:mmc_switch()failed. err=%d\n",
= > > +__func__, err);
= >
= > how about using mmcblkX instead of just mmcblk?Ok. I changed it to mmc%d
= >
= > > +
= > > +mmc_sd_card_set_sanitize_completed(card);
= > > +
= > > +out:
= > > +spin_lock_irq(&md->lock);
= > > +__blk_end_request(req, err, blk_rq_bytes(req));
= > > +spin_unlock_irq(&md->lock);
= > > +
= > > + return err ? 0 : 1;
= > > +}
= > > +
= > > static intmmc_blk_issue_flush(struct mmc_queue *mq, struct = > request *req)
= > > {
= > > structmmc_blk_data*md =mq->data;
= > > @@ -1379,7 +1413,12 @@ static intmmc_blk_issue_rq(struct mmc_queue = > *mq, struct request *req)
= > > goto out;
= > > }
= > >
= > > - if (req &&req->cmd_flags&REQ_DISCARD) {
= > > + if (req &&req->cmd_flags&REQ_SANITIZE) {
= > > + /* complete ongoing async transfer before issuing discard
= > */
= >
= > Issuing Sanitize, not discard. typo.Typo fixed.
= >
= > > + if (card->host&&card->host->areq)
= > > +mmc_blk_issue_rw_rq(mq, NULL);
= > > + ret =mmc_blk_issue_sanitize_rq(mq, req);
= > > + } else if (req &&req->cmd_flags&REQ_DISCARD) {
= > > /* complete ongoing async transfer before issuing discard
= > */
= > > if (card->host->areq)
= > >mmc_blk_issue_rw_rq(mq, NULL);
= > > @@ -1396,6 +1435,7 @@ static intmmc_blk_issue_rq(struct mmc_queue = > *mq, struct request *req)
= > > ret =mmc_blk_issue_rw_rq(mq, req);
= > > }
= > >
= > > += > > out: = > > if (!req) = > > /* release host only when there are no more requests */= > > diff --git
a/drivers/mmc/card/queue.cb/drivers/mmc/card/queue.c= > > index dcad59c..6946ac1 100644
= > > ---a/drivers/mmc/card/queue.c
= > > +++b/drivers/mmc/card/queue.c
= > > @@ -140,10 +140,15 @@ static void mmc_queue_setup_discard(struct = >request_queue*q,= > > /* granularity must not be greater than max. discard */ = > > if (card->pref_erase > max_discard) = > > q->limits.discard_granularity = 0;= > > - if (
mmc_can_secure_erase_trim(card)||mmc_can_sanitize(card))
= > > + if (mmc_can_secure_erase_trim(card))
= > >queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
= > > }
= > >
= > > +static voidmmc_queue_setup_sanitize(struct request_queue *q)= > > +{
= > > +queue_flag_set_unlocked(QUEUE_FLAG_SANITIZE, q);
= > > +}
= > > +
= > > /**
= > > *mmc_init_queue- initialise a queue structure.
= > > * @mq: mmc queue
= > > @@ -181,6 +186,11 @@ int mmc_init_queue(structmmc_queue*mq, = > structmmc_card*card,
= > > if (mmc_can_erase(card))
= > >mmc_queue_setup_discard(mq->queue, card);
= > >
= > > + if ((mmc_can_sanitize(card)&& (host->caps2&
= >MMC_CAP2_SANITIZE)))
= > > +mmc_queue_setup_sanitize(mq->queue);
= > > + else
= > > +pr_info("%s - card doesn't support sanitize", __func__);
= > > += > > #ifdef CONFIG_MMC_BLOCK_BOUNCE = > > if (host->max_segs == 1) { = > > unsigned int bouncesz;= > > diff --git
a/include/linux/mmc/card.hb/include/linux/mmc/card.h= > > index 9478a6b..0890e9c 100644
= > > ---a/include/linux/mmc/card.h
= > > +++b/include/linux/mmc/card.h
= > > @@ -236,6 +236,9 @@ structmmc_card{
= > > #defineMMC_POWEROFF_SHORT2
= > > #defineMMC_POWEROFF_LONG3
= > >
= > > +/* card is in sanitize progress */
= > > +#defineMMC_STATE_SANITIZE_IN_PROGRESS(1<<9)
= > > +
= > > unsigned interase_size; /* erase size in sectors */
= > > unsigned interase_shift; /* if erase unit is
= > power 2 */
= > > unsigned intpref_erase; /* in sectors */
= > > @@ -388,6 +391,10 @@ static inline void__maybe_unused= >remove_quirk(struct mmc_card *card, int data)
= > > #definemmc_card_set_ddr_mode(c)((c)->state |=
= >MMC_STATE_HIGHSPEED_DDR)
= > > #definemmc_card_set_uhs(c)((c)->state |=
= >MMC_STATE_ULTRAHIGHSPEED)
= > > #definemmc_sd_card_set_uhs(c)((c)->state |=
= >MMC_STATE_ULTRAHIGHSPEED)
= > > +#definemmc_sd_card_set_sanitize_in_progress(c)((c)->state |= \
= > > +MMC_STATE_SANITIZE_IN_PROGRESS)
= > > +#definemmc_sd_card_set_sanitize_completed(c)((c)->state &= \
= > > + ~MMC_STATE_SANITIZE_IN_PROGRESS)
= > > #definemmc_card_set_ext_capacity(c)((c)->state |=MMC_CARD_SDXC) = > > #definemmc_card_set_removed(c)((c)->state |=MMC_CARD_REMOVED) = > >
= > > diff --gita/include/linux/mmc/host.hb/include/linux/mmc/host.h= > > index 9a03d03..93210aa 100644
= > > ---a/include/linux/mmc/host.h
= > > +++b/include/linux/mmc/host.h
= > > @@ -242,6 +242,7 @@ structmmc_host{
= > > #defineMMC_CAP2_CACHE_CTRL(1 << 1) /* Allow cache
= > control */
= > > #defineMMC_CAP2_POWEROFF_NOTIFY(1 << 2) /* Notify poweroff
= > supported */
= > > #defineMMC_CAP2_NO_MULTI_READ(1 << 3) /* Multiblock reads
= > don't work */
= > > +#defineMMC_CAP2_SANITIZE(1<<4) /* Support Sanitize
= > */
= > >
= > >mmc_pm_flag_tpm_caps; /* supported pm features */
= > > unsigned intpower_notify_type;
= >