[PATCH] mmc:sdhci: restore the enabled dma when do reset all
If dma is enabled, it'll be cleared when reset all is performed, this can be observed on some platforms, such as P2041 which has a version 2.3 controller, but platform like P4080 which has a version 2.2 controller, does not suffer this, so we will check if the dma is enabled, we should restore it after reset all. Signed-off-by: Shaohui Xie shaohui@freescale.com --- based on http://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git, branch 'for-linus'. drivers/mmc/host/sdhci.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 19ed580..22033c3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -29,6 +29,7 @@ #include linux/mmc/host.h #include sdhci.h +#include sdhci-esdhc.h #define DRIVER_NAME sdhci @@ -176,6 +177,7 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) { unsigned long timeout; u32 uninitialized_var(ier); + u32 uninitialized_var(dma); if (host-quirks SDHCI_QUIRK_NO_CARD_NO_RESET) { if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) @@ -189,6 +191,8 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) if (host-ops-platform_reset_enter) host-ops-platform_reset_enter(host, mask); + dma = sdhci_readl(host, ESDHC_DMA_SYSCTL); + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); if (mask SDHCI_RESET_ALL) @@ -214,6 +218,9 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) if (host-quirks SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET) sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier); + + if ((dma ESDHC_DMA_SNOOP) (mask SDHCI_RESET_ALL)) + sdhci_writel(host, dma, ESDHC_DMA_SYSCTL); } static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); -- 1.6.4 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0cad48a..e680929 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } + /* Disallow the IOCTL run if card is already mounted or device is +* opened elsewhere */ + if (md-usage 3) { + err = -EINVAL; + goto cmd_done; + } card = md-queue.card; if (IS_ERR(card)) { -- 1.7.6.4 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
On Wed, Dec 28, 2011 at 5:46 AM, Shashidhar hiremath shashidh...@vayavyalabs.com wrote: From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c | 6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0cad48a..e680929 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } + /* Disallow the IOCTL run if card is already mounted or device is + * opened elsewhere */ Fix multi line comment Can refer : Documentation/kernel-doc-nano-HOWTO.txt + if (md-usage 3) { + err = -EINVAL; + goto cmd_done; + } card = md-queue.card; if (IS_ERR(card)) { -- 1.7.6.4 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] mmc: Check to disable IOCTL when card is mounted
From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e680929..e513d20 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,8 +387,10 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } - /* Disallow the IOCTL run if card is already mounted or device is -* opened elsewhere */ + /* +* Disallow the IOCTL run if card is already mounted or device is +* opened elsewhere +*/ if (md-usage 3) { err = -EINVAL; goto cmd_done; -- 1.7.6.4 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] mmc:sdhci: restore the enabled dma when do reset all
On 28/12/11 11:41, Shaohui Xie wrote: If dma is enabled, it'll be cleared when reset all is performed, this can be observed on some platforms, such as P2041 which has a version 2.3 controller, but platform like P4080 which has a version 2.2 controller, does not suffer this, so we will check if the dma is enabled, we should restore it after reset all. Signed-off-by: Shaohui Xie shaohui@freescale.com --- based on http://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git, branch 'for-linus'. drivers/mmc/host/sdhci.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 19ed580..22033c3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -29,6 +29,7 @@ #include linux/mmc/host.h #include sdhci.h +#include sdhci-esdhc.h #define DRIVER_NAME sdhci @@ -176,6 +177,7 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) { unsigned long timeout; u32 uninitialized_var(ier); + u32 uninitialized_var(dma); if (host-quirks SDHCI_QUIRK_NO_CARD_NO_RESET) { if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) @@ -189,6 +191,8 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) if (host-ops-platform_reset_enter) host-ops-platform_reset_enter(host, mask); + dma = sdhci_readl(host, ESDHC_DMA_SYSCTL); You must not access eSDHC-specific registers in generic SDHCI code + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); if (mask SDHCI_RESET_ALL) @@ -214,6 +218,9 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) if (host-quirks SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET) sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier); + + if ((dma ESDHC_DMA_SNOOP) (mask SDHCI_RESET_ALL)) + sdhci_writel(host, dma, ESDHC_DMA_SYSCTL); } static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
On 28/12/11 12:46, Shashidhar hiremath wrote: From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. What if someone wants to do that. Generally the kernel does not prevent access to raw block devices just because a file system is mounted on them, so I guess MMC should not either. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0cad48a..e680929 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } + /* Disallow the IOCTL run if card is already mounted or device is + * opened elsewhere */ + if (md-usage 3) { + err = -EINVAL; + goto cmd_done; + } Checking the usage will not work consistently e.g. if there is a sysfs access or another ioctl access at the same time, or just some other kernel user of the device. card = md-queue.card; if (IS_ERR(card)) { -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
On 28/12/11 05:11, Aaron Lu wrote: If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc. Previously, sdhci_suspend_host will return the error code and rely on the calling function to handle it. sdhci-pci will handle it in sdhci_pci_suspend while sdhci-platform code will not. Signed-off-by: Philip Rakity prak...@marvell.com Signed-off-by: Aaron Lu aaron...@amd.com --- drivers/mmc/host/sdhci-pci.c |9 ++--- drivers/mmc/host/sdhci.c | 27 +-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index d2e77fb..494d14b 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c @@ -1013,7 +1013,7 @@ static int sdhci_pci_suspend(struct device *dev) ret = sdhci_suspend_host(slot-host); if (ret) - goto err_pci_suspend; + return ret; slot_pm_flags = slot-host-mmc-pm_flags; if (slot_pm_flags MMC_PM_WAKE_SDIO_IRQ) @@ -1025,7 +1025,7 @@ static int sdhci_pci_suspend(struct device *dev) if (chip-fixes chip-fixes-suspend) { ret = chip-fixes-suspend(chip); if (ret) - goto err_pci_suspend; + return ret; } pci_save_state(pdev); @@ -1042,11 +1042,6 @@ static int sdhci_pci_suspend(struct device *dev) } return 0; - -err_pci_suspend: - while (--i = 0) - sdhci_resume_host(chip-slots[i]-host); - return ret; This doesn't look right. This is about having multiple host controllers on the same PCI device. If those hosts have been successfully suspended, then they must be resumed on error. } static int sdhci_pci_resume(struct device *dev) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2007d37..37aeb81 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2339,25 +2339,40 @@ out: int sdhci_suspend_host(struct sdhci_host *host) { - int ret; + int ret, has_tuning_timer; sdhci_disable_card_detection(host); /* Disable tuning since we are suspending */ - if (host-version = SDHCI_SPEC_300 host-tuning_count - host-tuning_mode == SDHCI_TUNING_MODE_1) { + has_tuning_timer = host-version = SDHCI_SPEC_300 + host-tuning_count host-tuning_mode == SDHCI_TUNING_MODE_1; + if (has_tuning_timer) { del_timer_sync(host-tuning_timer); host-flags = ~SDHCI_NEEDS_RETUNING; } ret = mmc_suspend_host(host-mmc); if (ret) - return ret; + goto err_suspend; + + if (host-vmmc) { + ret = regulator_disable(host-vmmc); + if (ret) + goto err_suspend; + } free_irq(host-irq, host); - if (host-vmmc) - ret = regulator_disable(host-vmmc); + return 0; + +err_suspend: + if (has_tuning_timer) { + host-flags |= SDHCI_NEEDS_RETUNING; + mod_timer(host-tuning_timer, jiffies + + host-tuning_count * HZ); + } + + sdhci_enable_card_detection(host); return ret; } -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
On Wed, Dec 28, 2011 at 5:39 PM, Adrian Hunter adrian.hun...@intel.com wrote: On 28/12/11 12:46, Shashidhar hiremath wrote: From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. What if someone wants to do that. The issue with not having this is that if there is huge size data transfer operation happening, the IOCTL issuing will corrupt the data transfer operation. So it would be better to finish the device's access by one thing and give control to ioctl after that. Generally the kernel does not prevent access to raw block devices just because a file system is mounted on them, so I guess MMC should not either. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c | 6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0cad48a..e680929 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } + /* Disallow the IOCTL run if card is already mounted or device is + * opened elsewhere */ + if (md-usage 3) { + err = -EINVAL; + goto cmd_done; + } Checking the usage will not work consistently e.g. if there is a sysfs access or another ioctl access at the same time, or just some other kernel user of the device. card = md-queue.card; if (IS_ERR(card)) { -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- regards, Shashidhar Hiremath -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] mmc: Check to disable IOCTL when card is mounted
On 28/12/11 14:46, Shashidhar Hiremath wrote: On Wed, Dec 28, 2011 at 5:39 PM, Adrian Hunter adrian.hun...@intel.com wrote: On 28/12/11 12:46, Shashidhar hiremath wrote: From: Shashidhar Hiremath shashidh...@vayavyalabs.com The Patch adds a check to disable the IOCTL from running when the card is mounted or device is opened elsewhere. What if someone wants to do that. The issue with not having this is that if there is huge size data transfer operation happening, the IOCTL issuing will corrupt the data transfer operation. So it would be better to finish the device's access by one thing and give control to ioctl after that. It does claim the host so the ioctl will wait while I/O requests are being processed. Generally the kernel does not prevent access to raw block devices just because a file system is mounted on them, so I guess MMC should not either. Signed-off-by: Shashidhar Hiremath shashidh...@vayavyalabs.com --- drivers/mmc/card/block.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0cad48a..e680929 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -387,6 +387,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, err = -EINVAL; goto cmd_done; } + /* Disallow the IOCTL run if card is already mounted or device is + * opened elsewhere */ + if (md-usage 3) { + err = -EINVAL; + goto cmd_done; + } Checking the usage will not work consistently e.g. if there is a sysfs access or another ioctl access at the same time, or just some other kernel user of the device. card = md-queue.card; if (IS_ERR(card)) { -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH V2] mmc: card: IOCTL support for Sanitize feature of eMMC v4.5
Hi Kyungmin, Probably I will split this patch into 2 dependent uploads. Thanks, Yaniv = -Original Message- = From: linux-mmc-ow...@vger.kernel.org [mailto:linux-mmc- = ow...@vger.kernel.org] On Behalf Of Kyungmin Park = Sent: Tuesday, December 27, 2011 3:54 PM = To: Yaniv Gardi = Cc: linux-mmc@vger.kernel.org; linux-arm-...@vger.kernel.org; open = list = Subject: Re: [PATCH V2] mmc: card: IOCTL support for Sanitize feature = of eMMC v4.5 = = Hi Yaniv, = = You maybe split the patch into block and mmc parts. = Please see the comments inlined. = = Thank you, = Kyungmin Park = = On Tue, Dec 27, 2011 at 10:33 PM, Yaniv Gardi yga...@codeaurora.org = wrote: = Signed-off-by: Yaniv Gardi yga...@codeaurora.org = = --- = block/blk-core.c | 15 ++-- = block/blk-lib.c | 44 = +++ = block/blk-merge.c | 6 + = block/elevator.c | 8 ++- = block/ioctl.c | 9 = drivers/mmc/card/block.c | 50 = = drivers/mmc/card/queue.c | 7 +- = include/linux/blk_types.h | 7 - = include/linux/blkdev.h | 3 ++ = include/linux/fs.h | 1 + = include/linux/mmc/card.h | 7 ++ = kernel/trace/blktrace.c | 2 + = 12 files changed, 143 insertions(+), 16 deletions(-) = = diff --git a/block/blk-core.c b/block/blk-core.c = index e6c05a9..e3512a4 100644 = --- a/block/blk-core.c = +++ b/block/blk-core.c = @@ -1544,7 +1544,7 @@ generic_make_request_checks(struct bio *bio) = goto end_io; = } = = - if (unlikely(!(bio-bi_rw REQ_DISCARD) = + if (unlikely(!(bio-bi_rw (REQ_DISCARD | REQ_SANITIZE)) = = nr_sectors queue_max_hw_sectors(q))) { = printk(KERN_ERR bio too big device %s (%u %u)\n, = bdevname(bio-bi_bdev, b), = @@ -1592,6 +1592,14 @@ generic_make_request_checks(struct bio *bio) = goto end_io; = } = = + if ((bio-bi_rw REQ_SANITIZE) = + (!blk_queue_sanitize(q))) { = + pr_err(%s - SANITIZE request but queue = + doesn't support sanitize, __func__); = + err = -EOPNOTSUPP; = + goto end_io; = + } = + = if (blk_throtl_bio(q, bio)) = return false; /* throttled, will be resubmitted = later */ = = @@ -1697,7 +1705,8 @@ void submit_bio(int rw, struct bio *bio) = * If it's a regular read/write or a barrier with data = attached, = * go through the normal accounting stuff before submission. = */ = - if (bio_has_data(bio) !(rw REQ_DISCARD)) { = + if (bio_has_data(bio) = + (!(rw (REQ_DISCARD | REQ_SANITIZE { = if (rw WRITE) { = count_vm_events(PGPGOUT, count); = } else { = @@ -1743,7 +1752,7 @@ EXPORT_SYMBOL(submit_bio); = */ = int blk_rq_check_limits(struct request_queue *q, struct request = *rq) = { = - if (rq-cmd_flags REQ_DISCARD) = + if ((rq-cmd_flags REQ_DISCARD) || (rq-cmd_flags = REQ_SANITIZE)) = (rq-cmd_flags (REQ_DISCARD | REA_SANITIZE))? = return 0; = = if (blk_rq_sectors(rq) queue_max_sectors(q) || = diff --git a/block/blk-lib.c b/block/blk-lib.c = index 2b461b4..76ed930 100644 = --- a/block/blk-lib.c = +++ b/block/blk-lib.c = @@ -114,6 +114,50 @@ int blkdev_issue_discard(struct block_device = *bdev, sector_t sector, = } = EXPORT_SYMBOL(blkdev_issue_discard); = = +int blkdev_issue_sanitize(struct block_device *bdev, gfp_t = gfp_mask) = +{ = + DECLARE_COMPLETION_ONSTACK(wait); = + struct request_queue *q = bdev_get_queue(bdev); = + int type = REQ_WRITE | REQ_SANITIZE; = + = + struct bio_batch bb; = + struct bio *bio; = + int ret = 0; = + = + if (!q) = + return -ENXIO; = + = + bio = bio_alloc(gfp_mask, 1); = + if (!bio) = + return -ENOMEM; = + = + if (!blk_queue_sanitize(q)) { = + pr_err(%s - card doesn't support sanitize, = __func__); = You should add the bio_free-like at here? = + return -EOPNOTSUPP; = + } = + = + atomic_set(bb.done, 1); = + bb.flags = 1 BIO_UPTODATE; = + bb.wait = wait; = + = + bio-bi_end_io = bio_batch_end_io; = + bio-bi_bdev = bdev; = + bio-bi_private = bb; = + = + atomic_inc(bb.done); = + submit_bio(type, bio); = + = + /* Wait for bios in-flight */ = + if (!atomic_dec_and_test(bb.done)) = + wait_for_completion(wait); = + = + if (!test_bit(BIO_UPTODATE, bb.flags)) = + ret =
Re: [PATCH 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
On Wed, Dec 28, 2011 at 02:23:32PM +0200, Adrian Hunter wrote: - -err_pci_suspend: - while (--i = 0) - sdhci_resume_host(chip-slots[i]-host); - return ret; This doesn't look right. This is about having multiple host controllers on the same PCI device. If those hosts have been successfully suspended, then they must be resumed on error. You are right, I failed to understand the code. Will send the patch again without touching the pci recover code, thanks. } -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
V2: Error processing code in sdhci_pci_suspend should not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian. If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with an error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc. Signed-off-by: Philip Rakity prak...@marvell.com Signed-off-by: Aaron Lu aaron...@amd.com Cc: Adrian Hunter adrian.hun...@intel.com --- drivers/mmc/host/sdhci.c | 27 +-- 1 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2007d37..37aeb81 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2339,25 +2339,40 @@ out: int sdhci_suspend_host(struct sdhci_host *host) { - int ret; + int ret, has_tuning_timer; sdhci_disable_card_detection(host); /* Disable tuning since we are suspending */ - if (host-version = SDHCI_SPEC_300 host-tuning_count - host-tuning_mode == SDHCI_TUNING_MODE_1) { + has_tuning_timer = host-version = SDHCI_SPEC_300 + host-tuning_count host-tuning_mode == SDHCI_TUNING_MODE_1; + if (has_tuning_timer) { del_timer_sync(host-tuning_timer); host-flags = ~SDHCI_NEEDS_RETUNING; } ret = mmc_suspend_host(host-mmc); if (ret) - return ret; + goto err_suspend; + + if (host-vmmc) { + ret = regulator_disable(host-vmmc); + if (ret) + goto err_suspend; + } free_irq(host-irq, host); - if (host-vmmc) - ret = regulator_disable(host-vmmc); + return 0; + +err_suspend: + if (has_tuning_timer) { + host-flags |= SDHCI_NEEDS_RETUNING; + mod_timer(host-tuning_timer, jiffies + + host-tuning_count * HZ); + } + + sdhci_enable_card_detection(host); return ret; } -- 1.7.7.4 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html