Received: by 10.213.65.68 with SMTP id h4csp229406imn; Wed, 28 Mar 2018 02:26:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx48aR5h0T+QOQ09CrX2VrOuHZCYyfoqvlNdysFlcWT7hTNcpB5pfIZnqDWWU9DPFCh1mglUk X-Received: by 10.101.97.205 with SMTP id j13mr1994786pgv.266.1522229213158; Wed, 28 Mar 2018 02:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522229213; cv=none; d=google.com; s=arc-20160816; b=a+bMBDvuYNsCsiHtm2OHpKL4VpCH3mykkjYprkiJz0p8P98nsm2zywlYpoEFnrrfAj QSTge44KXwMe/2CA8JblKp7r3qtwTCMPn0cqFauFlICJOXoRYsY3kQwQe45/yRjPwlea 6HcXwY9p6itg7z8sSlO+aCsTEoT47TFtlePYhsPfS9wX+EHoPXfGMP9xWUWGIA13/2k7 kA6SupicnX1Bv4OSWwzDhFB0Eog74mlk8tq3X9Xm39hC1u1aBbreA6kj5vA5fij1Rga9 JE2VKw9B3mRJjgDb838lrwOIdZDm67p/KNr9CX6jIIfz5oAIrF/m1JusThflfs7a7GUJ ZyoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=3OvVxc2DfKBb1f7l9/Q9wDIDg20rJGWwwxSWkMFwKRo=; b=Kwk97agGnMphQ3fBTZgPdayocJP5OFiPRpTWIJTXU0F+A3GQGDrywC45CKUGBQBv7t oMNXmM7mtHj71ZDTVE56pvv2Yj1ViIKlC5hs3UdoF/g+JPQ/7Qn7hxYttNY5+iuGHtEF I4nJmDVnCRMWqw6w5rU8uDU5ZWQ3fApr1Tw3wUID1WQXNL3BfjNSGBBGW9sLEwmMs1k4 g2n8ihB2/k096e6gICZe/UPfZkMj5+Of4+Ix0+5ktizxn1O2xNNi7huP0DX689kDdFJr vIBn3bfLryCvs7WYzzx7dblXL0k8/qtcmrZV5EgG0eY1HH/HWpNl5MvNAzTQJ6YyU0vQ nRbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg10-v6si3384657plb.30.2018.03.28.02.26.37; Wed, 28 Mar 2018 02:26:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753330AbeC1HfI (ORCPT + 99 others); Wed, 28 Mar 2018 03:35:08 -0400 Received: from mail.bootlin.com ([62.4.15.54]:49181 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751932AbeC1HfG (ORCPT ); Wed, 28 Mar 2018 03:35:06 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 6941520893; Wed, 28 Mar 2018 09:35:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id C30F620876; Wed, 28 Mar 2018 09:34:53 +0200 (CEST) Date: Wed, 28 Mar 2018 09:34:54 +0200 From: Boris Brezillon To: Peter Rosin Cc: linux-kernel@vger.kernel.org, Boris Brezillon , David Airlie , Nicolas Ferre , Alexandre Belloni , Takashi Iwai , Egbert Eich , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] drm/atmel-hlcdc: add command line option to specify preferred depth Message-ID: <20180328093454.4149fa3b@bbrezillon> In-Reply-To: <20180326073502.19259-1-peda@axentia.se> References: <20180326073502.19259-1-peda@axentia.se> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On Mon, 26 Mar 2018 09:35:02 +0200 Peter Rosin wrote: > I have an sama5d31-based system with 64MB of memory and a 1920x1080 > LVDS display wired for 16-bpp. When I enable legacy fbdev support, > the contiguous memory allocator invariably fails with the order-11 > allocation for a 1920x1080@24-bpp buffer (~6MB). But this HW can never > make any good use of RGB888, so that is a wasted attempt anyway that > would also waste precious memory should it succeed. > > Sure, I could rewrite user-space to go directly to KMS etc, and that > makes the (attempted) order-11 allocation go away, replacing it with > one order-10 allocation per application restart for a 1920x1080@16-bpp > buffer (<4MB). But after a few restarts, order-10 allocations start to > fail as well, which is only to be expected AFAIU. > > So, I'd rather not change user-space (which was originally written > to target a smaller display) so that I at the same time get the > benefit of an early pre-allocated fbdev frame-buffer that can be > reused over and over. But to do that I need to tell the driver that > 16-bpp is the preferred depth. Add a module parameter to do just that. > > Signed-off-by: Peter Rosin > --- > drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > I found some inspiration regarding naming and implementation here: > https://patchwork.kernel.org/patch/9848631/ > > I have found no feedback on that patch though, which makes me wonder if > I'm perhaps barking up the wronig tree? Hm, isn't that something you can already overload with the video= parameter? video=:[-] AFAIR, encodes the color depth, so what is the benefit of adding this new property to overload the default depth? Maybe I'm wrong and the default depth param is actually useful, but in this case we should probably make it generic since other drivers seems to need it too, and we might want to attach it to a specific display engine instance. Thanks, Boris > > Cheers, > Peter > > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > index c1ea5c36b006..f0148627c221 100644 > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > @@ -29,6 +29,11 @@ > > #define ATMEL_HLCDC_LAYER_IRQS_OFFSET 8 > > +static int atmel_hlcdc_preferred_depth __read_mostly; > + > +MODULE_PARM_DESC(preferreddepth, "Set preferred bpp"); > +module_param_named(preferreddepth, atmel_hlcdc_preferred_depth, int, 0400); > + > static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9n12_layers[] = { > { > .name = "base", > @@ -590,6 +595,7 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev) > dev->mode_config.min_height = dc->desc->min_height; > dev->mode_config.max_width = dc->desc->max_width; > dev->mode_config.max_height = dc->desc->max_height; > + dev->mode_config.preferred_depth = 24; > dev->mode_config.funcs = &mode_config_funcs; > > return 0; > @@ -658,7 +664,7 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev) > > platform_set_drvdata(pdev, dev); > > - drm_fb_cma_fbdev_init(dev, 24, 0); > + drm_fb_cma_fbdev_init(dev, atmel_hlcdc_preferred_depth, 0); > > drm_kms_helper_poll_init(dev); > > @@ -756,6 +762,16 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev) > struct drm_device *ddev; > int ret; > > + switch (atmel_hlcdc_preferred_depth) { > + case 0: /* driver default */ > + case 8: > + case 16: > + case 24: > + break; > + default: > + return -EINVAL; > + } > + > ddev = drm_dev_alloc(&atmel_hlcdc_dc_driver, &pdev->dev); > if (IS_ERR(ddev)) > return PTR_ERR(ddev); -- Boris Brezillon, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com