From patchwork Wed Feb 3 01:06:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 8196681 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5D8C69FBF9 for ; Wed, 3 Feb 2016 01:05:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A5582026D for ; Wed, 3 Feb 2016 01:05:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B1E2720263 for ; Wed, 3 Feb 2016 01:05:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49B6E6E643; Tue, 2 Feb 2016 17:05:54 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kmu-office.ch (mail.kmu-office.ch [178.209.48.109]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC7026E624 for ; Tue, 2 Feb 2016 17:05:52 -0800 (PST) Received: from trochilidae.toradex.int (unknown [IPv6:2601:602:8b00:ffde:3e97:eff:fe92:db3b]) by mail.kmu-office.ch (Postfix) with ESMTPSA id A25775C1759; Wed, 3 Feb 2016 02:04:24 +0100 (CET) From: Stefan Agner To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/2] drm/fsl-dcu: use flat regmap cache Date: Tue, 2 Feb 2016 17:06:18 -0800 Message-Id: <1454461578-8649-2-git-send-email-stefan@agner.ch> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454461578-8649-1-git-send-email-stefan@agner.ch> References: <1454461578-8649-1-git-send-email-stefan@agner.ch> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1454461466; bh=j4N9uNFOfcR82iwle/vLnO/J9QVOxdMJzoFF6swrRQ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=XsvrsXe60M2I5hVwG3ero2oewW08g20I5akG132a0A7ildripVu3HcKQaz9s/y1YFq6pNsYvnLuoWPOflnaaITjizCW9Dy+cAjrD8JZlJKFFrebRxTvrfpR9JiRMrSuo2kA+OCCsFVKk8bgWJJf402F0Kl1zzc2bMkOBycI/R3s= Cc: meng.yi@nxp.com, alison.wang@freescale.com, daniel.vetter@ffwll.ch, linux-kernel@vger.kernel.org, Mark Brown X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using flat regmap cache instead of RB-tree to avoid the following lockdep warning on driver load: [ 0.697285] WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:2755 lockdep_trace_alloc+0x15c/0x160() [ 0.697449] DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)) The RB-tree regmap cache needs to allocate new space on first writes. However, allocations in an atomic context (e.g. when a spinlock is held) are not allowed. The function regmap_write calls map->lock, which acquires a spinlock in the fast_io case. Since the FSL DCU driver uses MMIO, the regmap bus of type regmap_mmio is being used which has fast_io set to true. The MMIO space of the DCU driver is reasonable condense, hence using the much faster flat regmap cache is anyway the better choice. Signed-off-by: Stefan Agner Cc: Mark Brown --- Changes since v1: - Do not move drm_dev_alloc drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 18 +++++++++++------- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h | 6 ++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index e01c813..9c21aad 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -36,11 +36,11 @@ static bool fsl_dcu_drm_is_volatile_reg(struct device *dev, unsigned int reg) return false; } -static const struct regmap_config fsl_dcu_regmap_config = { +static struct regmap_config fsl_dcu_regmap_config = { .reg_bits = 32, .reg_stride = 4, .val_bits = 32, - .cache_type = REGCACHE_RBTREE, + .cache_type = REGCACHE_FLAT, .volatile_reg = fsl_dcu_drm_is_volatile_reg, }; @@ -260,12 +260,14 @@ static const struct fsl_dcu_soc_data fsl_dcu_ls1021a_data = { .name = "ls1021a", .total_layer = 16, .max_layer = 4, + .max_register = LS1021A_DCU_MAX_REGISTER, }; static const struct fsl_dcu_soc_data fsl_dcu_vf610_data = { .name = "vf610", .total_layer = 64, .max_layer = 6, + .max_register = VF610_DCU_MAX_REGISTER, }; static const struct of_device_id fsl_dcu_of_match[] = { @@ -331,6 +333,13 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) return ret; } + id = of_match_node(fsl_dcu_of_match, pdev->dev.of_node); + if (!id) + return -ENODEV; + + fsl_dev->soc = id->data; + + fsl_dcu_regmap_config.max_register = fsl_dev->soc->max_register; fsl_dev->regmap = devm_regmap_init_mmio(dev, base, &fsl_dcu_regmap_config); if (IS_ERR(fsl_dev->regmap)) { @@ -338,11 +347,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) return PTR_ERR(fsl_dev->regmap); } - id = of_match_node(fsl_dcu_of_match, pdev->dev.of_node); - if (!id) - return -ENODEV; - fsl_dev->soc = id->data; - drm = drm_dev_alloc(driver, dev); if (!drm) return -ENOMEM; diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h index 2a724f3..7c296a0 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h @@ -114,8 +114,6 @@ #define DCU_UPDATE_MODE_MODE BIT(31) #define DCU_UPDATE_MODE_READREG BIT(30) -#define DCU_DCFB_MAX 0x300 - #define DCU_CTRLDESCLN(layer, reg) (0x200 + (reg - 1) * 4 + (layer) * 0x40) #define DCU_LAYER_HEIGHT(x) ((x) << 16) @@ -155,6 +153,9 @@ #define DCU_LAYER_POST_SKIP(x) ((x) << 16) #define DCU_LAYER_PRE_SKIP(x) (x) +#define VF610_DCU_MAX_REGISTER 0x11fc +#define LS1021A_DCU_MAX_REGISTER 0x5fc + #define FSL_DCU_RGB565 4 #define FSL_DCU_RGB888 5 #define FSL_DCU_ARGB8888 6 @@ -175,6 +176,7 @@ struct fsl_dcu_soc_data { unsigned int total_layer; /*max layer number DCU supported*/ unsigned int max_layer; + unsigned int max_register; }; struct fsl_dcu_drm_device {