diff options
Diffstat (limited to 'drivers/mmc/core')
| -rw-r--r-- | drivers/mmc/core/Makefile | 1 | ||||
| -rw-r--r-- | drivers/mmc/core/block.c | 3 | ||||
| -rw-r--r-- | drivers/mmc/core/block.h | 1 | ||||
| -rw-r--r-- | drivers/mmc/core/mmc.c | 36 | ||||
| -rw-r--r-- | drivers/mmc/core/queue.c | 120 | ||||
| -rw-r--r-- | drivers/mmc/core/queue.h | 7 | ||||
| -rw-r--r-- | drivers/mmc/core/quirks.h | 1 | ||||
| -rw-r--r-- | drivers/mmc/core/sd.h | 1 | 
8 files changed, 33 insertions, 137 deletions
| diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile index 7e3ed1aeada2..abba078f7f49 100644 --- a/drivers/mmc/core/Makefile +++ b/drivers/mmc/core/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0  #  # Makefile for the kernel mmc core.  # diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 29fc1e662891..2ad7b5c69156 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1634,8 +1634,6 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq,  	}  	mqrq->areq.mrq = &brq->mrq; - -	mmc_queue_bounce_pre(mqrq);  }  static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, @@ -1829,7 +1827,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)  		brq = &mq_rq->brq;  		old_req = mmc_queue_req_to_req(mq_rq);  		type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE; -		mmc_queue_bounce_post(mq_rq);  		switch (status) {  		case MMC_BLK_SUCCESS: diff --git a/drivers/mmc/core/block.h b/drivers/mmc/core/block.h index 860ca7c8df86..5946636101ef 100644 --- a/drivers/mmc/core/block.h +++ b/drivers/mmc/core/block.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  #ifndef _MMC_CORE_BLOCK_H  #define _MMC_CORE_BLOCK_H diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index a7eb623f8daa..36217ad5e9b1 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1286,6 +1286,23 @@ out_err:  	return err;  } +static void mmc_select_driver_type(struct mmc_card *card) +{ +	int card_drv_type, drive_strength, drv_type; + +	card_drv_type = card->ext_csd.raw_driver_strength | +			mmc_driver_type_mask(0); + +	drive_strength = mmc_select_drive_strength(card, +						   card->ext_csd.hs200_max_dtr, +						   card_drv_type, &drv_type); + +	card->drive_strength = drive_strength; + +	if (drv_type) +		mmc_set_driver_type(card->host, drv_type); +} +  static int mmc_select_hs400es(struct mmc_card *card)  {  	struct mmc_host *host = card->host; @@ -1341,6 +1358,8 @@ static int mmc_select_hs400es(struct mmc_card *card)  		goto out_err;  	} +	mmc_select_driver_type(card); +  	/* Switch card to HS400 */  	val = EXT_CSD_TIMING_HS400 |  	      card->drive_strength << EXT_CSD_DRV_STR_SHIFT; @@ -1374,23 +1393,6 @@ out_err:  	return err;  } -static void mmc_select_driver_type(struct mmc_card *card) -{ -	int card_drv_type, drive_strength, drv_type; - -	card_drv_type = card->ext_csd.raw_driver_strength | -			mmc_driver_type_mask(0); - -	drive_strength = mmc_select_drive_strength(card, -						   card->ext_csd.hs200_max_dtr, -						   card_drv_type, &drv_type); - -	card->drive_strength = drive_strength; - -	if (drv_type) -		mmc_set_driver_type(card->host, drv_type); -} -  /*   * For device supporting HS200 mode, the following sequence   * should be done before executing the tuning process. diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index affa7370ba82..0a4e77a5ba33 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -23,8 +23,6 @@  #include "core.h"  #include "card.h" -#define MMC_QUEUE_BOUNCESZ	65536 -  /*   * Prepare a MMC request. This just filters out odd stuff.   */ @@ -150,26 +148,6 @@ static void mmc_queue_setup_discard(struct request_queue *q,  		queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q);  } -static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host) -{ -	unsigned int bouncesz = MMC_QUEUE_BOUNCESZ; - -	if (host->max_segs != 1 || (host->caps & MMC_CAP_NO_BOUNCE_BUFF)) -		return 0; - -	if (bouncesz > host->max_req_size) -		bouncesz = host->max_req_size; -	if (bouncesz > host->max_seg_size) -		bouncesz = host->max_seg_size; -	if (bouncesz > host->max_blk_count * 512) -		bouncesz = host->max_blk_count * 512; - -	if (bouncesz <= 512) -		return 0; - -	return bouncesz; -} -  /**   * mmc_init_request() - initialize the MMC-specific per-request data   * @q: the request queue @@ -184,26 +162,9 @@ static int mmc_init_request(struct request_queue *q, struct request *req,  	struct mmc_card *card = mq->card;  	struct mmc_host *host = card->host; -	if (card->bouncesz) { -		mq_rq->bounce_buf = kmalloc(card->bouncesz, gfp); -		if (!mq_rq->bounce_buf) -			return -ENOMEM; -		if (card->bouncesz > 512) { -			mq_rq->sg = mmc_alloc_sg(1, gfp); -			if (!mq_rq->sg) -				return -ENOMEM; -			mq_rq->bounce_sg = mmc_alloc_sg(card->bouncesz / 512, -							gfp); -			if (!mq_rq->bounce_sg) -				return -ENOMEM; -		} -	} else { -		mq_rq->bounce_buf = NULL; -		mq_rq->bounce_sg = NULL; -		mq_rq->sg = mmc_alloc_sg(host->max_segs, gfp); -		if (!mq_rq->sg) -			return -ENOMEM; -	} +	mq_rq->sg = mmc_alloc_sg(host->max_segs, gfp); +	if (!mq_rq->sg) +		return -ENOMEM;  	return 0;  } @@ -212,13 +173,6 @@ static void mmc_exit_request(struct request_queue *q, struct request *req)  {  	struct mmc_queue_req *mq_rq = req_to_mmc_queue_req(req); -	/* It is OK to kfree(NULL) so this will be smooth */ -	kfree(mq_rq->bounce_sg); -	mq_rq->bounce_sg = NULL; - -	kfree(mq_rq->bounce_buf); -	mq_rq->bounce_buf = NULL; -  	kfree(mq_rq->sg);  	mq_rq->sg = NULL;  } @@ -265,18 +219,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); -	card->bouncesz = mmc_queue_calc_bouncesz(host); -	if (card->bouncesz) { -		blk_queue_max_hw_sectors(mq->queue, card->bouncesz / 512); -		blk_queue_max_segments(mq->queue, card->bouncesz / 512); -		blk_queue_max_segment_size(mq->queue, card->bouncesz); -	} else { -		blk_queue_bounce_limit(mq->queue, limit); -		blk_queue_max_hw_sectors(mq->queue, -			min(host->max_blk_count, host->max_req_size / 512)); -		blk_queue_max_segments(mq->queue, host->max_segs); -		blk_queue_max_segment_size(mq->queue, host->max_seg_size); -	} +	blk_queue_bounce_limit(mq->queue, limit); +	blk_queue_max_hw_sectors(mq->queue, +		min(host->max_blk_count, host->max_req_size / 512)); +	blk_queue_max_segments(mq->queue, host->max_segs); +	blk_queue_max_segment_size(mq->queue, host->max_seg_size);  	sema_init(&mq->thread_sem, 1); @@ -365,56 +312,7 @@ void mmc_queue_resume(struct mmc_queue *mq)   */  unsigned int mmc_queue_map_sg(struct mmc_queue *mq, struct mmc_queue_req *mqrq)  { -	unsigned int sg_len; -	size_t buflen; -	struct scatterlist *sg;  	struct request *req = mmc_queue_req_to_req(mqrq); -	int i; - -	if (!mqrq->bounce_buf) -		return blk_rq_map_sg(mq->queue, req, mqrq->sg); - -	sg_len = blk_rq_map_sg(mq->queue, req, mqrq->bounce_sg); - -	mqrq->bounce_sg_len = sg_len; - -	buflen = 0; -	for_each_sg(mqrq->bounce_sg, sg, sg_len, i) -		buflen += sg->length; - -	sg_init_one(mqrq->sg, mqrq->bounce_buf, buflen); - -	return 1; -} - -/* - * If writing, bounce the data to the buffer before the request - * is sent to the host driver - */ -void mmc_queue_bounce_pre(struct mmc_queue_req *mqrq) -{ -	if (!mqrq->bounce_buf) -		return; - -	if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != WRITE) -		return; - -	sg_copy_to_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len, -		mqrq->bounce_buf, mqrq->sg[0].length); -} - -/* - * If reading, bounce the data from the buffer after the request - * has been handled by the host driver - */ -void mmc_queue_bounce_post(struct mmc_queue_req *mqrq) -{ -	if (!mqrq->bounce_buf) -		return; - -	if (rq_data_dir(mmc_queue_req_to_req(mqrq)) != READ) -		return; -	sg_copy_from_buffer(mqrq->bounce_sg, mqrq->bounce_sg_len, -		mqrq->bounce_buf, mqrq->sg[0].length); +	return blk_rq_map_sg(mq->queue, req, mqrq->sg);  } diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 04fc89360a7a..6bfba32ffa66 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  #ifndef MMC_QUEUE_H  #define MMC_QUEUE_H @@ -49,9 +50,6 @@ enum mmc_drv_op {  struct mmc_queue_req {  	struct mmc_blk_request	brq;  	struct scatterlist	*sg; -	char			*bounce_buf; -	struct scatterlist	*bounce_sg; -	unsigned int		bounce_sg_len;  	struct mmc_async_req	areq;  	enum mmc_drv_op		drv_op;  	int			drv_op_result; @@ -81,11 +79,8 @@ extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,  extern void mmc_cleanup_queue(struct mmc_queue *);  extern void mmc_queue_suspend(struct mmc_queue *);  extern void mmc_queue_resume(struct mmc_queue *); -  extern unsigned int mmc_queue_map_sg(struct mmc_queue *,  				     struct mmc_queue_req *); -extern void mmc_queue_bounce_pre(struct mmc_queue_req *); -extern void mmc_queue_bounce_post(struct mmc_queue_req *);  extern int mmc_access_rpmb(struct mmc_queue *); diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index fb725934fa21..f664e9cbc9f8 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  /*   *  This file contains work-arounds for many known SD/MMC   *  and SDIO hardware bugs. diff --git a/drivers/mmc/core/sd.h b/drivers/mmc/core/sd.h index 1ada9808c329..497c026a5c5a 100644 --- a/drivers/mmc/core/sd.h +++ b/drivers/mmc/core/sd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */  #ifndef _MMC_CORE_SD_H  #define _MMC_CORE_SD_H |