Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp243026rwb; Wed, 28 Sep 2022 02:00:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fxW0c6CG4zLIItVp6CXtArY+2LSiUv1aFfGSWuoa18RcjH/GkpQFMAOcsB9ZIXxBq7Tzm X-Received: by 2002:a50:ee0c:0:b0:457:29d4:80df with SMTP id g12-20020a50ee0c000000b0045729d480dfmr17161959eds.397.1664355610652; Wed, 28 Sep 2022 02:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664355610; cv=none; d=google.com; s=arc-20160816; b=0smsMgkkYZcofMwK1tl3Y/7uhm1u0RoBGOuHTeSFHqxd0K61nkq0jQDVOYazsCVQtH YzvT11rvzBPkWx5wZJtiVrmOtgnbppEKWMrq1xdjlHAFYcStiPTPJb1A6YlbgAiy366P 45qj7GqZ0WiDkNyOw6FIU3oaMsMzMEVag3qWP+G1+TbTE0Fukv0nEUt2dbGmr9kj7Ijk hzT7KWfI6CYSv78ohs1mFMYN31BvC3/5RvcVmaclCxXR9sHiaYnuWxvfv17S5twq1Ejx YtfBaDvN2qrgg7/LmOje4mgwDDa4dC07jBssm2/zhsfD5WVYnVYS7T8/72SFm+zcYrZs sBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IPiPt8qu9c4GMt3qjr1OeYEV1x9C5G/E/Mff1WLOIOI=; b=s+5fTd/knr+V4wY3U3sSgoKc7QVefTmYsvh2inBmcPyAtblqrnC3Lbw2fV+EXi82ko RQ6YpUFE4pFAEJqHdrZ95ZRtcZ9Qc4TIkxNo6vsoxyDSs/IhOB3S8g/piazgk75LGe2X cTkN+Etwq5gKWeUd0IE+zJ2pjLi5tD8TUeXWOgfhn3DiEAtEM7uDBNxFwYOmYdR1YOQ3 m1sw9Kfzg0ZufIbC08CJHV9UuWu/wduHzeP9iWM8YG8rXafJk+TBW7ckiE7jzS3Fnce4 mrV9aUG8V8OJXhF4XKXulGMLNf31AgJ/mq3DEwwQbQnp31/voRpRb5be8+Ib9k8iphL/ m/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QQi247+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a1709065d0300b0077f8c8e2c6bsi4589176ejt.815.2022.09.28.01.59.44; Wed, 28 Sep 2022 02:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QQi247+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbiI1IQC (ORCPT + 99 others); Wed, 28 Sep 2022 04:16:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234036AbiI1IOk (ORCPT ); Wed, 28 Sep 2022 04:14:40 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5775495A7; Wed, 28 Sep 2022 01:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664352878; x=1695888878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sje3TAP90mMjJ4940AZvP8k1syPAFp/h9HzOk/O8E9U=; b=QQi247+rtNGN+h1CUiI4NoA5kygwLvjGRHySTnaQF+AqlnTKOFAaa4ax yDjpkM/2jmoTZXBnFlM1dakswlQ14ERRfsP3N9jROGwVjKAis7xwGzCqY DWeo/7oMrI/wluUJmb/IHsvEzkVe7AWV6DXI8RGc1cFWzUJLtbhukyl8b UOfD6HOrao7TZp6jcJXayHWz+XYscmGSqxSbJa34DP90ZtYoRnMtr7R8P L6xdjigtymmRhjfMQNJNCZ+pdAAfTlzPhfYU9Fga7zChl8nKkZ4nsShik RsMPwnNNIcS7SSIb3AeAOMluK8DJ23vdgJ16055cuLiPJ54ztWpKbrBgs g==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="281910375" X-IronPort-AV: E=Sophos;i="5.93,351,1654585200"; d="scan'208";a="281910375" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 01:14:37 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="621836436" X-IronPort-AV: E=Sophos;i="5.93,351,1654585200"; d="scan'208";a="621836436" Received: from maciejos-mobl.ger.corp.intel.com (HELO paris.ger.corp.intel.com) ([10.249.147.47]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 01:14:28 -0700 From: Gwan-gyeong Mun To: intel-gfx@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, mchehab@kernel.org, chris@chris-wilson.co.uk, matthew.auld@intel.com, thomas.hellstrom@linux.intel.com, jani.nikula@intel.com, nirmoy.das@intel.com, airlied@redhat.com, daniel@ffwll.ch, andi.shyti@linux.intel.com, andrzej.hajda@intel.com, keescook@chromium.org, mauro.chehab@linux.intel.com, linux@rasmusvillemoes.dk, vitor@massaru.org, dlatypov@google.com, ndesaulniers@google.com, trix@redhat.com, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-sparse@vger.kernel.org, nathan@kernel.org, gustavoars@kernel.org, luc.vanoostenryck@gmail.com Subject: [PATCH v13 8/9] drm/i915: Use error code as -E2BIG when the size of gem ttm object is too large Date: Wed, 28 Sep 2022 11:12:59 +0300 Message-Id: <20220928081300.101516-9-gwan-gyeong.mun@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220928081300.101516-1-gwan-gyeong.mun@intel.com> References: <20220928081300.101516-1-gwan-gyeong.mun@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ttm_bo_init_reserved() functions returns -ENOSPC if the size is too big to add vma. The direct function that returns -ENOSPC is drm_mm_insert_node_in_range(). To handle the same error as other code returning -E2BIG when the size is too large, it converts return value to -E2BIG. Signed-off-by: Gwan-gyeong Mun Cc: Chris Wilson Cc: Matthew Auld Cc: Thomas Hellström Reviewed-by: Nirmoy Das Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index d33f06b95c48..a2557f1ecbce 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1243,6 +1243,17 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), bo_type, &i915_sys_placement, page_size >> PAGE_SHIFT, &ctx, NULL, NULL, i915_ttm_bo_destroy); + + /* + * XXX: The ttm_bo_init_reserved() functions returns -ENOSPC if the size + * is too big to add vma. The direct function that returns -ENOSPC is + * drm_mm_insert_node_in_range(). To handle the same error as other code + * that returns -E2BIG when the size is too large, it converts -ENOSPC to + * -E2BIG. + */ + if (size >> PAGE_SHIFT > INT_MAX && ret == -ENOSPC) + ret = -E2BIG; + if (ret) return i915_ttm_err_to_gem(ret); -- 2.37.1