{
  "slug": "mtd-bitflip-threshold",
  "term": "MTD bitflip threshold",
  "aliases": [
    "bitflip_threshold"
  ],
  "definition": "The MTD bitflip threshold is the per-ECC-step corrected-bit warning threshold used by Linux kernel MTD read APIs to report -EUCLEAN on otherwise successful ECC-enabled reads.",
  "note": "The comparison uses the largest driver-reported correction count in any one ECC step, not their sum. In a hypothetical read with threshold 4, two steps reporting 3 and 3 corrections stay below it; a step reporting 4 reaches it. These examples illustrate the API rule, not a measurement or a recommended setting. [mtd-abi]\n\nA 0 status can therefore accompany corrected errors. The normal ECC-enabled path compares the nonnegative driver result against the threshold; it preserves negative errors first and bypasses the comparison if ecc_strength is zero. With threshold zero, even a reported correction count of zero can yield -EUCLEAN. [mtd-core]\n\nDo not infer the effective threshold from ECC strength alone. In Linux v6.16, raw NAND initialization supplies ceil(3 * ecc_strength / 4) when a threshold has not already been set. This is a software default for that path, not a universal NAND failure limit. [nand-init]\n\nUBI translates MTD's -EUCLEAN to UBI_IO_BITFLIPS. Its logical-eraseblock read path can request scrubbing, whereas -EBADMSG has distinct handling. A warning is not an automatic permanent bad-block mark, and changing its threshold does not strengthen the ECC code. [ubi-io] [ubi-read]\n\nThis threshold rule is not the MEMREAD ioctl's complete return contract. Its accumulated corrected-bit statistics can trigger EUCLEAN below the threshold. Record the API as well as the status. [mtd-char]",
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "related": [
    "mtd",
    "error-correcting-code",
    "bad-block-management",
    "ubi",
    "nand-page"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-22",
  "citations": [
    {
      "id": "mtd-abi",
      "title": "Linux v6.16, MTD sysfs ABI: ECC step, strength and bitflip threshold",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/Documentation/ABI/testing/sysfs-class-mtd",
      "accessed": "2026-10-22"
    },
    {
      "id": "mtd-core",
      "title": "Linux v6.16, mtd_read and mtd_read_oob: status conversion",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/drivers/mtd/mtdcore.c",
      "accessed": "2026-10-22"
    },
    {
      "id": "nand-init",
      "title": "Linux v6.16, nand_scan_tail: raw-NAND bitflip threshold initialization",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/drivers/mtd/nand/raw/nand_base.c",
      "accessed": "2026-10-22"
    },
    {
      "id": "ubi-io",
      "title": "Linux v6.16, ubi_io_read: corrected and uncorrectable read results",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/drivers/mtd/ubi/io.c",
      "accessed": "2026-10-22"
    },
    {
      "id": "ubi-read",
      "title": "Linux v6.16, ubi_eba_read_leb: volume-specific CRC and scrubbing paths",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/drivers/mtd/ubi/eba.c",
      "accessed": "2026-10-22"
    },
    {
      "id": "mtd-char",
      "title": "Linux v6.16, mtdchar_read and mtdchar_read_ioctl: userspace read results",
      "url": "https://raw.githubusercontent.com/torvalds/linux/v6.16/drivers/mtd/mtdchar.c",
      "accessed": "2026-10-22"
    }
  ],
  "provenance": [
    "Source review scoped to Linux v6.16. No raw-flash device, fault injection or endurance experiment was run."
  ]
}
