From patchwork Wed Aug 8 16:09:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10563435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A64414C0 for ; Sat, 11 Aug 2018 12:06:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBA602A2B8 for ; Sat, 11 Aug 2018 12:06:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCD462A529; Sat, 11 Aug 2018 12:06:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 226D82A2B8 for ; Sat, 11 Aug 2018 12:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3090C6E1C7; Sat, 11 Aug 2018 12:05:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on0619.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::619]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8468B6E5C7 for ; Wed, 8 Aug 2018 16:09:38 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by VI1PR04MB4301.eurprd04.prod.outlook.com (2603:10a6:803:3f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Wed, 8 Aug 2018 16:09:35 +0000 From: Leonard Crestez To: Stefan Agner , Marek Vasut , Shawn Guo Subject: [PATCH v4 5/5] drm/mxsfb: Switch to drm_atomic_helper_commit_tail_rpm Date: Wed, 8 Aug 2018 19:09:02 +0300 Message-Id: <172ea0eeed9f129632cc1e279b922e637dff088b.1533743954.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: DB6PR02CA0004.eurprd02.prod.outlook.com (2603:10a6:6:15::17) To VI1PR04MB4301.eurprd04.prod.outlook.com (2603:10a6:803:3f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: faf649cb-ff57-46e8-0e5d-08d5fd495633 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4301; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4301; 3:QIrcTrEVi4Wv3YshR98XWFRbvG0LGpdeBn9LentCBmzaCmIQUeYG4gLicCEVF2W+uazlz1I7LGaIEZNAADg10+pELxT2R/3IDViduOlWeKeEEGoXkbX8OJYYlnsfPwbn7TjHzkO7lwIWXd+1xoadYn85UzSBlojBSO+4XEgyFOn/STcK0beXjKYDG/0yjc5RlDGvR1leTjMJLTXsHdf2+KTQeeklJ38wVx8AHy6N2sH6fxIZRhBl7QqYD0a7u80+; 25:1rnwf2PVPGdTH9Kg7+X+ozWdKem3jQYIJCGL20keD9FdfplUjphiWIXmfYo9CcMctAU7UNpCMRm8Jh/awu493Vdu9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4:QRpveA8fixJVeLRzYm6PIu+spppSzChWCMWzn9+wjvvRzQ2W1CT4d1mBkDm6nbeD62DXtt9Gvuw8nNqocZoDdxAsDW+oW2ZIGPi2ZHZT58KqKmlPYEyQqfYm+gnN7pK3Wnw7z4WE4sG2GnND/Cfr37woFRPiTcVEVhmdDCHrMMoGty+/xsfx4X910snnLKIQL6hzKfMaGtm+UGg/3QlrExATr37XYo6ZMlwCkiooGchl2BAPkgb+L3m8J1j2r+SdKg9lJix513PX0X64LP95wEpJdPOZscexOc2TeYiIRUtCMqk09cpUK0zLtBGP/1k0+Lw0UQxxqsBINdwwH2LnPzjf7Ro6VdUfAfMXqPgjx+U= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(17755550239193); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB4301; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4301; X-Forefront-PRVS: 07584EDBCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(39850400004)(376002)(396003)(346002)(366004)(136003)(199004)(189003)(66066001)(7736002)(76176011)(47776003)(6512007)(81166006)(68736007)(81156014)(25786009)(8676002)(6666003)(110136005)(54906003)(36756003)(14444005)(305945005)(106356001)(105586002)(53936002)(50466002)(6486002)(97736004)(48376002)(86362001)(4326008)(3846002)(5660300001)(26005)(486006)(16526019)(186003)(316002)(2906002)(16586007)(6116002)(6506007)(44832011)(478600001)(8936002)(956004)(11346002)(2616005)(50226002)(386003)(446003)(476003)(51416003)(52116002)(118296001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4301; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB4301; 23:KKEEZg0OLqhOYBVO38jYtB4cLLmZfGQFTABQLgpv6?= RQ1zbfyzEmMIkLN8HuuYZkJczaGDUzQOkeBmSWyb0j9a+nqGkpWmnNUlWCxNQjSch/Llg2SCoEqeB6ddfn5Q0DRvBS2Tofv4uu54B3viHVUadLccvlVgmTgboJPBR6Qdyc1TjDBVUIdAvbju2kQNhCr2rbJFSaBlsenwIUjrnt7LCrq14WcDGKotBtc4rJ2RF/qvm//NdhGtPAaNqxXIyYHGtO/mJwjgI8j4kLp1BekhWA2w3xryAwcX071TkiKZnJM2I92tIBywDi9B/wAB15Up0f0Zpg/LXeq/uVbj26brvcTo08N56/gAUgfTXEtrH7wDL7uGKoOfFy7SrT3OlulhCoFEsYhLx4ykCZ4TmQPcDXmwffKIagKbUzGvKEyparo7G6No7C7vvqKrTt2BpzYRLJvm/Rysec1jnN+RsNIzPNr01xppoHZsKxF26LYtVHnboNfMd0zk7Y0JjH/fPnc0nppTZB+icKIv8iIG/JyEcC4BF7Wf9GhlRKvYViuyjtfZeLa3uMyASJiy6g0nE+tuFXw5ZDGgC7PsMPhSkRfcl7xP9pYeW8aMsqPsmOPh6TeHyU7VSyqED40U4iz5TuO1onFavc37uIzoF6p/NQGTbfdZaLrRCj8bJJp9GG8QoUElD66v4b0qdSQ96nJmw9/N8DYTq0iPNdfzAxGA30gg9EjKB+TavrZeJu+wBys+j6iQZCSt2EqW6Nw4i6d88O4WkPkc1TAy63+0DLg3kYwcTKtm4UM53Hur2ZgpBos4EcHtEthLWXX4kfYbRBCPVC17Z8bZpNUYt271zjgNWV12iLXB3tQIxbygH6GNCDcOhTJuI9JWTt1bq6/JHinpGC0UzOwWi0QUatTjWq8sMePTbpuTJX2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jiJiQoYdLK8yJVqUC1rwGVr8iXiCp6ONi+dSp2rnfgb7biZYWjRKjB66lYFORi3kVf4zSyCEVfD3w0sTc96Y79h2kEo9vnH1cYjYkEc3wDNLjB9ghYk7eaFUTYvG4Rt8b32MbS3dattiB24Gcs6dVwMRrVqMTJus+rkZc07fuVhqpBFKA==; 5:9epmmeeh0602XlssYix2bbD/yoJ82hk62nbF/cxEmsZcqLhHUV8Eoc5VJQrbpEYz3JI2wYdCF8JCDdVe62vT1Fi2CpD9097EfLjgMkogqJQuVjy8vIf59i/cpzOCS2bAmM0w7+90WiyN1BVZLw5s9c5rxCoqRl9K2iV+K7a7HFI=; 7:MAvVU+LYVQU1P9qSGIWQdBzM6FWQOGuJICT8eHCm+y6eruf0R/pSdT6iEDiShb1aEVXNPjeQjWuHW5YP1XxfmNUIE73vnl+77DBNiill8xiKURFVdtQoBwtzWFG51K+4Xw8Mw+b0LwBIJbCObYEFZ4qY/l7y58X7xUm0bADno1NycIluqV4bTtYO8lj6bqLYPeI+4wwR5Eo5G4P1sgvqfz+DeIausdbq2fAljQIbREORxsSJit1I5xGGmohXl89m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2018 16:09:35.0294 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: faf649cb-ff57-46e8-0e5d-08d5fd495633 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4301 X-Mailman-Approved-At: Sat, 11 Aug 2018 12:05:13 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , kernel@pengutronix.de, Anson Huang , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Fabio Estevam , linux-imx@nxp.com, Robert Chiras Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The lcdif block is only powered on when display is active so plane updates when not enabled are not valid. Writing to an unpowered IP block is mostly ignored but can trigger bus errors on some chips. Prevent this situation by switching to drm_atomic_helper_commit_tail_rpm and having the drm core ensure atomic_plane_update is only called while the crtc is active. This avoids having to keep track of "enabled" bits inside the mxsfb driver. This also requires handling the vblank event for disable from mxsfb_pipe_update. Signed-off-by: Leonard Crestez Suggested-by: Stefan Agner Reviewed-by: Stefan Agner --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index d797dfd40d98..5777e730085b 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -96,10 +96,14 @@ static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = { .fb_create = drm_gem_fb_create, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; +static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = { + .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, +}; + static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe); @@ -113,15 +117,25 @@ static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe, static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe) { struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe); struct drm_device *drm = pipe->plane.dev; + struct drm_crtc *crtc = &pipe->crtc; + struct drm_pending_vblank_event *event; drm_panel_disable(mxsfb->panel); mxsfb_crtc_disable(mxsfb); drm_panel_unprepare(mxsfb->panel); pm_runtime_put_sync(drm->dev); + + spin_lock_irq(&drm->event_lock); + event = crtc->state->event; + if (event) { + crtc->state->event = NULL; + drm_crtc_send_vblank_event(crtc, event); + } + spin_unlock_irq(&drm->event_lock); } static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { @@ -232,10 +246,11 @@ static int mxsfb_load(struct drm_device *drm, unsigned long flags) drm->mode_config.min_width = MXSFB_MIN_XRES; drm->mode_config.min_height = MXSFB_MIN_YRES; drm->mode_config.max_width = MXSFB_MAX_XRES; drm->mode_config.max_height = MXSFB_MAX_YRES; drm->mode_config.funcs = &mxsfb_mode_config_funcs; + drm->mode_config.helper_private = &mxsfb_mode_config_helpers; drm_mode_config_reset(drm); pm_runtime_get_sync(drm->dev); ret = drm_irq_install(drm, platform_get_irq(pdev, 0));