Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-05-29 Thread Greg Ungerer

Hi Sergio,

On 30/5/19 10:44 am, Greg Ungerer wrote:

On 29/5/19 6:08 pm, Sergio Paracuellos wrote:
[snip]

I have added gpio consumer stuff and reorder a bit the code to be more
similar to 4.20.

I attach the patch. I have not try it to compile it, because my normal
environment is in another
computer and I am in the middle of moving from my current house and
don't have access to it, sorry.
So, please try this and let's see what happens.


No problem, thanks for the patch.

Unfortunately always locks up on kernel boot:

   ...
   mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
   mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
   mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
   mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
   mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
   mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)

That was original linux-5.1 patched with your attached patch.

I'll try and dig down into that further today and get some
feedback on where it is failing.


The first problem I see is that the GPIO MODE register bits for
PERST_MODE are set to 00, so in "PCIe Reset" mode. If I hack in
a register update for that with:

/* Force PERST PCIe reset into GPIO mode */
*(unsigned int *)(0xbe60) |=  BIT(10);

I do that at the start of mt7621_pcie_init_ports(). With that in
place I get further:

  mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
  mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
  mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
  mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
  mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)
  mt7621-pci 1e14.pcie: PCIE0 enabled
  mt7621-pci 1e14.pcie: PCI coherence region base: 0x6000, 
mask/settings: 0xf002
  mt7621-pci 1e14.pcie: PCI host bridge to bus :00
  pci_bus :00: root bus resource [io  0x]
  pci_bus :00: root bus resource [mem 0x6000-0x6fff]
  pci_bus :00: root bus resource [bus 00-ff]
  pci :00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring

It hangs there...

Regards
Greg


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-05-29 Thread Greg Ungerer

Hi Brett,

On 30/5/19 12:44 am, Brett Neumeier wrote:

On Wed, May 29, 2019 at 3:09 AM Sergio Paracuellos mailto:sergio.paracuel...@gmail.com>> wrote:

I have added gpio consumer stuff and reorder a bit the code to be more
similar to 4.20.

I attach the patch. I have not try it to compile it, because my normal
environment is in another
computer and I am in the middle of moving from my current house and
don't have access to it, sorry.
So, please try this and let's see what happens.

I'm jumping in late here because I just recently became aware of this thread. I 
have a GnuBee PC2 on which I'm running a 5.1.4 kernel with Neil Brown's patches 
applied; I'm having an issue where approximately 2/3 of the time the kernel 
hangs from a cold boot while configuring PCIe. I'd be happy to test whatever 
patches might help disagnose or correct what's going on. (I am not an expert 
device driver engineer or anything, so I probably won't be much help in other 
ways.)

In case it is helpful -- the kernel messages logged regardless of whether or 
not the problem occurs are:

mt7621-pci 1e14.pcie: Parsing DT failed
mt7621_gpio 1e000600.gpio: registering 32 gpios
mt7621_gpio 1e000600.gpio: registering 32 gpios
mt7621_gpio 1e000600.gpio: registering 32 gpios
spi-mt7621 1e000b00.spi: sys_freq: 22500
rt2880-pinmux pinctrl: pcie is already enabled
mt7621-pci 1e14.pcie: Error applying setting, reverse things back
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: PCIE0 enabled
mt7621-pci 1e14.pcie: PCIE0 enabled
mt7621-pci 1e14.pcie: PCIE0 enabled
mt7621-pci 1e14.pcie: PCI coherence region base: 0x6000, mask/settings: 
0xf002
mt7621-pci 1e14.pcie: PCI host bridge to bus :00
pci_bus :00: root bus resource [io  0x]
pci_bus :00: root bus resource [mem 0x6000-0x6fff]
pci_bus :00: root bus resource [bus 00-ff]
pci :00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci :00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci :00:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring

at that point the boot process sometimes hangs.


FWIW, I see this occasional hang here too. Sometimes it boots through,
sometimes hangs - with unchanged code.

Difference is when I get a good boot, I never get the PCI bus
probed, and never any devices found.

Regards
Greg



When it does not hang, it proceeds with:

pci :01:00.0: 2.000 Gb/s available PCIe bandwidth, limited by 2.5 GT/s x1 
link at :00:00.0 (capable of 4.000 Gb/s with 5 GT/s x1 link)
pci :00:00.0: PCI bridge to [bus 01-ff]
pci :02:00.0: 2.000 Gb/s available PCIe bandwidth, limited by 2.5 GT/s x1 
link at :00:01.0 (capable of 4.000 Gb/s with 5 GT/s x1 link)
pci :00:01.0: PCI bridge to [bus 02-ff]
pci :03:00.0: 2.000 Gb/s available PCIe bandwidth, limited by 2.5 GT/s x1 
link at :00:02.0 (capable of 4.000 Gb/s with 5 GT/s x1 link)
pci :00:02.0: PCI bridge to [bus 03-ff]

