From patchwork Thu Sep 22 13:57:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 9345367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 19F52607D0 for ; Thu, 22 Sep 2016 14:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C1E728E65 for ; Thu, 22 Sep 2016 14:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA32B2A9F1; Thu, 22 Sep 2016 14:00:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06AC229A79 for ; Thu, 22 Sep 2016 14:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756571AbcIVOAT (ORCPT ); Thu, 22 Sep 2016 10:00:19 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:47771 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756413AbcIVN55 (ORCPT ); Thu, 22 Sep 2016 09:57:57 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ODW01CRVS4FTG10@mailout4.samsung.com>; Thu, 22 Sep 2016 22:57:56 +0900 (KST) X-AuditID: cbfee61b-f79876d000007369-03-57e3e363d52a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id D0.93.29545.363E3E75; Thu, 22 Sep 2016 06:57:56 -0700 (MST) Received: from AMDC1976.DIGITAL.local ([106.120.53.102]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ODW00IPYS3US950@mmp1.samsung.com>; Thu, 22 Sep 2016 22:57:55 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Linus Walleij Cc: Ulf Hansson , Greg KH , Paolo Valente , Jens Axboe , Hannes Reinecke , Tejun Heo , Omar Sandoval , Christoph Hellwig , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH PoC 4/7] mmc-mq: implement checking for queue busy condition Date: Thu, 22 Sep 2016 15:57:07 +0200 Message-id: <1474552630-28314-5-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1474552630-28314-1-git-send-email-b.zolnierkie@samsung.com> References: <1474552630-28314-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsVy+t9jAd2Ux4/DDXa9Z7X4v+cYm8XGGetZ LZoXr2ezWPBmL5vFytVHmSym/FnOZHF51xw2iyP/+xkt9hw5w2jx6s9eJotfy48yWhxfG+7A 4zGx+R27x6ZVnWwed67tYfPYP3cNu8fumw1sHnP+HGT26NuyitFj/ZarLB6fN8kFcEZx2aSk 5mSWpRbp2yVwZVw/tIul4J1wxe+fN5gbGDcLdDFyckgImEh03GllgrDFJC7cW8/WxcjFISSw lFHixou1jBDOL0aJR/++s4FUsQlYSUxsX8UIYosI6Eh0b/vJClLELPCRSWLvk/1gCWEBH4kJ ZzeD2SwCqhK3lr9m72Lk4OAV8JBoXJoOsU1O4uSxyawgYU4BT4nbO+1BwkJAFSf2L2OfwMi7 gJFhFaNEakFyQXFSeq5RXmq5XnFibnFpXrpecn7uJkZwyD6T3sF4eJf7IUYBDkYlHt4T5x6H C7EmlhVX5h5ilOBgVhLh1bwPFOJNSaysSi3Kjy8qzUktPsQozcGiJM77+P+6MCGB9MSS1OzU 1ILUIpgsEwenVANjwmNvxWdP5+abr76T0L6zdfOatkesj3jiVrwLWZH7dtVldi2H33E7TIxf FiZMPHTNSXli2frNFxR2scfqlmf9uDSpXcnv6uGGjKuM09hncJ/dULNce//M9SUy3mLaSWov 1108vJS7e6FXW6GBA4vaFpb6yymTBSVPb/d+NCc1YbJb8sxTzjcMlFiKMxINtZiLihMBmhRh 0FUCAAA= Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/mmc/card/queue.c | 28 +++++++++++++++++++++++----- drivers/mmc/card/queue.h | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 6fd711d..3ed4477 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -46,6 +46,21 @@ static int mmc_prep_request(struct request_queue *q, struct request *req) return BLKPREP_OK; } +int mmc_queue_ready(struct request_queue *q, struct mmc_queue *mq) +{ + unsigned int busy; + + busy = atomic_inc_return(&mq->device_busy) - 1; + + if (busy >= mq->qdepth) + goto out_dec; + + return 1; +out_dec: + atomic_dec(&mq->device_busy); + return 0; +} + struct mmc_queue_req *mmc_queue_req_find(struct mmc_queue *mq, struct request *req) { @@ -81,13 +96,14 @@ void mmc_queue_req_free(struct mmc_queue *mq, struct request *req; pr_info("%s: enter\n", __func__); req = mqrq->req; - spin_lock_irq(req->q->queue_lock); +//// spin_lock_irq(req->q->queue_lock); WARN_ON(!mqrq->req || mq->qcnt < 1 || !test_bit(mqrq->task_id, &mq->qslots)); mqrq->req = NULL; mq->qcnt -= 1; __clear_bit(mqrq->task_id, &mq->qslots); - spin_unlock_irq(req->q->queue_lock); +//// spin_unlock_irq(req->q->queue_lock); + atomic_dec(&mq->device_busy); pr_info("%s: exit\n", __func__); } @@ -114,9 +130,9 @@ repeat: req = blk_fetch_request(q); WARN_ON(req && req->cmd_type != REQ_TYPE_FS); if (req && req->cmd_type == REQ_TYPE_FS) { - mqrq_cur = mmc_queue_req_find(mq, req); - if (!mqrq_cur) { - pr_info("%s: command already queued (%d)\n", __func__, mq->qcnt); + if (mmc_queue_ready(q, mq)) { + } else { + pr_info("%s: command already queued\n", __func__); // WARN_ON(1); // spin_unlock_irq(q->queue_lock); blk_requeue_request(mq->queue, req); @@ -129,6 +145,8 @@ repeat: return; } spin_unlock_irq(q->queue_lock); + mqrq_cur = mmc_queue_req_find(mq, req); + BUG_ON(!mqrq_cur); mq->issue_fn(mq, req, mqrq_cur); spin_lock_irq(q->queue_lock); goto repeat; diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h index 3adf1bc..20399e4 100644 --- a/drivers/mmc/card/queue.h +++ b/drivers/mmc/card/queue.h @@ -61,6 +61,8 @@ struct mmc_queue { unsigned long qslots; int testtag; + + atomic_t device_busy; }; extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,