From patchwork Thu Jun 8 13:27:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 103394 Delivered-To: patches@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2439515qgd; Thu, 8 Jun 2017 06:27:55 -0700 (PDT) X-Received: by 10.25.18.168 with SMTP id 40mr7364366lfs.26.1496928475077; Thu, 08 Jun 2017 06:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496928475; cv=none; d=google.com; s=arc-20160816; b=ST76kdwpAkIJVweIECfDCPt6WGmfnR9sXfy4wX+CSoBMMCTWH7vgBzhf80p276PU6Z 6x9yQfo/dIZO5w0nkVuklvWKvX2RcnxGys/no8tXfdKvIBjxGGjAtGUJuerpVWpqU6Gj JnQ2PQkLGaiMIFPCMPVSpP8Q3Z7L0mdIkn3WV572aasl8NIRNcuBc3GQkdoiB9jVREvi AIYfw3OiPnxIOCrpj2RP0P/rAT0uQW8gPoqoO/MLWD6DzzwWydqFwvvauNewIrLp1AdO 8EQjM7TCi4nl2KWj+dIHjyNQOzVOsKgtvIl8LOwfOaRy00zc1zIfZomqI8x9zoksXhsh Xyog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=pi0uGWY1EG1C1S4KEdyNrf/1J9zy8gEPM0ZzihNJFX8=; b=d0PCgXnsvM+d4tvcnxcqpKtRAKeQ7yr0tW+r9DF3Vcapw50iEh/kLdpuMNMCt2RBKx Ppmx/bqGOwX+GSJ/6GTXCF8P2E2znR/zUeKd7EGEd7XtKT3gAt7agRK1115IqNAy+e8I DVWGcsHl3I2FsLphI4wU1eSLfxHXzXT+VPtgD8Vn2kYQ7ja8jmuCHtKVwATG0hBLQ7lT q5gJNmz3bLs84ud370i9AYhkmvjnlRzpH/U3Eh1EGcLlvvKpwmw/M/0pWaT3gNAJFcoP G4hrq88fb+1Qkhr7KZ7ExFwydBX6mTMloV4j246/vLxyF5zjzIrQqPKhYO9UugVnhRO/ e2Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22e.google.com (mail-lf0-x22e.google.com. [2a00:1450:4010:c07::22e]) by mx.google.com with ESMTPS id b73si2570683lfb.87.2017.06.08.06.27.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 06:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) client-ip=2a00:1450:4010:c07::22e; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22e as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22e.google.com with SMTP id a136so18052199lfa.0 for ; Thu, 08 Jun 2017 06:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pi0uGWY1EG1C1S4KEdyNrf/1J9zy8gEPM0ZzihNJFX8=; b=E5VP7XVEAxTTN8uDStnEuJ3RXseH2BBVC5QA6ESbtwumQsELLJ+k9MM1IvX2luTpsY uztcppZdBWDGs9y7c+DQdpc3EHpbyZKwPt7Mogz2cjNk+eOwS7lh6rmqlPNqpvCQr2Do Q934dY90DEiZMqetc3osgDm9mC2OMWmMpm7b4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pi0uGWY1EG1C1S4KEdyNrf/1J9zy8gEPM0ZzihNJFX8=; b=o9ZjrVJgvhvKdmJfAFeHTgqVldfjc7ERuP74gETyE5j9oINGTJ1JTtBBTfmQu5Ervw iRT/fe0ArcYomMbi/A8/6xVBa/iRGrxzfjyENX3lVu+ZnfxLZlMV2oElEJCJ6J05dk8b TEQyoFJeg64whvqjkd5qEVeKlORAwMReNYguDvmuqd1woYGDV/lsId6pq9b2UE9D+Ug0 EvX0/dJ7x/kcDTZ6Cra8OEci0d7m5C2/Nb9p17P3J+Kcpunx/GdvAikebAo97ZzhjH72 jo6n2FR+VpWuJp/HI1fo9qeoQAZ3/L650Q246SS7PqZl5x4s61kODeETIQwzkjekwJbi NKrw== X-Gm-Message-State: AODbwcBQdm/QMAnW6+jjPyN7lW2llr07bd/WCFOhsd4tEKw2TiSGl6RK yStG5VpeOgSMFvmlork= X-Received: by 10.25.210.6 with SMTP id j6mr10626911lfg.21.1496928474655; Thu, 08 Jun 2017 06:27:54 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id i8sm1025178ljb.55.2017.06.08.06.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jun 2017 06:27:53 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij Subject: [PATCH 3/9] mmc: core: Move mmc_interrupt_hpi() from core.c to mmc_ops.c Date: Thu, 8 Jun 2017 15:27:39 +0200 Message-Id: <1496928465-25004-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496928465-25004-1-git-send-email-ulf.hansson@linaro.org> References: <1496928465-25004-1-git-send-email-ulf.hansson@linaro.org> The mmc_interrupt_hpi() is a eMMC specific function, let's move it to mmc_ops.c to make that clear. The move also enables us to make mmc_send_hpi_cmd() static, so let's do that change as well. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 64 -------------------------------------------- drivers/mmc/core/mmc_ops.c | 66 +++++++++++++++++++++++++++++++++++++++++++++- drivers/mmc/core/mmc_ops.h | 1 - 3 files changed, 65 insertions(+), 66 deletions(-) -- 2.7.4 Reviewed-by: Linus Walleij diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d7c934c..de31f30 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -675,70 +675,6 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) EXPORT_SYMBOL(mmc_wait_for_req); /** - * mmc_interrupt_hpi - Issue for High priority Interrupt - * @card: the MMC card associated with the HPI transfer - * - * Issued High Priority Interrupt, and check for card status - * until out-of prg-state. - */ -int mmc_interrupt_hpi(struct mmc_card *card) -{ - int err; - u32 status; - unsigned long prg_wait; - - if (!card->ext_csd.hpi_en) { - pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host)); - return 1; - } - - mmc_claim_host(card->host); - err = mmc_send_status(card, &status); - if (err) { - pr_err("%s: Get card status fail\n", mmc_hostname(card->host)); - goto out; - } - - switch (R1_CURRENT_STATE(status)) { - case R1_STATE_IDLE: - case R1_STATE_READY: - case R1_STATE_STBY: - case R1_STATE_TRAN: - /* - * In idle and transfer states, HPI is not needed and the caller - * can issue the next intended command immediately - */ - goto out; - case R1_STATE_PRG: - break; - default: - /* In all other states, it's illegal to issue HPI */ - pr_debug("%s: HPI cannot be sent. Card state=%d\n", - mmc_hostname(card->host), R1_CURRENT_STATE(status)); - err = -EINVAL; - goto out; - } - - err = mmc_send_hpi_cmd(card, &status); - if (err) - goto out; - - prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time); - do { - err = mmc_send_status(card, &status); - - if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN) - break; - if (time_after(jiffies, prg_wait)) - err = -ETIMEDOUT; - } while (!err); - -out: - mmc_release_host(card->host); - return err; -} - -/** * mmc_wait_for_cmd - start a command and wait for completion * @host: MMC host to start command * @cmd: MMC command to start diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 0648fae..53e4da48 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -807,7 +807,7 @@ int mmc_bus_test(struct mmc_card *card, u8 bus_width) return mmc_send_bus_test(card, card->host, MMC_BUS_TEST_R, width); } -int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) +static int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) { struct mmc_command cmd = {}; unsigned int opcode; @@ -841,6 +841,70 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) return 0; } +/** + * mmc_interrupt_hpi - Issue for High priority Interrupt + * @card: the MMC card associated with the HPI transfer + * + * Issued High Priority Interrupt, and check for card status + * until out-of prg-state. + */ +int mmc_interrupt_hpi(struct mmc_card *card) +{ + int err; + u32 status; + unsigned long prg_wait; + + if (!card->ext_csd.hpi_en) { + pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host)); + return 1; + } + + mmc_claim_host(card->host); + err = mmc_send_status(card, &status); + if (err) { + pr_err("%s: Get card status fail\n", mmc_hostname(card->host)); + goto out; + } + + switch (R1_CURRENT_STATE(status)) { + case R1_STATE_IDLE: + case R1_STATE_READY: + case R1_STATE_STBY: + case R1_STATE_TRAN: + /* + * In idle and transfer states, HPI is not needed and the caller + * can issue the next intended command immediately + */ + goto out; + case R1_STATE_PRG: + break; + default: + /* In all other states, it's illegal to issue HPI */ + pr_debug("%s: HPI cannot be sent. Card state=%d\n", + mmc_hostname(card->host), R1_CURRENT_STATE(status)); + err = -EINVAL; + goto out; + } + + err = mmc_send_hpi_cmd(card, &status); + if (err) + goto out; + + prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time); + do { + err = mmc_send_status(card, &status); + + if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN) + break; + if (time_after(jiffies, prg_wait)) + err = -ETIMEDOUT; + } while (!err); + +out: + mmc_release_host(card->host); + return err; +} + int mmc_can_ext_csd(struct mmc_card *card) { return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index b8d0552..063500c 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -31,7 +31,6 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid); int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp); int mmc_spi_set_crc(struct mmc_host *host, int use_crc); int mmc_bus_test(struct mmc_card *card, u8 bus_width); -int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status); int mmc_interrupt_hpi(struct mmc_card *card); int mmc_can_ext_csd(struct mmc_card *card); int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);