Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796375807; b=PhpP07Ry3Yf5z/qwWPoalbErr3FpS6R2Fhr1CIOql/5GPhI+8QH2j2eDlI6SrWpzJqN9 rqg+3xd/RxUetpJgZJAlNR3KccSf52q6XJEFu9zYWCbCTS6v05oLnK+JuA05xF/sxISP/ b9oh8Lvzq+oB7Jji8yySQgqRc2lvWR7nvMYQkG1w2XuALO8ZTD1//LqmXzaczXaHQhPOV ZukCrIvVkzfTcfE4031uYRJOp7SYbnq695TTZp7pbnVVbfBlPF6oMu5xYNj1Yl0YJlwqu YNSNgTtSoMyAy68W00OYrNe5Rw8KXOy6Bjt7r8z7KZQGp9vFSP56eQWh/2Fa0ubGq2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375807; 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=JepY6CHf//0QNTtOg8PAS/zCUpq1ovXChTRDWwR//5o=; b=zp+dVej5K923eM4sGFOcyKHwkMO1a6eJqvZoazK32+1JU06atHRUI+2ivE/XfLdPHlbN iQofXEdak5Eni1zdjm06FYxBODphBG4MPIK1TO141av8yltDg47xc8hsTZBzuPHze86nO 6siBZxvLFj2SvT71kfy6z8uidBrg0Kwmiuy7pg3ASQYMZOLTK2PsyI26uYEquqIyl74sl VlTf8GP4IV5STfnnCQo4pqHAZ0qM8rf7waBS66UWV/LOttKDFWTJAHEco04PtHNOaTfzV F3F3wViWEiqZ7TCrXAncKQ+pzYbnl86glAw4v4mWsclv29AkyXoSnQpwSKXwkuBCZ5w== 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=Ed89rL3C; arc=none smtp.remote-ip=209.85.216.47 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 0F7E2606A322 for ; Fri, 4 Dec 2026 09:16:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0F7E2606A322 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=Ed89rL3C Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3b4a93d0814so379188a91.1 for ; Fri, 04 Dec 2026 01:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796375806; x=1796980606; 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=JepY6CHf//0QNTtOg8PAS/zCUpq1ovXChTRDWwR//5o=; b=Ed89rL3CicLD4wAu78NnXEmk9/Tji/3BjDpqb0wqTLFbkMZr7TcJtsfW9vPgtuiGZc BK+ufHyLk4R/4ODh2wmrkpMlGRSTIYaGRtJcCt35afd/PW8YoXId/FxIBmXEOimm4ldR YHpeLAiQif6niLKlmc5AHQGd2+LQtBUJb+e+OnmWjkfjeTTOw2oqcsJAiOW7+oaFvbRD YHg3ir7iDDqDeTRf9en3OHzxcs3UkPtL1lrtrpH7MzKXV91ldJYCeFu04VifO/ugcJkB FFuVaNjxHv23nnABTUTF5cD9R1dypJ8KGdLqjyf/F3G8RKtJ1BYdc29Z4r8L9WBhSGMU v16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796375806; x=1796980606; 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=JepY6CHf//0QNTtOg8PAS/zCUpq1ovXChTRDWwR//5o=; b=uuNJYzcraEkRON+5FfhUdZs8hzhwzW+3IXwRKerWaMs+JcJFxkm8o+R/9nUknfdBsu RPqxeRN4gOa5EWEmyZIKxjuacLtYjdrQ3LHmbcBYiGh8437wwol6J9chuXmjiGpQLkkg t74pBTNva3ln79HEwtnuLirfZPIVnV3E4wiA+u3pYYdW6+vQXmqshz+WAa+FdqmmycG3 LGXKRtnPYAEHv1Zv2hXw0l4+nRmvqTidxf2HQ6L50MjFI6iVHnDnJAh/L0yIP6fHSxBc +Ek43kCOFERoYOQIwvOD25HAfHLDB2TTOkScgGZK17LnrLDi1tr39aNmTI/fWCjhkY5v BxBw== X-Forwarded-Encrypted: i=1; AL+hErEe+T13B9mzIDRkxC0FB0FfN1vz1ws396uEiX3LQb6KgSOe/TOQ8nzcwBwY4ew/bMqetWwwYG3LQCzDpdE=@vger.kernel.org X-Gm-Message-State: APuU4Z8n0sS0IPwxa7TxOYwsb1ewRibUgNVbUTpRQh3XrvhXWcL0A4oM wm9Hnojo7r4IP3aUFSXdlKRjWPlVwBFBBeZLYdXJqa5Ou4Q9TXIEigVL X-Gm-Gg: AZFdTZcmuhiHuE1Rb8j71pb3AfnFMCjU0O/zNmJmDIMlvqFm0zF9EYPQbzZO2wJoUUq CtMAH1lGb53WxCKcWBdGsLmlNosZxcm1PwHWg3D9O+jZMGZryU5v+cNAD6gsrY8t74HgZ7wbe0E GZkUc9Dz8gA7ZC4tD18+HbjVOxqso4/bjFuvZHHv7UOPBxOoS1wfjnJqEP8r9bzwSWmrLkTsrRW f01LP7b0YET2oWP5mMRINFQXB8cRA3I/31Z+zJYJYlOyv++MMBZy+saxP8cITYFtcRfin9S3Fje 2N6R9i4aqqTBXkyF20+AczGqsqxwVYpcSHEYdt6R/BaGRBY9AaZnyBa4DSlDPsj7lXjYEvWkCw2 LnlzM+sb/DfyVD6TcHsP9R8lyOmFTbqyjV4z3MI1jA0lAwL0k3jTsXowUD85aBgXnxUG/ze1f7e HTfMSABowrrus/+74VrYmNOhRFw5jqecTZDMRURZjfJ5Z5N8RaWT7kwIEhtC+4/Nqe06c8zEH/u ayezo8K0L2jBPsi1cJdosL0mhfCKPDRqC3jGWLYG7zAf0ZzNijAUsH+YO0gN+lV5tpp8F2jmJZ7 DuL5KykraHxMC1gfLNZ9HryBeQfdTFY+0g== X-Received: by 2002:a17:90b:1dc4:b0:3ad:d4aa:8559 with SMTP id 98e67ed59e1d1-3b5e0623fd5mr940435a91.17.1796375806119; Fri, 04 Dec 2026 01:16:46 -0800 (PST) Received: from server225.. ([39.170.101.209]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc54888sm2885970a91.11.2026.12.04.01.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 01:16:45 -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 v4 0/4] mtdchar: per-device bounce buffer policy Date: Fri, 4 Dec 2026 17:16:36 +0800 Message-Id: <20261204091640.444442-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 series implements a per-device bounce buffer allocation policy: low-level drivers decide whether they may receive non-linear-map buffers, and a helper applies the allocation policy accordingly. The design follows the discussion with Miquel [1][2], and the previous revision of this series is at [3]. 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 fixes a pre-existing bug found while re-reviewing v3: the bounce buffer size is taken from the unclamped count, so a read() near the end of a device allocates far more than the actual transfer. Patch 3 converts mtdchar_read()/mtdchar_write() to the helper. Patch 4 is the first user: rpc-if copies data with the CPU (memcpy_fromio), so vmalloc'd buffers are safe to hand over; am654-hbmc, whose DMA fast path a vmalloc'd buffer would bypass, keeps the default behaviour. This conversion is compile-tested only. Changes in v4: - Add __GFP_NORETRY to the kvmalloc() call to avoid the OOM killer. - Fix the unclamped bounce buffer size as a separate patch. - Restrict the hyperbus opt-in to rpc-if only, instead of opting in both controllers from the core. - Drop the onenand samsung opt-in (its DMA path only serves aligned, single-page accesses, so a vmalloc'd buffer would hurt performance for unaligned transfers). - Re-run the platform tests on this revision: the opt-in still delivers the full-size transfer in one piece under heavy fragmentation, matching the v3 numbers. [1] https://lore.kernel.org/linux-mtd/875wxtf8uy.fsf@bootlin.com/ [2] https://lore.kernel.org/linux-mtd/87ecbyk5wo.fsf@bootlin.com/ [3] https://lore.kernel.org/linux-mtd/20261204054630.3443342-1-leeonion.muyu@gmail.com/ Ping Li (4): mtd: core: add per-device bounce buffer allocation helper mtd: mtdchar: clamp bounce buffer size to the remaining transfer mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers drivers/mtd/hyperbus/hyperbus-core.c | 1 + drivers/mtd/hyperbus/rpc-if.c | 1 + drivers/mtd/mtdchar.c | 30 ++++++++++--------- drivers/mtd/mtdcore.c | 45 ++++++++++++++++++++++++++++ drivers/mtd/mtdpart.c | 1 + include/linux/mtd/hyperbus.h | 2 ++ include/linux/mtd/mtd.h | 9 ++++++ 7 files changed, 75 insertions(+), 14 deletions(-) base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3 -- 2.34.1