From patchwork Wed Aug 10 21:24:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9274179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95E736022E for ; Wed, 10 Aug 2016 21:24:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8382627E22 for ; Wed, 10 Aug 2016 21:24:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7818B283E9; Wed, 10 Aug 2016 21:24:28 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 1F25027E22 for ; Wed, 10 Aug 2016 21:24:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E916F6E883; Wed, 10 Aug 2016 21:24:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D71786E883 for ; Wed, 10 Aug 2016 21:24:25 +0000 (UTC) Received: by mail-qk0-x22c.google.com with SMTP id t7so56959568qkh.0 for ; Wed, 10 Aug 2016 14:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Iab1fC79Iv0s+LxmpW0mxtyc8hsYjrFwkq6FO7ZGtM=; b=nT99J4geG5zJ/WBqdt6EGicYo+IuYJbwmEMqiCSfFrkq14jEo1RTg9OJlyqQ7Momkt +GdzEqlqRoZ2Uv9eDNv1kt3dhZjFiThMf09Fw7DXHDq5cxF72wD+MpFcdFxE/oE+AIw3 wmP9WEGv7NuUmTpMP6q6QKJo2gW06CGHq8tdk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Iab1fC79Iv0s+LxmpW0mxtyc8hsYjrFwkq6FO7ZGtM=; b=SWRlOQmNR16SvpWhv9L94/hLQpWB1cCRY6b6Utn1uV9+i5kKoiv8kAeujKgtIL0YTF /wbEPhJ2qFHSHhPjjR5oVHcuq61uemcv9WoZ5EzVCVcXvdGs6UmEAXRM7Eyq60rMz2Dv KduCy5nrLtwJ8XDzX+TD+9fsUrFBbY74HxYfy9dpVEGYvMboec0OfvVvsuLsUOB3y8YJ XBXHvtkzr+CumMXTaz4pNGND901FUb1u8AeIPerCTBkmD1UJo1gqu1+OP2twT2b1hOTn ivp/9SZYnkITFmIfP0qmtO9hRXWONDNcrdxcOM2OAF+i2Qf1vAMVLrmIrq3PdaBzc2w3 4gvw== X-Gm-Message-State: AEkoouu1hFTqgHwboEmHfcNPZT18jpHR8XB5utJSEue8jPRu3s2bc8LyGQnqAsrKKUIJ+Odz X-Received: by 10.55.159.82 with SMTP id i79mr7029825qke.192.1470864265053; Wed, 10 Aug 2016 14:24:25 -0700 (PDT) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id l32sm24452678qta.23.2016.08.10.14.24.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 14:24:24 -0700 (PDT) From: Sean Paul To: mark.yao@rock-chips.com, dri-devel@lists.freedesktop.org, ykk@rock-chips.com Subject: [PATCH 1/6] drm/rockchip: Change psr list mutex to spinlock Date: Wed, 10 Aug 2016 17:24:14 -0400 Message-Id: <1470864258-22680-2-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1470864258-22680-1-git-send-email-seanpaul@chromium.org> References: <1470864258-22680-1-git-send-email-seanpaul@chromium.org> Cc: marcheu@chromium.org, dianders@chromium.org, linux-rockchip@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since it needs to be taken in the vblank_enable/disable stack, which is protected by another spinlock. This lock should be completely uncontested, since it's only taken in find_psr and register, which is only called on init. Signed-off-by: Sean Paul --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 30 ++++++++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index fe89ea5..0f57f3b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -189,7 +189,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags) drm_dev->dev_private = private; INIT_LIST_HEAD(&private->psr_list); - mutex_init(&private->psr_list_mutex); + spin_lock_init(&private->psr_list_lock); drm_mode_config_init(drm_dev); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 6281ac6..653aeb8 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -75,7 +75,7 @@ struct rockchip_drm_private { struct drm_mm mm; struct list_head psr_list; - struct mutex psr_list_mutex; + spinlock_t psr_list_lock; }; void rockchip_drm_atomic_work(struct work_struct *work); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c index 04d1c71..6a51851 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c @@ -41,17 +41,18 @@ static struct psr_drv *find_psr_by_crtc(struct drm_crtc *crtc) { struct rockchip_drm_private *drm_drv = crtc->dev->dev_private; struct psr_drv *psr; + unsigned long flags; - mutex_lock(&drm_drv->psr_list_mutex); + spin_lock_irqsave(&drm_drv->psr_list_lock, flags); list_for_each_entry(psr, &drm_drv->psr_list, list) { - if (psr->encoder->crtc == crtc) { - mutex_unlock(&drm_drv->psr_list_mutex); - return psr; - } + if (psr->encoder->crtc == crtc) + goto out; } - mutex_unlock(&drm_drv->psr_list_mutex); + psr = ERR_PTR(-ENODEV); - return ERR_PTR(-ENODEV); +out: + spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags); + return psr; } static void psr_set_state(struct psr_drv *psr, enum psr_state state) @@ -142,8 +143,9 @@ void rockchip_drm_psr_flush(struct drm_device *dev) { struct rockchip_drm_private *drm_drv = dev->dev_private; struct psr_drv *psr; + unsigned long flags; - mutex_lock(&drm_drv->psr_list_mutex); + spin_lock_irqsave(&drm_drv->psr_list_lock, flags); list_for_each_entry(psr, &drm_drv->psr_list, list) { if (psr->state == PSR_DISABLE) continue; @@ -153,7 +155,7 @@ void rockchip_drm_psr_flush(struct drm_device *dev) psr_set_state(psr, PSR_FLUSH); } - mutex_unlock(&drm_drv->psr_list_mutex); + spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags); } EXPORT_SYMBOL(rockchip_drm_psr_flush); @@ -170,6 +172,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, { struct rockchip_drm_private *drm_drv = encoder->dev->dev_private; struct psr_drv *psr; + unsigned long flags; if (!encoder || !psr_set) return -EINVAL; @@ -186,9 +189,9 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, psr->encoder = encoder; psr->set = psr_set; - mutex_lock(&drm_drv->psr_list_mutex); + spin_lock_irqsave(&drm_drv->psr_list_lock, flags); list_add_tail(&psr->list, &drm_drv->psr_list); - mutex_unlock(&drm_drv->psr_list_mutex); + spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags); return 0; } @@ -206,8 +209,9 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder) { struct rockchip_drm_private *drm_drv = encoder->dev->dev_private; struct psr_drv *psr, *n; + unsigned long flags; - mutex_lock(&drm_drv->psr_list_mutex); + spin_lock_irqsave(&drm_drv->psr_list_lock, flags); list_for_each_entry_safe(psr, n, &drm_drv->psr_list, list) { if (psr->encoder == encoder) { del_timer(&psr->flush_timer); @@ -215,6 +219,6 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder) kfree(psr); } } - mutex_unlock(&drm_drv->psr_list_mutex); + spin_unlock_irqrestore(&drm_drv->psr_list_lock, flags); } EXPORT_SYMBOL(rockchip_drm_psr_unregister);