Re: [PATCH 3/3 v2] mmc: Use mmc_delay() instead of mdelay() for time delay
On Thu, 01 Sep 2011 12:42:08 +0800, Kumar Gala kumar.g...@freescale.com wrote: On Aug 26, 2011, at 2:55 AM, Chunhe Lan wrote: The mmc_delay() is a wrapper function for mdelay() and msleep(). o mdelay() -- block the system when busy-waiting. o msleep() -- suspend the currently running task to enable CPU to process other tasks, so it is non-blocking regarding the whole system. When the desired delay time is more than a period of timer interrupt, just use msleep(). Change mdelay() to mmc_delay() to avoid chewing CPU when busy wait. Signed-off-by: Shengzhou Liu b36...@freescale.com Signed-off-by: Chunhe Lan chunhe@freescale.com Cc: Chris Ball c...@laptop.org --- drivers/mmc/host/sdhci.c | 10 +- 1 files changed, 5 insertions(+), 5 deletions(-) It might be good to either merge patch 2/3 3/3 or rename them since they have same commit message. Chris, Any comments on closing on these patches? Hello Chris, Do you any comments on these patches ? If not, can you apply these patches to mmc-next ? Thanks. -Jack - k -- 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: core: Add poweroff notify handling feature
Hi Girish K S, I think short type is proper rather than long type by default. Long type seems to be unacceptable in suspend regarding long timeout. One question, Is this patch considered for system power off besides suspend? Beset regards, Seungwon Jeon. Girish K S wrote: Hi Mr Park, On 5 September 2011 18:03, Kyungmin Park kmp...@infradead.org wrote: Hi Girish, I think it's still incomplete, does power off short function is called at suspend properly? there are some comments below. Thank you, Kyungmin Park On Mon, Sep 5, 2011 at 8:49 PM, Girish K S girish.shivananja...@linaro.org wrote: This patch adds the handling of the poweroff notify feature during powerdown phase. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 29 + drivers/mmc/core/mmc.c |3 +++ drivers/mmc/host/sdhci.c | 11 +++ include/linux/mmc/card.h | 29 + include/linux/mmc/host.h |7 +-- 5 files changed, 73 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..37b09d7 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) mmc_card_powernotify_on(card)) { + + if (host-power_notify_type == MMC_POWEROFF_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + + mmc_card_set_powernotify_off(card); + } /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..b369c6f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -720,8 +720,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); + if (err err != -EBADMSG) goto free_card; + + mmc_card_set_powernotify_on(card); } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..a24a31b 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,17 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + if (mmc-caps == MMC_CAP_POWER_OFF_NOTIFY) { It should be if (mmc-caps MMC_CAP_POWER_OFF_NOTIFY) { + /* +* If Notify capability is enabled and +* platform data is not initialised, set default to +* long power off notify timeout value +*/ + if (mmc-power_notify_type == MMC_POWEROFF_NOTIFY_NONE) + mmc-power_notify_type = MMC_POWEROFF_NOTIFY_LONG; + } else { + mmc-power_notify_type = MMC_POWEROFF_NOTIFY_NONE; + } What's the goal of these statements? the goal of the statement is to set the notification type to a default value. if host doesnt have the capability then notification type is none. If the host supports the capability and the notification type (whether the short or long is not set), then default is long type. /* Initial value for re-tuning timer count */ host-tuning_count = (caps[1] SDHCI_RETUNING_TIMER_COUNT_MASK) SDHCI_RETUNING_TIMER_COUNT_SHIFT; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
Re: [PATCH 2/2] mmc: core: Add poweroff notify handling feature
Hello Mr Jeon, i have modified the patch to handle the poweroff in suspend and normal condition. during suspend it is be short and during normal poweroff it is long. I will update the V2 patch with Mr Parks changes updated. regards Girish K S On 6 September 2011 12:31, Seungwon Jeon tgih@samsung.com wrote: Hi Girish K S, I think short type is proper rather than long type by default. Long type seems to be unacceptable in suspend regarding long timeout. One question, Is this patch considered for system power off besides suspend? Beset regards, Seungwon Jeon. Girish K S wrote: Hi Mr Park, On 5 September 2011 18:03, Kyungmin Park kmp...@infradead.org wrote: Hi Girish, I think it's still incomplete, does power off short function is called at suspend properly? there are some comments below. Thank you, Kyungmin Park On Mon, Sep 5, 2011 at 8:49 PM, Girish K S girish.shivananja...@linaro.org wrote: This patch adds the handling of the poweroff notify feature during powerdown phase. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 29 + drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/host/sdhci.c | 11 +++ include/linux/mmc/card.h | 29 + include/linux/mmc/host.h | 7 +-- 5 files changed, 73 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..37b09d7 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) mmc_card_powernotify_on(card)) { + + if (host-power_notify_type == MMC_POWEROFF_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + + mmc_card_set_powernotify_off(card); + } /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..b369c6f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -720,8 +720,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); + if (err err != -EBADMSG) goto free_card; + + mmc_card_set_powernotify_on(card); } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..a24a31b 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,17 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + if (mmc-caps == MMC_CAP_POWER_OFF_NOTIFY) { It should be if (mmc-caps MMC_CAP_POWER_OFF_NOTIFY) { + /* + * If Notify capability is enabled and + * platform data is not initialised, set default to + * long power off notify timeout value + */ + if (mmc-power_notify_type == MMC_POWEROFF_NOTIFY_NONE) + mmc-power_notify_type = MMC_POWEROFF_NOTIFY_LONG; + } else { + mmc-power_notify_type = MMC_POWEROFF_NOTIFY_NONE; + } What's the goal of these statements? the goal of the statement is to set the notification type to a default value. if host doesnt have the capability then notification type is none. If the host supports the capability and the notification type (whether
[PATCH v2 0/2] PowerOff Notify/handle feature eMMC 4.5
This set of patch implements the PowerOff notification feature for eMMC 4.5 devices. Girish K S (2): mmc: core: Add power off notify feature(eMMC 4.5) mmc: core: Add Poweroff Notify handling drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c | 21 +++-- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 20 include/linux/mmc/host.h |5 + include/linux/mmc/mmc.h |7 +++ 6 files changed, 94 insertions(+), 2 deletions(-) -- 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 1/2] mmc: core: Add power off notify feature(eMMC 4.5)
This patch adds the support for power off notify feature available in eMMC 4.5 devices. If the the host has support for this feature, then the mmc core will notify it to the device by setting the POWER_OFF_NOTIFICATION byte in the extended csd register with a value 1(POWER_ON). This patch should be applied after Seungwon Jeon's patch for cmd6 timeout. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/mmc.c | 19 +-- include/linux/mmc/card.h |1 + include/linux/mmc/host.h |1 + include/linux/mmc/mmc.h |7 +++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 68eb368..2f06b37 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -410,10 +410,12 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) else card-erased_byte = 0x0; - if (card-ext_csd.rev = 6) + if (card-ext_csd.rev = 6) { card-ext_csd.generic_cmd6_time = 10 * ext_csd[EXT_CSD_GENERIC_CMD6_TIME]; - + card-ext_csd.power_off_longtime = 10 * + ext_csd[EXT_CSD_POWER_OFF_LONG_TIME]; + } out: return err; } @@ -710,6 +712,19 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } /* +* If the host supports the power_off_notify capability then +* set the notification byte in the ext_csd register of device +*/ + if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + EXT_CSD_POWER_ON, + card-ext_csd.generic_cmd6_time); + if (err err != -EBADMSG) + goto free_card; + } + + /* * Activate high speed (if supported) */ if ((card-ext_csd.hs_max_dtr != 0) diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index e992fe3..2bf2843 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -53,6 +53,7 @@ struct mmc_ext_csd { unsigned intpart_time; /* Units: ms */ unsigned intsa_timeout; /* Units: 100ns */ unsigned intgeneric_cmd6_time; /* Units: ms */ + unsigned intpower_off_longtime; /* Units: ms */ unsigned inths_max_dtr; unsigned intsectors; unsigned intcard_type; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 1d09562..cf2dadc 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -229,6 +229,7 @@ struct mmc_host { #define MMC_CAP_MAX_CURRENT_600(1 28) /* Host max current limit is 600mA */ #define MMC_CAP_MAX_CURRENT_800(1 29) /* Host max current limit is 800mA */ #define MMC_CAP_CMD23 (1 30) /* CMD23 supported. */ +#define MMC_CAP_POWER_OFF_NOTIFY(1 31)/*Notify poweroff supported */ mmc_pm_flag_t pm_caps;/* supported pm features */ diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index e869f00..a788e01 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -270,6 +270,7 @@ struct _mmc_csd { * EXT_CSD fields */ +#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ #define EXT_CSD_PARTITION_ATTRIBUTE156 /* R/W */ #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ #define EXT_CSD_WR_REL_PARAM 166 /* RO */ @@ -293,6 +294,7 @@ struct _mmc_csd { #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT231 /* RO */ #define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_POWER_OFF_LONG_TIME247 /*RO*/ #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ /* @@ -329,6 +331,11 @@ struct _mmc_csd { #define EXT_CSD_SEC_BD_BLK_EN BIT(2) #define EXT_CSD_SEC_GB_CL_EN BIT(4) +#define EXT_CSD_NO_POWER_NOTIFICATION 0 +#define EXT_CSD_POWER_ON 1 +#define EXT_CSD_POWER_OFF_SHORT2 +#define EXT_CSD_POWER_OFF_LONG 3 + /* * MMC_SWITCH access modes */ -- 1.7.1 -- 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: core: Add Poweroff Notify handling
This patch adds the power off notification handling during suspend and system poweroff. For suspend mode short timeout is used, whereas for the normal poweroff long timeout is used. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c |4 +++- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 19 +++ include/linux/mmc/host.h |4 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..16da927 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) + (mmc_card_powernotify_on(card))) { + + if (host-power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + } + /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. @@ -1147,6 +1176,8 @@ static void mmc_power_off(struct mmc_host *host) host-ios.bus_width = MMC_BUS_WIDTH_1; host-ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + /*Set the card state to no notification after the poweroff*/ + mmc_card_set_powernotify_off(card); } /* @@ -2026,6 +2057,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 1; + host-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; spin_unlock_irqrestore(host-lock, flags); cancel_delayed_work_sync(host-detect); @@ -2048,6 +2080,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 0; + host-power_notify_type = MMC_HOST_PW_NOTIFY_LONG; spin_unlock_irqrestore(host-lock, flags); mmc_detect_change(host, 0); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..8868da8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -715,13 +715,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If the host supports the power_off_notify capability then * set the notification byte in the ext_csd register of device */ - if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + if ((host-caps MMC_CAP_POWER_OFF_NOTIFY) + (mmc_card_powernotify_off(card))) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); if (err err != -EBADMSG) goto free_card; + mmc_card_set_powernotify_on(card); } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..2ca427a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,16 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + /* +* If Notify capability is enabled and +* notify type is not initialised by host, set default to +* long power off notify timeout value +*/ + if (mmc-caps == MMC_CAP_POWER_OFF_NOTIFY) + mmc-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; + else + mmc-power_notify_type = MMC_HOST_PW_NOTIFY_NONE; + /* Initial value for re-tuning timer count */ host-tuning_count = (caps[1]
RE: [PATCH v2 2/2] mmc: core: Add Poweroff Notify handling
Hi Girish, In case of system poweroff, mmc_power_off can be called indeed? And I added some comments. Best regards, Seungwon Jeon. Girish K S wrote: This patch adds the power off notification handling during suspend and system poweroff. For suspend mode short timeout is used, whereas for the normal poweroff long timeout is used. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c |4 +++- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 19 +++ include/linux/mmc/host.h |4 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..16da927 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) + (mmc_card_powernotify_on(card))) { + + if (host-power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + } + It'd be fine if one function take it above all. /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. @@ -1147,6 +1176,8 @@ static void mmc_power_off(struct mmc_host *host) host-ios.bus_width = MMC_BUS_WIDTH_1; host-ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + /*Set the card state to no notification after the poweroff*/ + mmc_card_set_powernotify_off(card); } /* @@ -2026,6 +2057,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 1; + host-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; spin_unlock_irqrestore(host-lock, flags); cancel_delayed_work_sync(host-detect); @@ -2048,6 +2080,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 0; + host-power_notify_type = MMC_HOST_PW_NOTIFY_LONG; spin_unlock_irqrestore(host-lock, flags); mmc_detect_change(host, 0); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..8868da8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -715,13 +715,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If the host supports the power_off_notify capability then * set the notification byte in the ext_csd register of device */ - if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + if ((host-caps MMC_CAP_POWER_OFF_NOTIFY) + (mmc_card_powernotify_off(card))) { Previous version seems to be good. err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); if (err err != -EBADMSG) goto free_card; + mmc_card_set_powernotify_on(card); If err is -EBADMSG, switching for 'POWERED_ON' is maybe failed. It is sure to be successful? So, your state flag should be changed to 'off' } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..2ca427a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,16 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + /* + * If Notify capability is enabled and + * notify type is not initialised by host, set default to + *
Re: [PATCH v2 2/2] mmc: core: Add Poweroff Notify handling
Hi Jeon, Thanks for the review. On 6 September 2011 17:22, Seungwon Jeon tgih@samsung.com wrote: Hi Girish, In case of system poweroff, mmc_power_off can be called indeed? And I added some comments. Best regards, Seungwon Jeon. Girish K S wrote: This patch adds the power off notification handling during suspend and system poweroff. For suspend mode short timeout is used, whereas for the normal poweroff long timeout is used. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c | 4 +++- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 19 +++ include/linux/mmc/host.h | 4 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..16da927 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) + (mmc_card_powernotify_on(card))) { + + if (host-power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + } + It'd be fine if one function take it above all. I change the state to off after the host executes the poweroff function. i.e. after complete device power off. /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. @@ -1147,6 +1176,8 @@ static void mmc_power_off(struct mmc_host *host) host-ios.bus_width = MMC_BUS_WIDTH_1; host-ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + /*Set the card state to no notification after the poweroff*/ + mmc_card_set_powernotify_off(card); } /* @@ -2026,6 +2057,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 1; + host-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; spin_unlock_irqrestore(host-lock, flags); cancel_delayed_work_sync(host-detect); @@ -2048,6 +2080,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 0; + host-power_notify_type = MMC_HOST_PW_NOTIFY_LONG; spin_unlock_irqrestore(host-lock, flags); mmc_detect_change(host, 0); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..8868da8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -715,13 +715,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If the host supports the power_off_notify capability then * set the notification byte in the ext_csd register of device */ - if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + if ((host-caps MMC_CAP_POWER_OFF_NOTIFY) + (mmc_card_powernotify_off(card))) { Previous version seems to be good. err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); if (err err != -EBADMSG) goto free_card; + mmc_card_set_powernotify_on(card); If err is -EBADMSG, switching for 'POWERED_ON' is maybe failed. It is sure to be successful? So, your state flag should be changed to 'off' If err is -EBADMSG then the state remains off. it will change only if successful. } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..2ca427a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c
Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On Fri, Sep 2, 2011 at 12:35 AM, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. Signed-off-by: Venkatraman S svenk...@ti.com --- drivers/mmc/host/omap_hsmmc.c | 20 +--- 1 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 21e4a79..5b7776c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -999,7 +999,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) { int dma_ch; - host-data-error = errno; + if (host-data) The condition check above becomes redundant since dma_cleanup is called during errors in omap_hsmmc_do_irq. Better have this check in the dma_cb where dma_cleanup is newly added. + host-data-error = errno; spin_lock(host-irq_lock); dma_ch = host-dma_ch; @@ -1007,12 +1008,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) spin_unlock(host-irq_lock); if (host-use_dma dma_ch != -1) { - dma_unmap_sg(mmc_dev(host-mmc), host-data-sg, - host-data-sg_len, - omap_hsmmc_get_dma_dir(host, host-data)); omap_free_dma(dma_ch); } - host-data = NULL; No need to remove the above one. } /* @@ -1370,7 +1367,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) { struct omap_hsmmc_host *host = cb_data; struct mmc_data *data; - int dma_ch, req_in_progress; + int req_in_progress; if (!(ch_status OMAP_DMA_BLOCK_IRQ)) { dev_warn(mmc_dev(host-mmc), unexpected dma status %x\n, @@ -1394,16 +1391,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) return; } - if (!data-host_cookie) - dma_unmap_sg(mmc_dev(host-mmc), data-sg, data-sg_len, - omap_hsmmc_get_dma_dir(host, data)); - req_in_progress = host-req_in_progress; - dma_ch = host-dma_ch; - host-dma_ch = -1; spin_unlock(host-irq_lock); - - omap_free_dma(dma_ch); + omap_hsmmc_dma_cleanup(host, 0); /* If DMA has finished after TC, complete the request */ if (!req_in_progress) { @@ -1575,7 +1565,7 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, struct omap_hsmmc_host *host = mmc_priv(mmc); struct mmc_data *data = mrq-data; - if (host-use_dma) { Here also , the above conditional check is required. + if (data-host_cookie) { dma_unmap_sg(mmc_dev(host-mmc), data-sg, data-sg_len, omap_hsmmc_get_dma_dir(host, data)); data-host_cookie = 0; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-omap 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 2/2] mmc: core: Add Poweroff Notify handling
On Tue, Sep 6, 2011 at 7:59 PM, Girish K S girish.shivananja...@linaro.org wrote: This patch adds the power off notification handling during suspend and system poweroff. For suspend mode short timeout is used, whereas for the normal poweroff long timeout is used. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c | 4 +++- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 19 +++ include/linux/mmc/host.h | 4 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..16da927 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) + (mmc_card_powernotify_on(card))) { + + if (host-power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + } + Okay this function is called when suspend. /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. @@ -1147,6 +1176,8 @@ static void mmc_power_off(struct mmc_host *host) host-ios.bus_width = MMC_BUS_WIDTH_1; host-ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + /*Set the card state to no notification after the poweroff*/ + mmc_card_set_powernotify_off(card); } /* @@ -2026,6 +2057,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 1; + host-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; spin_unlock_irqrestore(host-lock, flags); cancel_delayed_work_sync(host-detect); @@ -2048,6 +2080,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 0; + host-power_notify_type = MMC_HOST_PW_NOTIFY_LONG; spin_unlock_irqrestore(host-lock, flags); mmc_detect_change(host, 0); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..8868da8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -715,13 +715,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If the host supports the power_off_notify capability then * set the notification byte in the ext_csd register of device */ - if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + if ((host-caps MMC_CAP_POWER_OFF_NOTIFY) + (mmc_card_powernotify_off(card))) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); if (err err != -EBADMSG) goto free_card; + mmc_card_set_powernotify_on(card); } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..2ca427a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,16 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + /* + * If Notify capability is enabled and + * notify type is not initialised by host, set default to + * long power off notify timeout value + */ + if (mmc-caps == MMC_CAP_POWER_OFF_NOTIFY) You should be check the mmc-caps MMC_CAP_*. I think it's almost false.
Re: [PATCH v2 2/2] mmc: core: Add Poweroff Notify handling
On 7 September 2011 07:19, Kyungmin Park kmp...@infradead.org wrote: On Tue, Sep 6, 2011 at 7:59 PM, Girish K S girish.shivananja...@linaro.org wrote: This patch adds the power off notification handling during suspend and system poweroff. For suspend mode short timeout is used, whereas for the normal poweroff long timeout is used. Signed-off-by: Girish K S girish.shivananja...@linaro.org --- drivers/mmc/core/core.c | 33 + drivers/mmc/core/mmc.c | 4 +++- drivers/mmc/host/sdhci.c | 10 ++ include/linux/mmc/card.h | 19 +++ include/linux/mmc/host.h | 4 5 files changed, 69 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a65e1ca..16da927 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1130,9 +1130,38 @@ static void mmc_power_up(struct mmc_host *host) static void mmc_power_off(struct mmc_host *host) { + struct mmc_card *card = host-card; + unsigned int notify_type; + unsigned int timeout; + int err; + host-ios.clock = 0; host-ios.vdd = 0; + if (mmc_card_mmc(card) + (mmc_card_powernotify_on(card))) { + + if (host-power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { + notify_type = EXT_CSD_POWER_OFF_SHORT; + timeout = card-ext_csd.generic_cmd6_time; + mmc_card_set_powernotify_short(card); + } else { + notify_type = EXT_CSD_POWER_OFF_LONG; + timeout = card-ext_csd.power_off_longtime; + mmc_card_set_powernotify_long(card); + } + + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); + + if (err err != -EBADMSG) + printk(KERN_ERR Device failed to respond + within %d poweroff time. + forcefully powering down + the device\n, timeout); + } + Okay this function is called when suspend. /* * Reset ocr mask to be the highest possible voltage supported for * this mmc host. This value will be used at next power up. @@ -1147,6 +1176,8 @@ static void mmc_power_off(struct mmc_host *host) host-ios.bus_width = MMC_BUS_WIDTH_1; host-ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + /*Set the card state to no notification after the poweroff*/ + mmc_card_set_powernotify_off(card); } /* @@ -2026,6 +2057,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 1; + host-power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; spin_unlock_irqrestore(host-lock, flags); cancel_delayed_work_sync(host-detect); @@ -2048,6 +2080,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(host-lock, flags); host-rescan_disable = 0; + host-power_notify_type = MMC_HOST_PW_NOTIFY_LONG; spin_unlock_irqrestore(host-lock, flags); mmc_detect_change(host, 0); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2f06b37..8868da8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -715,13 +715,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If the host supports the power_off_notify capability then * set the notification byte in the ext_csd register of device */ - if (host-caps MMC_CAP_POWER_OFF_NOTIFY) { + if ((host-caps MMC_CAP_POWER_OFF_NOTIFY) + (mmc_card_powernotify_off(card))) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, EXT_CSD_POWER_ON, card-ext_csd.generic_cmd6_time); if (err err != -EBADMSG) goto free_card; + mmc_card_set_powernotify_on(card); } /* diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 0e02cc1..2ca427a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2566,6 +2566,16 @@ int sdhci_add_host(struct sdhci_host *host) if (caps[1] SDHCI_DRIVER_TYPE_D) mmc-caps |= MMC_CAP_DRIVER_TYPE_D; + /* + * If Notify capability is enabled and + * notify type is not initialised by host, set default to + * long power off notify timeout value + */ + if (mmc-caps == MMC_CAP_POWER_OFF_NOTIFY)