lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+Da2qwei0=0EH57pCC+4StijJ_NxSqHv1SkPj_PS-yzZh6hnw@mail.gmail.com>
Date:   Fri, 21 Oct 2022 16:47:43 +0800
From:   Wenchao Chen <wenchao.chen666@...il.com>
To:     Avri Altman <Avri.Altman@....com>
Cc:     "ulf.hansson@...aro.org" <ulf.hansson@...aro.org>,
        "adrian.hunter@...el.com" <adrian.hunter@...el.com>,
        "orsonzhai@...il.com" <orsonzhai@...il.com>,
        "baolin.wang@...ux.alibaba.com" <baolin.wang@...ux.alibaba.com>,
        "zhang.lyra@...il.com" <zhang.lyra@...il.com>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        "kch@...dia.com" <kch@...dia.com>,
        "CLoehle@...erstone.com" <CLoehle@...erstone.com>,
        "vincent.whitchurch@...s.com" <vincent.whitchurch@...s.com>,
        "bigeasy@...utronix.de" <bigeasy@...utronix.de>,
        "s.shtylyov@....ru" <s.shtylyov@....ru>,
        "michael@...winnertech.com" <michael@...winnertech.com>,
        "linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "megoo.tang@...il.com" <megoo.tang@...il.com>,
        "lzx.stg@...il.com" <lzx.stg@...il.com>
Subject: Re: [PATCH V2 1/2] mmc: block: Support Host to control FUA

Avri Altman <Avri.Altman@....com> 于2022年10月21日周五 15:53写道:
>
> > From: Wenchao Chen <wenchao.chen@...soc.com>
> >
> > This patch introduces host->fua_disable for MMC host controller.
> > The host can turn off FUA to improve performance.
> >
> > Signed-off-by: Wenchao Chen <wenchao.chen@...soc.com>
> > ---
> > V1 -> V2
> > Address Chaitanyak's suggestions
> > Address Avri's suggestions
> > ---
> >  drivers/mmc/core/block.c | 3 ++-
> >  include/linux/mmc/host.h | 3 +++
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index
> > 54cd009aee50..333e819e077a 100644
> > --- a/drivers/mmc/core/block.c
> > +++ b/drivers/mmc/core/block.c
> > @@ -2490,7 +2490,8 @@ static struct mmc_blk_data
> > *mmc_blk_alloc_req(struct mmc_card *card,
> >             ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
> >              card->ext_csd.rel_sectors)) {
> >                 md->flags |= MMC_BLK_REL_WR;
> > -               fua_enabled = true;
> > +               if (!card->host->fua_disable)
> > +                       fua_enabled = true;
> >                 cache_enabled = true;
> >         }
> >         if (mmc_cache_enabled(card->host)) diff --git a/include/linux/mmc/host.h
> > b/include/linux/mmc/host.h index 8fdd3cf971a3..16a5bee3eeae 100644
> > --- a/include/linux/mmc/host.h
> > +++ b/include/linux/mmc/host.h
> > @@ -517,6 +517,9 @@ struct mmc_host {
> >         struct blk_crypto_profile crypto_profile;  #endif
> >
> > +       /* Host FUA support */
> > +       bool                    fua_disable;
> Why do you need to invent a LLD mechanism, when you already have a block api (QUEUE_FLAG_FUA) for that?
> Which is actually misleading, since /sys/block/mmcblk0/queue/fua will still reads 0.
>
> Thanks,
> Avri
>
Hi Avri
The code expands as follows:
static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
      struct device *parent,
      sector_t size,
      bool default_ro,
      const char *subname,
      int area_type,
      unsigned int part_type)
{
...
if (md->flags & MMC_BLK_CMD23 &&
    ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
     card->ext_csd.rel_sectors)) {
md->flags |= MMC_BLK_REL_WR;
if (!card->host->fua_disable) <<<Allow chip manufacturers whether to use FUA.
fua_enabled = true;
cache_enabled = true;
}
if (mmc_cache_enabled(card->host))
cache_enabled  = true;

blk_queue_write_cache(md->queue.queue, cache_enabled, fua_enabled); <<<
...
}

void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua)
{
if (wc)
blk_queue_flag_set(QUEUE_FLAG_WC, q);
else
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
if (fua)
blk_queue_flag_set(QUEUE_FLAG_FUA, q);  <<<
else
blk_queue_flag_clear(QUEUE_FLAG_FUA, q);

wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags));
}

Also, echo 0 > fua is forbidden regardless of permissions.
Do you have any better suggestions?

> > +
> >         /* Host Software Queue support */
> >         bool                    hsq_enabled;
> >
> > --
> > 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