Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5052776ima; Tue, 5 Feb 2019 05:44:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IZSrEOXBhwGITig8fXFw9MuwyGxDp77GHvKciGoLc1C8Znkmzib4+9b/QvKhDiMkUbeJeRp X-Received: by 2002:a17:902:3383:: with SMTP id b3mr5120217plc.170.1549374279869; Tue, 05 Feb 2019 05:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549374279; cv=none; d=google.com; s=arc-20160816; b=0URdVlYYKD9x847bVDwhBwv9Bzl2DicV5dKGpJ7mmPuN9ej2FH163fkc+aDXPcGts8 2QfFpSTJY5Vf3Jb4tNUxOB5DDcPO1eecGHRWXG6Tz1geH+AyT61Xq5VVtJOzDyrNlNPh UJeUkHB55wQGVsAEiDVLuw1hbXR1Cealsq0cSVwVIelmc1YIHYrKIOSvYD829cPYmc2y 0Hlbfl9MLhV7i4nrQq7C55TOIkZ05bjoVnWxb2QUGH5f9xj5snfgWxJ6qlgYhDGOaqoj 1MxzgVzGDG38wp0isX/l91EeJEu1Vz0afOe3ZUboQ3Py7xamLHWbWuCkwipZX2hA4Qqg 5euw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=prvhephNXIydJvkflBaOKno9ZKAnc8T5wtxtA/w0psM=; b=znh7R2m3NC3pKzQHCHTAt16JmhXbXnPPHVxAi0Vug3E3ytYVtXGnNt1VbvPyfpMC6C ZHh0ry7adhTOEQIlrZu3LDctWIRqOV8GONCjBrjmHQgToqwcM8b3TjX3zDCjNRabike6 sDct+bRm4R/4hQGJVHl6lXGIznEgvbGOJUH4Tked93yQJJW2u8iOygqq54cUF3xcqYdD xS2Mlsjm0j93Pl/Yv5Ib14dlKrgdL7v3jw5gs+E2lKkel1ni6IwtBD7ZbFtFvONrJK5Q YMmYxIOhAaX+saWsahvqygGtfTGAKurHpmP4IzWfFECvJ8liNr3jECjmmDG5MbO70kdc 4UPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSIaMY0v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p64si3431182pfa.94.2019.02.05.05.44.24; Tue, 05 Feb 2019 05:44:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSIaMY0v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727782AbfBENdu (ORCPT + 99 others); Tue, 5 Feb 2019 08:33:50 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:42550 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfBENdt (ORCPT ); Tue, 5 Feb 2019 08:33:49 -0500 Received: by mail-vs1-f65.google.com with SMTP id b74so2111277vsd.9 for ; Tue, 05 Feb 2019 05:33:49 -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=prvhephNXIydJvkflBaOKno9ZKAnc8T5wtxtA/w0psM=; b=CSIaMY0vIhc86nAsbhL2w6X4PmK0zYrErL9DXxsAN2vvWugY+VHtUm65/KTK9Uptmu LvBBpvs6OiiJdJEtGzKpp5hIOln9bh9KPMuHM+K91+BjJVzlzUB2MWIv2HTQBIJmLNnr 8A0+rlnp1TLqBi3Bb7m2DDjXymQ6tmrwWr259bp805MmYY1rhtJNpCmDCiZwoFjNn0f1 WCB7h3juUnNlLxA7RqPc5cdKh+9OceusPUi7RDNeRZfTrkn1L/621gKdnycm0gu3zJVV KKqa2DqOz1z1sksycc80XalfPfqwbE6kcqwaKxW2TwHSoC+4x6AXZ8GLp4r18teK2EKo +Xfg== 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=prvhephNXIydJvkflBaOKno9ZKAnc8T5wtxtA/w0psM=; b=Cv+BrUsTDVCA7ZJxdeTIQ15mHi9gZUp4To5aHPPBsdc0s17hth5juPE8WNtvylYIYt BvvmP4hFiWs73r+mLtdESqcghKUhMmLnDJ/w4/uEV963kjMJEL/M+qrYKD2mewWhsdw0 YemLFJD1C5+qqjb9yjImrURD6bSvvJM8noNYyiLLucjmirL7EVfPEb61aP4N8uWak9vt x/ea2AuLP4xxdgsfLSudC991Go0qdDUB/Ax/YOfzTNF2n6QSkHrR2iO5d10eVymBdtsl i+3zEHeny9lIFk1ng+n4QK/IeCvZbV6pTfo37Cy4vv3beYHTOK8QTIXDNUCcGnI1rJXF MVqA== X-Gm-Message-State: AHQUAuav1fpzJXE3glwpEF/r6SmzaVlHnY8aEdQd2VySSOlbMwFDxCDP 9Vnw53awHUi+RkkKAMcJplfgDTEGWI1W0gLr52NsCQ== X-Received: by 2002:a67:d00f:: with SMTP id r15mr575422vsi.191.1549373628614; Tue, 05 Feb 2019 05:33:48 -0800 (PST) MIME-Version: 1.0 References: <1549183828-17316-1-git-send-email-avri.altman@wdc.com> <1549183828-17316-2-git-send-email-avri.altman@wdc.com> In-Reply-To: <1549183828-17316-2-git-send-email-avri.altman@wdc.com> From: Ulf Hansson Date: Tue, 5 Feb 2019 14:33:12 +0100 Message-ID: Subject: Re: [PATCH 1/3] mmc: core: Calculate the discard arg only once To: Avri Altman Cc: "linux-mmc@vger.kernel.org" , Wolfram Sang , Adrian Hunter , Jaehoon Chung , Shawn Lin , Avi Shchislowski , Alex Lemberg , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 3 Feb 2019 at 09:51, Avri Altman wrote: > > The discard arg is a read-only ext_csd parameter - > set it once on card init. I like the idea here. There is really no point checking this for every corresponding request, nice! However, the "discard arg" isn't specific to eMMC, as it's also used for SD cards. So, the change log is a bit miss-leading, I think. Can you please clarify this. > > Signed-off-by: Avri Altman > --- > drivers/mmc/core/block.c | 12 +++--------- > drivers/mmc/core/mmc.c | 8 ++++++++ > include/linux/mmc/card.h | 2 ++ > 3 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c > index b08fb91..3502f2c 100644 > --- a/drivers/mmc/core/block.c > +++ b/drivers/mmc/core/block.c > @@ -1124,7 +1124,7 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) > { > struct mmc_blk_data *md = mq->blkdata; > struct mmc_card *card = md->queue.card; > - unsigned int from, nr, arg; > + unsigned int from, nr; > int err = 0, type = MMC_BLK_DISCARD; > blk_status_t status = BLK_STS_OK; > > @@ -1136,24 +1136,18 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) > from = blk_rq_pos(req); > nr = blk_rq_sectors(req); > > - if (mmc_can_discard(card)) > - arg = MMC_DISCARD_ARG; > - else if (mmc_can_trim(card)) > - arg = MMC_TRIM_ARG; > - else > - arg = MMC_ERASE_ARG; > do { > err = 0; > if (card->quirks & MMC_QUIRK_INAND_CMD38) { > err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, > INAND_CMD38_ARG_EXT_CSD, > - arg == MMC_TRIM_ARG ? > + card->discard_arg == MMC_TRIM_ARG ? > INAND_CMD38_ARG_TRIM : > INAND_CMD38_ARG_ERASE, > 0); > } > if (!err) > - err = mmc_erase(card, from, nr, arg); > + err = mmc_erase(card, from, nr, card->discard_arg); > } while (err == -EIO && !mmc_blk_reset(md, card->host, type)); > if (err) > status = BLK_STS_IOERR; > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index da892a5..120739c 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -1743,6 +1743,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, > card->ext_csd.power_off_notification = EXT_CSD_POWER_ON; > } > > + /* set discard_arg */ > + if (mmc_can_discard(card)) > + card->discard_arg = MMC_DISCARD_ARG; > + else if (mmc_can_trim(card)) > + card->discard_arg = MMC_TRIM_ARG; > + else > + card->discard_arg = MMC_ERASE_ARG; You are assigning card->discard_arg only for (e)MMC, while I think you should do that also for SD. I guess it practice it doesn't matter, because MMC_ERASE_ARG is zero. Although, I would prefer to keep the code consistent, so I think you should assign card->discard_arg for for SD cards as well. > + > /* > * Select timing interface > */ > diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h > index de73778..447648b 100644 > --- a/include/linux/mmc/card.h > +++ b/include/linux/mmc/card.h > @@ -308,6 +308,8 @@ struct mmc_card { > unsigned int nr_parts; > > unsigned int bouncesz; /* Bounce buffer size */ > + > + unsigned int discard_arg; /* discard args */ Please move this a couple of lines above, close to the other "erase" related variables. You may even consider to rename the arg to "erase_arg", but I have no strong opinion changing to that. > }; > > static inline bool mmc_large_sector(struct mmc_card *card) > -- > 1.9.1 > Kind regards Uffe