drivers/fsi: Add hub master
v2 cover drivers/fsi: Add hub master
Adds the FSI hub master functionality to the OpenFSI device driver. Hub master is a FSI client device driver that registers with the core and is notified when devices it wants, hub master engine and links, are discovered.
v2: Restructured to move hub into the core instead of a separate
slave device driver.
Christopher Bostic (7):
drivers/fsi: Add hub master scan detect drivers/fsi: Initialize hub master
drivers/fsi: Define hub master callbacks drivers/fsi: Move common read write ops into single function drivers/fsi: Add retry on bus error detect drivers/fsi: Cleanup bus errors tools/testing/selftests: Add fsi command line tool
Signature · 1 line
1.8.2.2
PATCH v2 1/7 drivers/fsi: Add hub master scan detect
On detect of hub master engine in config space set up a master device and register it with the core.
---
Changes in V2:
- Refactor structures for hub master. Previously hub master engine was considered a slave engine.
--- drivers/fsi/fsi-core.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +45 -2
@@ -43,6 +43,11 @@#define FSI_IPOLL_PERIOD msecs_to_jiffies(fsi_ipoll_period_ms) +#define FSI_ENGID_HUB_MASTER 0x1c +#define FSI_ENGID_HUB_LINK 0x1d +#define FSI_HUB_LINK_OFFSET 0x80000 +#define FSI_HUB_MASTER_MAX_LINKS 8 +static const int engine_page_size =0x400 ;static struct task_struct *master_ipoll;static unsigned int fsi_ipoll_period_ms =100 ;
@@ -58,6 +63,14 @@ struct fsi_slave {uint8_t id; }; +struct fsi_master_hub { +struct fsi_master master; +struct fsi_slave *slave; +uint32_t control_regs;/* slave-relative addr regs */ +uint32_t base;/* slave-relative addr of */ +/* master address space */ +}; +#define to_fsi_slave (d) container_of(d, struct fsi_slave, dev) static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
@@ -203,12 +216,18 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, slave->id, addr, val, size); } +static int hub_master_init (struct fsi_master_hub *hub) +{ +return 0 ; +} +static int fsi_slave_scan (struct fsi_slave *slave) {uint32_t engine_addr;uint32_t conf;int rc, i;uint8_t si1s_bit =1 ; +struct fsi_master_hub *hub;INIT_LIST_HEAD (&slave->my_engines);
@@ -252,7 +271,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)* Unused address areas are marked by a zero type value; this * skips the defined address areas */ -if (type !=0 && slots !=0 ) { +if (type !=0 ) { + +if (type ==FSI_ENGID_HUB_MASTER ) { + hub =kzalloc (sizeof (*hub),GFP_KERNEL ); +if (!hub) +return -ENOMEM ; + + hub->base =FSI_HUB_LINK_OFFSET ; + hub->control_regs = engine_addr; + hub->slave = slave; + rc =hub_master_init (hub); + +continue ; + } +if (type ==FSI_ENGID_HUB_LINK ) { +if (!hub) +continue ; + + hub->master.n_links++; +if (hub->master.n_links == + (FSI_HUB_MASTER_MAX_LINKS *2 )) + rc =fsi_master_register (&hub->master); + +continue ; + }/* create device */ dev =fsi_create_device (slave);
@@ -597,7 +640,7 @@ DEVICE_ATTR(fsi_ipoll_period, S_IRUGO | S_IWUSR, fsi_ipoll_period_show,int fsi_master_register (struct fsi_master *master) { -if (!master || !master->dev) +if (!master)return -EINVAL ; master->idx =ida_simple_get (&master_ida,0 ,INT_MAX ,GFP_KERNEL );
Signature · 1 line
1.8.2.2
Re: [PATCH linux dev-4.7 v2 1/7] drivers/fsi: Add hub master scan detect
Hi Chris,
drivers/fsi/fsi-core.c static int fsi_slave_scan(struct fsi_slave *slave) · line 276
Quoted 8 lines
drivers/fsi/fsi-core.c +3
-1@@ -252,7 +271,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)* Unused address areas are marked by a zero type value; this * skips the defined address areas */ -if (type !=0 && slots !=0 ) { +if (type !=0 ) { + +if (type ==FSI_ENGID_HUB_MASTER ) {
I'd split this into a separate part of the above 'if' statement. Or, convert it to a switch.
Quoted 12 lines
drivers/fsi/fsi-core.c +12
-0+ hub =kzalloc (sizeof (*hub),GFP_KERNEL ); +if (!hub) +return -ENOMEM ; + + hub->base =FSI_HUB_LINK_OFFSET ; + hub->control_regs = engine_addr; + hub->slave = slave; + rc =hub_master_init (hub); + +continue ; + } +if (type ==FSI_ENGID_HUB_LINK ) {
drivers/fsi/fsi-core.c static int fsi_slave_scan(struct fsi_slave *slave) · line 298
Quoted 10 lines
drivers/fsi/fsi-core.c +10
-0+if (!hub) +continue ; + + hub->master.n_links++; +if (hub->master.n_links == + (FSI_HUB_MASTER_MAX_LINKS *2 )) + rc =fsi_master_register (&hub->master); + +continue ; + }
This logic doesn't make a lot of sense. You're counting the number of link slots, but then registering the master when that count hits a predefined number. I'd suggest either:
- just setting n_links to the predefined number; or
- keeping a separate variable for n_links, and then once we've finished scanning the configuration table (after the for loop)
if (hub) {
hub->n_links = conf_link_count / 2;
fsi_master_register(&hub->master);
}I'd much prefer the second option, as that actually uses the link count from the config table.
Quoted 5 lines
drivers/fsi/fsi-core.c +1
-1int fsi_master_register (struct fsi_master *master) { -if (!master || !master->dev) +if (!master)return
-EINVAL;
I'm worried if this is needed - we should be creating a device for all masters.
Cheers,
Jeremy
Re: [PATCH linux dev-4.7 v2 1/7] drivers/fsi: Add hub master scan detect
Quoted 12 lines · Jeremy Kerr
Hi Chris,
drivers/fsi/fsi-core.c static int fsi_slave_scan(struct fsi_slave *slave) · line 276
Quoted 8 lines
drivers/fsi/fsi-core.c +3
-1@@ -252,7 +271,31 @@ static int fsi_slave_scan(struct fsi_slave *slave)* Unused address areas are marked by a zero type value; this * skips the defined address areas */ -if (type !=0 && slots !=0 ) { +if (type !=0 ) { + +if (type ==FSI_ENGID_HUB_MASTER ) {I'd split this into a separate part of the above 'if' statement. Or, convert it to a switch.
Hi Jeremy,
Will change.
Quoted 36 lines
Quoted 12 lines
drivers/fsi/fsi-core.c +12
-0+ hub =kzalloc (sizeof (*hub),GFP_KERNEL ); +if (!hub) +return -ENOMEM ; + + hub->base =FSI_HUB_LINK_OFFSET ; + hub->control_regs = engine_addr; + hub->slave = slave; + rc =hub_master_init (hub); + +continue ; + } +if (type ==FSI_ENGID_HUB_LINK ) {drivers/fsi/fsi-core.c static int fsi_slave_scan(struct fsi_slave *slave) · line 298
Quoted 10 lines
drivers/fsi/fsi-core.c +10
-0+if (!hub) +continue ; + + hub->master.n_links++; +if (hub->master.n_links == + (FSI_HUB_MASTER_MAX_LINKS *2 )) + rc =fsi_master_register (&hub->master); + +continue ; + }This logic doesn't make a lot of sense. You're counting the number of link slots, but then registering the master when that count hits a predefined number. I'd suggest either:
- just setting
n_linksto the predefined number; or- keeping a separate variable for
n_links, and then once we've finishedscanning the configuration table (after the for loop) if (hub) { hub->n_links = conf_link_count / 2; fsi_master_register(&hub->master); }
Quoted 2 lines
I'd much prefer the second option, as that actually uses the link count from the config table.
Will implement the second option
Quoted 7 lines
Quoted 5 lines
drivers/fsi/fsi-core.c +1
-1int fsi_master_register (struct fsi_master *master) { -if (!master || !master->dev) +if (!master)return
-EINVAL;I'm worried if this is needed - we should be creating a device for all masters.
Will add a dev for struct fsi_master.
Thanks
Quoted 5 lines
Cheers,
Jeremy
PATCH v2 2/7 drivers/fsi: Initialize hub master
In reply to Christopher BosticInitialize the hub master control registers. Set up clock delays, error handling behavior, toggle link enables.
---
Changes in V2:
- Add some description of what a hub master is and how it differs from a cascaded master.
--- drivers/fsi/fsi-core.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/fsi/fsi-master.h | 57 +++++++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +115 -1
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/jiffies.h> +#include <linux/delay.h> #include "fsi-master.h"
@@ -216,11 +217,124 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, slave->id, addr, val, size); } -static int hub_master_init (struct fsi_master_hub *hub) +/* +* FSI hub master support +* +* A hub master increases the number of potential target devices that the +* primary FSI master can access. For each link a primary master supports +* each of those links can in turn be chained to a hub master with multiple +* hub links of its own. Hubs differ from cascaded masters (cMFSI) in the +* total addressable range per link -hubs having address ranges that are much +* larger. +*/ +int hub_master_read (struct fsi_master *master,int linkno,uint8_t slave, +uint32_t addr,void *val,size_t size) +{ +return 0 ; +} + +int hub_master_write (struct fsi_master *master,int linkno,uint8_t slave, +uint32_t addr,const void *val,size_t size) {return 0 ; } +int hub_master_break (struct fsi_master *master,int linkno) +{ +return 0 ; +} + +int hub_master_link_enable (struct fsi_master *master,int linkno) +{ +return 0 ; +} + +static int hub_master_init (struct fsi_master_hub *hub) +{ +int rc; +uint32_t mver; +struct fsi_master *master = &hub->master; + + master->read = hub_master_read; + master->write = hub_master_write; + master->send_break = hub_master_break; + master->link_enable = hub_master_link_enable; + +/* Initialize the MFSI (hub master) engine */ + rc =fsi_slave_read (hub->slave, hub->control_regs +FSI_MVER , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =FSI_MRESP_RST_ALL_MASTER |FSI_MRESP_RST_ALL_LINK + |FSI_MRESP_RST_MCR |FSI_MRESP_RST_PYE ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MRESP0 , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =FSI_MECTRL_EOAE |FSI_MECTRL_P8_AUTO_TERM ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MECTRL , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =FSI_MMODE_EIP |FSI_MMODE_ECRC |FSI_MMODE_EPC + |fsi_mmode_crs0 (1 ) |fsi_mmode_crs1 (1 ) + |FSI_MMODE_P8_TO_LSB ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MMODE , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =0xffff0000 ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MDLYR , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver = ~0 ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MSENP0 , &mver, +sizeof (mver)); +if (rc) +return rc; + +/* Leave enabled long enough for master logic to set up */ +udelay (1000 ); + + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MCENP0 , &mver, +sizeof (mver)); +if (rc) +return rc; + + rc =fsi_slave_read (hub->slave, hub->control_regs +FSI_MAEB , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =FSI_MRESP_RST_ALL_MASTER |FSI_MRESP_RST_ALL_LINK ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MRESP0 , &mver, +sizeof (mver)); +if (rc) +return rc; + + rc =fsi_slave_read (hub->slave, hub->control_regs +FSI_MLEVP0 , &mver, +sizeof (mver)); +if (rc) +return rc; + +/* Reset the master bridge */ + mver =FSI_MRESB_RST_GEN ; + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MRESB0 , &mver, +sizeof (mver)); +if (rc) +return rc; + + mver =FSI_MRESB_RST_ERR ; +return fsi_slave_write (hub->slave, hub->control_regs +FSI_MRESB0 , + &mver,sizeof (mver)); +} +static int fsi_slave_scan (struct fsi_slave *slave) {uint32_t engine_addr;
drivers/fsi/fsi-master.h +57 -0
67 lines not on this page · raw message
Signature · 1 line
1.8.2.2
PATCH v2 3/7 drivers/fsi: Define hub master callbacks
In reply to Christopher BosticDefine hub master read, write, link enable, and break ops.
--- drivers/fsi/fsi-core.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/fsi/fsi-core.c +32 -4
@@ -27,6 +27,7 @@#define DEBUG #define FSI_N_SLAVES 4 +#define FSI_BREAK 0xc0de0000#define FSI_SLAVE_CONF_NEXT_MASK 0x80000000#define FSI_SLAVE_CONF_SLOTS_MASK 0x00ff0000
@@ -47,6 +48,7 @@#define FSI_ENGID_HUB_MASTER 0x1c#define FSI_ENGID_HUB_LINK 0x1d#define FSI_HUB_LINK_OFFSET 0x80000 +#define FSI_MASTER_HUB_LINK_SIZE 0x80000#define FSI_HUB_MASTER_MAX_LINKS 8static const int engine_page_size =0x400 ;
@@ -72,6 +74,7 @@ struct fsi_master_hub {/* master address space */ }; +#define to_fsi_master_hub (d) container_of(d, struct fsi_master_hub, master)#define to_fsi_slave (d) container_of(d, struct fsi_slave, dev) static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
@@ -230,23 +233,47 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,int hub_master_read (struct fsi_master *master,int linkno,uint8_t slave,uint32_t addr,void *val,size_t size) { -return 0 ; +struct fsi_master_hub *hub =to_fsi_master_hub (master); + + addr += (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; +return fsi_slave_read (hub->slave, addr, val, size); }int hub_master_write (struct fsi_master *master,int linkno,uint8_t slave,uint32_t addr,const void *val,size_t size) { -return 0 ; +struct fsi_master_hub *hub =to_fsi_master_hub (master); + + addr += (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; +return fsi_slave_write (hub->slave, addr, val, size); }int hub_master_break (struct fsi_master *master,int linkno) { -return 0 ; +struct fsi_master_hub *hub =to_fsi_master_hub (master); +uint32_t command; +uint32_t break_offset =0x4 ;/* hw workaround */ +uint32_t addr; + + command =FSI_BREAK ; + addr = (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; +return fsi_slave_write (hub->slave, addr + break_offset, &command, +sizeof (command)); }int hub_master_link_enable (struct fsi_master *master,int linkno) { -return 0 ; +struct fsi_master_hub *hub =to_fsi_master_hub (master); +uint32_t menp =L_MSB_MASK (linkno); +int rc; + + rc =fsi_slave_write (hub->slave, hub->control_regs +FSI_MSENP0 , &menp, +sizeof (menp)); + +/* Wait for hw to finish enable */ +mdelay (10 ); + +return rc; }static int hub_master_init (struct fsi_master_hub *hub)
@@ -571,6 +598,7 @@ static int fsi_slave_init(struct fsi_master *master, slave->id = slave_id; slave->dev.parent = master->dev; slave->dev.release = fsi_slave_release; + slave->link = link;dev_set_name (&slave->dev,"slave@%02x:%02x" , link, slave_id); rc =device_register (&slave->dev);
Signature · 1 line
1.8.2.2
Re: [PATCH linux dev-4.7 v2 3/7] drivers/fsi: Define hub master callbacks
Hi Chris,
Quoted 1 line
Define hub master read, write, link enable, and break ops.
Now that we have things more contained, you may want to add the complete hub functionality in one patch.
However:
drivers/fsi/fsi-core.c static int fsi_slave_init(struct fsi_master *master, · line 604
Quoted 8 lines
drivers/fsi/fsi-core.c +1
-0@@ -571,6 +598,7 @@ static int fsi_slave_init(struct fsi_master *master, slave->id = slave_id; slave->dev.parent = master->dev; slave->dev.release = fsi_slave_release; + slave->link = link;dev_set_name (&slave->dev,"slave@%02x:%02x" , link, slave_id); rc =device_register (&slave->dev);
This looks like a generally-useful fix, for more than just the hub code.
Otherwise, looks good.
Cheers,
Jeremy
Re: [PATCH linux dev-4.7 v2 3/7] drivers/fsi: Define hub master callbacks
Quoted 5 lines · Jeremy Kerr
Hi Chris,
Quoted 1 line
Define hub master read, write, link enable, and break ops.
Now that we have things more contained, you may want to add the complete hub functionality in one patch.
Hi Jeremy,
OK will add all in one patch.
Quoted 11 lines
However:
drivers/fsi/fsi-core.c static int fsi_slave_init(struct fsi_master *master, · line 604
Quoted 8 lines
drivers/fsi/fsi-core.c +1
-0@@ -571,6 +598,7 @@ static int fsi_slave_init(struct fsi_master *master, slave->id = slave_id; slave->dev.parent = master->dev; slave->dev.release = fsi_slave_release; + slave->link = link;dev_set_name (&slave->dev,"slave@%02x:%02x" , link, slave_id); rc =device_register (&slave->dev);This looks like a generally-useful fix, for more than just the hub code.
This was uncovered in hub link testing. Will treat it as a separate patch from hub and error handling.
Thanks
Quoted 7 lines
Otherwise, looks good.
Cheers,
Jeremy
PATCH v2 4/7 drivers/fsi: Move common read write ops into single function
In reply to Christopher BosticMove common operations between gpio reads/writes into a new utility send_command.
---
v2: Separate the break out of common read/write elements into its
own separate patch.
--- drivers/fsi/fsi-master-gpio.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/fsi/fsi-master-gpio.c +18 -18
@@ -354,26 +354,34 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode, cmd->msg >>= (64 - cmd->bits); } +static int send_command (struct fsi_master_gpio *master, +struct fsi_gpio_msg *cmd,uint8_t expected, +size_t size,void *val) +{ +unsigned long flags; +int rc; + +spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); +serial_out (master, cmd); +echo_delay (master); + rc =poll_for_response (master, expected, size, val); +spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); + +return rc; +} +static int fsi_master_gpio_read (struct fsi_master *_master,int link,uint8_t slave,uint32_t addr,void *val,size_t size) {struct fsi_master_gpio *master =to_fsi_master_gpio (_master);struct fsi_gpio_msg cmd;int rc; -unsigned long flags;if (link !=0 )return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); - -spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); -serial_out (master, &cmd); -echo_delay (master); - rc =poll_for_response (master,FSI_GPIO_RESP_ACKD , size, val); -spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); - -return rc; +return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); } static int fsi_master_gpio_write(struct fsi_master *_master, int link,
@@ -382,20 +390,12 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,struct fsi_master_gpio *master =to_fsi_master_gpio (_master);struct fsi_gpio_msg cmd;int rc; -unsigned long flags;if (link !=0 )return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); - -spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); -serial_out (master, &cmd); -echo_delay (master); - rc =poll_for_response (master,FSI_GPIO_RESP_ACK , size,NULL ); -spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); - -return rc; +return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); }/*
Signature · 1 line
1.8.2.2
Re: [PATCH linux dev-4.7 v2 4/7] drivers/fsi: Move common read write ops into single function
Quoted 9 lines · Christopher Bostic
Move common operations between gpio reads/writes into a new utility
send_command.Signed-off-by Christopher Bostic <[email protected]>---
v2: Separate the break out of common read/write elements into its
own separate patch.
Nice one.
Quoted 77 lines
--- drivers/fsi/fsi-master-gpio.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/fsi/fsi-master-gpio.c +18
-19@@ -354,26 +354,34 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode, cmd->msg >>= (64 - cmd->bits); } +static int send_command (struct fsi_master_gpio *master, +struct fsi_gpio_msg *cmd,uint8_t expected, +size_t size,void *val) +{ +unsigned long flags; +int rc; + +spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); +serial_out (master, cmd); +echo_delay (master); + rc =poll_for_response (master, expected, size, val); +spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); + +return rc; +} +static int fsi_master_gpio_read (struct fsi_master *_master,int link,uint8_t slave,uint32_t addr,void *val,size_t size) {struct fsi_master_gpio *master =to_fsi_master_gpio (_master);struct fsi_gpio_msg cmd;int rc; -unsigned long flags;if (link !=0 )return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); - -spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); -serial_out (master, &cmd); -echo_delay (master); - rc =poll_for_response (master,FSI_GPIO_RESP_ACKD , size, val); -spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); - -return rc; +return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); } static int fsi_master_gpio_write(struct fsi_master *_master, int link,@@ -382,20 +390,12 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,struct fsi_master_gpio *master =to_fsi_master_gpio (_master);struct fsi_gpio_msg cmd;int rc; -unsigned long flags;if (link !=0 )return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); - -spin_lock_irqsave (&fsi_gpio_cmd_lock, flags); -serial_out (master, &cmd); -echo_delay (master); - rc =poll_for_response (master,FSI_GPIO_RESP_ACK , size,NULL ); -spin_unlock_irqrestore (&fsi_gpio_cmd_lock, flags); - -return rc; +return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); }/* -- 1.8.2.2
PATCH v2 5/7 drivers/fsi: Add retry on bus error detect
In reply to Christopher BosticAfter each gpio master read/write check for bus errors. If errors detected then clean it up and retry the original operation again. If second attempt succeeds then don't report original error to caller.
--- drivers/fsi/fsi-core.c | 4 ++++ drivers/fsi/fsi-master-gpio.c | 24 ++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +4 -0
@@ -639,6 +639,10 @@ static int fsi_master_break(struct fsi_master *master, int link)return 0 ; } +void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) +{ +} +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;
drivers/fsi/fsi-master-gpio.c +22 -2
@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc; } static int fsi_master_gpio_write(struct fsi_master *_master, int link,
@@ -395,7 +405,17 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); -return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc; }/*
drivers/fsi/fsi-master.h +3 -0
@@ -19,6 +19,8 @@#include <linux/device.h> +#include "fsi-master.h" +/* Control Registers */ #define FSI_MMODE 0x0/* R/W: mode */ #define FSI_MDLYR 0x4/* R/W: delay */
@@ -85,6 +87,7 @@ struct fsi_master {extern int fsi_master_register (struct fsi_master *master);extern void fsi_master_unregister (struct fsi_master *master);extern int fsi_master_start_ipoll (struct fsi_master *master); +extern void fsi_master_handle_error (struct fsi_master *master,uint32_t addr);/** * crc4 helper: Given a starting crc4 state @c, calculate the crc4 vaue of @x,
Signature · 1 line
1.8.2.2
Re: [PATCH linux dev-4.7 v2 5/7] drivers/fsi: Add retry on bus error detect
Quoted 51 lines · Christopher Bostic
After each gpio master read/write check for bus errors. If errors detected then clean it up and retry the original operation again. If second attempt succeeds then don't report original error to caller.
Signed-off-by Christopher Bostic <[email protected]>--- drivers/fsi/fsi-core.c | 4 ++++ drivers/fsi/fsi-master-gpio.c | 24 ++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-)drivers/fsi/fsi-core.c +4
-0@@ -639,6 +639,10 @@ static int fsi_master_break(struct fsi_master *master, int link)return 0 ; } +void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) +{ +} +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;drivers/fsi/fsi-master-gpio.c +11
-1@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc; } static int fsi_master_gpio_write(struct fsi_master *_master, int link,
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 412
Quoted 9 lines
drivers/fsi/fsi-master-gpio.c +5
-1@@ -395,7 +405,17 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); -return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */
It's obvious from the code that we're trying again. You could change the comment to indicate why we are trying again.
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 416
Quoted 4 lines
drivers/fsi/fsi-master-gpio.c +4
-0+ rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) +fsi_master_handle_error (&master->master, addr); + }
You're repeating yourself here. Perhaps a loop?
You have the same sequence in fsi_master_gpio_read. It would be nice to not repeat the sequence.
Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +2
-0+ +return rc; }/* drivers/fsi/fsi-master.h +0
-0
drivers/fsi/fsi-master.h line 22
Quoted 4 lines
drivers/fsi/fsi-master.h +1
-0@@ -19,6 +19,8 @@#include <linux/device.h> +#include "fsi-master.h"
This looks wrong.
drivers/fsi/fsi-master.h struct fsi_master { · line 90
Quoted 9 lines
drivers/fsi/fsi-master.h +2
-0+/* Control Registers */ #define FSI_MMODE 0x0/* R/W: mode */ #define FSI_MDLYR 0x4/* R/W: delay */ @@ -85,6 +87,7 @@ struct fsi_master {extern int fsi_master_register (struct fsi_master *master);extern void fsi_master_unregister (struct fsi_master *master);extern int fsi_master_start_ipoll (struct fsi_master *master); +extern void fsi_master_handle_error (struct fsi_master *master,uint32_t addr);
Does this need to be added to the header?
Quoted 6 lines
drivers/fsi/fsi-master.h +0
-1/** * crc4 helper: Given a starting crc4 state @c, calculate the crc4 vaue of @x, -- 1.8.2.2
Re: [PATCH linux dev-4.7 v2 5/7] drivers/fsi: Add retry on bus error detect
Quoted 55 lines · Joel Stanley
Quoted 53 lines · Christopher Bostic
After each gpio master read/write check for bus errors. If errors detected then clean it up and retry the original operation again. If second attempt succeeds then don't report original error to caller.
Signed-off-by Christopher Bostic <[email protected]>--- drivers/fsi/fsi-core.c | 4 ++++ drivers/fsi/fsi-master-gpio.c | 24 ++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-)drivers/fsi/fsi-core.c +4
-0@@ -639,6 +639,10 @@ static int fsi_master_break(struct fsi_master *master, int link)return 0 ; } +void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) +{ +} +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;drivers/fsi/fsi-master-gpio.c +11
-1@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc; } static int fsi_master_gpio_write(struct fsi_master *_master, int link,@@ -395,7 +405,17 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,return -ENODEV ;
Quoted 9 lines
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 412
Quoted 7 lines
drivers/fsi/fsi-master-gpio.c +5
-1build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); -return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ It's obvious from the code that we're trying again. You could change the comment to indicate why we are trying again.
Hi Joel
will update.
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 416
Quoted 4 lines
drivers/fsi/fsi-master-gpio.c +4
-0+ rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) +fsi_master_handle_error (&master->master, addr); + }You're repeating yourself here. Perhaps a loop?
You have the same sequence in
fsi_master_gpio_read. It would be nice to not repeat the sequence.
OK, will add a loop here.
Quoted 16 lines
Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +2
-0+ +return rc; }/* drivers/fsi/fsi-master.h +0
-0drivers/fsi/fsi-master.h line 22
Quoted 4 lines
drivers/fsi/fsi-master.h +1
-0@@ -19,6 +19,8 @@#include <linux/device.h> +#include "fsi-master.h" This looks wrong.
Quoted 10 lines
drivers/fsi/fsi-master.h struct fsi_master { · line 90
Quoted 9 lines
drivers/fsi/fsi-master.h +2
-0+/* Control Registers */ #define FSI_MMODE 0x0/* R/W: mode */ #define FSI_MDLYR 0x4/* R/W: delay */ @@ -85,6 +87,7 @@ struct fsi_master {extern int fsi_master_register (struct fsi_master *master);extern void fsi_master_unregister (struct fsi_master *master);extern int fsi_master_start_ipoll (struct fsi_master *master); +extern void fsi_master_handle_error (struct fsi_master *master,uint32_t addr);Does this need to be added to the header?
Probably not, will remove.
Thanks,
Chris
Quoted 5 lines
Quoted 5 lines
drivers/fsi/fsi-master.h +0
-1/** * crc4 helper: Given a starting crc4 state @c, calculate the crc4 vaue of @x, -- 1.8.2.2
Re: [PATCH linux dev-4.7 v2 5/7] drivers/fsi: Add retry on bus error detect
In reply to Joel StanleyQuoted 90 lines · Joel Stanley
Quoted 51 lines · Christopher Bostic
After each gpio master read/write check for bus errors. If errors detected then clean it up and retry the original operation again. If second attempt succeeds then don't report original error to caller.
Signed-off-by Christopher Bostic <[email protected]>--- drivers/fsi/fsi-core.c | 4 ++++ drivers/fsi/fsi-master-gpio.c | 24 ++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-)drivers/fsi/fsi-core.c +4
-0@@ -639,6 +639,10 @@ static int fsi_master_break(struct fsi_master *master, int link)return 0 ; } +void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) +{ +} +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;drivers/fsi/fsi-master-gpio.c +11
-1@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc; } static int fsi_master_gpio_write(struct fsi_master *_master, int link,drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 412
Quoted 9 lines
drivers/fsi/fsi-master-gpio.c +5
-1@@ -395,7 +405,17 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_WRITE , slave, addr, size, val); -return send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ It's obvious from the code that we're trying again. You could change the comment to indicate why we are trying again.
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_write(struct fsi_master *_master, int link, · line 416
Quoted 4 lines
drivers/fsi/fsi-master-gpio.c +4
-0+ rc =send_command (master, &cmd,FSI_GPIO_RESP_ACK , size,NULL ); +if (rc) +fsi_master_handle_error (&master->master, addr); + }You're repeating yourself here. Perhaps a loop?
You have the same sequence in
fsi_master_gpio_read. It would be nice to not repeat the sequence.Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +2
-0+ +return rc; }/* drivers/fsi/fsi-master.h +0
-0drivers/fsi/fsi-master.h line 22
Quoted 4 lines
drivers/fsi/fsi-master.h +1
-0@@ -19,6 +19,8 @@#include <linux/device.h> +#include "fsi-master.h" This looks wrong.
Quoted 10 lines
drivers/fsi/fsi-master.h struct fsi_master { · line 90
Quoted 9 lines
drivers/fsi/fsi-master.h +2
-0+/* Control Registers */ #define FSI_MMODE 0x0/* R/W: mode */ #define FSI_MDLYR 0x4/* R/W: delay */ @@ -85,6 +87,7 @@ struct fsi_master {extern int fsi_master_register (struct fsi_master *master);extern void fsi_master_unregister (struct fsi_master *master);extern int fsi_master_start_ipoll (struct fsi_master *master); +extern void fsi_master_handle_error (struct fsi_master *master,uint32_t addr);Does this need to be added to the header?
Hi Joel,
Yes, since the gpio master is requiring a core function, similar to fsi_master_register()/unregister()
Thanks,
Chris
Quoted 5 lines
Quoted 5 lines
drivers/fsi/fsi-master.h +0
-1/** * crc4 helper: Given a starting crc4 state @c, calculate the crc4 vaue of @x, -- 1.8.2.2
Re: [PATCH linux dev-4.7 v2 5/7] drivers/fsi: Add retry on bus error detect
In reply to Christopher BosticHi Chris,
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c +1
-1@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val);
drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_read(struct fsi_master *_master, int link, · line 394
Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +10
-0+if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc;
Lets avoid the repeated code:
const static int master_retries = 2;
[...]
for (retries = 0; retries < master_retries; retries++) {
rc = send_command(master, &cmd, FSI_GPIO_RESP_ACKD, size, val);
if (!rc)
break;
fsi_master_handle_error(&master->master, addr);
}
return rc;[or even better, we may want to put this in a helper, for use by both call sites]
Also, is there any condition where fsi_master_handle_error() knows that the FSI bus is totally hosed, and there's no point retrying?
Cheers,
Jeremy
Re: [PATCH linux dev-4.7 v2 5/7] drivers/fsi: Add retry on bus error detect
Quoted 35 lines · Jeremy Kerr
Hi Chris,
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c +1
-1@@ -381,7 +381,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,return -ENODEV ;build_abs_ar_command (&cmd,FSI_GPIO_CMD_READ , slave, addr, size,NULL ); -return send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val);drivers/fsi/fsi-master-gpio.c static int fsi_master_gpio_read(struct fsi_master *_master, int link, · line 394
Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +10
-0+if (rc) { +fsi_master_handle_error (&master->master, addr); + +/* Try again */ + rc =send_command (master, &cmd,FSI_GPIO_RESP_ACKD , size, val); +if (rc) +fsi_master_handle_error (&master->master, addr); + } + +return rc;Lets avoid the repeated code:
const static int master_retries = 2; [...] for (retries = 0; retries < master_retries; retries++) { rc = send_command(master, &cmd, FSI_GPIO_RESP_ACKD, size, val); if (!rc) break; fsi_master_handle_error(&master->master, addr); } return rc;
Quoted 2 lines
[or even better, we may want to put this in a helper, for use by both call sites]
Hi Jeremy,
Will change to a loop.
Quoted 2 lines
Also, is there any condition where
fsi_master_handle_error()knows that the FSI bus is totally hosed, and there's no point retrying?
There's not anything defined to flag a bad bus -will look into it.
Thanks,
Chris
Quoted 5 lines
Cheers,
Jeremy
PATCH v2 6/7 drivers/fsi: Cleanup bus errors
In reply to Christopher BosticDefine the bus error cleanup method for primary and hub links.
---
v2: Change to atomic operation when checking for nested error
handling.
Move slave access details out of gpio master and into the core.
Only allow hub link 1 scans to cut down on scan bus errors.
--- drivers/fsi/fsi-core.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/fsi/fsi-core.c +34 -0
@@ -21,6 +21,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/delay.h> +#include <linux/bitops.h> #include "fsi-master.h"
@@ -42,6 +43,9 @@#define FSI_PEEK_BASE 0x410#define FSI_SLAVE_BASE 0x800 +#define FSI_HUB_CONTROL 0x3400 + +#define FSI_SLAVE_SMODE_DFLT 0xa0ff0100#define FSI_IPOLL_PERIOD msecs_to_jiffies(fsi_ipoll_period_ms)
@@ -54,6 +58,10 @@static const int engine_page_size =0x400 ;static struct task_struct *master_ipoll;static unsigned int fsi_ipoll_period_ms =100 ; +static unsigned long fsi_state; + +/* state flags */ +#define FSI_IN_ERR_CLEANUP 0static DEFINE_IDA (master_ida);
@@ -255,6 +263,10 @@ int hub_master_break(struct fsi_master *master, int linkno)uint32_t break_offset =0x4 ;/* hw workaround */ uint32_t addr; +/* config table lists 2 entries per hub link */ +if (linkno >= (master->n_links /2 )) +return -ENODEV ; + command =FSI_BREAK ; addr = (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; return fsi_slave_write(hub->slave, addr + break_offset, &command,
@@ -641,6 +653,28 @@ static int fsi_master_break(struct fsi_master *master, int link)void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) { +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +/* Avoid nested error handling */ +if (test_and_set_bit (FSI_IN_ERR_CLEANUP , &fsi_state)) +return ; + +fsi_master_break (master,0 ); +udelay (200 ); + master->write (master,0 ,0 ,FSI_SLAVE_BASE +FSI_SMODE , &smode, +sizeof (smode)); + smode =FSI_MRESB_RST_GEN |FSI_MRESB_RST_ERR ; + master->write (master,0 ,0 ,FSI_HUB_CONTROL +FSI_MRESB0 , &smode, +sizeof (smode)); + +if (addr >FSI_HUB_LINK_OFFSET ) { + smode =FSI_BREAK ; + master->write (master,0 ,0 ,0x100004 , &smode,sizeof (smode)); + smode =FSI_SLAVE_SMODE_DFLT ; + master->write (master,0 ,0 ,0x100800 , &smode,sizeof (smode)); + } + +clear_bit (FSI_IN_ERR_CLEANUP , &fsi_state); }static int fsi_master_scan (struct fsi_master *master)
Signature · 1 line
1.8.2.2
Re: [PATCH linux dev-4.7 v2 6/7] drivers/fsi: Cleanup bus errors
Hi Chris,
drivers/fsi/fsi-core.c int hub_master_break(struct fsi_master *master, int linkno) · line 269
Quoted 8 lines
drivers/fsi/fsi-core.c +4
-0@@ -255,6 +263,10 @@ int hub_master_break(struct fsi_master *master, int linkno)uint32_t break_offset =0x4 ;/* hw workaround */ uint32_t addr; +/* config table lists 2 entries per hub link */ +if (linkno >= (master->n_links /2 )) +return -ENODEV ; +
master->n_links should represent the actual number of links, rather than reflect what's in the config table.
[besides, don't we do the / 2 during the config table parse anyway?]
drivers/fsi/fsi-core.c static int fsi_master_break(struct fsi_master *master, int link) · line 660
Quoted 12 lines
drivers/fsi/fsi-core.c +5
-0command =FSI_BREAK ; addr = (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; return fsi_slave_write(hub->slave, addr + break_offset, &command,@@ -641,6 +653,28 @@ static int fsi_master_break(struct fsi_master *master, int link)void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) { +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +/* Avoid nested error handling */ +if (test_and_set_bit (FSI_IN_ERR_CLEANUP , &fsi_state)) +return ;
Do we have any other bits of state to represent? If not, just use a plain atomic_t rather than a set of flags.
Cheers,
Jeremy
Re: [PATCH linux dev-4.7 v2 6/7] drivers/fsi: Cleanup bus errors
Quoted 6 lines · Jeremy Kerr
Hi Chris,
Quoted 4 lines
drivers/fsi/fsi-core.c +0
-0@@ -255,6 +263,10 @@ int hub_master_break(struct fsi_master *master, int linkno)uint32_t break_offset =0x4 ;/* hw workaround */ uint32_t addr;
Quoted 8 lines
drivers/fsi/fsi-core.c int hub_master_break(struct fsi_master *master, int linkno) · line 269
Quoted 4 lines
drivers/fsi/fsi-core.c +4
-0+/* config table lists 2 entries per hub link */ +if (linkno >= (master->n_links /2 )) +return -ENODEV ; +
master->n_linksshould represent the actual number of links, rather than reflect what's in the config table.[besides, don't we do the / 2 during the config table parse anyway?]
Hi Jeremy,
Yes that's true, its set in scan so no need for the /2 here - will fix.
Quoted 5 lines
Quoted 5 lines
drivers/fsi/fsi-core.c +0
-0command =FSI_BREAK ; addr = (linkno *FSI_MASTER_HUB_LINK_SIZE ) + hub->base; return fsi_slave_write(hub->slave, addr + break_offset, &command,@@ -641,6 +653,28 @@ static int fsi_master_break(struct fsi_master *master, int link)
Quoted 9 lines
drivers/fsi/fsi-core.c static int fsi_master_break(struct fsi_master *master, int link) · line 660
Quoted 7 lines
drivers/fsi/fsi-core.c +5
-0void fsi_master_handle_error (struct fsi_master *master,uint32_t addr) { +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +/* Avoid nested error handling */ +if (test_and_set_bit (FSI_IN_ERR_CLEANUP , &fsi_state)) +return ;Do we have any other bits of state to represent? If not, just use a plain
atomic_trather than a set of flags.
No others at this point, will change to an atomic_t
Thanks,
Chris
Quoted 5 lines
Cheers,
Jeremy
PATCH v2 7/7 tools/testing/selftests: Add fsi command line tool
In reply to Christopher BosticAdd command line tool to read/write CFAMs via the slave 'raw' sysfs file.
--- tools/testing/selftests/fsi/fsitest.c | 163 ++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 tools/testing/selftests/fsi/fsitest.c
tools/testing/selftests/fsi/fsitest.c new file +163 -0
@@ -0,0 +1,163 @@ +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <unistd.h> +#include <err.h> +#include <errno.h> +#include <stdlib.h> +#include <stdint.h> +#include <getopt.h> +#include <string.h> + +int testread (int fd,uint32_t addr,uint32_t *value) +{ +int rc; + +lseek (fd, addr,SEEK_SET ); + rc =read (fd, value,4 ); +if (rc >=0 ) + rc =0 ; + +return rc; +} + +int testwrite (int fd,uint32_t addr,uint32_t value) +{ +int rc; + +lseek (fd, addr,SEEK_SET ); + rc =write (fd, &value,4 ); +if (rc >=0 ) + rc =0 ; + +return rc; +} + +#define NUM_WRITES 6 +#define NUM_READS 9 +#define NUM_HUB_READS 9 + +int main (int argc,char **argv) +{ +int rc =0 ; +int i, fd, option; +int skip_write =0 ; +int verbose =0 ; +int hub =0 ; +char path[64 ] ="/sys/bus/platform/devices/fsi-master/slave@00:00/raw" ; +uint32_t value; +const uint32_t write_addresses[NUM_WRITES ] = { +0x800 , +0x818 , +0x35D0 , +0x100800 , +0x100818 , +0x1035D0 , + }; +const uint32_t addresses[NUM_READS ] = { +0x800 ,/* smode */ +0x818 ,/* si1m */ +0x81C ,/* si1s */ +0x101C ,/* scom status */ +0x1028 ,/* scom chipid */ +0x1808 ,/* i2c mode */ +0x181C ,/* i2c status */ +0x3400 ,/* hub mmode */ +0x35D0 ,/* hub status */ + }; +const uint32_t hub_addresses[NUM_HUB_READS ] = { +0x100800 ,/* smode */ +0x100818 ,/* si1m */ +0x10081C ,/* si1s */ +0x10101C ,/* scom status */ +0x101028 ,/* scom chipid */ +0x101808 ,/* i2c mode */ +0x10181C ,/* i2c status */ +0x103400 ,/* hub mmode */ +0x1035D0 ,/* hub status */ + }; + +while ((option =getopt (argc, argv,"vsb:x" )) !=-1 ) { +switch (option) { +case 'v' : + verbose =1 ; +break ; +case 's' : + skip_write =1 ; +break ; +case 'b' : +strncpy (path, optarg,64 ); +break ; +case 'x' : + hub =1 ; +break ; +default : +printf ("unknown option\n" ); + } + } + + fd =open (path,O_RDWR ); +if (fd <0 ) { +printf ("FAILED - failed to open %s\n" , path); +return -ENODEV ; + } + +for (i =0 ; i <NUM_READS ; ++i) { + rc =testread (fd, addresses[i], &value); +if (rc) { +printf ("FAILED - failed to read %08x\n" , addresses[i]); + goto exit; + } + +if (verbose) +printf ("read %08x: %08x\n" , addresses[i], value); + } + +if (!skip_write) { +for (i =0 ; i <NUM_WRITES ; ++i) { + value =0 ; + rc =testread (fd, write_addresses[i], &value); +if (rc) { +printf ("FAILED - failed to read %08x\n" , + write_addresses[i]); + goto exit; + } + + rc =testwrite (fd, write_addresses[i], value); +if (rc) { +printf ("FAILED - failed to write %08x\n" , + write_addresses[i]); + goto exit; + } + +if (verbose) +printf ("wrote %08x: %08x\n" , + write_addresses[i], value); + } + }else if (verbose) +printf ("skipping write\n" ); + +if (hub) { +for (i =0 ; i <NUM_HUB_READS ; ++i) { + rc =testread (fd, hub_addresses[i], &value); +if (rc) { +printf ("FAILED - failed to read hub %08x\n" , + hub_addresses[i]); + goto exit; + } + +if (verbose) +printf ("read %08x: %08x\n" , hub_addresses[i], + value); + } + } + +printf ("SUCCESS\n" ); + +exit: +close (fd); + +return rc; +}
Signature · 1 line
1.8.2.2
Hi Chris,
Quoted 8 lines
Adds the FSI hub master functionality to the OpenFSI device driver. Hub master is a FSI client device driver that registers with the core and is notified when devices it wants, hub master engine and links, are discovered.
v2: Restructured to move hub into the core instead of a separate
slave device driver.
Quoted 8 lines
Christopher Bostic (7):
drivers/fsi: Add hub master scan detectdrivers/fsi: Initialize hub master
drivers/fsi: Define hub master callbacksdrivers/fsi: Move common read write ops into single functiondrivers/fsi: Add retry on bus error detectdrivers/fsi: Cleanup bus errorstools/testing/selftests: Add fsi command line tool
This changeset seems to add both the hub master, and the generic error handing. Could this be split into two series?
Cheers,
Jeremy
Quoted 18 lines · Jeremy Kerr
Hi Chris,
Quoted 8 lines
Adds the FSI hub master functionality to the OpenFSI device driver. Hub master is a FSI client device driver that registers with the core and is notified when devices it wants, hub master engine and links, are discovered.
v2: Restructured to move hub into the core instead of a separate
slave device driver.Quoted 8 lines
Christopher Bostic (7):
drivers/fsi: Add hub master scan detectdrivers/fsi: Initialize hub master
drivers/fsi: Define hub master callbacksdrivers/fsi: Move common read write ops into single functiondrivers/fsi: Add retry on bus error detectdrivers/fsi: Cleanup bus errorstools/testing/selftests: Add fsi command line tool
Quoted 2 lines
This changeset seems to add both the hub master, and the generic error handing. Could this be split into two series?
Hi Jeremy,
Sure, will split those up.
Thanks
Quoted 5 lines
Cheers,
Jeremy
Quoted 18 lines · Christopher Bostic
Adds the FSI hub master functionality to the OpenFSI device driver. Hub master is a FSI client device driver that registers with the core and is notified when devices it wants, hub master engine and links, are discovered.
v2: Restructured to move hub into the core instead of a separate
slave device driver.Christopher Bostic (7):
drivers/fsi: Add hub master scan detectdrivers/fsi: Initialize hub master
drivers/fsi: Define hub master callbacksdrivers/fsi: Move common read write ops into single functiondrivers/fsi: Add retry on bus error detectdrivers/fsi: Cleanup bus errorstools/testing/selftests: Add fsi command line tool
Quoted 3 lines
--
1.8.2.2
Do I need to respond that I tested to all commits in this series? I'll just do this one for now.
I built all patches into an image and we verified all is looking good on Witherspoon and Zaius.