From patchwork Thu Sep 26 14:10:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 11162809 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F348113B1 for ; Thu, 26 Sep 2019 14:12:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBADA222C5 for ; Thu, 26 Sep 2019 14:12:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBADA222C5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B9AB6ED43; Thu, 26 Sep 2019 14:12:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D8556ED42; Thu, 26 Sep 2019 14:12:31 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id q21so1898531pfn.11; Thu, 26 Sep 2019 07:12:31 -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; bh=Iz6GPeVEWxjGTFyACmaAqr696d/fTgvzJcKi4N4gyXI=; b=Q9tYoHl6EMOQmnw/gM2BQ7vYo7gBkVOrVF4myId85dEZGCr3AZBUKV/7FyodVqF7mc 0/8NXGN8nhzEgVqAbBFqzbtX7NWN0SgikAI40DohsVsME1fMlrdyHfcAtt+B72hQBsQT zzo4w88WP4EGn3I/+jtdinQ6eGtsezTqI+idgxTTMwXL9PA0FwxFoVmFct/1kCCgp0eM FriTp43ChgMNqHHqlWScL1a6iFWazTzxiXfW4XI5aIOix5/MuD1enVGTYCIKl+vO17oK EKLpfQLnBk9odRJZSLbg+ONkdljik9vUjBOZwd5OR5dNjmMYDFKjUbNpq0iEYVm6p/Bb 9AXQ== X-Gm-Message-State: APjAAAVP3uhBYMPqXkdZJNvPcrWNCglDfWdtEnuETmWlC4165NNexXMC uLFXqZJ9S/4KP9m4TQLdAQc2TvdpFkk= X-Google-Smtp-Source: APXvYqxoaf0L9tPwXSoSE7sgKT/dxV6NdWxrZv+tRrJpRjuMb0IaZSEKBpHQb5QTbzB6mdC9mjJygQ== X-Received: by 2002:a63:550a:: with SMTP id j10mr3561266pgb.369.1569507150886; Thu, 26 Sep 2019 07:12:30 -0700 (PDT) Received: from localhost.localdomain (ah.ptr230.ptrcloud.net. [153.122.161.8]) by smtp.gmail.com with ESMTPSA id w188sm2176740pgw.26.2019.09.26.07.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 07:12:30 -0700 (PDT) From: Qiang Yu To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm/v3d: use drm_gem_objects_lookup Date: Thu, 26 Sep 2019 22:10:41 +0800 Message-Id: <20190926141046.30758-4-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190926141046.30758-1-yuq825@gmail.com> References: <20190926141046.30758-1-yuq825@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iz6GPeVEWxjGTFyACmaAqr696d/fTgvzJcKi4N4gyXI=; b=KwFNXU/XG+vPgCYiZvnpfMCfxK9bZs1C+IfwdCXL8VDIJddmEzlp9ykhwaqC/Fi9q2 1HbtKbYlNmSifXYjcrHJNaXd4AO2l3E9VN/M4JNGAfyjnwGH9GEs0M8rxahU0H7boLJE 7yfdO7G/61SAen5Ct3xUQmKNmyaT7lc8I+aTJo8UqF7LXmWzKJwCqwfoXQV54bkIZoWM Kasq30nbFjEZ+tndFWa9GlWqXFruU/U/MIRAMlBam42X+UHCUuN1WF33zbogOqwNOkGI WPes8qAj4kOvBMDZzGsjWqbBJHxwYLmSWauARv7Rj+f+KUp4EdpvZoJ96AE32u2d8zVj 5Vbg== 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: lima@lists.freedesktop.org, Maxime Ripard , David Airlie , Qiang Yu , Sean Paul MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Cc: Eric Anholt Signed-off-by: Qiang Yu --- drivers/gpu/drm/v3d/v3d_gem.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index 4c4b59ae2c81..b7c4e56dafd2 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -291,8 +291,7 @@ v3d_lookup_bos(struct drm_device *dev, u32 bo_count) { u32 *handles; - int ret = 0; - int i; + int ret; job->bo_count = bo_count; @@ -304,19 +303,10 @@ v3d_lookup_bos(struct drm_device *dev, return -EINVAL; } - job->bo = kvmalloc_array(job->bo_count, - sizeof(struct drm_gem_cma_object *), - GFP_KERNEL | __GFP_ZERO); - if (!job->bo) { - DRM_DEBUG("Failed to allocate validated BO pointers\n"); - return -ENOMEM; - } - handles = kvmalloc_array(job->bo_count, sizeof(u32), GFP_KERNEL); if (!handles) { - ret = -ENOMEM; DRM_DEBUG("Failed to allocate incoming GEM handles\n"); - goto fail; + return -ENOMEM; } if (copy_from_user(handles, @@ -324,26 +314,13 @@ v3d_lookup_bos(struct drm_device *dev, job->bo_count * sizeof(u32))) { ret = -EFAULT; DRM_DEBUG("Failed to copy in GEM handles\n"); - goto fail; + goto out; } - spin_lock(&file_priv->table_lock); - for (i = 0; i < job->bo_count; i++) { - struct drm_gem_object *bo = idr_find(&file_priv->object_idr, - handles[i]); - if (!bo) { - DRM_DEBUG("Failed to look up GEM BO %d: %d\n", - i, handles[i]); - ret = -ENOENT; - spin_unlock(&file_priv->table_lock); - goto fail; - } - drm_gem_object_get(bo); - job->bo[i] = bo; - } - spin_unlock(&file_priv->table_lock); + ret = drm_gem_objects_lookup(file_priv, handles, + job->bo_count, &job->bo); -fail: +out: kvfree(handles); return ret; }