From patchwork Mon May 8 20:34:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 9716621 X-Patchwork-Delegate: agross@codeaurora.org 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 C036560385 for ; Mon, 8 May 2017 20:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5A35204BA for ; Mon, 8 May 2017 20:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA18925EF7; Mon, 8 May 2017 20:35:16 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D75626224 for ; Mon, 8 May 2017 20:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753778AbdEHUfP (ORCPT ); Mon, 8 May 2017 16:35:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55086 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752402AbdEHUfO (ORCPT ); Mon, 8 May 2017 16:35:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A9DA4607DE; Mon, 8 May 2017 20:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1494275713; bh=VTf1Si/oas0uUBIAZQd11SoaYDEN54eKdehid5ToJ3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsO+inI7ogoZzP5uPntYfuLT9QJzqhDbOFDqFILcSPDHSMeDFKQO88zS8uiE+nkyF kRXYyM+p8yplg88iNpHoI3VgFSZ+qVAdX8f/NvvQXt/6NRcnbTeUxGGAyvTHak6KsD slLoKkwtzHL/8wC2ESUUSleAodg+jWUWSKbNtL2c= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1BA9B60731; Mon, 8 May 2017 20:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1494275713; bh=VTf1Si/oas0uUBIAZQd11SoaYDEN54eKdehid5ToJ3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsO+inI7ogoZzP5uPntYfuLT9QJzqhDbOFDqFILcSPDHSMeDFKQO88zS8uiE+nkyF kRXYyM+p8yplg88iNpHoI3VgFSZ+qVAdX8f/NvvQXt/6NRcnbTeUxGGAyvTHak6KsD slLoKkwtzHL/8wC2ESUUSleAodg+jWUWSKbNtL2c= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1BA9B60731 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 01/13] drm/msm: Take the mutex before calling msm_gem_new_impl Date: Mon, 8 May 2017 14:34:57 -0600 Message-Id: <1494275709-25782-2-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494275709-25782-1-git-send-email-jcrouse@codeaurora.org> References: <1494275709-25782-1-git-send-email-jcrouse@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Amongst its other duties, msm_gem_new_impl adds the newly created GEM object to the shared inactive list which may also be actively modifiying the list during submission. All the paths to modify the list are protected by the mutex except for the one through msm_gem_import which can end up causing list corruption. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_gem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 68e509b..7a82eaa 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -853,7 +853,11 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, size = PAGE_ALIGN(dmabuf->size); + /* Take mutex so we can modify the inactive list in msm_gem_new_impl */ + mutex_lock(&dev->struct_mutex); ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj); + mutex_unlock(&dev->struct_mutex); + if (ret) goto fail;