Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5996188pxb; Mon, 14 Feb 2022 12:42:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx++jgMpoLaGZnZ+kXBd/WPxt3IG+vynefiOYKMk3rl1Dr4VhCf6ucrBlk2+IH/rx6rX+SB X-Received: by 2002:a17:902:d48b:: with SMTP id c11mr565679plg.109.1644871323140; Mon, 14 Feb 2022 12:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871323; cv=none; d=google.com; s=arc-20160816; b=FPtJ4k9Sc/sx5Sf9sZOADSX+VMmgMGSkZNOhzCQuDElVZiGJKmiMgibICTfG3EFVac praaonwQZVB9yXNbbNFNTgVhxfC2tzeteHivlTndTyvcPZxgJGt6aOsX9+zvAdGdnLS/ N8xJQUMPxbrbW6p1N7shtsmMZoCX44A1bCIpTWhg/VuxkVTli+0MKs/5hHE5ygJMyopC 02rDtY6OmC0y2+WwYmY8dZ/7S5mbY0PfM8vcz9OidFCYk5PdsJCqEpYV/KDncK1UqGva zAWsPB64WhgtGADk+/GgtR5qjTRaK45G6MTU6zr+KtYKYdLTj6jUi1gYkFVWkgSWey4b YltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7lnMhtpi0tedfFeaMFYKaQ71qw/HvwjAz4fhdXBH9Yc=; b=uKNvDbDwhArY8WeG+zx7c0Q7/TYGrC08AQbegtHP0nlp25JCMkzmtdygius1lOsLyu rr9EoANvj2Oom0B3QuYvdPXeIMtvX/uGptTTAVXsehcdXihUb58zUe9awkGQHMJnbguN ZL57aHSMg9lS1RmkZncbxoUajYoL+XdKV3nSZff2TamRjLJEtV6nuWx88WHQGpoeEdIL J7RJmgW3teXqoQgIKmphmNSaBDF9pGiZkXldL1a34eedHjttDIlRkdnUabuh4iZN5knY q6haNt62f8B1xDDU3Ygar2QuKjmtDHm8rfzkbajGSPNDs6igPV+ryfuq3CDj28pHSpUI oEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=GmIVfeBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h7si7621993plk.308.2022.02.14.12.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=GmIVfeBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6172815AF08; Mon, 14 Feb 2022 12:10:06 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351827AbiBNLdW (ORCPT + 99 others); Mon, 14 Feb 2022 06:33:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352889AbiBNLcB (ORCPT ); Mon, 14 Feb 2022 06:32:01 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37B24553B for ; Mon, 14 Feb 2022 03:18:16 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id bu29so24630558lfb.0 for ; Mon, 14 Feb 2022 03:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=7lnMhtpi0tedfFeaMFYKaQ71qw/HvwjAz4fhdXBH9Yc=; b=GmIVfeBVHFoj2YipuxdPvmcHpJKJ5UqQJdD8lrN7iLIxX7C/Jk27HNQtBZbsbnUpp7 3Fya2xulzvXorMJOya4wQofhyNaVxz8NZJvqvScB0HfqNzq3NQebWapLsmZuVldqY0XD HMvdfGibYpIpl/3bXD88L9k+BTSpX8EYbvS1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=7lnMhtpi0tedfFeaMFYKaQ71qw/HvwjAz4fhdXBH9Yc=; b=kW0Nqj0gNY6anJJwCEUs406XP9Ue11yQCI6gyCduG7KUFc4s2hq0fblIJGtu90eDqE X4HRKEa+34wIapDBJlcwMGOq4epJXySqABf3e2KLpLl/jU+SjjStYnMvl1fNNY/oxkxX Sz55vnAaIRD++hSS2yQhtM3/7x/TyfeW5KcIJ6LhOHazNe0m6/+p61WGxORUaTBX4/AU buLivP+9PhDvxN4OK3HkQ9NUJNVOh351jlY8fdMQM5k61terbFjr1PExTrqsgMrvfPvc aIFRHWV+LCjvt7Ue9Gezg4W38OFF3HHCA3wuKBhpWh7ekDO8JmZ984CIa8XHIfTAZN95 dVsw== X-Gm-Message-State: AOAM5330Fth95ZPwtHHIwgP4AO81qHpKTHbItcziFoW9Nb0lU9o0V/3u 0x3bf+/HvPGuBO2cWuzRq+ecAw== X-Received: by 2002:a19:385a:: with SMTP id d26mr10711937lfj.220.1644837495267; Mon, 14 Feb 2022 03:18:15 -0800 (PST) Received: from larwa.hq.kempniu.pl ([2001:470:64df:111::e02]) by smtp.gmail.com with ESMTPSA id o17sm527233lfr.240.2022.02.14.03.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 03:18:14 -0800 (PST) Date: Mon, 14 Feb 2022 12:18:12 +0100 From: =?utf-8?B?TWljaGHFgiBLxJlwaWXFhA==?= To: Richard Weinberger Cc: Miquel Raynal , Vignesh Raghavendra , Boris Brezillon , linux-mtd , linux-kernel Subject: Re: [PATCH v3 4/4] mtdchar: add MEMREAD ioctl Message-ID: References: <20220125104822.8420-1-kernel@kempniu.pl> <20220125104822.8420-5-kernel@kempniu.pl> <1173246756.12597.1643879936765.JavaMail.zimbra@nod.at> <20220203104654.6cb43ea3@xps13> <340602071.12640.1643883222200.JavaMail.zimbra@nod.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <340602071.12640.1643883222200.JavaMail.zimbra@nod.at> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> If mtd->erasesize is large (which is not uncommon these days) you might > >> request more from kmalloc() than it can serve. > >> Maybe kvmalloc() makes more sense? > > > > Mmmh, I would really like these buffers dma-able. > > > > I just discovered mtd_kmalloc_up_to(). Would this work? > > mtd_kmalloc_up_to() makes sense to be more friendly to the system. > It tries to get memory without forcing write-back and such. > But if we're out of continuous memory it won't help much. > > Regarding dma-able, as soon you use something like UBI/UBIFS ontop of it > the mtd driver has to be able to deal in any way with vmalloc()'ed memory. Note that the MEMWRITE ioctl is affected by the same issue. Judging from the discussion above, I assume a separate patch is in order to turn kmalloc() calls in mtdchar_write_ioctl() into kvmalloc() calls? > Another option would be not working on full erase blocks. Right, the approach proposed in this patch series and also previously in commit f6562bca84d22525f792305e3106571f8714d057 ("mtdchar: prevent unbounded allocation in MEMWRITE ioctl") is a trade-off. I followed a suggestion I heard earlier: https://lists.infradead.org/pipermail/linux-mtd/2021-September/088485.html -- Best regards, Michał Kępień