Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932478AbdIYCjj (ORCPT ); Sun, 24 Sep 2017 22:39:39 -0400 Received: from mail-eopbgr10086.outbound.protection.outlook.com ([40.107.1.86]:48288 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932135AbdIYCjg (ORCPT ); Sun, 24 Sep 2017 22:39:36 -0400 From: Bough Chen To: Adrian Hunter , Ulf Hansson CC: linux-mmc , linux-block , linux-kernel , Alex Lemberg , Mateusz Nowak , Yuliy Izrailov , Jaehoon Chung , Dong Aisheng , Das Asutosh , Zhangfei Gao , Sahitya Tummala , Harjani Ritesh , Venu Byravarasu , "Linus Walleij" , Shawn Lin , Christoph Hellwig Subject: RE: [PATCH V9 14/15] mmc: cqhci: support for command queue enabled host Thread-Topic: [PATCH V9 14/15] mmc: cqhci: support for command queue enabled host Thread-Index: AQHTM6ChlB5IpsPXWEOynON9wqGEGqLE5kmA Date: Mon, 25 Sep 2017 02:39:33 +0000 Message-ID: References: <1506083824-4024-1-git-send-email-adrian.hunter@intel.com> <1506083824-4024-15-git-send-email-adrian.hunter@intel.com> In-Reply-To: <1506083824-4024-15-git-send-email-adrian.hunter@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; x-originating-ip: [192.158.241.86] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM4PR0401MB2323;6:pnqnp8BBx7FGDgL9O+Lr++R7cLuM1IqBmjKDjXAltRfHyWIkmpfdNZ8rIoRHaDUuBJf6IJrQDwCBYeI2J6RjV1FKMnnVHQT4lOYVFjX76dvc/JJfN7AyFtKjO3YkBDLy6R/6Q5CcsgYnTQ0/JOunav37laMiSzXMA3+XyjoA4tAMWbcgYTZNnTxd71w2RVBEw+psDtZ6FnNQumQQEwKTgIwKsMHkqBpV3b23SHWwOIJAhZP9e4DXqyTL1hZrmvJaKtx40LuJ4O/Z3RvmfClUel9FUGOwG68rpgHGdto0AnvYYI53zKg/6H7EI8l/KBJpHLXOl9udV0OnTjrwAAcASg==;5:hsoBi47wiBnpL+ZmS9h19KTRLgvnyhFEWA+YjwQpAILdw8xNRqpWD8wEQCecv2vpSWb8br3esZ9zKvNqLhEv/SO2C8y530aBxJi4EYpPwxYX6CJFQcTLwCjwdrE2LcsIwXEOGO3hhbFIsB4yRoARuA==;24:VMygL/35zQl5IWMjuod2WkRPtQ5Bg8m7FKiCVA0b+JufSE3wU2QwVNJtEHtuFYl6AOD/+auGD2t6Shda4g+VssdXKr/FcOwbw+jQOtJRfWY=;7:9OV7K/B4mk+LeMyR60sdCC/wAQLvIkj6wApqIxmVotHXosuMdk7U3gHGjg8Kex6TZBZNAyJeomXPM03gwVlkAhHem2EIDg5WhB6NfrliESCUb/rdZccCfzQVAzaEpoRP8DAQxFtNAvSYcfcl4ias9z9a49I/1AeRwePebGFMN7I1g+wZD8jcBiCylkdi51mMX5xx5vPSyhKzsuC6Z8TM7FOjw5sytzVxU8AQ3zcoT5M= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: b1bdd332-7ef0-4078-cdcd-08d503bea788 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:AM4PR0401MB2323; x-ms-traffictypediagnostic: AM4PR0401MB2323: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197)(7411616537696)(42932892334569)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM4PR0401MB2323;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM4PR0401MB2323; x-forefront-prvs: 04410E544A x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(376002)(39860400002)(346002)(377454003)(13464003)(199003)(189002)(7736002)(5250100002)(305945005)(3846002)(86362001)(76176999)(229853002)(54356999)(50986999)(14454004)(5660300001)(4326008)(99286003)(9686003)(55016002)(39060400002)(6246003)(53936002)(33656002)(7696004)(7416002)(8656003)(105586002)(106356001)(575784001)(101416001)(2950100002)(189998001)(53546010)(8936002)(68736007)(66066001)(6436002)(25786009)(74316002)(81156014)(8676002)(6116002)(81166006)(6506006)(102836003)(316002)(97736004)(2900100001)(54906003)(3660700001)(110136005)(478600001)(3280700002)(2906002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0401MB2323;H:AM4PR0401MB2324.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2017 02:39:33.0973 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2323 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8P2eNbE020377 Content-Length: 7026 Lines: 199 > -----Original Message----- > From: Adrian Hunter [mailto:adrian.hunter@intel.com] > Sent: Friday, September 22, 2017 8:37 PM > To: Ulf Hansson > Cc: linux-mmc ; linux-block block@vger.kernel.org>; linux-kernel ; Bough > Chen ; Alex Lemberg ; > Mateusz Nowak ; Yuliy Izrailov > ; Jaehoon Chung ; > Dong Aisheng ; Das Asutosh > ; Zhangfei Gao ; > Sahitya Tummala ; Harjani Ritesh > ; Venu Byravarasu ; > Linus Walleij ; Shawn Lin chips.com>; Christoph Hellwig > Subject: [PATCH V9 14/15] mmc: cqhci: support for command queue enabled > host > > From: Venkat Gopalakrishnan > > This patch adds CMDQ support for command-queue compatible hosts. > > Command queue is added in eMMC-5.1 specification. This enables the > controller to process upto 32 requests at a time. > > Adrian Hunter contributed renaming to cqhci, recovery, suspend and resume, > cqhci_off, cqhci_wait_for_idle, and external timeout handling. > > Signed-off-by: Asutosh Das > Signed-off-by: Sujit Reddy Thumma > Signed-off-by: Konstantin Dorfman > Signed-off-by: Venkat Gopalakrishnan > Signed-off-by: Subhash Jadavani > Signed-off-by: Ritesh Harjani > Signed-off-by: Adrian Hunter > --- > drivers/mmc/host/Kconfig | 13 + > drivers/mmc/host/Makefile | 1 + > drivers/mmc/host/cqhci.c | 1154 > +++++++++++++++++++++++++++++++++++++++++++++ > drivers/mmc/host/cqhci.h | 240 ++++++++++ > 4 files changed, 1408 insertions(+) > create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 > drivers/mmc/host/cqhci.h > > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index > 17afe1ad3a03..f2751465bc54 100644 > --- a/drivers/mmc/host/Kconfig > +++ b/drivers/mmc/host/Kconfig > @@ -843,6 +843,19 @@ config MMC_SUNXI > This selects support for the SD/MMC Host Controller on > Allwinner sunxi SoCs. > > +config MMC_CQHCI > + tristate "Command Queue Host Controller Interface support" > + depends on HAS_DMA > + help > + This selects the Command Queue Host Controller Interface (CQHCI) > + support present in host controllers of Qualcomm Technologies, Inc > + amongst others. > + This controller supports eMMC devices with command queue support. > + > + If you have a controller with this interface, say Y or M here. > + > + If unsure, say N. > + > config MMC_TOSHIBA_PCI > tristate "Toshiba Type A SD/MMC Card Interface Driver" > depends on PCI > diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index > 2b5a8133948d..f01d9915304d 100644 > --- a/drivers/mmc/host/Makefile > +++ b/drivers/mmc/host/Makefile > @@ -90,6 +90,7 @@ obj-$(CONFIG_MMC_SDHCI_ST) += sdhci-st.o > obj-$(CONFIG_MMC_SDHCI_MICROCHIP_PIC32) += sdhci-pic32.o > obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o > obj-$(CONFIG_MMC_SDHCI_OMAP) += sdhci-omap.o > +obj-$(CONFIG_MMC_CQHCI) += cqhci.o > > ifeq ($(CONFIG_CB710_DEBUG),y) > CFLAGS-cb710-mmc += -DDEBUG > diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c new file > mode 100644 index 000000000000..eb3c1695b0c7 > --- /dev/null > +++ b/drivers/mmc/host/cqhci.c > @@ -0,0 +1,1154 @@ > +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 and > + * only version 2 as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include "cqhci.h" > + > +#define DCMD_SLOT 31 > +#define NUM_SLOTS 32 > + > +struct cqhci_slot { > + struct mmc_request *mrq; > + unsigned int flags; > +#define CQHCI_EXTERNAL_TIMEOUT BIT(0) > +#define CQHCI_COMPLETED BIT(1) > +#define CQHCI_HOST_CRC BIT(2) > +#define CQHCI_HOST_TIMEOUT BIT(3) > +#define CQHCI_HOST_OTHER BIT(4) > +}; > + > +static inline u8 *get_desc(struct cqhci_host *cq_host, u8 tag) { > + return cq_host->desc_base + (tag * cq_host->slot_sz); } > + > +static inline u8 *get_link_desc(struct cqhci_host *cq_host, u8 tag) { > + u8 *desc = get_desc(cq_host, tag); > + > + return desc + cq_host->task_desc_len; > +} > + > +static inline dma_addr_t get_trans_desc_dma(struct cqhci_host *cq_host, > +u8 tag) { > + return cq_host->trans_desc_dma_base + > + (cq_host->mmc->max_segs * tag * > + cq_host->trans_desc_len); > +} > + > +static inline u8 *get_trans_desc(struct cqhci_host *cq_host, u8 tag) { > + return cq_host->trans_desc_base + > + (cq_host->trans_desc_len * cq_host->mmc->max_segs * tag); } > + > +static void setup_trans_desc(struct cqhci_host *cq_host, u8 tag) { > + u8 *link_temp; > + dma_addr_t trans_temp; > + > + link_temp = get_link_desc(cq_host, tag); > + trans_temp = get_trans_desc_dma(cq_host, tag); > + > + memset(link_temp, 0, cq_host->link_desc_len); > + if (cq_host->link_desc_len > 8) > + *(link_temp + 8) = 0; > + > + if (tag == DCMD_SLOT && (cq_host->mmc->caps2 & > MMC_CAP2_CQE_DCMD)) { > + *link_temp = CQHCI_VALID(0) | CQHCI_ACT(0) | > CQHCI_END(1); > + return; > + } > + > + *link_temp = CQHCI_VALID(1) | CQHCI_ACT(0x6) | CQHCI_END(0); > + > + if (cq_host->dma64) { > + __le64 *data_addr = (__le64 __force *)(link_temp + 4); > + > + data_addr[0] = cpu_to_le64(trans_temp); > + } else { > + __le32 *data_addr = (__le32 __force *)(link_temp + 4); > + > + data_addr[0] = cpu_to_le32(trans_temp); > + } > +} > + > +static void cqhci_set_irqs(struct cqhci_host *cq_host, u32 set) { > + u32 ier; > + > + ier = cqhci_readl(cq_host, CQHCI_ISTE); > + ier |= set; Hi Adrian, I think operation ' |= ' is not correct, since we will also call cqhci_set_irqs(cq_host, 0), Which means to mask all cmdq irq, so I think better to directly write the parameter 'set' to ISTE and ISGE. Best Regards, Haibo Chen > + cqhci_writel(cq_host, ier, CQHCI_ISTE); > + cqhci_writel(cq_host, ier, CQHCI_ISGE); } > + > +#define DRV_NAME "cqhci" > +