Skip to content

Conversation

@commodo
Copy link
Contributor

@commodo commodo commented Sep 4, 2019

The gmii2rgmii driver had a bug when the PHY driver would have a private field/data.
This was fixed via net: gmii2rgmii: do not attach if phy has a priv field , but that only helped to avoid the memory corruption.

Xilinx fixed the issue by adding a priv field to struct mdio_device.
Not sure if that's the best fix, but since Xilinx is our upstream, we will get it anyway at some point in time.

We need this to make the ADIN dual-phy board to work with the GMII2RGMII converter.
The gmii2rgmii driver overrides the read_status hook of the PHY driver, because it also needs to update link status to the gmii2rgmii HDL converter.

Signed-off-by: Alexandru Ardelean alexandru.ardelean@analog.com

@commodo commodo requested review from a team and AndreiGrozav September 4, 2019 10:48
commodo added a commit that referenced this pull request Sep 4, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
commodo added a commit that referenced this pull request Sep 4, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Copy link
Contributor

@stefpopa stefpopa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@commodo commodo merged commit 4330036 into master Sep 4, 2019
@commodo commodo deleted the gmii2rgmii-backports branch September 4, 2019 13:13
commodo added a commit that referenced this pull request Sep 4, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
scuciurean pushed a commit that referenced this pull request Sep 4, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
harini-katakam and others added 3 commits September 4, 2019 16:24
Add a priv pointer to mdio structure to be used by mdio devices if
required.

This priv field will be used by gmii2rgmii driver. As this IP has
no capability to read status on the MDIO bus, the driver currently
snoops the same and needs the instance information is some private
field. Since phy device "priv" can be used by external phy drivers,
it is not appropriate. Hence this addition to mdio device. This is
a temporary solution before the IP can be improved. The need for
this priv field can be re-evaluated later based on other mdio devices.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
(cherry picked from commit 81f7424)
This driver has a ugly mechanism of attaching it's own private data to the
PHY to which it attaches itself to (for conversion).

This is in essence data corruption, as the other PHY tries to access it's
own private/extra state, and finds weird values, and likely does also some
out-of-bounds access.

This problem does not exist if the PHY has not private data.
But some PHYs do have private data (for keeping PHY stats, or other
internal information), and that data becomes invalid/corrupt.

Unfortunately, there is no clean way to fix this, because there is no
information about the length of the private data.
The only sane thing to do at this point, is to error out the driver and
print a message. This will at least notify the user that it is impossible
to use this PHY converter driver with such PHYs (that have a priv field).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
(cherry picked from commit b145197)
Use the priv field in mdio device structure instead of the one in
phy device structure. The phy device priv field may be used by the
external phy driver and should not be overwritten. Also remove the
check for phy priv field as it is no longer used.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
(cherry picked from commit a233487)
commodo added a commit that referenced this pull request Sep 5, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Sep 5, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Sep 5, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Sep 5, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Oct 2, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Nov 21, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
commodo added a commit that referenced this pull request Nov 22, 2019
This change adds the example device-tree for the dual ADIN1300 reference
board.

On the ZC706, the PHYs need to be configured in RGMII-ID to work.

The reference design has a GMII2RGMII converter, which sits in-between the
PHY & MAC. This converter IP/HDL needs the `gmii2rgmii` driver to be
instantiated to do the work.

In order to properly work (with the ADIN PHY), this PR is also required:
  #556
The PR fixes some memory corruption caused by the `gmii2rgmii` when
operating with the ADIN PHY driver.

A common `adi-adin1300-dual.dtsi` has been split to be re-used in order
boards (like ZedBoard or ZC702) should the need arise to support them.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
(cherry picked from commit 3c3cc1f)
github-actions bot pushed a commit that referenced this pull request Jul 31, 2025
Add JIT support for the load_acquire and store_release instructions. The
implementation is similar to the kernel where:

        load_acquire  => plain load -> lwsync
        store_release => lwsync -> plain store

