s390x/css: Allocate channel_subsys statically
There's no need to use g_malloc0() to allocate the channel_subsys struct, just use a static variable. Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Alexander Graf <agraf@suse.de> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <1455656347-29033-3-git-send-email-ehabkost@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> [adapted on top of indicator changes] Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
		
							parent
							
								
									8581c115d2
								
							
						
					
					
						commit
						562f5e0b97
					
				
							
								
								
									
										185
									
								
								hw/s390x/css.c
									
									
									
									
									
								
							
							
						
						
									
										185
									
								
								hw/s390x/css.c
									
									
									
									
									
								
							@ -63,13 +63,13 @@ typedef struct ChannelSubSys {
 | 
				
			|||||||
    QTAILQ_HEAD(, IndAddr) indicator_addresses;
 | 
					    QTAILQ_HEAD(, IndAddr) indicator_addresses;
 | 
				
			||||||
} ChannelSubSys;
 | 
					} ChannelSubSys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static ChannelSubSys *channel_subsys;
 | 
					static ChannelSubSys channel_subsys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
IndAddr *get_indicator(hwaddr ind_addr, int len)
 | 
					IndAddr *get_indicator(hwaddr ind_addr, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    IndAddr *indicator;
 | 
					    IndAddr *indicator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_FOREACH(indicator, &channel_subsys->indicator_addresses, sibling) {
 | 
					    QTAILQ_FOREACH(indicator, &channel_subsys.indicator_addresses, sibling) {
 | 
				
			||||||
        if (indicator->addr == ind_addr) {
 | 
					        if (indicator->addr == ind_addr) {
 | 
				
			||||||
            indicator->refcnt++;
 | 
					            indicator->refcnt++;
 | 
				
			||||||
            return indicator;
 | 
					            return indicator;
 | 
				
			||||||
@ -79,7 +79,7 @@ IndAddr *get_indicator(hwaddr ind_addr, int len)
 | 
				
			|||||||
    indicator->addr = ind_addr;
 | 
					    indicator->addr = ind_addr;
 | 
				
			||||||
    indicator->len = len;
 | 
					    indicator->len = len;
 | 
				
			||||||
    indicator->refcnt = 1;
 | 
					    indicator->refcnt = 1;
 | 
				
			||||||
    QTAILQ_INSERT_TAIL(&channel_subsys->indicator_addresses,
 | 
					    QTAILQ_INSERT_TAIL(&channel_subsys.indicator_addresses,
 | 
				
			||||||
                       indicator, sibling);
 | 
					                       indicator, sibling);
 | 
				
			||||||
    return indicator;
 | 
					    return indicator;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -100,7 +100,7 @@ void release_indicator(AdapterInfo *adapter, IndAddr *indicator)
 | 
				
			|||||||
    if (indicator->refcnt > 0) {
 | 
					    if (indicator->refcnt > 0) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    QTAILQ_REMOVE(&channel_subsys->indicator_addresses, indicator, sibling);
 | 
					    QTAILQ_REMOVE(&channel_subsys.indicator_addresses, indicator, sibling);
 | 
				
			||||||
    if (indicator->map) {
 | 
					    if (indicator->map) {
 | 
				
			||||||
        s390_io_adapter_map(adapter, indicator->map, false);
 | 
					        s390_io_adapter_map(adapter, indicator->map, false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -132,12 +132,12 @@ int css_create_css_image(uint8_t cssid, bool default_image)
 | 
				
			|||||||
    if (cssid > MAX_CSSID) {
 | 
					    if (cssid > MAX_CSSID) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (channel_subsys->css[cssid]) {
 | 
					    if (channel_subsys.css[cssid]) {
 | 
				
			||||||
        return -EBUSY;
 | 
					        return -EBUSY;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    channel_subsys->css[cssid] = g_malloc0(sizeof(CssImage));
 | 
					    channel_subsys.css[cssid] = g_malloc0(sizeof(CssImage));
 | 
				
			||||||
    if (default_image) {
 | 
					    if (default_image) {
 | 
				
			||||||
        channel_subsys->default_cssid = cssid;
 | 
					        channel_subsys.default_cssid = cssid;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -152,7 +152,7 @@ int css_register_io_adapter(uint8_t type, uint8_t isc, bool swap,
 | 
				
			|||||||
    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
 | 
					    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    *id = 0;
 | 
					    *id = 0;
 | 
				
			||||||
    QTAILQ_FOREACH(adapter, &channel_subsys->io_adapters, sibling) {
 | 
					    QTAILQ_FOREACH(adapter, &channel_subsys.io_adapters, sibling) {
 | 
				
			||||||
        if ((adapter->type == type) && (adapter->isc == isc)) {
 | 
					        if ((adapter->type == type) && (adapter->isc == isc)) {
 | 
				
			||||||
            *id = adapter->id;
 | 
					            *id = adapter->id;
 | 
				
			||||||
            found = true;
 | 
					            found = true;
 | 
				
			||||||
@ -172,7 +172,7 @@ int css_register_io_adapter(uint8_t type, uint8_t isc, bool swap,
 | 
				
			|||||||
        adapter->id = *id;
 | 
					        adapter->id = *id;
 | 
				
			||||||
        adapter->isc = isc;
 | 
					        adapter->isc = isc;
 | 
				
			||||||
        adapter->type = type;
 | 
					        adapter->type = type;
 | 
				
			||||||
        QTAILQ_INSERT_TAIL(&channel_subsys->io_adapters, adapter, sibling);
 | 
					        QTAILQ_INSERT_TAIL(&channel_subsys.io_adapters, adapter, sibling);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        g_free(adapter);
 | 
					        g_free(adapter);
 | 
				
			||||||
        fprintf(stderr, "Unexpected error %d when registering adapter %d\n",
 | 
					        fprintf(stderr, "Unexpected error %d when registering adapter %d\n",
 | 
				
			||||||
@ -184,7 +184,7 @@ out:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
uint16_t css_build_subchannel_id(SubchDev *sch)
 | 
					uint16_t css_build_subchannel_id(SubchDev *sch)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (channel_subsys->max_cssid > 0) {
 | 
					    if (channel_subsys.max_cssid > 0) {
 | 
				
			||||||
        return (sch->cssid << 8) | (1 << 3) | (sch->ssid << 1) | 1;
 | 
					        return (sch->cssid << 8) | (1 << 3) | (sch->ssid << 1) | 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return (sch->ssid << 1) | 1;
 | 
					    return (sch->ssid << 1) | 1;
 | 
				
			||||||
@ -840,12 +840,12 @@ static void css_update_chnmon(SubchDev *sch)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        offset = sch->curr_status.pmcw.mbi << 5;
 | 
					        offset = sch->curr_status.pmcw.mbi << 5;
 | 
				
			||||||
        count = address_space_lduw(&address_space_memory,
 | 
					        count = address_space_lduw(&address_space_memory,
 | 
				
			||||||
                                   channel_subsys->chnmon_area + offset,
 | 
					                                   channel_subsys.chnmon_area + offset,
 | 
				
			||||||
                                   MEMTXATTRS_UNSPECIFIED,
 | 
					                                   MEMTXATTRS_UNSPECIFIED,
 | 
				
			||||||
                                   NULL);
 | 
					                                   NULL);
 | 
				
			||||||
        count++;
 | 
					        count++;
 | 
				
			||||||
        address_space_stw(&address_space_memory,
 | 
					        address_space_stw(&address_space_memory,
 | 
				
			||||||
                          channel_subsys->chnmon_area + offset, count,
 | 
					                          channel_subsys.chnmon_area + offset, count,
 | 
				
			||||||
                          MEMTXATTRS_UNSPECIFIED, NULL);
 | 
					                          MEMTXATTRS_UNSPECIFIED, NULL);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -874,7 +874,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If monitoring is active, update counter. */
 | 
					    /* If monitoring is active, update counter. */
 | 
				
			||||||
    if (channel_subsys->chnmon_active) {
 | 
					    if (channel_subsys.chnmon_active) {
 | 
				
			||||||
        css_update_chnmon(sch);
 | 
					        css_update_chnmon(sch);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    sch->channel_prog = orb->cpa;
 | 
					    sch->channel_prog = orb->cpa;
 | 
				
			||||||
@ -1033,16 +1033,16 @@ int css_do_stcrw(CRW *crw)
 | 
				
			|||||||
    CrwContainer *crw_cont;
 | 
					    CrwContainer *crw_cont;
 | 
				
			||||||
    int ret;
 | 
					    int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    crw_cont = QTAILQ_FIRST(&channel_subsys->pending_crws);
 | 
					    crw_cont = QTAILQ_FIRST(&channel_subsys.pending_crws);
 | 
				
			||||||
    if (crw_cont) {
 | 
					    if (crw_cont) {
 | 
				
			||||||
        QTAILQ_REMOVE(&channel_subsys->pending_crws, crw_cont, sibling);
 | 
					        QTAILQ_REMOVE(&channel_subsys.pending_crws, crw_cont, sibling);
 | 
				
			||||||
        copy_crw_to_guest(crw, &crw_cont->crw);
 | 
					        copy_crw_to_guest(crw, &crw_cont->crw);
 | 
				
			||||||
        g_free(crw_cont);
 | 
					        g_free(crw_cont);
 | 
				
			||||||
        ret = 0;
 | 
					        ret = 0;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* List was empty, turn crw machine checks on again. */
 | 
					        /* List was empty, turn crw machine checks on again. */
 | 
				
			||||||
        memset(crw, 0, sizeof(*crw));
 | 
					        memset(crw, 0, sizeof(*crw));
 | 
				
			||||||
        channel_subsys->do_crw_mchk = true;
 | 
					        channel_subsys.do_crw_mchk = true;
 | 
				
			||||||
        ret = 1;
 | 
					        ret = 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1061,12 +1061,12 @@ void css_undo_stcrw(CRW *crw)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    crw_cont = g_try_malloc0(sizeof(CrwContainer));
 | 
					    crw_cont = g_try_malloc0(sizeof(CrwContainer));
 | 
				
			||||||
    if (!crw_cont) {
 | 
					    if (!crw_cont) {
 | 
				
			||||||
        channel_subsys->crws_lost = true;
 | 
					        channel_subsys.crws_lost = true;
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    copy_crw_from_guest(&crw_cont->crw, crw);
 | 
					    copy_crw_from_guest(&crw_cont->crw, crw);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_INSERT_HEAD(&channel_subsys->pending_crws, crw_cont, sibling);
 | 
					    QTAILQ_INSERT_HEAD(&channel_subsys.pending_crws, crw_cont, sibling);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int css_do_tpi(IOIntCode *int_code, int lowcore)
 | 
					int css_do_tpi(IOIntCode *int_code, int lowcore)
 | 
				
			||||||
@ -1084,9 +1084,9 @@ int css_collect_chp_desc(int m, uint8_t cssid, uint8_t f_chpid, uint8_t l_chpid,
 | 
				
			|||||||
    CssImage *css;
 | 
					    CssImage *css;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!m && !cssid) {
 | 
					    if (!m && !cssid) {
 | 
				
			||||||
        css = channel_subsys->css[channel_subsys->default_cssid];
 | 
					        css = channel_subsys.css[channel_subsys.default_cssid];
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        css = channel_subsys->css[cssid];
 | 
					        css = channel_subsys.css[cssid];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!css) {
 | 
					    if (!css) {
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
@ -1121,15 +1121,15 @@ void css_do_schm(uint8_t mbk, int update, int dct, uint64_t mbo)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    /* dct is currently ignored (not really meaningful for our devices) */
 | 
					    /* dct is currently ignored (not really meaningful for our devices) */
 | 
				
			||||||
    /* TODO: Don't ignore mbk. */
 | 
					    /* TODO: Don't ignore mbk. */
 | 
				
			||||||
    if (update && !channel_subsys->chnmon_active) {
 | 
					    if (update && !channel_subsys.chnmon_active) {
 | 
				
			||||||
        /* Enable measuring. */
 | 
					        /* Enable measuring. */
 | 
				
			||||||
        channel_subsys->chnmon_area = mbo;
 | 
					        channel_subsys.chnmon_area = mbo;
 | 
				
			||||||
        channel_subsys->chnmon_active = true;
 | 
					        channel_subsys.chnmon_active = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!update && channel_subsys->chnmon_active) {
 | 
					    if (!update && channel_subsys.chnmon_active) {
 | 
				
			||||||
        /* Disable measuring. */
 | 
					        /* Disable measuring. */
 | 
				
			||||||
        channel_subsys->chnmon_area = 0;
 | 
					        channel_subsys.chnmon_area = 0;
 | 
				
			||||||
        channel_subsys->chnmon_active = false;
 | 
					        channel_subsys.chnmon_active = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1157,7 +1157,7 @@ int css_do_rsch(SubchDev *sch)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If monitoring is active, update counter. */
 | 
					    /* If monitoring is active, update counter. */
 | 
				
			||||||
    if (channel_subsys->chnmon_active) {
 | 
					    if (channel_subsys.chnmon_active) {
 | 
				
			||||||
        css_update_chnmon(sch);
 | 
					        css_update_chnmon(sch);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1173,23 +1173,23 @@ int css_do_rchp(uint8_t cssid, uint8_t chpid)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    uint8_t real_cssid;
 | 
					    uint8_t real_cssid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (cssid > channel_subsys->max_cssid) {
 | 
					    if (cssid > channel_subsys.max_cssid) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (channel_subsys->max_cssid == 0) {
 | 
					    if (channel_subsys.max_cssid == 0) {
 | 
				
			||||||
        real_cssid = channel_subsys->default_cssid;
 | 
					        real_cssid = channel_subsys.default_cssid;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        real_cssid = cssid;
 | 
					        real_cssid = cssid;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!channel_subsys->css[real_cssid]) {
 | 
					    if (!channel_subsys.css[real_cssid]) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!channel_subsys->css[real_cssid]->chpids[chpid].in_use) {
 | 
					    if (!channel_subsys.css[real_cssid]->chpids[chpid].in_use) {
 | 
				
			||||||
        return -ENODEV;
 | 
					        return -ENODEV;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!channel_subsys->css[real_cssid]->chpids[chpid].is_virtual) {
 | 
					    if (!channel_subsys.css[real_cssid]->chpids[chpid].is_virtual) {
 | 
				
			||||||
        fprintf(stderr,
 | 
					        fprintf(stderr,
 | 
				
			||||||
                "rchp unsupported for non-virtual chpid %x.%02x!\n",
 | 
					                "rchp unsupported for non-virtual chpid %x.%02x!\n",
 | 
				
			||||||
                real_cssid, chpid);
 | 
					                real_cssid, chpid);
 | 
				
			||||||
@ -1198,8 +1198,8 @@ int css_do_rchp(uint8_t cssid, uint8_t chpid)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* We don't really use a channel path, so we're done here. */
 | 
					    /* We don't really use a channel path, so we're done here. */
 | 
				
			||||||
    css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,
 | 
					    css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT,
 | 
				
			||||||
                  channel_subsys->max_cssid > 0 ? 1 : 0, chpid);
 | 
					                  channel_subsys.max_cssid > 0 ? 1 : 0, chpid);
 | 
				
			||||||
    if (channel_subsys->max_cssid > 0) {
 | 
					    if (channel_subsys.max_cssid > 0) {
 | 
				
			||||||
        css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);
 | 
					        css_queue_crw(CRW_RSC_CHP, CRW_ERC_INIT, 0, real_cssid << 8);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
@ -1210,13 +1210,13 @@ bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid)
 | 
				
			|||||||
    SubchSet *set;
 | 
					    SubchSet *set;
 | 
				
			||||||
    uint8_t real_cssid;
 | 
					    uint8_t real_cssid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    real_cssid = (!m && (cssid == 0)) ? channel_subsys->default_cssid : cssid;
 | 
					    real_cssid = (!m && (cssid == 0)) ? channel_subsys.default_cssid : cssid;
 | 
				
			||||||
    if (real_cssid > MAX_CSSID || ssid > MAX_SSID ||
 | 
					    if (real_cssid > MAX_CSSID || ssid > MAX_SSID ||
 | 
				
			||||||
        !channel_subsys->css[real_cssid] ||
 | 
					        !channel_subsys.css[real_cssid] ||
 | 
				
			||||||
        !channel_subsys->css[real_cssid]->sch_set[ssid]) {
 | 
					        !channel_subsys.css[real_cssid]->sch_set[ssid]) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    set = channel_subsys->css[real_cssid]->sch_set[ssid];
 | 
					    set = channel_subsys.css[real_cssid]->sch_set[ssid];
 | 
				
			||||||
    return schid > find_last_bit(set->schids_used,
 | 
					    return schid > find_last_bit(set->schids_used,
 | 
				
			||||||
                                 (MAX_SCHID + 1) / sizeof(unsigned long));
 | 
					                                 (MAX_SCHID + 1) / sizeof(unsigned long));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1229,7 +1229,7 @@ static int css_add_virtual_chpid(uint8_t cssid, uint8_t chpid, uint8_t type)
 | 
				
			|||||||
    if (cssid > MAX_CSSID) {
 | 
					    if (cssid > MAX_CSSID) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    css = channel_subsys->css[cssid];
 | 
					    css = channel_subsys.css[cssid];
 | 
				
			||||||
    if (!css) {
 | 
					    if (!css) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1250,7 +1250,7 @@ void css_sch_build_virtual_schib(SubchDev *sch, uint8_t chpid, uint8_t type)
 | 
				
			|||||||
    PMCW *p = &sch->curr_status.pmcw;
 | 
					    PMCW *p = &sch->curr_status.pmcw;
 | 
				
			||||||
    SCSW *s = &sch->curr_status.scsw;
 | 
					    SCSW *s = &sch->curr_status.scsw;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
    CssImage *css = channel_subsys->css[sch->cssid];
 | 
					    CssImage *css = channel_subsys.css[sch->cssid];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert(css != NULL);
 | 
					    assert(css != NULL);
 | 
				
			||||||
    memset(p, 0, sizeof(PMCW));
 | 
					    memset(p, 0, sizeof(PMCW));
 | 
				
			||||||
@ -1276,27 +1276,27 @@ SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid, uint16_t schid)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    uint8_t real_cssid;
 | 
					    uint8_t real_cssid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    real_cssid = (!m && (cssid == 0)) ? channel_subsys->default_cssid : cssid;
 | 
					    real_cssid = (!m && (cssid == 0)) ? channel_subsys.default_cssid : cssid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!channel_subsys->css[real_cssid]) {
 | 
					    if (!channel_subsys.css[real_cssid]) {
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!channel_subsys->css[real_cssid]->sch_set[ssid]) {
 | 
					    if (!channel_subsys.css[real_cssid]->sch_set[ssid]) {
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return channel_subsys->css[real_cssid]->sch_set[ssid]->sch[schid];
 | 
					    return channel_subsys.css[real_cssid]->sch_set[ssid]->sch[schid];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool css_subch_visible(SubchDev *sch)
 | 
					bool css_subch_visible(SubchDev *sch)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (sch->ssid > channel_subsys->max_ssid) {
 | 
					    if (sch->ssid > channel_subsys.max_ssid) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (sch->cssid != channel_subsys->default_cssid) {
 | 
					    if (sch->cssid != channel_subsys.default_cssid) {
 | 
				
			||||||
        return (channel_subsys->max_cssid > 0);
 | 
					        return (channel_subsys.max_cssid > 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
@ -1304,20 +1304,20 @@ bool css_subch_visible(SubchDev *sch)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool css_present(uint8_t cssid)
 | 
					bool css_present(uint8_t cssid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return (channel_subsys->css[cssid] != NULL);
 | 
					    return (channel_subsys.css[cssid] != NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno)
 | 
					bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!channel_subsys->css[cssid]) {
 | 
					    if (!channel_subsys.css[cssid]) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (!channel_subsys->css[cssid]->sch_set[ssid]) {
 | 
					    if (!channel_subsys.css[cssid]->sch_set[ssid]) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return !!test_bit(devno,
 | 
					    return !!test_bit(devno,
 | 
				
			||||||
                      channel_subsys->css[cssid]->sch_set[ssid]->devnos_used);
 | 
					                      channel_subsys.css[cssid]->sch_set[ssid]->devnos_used);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
 | 
					void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
 | 
				
			||||||
@ -1328,13 +1328,13 @@ void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    trace_css_assign_subch(sch ? "assign" : "deassign", cssid, ssid, schid,
 | 
					    trace_css_assign_subch(sch ? "assign" : "deassign", cssid, ssid, schid,
 | 
				
			||||||
                           devno);
 | 
					                           devno);
 | 
				
			||||||
    if (!channel_subsys->css[cssid]) {
 | 
					    if (!channel_subsys.css[cssid]) {
 | 
				
			||||||
        fprintf(stderr,
 | 
					        fprintf(stderr,
 | 
				
			||||||
                "Suspicious call to %s (%x.%x.%04x) for non-existing css!\n",
 | 
					                "Suspicious call to %s (%x.%x.%04x) for non-existing css!\n",
 | 
				
			||||||
                __func__, cssid, ssid, schid);
 | 
					                __func__, cssid, ssid, schid);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    css = channel_subsys->css[cssid];
 | 
					    css = channel_subsys.css[cssid];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!css->sch_set[ssid]) {
 | 
					    if (!css->sch_set[ssid]) {
 | 
				
			||||||
        css->sch_set[ssid] = g_malloc0(sizeof(SubchSet));
 | 
					        css->sch_set[ssid] = g_malloc0(sizeof(SubchSet));
 | 
				
			||||||
@ -1359,7 +1359,7 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid)
 | 
				
			|||||||
    /* TODO: Maybe use a static crw pool? */
 | 
					    /* TODO: Maybe use a static crw pool? */
 | 
				
			||||||
    crw_cont = g_try_malloc0(sizeof(CrwContainer));
 | 
					    crw_cont = g_try_malloc0(sizeof(CrwContainer));
 | 
				
			||||||
    if (!crw_cont) {
 | 
					    if (!crw_cont) {
 | 
				
			||||||
        channel_subsys->crws_lost = true;
 | 
					        channel_subsys.crws_lost = true;
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    crw_cont->crw.flags = (rsc << 8) | erc;
 | 
					    crw_cont->crw.flags = (rsc << 8) | erc;
 | 
				
			||||||
@ -1367,15 +1367,15 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid)
 | 
				
			|||||||
        crw_cont->crw.flags |= CRW_FLAGS_MASK_C;
 | 
					        crw_cont->crw.flags |= CRW_FLAGS_MASK_C;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    crw_cont->crw.rsid = rsid;
 | 
					    crw_cont->crw.rsid = rsid;
 | 
				
			||||||
    if (channel_subsys->crws_lost) {
 | 
					    if (channel_subsys.crws_lost) {
 | 
				
			||||||
        crw_cont->crw.flags |= CRW_FLAGS_MASK_R;
 | 
					        crw_cont->crw.flags |= CRW_FLAGS_MASK_R;
 | 
				
			||||||
        channel_subsys->crws_lost = false;
 | 
					        channel_subsys.crws_lost = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_INSERT_TAIL(&channel_subsys->pending_crws, crw_cont, sibling);
 | 
					    QTAILQ_INSERT_TAIL(&channel_subsys.pending_crws, crw_cont, sibling);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (channel_subsys->do_crw_mchk) {
 | 
					    if (channel_subsys.do_crw_mchk) {
 | 
				
			||||||
        channel_subsys->do_crw_mchk = false;
 | 
					        channel_subsys.do_crw_mchk = false;
 | 
				
			||||||
        /* Inject crw pending machine check. */
 | 
					        /* Inject crw pending machine check. */
 | 
				
			||||||
        s390_crw_mchk();
 | 
					        s390_crw_mchk();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1390,9 +1390,9 @@ void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
 | 
				
			|||||||
    if (add && !hotplugged) {
 | 
					    if (add && !hotplugged) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (channel_subsys->max_cssid == 0) {
 | 
					    if (channel_subsys.max_cssid == 0) {
 | 
				
			||||||
        /* Default cssid shows up as 0. */
 | 
					        /* Default cssid shows up as 0. */
 | 
				
			||||||
        guest_cssid = (cssid == channel_subsys->default_cssid) ? 0 : cssid;
 | 
					        guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* Show real cssid to the guest. */
 | 
					        /* Show real cssid to the guest. */
 | 
				
			||||||
        guest_cssid = cssid;
 | 
					        guest_cssid = cssid;
 | 
				
			||||||
@ -1401,14 +1401,14 @@ void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
 | 
				
			|||||||
     * Only notify for higher subchannel sets/channel subsystems if the
 | 
					     * Only notify for higher subchannel sets/channel subsystems if the
 | 
				
			||||||
     * guest has enabled it.
 | 
					     * guest has enabled it.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if ((ssid > channel_subsys->max_ssid) ||
 | 
					    if ((ssid > channel_subsys.max_ssid) ||
 | 
				
			||||||
        (guest_cssid > channel_subsys->max_cssid) ||
 | 
					        (guest_cssid > channel_subsys.max_cssid) ||
 | 
				
			||||||
        ((channel_subsys->max_cssid == 0) &&
 | 
					        ((channel_subsys.max_cssid == 0) &&
 | 
				
			||||||
         (cssid != channel_subsys->default_cssid))) {
 | 
					         (cssid != channel_subsys.default_cssid))) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    chain_crw = (channel_subsys->max_ssid > 0) ||
 | 
					    chain_crw = (channel_subsys.max_ssid > 0) ||
 | 
				
			||||||
            (channel_subsys->max_cssid > 0);
 | 
					            (channel_subsys.max_cssid > 0);
 | 
				
			||||||
    css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid);
 | 
					    css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid);
 | 
				
			||||||
    if (chain_crw) {
 | 
					    if (chain_crw) {
 | 
				
			||||||
        css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
 | 
					        css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0,
 | 
				
			||||||
@ -1423,28 +1423,28 @@ void css_generate_chp_crws(uint8_t cssid, uint8_t chpid)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void css_generate_css_crws(uint8_t cssid)
 | 
					void css_generate_css_crws(uint8_t cssid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!channel_subsys->sei_pending) {
 | 
					    if (!channel_subsys.sei_pending) {
 | 
				
			||||||
        css_queue_crw(CRW_RSC_CSS, 0, 0, cssid);
 | 
					        css_queue_crw(CRW_RSC_CSS, 0, 0, cssid);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    channel_subsys->sei_pending = true;
 | 
					    channel_subsys.sei_pending = true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void css_clear_sei_pending(void)
 | 
					void css_clear_sei_pending(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    channel_subsys->sei_pending = false;
 | 
					    channel_subsys.sei_pending = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int css_enable_mcsse(void)
 | 
					int css_enable_mcsse(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    trace_css_enable_facility("mcsse");
 | 
					    trace_css_enable_facility("mcsse");
 | 
				
			||||||
    channel_subsys->max_cssid = MAX_CSSID;
 | 
					    channel_subsys.max_cssid = MAX_CSSID;
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int css_enable_mss(void)
 | 
					int css_enable_mss(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    trace_css_enable_facility("mss");
 | 
					    trace_css_enable_facility("mss");
 | 
				
			||||||
    channel_subsys->max_ssid = MAX_SSID;
 | 
					    channel_subsys.max_ssid = MAX_SSID;
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1567,10 +1567,10 @@ int subch_device_load(SubchDev *s, QEMUFile *f)
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {
 | 
					    if (s->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA) {
 | 
				
			||||||
        if (s->ssid) {
 | 
					        if (s->ssid) {
 | 
				
			||||||
            channel_subsys->max_ssid = MAX_SSID;
 | 
					            channel_subsys.max_ssid = MAX_SSID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (s->cssid != channel_subsys->default_cssid) {
 | 
					        if (s->cssid != channel_subsys.default_cssid) {
 | 
				
			||||||
            channel_subsys->max_cssid = MAX_CSSID;
 | 
					            channel_subsys.max_cssid = MAX_CSSID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
@ -1579,14 +1579,13 @@ int subch_device_load(SubchDev *s, QEMUFile *f)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void css_init(void)
 | 
					static void css_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    channel_subsys = g_malloc0(sizeof(*channel_subsys));
 | 
					    QTAILQ_INIT(&channel_subsys.pending_crws);
 | 
				
			||||||
    QTAILQ_INIT(&channel_subsys->pending_crws);
 | 
					    channel_subsys.sei_pending = false;
 | 
				
			||||||
    channel_subsys->sei_pending = false;
 | 
					    channel_subsys.do_crw_mchk = true;
 | 
				
			||||||
    channel_subsys->do_crw_mchk = true;
 | 
					    channel_subsys.crws_lost = false;
 | 
				
			||||||
    channel_subsys->crws_lost = false;
 | 
					    channel_subsys.chnmon_active = false;
 | 
				
			||||||
    channel_subsys->chnmon_active = false;
 | 
					    QTAILQ_INIT(&channel_subsys.io_adapters);
 | 
				
			||||||
    QTAILQ_INIT(&channel_subsys->io_adapters);
 | 
					    QTAILQ_INIT(&channel_subsys.indicator_addresses);
 | 
				
			||||||
    QTAILQ_INIT(&channel_subsys->indicator_addresses);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
machine_init(css_init);
 | 
					machine_init(css_init);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1627,19 +1626,19 @@ void css_reset(void)
 | 
				
			|||||||
    CrwContainer *crw_cont;
 | 
					    CrwContainer *crw_cont;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Clean up monitoring. */
 | 
					    /* Clean up monitoring. */
 | 
				
			||||||
    channel_subsys->chnmon_active = false;
 | 
					    channel_subsys.chnmon_active = false;
 | 
				
			||||||
    channel_subsys->chnmon_area = 0;
 | 
					    channel_subsys.chnmon_area = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Clear pending CRWs. */
 | 
					    /* Clear pending CRWs. */
 | 
				
			||||||
    while ((crw_cont = QTAILQ_FIRST(&channel_subsys->pending_crws))) {
 | 
					    while ((crw_cont = QTAILQ_FIRST(&channel_subsys.pending_crws))) {
 | 
				
			||||||
        QTAILQ_REMOVE(&channel_subsys->pending_crws, crw_cont, sibling);
 | 
					        QTAILQ_REMOVE(&channel_subsys.pending_crws, crw_cont, sibling);
 | 
				
			||||||
        g_free(crw_cont);
 | 
					        g_free(crw_cont);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    channel_subsys->sei_pending = false;
 | 
					    channel_subsys.sei_pending = false;
 | 
				
			||||||
    channel_subsys->do_crw_mchk = true;
 | 
					    channel_subsys.do_crw_mchk = true;
 | 
				
			||||||
    channel_subsys->crws_lost = false;
 | 
					    channel_subsys.crws_lost = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Reset maximum ids. */
 | 
					    /* Reset maximum ids. */
 | 
				
			||||||
    channel_subsys->max_cssid = 0;
 | 
					    channel_subsys.max_cssid = 0;
 | 
				
			||||||
    channel_subsys->max_ssid = 0;
 | 
					    channel_subsys.max_ssid = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user