From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Blue Swirl <blauwirbel@gmail.com>,
Heinz Graalfs <graalfs@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v4 06/07] s390: sclp ascii console support
Date: Tue, 31 Jul 2012 15:05:22 +0200 [thread overview]
Message-ID: <5017D812.5090403@de.ibm.com> (raw)
In-Reply-To: <5717F05F-62A3-47DE-8961-12031F1713B5@suse.de>
On 30/07/12 16:02, Alexander Graf wrote:
>> + qemu_irq sclp_read_vt220;
>
> I'm sure this one wants a name that indicates it's an irq line ;)
ok.
>
>> +} SCLPConsole;
>> +
>> +/* character layer call-back functions */
>> +
>> +/* Return number of bytes that fit into iov buffer */
>> +static int chr_can_read(void *opaque)
>> +{
>> + int can_read;
>> + SCLPConsole *scon = opaque;
>> +
>> + qemu_mutex_lock(&scon->event.lock);
>
> Explicit locks now?
IIRC Heinz introduced the locks since we have multiple threads working on the same
kind of buffers (the cpu threads and the main thread). We could not verify that the
main thread has the big qemu lock in all cases. Furthermore, this makes the code already
thread safe if we get rid of the big qemu lock somewhen. But I agree, we have to double
check why there are two different kind of locks.
[...]
>> + /* if new data do not fit into current buffer */
>> + if (scon->iov_data_len + size > SIZE_BUFFER_VT220) {
>> + /* character layer sent more than allowed */
>> + qemu_mutex_unlock(&scon->event.lock);
>> + return;
>
> So we drop the bytes it did send? Isn't there usually some can_read function from the char layer that we can indicate to that we have enough space?
>
> If so, then this should be an assert(), right?
Probably yes. Will double check.
[..]
>> + SCLPConsole *cons = DO_UPCAST(SCLPConsole, event, event);
>> +
>> + /* first byte is hex 0 saying an ascii string follows */
>> + *buf++ = '\0';
>> + avail--;
>> + /* if all data fit into provided SCLP buffer */
>> + if (avail >= cons->iov_sclp_rest) {
>> + /* copy character byte-stream to SCLP buffer */
>> + memcpy(buf, cons->iov_sclp, cons->iov_sclp_rest);
>> + *size = cons->iov_sclp_rest + 1;
>> + cons->iov_sclp = cons->iov;
>> + cons->iov_bs = cons->iov;
>> + cons->iov_data_len = 0;
>> + cons->iov_sclp_rest = 0;
>> + event->event_pending = false;
>> + /* data provided and no more data pending */
>> + } else {
>> + /* if provided buffer is too small, just copy part */
>> + memcpy(buf, cons->iov_sclp, avail);
>> + *size = avail + 1;
>> + cons->iov_sclp_rest -= avail;
>> + cons->iov_sclp += avail;
>> + /* more data pending */
>> + }
>> +}
>
> I'm wondering whether we actually need this indirection from
>
> chr layer -> buffer -> sclp buffer.
>
> Why can't we just do
>
> chr layer -> sclp buffer?
>
The sclp interface is a bit different here. On an input event, the hw generated an service
interrupt with the event pending bit set. Then the guest kernel does a read event data sclp
call with input buffer. The input data has to copied into that and then returned via an
additional interrupt.
Without the buffering our can_read function could only return 0 as size since there is yet no
buffer. Makes sense?
Christian
next prev parent reply other threads:[~2012-07-31 13:05 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-24 7:37 [Qemu-devel] [PATCH 0/7v3] s390: sclp patch set Christian Borntraeger
2012-07-24 7:37 ` [Qemu-devel] [PATCH 1/7] s390: Fix error handling and condition code of service call Christian Borntraeger
2012-07-24 7:37 ` [Qemu-devel] [PATCH 2/7] s390: provide interface for service interrupt/introduce interrupt.c Christian Borntraeger
2012-07-24 7:37 ` [Qemu-devel] [PATCH 3/7] s390: sclp base support Christian Borntraeger
2012-07-30 12:38 ` Alexander Graf
2012-07-30 14:34 ` Christian Borntraeger
2012-08-20 12:15 ` Heinz Graalfs
2012-08-03 15:23 ` Andreas Färber
2012-07-24 7:37 ` [Qemu-devel] [PATCH 4/7] s390: sclp event support Christian Borntraeger
2012-07-30 13:24 ` Alexander Graf
2012-07-30 14:46 ` Christian Borntraeger
2012-07-30 14:57 ` Alexander Graf
2012-08-20 12:15 ` Heinz Graalfs
2012-07-31 12:59 ` Andreas Färber
2012-08-03 12:31 ` Christian Borntraeger
2012-08-20 12:14 ` Heinz Graalfs
2012-07-24 7:37 ` [Qemu-devel] [PATCH 5/7] s390: sclp signal quiesce support Christian Borntraeger
2012-07-24 7:37 ` [Qemu-devel] [PATCH 6/7] s390: sclp ascii console support Christian Borntraeger
2012-07-24 19:42 ` Blue Swirl
2012-07-26 8:55 ` [Qemu-devel] [PATCH v4 06/07] " Christian Borntraeger
2012-07-30 14:02 ` Alexander Graf
2012-07-31 13:05 ` Christian Borntraeger [this message]
2012-07-24 7:37 ` [Qemu-devel] [PATCH 7/7] s390: make sclp ascii console the default Christian Borntraeger
2012-07-24 19:35 ` Blue Swirl
2012-07-25 6:55 ` Christian Borntraeger
2012-07-26 13:48 ` Andreas Färber
2012-07-26 8:59 ` [Qemu-devel] [PATCH v4 07/07] " Christian Borntraeger
2012-07-30 14:05 ` Alexander Graf
2012-07-31 12:44 ` Christian Borntraeger
2012-07-31 12:52 ` Alexander Graf
2012-07-26 9:11 ` Christian Borntraeger
2012-07-30 9:00 ` [Qemu-devel] [PATCH 0/7v3] s390: sclp patch set Christian Borntraeger
2012-07-30 14:11 ` Alexander Graf
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=5017D812.5090403@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=blauwirbel@gmail.com \
--cc=graalfs@linux.vnet.ibm.com \
--cc=jfrei@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).