From patchwork Thu May 11 12:39:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 99639 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp708972qge; Thu, 11 May 2017 05:39:07 -0700 (PDT) X-Received: by 10.28.216.85 with SMTP id p82mr726504wmg.91.1494506347589; Thu, 11 May 2017 05:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494506347; cv=none; d=google.com; s=arc-20160816; b=Nh+tcKD6HNk630U58GL+3deNC4JsICuH4AsT27sOgsfPGOwZxSm6GyWx+rDCWtp0lm DfBl5zBSAKV31ckGLtGXfvK0RxmBhnpapiK+15z9BGLwScN9XQDNyU0U/QX9aWpalr1/ WTrHGxY9ung2Ga2XjOVPpWoaKWhjIN6Mqg3dDurIBCF4tzspU2wJsYBKm1M6+EsbJhi4 mkRbf727UATC3YO6echvZ47mJJox70M4jwWR9Ei/UBhhvpouuH7cPWvthjwa49ySxgZ3 NFq/XJUlLyjU98f2W9NeTnuUsCfazmAQmXBj+gHeK96QTo9PTpwIWytnYMjl3qDE/w3W M9mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=zkIisz2tZpoFASbESPqFCPM3gTo3CNsg17xHRg84wY4=; b=sZqNxIQKqKOGSWisHiT9e4lNLkkIPkHiaO9Co3DNlJHArxrlJ1XQdm8c6wUFJ2Hl99 uDrbfugLjcNeIWxGuJN/zzp7To7dcMnxIijZmHk+sKkduiszF1DJo11V+fcyiANa+u9B u+QwznzPK20NNOHRrLioIhehZqjutq/AdykwJksDxL8C04PtnWlAjGGFThB6zYPTOnYs a4r3orXyaRFrfhKpmrsvJilpiTCVkpJp6ExfF5ue7vqnCrGqr9DfRlRd2tid7A6poIYK 6035yDKJxazg2pJwibt4JQFDYSkKlAXN13svpBlBwIa1syIwKs4U9OwpOx5CvdW983AK yrvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::233 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com. [2a00:1450:400c:c0c::233]) by mx.google.com with ESMTPS id z57si50929wrz.83.2017.05.11.05.39.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 05:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::233 as permitted sender) client-ip=2a00:1450:400c:c0c::233; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::233 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x233.google.com with SMTP id l9so19527172wre.1 for ; Thu, 11 May 2017 05:39:07 -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; bh=zkIisz2tZpoFASbESPqFCPM3gTo3CNsg17xHRg84wY4=; b=dbNPTAYIN1c/MZvXBK74lJ3xOY5cnwLc89MIkrz+ySYe7R6CIAShkew+oyrA5PHgyn Csw1hDHDrtKBsiW/YfvK7TWpfCb1/NGW3C733+vT9+3wtb5VPMZmOFNAn0mfzBmn5m7d 7fuGWvatM3znIT/vf3B0uJ+bcyXPvNWYrxM24= 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=zkIisz2tZpoFASbESPqFCPM3gTo3CNsg17xHRg84wY4=; b=ctcYYYW7uGBNWbJHxyy/ApGPwcsRo8QGzgsjFCy+rNf9Ff2Vaw8Hq6DuEqWVVLGdJ+ QeQiFHiiytxdoy0lEqlvctYB06SrmPqmRDAMh5wtw7oCLYwaoiPcjypt7M8IKeBVGCHE IZD+jZ8la5nZBQ1unoUYkjoDQSBdO70nXid2oxBSlwLAoKxHAzAIV/fYwaXEH9IyhSm7 iFrvbEdJtLMtAyWGFUOicl4Y4yLW2bOjl6b8722P+gbvAgMu92bHVkzJtDclgu9TzDKT PhRLfhdzFEZE13biPcjwyTyD0REOjxMWSkAtPoYSdxdN6W6u0Avq3dM1zx35WmLwMtaL Ytug== X-Gm-Message-State: AODbwcCgzR182ayq17NKhyi5POLTanGykPd3VOlKZUFzBvbEX28HTfjZ udrN16s3KF7ZbqbTIOo= X-Received: by 10.46.81.17 with SMTP id f17mr40451ljb.96.1494506347223; Thu, 11 May 2017 05:39:07 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id h13sm13935ljh.5.2017.05.11.05.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 May 2017 05:39:06 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jens Axboe , Paolo Valente , linux-block@vger.kernel.org, Linus Walleij , Mark Brown , Adrian Hunter Subject: [RFC PATCH 1/3] mmc: sdio: Don't use abort-able claim host method from SDIO IRQ thread Date: Thu, 11 May 2017 14:39:00 +0200 Message-Id: <1494506343-28572-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> References: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> In a step to simplify the use of the lock, mmc_claim|release_host(), let's change the SDIO IRQ thread to move away from using the abort-able claim host method. In the SDIO IRQ thread case, we can instead check the numbers of SDIO IRQs that are currently claimed via host->sdio_irqs, as this field is protected from updates unless the host is claimed. When host->sdio_irqs has become zero, it means the SDIO func driver(s) has released the SDIO IRQ, then we can bail out and stop running the SDIO IRQ thread. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio_irq.c | 10 ++++++---- include/linux/mmc/host.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 6d4b720..95f7a09 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -137,9 +137,13 @@ static int sdio_irq_thread(void *_host) * holding of the host lock does not cover too much work * that doesn't require that lock to be held. */ - ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort); - if (ret) + mmc_claim_host(host); + if (!host->sdio_irqs) { + ret = 1; + mmc_release_host(host); break; + } + ret = process_sdio_pending_irqs(host); host->sdio_irq_pending = false; mmc_release_host(host); @@ -195,7 +199,6 @@ static int sdio_card_irq_get(struct mmc_card *card) if (!host->sdio_irqs++) { if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) { - atomic_set(&host->sdio_irq_thread_abort, 0); host->sdio_irq_thread = kthread_run(sdio_irq_thread, host, "ksdioirqd/%s", mmc_hostname(host)); @@ -223,7 +226,6 @@ static int sdio_card_irq_put(struct mmc_card *card) if (!--host->sdio_irqs) { if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) { - atomic_set(&host->sdio_irq_thread_abort, 1); kthread_stop(host->sdio_irq_thread); } else if (host->caps & MMC_CAP_SDIO_IRQ) { host->ops->enable_sdio_irq(host, 0); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 21385ac..8a4131f 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -359,7 +359,6 @@ struct mmc_host { unsigned int sdio_irqs; struct task_struct *sdio_irq_thread; bool sdio_irq_pending; - atomic_t sdio_irq_thread_abort; mmc_pm_flag_t pm_flags; /* requested pm features */ From patchwork Thu May 11 12:39:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 99640 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp708978qge; Thu, 11 May 2017 05:39:08 -0700 (PDT) X-Received: by 10.28.29.205 with SMTP id d196mr4909130wmd.30.1494506348683; Thu, 11 May 2017 05:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494506348; cv=none; d=google.com; s=arc-20160816; b=sx1wAHAFdPghlghlrIOAYxQQcnf6hvHfzQ+3Y89QLoOz8b4edxj1J389IoyI5zzaXe dUcMcqoMjuc6bk9SRsjCkEp89idJVwiXDqwlK+o+t34PEqKrCUihs0jJG+PysMklyFPK YmBok8OP3TuRQ6pFQwgMkcTlqowQzYLWqjgAhrVk2Pm7cGCN+3xuZ2a823/MhCabEtAi r5zDtXqQf34xEu4BhxCtJiBF3+Lnw1IXYl++MMmBElnau0tOpj31Bkz2P8HTWUIu9s+c JiW+E7vHRvmSMOIKBa2MhMrb/H1YDquDSdSaR38Zs/5JhkljaaUTrHT6XIeSQVMIvCZu HP/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=6Z+X5DV4GGgVpcea4LF0/4EAHFhaXZ0ONLEJGWGi1VI=; b=SzGCbaDca/nMcL5R+GGy3brNEgDhogblpnMyGNbhUoCMf2u6WjexeSXQDMF+Ufsa2t dYvhE+Fks3gFzR5m9sH26BaZpP4pgOT6shrZZNPySlbztzFRVRal82mzVMihkLveWQm/ 6fVtFCk1YXDnebNAS912xonRJKiQLGav91DedXRjAMH4x36i+Dvi1Go/KJ/MlAuoTupo iaDNR1tUfuB9oWB5CM4gRCMP6PZHduxIpOrhRwQzv+uMO3UHuNq2NWzt5Hzi5Qm/wlhq Zs+k8y4U7tCW0eGMm4VHrSy9umTArAV954n3BggciYW2Y0AGOBnpkbLG4Bh7BPkYF/fN MtbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com. [2a00:1450:400c:c0c::22a]) by mx.google.com with ESMTPS id i8si54544wrb.99.2017.05.11.05.39.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 05:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22a as permitted sender) client-ip=2a00:1450:400c:c0c::22a; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22a as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x22a.google.com with SMTP id l9so19527623wre.1 for ; Thu, 11 May 2017 05:39:08 -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; bh=6Z+X5DV4GGgVpcea4LF0/4EAHFhaXZ0ONLEJGWGi1VI=; b=JAgjfJr0n4WSVsy+IF+RpskwN2lilT/hHA2guvYK3snaFSoefEzHS60xZgsDBh2S6m 2PARDZhdOBVLIDSyzEvAikgb4axj1fcl07J1Z0WxfXTMOfGDz0gA9CyYTURP2ux2CCSl ETjmeZJQiiQJ+K94gp46CshMWMP5S54M62RHI= 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=6Z+X5DV4GGgVpcea4LF0/4EAHFhaXZ0ONLEJGWGi1VI=; b=G0YY2x4vbCHZ3u5TwE0IExlAlfO+pZOWCsmVaCnHDg2+eciXrjs2FtuLTAG0ncxgOo LS1iOlyY68uW9+U8ASKk0o8lIjsj0WhQNlRScI/1d+PrHUbrlseLhcWOeggOjFRAupLa TjrxCX1On9OF4q3CYTWdVDt1vxSNDkj8xychsbA5TpgD+yuq39MSxYLeq5NMiz1A2tjb T2rkj61V063HLmqkkHIPtlIHV5OtKVXF773FA1JvUlmbPuiXvjq+qSUH/xqyElJo7OGz HyKV0edTY5ZeOTJ3rCN3E7LooGBY2qXtheoXFJrQeVtnCFLcP5BMbhhMkIsqWsMJSFO4 pvvg== X-Gm-Message-State: AODbwcC46bAL8xKmvlKUCxe+9BYNQFfToLdwHMLTrPb/P2/s6lo12cgZ LXFMXx+rvzrRS2N/i+4= X-Received: by 10.46.14.9 with SMTP id 9mr35545ljo.27.1494506348285; Thu, 11 May 2017 05:39:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id h13sm13935ljh.5.2017.05.11.05.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 May 2017 05:39:07 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jens Axboe , Paolo Valente , linux-block@vger.kernel.org, Linus Walleij , Mark Brown , Adrian Hunter Subject: [RFC PATCH 2/3] mmc: core: Remove redundant abort-able claim host API Date: Thu, 11 May 2017 14:39:01 +0200 Message-Id: <1494506343-28572-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> References: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> The only user of the abort-able claim host API was the SDIO IRQ thread, but as that use has now been removed, let's simplify the code and remove the API. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 31 ++++++++++--------------------- drivers/mmc/core/core.h | 13 +------------ 2 files changed, 11 insertions(+), 33 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 82c45dd..0701e30 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1019,20 +1019,15 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) EXPORT_SYMBOL(mmc_align_data_size); /** - * __mmc_claim_host - exclusively claim a host + * mmc_claim_host - exclusively claim a host * @host: mmc host to claim - * @abort: whether or not the operation should be aborted * - * Claim a host for a set of operations. If @abort is non null and - * dereference a non-zero value then this will return prematurely with - * that non-zero value without acquiring the lock. Returns zero - * with the lock held otherwise. + * Claim a host for a set of operations. */ -int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) +void mmc_claim_host(struct mmc_host *host) { DECLARE_WAITQUEUE(wait, current); unsigned long flags; - int stop; bool pm = false; might_sleep(); @@ -1041,31 +1036,25 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) spin_lock_irqsave(&host->lock, flags); while (1) { set_current_state(TASK_UNINTERRUPTIBLE); - stop = abort ? atomic_read(abort) : 0; - if (stop || !host->claimed || host->claimer == current) + if (!host->claimed || host->claimer == current) break; spin_unlock_irqrestore(&host->lock, flags); schedule(); spin_lock_irqsave(&host->lock, flags); } set_current_state(TASK_RUNNING); - if (!stop) { - host->claimed = 1; - host->claimer = current; - host->claim_cnt += 1; - if (host->claim_cnt == 1) - pm = true; - } else - wake_up(&host->wq); + host->claimed = 1; + host->claimer = current; + host->claim_cnt += 1; + if (host->claim_cnt == 1) + pm = true; spin_unlock_irqrestore(&host->lock, flags); remove_wait_queue(&host->wq, &wait); if (pm) pm_runtime_get_sync(mmc_dev(host)); - - return stop; } -EXPORT_SYMBOL(__mmc_claim_host); +EXPORT_SYMBOL(mmc_claim_host); /** * mmc_release_host - release a host diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 55f543f..b247b1f 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -122,20 +122,9 @@ int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen); int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, bool is_rel_write); -int __mmc_claim_host(struct mmc_host *host, atomic_t *abort); +void mmc_claim_host(struct mmc_host *host); void mmc_release_host(struct mmc_host *host); void mmc_get_card(struct mmc_card *card); void mmc_put_card(struct mmc_card *card); -/** - * mmc_claim_host - exclusively claim a host - * @host: mmc host to claim - * - * Claim a host for a set of operations. - */ -static inline void mmc_claim_host(struct mmc_host *host) -{ - __mmc_claim_host(host, NULL); -} - #endif From patchwork Thu May 11 12:39:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 99641 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp708983qge; Thu, 11 May 2017 05:39:09 -0700 (PDT) X-Received: by 10.28.103.3 with SMTP id b3mr720566wmc.5.1494506349764; Thu, 11 May 2017 05:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494506349; cv=none; d=google.com; s=arc-20160816; b=wcLu1fMNPkzcThrMk1Y+841xScMtKWD27iV3oULmED/oxFXwbBExM6602UPzsfmsFL bzju1iGE+7cpsVhTOwY7My+P8eeuSWAJG0c4v0SzHj335kmPB/8kyybNQVsukuSL48dD QtF+/GiNYfoMRWMmt+IOaltf2UTgR2629XmA33DlnEtGsHGbVA+b/LDQAEILAXpzLchD HiP5lRQd5ExGXZDCT1havhhna2S3xNXR8Qwfyl6JZ/wbh4/F1SEogHTlYzKIynbNWHzF 8VhRNV5j/4unLNg4YnvHM7TV4A9wCjIYdI5yAUUPkmnMRvaWSMcCyy01j30BiaOa4luE JEog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=4dPoyW1Q25bFcFdk/CwHC/dXRZb6eYQA9pRjDQsrLds=; b=trtsDT4F1En7ZomNoOL9Bwj30LcrvJsOzTI/LxfOkM3mRYtKT8RJjMQXYNfpR39tsd iJpOkBmkANHUccBTWVOSY50my64KV3uZQwn1Q+T/oWhTHcoj3t+GPpCvB2w9UtyTwkdq OE2vTTxfodigzGe3EL6TE4bBBOcTYHvRJFiY0avTIqDKksbZdbSkCiOqwyoh1IZah6iR bmnsimO8d19aUzFGAPcT2zTjzt2nfoPNVdGajnUhxk3oQnTkxT8III9b/S2YrxLFKvCx c09FQ1aJW7dBTICBFfFEi43MKTBXiwu54rwi2/ZUUhR1cNhJlfLp7wZLGt1olxsHCtyo t1Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-wr0-x22b.google.com (mail-wr0-x22b.google.com. [2a00:1450:400c:c0c::22b]) by mx.google.com with ESMTPS id 3si32648wrj.209.2017.05.11.05.39.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 05:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22b as permitted sender) client-ip=2a00:1450:400c:c0c::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x22b.google.com with SMTP id w50so19594557wrc.0 for ; Thu, 11 May 2017 05:39:09 -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; bh=4dPoyW1Q25bFcFdk/CwHC/dXRZb6eYQA9pRjDQsrLds=; b=GTZKcRjW4O5pcqM/GSNbJTN0QwvgS3vhtwlZLTWnUtEx2NQUjSPUd38y9TMqzPxHII grJQjOpgr0xrMsjp5n/6RjLs1/jVePMKM01vPXbMxV/CRKvm0/ECxbYvff0T5rO3Zpay x2Tmp5PgaLLahohKgVnLoKlYijsDDo47IOeIU= 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=4dPoyW1Q25bFcFdk/CwHC/dXRZb6eYQA9pRjDQsrLds=; b=la/w1hVx867t/1XzyLQvA03yaUVJi15QLZNUFMQ0/XsCwKQJFQFAXibVC7uIZyqce1 UyM7aK57CjUIGe1xo8kxqxIYXWraNiXNjJ5Q+GtvLzEMiwIA/h+34Wmb0xjEK7Naby6B Xh6/gtX20zWgJ+REya/Z4nz4LE6P07tF3Vfkwu345e8qzVtqb/B97EXXqXabf1XhutIp LklpiIQEkZZj6bRn830cqQ6x0EndwK2S9pAkgfEnX0VgTwHH/23LUc8ZfeAC0NUDnb8a k23pj96WG2p1gNTGqNWHVlMnOv2ziRYYM6F8RHWtsR7og30Fv98LnSwOnxwY0iH04nB/ ZdbQ== X-Gm-Message-State: AODbwcBCZUxRt8vuLzK31xVbgwVlJDgjNYoA2NChFr7dJvJEPbqOrMmr uy9Z6Cx+97ZY33JEgRQ= X-Received: by 10.46.33.146 with SMTP id h18mr43495lji.86.1494506349341; Thu, 11 May 2017 05:39:09 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id h13sm13935ljh.5.2017.05.11.05.39.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 May 2017 05:39:08 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jens Axboe , Paolo Valente , linux-block@vger.kernel.org, Linus Walleij , Mark Brown , Adrian Hunter Subject: [RFC PATCH 3/3] mmc: core: Allow mmc block device to re-claim the host Date: Thu, 11 May 2017 14:39:02 +0200 Message-Id: <1494506343-28572-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> References: <1494506343-28572-1-git-send-email-ulf.hansson@linaro.org> The current mmc block device implementation is tricky when it comes to claim and release of the host, while processing I/O requests. In principle we need to claim the host at the first request entering the queue and then we need to release the host, as soon as the queue becomes empty. This complexity relates to the asynchronous request mechanism that the mmc block device driver implements. For the legacy block interface that we currently implements, the above issue can be addressed, as we can find out when the queue really becomes empty. However, to find out whether the queue is empty, isn't really an applicable method when using the new blk-mq interface, as requests are instead pushed to us via the struct struct blk_mq_ops and its function pointers. Being able to support the asynchronous request method using the blk-mq interface, means we have to allow the mmc block device driver to re-claim the host from different tasks/contexts, as we may have > 1 request to operate upon. Therefore, let's extend the mmc_claim_host() API to support reference counting for the mmc block device. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 14 ++++++++++---- drivers/mmc/core/core.h | 7 ++++++- include/linux/mmc/host.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 0701e30..3633699 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1019,12 +1019,12 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) EXPORT_SYMBOL(mmc_align_data_size); /** - * mmc_claim_host - exclusively claim a host + * __mmc_claim_host - exclusively claim a host * @host: mmc host to claim * * Claim a host for a set of operations. */ -void mmc_claim_host(struct mmc_host *host) +void __mmc_claim_host(struct mmc_host *host, bool is_blkdev) { DECLARE_WAITQUEUE(wait, current); unsigned long flags; @@ -1036,7 +1036,11 @@ void mmc_claim_host(struct mmc_host *host) spin_lock_irqsave(&host->lock, flags); while (1) { set_current_state(TASK_UNINTERRUPTIBLE); - if (!host->claimed || host->claimer == current) + if (!host->claimed) + break; + if (host->claimer_is_blkdev && is_blkdev) + break; + if (host->claimer == current) break; spin_unlock_irqrestore(&host->lock, flags); schedule(); @@ -1045,6 +1049,7 @@ void mmc_claim_host(struct mmc_host *host) set_current_state(TASK_RUNNING); host->claimed = 1; host->claimer = current; + host->claimer_is_blkdev = is_blkdev; host->claim_cnt += 1; if (host->claim_cnt == 1) pm = true; @@ -1054,7 +1059,7 @@ void mmc_claim_host(struct mmc_host *host) if (pm) pm_runtime_get_sync(mmc_dev(host)); } -EXPORT_SYMBOL(mmc_claim_host); +EXPORT_SYMBOL(__mmc_claim_host); /** * mmc_release_host - release a host @@ -1076,6 +1081,7 @@ void mmc_release_host(struct mmc_host *host) } else { host->claimed = 0; host->claimer = NULL; + host->claimer_is_blkdev = 0; spin_unlock_irqrestore(&host->lock, flags); wake_up(&host->wq); pm_runtime_mark_last_busy(mmc_dev(host)); diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index b247b1f..1598a37 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -122,9 +122,14 @@ int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen); int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, bool is_rel_write); -void mmc_claim_host(struct mmc_host *host); +void __mmc_claim_host(struct mmc_host *host, bool is_blkdev); void mmc_release_host(struct mmc_host *host); void mmc_get_card(struct mmc_card *card); void mmc_put_card(struct mmc_card *card); +static inline void mmc_claim_host(struct mmc_host *host) +{ + __mmc_claim_host(host, 0); +} + #endif diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 8a4131f..7199817 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -347,6 +347,7 @@ struct mmc_host { wait_queue_head_t wq; struct task_struct *claimer; /* task that has host claimed */ + bool claimer_is_blkdev; /* claimer is blkdev */ int claim_cnt; /* "claim" nesting count */ struct delayed_work detect;