From patchwork Wed Jan 29 08:24:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11355665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A4371398 for ; Wed, 29 Jan 2020 08:24:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3920220708 for ; Wed, 29 Jan 2020 08:24:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="E5cyQp0r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3920220708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 093176F48B; Wed, 29 Jan 2020 08:24:19 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5940B6E27C for ; Wed, 29 Jan 2020 08:24:18 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id c9so19085949wrw.8 for ; Wed, 29 Jan 2020 00:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AnvVhyRRmoo/xlkf99eP9Y/JmLE54NitcFMa1DSVDVE=; b=E5cyQp0rjuHu5tUyA8ZQ0acrUmQVjj2klXe6IHLgEoEfVgIU2Ui/BsJhDWMRieidAn OtjpuptoipI1m8FqdN7DyPT0uskJFPek6DTQo6GJMFckBOmACYVrjyM6dG9wbY50K940 D/HEjgQlLl8+Ufh5EEfMsT+ItQRfUNAeQ7cRo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AnvVhyRRmoo/xlkf99eP9Y/JmLE54NitcFMa1DSVDVE=; b=XbVn29sLsF1Rk0UKTFXOf/2wxHCA1XO3txstbWIx2ye1uITUhgbU3HLoXwqg9EHfyN xU/zpTyweOI34WVIeh2tU6WIjh3V8RojFMU+ZbUi81daS9sv8epNEv/VzXF4qqkZqyt3 vl+Y9jRkW+FGs2ZnFImxcgMMk5f08mc/6wsAY4ZBIBY1PV8Rieodq4CcT0qUnrE47ahH Njy3/1i/ISXY6d293MOAh7o92SvnzUw71F5s27gYU8Irhln2jCICsFkC38y/2I7VqlJz 30dT+eGkN4RHhwANR/2n7mqQBtbt1XQkyjb6MebyxPRZYZ8l6QCaMWghbS3W/hBpbE0H x4uA== X-Gm-Message-State: APjAAAVTerooljPwskxGBIx5oBDYkU/aewc6f5JE8SWuAvye5JTtRGlI hhogPKXynaGmt6O8xTlxII3P1g== X-Google-Smtp-Source: APXvYqynuOkbfAC0AhKxa/6O406C88xYMYBgSclcHi+aRhHzpp8zNprB077N+wPTHSrYD5VnfUJ2+w== X-Received: by 2002:adf:ebc3:: with SMTP id v3mr34841384wrn.280.1580286256970; Wed, 29 Jan 2020 00:24:16 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n14sm1351931wmi.26.2020.01.29.00.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 00:24:16 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 29 Jan 2020 09:24:06 +0100 Message-Id: <20200129082410.1691996-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> References: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/5] drm: Complain if drivers still use the ->load callback X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , Thomas Zimmermann , Alex Deucher , Daniel Vetter , Harry Wentland Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Kinda time to get this sorted. The locking around this really is not nice. Thomas mentioned in his review that the only drivers left unconverted are radeon and amdgpu. Cc: Harry Wentland Cc: Alex Deucher Reviewed-by: Chris Wilson Reviewed-by: Thomas Zimmermann Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 6 ++++++ include/drm/drm_drv.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 7c18a980cd4b..8deff75b484c 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -948,6 +948,12 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) mutex_lock(&drm_global_mutex); + if (dev->driver->load) { + if (!drm_core_check_feature(dev, DRIVER_LEGACY)) + DRM_INFO("drm driver %s is using deprecated ->load callback\n", + dev->driver->name); + } + ret = drm_minor_register(dev, DRM_MINOR_RENDER); if (ret) goto err_minors; diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 77685ed7aa65..77bc63de0a91 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -173,6 +173,9 @@ struct drm_driver { * * This is deprecated, do not use! * + * FIXME: A few non-DRIVER_LEGACY drivers still use this, and should be + * converted. + * * Returns: * * Zero on success, non-zero value on failure. From patchwork Wed Jan 29 08:24:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11355677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CB0E1398 for ; Wed, 29 Jan 2020 08:24:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5BB1920708 for ; Wed, 29 Jan 2020 08:24:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="WIiuK4E9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BB1920708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D5FB6F493; Wed, 29 Jan 2020 08:24:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 64B116F48C for ; Wed, 29 Jan 2020 08:24:19 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id g17so19067988wro.2 for ; Wed, 29 Jan 2020 00:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e9RykBY7CT/sd2nPUs0+4zQdEEH/jpXwer/6pk7GTG4=; b=WIiuK4E98R2xaX/rr9Zy1W9syU9RnQNW/Gvn7b9CPZmf8rseKsVXmorY7fD/TGkXoU DQt3uEDsI91XOEcMjKoQ5F3oHNI/8XSEdzt06M5ZsOtqVCoohfeiZRGvrvlC1bCJiBkx 8Cuc0X/8PJxvr5BvEd9Ey9yYV2JFhDtLFS7T8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e9RykBY7CT/sd2nPUs0+4zQdEEH/jpXwer/6pk7GTG4=; b=pYx+lf2qxCf2o3dDiT/fclLJfJG46ENPO8J2gIdLFWkOq70rJP1UQt2cCjM+Kg/Bbk AVRkuLlldttiNkejYL3sP1M3j+CrrTTZlUIK8Q+cPMG6vIgBpSMeBz8pCIlW52HT1cp1 pJKzLVYdNdZT2DHViUInp0qcSXH+SmkYcg7t4dEK143og2qKLeRTaPgDLVpIJl9VL8w7 uccfdi9l87qA5VzIBaaS/Z03E16vUHicgBFbtUatfq72bsgsQTVeMulwQqQUG1tLjI8V Z6vob9WHygkulsU6gT2nx7GZqg+UU3sQ+hDwrHFA+sNpacR1wYnUNO6+0BNW3ZC/h2he wLRw== X-Gm-Message-State: APjAAAX1jMSasaD19mhQjXa4zl0cMFt3vovIQy5AC03Qx8V8QkbnDN0S nvpBD3bPdeaS6GGSsW4ntN+mgg== X-Google-Smtp-Source: APXvYqwPQdCtREi5yfUJfbB3vKnvYE+SipiV67Al3l9Lil6utvRB/MbtlPjZOYo0oJSVvlfmfc34Jg== X-Received: by 2002:a5d:43c7:: with SMTP id v7mr32530737wrr.32.1580286257965; Wed, 29 Jan 2020 00:24:17 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n14sm1351931wmi.26.2020.01.29.00.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 00:24:17 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 29 Jan 2020 09:24:07 +0100 Message-Id: <20200129082410.1691996-3-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> References: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 2/5] drm/fbdev-helper: don't force restores X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , =?utf-8?q?Nor?= =?utf-8?q?alf_Tr=C3=B8nnes?= , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Instead check for master status, in case we've raced. This is the last exception to the general rule that we restore fbcon only when there's no master active. Compositors are supposed to drop their master status before they switch to a different console back to text mode (or just switch to text mode directly, without a vt switch). This is known to break some subtests of kms_fbcon_fbt in igt, but they're just wrong - it does a graphics/text mode switch for the vt without updating the master status. Also add a comment to the drm_client->restore hook that this is expected going forward from all clients (there's currently just one). v2: Also drop the force in pan_display v3: Restore the _force to pan_display, this actually means _locked in that path. Spotted by Noralf. Cc: Noralf Trønnes Reviewed-by: Noralf Trønnes Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 12 +----------- include/drm/drm_client.h | 5 +++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 4c7cbce7bae7..672934e0eeed 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -250,17 +250,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper) return 0; mutex_lock(&fb_helper->lock); - /* - * TODO: - * We should bail out here if there is a master by dropping _force. - * Currently these igt tests fail if we do that: - * - kms_fbcon_fbt@psr - * - kms_fbcon_fbt@psr-suspend - * - * So first these tests need to be fixed so they drop master or don't - * have an fd open. - */ - ret = drm_client_modeset_commit_force(&fb_helper->client); + ret = drm_client_modeset_commit(&fb_helper->client); do_delayed = fb_helper->delayed_hotplug; if (do_delayed) diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h index 5cf2c5dd8b1e..d01d311023ac 100644 --- a/include/drm/drm_client.h +++ b/include/drm/drm_client.h @@ -44,6 +44,11 @@ struct drm_client_funcs { * returns zero gets the privilege to restore and no more clients are * called. This callback is not called after @unregister has been called. * + * Note that the core does not guarantee exclusion against concurrent + * drm_open(). Clients need to ensure this themselves, for example by + * using drm_master_internal_acquire() and + * drm_master_internal_release(). + * * This callback is optional. */ int (*restore)(struct drm_client_dev *client); From patchwork Wed Jan 29 08:24:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11355683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C43B1398 for ; Wed, 29 Jan 2020 08:24:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4A6B120708 for ; Wed, 29 Jan 2020 08:24:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="NBvD1Zhd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A6B120708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CD786F496; Wed, 29 Jan 2020 08:24:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6615B6F48C for ; Wed, 29 Jan 2020 08:24:20 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id t14so5342594wmi.5 for ; Wed, 29 Jan 2020 00:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2urneP7q/3cnqLvcnI+NCYajH6nQSRpJjVYFXyW3qJo=; b=NBvD1ZhdUfWuB7lsBt1LeLhSlB/SyHgDGJUy6+h72TA/gvnuutSnuNU+558MiM6jAM 7uWwEFFVKnVt4FGTARefqGX8P/WiYLpkOCJspw2XcFSAX48k5Fx6ieWgd3a8LmKLda2c 7APfZpb9Fd1loz1cUQobxuARlFyD3WiLZGHhE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2urneP7q/3cnqLvcnI+NCYajH6nQSRpJjVYFXyW3qJo=; b=PHeN/eCavC4jqEPOfRshBzZlu/cWweSEDaktzm/qJ0Dp3OBCZyniQYPqDUyZSaa2nm anLQ4WOue1nWIY/TEr20ZpCtU0nBSlvvoJu0NHu9TGGFGPeA6e28PcdPTBQq3Aqmvl5F VDk+EXDO1qykYmIfIJ/9LxanRXLJir7pG/WH9a7wRRHlg/2/c0/TGBdf3UD8ndd6YXWI dJ8C2i00Q53SFIWwdECAWzHWUm0eHbg6dvq51d1BnQVfbNujt5EAZwLAADbM2eh095SL r0ZA7U7k5kXFzDeRsxrLRqnY4bFn5bShq6rFio+V3GrGEyHwov55FAb33Q0Cjz39hIeT qaRQ== X-Gm-Message-State: APjAAAU427bzHQAGYj7p2306gLNxakr4eK7MImKLNhZunOdbvGHYLsCI 66lxDT+0b4428SZfNykzujGB7ERboSFC/g== X-Google-Smtp-Source: APXvYqzCuxdyyU0+a/SprGJLlzlQ8pZSpmLG8aX3KOXrgPrsF/z16lDfC//UDieMSOSodsk2rs3VIA== X-Received: by 2002:a05:600c:2409:: with SMTP id 9mr9960827wmp.109.1580286258997; Wed, 29 Jan 2020 00:24:18 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n14sm1351931wmi.26.2020.01.29.00.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 00:24:18 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 29 Jan 2020 09:24:08 +0100 Message-Id: <20200129082410.1691996-4-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> References: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 3/5] drm/client: Rename _force to _locked X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , =?utf-8?q?Nor?= =?utf-8?q?alf_Tr=C3=B8nnes?= , Daniel Vetter Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Plus extend the kerneldoc a bit to explain how this should be used. With the previous patch to drop the force restore the main user of this function is not emphasis on the "I hold the internal master lock already" aspect, so rename the function to match. Suggested by Noralf. Cc: Noralf Trønnes Signed-off-by: Daniel Vetter Reviewed-by: Noralf Trønnes --- drivers/gpu/drm/drm_client_modeset.c | 12 +++++++----- drivers/gpu/drm/drm_fb_helper.c | 4 ++-- include/drm/drm_client.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index 6d4a29e99ae2..841794e19eb6 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -1094,15 +1094,17 @@ static int drm_client_modeset_commit_legacy(struct drm_client_dev *client) } /** - * drm_client_modeset_commit_force() - Force commit CRTC configuration + * drm_client_modeset_commit_locked() - Force commit CRTC configuration * @client: DRM client * - * Commit modeset configuration to crtcs without checking if there is a DRM master. + * Commit modeset configuration to crtcs without checking if there is a DRM + * master. The assumption is that the caller already holds an internal DRM + * master reference acquired with drm_master_internal_acquire(). * * Returns: * Zero on success or negative error code on failure. */ -int drm_client_modeset_commit_force(struct drm_client_dev *client) +int drm_client_modeset_commit_locked(struct drm_client_dev *client) { struct drm_device *dev = client->dev; int ret; @@ -1116,7 +1118,7 @@ int drm_client_modeset_commit_force(struct drm_client_dev *client) return ret; } -EXPORT_SYMBOL(drm_client_modeset_commit_force); +EXPORT_SYMBOL(drm_client_modeset_commit_locked); /** * drm_client_modeset_commit() - Commit CRTC configuration @@ -1135,7 +1137,7 @@ int drm_client_modeset_commit(struct drm_client_dev *client) if (!drm_master_internal_acquire(dev)) return -EBUSY; - ret = drm_client_modeset_commit_force(client); + ret = drm_client_modeset_commit_locked(client); drm_master_internal_release(dev); diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 672934e0eeed..490a99de6ec1 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -284,7 +284,7 @@ static bool drm_fb_helper_force_kernel_mode(void) continue; mutex_lock(&helper->lock); - ret = drm_client_modeset_commit_force(&helper->client); + ret = drm_client_modeset_commit_locked(&helper->client); if (ret) error = true; mutex_unlock(&helper->lock); @@ -1347,7 +1347,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, pan_set(fb_helper, var->xoffset, var->yoffset); - ret = drm_client_modeset_commit_force(&fb_helper->client); + ret = drm_client_modeset_commit_locked(&fb_helper->client); if (!ret) { info->var.xoffset = var->xoffset; info->var.yoffset = var->yoffset; diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h index d01d311023ac..3ed5dee899fd 100644 --- a/include/drm/drm_client.h +++ b/include/drm/drm_client.h @@ -161,7 +161,7 @@ int drm_client_modeset_create(struct drm_client_dev *client); void drm_client_modeset_free(struct drm_client_dev *client); int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int height); bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation); -int drm_client_modeset_commit_force(struct drm_client_dev *client); +int drm_client_modeset_commit_locked(struct drm_client_dev *client); int drm_client_modeset_commit(struct drm_client_dev *client); int drm_client_modeset_dpms(struct drm_client_dev *client, int mode); From patchwork Wed Jan 29 08:24:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11355675 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB53713A4 for ; Wed, 29 Jan 2020 08:24:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 AA08920708 for ; Wed, 29 Jan 2020 08:24:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="FVPTkFgv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA08920708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0FA46F492; Wed, 29 Jan 2020 08:24:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F25F6F48D for ; Wed, 29 Jan 2020 08:24:21 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id z3so19108154wru.3 for ; Wed, 29 Jan 2020 00:24:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2eg3fDR5VispgYeOao22kfgLqHLdVyylrWybH877xNM=; b=FVPTkFgvY1puRuk3/i6d2Za9ans+S2JXCFlhIyS0+yVSzukxrgEtWln0nLphxOGpAH YZu8bK5jde2s3ops2fdGXuZmPf3bhmjroarJbEZ2EcYlWErg1fKBrO0W6P18PTtO1Rtu XY6PNMw3tKhUmsL4qCaiVq9ZrVsfusioHliyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2eg3fDR5VispgYeOao22kfgLqHLdVyylrWybH877xNM=; b=NZ5130kBRhOZGugm6KRI3xh0iXNi1OBiYXja+AmXr6hBATbHtx/c+GpAl/caQ8HdBl eW3gJFvyx1O0MF/4Dle89ru3j8xFIJ5P27dV4UcYMljXh4spfsCTKj47e7WkZMd84rU+ slu4hwBOacqiPF3nNgr8PATApk9tmmLacIV9n/dIC7WxBMthq4KrbPZJotU+SBaBIRVc hzYY8BTAJpBUFTJwcCXeB8su4upR6iJEZHD0tiDKcvEAoiLHsnhM4tcjDF6+/2cjqVs3 yfIyazNwIpVUTIeCg/7bJ21T+D1e1xSpl8grZCBVaa4KwlyZfD+geYLWCSPrz3/RJCUq GQ9Q== X-Gm-Message-State: APjAAAWSWBcOIIZXl/zyIvETkWS6GrfkOdsyaimd37R+lz1yURUcx2Hs RWRPFqZP5gbvezsUi1fdP2EqXA== X-Google-Smtp-Source: APXvYqxf6y4uUmP+RtjUzj9NZYmPz7jamiIttJcUz1MEhiaux0UOBda9dUS/OrPeeysvoJUMZjWhog== X-Received: by 2002:a5d:45cc:: with SMTP id b12mr32492822wrs.424.1580286259920; Wed, 29 Jan 2020 00:24:19 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n14sm1351931wmi.26.2020.01.29.00.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 00:24:19 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 29 Jan 2020 09:24:09 +0100 Message-Id: <20200129082410.1691996-5-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> References: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 4/5] drm: Push drm_global_mutex locking in drm_open X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We want to only take the BKL on crap drivers, but to know whether we have a crap driver we first need to look it up. Split this shuffle out from the main BKL-disabling patch, for more clarity. Since the minors are refcounted drm_minor_acquire is purely internal and this does not have a driver visible effect. v2: Push the locking even further into drm_open(), suggested by Chris. This gives us more symmetry with drm_release(), and maybe a futuer avenue where we make drm_globale_mutex locking (partially) opt-in like with drm_release_noglobal(). Reviewed-by: Chris Wilson Cc: Chris Wilson Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 14 +++++--------- drivers/gpu/drm/drm_file.c | 6 ++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8deff75b484c..05bdf0b9d2b3 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -1085,17 +1085,14 @@ static int drm_stub_open(struct inode *inode, struct file *filp) DRM_DEBUG("\n"); - mutex_lock(&drm_global_mutex); minor = drm_minor_acquire(iminor(inode)); - if (IS_ERR(minor)) { - err = PTR_ERR(minor); - goto out_unlock; - } + if (IS_ERR(minor)) + return PTR_ERR(minor); new_fops = fops_get(minor->dev->driver->fops); if (!new_fops) { err = -ENODEV; - goto out_release; + goto out; } replace_fops(filp, new_fops); @@ -1104,10 +1101,9 @@ static int drm_stub_open(struct inode *inode, struct file *filp) else err = 0; -out_release: +out: drm_minor_release(minor); -out_unlock: - mutex_unlock(&drm_global_mutex); + return err; } diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 1075b3a8b5b1..d36cb74ebe0c 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -378,6 +378,8 @@ int drm_open(struct inode *inode, struct file *filp) if (IS_ERR(minor)) return PTR_ERR(minor); + mutex_unlock(&drm_global_mutex); + dev = minor->dev; if (!atomic_fetch_inc(&dev->open_count)) need_setup = 1; @@ -395,10 +397,14 @@ int drm_open(struct inode *inode, struct file *filp) goto err_undo; } } + + mutex_unlock(&drm_global_mutex); + return 0; err_undo: atomic_dec(&dev->open_count); + mutex_unlock(&drm_global_mutex); drm_minor_release(minor); return retcode; } From patchwork Wed Jan 29 08:24:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11355673 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F308D13A4 for ; Wed, 29 Jan 2020 08:24:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D226A20708 for ; Wed, 29 Jan 2020 08:24:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Lv8k7/we" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D226A20708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4D126F491; Wed, 29 Jan 2020 08:24:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F3486F48C for ; Wed, 29 Jan 2020 08:24:22 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id k11so4393542wrd.9 for ; Wed, 29 Jan 2020 00:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u0SyUN+f040Xl3NaI5OiGhbHqNxJaeVyihljYxH1raA=; b=Lv8k7/we+VBdUo5z8zTFzGvkaJNWyGuEx06eSWrrztVt1laXYFsv2JmGSYqVONJBeM U5dRsEchYj+qSosWIzDhje8oZzQR1170gIHQZflCP1ZpIltllQFSr/fE8pTKhmbr8gXJ DyWwW1mN/SaXOloeLJh+WOIUbLNCBn88aDMa0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u0SyUN+f040Xl3NaI5OiGhbHqNxJaeVyihljYxH1raA=; b=fXwefUb7/5NEeXnksdvy8yHvcApSS5K30wyeHIGuNW+3Whb+giEH87tbJDVA3yPuT+ reRPenhmQEoiL/KBYLitpPtimdersUuFSPJs7mfoWg8GKg7weqfCEhWRiB5KkQrv2x4D PblMCwv8bWjXLysaEHFbMgadSsgBPLxxXo52Bk1+jlhlnq1SkWs4mz80i0tWvW0/JYjc NstS+Vz8h/0wa9hkl/vPyG6mTZZAfmp5JPzjgAsoZqXtdq8TvJupSSNkIMSffx1gCwlT 9AmNkIblGmLUUqWm5GZV2wjTPOcsjgGKRyH4WMbqtKSqrA3SsbDD7GrRbrPr+Oty0MzA Ov7w== X-Gm-Message-State: APjAAAW/9BE3hog0nZAVId+qs9t56aIOc2mMNT1+c6bhGSANbvDXsHcl AaspqpyDSSRr2QPntD31qGwi0Q== X-Google-Smtp-Source: APXvYqwZkMB4ur5rbp90mF9VVED8t+um2q7ZO3kjZufzCGwknX5Xq0RZLDiuOYgqhGiwaIyPK+tGvg== X-Received: by 2002:adf:ef41:: with SMTP id c1mr5189909wrp.128.1580286260959; Wed, 29 Jan 2020 00:24:20 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id n14sm1351931wmi.26.2020.01.29.00.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 00:24:20 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 29 Jan 2020 09:24:10 +0100 Message-Id: <20200129082410.1691996-6-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> References: <20200129082410.1691996-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 5/5] drm: Nerv drm_global_mutex BKL for good drivers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This catches the majority of drivers (unfortunately not if we take users into account, because all the big drivers have at least a lastclose hook). With the prep patches out of the way all drm state is fully protected and either prevents or can deal with the races from dropping the BKL around open/close. The only thing left to audit are the various driver hooks - by keeping the BKL around if any of them are set we have a very simple cop-out! Note that one of the biggest prep pieces to get here was making dev->open_count atomic, which was done in commit 7e13ad896484a0165a68197a2e64091ea28c9602 Author: Chris Wilson Date: Fri Jan 24 13:01:07 2020 +0000 drm: Avoid drm_global_mutex for simple inc/dec of dev->open_count Reviewed-by: Chris Wilson Cc: Chris Wilson Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 6 +++-- drivers/gpu/drm/drm_file.c | 46 ++++++++++++++++++++++++++++++---- drivers/gpu/drm/drm_internal.h | 1 + 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 05bdf0b9d2b3..9fcd6ab3c154 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -946,7 +946,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) struct drm_driver *driver = dev->driver; int ret; - mutex_lock(&drm_global_mutex); + if (drm_dev_needs_global_mutex(dev)) + mutex_lock(&drm_global_mutex); if (dev->driver->load) { if (!drm_core_check_feature(dev, DRIVER_LEGACY)) @@ -992,7 +993,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) drm_minor_unregister(dev, DRM_MINOR_PRIMARY); drm_minor_unregister(dev, DRM_MINOR_RENDER); out_unlock: - mutex_unlock(&drm_global_mutex); + if (drm_dev_needs_global_mutex(dev)) + mutex_unlock(&drm_global_mutex); return ret; } EXPORT_SYMBOL(drm_dev_register); diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index d36cb74ebe0c..efd6fe0b6b4f 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -51,6 +51,37 @@ /* from BKL pushdown */ DEFINE_MUTEX(drm_global_mutex); +bool drm_dev_needs_global_mutex(struct drm_device *dev) +{ + /* + * Legacy drivers rely on all kinds of BKL locking semantics, don't + * bother. They also still need BKL locking for their ioctls, so better + * safe than sorry. + */ + if (drm_core_check_feature(dev, DRIVER_LEGACY)) + return true; + + /* + * The deprecated ->load callback must be called after the driver is + * already registered. This means such drivers rely on the BKL to make + * sure an open can't proceed until the driver is actually fully set up. + * Similar hilarity holds for the unload callback. + */ + if (dev->driver->load || dev->driver->unload) + return true; + + /* + * Drivers with the lastclose callback assume that it's synchronized + * against concurrent opens, which again needs the BKL. The proper fix + * is to use the drm_client infrastructure with proper locking for each + * client. + */ + if (dev->driver->lastclose) + return true; + + return false; +} + /** * DOC: file operations * @@ -378,9 +409,10 @@ int drm_open(struct inode *inode, struct file *filp) if (IS_ERR(minor)) return PTR_ERR(minor); - mutex_unlock(&drm_global_mutex); - dev = minor->dev; + if (drm_dev_needs_global_mutex(dev)) + mutex_unlock(&drm_global_mutex); + if (!atomic_fetch_inc(&dev->open_count)) need_setup = 1; @@ -398,13 +430,15 @@ int drm_open(struct inode *inode, struct file *filp) } } - mutex_unlock(&drm_global_mutex); + if (drm_dev_needs_global_mutex(dev)) + mutex_unlock(&drm_global_mutex); return 0; err_undo: atomic_dec(&dev->open_count); - mutex_unlock(&drm_global_mutex); + if (drm_dev_needs_global_mutex(dev)) + mutex_unlock(&drm_global_mutex); drm_minor_release(minor); return retcode; } @@ -444,6 +478,7 @@ int drm_release(struct inode *inode, struct file *filp) struct drm_minor *minor = file_priv->minor; struct drm_device *dev = minor->dev; + if (drm_dev_needs_global_mutex(dev)) mutex_lock(&drm_global_mutex); DRM_DEBUG("open_count = %d\n", atomic_read(&dev->open_count)); @@ -453,7 +488,8 @@ int drm_release(struct inode *inode, struct file *filp) if (atomic_dec_and_test(&dev->open_count)) drm_lastclose(dev); - mutex_unlock(&drm_global_mutex); + if (drm_dev_needs_global_mutex(dev)) + mutex_unlock(&drm_global_mutex); drm_minor_release(minor); diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 6937bf923f05..aeec2e68d772 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -41,6 +41,7 @@ struct drm_printer; /* drm_file.c */ extern struct mutex drm_global_mutex; +bool drm_dev_needs_global_mutex(struct drm_device *dev); struct drm_file *drm_file_alloc(struct drm_minor *minor); void drm_file_free(struct drm_file *file); void drm_lastclose(struct drm_device *dev);