Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x-2.6

* 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6:
  [S390] monwriter: Serialization bug for multithreaded applications.
  [S390] vmur: diag14 only works with buffers below 2GB
  [S390] vmur: add "top of queue" sanity check for reader open
  [S390] vmur: reject open on z/VM reader files with status HOLD
  [S390] vmur: use DECLARE_COMPLETION_ONSTACK to keep lockdep happy
  [S390] vmur: allocate single record buffers instead of one big data buffer
  [S390] remove DEFAULT_MIGRATION_COST
  [S390] qdio: make sure data structures are correctly aligned.
  [S390] hypfs: implement show_options
  [S390] cio: avoid memory leak on error in css_alloc_subchannel().
  • Loading branch information
Linus Torvalds committed Aug 11, 2007
2 parents 75ecb1a + cbea66d commit 3864e8c
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 118 deletions.
4 changes: 0 additions & 4 deletions arch/s390/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ config HOTPLUG_CPU
can be controlled through /sys/devices/system/cpu/cpu#.
Say N if you want to disable CPU hotplug.

config DEFAULT_MIGRATION_COST
int
default "1000000"

config MATHEMU
bool "IEEE FPU emulation"
depends on MARCH_G5
Expand Down
12 changes: 12 additions & 0 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <linux/parser.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/mount.h>
#include <asm/ebcdic.h>
#include "hypfs.h"

Expand Down Expand Up @@ -256,6 +258,15 @@ static int hypfs_parse_options(char *options, struct super_block *sb)
return 0;
}

static int hypfs_show_options(struct seq_file *s, struct vfsmount *mnt)
{
struct hypfs_sb_info *hypfs_info = mnt->mnt_sb->s_fs_info;

seq_printf(s, ",uid=%u", hypfs_info->uid);
seq_printf(s, ",gid=%u", hypfs_info->gid);
return 0;
}

