Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2063881pxv; Sat, 24 Jul 2021 04:22:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFQxOjDVs6so6pIwPbnPOzK2NP7i1y8D+HDxSO0jMxE+0HdFZhjxZoBi9nJwnIOePR4OkC X-Received: by 2002:a50:fb95:: with SMTP id e21mr10720785edq.65.1627125731367; Sat, 24 Jul 2021 04:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627125731; cv=none; d=google.com; s=arc-20160816; b=bR+mFsrk/DTw7jzANtaRi0SkdxRkzFdacxXwQoOLgSOxJZhd/MPHDJ1REhkueHDTBK GLMJMjwBjL8nOftnDkv/e1M2jp9Ikev9agOXQQcSQmOD2obm3hVW3P+F48HcBGkDLKwt ajLBDIfJRtKYpYYeIky3/Vj3hxVrqfem5jbnkgRMccF6yUJiOlfcoH/Rl7cP8vTZR4pn NPiVVq3K8QKcXcVgDrd5+26WFkpaybeYzlYL+1I4KMK64MhRij2/YWrjap7xk/ARIuJ0 iCSw2RgwhUghjBPm4U2gVod2hqDgzJDej123+WJEZnfe5nLYgXNgKvdxYCqoLfrkSwhX CtJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9YtTx2F8aCtjxUTXqe0aUtd1QKwb/HSkiydeejpIB4k=; b=Z0Q65c2aAVWy39R0g4PWTRhLQXSXQxaz4sZDWcNQWnjnhtajQF+odDyOm1hlxLNslE 09NVgCPwvtwsyA2PRZ6WGYbFXuKbYaAJlZarsqvcaFZ3Ut+IruByjhQ40x8tueRWYIvg I7h54xeS89OGeMtVGVrwLgvdPKErJNdRGVXnkDG7ALh1+Hf5e2YiqQDgezAsT0x9Piio 2uCD/DCFbpLwtjUClpgYYdL70bhwiLgeSIkvhdiuPhYBwGzpFhFy/aX+GcCjTLoo+jd1 DswbY2svNHQPs7qZBkegvAa07cWyJwum7I05kdZjQi6AHk6aXpMQMAdgal/4m18htOFP W96w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DvPcmCPE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b2si35609612ejc.314.2021.07.24.04.21.46; Sat, 24 Jul 2021 04:22:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DvPcmCPE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234170AbhGXKiq (ORCPT + 99 others); Sat, 24 Jul 2021 06:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbhGXKiq (ORCPT ); Sat, 24 Jul 2021 06:38:46 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47ACFC061575 for ; Sat, 24 Jul 2021 04:19:17 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so7299640pjh.3 for ; Sat, 24 Jul 2021 04:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9YtTx2F8aCtjxUTXqe0aUtd1QKwb/HSkiydeejpIB4k=; b=DvPcmCPEmDyLe3TGFTP1QJeVA2WB+aAXO8mtDMt92/tIWfVwoxyj/t+ohBnZhllumo FE8nIVjaonsiw5dBGIuKHq5HwvCS+RUy7HQLPgjUJ2OG2ki1X2sPyNz9OTIz5RDCj/Q0 TULtxmO2p7V7NaIniuhDYieJ05ETRDTZNH06S96TDnJAYDgnwUyK56O6hTnJIBCrZzbz oE2sV1ptouoT+cunTJ6XEJvbfVFqHx6uyfCFZdyW/zYc0CLRjOcIxxstpi8unewZ8ZMw CcMBMYraxUKiFmoranTvKMp1CVTb6CaPaHx45wcC25uTJLdvQmxvvr3oWnzD4gXSggTr 5YEg== 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=9YtTx2F8aCtjxUTXqe0aUtd1QKwb/HSkiydeejpIB4k=; b=DeDuFVo3p09VdE10e/GFezQBWUh5NQZq1hiERu2PqARXfkzzJo+9/Qm+jqWxcwDK1d p7NR6pr35fVJ/w36mqY8Kf7XTZsq703xirGZVCHtQJju069t4AQat62ZHRjtLXLHmUdz PpgFYs72Ch9hF3Uy4sh1BMv8632KUYWBvGG/MQPsGlOW8togXC7f0RG+e1PABTIrKGfI KBQ/rz6BIPQt7mq9h4vcrJFd3czW09xSG/aznYc10tSRb8KYSSiXmJMdOYpPfWrbVh5i JETmOP6cBntlygVBYOYlqhKtiZJLVaOKh3sDyfugDlc1GtaEfzveA54eOfkh9PO72g2e qa0g== X-Gm-Message-State: AOAM533VcqfYUhWfqNGpRSRldCFNLxvGpiB4amt95jE1fdKtLC/augWD Y5QcPG6xYxyZ2eziz8N6b28= X-Received: by 2002:a17:90a:9ac:: with SMTP id 41mr17424928pjo.97.1627125556886; Sat, 24 Jul 2021 04:19:16 -0700 (PDT) Received: from localhost.localdomain ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id v15sm21310057pff.105.2021.07.24.04.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 04:19:16 -0700 (PDT) From: Desmond Cheong Zhi Xi To: linux-graphics-maintainer@vmware.com, zackr@vmware.com, airlied@linux.ie, daniel@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, corbet@lwn.net Cc: Desmond Cheong Zhi Xi , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, intel-gfx@lists.freedesktop.org, Daniel Vetter Subject: [PATCH v2 1/3] drm: use the lookup lock in drm_is_current_master Date: Sat, 24 Jul 2021 19:18:22 +0800 Message-Id: <20210724111824.59266-2-desmondcheongzx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724111824.59266-1-desmondcheongzx@gmail.com> References: <20210724111824.59266-1-desmondcheongzx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Inside drm_is_current_master, using the outer drm_device.master_mutex to protect reads of drm_file.master makes the function prone to creating lock hierarchy inversions. Instead, we can use the drm_file.master_lookup_lock that sits at the bottom of the lock hierarchy. Reported-by: Daniel Vetter Signed-off-by: Desmond Cheong Zhi Xi Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_auth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index f00354bec3fb..9c24b8cc8e36 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -63,8 +63,9 @@ static bool drm_is_current_master_locked(struct drm_file *fpriv) { - lockdep_assert_held_once(&fpriv->minor->dev->master_mutex); - + /* Either drm_device.master_mutex or drm_file.master_lookup_lock + * should be held here. + */ return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master; } @@ -82,9 +83,9 @@ bool drm_is_current_master(struct drm_file *fpriv) { bool ret; - mutex_lock(&fpriv->minor->dev->master_mutex); + spin_lock(&fpriv->master_lookup_lock); ret = drm_is_current_master_locked(fpriv); - mutex_unlock(&fpriv->minor->dev->master_mutex); + spin_unlock(&fpriv->master_lookup_lock); return ret; } -- 2.25.1