Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp184567imn; Thu, 4 Aug 2022 01:43:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/EB9qe9MpBMDtiHf/M0T4xyNsMG+aJDDMIarxhVYeqKwrGJQCMm7asRTBw1n0LQsCOmoO X-Received: by 2002:a17:907:96a1:b0:72b:918c:13f with SMTP id hd33-20020a17090796a100b0072b918c013fmr639094ejc.659.1659602609323; Thu, 04 Aug 2022 01:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659602609; cv=none; d=google.com; s=arc-20160816; b=EblVjx1IWqaWDEDayh0eBfr+D+ivR1+YB5Bplrrd08LdsiRZPaYMxmvL1i9I4onUNt Rx93LkWbcCMi/B0YGe8ptRi49zp8LkvviYoktLkAnahxFrfe0jm8RWA9VbVNZ9dRWgK6 uenFvlA9z86q4x9MKH6h66A/X9Q9FaPtCtvznYr2Eu/70x+v6tHVTTnM3B/tugJNuElj tYy3EHN2xsRWgxdJibTGWBh3jkF2WOpWN6Ns8XLJFKyrWkZDEBB2xfkjhn5a1ENptaEY o8xJDF6rWqRFOQ/+E8bo8Q7V0951RW4iCOWTIziOi3nAzKqJFPq4+hbcFe/9RFkNkPev EgPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=4W9piaEyc8P2Dj0d9umPPJaY8KKoO4/n/dOjh8FyNQM=; b=ZknOexdhH8bm6BMYZP4pp4MgvZyq+qhNsGe0oPMiludTZGUx4d2mmEAtwiflOM2pTR rFkHov+i0rfzoOo3syaIMSZV8ouVh74vX+C8MpOlao8rOhV6dpoQ4n5dk47UjPBwdlgq HdcSBjVeuFXQ4s2hcPwCag1QaolgBhucL6VIDeiFpLhuakG4XvcC/fUP3SO1FVUZnIm0 61C4/KPfcH6rPJx2wkVi06JONwahfRtfzZaoFoo1EtK7etqg4U/mf5W/3UOM5Olp2Q+m bz8m6I5C8kuE6lNN5JeP9NyS9AW4xkT6Ami5UvBJC24wskr0JEryYzIqjRdmclNRyB+L 8ZuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt43-20020a1709072dab00b0072f390774a6si236736ejc.769.2022.08.04.01.43.04; Thu, 04 Aug 2022 01:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237894AbiHDIYr (ORCPT + 99 others); Thu, 4 Aug 2022 04:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiHDIYm (ORCPT ); Thu, 4 Aug 2022 04:24:42 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C084C636; Thu, 4 Aug 2022 01:24:38 -0700 (PDT) Received: from mail-ej1-f52.google.com ([209.85.218.52]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MRnXY-1nqTl91Vb0-00TFTN; Thu, 04 Aug 2022 10:24:37 +0200 Received: by mail-ej1-f52.google.com with SMTP id c24so4771700ejd.11; Thu, 04 Aug 2022 01:24:37 -0700 (PDT) X-Gm-Message-State: ACgBeo1ODei5vSwkfmgxd+RMkNkBJYahML4QqrXyvnGlAAohjLkf5ouW 9HPhMcGAQfTwRweY2+WsTKG/+E51uYJRgn+Mpyg= X-Received: by 2002:a17:907:d0f:b0:72e:db1f:9b91 with SMTP id gn15-20020a1709070d0f00b0072edb1f9b91mr603460ejc.470.1659601476990; Thu, 04 Aug 2022 01:24:36 -0700 (PDT) MIME-Version: 1.0 References: <20220711122459.13773-1-me@linux.beauty> <20220711122459.13773-5-me@linux.beauty> <181efcca6ae.de84203d522625.7740936811073442334@linux.beauty> <18267b7a61f.12b26bd91245310.4476663913461696630@linux.beauty> In-Reply-To: <18267b7a61f.12b26bd91245310.4476663913461696630@linux.beauty> From: Arnd Bergmann Date: Thu, 4 Aug 2022 10:24:20 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/4] sample/reserved_mem: Introduce a sample of struct page and dio support to no-map rmem To: Li Chen Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , Rob Herring , Frank Rowand , Andrew Morton , Li Chen , Linux ARM , Linux Kernel Mailing List , DTML , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:yzIq8vPx8ZJNLHi/8z+h6JR8GjTYb5Rb2KDVoPjo6kuFclbusm9 n43hDbTALvs30gNLs4/GKVw2NRxBXHG6kL5K1bR2gzPvtWxyl9RUZIEen5QdoNgQUNt9N/a hnZVqZHGEVWzLPJhdGpoKlZMUFn16b02TLX+YyY8Rw4SXsUHoy1FUB0tEoeuaa1da4sDDNG iWB87lCpj+48aIUj8sZzA== X-UI-Out-Filterresults: notjunk:1;V03:K0:yldv/sAQqdM=:EwoksoRYbM8iRTgYdnh2Yp A5QecUZZ53vcBhiB3yv4FaJtYWM7cBBiXj3rQ41Eledd1Uvn7yLVKzZtJ5F5w3skDcy/qJjZD NaAA4ikEEUmwoWNv9dbZXSjkmptgV5r0v1FIQoPy3cOESZHhMJW+TcqHJK9gBUmW57qf965Gq PhULGktuvvzfqVB2hdg9hL+8EHNEaP2czv5Gc2GkBRvvAb7l8axDjou3VYxBlESI92Q0gCR4L dnlp04UkIlzB5bBRTCFscwfMYpxByiaTVEJe8iqClIKOJym4xgegmZZNwgYFvX4a5DZYHJpIg Nj3Ui4D6N0HjivDuvo5jdmjeakDxVbzoO2ZBtT6tNbmakH3/X90APX6gJKFYuoXBJzwlRTDtK IEpnBB/CTeWcweaJlUXD614sFiEdhwijVvkapA/2J6evO+e7teFmfNJGE83VQ1YfTVnoJfc9z IthtoNfsKKOf0vI61qvh4nBbpoiqD/i1W6Rd4Cck1jFwyyyADTXXxVb77r3eC7Pw3B+z4XIJ8 eCP7NAoF4fqM7Kgh2razmMMqZvCNW9h7Q7xyw/eeI6f5gdYgHQ4jmSsf9sI+ShKGPExr9Ag9k TVEp8dprAzmLeu3XqwhKgQBuO3jZ9G0gQQJRXf0noZ1pKnkdgdBx83VKg8Y79U97v17DwBzER Y3LlGdv8i5GAWfgMoH/fdi0JuB7wl5YC/zFARgpwxhhVwwElBa7SAcc6u2erOQr60qRxXPp6G WVB7Vd+PXQKtRXs+VK2iuHrQWhvl6Hg0wrdMBzrWY1GarGNhS2zN2T+FLDFnYUvdty1EL8JCk bzkUGGZVDlRKlGbFEsa4f7WUxAzccN8PB/p8XWoiTcuIFKg0husKD6e7WsAFve4+LjzuZ/dWo 03bsVvPzleYJgF0zWO/g== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On Thu, Aug 4, 2022 at 9:17 AM Li Chen wrote: > ---- On Tue, 12 Jul 2022 16:50:46 +0900 Arnd Bergmann wrote --- > > Does your hardware require a fixed address for the buffer? If it can be > > anywhere in memory (or at least within a certain range) but just has to > > be physically contiguous, the normal way would be to use a CMA area > > to allocate from, which gives you 'struct page' backed pages. > > CMA does support Direct I/O, but it has its own issue: > It does not guarantee that the memory previously borrowed by the OS will be returned to the device. > > We've been plagued by examples like this in the past: > Many other kernel modules/subsystems have already allocated much memory from both non-CMA and CMA memory, > When our DSP driver got probed then, cma_alloc will fail in that non-CMA system memory is not enough > for CMA memory to migrate. This part should at least be possible to solve by declaring the amount and location of CMA areas in the right way. It's not great to fine-tune the DT for a particular kernel's use, but if you know which other drivers require CMA type allocations you can find a lower bound that should suffice. Most coherent allocations tend to be long-lived and only for very small memory regions. If you have another driver that uses large or periodic dma_alloc_coherent() type allocations, you can consider either giving that device its own CMA area, or fixing it to use streaming mappings. Arnd