Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp119465ybh; Tue, 21 Jul 2020 18:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFDXtT94iucdnvbf3ra393MO92OlzVvJ0j2yIZxII6AfZkB0a4ikGyqwwz89TyLUZg3xjF X-Received: by 2002:a17:906:774d:: with SMTP id o13mr27423547ejn.373.1595380105706; Tue, 21 Jul 2020 18:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595380105; cv=none; d=google.com; s=arc-20160816; b=lBkD03+EbI31sHujrjL9gUWdCChmB+pZnbxgeO70avFVm53zvPE4HEc6ac5kiubdam wc976g21p2GMx5a4ThLUtfFRtennPjHVe+pfYLHnfT1wit437x2YQN3Rd2rMPzMIRJnx FafcvrdxFt30+4UwRdH05miA43CpfSBrRcMjcM6yYn9eC6vu9E5/G3anSSzPipJW1Q3r ftuLBKIerVvaeTAEm+//Ei4y8LierGOO7ez7AwMI53vOWP2m+8d2poCjQRMhhbFtmcWG oOL1iO3zeSe+fTmy/FHF8IDA9UYv9Y4Jebg1KmDnl1D/70B5XiJC5vbtL1HHdUovna92 r5bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ePyPgKjhIWiwRMTmHSQ4366cQXTJEk6hNG1mV007kY8=; b=LbLWOb2T9R3juOc1shrXtm+hP0d0MsKX0kKh7F2RnTEw84rzqzFseNDjHKbb8akC7/ X7jFlTy0e6NPB+caoASY6011Ds/nEKayYzFTwmj805sEz8r84NNjxNrtQMZrAT6Vqa9Q ElwbnNG7SW/SntSRF4AYwcY7KUsIsREK2cWouqu+5MInl8yOgfacqANLeDBtXyLdk0WO wL9Stxcia+CrBba0zpxOUZ23SrrKkyCI1yPyUtfJ4JQHROKxPEySyL0kYrKSyLST7IOK Oa7zOFZvZUnjBHCcWQpihvLWNEs0xFPpgddsK7iBC6XWdfxZ3yRI2GjDY7GRZxMhA1Gh rFOg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b36si13798046edf.590.2020.07.21.18.08.02; Tue, 21 Jul 2020 18:08:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731562AbgGVBGw (ORCPT + 99 others); Tue, 21 Jul 2020 21:06:52 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54112 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726959AbgGVBGw (ORCPT ); Tue, 21 Jul 2020 21:06:52 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 86ACFD3762CF24A44D79; Wed, 22 Jul 2020 09:06:49 +0800 (CST) Received: from huawei.com (10.175.112.208) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Wed, 22 Jul 2020 09:06:42 +0800 From: Xu Qiang To: , , , , CC: , , Subject: [PATCH -next] gpu: drm: Fix spinlock vblank_time_lock use error. Date: Wed, 22 Jul 2020 01:05:27 +0000 Message-ID: <20200722010527.52293-1-xuqiang36@huawei.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.208] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The drm_handle_vblank function is in the interrupt context. Therefore, the spin lock vblank_time_lock is obtained from the interrupt context. Cc: Signed-off-by: Xu Qiang --- drivers/gpu/drm/drm_vblank.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index f402c75b9d34..4ca63ff33a43 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -229,10 +229,11 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe { u32 cur_vblank; bool rc; + unsigned long irqflags; ktime_t t_vblank; int count = DRM_TIMESTAMP_MAXRETRIES; - spin_lock(&dev->vblank_time_lock); + spin_lock_irqsave(&dev->vblank_time_lock, irqflags); /* * sample the current counter to avoid random jumps @@ -257,7 +258,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe */ store_vblank(dev, pipe, 1, t_vblank, cur_vblank); - spin_unlock(&dev->vblank_time_lock); + spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); } /* @@ -1106,11 +1107,12 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe) static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe) { struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; + unsigned long irqflags; int ret = 0; assert_spin_locked(&dev->vbl_lock); - spin_lock(&dev->vblank_time_lock); + spin_lock_irqsave(&dev->vblank_time_lock, irqflags); if (!vblank->enabled) { /* @@ -1136,7 +1138,7 @@ static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe) } } - spin_unlock(&dev->vblank_time_lock); + spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); return ret; } @@ -1917,6 +1919,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe) { struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; unsigned long irqflags; + unsigned long irqflags_vblank; bool disable_irq; if (drm_WARN_ON_ONCE(dev, !drm_dev_has_vblank(dev))) @@ -1931,18 +1934,18 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe) * vblank enable/disable, as this would cause inconsistent * or corrupted timestamps and vblank counts. */ - spin_lock(&dev->vblank_time_lock); + spin_lock_irqsave(&dev->vblank_time_lock, irqflags_vblank); /* Vblank irq handling disabled. Nothing to do. */ if (!vblank->enabled) { - spin_unlock(&dev->vblank_time_lock); + spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags_vblank); spin_unlock_irqrestore(&dev->event_lock, irqflags); return false; } drm_update_vblank_count(dev, pipe, true); - spin_unlock(&dev->vblank_time_lock); + spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags_vblank); wake_up(&vblank->queue); -- 2.25.0