From patchwork Mon Sep 17 13:42:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10604023 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 5C31213AD for ; Tue, 18 Sep 2018 09:59:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B77429CA2 for ; Tue, 18 Sep 2018 09:59:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EE2829C91; Tue, 18 Sep 2018 09:59: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 D55E029C91 for ; Tue, 18 Sep 2018 09:59:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EB756E3AF; Tue, 18 Sep 2018 09:58:49 +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-eopbgr30067.outbound.protection.outlook.com [40.107.3.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 64DB888FE1 for ; Mon, 17 Sep 2018 13:43:08 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Mon, 17 Sep 2018 13:43:05 +0000 From: Leonard Crestez To: Daniel Vetter , Philipp Zabel , Marek Vasut Subject: [RESEND 5/5] drm/mxsfb: Switch to drm_atomic_helper_commit_tail_rpm Date: Mon, 17 Sep 2018 16:42:15 +0300 Message-Id: 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: HE1P190CA0028.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::17) To AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9fa18ec-5485-45b4-0c0e-08d61ca37ffb X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4290; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4290; 3:xuiDAKE4I9QOwN2MtNJCv5H3BncUb5EejHoFN6wbUkj5USRd/DOI9vdmH9U8wF3O+3FBZQrdN+bxRo5oMj+5TLk4YiNKQ3QAlNVGqObDGJit+QKWu4CP9zlWUFfEeMegsfI/f55rEHitJwVv6+1p7HPjR5pvlWsq4LQX7ZZCLF4Fq0EeTP1YDMKEwevErh1e6PYrh28Us+vuXDI5lGUMWSXHyv/dQN52ISvizQG99t8q0bBLrxITaF1B6p2Av1C/; 25:OEtnTiF6Z+svmQYu56Qst3KuzSSWErJxSwUnARererBuSZ7ppO3kDNen04Zamp4M7GutdH+IAB+IN7s3cGne0Be98D96M5arURtGckh8H08S82V/HO1ydrCIBuIFX8XFTYjqyJtIpWPwwGf4J8+IZRS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T3s4YsRcCJM8tKQKe2HR+WQ+zslfMTM88Z/0jcJ2IpP/TQqwTU0C60jLMv0knjSkG4NuXZm9KqhTrHV09gDvycl1/cU+6cnsG6Dwii6x2ze0Awmx2WQ9lCoQvEskxFabfcDDz3GsQVHu+ksX/jEz61tMzCUkGtQaP+QcOAi++R1TgU7614aT+7jTbHAhj1AbMils9hhG+KOvycdI5GoGptRuPpCJjlPxdVaj+MS3SCsBJ+BaX+UMx6tQi5UgkmqdLj+vgp1YY6P/cjYY0RE+l7aLGbTpa+rHpC4zkkUWeo= 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)(93006095)(93001095)(3231355)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699050); SRVR:AM0PR04MB4290; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4290; X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(376002)(396003)(346002)(136003)(39860400002)(366004)(199004)(189003)(6506007)(81166006)(81156014)(8936002)(14444005)(50226002)(478600001)(16526019)(186003)(106356001)(3846002)(6116002)(105586002)(97736004)(47776003)(26005)(68736007)(50466002)(48376002)(66066001)(6512007)(2906002)(5660300001)(118296001)(11346002)(446003)(386003)(110136005)(4326008)(7736002)(6666003)(476003)(956004)(2616005)(54906003)(51416003)(16586007)(86362001)(305945005)(6486002)(44832011)(25786009)(53936002)(36756003)(8676002)(52116002)(486006)(69590400006)(76176011)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4290; 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; AM0PR04MB4290; 23:ogmAz2qaDWkcrlps68CYx+jnaZ9UkgLPgkjYK+VUy?= T8asyGogPOh9gciwQrAI0HMfPZPUsUW7SLNFG+x/xItTfrtB2fA80866FXDsp/H/7FigpJUS+yiRe2t1fTn8WZM6NeFNcezbSpC8/yWWC9U/CJhGMSlgSLspEeyZKJd8l60KY+KazlBCnWtWW29q+ebxPMN0gqdxZj8WJcbqZIVnRM+K79EP0Zpjvs8kKX2kpLkVqbF+CPA4iAMEV9bJozaoxspdaUkT+xhIRJbuBd46dYw4dJDNpZBEjrURO6cJomkfpLaCu6BdyNHCvxMB4aXyF7N3h6Dvi7H5/P9y51sNxX7h+8REU5468yFi1jAb5r0JlyLsHRQMztye1DkeWXl0k2lUHlhUtbDZowNEkJKlh2r8Rs1Xn5Rz546eKzQ1AkulFJmvieiXFzHlr1bn0CfiMl0Xmrt5q2YT8pdW3PFQc7Pbmkm5VLmwxVDVlzbl675ICq6/ZYjtngmwocuaG5HvX8fM91p9VAUvk4aCpZC+HrAy55ZLYElOiu7YgWQ6XWuvl06TtT17xrUWAOWqEi4SdXpxXrx2HZQxLRG+i74dSmpoBtZGSdX59zu3NUCAtsF7p1P5fVOF1PVsVM5quZHsCTNj7UboHWSey4JOQbw7AcgE8c1kNRVooOZn0DKVu7s6/VRI2Grk8VAu4dgQS8Z670mkT/nSsrHdJ/xczhfDCuKSgVXWQpoOy7QFaOSRtt303YlPgvdIZyxk0hIzIH0Vscx0jhVF2OR4cA+Cw7TWzVi+i74gVJtI7d3qIMZQ1EV7V1B5HU9XuLaRJlzJl6z6uOGHQkruhcbk+QZtQdTuvrayJwhn5/1X4lgNFqdCrr98W+pc1D79BaYIFxw5yZYKjt8JH3//GYJKfvH2Lr8bkPidhJX2QaZkk4NDs6Fj5dRNRxotw42T1WrwvMUJCf1T00FK6dtyFjm3gww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ytwaN5eho2/AENB3ygwFNrHpVjyr9Z4TXgRtMpizsqRUIMoOBMSWFixrQ9ppXwaq0HfbDgSKGT/fOnqpf/bHkIisgbSwN7wOBC4xZZaLddnJexrpJb9FaTxzyQcJb66e/kw7iPCYIOchWoO17UJaydGyEEyk42VGO8yfNXjIdxbgkItw==; 5:8q46Toc47YefRJt3fUyYcUvRj3pX5qWqCidf8Sen0gqQ8QWc+HWBdCWF8ytZKB/d2Cio6+v3QtSVkrd1viPBhCi10SdtimNmgaW4bwsbRJmjC8iOV1EOSChSMZpHJX0c11l4BtfaSk6JzFOBFj29PIY35afERbOWha3H7MqBhDk=; 7:/pxE3gsz7ivhr+rmZWIfCpDIzs+g5JMdbfQwQBqlHnh12yd78hnXGDAb6zzh/fspxRrZmHwVbB9EqEUbPgdAZ6SpgLbg2dj1u/O9He2IqRJzx5YM6dlYwJhv8k7lEC3Iq69xqsYDXEohpkiAn7hNzzbCXonViWeXCzNIi83hlRdOplmLmUNt76iSaYwIk3jgf7nfA8kOhSW+BzPumBWX/+DB3yhO7u7bbzbnBQI5I7soGzUT1tf2qf/eYaZORCke SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2018 13:43:05.7840 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9fa18ec-5485-45b4-0c0e-08d61ca37ffb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4290 X-Mailman-Approved-At: Tue, 18 Sep 2018 09:57:51 +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: Anson Huang , David Airlie , linux-kernel@vger.kernel.org, Robert Chiras , dri-devel@lists.freedesktop.org, kernel@pengutronix.de, Fabio Estevam , Shawn Guo , linux-imx@nxp.com 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_disable. 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));