CFT: TRIM Consolodation on UFS/FFS filesystems

Mark Millard marklmi at
Sat Sep 8 09:32:46 UTC 2018

On 2018-Sep-8, at 1:36 AM, Mark Millard <marklmi at> wrote:

> Just an FYI.
> I figured out a hack that allows the e.MMC on a microsd card
> adapter to be used to boot and operate the Pine64+ 2GB, in
> DDR52 mode at that. (And so shows what was missing in the
> FreeBSD operation even if the code change is not the
> proper form of an official fix.)
> But in the process I discovered that FreeBSD is using
> (for e.MMC in this tested context):
> mmc0: REQUEST: CMD38 arg 0x1 flags 0x1d
> That "0x1" means: TRIM that forces reads of zeros: the true
> Data Removal command for mmc protocol, a form of erase. 0x3
> would be DISCARD, the "performance command" that does not
> guarantee what would be read afterwards: no erase required.
> TRIM is older (added in e/MCC 4.4). DISCARD is newer (added
> in e.MMC 4.5). Each is mandatory when the version has the
> function at all.
> Does FreeBSD have a policy of preferring erasure when
> there is also the option to not require it?

I looked up published SD card material and that command
set encodes differently for the argument:

0x1 is DISCARD (also not requiring an erase)
0x2 is FULE when start LBA=LBA0 and end LBA=MaxLBA.
Otherwise it is ERASE.
(FreeBSD's mmcsd_delete uses 0x0 for ERASE selection.)

(I ignore handling violations of start LBA <= end LBA <= Max LBA
or out of order command sequences. FULE: Full User Area Logical

It looks like FreeBSD uses mmcsd_delete for both SD and e.MMC
and it is coded for SD to be more optimal (DISCARD), not
differentiating e.MMC from SD for argument values to use.

In e.MMC 4.5+ 0x2 is a "discard enable" bit in the argument,
and never a FULE or other such.

In e.MMC the 0x0 case for CMD38's argument is for performing
an erase on erase group(s) instead of sector(s).

(I'm not describing Secure Request or Force Garbage Collect
being 0x1 for e.MMC: apparently unused by mmcsd_delete .)

Mark Millard
marklmi at
( went
away in early 2018-Mar)

More information about the freebsd-fs mailing list