static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
{
struct inode *root_inode;
Expand Down Expand Up @@ -459,6 +470,7 @@ static struct file_system_type hypfs_type = {
static struct super_operations hypfs_s_ops = {
.statfs = simple_statfs,
.drop_inode = hypfs_drop_inode,
.show_options = hypfs_show_options,
};

static decl_subsys(s390, NULL, NULL);
Expand Down
6 changes: 6 additions & 0 deletions drivers/s390/char/monwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/miscdevice.h>
#include <linux/ctype.h>
#include <linux/poll.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/ebcdic.h>
#include <asm/io.h>
Expand All @@ -41,6 +42,7 @@ struct mon_private {
size_t hdr_to_read;
size_t data_to_read;
struct mon_buf *current_buf;
struct mutex thread_mutex;
};

/*
Expand Down Expand Up @@ -179,6 +181,7 @@ static int monwrite_open(struct inode *inode, struct file *filp)
return -ENOMEM;
INIT_LIST_HEAD(&monpriv->list);
monpriv->hdr_to_read = sizeof(monpriv->hdr);
mutex_init(&monpriv->thread_mutex);
filp->private_data = monpriv;
return nonseekable_open(inode, filp);
}
Expand Down Expand Up @@ -209,6 +212,7 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
void *to;
int rc;

mutex_lock(&monpriv->thread_mutex);
for (written = 0; written < count; ) {
if (monpriv->hdr_to_read) {
len = min(count - written, monpriv->hdr_to_read);
Expand Down Expand Up @@ -247,11 +251,13 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
}
monpriv->hdr_to_read = sizeof(monpriv->hdr);
}
mutex_unlock(&monpriv->thread_mutex);
return written;

out_error:
monpriv->data_to_read = 0;
monpriv->hdr_to_read = sizeof(struct monwrite_hdr);
mutex_unlock(&monpriv->thread_mutex);
return rc;
}

Expand Down
176 changes: 108 additions & 68 deletions drivers/s390/char/vmur.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ static void urdev_put(struct urdev *urd)
/*
* Low-level functions to do I/O to a ur device.
* alloc_chan_prog
* free_chan_prog
* do_ur_io
* ur_int_handler
*
* alloc_chan_prog allocates and builds the channel program
* free_chan_prog frees memory of the channel program
*
* do_ur_io issues the channel program to the device and blocks waiting
* on a completion event it publishes at urd->io_done. The function
Expand All @@ -137,59 +139,70 @@ static void urdev_put(struct urdev *urd)
* address pointer that alloc_chan_prog returned.
*/

static void free_chan_prog(struct ccw1 *cpa)
{
struct ccw1 *ptr = cpa;

while (ptr->cda) {
kfree((void *)(addr_t) ptr->cda);
ptr++;
}
kfree(cpa);
}

/*
* alloc_chan_prog
* The channel program we use is write commands chained together
* with a final NOP CCW command-chained on (which ensures that CE and DE
* are presented together in a single interrupt instead of as separate
* interrupts unless an incorrect length indication kicks in first). The
* data length in each CCW is reclen. The caller must ensure that count
* is an integral multiple of reclen.
* The channel program pointer returned by this function must be freed
* with kfree. The caller is responsible for checking that
* count/reclen is not ridiculously large.
* data length in each CCW is reclen.
*/
static struct ccw1 *alloc_chan_prog(char *buf, size_t count, size_t reclen)
static struct ccw1 *alloc_chan_prog(const char __user *ubuf, int rec_count,
int reclen)
{
size_t num_ccws;
struct ccw1 *cpa;
void *kbuf;
int i;

TRACE("alloc_chan_prog(%p, %zu, %zu)\n", buf, count, reclen);
TRACE("alloc_chan_prog(%p, %i, %i)\n", ubuf, rec_count, reclen);

/*
* We chain a NOP onto the writes to force CE+DE together.
* That means we allocate room for CCWs to cover count/reclen
* records plus a NOP.
*/
num_ccws = count / reclen + 1;
cpa = kmalloc(num_ccws * sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
cpa = kzalloc((rec_count + 1) * sizeof(struct ccw1),
GFP_KERNEL | GFP_DMA);
if (!cpa)
return NULL;
return ERR_PTR(-ENOMEM);

for (i = 0; count; i++) {
for (i = 0; i < rec_count; i++) {
cpa[i].cmd_code = WRITE_CCW_CMD;
cpa[i].flags = CCW_FLAG_CC | CCW_FLAG_SLI;
cpa[i].count = reclen;
cpa[i].cda = __pa(buf);
buf += reclen;
count -= reclen;
kbuf = kmalloc(reclen, GFP_KERNEL | GFP_DMA);
if (!kbuf) {
free_chan_prog(cpa);
return ERR_PTR(-ENOMEM);
}
cpa[i].cda = (u32)(addr_t) kbuf;
if (copy_from_user(kbuf, ubuf, reclen)) {
free_chan_prog(cpa);
return ERR_PTR(-EFAULT);
}
ubuf += reclen;
}
/* The following NOP CCW forces CE+DE to be presented together */
cpa[i].cmd_code = CCW_CMD_NOOP;
cpa[i].flags = 0;
cpa[i].count = 0;
cpa[i].cda = 0;

return cpa;
}

static int do_ur_io(struct urdev *urd, struct ccw1 *cpa)
{
int rc;
struct ccw_device *cdev = urd->cdev;
DECLARE_COMPLETION(event);
DECLARE_COMPLETION_ONSTACK(event);

TRACE("do_ur_io: cpa=%p\n", cpa);

Expand Down Expand Up @@ -325,24 +338,11 @@ static ssize_t do_write(struct urdev *urd, const char __user *udata,
size_t count, size_t reclen, loff_t *ppos)
{
struct ccw1 *cpa;
char *buf;
int rc;

/* Data buffer must be under 2GB line for fmt1 CCWs: hence GFP_DMA */
buf = kmalloc(count, GFP_KERNEL | GFP_DMA);
if (!buf)
return -ENOMEM;

if (copy_from_user(buf, udata, count)) {
rc = -EFAULT;
goto fail_kfree_buf;
}

cpa = alloc_chan_prog(buf, count, reclen);
if (!cpa) {
rc = -ENOMEM;
goto fail_kfree_buf;
}
cpa = alloc_chan_prog(udata, count / reclen, reclen);
if (IS_ERR(cpa))
return PTR_ERR(cpa);

rc = do_ur_io(urd, cpa);
if (rc)
Expand All @@ -354,10 +354,9 @@ static ssize_t do_write(struct urdev *urd, const char __user *udata,
}
*ppos += count;
rc = count;

fail_kfree_cpa:
kfree(cpa);
fail_kfree_buf:
kfree(buf);
free_chan_prog(cpa);
return rc;
}

Expand Down Expand Up @@ -473,7 +472,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
return rc;

len = min((size_t) PAGE_SIZE, count);
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
if (!buf)
return -ENOMEM;

Expand All @@ -500,7 +499,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
*offs += copied;
rc = copied;
fail:
kfree(buf);
free_page((unsigned long) buf);
return rc;
}

Expand Down Expand Up @@ -543,56 +542,97 @@ static int diag_read_next_file_info(struct file_control_block *buf, int spid)
}
}

static int verify_device(struct urdev *urd)
static int verify_uri_device(struct urdev *urd)
{
struct file_control_block fcb;
struct file_control_block *fcb;
char *buf;
int rc;

fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA);
if (!fcb)
return -ENOMEM;

/* check for empty reader device (beginning of chain) */
rc = diag_read_next_file_info(fcb, 0);
if (rc)
goto fail_free_fcb;

/* if file is in hold status, we do not read it */
if (fcb->file_stat & (FLG_SYSTEM_HOLD | FLG_USER_HOLD)) {
rc = -EPERM;
goto fail_free_fcb;
}

/* open file on virtual reader */
buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
if (!buf) {
rc = -ENOMEM;
goto fail_free_fcb;
}
rc = diag_read_file(urd->dev_id.devno, buf);
if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */
goto fail_free_buf;

/* check if the file on top of the queue is open now */
rc = diag_read_next_file_info(fcb, 0);
if (rc)
goto fail_free_buf;
if (!(fcb->file_stat & FLG_IN_USE)) {
rc = -EMFILE;
goto fail_free_buf;
}
rc = 0;

fail_free_buf:
free_page((unsigned long) buf);
fail_free_fcb:
kfree(fcb);
return rc;
}

static int verify_device(struct urdev *urd)
{
switch (urd->class) {
case DEV_CLASS_UR_O:
return 0; /* no check needed here */
case DEV_CLASS_UR_I:
/* check for empty reader device (beginning of chain) */
rc = diag_read_next_file_info(&fcb, 0);
if (rc)
return rc;

/* open file on virtual reader */
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;
rc = diag_read_file(urd->dev_id.devno, buf);
kfree(buf);

if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */
return rc;
return 0;
return verify_uri_device(urd);
default:
return -ENOTSUPP;
}
}

static int get_file_reclen(struct urdev *urd)
static int get_uri_file_reclen(struct urdev *urd)
{
struct file_control_block fcb;
struct file_control_block *fcb;
int rc;

fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA);
if (!fcb)
return -ENOMEM;
rc = diag_read_next_file_info(fcb, 0);
if (rc)
goto fail_free;
if (fcb->file_stat & FLG_CP_DUMP)
rc = 0;
else
rc = fcb->rec_len;

fail_free:
kfree(fcb);
return rc;
}

