From patchwork Fri Apr 7 00:16:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 747998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vzgCX4148z9s8P for ; Fri, 7 Apr 2017 10:18:16 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vzgCX2KsvzDqL0 for ; Fri, 7 Apr 2017 10:18:16 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vzgBr2xpXzDqJ0 for ; Fri, 7 Apr 2017 10:17:40 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v370Db1m120983 for ; Thu, 6 Apr 2017 20:17:29 -0400 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0a-001b2d01.pphosted.com with ESMTP id 29nx4j488x-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 06 Apr 2017 20:17:28 -0400 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Apr 2017 10:17:26 +1000 Received: from d23relay07.au.ibm.com (202.81.31.226) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 7 Apr 2017 10:17:23 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v370HFPZ45088870 for ; Fri, 7 Apr 2017 10:17:23 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v370GlbB017042 for ; Fri, 7 Apr 2017 10:16:47 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v370Gk6I016922; Fri, 7 Apr 2017 10:16:47 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 56E40A0278; Fri, 7 Apr 2017 10:16:26 +1000 (AEST) Received: from gwshan.ozlabs.ibm.com (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 4B0A1E3AC4; Fri, 7 Apr 2017 10:16:26 +1000 (AEST) Received: by gwshan.ozlabs.ibm.com (Postfix, from userid 1000) id 416CAAC235E; Fri, 7 Apr 2017 10:16:26 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 7 Apr 2017 10:16:18 +1000 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491524180-12644-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1491524180-12644-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17040700-0048-0000-0000-0000021B18BE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040700-0049-0000-0000-000047C76362 Message-Id: <1491524180-12644-3-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-06_20:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704070001 Subject: [Skiboot] [PATCH 2/4] hw/phb3: Use cached vendor/device IDs in phb3_check_device_quirks() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This uses the cached vendor/device IDs in phb3_check_device_quirks(). Also, to give the code and comment a cleaup. No logical changes are introduced. Signed-off-by: Gavin Shan Acked-by: Benjamin Herrenschmidt --- hw/phb3.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/hw/phb3.c b/hw/phb3.c index 9bc9d78..64724b9 100644 --- a/hw/phb3.c +++ b/hw/phb3.c @@ -589,39 +589,40 @@ static void phb3_endpoint_init(struct phb *phb, static void phb3_check_device_quirks(struct phb *phb, struct pci_device *dev) { struct phb3 *p = phb_to_phb3(phb); - u32 vdid; - u16 vendor, device; if (dev->primary_bus != 0 && dev->primary_bus != 1) return; - pci_cfg_read32(phb, dev->bdfn, 0, &vdid); - vendor = vdid & 0xffff; - device = vdid >> 16; - if (dev->primary_bus == 1) { u64 modectl; - /* For these adapters, if they are directly under the PHB, we - * adjust some settings for performances + /* + * For these adapters, if they are directly under the PHB, we + * adjust the disable_wr_scope_group bit for performances + * + * 15b3:1003 Mellanox Travis3-EN (CX3) + * 15b3:1011 Mellanox HydePark (ConnectIB) + * 15b3:1013 Mellanox GlacierPark (CX4) */ xscom_read(p->chip_id, p->pe_xscom + 0x0b, &modectl); - if (vendor == 0x15b3 && /* Mellanox */ - (device == 0x1003 || /* Travis3-EN (CX3) */ - device == 0x1011 || /* HydePark (ConnectIB) */ - device == 0x1013)) { /* GlacierPark (CX4) */ - /* Set disable_wr_scope_group bit */ + if (PCI_VENDOR_ID(dev->vdid) == 0x15b3 && + (PCI_DEVICE_ID(dev->vdid) == 0x1003 || + PCI_DEVICE_ID(dev->vdid) == 0x1011 || + PCI_DEVICE_ID(dev->vdid) == 0x1013)) modectl |= PPC_BIT(14); - } else { - /* Clear disable_wr_scope_group bit */ + else modectl &= ~PPC_BIT(14); - } - xscom_write(p->chip_id, p->pe_xscom + 0x0b, modectl); } else if (dev->primary_bus == 0) { - if (vendor == 0x1014 && /* IBM */ - device == 0x03dc) { /* P8/P8E/P8NVL Root port */ + /* + * Emulate the prefetchable window of the root port + * when the corresponding HW registers are readonly. + * + * 1014:03dc Root port on P8/P8E/P8NVL + */ + if (PCI_VENDOR_ID(dev->vdid) == 0x1014 && + PCI_DEVICE_ID(dev->vdid) == 0x03dc) { uint32_t pref_hi, tmp; pci_cfg_read32(phb, dev->bdfn,