Skip to contentSkip to conversation

PHY fixed driver: rework release path and update phy_id notation

PATCH In review Vitaly Bordug 3 participants 5 messages Jul 18, 2007 – Jul 20, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PHY fixed driver: rework release path and update phy_id notation

device_bind_driver() error code returning has been fixed. release() function has been written, so that to free resources in correct way; the release path is now clean.

Before the rework, it used to cause
Device 'fixed@100:1' does not have a release() function, it is broken and must be fixed.

 BUG: at drivers/base/core.c:104 device_release() 
  
 Call Trace:   
  [<ffffffff802ec380>] kobject_cleanup+0x53/0x7e 
  [<ffffffff802ec3ab>] kobject_release+0x0/0x9 
  [<ffffffff802ecf3f>] kref_put+0x74/0x81 
  [<ffffffff8035493b>] fixed_mdio_register_device+0x230/0x265 
  [<ffffffff80564d31>] fixed_init+0x1f/0x35 
  [<ffffffff802071a4>] init+0x147/0x2fb 
  [<ffffffff80223b6e>] schedule_tail+0x36/0x92 
  [<ffffffff8020a678>] child_rip+0xa/0x12 
  [<ffffffff80311714>] acpi_ds_init_one_object+0x0/0x83 
  [<ffffffff8020705d>] init+0x0/0x2fb 
  [<ffffffff8020a66e>] child_rip+0x0/0x12   

Also changed the notation of the fixed phy definition on
mdio bus to the form of <speed>+<duplex> to make it able to be used by gianfar and ucc_geth that define phy_id strictly as "%d:%d" and cleaned up the whitespace issues.

---

 drivers/net/phy/Kconfig   |   14 ++
 drivers/net/phy/fixed.c   |  310 +++++++++++++++++++++++----------------------
 include/linux/phy_fixed.h |   38 ++++++
 3 files changed, 207 insertions(+), 155 deletions(-)
drivers/net/phy/Kconfig +14 -0
index dd09011..432c210 100644
@@ -76,4 +76,18 @@ config FIXED_MII_100_FDX
 	bool "Emulation for 100M Fdx fixed PHY behavior"
 	depends on FIXED_PHY
 
+config FIXED_MII_1000_FDX
+	bool "Emulation for 1000M Fdx fixed PHY behavior"
+	depends on FIXED_PHY
+
+config FIXED_MII_AMNT
+        int "Number of emulated PHYs to allocate "
+        depends on FIXED_PHY
+        default "1"
+        ---help---
+        Sometimes it is required to have several independent emulated
+        PHYs on the bus (in case of multi-eth but phy-less HW for instance).
+        This control will have specified number allocated for each fixed
+        PHY type enabled.
+
 endif # PHYLIB
drivers/net/phy/fixed.c +155 -155

477 lines not on this page · raw message

include/linux/phy_fixed.h new file +38 -0
new file mode 100644
index 0000000..04ba70d
@@ -0,0 +1,38 @@
+#ifndef __PHY_FIXED_H
+#define __PHY_FIXED_H
+
+#define MII_REGS_NUM	29
+
+/* max number of virtual phy stuff */
+#define MAX_PHY_AMNT	10
+/*
+    The idea is to emulate normal phy behavior by responding with
+    pre-defined values to mii BMCR read, so that read_status hook could
+    take all the needed info.
+*/
+
+struct fixed_phy_status {
+	u8 link;
+	u16 speed;
+	u8 duplex;
+};
+
+/*-----------------------------------------------------------------------------
+ *  Private information hoder for mii_bus
+ *-----------------------------------------------------------------------------*/
+struct fixed_info {
+	u16 *regs;
+	u8 regs_num;
+	struct fixed_phy_status phy_status;
+	struct phy_device *phydev;	/* pointer to the container */
+	/* link & speed cb */
+	int (*link_update) (struct net_device *, struct fixed_phy_status *);
+
+};
+
+
+int fixed_mdio_set_link_update(struct phy_device *,
+       int (*link_update) (struct net_device *, struct fixed_phy_status *));
+struct fixed_info *fixed_mdio_get_phydev (int phydev_ind);
+
+#endif /* __PHY_FIXED_H */
#1 lore raw
Quoted 24 lines · On Thu, 19 Jul 2007 03:38:04 +0400 Vitaly Bordug <[email protected]>…

device_bind_driver() error code returning has been fixed. release() function has been written, so that to free resources in correct way; the release path is now clean.

