From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC7F8C55ABD for ; Fri, 13 Nov 2020 15:34:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37B3622249 for ; Fri, 13 Nov 2020 15:33:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rYl0y133"; dkim=temperror (0-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="kb5uh5PP"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lmq0WPN3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37B3622249 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tTmnPKX7X8p17mSU1l5i/FPXJYYFEUu65pr5auF0Qdw=; b=rYl0y133y+lzHzZeBlzpJdfKv 90i47G/dmsdgR3bHpd/CVkh+vhAAXKJLtgoorDME/gcsEQMCJJ3ZrGYDqZlXuIwXdVJ6bX0Ep+Uog BUWeMV7RSfMSh1LTzy2OkBz+tzGUL5D1FOGalGSmE67TcUzWR8uJEnKWhZ8LR7mFanV/xT29ll7Su im5/+GhrTwRVDR7PtUUsPwcr4SQOllHt3i3RhQIixsxpbJQ8N+jobB45B3VkSuJe17gHwm0PiF1ZS UR0SLe5yWKglDC1kTF8MfMgKfNeq34q54r261RZI/zd/oJ1VUr4AVqYes4wr8GZSODj6xlA0jVLCF LfUlyTTRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdb4k-0004kL-IE; Fri, 13 Nov 2020 15:33:22 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdb3p-0004UD-AX; Fri, 13 Nov 2020 15:32:28 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 04638580333; Fri, 13 Nov 2020 10:32:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 13 Nov 2020 10:32:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=j8EkEGHe/t92f 2Hvnx5xgl097ZjSfSkOfuxxQC4z7yE=; b=kb5uh5PPd6/cFdwmFtXP5We89y+op 7oPsGGtCEwvV5UrzlprBw5qrL/LEk6a3oNvnXNJ+0nVbUqewDkf/w5t2Vj4hMZ1t gad3VQTStZq+q43ZixQBzfJdN56astrMm9ILH135zyi3NODh++xyV76b7xbR1sub qSGsTo/M5o0IgjAf4e1hYdaoV6y4R/9soOwRd2u91vgKBb+WvWA/N/+z9cg5EM0K 8RLcYpqCLJH7B/dsa65inSg16fviOGywhqU1f98GK5geVCk3fLHXdKBoZHhQWqcE WTJz6xMj4mION7c6mFJI8EQIwVspyCKxns6e8S2cMNz49qYLTGGW2hpDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=j8EkEGHe/t92f2Hvnx5xgl097ZjSfSkOfuxxQC4z7yE=; b=lmq0WPN3 KbfYGSBaJ30B/6SF6FXk/dpAdBe+zvncVlXn6qIKnXrTspQWtyos4lN4bO23S37s zGp9YQkfLwWOra4BOM9LRRGpD2yYtbiAGLAFAWbxJYvDpdk3u8A3Z35ZRMAOmP4p W/nRms9Mw/3uEcKlCbGY+IyRUk7apCxrWUyGhU9LWKhe30Yi3l0dgOSYcRQj30N/ sKAA2CkyMCP/i7zzzJdhTyL2Afsn+XB5V2HY+GF7Fh9O4hC8GAq1lZRHHFD81TjM tFjJf5VE7uue4u/nE5QzpcpDKkZotB0wg+ilyRbGRcZQsuZVnsIdWOE9Ven8psAJ kIW0pdJl71irew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvhedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 3FFFC3064AB5; Fri, 13 Nov 2020 10:32:24 -0500 (EST) From: Maxime Ripard To: Mark Rutland , Rob Herring , Frank Rowand , Eric Anholt , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Subject: [PATCH 1/8] drm: Introduce an atomic_commit_setup function Date: Fri, 13 Nov 2020 16:29:49 +0100 Message-Id: <20201113152956.139663-2-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113152956.139663-1-maxime@cerno.tech> References: <20201113152956.139663-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_103225_547743_95BE5A95 X-CRM114-Status: GOOD ( 18.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Tim Gover , Dave Stevenson , Daniel Vetter , dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Phil Elwell , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Private objects storing a state shared across all CRTCs need to be carefully handled to avoid a use-after-free issue. The proper way to do this to track all the commits using that shared state and wait for the previous commits to be done before going on with the current one to avoid the reordering of commits that could occur. However, this commit setup needs to be done after drm_atomic_helper_setup_commit(), because before the CRTC commit structure hasn't been allocated before, and before the workqueue is scheduled, because we would be potentially reordered already otherwise. That means that drivers currently have to roll their own drm_atomic_helper_commit() function, even though it would be identical if not for the commit setup. Let's introduce a hook to do so that would be called as part of drm_atomic_helper_commit, allowing us to reuse the atomic helpers. Suggested-by: Daniel Vetter Signed-off-by: Maxime Ripard --- drivers/gpu/drm/drm_atomic_helper.c | 6 ++++++ include/drm/drm_modeset_helper_vtables.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ddd0e3239150..7d69c7844dfc 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2083,8 +2083,11 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state, struct drm_plane *plane; struct drm_plane_state *old_plane_state, *new_plane_state; struct drm_crtc_commit *commit; + const struct drm_mode_config_helper_funcs *funcs; int i, ret; + funcs = state->dev->mode_config.helper_private; + for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { commit = kzalloc(sizeof(*commit), GFP_KERNEL); if (!commit) @@ -2169,6 +2172,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state, new_plane_state->commit = drm_crtc_commit_get(commit); } + if (funcs && funcs->atomic_commit_setup) + return funcs->atomic_commit_setup(state); + return 0; } EXPORT_SYMBOL(drm_atomic_helper_setup_commit); diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index f2de050085be..56470baf0513 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -1396,6 +1396,24 @@ struct drm_mode_config_helper_funcs { * drm_atomic_helper_commit_tail(). */ void (*atomic_commit_tail)(struct drm_atomic_state *state); + + /** + * @atomic_commit_setup: + * + * This hook is used by the default atomic_commit() hook implemented in + * drm_atomic_helper_commit() together with the nonblocking helpers (see + * drm_atomic_helper_setup_commit()) to extend the DRM commit setup. It + * is not used by the atomic helpers. + * + * This function is called at the end of + * drm_atomic_helper_setup_commit(), so once the commit has been + * properly setup across the generic DRM object states. It allows + * drivers to do some additional commit tracking that isn't related to a + * CRTC, plane or connector, typically a private object. + * + * This hook is optional. + */ + int (*atomic_commit_setup)(struct drm_atomic_state *state); }; #endif -- 2.28.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel