Loading drivers/mtd/devices/msm_qpic_nand.c +36 −1 Original line number Diff line number Diff line /* * Copyright (C) 2007 Google, Inc. * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -14,8 +14,10 @@ */ #include "msm_qpic_nand.h" #include <linux/timer.h> #define QPIC_BAM_DEFAULT_IPC_LOGLVL 2 #define SW_REQ_TIMEOUT_SEC 10 static bool enable_euclean; static bool enable_perfstats; Loading Loading @@ -196,6 +198,25 @@ static void msm_nand_update_erase_perf_stats(struct msm_nand_info *info, spin_unlock(&info->perf.lock); } static struct timer_list timer; static void msm_nand_tout_work_fn(struct work_struct *work) { struct msm_nand_info *info = container_of(work, struct msm_nand_info, tout_work); sps_get_bam_debug_info(info->sps.bam_handle, 93, (SPS_BAM_PIPE(0) | SPS_BAM_PIPE(1) | SPS_BAM_PIPE(2)), 0, 2); } static void msm_nand_transfer_timeout(unsigned long data) { struct msm_nand_info *info = (struct msm_nand_info *)data; pr_err("NAND request timeout\n"); schedule_work(&info->tout_work); } /* * Get the DMA memory for requested amount of size. It returns the pointer * to free memory available from the allocated pool. Returns NULL if there Loading Loading @@ -1888,6 +1909,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -1939,6 +1961,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, } err = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (err) goto free_dma; Loading Loading @@ -2065,6 +2088,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); Loading Loading @@ -2432,6 +2456,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -2482,6 +2507,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, } err = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (err) goto free_dma; Loading Loading @@ -2515,6 +2541,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); Loading Loading @@ -2721,6 +2748,7 @@ static int msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -2765,6 +2793,7 @@ static int msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); out: Loading Loading @@ -2892,8 +2921,10 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); ret = msm_nand_get_device(chip->dev); if (ret) { del_timer_sync(&timer); mutex_unlock(&info->lock); goto free_dma; } Loading Loading @@ -2931,6 +2962,7 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) } ret = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (ret) goto free_dma; Loading @@ -2953,6 +2985,7 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) goto free_dma; put_dev: msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 4); Loading Loading @@ -3708,6 +3741,8 @@ static int msm_nand_probe(struct platform_device *pdev) err = -ENXIO; goto free_bam; } INIT_WORK(&info->tout_work, msm_nand_tout_work_fn); setup_timer(&timer, msm_nand_transfer_timeout, (unsigned long)info); for (i = 0; i < nr_parts; i++) { mtd_part[i].offset *= info->mtd.erasesize; mtd_part[i].size *= info->mtd.erasesize; Loading drivers/mtd/devices/msm_qpic_nand.h +2 −1 Original line number Diff line number Diff line /* * Copyright (C) 2007 Google, Inc. * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -341,6 +341,7 @@ struct msm_nand_info { struct msm_nand_clk_data clk_data; struct msm_nand_perf_stats perf; u64 dma_mask; struct work_struct tout_work; }; /* Structure that defines an ONFI parameter page (512B) */ Loading Loading
drivers/mtd/devices/msm_qpic_nand.c +36 −1 Original line number Diff line number Diff line /* * Copyright (C) 2007 Google, Inc. * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -14,8 +14,10 @@ */ #include "msm_qpic_nand.h" #include <linux/timer.h> #define QPIC_BAM_DEFAULT_IPC_LOGLVL 2 #define SW_REQ_TIMEOUT_SEC 10 static bool enable_euclean; static bool enable_perfstats; Loading Loading @@ -196,6 +198,25 @@ static void msm_nand_update_erase_perf_stats(struct msm_nand_info *info, spin_unlock(&info->perf.lock); } static struct timer_list timer; static void msm_nand_tout_work_fn(struct work_struct *work) { struct msm_nand_info *info = container_of(work, struct msm_nand_info, tout_work); sps_get_bam_debug_info(info->sps.bam_handle, 93, (SPS_BAM_PIPE(0) | SPS_BAM_PIPE(1) | SPS_BAM_PIPE(2)), 0, 2); } static void msm_nand_transfer_timeout(unsigned long data) { struct msm_nand_info *info = (struct msm_nand_info *)data; pr_err("NAND request timeout\n"); schedule_work(&info->tout_work); } /* * Get the DMA memory for requested amount of size. It returns the pointer * to free memory available from the allocated pool. Returns NULL if there Loading Loading @@ -1888,6 +1909,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -1939,6 +1961,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, } err = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (err) goto free_dma; Loading Loading @@ -2065,6 +2088,7 @@ static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); Loading Loading @@ -2432,6 +2456,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -2482,6 +2507,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, } err = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (err) goto free_dma; Loading Loading @@ -2515,6 +2541,7 @@ static int msm_nand_write_oob(struct mtd_info *mtd, loff_t to, put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); Loading Loading @@ -2721,6 +2748,7 @@ static int msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); err = msm_nand_get_device(chip->dev); if (err) goto unlock_mutex; Loading Loading @@ -2765,6 +2793,7 @@ static int msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) put_dev: msm_nand_put_device(chip->dev); unlock_mutex: del_timer_sync(&timer); mutex_unlock(&info->lock); msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); out: Loading Loading @@ -2892,8 +2921,10 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) iovec++; } mutex_lock(&info->lock); mod_timer(&timer, jiffies + SW_REQ_TIMEOUT_SEC * HZ); ret = msm_nand_get_device(chip->dev); if (ret) { del_timer_sync(&timer); mutex_unlock(&info->lock); goto free_dma; } Loading Loading @@ -2931,6 +2962,7 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) } ret = msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); if (ret) goto free_dma; Loading @@ -2953,6 +2985,7 @@ static int msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) goto free_dma; put_dev: msm_nand_put_device(chip->dev); del_timer_sync(&timer); mutex_unlock(&info->lock); free_dma: msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 4); Loading Loading @@ -3708,6 +3741,8 @@ static int msm_nand_probe(struct platform_device *pdev) err = -ENXIO; goto free_bam; } INIT_WORK(&info->tout_work, msm_nand_tout_work_fn); setup_timer(&timer, msm_nand_transfer_timeout, (unsigned long)info); for (i = 0; i < nr_parts; i++) { mtd_part[i].offset *= info->mtd.erasesize; mtd_part[i].size *= info->mtd.erasesize; Loading
drivers/mtd/devices/msm_qpic_nand.h +2 −1 Original line number Diff line number Diff line /* * Copyright (C) 2007 Google, Inc. * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -341,6 +341,7 @@ struct msm_nand_info { struct msm_nand_clk_data clk_data; struct msm_nand_perf_stats perf; u64 dma_mask; struct work_struct tout_work; }; /* Structure that defines an ONFI parameter page (512B) */ Loading