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
{
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));
}
#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
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))
{
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;
}
}
}
#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", \
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; timeout<FIFO_DEPTH; timeout++)
{
if ((mmc_resp_type(cmd) == MMC_RSP_R1B) || (MMC_STOP_TRANSMISSION == cmd->opcode))
{
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);
}
}
}
//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",\
#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
/*-------------------------------------------------------------------------*/
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;
#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 */
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);