diff mbox

[linux,dev-4.10,1/2] drivers/fsi: Defer hub master scan on probe

Message ID 20170803185306.85007-2-cbostic@linux.vnet.ibm.com
State Superseded, archived
Headers show

Commit Message

Christopher Bostic Aug. 3, 2017, 6:53 p.m. UTC
Prevent hub master from scanning its connected links/slaves
at probe time.  Needed to keep from creating arbitration
conflicts on the hub connected links during host boot
FSI bus accesses.

Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
---
 drivers/fsi/fsi-core.c        | 3 +++
 drivers/fsi/fsi-master-gpio.c | 1 +
 drivers/fsi/fsi-master-hub.c  | 7 +++++++
 drivers/fsi/fsi-master.h      | 1 +
 4 files changed, 12 insertions(+)

Comments

Jeremy Kerr Aug. 4, 2017, 1:43 a.m. UTC | #1
Hi Chris,

> Prevent hub master from scanning its connected links/slaves
> at probe time.  Needed to keep from creating arbitration
> conflicts on the hub connected links during host boot
> FSI bus accesses.

This change doesn't need to be specific to the hub code - this just
makes it more complex.

As I mentioned yesterday, this can be done entirely in the fsi core.
When a master is registered, it has a reference to the of_node; just
check that. This way, we don't need to a) assume behaviour of different
master types, or 2) implement this logic in every master.

So, the basis of the change will just be something like:

    diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
    --- a/drivers/fsi/fsi-core.c
    +++ b/drivers/fsi/fsi-core.c
    @@ -927,7 +927,9 @@ int fsi_master_register(struct fsi_master *master)
     		return rc;
     	}

    -	fsi_master_scan(master);
    +	np = dev_of_node(&master->dev);
    +	if (!np || !of_property_read_bool(np, "no-scan-on-init"))
    +		fsi_master_scan(master);

     	return 0;
     }

This way, the no-scan-on-init (or whatever would be a better name)
node applies to the core, rather than every master implementation.
Consequently, this property is related to compatible = fsi-master and
not fsi-master-gpio or fsi-master-whatever-else.

[Also, don't forget to add this to the binding doc; it'd go in fsi.txt,
under the "FSI Masters" section].

Regarding names, I wouldn't use "probe" in the property name, as it's a
linux implementation detail. Some ideas:

 - no-scan-on-init
 - explicit-scan
 - arbitration-required
 - multiple-access

 : the latter two indicating that other entities can access the device, so
 we need to be careful when scanning, and scan explicitly. Or, anything
 else that you think is appropriate (but doesn't imply any specific OS
 implementation.

Cheers,


Jeremy
Christopher Bostic Aug. 4, 2017, 2:46 a.m. UTC | #2
On 8/3/17 8:43 PM, Jeremy Kerr wrote:
> Hi Chris,
>
>> Prevent hub master from scanning its connected links/slaves
>> at probe time.  Needed to keep from creating arbitration
>> conflicts on the hub connected links during host boot
>> FSI bus accesses.
> This change doesn't need to be specific to the hub code - this just
> makes it more complex.
>
> As I mentioned yesterday, this can be done entirely in the fsi core.
> When a master is registered, it has a reference to the of_node; just
> check that. This way, we don't need to a) assume behaviour of different
> master types, or 2) implement this logic in every master.
>
> So, the basis of the change will just be something like:
>
>      diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
>      --- a/drivers/fsi/fsi-core.c
>      +++ b/drivers/fsi/fsi-core.c
>      @@ -927,7 +927,9 @@ int fsi_master_register(struct fsi_master *master)
>       		return rc;
>       	}
>
>      -	fsi_master_scan(master);
>      +	np = dev_of_node(&master->dev);
>      +	if (!np || !of_property_read_bool(np, "no-scan-on-init"))
>      +		fsi_master_scan(master);
>
>       	return 0;
>       }
>
> This way, the no-scan-on-init (or whatever would be a better name)
> node applies to the core, rather than every master implementation.
> Consequently, this property is related to compatible = fsi-master and
> not fsi-master-gpio or fsi-master-whatever-else.
>
> [Also, don't forget to add this to the binding doc; it'd go in fsi.txt,
> under the "FSI Masters" section].
>
> Regarding names, I wouldn't use "probe" in the property name, as it's a
> linux implementation detail. Some ideas:
>
>   - no-scan-on-init
>   - explicit-scan
>   - arbitration-required
>   - multiple-access
>
>   : the latter two indicating that other entities can access the device, so
>   we need to be careful when scanning, and scan explicitly. Or, anything
>   else that you think is appropriate (but doesn't imply any specific OS
>   implementation.
Hi Jeremy,

Ok thanks for the detailed description.  Will get version 2 out shortly.

Thanks,
Chris


> Cheers,
>
>
> Jeremy
>
diff mbox

Patch

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 9b83f1a..3e00398 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -927,6 +927,9 @@  int fsi_master_register(struct fsi_master *master)
 		return rc;
 	}
 
+	if (master->no_scan_on_probe)
+		return 0;
+
 	fsi_master_scan(master);
 
 	return 0;
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 9e7a2ed..4e07b64 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -650,6 +650,7 @@  static int fsi_master_gpio_probe(struct platform_device *pdev)
 	master->master.term = fsi_master_gpio_term;
 	master->master.send_break = fsi_master_gpio_break;
 	master->master.link_enable = fsi_master_gpio_link_enable;
+	master->master.no_scan_on_probe = false;
 	platform_set_drvdata(pdev, master);
 
 	fsi_master_gpio_init(master);
diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c
index 3223a67..94a61fc 100644
--- a/drivers/fsi/fsi-master-hub.c
+++ b/drivers/fsi/fsi-master-hub.c
@@ -244,6 +244,7 @@  static int hub_master_probe(struct device *dev)
 {
 	struct fsi_device *fsi_dev = to_fsi_dev(dev);
 	struct fsi_master_hub *hub;
+	struct device_node *np;
 	uint32_t reg, links;
 	__be32 __reg;
 	int rc;
@@ -283,6 +284,12 @@  static int hub_master_probe(struct device *dev)
 	hub->master.send_break = hub_master_break;
 	hub->master.link_enable = hub_master_link_enable;
 
+	np = dev->of_node;
+	if (of_property_read_bool(np, "no-scan-on-probe"))
+		hub->master.no_scan_on_probe = true;
+	else
+		hub->master.no_scan_on_probe = false;
+
 	dev_set_drvdata(dev, hub);
 
 	hub_master_init(hub);
diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h
index 546257d..7f8e288 100644
--- a/drivers/fsi/fsi-master.h
+++ b/drivers/fsi/fsi-master.h
@@ -26,6 +26,7 @@  struct fsi_master {
 	int		idx;
 	int		n_links;
 	int		flags;
+	bool		no_scan_on_probe;
 	int		(*read)(struct fsi_master *, int link, uint8_t id,
 				uint32_t addr, void *val, size_t size);
 	int		(*write)(struct fsi_master *, int link, uint8_t id,