and then does a bunch of resource assignments and things and all is well.

I'm building a new kernel with the "use perst gpio instead of builtin perst" 
patch and will report back my results. If there's anything else I can do to help, please 
let me know!

--
Brett Neumeier (bneume...@gmail.com )

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-05-29 Thread Greg Ungerer

Hi Sergio,

On 29/5/19 6:08 pm, Sergio Paracuellos wrote:
[snip]

I have added gpio consumer stuff and reorder a bit the code to be more
similar to 4.20.

I attach the patch. I have not try it to compile it, because my normal
environment is in another
computer and I am in the middle of moving from my current house and
don't have access to it, sorry.
So, please try this and let's see what happens.


No problem, thanks for the patch.

Unfortunately always locks up on kernel boot:

  ...
  mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
  mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
  mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
  mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
  mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
  mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
  mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)

That was original linux-5.1 patched with your attached patch.

I'll try and dig down into that further today and get some
feedback on where it is failing.

Regards
Greg

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/22] Some documentation fixes

2019-05-29 Thread Mauro Carvalho Chehab
Fix several warnings and broken links.

This series was generated against linux-next, but was rebased to be applied at
docs-next. It should apply cleanly on either tree.

There's a git tree with all of them applied on the top of docs/docs-next
at:

https://git.linuxtv.org/mchehab/experimental.git/log/?h=fix_doc_links_v2


Mauro Carvalho Chehab (21):
  ABI: sysfs-devices-system-cpu: point to the right docs
  isdn: mISDN: remove a bogus reference to a non-existing doc
  dt: fix broken references to nand.txt
  docs: zh_CN: get rid of basic_profiling.txt
  doc: it_IT: fix reference to magic-number.rst
  docs: mm: numaperf.rst: get rid of a build warning
  docs: bpf: get rid of two warnings
  docs: mark orphan documents as such
  docs: amd-memory-encryption.rst get rid of warnings
  gpu: amdgpu: fix broken amdgpu_dma_buf.c references
  gpu: i915.rst: Fix references to renamed files
  docs: zh_CN: avoid duplicate citation references
  docs: vm: hmm.rst: fix some warnings
  docs: it: license-rules.rst: get rid of warnings
  docs: gpio: driver.rst: fix a bad tag
  docs: soundwire: locking: fix tags for a code-block
  docs: security: trusted-encrypted.rst: fix code-block tag
  docs: security: core.rst: Fix several warnings
  docs: net: dpio-driver.rst: fix two codeblock warnings
  docs: net: sja1105.rst: fix table format
  docs: fix broken documentation links

