From patchwork Mon Jun 10 16:58:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 10985187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5895D1398 for ; Mon, 10 Jun 2019 16:58:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479C62874A for ; Mon, 10 Jun 2019 16:58:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B20D2876B; Mon, 10 Jun 2019 16:58:30 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF9502874A for ; Mon, 10 Jun 2019 16:58:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8779E8903B; Mon, 10 Jun 2019 16:58:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ua1-f66.google.com (mail-ua1-f66.google.com [209.85.222.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3A2B8903B for ; Mon, 10 Jun 2019 16:58:25 +0000 (UTC) Received: by mail-ua1-f66.google.com with SMTP id o19so3310730uap.13 for ; Mon, 10 Jun 2019 09:58:25 -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:mime-version :content-transfer-encoding; bh=fP7YpHWgglKrcyzFnh2irV1N3UnxTxR7hTUY8S1RfRI=; b=WiaDec0JqKjFSyFwqlseBvcuhiJyfUxRsOkaOAeSAIiL9UgW39bklvhF+lRzGgv+Ru A0MH9+EhObOhJzCi9wDGngMgQhjR+CrCbZJf/gBgjUoMp5VQP2UQ+Al8dQyC5M2k4I4N V8wU86287xhIvQ9rpas2OwsOIvnWILci5WYG/Vl6osetwzjPEjMOSzmIld9ajeqUG6Od AtKFkfX552/e6ZzTIqo+5/HmfLtM+78wGtOtzeooUfDYOPUqIVkHl0Oylf9Wzq9DKfs0 hLlS6guARl8d/F+dUGfJEvLNEU7uIKvFhFGlyWl0QedGOSDAckg7Fh/LDJuGkK75rfrC 02Mg== X-Gm-Message-State: APjAAAUu1W0HkXpn6P5m8Ktxq68N8QoZ+W60zTJsvCzAWFzC9cghk+lB Kb6JcKTNF57ldlU8/liZFqNk3qI= X-Google-Smtp-Source: APXvYqzr7EYiXkxb3cR+hs3tLYAVe1LTyyEaBwjiIw+TLeMotk6/t0i6hXbuIBqHf+4WqbyJhJGZww== X-Received: by 2002:a9f:3770:: with SMTP id a45mr6415917uae.64.1560185904499; Mon, 10 Jun 2019 09:58:24 -0700 (PDT) Received: from localhost.localdomain ([64.188.179.199]) by smtp.googlemail.com with ESMTPSA id p67sm3366457vkd.40.2019.06.10.09.58.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 09:58:24 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/panfrost: Align GEM objects GPU VA to 2MB Date: Mon, 10 Jun 2019 10:58:06 -0600 Message-Id: <20190610165806.24854-1-robh@kernel.org> X-Mailer: git-send-email 2.20.1 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: Robin Murphy , Tomeu Vizoso , Steven Price Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to increase the chances of using 2MB pages, we need to align the GPU VA mapping to 2MB. Only do this if the object size is 2MB or more. Cc: Robin Murphy Cc: Steven Price Cc: Tomeu Vizoso Signed-off-by: Rob Herring Reviewed-by: Tomeu Vizoso --- drivers/gpu/drm/panfrost/panfrost_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index a5528a360ef4..886875ae31d3 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -52,6 +52,7 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t int ret; struct panfrost_device *pfdev = dev->dev_private; struct panfrost_gem_object *obj; + u64 align; obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) @@ -59,9 +60,12 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t obj->base.base.funcs = &panfrost_gem_funcs; + size = roundup(size, PAGE_SIZE); + align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0; + spin_lock(&pfdev->mm_lock); - ret = drm_mm_insert_node(&pfdev->mm, &obj->node, - roundup(size, PAGE_SIZE) >> PAGE_SHIFT); + ret = drm_mm_insert_node_generic(&pfdev->mm, &obj->node, + size >> PAGE_SHIFT, align, 0, 0); spin_unlock(&pfdev->mm_lock); if (ret) goto free_obj;