Fix Xilinx SystemACE driver to handle empty CF slot
PATCH 1/1 Fix Xilinx SystemACE driver to handle empty CF slot
From: Grant Likely <[email protected]>
The SystemACE driver does not handle an empty CF slot gracefully. An empty CF slot ends up hanging the system. This patch adds a check for the CF state and stops trying to process requests if the slot is empty.
---
drivers/block/xsysace.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
drivers/block/xsysace.c +22 -0
@@ -489,6 +489,28 @@ static void ace_fsm_dostate(struct ace_device *ace) ace->fsm_state, ace->id_req_count);#endif +/* Verify that there is actually a CF in the slot. If not, then +* bail out back to the idle state and wake up all the waiters */ + status =ace_in32 (ace,ACE_STATUS ); +if ((status &ACE_STATUS_CFDETECT ) ==0 ) { + ace->fsm_state =ACE_FSM_STATE_IDLE ; + ace->media_change =1 ; +set_capacity (ace->gd,0 ); +dev_info (ace->dev,"No CF in slot\n" ); + +/* Drop all pending requests */ +while ((req =elv_next_request (ace->queue)) !=NULL ) +end_request (req,0 ); + +/* Drop back to IDLE state and notify waiters */ + ace->fsm_state =ACE_FSM_STATE_IDLE ; + ace->id_result = -EIO ; +while (ace->id_req_count) { +complete (&ace->id_completion); + ace->id_req_count--; + } + } +switch (ace->fsm_state) {case ACE_FSM_STATE_IDLE :/* See if there is anything to do */
Oops, sorry Jens. I forgot to CC: you on this patch.
g.
On Sat, Feb 28, 2009 at 1:46 PM, Grant Likely <[email protected]> w= rote:
Quoted 21 lines
From: Grant Likely <[email protected]>
The SystemACE driver does not handle an empty CF slot gracefully. =A0An empty CF slot ends up hanging the system. =A0This patch adds a check for the CF state and stops trying to process requests if the slot is empty.
Signed-off-by Grant Likely <[email protected]>---
=A0drivers/block/xsysace.c | =A0 22 ++++++++++++++++++++++ =A01 files changed, 22 insertions(+), 0 deletions(-)
drivers/block/xsysace.c +0
-0@@ -489,6 +489,28 @@ static void ace_fsm_dostate(struct ace_device *ace) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ace->fsm_state, ace->id_req_count);=A0#endif
Quoted 1 line
+ =A0 =A0 =A0 /* Verify that there is actually a CF in the slot. =A0If no=
t, then
Quoted 1 line
+ =A0 =A0 =A0 =A0* bail out back to the idle state and wake up all the wa=
iters */
Quoted 9 lines
+ =A0 =A0 =A0 status =3D
ace_in32(ace, ACE_STATUS);
+ =A0 =A0 =A0 if ((status &ACE_STATUS_CFDETECT) =3D=3D 0) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0ace->fsm_state=3DACE_FSM_STATE_IDLE;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0ace->media_change=3D 1;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0set_capacity(ace->gd, 0);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_info(ace->dev, "No CF in slot\n"); +
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Drop all pending requests */
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 while ((req =3D elv_next_request(ace->queue=
)) !=3D NULL)
Quoted 3 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
end_request(req, 0); +
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Drop back to IDLE state and notify waite=
rs */
Quoted 4 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0
ace->fsm_state=3DACE_FSM_STATE_IDLE;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0ace->id_result=3D-EIO;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (ace->id_req_count) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 complete(&ace->id_completio=
n);
Quoted 9 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ace->id_req_count--;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+ =A0 =A0 =A0 }
+
=A0 =A0 =A0 =A0switch (ace->fsm_state) {
=A0 =A0 =A0 =A0caseACE_FSM_STATE_IDLE:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* See if there is anything to do */
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Quoted 10 lines · Grant Likely
Oops, sorry Jens. I forgot to CC: you on this patch.
g.
Quoted 5 lines · Grant Likely
From: Grant Likely <[email protected]>
The SystemACE driver does not handle an empty CF slot gracefully. An empty CF slot ends up hanging the system. This patch adds a check for the CF state and stops trying to process requests if the slot is empty.
So with patches like this, it's always nice to know what your target is. Do you want this in .29, or just queued up for .30? It's not always easy to judge the urgency of such patches :-)
Also, I note that you are using end_request() throughout the driver. We really want to get away from that, you should be using blk_end_request() as that will handle full requests and not just segment-by-segment. No worries for this patch, but you may want to consider that for a future patch.
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
Quoted 1 line · Grant Likely
Quoted 1 line
The SystemACE driver does not handle an empty CF slot gracefully. =A0A=
n
Quoted 1 line
Quoted 1 line
Quoted 1 line
empty CF slot ends up hanging the system. =A0This patch adds a check f=
or
Quoted 1 line
Quoted 1 line
Quoted 1 line
the CF state and stops trying to process requests if the slot is empty=
.
Quoted 4 lines
So with patches like this, it's always nice to know what your target is. Do you want this in .29, or just queued up for .30? It's not always easy to judge the urgency of such patches :-)
The driver completely falls down and hangs the system if the CF slot is empty, so I would like to get it into .29. On the other hand, it has been a long standing issue, so if merging it will raise any eyebrows then I'm okay to wait for .30.
Quoted 5 lines
Also, I note that you are using
end_request()throughout the driver. We really want to get away from that, you should be usingblk_end_request()as that will handle full requests and not just segment-by-segment. No worries for this patch, but you may want to consider that for a future patch.
Okay, will do.
Thanks,
g.
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.