Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37158090rwd; Tue, 11 Jul 2023 10:09:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFISDV1DX6V39qsvCV0tIIl7PH4oRQOBPOj9KVkwWeLnniwwLApxk3IgzDqB6MVVQ8sKRtv X-Received: by 2002:a17:902:b402:b0:1b6:a972:4414 with SMTP id x2-20020a170902b40200b001b6a9724414mr13515273plr.3.1689095345452; Tue, 11 Jul 2023 10:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689095345; cv=none; d=google.com; s=arc-20160816; b=BLoAV7AvaUcpsZo9ugqtJFRQzxODvxyq0e01bS4ToVh9irET1nF03likY1Q/sfDaAi Qx2LzmFmx6na8pOcgy4mEOH77ZmvOGaPLEaLropQW5ce6bH1ZxG/ZCbYm8S+DMdRtcPZ rPLzDYXIarojlLM47FD1etazDey+UMzdWQLFCKVaMd1cRDIpMGPr/LroL3NLK86+ktwP j7yVyO+kfD5VSnxII/EdlmOv4cAhFahSxMMSQ2LYMQ4RkHjLI6t0fvJH8qx8UlpPVIP9 0GeZAEEZHTErCrUQC2A9WV2w0lIEh1wS4Av2JGaomrJxNW+qfdE1PFK7BI96mhvdpi3m d+tQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AOe2sK5corMJVr8s18spKTEHFO7S6COQNSRgsjkc54A=; fh=ygkTXrv1QW2aJHL5AkX1nEAGd3njUqmECwhnenyY9Ag=; b=JWzhtAeDVzNK6FNwDs9WjbETiBzBRTDfqWt5heOIqdcwqBQCMk8dw48Fyro5HoVJWI iMzenv+Ooyx0I5WGhzFdaBD8f3qnqX04kV6A0iE37YiWL1qhuFvI7hA+oig1NcpFdVNg 3Pv7q3Jwozd+XgAXULo5gGrlePQ32Re7SrvC6FYZN8jfkBV73JjIZseeRf++83HmdiwF +1ikTTuzlzIF/5JxPvnj0urqQxRY0mxsP17fXGlzTwBiR1A6abg7aZEXsXIpm5Tfl77r MOP/FJUFF3QqD4RoZfDjugp0S6n80Wp6q1TuRc4e1IuPXVN0AM/9hVurYsKB0bQLoCyK r4GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HvE3n3cE; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a170903234300b001b8b2865f38si1913588plh.170.2023.07.11.10.08.52; Tue, 11 Jul 2023 10:09:05 -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=@linux.dev header.s=key1 header.b=HvE3n3cE; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232579AbjGKQn2 (ORCPT + 99 others); Tue, 11 Jul 2023 12:43:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232648AbjGKQn1 (ORCPT ); Tue, 11 Jul 2023 12:43:27 -0400 Received: from out-52.mta1.migadu.com (out-52.mta1.migadu.com [IPv6:2001:41d0:203:375::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EE710CA for ; Tue, 11 Jul 2023 09:43:25 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689093803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AOe2sK5corMJVr8s18spKTEHFO7S6COQNSRgsjkc54A=; b=HvE3n3cEhL+NyqDPKs/PppZJPBBvkJ6Z4GSVgABYNxQ2TNgTefhpbD3IAngGIGTrb5+KTM icD3Y1kKySVnFd4+WbZ+s5x0ORowvdjlmISvzqeRR17HIuhuiCDtQTtAfWl+F7Idw7tj4L vMOMD463UkpiH9xDww2GoIrwBEM6k90= From: Sui Jingfeng To: David Airlie Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 0/9] PCI/VGA: Improve the default VGA device selection Date: Wed, 12 Jul 2023 00:43:01 +0800 Message-Id: <20230711164310.791756-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: Sui Jingfeng Currently, the default VGA device selection is not perfect. Potential problems are: 1) This function is a no-op on non-x86 architectures. 2) It does not take the PCI Bar may get relocated into consideration. 3) It is not effective for the PCI device without a dedicated VRAM Bar. 4) It is device-agnostic, thus it has to waste the effort to iterate all of the PCI Bar to find the VRAM aperture. 5) It has invented lots of methods to determine which one is the default boot device on a multiple video card coexistence system. But this is still a policy because it doesn't give the user a choice to override. With the observation that device drivers or video aperture helpers may have better knowledge about which PCI bar contains the firmware FB, This patch tries to solve the above problems by introducing a function callback to the vga_client_register() function interface. DRM device drivers for the PCI device need to register the is_boot_device() function callback during the driver loading time. Once the driver binds the device successfully, VRAARB will call back to the driver. This gives the device drivers a chance to provide accurate boot device identification. Which in turn unlock the abitration service to non-x86 architectures. A device driver can also pass a NULL pointer to keep the original behavior. This series is applied on the drm-tip branch (with a cleanup patch set[1] applied beforehand) [1] https://patchwork.freedesktop.org/series/120548/ v2: * Add a simple implemment for drm/i915 and drm/ast * Pick up all tags (Mario) v3: * Fix a mistake for drm/i915 implement * Fix patch can not be applied problem because of drm/amdgpu merged other people's patch. Sui Jingfeng (9): video/aperture: Add a helper to detect if an aperture contains firmware FB video/aperture: Add a helper for determining if an unmoved aperture contain FB PCI/VGA: Switch to aperture_contain_firmware_fb_nonreloc() PCI/VGA: Improve the default VGA device selection drm/amdgpu: Implement the is_primary_gpu callback of vga_client_register() drm/radeon: Add an implement for the is_primary_gpu function callback drm/i915: Add an implement for the is_primary_gpu hook drm/ast: Register as a vga client to vgaarb by calling vga_client_register() drm/loongson: Add an implement for the is_primary_gpu function callback drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++- drivers/gpu/drm/ast/ast_drv.c | 29 +++++++++ drivers/gpu/drm/drm_aperture.c | 16 +++++ drivers/gpu/drm/i915/display/intel_vga.c | 31 ++++++++- drivers/gpu/drm/loongson/lsdc_drv.c | 10 ++- drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +- drivers/gpu/drm/radeon/radeon_device.c | 12 +++- drivers/pci/vgaarb.c | 74 ++++++++++++++++------ drivers/vfio/pci/vfio_pci_core.c | 2 +- drivers/video/aperture.c | 65 +++++++++++++++++++ include/drm/drm_aperture.h | 2 + include/linux/aperture.h | 14 ++++ include/linux/vgaarb.h | 8 ++- 13 files changed, 247 insertions(+), 30 deletions(-) -- 2.25.1