Add FSI bus error recovery
v3 cover Add FSI bus error recovery
On detect of FSI bus errors attempt to clean up the links by sending a break to the slave, re-init slave ID, reset hub master bridge and break to hub links if necessary.
Christopher Bostic (2):
drivers/fsi: Move common read/write code into shared utility drivers/fsi: Cleanup and retry op on error
drivers/fsi/fsi-core.c | 215 ++--------------------------------------------- drivers/fsi/fsi-master.h | 57 ------------- 2 files changed, 5 insertions(+), 267 deletions(-)
Signature · 1 line
1.8.2.2
PATCH v3 1/2 drivers/fsi: Move common read/write code into shared utility
Move common code shared between fsi_master_gpio_read/write into send utility.
---
v2 - Separate this patch from a collection of other changes in the
v1 related patch.
--- drivers/fsi/fsi-master-gpio.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)
drivers/fsi/fsi-master-gpio.c +18 -20
@@ -354,26 +354,33 @@ 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,
@@ -381,21 +388,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 v3 1/2] drivers/fsi: Move common read/write code into shared utility
Looks good.
Quoted 84 lines · Christopher Bostic
Move common code shared between fsi_master_gpio_read/write into send utility.
Signed-off-by Christopher Bostic <[email protected]>---
v2 - Separate this patch from a collection of other changes in the
v1 related patch.--- drivers/fsi/fsi-master-gpio.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)drivers/fsi/fsi-master-gpio.c +18
-20@@ -354,26 +354,33 @@ 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,@@ -381,21 +388,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 ); }/*
Re: [PATCH linux dev-4.7 v3 1/2] drivers/fsi: Move common read/write code into shared utility
Hi Eddie,
Quoted 3 lines · Eddie James
Looks good.
Acked-by Eddie James <[email protected]>
Please don't top post on the mailing list.
Cheers,
Joel
Quoted 95 lines · Christopher Bostic
Quoted 90 lines
Move common code shared between fsi_master_gpio_read/write into send utility.
Signed-off-by Christopher Bostic <[email protected]>---
v2 - Separate this patch from a collection of other changes in the
v1 related patch.--- drivers/fsi/fsi-master-gpio.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)drivers/fsi/fsi-master-gpio.c +17
-10@@ -354,26 +354,33 @@ 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,drivers/fsi/fsi-master-gpio.c +1
-10@@ -381,21 +388,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 ); }/*
Re: [PATCH linux dev-4.7 v3 1/2] drivers/fsi: Move common read/write code into shared utility
In reply to Christopher BosticHi Chris,
Quoted 9 lines · Christopher Bostic
Move common code shared between fsi_master_gpio_read/write into send utility.
Signed-off-by Christopher Bostic <[email protected]>---
v2 - Separate this patch from a collection of other changes in the
v1 related patch.
This patch is unchanged from when I acked the previous revision. You should include the tags from your reviewers when you re-send.
Cheers,
Joel
Quoted 78 lines
--- drivers/fsi/fsi-master-gpio.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-)drivers/fsi/fsi-master-gpio.c +18
-21@@ -354,26 +354,33 @@ 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,@@ -381,21 +388,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 v3 2/2 drivers/fsi: Cleanup and retry op on error
In reply to Christopher BosticOn detect of FSI bus error clean up the bus and then retry the original operation.
v3 - Move comon read/write code into a retry utility
- Add comment on why trying again
- Change nested error check from atomic bit type to atomic_t
- loop on retry instead of duplicating the same code
--- drivers/fsi/fsi-core.c | 30 ++++++++++++++++++++++++++++++ drivers/fsi/fsi-master-gpio.c | 28 ++++++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +30 -0
@@ -42,6 +42,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)
@@ -55,6 +58,7 @@ static const int engine_page_size = 0x400;static struct task_struct *master_ipoll;static unsigned int fsi_ipoll_period_ms =100 ;struct class *hub_master_class; +static atomic_t in_err_cleanup =ATOMIC_INIT (-1 );static DEFINE_IDA (master_ida);
@@ -653,6 +657,32 @@ 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) +{ +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +if (!atomic_inc_and_test (&in_err_cleanup)) +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)); + } + +atomic_set (&in_err_cleanup,-1 ); +} +EXPORT_SYMBOL (fsi_master_handle_error); +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;
drivers/fsi/fsi-master-gpio.c +26 -2
@@ -370,6 +370,28 @@ static int send_command(struct fsi_master_gpio *master,return rc; } +static int fsi_master_gpio_send (struct fsi_master_gpio *master, +struct fsi_gpio_msg *cmd,uint8_t expected, +uint32_t addr,size_t size,void *val) +{ +static const int master_retries =2 ; +uint8_t retries; +int rc; + +/* +* In case the FSI bus is in a bad state a retry may help +* the operation to complete successfully +*/ +for (retries =0 ; retries < master_retries; retries++) { + rc =send_command (master, cmd, expected, size, val); +if (!rc) +break ; +fsi_master_handle_error (&master->master, addr); + } + +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) {
@@ -380,7 +402,8 @@ 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); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACKD , addr, + size, val); } static int fsi_master_gpio_write(struct fsi_master *_master, int link,
@@ -393,7 +416,8 @@ 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 ); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACK , addr, + size,NULL ); }/*
drivers/fsi/fsi-master.h +1 -0
@@ -85,6 +85,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 v3 2/2] drivers/fsi: Cleanup and retry op on error
Quoted 138 lines · Christopher Bostic
On detect of FSI bus error clean up the bus and then retry the original operation.
Signed-off-by Christopher Bostic <[email protected]>v3 - Move comon read/write code into a retry utility
- Add comment on why trying again
- Change nested error check from atomic bit type to
atomic_t- loop on retry instead of duplicating the same code
--- drivers/fsi/fsi-core.c | 30 ++++++++++++++++++++++++++++++ drivers/fsi/fsi-master-gpio.c | 28 ++++++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-)drivers/fsi/fsi-core.c +30
-0@@ -42,6 +42,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)@@ -55,6 +58,7 @@ static const int engine_page_size = 0x400;static struct task_struct *master_ipoll;static unsigned int fsi_ipoll_period_ms =100 ;struct class *hub_master_class; +static atomic_t in_err_cleanup =ATOMIC_INIT (-1 );static DEFINE_IDA (master_ida);@@ -653,6 +657,32 @@ 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) +{ +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +if (!atomic_inc_and_test (&in_err_cleanup)) +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)); + } + +atomic_set (&in_err_cleanup,-1 ); +} +EXPORT_SYMBOL (fsi_master_handle_error); +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;drivers/fsi/fsi-master-gpio.c +26
-2@@ -370,6 +370,28 @@ static int send_command(struct fsi_master_gpio *master,return rc; } +static int fsi_master_gpio_send (struct fsi_master_gpio *master, +struct fsi_gpio_msg *cmd,uint8_t expected, +uint32_t addr,size_t size,void *val) +{ +static const int master_retries =2 ; +uint8_t retries; +int rc; + +/* +* In case the FSI bus is in a bad state a retry may help +* the operation to complete successfully +*/ +for (retries =0 ; retries < master_retries; retries++) { + rc =send_command (master, cmd, expected, size, val); +if (!rc) +break ; +fsi_master_handle_error (&master->master, addr); + } + +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) {@@ -380,7 +402,8 @@ 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); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACKD , addr, + size, val); } static int fsi_master_gpio_write(struct fsi_master *_master, int link,@@ -393,7 +416,8 @@ 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 ); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACK , addr, + size,NULL ); }/* drivers/fsi/fsi-master.h +1
-0@@ -85,6 +85,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,
Re: [PATCH linux dev-4.7 v3 2/2] drivers/fsi: Cleanup and retry op on error
In reply to Christopher BosticQuoted 5 lines · Christopher Bostic
On detect of FSI bus error clean up the bus and then retry the original operation.
Signed-off-by Christopher Bostic <[email protected]>
Quoted 7 lines
v3 - Move comon read/write code into a retry utility
- Add comment on why trying again
- Change nested error check from atomic bit type to
atomic_t- loop on retry instead of duplicating the same code
Thanks for including the changelog. As I mentioned on the list to Eddie yesterday, the convention is to place the review comments below the --- on the next line:
Quoted 21 lines
--- drivers/fsi/fsi-core.c | 30 ++++++++++++++++++++++++++++++ drivers/fsi/fsi-master-gpio.c | 28 ++++++++++++++++++++++++++-- drivers/fsi/fsi-master.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-)drivers/fsi/fsi-core.c +3
-0@@ -42,6 +42,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)
drivers/fsi/fsi-core.c static const int engine_page_size = 0x400; · line 61
Quoted 4 lines
drivers/fsi/fsi-core.c +1
-0@@ -55,6 +58,7 @@ static const int engine_page_size = 0x400;static struct task_struct *master_ipoll;static unsigned int fsi_ipoll_period_ms =100 ;struct class *hub_master_class; +static atomic_t in_err_cleanup =ATOMIC_INIT (-1 );
As I said in my initial review:
"Instead use a atomic type for in_err_cleanup, declared in the scope of fsi_master_gpio_handle_error."
The variable should be declared inside fsi_master_handle_error.
Quoted 104 lines
drivers/fsi/fsi-core.c +26
-0static DEFINE_IDA (master_ida);@@ -653,6 +657,32 @@ 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) +{ +uint32_t smode =FSI_SLAVE_SMODE_DFLT ; + +if (!atomic_inc_and_test (&in_err_cleanup)) +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)); + } + +atomic_set (&in_err_cleanup,-1 ); +} +EXPORT_SYMBOL (fsi_master_handle_error); +static int fsi_master_scan (struct fsi_master *master) {int link, slave_id, rc;drivers/fsi/fsi-master-gpio.c +26
-2@@ -370,6 +370,28 @@ static int send_command(struct fsi_master_gpio *master,return rc; } +static int fsi_master_gpio_send (struct fsi_master_gpio *master, +struct fsi_gpio_msg *cmd,uint8_t expected, +uint32_t addr,size_t size,void *val) +{ +static const int master_retries =2 ; +uint8_t retries; +int rc; + +/* +* In case the FSI bus is in a bad state a retry may help +* the operation to complete successfully +*/ +for (retries =0 ; retries < master_retries; retries++) { + rc =send_command (master, cmd, expected, size, val); +if (!rc) +break ; +fsi_master_handle_error (&master->master, addr); + } + +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) {@@ -380,7 +402,8 @@ 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); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACKD , addr, + size, val); } static int fsi_master_gpio_write(struct fsi_master *_master, int link,@@ -393,7 +416,8 @@ 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 ); +return fsi_master_gpio_send (master, &cmd,FSI_GPIO_RESP_ACK , addr, + size,NULL ); }/* drivers/fsi/fsi-master.h +1
-1@@ -85,6 +85,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, -- 1.8.2.2