Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4193033imw; Tue, 12 Jul 2022 03:46:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s+hsuuOCU0AHFvLw8Cy+652U/mH2YNHRVR+VNmbk4gLQYq4AAUPkclwcqoDjmUhwk/Fs9E X-Received: by 2002:a17:907:3d92:b0:726:39f9:4a33 with SMTP id he18-20020a1709073d9200b0072639f94a33mr22767202ejc.766.1657622761668; Tue, 12 Jul 2022 03:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657622761; cv=none; d=google.com; s=arc-20160816; b=L7FeglfegxW8R7ZZlQblByA6lui3d9lxzXq50FQSIk9Wqp7SWnDKWX4mCC2IhDa5GW wRcEa7eIHK3mevNGvsixhz8EVt+QkCc2Y5FR3SzL2Cpj5mNIISV+afjwRy3F0URJ3bva otsF33DlnE1AFk+pffkRcd3DJ+VpcTaRvIVv2Ecf0UetarEaESlCGSTo9MVngoCs/NE0 wibYdqquFjsGroc27AjsShMe/vkvpxQHELE1/psT5rOHi6SiKeZULh0jkv7bT/fZ75fK olUYXCHU2Z9GsxlfOM8ZCRk7BuAI9ZQ5FtcbJwWmR5eLiT/drjXilIuv5N3dpebslTZi dhyw== 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=KRONuOqE173JKKYk7tJ10sKKRmxjEKn8t210xbfjixY=; b=GCsEEim58e2gtKFqXM/N7TMdNYvJB2a3PlqxqAb1zJlPEuJjWfeNZs24QdEmqNbZHh UhBtE1sjEfi/uJPew+WpxhZfsEYXQpb0yBW0G/i1p2ZU7TNJqYkD9vpkUDgXrSJgSLEK ax6LszI0K/+jqkPkjEB5k6aUdkZhbSfiwcygTPqrFn7YZ5ktwwI4XXc60raAWM+pHO3w UfrD5UpuYghDkA87f2lbvth3XTHRY8JqDboSlcRv+hIG6dYKcYUhA8WrTE9ac2l1bVb8 PBIlSgba6DbXGo9s93huHCXSx0p89mfaU8Mv+/l7z3dHVXnRah/PVyxrQCD2dn35ub2V /Hvg== 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 sa40-20020a1709076d2800b007219be3906bsi5118182ejc.578.2022.07.12.03.45.12; Tue, 12 Jul 2022 03:46:01 -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 S232848AbiGLKIg (ORCPT + 99 others); Tue, 12 Jul 2022 06:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbiGLKId (ORCPT ); Tue, 12 Jul 2022 06:08:33 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CBFAB6A5; Tue, 12 Jul 2022 03:08:30 -0700 (PDT) Received: from mail-yw1-f171.google.com ([209.85.128.171]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N95Rn-1nWubb3jkt-016BfD; Tue, 12 Jul 2022 12:08:29 +0200 Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-31cf1adbf92so75818957b3.4; Tue, 12 Jul 2022 03:08:28 -0700 (PDT) X-Gm-Message-State: AJIora9+AI63I3LjNh7KOVK/ZJk/GkVX8OLiQHJ85sJek45pCnLlxBEx rgwm6yipqrSCLBX79OASXUHEDLaNibLkF/s4tc4= X-Received: by 2002:a81:1914:0:b0:31c:e12a:f33a with SMTP id 20-20020a811914000000b0031ce12af33amr24610715ywz.209.1657620507572; Tue, 12 Jul 2022 03:08:27 -0700 (PDT) MIME-Version: 1.0 References: <20220711122459.13773-1-me@linux.beauty> <20220711122459.13773-5-me@linux.beauty> <181efcca6ae.de84203d522625.7740936811073442334@linux.beauty> <181f1d88b64.e2eb2601586551.453778983551010212@linux.beauty> In-Reply-To: <181f1d88b64.e2eb2601586551.453778983551010212@linux.beauty> From: Arnd Bergmann Date: Tue, 12 Jul 2022 12:08:10 +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:Pnojn1jCOJfUaOK/YyrDsJCc2p4gM9GmSs9xBtBbrAKJfsYznNF DrvfNt9PKvSA9vZCtHG20w1N7bLQV01zQdNEYmr6a0WO8/adPZtUlmx+WBgyWBdkVxczuAD 13xvlxQUfyssiiOXH4KgqwjYAGwyGmXXWWy8rDPPaGaOyfYAwVaSUaiaOK0r8ed724uqhhT Os0jG00RotVlGVAhL2fiQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:nbUa4DFy3kc=:2M8dSRt9xoxJ5LTzynVMzU gDj1R7IM0E3AA8ub/eJpmAoi9uKOBfb3kSgGp2TBaTUDkyEY0CFCq5azAmLztgy2HU+2n3vx7 XZlsxFiEAZL91dNtpcWZze0Zkgowd7PFFKf5UAag8Aj2uc1xlHnixdKlHx7oJdrCLUy7Wfv7W sIV1xsVzi98HXsG6NsgJcZjf5wzsmQcSL1FxxsRNl3C/jEpmDw4KBDSd0EqJ50Jlw/1cyQOHX XqHYdtg6BJ2aNoBBdqKE8pz2jsoKWtBdcLIweQk+wNYr6FmWKbPmcIXbWPBeeKIoAFJAk9S26 bvMa+ntaMhutUoqTpiVA0SFkkamfu62sg7nDKL/XS/zRueHJvFi11sSGLIWcGRZp5eCfPBD2d CeWsgnznUBp30bwww/+PV9aeJd1XSGD8i51MxqRM1tkcjF/lih2/oD1PmCLAf1Alz7jh2Vr1n lCuF+Bv+kdkbZ9W5aTFoSxYIVWlRt/ZfMnq/A2lBiODFSKtMsMBhheZ8QXWUK1PSf2zUOpZrd CevwmKU5HYczhjoZmrycRh/WdpMVg8KcFhnGPLSrKdY1siASTu4Br94o+H4ykkZRZqJTXldUv SRuRhcpdImygwXJ1Vj5AH1NAdfiOUS24+QMbAimdu3cU5/Ray0vjRMvLzxz5L5bB0kb5RG/VN LnMYUaXyN7prw0AB3ASw+HU4it36F7TxUuTb5/sI7wbfinFwmypy/89h/bqDhdVg286zWCrLO uU+53NynfW8U01hyngURKIDqWSu6PN2ZbQQAbSSjGovPx2ZOIACRYqILs3dcbZPLoBYcI8i7J s7pVk1IHjcpHe4wQKCe8QP1QxDK3nNJfytQlsFkrPDdfwrdxgXWy/Fh59p0mW77ARF0IYRVdZ Q3ZWIydaWZzkbk36iBJyrsSXxlFw3bv0ViShZFdxM= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, Jul 12, 2022 at 11:58 AM Li Chen wrote: > > On Tue, Jul 12, 2022 at 2:26 AM Li Chen wrote: > > > ---- On Mon, 11 Jul 2022 21:28:10 +0800 Arnd Bergmann wrote --- > > > > On Mon, Jul 11, 2022 at 2:24 PM Li Chen wrote: > > > > The problem here is that the DT is meant to describe the platform in an OS > > > > independent way, so having a binding that just corresponds to a user space > > > > interface is not a good abstraction. > > > > > > Gotcha, but IMO dts + rmem is the only choice for our use case. In our real > > > case, we use reg instead of size to specify the physical address, so > > > memremap cannot be used. > > > > 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. > > The limitation is our DSP can only access 32bit memory, but total dram is > 4G, so I cannot use > "size = <...>" in our real case (it might get memory above 4G). I'm not sure if other vendors' DSP also has > this limitation, if so, how do they deal with it if throughput matters. This is a common limitation that gets handled automatically by setting the dma_mask of the device through the dma-ranges property in DT. When the driver does dma_alloc_coherent() or similar to gets its buffer, it will then allocate pages below this boundary. If you need a large contiguous memory area, then using CMA allows you to specify a region of memory that is kept reserved for DMA allocations, so a call to dma_alloc_coherent() on your device will get contiguous pages from that area, and move other data in those pages elsewhere if necessary. non-movable data is allocated from pages outside of the CMA reserved area in this case. Arnd