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 */