Thread (7 messages) 7 messages, 3 authors, 2020-09-30

Re: [BUG] discard_granularity is 0 on rk3399-gru-kevin

From: Vicente Bergas <hidden>
Date: 2020-09-30 00:07:07
Also in: linux-rockchip

On Monday, September 28, 2020 7:02:00 AM CEST, Coly Li wrote:
On 2020/9/28 11:15, Coly Li wrote:
quoted
On 2020/9/28 04:29, Vicente Bergas wrote:
quoted
Hi,
since recently the rk3399-gru-kevin is reporting the trace below.
The issue has been uncovered by
 b35fd7422c2f8e04496f5a770bd4e1a205414b3f
 block: check queue's limits.discard_granularity in ...
Hi Vicente,

Thanks for the information. It seems the device with f2fs declares to
support DISCARD but don't initialize discard_granularity for its queue.

Can I know which block driver is under f2fs ?
Hi Coly, yes, i confirm it is the mmc driver.
Regards,
  Vicente.
quoted hunk ↗ jump to hunk
Maybe it is the mmc driver. A zero value discard_granularity is from the
following commit:

commit e056a1b5b67b4e4bfad00bf143ab14f634777705
Author: Adrian Hunter [off-list ref]
Date:   Tue Jun 28 17:16:02 2011 +0300

    mmc: queue: let host controllers specify maximum discard timeout

    Some host controllers will not operate without a hardware
    timeout that is limited in value.  However large discards
    require large timeouts, so there needs to be a way to
    specify the maximum discard size.

    A host controller driver may now specify the maximum discard
    timeout possible so that max_discard_sectors can be calculated.

    However, for eMMC when the High Capacity Erase Group Size
    is not in use, the timeout calculation depends on clock
    rate which may change.  For that case Preferred Erase Size
    is used instead.

    Signed-off-by: Adrian Hunter [off-list ref]
    Signed-off-by: Chris Ball [off-list ref]


Hi Adrian and Chris,

I am not familiar with mmc driver, therefore I won't provide a quick fix
like this (which might probably wrong),
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -190,7 +190,7 @@ static void mmc_queue_setup_discard(struct
request_queue *q,
        q->limits.discard_granularity = card->pref_erase << 9;
        /* granularity must not be greater than max. discard */
        if (card->pref_erase > max_discard)
-               q->limits.discard_granularity = 0;
+               q->limits.discard_granularity = SECTOR_SIZE;
        if (mmc_can_secure_erase_trim(card))
                blk_queue_flag_set(QUEUE_FLAG_SECERASE, q);
 }


It is improper for a device driver to declare to support DISCARD but set
queue's discard_granularity as 0.

Could you please to take a look for mmc_queue_setup_discard() ?

Thanks in advance.

Coly Li

quoted
 ...
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help