From patchwork Fri Aug 2 19:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 170446 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1223083ile; Fri, 2 Aug 2019 12:52:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqJUX76I399XKJQS/X9TsJorc4coNlsKz29usP+0MuV3KeIh+YmVWI2tF7oVYqgsY/wzri X-Received: by 2002:a17:90a:d997:: with SMTP id d23mr5631252pjv.84.1564775521102; Fri, 02 Aug 2019 12:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564775521; cv=none; d=google.com; s=arc-20160816; b=L6bmT1KvByjASdYMhQqqMUj1NQCT0LciFxotT9/wmtUVs2ASSFZ+VBlsbDIQrOldVc YIfBmw4YsoQnpgZChbHWtHxCdtMSd5NJiYcyue56nInuuhjR3plBdtjg8J67o6DyPm14 tEzyIKSsr3xjV7Bpi0yFZuj2etBUgCitBFTgJRiEHj7qbceo/xwfbJ5ageCtR9t4zD7o VERN1XyDwF203VwZrqJiWDR9Bh7CwjJgkNFVjI4BIY6bS4F2dz6Ppl1XpEkEIoBNi0/L oWRLESnNha8HMf8kWaGOGKBByRmamdLuVsH056wuteqCRcccVNh+2MZXRT+0a8WNNzdY 4Ecw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=fWd3AhBFV218/gqZRYdVkqdgDKemrSLvu5MCyL5Mvdc=; b=mRtaMKQtb523nDQNP4hW/5WWsbwQYRFO2v9EhCSd0aFadbPGQhFO9Je0SvE3878MkA 8cXPZOHc6DTJBQxn2jzZ4fyMGpsiiVipdzuT3yQ0smOfg6L7t5lr0EUKFN2cs0Bp3YGP GJa4XcgZiZMtETIRso/tZG8THczmFC9kEvfvTRa3pwzTerQ5kgCuRc1z2BEGXC82V/j2 W40uZbalmBxI58C/KPgCG1lsiE89sbQ5zQze8MISxYBdsOuc3PZ6fpRd5nDuL6f1wLUc puPZSGgodC8lGScUygK93fh3q4Qfl4UH0PK8dMSPngu2jF1KyCwcARJkdNmaulQQGZGI 4urQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id h15si36704017plk.74.2019.08.02.12.52.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2019 12:52:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B8C76ED66; Fri, 2 Aug 2019 19:51:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04CC16E5BB for ; Fri, 2 Aug 2019 19:51:56 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id f4so154739285ioh.6 for ; Fri, 02 Aug 2019 12:51:55 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DsLdLXwkKyVix7l/rZud1QvU7xBYPQX9vimqxkDxj0k=; b=CIK59CFgeIDT/zt4QFu0YkOt1SJAjpKzzwJ5pVJkE6pDf7z3nepcoR+rVcPptjVIfV 2oNM9Wzn3c3Y3IelgX3jQOLeNSxd9tm9sBQhgmkeeEPxlG8baNB9c59qKSkmtuxV4nuc KlD3HJSmBah2XM3f2AD/zPVjmMYMq8cJiTnknsQw11nEDYjybA6WeV4feyDapYS98J2G gqgDP8AaM/uOcG1Bru+d12zPSBCfz9Nk6BIWbUsMWuBkObqCw/kOYowdqmZsQHLwfj+b a4VCsMvf0WO9NBKusBlVjldni/N08Gy1CqIeSk4FuiEzLW+EaSg8In2Uiv1E4aRFi1et VSNQ== X-Gm-Message-State: APjAAAVUvnXUDA6GzrR+PmdbrYiAd6oWILLKOAU3D2H1Bhr5Bje+ncgS R01I5SftEM2Jcm/CMDBHGxEP1bI= X-Received: by 2002:a05:6602:1d2:: with SMTP id w18mr9841177iot.157.1564775515011; Fri, 02 Aug 2019 12:51:55 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id s4sm98419934iop.25.2019.08.02.12.51.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 12:51:54 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/8] drm/shmem: Put pages independent of a SG table being set Date: Fri, 2 Aug 2019 13:51:44 -0600 Message-Id: <20190802195150.23207-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802195150.23207-1-robh@kernel.org> References: <20190802195150.23207-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , Maxime Ripard , Sean Paul , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a driver does its own management of pages, the shmem helper object's pages array could be allocated when a SG table is not. There's not really any good reason to tie putting pages with having a SG table when freeing the object, so just put pages if the pages array is populated. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Eric Anholt Reviewed-by: Steven Price Acked-by: Alyssa Rosenzweig Signed-off-by: Rob Herring --- drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 2f64667ac805..477e4cc50f7a 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -118,11 +118,11 @@ void drm_gem_shmem_free_object(struct drm_gem_object *obj) if (shmem->sgt) { dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl, shmem->sgt->nents, DMA_BIDIRECTIONAL); - - drm_gem_shmem_put_pages(shmem); sg_free_table(shmem->sgt); kfree(shmem->sgt); } + if (shmem->pages) + drm_gem_shmem_put_pages(shmem); } WARN_ON(shmem->pages_use_count);