From patchwork Fri Jul 14 17:03:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gabriele Paoloni X-Patchwork-Id: 9841455 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 F40DA60381 for ; Fri, 14 Jul 2017 17:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE34A2874F for ; Fri, 14 Jul 2017 17:05:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D29C228751; Fri, 14 Jul 2017 17:05:19 +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=unavailable 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 71FF62874F for ; Fri, 14 Jul 2017 17:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754599AbdGNREz (ORCPT ); Fri, 14 Jul 2017 13:04:55 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:9775 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754595AbdGNREy (ORCPT ); Fri, 14 Jul 2017 13:04:54 -0400 Received: from 172.30.72.57 (EHLO nkgeml411-hub.china.huawei.com) ([172.30.72.57]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ASC32142; Sat, 15 Jul 2017 01:04:11 +0800 (CST) Received: from FRAEML702-CAH.china.huawei.com (10.206.14.33) by nkgeml411-hub.china.huawei.com (10.98.56.70) with Microsoft SMTP Server (TLS) id 14.3.235.1; Sat, 15 Jul 2017 01:04:11 +0800 Received: from FRAEML521-MBX.china.huawei.com ([169.254.1.122]) by fraeml702-cah.china.huawei.com ([10.206.14.33]) with mapi id 14.03.0301.000; Fri, 14 Jul 2017 19:04:00 +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///e9AIAAoqUAgAACrwCAARsB8P//+TwAgAAzgMA= Date: Fri, 14 Jul 2017 17:03:59 +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> <1500040204.2865.90.camel@kernel.crashing.org> In-Reply-To: <1500040204.2865.90.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.0A020205.5968F98D.0091, 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 Alex, Ben > -----Original Message----- > From: Benjamin Herrenschmidt [mailto:benh@kernel.crashing.org] > Sent: 14 July 2017 14:50 > To: Gabriele Paoloni; 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 > > On Fri, 2017-07-14 at 12:26 +0000, Gabriele Paoloni wrote: > > 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 > > > > 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? > > I honestly don't remember all of the details of the arbiter but just > make sure that it won't think that device is enabled for things like > VGA etc... if it's memory/IO decode weren't enabled. > I think the following one should make sure that MEM/IO response are enabled (also as suggested by Alex) Also the above one could allow us to get rid of fixup_vga in powerpc.... > I'd rather we have no default device until a driver actually picks up > though, and then, if we still have no default, use the first driver to > pick up. Well from my understanding the PCI host controller driver will enumerate all the devices in the PCI hierarchy and call pci_device_add() for each of them, that in turn will call device_add(), at this stage if there is a driver available for the device such driver will probe otherwise it will not. Are you suggesting to add the code above in pci_device_add() after device_add() and after checking that a driver has been bound for such dev? Thanks Gab > > Ben. diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 92f1452..a90c48c 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -1424,6 +1424,21 @@ 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, + * justpick up the first one in the list capable of responding to + * mem and io requests*/ + if (vga_default == NULL) { + u16 cmd; + + pci_read_config_word(vgadev->pdev, PCI_COMMAND, &cmd); + if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || + !vga_default_device()) { + vga_set_default_device(vgadev->pdev); + vgaarb_info(dev, "setting as boot VGA device\n"); + } + } + #if defined(CONFIG_X86) || defined(CONFIG_IA64) /* * Override vga_arbiter_add_pci_device()'s I/O based detection