qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.vnet.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,
	Pierre Morel <pmorel@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] virtio-ccw: use ccw data stream
Date: Wed, 6 Sep 2017 14:49:52 +0200	[thread overview]
Message-ID: <b5948d5c-cc42-5a76-061d-d65eb7b6bc7c@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170906144221.76132052.cohuck@redhat.com>



On 09/06/2017 02:42 PM, Cornelia Huck wrote:
> On Tue,  5 Sep 2017 13:16:43 +0200
> Halil Pasic <pasic@linux.vnet.ibm.com> wrote:
> 
>> Replace direct access which implicitly assumes no IDA
>> or MIDA with the new ccw data stream interface which should
>> cope with these transparently in the future.
>>
>> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
>>
>> ---
>>
>> Error handling: At the moment we ignore errors reported
>> by stream ops to keep the change minimal. It might make sense
>> to change this.
> 
> Do that as an add-on patch?

That was the idea.

> 
>> ---
>>  hw/s390x/virtio-ccw.c | 158 +++++++++++++++-----------------------------------
>>  1 file changed, 48 insertions(+), 110 deletions(-)
>>
>> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
>> index b1976fdd19..72dd129a15 100644
>> --- a/hw/s390x/virtio-ccw.c
>> +++ b/hw/s390x/virtio-ccw.c
>> @@ -287,49 +287,19 @@ static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1 ccw, bool check_len,
>>          return -EFAULT;
>>      }
>>      if (is_legacy) {
>> -        linfo.queue = address_space_ldq_be(&address_space_memory, ccw.cda,
>> -                                           MEMTXATTRS_UNSPECIFIED, NULL);
>> -        linfo.align = address_space_ldl_be(&address_space_memory,
>> -                                           ccw.cda + sizeof(linfo.queue),
>> -                                           MEMTXATTRS_UNSPECIFIED,
>> -                                           NULL);
>> -        linfo.index = address_space_lduw_be(&address_space_memory,
>> -                                            ccw.cda + sizeof(linfo.queue)
>> -                                            + sizeof(linfo.align),
>> -                                            MEMTXATTRS_UNSPECIFIED,
>> -                                            NULL);
>> -        linfo.num = address_space_lduw_be(&address_space_memory,
>> -                                          ccw.cda + sizeof(linfo.queue)
>> -                                          + sizeof(linfo.align)
>> -                                          + sizeof(linfo.index),
>> -                                          MEMTXATTRS_UNSPECIFIED,
>> -                                          NULL);
>> +        ccw_dstream_read(&sch->cds, linfo);
>> +        be64_to_cpus(&linfo.queue);
>> +        be32_to_cpus(&linfo.align);
>> +        be16_to_cpus(&linfo.index);
>> +        be16_to_cpus(&linfo.num);
> 
> That's a very nice contraction :)

Thanks.

> 
>>          ret = virtio_ccw_set_vqs(sch, NULL, &linfo);
>>      } else {
>> -        info.desc = address_space_ldq_be(&address_space_memory, ccw.cda,
>> -                                           MEMTXATTRS_UNSPECIFIED, NULL);
>> -        info.index = address_space_lduw_be(&address_space_memory,
>> -                                           ccw.cda + sizeof(info.desc)
>> -                                           + sizeof(info.res0),
>> -                                           MEMTXATTRS_UNSPECIFIED, NULL);
>> -        info.num = address_space_lduw_be(&address_space_memory,
>> -                                         ccw.cda + sizeof(info.desc)
>> -                                         + sizeof(info.res0)
>> -                                         + sizeof(info.index),
>> -                                         MEMTXATTRS_UNSPECIFIED, NULL);
>> -        info.avail = address_space_ldq_be(&address_space_memory,
>> -                                          ccw.cda + sizeof(info.desc)
>> -                                          + sizeof(info.res0)
>> -                                          + sizeof(info.index)
>> -                                          + sizeof(info.num),
>> -                                          MEMTXATTRS_UNSPECIFIED, NULL);
>> -        info.used = address_space_ldq_be(&address_space_memory,
>> -                                         ccw.cda + sizeof(info.desc)
>> -                                         + sizeof(info.res0)
>> -                                         + sizeof(info.index)
>> -                                         + sizeof(info.num)
>> -                                         + sizeof(info.avail),
>> -                                         MEMTXATTRS_UNSPECIFIED, NULL);
>> +        ccw_dstream_read(&sch->cds, info);
>> +        be64_to_cpus(&info.desc);
>> +        be16_to_cpus(&info.index);
>> +        be16_to_cpus(&info.num);
>> +        be64_to_cpus(&info.avail);
>> +        be64_to_cpus(&info.used);
>>          ret = virtio_ccw_set_vqs(sch, &info, NULL);
>>      }
>>      sch->curr_status.scsw.count = 0;
> 
> (...)
> 
>> @@ -488,7 +446,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>>          } else {
>>              virtio_bus_get_vdev_config(&dev->bus, vdev->config);
>>              /* XXX config space endianness */
> 
> Unrelated: That should be fine, I guess?
> 
>> -            cpu_physical_memory_write(ccw.cda, vdev->config, len);
>> +            /* TODO we may have made -EINVAL out of -EFAULT */
> 
> Eek.
> 

Actually I wanted to send a patch which gets rid of the -EFAULT case
in sch_handle_start_func_virtual.

IMHO a program check is more appropriate here. We did the EFAULT if
cpu_physical_memory_map failed, but we don't have that any more.

>> +            ccw_dstream_write_buf(&sch->cds, vdev->config, len);
>>              sch->curr_status.scsw.count = ccw.count - len;
>>              ret = 0;
>>          }
> 
> Looks fine in general.
> 

