Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp658988imm; Tue, 5 Jun 2018 02:13:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKeH/5S9vqXX2T0jiVM0z22rFhRy9gghHZbrYHCDlwrl2CSrI0x1XNF44cB6Q0cEvnASiiX X-Received: by 2002:a62:e903:: with SMTP id j3-v6mr25055817pfh.196.1528190004071; Tue, 05 Jun 2018 02:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528190004; cv=none; d=google.com; s=arc-20160816; b=fR+2Df8e0/0Gzem1yhIOAseGWX41cEiwhsav18cwRjNZo4tTNx+bUF0FnBRfl6uL5M ffXZ45c0H+EPyKaP187kb73PWaBxxGeTnq0dQFPNd0AqHBZKn18vYI/hE0IACTVwO1q5 d4OCG/KwZ/tGt+hJOmn2y29UVKqpkXciasibjAaYaYcdYlSeMoB+pJ7hd++uhVPij6/6 AZ4FA44sGLxf0yWI7y+FV38jCKn0rXMpZ5Mwt5J2CqL41R29CjqW6SPdLu8UAdAPb3JX 8uVx6A2e7Ez1b/B6jNnhchKk9Xv5um4btyGC+5Q4LVZMq7lPcNHXyWGgRqyMX0RetkCv V5pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=nzrGF4NTx0ZWH8OD+AOtRWzYbyApi7NVEm15TT/AW5k=; b=zQv7+tKg3CSrdGhrjSxID02X/UMF8ghWU1pCG4UGX92kpGRQjgVQTVSHQOlIpCb7z7 vnqdqN6zd9wlwD7N6vPOR4g3GbIw9Ny6RMrGZ+nJEIYk2Qz2XBvIEVUhPo5Jetfgtnyn QvL2KF8Q8zReTBK5LJjiAxhJdEPlhzjmga9zZCmT5Pge/j9QRhgJB/eq6kAMrGfOiR78 eUj31ruvimj4z+TT4MyqPdEkXakKxeyQKkd+1UWtiew9cz7Z0XgHhnkWwDR7HZBv+MGz SdHurBEbURjInlfGZoHSPBqPQAHxnr1a/EMyqZAyfXWQl9vF3kG07yqI5tpXSFPTpCi9 2ZzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIgQFUUa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3-v6si37092989pgp.95.2018.06.05.02.13.09; Tue, 05 Jun 2018 02:13:24 -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=@gmail.com header.s=20161025 header.b=vIgQFUUa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751747AbeFEJMl (ORCPT + 99 others); Tue, 5 Jun 2018 05:12:41 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:37397 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751497AbeFEJMi (ORCPT ); Tue, 5 Jun 2018 05:12:38 -0400 Received: by mail-qt0-f196.google.com with SMTP id q13-v6so1611089qtp.4; Tue, 05 Jun 2018 02:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nzrGF4NTx0ZWH8OD+AOtRWzYbyApi7NVEm15TT/AW5k=; b=vIgQFUUaUuSiaqlTjlWaokn1L29rvI8/NAj9UnGUsQk1cWQ61f7Ldxpuf3NeOJf7CC KkBDGoE7vtMjZC6rYL83DS/LM3vUKMN7YoM21nToeZiLw1Sdo9rtkEsSmykp5MiHs6Zg PYoU6qdb2mB4NzaDyAgYRdL/hKTSzX3gYQAN1lgK8LOh1tCLImW6Ng/UaH9o+GSJGv+3 3ZNIPFCF+NujMPkGv7QWLV3tCj1aRbaGolnUaAFRI0pK6uxMGR4EOSFiASoQE+Hpm6kY bjnq6erQYFEiATb9xDg5fVnX06fc8wcs0hT8tHya1gytxfmE85lkR6C91bRB6nyY0y6W KBUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nzrGF4NTx0ZWH8OD+AOtRWzYbyApi7NVEm15TT/AW5k=; b=X9yM6UFE4Qfc2nNzhAJh1+v0NdURfokmIBLkI/M5n2J8cnnqxB2Tot2vF54CWDYjDP +AdqFyJR9Ki6BPs83qJLts/W/kHGm1xq3clNMZW4lKDOgKUMS3XBOyI/jnn2Fo6KvHQw 2IbgbohHg41bQy6QIIkSqUU4d7DOze2SOBRAnytPO4/aMVbSUSm43MasnfLPNXO1s0io QQ7ZcxZFNOTZI2uqqWDw3BMRdxCHnSlHtSYZ9KquFCwaITQYYXLbNm1TsJwxo7N+hLTm LrPKjB6zp416BBgVaCur7cxJX7v29SO6U6LeqWhr3BIl6nCKvQZnL7UDXm+YJbgrg9zH 4d2A== X-Gm-Message-State: APt69E1I/5p3Gqm6yC6ZVRVusVHRPolfVi9I1EWSwxYdV2bZtNLW5GMs A4oLt4n8GBBMdHqXvd/PDNHxNZwdgj/IwrkeJXI= X-Received: by 2002:aed:3ce8:: with SMTP id e37-v6mr23965806qtf.295.1528189957748; Tue, 05 Jun 2018 02:12:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 02:12:37 -0700 (PDT) In-Reply-To: <1528164985-14099-1-git-send-email-okaya@codeaurora.org> References: <1528164985-14099-1-git-send-email-okaya@codeaurora.org> From: Andy Shevchenko Date: Tue, 5 Jun 2018 12:12:37 +0300 Message-ID: Subject: Re: [PATCH V4] PCI: move early dump functionality from x86 arch into the common code To: Sinan Kaya 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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 > -- With Best Regards, Andy Shevchenko