From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757042AbcASBy2 (ORCPT ); Mon, 18 Jan 2016 20:54:28 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:36538 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757022AbcASByY (ORCPT ); Mon, 18 Jan 2016 20:54:24 -0500 Subject: Re: [PATCH V3 20/21] pci, acpi: Match PCI config space accessors against platfrom specific quirks. To: Tomasz Nowicki , Mark Salter , , , , , , , , , , References: <1452691267-32240-1-git-send-email-tn@semihalf.com> <1452691267-32240-21-git-send-email-tn@semihalf.com> <1452785776.28109.22.camel@redhat.com> <569CDD8F.807@semihalf.com> CC: , , , , , , , , , , , , , , Zhou Wang , Gabriele Paoloni From: "liudongdong (C)" Message-ID: <569D9634.3040304@huawei.com> Date: Tue, 19 Jan 2016 09:49:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <569CDD8F.807@semihalf.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.61.21.156] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.569D9643.0136,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3de1e7f89ade93cabfa1660a42f36d85 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomasz, Mark 在 2016/1/18 20:41, Tomasz Nowicki 写道: > On 14.01.2016 16:36, Mark Salter wrote: >>> +extern struct pci_mcfg_fixup __start_acpi_mcfg_fixups[]; >>> >+extern struct pci_mcfg_fixup __end_acpi_mcfg_fixups[]; >>> >+ >>> >+static struct pci_ops *pci_mcfg_check_quirks(struct acpi_pci_root *root) >>> >+{ >>> >+ struct pci_mcfg_fixup *f; >>> >+ int bus_num = root->secondary.start; >>> >+ int domain = root->segment; >>> >+ >>> >+ /* >>> >+ * First match against PCI topology then use DMI or >>> >+ * custom match handler. >>> >+ */ >>> >+ for (f = __start_acpi_mcfg_fixups; f < __end_acpi_mcfg_fixups; f++) { >>> >+ if ((f->domain == domain || f->domain == PCI_MCFG_DOMAIN_ANY) && >>> >+ (f->bus_num == bus_num || f->bus_num == PCI_MCFG_BUS_ANY) && >>> >+ (f->system ? dmi_check_system(f->system) : 0 || >>> >+ f->match ? f->match(f, root) : 0)) >>> >+ return f->ops; >> I think this would be better as: >> >> (f->system ? dmi_check_system(f->system) : 1 && >> f->match ? f->match(f, root) : 1)) >> return f->ops; >> >> Otherwise, one has to call dmi_check_system() from f->match() if >> access to root is needed. > Non-DMI, we need not to call dmi_check_system() from f->match(), we can use _HID to decide to hook the pci_ops or not. Device (PCI1) { Name (_HID, "HISI0080") // PCI Express Root Bridge Name (_CID, "PNP0A03") // Compatible PCI Root Bridge ... } static const struct acpi_device_id hisi_pcie_ids[] = { {"HISI0080", 0}, {"", 0}, }; static int hisi_pcie_match(struct pci_mcfg_fixup *fixup, struct acpi_pci_root *root) { int ret; struct acpi_device *device; device = root->device; ret = acpi_match_device_ids(device, hisi_pcie_ids); if (ret) return 0; ...... return 1; } static struct pci_ops hisi_ecam_pci_ops = { .map_bus = pci_mcfg_dev_base, .read = hisi_pci_read, .write = hisi_pci_write, }; DECLARE_ACPI_MCFG_FIXUP(NULL, hisi_pcie_match, &hisi_ecam_pci_ops, PCI_MCFG_DOMAIN_ANY, PCI_MCFG_BUS_ANY); Thanks Dongdong > Makes a lot of sense to me, I will modify as you suggested. > > Tomasz > -- > To unsubscribe from this list: send the line "unsubscribe linux-pci" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > . >