From mboxrd@z Thu Jan 1 00:00:00 1970 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 9531CC433F5 for ; Tue, 15 Mar 2022 11:31:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40F6210E3BF; Tue, 15 Mar 2022 11:31:17 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5814F10E3B5; Tue, 15 Mar 2022 11:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647343875; x=1678879875; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=iCs162XcE1/cnIipmN5m0bOdvbMF1WgSBo898ixy8XY=; b=jDpc4xOWB2tddrZbNVkd3G1ghy0lx2yW4i+Y3zkm436kY47qfNewR+pk 5SrIv3+tUuQO4KZq0mWURTzJ/+4JpolsEntqkgzX1ZbyPCeckkTk+N8Y2 6HVlVG/mP9EU2DZTjh/Jwh3rdVQ9HegNpLS9SQFM4WSmRumqzNAUMQIOy D1bJeZ+5UBOQM+IBO8hdRPHwK9wxKGtquCgsY6x6owu01PuC/VpLaBF5R vE5xpdVlDQswkuchxHp/BYprhAtdANpweO4iW1JtU7r02Nke8hdo2fyFx PtemvAf7hNqHJbS55J67k+fampFBhvp2xIiGPdeZ1qP2dDUbIMR/tjn8h w==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="319495739" X-IronPort-AV: E=Sophos;i="5.90,183,1643702400"; d="scan'208";a="319495739" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2022 04:31:14 -0700 X-IronPort-AV: E=Sophos;i="5.90,183,1643702400"; d="scan'208";a="556883345" Received: from sobyrne-mobl.ger.corp.intel.com (HELO [10.252.31.219]) ([10.252.31.219]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2022 04:31:12 -0700 Message-ID: <01c75d44-80b1-3368-e568-0e38072138d6@intel.com> Date: Tue, 15 Mar 2022 11:31:10 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-GB To: Arunpravin , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org References: <20220314194049.534471-1-Arunpravin.PaneerSelvam@amd.com> From: Matthew Auld In-Reply-To: <20220314194049.534471-1-Arunpravin.PaneerSelvam@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Intel-gfx] [PATCH] drm: Fix a infinite loop condition when order becomes 0 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: , Cc: alexander.deucher@amd.com, christian.koenig@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 14/03/2022 19:40, Arunpravin wrote: > handle a situation in the condition order-- == min_order, > when order = 0, leading to order = -1, it now won't exit > the loop. To avoid this problem, added a order check in > the same condition, (i.e) when order is 0, we return > -ENOSPC > > Signed-off-by: Arunpravin Hmm, it sounded like we were instead going to go with the round_up(size, min_page_size), or check and bail if the size is misaligned, in which case we don't need this, AFAICT. > --- > drivers/gpu/drm/drm_buddy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c > index 72f52f293249..5ab66aaf2bbd 100644 > --- a/drivers/gpu/drm/drm_buddy.c > +++ b/drivers/gpu/drm/drm_buddy.c > @@ -685,7 +685,7 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm, > if (!IS_ERR(block)) > break; > > - if (order-- == min_order) { > + if (!order || order-- == min_order) { > err = -ENOSPC; > goto err_free; > }