From patchwork Thu Jul 25 01:09:58 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: 169659 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10934971ilk; Wed, 24 Jul 2019 18:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqznjk2jD0Tio5LAxdt9f1X2LsjG7B4AUzDHAxatlhJ54R2wNIrrz0MBbFUJ/zM8J8OM9h2n X-Received: by 2002:a17:902:b608:: with SMTP id b8mr89730735pls.303.1564017016843; Wed, 24 Jul 2019 18:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564017016; cv=none; d=google.com; s=arc-20160816; b=06NeD0rCV+NBZ2R6Q5OOAwljfVRWZWFJFv+0TWoYxEq9ATOMXlxApfY9ZbCJzC19Nn VtGVALMGlxTdZP+RxYcR645Yhhhi4swC1h89x+KJBbxXPukt/YoCxdmoD4tKObPIi9oj +udWqYd6h4WURNwZCXCUS1XW4S0y1vmEwJ/vydIsW1ZktdP8ULOKBVdAcDkDJjJ9ow1K QY4eTmzrM5w2arVxm4uy+1W+yPQXt8tAfpdEKCo/2NkOT/3wxBYj6Ec+HjA9y+pKatQy sLG20p5+N/U6srV3IDnytQq4RyxnxYOeFnNqhCr/lkg5B8GLne1A53SGDirZSpD2EfBz YsFA== 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=+X9uNoJSUAaVqVpKQDzL9NtXL+yT7SpGftwfMsqyc9c=; b=SJ/j22f1dNfLMh8Q8J1S6VaoDuNP16WArJ2LMJfVWIZejs2YY8ceaBBo57QnADUYE+ jRZ66iG5Q3PL7rrRre8giGeWTMtdFnPxobEVWpEiMnNC4YdsodWnj4XK4l62IK/f984t du3xoYish8X2EHCiYoE4kw93N/K5VSvOrEctnUraS1NAWl4jjJOQjsr+vqWXzMPNyyAW L8VdSL43QFkZivicLTQ8fAiYsUZ0XTeTNZimdW+wr3Mbcf2bEg/YBfnvAcGWJkxgeHnT wpUtMP5DQi4oDtv79Yu7bd2D/3PDCDgKz/JA8TDULCEwKucyTtnpTDuyXuC4BHaUBeyq rBmg== 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 h7si19617193pgc.130.2019.07.24.18.10.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jul 2019 18:10:16 -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 AD9DC6E2D1; Thu, 25 Jul 2019 01:10:15 +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 6D3946E2D1 for ; Thu, 25 Jul 2019 01:10:09 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id j6so18497643ioa.5 for ; Wed, 24 Jul 2019 18:10:09 -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=7wo6KKh0OlJFgHNJTysz7wNQAp+MWYAtsandKNyFgTE=; b=MhGqhTlAi6o9ewT2IapteV84Tmn0FK1ChG4gvsNT1UG915Eqyu7xozXaCyZJvMzMqg Qg5RAguL+nt8mJSo1V80d0gto1tUPPEKwrsIDUtu+CzdH1XAXcdKDPYm1HtLR35Z/GRk 6JNCmP18kTNtBuakyYsVo6huxmHvD0+EKE6A407E0P2mcyqQmSayXiXUwAqPTQDMWBs2 JKdybEV/Np7+sZvOY0pUOaiaQ0m8nvdNDc5Y1BXvfG9Q2uM4oAHP1mam7EhiqJZByxsF Zz/6bUsSbho5uOkS34fQraXluZBchgJrhMqAkZsYAiPfsbUvojy7myBGTSDniREZ2i1c LNgw== X-Gm-Message-State: APjAAAV4QNDAdB5wmbw0jMYDuDJXiJ1B9Rucz7E+a5n3ticKrsK9Di/P tCJQK0bDtOFuwcW3OVbugOHyxMM= X-Received: by 2002:a02:b609:: with SMTP id h9mr84902773jam.36.1564017008474; Wed, 24 Jul 2019 18:10:08 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.254]) by smtp.googlemail.com with ESMTPSA id o7sm40675924ioo.81.2019.07.24.18.10.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 18:10:07 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/7] drm/shmem: Put pages independent of a SG table being set Date: Wed, 24 Jul 2019 19:09:58 -0600 Message-Id: <20190725011003.30837-3-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190725011003.30837-1-robh@kernel.org> References: <20190725011003.30837-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 Signed-off-by: Rob Herring --- v2: - new patch drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 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);