All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason J. Herne" <jjherne@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org,
	pasic@linux.ibm.com, alifm@linux.ibm.com, borntraeger@de.ibm.com
Subject: Re: [Qemu-devel] [PATCH v3 01/16] s390 vfio-ccw: Add bootindex property and IPLB data
Date: Wed, 6 Mar 2019 09:55:40 -0500	[thread overview]
Message-ID: <cf5e9c71-a78a-02b1-eaa8-4c8ba5c2c8a3@linux.ibm.com> (raw)
In-Reply-To: <20190304144010.109e5ee1.cohuck@redhat.com>

On 3/4/19 8:40 AM, Cornelia Huck wrote:
> On Fri,  1 Mar 2019 13:59:21 -0500
> "Jason J. Herne" <jjherne@linux.ibm.com> wrote:
> 
>> Add bootindex property and iplb data for vfio-ccw devices. This allows us to
>> forward boot information into the bios for vfio-ccw devices.
>>
>> Refactor s390_get_ccw_device() to return device type. This prevents us from
>> having to use messy casting logic in several places.
>>
>> Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
>> Acked-by: Halil Pasic <pasic@linux.vnet.ibm.com>
>> ---
>>   MAINTAINERS                 |  1 +
>>   hw/s390x/ipl.c              | 39 +++++++++++++++++++++++++++++++++------
>>   hw/s390x/s390-ccw.c         |  9 +++++++++
>>   hw/vfio/ccw.c               |  2 +-
>>   include/hw/s390x/s390-ccw.h |  1 +
>>   include/hw/s390x/vfio-ccw.h | 28 ++++++++++++++++++++++++++++
>>   6 files changed, 73 insertions(+), 7 deletions(-)
>>   create mode 100644 include/hw/s390x/vfio-ccw.h
>>
> (...)
>> @@ -305,16 +306,29 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl)
>>       *timeout = cpu_to_be32(splash_time);
>>   }
>>   
>> -static CcwDevice *s390_get_ccw_device(DeviceState *dev_st)
>> +#define CCW_DEVTYPE_NONE    0x00
>> +#define CCW_DEVTYPE_VIRTIO  0x01
>> +#define CCW_DEVTYPE_SCSI    0x02
>> +#define CCW_DEVTYPE_VFIO    0x03
> 
> Hm, how would the code look if you introduced a CCW_DEVTYPE_VIRTIO_NET
> or so? You could use the simply set the netboot flag in
> get_initial_iplb and fall through to the handling of
> CCW_DEVTYPE_VIRTIO...
> 
>> +
>> +static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int* devtype)
> 
> s/int* devtype/int *devtype/
> 
>>   {
>>       CcwDevice *ccw_dev = NULL;
>>   
>> +    *devtype = CCW_DEVTYPE_NONE;
>> +
>>       if (dev_st) {
>>           VirtioCcwDevice *virtio_ccw_dev = (VirtioCcwDevice *)
>>               object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent),
>>                                   TYPE_VIRTIO_CCW_DEVICE);
>> +        VFIOCCWDevice *vfio_ccw_dev = (VFIOCCWDevice *)
>> +            object_dynamic_cast(OBJECT(dev_st), TYPE_VFIO_CCW);
>>           if (virtio_ccw_dev) {
>>               ccw_dev = CCW_DEVICE(virtio_ccw_dev);
>> +            *devtype = CCW_DEVTYPE_VIRTIO;
>> +        } else if (vfio_ccw_dev) {
>> +            ccw_dev = CCW_DEVICE(vfio_ccw_dev);
>> +            *devtype = CCW_DEVTYPE_VFIO;
>>           } else {
>>               SCSIDevice *sd = (SCSIDevice *)
>>                   object_dynamic_cast(OBJECT(dev_st),
>> @@ -327,6 +341,7 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st)
>>   
>>                   ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw),
>>                                                              TYPE_CCW_DEVICE);
>> +                *devtype = CCW_DEVTYPE_SCSI;
>>               }
>>           }
>>       }
>> @@ -337,10 +352,11 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
>>   {
>>       DeviceState *dev_st;
>>       CcwDevice *ccw_dev = NULL;
>> +    int devtype;
>>   
>>       dev_st = get_boot_device(0);
>>       if (dev_st) {
>> -        ccw_dev = s390_get_ccw_device(dev_st);
>> +        ccw_dev = s390_get_ccw_device(dev_st, &devtype);
>>       }
>>   
>>       /*
>> @@ -349,8 +365,10 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
>>       if (ccw_dev) {
>>           SCSIDevice *sd = (SCSIDevice *) object_dynamic_cast(OBJECT(dev_st),
>>                                                               TYPE_SCSI_DEVICE);
>> +        VirtIONet *vn;
> 
> I think you could get rid of this variable with my suggestion from
> above.
> 
>>   
>> -        if (sd) {
>> +        switch (devtype) {
>> +        case CCW_DEVTYPE_SCSI:
> 
> Move obtaining sd into this case?
> 
>>               ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN);
>>               ipl->iplb.blk0_len =
>>                   cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN - S390_IPLB_HEADER_LEN);
>> @@ -360,8 +378,15 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
>>               ipl->iplb.scsi.channel = cpu_to_be16(sd->channel);
>>               ipl->iplb.scsi.devno = cpu_to_be16(ccw_dev->sch->devno);
>>               ipl->iplb.scsi.ssid = ccw_dev->sch->ssid & 3;
>> -        } else {
>> -            VirtIONet *vn = (VirtIONet *) object_dynamic_cast(OBJECT(dev_st),
>> +            break;
>> +        case CCW_DEVTYPE_VFIO:
>> +            ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_CCW_LEN);
>> +            ipl->iplb.pbt = S390_IPL_TYPE_CCW;
>> +            ipl->iplb.ccw.devno = cpu_to_be16(ccw_dev->sch->devno);
>> +            ipl->iplb.ccw.ssid = ccw_dev->sch->ssid & 3;
>> +            break;
>> +        case CCW_DEVTYPE_VIRTIO:
>> +            vn = (VirtIONet *) object_dynamic_cast(OBJECT(dev_st),
>>                                                                 TYPE_VIRTIO_NET);
>>   
>>               ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_CCW_LEN);
>> @@ -374,6 +399,7 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
>>               if (vn) {
>>                   ipl->netboot = true;
>>               }
>> +            break;
>>           }
>>   
>>           if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) {
>> @@ -518,6 +544,7 @@ IplParameterBlock *s390_ipl_get_iplb(void)
>>   void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type)
>>   {
>>       S390IPLState *ipl = get_ipl_device();
>> +    int devtype;
>>   
>>       if (reset_type == S390_RESET_EXTERNAL || reset_type == S390_RESET_REIPL) {
>>           /* use CPU 0 for full resets */
>> @@ -532,7 +559,7 @@ void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type)
>>           !ipl->netboot &&
>>           ipl->iplb.pbt == S390_IPL_TYPE_CCW &&
>>           is_virtio_scsi_device(&ipl->iplb)) {
>> -        CcwDevice *ccw_dev = s390_get_ccw_device(get_boot_device(0));
>> +        CcwDevice *ccw_dev = s390_get_ccw_device(get_boot_device(0), &devtype);
> 
> It feels wrong to have a variable that is not used later... what about
> either
> - making s390_get_ccw_device() capable of handling a NULL second
>    parameter, or
> - (what I think would be nicer) passing in the devtype as an optional
>    parameter to gen_initial_iplb() so you don't need to do the casting
>    dance twice?
> 

I'm with you on everything suggested for this patch except this last item. I'm not sure 
what you are suggesting here. I can easily visualize passing NULL for devtype when we want 
to ignore it but I'm not sure what you mean by 'optional parameter'

>>   
>>           if (ccw_dev &&
>>               cpu_to_be16(ccw_dev->sch->devno) == ipl->iplb.ccw.devno &&
> 
> 


-- 
-- Jason J. Herne (jjherne@linux.ibm.com)

  reply	other threads:[~2019-03-06 14:55 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 18:59 [Qemu-devel] [PATCH v3 00/16] s390: vfio-ccw dasd ipl support Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 01/16] s390 vfio-ccw: Add bootindex property and IPLB data Jason J. Herne
2019-03-04 13:40   ` Cornelia Huck
2019-03-06 14:55     ` Jason J. Herne [this message]
2019-03-06 15:27       ` Cornelia Huck
2019-03-06 16:28         ` Jason J. Herne
2019-03-06 17:31           ` Cornelia Huck
2019-03-04 16:09   ` Farhan Ali
2019-03-06 15:16     ` Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 02/16] s390-bios: decouple cio setup from virtio Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 03/16] s390-bios: decouple common boot logic " Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 04/16] s390-bios: Extend find_dev() for non-virtio devices Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 05/16] s390-bios: Factor finding boot device out of virtio code path Jason J. Herne
2019-03-04 17:07   ` Cornelia Huck
2019-03-04 19:26     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-03-05  8:38       ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 06/16] s390-bios: Clean up cio.h Jason J. Herne
2019-03-04 17:23   ` Cornelia Huck
2019-03-05  5:51   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-03-06 18:42     ` Jason J. Herne
2019-03-07  8:08       ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 07/16] s390-bios: Decouple channel i/o logic from virtio Jason J. Herne
2019-03-04 17:28   ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 08/16] s390-bios: Map low core memory Jason J. Herne
2019-03-04 17:46   ` Cornelia Huck
2019-03-05  6:27   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-03-06 19:28     ` Jason J. Herne
2019-03-07  8:11       ` Cornelia Huck
2019-03-06 19:42     ` Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 09/16] s390-bios: ptr2u32 and u32toptr Jason J. Herne
2019-03-05  7:22   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-03-07 14:11     ` Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 10/16] s390-bios: Support for running format-0/1 channel programs Jason J. Herne
2019-03-04 18:25   ` Cornelia Huck
2019-03-07 19:25     ` Jason J. Herne
2019-03-08  9:19       ` Cornelia Huck
2019-03-05  7:32   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 11/16] s390-bios: cio error handling Jason J. Herne
2019-03-04 18:35   ` Cornelia Huck
2019-03-07 19:31     ` Jason J. Herne
2019-03-08  9:21       ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 12/16] s390-bios: Refactor virtio to run channel programs via cio Jason J. Herne
2019-03-05 12:30   ` Cornelia Huck
2019-03-07 15:09     ` Jason J. Herne
2019-03-07 15:37       ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 13/16] s390-bios: Use control unit type to determine boot method Jason J. Herne
2019-03-05 12:27   ` Cornelia Huck
2019-03-07 16:27     ` Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 14/16] s390-bios: Add channel command codes/structs needed for dasd-ipl Jason J. Herne
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 15/16] s390-bios: Support booting from real dasd device Jason J. Herne
2019-03-05 13:03   ` Cornelia Huck
2019-03-01 18:59 ` [Qemu-devel] [PATCH v3 16/16] s390-bios: dasd-ipl: Use control unit type to customize error data Jason J. Herne
2019-03-04 17:02   ` [Qemu-devel] [qemu-s390x] " Eric Farman
2019-03-07 14:38     ` Jason J. Herne
2019-03-07 18:15       ` Eric Farman
2019-03-07 18:26         ` Jason J. Herne
2019-03-04 17:51   ` [Qemu-devel] " Cornelia Huck
2019-03-01 21:26 ` [Qemu-devel] [PATCH v3 00/16] s390: vfio-ccw dasd ipl support no-reply
2019-03-01 21:30 ` no-reply
2019-03-01 21:35 ` no-reply
2019-03-01 21:38 ` no-reply
2019-03-01 21:45 ` no-reply
2019-03-01 21:49 ` no-reply
2019-03-04 16:24 ` Cornelia Huck
2019-03-04 17:53   ` Christian Borntraeger
2019-03-04 17:28 ` no-reply
2019-03-04 17:51 ` no-reply
2019-03-05  5:55 ` no-reply
2019-03-05  7:30 ` no-reply
2019-03-05  8:42 ` no-reply
2019-03-05 13:08 ` no-reply

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=cf5e9c71-a78a-02b1-eaa8-4c8ba5c2c8a3@linux.ibm.com \
    --to=jjherne@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.