Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp481263lql; Mon, 11 Mar 2024 08:17:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpVY0GAbSpSoNo5IJ4nfWbCXmb3ZmzYpU2DEdk6dY1mBjc0ZXTiISy8MG5IH63GVGIJAPOO/EiTApittb6xWO9SGgytfYoDCe9twAjcA== X-Google-Smtp-Source: AGHT+IFXDm+7pLbxh4he7A8wCxLsEsVe5a/3qVQEumZOmv2YEb6uCZ/YiBwYjuE5LrUF9e2cnC8j X-Received: by 2002:a17:902:b414:b0:1dd:8ffd:ef8 with SMTP id x20-20020a170902b41400b001dd8ffd0ef8mr626473plr.34.1710170266827; Mon, 11 Mar 2024 08:17:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710170266; cv=pass; d=google.com; s=arc-20160816; b=stjDBEL6PDiC9xWcJIXEIljRrcxXw9FV4F+BaukzQhRHrOdk+auX6MVcJ3I3nuXyck DKN/fXsKAYG261HqszR/Z9usTJNqDKzdNe08plYVFPS3+hEHu/lKFRINPMwbJ0i+TqXL 6z8B6vqjLX+LT8haBckd/H/3hnTfCV4J2bvjUIW8l68aKg6g3N2Fgi9ozLBQFauuB+wo DHISuNRff4MAOxZGDZuVWHg3fFWO96uy2d8Ihqlgg2iXPm9Y4Je/TMQsKYTDMnfwJnhU zSnIjLag3UDDyQU76q7Edbnf4UCvcAQHDxUCEyiBrFDbsgi5h1XUkNac4PWEL5skfGdG khTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7s/HTn0BnJtuzNlwwoBuEVX2IajZPDVBE4BcLtWlMLA=; fh=D+GIBiUpJhYOk59DlDwdWpMXCBNHBaLtGyEvcW4A824=; b=lgQN5wlG5zCa5nVlFoS4w/BcpDr3DshER7I0/DZg9tK5KmjMOIRCd3/+w2svaV63SJ Upul5ur8cp5ScVl/dT4LCis8nEBoicQsDBk9Xc/nc92PUVaKkorbgu1xRfmNMPlkmfIZ P5/CWLBAOdgTG79iBKGthrZTl2D8QjsSQgKgyR9luQzxANR8KYBuxjWeKlxGGgB2tRCR 7UR3vSY5j+hsZsdw+UzKGMFtEFTh/ZzSgESG3VSXqu/QWrR/vPWXXdPQJyeCroSRiu9S E2V65to4pEFX5cUCN55mI/8nNrqCbrBJiFo9gfSNLE1bUZnDN0xZqI3qHOkOONHKkrlp mOsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o38p21XE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q2-20020a170902e30200b001dd63191462si4734341plc.318.2024.03.11.08.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 08:17:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o38p21XE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9EF50283786 for ; Mon, 11 Mar 2024 15:17:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33BC05677F; Mon, 11 Mar 2024 15:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o38p21XE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B8255674D; Mon, 11 Mar 2024 15:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710169976; cv=none; b=nKyrl1lkWhnbMHP3COFdt4sXyxZSBxfBnHPqFKpcP9+qandPOWeCwZlmA3s3ktJBvQ9HiOXdTlBJP0IYHNCPOJN6iMUwwgqBRXKEvbb+CaEWlnBLcyHmJdfocQczoKzRXreD9hYGIUx0Rauocvf3XQTebLiWT6GoTkwYf1IGRO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710169976; c=relaxed/simple; bh=OgG/WDJUTsEvv9Tyw8GnnVBTZTEmUUmnwLIp/HEj/Eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mt6bzHxuSg1Xd6lZOb0XSELvRhiyufIta7ZnPWGrLthRc2wsPDib72/DPbozw67dkTyaqTYD7iAHzZPCoT6stFWB52B4RMdLRaEqEa3JEI2KFk+83MRrAm0RzsOzJrVPE2n+MaDyQg78du8vvFtViD8Qh5j2YXTbhn5UDbqriLY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o38p21XE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F724C43394; Mon, 11 Mar 2024 15:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710169976; bh=OgG/WDJUTsEvv9Tyw8GnnVBTZTEmUUmnwLIp/HEj/Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o38p21XEU9GB+2aFSM+Zo6CewuEX9KSjwQghrgnqQ3YDu9cJQkWG0WYyITouLQRZ7 FCoBTDd15pcKXJx3BrCktgsc1eZFtD/1Ph+XkOlyoN7qCYxj8NJL/6wX58TE19kcFo EPuCmKbTN53+sYUQNF4MwA4TFn802NQHKMPr1V+jRpXCA6Ejjd8eFMCt59dKFzYISn fCXfcrRg4hyFNvtYRtyuzhwxMbUdxAKytou89aNwc2N8BlgPvKjAARNrk2sRtbYrAY DLdnZTvw33Wk/LN+bvAhaw/tKSU0L7tXOAHEWfHZuhQ5OlRZhQLQStCluTgGTPd7/4 O44u31JEf51gg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Matthew Auld , Arunpravin Paneer Selvam , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin , maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.7 17/23] drm/buddy: check range allocation matches alignment Date: Mon, 11 Mar 2024 11:11:57 -0400 Message-ID: <20240311151217.317068-17-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240311151217.317068-1-sashal@kernel.org> References: <20240311151217.317068-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.9 Content-Transfer-Encoding: 8bit From: Matthew Auld [ Upstream commit 2986314aa811c8a23aeb292edd30315495d54966 ] Likely not a big deal for real users, but for consistency we should respect the min_page_size here. Main issue is that bias allocations turns into normal range allocation if the range and size matches exactly, and in the next patch we want to add some unit tests for this part of the api. Signed-off-by: Matthew Auld Cc: Arunpravin Paneer Selvam Cc: Christian König Reviewed-by: Arunpravin Paneer Selvam Link: https://patchwork.freedesktop.org/patch/msgid/20240219121851.25774-5-matthew.auld@intel.com Signed-off-by: Christian König Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_buddy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c index f3a6ac908f815..5ebdd6f8f36e6 100644 --- a/drivers/gpu/drm/drm_buddy.c +++ b/drivers/gpu/drm/drm_buddy.c @@ -771,8 +771,12 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm, return -EINVAL; /* Actual range allocation */ - if (start + size == end) + if (start + size == end) { + if (!IS_ALIGNED(start | end, min_block_size)) + return -EINVAL; + return __drm_buddy_alloc_range(mm, start, size, NULL, blocks); + } original_size = size; original_min_size = min_block_size; -- 2.43.0