Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2956966pxa; Tue, 18 Aug 2020 02:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLotuzv20NhMcMBO1Gfe+7UJV9baVxEeiN2MumTj8FP5rP3wWecgyTiCSz4cMTn9g6M1nE X-Received: by 2002:aa7:d84d:: with SMTP id f13mr18389848eds.155.1597743372057; Tue, 18 Aug 2020 02:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597743372; cv=none; d=google.com; s=arc-20160816; b=zrwnUoyyELWEA1edvk74RdHCZIzIYaE3X7IiJpjHLReuSq3nD/lETQTLZb1kQeEyMu clUBAx83YeO/TqI+37SstlHvDW8y+iPeeB1BY2sa6IsGi5cLNL7ZbxFqvK1EjnNmEUsX Jl6+lpx7vbZPOZnReVK9cezT5eEcj+u/5+z+YCnCBamOEH24AwJMboek+aLvmam0n6bp pyV7trCJKiMnyTIfTfrGU00xQrAkydmRM0XrtjsPFonbW2bXP7quZGF1sjXrdU1VilPx hbL0WVA/HtPkMFfnDH7HMqxJ9Q2OZjYFz/zDTpVacwIkwOWQEVAu4Fmw08praq9PijNN O85A== 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; bh=lQEnr1E0FkYfl8/opBzZg7zC3NnQ2+xbg56m7aN3EfQ=; b=gFt2V1lrkbz9rIVJsxPqWtmS5iv+A4sKSl4ifRrZcVPdvYufDewYG0BVtCooxecki8 IxYUvsn1mOxWa7+/K75MKOmGbxGCQuNHi9J5a5aQJsW2s+NloSseMZFEwm94NHILKfAz tA0q0sxPQvqa+fjp9iH2iT/3MmII1cLvfnCtM3IU+aMM+sgbWhuPxz5HOOrfSvOFJptk /2rxeoQmTMmzgBdEndqONbRC9C5GLn8xWGMnwL6dWTpiva+igCtB5eSm+zQ3xWWSpGyW JhuKy/kZIN+/HQh2CzyEyEnnATqsdLKmfeIWDW1Je4YrwSjlKwqThIrsd86D/hJ4pEb0 KROA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si12856611edw.437.2020.08.18.02.35.48; Tue, 18 Aug 2020 02:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbgHRJfL (ORCPT + 99 others); Tue, 18 Aug 2020 05:35:11 -0400 Received: from inva020.nxp.com ([92.121.34.13]:33990 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726145AbgHRJfK (ORCPT ); Tue, 18 Aug 2020 05:35:10 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D58391A019F; Tue, 18 Aug 2020 11:35:08 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 1F2241A1994; Tue, 18 Aug 2020 11:35:05 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 07553402AD; Tue, 18 Aug 2020 11:34:59 +0200 (CEST) From: Zhiqiang Hou To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, bhelgaas@google.com, amurray@thegoodpenguin.co.uk, jingoohan1@gmail.com, gustavo.pimentel@synopsys.com Cc: Hou Zhiqiang Subject: [PATCHv2] PCI: designware-ep: Fix the Header Type check Date: Tue, 18 Aug 2020 17:27:46 +0800 Message-Id: <20200818092746.24366-1-Zhiqiang.Hou@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hou Zhiqiang The current check will result in the multiple function device fails to initialize. So fix the check by masking out the multiple function bit. Fixes: 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set to correct mode") Signed-off-by: Hou Zhiqiang --- V2: - Add marco PCI_HEADER_TYPE_MASK and print the masked value. drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++- include/uapi/linux/pci_regs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 4680a51c49c0..0634bd3a0b96 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -653,7 +653,8 @@ int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep) u32 reg; int i; - hdr_type = dw_pcie_readb_dbi(pci, PCI_HEADER_TYPE); + hdr_type = dw_pcie_readb_dbi(pci, PCI_HEADER_TYPE) & + PCI_HEADER_TYPE_MASK; if (hdr_type != PCI_HEADER_TYPE_NORMAL) { dev_err(pci->dev, "PCIe controller is not set to EP mode (hdr_type:0x%x)!\n", diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f9701410d3b5..57a222014cd2 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -76,6 +76,7 @@ #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ #define PCI_LATENCY_TIMER 0x0d /* 8 bits */ #define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_MASK 0x7f #define PCI_HEADER_TYPE_NORMAL 0 #define PCI_HEADER_TYPE_BRIDGE 1 #define PCI_HEADER_TYPE_CARDBUS 2 -- 2.17.1