Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp762321imu; Wed, 23 Jan 2019 05:20:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN70ESIbDmelBFyusrLOP1UtkugtFmYhvnZINAU0YfA+RblM+RLnGNkqH/KgNot58CgmDbXz X-Received: by 2002:a17:902:7d90:: with SMTP id a16mr2109339plm.249.1548249606501; Wed, 23 Jan 2019 05:20:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548249606; cv=none; d=google.com; s=arc-20160816; b=Wk6kh2YZM4eKy7eHC8GQOqF045PHxVy79TIaG62Yo8p/K6n9PjerELLlU2bKbbT9Uv wLhpBvI9zYNpkL87U2cO23biTsvFesVk511dSp2vKkYqTJxA5UaMax2kurtmWQEu9c1l KMpL/xNq64YTLdNJ0NajM6xxFnghBYskGgwfom6Ewa6dvNofHYGOhn7O25QOQ1/Nz2Kt Gjk+O4wJiTYyI9fc7DFYuBKRe86vzYR/jIJ4KB4CtuktYxOrVBYYib+9t7wFk/4O+BAk 1/T/x6KnrwTVph7D7fIwHPdpBU++UmieZ8NLDSXGv9C9GvcWOYSCk2qzk7Z6QPQx8e7s 3a6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=yeQZUst3szUtse1rNYD2HazCWJM4cvJaQarIDmvvznI=; b=rXfxTSCp+ckNcD1neXvKRtZ4wTaUbWhpqrgIC2jU738uO/i5P51sOfBian+tX7pVp4 ZAcblv4n8ZntEx4UjZ0CAPOV6/vKnSwk9iFOBEVOUsB6L8nXCUAS/X77C6toYaQSaLC5 tg/WDcgHVnn7u2mi44rX1s+eWWTRfiF3FS7XkN03a0m9LKLyG61b+9Dem0qz5mLTprmm pp8Vhmbg0BZk2ql77EPUq1FRwdVWWd6x7ZMlv3u58yojEW/e+K2X55PXeOUzK0rY/32N 4R4e/oyPMSuYTG2Bj5m8HCrQT2rj3dhTTMYDeYC9I1u2ioKOYYo3Nm6gPYfYFQOr5yGB p1HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YSImpivu; 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 d142si18200566pfd.93.2019.01.23.05.19.51; Wed, 23 Jan 2019 05:20:06 -0800 (PST) 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=YSImpivu; 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 S1726321AbfAWNSf (ORCPT + 99 others); Wed, 23 Jan 2019 08:18:35 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42871 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbfAWNSf (ORCPT ); Wed, 23 Jan 2019 08:18:35 -0500 Received: by mail-pf1-f196.google.com with SMTP id 64so1172263pfr.9; Wed, 23 Jan 2019 05:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=yeQZUst3szUtse1rNYD2HazCWJM4cvJaQarIDmvvznI=; b=YSImpivuAaM/+DsgeLKyDRWYoeqPbSwffNXc/wFkdvxOjBtd2gxJVwxvzaFcix2pKe FghV7Di/C+6KWf2pnNMjkIlAcTupNsmPmtylXZCnwD7s2qLlLlr1xnxCFRRiukJrZCjd siSEHEkbcGoI/RJ4oLP3dyPSZgVjhOKEM9cOc4luwyHiOnEf+3/8xqOGESbhUY+1BplW 1lLJCn3iBwQFbe3X8AYLhnpOz54jH2X+EDQ78nM/U8ZO5e82RyEr7wRadRiKwG+zpBe6 kDkVtT3s4O8BeiICT39HzoHCijWljPruMc+5/7If4K3b+Gvl2y15q5+lirezEPUjrDTZ ek0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yeQZUst3szUtse1rNYD2HazCWJM4cvJaQarIDmvvznI=; b=R9kIdS6IbLH4HN7FcL/MskGkugG7oCA0+cFOrUl4Sp5grYHcmEEFoqBb1CYUOEUlcb QdEXk4eicOz6cBZjancKlYuPQVWzBIqFS7OZFV9+4aiPvXDRXGmHlW+C9TKJULkO2CuC SD7fqMgVdudAAA9L1pLR572oRmB+QfZRqoPJBE3XgcpD7sjvQpE5yWL8zhxWeBOmPdLl ShfZWwkgSNocFfnEmeRAmwPOB5HG51uEemjIxIWI5uuVLRPLjj300bLgNFqbzJ11iY25 VtWRHxLFX7fT7KODBCxOqcW5Fg3D5HE6T4+sNizUEftEE3T6S7sNj3oegJs12i76LMnj mh9A== X-Gm-Message-State: AJcUukdeUaOnEXP/QkocABqAS4ZeE/cnphWRJemRT/chnRuClq+Zg4yc tUZPl4OpBw8hftREdgp2iJ4lLQ2Q X-Received: by 2002:a63:9e58:: with SMTP id r24mr2005711pgo.264.1548249514168; Wed, 23 Jan 2019 05:18:34 -0800 (PST) Received: from hyd1358.caveonetworks.com. ([115.113.156.2]) by smtp.googlemail.com with ESMTPSA id r187sm64600381pfc.63.2019.01.23.05.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 05:18:33 -0800 (PST) From: sundeep.lkml@gmail.com To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: sean.stalley@intel.com, sgoutham@marvell.com, helgaas@kernel.org, Subbaraya Sundeep Subject: [v3 PATCH 1/2] PCI: read fixed bus numbers in EA for type 1 functions Date: Wed, 23 Jan 2019 18:48:00 +0530 Message-Id: <1548249481-24645-1-git-send-email-sundeep.lkml@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Subbaraya Sundeep As per the spec - ECN_Enhanced_Allocation_23_Oct_2014_Final and section 6.9.1.2, EA capability contains fixed secondary and subordinate bus numbers for type 1 functions. This patch adds support to read the fixed bus numbers from EA capability for bridge. Signed-off-by: Subbaraya Sundeep --- v3: As per Bjorn's suggestion placed EA stuff in pci_ea_init and captured bus numbers in pci_dev v2: None just added Sean drivers/pci/pci.c | 10 ++++++++-- include/linux/pci.h | 4 ++++ include/uapi/linux/pci_regs.h | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c25acac..484b63e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2909,6 +2909,7 @@ void pci_ea_init(struct pci_dev *dev) u8 num_ent; int offset; int i; + u32 dw; /* find PCI EA capability in list */ ea = pci_find_capability(dev, PCI_CAP_ID_EA); @@ -2922,9 +2923,14 @@ void pci_ea_init(struct pci_dev *dev) offset = ea + PCI_EA_FIRST_ENT; - /* Skip DWORD 2 for type 1 functions */ - if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) + /* Note fixed bus numbers for type 1 functions */ + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { + pci_read_config_dword(dev, offset, &dw); + dev->fixed_sec_busnr = dw & PCI_EA_FIXED_SEC_BUS; + dev->fixed_sub_busnr = (dw & PCI_EA_FIXED_SUB_BUS) >> + PCI_EA_FIXED_SUB_SHIFT; offset += 4; + } /* parse each EA entry */ for (i = 0; i < num_ent; ++i) diff --git a/include/linux/pci.h b/include/linux/pci.h index 65f1d8c..3e9a3ae 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -459,6 +459,10 @@ struct pci_dev { char *driver_override; /* Driver name to force a match */ unsigned long priv_flags; /* Private flags for the PCI driver */ + + /* bus numbers from EA capability if this device is a bridge */ + u8 fixed_sec_busnr; /* Fixed Secondary Bus number */ + u8 fixed_sub_busnr; /* Fixed Subordinate Bus number */ }; static inline struct pci_dev *pci_physfn(struct pci_dev *dev) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index e1e9888..51e9ac0 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -372,6 +372,10 @@ #define PCI_EA_FIRST_ENT_BRIDGE 8 /* First EA Entry for Bridges */ #define PCI_EA_ES 0x00000007 /* Entry Size */ #define PCI_EA_BEI 0x000000f0 /* BAR Equivalent Indicator */ +/* Fixed Secondary and Subordinate bus numbers in EA for Bridge */ +#define PCI_EA_FIXED_SEC_BUS 0xff +#define PCI_EA_FIXED_SUB_BUS 0xff00 +#define PCI_EA_FIXED_SUB_SHIFT 8 /* 0-5 map to BARs 0-5 respectively */ #define PCI_EA_BEI_BAR0 0 #define PCI_EA_BEI_BAR5 5 -- 1.8.3.1