Otto Sabart (1):
  mfd: madera: Fix bad reference to pinctrl.txt file

 .../ABI/testing/sysfs-devices-system-cpu  |  3 +-
 Documentation/accelerators/ocxl.rst   |  2 +
 Documentation/acpi/dsd/leds.txt   |  2 +-
 .../admin-guide/kernel-parameters.rst |  6 +-
 .../admin-guide/kernel-parameters.txt | 16 ++---
 Documentation/admin-guide/mm/numaperf.rst |  5 +-
 Documentation/admin-guide/ras.rst |  2 +-
 Documentation/arm/stm32/overview.rst  |  2 +
 .../arm/stm32/stm32f429-overview.rst  |  2 +
 .../arm/stm32/stm32f746-overview.rst  |  2 +
 .../arm/stm32/stm32f769-overview.rst  |  2 +
 .../arm/stm32/stm32h743-overview.rst  |  2 +
 .../arm/stm32/stm32mp157-overview.rst |  2 +
 Documentation/bpf/btf.rst |  2 +
 .../bindings/mtd/amlogic,meson-nand.txt   |  2 +-
 .../devicetree/bindings/mtd/gpmc-nand.txt |  2 +-
 .../devicetree/bindings/mtd/marvell-nand.txt  |  2 +-
 .../devicetree/bindings/mtd/tango-nand.txt|  2 +-
 .../devicetree/bindings/net/fsl-enetc.txt |  7 +-
 .../bindings/pci/amlogic,meson-pcie.txt   |  2 +-
 .../regulator/qcom,rpmh-regulator.txt |  2 +-
 .../devicetree/booting-without-of.txt |  2 +-
 Documentation/driver-api/gpio/board.rst   |  2 +-
 Documentation/driver-api/gpio/consumer.rst|  2 +-
 Documentation/driver-api/gpio/driver.rst  |  2 +-
 .../driver-api/soundwire/locking.rst  |  4 +-
 .../firmware-guide/acpi/enumeration.rst   |  2 +-
 .../firmware-guide/acpi/method-tracing.rst|  2 +-
 Documentation/gpu/amdgpu.rst  |  4 +-
 Documentation/gpu/i915.rst|  6 +-
 Documentation/gpu/msm-crash-dump.rst  |  2 +
 Documentation/i2c/instantiating-devices   |  2 +-
 Documentation/interconnect/interconnect.rst   |  2 +
 Documentation/laptops/lg-laptop.rst   |  2 +
 .../freescale/dpaa2/dpio-driver.rst   |  4 +-
 Documentation/networking/dsa/sja1105.rst  |  6 +-
 Documentation/powerpc/isa-versions.rst|  2 +
 Documentation/security/keys/core.rst  | 16 +++--
 .../security/keys/trusted-encrypted.rst   |  4 +-
 Documentation/sysctl/kernel.txt   |  4 +-
 .../translations/it_IT/process/howto.rst  |  2 +-
 .../it_IT/process/license-rules.rst   | 28 
 .../it_IT/process/magic-number.rst|  2 +-
 .../it_IT/process/stable-kernel-rules.rst |  4 +-
 .../translations/zh_CN/basic_profiling.txt| 71 ---
 .../translations/zh_CN/process/4.Coding.rst   |  2 +-
 .../zh_CN/process/management-style.rst|  4 +-
 .../zh_CN/process/programming-language.rst| 28 
 .../virtual/kvm/amd-memory-encryption.rst |  5 ++
 Documentation/virtual/kvm/vcpu-requests.rst   |  2 +
 Documentation/vm/hmm.rst  |  9 ++-
 Documentation/x86/x86_64/5level-paging.rst|  2 +-
 Documentation/x86/x86_64/boot-options.rst |  4 +-
 .../x86/x86_64/fake-numa-for-cpusets.rst  |  2 +-
 MAINTAINERS   |  6 +-
 arch/arm/Kconfig  |  2 +-
 arch/arm64/kernel/kexec_image.c   |  2 +-
 arch/powerpc/Kconfig  |  2 +-
 arch/x86/Kconfig  | 16 ++---
 arch/x86/Kconfig.debug|  2 +-
 arch/x86/boot/header.S|  2 +-
 arch/x86/entry/entry_64.S |  2 +-
 arch/x86/include/asm/bootparam_utils.h|  2 +-
 arch/x86/include/asm/page_64_types.h  |  2 +-
 

[PATCH] staging: kpc2000: replace bogus variable name in core.c

2019-05-29 Thread Simon Sandström
"struct kp2000_regs temp" has nothing to do with temperatures, so
replace it with the more proper name "regs".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 4110032d0cbb..11ac57e31d45 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -314,24 +314,24 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned 
int ioctl_num,
case KP2000_IOCTL_GET_PCIE_ERROR_REG:   return 
readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT);
 
case KP2000_IOCTL_GET_EVERYTHING: {
-   struct kp2000_regs temp;
+   struct kp2000_regs regs;
int ret;
 
-   memset(, 0, sizeof(temp));
-   temp.card_id = pcard->card_id;
-   temp.build_version = pcard->build_version;
-   temp.build_datestamp = pcard->build_datestamp;
-   temp.build_timestamp = pcard->build_timestamp;
-   temp.hw_rev = pcard->hardware_revision;
-   temp.ssid = pcard->ssid;
-   temp.ddna = pcard->ddna;
-   temp.cpld_reg = readq(pcard->sysinfo_regs_base + 
REG_CPLD_CONFIG);
-
-   ret = copy_to_user((void*)ioctl_param, (void*), 
sizeof(temp));
+   memset(, 0, sizeof(regs));
+   regs.card_id = pcard->card_id;
+   regs.build_version = pcard->build_version;
+   regs.build_datestamp = pcard->build_datestamp;
+   regs.build_timestamp = pcard->build_timestamp;
+   regs.hw_rev = pcard->hardware_revision;
+   regs.ssid = pcard->ssid;
+   regs.ddna = pcard->ddna;
+   regs.cpld_reg = readq(pcard->sysinfo_regs_base + 
REG_CPLD_CONFIG);
+
+   ret = copy_to_user((void*)ioctl_param, (void*), 
sizeof(regs));
if (ret)
return -EFAULT;
 
-   return sizeof(temp);
+   return sizeof(regs);
}
 
default:
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c

