Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2807583rwb; Mon, 15 Aug 2022 11:44:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7y788f6Em/XiwUHq6F2Sat71deTP9tDMIPWGn+wjSKXzqgBO4YGKHBvvCvlfwPNhIeoTNx X-Received: by 2002:a05:6402:341:b0:440:86a2:8272 with SMTP id r1-20020a056402034100b0044086a28272mr15454766edw.70.1660589097071; Mon, 15 Aug 2022 11:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589097; cv=none; d=google.com; s=arc-20160816; b=kSAbvEfG+2XZYYnXJdnD3CY4JiJPl7X2TT+1PXsZJbVy8NPXk3EvrZp2rDnzDo4Nd+ UWxXWlSvsTunqnWP/PpeeHQ4Ut7nJkQAx3DTe03mwhUT+LlEJAvq8ww76SQxWAGVUXdd tUz5jSPLgl8Z+TQB1wNrkaneoFU/XJ4fOIxZuQ0YsUHu4fPAKKLaJm+WJy6+i55ypTly i8fr6vuAsx5RO5D4l6eB/HkVWVWMDlPnDvqzQn9+glplMfyZKOBL5tioXAjQR8awEtB6 B9SdH197QHx/R1JDTEg6pxyzVORqgQQOGNJWeIZLNfaro4qQeNETqLVCmjqljzKRw4JE 1c7Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qHm12iSX4/D3OEqJV+ISFTDTuVyboTbFCsiSS5pKoIY=; b=BGKV4LLnbNOU4LD7PZnGHzXBjcJUKGRDXPB8uf7ASQfIRe0SX9xU9/WDddIZfFKUCr BLTczSnBAyxChEbNt2wouuu1MHS5GoWiUcODa/ODyxDUykR02x+hdfNy2UnwzzIWtI81 mQDkolwLElEhmjHM66sfoywp64MxSj5626DAFRx6RM178ekIgvXEhM2xZzVUz1zklRaV 3s4LmVnd7rHA+B8YXvIxS8B5G3nAkKj5ZccBtX/01tvRzHkkFCAiNjeHweDjDbz1Z3zM iiQSLsj/rDRGknShqZizEfWPD9LeYsmrwW7DP1y46cCksJTWs55Z7ySA7rf2/RXcih+k lBiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U+Ib1274; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht9-20020a170907608900b006ff21423705si8395366ejc.323.2022.08.15.11.44.31; Mon, 15 Aug 2022 11:44:57 -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=@linuxfoundation.org header.s=korg header.b=U+Ib1274; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240479AbiHOSUT (ORCPT + 99 others); Mon, 15 Aug 2022 14:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239819AbiHOSS5 (ORCPT ); Mon, 15 Aug 2022 14:18:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC7012BB15; Mon, 15 Aug 2022 11:16:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 64FB7B81063; Mon, 15 Aug 2022 18:16:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD08DC433D6; Mon, 15 Aug 2022 18:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587380; bh=lk6E3HO1m9rC2T2mQWrxN4dvmUWts8HkHyFZ9zjhZVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+Ib1274h5jvs5GsXXjw59HXOi8rgX7PNXLFtL2icL1rsjvyrWiScbXauQhg+qn7R 55bbJO2GHsPYzl6ofZAH60krJ+UmlHDMVUUsEgVtZvYxCXZvVN/ZQKV6FA7LK0xPlm hnpQEjh+8KcjBm1/jitWVOqz0Ztfe54o3kt+PUz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Li , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH 5.15 068/779] drm/amdgpu: Check BOs requested pinning domains against its preferred_domains Date: Mon, 15 Aug 2022 19:55:12 +0200 Message-Id: <20220815180340.188431192@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Leo Li commit f5ba14043621f4afdf3ad5f92ee2d8dbebbe4340 upstream. When pinning a buffer, we should check to see if there are any additional restrictions imposed by bo->preferred_domains. This will prevent the BO from being moved to an invalid domain when pinning. For example, this can happen if the user requests to create a BO in GTT domain for display scanout. amdgpu_dm will allow pinning to either VRAM or GTT domains, since DCN can scanout from either or. However, in amdgpu_bo_pin_restricted(), pinning to VRAM is preferred if there is adequate carveout. This can lead to pinning to VRAM despite the user requesting GTT placement for the BO. v2: Allow the kernel to override the domain, which can happen when exporting a BO to a V4L camera (for example). Signed-off-by: Leo Li Reviewed-by: Alex Deucher Reviewed-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -912,6 +912,10 @@ int amdgpu_bo_pin_restricted(struct amdg if (WARN_ON_ONCE(min_offset > max_offset)) return -EINVAL; + /* Check domain to be pinned to against preferred domains */ + if (bo->preferred_domains & domain) + domain = bo->preferred_domains & domain; + /* A shared bo cannot be migrated to VRAM */ if (bo->tbo.base.import_attach) { if (domain & AMDGPU_GEM_DOMAIN_GTT)