All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryder Lee <ryder.lee@mediatek.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <linux-mediatek@lists.infradead.org>,
	Ryder Lee <ryder.lee@mediatek.com>
Subject: [PATCH v2] PCI: mediatek: Fix wrong operator used
Date: Wed, 4 Nov 2020 07:10:11 +0800	[thread overview]
Message-ID: <21f722bb80c440b69dd350b48f86cd7d076a8adf.1604443256.git.ryder.lee@mediatek.com> (raw)

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 <ryder.lee@mediatek.com>
---
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;
-- 
2.18.0

WARNING: multiple messages have this Message-ID (diff)
From: Ryder Lee <ryder.lee@mediatek.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Ryder Lee <ryder.lee@mediatek.com>,
	linux-mediatek@lists.infradead.org
Subject: [PATCH v2] PCI: mediatek: Fix wrong operator used
Date: Wed, 4 Nov 2020 07:10:11 +0800	[thread overview]
Message-ID: <21f722bb80c440b69dd350b48f86cd7d076a8adf.1604443256.git.ryder.lee@mediatek.com> (raw)

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 <ryder.lee@mediatek.com>
---
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;
-- 
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

             reply	other threads:[~2020-11-03 23:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 23:10 Ryder Lee [this message]
2020-11-03 23:10 ` [PATCH v2] PCI: mediatek: Fix wrong operator used Ryder Lee
2020-11-04 13:10 ` Bjorn Helgaas
2020-11-04 13:10   ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21f722bb80c440b69dd350b48f86cd7d076a8adf.1604443256.git.ryder.lee@mediatek.com \
    --to=ryder.lee@mediatek.com \
    --cc=bhelgaas@google.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.