From: xbw Date: Mon, 10 Oct 2011 01:24:33 +0000 (+0800) Subject: fix the bug about the interrupt during SDcard copy by USB,continue with the commit... X-Git-Tag: firefly_0821_release~9766^2~32 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=43e7a824f25c2a592c265efee7119b8b018b72e9;p=firefly-linux-kernel-4.4.55.git fix the bug about the interrupt during SDcard copy by USB,continue with the commit 02b08b06e7d7d896e7e5ed005f961f98d963d2fc --- diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 20e0f52d9785..314b4ae171a4 100755 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -221,7 +221,12 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) multi += (datasize%unit)?1:0; multi = (multi>0) ? multi : 1; multi += (mrq->cmd->retries>0)?1:0; - waittime = wait_for_completion_timeout(&complete,HZ*2*multi); + waittime = wait_for_completion_timeout(&complete,HZ*5*multi); //It should be longer than bottom driver's time,due to the sum of two cmd time. + //modifyed by xbw at 2011-10-08 + // + //example: + //rk29_sdmmc_request_end..2336... CMD12 wait busy timeout!!!!! ====xbw=[sd_mmc]==== + //mmc_wait_for_req..236.. !!!!! wait for CMD25 timeout ===xbw[mmc0]=== } else { @@ -232,6 +237,7 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) if(waittime <= 1) { host->doneflag = 0; + mrq->cmd->error = -EIO; printk("%s..%d.. !!!!! wait for CMD%d timeout ===xbw[%s]===\n",\ __FUNCTION__, __LINE__, mrq->cmd->opcode, mmc_hostname(host)); } diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index 46d69156d9a0..216353d21309 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -72,7 +72,7 @@ int debug_level = 4; #define RK29_SDMMC_WAIT_DTO_INTERNVAL 1000 //The time interval from the CMD_DONE_INT to DTO_INT #define RK29_SDMMC_REMOVAL_DELAY 1000 //The time interval from the CD_INT to detect_timer react. -#define RK29_SDMMC_VERSION "Ver.2.10 The last modify date is 2011-09-30,modifyed by XBW." +#define RK29_SDMMC_VERSION "Ver.2.11 The last modify date is 2011-10-08,modifyed by XBW." #define RK29_CTRL_SDMMC_ID 0 //mainly used by SDMMC #define RK29_CTRL_SDIO1_ID 1 //mainly used by sdio-wifi @@ -791,7 +791,7 @@ static int rk29_sdmmc_reset_fifo(struct rk29_sdmmc *host) static int rk29_sdmmc_wait_unbusy(struct rk29_sdmmc *host) { - int time_out = 250000; //max is 250ms + int time_out = 500000;//250000; //max is 250ms; //adapt the value to the sick card. modify at 2011-10-08 while (rk29_sdmmc_read(host->regs, SDMMC_STATUS) & (SDMMC_STAUTS_DATA_BUSY|SDMMC_STAUTS_MC_BUSY)) { @@ -1784,6 +1784,7 @@ static int rk29_sdmmc_start_request(struct mmc_host *mmc ) printk("%s..Error happen in CMD_PRV_DAT_WAIT. STATUS-reg=0x%x ===xbw[%s]===\n", \ __FUNCTION__, rk29_sdmmc_read(host->regs, SDMMC_STATUS),host->dma_name); } + rk29_sdmmc_clear_fifo(host); goto start_request_Err; } } @@ -1958,6 +1959,11 @@ static void rk29_sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq) } #if 1 + if(0 == host->mmc->doneflag) + { + host->state = STATE_IDLE; + } + if(host->state != STATE_IDLE) { printk("%s..%d..state Error! ,old_state=%d, OldCMD=%d ,NewCMD%2d,arg=0x%x ===xbw[%s]===\n", \ @@ -2176,14 +2182,10 @@ static int rk29_sdmmc_clear_fifo(struct rk29_sdmmc *host) rk29_sdmmc_write(host->regs, SDMMC_RINTSTS, 0xFFFFFFFF); } - //stop DMA - if(host->dodma) - { - rk29_sdmmc_stop_dma(host); - rk29_sdmmc_control_host_dma(host, FALSE); - host->dodma = 0; - } - + rk29_sdmmc_stop_dma(host); + rk29_sdmmc_control_host_dma(host, FALSE); + host->dodma = 0; + //Clean the fifo. for(timeout=0; timeoutopcode)) { output = rk29_sdmmc_wait_unbusy(host); - if(SDM_SUCCESS != output) + if((SDM_SUCCESS != output) && (!host->mrq->cmd->error)) { + printk("%s..%d... CMD12 wait busy timeout!!!!! errorStep=0x%x ====xbw=[%s]====\n", \ + __FUNCTION__, __LINE__, host->errorstep, host->dma_name); rk29_sdmmc_clear_fifo(host); cmd->error = -ETIMEDOUT; host->mrq->cmd->error = -ETIMEDOUT; host->errorstep = 0x1C; - printk("%s..%d... CMD12 wait busy timeout!!!!! ====xbw=[%s]====\n", \ - __FUNCTION__, __LINE__, host->dma_name); } } } @@ -2342,7 +2344,7 @@ static void rk29_sdmmc_request_end(struct rk29_sdmmc *host, struct mmc_command * //trace error if(cmd->data && cmd->data->error) { - if( (!cmd->error) && (0==cmd->retries) && (host->error_times++%RK29_ERROR_PRINTK_INTERVAL == 0)) + if( (!cmd->error) && (0==cmd->retries)) { printk("%s..%d......CMD=%d error!!!(arg=0x%x,cmdretry=%d,blksize=%d, blocks=%d), \n \ statusReg=0x%x, ctrlReg=0x%x, nerrorTimes=%d, errorStep=0x%x ====xbw[%s]====\n",\ diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 072ae172d05f..79aad93fcdeb 100755 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -84,8 +84,8 @@ #define BULK_BUFFER_SIZE 16384 * 4//4096 /* flush after every 4 meg of writes to avoid excessive block level caching */ -//#define MAX_UNFLUSHED_BYTES (512 * 1024)// (4 * 1024 * 1024) //original value is 4MB,Modifyed by xbw at 2011-08-18 -#define MAX_UNFLUSHED_PACKETS 16 +#define MAX_UNFLUSHED_BYTES (64 * 1024)// (4 * 1024 * 1024) //original value is 4MB,Modifyed by xbw at 2011-08-18 +#define MAX_UNFLUSHED_PACKETS 4//16 /*-------------------------------------------------------------------------*/ @@ -235,6 +235,7 @@ struct lun { loff_t file_length; loff_t num_sectors; unsigned int unflushed_packet; + unsigned int unflushed_bytes; unsigned int ro : 1; unsigned int prevent_medium_removal : 1; @@ -1081,9 +1082,11 @@ static int do_write(struct fsg_dev *fsg) #ifdef MAX_UNFLUSHED_PACKETS curlun->unflushed_packet ++; - if (curlun->unflushed_packet >= MAX_UNFLUSHED_PACKETS) { + curlun->unflushed_bytes += nwritten; + if( (curlun->unflushed_packet >= MAX_UNFLUSHED_PACKETS) || (curlun->unflushed_bytes >= MAX_UNFLUSHED_BYTES)) { fsync_sub(curlun); curlun->unflushed_packet = 0; + curlun->unflushed_bytes = 0; } #endif /* If an error occurred, report it and its position */ @@ -2764,6 +2767,7 @@ static int open_backing_file(struct fsg_dev *fsg, struct lun *curlun, curlun->filp = filp; curlun->file_length = size; curlun->unflushed_packet = 0; + curlun->unflushed_bytes = 0; curlun->num_sectors = num_sectors; LDBG(curlun, "open backing file: %s size: %lld num_sectors: %lld\n", filename, size, num_sectors);