From patchwork Wed May 31 02:14:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9755697 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 8232F60390 for ; Wed, 31 May 2017 02:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74EF220499 for ; Wed, 31 May 2017 02:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6996E204BD; Wed, 31 May 2017 02:14:59 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5EEC420499 for ; Wed, 31 May 2017 02:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=0ducD8vFVOWF/S9R1HbgiWFSQEk/AYqhxPDnTRZb6yw=; b=lau Wt0hhukSBkumzs5fSJYcLEgq5ubkzl40W9g3+eP8xex97J1a1UiM8DkIKt86NW/qZNrx91ZcgV/IC VV2vLaquWOmC+/q3JdUBYkfk5gjoGoSV4j4IT2uhaHTPF4IfvVQcAOIc/l2rtOlmemLio9LgP912S NcbOuJ4JIEevacdW8ePgstSIjRMieCU78dr6dxWFbeJ9xlOGrjNH88tpU9MIXCvSkEcV0C9z7TS1x QgOq8FMhFQ+1tQvwVMj0Q4ZCMurFknorFBn+9eyR7PuIbPTM0eTL8PU/wJ8ao4OR1TvtluhpN9WoW yQ26wna1J/kXw/Zs+1SFlOPB9U4U0cQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dFt9z-0003Qi-B8; Wed, 31 May 2017 02:14:55 +0000 Received: from mail-pg0-f66.google.com ([74.125.83.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dFt9x-0003P3-84 for linux-rockchip@lists.infradead.org; Wed, 31 May 2017 02:14:54 +0000 Received: by mail-pg0-f66.google.com with SMTP id s62so151017pgc.0 for ; Tue, 30 May 2017 19:14:32 -0700 (PDT) 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; bh=kIIkOvOQRtAuA7UAH7+3TJZLgTEfWzP4CJFfOuuKru0=; b=ikHeR/CC3faCPg0nDeHPcO6vvKfRPDg8XMg1m3MaMPW+gZGpvwf7zwcM3r4xwplTI/ LMcU0JiwWBa0Nr7N+XaA4+QDootSSYhio/Dtt1MQKg34awmsOOiU593nmxSdpHULcDP/ TVpkfXclYzeGdxUUnQystrLvu0b+bRoPUTD5fxfcajiS88U0x/xfnO/MsOCrEKtCGTYU LZZYIVjH2941l6pK0WxlTtb8c9zOnqUvtJDPa+6RnokiZ3RvzbOnfITnhgVNXYkRGN6e S7+QuQEBuGv8G/HFT2S8Ne8v6ZDPThyqUlg4CR6g2xeqRTwp1NJeviL/SjXgqUj8ZRQO TNDw== X-Gm-Message-State: AODbwcBEdQZBjxPGkk+kzHCX6mDxQqyNwoplDnlh+BaXWZaLWuz/KUhh db4MS/Fk6PpoBw== X-Received: by 10.84.217.141 with SMTP id p13mr85169549pli.59.1496196871709; Tue, 30 May 2017 19:14:31 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id h84sm26457479pfh.45.2017.05.30.19.14.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 May 2017 19:14:30 -0700 (PDT) From: Caesar Wang To: mark.yao@rock-chips.com Subject: [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes Date: Wed, 31 May 2017 10:14:23 +0800 Message-Id: <1496196863-25738-1-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170530_191453_325969_B9760968 X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, linux-rockchip@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As the allocation and free buffer that need to add mutex lock for drm mm, but it lacks the locking on error path in rockchip_gem_iommu_map(). Also, the trivial changes like The comment should be placed in the kerneldoc and unused blank line. Signed-off-by: Caesar Wang Reviewed-by: Mark Yao --- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 47905fa..c7e96b8 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -45,13 +45,13 @@ struct rockchip_crtc_state { * * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc. * @num_pipe: number of pipes for this device. + * @mm_lock: protect drm_mm on multi-threads. */ struct rockchip_drm_private { struct drm_fb_helper fbdev_helper; struct drm_gem_object *fbdev_bo; struct drm_atomic_state *state; struct iommu_domain *domain; - /* protect drm_mm on multi-threads */ struct mutex mm_lock; struct drm_mm mm; struct list_head psr_list; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index df9e570..b74ac71 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -29,12 +29,11 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj) ssize_t ret; mutex_lock(&private->mm_lock); - ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm, rk_obj->base.size, PAGE_SIZE, 0, 0); - mutex_unlock(&private->mm_lock); + if (ret < 0) { DRM_ERROR("out of I/O virtual memory: %zd\n", ret); return ret; @@ -56,7 +55,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj) return 0; err_remove_node: + mutex_lock(&private->mm_lock); drm_mm_remove_node(&rk_obj->mm); + mutex_unlock(&private->mm_lock); return ret; }