Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp808583imm; Tue, 5 Jun 2018 04:59:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKkG6kp9dJfQe47YZB2Q0wmS7X+um0yCciA1vkQXcOi8RiqZihWKiw/NEZB0n1q4xeR7TnO X-Received: by 2002:a62:4556:: with SMTP id s83-v6mr5225114pfa.73.1528199940325; Tue, 05 Jun 2018 04:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528199940; cv=none; d=google.com; s=arc-20160816; b=k8g79KL+Uicy21IlMgI0ERtRiA4VPYNIWJvRvr/lSwVdHQNaQ/MHuf4IiOC8UyQf7Q thjP/9g4dLA4KeB+Z3xdBG6THBA7Gud2yur89j84/djx5n1keD7b8gdnGIaJR4txuD1k BZUZsaCdJT9ajb0NBQz7fByNBI73Df1A6X8lzIdcrH1f4KqnTPYrvAeF/UyttgkVqkKH kbknvp32qmDxDOFEPhpa3VKla74UoD3jwm84Y6MuNTJUuoLkng/C3ujHgRBGxUIzbK7C Aqr7PQ+bUvhkJxwNLfXJiQz0oAGtqe8TF28F0e8iiVuQg3K2iKAXh33Dibp/0SoUXxak iSZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=T+BrHZs9OYSAzWvlC3LQrWTrKoYYtx1E1D5v8ab5nL8=; b=HaVuKj5c5KB8sgCUpL33jSkPWUQpKhm0el2WfgtBTVWUDEV78hyq8Yu65t5HwiFJ3I 9xDccIrSgCAnDfOkSMlI35m7dWWfIeI0lpeuXDSaikiij8hOvFeSTrlRNjgpV2ckQ7Du XbPZFO2TxqpKcg3ClYubaXDvCPosk4wwjmJWtd1JN8jV/Lr2wHHv9TWswENm9U2WGWPV 5qE33jinu43GHiYUw13PB7l98caY6FtOmK6gIDI6TAYmL1FaLzdltnRYMTi/+c7z5PC+ geJCoa+hC/Q/1KYxzCqQGwJjpMSd4w8ixkSUI8Te6jyR+JkAQk+2XmeFPmFLyrQDdC// ZL6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fQnQiEUH; dkim=pass header.i=@codeaurora.org header.s=default header.b=VourSqLT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w65-v6si49250546pfa.18.2018.06.05.04.58.45; Tue, 05 Jun 2018 04:59:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fQnQiEUH; dkim=pass header.i=@codeaurora.org header.s=default header.b=VourSqLT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbeFEL6P (ORCPT + 99 others); Tue, 5 Jun 2018 07:58:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39886 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbeFEL6N (ORCPT ); Tue, 5 Jun 2018 07:58:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A6F62601D9; Tue, 5 Jun 2018 11:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528199892; bh=RpQm7fubcsg1K3MyluE2rKDVVoP4yU9uzAM5K0JN9PM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fQnQiEUHXXmEiSPwkiG3Ye5CLFVgexEauVWVjZkzPrfVVDKy8p/ABGDzNJ0u8EhK2 3ZR6mqRKoDYVmD6yoLG11URgzFXrGmgPcKFKa3ThFut/KJhY19fIBwv8o0PPgTQdcr BP5IKo07cUFB2l3u6x41XTzjtRThoLg2Yl5rHxQc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 72E1E605BD; Tue, 5 Jun 2018 11:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528199889; bh=RpQm7fubcsg1K3MyluE2rKDVVoP4yU9uzAM5K0JN9PM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VourSqLT6e+OhnOXvDu+Da/55klz3JaF7C3/O87tT/YfSQNa8drZ2I2dilyb5DMeT id6QJUM9yImK6S8/oVcH/OyWnSbXE4Y36b16yYTwSV5u8/7HmM06Q6da830yRyKEit 77UipWREYHVkXjGZX8gJj32e8TSNjOoOqIlqDESs= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 05 Jun 2018 07:58:09 -0400 From: okaya@codeaurora.org To: Andy Shevchenko Cc: linux-pci@vger.kernel.org, Timur Tabi , linux-arm-msm@vger.kernel.org, linux-arm Mailing List , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Bjorn Helgaas , Christoffer Dall , "Paul E. McKenney" , Marc Zyngier , Kai-Heng Feng , Thymo van Beers , Frederic Weisbecker , Greg Kroah-Hartman , David Rientjes , Philippe Ombredanne , Kate Stewart , Juergen Gross , Tom Lendacky , Borislav Petkov , Mikulas Patocka , Petr Tesarik , Andy Lutomirski , Dou Liyang , Ram Pai , Boris Ostrovsky , "open list:DOCUMENTATION" , open list Subject: Re: [PATCH V4] PCI: move early dump functionality from x86 arch into the common code In-Reply-To: References: <1528164985-14099-1-git-send-email-okaya@codeaurora.org> Message-ID: <78bfd7951abae5cd5043c2c6f513a224@codeaurora.org> X-Sender: okaya@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-06-05 05:12, Andy Shevchenko wrote: > On Tue, Jun 5, 2018 at 5:16 AM, Sinan Kaya > wrote: >> Move early dump functionality into common code so that it is available >> for >> all archtiectures. No need to carry arch specific reads around as the >> read >> hooks are already initialized by the time pci_setup_device() is >> getting >> called during scan. >> > > Makes sense. > > Reviewed-by: Andy Shevchenko > > One style comment below, though. > > If you wait a bit, I perhaps would be able to test on x86. Sure, no rush. This is a nice to have feature with no urgency. > >> Signed-off-by: Sinan Kaya >> --- >> Documentation/admin-guide/kernel-parameters.txt | 2 +- >> arch/x86/include/asm/pci-direct.h | 4 --- >> arch/x86/kernel/setup.c | 5 --- >> arch/x86/pci/common.c | 4 --- >> arch/x86/pci/early.c | 44 >> ------------------------- >> drivers/pci/pci.c | 5 +++ >> drivers/pci/pci.h | 1 + >> drivers/pci/probe.c | 19 +++++++++++ >> 8 files changed, 26 insertions(+), 58 deletions(-) >> >> diff --git a/Documentation/admin-guide/kernel-parameters.txt >> b/Documentation/admin-guide/kernel-parameters.txt >> index e490902..e64f1d8 100644 >> --- a/Documentation/admin-guide/kernel-parameters.txt >> +++ b/Documentation/admin-guide/kernel-parameters.txt >> @@ -2995,7 +2995,7 @@ >> See also Documentation/blockdev/paride.txt. >> >> pci=option[,option...] [PCI] various PCI subsystem options: >> - earlydump [X86] dump PCI config space before the >> kernel >> + earlydump dump PCI config space before the >> kernel >> changes anything >> off [X86] don't probe for the PCI bus >> bios [X86-32] force use of PCI BIOS, don't >> access >> diff --git a/arch/x86/include/asm/pci-direct.h >> b/arch/x86/include/asm/pci-direct.h >> index e1084f7..94597a3 100644 >> --- a/arch/x86/include/asm/pci-direct.h >> +++ b/arch/x86/include/asm/pci-direct.h >> @@ -15,8 +15,4 @@ extern void write_pci_config_byte(u8 bus, u8 slot, >> u8 func, u8 offset, u8 val); >> extern void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, >> u16 val); >> >> extern int early_pci_allowed(void); >> - >> -extern unsigned int pci_early_dump_regs; >> -extern void early_dump_pci_device(u8 bus, u8 slot, u8 func); >> -extern void early_dump_pci_devices(void); >> #endif /* _ASM_X86_PCI_DIRECT_H */ >> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c >> index 2f86d88..480f250 100644 >> --- a/arch/x86/kernel/setup.c >> +++ b/arch/x86/kernel/setup.c >> @@ -991,11 +991,6 @@ void __init setup_arch(char **cmdline_p) >> setup_clear_cpu_cap(X86_FEATURE_APIC); >> } >> >> -#ifdef CONFIG_PCI >> - if (pci_early_dump_regs) >> - early_dump_pci_devices(); >> -#endif >> - >> e820__reserve_setup_data(); >> e820__finish_early_params(); >> >> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c >> index 563049c..d4ec117 100644 >> --- a/arch/x86/pci/common.c >> +++ b/arch/x86/pci/common.c >> @@ -22,7 +22,6 @@ >> unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | >> PCI_PROBE_CONF2 | >> PCI_PROBE_MMCONF; >> >> -unsigned int pci_early_dump_regs; >> static int pci_bf_sort; >> int pci_routeirq; >> int noioapicquirk; >> @@ -599,9 +598,6 @@ char *__init pcibios_setup(char *str) >> pci_probe |= PCI_BIG_ROOT_WINDOW; >> return NULL; >> #endif >> - } else if (!strcmp(str, "earlydump")) { >> - pci_early_dump_regs = 1; >> - return NULL; >> } else if (!strcmp(str, "routeirq")) { >> pci_routeirq = 1; >> return NULL; >> diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c >> index e5f753c..f5fc953 100644 >> --- a/arch/x86/pci/early.c >> +++ b/arch/x86/pci/early.c >> @@ -57,47 +57,3 @@ int early_pci_allowed(void) >> PCI_PROBE_CONF1; >> } >> >> -void early_dump_pci_device(u8 bus, u8 slot, u8 func) >> -{ >> - u32 value[256 / 4]; >> - int i; >> - >> - pr_info("pci 0000:%02x:%02x.%d config space:\n", bus, slot, >> func); >> - >> - for (i = 0; i < 256; i += 4) >> - value[i / 4] = read_pci_config(bus, slot, func, i); >> - >> - print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, >> value, 256, false); >> -} >> - >> -void early_dump_pci_devices(void) >> -{ >> - unsigned bus, slot, func; >> - >> - if (!early_pci_allowed()) >> - return; >> - >> - for (bus = 0; bus < 256; bus++) { >> - for (slot = 0; slot < 32; slot++) { >> - for (func = 0; func < 8; func++) { >> - u32 class; >> - u8 type; >> - >> - class = read_pci_config(bus, slot, >> func, >> - >> PCI_CLASS_REVISION); >> - if (class == 0xffffffff) >> - continue; >> - >> - early_dump_pci_device(bus, slot, >> func); >> - >> - if (func == 0) { >> - type = >> read_pci_config_byte(bus, slot, >> - >> func, >> - >> PCI_HEADER_TYPE); >> - if (!(type & 0x80)) >> - break; >> - } >> - } >> - } >> - } >> -} >> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c >> index 97acba7..04052dc 100644 >> --- a/drivers/pci/pci.c >> +++ b/drivers/pci/pci.c >> @@ -115,6 +115,9 @@ static bool pcie_ari_disabled; >> /* If set, the PCIe ATS capability will not be used. */ >> static bool pcie_ats_disabled; >> >> +/* If set, the PCI config space of each device is printed during >> boot. */ >> +bool pci_early_dump; >> + >> bool pci_ats_disabled(void) >> { >> return pcie_ats_disabled; >> @@ -5805,6 +5808,8 @@ static int __init pci_setup(char *str) >> pcie_ats_disabled = true; >> } else if (!strcmp(str, "noaer")) { >> pci_no_aer(); >> + } else if (!strcmp(str, "earlydump")) { >> + pci_early_dump = true; >> } else if (!strncmp(str, "realloc=", 8)) { >> pci_realloc_get_opt(str + 8); >> } else if (!strncmp(str, "realloc", 7)) { >> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h >> index c358e7a0..c33265e 100644 >> --- a/drivers/pci/pci.h >> +++ b/drivers/pci/pci.h >> @@ -7,6 +7,7 @@ >> #define PCI_VSEC_ID_INTEL_TBT 0x1234 /* Thunderbolt */ >> >> extern const unsigned char pcie_link_speed[]; >> +extern bool pci_early_dump; >> >> bool pcie_cap_has_lnkctl(const struct pci_dev *dev); >> >> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c >> index 56771f3..3678f0a 100644 >> --- a/drivers/pci/probe.c >> +++ b/drivers/pci/probe.c >> @@ -1545,6 +1545,23 @@ static int pci_intx_mask_broken(struct pci_dev >> *dev) >> return 0; >> } >> >> +static void early_dump_pci_device(struct pci_dev *pdev) >> +{ >> + u32 value[256 / 4]; >> + int i; >> + >> + if (!pci_early_dump) >> + return; >> + >> + pci_info(pdev, "config space:\n"); >> + >> + for (i = 0; i < 256; i += 4) >> + pci_read_config_dword(pdev, i, &value[i / 4]); >> + > >> + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, >> value, >> + 256, false); > > Logically better either to move value to second line, or move 256 on > the first line. > >> +} >> + >> /** >> * pci_setup_device - Fill in class and map information of a device >> * @dev: the device structure to fill >> @@ -1594,6 +1611,8 @@ int pci_setup_device(struct pci_dev *dev) >> pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class >> %#08x\n", >> dev->vendor, dev->device, dev->hdr_type, >> dev->class); >> >> + early_dump_pci_device(dev); >> + >> /* Need to have dev->class ready */ >> dev->cfg_size = pci_cfg_space_size(dev); >> >> -- >> 2.7.4 >>