Skip to content

Commit d726f6b

Browse files
mellanoxbmcdvhart
authored andcommitted
platform/x86: mlx-platform: Add deffered bus functionality
mlx-platform activates i2c-mux-reg, which creates buses needed by mlxreg-hotplug. If the mlxreg-hotplug probe runs before the i2c-mux-reg probe completes, it may attempt to connect a device to an adapter number that has not been created yet, and fail. Make mlx-platform driver record the highest bus number in mlxreg-hotplug platform data and defer mlxreg-hotplug probe until all the buses are created. Signed-off-by: Vadim Pasternak <[email protected]> [dvhart: rewrite commit message more concisely] Signed-off-by: Darren Hart (VMware) <[email protected]>
1 parent d066f14 commit d726f6b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

drivers/platform/mellanox/mlxreg-hotplug.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev)
550550
{
551551
struct mlxreg_core_hotplug_platform_data *pdata;
552552
struct mlxreg_hotplug_priv_data *priv;
553+
struct i2c_adapter *deferred_adap;
553554
int err;
554555

555556
pdata = dev_get_platdata(&pdev->dev);
@@ -558,6 +559,12 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev)
558559
return -EINVAL;
559560
}
560561

562+
/* Defer probing if the necessary adapter is not configured yet. */
563+
deferred_adap = i2c_get_adapter(pdata->deferred_nr);
564+
if (!deferred_adap)
565+
return -EPROBE_DEFER;
566+
i2c_put_adapter(deferred_adap);
567+
561568
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
562569
if (!priv)
563570
return -ENOMEM;

drivers/platform/x86/mlx-platform.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi)
697697
ARRAY_SIZE(mlxplat_default_channels[i]);
698698
}
699699
mlxplat_hotplug = &mlxplat_mlxcpld_default_data;
700+
mlxplat_hotplug->deferred_nr =
701+
mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
700702

701703
return 1;
702704
};
@@ -711,6 +713,8 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi)
711713
ARRAY_SIZE(mlxplat_msn21xx_channels);
712714
}
713715
mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data;
716+
mlxplat_hotplug->deferred_nr =
717+
mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
714718

715719
return 1;
716720
};
@@ -725,6 +729,8 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi)
725729
ARRAY_SIZE(mlxplat_msn21xx_channels);
726730
}
727731
mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data;
732+
mlxplat_hotplug->deferred_nr =
733+
mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
728734

729735
return 1;
730736
};
@@ -739,6 +745,8 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi)
739745
ARRAY_SIZE(mlxplat_msn21xx_channels);
740746
}
741747
mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data;
748+
mlxplat_hotplug->deferred_nr =
749+
mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
742750

743751
return 1;
744752
};
@@ -753,6 +761,8 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi)
753761
ARRAY_SIZE(mlxplat_msn21xx_channels);
754762
}
755763
mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data;
764+
mlxplat_hotplug->deferred_nr =
765+
mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
756766

757767
return 1;
758768
};

include/linux/platform_data/mlxreg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct mlxreg_core_platform_data {
129129
* @mask: top aggregation interrupt common mask;
130130
* @cell_low: location of low aggregation interrupt register;
131131
* @mask_low: low aggregation interrupt common mask;
132+
* @deferred_nr: I2C adapter number must be exist prior probing execution;
132133
*/
133134
struct mlxreg_core_hotplug_platform_data {
134135
struct mlxreg_core_item *items;
@@ -139,6 +140,7 @@ struct mlxreg_core_hotplug_platform_data {
139140
u32 mask;
140141
u32 cell_low;
141142
u32 mask_low;
143+
int deferred_nr;
142144
};
143145

144146
#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */

0 commit comments

Comments
 (0)