From patchwork Fri Jul 14 12:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gabriele Paoloni X-Patchwork-Id: 9840899 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5174B60381 for ; Fri, 14 Jul 2017 12:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4331628778 for ; Fri, 14 Jul 2017 12:33:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3805B28780; Fri, 14 Jul 2017 12:33:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E3F328778 for ; Fri, 14 Jul 2017 12:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045AbdGNMdT (ORCPT ); Fri, 14 Jul 2017 08:33:19 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:9774 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753577AbdGNMdS (ORCPT ); Fri, 14 Jul 2017 08:33:18 -0400 Received: from 172.30.72.55 (EHLO nkgeml414-hub.china.huawei.com) ([172.30.72.55]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ASC11037; Fri, 14 Jul 2017 20:26:20 +0800 (CST) Received: from FRAEML703-CAH.china.huawei.com (10.206.14.34) by nkgeml414-hub.china.huawei.com (10.98.56.75) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 14 Jul 2017 20:26:17 +0800 Received: from FRAEML521-MBX.china.huawei.com ([169.254.1.122]) by fraeml703-cah.china.huawei.com ([10.206.14.34]) with mapi id 14.03.0301.000; Fri, 14 Jul 2017 14:26:05 +0200 From: Gabriele Paoloni To: Benjamin Herrenschmidt , Alex Williamson , Bjorn Helgaas CC: Daniel Axtens , "linux-pci@vger.kernel.org" , "Liuxinliang (Matthew Liu)" , Rongrong Zou , Catalin Marinas , Will Deacon , "linux-arm-kernel@lists.infradead.org" , David Airlie , Daniel Vetter Subject: RE: [PATCH v4] PCI: Support hibmc VGA cards behind a misbehaving HiSilicon bridge Thread-Topic: [PATCH v4] PCI: Support hibmc VGA cards behind a misbehaving HiSilicon bridge Thread-Index: AQHS+s1b+EtR4rKf6ku/WSkA/VN5laJQfQIAgAEKviD///e9AIAAoqUAgAACrwCAARsB8A== Date: Fri, 14 Jul 2017 12:26:05 +0000 Message-ID: References: <20170712050811.3620-1-dja@axtens.net> <20170712200430.GI14614@bhelgaas-glaptop.roam.corp.google.com> <20170713112938.GI4486@bhelgaas-glaptop.roam.corp.google.com> <20170713151146.53e9644c@w520.home> <1499980882.2865.65.camel@kernel.crashing.org> In-Reply-To: <1499980882.2865.65.camel@kernel.crashing.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.220.134.92] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5968B86E.00B3, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.1.122, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 86d06e2286f83f3fd02ac0f4b22bc8e7 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Ben, Alex > -----Original Message----- > From: Benjamin Herrenschmidt [mailto:benh@kernel.crashing.org] > Sent: 13 July 2017 22:21 > To: Alex Williamson; Bjorn Helgaas > Cc: Gabriele Paoloni; Daniel Axtens; linux-pci@vger.kernel.org; > Liuxinliang (Matthew Liu); Rongrong Zou; Catalin Marinas; Will Deacon; > linux-arm-kernel@lists.infradead.org; David Airlie; Daniel Vetter > Subject: Re: [PATCH v4] PCI: Support hibmc VGA cards behind a > misbehaving HiSilicon bridge > > On Thu, 2017-07-13 at 15:11 -0600, Alex Williamson wrote: > > > >       */ > > > > -   if (vga_default == NULL && > > > > -       ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == > VGA_RSRC_LEGACY_MASK)) { > > > > +   if (vga_default == NULL) { > > > >              vgaarb_info(&pdev->dev, "setting as boot VGA > device\n"); > > > >              vga_set_default_device(pdev); > > > >      } > > > > > > "Legacy" is the breadcrumb we use to try to pick the same device for > > default VGA as the system firmware used as the boot VGA.  There can > be > > multiple VGA devices in the system, the change above would simply > make > > the first discovered device be the default VGA.  That would break > many, > > many systems.  If legacy VGA ranges mean nothing on ARM64, then > follow > > the powerpc lead and make an arch quirk that simply selects the first > > enabled VGA device as the default.  VGA routing is part of the PCI > spec > > though, so the default of selecting the device with routing enabled > > makes sense.  Thanks, > > "Legacy" there iirc also means that it has decoding enabled at boot. If > you pick the first one you may pick a device that doesn't and hasn't > been initialized by any driver (good old BIOS-initialized text mode). Right so effectively if there is a legacy dev we should pick that up; however what about the following code: Above after we have filled the list of VGA devices by iterating over all PCI devices we check if no legacy one has been set as default VGA device yet: therefore we set the first VGA device in the list as default one... Do you think it would work? Thanks Gab > > Cheers, > Ben. diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 92f1452..ab3ad9a 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -1424,6 +1424,14 @@ static int __init vga_arb_device_init(void) list_for_each_entry(vgadev, &vga_list, list) { struct device *dev = &vgadev->pdev->dev; + + /* if no legacy device has been set as default VGA + * device, just pick up the first one in the list */ + if (vga_default == NULL) { + vgaarb_info(dev, "setting as boot VGA device\n"); + vga_set_default_device(vgadev->pdev); + } + #if defined(CONFIG_X86) || defined(CONFIG_IA64) /* * Override vga_arbiter_add_pci_device()'s I/O based detection