mmc: rtsx: add check before sending request
cover mmc: rtsx: add check before sending request
From: Micky Ching <[email protected]>
Add check before sending request can make request return faster.
- finish request if no card exist
This can make request finish faster, especial for some sdio card, when card removed, there still a lot of command pending, if we check card exist and stop request, the card will disappear faster in user space.
- check sg_count before long data xfer
modify sg_count type unsigned -> int, because dma_map_sg() return int, and this value can be negative to indicate some error occurs.
Micky Ching (2):
mmc: rtsx: finish request if no card exist
mmc: rtsx: check sg_count before long data xfer
drivers/mmc/host/rtsx_pci_sdmmc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 mmc: rtsx: finish request if no card exist
From: Micky Ching <[email protected]>
Return error-code directly if no card exist, this can make card remove faster.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +7 -2
@@ -100,6 +100,11 @@ static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)#define sd_print_debug_regs (host)#endif /* DEBUG */ +static inline int sd_get_cd_int (struct realtek_pci_sdmmc *host) +{ +return rtsx_pci_readl (host->pcr,RTSX_BIPR ) &SD_EXIST ; +} +static void sd_cmd_set_sd_cmd (struct rtsx_pcr *pcr,struct mmc_command *cmd) { rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CMD0, 0xFF,
@@ -798,7 +803,7 @@ static void sd_request(struct work_struct *work)unsigned int data_size =0 ;int err; -if (host->eject) { +if (host->eject || !sd_get_cd_int (host)) { cmd->error = -ENOMEDIUM ; goto finish; }
@@ -1116,7 +1121,7 @@ static int sdmmc_get_cd(struct mmc_host *mmc)u32 val;if (host->eject) -return -ENOMEDIUM ; +return cd;mutex_lock (&pcr->pcr_mutex);
Signature · 1 line
1.9.1
PATCH 2/2 mmc: rtsx: check sg_count before long data xfer
In reply to [email protected]From: Micky Ching <[email protected]>
Check sg_count before sending long data xfer. Because dma_map_sg() return int, and sg_count may be negative, so using int instead of unsigned.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +9 -2
@@ -54,9 +54,9 @@ struct realtek_pci_sdmmc {#define SDMMC_POWER_ON 1#define SDMMC_POWER_OFF 0 -unsigned int sg_count; +int sg_count;s32 cookie; -unsigned int cookie_sg_count; +int cookie_sg_count;bool using_cookie; };
@@ -557,6 +557,13 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq) {struct mmc_data *data = mrq->data; +if (host->sg_count <0 ) { + data->error = host->sg_count; +dev_dbg (sdmmc_dev (host),"%s: sg_count = %d is invalid\n" , + __func__, host->sg_count); +return data->error; + } +if (data->flags &MMC_DATA_READ )return sd_read_long_data (host, mrq);
Signature · 1 line
1.9.1
Ulf Hansson
AppliedQuoted 17 lines · On 14 January 2015 at 04:09, <[email protected]> wrote:
From: Micky Ching <[email protected]>
Add check before sending request can make request return faster.
- finish request if no card exist
This can make request finish faster, especial for some sdio card, when card removed, there still a lot of command pending, if we check card exist and stop request, the card will disappear faster in user space.- check
sg_countbefore long data xfer
modifysg_counttype unsigned -> int, becausedma_map_sg()return int, and this value can be negative to indicate some error occurs.Micky Ching (2):
mmc: rtsx: finish request if no card exist
mmc: rtsx: checksg_countbefore long data xfer
Quoted 6 lines
drivers/mmc/host/rtsx_pci_sdmmc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)--
1.9.1
Thanks! Applied for next.
Kind regards
Uffe