Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3851613imw; Mon, 11 Jul 2022 17:49:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vltn+Nz4Pi4RF86ilWvL/7kiuioPRxf6G4oAzp/r5Q0o8gHQ+E/4s0vcH/1BLjBPn1JXfx X-Received: by 2002:a17:907:6d1e:b0:72b:4add:75db with SMTP id sa30-20020a1709076d1e00b0072b4add75dbmr10670195ejc.717.1657586998056; Mon, 11 Jul 2022 17:49:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657586998; cv=pass; d=google.com; s=arc-20160816; b=auGNA2cjD7NsNBFm182e8gug4JuOPLz4juc4Z2pYVNuVRs18y5i1TrCsYa1rBKniY0 ghErRTcUiOPhIpQgeOU1Pio4wB8SnCaKv05/q10yaGzg/MYkreqc2QL9KwEvRiSYZ96F 0Ft8WvFUs4lfjUC62V+DtUsCDK8Vk3BAbzWE+4iks0Wn3dh81b4+L+IYuH6+/Gr0cBFa Dz+FV8O5ZDnjjSBzJ4xNL3G6BRg9itgJ5r4kWFwYfofuGWrqbOdm7RtmlOVWIrNy7LYi CLHVRw1lcxJlMeLXbp/VTn3pIUxoZ4aZBndHR51hXZEh6CtkjFpEG2dicwvi1NKg+tdl 9m9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=jFBczO4Z9TfDcxdB0ArqJHoDxH8ici/TI/3XLJb7X3M=; b=knHZxrlS0cIae4F/nQ4e+rkpA2kJweBb5YUtfvetWMHwZZpXBZHy6PPxSlxkiwDt7+ pwqXY3viIaypKc7vjsyWyZeDrKo0Nc9jA2Rzf5u7B06cH/IDSyXsapmuImwBHPwxiOf6 uv/SVCPbXO//aOUOiOPnkEMX8GCUvjDmitmarmQEE+TcjNLEKJK4JAkCqjz8Cyd18gn6 Y4DR6WI2JNGLQ2E9dyIrpvLgx4XpjxMD5u0uMCRGC2egT8LMkJCJl3iTM5w4XiD0vKti L85qqHtt05WaRm9Uuu015stlZhVsJwTuEE4/pIxLs8OXU6MVjuXf/SNj2uTxmJZI76Gu U3og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.beauty header.s=zmail header.b="Qxdai5D/"; arc=pass (i=1 spf=pass spfdomain=linux.beauty dkim=pass dkdomain=linux.beauty dmarc=pass fromdomain=linux.beauty>); 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 u22-20020a509516000000b0043aa5c0495esi13380896eda.281.2022.07.11.17.49.33; Mon, 11 Jul 2022 17:49:58 -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; dkim=pass header.i=@linux.beauty header.s=zmail header.b="Qxdai5D/"; arc=pass (i=1 spf=pass spfdomain=linux.beauty dkim=pass dkdomain=linux.beauty dmarc=pass fromdomain=linux.beauty>); 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 S229996AbiGLA0d (ORCPT + 99 others); Mon, 11 Jul 2022 20:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiGLA0a (ORCPT ); Mon, 11 Jul 2022 20:26:30 -0400 Received: from sender4-op-o14.zoho.com (sender4-op-o14.zoho.com [136.143.188.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 395F22DA85; Mon, 11 Jul 2022 17:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657585576; cv=none; d=zohomail.com; s=zohoarc; b=mtb8jFe3/4+KkVb5dM6qz1JRAB7qefaldXT89p6pXK6rdhAIRyC5ZqAWeOEKLZ1IWKCuEgkZi2zBDUe12Nhfr/JdzYaBcjAFKVPqdnTntFyAB6XUgp3BQxG8saRVwkU4Lih2mFTYKjRBmKYTu+dhShXWYpPOt2KUY3j8OHAdaWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657585576; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jFBczO4Z9TfDcxdB0ArqJHoDxH8ici/TI/3XLJb7X3M=; b=cdZcTbIsOwFaXI2jkalL2uFsW/IBksDLq9RALhunhNE69mFkn9TliQ7HZ2QNcanWnH/JzCon1YZK5cvBziPhu5Cqn72ZPd7q4640LwIRQNaXeTbBXOII0RXZkOiRh3qoxftIyFp4r905dQntTSvMQEMi0gsD0kAz7sp9dJGUS/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1657585576; s=zmail; d=linux.beauty; i=me@linux.beauty; h=Date:Date:From:From:To:To:Cc:Cc:Message-ID:In-Reply-To:References:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=jFBczO4Z9TfDcxdB0ArqJHoDxH8ici/TI/3XLJb7X3M=; b=Qxdai5D/7eund7w0ApVgHQPm3iT1PEKhQUQr/EKe6+bZWVe6dGmw46m7vQzLluIt KqVJkuBBUm+pEf0bNY/sg1MtjYSuEEev22U45PkSvtEbg4YwgfUVkOrqR0rfLZFGusa 3/CwneaPhUp564pkpdxcZkMdvtNdwWP9q9ZmqKFI= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1657585575627718.8384328597048; Mon, 11 Jul 2022 17:26:15 -0700 (PDT) Date: Tue, 12 Jul 2022 08:26:15 +0800 From: Li Chen To: "Arnd Bergmann" Cc: "Catalin Marinas" , "Will Deacon" , "Rob Herring" , "Frank Rowand" , "Andrew Morton" , "Li Chen" , "Linux ARM" , "Linux Kernel Mailing List" , "DTML" , "Linux-MM" Message-ID: <181efcca6ae.de84203d522625.7740936811073442334@linux.beauty> In-Reply-To: References: <20220711122459.13773-1-me@linux.beauty> <20220711122459.13773-5-me@linux.beauty> Subject: Re: [PATCH 4/4] sample/reserved_mem: Introduce a sample of struct page and dio support to no-map rmem MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_RED 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 Hi Arnd, ---- On Mon, 11 Jul 2022 21:28:10 +0800 Arnd Bergmann wrote --- > On Mon, Jul 11, 2022 at 2:24 PM Li Chen wrote: > > > > From: Li Chen > > > > This sample driver shows how to build struct pages support to no-map rmem. > > > > Signed-off-by: Li Chen > > Not sure what a sample driver helps here if there are no actual users in-tree. > > It would make more sense to merge the driver that wants to actually use this > first, and then add the additional feature. Totally agree, but we plan to start rewriting our video driver in a long time, it has many legacy codes and I need to rewrite a lot of codes to migrate to v4l2. That's why I also submit a sample driver here: to make the review progress easier and don't need reviewers to read video driver codes. > > +/* > > + * dts example > > + * rmem: rmem@1 { > > + * compatible = "shared-dma-pool"; > > + * no-map; > > + * size = <0x0 0x20000000>; > > + * }; > > + * perf { > > + * compatible = "example,rmem"; > > + * memory-region = <&rmem>; > > + * }; > > 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. > > > + vaddr = reserved_mem_memremap_pages(dev, rmem); > > + if (IS_ERR_OR_NULL(vaddr)) > > + return PTR_ERR(vaddr); > > Using IS_ERR_OR_NULL() is usually an indication of a bad interface. > > For the reserved_mem_memremap_pages(), you should decide whether to return > NULL on error or an error pointer, but not both. Thanks, will fix in v2. > > Arnd >