2019-05-29 Thread Dan Carpenter
On Wed, May 29, 2019 at 05:54:19PM +0200, Simon Sandström wrote:
> On Mon, May 27, 2019 at 10:31:59AM +0300, Dan Carpenter wrote:
> > On Fri, May 24, 2019 at 01:08:01PM +0200, Simon Sandström wrote:
> > > [..]
> > > - ret = copy_to_user((void*)ioctl_param, (void*), 
> > > sizeof(temp));
> > > + ret = copy_to_user((void *)ioctl_param, (void *), 
> > > sizeof(temp));
> > >   if (ret)
> > >   return -EFAULT;
> > 
> > This should really be written like so:
> > 
> > if (copy_to_user((void __user *)ioctl_param, ,
> >  sizeof(temp)))
> > return -EFAULT;
> > 
> > temp is really the wrong name.  "temp" is for temperatures.  "tmp" means
> > temporary.  But also "tmp" is wrong here because it's not a temporary
> > variable.  It's better to call it "regs" here.
> > 
> > regards,
> > dan carpenter
> > 
> 
> I agree, but I don't think it fits within this patch. I can send a
> separate patch with this change.

You could send the other chunk as a separate patch, but I don't think it
makes sense to apply this chunk when really it just needs to be
re-written.

I normally don't complain too much about mechanical no-thought patches,
but in this case the function is very sub-par and should be re-written.

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c

2019-05-29 Thread Simon Sandström
On Mon, May 27, 2019 at 10:31:59AM +0300, Dan Carpenter wrote:
> On Fri, May 24, 2019 at 01:08:01PM +0200, Simon Sandström wrote:
> > [..]
> > -   ret = copy_to_user((void*)ioctl_param, (void*), 
> > sizeof(temp));
> > +   ret = copy_to_user((void *)ioctl_param, (void *), 
> > sizeof(temp));
> > if (ret)
> > return -EFAULT;
> 
> This should really be written like so:
> 
>   if (copy_to_user((void __user *)ioctl_param, ,
>sizeof(temp)))
>   return -EFAULT;
> 
> temp is really the wrong name.  "temp" is for temperatures.  "tmp" means
> temporary.  But also "tmp" is wrong here because it's not a temporary
> variable.  It's better to call it "regs" here.
> 
> regards,
> dan carpenter
> 

I agree, but I don't think it fits within this patch. I can send a
separate patch with this change.

Thanks

- Simon
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6655: Change return type of function and remove variable

2019-05-29 Thread Nishka Dasgupta
As the function CARDbRadioPowerOff always returns true, and this value
does not appear to be used anywhere, the return variable can be entirely
removed and the function converted to type void.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/vt6655/card.c | 56 ---
 drivers/staging/vt6655/card.h |  2 +-
 2 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index 6ecbe925026d..2aca5b38be5c 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -409,42 +409,38 @@ bool CARDbSetBeaconPeriod(struct vnt_private *priv,
  *  Out:
  *  none
  *
- * Return Value: true if success; otherwise false
+ * Return Value: none
  */
-bool CARDbRadioPowerOff(struct vnt_private *priv)
+void CARDbRadioPowerOff(struct vnt_private *priv)
 {
-   bool bResult = true;
-
-   if (priv->bRadioOff)
-   return true;
-
-   switch (priv->byRFType) {
-   case RF_RFMD2959:
-   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
-  SOFTPWRCTL_TXPEINV);
-   MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL,
- SOFTPWRCTL_SWPE1);
-   break;
+   if (!priv->bRadioOff) {
+   switch (priv->byRFType) {
+   case RF_RFMD2959:
+   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
+  SOFTPWRCTL_TXPEINV);
+   MACvWordRegBitsOn(priv->PortOffset, MAC_REG_SOFTPWRCTL,
+ SOFTPWRCTL_SWPE1);
+   break;
 
-   case RF_AIROHA:
-   case RF_AL2230S:
-   case RF_AIROHA7230:
-   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
-  SOFTPWRCTL_SWPE2);
-   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
-  SOFTPWRCTL_SWPE3);
-   break;
-   }
+   case RF_AIROHA:
+   case RF_AL2230S:
+   case RF_AIROHA7230:
+   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
+  SOFTPWRCTL_SWPE2);
+   MACvWordRegBitsOff(priv->PortOffset, MAC_REG_SOFTPWRCTL,
+  SOFTPWRCTL_SWPE3);
+   break;
+   }
 
