From patchwork Thu Jul 23 17:44:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 6855281 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AA04A9F38B for ; Thu, 23 Jul 2015 17:45:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF17620783 for ; Thu, 23 Jul 2015 17:45:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 867B52077F for ; Thu, 23 Jul 2015 17:45:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 266C46EAC6; Thu, 23 Jul 2015 10:45:01 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f53.google.com (mail-qg0-f53.google.com [209.85.192.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id E31966E761 for ; Thu, 23 Jul 2015 10:44:59 -0700 (PDT) Received: by qged69 with SMTP id d69so91829415qge.0 for ; Thu, 23 Jul 2015 10:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=qkyLSPN+VVObDUZew8xmcdDScPnvUDRwVxYHdMNnkVM=; b=zWUaX5/6WaDRcYrqIleDe6t6XpSPkHrUY6eAsUKYKWEqulmXWzP06mVOSGUe5LDm9P +5rPOWqcbDiif6JuNSFShKth+4IZIvc3Ve2XyuqR6GbUJ6H4o4Z5/VN+Bjzp5TTAVUEa DE6+pplx+tY3ZEcTLZ3WJCv1MNhhwaGMljDCsFoRdoYTkWtDPSxZnRpN6kZbDCp4De8z IYOpNyP/Ts4pCew1jaqv/vExI6+DiA6aXujfVjuMkGBRKpbYQrYkLEaCYKvrNxmidvFw 43GbJd/nTZ9VbFkmdxnyPmh4pzS03QN/GXd3senXvRC/KgFwDF2W6LDdnlR3Ah1Q/K7W kMyA== X-Received: by 10.140.22.135 with SMTP id 7mr13844540qgn.98.1437673499050; Thu, 23 Jul 2015 10:44:59 -0700 (PDT) Received: from localhost (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id d30sm2722647qkh.45.2015.07.23.10.44.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2015 10:44:58 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/msm: fix msm_gem_prime_get_sg_table() Date: Thu, 23 Jul 2015 13:44:56 -0400 Message-Id: <1437673496-28843-1-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 2.4.3 Cc: Stanimir Varbanov , linux-arm-msm@vger.kernel.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-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to return a new sgt, since the caller takes ownership of it. Reported-by: Stanimir Varbanov Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gem_prime.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_prime.c b/drivers/gpu/drm/msm/msm_gem_prime.c index dd7a7ab..831461b 100644 --- a/drivers/gpu/drm/msm/msm_gem_prime.c +++ b/drivers/gpu/drm/msm/msm_gem_prime.c @@ -23,8 +23,12 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj) { struct msm_gem_object *msm_obj = to_msm_bo(obj); - BUG_ON(!msm_obj->sgt); /* should have already pinned! */ - return msm_obj->sgt; + int npages = obj->size >> PAGE_SHIFT; + + if (WARN_ON(!msm_obj->pages)) /* should have already pinned! */ + return NULL; + + return drm_prime_pages_to_sg(msm_obj->pages, npages); } void *msm_gem_prime_vmap(struct drm_gem_object *obj)