From patchwork Tue Nov 5 13:27:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 3141601 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 96BCABEEB2 for ; Tue, 5 Nov 2013 13:28:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0569820233 for ; Tue, 5 Nov 2013 13:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E051200DE for ; Tue, 5 Nov 2013 13:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754896Ab3KEN2A (ORCPT ); Tue, 5 Nov 2013 08:28:00 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:56557 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893Ab3KEN17 (ORCPT ); Tue, 5 Nov 2013 08:27:59 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MVS002BXLEHFNH0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Tue, 05 Nov 2013 22:27:58 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.48]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id F8.16.07052.E52F8725; Tue, 05 Nov 2013 22:27:58 +0900 (KST) X-AuditID: cbfee691-b7f866d000001b8c-b2-5278f25e17c5 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 37.C1.09687.E52F8725; Tue, 05 Nov 2013 22:27:58 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MVS00GF1LEMG800@mmp2.samsung.com>; Tue, 05 Nov 2013 22:27:58 +0900 (KST) From: Seungwon Jeon To: 'Chris Ball' , 'Ulf Hansson' Cc: linux-mmc@vger.kernel.org References: <1383653403-10049-1-git-send-email-ulf.hansson@linaro.org> In-reply-to: <1383653403-10049-1-git-send-email-ulf.hansson@linaro.org> Subject: [PATCH 2/3] mmc: correct some exclusive card state to clear Date: Tue, 05 Nov 2013 22:27:58 +0900 Message-id: <003501ceda2a$d7ae2980$870a7c80$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=ks_c_5601-1987 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac7aH/uUm1J6MxFOSyaXb4Fx/nx/rAABnFmg Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsVy+t8zA924TxVBBve/y1hsf72RzeLI/35G i+Nrwx2YPQ5dWcvocefaHjaPz5vkApijuGxSUnMyy1KL9O0SuDJmTrjOVjDfsOLMjzb2BsaV ml2MnBwSAiYSV6ctY4awxSQu3FvPBmILCSxjlHjSwwlTM+nmfsYuRi6g+HRGiYcP+9ghnD+M EjP/HQLrZhPQkvj75g2YLSLgKbF+7RUmEJtZQFbi4v6rjBBT3YCGLgHbwCngLvFq8R1WEFtY wEXi7aQNYL0sAqoSfSs+gcV5BWwltl14zQxhC0r8mHyPBWKmgcT7WX2sELa8xOY1b4FqOIAu VZd49FcXxBQRMJL425cJUSEise/FO7D7JQT2sUt0tc5jgVglIPFt8iEWiFZZiU0HoOEgKXFw xQ2WCYwSs5AsnoVk8Swki2chWbGAkWUVo2hqQXJBcVJ6kalecWJucWleul5yfu4mRk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+c5H+NxVZmv+Hl+k9bNyV7WclGv3t1Y5bT ZflukYCE/xdec/yq2ffW/+HLiwKBr46HLJbSfWZ5+7uzkXztvOdMEtdPJix1eVx9Yw2bDXPT IVfz+/bflViKMxINtZiLihMBzCVmATIDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Card state related to speed mode should be in non-overlapped. Consideration for all cases is required when being cleared. Also, MMC_STATE_PRESENT and MMC_STATE_REMOVED are same. It's exclusive state which cannot be set at the same time. Signed-off-by: Seungwon Jeon --- drivers/mmc/core/core.c | 1 - drivers/mmc/core/mmc.c | 4 ++-- drivers/mmc/core/sd.c | 5 +++-- drivers/mmc/core/sdio.c | 5 ++++- include/linux/mmc/card.h | 37 +++++++++++++++++++++++++++++++------ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 57a2b40..b183d56 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2281,7 +2281,6 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check) } } - host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_DDR); if (mmc_host_is_spi(host)) { host->ios.chip_select = MMC_CS_HIGH; host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f4f8991..1668ea4 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1597,11 +1597,11 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) err = mmc_sleep(host); else if (!mmc_host_is_spi(host)) err = mmc_deselect_cards(host); - host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); if (!err) { mmc_power_off(host); mmc_card_set_suspended(host->card); + mmc_card_set_ds(host->card); } out: mmc_release_host(host); @@ -1727,8 +1727,8 @@ static int mmc_power_restore(struct mmc_host *host) { int ret; - host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); mmc_claim_host(host); + mmc_card_set_ds(host->card); ret = mmc_init_card(host, host->card->ocr, host->card); mmc_release_host(host); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 6f42050..b19a8f4 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1082,10 +1082,11 @@ static int _mmc_sd_suspend(struct mmc_host *host) if (!mmc_host_is_spi(host)) err = mmc_deselect_cards(host); - host->card->state &= ~MMC_STATE_HIGHSPEED; + if (!err) { mmc_power_off(host); mmc_card_set_suspended(host->card); + mmc_card_set_ds(host->card); } out: @@ -1191,8 +1192,8 @@ static int mmc_sd_power_restore(struct mmc_host *host) { int ret; - host->card->state &= ~MMC_STATE_HIGHSPEED; mmc_claim_host(host); + mmc_card_set_ds(host->card); ret = mmc_sd_init_card(host, host->card->ocr, host->card); mmc_release_host(host); diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 4d721c6..7c6c43c 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -968,8 +968,10 @@ static int mmc_sdio_suspend(struct mmc_host *host) mmc_release_host(host); } - if (!err && !mmc_card_keep_power(host)) + if (!err && !mmc_card_keep_power(host)) { mmc_power_off(host); + mmc_card_set_ds(host->card); + } return err; } @@ -1075,6 +1077,7 @@ static int mmc_sdio_power_restore(struct mmc_host *host) if (ret) goto out; + mmc_card_set_ds(host->card); ret = mmc_sdio_init_card(host, host->card->ocr, host->card, mmc_card_keep_power(host)); if (!ret && host->sdio_irqs) diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index c119735..f2c2620 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -260,6 +260,11 @@ struct mmc_card { #define MMC_STATE_HIGHSPEED_200 (1<<8) /* card is in HS200 mode */ #define MMC_STATE_DOING_BKOPS (1<<10) /* card is doing BKOPS */ #define MMC_STATE_SUSPENDED (1<<11) /* card is suspended */ +#define MMC_STATE_SPEED_MASK (MMC_STATE_HIGHSPEED | \ + MMC_STATE_HIGHSPEED_DDR | \ + MMC_STATE_ULTRAHIGHSPEED | \ + MMC_STATE_HIGHSPEED_200) + /* Mask for default speed(DS) */ unsigned int quirks; /* card quirks */ #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ @@ -431,19 +436,39 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) #define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS) #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED) -#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) + #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) -#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) -#define mmc_card_set_hs200(c) ((c)->state |= MMC_STATE_HIGHSPEED_200) #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) -#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR) -#define mmc_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED) #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) -#define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) #define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS) #define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS) #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED) #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED) +#define mmc_card_set_highspeed(c) \ + ((c)->state = \ + ((c)->state & ~MMC_STATE_SPEED_MASK) | \ + MMC_STATE_HIGHSPEED) +#define mmc_card_set_ddr_mode(c) \ + ((c)->state = \ + ((c)->state & ~MMC_STATE_SPEED_MASK) | \ + MMC_STATE_HIGHSPEED_DDR) +#define mmc_card_set_hs200(c) \ + ((c)->state = \ + ((c)->state & ~MMC_STATE_SPEED_MASK) | \ + MMC_STATE_HIGHSPEED_200) +#define mmc_card_set_uhs(c) \ + ((c)->state = \ + ((c)->state & ~MMC_STATE_SPEED_MASK) | \ + MMC_STATE_ULTRAHIGHSPEED) +#define mmc_card_set_present(c) \ + ((c)->state = \ + ((c)->state & ~MMC_CARD_REMOVED) | \ + MMC_STATE_PRESENT) +#define mmc_card_set_removed(c) \ + ((c)->state = \ + ((c)->state & ~MMC_STATE_PRESENT) | \ + MMC_CARD_REMOVED) +#define mmc_card_set_ds(c) ((c)->state &= ~MMC_STATE_SPEED_MASK) /* * Quirk add/remove for MMC products.