Before the rework, it used to cause
Device 'fixed@100:1' does not have a release() function, it is broken and must be fixed.

 BUG: at drivers/base/core.c:104 device_release() 
  
 Call Trace:   
  [<ffffffff802ec380>] kobject_cleanup+0x53/0x7e 
  [<ffffffff802ec3ab>] kobject_release+0x0/0x9 
  [<ffffffff802ecf3f>] kref_put+0x74/0x81 
  [<ffffffff8035493b>] fixed_mdio_register_device+0x230/0x265 
  [<ffffffff80564d31>] fixed_init+0x1f/0x35 
  [<ffffffff802071a4>] init+0x147/0x2fb 
  [<ffffffff80223b6e>] schedule_tail+0x36/0x92 
  [<ffffffff8020a678>] child_rip+0xa/0x12 
  [<ffffffff80311714>] acpi_ds_init_one_object+0x0/0x83 
  [<ffffffff8020705d>] init+0x0/0x2fb 
  [<ffffffff8020a66e>] child_rip+0x0/0x12   
Quoted 5 lines

Also changed the notation of the fixed phy definition on
mdio bus to the form of <speed>+<duplex> to make it able to be used by gianfar and ucc_geth that define phy_id strictly as "%d:%d" and cleaned up the whitespace issues.

Confused. Does the above refer to the difference between this patch and the previous version, or does it just describe this patch? Hopefully the latter, because the former isn't interesting, long-term.

If is _is_ a full standalone description of this patch then it's a bit hard to follow ;)

drivers/net/phy/Kconfig config FIXED_MII_100_FDX · line 91

Quoted 13 lines
drivers/net/phy/Kconfig +13 -0
+config FIXED_MII_1000_FDX
+	bool "Emulation for 1000M Fdx fixed PHY behavior"
+	depends on FIXED_PHY
+
+config FIXED_MII_AMNT
+        int "Number of emulated PHYs to allocate "
+        depends on FIXED_PHY
+        default "1"
+        ---help---
+        Sometimes it is required to have several independent emulated
+        PHYs on the bus (in case of multi-eth but phy-less HW for instance).
+        This control will have specified number allocated for each fixed
+        PHY type enabled.

Shouldn't these be runtime options (ie: module parameters)?

Quoted 4 lines

...

+ * Private information hoder for mii_bus

tpyo.

#2 lore raw
Quoted 33 lines · On Thu, 19 Jul 2007 23:23:37 -0700 Andrew Morton wrote:
Quoted 24 lines · On Thu, 19 Jul 2007 03:38:04 +0400 Vitaly Bordug <[email protected]>…

device_bind_driver() error code returning has been fixed. release() function has been written, so that to free resources in correct way; the release path is now clean.

Before the rework, it used to cause
Device 'fixed@100:1' does not have a release() function, it is
broken and must be fixed.

 BUG: at drivers/base/core.c:104 device_release() 
  
 Call Trace:   
  [<ffffffff802ec380>] kobject_cleanup+0x53/0x7e 
  [<ffffffff802ec3ab>] kobject_release+0x0/0x9 
  [<ffffffff802ecf3f>] kref_put+0x74/0x81 
  [<ffffffff8035493b>] fixed_mdio_register_device+0x230/0x265 
  [<ffffffff80564d31>] fixed_init+0x1f/0x35 
  [<ffffffff802071a4>] init+0x147/0x2fb 
  [<ffffffff80223b6e>] schedule_tail+0x36/0x92 
  [<ffffffff8020a678>] child_rip+0xa/0x12 
  [<ffffffff80311714>] acpi_ds_init_one_object+0x0/0x83 
  [<ffffffff8020705d>] init+0x0/0x2fb 
  [<ffffffff8020a66e>] child_rip+0x0/0x12   
Quoted 5 lines

Also changed the notation of the fixed phy definition on mdio bus to the form of <speed>+<duplex> to make it able to be used by gianfar and ucc_geth that define phy_id strictly as "%d:%d" and cleaned up the whitespace issues.

Quoted 4 lines

Confused. Does the above refer to the difference between this patch and the previous version, or does it just describe this patch? Hopefully the latter, because the former isn't interesting, long-term.

Latter. IOW, that does mean, that mdio bus registered by this driver, now uses same naming conventioun that other PHYLIB things use. Hereby it will make it able to be used in NIC drivers other than fs_enet (and gianfar and ucc_geth are now points of interest).

Quoted 3 lines

If is _is_ a full standalone description of this patch then it's a bit hard to follow ;)

Hmm -so what are my options - change the description and resubmit?

Quoted 10 lines
Quoted 10 lines
drivers/net/phy/Kconfig +10 -0
+config FIXED_MII_1000_FDX
+	bool "Emulation for 1000M Fdx fixed PHY behavior"
+	depends on FIXED_PHY
+
+config FIXED_MII_AMNT
+        int "Number of emulated PHYs to allocate "
+        depends on FIXED_PHY
+        default "1"
+        ---help---
+        Sometimes it is required to have several independent
Quoted 9 lines
Quoted 6 lines