-   MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
+   MACvRegBitsOff(priv->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
 
-   BBvSetDeepSleep(priv, priv->byLocalID);
+   BBvSetDeepSleep(priv, priv->byLocalID);
 
-   priv->bRadioOff = true;
-   pr_debug("chester power off\n");
-   MACvRegBitsOn(priv->PortOffset, MAC_REG_GPIOCTL0,
- LED_ACTSET);  /* LED issue */
-   return bResult;
+   priv->bRadioOff = true;
+   pr_debug("chester power off\n");
+   MACvRegBitsOn(priv->PortOffset, MAC_REG_GPIOCTL0,
+ LED_ACTSET);  /* LED issue */
+   }
 }
 
 /*
diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h
index f422fb3c78bd..887c1692e05b 100644
--- a/drivers/staging/vt6655/card.h
+++ b/drivers/staging/vt6655/card.h
@@ -57,7 +57,7 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 
qwTSF2);
 unsigned char CARDbyGetPktType(struct vnt_private *priv);
 void CARDvSafeResetTx(struct vnt_private *priv);
 void CARDvSafeResetRx(struct vnt_private *priv);
-bool CARDbRadioPowerOff(struct vnt_private *priv);
+void CARDbRadioPowerOff(struct vnt_private *priv);
 bool CARDbRadioPowerOn(struct vnt_private *priv);
 bool CARDbSetPhyParameter(struct vnt_private *priv, u8 bb_type);
 bool CARDbUpdateTSF(struct vnt_private *priv, unsigned char byRxRate,
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: staging: allegro: cleanup two warnings

2019-05-29 Thread Mauro Carvalho Chehab
Sparse complains about two issues when building with i386
and COMPILE_TEST:

drivers/staging/media/allegro-dvt/allegro-core.c:1849:36: warning: 
constant 0xUL is so big it is unsigned long long
drivers/staging/media/allegro-dvt/allegro-core.c:865:24: error: 
incompatible types in comparison expression (different type sizes)

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/allegro-dvt/allegro-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c 
b/drivers/staging/media/allegro-dvt/allegro-core.c
index d007d1778f0e..20b38b737869 100644
--- a/drivers/staging/media/allegro-dvt/allegro-core.c
+++ b/drivers/staging/media/allegro-dvt/allegro-core.c
@@ -863,7 +863,7 @@ static ssize_t allegro_mbox_read(struct allegro_dev *dev,
 * Skip the header, as was already read to get the size of the body.
 */