static int get_file_reclen(struct urdev *urd)
{
switch (urd->class) {
case DEV_CLASS_UR_O:
return 0;
case DEV_CLASS_UR_I:
rc = diag_read_next_file_info(&fcb, 0);
if (rc)
return rc;
break;
return get_uri_file_reclen(urd);
default:
return -ENOTSUPP;
}
if (fcb.file_stat & FLG_CP_DUMP)
return 0;

return fcb.rec_len;
}

static int ur_open(struct inode *inode, struct file *file)
Expand Down
5 changes: 4 additions & 1 deletion drivers/s390/char/vmur.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ struct file_control_block {
char rest[200];
} __attribute__ ((packed));

#define FLG_CP_DUMP 0x10
#define FLG_SYSTEM_HOLD 0x04
#define FLG_CP_DUMP 0x10
#define FLG_USER_HOLD 0x20
#define FLG_IN_USE 0x80

/*
* A struct urdev is created for each ur device that is made available
Expand Down
1 change: 1 addition & 0 deletions drivers/s390/cio/css.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ css_alloc_subchannel(struct subchannel_id schid)
sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
ret = cio_modify(sch);
if (ret) {
kfree(sch->lock);
kfree(sch);
return ERR_PTR(ret);
}
Expand Down
Loading

0 comments on commit 3864e8c

Please sign in to comment.