Thanks!

  reply	other threads:[~2017-09-06 12:50 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 11:16 [Qemu-devel] [PATCH 0/5] add CCW indirect data access support Halil Pasic
2017-09-05 11:16 ` [Qemu-devel] [PATCH 1/5] s390x/css: introduce css data stream Halil Pasic
2017-09-06 12:18   ` Cornelia Huck
2017-09-06 12:40     ` Halil Pasic
2017-09-06 12:51       ` Cornelia Huck
2017-09-11 16:36         ` Halil Pasic
2017-09-13  9:53           ` Cornelia Huck
2017-09-13 11:35             ` Halil Pasic
2017-09-05 11:16 ` [Qemu-devel] [PATCH 2/5] s390x/css: use ccw " Halil Pasic
2017-09-06 12:32   ` Cornelia Huck
2017-09-06 12:42     ` Halil Pasic
2017-09-21  9:33   ` Pierre Morel
2017-09-21  9:36     ` Pierre Morel
2017-09-21  9:45     ` Cornelia Huck
2017-09-05 11:16 ` [Qemu-devel] [PATCH 3/5] virtio-ccw: " Halil Pasic
2017-09-06 12:42   ` Cornelia Huck
2017-09-06 12:49     ` Halil Pasic [this message]
2017-09-06 12:54       ` Cornelia Huck
2017-09-11 18:14     ` Halil Pasic
2017-09-13  9:58       ` Cornelia Huck
2017-09-13 11:36         ` Halil Pasic
2017-09-05 11:16 ` [Qemu-devel] [PATCH 4/5] s390x/css: support ccw IDA Halil Pasic
2017-09-06 13:10   ` Cornelia Huck
2017-09-11 18:08     ` Halil Pasic
2017-09-13  9:58       ` Cornelia Huck
2017-09-13 10:31         ` Halil Pasic
2017-09-13 10:50           ` Cornelia Huck
2017-09-05 11:16 ` [Qemu-devel] [PATCH 5/5] s390x/ccs: add ccw-tester emulated device Halil Pasic
2017-09-06 13:18   ` Cornelia Huck
2017-09-06 14:24     ` Halil Pasic
2017-09-06 15:20       ` Cornelia Huck
2017-09-06 16:16         ` Halil Pasic
2017-09-07  8:06           ` Cornelia Huck
2017-09-07  9:10             ` Janosch Frank
2017-09-07 12:24               ` Cornelia Huck
2017-09-07  7:31     ` Dong Jia Shi
2017-09-07  8:08       ` Cornelia Huck
2017-09-07 10:21         ` Halil Pasic
2017-09-07 10:52           ` Cornelia Huck
2017-09-08  2:01             ` Dong Jia Shi
2017-09-08 10:28               ` Halil Pasic
2017-09-19  6:03                 ` Dong Jia Shi
2017-09-21  8:45         ` Dong Jia Shi
2017-09-21  8:54           ` Cornelia Huck
2017-09-26  7:48             ` Dong Jia Shi
2017-09-27  7:11               ` Dong Jia Shi
2017-09-08 10:45 ` [Qemu-devel] [PATCH 0/5] add CCW indirect data access support Halil Pasic
2017-09-08 10:49   ` Cornelia Huck
2017-09-08 11:03     ` Halil Pasic
2017-09-08 11:19       ` Cornelia Huck
2017-09-08 11:43         ` Halil Pasic

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=b5948d5c-cc42-5a76-061d-d65eb7b6bc7c@linux.vnet.ibm.com \
    --to=pasic@linux.vnet.ibm.com \
    --cc=bjsdjshi@linux.vnet.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=qemu-devel@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).