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: 9841453 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 13F1A60381 for ; Fri, 14 Jul 2017 17:05:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F051D2874F for ; Fri, 14 Jul 2017 17:05:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39C528751; Fri, 14 Jul 2017 17:05:05 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66B142874F for ; Fri, 14 Jul 2017 17:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g0PTUB4QCa8WS8d+NpnxrjkgtT3iWrBsgJxbWgjDgUs=; b=V8rimSSZWO89J5 FBO/SHv4gxS8Ke0U3C9nmAoFEs0u3ixg8I4glnpc7khY/qvk+Gy2RhfTf4SIOr9NwuTJ0tKry86ol FwYnyuQdhU/4uufhJxWP7bRvyiB3t8R5qFQXH7m6QH7nmYJfs3Y6Cdv/6knj/XmjWYmp7MhmoT4s3 thAAYSzXwSkFuiFuuhcO92g1jErvlYK6HKO3tr2W/FAwR2GDJzJ9nqn0fCnJmcXa5w3ZcDR3Gak5q f6WrDyzsb2MGXL3GeoFZPzmcJxMRika13z/6nvf4eYG2Pv5FYFcHxqRCMtFfT46+IQ8ayiAhmT1v7 BWB0ONuie828HQHY8paw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dW41N-0006AK-4p; Fri, 14 Jul 2017 17:04:53 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dW41I-000699-VQ for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2017 17:04:51 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170714_100449_498220_09DB68FC X-CRM114-Status: GOOD ( 20.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , "linux-pci@vger.kernel.org" , Will Deacon , "Liuxinliang \(Matthew Liu\)" , Catalin Marinas , Rongrong Zou , Daniel Vetter , "linux-arm-kernel@lists.infradead.org" , Daniel Axtens Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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