From patchwork Thu Feb 9 15:33:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9564971 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 BAB9360236 for ; Thu, 9 Feb 2017 15:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA18F2853A for ; Thu, 9 Feb 2017 15:41:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ECDB2853D; Thu, 9 Feb 2017 15:41:15 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 48FA12853A for ; Thu, 9 Feb 2017 15:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbdBIPlO (ORCPT ); Thu, 9 Feb 2017 10:41:14 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:36209 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbdBIPlO (ORCPT ); Thu, 9 Feb 2017 10:41:14 -0500 Received: by mail-lf0-f47.google.com with SMTP id z134so4612951lff.3 for ; Thu, 09 Feb 2017 07:41:13 -0800 (PST) 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=Mu/ARdi/IpU+hzF3TBvWTiggjuulaAkuB4VzBddZvoE=; b=NE0SCJI7mbFCa+DVwLZOy1KzL80Ih5bmRJQELqkycdP20FWaY9bcZBTE45CoCseEOd TFuK90ijwn6A8tV6RaK6YXFbBIJIMxPy2FdegGDQIrxQMiIXc4sjMOnlLFseB5u5Ya4I pwrQ3F3C+E7TP4AAsVFh4VYeuILxONx73C5VA= 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=Mu/ARdi/IpU+hzF3TBvWTiggjuulaAkuB4VzBddZvoE=; b=Yf13FRDZQxB4Fq1FrU6r3mIL7vehY1woyECQP3YEE3ZdXosnhnb+NOy4J/uzozEnIA GuMVSQRLc2BSQ/R2W4AZL/pWytfNUyOuKeSeZz5XxrawxSHhyGFzKNM1VGRDHL1MLTYW HjC/VUZaaym/DgxTXFmnFneqqQPwsvcs5U0a660TC3DioJbqkDzgquIFT3OpIT2IGjN6 iqt+p9V6iX7dlRl/Dr8NRlVXlS56pwTi8AmJ3J9d3Gf2CYPj3oCHzx/XcE0MhN43EAyz 8jsPJPTK3vfRf2oc1jgNZzzCEuIkEgNXfQ7eACUMQEDW6nZ6AyXXM6h7bEksZNFaeJ49 C9Lw== X-Gm-Message-State: AMke39maZls6by793XnaYiNOPi6Y8euBHMIKO2CRBOVcqgIfyWyqVChNakwgTY+rdVUkkW90 X-Received: by 10.25.65.15 with SMTP id o15mr1182943lfa.14.1486654492060; Thu, 09 Feb 2017 07:34:52 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e86sm3670614lji.32.2017.02.09.07.34.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 07:34:50 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Paolo Valente Cc: Chunyan Zhang , Baolin Wang , linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Linus Walleij Subject: [PATCH 05/16] mmc: core: add a kthread for completing requests Date: Thu, 9 Feb 2017 16:33:52 +0100 Message-Id: <20170209153403.9730-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170209153403.9730-1-linus.walleij@linaro.org> References: <20170209153403.9730-1-linus.walleij@linaro.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As we want to complete requests autonomously from feeding the host with new requests, we create a worker thread to deal with this specifically in response to the callback from a host driver. This patch just adds the worker, later patches will make use of it. Signed-off-by: Linus Walleij Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/host.c | 2 +- include/linux/mmc/host.h | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 0972c649ea7a..663799240635 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2794,6 +2794,10 @@ void mmc_start_host(struct mmc_host *host) host->f_init = max(freqs[0], host->f_min); host->rescan_disable = 0; host->ios.power_mode = MMC_POWER_UNDEFINED; + /* Worker for completing requests */ + host->req_done_worker_task = kthread_run(kthread_worker_fn, + &host->req_done_worker, + "mmc%d-reqdone", host->index); if (!(host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP)) { mmc_claim_host(host); @@ -2818,6 +2822,8 @@ void mmc_stop_host(struct mmc_host *host) host->rescan_disable = 1; cancel_delayed_work_sync(&host->detect); + kthread_flush_worker(&host->req_done_worker); + kthread_stop(host->req_done_worker_task); /* clear pm flags now and let card drivers set them as needed */ host->pm_flags = 0; diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 98f25ffb4258..d33e2b260bf3 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -388,7 +388,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) init_waitqueue_head(&host->wq); INIT_DELAYED_WORK(&host->detect, mmc_rescan); setup_timer(&host->retune_timer, mmc_retune_timer, (unsigned long)host); - + kthread_init_worker(&host->req_done_worker); /* * By default, hosts do not support SGIO or large requests. * They have to set these according to their abilities. diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 97699d55b2ae..b04f8cd51c82 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -375,6 +376,10 @@ struct mmc_host { struct mmc_async_req *areq; /* active async req */ struct mmc_context_info context_info; /* async synchronization info */ + /* finalization work thread, handles finalizing requests */ + struct kthread_worker req_done_worker; + struct task_struct *req_done_worker_task; + /* Ongoing data transfer that allows commands during transfer */ struct mmc_request *ongoing_mrq;