From patchwork Wed Jan 26 15:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 12725272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 593CBC63684 for ; Wed, 26 Jan 2022 15:22:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5827410E91C; Wed, 26 Jan 2022 15:22:20 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75B0210E8F7; Wed, 26 Jan 2022 15:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643210536; x=1674746536; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d/dJyJfJHyoFjHHsYcxW6VfzFlORPetb+CPpCXnBDQI=; b=QTvsv/MLNkZxmvO5ds6KRW3SJC908B7Cje7QoA8sC/7+fnrKuyafWnoP QZStBJQaFkYG1YQVZo5yT4GMSGa8o1/z2cBXlvDJtiUjc4fm+tdvoEVrn 1DvU1LiFrEgcJLhPocjG55TUFVKfm/eTD0/x4MGK4zeAOF39LVVNqSF+g rF7SqunsfYmofNmdkMmgKoAm1x6mxfcHBR+nKwrhI7PbZkjrNB1WLb+Ro OIosTGbuEb6hkYQvlDIvBVmA1cdUbaJ+DEReUosaVQkcNoQRyP0MDymNq ni7kliXiqFyOszLvyAyb41dQh673TDLBx/KBnmRIb8yZLaIwOLIs3Af5w A==; X-IronPort-AV: E=McAfee;i="6200,9189,10238"; a="309885234" X-IronPort-AV: E=Sophos;i="5.88,318,1635231600"; d="scan'208";a="309885234" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 07:22:16 -0800 X-IronPort-AV: E=Sophos;i="5.88,318,1635231600"; d="scan'208";a="674386264" Received: from jamesstx-mobl.ger.corp.intel.com (HELO mwauld-desk1.intel.com) ([10.213.247.182]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 07:22:15 -0800 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Subject: [PATCH 09/20] drm/i915/buddy: tweak 2big check Date: Wed, 26 Jan 2022 15:21:44 +0000 Message-Id: <20220126152155.3070602-10-matthew.auld@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220126152155.3070602-1-matthew.auld@intel.com> References: <20220126152155.3070602-1-matthew.auld@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Otherwise we get -EINVAL, instead of the more useful -E2BIG if the allocation doesn't fit within the pfn range, like with mappable lmem. The hugepages selftest, for example, needs this to know if a smaller size is needed. Signed-off-by: Matthew Auld Cc: Thomas Hellström Reviewed-by: Thomas Hellström --- drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c index bc725a92fc5c..7c24cc6608e3 100644 --- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c +++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c @@ -81,7 +81,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man, lpfn = pages; } - if (size > mm->size) { + if (size > lpfn << PAGE_SHIFT) { err = -E2BIG; goto err_free_res; }