Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8652424rwp; Wed, 19 Jul 2023 13:10:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlFu0YP0onDV8/ND4zT01jSKoTPyo/ASQXKF/FzCrHuNaOmXxfOKAHvnbFVJ7z3dU2QMfHtE X-Received: by 2002:aa7:d793:0:b0:51d:d390:143f with SMTP id s19-20020aa7d793000000b0051dd390143fmr3375239edq.5.1689797438389; Wed, 19 Jul 2023 13:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689797438; cv=none; d=google.com; s=arc-20160816; b=b2N7Cv2pg0rBmWqUxQRy0zD982CKVHe+eqOvyXBVej5twzwzHrmH5SJDCkdupO9Nvh atzPj+iQIq+mGvsELR1Jxea629mXIX6DCf8rQbHN4OVYpholEI0yfvqo8LbOrcY0cPDk WOoMB+aACi19p8CX5eM1aLatxPynz4AUZYu0brcFsdnw4UtS8Rfy33OyyficNT017jS8 E3ubv3GJjQZLKYm+3v5yaar+03xeTqIuPtiAtkAMhSss0LLfcKP9sp4jc3tM/2mhYAH7 3AtoP1P7M3N+8/eJJEi4eO5MI8qjHH+nAewyjDWkGEw0yZtSipbg7VZwC1FleO8Y8UxJ cJdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=X++DL9l0FVpouvJqw9VeRG1i/reUcDfPJhbmyigTho8=; fh=Np0nZO1D/ffhTLoWb+P8+iN1JZhKI2X68pqPr3NAfyU=; b=V+n4L9ArsCIdpfcIQ7qS2YbTfLSv9YU7lM1ytAf7HwOF98+CYm5iSUA/wzRp3H32QG 8akRRZPuy5GEHg2ZqracVmEUNTxqGRqIuM/IJR9/3detLCa8skDrN7DFrM97q4Nu8CSt aNHm5JTHr0ypiSE5Z36dSbmG99ALbpnQspgGGrnWeA0ojUAYlyrhn99sjn+lqrM1n6lJ 7smR8a0lg9W7EAejc58Z3k+ehUtCoiox/kgT+eP9xmc1uK/uOtdWQ+2CJtt9AtNA0I6o wr1JDhMIG9LB6PWR5MK1uHb7fiubPT5DN1gH4RzwnQaUYdu6wzx3X0u2d+d8N4/mze1W 93bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sKPn8Hun; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a056402041200b005217878c5fbsi3415881edv.674.2023.07.19.13.10.13; Wed, 19 Jul 2023 13:10:38 -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=@kernel.org header.s=k20201202 header.b=sKPn8Hun; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbjGSTck (ORCPT + 99 others); Wed, 19 Jul 2023 15:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjGSTci (ORCPT ); Wed, 19 Jul 2023 15:32:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2366D199A; Wed, 19 Jul 2023 12:32:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA37D617F4; Wed, 19 Jul 2023 19:32:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C165BC433C8; Wed, 19 Jul 2023 19:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689795156; bh=5B2uDA9tsswf97AKzHjJwVKSaC/eQwz3Ft+8HwN2cMY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=sKPn8HunIyLND9JEMu4ESWhCtE81F+Kc4q9T+MsHvJe5fiVAGpbXuDRp/BYXpZpLS W6t2CpoThhFjaBKMq9V/vJ4xDtEDO/+QJLKs4qmGj74udh8yjbH1CzdstTCReicUZ8 a+GuNCN4+RignvXbuNN79PYXWUJifJtjcjTBO9iPpuJst49Rh/J1yePIbEk1m6saDf mz8tkyzl0u4mUpS4M6IUgiyI4u7WnVW2a2CTTQ6PLdK70OCT8nqJw53A7dhVhXa36m HFuvV439o4y7M4ZqbsSopjve8dD2ar20mZs0A1OecssekbzYQInKUphXz5EvXRa7wO tCq85pkSsXacQ== Date: Wed, 19 Jul 2023 14:32:33 -0500 From: Bjorn Helgaas To: Sui Jingfeng Cc: David Airlie , 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-pci@vger.kernel.org, linux-fbdev@vger.kernel.org, Sui Jingfeng , Alex Deucher , Christian Konig , Pan Xinhui , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Ben Skeggs , Karol Herbst , Lyude Paul , Bjorn Helgaas , Alex Williamson , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Hawking Zhang , Mario Limonciello , Lijo Lazar , YiPeng Chai , Bokun Zhang , Likun Gao , Ville Syrjala , Jason Gunthorpe , Kevin Tian , Cornelia Huck , Yishai Hadas , Abhishek Sahu , Yi Liu , Jani Nikula Subject: Re: [PATCH v3 4/9] PCI/VGA: Improve the default VGA device selection Message-ID: <20230719193233.GA511659@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230711164310.791756-5-sui.jingfeng@linux.dev> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 [+cc linux-pci (please cc in the future since the bulk of this patch is in drivers/pci/)] On Wed, Jul 12, 2023 at 12:43:05AM +0800, Sui Jingfeng wrote: > From: Sui Jingfeng > > Currently, the strategy of selecting the default boot on a multiple video > card coexistence system is not perfect. Potential problems are: > > 1) This function is a no-op on non-x86 architectures. Which function in particular is a no-op for non-x86? > 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, but this is still a policy because it doesn't give the > user a choice to override. I don't think we need a list of *potential* problems. We need an example of the specific problem this will solve, i.e., what currently does not work? The drm/ast and maybe drm/loongson patches are the only ones that use the new callback, so I assume there are real problems with those drivers. CONFIG_DRM_AST is a tristate. We're talking about identifying the boot-time console device. So if CONFIG_DRM_AST=m, I guess we don't get the benefit of the new callback unless the module gets loaded? > Also honor the comment: "Clients have *TWO* callback mechanisms they > can use" This refers to the existing vga_client_register() function comment: * vga_client_register - register or unregister a VGA arbitration client * @pdev: pci device of the VGA client * @set_decode: vga decode change callback * * Clients have two callback mechanisms they can use. * * @set_decode callback: If a client can disable its GPU VGA resource, it * will get a callback from this to set the encode/decode state. and the fact that struct vga_device currently only contains *one* callback function pointer: unsigned int (*set_decode)(struct pci_dev *pdev, bool decode); Adding the .is_primary_gpu() callback does mean there will now be two callbacks, as the comment says, but I think it's just confusing to mention this in the commit log, so I would just remove it. > @@ -1509,13 +1543,24 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, > * cases of hotplugable vga cards. > */ > > - if (action == BUS_NOTIFY_ADD_DEVICE) > + switch (action) { > + case BUS_NOTIFY_ADD_DEVICE: > notify = vga_arbiter_add_pci_device(pdev); > - else if (action == BUS_NOTIFY_DEL_DEVICE) > + if (notify) > + vga_arbiter_notify_clients(); > + break; > + case BUS_NOTIFY_DEL_DEVICE: > notify = vga_arbiter_del_pci_device(pdev); > + if (notify) > + vga_arbiter_notify_clients(); > + break; > + case BUS_NOTIFY_BOUND_DRIVER: > + vga_arbiter_do_arbitration(pdev); > + break; > + default: > + break; > + } Changing from if/else to switch makes the patch bigger than necessary for no real benefit and obscures what is really changing. Bjorn