From patchwork Tue Nov 3 23:10:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11879231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDFCE1752 for ; Tue, 3 Nov 2020 23:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FC57238E6 for ; Tue, 3 Nov 2020 23:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="efIp3+vk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729490AbgKCXKV (ORCPT ); Tue, 3 Nov 2020 18:10:21 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:59143 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728415AbgKCXKU (ORCPT ); Tue, 3 Nov 2020 18:10:20 -0500 X-UUID: b397e3c3c9864c158a4c3f24dda5955c-20201104 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=YSxMnqGbz4l5hYXgU6bg34RyZNddCK+MyndOJMEH3FI=; b=efIp3+vk3ddB1R7qmjqQGRrpGJotehsk3rS4qhA3YgC0bfwKxyGdZO3bxtqzzxOUaWTntdRTy6qVY6TiWpv3zJMRyGJBsW9AAE7rFLc7zfcP8LptwgTwqdLlyHihJG9clqgPoBP/FEwF/N30MFOtzsnh92zYgFzgKy1tDQ6Nz5w=; X-UUID: b397e3c3c9864c158a4c3f24dda5955c-20201104 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 723300426; Wed, 04 Nov 2020 07:10:15 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 4 Nov 2020 07:10:13 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 4 Nov 2020 07:10:13 +0800 From: Ryder Lee To: Bjorn Helgaas CC: , , Ryder Lee Subject: [PATCH v2] PCI: mediatek: Fix wrong operator used Date: Wed, 4 Nov 2020 07:10:11 +0800 Message-ID: <21f722bb80c440b69dd350b48f86cd7d076a8adf.1604443256.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org SoCs like MT2701 and MT7623 use mtk_pcie_startup_port() to compute "func", but from the code, the result we get is incorrect. #define PCI_FUNC(devfn) ((devfn) & 0x07) func = PCI_FUNC(port->slot << 3) The "func" is always 0, which results in other functions may not have been configured correctly. (i.e. FC credits and FTS) Addresses-Coverity-ID: 1437218 ("Wrong operator used") Signed-off-by: Ryder Lee --- V2 - revise commit log --- drivers/pci/controller/pcie-mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index cf4c18f0c25a..1980b01cee35 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -760,7 +760,7 @@ static struct pci_ops mtk_pcie_ops = { static int mtk_pcie_startup_port(struct mtk_pcie_port *port) { struct mtk_pcie *pcie = port->pcie; - u32 func = PCI_FUNC(port->slot << 3); + u32 func = PCI_FUNC(port->slot); u32 slot = PCI_SLOT(port->slot << 3); u32 val; int err;