Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp281385pxf; Thu, 11 Mar 2021 03:53:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRW144EoHrdjr+jB6ZHRPvbjUzORpoBzSQnCbGoTY9KMOdXiQxCHJKWyK7Abi/gcO6X6oB X-Received: by 2002:a17:906:c099:: with SMTP id f25mr2736536ejz.141.1615463622432; Thu, 11 Mar 2021 03:53:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615463622; cv=none; d=google.com; s=arc-20160816; b=YiFrz8r+FvIIGXj0lv/BKgs1kxP1z4QJJ739EbWrG49onzpH9ihN5tPUpJJ/syTstl czYb/y8cgjHnGC3R9fB9kBME3KfmY8iNx/45K8l4tE0hBEhSvNmFTo3Q5N44eVE4CVCj ReryfOlXctAi5IcZU3zZYkqKYo4wtxfoCa5iNLHJzsjSZmERBiETsdzJbLnNvImRbcS3 i6STC5hjby1PU9NqxraRSMaeIGLlJCKl4gpPn7vl4OCHei7fFvb6vcZQTISl7vayl8qo OjXcoo69r1OAx+/VqoArAPADXXZ0EUS5upBT88lkzh9bb+dg2/NDGWU1LjCIaKuAJ/wl bVwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PFTIqFdLWWdY29/pRWKsrCjVVaUcvjydilTqihigIMs=; b=BLv5AYOQ3lOBwsO0xegyFQ90UINDlrYcgz3Ap8obc1rqTaNIA57LzFavBSjbBnlKli JkEh4G9IC+huMX7bAYc11wlCm64A6XbUKrXD06V3fj1rnW0dII7gkvpmEorQ8kwIAa6c +ItbMtLz3m5K8DUxBWrl1n51HjWXOWit2KYU2ghBBEvB7dRM3ZntoC/p7UB0tyPiBMVg UfeviblhTxIIVxMhVYRZqddeSBR4x/phNcnsjQQ32IB3qJLLWiB/yewBdZXyf0vJ4EXr 5LiH99gqM9AHQYKBvFbvOhFn8/QLVp/bZQA3RLzNOSTcbqs+CsA6vdM1Cvi4kLWvIBVV krmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cu4PSIOj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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. [23.128.96.18]) by mx.google.com with ESMTP id g7si1587950edh.31.2021.03.11.03.53.20; Thu, 11 Mar 2021 03:53:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cu4PSIOj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S232893AbhCKLuD (ORCPT + 99 others); Thu, 11 Mar 2021 06:50:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232757AbhCKLtj (ORCPT ); Thu, 11 Mar 2021 06:49:39 -0500 Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F8ADC061760 for ; Thu, 11 Mar 2021 03:49:39 -0800 (PST) Received: by mail-ua1-x931.google.com with SMTP id g7so508931uab.12 for ; Thu, 11 Mar 2021 03:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PFTIqFdLWWdY29/pRWKsrCjVVaUcvjydilTqihigIMs=; b=cu4PSIOj96NZbIS+1jrpPVRxPh9/bAfihyDQaoU03m758Y6gyvh6OMia8ws4vOZcMc M7Qhx87oZNkO35S7goR6IRdaiTw0/19mhWGN6uPE1o2Iu3gJHmqkImd22aPQMWErZepZ Ant7OZm5qaFM6K9Ma9hfyUHxXTtOU+vaGGt8vpppf3zH2oFjMHclSozE1aQF7yMwEYxE 2UXsFllf891X2O1C3xSRyFoAFNoIa4MY3eM5yFHnZlEycgare9N/5WQTgkZfUkGA5QB4 T2CpILr5SH5dgP6n+RdqCQBY2wRpHUjge3bMbG96M9sUigQmcn6ZWwLhYN/aJKpqDhb1 UNaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PFTIqFdLWWdY29/pRWKsrCjVVaUcvjydilTqihigIMs=; b=s4YkuQfcAcgQRMqGHhdYTIIYZENkMTIz7bD2uPlOP8PhiimGy/VG0cOEBICa2zHvVK m4T5ioSzCoITVWnQyS7CbVIcTdRb2ix5A/SHgH73IMnOnD4kD7ewjq8wF5iQ74xwmtyw 3FejMW/RrF4DVxG9GzRxcYamsSRInUZnAPFUjA9WhPmfgimbqzRZZ4XGiRWLdSoJo00y DloicWIeZX2Bs574yNoizkKAWXkB5lHP5wcOi9BQMWGiwf//FiUyYaItVekszmWKNFf0 FBX4rF97iYtS9wFEWa8PDHHBQSe4FUr68MH9EOl8PBeK1Dz9R/kblJsy3CfHNPklJOwc QfbA== X-Gm-Message-State: AOAM533xWEfh1wUKTfKhO/O4ELkWJ9pSdImYCsIyvvVv77HA7JYBxkl2 AJjftMvWDswkBLuUxU5W5SgahWf6om7oRHB88vD86w== X-Received: by 2002:ab0:6045:: with SMTP id o5mr4562650ual.100.1615463378649; Thu, 11 Mar 2021 03:49:38 -0800 (PST) MIME-Version: 1.0 References: <20210311174046.597d1951@xhacker.debian> In-Reply-To: <20210311174046.597d1951@xhacker.debian> From: Ulf Hansson Date: Thu, 11 Mar 2021 12:49:02 +0100 Message-ID: Subject: Re: [PATCH] mmc: sdhci: Use "mmc" directly rather than "host->mmc" To: Jisheng Zhang Cc: Adrian Hunter , linux-mmc , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Mar 2021 at 10:40, Jisheng Zhang wrote: > > Clean up the code to use the "mmc" directly instead of "host->mmc". > If the code sits in hot code path, this clean up also brings trvial > performance improvement. Take the sdhci_post_req() for example: > > before the patch: > ... > 8d0: a9be7bfd stp x29, x30, [sp, #-32]! > 8d4: 910003fd mov x29, sp > 8d8: f9000bf3 str x19, [sp, #16] > 8dc: f9400833 ldr x19, [x1, #16] > 8e0: b9404261 ldr w1, [x19, #64] > 8e4: 34000161 cbz w1, 910 > 8e8: f9424400 ldr x0, [x0, #1160] > 8ec: d2800004 mov x4, #0x0 // #0 > 8f0: b9401a61 ldr w1, [x19, #24] > 8f4: b9403262 ldr w2, [x19, #48] > 8f8: f9400000 ldr x0, [x0] > 8fc: f278003f tst x1, #0x100 > 900: f9401e61 ldr x1, [x19, #56] > 904: 1a9f17e3 cset w3, eq // eq = none > 908: 11000463 add w3, w3, #0x1 > 90c: 94000000 bl 0 > ... > > After the patch: > ... > 8d0: a9be7bfd stp x29, x30, [sp, #-32]! > 8d4: 910003fd mov x29, sp > 8d8: f9000bf3 str x19, [sp, #16] > 8dc: f9400833 ldr x19, [x1, #16] > 8e0: b9404261 ldr w1, [x19, #64] > 8e4: 34000141 cbz w1, 90c > 8e8: b9401a61 ldr w1, [x19, #24] > 8ec: d2800004 mov x4, #0x0 // #0 > 8f0: b9403262 ldr w2, [x19, #48] > 8f4: f9400000 ldr x0, [x0] > 8f8: f278003f tst x1, #0x100 > 8fc: f9401e61 ldr x1, [x19, #56] > 900: 1a9f17e3 cset w3, eq // eq = none > 904: 11000463 add w3, w3, #0x1 > 908: 94000000 bl 0 > ... > > We saved one ldr instruction: "ldr x0, [x0, #1160]" > > Signed-off-by: Jisheng Zhang Applied for next, thanks! Kind regards Uffe > --- > drivers/mmc/host/sdhci.c | 33 ++++++++++++++++----------------- > 1 file changed, 16 insertions(+), 17 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 2d73407ee52e..b1afabab9cae 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -907,7 +907,7 @@ static void sdhci_calc_sw_timeout(struct sdhci_host *host, > > if (data) { > blksz = data->blksz; > - freq = host->mmc->actual_clock ? : host->clock; > + freq = mmc->actual_clock ? : host->clock; > transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width); > do_div(transfer_time, freq); > /* multiply by '2' to account for any unknowns */ > @@ -2269,14 +2269,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > > if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK && > host->clock) { > - host->timeout_clk = host->mmc->actual_clock ? > - host->mmc->actual_clock / 1000 : > + host->timeout_clk = mmc->actual_clock ? > + mmc->actual_clock / 1000 : > host->clock / 1000; > - host->mmc->max_busy_timeout = > + mmc->max_busy_timeout = > host->ops->get_max_timeout_count ? > host->ops->get_max_timeout_count(host) : > 1 << 27; > - host->mmc->max_busy_timeout /= host->timeout_clk; > + mmc->max_busy_timeout /= host->timeout_clk; > } > } > > @@ -2399,7 +2399,7 @@ static int sdhci_get_cd(struct mmc_host *mmc) > return 0; > > /* If nonremovable, assume that the card is always present. */ > - if (!mmc_card_is_removable(host->mmc)) > + if (!mmc_card_is_removable(mmc)) > return 1; > > /* > @@ -2489,14 +2489,14 @@ void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) > unsigned long flags; > > if (enable) > - pm_runtime_get_noresume(host->mmc->parent); > + pm_runtime_get_noresume(mmc->parent); > > spin_lock_irqsave(&host->lock, flags); > sdhci_enable_sdio_irq_nolock(host, enable); > spin_unlock_irqrestore(&host->lock, flags); > > if (!enable) > - pm_runtime_put_noidle(host->mmc->parent); > + pm_runtime_put_noidle(mmc->parent); > } > EXPORT_SYMBOL_GPL(sdhci_enable_sdio_irq); > > @@ -2837,7 +2837,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) > goto out; > } > > - host->mmc->retune_period = tuning_count; > + mmc->retune_period = tuning_count; > > if (host->tuning_delay < 0) > host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK; > @@ -2886,11 +2886,10 @@ static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable) > static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq, > int err) > { > - struct sdhci_host *host = mmc_priv(mmc); > struct mmc_data *data = mrq->data; > > if (data->host_cookie != COOKIE_UNMAPPED) > - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, > + dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len, > mmc_get_dma_dir(data)); > > data->host_cookie = COOKIE_UNMAPPED; > @@ -2941,9 +2940,9 @@ static void sdhci_card_event(struct mmc_host *mmc) > /* Check sdhci_has_requests() first in case we are runtime suspended */ > if (sdhci_has_requests(host) && !present) { > pr_err("%s: Card removed during transfer!\n", > - mmc_hostname(host->mmc)); > + mmc_hostname(mmc)); > pr_err("%s: Resetting controller.\n", > - mmc_hostname(host->mmc)); > + mmc_hostname(mmc)); > > sdhci_do_reset(host, SDHCI_RESET_CMD); > sdhci_do_reset(host, SDHCI_RESET_DATA); > @@ -3675,7 +3674,7 @@ int sdhci_resume_host(struct sdhci_host *host) > host->ops->enable_dma(host); > } > > - if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) && > + if ((mmc->pm_flags & MMC_PM_KEEP_POWER) && > (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) { > /* Card keeps power but host controller does not */ > sdhci_init(host, 0); > @@ -3683,7 +3682,7 @@ int sdhci_resume_host(struct sdhci_host *host) > host->clock = 0; > mmc->ops->set_ios(mmc, &mmc->ios); > } else { > - sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); > + sdhci_init(host, (mmc->pm_flags & MMC_PM_KEEP_POWER)); > } > > if (host->irq_wake_enabled) { > @@ -3691,7 +3690,7 @@ int sdhci_resume_host(struct sdhci_host *host) > } else { > ret = request_threaded_irq(host->irq, sdhci_irq, > sdhci_thread_irq, IRQF_SHARED, > - mmc_hostname(host->mmc), host); > + mmc_hostname(mmc), host); > if (ret) > return ret; > } > @@ -4378,7 +4377,7 @@ int sdhci_setup_host(struct sdhci_host *host) > > if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && > mmc_card_is_removable(mmc) && > - mmc_gpio_get_cd(host->mmc) < 0) > + mmc_gpio_get_cd(mmc) < 0) > mmc->caps |= MMC_CAP_NEEDS_POLL; > > if (!IS_ERR(mmc->supply.vqmmc)) { > -- > 2.30.2 >