From patchwork Fri Sep 6 03:51:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 173189 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp179974ilq; Thu, 5 Sep 2019 20:52:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9z+9KGkylANB+oMQWUJB6krEn6lHLq6GpynbpmJe1nNpeaLbjy/eTQ45YLZjOURMGFGfL X-Received: by 2002:a17:902:23:: with SMTP id 32mr7277798pla.214.1567741971841; Thu, 05 Sep 2019 20:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567741971; cv=none; d=google.com; s=arc-20160816; b=vUzfKKXJ1835ROTnu7FjOvF9C2s7tglxgcWt4cxDs9smRioEmIEii5/5WXQvU222LZ OwkT1THNkCMqJIFLzUULoiZe6krHRH8kAA/WWMde/u2CFqP04CcCBPSwe+JIb3KpZzZv pnu3sZzUYLBW8EIKDgCD8X1cpp7l+8Jau7Q0M6UtLL/hK85AAtSgv5CR0FGi3qFhWltF aI2qxmUvO6Li/b4EVWFig9NLp9lQZ7ISl4VUOrViQTw3OX485HH6yj7RSW9wNrbO973t EigjCtlgw3GnvF1xrX4QcoGpq4fPXLQ5dC64KYiCAJTc0dPvEm/GLThR6lqB4hqpVTSd G4YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=LB2crZ9I7ACv+30hmydmVm4238zRkVsO0qfLPmJY+cQ=; b=ctkcxfnEb1Pvjhjbi3L/6rs4oM9NJIHT3tZ23KZgoP0qkHkDasoAZJgfrrDgpkq0hX By2jL0vfPtqYzlvEeVTe3lhM0y5mfohbKUuOzfxJBBAYUo4gXQ2596NnDVarSrtvHcIM pWNL0Nsl6rJx6sWF2h3Oi+OJ/iQjGPRgfZ2IBycRB0HVgkIP8r8oEXIvYIh6pvFQWi/s OBYCmPIgigrakDej9//j1qluFmPjvt8Tudvq99mujcTgESKf3Utq6yV5dPomLMf/5mE1 DmhSIGJIAYiqJTaAyg7Eg19kWZ5/KEZrqBFxdSvvg06mThHazNNze5zD0cnZsD0rRtaM 92XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q6r3Zj1g; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b190si3550920pga.105.2019.09.05.20.52.51; Thu, 05 Sep 2019 20:52:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=Q6r3Zj1g; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392189AbfIFDwq (ORCPT + 5 others); Thu, 5 Sep 2019 23:52:46 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40806 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733221AbfIFDwp (ORCPT ); Thu, 5 Sep 2019 23:52:45 -0400 Received: by mail-pl1-f196.google.com with SMTP id y10so2431011pll.7 for ; Thu, 05 Sep 2019 20:52:45 -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 :in-reply-to:references; bh=LB2crZ9I7ACv+30hmydmVm4238zRkVsO0qfLPmJY+cQ=; b=Q6r3Zj1gkoYJYVCwVD7Ne22kO6WvhtvqoYb0qSFwbj0Z4t/1ksnlrK+2TSj7GogfgN 9MjOcX/yrli6OOolR+lfiTyGybj89BJes1otScVH84LTGyLhLtSPkSzKegomEwgVq1Mu Lu58hmoAF12uR2+sj80m2DleX7sSG7KkIeAmUyMU7NI59uPfy/FJwm6ntJgEdCRwAiuq mOBrZOhtDgxMlNseys4zhQCCYiauX6ScycKmA7jd4W2f6YdgN8xRn5PYeCKd2CKDRGoZ vB+X+X81JpoPMOXkHzc47we11Fn3qkFpbQm9ATZUxBit7NAHjzKEoRV4AZYPeeGmQDu7 FOJw== 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:in-reply-to:references; bh=LB2crZ9I7ACv+30hmydmVm4238zRkVsO0qfLPmJY+cQ=; b=FCyhW6Znn81HRHvZoIwwtd6TlRiqRk6mm+2ZqdYNnmwa6AmOfZtP7wExC/sJjjDPj+ E55WH70j/zX6xyVunBUAvTpLv/Y0++BR3soZ+skIPzHgHPwvqORArPvn6QtFo/Y3bMRp lbOAQhEc4rCASGDOa5E9k9AYRBMmkCRcrmaOG3tFTZqbTxGE1iYTUG4gSKOkvchAtb7o Q5luVpZvmseU4JEceNlDDuJ/gwHlyzc1TCrBXf6W1+w5pIEjdVMsjy6uB5AhKhjJW+wA PCHaGke646wEhd0YG8kg3HUXeiZmTT9BiQBXCgrG+XG7nmQp2X3tICsNWqdOEKpZRyAX mguQ== X-Gm-Message-State: APjAAAVmcVxl6davP1dMBa/GHGb4sYbxdmrxCKauh4Fz9jrqo5uduApe co75ejBcHZ5uzEF9a8l7Wz8h3Q== X-Received: by 2002:a17:902:bb95:: with SMTP id m21mr7136794pls.26.1567741965356; Thu, 05 Sep 2019 20:52:45 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j7sm4205770pfi.96.2019.09.05.20.52.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 20:52:44 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, riteshh@codeaurora.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mmc: host: cqhci: Move the struct cqhci_slot into header file Date: Fri, 6 Sep 2019 11:51:59 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The struct cqhci_slot will be used by virtual command queue introducing by following patches, thus move it to the header file. Signed-off-by: Baolin Wang --- drivers/mmc/host/cqhci.c | 10 ---------- drivers/mmc/host/cqhci.h | 11 ++++++++++- 2 files changed, 10 insertions(+), 11 deletions(-) -- 1.7.9.5 diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c index f7bdae5..57ff1cc 100644 --- a/drivers/mmc/host/cqhci.c +++ b/drivers/mmc/host/cqhci.c @@ -21,16 +21,6 @@ #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); diff --git a/drivers/mmc/host/cqhci.h b/drivers/mmc/host/cqhci.h index def76e9..7b07bf24f 100644 --- a/drivers/mmc/host/cqhci.h +++ b/drivers/mmc/host/cqhci.h @@ -141,7 +141,16 @@ struct cqhci_host_ops; struct mmc_host; struct mmc_request; -struct cqhci_slot; + +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) +}; struct cqhci_host { const struct cqhci_host_ops *ops; From patchwork Fri Sep 6 03:52:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 173190 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp179981ilq; Thu, 5 Sep 2019 20:52:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZAADE+79sOcuEVX96FILBgRHy5a/Db4wao9AqeF/CFiP3OtRNm5YrLd6olZZJDiLQLICQ X-Received: by 2002:a17:902:f301:: with SMTP id gb1mr6970981plb.249.1567741972599; Thu, 05 Sep 2019 20:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567741972; cv=none; d=google.com; s=arc-20160816; b=zYspoMmaHc+h0WZZsYOIRPi0loEEvc+8nAJfF5G9Y/+9UNnYcVQEUwApm7mOU0zUDE tmdfYZv5jSy5nnFiJoGpA4jpb70AFqNyFTReSpdqkwmuUpSoMv9qqTuGAHjwSZhVzX6Z ijoPWGsSqw5LrjhbEzsPD4msgRLS01IHKmMW9Y0ufYCUhihhq7rnh/w3umIeuRlDTx66 3pE4UTsOUOHklYrvjI6cWr7MjjSTRbFEEBt8Z0DXucAdBTaNQxICWw4rUINlBhZgjtOb fn7NKCyhCjbMXbU6ZM59a78vp7+v+asqaizAjcEGxLPITo6gQ/FHl5liURoPWmgqnMHl SPtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=/mPYMgQpWwPs9Kfj7cZUhbMjGVT/C9wGX3LO9Qwmt0k=; b=cMou6Bb7rAr6iFiC1uovusuWN7afBfazac7+Qrz5UtWp4d5tn/gWg+nJPwZzJyksoF O3yGqTvejbwjav5VW5gkkIVL8qSLtjePHcFLMtfoHvYa57MKm4Kk0n0cbIrNb+T10pUh RLM64KSqsf3Vso9/bEdwvzksPEHNdaWU9/+IYREHNRB1BFEa+xRuwskLJJUIg7ZfkabG u+6LDs0yLeldsf4T3JfXRv1HQ0SIKhGYpd0daHT0posiYZ3AfHF6ft15u2cKWcJ0litx Cal1ZZWPaamJhLLrven7DJHHlPWldZ/5ZMYeVbkazeauDdICWavft/iWRmUKfoE4mue/ zMEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OzCouluv; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b190si3550920pga.105.2019.09.05.20.52.52; Thu, 05 Sep 2019 20:52:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=OzCouluv; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392202AbfIFDwv (ORCPT + 5 others); Thu, 5 Sep 2019 23:52:51 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42010 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392201AbfIFDwv (ORCPT ); Thu, 5 Sep 2019 23:52:51 -0400 Received: by mail-pf1-f194.google.com with SMTP id w22so3388521pfi.9 for ; Thu, 05 Sep 2019 20:52:50 -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 :in-reply-to:references; bh=/mPYMgQpWwPs9Kfj7cZUhbMjGVT/C9wGX3LO9Qwmt0k=; b=OzCouluvCaLyiJxlEsyP7QUXOOjyr8lPxGf9d149u2pbgNdxZkS2imxC9XlA2FN0Jf d0/hR4fFVoELfEVIMP7HJEEjxY+hOIPWjWm2HlEN+85QEAjcXzjj4ATwFjkkAGU+Qqk6 C7k2sAn0xXE7QzHgoXwAsbBCJN8lljDfcZMZJo1VaL03KfBDNBbNiXTSUtjVU5E5x759 fJeX3YT3f1ksogoJhhLzDOeWOoSqiUY1ed1jp4tYGcYOWSbWUZCXthsbbtdMWLDyP2+Z esFI1gE/+w3oqaIM8RQcSr27aAVKNYT3s/OHLy5WzEQ6HNbNu9gEUBbTwDi7bOxtOmyv zJaQ== 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:in-reply-to:references; bh=/mPYMgQpWwPs9Kfj7cZUhbMjGVT/C9wGX3LO9Qwmt0k=; b=RowypGd+Ww7Qp/CDARTwlnx6imsg3dC+uHR2fcPkN04gAtEvbXQ7ESFYJ02eeaap1u u0lpVMagUTDMltRZ6NRU4e58TowwR6+V3acUmT5vIH6PownvbezeZ49FM9crKPhR6Pkl 2+bmj836Gdb8x3p3OKsgrx1vw6V6xafQBuVq5NpNRAHzawuQ8bfykVg2TSxjnycGhqbG vSf8fBgenyFnmyZX/hVptkSE9frMbuPap3W07eh/ZmmpmN0wYJy3RqFXsYqtWkf/gWww Rk6Ur/SAuivLFKzJHDa+09bfBGMy52Fxa0RuhS95ZsMyZmNyHq9do0vuwB4fexHNNNx/ fO9g== X-Gm-Message-State: APjAAAVIxruEDEOhJe3dx+1uoL+/pPG/duiczEkXN8aZSDdS8A+oubNA VxXc9MZP8+ba08CC3bghRFK4zw== X-Received: by 2002:aa7:8053:: with SMTP id y19mr6531812pfm.1.1567741969610; Thu, 05 Sep 2019 20:52:49 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j7sm4205770pfi.96.2019.09.05.20.52.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 20:52:49 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, riteshh@codeaurora.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mmc: Add virtual command queue support Date: Fri, 6 Sep 2019 11:52:00 +0800 Message-Id: <14599f7165f23db2bf7b71a2596e808e2bc2056c.1567740135.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Now the MMC read/write stack will always wait for previous request is completed by mmc_blk_rw_wait(), before sending a new request to hardware, or queue a work to complete request, that will bring context switching overhead, especially for high I/O per second rates, to affect the IO performance. Thus this patch introduces virtual command queue interface, which is similar with the hardware command queue engine's idea, that can remove the context switching. Moreover we set the queue depth as 2 for virtual command queue, that is enough to let the irq handler always trigger the next request without a context switch and then ask the blk_mq layer for the next one to get queued, as well as avoiding a long latency. >From the fio testing data in cover letter, we can see the virtual command queue can improve performance obviously with 4K block size, increasing about 52% for sequential read, increasing about 114% for random read, increasing about 81% for sequential write, and increasing about 127% for random write. Moreover we can expand the virtual command queue interface to support MMC packed request or packed command in future. Signed-off-by: Baolin Wang --- drivers/mmc/core/block.c | 62 ++++++++ drivers/mmc/core/mmc.c | 13 +- drivers/mmc/core/queue.c | 25 ++- drivers/mmc/host/Kconfig | 8 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci-virt.c | 346 +++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 34 ++++ include/linux/mmc/host.h | 1 + 8 files changed, 480 insertions(+), 10 deletions(-) create mode 100644 drivers/mmc/host/cqhci-virt.c -- 1.7.9.5 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 2c71a43..63d487f 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -168,6 +168,11 @@ struct mmc_rpmb_data { static inline int mmc_blk_part_switch(struct mmc_card *card, unsigned int part_type); +static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, + struct mmc_card *card, + int disable_multi, + struct mmc_queue *mq); +static void mmc_blk_virt_cqe_req_done(struct mmc_request *mrq); static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { @@ -1569,9 +1574,31 @@ static int mmc_blk_cqe_issue_flush(struct mmc_queue *mq, struct request *req) return mmc_blk_cqe_start_req(mq->card->host, mrq); } +static int mmc_blk_virt_cqe_issue_rw_rq(struct mmc_queue *mq, + struct request *req) +{ + struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req); + struct mmc_host *host = mq->card->host; + int err; + + mmc_blk_rw_rq_prep(mqrq, mq->card, 0, mq); + mqrq->brq.mrq.done = mmc_blk_virt_cqe_req_done; + mmc_pre_req(host, &mqrq->brq.mrq); + + err = mmc_cqe_start_req(host, &mqrq->brq.mrq); + if (err) + mmc_post_req(host, &mqrq->brq.mrq, err); + + return err; +} + static int mmc_blk_cqe_issue_rw_rq(struct mmc_queue *mq, struct request *req) { struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req); + struct mmc_host *host = mq->card->host; + + if (host->virt_cqe) + return mmc_blk_virt_cqe_issue_rw_rq(mq, req); mmc_blk_data_prep(mq, mqrq, 0, NULL, NULL); @@ -1957,6 +1984,41 @@ static void mmc_blk_urgent_bkops(struct mmc_queue *mq, mmc_run_bkops(mq->card); } +static void mmc_blk_virt_cqe_req_done(struct mmc_request *mrq) +{ + struct mmc_queue_req *mqrq = + container_of(mrq, struct mmc_queue_req, brq.mrq); + struct request *req = mmc_queue_req_to_req(mqrq); + struct request_queue *q = req->q; + struct mmc_queue *mq = q->queuedata; + struct mmc_host *host = mq->card->host; + unsigned long flags; + + if (mmc_blk_rq_error(&mqrq->brq) || + mmc_blk_urgent_bkops_needed(mq, mqrq)) { + spin_lock_irqsave(&mq->lock, flags); + mq->recovery_needed = true; + mq->recovery_req = req; + spin_unlock_irqrestore(&mq->lock, flags); + + host->cqe_ops->cqe_recovery_start(host); + + schedule_work(&mq->recovery_work); + return; + } + + mmc_blk_rw_reset_success(mq, req); + + /* + * Block layer timeouts race with completions which means the normal + * completion path cannot be used during recovery. + */ + if (mq->in_recovery) + mmc_blk_cqe_complete_rq(mq, req); + else + blk_mq_complete_request(req); +} + void mmc_blk_mq_complete(struct request *req) { struct mmc_queue *mq = req->q->queuedata; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index c880489..316b0a6 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1852,15 +1852,22 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, */ card->reenable_cmdq = card->ext_csd.cmdq_en; - if (card->ext_csd.cmdq_en && !host->cqe_enabled) { + if (host->cqe_ops && !host->cqe_enabled) { err = host->cqe_ops->cqe_enable(host, card); if (err) { pr_err("%s: Failed to enable CQE, error %d\n", mmc_hostname(host), err); } else { host->cqe_enabled = true; - pr_info("%s: Command Queue Engine enabled\n", - mmc_hostname(host)); + + if (card->ext_csd.cmdq_en) { + pr_info("%s: Command Queue Engine enabled\n", + mmc_hostname(host)); + } else { + host->virt_cqe = true; + pr_info("%s: Virtual Command Queue Engine enabled\n", + mmc_hostname(host)); + } } } diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index e327f80..50d7fad 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -59,7 +59,7 @@ enum mmc_issue_type mmc_issue_type(struct mmc_queue *mq, struct request *req) { struct mmc_host *host = mq->card->host; - if (mq->use_cqe) + if (mq->use_cqe && !host->virt_cqe) return mmc_cqe_issue_type(host, req); if (req_op(req) == REQ_OP_READ || req_op(req) == REQ_OP_WRITE) @@ -121,12 +121,14 @@ static enum blk_eh_timer_return mmc_mq_timed_out(struct request *req, { struct request_queue *q = req->q; struct mmc_queue *mq = q->queuedata; + struct mmc_card *card = mq->card; + struct mmc_host *host = card->host; unsigned long flags; int ret; spin_lock_irqsave(&mq->lock, flags); - if (mq->recovery_needed || !mq->use_cqe) + if (mq->recovery_needed || !mq->use_cqe || host->virt_cqe) ret = BLK_EH_RESET_TIMER; else ret = mmc_cqe_timed_out(req); @@ -141,12 +143,13 @@ static void mmc_mq_recovery_handler(struct work_struct *work) struct mmc_queue *mq = container_of(work, struct mmc_queue, recovery_work); struct request_queue *q = mq->queue; + struct mmc_host *host = mq->card->host; mmc_get_card(mq->card, &mq->ctx); mq->in_recovery = true; - if (mq->use_cqe) + if (mq->use_cqe && !host->virt_cqe) mmc_blk_cqe_recovery(mq); else mmc_blk_mq_recovery(mq); @@ -157,6 +160,9 @@ static void mmc_mq_recovery_handler(struct work_struct *work) mq->recovery_needed = false; spin_unlock_irq(&mq->lock); + if (host->virt_cqe) + host->cqe_ops->cqe_recovery_finish(host); + mmc_put_card(mq->card, &mq->ctx); blk_mq_run_hw_queues(q, true); @@ -406,11 +412,16 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) * The queue depth for CQE must match the hardware because the request * tag is used to index the hardware queue. */ - if (mq->use_cqe) - mq->tag_set.queue_depth = - min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth); - else + if (mq->use_cqe) { + if (host->virt_cqe) + mq->tag_set.queue_depth = host->cqe_qdepth; + else + mq->tag_set.queue_depth = + min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth); + } else { mq->tag_set.queue_depth = MMC_QUEUE_DEPTH; + } + mq->tag_set.numa_node = NUMA_NO_NODE; mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; mq->tag_set.nr_hw_queues = 1; diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 14d89a1..e2a12c3 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -923,6 +923,14 @@ config MMC_CQHCI If unsure, say N. +config MMC_VIRTUAL_CQHCI + bool "Virtual Command Queue Host Controller Interface support" + help + This selects the Virtual Command Queue Host Controller Interface (VCQHCI) + support. + + 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 7357871..3611c96 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile @@ -97,6 +97,7 @@ obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o obj-$(CONFIG_MMC_SDHCI_OMAP) += sdhci-omap.o obj-$(CONFIG_MMC_SDHCI_SPRD) += sdhci-sprd.o obj-$(CONFIG_MMC_CQHCI) += cqhci.o +obj-$(CONFIG_MMC_VIRTUAL_CQHCI) += cqhci-virt.o ifeq ($(CONFIG_CB710_DEBUG),y) CFLAGS-cb710-mmc += -DDEBUG diff --git a/drivers/mmc/host/cqhci-virt.c b/drivers/mmc/host/cqhci-virt.c new file mode 100644 index 0000000..896c969 --- /dev/null +++ b/drivers/mmc/host/cqhci-virt.c @@ -0,0 +1,346 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Virtual Command Queue Support +// +// Copyright (C) 2019 Linaro, Inc. +// Author: Baolin Wang + +#include +#include +#include + +#include "cqhci.h" + +#define CQHCI_VIRT_NUM_SLOTS 2 +#define CQHCI_VIRT_INVALID_TAG CQHCI_VIRT_NUM_SLOTS + +static void cqhci_virt_pump_requests(struct cqhci_host *cqv_host) +{ + struct mmc_host *mmc = cqv_host->mmc; + struct cqhci_slot *slot; + unsigned long flags; + + spin_lock_irqsave(&cqv_host->lock, flags); + + /* Make sure we are not already running a request now */ + if (cqv_host->mrq) { + spin_unlock_irqrestore(&cqv_host->lock, flags); + return; + } + + /* Make sure there are remain requests need to pump */ + if (!cqv_host->qcnt || !cqv_host->enabled) { + spin_unlock_irqrestore(&cqv_host->lock, flags); + return; + } + + slot = &cqv_host->slot[cqv_host->next_tag]; + cqv_host->mrq = slot->mrq; + cqv_host->qcnt--; + + spin_unlock_irqrestore(&cqv_host->lock, flags); + + mmc->ops->request(mmc, cqv_host->mrq); +} + +static void cqhci_virt_update_next_tag(struct cqhci_host *cqv_host, int remains) +{ + struct cqhci_slot *slot; + int tag; + + /* + * If there are no remain requests in command queue, then set a invalid + * tag. + */ + if (!remains) { + cqv_host->next_tag = CQHCI_VIRT_INVALID_TAG; + return; + } + + /* + * Increasing the next tag and check if the corresponding request is + * available, if yes, then we found a candidate request. + */ + if (++cqv_host->next_tag != CQHCI_VIRT_INVALID_TAG) { + slot = &cqv_host->slot[cqv_host->next_tag]; + if (slot->mrq) + return; + } + + /* Othersie we should iterate all slots to find a available tag. */ + for (tag = 0; tag < CQHCI_VIRT_NUM_SLOTS; tag++) { + slot = &cqv_host->slot[tag]; + if (slot->mrq) + break; + } + + if (tag == CQHCI_VIRT_NUM_SLOTS) + tag = CQHCI_VIRT_INVALID_TAG; + + cqv_host->next_tag = tag; +} + +static void cqhci_virt_post_request(struct cqhci_host *cqv_host) +{ + unsigned long flags; + int remains; + + spin_lock_irqsave(&cqv_host->lock, flags); + + remains = cqv_host->qcnt; + cqv_host->mrq = NULL; + + /* Update the next available tag to be queued. */ + cqhci_virt_update_next_tag(cqv_host, remains); + + if (cqv_host->waiting_for_idle && !remains) { + cqv_host->waiting_for_idle = false; + wake_up(&cqv_host->wait_queue); + } + + /* Do not pump new request in recovery mode. */ + if (cqv_host->recovery_halt) { + spin_unlock_irqrestore(&cqv_host->lock, flags); + return; + } + + spin_unlock_irqrestore(&cqv_host->lock, flags); + + /* + * Try to pump new request to host controller as fast as possible, + * after completing previous request. + */ + if (remains > 0) + cqhci_virt_pump_requests(cqv_host); +} + +/** + * cqhci_virt_finalize_request - finalize one request if the request is done + * @mmc: the host controller + * @mrq: the request need to be finalized + * + * Return true if we finalized the corresponding request in command queue, + * otherwise return false. + */ +bool cqhci_virt_finalize_request(struct mmc_host *mmc, struct mmc_request *mrq) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + unsigned long flags; + + spin_lock_irqsave(&cqv_host->lock, flags); + + if (!cqv_host->enabled || !cqv_host->mrq || cqv_host->mrq != mrq) { + spin_unlock_irqrestore(&cqv_host->lock, flags); + return false; + } + + /* + * Clear current completed slot request to make a room for new request. + */ + cqv_host->slot[cqv_host->next_tag].mrq = NULL; + + spin_unlock_irqrestore(&cqv_host->lock, flags); + + mmc_cqe_request_done(mmc, cqv_host->mrq); + + cqhci_virt_post_request(cqv_host); + + return true; +} +EXPORT_SYMBOL_GPL(cqhci_virt_finalize_request); + +static void cqhci_virt_recovery_start(struct mmc_host *mmc) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + unsigned long flags; + + spin_lock_irqsave(&cqv_host->lock, flags); + + cqv_host->recovery_halt = true; + + spin_unlock_irqrestore(&cqv_host->lock, flags); +} + +static void cqhci_virt_recovery_finish(struct mmc_host *mmc) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + int remains; + + spin_lock_irq(&cqv_host->lock); + + cqv_host->recovery_halt = false; + remains = cqv_host->qcnt; + + spin_unlock_irq(&cqv_host->lock); + + /* + * Try to pump new request if there are request pending in command queue + * after finishing recovery. + */ + if (remains > 0) + cqhci_virt_pump_requests(cqv_host); +} + +static int cqhci_virt_request(struct mmc_host *mmc, struct mmc_request *mrq) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + int tag = mrq->tag; + + spin_lock_irq(&cqv_host->lock); + + if (!cqv_host->enabled) { + spin_unlock_irq(&cqv_host->lock); + return -ESHUTDOWN; + } + + /* Do not queue any new requests in recovery mode. */ + if (cqv_host->recovery_halt) { + spin_unlock_irq(&cqv_host->lock); + return -EBUSY; + } + + cqv_host->slot[tag].mrq = mrq; + + /* + * Set the next tag as current request tag if no available + * next tag. + */ + if (cqv_host->next_tag == CQHCI_VIRT_INVALID_TAG) + cqv_host->next_tag = tag; + + cqv_host->qcnt++; + + spin_unlock_irq(&cqv_host->lock); + + cqhci_virt_pump_requests(cqv_host); + + return 0; +} + +static void cqhci_virt_post_req(struct mmc_host *mmc, struct mmc_request *mrq) +{ + if (mmc->ops->post_req) + mmc->ops->post_req(mmc, mrq, 0); +} + +static bool cqhci_virt_queue_is_idle(struct cqhci_host *cqv_host, int *ret) +{ + bool is_idle; + + spin_lock_irq(&cqv_host->lock); + + is_idle = (!cqv_host->mrq && !cqv_host->qcnt) || + cqv_host->recovery_halt; + + *ret = cqv_host->recovery_halt ? -EBUSY : 0; + cqv_host->waiting_for_idle = !is_idle; + + spin_unlock_irq(&cqv_host->lock); + + return is_idle; +} + +static int cqhci_virt_wait_for_idle(struct mmc_host *mmc) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + int ret; + + wait_event(cqv_host->wait_queue, + cqhci_virt_queue_is_idle(cqv_host, &ret)); + + return ret; +} + +static void cqhci_virt_disable(struct mmc_host *mmc) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + u32 timeout = 500; + int ret; + + spin_lock_irq(&cqv_host->lock); + + if (!cqv_host->enabled) { + spin_unlock_irq(&cqv_host->lock); + return; + } + + spin_unlock_irq(&cqv_host->lock); + + ret = wait_event_timeout(cqv_host->wait_queue, + cqhci_virt_queue_is_idle(cqv_host, &ret), + msecs_to_jiffies(timeout)); + if (ret == 0) { + pr_warn("could not stop mmc virtual command queue\n"); + return; + } + + spin_lock_irq(&cqv_host->lock); + + cqv_host->enabled = false; + + spin_unlock_irq(&cqv_host->lock); +} + +static int cqhci_virt_enable(struct mmc_host *mmc, struct mmc_card *card) +{ + struct cqhci_host *cqv_host = mmc->cqe_private; + + spin_lock_irq(&cqv_host->lock); + + if (cqv_host->enabled) { + spin_unlock_irq(&cqv_host->lock); + return -EBUSY; + } + + cqv_host->enabled = true; + + spin_unlock_irq(&cqv_host->lock); + + return 0; +} + +static const struct mmc_cqe_ops cqhci_virt_ops = { + .cqe_enable = cqhci_virt_enable, + .cqe_disable = cqhci_virt_disable, + .cqe_request = cqhci_virt_request, + .cqe_post_req = cqhci_virt_post_req, + .cqe_wait_for_idle = cqhci_virt_wait_for_idle, + .cqe_recovery_start = cqhci_virt_recovery_start, + .cqe_recovery_finish = cqhci_virt_recovery_finish, +}; + +int cqhci_virt_init(struct cqhci_host *cqv_host, struct mmc_host *mmc) +{ + cqv_host->num_slots = CQHCI_VIRT_NUM_SLOTS; + cqv_host->next_tag = CQHCI_VIRT_INVALID_TAG; + mmc->cqe_qdepth = CQHCI_VIRT_NUM_SLOTS; + + cqv_host->slot = devm_kcalloc(mmc_dev(mmc), cqv_host->num_slots, + sizeof(struct cqhci_slot), GFP_KERNEL); + if (!cqv_host->slot) + return -ENOMEM; + + cqv_host->mmc = mmc; + cqv_host->mmc->cqe_private = cqv_host; + mmc->cqe_ops = &cqhci_virt_ops; + + spin_lock_init(&cqv_host->lock); + init_waitqueue_head(&cqv_host->wait_queue); + + pr_info("%s: Enable virtual command queue\n", mmc_hostname(mmc)); + + return 0; +} +EXPORT_SYMBOL_GPL(cqhci_virt_init); + +void cqhci_virt_suspend(struct mmc_host *mmc) +{ + cqhci_virt_disable(mmc); +} +EXPORT_SYMBOL_GPL(cqhci_virt_suspend); + +int cqhci_virt_resume(struct mmc_host *mmc) +{ + return cqhci_virt_enable(mmc, NULL); +} +EXPORT_SYMBOL_GPL(cqhci_virt_resume); diff --git a/drivers/mmc/host/cqhci.h b/drivers/mmc/host/cqhci.h index 7b07bf24f..cd8e1a8 100644 --- a/drivers/mmc/host/cqhci.h +++ b/drivers/mmc/host/cqhci.h @@ -205,6 +205,10 @@ struct cqhci_host { struct completion halt_comp; wait_queue_head_t wait_queue; struct cqhci_slot *slot; + + /* virtual command queue support */ + int next_tag; + struct mmc_request *mrq; }; struct cqhci_host_ops { @@ -242,4 +246,34 @@ irqreturn_t cqhci_irq(struct mmc_host *mmc, u32 intmask, int cmd_error, int cqhci_suspend(struct mmc_host *mmc); int cqhci_resume(struct mmc_host *mmc); +#ifdef CONFIG_MMC_VIRTUAL_CQHCI +int cqhci_virt_init(struct cqhci_host *cqv_host, struct mmc_host *mmc); +void cqhci_virt_suspend(struct mmc_host *mmc); +int cqhci_virt_resume(struct mmc_host *mmc); +bool cqhci_virt_finalize_request(struct mmc_host *mmc, struct mmc_request *mrq); +#else +static inline int cqhci_virt_init(struct cqhci_host *cqv_host, + struct mmc_host *mmc) +{ + return 0; +} + +static inline void cqhci_virt_suspend(struct mmc_host *mmc) +{ + +} + +static inline int cqhci_virt_resume(struct mmc_host *mmc) +{ + return 0; +} + +static inline bool cqhci_virt_finalize_request(struct mmc_host *mmc, + struct mmc_request *mrq) +{ + return false; +} + +#endif + #endif diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index d8115db7..26213fd 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -458,6 +458,7 @@ struct mmc_host { int cqe_qdepth; bool cqe_enabled; bool cqe_on; + bool virt_cqe; unsigned long private[0] ____cacheline_aligned; }; From patchwork Fri Sep 6 03:52:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 173191 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp180042ilq; Thu, 5 Sep 2019 20:52:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyngrP/6GkbL3x70gkjlDo0id9h+RFSzLQALQcj7IwWbkvtNdBoOV4vpBdr27OfavnfVkDN X-Received: by 2002:a62:834c:: with SMTP id h73mr8326747pfe.183.1567741977311; Thu, 05 Sep 2019 20:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567741977; cv=none; d=google.com; s=arc-20160816; b=pZblFsb5XCa4Vti7gBqa92uD/aVd8lMbeK1I7nU7eKCtk8VZY03yEiBrDAqDOi+/Ky I3/kJVaccluxiP/tTT8GmZ6aBLaNO6RnrOZ3j+cidwiPz11uHlO7xKcLfvQ6izNQ+Dvi kjl0pSSXIi6gaPJjURCRfstUWAYSLR5xpmvkqNDAokJlIulNkHTSq0VkJAdMcR8zlm9V 0WOgBLdD/eP3IAya/l2CuB0uuK4NAHc9UPXbz4VXTMLAYgKWqqc6Z8AJlSNNtth8n+hI ObSm+J7pNCTFKTAXnLzwDE0kauRY0QTijYXXJwa3dtLZDPAq9s7uY1FwiK0DGlVrx0AO zmHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=EBpVgRZKtjnDtjrwrB9mrGRM/gKC++RB5oNke1k5+K0=; b=hrrwBPfSWS/Xqya40nVVBG8SAl5TelPjtznXgX/2jdS65+8gCamtmzItD29hMz/t+K fFW1JBWDOLyN7Q6JOQOtJlKgxCA7YqkqDMbVW3MPOCsKfzVHpzVRJE+E7KZQr3kHnxQ0 RMD1tg/A6ueOF/6hDcDIySK4DpDEikpynmwKR5k8OYf0LrRMWNNVifJK+RRO/AbSaKFv NPZharWHrUi2q3q1VSINLr2uaK8d0CsOzYy8DPBWNkbKr/o4Loj3eUyYsnsSnXKRMtc3 u9EabFRXtDDZJ4bdqlvZLcwgEbzFpQlspxNzXWDHqvuHprQu3RO5HwA/Wsy4SmwFX16K VzOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WlFs3zRf; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k190si3359438pge.308.2019.09.05.20.52.57; Thu, 05 Sep 2019 20:52:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=WlFs3zRf; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392215AbfIFDwz (ORCPT + 5 others); Thu, 5 Sep 2019 23:52:55 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45312 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392213AbfIFDwy (ORCPT ); Thu, 5 Sep 2019 23:52:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id y72so3369600pfb.12 for ; Thu, 05 Sep 2019 20:52: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 :in-reply-to:references; bh=EBpVgRZKtjnDtjrwrB9mrGRM/gKC++RB5oNke1k5+K0=; b=WlFs3zRfTQzKlu/iTvwfrRb3LuO9bpKb7bMRAP3fFRCTTBU+Kpu/QJmmZ2wV7wARkt ikgPokG0OUliflF0l2MBe+3TRb/midzsick+m+wP93enWtA/Ol0+RdyoH7u/3oT8rTJs WOhrOW+CZAKbT1i2Xx8LF1n4RbR12BrxQ/OPXBxqyHPEzukJPwXycPHN1FjkKTEqiFQE l4nuN02Ats9HX8x21emOXHkoOmAlhjwdKErjdpHYQl1M5rJrbt9i2IYm+vkzx51s1/N1 BO3QYiec+jkUxUM9/7YGWrHy9s0t1H6YSs0T7lerdoPRUpjp7JD4Wmo+wP6LIlZIyqYL 76Xw== 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:in-reply-to:references; bh=EBpVgRZKtjnDtjrwrB9mrGRM/gKC++RB5oNke1k5+K0=; b=dPj5YdfqNOyME7joqQneaM6uxNcPkkLKuDzSY386Hg9OZEUBg8KiUNrrYUi/Mb+cbS BA16C2ezrsUmxTT+NFDYajD2TXrxnQuFvmxBuXPk0b+pjfdELvdKFwQhBmjpaYwurv1r s/hvyqxS9td/E3CB6iCoRo3LWzb2WCwDBKrOKe2JV2U9HNh6JyIhxPmbH/KkT99xGFdJ TQob7cmDUvn5qagR25xCENb+lbnEBHiKwwlgCr+7RG6z05Q6r1iPHNkZcB19NkF7Pa9d HxAzjtquQPpfFSV+LYvZ2t08JPkyqGPRNzLlVpGQj21kH3Vb2srKvUIbHMIT10oMJd3Q l1+A== X-Gm-Message-State: APjAAAWkCb2MaNpevlvOfvqpPLGefGA1fwSSZFJdcK2XfCVvK4AVrQ7t y9Imjo/W54zravCWplhm/XCPzw== X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr7339960pjz.140.1567741973694; Thu, 05 Sep 2019 20:52:53 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j7sm4205770pfi.96.2019.09.05.20.52.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 20:52:53 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, riteshh@codeaurora.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mmc: host: sdhci-sprd: Add virtual command queue support Date: Fri, 6 Sep 2019 11:52:01 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add virtual command queue support. Signed-off-by: Baolin Wang --- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-sprd.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) -- 1.7.9.5 diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index e2a12c3..851e947 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -619,6 +619,7 @@ config MMC_SDHCI_SPRD depends on ARCH_SPRD depends on MMC_SDHCI_PLTFM select MMC_SDHCI_IO_ACCESSORS + select MMC_VIRTUAL_CQHCI help This selects the SDIO Host Controller in Spreadtrum SoCs, this driver supports R11(IP version: R11P0). diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index 19a2104..ff4886a3 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -19,6 +19,7 @@ #include #include "sdhci-pltfm.h" +#include "cqhci.h" /* SDHCI_ARGUMENT2 register high 16bit */ #define SDHCI_SPRD_ARG2_STUFF GENMASK(31, 16) @@ -515,6 +516,7 @@ static int sdhci_sprd_probe(struct platform_device *pdev) { struct sdhci_host *host; struct sdhci_sprd_host *sprd_host; + struct cqhci_host *cqv_host; struct clk *clk; int ret = 0; @@ -625,6 +627,17 @@ static int sdhci_sprd_probe(struct platform_device *pdev) sprd_host->flags = host->flags; + cqv_host = devm_kzalloc(&pdev->dev, + sizeof(*cqv_host), GFP_KERNEL); + if (!cqv_host) { + ret = -ENOMEM; + goto err_cleanup_host; + } + + ret = cqhci_virt_init(cqv_host, host->mmc); + if (ret) + goto err_cleanup_host; + ret = __sdhci_add_host(host); if (ret) goto err_cleanup_host; @@ -685,6 +698,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); + cqhci_virt_suspend(host->mmc); sdhci_runtime_suspend_host(host); clk_disable_unprepare(sprd_host->clk_sdio); @@ -713,6 +727,8 @@ static int sdhci_sprd_runtime_resume(struct device *dev) goto clk_disable; sdhci_runtime_resume_host(host, 1); + cqhci_virt_resume(host->mmc); + return 0; clk_disable: From patchwork Fri Sep 6 03:52:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 173192 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp180107ilq; Thu, 5 Sep 2019 20:53:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1u23spAikMxuR7pBnvdxuSHaVOuOgq6xEYxCPe68vaKB7iEaH0V4c6IOa4imQN271YeUc X-Received: by 2002:a65:610a:: with SMTP id z10mr6281686pgu.178.1567741981965; Thu, 05 Sep 2019 20:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567741981; cv=none; d=google.com; s=arc-20160816; b=tDt8rzXqyASUPz9nCLBCEEzZXjhf+uuJTZIJA6IDBbhXRb5o0kwaAaUzNXkyZqwnej v3EPJT5PqumYA6+6ozXt6vACx+DntbZTq/b/M1FbNT/A5oigjaxCjVzXVmX0Mnd6+R0Z KU7Z5+58cOHvD+YxwCOaFhoGbr3NXAlx0pgdokD8S0If1mMV4KvDwJr93hvq3wAhczJK J3lVp14BsOYNAH9MVigg0t3iXER0g/edMs8RCZXK+X4uW7tTkt+dF83NJgHFntXai4JH nBCX8HPBva3jqE4+++iiZpjxp0FpXe1/URk8KjXGN1PVADxTCZZaBvOJvrdzhjw1JqxH V6aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=+Qa6FN4bybUWpL4Kw6U5VKtqicdkV7LDgiUgYM+LUYg=; b=jzRYha2b3yvGZNAzdSU9VIrEI7/AAKFZwMQJLxqFF+jEt52F7DLxAcFSMHnsjf2Ya4 buK2LpCPMFcSwfNQJtXJUWoGnTsuzKu7koaE8kS/dFTwD7WrBMk+Ow/izw7ZKU4AB4CW ztdzEQwQoXe2ySJUIIqioUhpleGSBEqDR14OxkCuB2ePgWnOljO20wRMjMz6G9tvQJl/ wHF0DOquM//o1zYCpOxvKvynsE3obXH061ZFfS4EIxrassCdUNyLADGXI9tKJ4J6yMc4 yz65XXA+U9vBkJpl57jdCP8eRuUNcAfliU9DJPQgf+SERLxJHC7W6Tld58rL6t2EmEbq vsFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uxSBN916; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k190si3359438pge.308.2019.09.05.20.53.01; Thu, 05 Sep 2019 20:53:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=uxSBN916; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404473AbfIFDw7 (ORCPT + 5 others); Thu, 5 Sep 2019 23:52:59 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42827 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404469AbfIFDw6 (ORCPT ); Thu, 5 Sep 2019 23:52:58 -0400 Received: by mail-pg1-f196.google.com with SMTP id p3so2671128pgb.9 for ; Thu, 05 Sep 2019 20:52:58 -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 :in-reply-to:references; bh=+Qa6FN4bybUWpL4Kw6U5VKtqicdkV7LDgiUgYM+LUYg=; b=uxSBN916hJwbA+vDDyLagwrLfwSaXLXvaXvT7/GTQRAnzOsCH+WDXs7QncMqgzLmyF y27gY2CoyiyQUPwpQGgqGY7xxPWrlVRjXUHMiTVZIVaFCFgroupu/GPS5I9tho3uYkVu YZnGJ1zDf3f2JB4R8y5x3qpb5Ych0HA5/0wGnDtMqlHI2Zi/It8lL+pKtNubEnu5BMId NDZh9X9bJctDYxCIRQIFR9QDuLO+3outSSYq4rk0LROg2ALEJ/zbABXB6DRIxE2S07tx Z2Bntybcl/W7gKM4knG+5bCVyOZ8yt4pODOwEfBvb9y0MB+8LqFcucZ3iK1w+Vzhknt7 v/vw== 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:in-reply-to:references; bh=+Qa6FN4bybUWpL4Kw6U5VKtqicdkV7LDgiUgYM+LUYg=; b=VnHX8VtSLMh5rgyrRTpymnT7rwjt7NpnrlVB29w7jgq/mFAYDABOvebPZ/bsoMP9uU oEsEKxk9+FvFqZbRxL7BVS+qo0eDVZwRRj91lns4hPGa86mJKsL/Wv6U7NvTj3VW14H3 seMyNx7Lk+AryyfQq9cwVPjQsO6pzSwhL98pf5ULzOUON4xwyAzeDxqB7egPYst+MKcg u/EURqRe0r60b9Z0makcXBbEqD+7JJcyLc8tMe36WXVJVdOeytQzTU7j6Hqg8Db5Y2gq Y/6Nbagh+LMvkfZrzGeA/q+qh7acHyMXkUKr7JhO+qpCtKap0/3WY+XeTF1rTl/DTv18 3QUQ== X-Gm-Message-State: APjAAAWthpS7qKu+4rJJ2vdHBYYBMpFzmEEkK8+rRuySJpXoag3D6U8J EDmoun/y33K2ipe5hGNk4CB+1w== X-Received: by 2002:a63:4522:: with SMTP id s34mr6154076pga.362.1567741977816; Thu, 05 Sep 2019 20:52:57 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j7sm4205770pfi.96.2019.09.05.20.52.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 20:52:57 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, riteshh@codeaurora.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mmc: host: sdhci: Add virtual command queue support Date: Fri, 6 Sep 2019 11:52:02 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add cqhci_virt_finalize_request() to help to complete a request from virtual command queue. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4e9ebc8..fb5983e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -32,6 +32,7 @@ #include #include "sdhci.h" +#include "cqhci.h" #define DRIVER_NAME "sdhci" @@ -2710,7 +2711,8 @@ static bool sdhci_request_done(struct sdhci_host *host) spin_unlock_irqrestore(&host->lock, flags); - mmc_request_done(host->mmc, mrq); + if (!cqhci_virt_finalize_request(host->mmc, mrq)) + mmc_request_done(host->mmc, mrq); return false; } @@ -3133,7 +3135,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) /* Process mrqs ready for immediate completion */ for (i = 0; i < SDHCI_MAX_MRQS; i++) { - if (mrqs_done[i]) + if (mrqs_done[i] && + !cqhci_virt_finalize_request(host->mmc, mrqs_done[i])) mmc_request_done(host->mmc, mrqs_done[i]); }