[PATCH v2] PCI: mediatek: Fix wrong operator used

Bjorn Helgaas helgaas at kernel.org
Wed Nov 4 08:10:54 EST 2020


The subject needs to say something about the user-visible problem
you're fixing, e.g., functions other than 0 aren't configured
correctly.

On Wed, Nov 04, 2020 at 07:10:11AM +0800, Ryder Lee wrote:
> SoCs like MT2701 and MT7623 use mtk_pcie_startup_port() to compute "func",
> but from the code, the result we get is incorrect.

This affects precisely "MT2701 and MT7623", not "SoCs *like* MT2701
and MT7623".  How about this:

  PCI: mediatek: Configure FC and FTS for functions other than 0

  "PCI_FUNC(port->slot << 3)" is always 0, so previously
  mtk_pcie_startup_port() only configured FC credits and FTs for
  function 0.

  Compute "func" correctly so we also configure functions other than
  0.  This affects MT2701 and MT7623.

> 	#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 at 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



More information about the Linux-mediatek mailing list