To test the correctness of the implementation, following selftests were
run:

  [fedora@linux-kernel bpf]$ sudo ./test_progs -a \
  verifier_load_acquire,verifier_store_release,atomics
  #11/1    atomics/add:OK
  #11/2    atomics/sub:OK
  #11/3    atomics/and:OK
  #11/4    atomics/or:OK
  #11/5    atomics/xor:OK
  #11/6    atomics/cmpxchg:OK
  #11/7    atomics/xchg:OK
  #11      atomics:OK
  #519/1   verifier_load_acquire/load-acquire, 8-bit:OK
  #519/2   verifier_load_acquire/load-acquire, 8-bit @unpriv:OK
  #519/3   verifier_load_acquire/load-acquire, 16-bit:OK
  #519/4   verifier_load_acquire/load-acquire, 16-bit @unpriv:OK
  #519/5   verifier_load_acquire/load-acquire, 32-bit:OK
  #519/6   verifier_load_acquire/load-acquire, 32-bit @unpriv:OK
  #519/7   verifier_load_acquire/load-acquire, 64-bit:OK
  #519/8   verifier_load_acquire/load-acquire, 64-bit @unpriv:OK
  #519/9   verifier_load_acquire/load-acquire with uninitialized
  src_reg:OK
  #519/10  verifier_load_acquire/load-acquire with uninitialized src_reg
  @unpriv:OK
  #519/11  verifier_load_acquire/load-acquire with non-pointer src_reg:OK
  #519/12  verifier_load_acquire/load-acquire with non-pointer src_reg
  @unpriv:OK
  #519/13  verifier_load_acquire/misaligned load-acquire:OK
  #519/14  verifier_load_acquire/misaligned load-acquire @unpriv:OK
  #519/15  verifier_load_acquire/load-acquire from ctx pointer:OK
  #519/16  verifier_load_acquire/load-acquire from ctx pointer @unpriv:OK
  #519/17  verifier_load_acquire/load-acquire with invalid register R15:OK
  #519/18  verifier_load_acquire/load-acquire with invalid register R15
  @unpriv:OK
  #519/19  verifier_load_acquire/load-acquire from pkt pointer:OK
  #519/20  verifier_load_acquire/load-acquire from flow_keys pointer:OK
  #519/21  verifier_load_acquire/load-acquire from sock pointer:OK
  #519     verifier_load_acquire:OK
  #556/1   verifier_store_release/store-release, 8-bit:OK
  #556/2   verifier_store_release/store-release, 8-bit @unpriv:OK
  #556/3   verifier_store_release/store-release, 16-bit:OK
  #556/4   verifier_store_release/store-release, 16-bit @unpriv:OK
  #556/5   verifier_store_release/store-release, 32-bit:OK
  #556/6   verifier_store_release/store-release, 32-bit @unpriv:OK
  #556/7   verifier_store_release/store-release, 64-bit:OK
  #556/8   verifier_store_release/store-release, 64-bit @unpriv:OK
  #556/9   verifier_store_release/store-release with uninitialized
  src_reg:OK
  #556/10  verifier_store_release/store-release with uninitialized src_reg
  @unpriv:OK
  #556/11  verifier_store_release/store-release with uninitialized
  dst_reg:OK
  #556/12  verifier_store_release/store-release with uninitialized dst_reg
  @unpriv:OK
  #556/13  verifier_store_release/store-release with non-pointer
  dst_reg:OK
  #556/14  verifier_store_release/store-release with non-pointer dst_reg
  @unpriv:OK
  #556/15  verifier_store_release/misaligned store-release:OK
  #556/16  verifier_store_release/misaligned store-release @unpriv:OK
  #556/17  verifier_store_release/store-release to ctx pointer:OK
  #556/18  verifier_store_release/store-release to ctx pointer @unpriv:OK
  #556/19  verifier_store_release/store-release, leak pointer to stack:OK
  #556/20  verifier_store_release/store-release, leak pointer to stack
  @unpriv:OK
  #556/21  verifier_store_release/store-release, leak pointer to map:OK
  #556/22  verifier_store_release/store-release, leak pointer to map
  @unpriv:OK
  #556/23  verifier_store_release/store-release with invalid register
  R15:OK
  #556/24  verifier_store_release/store-release with invalid register R15
  @unpriv:OK
  #556/25  verifier_store_release/store-release to pkt pointer:OK
  #556/26  verifier_store_release/store-release to flow_keys pointer:OK
  #556/27  verifier_store_release/store-release to sock pointer:OK
  #556     verifier_store_release:OK
  Summary: 3/55 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Tested-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250717202935.29018-2-puranjay@kernel.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants