Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7622778ybl; Thu, 16 Jan 2020 02:51:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzdIHFQDoH3JNvH8lRv86pOElIa0gROBDxCjggrGs0ZuRChFosTCCM/V45qWVGV/FZebvfM X-Received: by 2002:a54:4896:: with SMTP id r22mr3638801oic.30.1579171919648; Thu, 16 Jan 2020 02:51:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579171919; cv=none; d=google.com; s=arc-20160816; b=VI8LwDS23byvj8HCX0vJKvdxmeU4Luf6v55OE4Y0Ceum4fS8bOpL5p4nzCW3phrbF4 RDJOG84E+mefBOABNQMp4xb8tz0unmGfdm7fiduKuf5Rz/3zs+kr6vEFl4GCy7WYqnQ1 r+IFcv7tlSKKN7Yd+6VubBoVTm3/UOJz0YoT6fwoLPueYsvF8PiiFP4mqdlVx1J3mZL0 7b4Lh719lWtWtU4Y5GSUUjGOx2NCxeflwL8R0cet214D7h7ggMUlMnmnnp+DQyYVPweu kmAmiAmpA+wLFIQRUpvXx71dNPKkNf9fEjBDdkgQNLrKIdDs8IvQ43HJzZ/VZKSiyLah T/OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e7mhL131meFfHXqNLxcDF2mevdid+GzhZqStQmQYOhQ=; b=ksDZOekOKV1bwoem34qWRSvNrjI2RWyj7qxp1Y1hEL/ugCbRJNVPKh3YTwLWChppT4 UcraAYeSj9kyUvVksjUy+FCEwRbVTc6LGZS6l0iL5d0GDqq8oxUDLgFI3j2n6c5kw1/q WHXd/7MO4HlR6KHVwAGmdPiT0vVGx6Q7mjeGAQjKP1aAH/MEBNMvHMtNFuf4a10sA9Li 2u7ct7K6rZEnwIWdKnn6lTROVerccJG/U+Gw/k5AlI24BsbnnF0qsEYfs4VHnnbyYDdH +PIiAGSWhq0bX3Dk/++YogTMXGfc3KllyhDUQjhF+2boPkoLb7TPPw9gp73r95wcaUYm Hajw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=etswpo4o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q72si11872872oic.18.2020.01.16.02.51.48; Thu, 16 Jan 2020 02:51:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=etswpo4o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgAPKut (ORCPT + 99 others); Thu, 16 Jan 2020 05:50:49 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:44806 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgAPKur (ORCPT ); Thu, 16 Jan 2020 05:50:47 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 00GAobJQ050150; Thu, 16 Jan 2020 04:50:37 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1579171837; bh=e7mhL131meFfHXqNLxcDF2mevdid+GzhZqStQmQYOhQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=etswpo4oob4XHPc3Urmi3b6TqNeGER5JgWlZNvxM7I5TDFLY5I6upTkfsbezqcDpK owN1g2g4QtFqM+/mK7XYpd36YBL1HWjReYrmpTzu25S9eEvGMHnFCVVsyFGpT1oxDz Sv1KgEok9EKlAMhKhCp1uob7N7sWtMhODJJxWrdM= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00GAobD0085076; Thu, 16 Jan 2020 04:50:37 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 16 Jan 2020 04:50:37 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 16 Jan 2020 04:50:37 -0600 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00GAoRdU000589; Thu, 16 Jan 2020 04:50:34 -0600 From: Faiz Abbas To: , , , CC: , , , , , , Subject: [PATCH v5 02/10] mmc: sdhci: Factor out some operations set to their own functions Date: Thu, 16 Jan 2020 16:21:46 +0530 Message-ID: <20200116105154.7685-3-faiz_abbas@ti.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20200116105154.7685-1-faiz_abbas@ti.com> References: <20200116105154.7685-1-faiz_abbas@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for adding external dma support, factor out data initialization, block info and mrq_done to their own functions. Signed-off-by: Faiz Abbas Tested-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 94 ++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1b1c26da3fe0..53cd5d0c4290 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1025,18 +1025,9 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) } } -static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) +static void sdhci_initialize_data(struct sdhci_host *host, + struct mmc_data *data) { - struct mmc_data *data = cmd->data; - - host->data_timeout = 0; - - if (sdhci_data_line_cmd(cmd)) - sdhci_set_timeout(host, cmd); - - if (!data) - return; - WARN_ON(host->data); /* Sanity checks */ @@ -1047,6 +1038,34 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) host->data = data; host->data_early = 0; host->data->bytes_xfered = 0; +} + +static inline void sdhci_set_block_info(struct sdhci_host *host, + struct mmc_data *data) +{ + /* Set the DMA boundary value and block size */ + sdhci_writew(host, + SDHCI_MAKE_BLKSZ(host->sdma_boundary, data->blksz), + SDHCI_BLOCK_SIZE); + /* + * For Version 4.10 onwards, if v4 mode is enabled, 32-bit Block Count + * can be supported, in that case 16-bit block count register must be 0. + */ + if (host->version >= SDHCI_SPEC_410 && host->v4_mode && + (host->quirks2 & SDHCI_QUIRK2_USE_32BIT_BLK_CNT)) { + if (sdhci_readw(host, SDHCI_BLOCK_COUNT)) + sdhci_writew(host, 0, SDHCI_BLOCK_COUNT); + sdhci_writew(host, data->blocks, SDHCI_32BIT_BLK_CNT); + } else { + sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); + } +} + +static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) +{ + struct mmc_data *data = cmd->data; + + sdhci_initialize_data(host, data); if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { struct scatterlist *sg; @@ -1133,22 +1152,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) sdhci_set_transfer_irqs(host); - /* Set the DMA boundary value and block size */ - sdhci_writew(host, SDHCI_MAKE_BLKSZ(host->sdma_boundary, data->blksz), - SDHCI_BLOCK_SIZE); - - /* - * For Version 4.10 onwards, if v4 mode is enabled, 32-bit Block Count - * can be supported, in that case 16-bit block count register must be 0. - */ - if (host->version >= SDHCI_SPEC_410 && host->v4_mode && - (host->quirks2 & SDHCI_QUIRK2_USE_32BIT_BLK_CNT)) { - if (sdhci_readw(host, SDHCI_BLOCK_COUNT)) - sdhci_writew(host, 0, SDHCI_BLOCK_COUNT); - sdhci_writew(host, data->blocks, SDHCI_32BIT_BLK_CNT); - } else { - sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); - } + sdhci_set_block_info(host, data); } static inline bool sdhci_auto_cmd12(struct sdhci_host *host, @@ -1245,22 +1249,10 @@ static bool sdhci_needs_reset(struct sdhci_host *host, struct mmc_request *mrq) (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))); } -static void __sdhci_finish_mrq(struct sdhci_host *host, struct mmc_request *mrq) +static void sdhci_set_mrq_done(struct sdhci_host *host, struct mmc_request *mrq) { int i; - if (host->cmd && host->cmd->mrq == mrq) - host->cmd = NULL; - - if (host->data_cmd && host->data_cmd->mrq == mrq) - host->data_cmd = NULL; - - if (host->data && host->data->mrq == mrq) - host->data = NULL; - - if (sdhci_needs_reset(host, mrq)) - host->pending_reset = true; - for (i = 0; i < SDHCI_MAX_MRQS; i++) { if (host->mrqs_done[i] == mrq) { WARN_ON(1); @@ -1276,6 +1268,23 @@ static void __sdhci_finish_mrq(struct sdhci_host *host, struct mmc_request *mrq) } WARN_ON(i >= SDHCI_MAX_MRQS); +} + +static void __sdhci_finish_mrq(struct sdhci_host *host, struct mmc_request *mrq) +{ + if (host->cmd && host->cmd->mrq == mrq) + host->cmd = NULL; + + if (host->data_cmd && host->data_cmd->mrq == mrq) + host->data_cmd = NULL; + + if (host->data && host->data->mrq == mrq) + host->data = NULL; + + if (sdhci_needs_reset(host, mrq)) + host->pending_reset = true; + + sdhci_set_mrq_done(host, mrq); sdhci_del_timer(host, mrq); @@ -1390,12 +1399,15 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) } host->cmd = cmd; + host->data_timeout = 0; if (sdhci_data_line_cmd(cmd)) { WARN_ON(host->data_cmd); host->data_cmd = cmd; + sdhci_set_timeout(host, cmd); } - sdhci_prepare_data(host, cmd); + if (cmd->data) + sdhci_prepare_data(host, cmd); sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT); -- 2.19.2