Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3089748rwb; Mon, 15 Aug 2022 17:52:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7K42f+eXNkY2M8wk6rVX8oMNHL6z1IuFG3POTJanWZ0hlcgiFXqFTimOZ3iBsoEdLU7uOS X-Received: by 2002:a05:6402:40c2:b0:440:4ecd:f75f with SMTP id z2-20020a05640240c200b004404ecdf75fmr16259476edb.405.1660611164166; Mon, 15 Aug 2022 17:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611164; cv=none; d=google.com; s=arc-20160816; b=iRzjB12ztAzn3I46LBu8MWmffdPYglK7+e4DG17+SGirEYUFGXJJvNfAWymDbDN9zT sMT5ZIJ6Tl0BunqY7GuznOLZugfSCoYKiwM/gmqIDmUzUYs6bgpNFkpRANuZFNj/Jqpf X5lNkNt2ZWV4MQM6F3rl/1+eL+Dw7S5ezOyFJQxxT9w9WszRHc8HqExHudQCB1n3tZt8 NS7rgvncZOokpnuV6ftcF65wpxp9xJwL8RO8eMyh2KKgRdLnxpuVJlCGFBZry4r5MmB2 IZv6E+ML2zTH+SmZuHFwLNheMvFTamLoQ+ZTOAiTAp+MtyZphZuA/XqfCGYxYPdPOcsE oZiw== 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=EA9O2lzHBT+m1P4O+c0FcK9MJybgNApf8l6TWq9yOk8=; b=0iTgSngGgoC9i/d2pyoRgIaNbZB+/Yc6JPib9zEUcPVm4BIaD6akgZnOZRkcnwRoym ww9hgmXgExsHWijrToBkYgulV27zdDhj1uhPenEQwqJcj7BzfCZZ42RhzeZmApjTziaH qTnuWkRdakkjhVR5vhEg8v7kSNM1iDkRXhgBIhKUBU7YRDUNzOwgzfNnba+JriE3bH7u QeiqcilgFFrpW0yGhEyxiZJxZ9GN3Jr2YxDXO5SjIy/DDjcbIPiVBbv7ObgArvRNbq/+ xBOvOz5UOpUZvmNjheYuP19ZEgwNR3LbrNaEYqFzKB4sDIjdqQY847ZEThgIjQyR3spy GFOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="q/GPsx9d"; 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 ne10-20020a1709077b8a00b00730961131bdsi10174967ejc.137.2022.08.15.17.52.15; Mon, 15 Aug 2022 17:52:44 -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="q/GPsx9d"; 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 S243484AbiHOWOH (ORCPT + 99 others); Mon, 15 Aug 2022 18:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349882AbiHOWLr (ORCPT ); Mon, 15 Aug 2022 18:11:47 -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 762C511BB27; Mon, 15 Aug 2022 12:38:50 -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 EB08EB80EA8; Mon, 15 Aug 2022 19:38:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 324E1C433C1; Mon, 15 Aug 2022 19:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592328; bh=z5P5iOpHw9o5eHJmvlNNQbVx8HFSYja93QJ6343QSNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q/GPsx9dMtMOZ0Nfqv1Fe6wLN6j6Vd4zldiPJ0LC6XJkCELWb66YoIE1WqulnReIi jnN/SdCJh9qWW9aQSaEh+uXbuB90od8JKS/zl+ie0LlV1VHb76l+C64kU4sIFip5sj 5C/QvwaguwkkyARzNE74Us2AnzyFpFdCSJDCbvug= 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.19 0094/1157] drm/amdgpu: Check BOs requested pinning domains against its preferred_domains Date: Mon, 15 Aug 2022 19:50:50 +0200 Message-Id: <20220815180443.367402744@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 @@ -882,6 +882,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)