Skip to contentSkip to conversation

cio: fix stsch_reset.

S390 Chuck Ebbert 4 participants 4 messages Dec 31, 2006 – Jan 8, 2007

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <20061228103925.GB6270@skybase>

Quoted 10 lines · Martin Schwidefsky
(quoted diff) +2 -1
@@ -881,10 +880,18 @@ static void cio_reset_pgm_check_handler(
 static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
 {
      int rc;
+     register struct subchannel_id reg1 asm ("1") = schid;
 
      pgm_check_occured = 0;
      s390_reset_pgm_handler = cio_reset_pgm_check_handler;
-     rc = stsch(schid, addr);
+

Review static void cio_reset_pgm_check_handler( · line 897

Quoted 10 lines
(quoted diff) +7 -0
+     asm volatile(
+             "       stsch   0(%2)\n"
+             "       ipm     %0\n"
+             "       srl     %0,28"
+             : "=d" (rc)
+             : "d" (reg1), "a" (addr), "m" (*addr) : "memory", "cc");
+
      s390_reset_pgm_handler = NULL;
      if (pgm_check_occured)
              return -EIO;

Can't you just put a barrier() before the stsch() call?

Signature · 1 line
MBTI: IXTP
#1 lore raw
Quoted 15 lines · Chuck Ebbert
Quoted 15 lines
(quoted diff) +7 -1
@@ -881,10 +880,18 @@ static void cio_reset_pgm_check_handler(
 static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
 {
      int rc;
+     register struct subchannel_id reg1 asm ("1") = schid;
 
      pgm_check_occured = 0;
      s390_reset_pgm_handler = cio_reset_pgm_check_handler;
-     rc = stsch(schid, addr);
+
+     asm volatile(
+             "       stsch   0(%2)\n"
+             "       ipm     %0\n"
+             "       srl     %0,28"
+             : "=d" (rc)
Quoted 8 lines

Review static void cio_reset_pgm_check_handler( · line 897

Quoted 5 lines
(quoted diff) +2 -0
+             : "d" (reg1), "a" (addr), "m" (*addr) : "memory", "cc");
+
      s390_reset_pgm_handler = NULL;
      if (pgm_check_occured)
              return -EIO;

Can't you just put a barrier() before the stsch() call?

You mean after. We have to prevent the sequence
1) load pgm_check_occured,
2) stsch and the execution of cio_reset_pgm_check_handler
3) use of the the value loaded in 1)
A barrier before 2) forces a reload of pgm_check_occured but it does not force the reload to be before the stsch call.

But the basic idea is valid. The standard stsch() inline followed by a barrier() is equivalent to the new inline assembly.

Signature · 8 lines
blue skies,
  Martin.

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

"Reality continues to ruin my life." - Calvin.
#2 lore raw
In reply to Chuck Ebbert
Quoted 19 lines · Chuck Ebbert

In-Reply-To: <20061228103925.GB6270@skybase>

Quoted 15 lines · Martin Schwidefsky
(quoted diff) +7 -1
@@ -881,10 +880,18 @@ static void cio_reset_pgm_check_handler(
 static int stsch_reset(struct subchannel_id schid, volatile struct schib *addr)
 {
      int rc;
+     register struct subchannel_id reg1 asm ("1") = schid;
 
      pgm_check_occured = 0;
      s390_reset_pgm_handler = cio_reset_pgm_check_handler;
-     rc = stsch(schid, addr);
+
+     asm volatile(
+             "       stsch   0(%2)\n"
+             "       ipm     %0\n"
+             "       srl     %0,28"
+             : "=d" (rc)
Quoted 8 lines

Review static void cio_reset_pgm_check_handler( · line 897

Quoted 5 lines
(quoted diff) +2 -0
+             : "d" (reg1), "a" (addr), "m" (*addr) : "memory", "cc");
+
      s390_reset_pgm_handler = NULL;
      if (pgm_check_occured)
              return -EIO;

Can't you just put a barrier() before the stsch() call?

Yes, that would work too and would look much nicer.

I think we should change the reset program check handler, so that it searches the exception tables. At least for in-kernel addresses that should work. For addresses within modules this might cause deadlocks, since the module code takes spinlocks and we are in a context where we just killed all cpus not knowing what they executed... Hmm..

#3 lore raw

[email protected] wrote on 12/31/2006 01:22:03 PM:

Quoted 22 lines · Chuck Ebbert
Quoted 6 lines

In-Reply-To: <20061228103925.GB6270@skybase>

Review static void cio_reset_pgm_check_handler( · line 880

Quoted 2 lines · Martin Schwidefsky
(quoted diff) +0 -0
@@ -881,10 +880,18 @@ static void cio_reset_pgm_check_handler(
 static int stsch_reset(struct subchannel_id schid, volatile

struct schib *addr)

Quoted 14 lines
Quoted 14 lines
(quoted diff) +8 -1
 {
      int rc;
+     register struct subchannel_id reg1 asm ("1") = schid;
 
      pgm_check_occured = 0;
      s390_reset_pgm_handler = cio_reset_pgm_check_handler;
-     rc = stsch(schid, addr);
+
+     asm volatile(
+             "       stsch   0(%2)\n"
+             "       ipm     %0\n"
+             "       srl     %0,28"
+             : "=d" (rc)
+             : "d" (reg1), "a" (addr), "m" (*addr) : "memory",

"cc");

Quoted 11 lines
Quoted 7 lines

Review static void cio_reset_pgm_check_handler( · line 897

Quoted 4 lines
(quoted diff) +1 -0
+
      s390_reset_pgm_handler = NULL;
      if (pgm_check_occured)
              return -EIO;

Can't you just put a barrier() before the stsch() call?

Yes, that would work too and would look much nicer.

I think we should change the reset program check handler, so that it

searches

Quoted 1 line

the exception tables.

I think that this is really overkill, since having program checks in the reset case will be VERY rare and stsch will probably the only case. I would do that only, if we have a component, which needs that.

And I assume, that this will never happen!

Michael