body_no_wrap = min((size_t)header->length,
-  (mbox->size - (head + sizeof(*header;
+  (size_t)(mbox->size - (head + sizeof(*header;
regmap_bulk_read(dev->sram, mbox->data + head + sizeof(*header),
 dst + sizeof(*header), body_no_wrap / 4);
regmap_bulk_read(dev->sram, mbox->data,
@@ -1846,7 +1846,7 @@ static void allegro_copy_fw_codec(struct allegro_dev *dev,
 lower_32_bits(icache_offset));
 
dcache_offset =
-   (dev->firmware.paddr & 0xUL) - MCU_CACHE_OFFSET;
+   (dev->firmware.paddr & 0xULL) - MCU_CACHE_OFFSET;
v4l2_dbg(2, debug, >v4l2_dev,
 "dcache_offset: msb = 0x%x, lsb = 0x%x\n",
 upper_32_bits(dcache_offset), lower_32_bits(dcache_offset));
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8712: Remove initialisations

2019-05-29 Thread Nishka Dasgupta
Remove initialisations of multiple variables as these initial values are
never used.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/rtl871x_mp.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_mp.c 
b/drivers/staging/rtl8712/rtl871x_mp.c
index ba379506da3f..edd3da05fc06 100644
--- a/drivers/staging/rtl8712/rtl871x_mp.c
+++ b/drivers/staging/rtl8712/rtl871x_mp.c
@@ -709,20 +709,18 @@ static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, 
u32 selbit)
 
 u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
 {
-   u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+   u32 OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
+   u32 CCK_cnt  = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
+   u32 HT_cnt   = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT);
 
-   OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
-   CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
-   HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT);
return OFDM_cnt + CCK_cnt + HT_cnt;
 }
 
 u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
 {
-   u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+   u32 OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
+   u32 CCK_cnt  = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
+   u32 HT_cnt   = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT);
 
-   OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
-   CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
-   HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT);
return OFDM_cnt + CCK_cnt + HT_cnt;
 }
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8712: Remove return variable of different type

2019-05-29 Thread Nishka Dasgupta
The local return variable ret may be replaced directly by its value,
especially since its type (uint) is not the same as the function's
return type (int).
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index a7230c0c7b23..b424b8436fcf 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1577,7 +1577,7 @@ static int r8711_wx_get_enc(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *keybuf)
 {
-   uint key, ret = 0;
+   uint key;
struct _adapter *padapter = netdev_priv(dev);
struct iw_point *erq = &(wrqu->encoding);
struct  mlme_priv   *pmlmepriv = &(padapter->mlmepriv);
@@ -1633,7 +1633,7 @@ static int r8711_wx_get_enc(struct net_device *dev,
erq->flags |= IW_ENCODE_DISABLED;
break;
}
-   return ret;
+   return 0;
 }
 
 static int r8711_wx_get_power(struct net_device *dev,
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8712: Remove unnecessary variable in rtl8712_recv.c

2019-05-29 Thread Nishka Dasgupta
Remove unnecessary variable last_evm in rtl8712_recv.c and use its value
directly.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/rtl8712_recv.c | 5 ++---
 drivers/staging/rtl8712/rtl871x_cmd.c  | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
b/drivers/staging/rtl8712/rtl8712_recv.c
index 82ddc0c3ecd4..f6f7cd5fd0f2 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -885,7 +885,7 @@ static void query_rx_phy_status(struct _adapter *padapter,
 static void process_link_qual(struct _adapter *padapter,
  union recv_frame *prframe)
 {
-   u32 last_evm = 0, tmpVal;
+   u32 tmpVal;
struct rx_pkt_attrib *pattrib;
struct smooth_rssi_data *sqd = >recvpriv.signal_qual_data;
 
@@ -898,8 +898,7 @@ static void process_link_qual(struct _adapter *padapter,
 */
if (sqd->total_num++ >= PHY_LINKQUALITY_SLID_WIN_MAX) {
sqd->total_num = PHY_LINKQUALITY_SLID_WIN_MAX;
-   last_evm = sqd->elements[sqd->index];
-   sqd->total_val -= last_evm;
+   sqd->total_val -= sqd->elements[sqd->index];
}
sqd->total_val += pattrib->signal_qual;
sqd->elements[sqd->index++] = pattrib->signal_qual;
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index 05a78ac24987..7c437ee9e022 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -880,7 +880,7 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
}
r8712_indicate_connect(padapter);
} else {
-   pwlan = _r8712_alloc_network(pmlmepriv);
+   pwlan = r8712_alloc_network(pmlmepriv);
if (!pwlan) {
pwlan = r8712_get_oldest_wlan_network(
>scanned_queue);
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rts5208: Remove negations

2019-05-29 Thread Nishka Dasgupta
Previously return variable fake_para was being negated before return.
For simplification, fake_para can be changed to valid_para, which is
returned without negation (corresponding values swapped accordingly).
Further, the function names check_sd_current_prior and check_sd_speed_prior
can be changed to valid_sd_current_prior and valid_sd_speed_prior
respectively for greater clarity on the purpose of the functions.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rts5208/rtsx_chip.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_chip.c 
b/drivers/staging/rts5208/rtsx_chip.c
index 76c35f3c0208..17c4131f5f62 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -598,38 +598,38 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
return STATUS_SUCCESS;
 }
 
-static inline int check_sd_speed_prior(u32 sd_speed_prior)
+static inline int valid_sd_speed_prior(u32 sd_speed_prior)
 {
-   bool fake_para = false;
+   bool valid_para = true;
int i;
 
for (i = 0; i < 4; i++) {
u8 tmp = (u8)(sd_speed_prior >> (i * 8));
 
if ((tmp < 0x01) || (tmp > 0x04)) {
-   fake_para = true;
+   valid_para = false;
break;
}
}
 
-   return !fake_para;
+   return valid_para;
 }
 
-static inline int check_sd_current_prior(u32 sd_current_prior)
+static inline int valid_sd_current_prior(u32 sd_current_prior)
 {
-   bool fake_para = false;
+   bool valid_para = true;
int i;
 
for (i = 0; i < 4; i++) {
u8 tmp = (u8)(sd_current_prior >> (i * 8));
 
if (tmp > 0x03) {
-   fake_para = true;
+   valid_para = false;
break;
}
}
 
-   return !fake_para;
+   return valid_para;
 }
 
 static int rts5208_init(struct rtsx_chip *chip)
@@ -796,13 +796,13 @@ int rtsx_init_chip(struct rtsx_chip *chip)
chip->rw_fail_cnt[i] = 0;
}
 
-   if (!check_sd_speed_prior(chip->sd_speed_prior))
+   if (!valid_sd_speed_prior(chip->sd_speed_prior))
chip->sd_speed_prior = 0x01040203;
 
dev_dbg(rtsx_dev(chip), "sd_speed_prior = 0x%08x\n",
chip->sd_speed_prior);
 
-   if (!check_sd_current_prior(chip->sd_current_prior))
+   if (!valid_sd_current_prior(chip->sd_current_prior))
chip->sd_current_prior = 0x00010203;
 
dev_dbg(rtsx_dev(chip), "sd_current_prior = 0x%08x\n",
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: kpc2000: Change to use DIV_ROUND_UP

2019-05-29 Thread Nishka Dasgupta
Use macro DIV_ROUND_UP instead of an equivalent sequence of operations.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/kpc2000/kpc_dma/fileops.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c 
b/drivers/staging/kpc2000/kpc_dma/fileops.c
index 254fee593399..7b17362461b8 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -28,10 +28,7 @@ unsigned int  count_pages(unsigned long iov_base, size_t 
iov_len)
 static inline
 unsigned int  count_parts_for_sge(struct scatterlist *sg)
 {
-   unsigned int sg_length = sg_dma_len(sg);
-
-   sg_length += (0x8-1);
-   return (sg_length / 0x8);
+   return DIV_ROUND_UP(sg_dma_len(sg), 0x8);
 }
 
 /**  Transfer Helpers  **/
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: octeon-usb: Remove return variable

2019-05-29 Thread Nishka Dasgupta
Remove return variable result and return the value directly.
Issue found using Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/octeon-usb/octeon-hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/octeon-usb/octeon-hcd.c 
b/drivers/staging/octeon-usb/octeon-hcd.c
index aeec16314e0d..cd2b777073c4 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -521,8 +521,7 @@ static void octeon_unmap_urb_for_dma(struct usb_hcd *hcd, 
struct urb *urb)
  */
 static inline u32 cvmx_usb_read_csr32(struct octeon_hcd *usb, u64 address)
 {
-   u32 result = cvmx_read64_uint32(address ^ 4);
-   return result;
+   return cvmx_read64_uint32(address ^ 4);
 }
 
 /**
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-05-29 Thread Sergio Paracuellos
Hi Greg,

On Wed, May 29, 2019 at 9:11 AM Greg Ungerer  wrote:
>
> Hi Sergio,
>
> On 27/5/19 6:02 pm, Sergio Paracuellos wrote:
> > On Mon, May 27, 2019 at 9:29 AM Greg Ungerer  wrote:
> >> On 27/5/19 4:35 pm, Sergio Paracuellos wrote:
> >>> On Mon, May 27, 2019 at 6:37 AM Greg Ungerer  wrote:
>  On 24/5/19 3:35 pm, Sergio Paracuellos wrote:
> > On Fri, May 24, 2019 at 2:35 AM Greg Ungerer  wrote:
> >> On 23/5/19 3:26 pm, Sergio Paracuellos wrote:
> >>> On Thu, May 23, 2019 at 4:11 AM Greg Ungerer  wrote:
>  On 22/5/19 4:27 pm, Sergio Paracuellos wrote:
>  [snip]
> > There are some big changes between 4.20 and 5.x. One is the use of 
> > PERST_N
> > instead of using gpio. This PERT_N stuff is used now on enable ports
> > assuming the
> > link of PCI is properly detected after enabling the phy. And it 
> > seems
> > it is not according to
> > your dmesg traces. The previous 4.20 code used gpio before this was 
> > done.
> >
> > This code is the one I am referring:
> >
> > /* Use GPIO control instead of PERST_N */
> > *(unsigned int *)(0xbe000620) |= BIT(19) | BIT(8) | BIT(7); // set 
> > DATA
> > mdelay(1000);
> 
>  I have been looking closely at those, wondering why the old code
>  drove that PERST line as a GPIO instead of using the built-in 
>  behavior.
>  (I have ignored bits 7 and 8 here since they are control of UART 3)
> >>>
> >>> Yes, this was also at first one of my big concerns so I tried to 
> >>> change into
> >>> to use builtin behaviour (which is much more cleaner) and when the
> >>> code was tested
> >>> it worked. It seems it is not valid for every board.
> >>>
> 
> 
> > I assume reset lines on your device tree are properly set up which 
> > is
> > other of the big changes here: use
> > reset lines instead of that hardcoding stuff. Also, the
> > mt7621_reset_port routine is also using msleep(100)
> > but maybe you can try a bigger value and change it into a mdelay, to
> > see if that changes anything.
> 
>  I see the reset line configuration in the pcie section of 
>  mt7621.dtsi,
>  is there any others absolutely required here?  I couldn't see the
>  gbpc1.dts devicetree do anything else with pcie - othe than enable 
>  it.
>  My device tree for the EX15 is similar in that regard.
> 
>  I tried a couple of things with interesting results.
> 
>  1. I made sure that the PERST_N line is set for PCIe operation (not 
>  GPIO).
>  I forced it with:
> 
>  *(unsigned int *)(0xbe60) &= ~(0x3 << 10);
> 
>  I checked bits 10 and 11 at kernel PCI init and they were 00 
>  anyway.
>  So PERST_N was definitely in PCIe reset mode. No change in 
>  behavior,
> 
> 
>  2. I forced a GPIO style reset of that PERST line (using GPIO19) and 
>  got
>  the following result on kernel boot:
> 
>   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
>   mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
>   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
>   mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & 
>  CLK)
>   mt7621-pci 1e14.pcie: Initiating port 1 failed
>   mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
>   mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
>   mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & 
>  CLK)
>   mt7621-pci 1e14.pcie: Initiating port 2 failed
>   mt7621-pci 1e14.pcie: de-assert port 0 PERST_N
> >>>
> >>> This line seems to be the problem. When ports are init, (and with your
> >>> changes seems the are
> >>> init properly), the ports with pcie link are stored into a list to be
> >>> enabled afterwards. This code is
> >>> located into 'mt7621_pcie_enable_ports' which call simple
> >>> 'mt7621_pcie_enable_port' to enable each port
> >>> on the list. In this process it uses the PERS_N built-in register
> >>> deasserting and asserting it. If enabling fails
> >>> (and this is ypour case now) the port is removed from the list and it
> >>> is not properly set up. You should try to
> >>> comment this code:
> >>>
> >>> /* assert port PERST_N */
> >>> val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
> >>> val |= PCIE_PORT_PERST(slot);
> >>> pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);
> >>>
> >>> /* de-assert port PERST_N */
> >>> val = pcie_read(pcie, 

Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-05-29 Thread Greg Ungerer

Hi Sergio,

On 27/5/19 6:02 pm, Sergio Paracuellos wrote:

On Mon, May 27, 2019 at 9:29 AM Greg Ungerer  wrote:

On 27/5/19 4:35 pm, Sergio Paracuellos wrote:

On Mon, May 27, 2019 at 6:37 AM Greg Ungerer  wrote:

On 24/5/19 3:35 pm, Sergio Paracuellos wrote:

On Fri, May 24, 2019 at 2:35 AM Greg Ungerer  wrote:

On 23/5/19 3:26 pm, Sergio Paracuellos wrote:

On Thu, May 23, 2019 at 4:11 AM Greg Ungerer  wrote:

On 22/5/19 4:27 pm, Sergio Paracuellos wrote:
[snip]

There are some big changes between 4.20 and 5.x. One is the use of PERST_N
instead of using gpio. This PERT_N stuff is used now on enable ports
assuming the
link of PCI is properly detected after enabling the phy. And it seems
it is not according to
your dmesg traces. The previous 4.20 code used gpio before this was done.

This code is the one I am referring:

/* Use GPIO control instead of PERST_N */
*(unsigned int *)(0xbe000620) |= BIT(19) | BIT(8) | BIT(7); // set DATA
mdelay(1000);


I have been looking closely at those, wondering why the old code
drove that PERST line as a GPIO instead of using the built-in behavior.
(I have ignored bits 7 and 8 here since they are control of UART 3)


Yes, this was also at first one of my big concerns so I tried to change into
to use builtin behaviour (which is much more cleaner) and when the
code was tested
it worked. It seems it is not valid for every board.





I assume reset lines on your device tree are properly set up which is
other of the big changes here: use
reset lines instead of that hardcoding stuff. Also, the
mt7621_reset_port routine is also using msleep(100)
but maybe you can try a bigger value and change it into a mdelay, to
see if that changes anything.


I see the reset line configuration in the pcie section of mt7621.dtsi,
is there any others absolutely required here?  I couldn't see the
gbpc1.dts devicetree do anything else with pcie - othe than enable it.
My device tree for the EX15 is similar in that regard.

I tried a couple of things with interesting results.

1. I made sure that the PERST_N line is set for PCIe operation (not GPIO).
I forced it with:

*(unsigned int *)(0xbe60) &= ~(0x3 << 10);

I checked bits 10 and 11 at kernel PCI init and they were 00 anyway.
So PERST_N was definitely in PCIe reset mode. No change in behavior,


2. I forced a GPIO style reset of that PERST line (using GPIO19) and got
the following result on kernel boot:

 mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
 mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
 mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
 mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
 mt7621-pci 1e14.pcie: Initiating port 1 failed
 mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
 mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
 mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)
 mt7621-pci 1e14.pcie: Initiating port 2 failed
 mt7621-pci 1e14.pcie: de-assert port 0 PERST_N


This line seems to be the problem. When ports are init, (and with your
changes seems the are
init properly), the ports with pcie link are stored into a list to be
enabled afterwards. This code is
located into 'mt7621_pcie_enable_ports' which call simple
'mt7621_pcie_enable_port' to enable each port
on the list. In this process it uses the PERS_N built-in register
deasserting and asserting it. If enabling fails
(and this is ypour case now) the port is removed from the list and it
is not properly set up. You should try to
comment this code:

/* assert port PERST_N */
val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
val |= PCIE_PORT_PERST(slot);
pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);

/* de-assert port PERST_N */
val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
val &= ~PCIE_PORT_PERST(slot);
pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);

/* 100ms timeout value should be enough for Gen1 training */
err = readl_poll_timeout(port->base + RALINK_PCI_STATUS,
val, !!(val & PCIE_PORT_LINKUP),
20, 100 * USEC_PER_MSEC);
if (err)
return -ETIMEDOUT;

because on enabling, it seems it is getting ETIMEOUT and hence the
message '  mt7621-pci 1e14.pcie: de-assert port 0 PERST_N'.
Commenting
this code should end up into a properly configured pci?


No, unfortunately it doesn't. It does show PCIE0 enabled now though:


That is a surprise :(



mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 1 failed
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 2 failed
mt7621-pci 1e14.pcie: PCIE0 enabled
mt7621-pci 1e14.pcie: PCI coherence