qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: "Jason J. Herne" <jjherne@linux.ibm.com>,
	qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
	pasic@linux.ibm.com, bjsdjshi@linux.ibm.com
Subject: Re: [Qemu-devel] [qemu-s390x] [RFC 10/15] s390-bios: Support for running format-0/1 channel programs
Date: Fri, 6 Jul 2018 12:25:09 +0200	[thread overview]
Message-ID: <74a23a35-f083-23d5-9364-906dcee840c0@de.ibm.com> (raw)
In-Reply-To: <398b3770-75a4-8880-4cb9-a75770fb974b@de.ibm.com>



On 07/06/2018 09:04 AM, Christian Borntraeger wrote:
> 
> 
> On 07/05/2018 07:25 PM, Jason J. Herne wrote:
>> From: "Jason J. Herne" <jjherne@linux.vnet.ibm.com>
>>
>> Add struct for format-0 ccws. Support executing format-0 channel
>> programs and waiting for their completion before continuing execution.
>> This will be used for real dasd ipl.
>>
>> Add cu_type() to channel io library. This will be used to query control
>> unit type which is used to determine if we are booting a virtio device or a
>> real dasd device.
>>
>> Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
>> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
>> ---
>>  pc-bios/s390-ccw/cio.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  pc-bios/s390-ccw/cio.h |  25 +++++++++-
>>  2 files changed, 151 insertions(+), 1 deletion(-)
>>
>> diff --git a/pc-bios/s390-ccw/cio.c b/pc-bios/s390-ccw/cio.c
>> index 095f79b..f440380 100644
>> --- a/pc-bios/s390-ccw/cio.c
>> +++ b/pc-bios/s390-ccw/cio.c
>> @@ -10,6 +10,7 @@
>>  
>>  #include "libc.h"
>>  #include "s390-ccw.h"
>> +#include "s390-arch.h"
>>  #include "cio.h"
>>  
>>  static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
>> @@ -39,3 +40,129 @@ void enable_subchannel(SubChannelId schid)
>>      schib.pmcw.ena = 1;
>>      msch(schid, &schib);
>>  }
>> +
>> +__u16 cu_type(SubChannelId schid)
>> +{
>> +    Ccw1 senseIdCcw;
>> +    SenseId senseData;
>> +
>> +    senseIdCcw.cmd_code = CCW_CMD_SENSE_ID;
>> +    senseIdCcw.cda = ptr2u32(&senseData);
>> +    senseIdCcw.count = sizeof(senseData);
>> +
>> +    if (do_cio(schid, ptr2u32(&senseIdCcw), CCW_FMT1)) {
>> +        panic("Failed to run SenseID CCw\n");
>> +    }
>> +
>> +    return senseData.cu_type;
>> +}
>> +
>> +static bool irb_error(Irb *irb)
>> +{
>> +    /* We have to ignore Incorrect Length (cstat == 0x40) indicators because
>> +     * real devices expect a 24 byte SenseID  buffer, and virtio devices expect
>> +     * a much larger buffer. Neither device type can tolerate a buffer size
>> +     * different from what they expect so they set this indicator.
>> +     */
>> +    if (irb->scsw.cstat != 0x00 && irb->scsw.cstat != 0x40) {
>> +        return true;
>> +    }
>> +    return irb->scsw.dstat != 0xc;
>> +}
>> +
>> +/* Executes a channel program at a given subchannel. The request to run the
>> + * channel program is sent to the subchannel, we then wait for the interrupt
>> + * singaling completion of the I/O operation(s) perfomed by the channel
>> + * program. Lastly we verify that the i/o operation completed without error and
>> + * that the interrupt we received was for the subchannel used to run the
>> + * channel program.
>> + *
>> + * Note: This function assumes it is running in an environment where no other
>> + * cpus are generating or receiving I/O interrupts. So either run it in a
>> + * single-cpu environment or make sure all other cpus are not doing I/O and
>> + * have I/O interrupts masked off.
>> + */
>> +int do_cio(SubChannelId schid, uint32_t ccw_addr, int fmt)
>> +{
>> +    Ccw0 *this_ccw, *prev_ccw;
>> +    CmdOrb orb = {};
>> +    Irb irb = {};
>> +    int rc;
>> +
>> +    IPL_assert(fmt == 0 || fmt == 1, "Invalid ccw format");
>> +
>> +    /* ccw_addr must be <= 24 bits and point to at least one whole ccw. */
>> +    if (fmt == 0) {
>> +        IPL_assert(ccw_addr <= 0xFFFFFF - 8, "Invalid ccw address");
>> +    }
>> +
>> +    orb.fmt = fmt ;
>> +    orb.pfch = 1;  /* QEMU's cio implementation requires prefetch */
>> +    orb.c64 = 1;   /* QEMU's cio implementation requires 64-bit idaws */
>> +    orb.lpm = 0xFF; /* All paths allowed */
>> +    orb.cpa = ccw_addr;
>> +
>> +    rc = ssch(schid, &orb);
>> +    if (rc) {
>> +        print_int("ssch failed with rc=", rc);
>> +        return rc;
>> +    }
>> +
>> +    await_io_int(schid.sch_no);
>> +
>> +    /* Clear read */
>> +    rc = tsch(schid, &irb);
>> +    if (rc) {
>> +        print_int("tsch failed with rc=", rc);
>> +        return rc;
>> +    }
>> +
>> +    if (irb_error(&irb)) {
>> +        this_ccw = u32toptr(irb.scsw.cpa);
>> +        prev_ccw = u32toptr(irb.scsw.cpa - 8);
>> +
>> +        print_int("irb_error: cstat=", irb.scsw.cstat);
>> +        print_int("           dstat=", irb.scsw.dstat);
>> +        print_int("           cpa=", irb.scsw.cpa);
>> +        print_int("           prev_ccw=", *((uint64_t *)prev_ccw));
>> +        print_int("           this_ccw=", *((uint64_t *)this_ccw));
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +void await_io_int(uint16_t sch_no)
>> +{
>> +    /*
>> +     * wait_psw and ctl6 must be static to avoid stack allocation as gcc cannot
>> +     * align stack variables. The stctg, lctlg and lpswe instructions require
>> +     * that their operands be aligned on an 8-byte boundary.
>> +    */
>> +    static uint64_t ctl6 __attribute__((__aligned__(8)));
>> +    static PSW wait_psw;
>> +
>> +    /* PSW to load when I/O interrupt happens */
>> +    lowcore->io_new_psw.mask = PSW_MASK_ZMODE;
>> +    lowcore->io_new_psw.addr = (uint64_t)&&IOIntWakeup; /* Wake-up address */
>> +
>> +    /* Enable io interrupts subclass mask */
>> +    asm volatile("stctg 6,6,%0" : "=S" (ctl6) : : "memory");
> 
> For some reason the sles12 gcc does not like this. Can you use the "Q" constraint 
> everywhere instead of "S".
> 
Or better use "QS" and "=QS"

  reply	other threads:[~2018-07-06 10:25 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 17:25 [Qemu-devel] [RFC 00/15] s390: vfio-ccw dasd ipl support Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 01/15] s390 vfio-ccw: Add bootindex property and IPLB data Jason J. Herne
2018-07-06  7:33   ` Cornelia Huck
2018-07-11 10:33   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-07-05 17:25 ` [Qemu-devel] [RFC 02/15] s390-bios: decouple cio setup from virtio Jason J. Herne
2018-07-06  7:35   ` Cornelia Huck
2018-07-05 17:25 ` [Qemu-devel] [RFC 03/15] s390-bios: decouple common boot logic " Jason J. Herne
2018-07-11 10:41   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-07-05 17:25 ` [Qemu-devel] [RFC 04/15] s390-bios: Extend find_dev() for non-virtio devices Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 05/15] s390-bios: Factor finding boot device out of virtio code path Jason J. Herne
2018-07-10  6:53   ` Christian Borntraeger
2018-07-05 17:25 ` [Qemu-devel] [RFC 06/15] s390-bios: Clean up cio.h Jason J. Herne
2018-07-17 18:15   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-07-17 18:22     ` Richard Henderson
2018-07-05 17:25 ` [Qemu-devel] [RFC 07/15] s390-bios: Decouple channel i/o logic from virtio Jason J. Herne
2018-07-06  6:48   ` Christian Borntraeger
2018-07-05 17:25 ` [Qemu-devel] [RFC 08/15] s390-bios: Map low core memory Jason J. Herne
2018-07-06  6:46   ` Christian Borntraeger
2018-07-06  7:42   ` Cornelia Huck
2018-07-17 18:10   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-09-10 14:17     ` Jason J. Herne
2018-09-13  5:25       ` Thomas Huth
2018-09-13 14:39         ` Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 09/15] s390-bios: ptr2u32 and u32toptr Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 10/15] s390-bios: Support for running format-0/1 channel programs Jason J. Herne
2018-07-06  7:04   ` Christian Borntraeger
2018-07-06 10:25     ` Christian Borntraeger [this message]
2018-07-06  8:03   ` Cornelia Huck
2018-07-06 11:42     ` [Qemu-devel] [qemu-s390x] " Halil Pasic
2018-07-06 12:26       ` Cornelia Huck
2018-07-06 13:03         ` Halil Pasic
2018-07-06 13:15           ` Cornelia Huck
2018-07-06 13:33             ` Halil Pasic
2018-07-06 14:40               ` Jason J. Herne
2018-07-06 14:35     ` [Qemu-devel] " Jason J. Herne
2018-07-17 10:02       ` Cornelia Huck
2018-07-09  7:18   ` Christian Borntraeger
2018-07-09 10:51   ` Christian Borntraeger
2018-07-05 17:25 ` [Qemu-devel] [RFC 11/15] s390-bios: Refactor virtio to run channel programs via cio Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 12/15] s390-bios: Use control unit type to determine boot method Jason J. Herne
2018-07-17 18:25   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-07-05 17:25 ` [Qemu-devel] [RFC 13/15] s390-bios: Add channel command codes/structs needed for dasd-ipl Jason J. Herne
2018-07-05 17:25 ` [Qemu-devel] [RFC 14/15] s390-bios: Support booting from real dasd device Jason J. Herne
2018-07-17 20:43   ` [Qemu-devel] [qemu-s390x] " David Hildenbrand
2018-07-18  7:40     ` Cornelia Huck
2018-07-18  7:51       ` David Hildenbrand
2018-07-18 10:55       ` Halil Pasic
2018-07-18 11:35         ` Cornelia Huck
2018-07-18 11:47           ` Halil Pasic
2018-07-18 11:44   ` [Qemu-devel] " Halil Pasic
2018-07-05 17:25 ` [Qemu-devel] [RFC 15/15] s390-bios: Use sense ccw to ensure consistent device state at boot time Jason J. Herne
2018-07-06 10:08   ` Cornelia Huck
2018-07-06 14:45     ` Jason J. Herne
2018-07-06 22:20   ` Halil Pasic
2018-07-05 18:32 ` [Qemu-devel] [RFC 00/15] s390: vfio-ccw dasd ipl support no-reply
2018-07-06  6:42 ` Cornelia Huck
2018-08-15 11:48 ` Cornelia Huck
2018-08-21 19:31   ` Jason J. Herne
2018-08-22  7:46     ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74a23a35-f083-23d5-9364-906dcee840c0@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=bjsdjshi@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=jjherne@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).