kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Gleb Natapov <gleb@redhat.com>, KVM <kvm@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Avi Kivity <avi.kivity@gmail.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Carsten Otte <cotte@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: Re: [PATCH 3/5] s390: Add a mechanism to get the subchannel id.
Date: Tue, 11 Dec 2012 13:34:18 +0100	[thread overview]
Message-ID: <20121211133418.5eb58cd0@BR9GNB5Z> (raw)
In-Reply-To: <8EFB3FAF-AD87-4263-B190-0ED30ABED5DB@suse.de>

On Tue, 11 Dec 2012 11:09:55 +0100
Alexander Graf <agraf@suse.de> wrote:

> 
> On 10.12.2012, at 10:03, Cornelia Huck wrote:
> 
> > On Sun, 9 Dec 2012 13:12:37 +0100
> > Alexander Graf <agraf@suse.de> wrote:
> > 
> >> 
> >> On 07.12.2012, at 13:29, Cornelia Huck wrote:
> >> 
> >>> This will be needed by the new virtio-ccw transport.
> >>> 
> >>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> >>> ---
> >>> arch/s390/include/asm/ccwdev.h |  5 +++++
> >>> drivers/s390/cio/device_ops.c  | 12 ++++++++++++
> >>> 2 files changed, 17 insertions(+)
> >>> 
> >>> diff --git a/arch/s390/include/asm/ccwdev.h b/arch/s390/include/asm/ccwdev.h
> >>> index 1cb4bb3..9ad79f7 100644
> >>> --- a/arch/s390/include/asm/ccwdev.h
> >>> +++ b/arch/s390/include/asm/ccwdev.h
> >>> @@ -18,6 +18,9 @@ struct irb;
> >>> struct ccw1;
> >>> struct ccw_dev_id;
> >>> 
> >>> +/* from asm/schid.h */
> >>> +struct subchannel_id;
> >>> +
> >>> /* simplified initializers for struct ccw_device:
> >>> * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
> >>> * entry in your MODULE_DEVICE_TABLE and set the match_flag correctly */
> >>> @@ -226,5 +229,7 @@ int ccw_device_siosl(struct ccw_device *);
> >>> // FIXME: these have to go
> >>> extern int _ccw_device_get_subchannel_number(struct ccw_device *);
> >>> 
> >>> +extern void ccw_device_get_schid(struct ccw_device *, struct subchannel_id *);
> >>> +
> >>> extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
> >>> #endif /* _S390_CCWDEV_H_ */
> >>> diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
> >>> index ec7fb6d..2ad832f 100644
> >>> --- a/drivers/s390/cio/device_ops.c
> >>> +++ b/drivers/s390/cio/device_ops.c
> >>> @@ -763,6 +763,18 @@ _ccw_device_get_subchannel_number(struct ccw_device *cdev)
> >>> 	return cdev->private->schid.sch_no;
> >>> }
> >>> 
> >>> +/**
> >>> + * ccw_device_get_schid - obtain a subchannel id
> >>> + * @cdev: device to obtain the id for
> >>> + * @schid: where to fill in the values
> >>> + */
> >>> +void ccw_device_get_schid(struct ccw_device *cdev, struct subchannel_id *schid)
> >> 
> >> If you make this
> >> 
> >> u32 ccw_device_get_schid(struct ccw_device *cdev)
> >> 
> >> and you return the u32 (architected) value of the schid, not the internal struct, then you can save yourself the struct export (patch 2/5) and the ugly cast in patch 4/5 to get the u32 value.
> > 
> > I really prefer using the structure instead.
> > 
> > Moreover, there's a patch based on this that switches non-kvm users to
> > this new interface (getting rid of an old, broken interface) already
> > queued in the linux-s390 tree AFAIK.
> 
> Well, then base on top of that patch and add another interface that allows you to receive a schid as integer value. Randomly casting structs to u32 in random code across the tree is just pure ugly.

We seem to have different ideas of 'ugly' :)

I really prefer to have a function called ccw_device_get_schid()
provide a struct subchannel_id and not a u32 - a subchannel id is,
after all, what the caller asks for. The fact that a subchannel id may
fit into a u32 is an implementation detail, as well as the fact that an
instruction takes a 32 bit value containing a subchannel id. Passing
around a 32 bit value instead of a subchannel id basically discards the
information that we're dealing with a subchannel id and not with a
random 32 bit value.

> 
> An alternative would be to create a union around the struct and to return that one, so that you can access the u32 value or the struct value depending on the user's needs. That way the u32 cast is part of the API and not implicit, as it would be today.

What's the API here? I think we have two parts:

- The API to get the current subchannel id for a ccw device. For the
reasons above, I think this should use struct subchannel_id.

- The hardware/hypervisor API for addressing a subchannel, which
basically requires that a register contains a subchannel id. The easiest
way to do this is to cast to an integer. I don't see any need to play
games with unions here, after all we're using C and not Pascal ;)


  reply	other threads:[~2012-12-11 12:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 12:29 [PATCH v3 0/5] s390: Guest support for virtio-ccw Cornelia Huck
2012-12-07 12:29 ` [PATCH 1/5] KVM: s390: Handle hosts not supporting s390-virtio Cornelia Huck
2012-12-07 12:29 ` [PATCH 2/5] s390: Move css limits from drivers/s390/cio/ to include/asm/ Cornelia Huck
2012-12-07 12:29 ` [PATCH 3/5] s390: Add a mechanism to get the subchannel id Cornelia Huck
2012-12-09 12:12   ` Alexander Graf
2012-12-10  9:03     ` Cornelia Huck
2012-12-11 10:09       ` Alexander Graf
2012-12-11 12:34         ` Cornelia Huck [this message]
2012-12-12  0:33           ` Alexander Graf
2012-12-12 16:36             ` Cornelia Huck
2012-12-07 12:29 ` [PATCH 4/5] KVM: s390: Add a channel I/O based virtio transport driver Cornelia Huck
2012-12-07 12:29 ` [PATCH 5/5] KVM: s390: Split out early console code Cornelia Huck
2012-12-09 12:45   ` Alexander Graf
2012-12-10  9:06     ` Cornelia Huck
2012-12-11 10:10       ` Alexander Graf
2012-12-11 12:36         ` Cornelia Huck
  -- strict thread matches above, loose matches on Subject: below --
2012-10-29 13:07 [PATCH 0/5] s390: Guest support for virtio-ccw Cornelia Huck
2012-10-29 13:07 ` [PATCH 3/5] s390: Add a mechanism to get the subchannel id 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=20121211133418.5eb58cd0@BR9GNB5Z \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=avi.kivity@gmail.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=gleb@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=sebott@linux.vnet.ibm.com \
    /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).