emulated
+ PHYs on the bus (in case of multi-eth but phy-less HW for
instance).
+ This control will have specified number allocated for each
fixed
+ PHY type enabled.

Shouldn't these be runtime options (ie: module parameters)?

I thought about it but this thing is more like the one that will never tend/required to change while\
configured.. Will add if you see it appropriate though.

Quoted 6 lines
Quoted 4 lines

...

+ * Private information hoder for mii_bus

tpyo.

ok

Signature · 1 line
Sincerely, Vitaly
#3 lore raw
Quoted 40 lines · On Fri, 20 Jul 2007 11:50:39 +0400 Vitaly Bordug <[email protected]>…
Quoted 33 lines · On Thu, 19 Jul 2007 23:23:37 -0700 Andrew Morton wrote:
Quoted 24 lines · On Thu, 19 Jul 2007 03:38:04 +0400 Vitaly Bordug <[email protected]>…

device_bind_driver() error code returning has been fixed. release() function has been written, so that to free resources in correct way; the release path is now clean.

Before the rework, it used to cause
Device 'fixed@100:1' does not have a release() function, it is
broken and must be fixed.

 BUG: at drivers/base/core.c:104 device_release() 
  
 Call Trace:   
  [<ffffffff802ec380>] kobject_cleanup+0x53/0x7e 
  [<ffffffff802ec3ab>] kobject_release+0x0/0x9 
  [<ffffffff802ecf3f>] kref_put+0x74/0x81 
  [<ffffffff8035493b>] fixed_mdio_register_device+0x230/0x265 
  [<ffffffff80564d31>] fixed_init+0x1f/0x35 
  [<ffffffff802071a4>] init+0x147/0x2fb 
  [<ffffffff80223b6e>] schedule_tail+0x36/0x92 
  [<ffffffff8020a678>] child_rip+0xa/0x12 
  [<ffffffff80311714>] acpi_ds_init_one_object+0x0/0x83 
  [<ffffffff8020705d>] init+0x0/0x2fb 
  [<ffffffff8020a66e>] child_rip+0x0/0x12   
Quoted 5 lines

Also changed the notation of the fixed phy definition on mdio bus to the form of <speed>+<duplex> to make it able to be used by gianfar and ucc_geth that define phy_id strictly as "%d:%d" and cleaned up the whitespace issues.

Quoted 4 lines

Confused. Does the above refer to the difference between this patch and the previous version, or does it just describe this patch? Hopefully the latter, because the former isn't interesting, long-term.

Quoted 8 lines

Latter. IOW, that does mean, that mdio bus registered by this driver, now uses same naming conventioun that other PHYLIB things use. Hereby it will make it able to be used in NIC drivers other than fs_enet (and gianfar and ucc_geth are now points of interest).

Quoted 3 lines

If is _is_ a full standalone description of this patch then it's a bit hard to follow ;)

Hmm -so what are my options - change the description and resubmit?

umm, I guess it's OK as-is. But it wasn't clear to me which sort of changelog it was.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/phy/Kconfig +10 -0
+config FIXED_MII_1000_FDX
+	bool "Emulation for 1000M Fdx fixed PHY behavior"
+	depends on FIXED_PHY
+
+config FIXED_MII_AMNT
+        int "Number of emulated PHYs to allocate "
+        depends on FIXED_PHY
+        default "1"
+        ---help---
+        Sometimes it is required to have several independent
Quoted 9 lines
Quoted 6 lines

emulated
+ PHYs on the bus (in case of multi-eth but phy-less HW for
instance).
+ This control will have specified number allocated for each
fixed
+ PHY type enabled.

Shouldn't these be runtime options (ie: module parameters)?

Quoted 2 lines

I thought about it but this thing is more like the one that will never tend/required to change while\
configured.. Will add if you see it appropriate though.

99% of users don't compile their own kernels: their vendor will have to make this decision for them, and it sounds like any decision which they make will be wrong for some of their users?

#4 lore raw
Quoted 11 lines · Andrew Morton
Quoted 6 lines · On Fri, 20 Jul 2007 11:50:39 +0400 Vitaly Bordug <[email protected]>…
Quoted 2 lines · On Thu, 19 Jul 2007 23:23:37 -0700 Andrew Morton wrote:

Shouldn't these be runtime options (ie: module parameters)?

I thought about it but this thing is more like the one that will never tend/required to change while\
configured.. Will add if you see it appropriate though.

99% of users don't compile their own kernels: their vendor will have to make this decision for them, and it sounds like any decision which they make will be wrong for some of their users?

This is mostly of use on embedded hardware where the kernel will be rebuilt by someone who knows the hardware... That said, I don't see why it needs to be configured at all. Couldn't it use an idr table instead?

-Scott