From patchwork Thu Aug 8 22:21:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 170867 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp9165218ile; Thu, 8 Aug 2019 15:22:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBtdKNjsGIYxsMkEH7pz5IqVYAlirw5JOOc1BU1ww7+Yrvvq6bpjvVGYkR0m02z6pWd/ZH X-Received: by 2002:a62:7641:: with SMTP id r62mr17773648pfc.35.1565302931239; Thu, 08 Aug 2019 15:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565302931; cv=none; d=google.com; s=arc-20160816; b=MQ2Co2ooflmSNoHS2gEqI4Imj9jkiXxJMkTENcQfZ2YQkcbVbONe6QoRzgX7XA7Niw sNSuHCbH/g6T+eAdkfWNrd/57Z38M0MGPeAwjHayLPXCnT860zWZVKDrxqs1ylBCDNiG mkG83haQer5NtNCDbZdf+QRPrbVNWtWNxbXHrvdyd1QUPqLdz+XDmZNMJ5b54idduw75 VRMUAiN2IT86npL+zC+laZ4vVqeKjo0ULc/ohK84dB73mDntT/dK7wIbxc1r1DMr/sfq ENlrb7QHMuuiioRjqr/zOlMX88dvgAnFXhZwuYyO/IoecE3DQ4Z3NAf9SDm/PEFfNnXC qjOg== 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=WDle76tEh1iTxAGxPWCewvIvmKkf9ILVKJSbPVEbyNc=; b=C4qkrXV5PN6166DU2/2CSKmFv01JxE3bHuX0ZIJ/ryKEspYwn4ykPWCmw29g8HZzvw 5euCUwP4q8wYi1415hAMF10jg/LzDmul2NF6zH4ViMqMEhibt8gUtcgvaR+hHhpCbGFA 1tlyAEqLsNI9Am4/J8mHGuoxBJ5szTz3tBpSKmUvG5CNFM/uQyfZco0et22IHQipC1Q+ mq/0QRrc44eoffHhW9JO/Q+g6TFoo0IFRy2hIXlhTx9gEX+rkVipK2RZzfcgMp3j0tfx tUkiQyyki75EzOudiunr+cNO+f6lZ8jl21Nczs0kaCv3pMvNyZStu8otJ4vjozb4i6Ng Tflw== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id y187si56178084pgb.480.2019.08.08.15.22.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Aug 2019 15:22:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 05A8E6ECCE; Thu, 8 Aug 2019 22:22:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id C4A3E6ECCD for ; Thu, 8 Aug 2019 22:22:05 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id d17so125212836oth.5 for ; Thu, 08 Aug 2019 15:22:05 -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=9uNhmbTEbbQrM0MoHTtlKr7OqFoVNlAP3gF7AhHdlds=; b=ECw8BKPPQ5uDbTNj5F4/e3xSiplHnObjxUuzE4C/mjOWZy9Y/1WJxmji6+t0pOpR2w mfBcWkbExlzLGua0QlLxpo2F25fjomyKG5I/Har11kFVdIjpo8mGUsFVjdIZqTvwkAQ9 drWHdOwPeqOT4Fheg8bnkotFn+Sl8dYDlKcXAVoMGCfmwUqK1XgRWEV0E6w+qLzN0Mi1 g3/Wvb3VkghuVJOKVDSAsLGiROeGVb/DdHyNWEvrbARHmuvI7BbF6cVIt6eNcw3eYco5 gIft7C13Zv4RR4uIoJ2h0Kwbzn3K8hPAfISYLYJEOYzns510hCXkD4eqtYJxhmush6K+ f1rQ== X-Gm-Message-State: APjAAAUZ6SYkc17neWTWE2aZUsQ/ZTzbDbVZVOeCuVON7EAgX8CPB3nT pDgzH6SdT2rdIKCKD2C3lZJ1xZM= X-Received: by 2002:a02:b883:: with SMTP id p3mr19677005jam.79.1565302924703; Thu, 08 Aug 2019 15:22:04 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id i4sm118528553iog.31.2019.08.08.15.22.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 08 Aug 2019 15:22:04 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 2/9] drm/shmem: Put pages independent of a SG table being set Date: Thu, 8 Aug 2019 16:21:53 -0600 Message-Id: <20190808222200.13176-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808222200.13176-1-robh@kernel.org> References: <20190808222200.13176-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 , Robin Murphy , Steven Price , David Airlie , Boris Brezillon , Alyssa Rosenzweig , Sean Paul 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 Reviewed-by: Eric Anholt --- 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 4b442576de1c..df8f2c8adb2b 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -119,11 +119,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);