From patchwork Mon Dec 30 13:23:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 11313049 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 428AE14E3 for ; Mon, 30 Dec 2019 13:24:42 +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 2B59B20409 for ; Mon, 30 Dec 2019 13:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B59B20409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9591189D58; Mon, 30 Dec 2019 13:24:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8055589CF5 for ; Mon, 30 Dec 2019 13:24:34 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Dec 2019 05:24:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,375,1571727600"; d="scan'208";a="251375512" Received: from ramaling-i9x.iind.intel.com ([10.99.66.154]) by fmsmga002.fm.intel.com with ESMTP; 30 Dec 2019 05:24:32 -0800 From: Ramalingam C To: intel-gfx , Chris Wilson Date: Mon, 30 Dec 2019 18:53:51 +0530 Message-Id: <20191230132351.17487-4-ramalingam.c@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191230132351.17487-1-ramalingam.c@intel.com> References: <20191230132351.17487-1-ramalingam.c@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 3/3] drm/i915/dumb: return the allocated memory size X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On successful allocation, instead returning the requested size return the total size of allocated pages. Signed-off-by: Ramalingam C --- drivers/gpu/drm/i915/i915_gem.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 7f39df3fab7f..5a53de797852 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -241,7 +241,9 @@ i915_gem_dumb_create(struct drm_file *file, { enum intel_memory_type mem_type = INTEL_MEMORY_SYSTEM; int cpp = DIV_ROUND_UP(args->bpp, 8); + struct intel_memory_region *mr; u32 format; + int ret; switch (cpp) { case 1: @@ -270,8 +272,15 @@ i915_gem_dumb_create(struct drm_file *file, if (HAS_LMEM(to_i915(dev))) mem_type = INTEL_MEMORY_LOCAL; - return i915_gem_create(file, to_i915(dev), mem_type, - &args->size, &args->handle); + ret = i915_gem_create(file, to_i915(dev), mem_type, + &args->size, &args->handle); + if (ret) + goto out; + + mr = intel_memory_region_by_type(to_i915(dev), mem_type); + args->size = ALIGN(args->size, mr->min_page_size); +out: + return ret; } /**