Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3018627rwb; Mon, 15 Aug 2022 16:15:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4liZrWBMnLMEnICc2/g0nop6ymho9f3nmJ7vrYYZqx9WI1fLxGGu9JFkNkqEaIBgJ/Ukja X-Received: by 2002:a05:6402:32a8:b0:43e:5490:295f with SMTP id f40-20020a05640232a800b0043e5490295fmr16311552eda.193.1660605327571; Mon, 15 Aug 2022 16:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605327; cv=none; d=google.com; s=arc-20160816; b=UaItp8cUPlOyMPXbniwB1PEaaoE9f07d2mI9FquZBOwNVtfpNQawdFRI/NjGMI10ue HVCV0jN/1tajEYM6K0k0X8U/VmkHl8c30t6NKkbsD786mvntyM4JzlDAAjD/83SjBS6a MDvAwyOv/wwQPEB+v19ruRFRQQjQ9eCuY1ukZgJ6293X+dsd2E0vASB727GN1mrJpT3F XsiTSs/llt4o5aJczzxZH5R9OJs0UOVqNJdnqi5Z5ec6rrs3/tIesHoxns+qHpEMd39p ufH0lwtQZPJUD6k0a51hGQwXWpiMba8enO5kd4hBIII8G3OpPROvm94kHG3fQeLbXjnD KDMg== 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=eqawOxyz416v7LFDDJZ3EOfWJbq6oQ7cdmgE+3/UNxWVRl0PAL4a69csqZdv0jvxIU 9eXHnazrEJKKl0qB+C/yWiEi7lJlKk9Pci9IR121I7OwfF/OXhpgqsZBZ7e3QCvdr3mf BL12r4bGKlWVUxuJ7HVLw1TxTQylet2lbAqyabUOQ2OXV2enhyUCn3zxDAVBKcQP3+6v 10nZtZ87WfPWJl+k7EVmRv2NKAuJm8zV876xJQFLXxe5wsUQHgbtd9cSSAq3OGJeWfiY XsGk3t4DH9+rPjPOTmsMqIoHiwh+6e/5h1ZYyS6uFpaq5uAepkfhlPUbPH+0ZcAxxb8E 9Nlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B2jxVl0W; 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 eb13-20020a0564020d0d00b00440e4be2c8bsi10192536edb.507.2022.08.15.16.15.01; Mon, 15 Aug 2022 16:15:27 -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=B2jxVl0W; 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 S1346336AbiHOUT4 (ORCPT + 99 others); Mon, 15 Aug 2022 16:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346809AbiHOUMV (ORCPT ); Mon, 15 Aug 2022 16:12:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2F386891; Mon, 15 Aug 2022 11:58:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 60B6361280; Mon, 15 Aug 2022 18:58:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63316C43470; Mon, 15 Aug 2022 18:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589902; bh=z5P5iOpHw9o5eHJmvlNNQbVx8HFSYja93QJ6343QSNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2jxVl0W4VTD72HirGPc5g5ZE2EYH92zpVpw/oJkBSifXhGzyToA3ft3cyq2voC06 D8B6TtqayYJH55x1LLzDwgMtyIjaCqATgZY2E8okCQS2aYj2G6LRRdinmMXq6EXraq V7QtbHWBbtB76FF3UYDn8xsb5VH+wtFGnBmoer1o= 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.18 0085/1095] drm/amdgpu: Check BOs requested pinning domains against its preferred_domains Date: Mon, 15 Aug 2022 19:51:24 +0200 Message-Id: <20220815180433.042800016@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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)