From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796363196; b=TAmshD2Y8i1Q+ybYpMhZNOowC02km//wvWhc/nAWCHH8H0Z1OkdcK2u2PfF4GQ9iPQ2q zIZ/vwoEi4TwqO7+eKSpTaanVZ12uQarO9mEWF8iQSd/Jl/NthMijRvJiBuUe5QQDWet1 KSP0lB85+74pCZbIO/Xg9xsJHyE2zn7n8obiDQpAb3Pu08i+1pqSiDmHBPr6NfIYVInKH YFxlPZpF1OgQY3yUmvQhsXsa1Nj7K2/aHtMmDbGCEO4Bx8J9mOeiQcsuRc2mCx6kpeyCv Q2zoenvuHzfbbEMdx8fQ7d2+ciQPjBnxoY8Ns9rZwHEfXEvaXMS/xtCqM4RMu6V2Q0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796363196; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=a/YXnHNHNEahnyOpLH1yEkHPygw0wWfi/hSx4RDE9JQ=; b=rJ2rK+5q9IV8dopwCAgrYSa1L/xrCEUZK41hLFiLoJ9qDq8ZExuYc3zHuyaOIV25m5Vq EjG9oYLddxOP/he180qRubtQg0P/2oEV38rV/icF6ORQgkp+XZlg3asQvFFUx8gMAs0FT Vd8b9oatFJ7aCjpRkEi54LiiOT/nb3h+rv/iWWUGoQHQUbBo80GqKLdVdLPey/0VNXPdb AXjQE13EVyYROcg4vKwE7lunQP7nInYMxbCC0H0YxoEnCygt6koSqgW9Pqq0451JmGDch z3pDt8C1+R3JI5KcgAKDWxF3nGUUY2CUvc2PNGzNwaxLHe4anLCwRyDZjxMmpPynjkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ou6DjU9L; arc=none smtp.remote-ip=209.85.210.172 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E363606A322 for ; Fri, 4 Dec 2026 05:46:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0E363606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ou6DjU9L Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-8c5ebbc5150so364499b3a.3 for ; Thu, 03 Dec 2026 21:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796363195; x=1796967995; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=a/YXnHNHNEahnyOpLH1yEkHPygw0wWfi/hSx4RDE9JQ=; b=ou6DjU9LaW8UrktEIWVjs7b9zQjZ9oDHVz8VRF8SDPxGbZbzlnejTXU84wpI+UuA6r Jlx/2Ukd7NJ/tpqc0I3koNv/myit9d7sgsMjLoFfTuMuri1Z6BxgKMT1de3MmDXQP0SM StGdZVdihXD7j/R0nW7TAmUpkr5hUYwAnuhqSnBaC9EjSoYaPqE5UgV+nfMfOVT/eu9k a2gRG8VhCDHxWTndjUM0wnBKf5D/S9ojcSGegbFkXckSZa34lXANtNFo1KmiY1P/oqDt e/FI73qoSp17eiflZGC+YXftx91HtUtsKYeQuXt1uHyD1mue7XtiiM9oDOK/IEdqosp6 UHlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796363195; x=1796967995; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a/YXnHNHNEahnyOpLH1yEkHPygw0wWfi/hSx4RDE9JQ=; b=P2JW9zdAQny4Nsp2+RjyS0kfh23FKOVIHu74mwciRnULo/YboXUzxi1a8Ml/7sSFFs SeCptqBUNy4abj6hzc4H8MmSgKWxoCQyYi8OOmsHiJkSiBcarsXRvuJ3+KxKItMvAtCC 1+3x9oZmlxoo7ShD+balTAW44KfRL2NkpPOfh1fGgZIgvYiCb1Ka8io0sDbz1SeA5ndB iy9RTTicKeBXaUQcaVmVlevem14kg1YjzP0JY6a/doRGy+s8bWwP5rlS21tUNiBIrvHE PgoX+tI5SkElBOJfoHbn2l4sTiXmjl1Hqys+jAhncyB7wV0dEo6T5WWpSPbUrPbBO7Sh AG7A== X-Forwarded-Encrypted: i=1; AL+hErG4nBR2pLiiPGBjHu2oczRfAqx5ZAzRXQmhcVFb2kBEU/P/3uaJezEnVOfymgswTW8fQJejn9CmfhySA40=@vger.kernel.org X-Gm-Message-State: APuU4Z96uT2WDkLGcI6IGH4hKOLFiCYvM7jnwVRbLENM9hkN3xh2+05b 0RCUDdvDoOkxFDNCTjoWcNGyWU9L6rNVtvWQzcJqwwpb08M3lZfoqBym X-Gm-Gg: AZFdTZcX7XtV9yvQJi4jfSolx+0/CxvAs2qD1fzuL99egCH/vXFFY4egH2ZEEZNMDph vhORX03J1tsWOrxLHAdzwDFgXa3n84CJSl9HB8PADolr72u8uSQ1cyzlBCM0fs6jrDeol7BmvQP lS8OpkRtlao1HQkGOzBBiJG0ejJGOJ7TKNFKlYv8us8iukWy50YJP3ZIOlzjjt8Kl/cNkZwZp9m dwja1Gti8Ih/NivJInuvTU6Bnq0m3I4RNh5L6KS0BTJSkZLN/NjbSNJ4A1kaNs0P5GYLs4EuXeQ wVNQaF5jIqYexwfznIZqtEET1qLtrKGE+JcsXAglUPg3hbxietjK795fQbVm+FDVg6k27M10ot2 MfULGNQrwRSI8X0uZnwSOy7/XjnH2C74wEGMBTbhSD+PBtPZKknH/YwkJVcJHHEENTVUPDigjgk MEL3PEhZDnhscdr1+dolL+dO09DFkM6uAFtgCO8C8M/UnBAkIhkNmf+0bvRp23+pdxLuC8dDxD4 DH8Iq0TtohS+Fgf5cqi7n0yCoxIiHJph+lLVvOG3WpKkWgUI4dV7hGaBbnoHNNOpFVferS41tc3 lvIGhxR6xFgR+q9LKNVfWeJg0Vac74k5xGM1lEmgm8OiXo6/hFGIap4= X-Received: by 2002:a17:90b:4b8f:b0:3b4:1714:5bfc with SMTP id 98e67ed59e1d1-3b5e06aae54mr837581a91.61.1796363195190; Thu, 03 Dec 2026 21:46:35 -0800 (PST) Received: from server225.. ([39.170.101.209]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de121f321asm745490b3a.15.2026.12.03.21.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 21:46:34 -0800 (PST) From: Ping Li To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: tudor.ambarus@linaro.org, kyungmin.park@samsung.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Ping Li Subject: [PATCH v3 0/4] mtdchar: per-device bounce buffer policy Date: Fri, 4 Dec 2026 13:46:26 +0800 Message-Id: <20261204054630.3443342-1-leeonion.muyu@gmail.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is the third revision of the RFC series, following Miquel's review [1][2]. It implements the agreed direction: low-level drivers decide whether they may receive non-linear-map buffers, and a helper applies the allocation policy accordingly. Patch 1 introduces mtd->allows_vmalloc_bufs (defaults to false, partitions inherit it from their master) and mtd_alloc_buf()/ mtd_free_buf(). By default buffers come from mtd_kmalloc_up_to(), which shrinks the size under fragmentation. Drivers that can handle non-linear-map buffers may set the flag to get kvmalloc()'s vmalloc fallback instead, so a large read()/write() no longer degrades into many small mtd_read()/mtd_write() calls. Patch 2 converts mtdchar_read()/mtdchar_write() to the helper. Patches 3 and 4 add the first two users. Both the hyperbus and Samsung OneNAND controllers handle vmalloc'd buffers by design (CPU copy fallback and per-page DMA mapping respectively), so they opt in. These conversions are compile-tested only. Changes in v3: - Drop the RFC tag. - Add two in-tree users (patches 3 and 4), per Miquel's request. Numbers from our platform (an IPC-backed NOR flash device where each mtd_read()/mtd_write() is forwarded to a remote controller): - one transaction costs t ~= 20ms + 0.3ms/KB, i.e. ~620ms for the 2M+2K transfer this platform uses for OTA updates; - with the opt-in, every 2M+2K read() issued during the tests (~80 runs across clean, fragmented and severely fragmented memory states) produced exactly one transaction, in every single run; - without the opt-in, the same command was observed to produce both single full-size and halved (len=1049600, two transactions) transfers within the same session, depending on transient allocator state. The split is not reproducible on demand; - wall-clock throughput is not the benefit: a halved transfer pays only one extra fixed cost (~3%). The benefit is determinism: the opt-in makes the transaction count and buffer size independent of memory state, which is what transaction-bound backends need. [1] https://lore.kernel.org/linux-mtd/875wxtf8uy.fsf@bootlin.com/ [2] https://lore.kernel.org/linux-mtd/87ecbyk5wo.fsf@bootlin.com/ Ping Li (4): mtd: core: add per-device bounce buffer allocation helper mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers mtd: hyperbus: accept vmalloc'd bounce buffers mtd: onenand: samsung: accept vmalloc'd bounce buffers drivers/mtd/hyperbus/hyperbus-core.c | 1 + drivers/mtd/mtdchar.c | 24 ++++++------ drivers/mtd/mtdcore.c | 44 ++++++++++++++++++++++ drivers/mtd/mtdpart.c | 1 + drivers/mtd/nand/onenand/onenand_samsung.c | 2 + include/linux/mtd/mtd.h | 16 ++++++++ 6 files changed, 77 insertions(+), 11 deletions(-) base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3 -- 2.34.1