Commit d7f1589a authored by David Kershner's avatar David Kershner Committed by Greg Kroah-Hartman

staging: unisys: Use size of channel defined in the channel.

The size of the channel should be pulled from the channel header, not
from the message. All channels must be at least the size of the
channel_header.
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Reviewed-by: default avatarTim Sell <timothy.sell@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ebef2610
...@@ -38,12 +38,10 @@ int visorbus_init(void); ...@@ -38,12 +38,10 @@ int visorbus_init(void);
void visorbus_exit(void); void visorbus_exit(void);
/* visorchannel access functions */ /* visorchannel access functions */
struct visorchannel *visorchannel_create(u64 physaddr, struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp,
unsigned long channel_bytes, const guid_t *guid);
gfp_t gfp, const guid_t *guid); struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp,
struct visorchannel *visorchannel_create_with_lock(u64 physaddr, const guid_t *guid);
unsigned long channel_bytes,
gfp_t gfp, const guid_t *guid);
void visorchannel_destroy(struct visorchannel *channel); void visorchannel_destroy(struct visorchannel *channel);
int visorchannel_read(struct visorchannel *channel, ulong offset, int visorchannel_read(struct visorchannel *channel, ulong offset,
void *dest, ulong nbytes); void *dest, ulong nbytes);
......
...@@ -363,17 +363,8 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue, ...@@ -363,17 +363,8 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue,
* for a data area in memory, but does NOT modify * for a data area in memory, but does NOT modify
* this data area * this data area
* @physaddr: physical address of start of channel * @physaddr: physical address of start of channel
* @channel_bytes: size of the channel in bytes; this may 0 if the channel has
* already been initialized in memory (which is true for all
* channels provided to guest environments by the s-Par
* back-end), in which case the actual channel size will be
* read from the channel header in memory
* @gfp: gfp_t to use when allocating memory for the data struct * @gfp: gfp_t to use when allocating memory for the data struct
* @guid: GUID that identifies channel type; this may 0 if the channel * @guid: GUID that identifies channel type;
* has already been initialized in memory (which is true for all
* channels provided to guest environments by the s-Par
* back-end), in which case the actual channel guid will be
* read from the channel header in memory
* @needs_lock: must specify true if you have multiple threads of execution * @needs_lock: must specify true if you have multiple threads of execution
* that will be calling visorchannel methods of this * that will be calling visorchannel methods of this
* visorchannel at the same time * visorchannel at the same time
...@@ -381,11 +372,9 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue, ...@@ -381,11 +372,9 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue,
* Return: pointer to visorchannel that was created if successful, * Return: pointer to visorchannel that was created if successful,
* otherwise NULL * otherwise NULL
*/ */
static struct visorchannel *visorchannel_create_guts( static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp,
u64 physaddr, const guid_t *guid,
unsigned long channel_bytes, bool needs_lock)
gfp_t gfp, const guid_t *guid,
bool needs_lock)
{ {
struct visorchannel *channel; struct visorchannel *channel;
int err; int err;
...@@ -423,35 +412,28 @@ static struct visorchannel *visorchannel_create_guts( ...@@ -423,35 +412,28 @@ static struct visorchannel *visorchannel_create_guts(
channel->physaddr = physaddr; channel->physaddr = physaddr;
channel->nbytes = size; channel->nbytes = size;
err = visorchannel_read(channel, 0, &channel->chan_hdr, err = visorchannel_read(channel, 0, &channel->chan_hdr, size);
sizeof(struct channel_header));
if (err) if (err)
goto err_destroy_channel; goto err_destroy_channel;
size = (ulong)channel->chan_hdr.size;
/* we had better be a CLIENT of this channel */
if (channel_bytes == 0)
channel_bytes = (ulong)channel->chan_hdr.size;
if (guid_is_null(guid))
guid = &channel->chan_hdr.chtype;
memunmap(channel->mapped); memunmap(channel->mapped);
if (channel->requested) if (channel->requested)
release_mem_region(channel->physaddr, channel->nbytes); release_mem_region(channel->physaddr, channel->nbytes);
channel->mapped = NULL; channel->mapped = NULL;
channel->requested = request_mem_region(channel->physaddr, channel->requested = request_mem_region(channel->physaddr, size,
channel_bytes, VISOR_DRV_NAME); VISOR_DRV_NAME);
if (!channel->requested && !guid_equal(guid, &visor_video_guid)) if (!channel->requested && !guid_equal(guid, &visor_video_guid))
/* we only care about errors if this is not the video channel */ /* we only care about errors if this is not the video channel */
goto err_destroy_channel; goto err_destroy_channel;
channel->mapped = memremap(channel->physaddr, channel_bytes, channel->mapped = memremap(channel->physaddr, size, MEMREMAP_WB);
MEMREMAP_WB);
if (!channel->mapped) { if (!channel->mapped) {
release_mem_region(channel->physaddr, channel_bytes); release_mem_region(channel->physaddr, size);
goto err_destroy_channel; goto err_destroy_channel;
} }
channel->nbytes = channel_bytes; channel->nbytes = size;
guid_copy(&channel->guid, guid); guid_copy(&channel->guid, guid);
return channel; return channel;
...@@ -460,20 +442,16 @@ static struct visorchannel *visorchannel_create_guts( ...@@ -460,20 +442,16 @@ static struct visorchannel *visorchannel_create_guts(
return NULL; return NULL;
} }
struct visorchannel *visorchannel_create(u64 physaddr, struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp,
unsigned long channel_bytes, const guid_t *guid)
gfp_t gfp, const guid_t *guid)
{ {
return visorchannel_create_guts(physaddr, channel_bytes, gfp, guid, return visorchannel_create_guts(physaddr, gfp, guid, false);
false);
} }
struct visorchannel *visorchannel_create_with_lock(u64 physaddr, struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp,
unsigned long channel_bytes, const guid_t *guid)
gfp_t gfp, const guid_t *guid)
{ {
return visorchannel_create_guts(physaddr, channel_bytes, gfp, guid, return visorchannel_create_guts(physaddr, gfp, guid, true);
true);
} }
/** /**
......
...@@ -567,7 +567,6 @@ static int visorbus_create(struct controlvm_message *inmsg) ...@@ -567,7 +567,6 @@ static int visorbus_create(struct controlvm_message *inmsg)
} }
visorchannel = visorchannel_create(cmd->create_bus.channel_addr, visorchannel = visorchannel_create(cmd->create_bus.channel_addr,
cmd->create_bus.channel_bytes,
GFP_KERNEL, GFP_KERNEL,
&cmd->create_bus.bus_data_type_guid); &cmd->create_bus.bus_data_type_guid);
if (!visorchannel) { if (!visorchannel) {
...@@ -789,7 +788,6 @@ static int visorbus_device_create(struct controlvm_message *inmsg) ...@@ -789,7 +788,6 @@ static int visorbus_device_create(struct controlvm_message *inmsg)
visorchannel = visorchannel =
visorchannel_create_with_lock(cmd->create_device.channel_addr, visorchannel_create_with_lock(cmd->create_device.channel_addr,
cmd->create_device.channel_bytes,
GFP_KERNEL, GFP_KERNEL,
&cmd->create_device.data_type_guid); &cmd->create_device.data_type_guid);
if (!visorchannel) { if (!visorchannel) {
...@@ -1326,7 +1324,6 @@ static int controlvm_channel_create(struct visorchipset_device *dev) ...@@ -1326,7 +1324,6 @@ static int controlvm_channel_create(struct visorchipset_device *dev)
{ {
struct visorchannel *chan; struct visorchannel *chan;
u64 addr; u64 addr;
u32 size;
int err; int err;
err = unisys_vmcall(VMCALL_CONTROLVM_ADDR, err = unisys_vmcall(VMCALL_CONTROLVM_ADDR,
...@@ -1334,8 +1331,7 @@ static int controlvm_channel_create(struct visorchipset_device *dev) ...@@ -1334,8 +1331,7 @@ static int controlvm_channel_create(struct visorchipset_device *dev)
if (err) if (err)
return err; return err;
addr = dev->controlvm_params.address; addr = dev->controlvm_params.address;
size = dev->controlvm_params.channel_bytes; chan = visorchannel_create_with_lock(addr, GFP_KERNEL,
chan = visorchannel_create_with_lock(addr, size, GFP_KERNEL,
&visor_controlvm_channel_guid); &visor_controlvm_channel_guid);
if (!chan) if (!chan)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment