From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel@nongnu.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com,
Yi Min Zhao <zyimin@linux.vnet.ibm.com>,
agraf@suse.de
Subject: [Qemu-devel] [PATCH 07/10] s390x/css: introduce indicator refcounting interfaces
Date: Tue, 23 Feb 2016 12:19:07 +0100 [thread overview]
Message-ID: <1456226350-3367-8-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1456226350-3367-1-git-send-email-cornelia.huck@de.ibm.com>
From: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Currently, virtio-ccw uses its own interfaces to keep indicators mapped
just once even if the same address has been registered multiple times.
These interfaces fit the PCI use case as well. Therefore, move them to
css and make them generic interfaces.
Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/s390x/css.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
hw/s390x/css.h | 14 ++++++++++++
hw/s390x/virtio-ccw.c | 63 ---------------------------------------------------
hw/s390x/virtio-ccw.h | 11 ++-------
4 files changed, 79 insertions(+), 72 deletions(-)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index c29068b..c02f5bc 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -60,10 +60,72 @@ typedef struct ChannelSubSys {
CssImage *css[MAX_CSSID + 1];
uint8_t default_cssid;
QTAILQ_HEAD(, IoAdapter) io_adapters;
+ QTAILQ_HEAD(, IndAddr) indicator_addresses;
} ChannelSubSys;
static ChannelSubSys *channel_subsys;
+IndAddr *get_indicator(hwaddr ind_addr, int len)
+{
+ IndAddr *indicator;
+
+ QTAILQ_FOREACH(indicator, &channel_subsys->indicator_addresses, sibling) {
+ if (indicator->addr == ind_addr) {
+ indicator->refcnt++;
+ return indicator;
+ }
+ }
+ indicator = g_new0(IndAddr, 1);
+ indicator->addr = ind_addr;
+ indicator->len = len;
+ indicator->refcnt = 1;
+ QTAILQ_INSERT_TAIL(&channel_subsys->indicator_addresses,
+ indicator, sibling);
+ return indicator;
+}
+
+static int s390_io_adapter_map(AdapterInfo *adapter, uint64_t map_addr,
+ bool do_map)
+{
+ S390FLICState *fs = s390_get_flic();
+ S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
+
+ return fsc->io_adapter_map(fs, adapter->adapter_id, map_addr, do_map);
+}
+
+void release_indicator(AdapterInfo *adapter, IndAddr *indicator)
+{
+ assert(indicator->refcnt > 0);
+ indicator->refcnt--;
+ if (indicator->refcnt > 0) {
+ return;
+ }
+ QTAILQ_REMOVE(&channel_subsys->indicator_addresses, indicator, sibling);
+ if (indicator->map) {
+ s390_io_adapter_map(adapter, indicator->map, false);
+ }
+ g_free(indicator);
+}
+
+int map_indicator(AdapterInfo *adapter, IndAddr *indicator)
+{
+ int ret;
+
+ if (indicator->map) {
+ return 0; /* already mapped is not an error */
+ }
+ indicator->map = indicator->addr;
+ ret = s390_io_adapter_map(adapter, indicator->map, true);
+ if ((ret != 0) && (ret != -ENOSYS)) {
+ goto out_err;
+ }
+ return 0;
+
+out_err:
+ indicator->map = 0;
+ return ret;
+}
+
int css_create_css_image(uint8_t cssid, bool default_image)
{
trace_css_new_image(cssid, default_image ? "(default)" : "");
@@ -1524,6 +1586,7 @@ static void css_init(void)
channel_subsys->crws_lost = false;
channel_subsys->chnmon_active = false;
QTAILQ_INIT(&channel_subsys->io_adapters);
+ QTAILQ_INIT(&channel_subsys->indicator_addresses);
}
machine_init(css_init);
diff --git a/hw/s390x/css.h b/hw/s390x/css.h
index a47937d..a320eea 100644
--- a/hw/s390x/css.h
+++ b/hw/s390x/css.h
@@ -12,6 +12,8 @@
#ifndef CSS_H
#define CSS_H
+#include "hw/s390x/adapter.h"
+#include "hw/s390x/s390_flic.h"
#include "ioinst.h"
/* Channel subsystem constants. */
@@ -86,6 +88,18 @@ struct SubchDev {
void *driver_data;
};
+typedef struct IndAddr {
+ hwaddr addr;
+ uint64_t map;
+ unsigned long refcnt;
+ int len;
+ QTAILQ_ENTRY(IndAddr) sibling;
+} IndAddr;
+
+IndAddr *get_indicator(hwaddr ind_addr, int len);
+void release_indicator(AdapterInfo *adapter, IndAddr *indicator);
+int map_indicator(AdapterInfo *adapter, IndAddr *indicator);
+
typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t ssid,
uint16_t schid);
void subch_device_save(SubchDev *s, QEMUFile *f);
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 74b9e2e..cb887ba 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -32,69 +32,6 @@
#include "virtio-ccw.h"
#include "trace.h"
-static QTAILQ_HEAD(, IndAddr) indicator_addresses =
- QTAILQ_HEAD_INITIALIZER(indicator_addresses);
-
-static IndAddr *get_indicator(hwaddr ind_addr, int len)
-{
- IndAddr *indicator;
-
- QTAILQ_FOREACH(indicator, &indicator_addresses, sibling) {
- if (indicator->addr == ind_addr) {
- indicator->refcnt++;
- return indicator;
- }
- }
- indicator = g_new0(IndAddr, 1);
- indicator->addr = ind_addr;
- indicator->len = len;
- indicator->refcnt = 1;
- QTAILQ_INSERT_TAIL(&indicator_addresses, indicator, sibling);
- return indicator;
-}
-
-static int s390_io_adapter_map(AdapterInfo *adapter, uint64_t map_addr,
- bool do_map)
-{
- S390FLICState *fs = s390_get_flic();
- S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
-
- return fsc->io_adapter_map(fs, adapter->adapter_id, map_addr, do_map);
-}
-
-static void release_indicator(AdapterInfo *adapter, IndAddr *indicator)
-{
- assert(indicator->refcnt > 0);
- indicator->refcnt--;
- if (indicator->refcnt > 0) {
- return;
- }
- QTAILQ_REMOVE(&indicator_addresses, indicator, sibling);
- if (indicator->map) {
- s390_io_adapter_map(adapter, indicator->map, false);
- }
- g_free(indicator);
-}
-
-static int map_indicator(AdapterInfo *adapter, IndAddr *indicator)
-{
- int ret;
-
- if (indicator->map) {
- return 0; /* already mapped is not an error */
- }
- indicator->map = indicator->addr;
- ret = s390_io_adapter_map(adapter, indicator->map, true);
- if ((ret != 0) && (ret != -ENOSYS)) {
- goto out_err;
- }
- return 0;
-
-out_err:
- indicator->map = 0;
- return ret;
-}
-
static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
VirtioCcwDevice *dev);
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index a526d2f..66c831b 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -23,7 +23,8 @@
#include <hw/virtio/virtio-balloon.h>
#include <hw/virtio/virtio-rng.h>
#include <hw/virtio/virtio-bus.h>
-#include <hw/s390x/s390_flic.h>
+
+#include "css.h"
#define VIRTUAL_CSSID 0xfe
@@ -75,14 +76,6 @@ typedef struct VirtIOCCWDeviceClass {
#define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1
#define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)
-typedef struct IndAddr {
- hwaddr addr;
- uint64_t map;
- unsigned long refcnt;
- int len;
- QTAILQ_ENTRY(IndAddr) sibling;
-} IndAddr;
-
struct VirtioCcwDevice {
DeviceState parent_obj;
SubchDev *sch;
--
2.7.1
next prev parent reply other threads:[~2016-02-23 11:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 11:19 [Qemu-devel] [PATCH 00/10] s390x: pending patches Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 01/10] linux-headers: update against kvm/next Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 02/10] s390x/kvm: sync fprs via kvm_run Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 03/10] s390x: fix debug statement in trigger_page_fault() Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 04/10] s390x: remove {kvm_}s390_virtio_irq() Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 05/10] watchdog/diag288: avoid race condition on expired watchdog Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 06/10] s390x/virtio: old machine leftovers Cornelia Huck
2016-02-23 11:19 ` Cornelia Huck [this message]
2016-02-23 11:19 ` [Qemu-devel] [PATCH 08/10] s390x/pci: fix reg/dereg irq functions Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 09/10] s390x/css: Allocate channel_subsys statically Cornelia Huck
2016-02-23 11:19 ` [Qemu-devel] [PATCH 10/10] s390x/css: Use static initialization for channel_subsys fields Cornelia Huck
2016-02-29 15:31 ` [Qemu-devel] [PATCH 00/10] s390x: pending patches Cornelia Huck
2016-02-29 15:32 ` [Qemu-devel] [PATCH] s390x/css: only suspend when enabled by orb 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=1456226350-3367-8-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=zyimin@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).