From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753028AbdKIBcE (ORCPT ); Wed, 8 Nov 2017 20:32:04 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:49939 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbdKIBcC (ORCPT ); Wed, 8 Nov 2017 20:32:02 -0500 From: Laurent Pinchart To: Geert Uytterhoeven Cc: Jacopo Mondi , Yoshinori Sato , Rich Felker , Linux-sh list , Linux-Renesas , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] sh: migor: Reserve memory block for CEU Date: Thu, 09 Nov 2017 03:32:07 +0200 Message-ID: <1691054.qjv9XWrNm9@avalon> Organization: Ideas on Board Oy In-Reply-To: References: <1510164346-21134-1-git-send-email-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On Wednesday, 8 November 2017 20:31:22 EET Geert Uytterhoeven wrote: > On Wed, Nov 8, 2017 at 7:05 PM, Jacopo Mondi wrote: > > A memory region for CEU video buffer has to be reserved during machine > > initialization. > > > > Originally, it was allocated through DMA API helpers and stored in the > > second IORESOURCE_MEM entry, to be later remapped by the CEU driver with > > a call to 'dma_declare_coherent_memory()' > > > > As Linux does not allow anymore to remap system RAM regions with > > 'memremap' function, sh_mobile_ceu driver fails when trying to remap the > > memory area: > > > > WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n", > > > > &offset, (unsigned long) size) > > > > from 'memremap()' function in kernel/memremap.c > > > > To avoid hitting that WARN_ONCE() and have memory successfully remapped, > > reserve a region using '.mv_mem_reserve' member of SH's 'struct > > sh_machine_vector' to make sure memory is reserved early enough, and > > removed from the available system RAM. > > > > This is similar to what happens on ARM architecture with > > 'arm_memblock_steal()' function. > > > > Suggested-by: Laurent Pinchart > > Signed-off-by: Jacopo Mondi > > I assume this failure isnot limited to CEU on Migo-R, but applies to > the other 24 callers of platform_resource_setup_memory(), too? > > Can platform_resource_setup_memory() be fixed instead, or is that difficult > due to the need to reserve the memory very early in the boot process? That's exactly the problem, memory needs to be reserved early at boot, earlier than the current call sites of platform_resource_setup_memory(). The real fix in my opinion would be to use CMA, but implementing CMA for SH is out of scope of Jacopo's work on the CEU driver. And that would still require patching all the 24 callers of platform_resource_setup_memory() anyway. -- Regards, Laurent Pinchart