[S390] chsc: use the global page to determine the chp desriptor
chsc_determine_channel_path_desc is called by a wrapper who allocates a response struct. The response data is then memcpy'ed to this response struct by chsc_determine_channel_path_desc. Change chsc_determine_base_channel_path_desc to use the global chsc_page and deliver it to the function doing the actual chsc call. The channel path desriptor is then directly read from the response data. As a result we get rid of the additional allocation for the response struct. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
34196f82b1
commit
906c9768c7
|
@ -639,36 +639,18 @@ chsc_secm(struct channel_subsystem *css, int enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
|
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
|
||||||
int c, int m,
|
int c, int m, void *page)
|
||||||
struct chsc_response_struct *resp)
|
|
||||||
{
|
{
|
||||||
|
struct chsc_scpd *scpd_area;
|
||||||
int ccode, ret;
|
int ccode, ret;
|
||||||
|
|
||||||
struct {
|
|
||||||
struct chsc_header request;
|
|
||||||
u32 : 2;
|
|
||||||
u32 m : 1;
|
|
||||||
u32 c : 1;
|
|
||||||
u32 fmt : 4;
|
|
||||||
u32 cssid : 8;
|
|
||||||
u32 : 4;
|
|
||||||
u32 rfmt : 4;
|
|
||||||
u32 first_chpid : 8;
|
|
||||||
u32 : 24;
|
|
||||||
u32 last_chpid : 8;
|
|
||||||
u32 zeroes1;
|
|
||||||
struct chsc_header response;
|
|
||||||
u8 data[PAGE_SIZE - 20];
|
|
||||||
} __attribute__ ((packed)) *scpd_area;
|
|
||||||
|
|
||||||
if ((rfmt == 1) && !css_general_characteristics.fcs)
|
if ((rfmt == 1) && !css_general_characteristics.fcs)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if ((rfmt == 2) && !css_general_characteristics.cib)
|
if ((rfmt == 2) && !css_general_characteristics.cib)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
spin_lock_irq(&chsc_page_lock);
|
memset(page, 0, PAGE_SIZE);
|
||||||
memset(chsc_page, 0, PAGE_SIZE);
|
scpd_area = page;
|
||||||
scpd_area = chsc_page;
|
|
||||||
scpd_area->request.length = 0x0010;
|
scpd_area->request.length = 0x0010;
|
||||||
scpd_area->request.code = 0x0002;
|
scpd_area->request.code = 0x0002;
|
||||||
scpd_area->cssid = chpid.cssid;
|
scpd_area->cssid = chpid.cssid;
|
||||||
|
@ -680,20 +662,13 @@ int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
|
||||||
scpd_area->rfmt = rfmt;
|
scpd_area->rfmt = rfmt;
|
||||||
|
|
||||||
ccode = chsc(scpd_area);
|
ccode = chsc(scpd_area);
|
||||||
if (ccode > 0) {
|
if (ccode > 0)
|
||||||
ret = (ccode == 3) ? -ENODEV : -EBUSY;
|
return (ccode == 3) ? -ENODEV : -EBUSY;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = chsc_error_from_response(scpd_area->response.code);
|
ret = chsc_error_from_response(scpd_area->response.code);
|
||||||
if (ret == 0)
|
if (ret)
|
||||||
/* Success. */
|
|
||||||
memcpy(resp, &scpd_area->response, scpd_area->response.length);
|
|
||||||
else
|
|
||||||
CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
|
CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
|
||||||
scpd_area->response.code);
|
scpd_area->response.code);
|
||||||
out:
|
|
||||||
spin_unlock_irq(&chsc_page_lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
|
EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
|
||||||
|
@ -702,17 +677,18 @@ int chsc_determine_base_channel_path_desc(struct chp_id chpid,
|
||||||
struct channel_path_desc *desc)
|
struct channel_path_desc *desc)
|
||||||
{
|
{
|
||||||
struct chsc_response_struct *chsc_resp;
|
struct chsc_response_struct *chsc_resp;
|
||||||
|
struct chsc_scpd *scpd_area;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
chsc_resp = kzalloc(sizeof(*chsc_resp), GFP_KERNEL);
|
spin_lock_irq(&chsc_page_lock);
|
||||||
if (!chsc_resp)
|
scpd_area = chsc_page;
|
||||||
return -ENOMEM;
|
ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, scpd_area);
|
||||||
ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out;
|
||||||
|
chsc_resp = (void *)&scpd_area->response;
|
||||||
memcpy(desc, &chsc_resp->data, sizeof(*desc));
|
memcpy(desc, &chsc_resp->data, sizeof(*desc));
|
||||||
out_free:
|
out:
|
||||||
kfree(chsc_resp);
|
spin_unlock_irq(&chsc_page_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,25 @@ struct chsc_ssd_info {
|
||||||
struct chp_id chpid[8];
|
struct chp_id chpid[8];
|
||||||
u16 fla[8];
|
u16 fla[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct chsc_scpd {
|
||||||
|
struct chsc_header request;
|
||||||
|
u32:2;
|
||||||
|
u32 m:1;
|
||||||
|
u32 c:1;
|
||||||
|
u32 fmt:4;
|
||||||
|
u32 cssid:8;
|
||||||
|
u32:4;
|
||||||
|
u32 rfmt:4;
|
||||||
|
u32 first_chpid:8;
|
||||||
|
u32:24;
|
||||||
|
u32 last_chpid:8;
|
||||||
|
u32 zeroes1;
|
||||||
|
struct chsc_header response;
|
||||||
|
u8 data[PAGE_SIZE - 20];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
extern int chsc_get_ssd_info(struct subchannel_id schid,
|
extern int chsc_get_ssd_info(struct subchannel_id schid,
|
||||||
struct chsc_ssd_info *ssd);
|
struct chsc_ssd_info *ssd);
|
||||||
extern int chsc_determine_css_characteristics(void);
|
extern int chsc_determine_css_characteristics(void);
|
||||||
|
@ -70,8 +89,7 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable);
|
||||||
|
|
||||||
int chsc_chp_vary(struct chp_id chpid, int on);
|
int chsc_chp_vary(struct chp_id chpid, int on);
|
||||||
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
|
int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
|
||||||
int c, int m,
|
int c, int m, void *page);
|
||||||
struct chsc_response_struct *resp);
|
|
||||||
int chsc_determine_base_channel_path_desc(struct chp_id chpid,
|
int chsc_determine_base_channel_path_desc(struct chp_id chpid,
|
||||||
struct channel_path_desc *desc);
|
struct channel_path_desc *desc);
|
||||||
void chsc_chp_online(struct chp_id chpid);
|
void chsc_chp_online(struct chp_id chpid);
|
||||||
|
|
|
@ -688,25 +688,31 @@ out_free:
|
||||||
|
|
||||||
static int chsc_ioctl_chpd(void __user *user_chpd)
|
static int chsc_ioctl_chpd(void __user *user_chpd)
|
||||||
{
|
{
|
||||||
|
struct chsc_scpd *scpd_area;
|
||||||
struct chsc_cpd_info *chpd;
|
struct chsc_cpd_info *chpd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
chpd = kzalloc(sizeof(*chpd), GFP_KERNEL);
|
chpd = kzalloc(sizeof(*chpd), GFP_KERNEL);
|
||||||
if (!chpd)
|
scpd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
|
||||||
return -ENOMEM;
|
if (!scpd_area || !chpd) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
if (copy_from_user(chpd, user_chpd, sizeof(*chpd))) {
|
if (copy_from_user(chpd, user_chpd, sizeof(*chpd))) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
ret = chsc_determine_channel_path_desc(chpd->chpid, chpd->fmt,
|
ret = chsc_determine_channel_path_desc(chpd->chpid, chpd->fmt,
|
||||||
chpd->rfmt, chpd->c, chpd->m,
|
chpd->rfmt, chpd->c, chpd->m,
|
||||||
&chpd->chpdb);
|
scpd_area);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
memcpy(&chpd->chpdb, &scpd_area->response, scpd_area->response.length);
|
||||||
if (copy_to_user(user_chpd, chpd, sizeof(*chpd)))
|
if (copy_to_user(user_chpd, chpd, sizeof(*chpd)))
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
out_free:
|
out_free:
|
||||||
kfree(chpd);
|
kfree(chpd);
|
||||||
|
free_page((unsigned long)scpd_area);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue