[PATCH] powerpc: remove bitfields from HvLpEvent
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
6814350b80
commit
677f8c0d04
@ -147,20 +147,11 @@ static void int_received(struct pci_event *event, struct pt_regs *regs)
|
||||
static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs)
|
||||
{
|
||||
if (event && (event->xType == HvLpEvent_Type_PciIo)) {
|
||||
switch (event->xFlags.xFunction) {
|
||||
case HvLpEvent_Function_Int:
|
||||
if (hvlpevent_is_int(event))
|
||||
int_received((struct pci_event *)event, regs);
|
||||
break;
|
||||
case HvLpEvent_Function_Ack:
|
||||
else
|
||||
printk(KERN_ERR
|
||||
"pci_event_handler: unexpected ack received\n");
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR
|
||||
"pci_event_handler: unexpected event function %d\n",
|
||||
(int)event->xFlags.xFunction);
|
||||
break;
|
||||
}
|
||||
} else if (event)
|
||||
printk(KERN_ERR
|
||||
"pci_event_handler: Unrecognized PCI event type 0x%x\n",
|
||||
|
@ -53,7 +53,7 @@ static struct HvLpEvent * get_next_hvlpevent(void)
|
||||
struct HvLpEvent * event;
|
||||
event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
|
||||
|
||||
if (event->xFlags.xValid) {
|
||||
if (hvlpevent_is_valid(event)) {
|
||||
/* rmb() needed only for weakly consistent machines (regatta) */
|
||||
rmb();
|
||||
/* Set pointer to next potential event */
|
||||
@ -84,7 +84,7 @@ int hvlpevent_is_pending(void)
|
||||
|
||||
next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
|
||||
|
||||
return next_event->xFlags.xValid |
|
||||
return hvlpevent_is_valid(next_event) ||
|
||||
hvlpevent_queue.xPlicOverflowIntPending;
|
||||
}
|
||||
|
||||
@ -101,18 +101,18 @@ static void hvlpevent_clear_valid(struct HvLpEvent * event)
|
||||
switch (extra) {
|
||||
case 3:
|
||||
tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign);
|
||||
tmp->xFlags.xValid = 0;
|
||||
hvlpevent_invalidate(tmp);
|
||||
case 2:
|
||||
tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign);
|
||||
tmp->xFlags.xValid = 0;
|
||||
hvlpevent_invalidate(tmp);
|
||||
case 1:
|
||||
tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign);
|
||||
tmp->xFlags.xValid = 0;
|
||||
hvlpevent_invalidate(tmp);
|
||||
}
|
||||
|
||||
mb();
|
||||
|
||||
event->xFlags.xValid = 0;
|
||||
hvlpevent_invalidate(event);
|
||||
}
|
||||
|
||||
void process_hvlpevents(struct pt_regs *regs)
|
||||
|
@ -251,10 +251,7 @@ static struct pending_event *new_pending_event(void)
|
||||
}
|
||||
memset(ev, 0, sizeof(struct pending_event));
|
||||
hev = &ev->event.hp_lp_event;
|
||||
hev->xFlags.xValid = 1;
|
||||
hev->xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
|
||||
hev->xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
|
||||
hev->xFlags.xFunction = HvLpEvent_Function_Int;
|
||||
hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DO_ACK | HV_LP_EVENT_INT;
|
||||
hev->xType = HvLpEvent_Type_MachineFac;
|
||||
hev->xSourceLp = HvLpConfig_getLpIndex();
|
||||
hev->xTargetLp = primary_lp;
|
||||
@ -518,17 +515,10 @@ static void handle_ack(struct io_mf_lp_event *event)
|
||||
static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs)
|
||||
{
|
||||
if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
|
||||
switch(event->xFlags.xFunction) {
|
||||
case HvLpEvent_Function_Ack:
|
||||
if (hvlpevent_is_ack(event))
|
||||
handle_ack((struct io_mf_lp_event *)event);
|
||||
break;
|
||||
case HvLpEvent_Function_Int:
|
||||
else
|
||||
handle_int((struct io_mf_lp_event *)event);
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "mf.c: non ack/int event received\n");
|
||||
break;
|
||||
}
|
||||
} else
|
||||
printk(KERN_ERR "mf.c: alien event received\n");
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ static void handleMonitorEvent(struct HvLpEvent *event)
|
||||
* First see if this is just a normal monitor message from the
|
||||
* other partition
|
||||
*/
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
remoteLp = event->xSourceLp;
|
||||
if (!viopathStatus[remoteLp].isActive)
|
||||
sendMonMsg(remoteLp);
|
||||
@ -331,13 +331,12 @@ static void handleConfig(struct HvLpEvent *event)
|
||||
{
|
||||
if (!event)
|
||||
return;
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
printk(VIOPATH_KERN_WARN
|
||||
"unexpected config request from partition %d",
|
||||
event->xSourceLp);
|
||||
|
||||
if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
|
||||
(event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
|
||||
if (hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
@ -377,7 +376,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
|
||||
int subtype = (event->xSubtype & VIOMAJOR_SUBTYPE_MASK)
|
||||
>> VIOMAJOR_SUBTYPE_SHIFT;
|
||||
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
remoteLp = event->xSourceLp;
|
||||
/*
|
||||
* The isActive is checked because if the hosting partition
|
||||
@ -436,8 +435,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
|
||||
"unexpected virtual io event subtype %d from partition %d\n",
|
||||
event->xSubtype, remoteLp);
|
||||
/* No handler. Ack if necessary */
|
||||
if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
|
||||
(event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
|
||||
if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
|
@ -293,6 +293,7 @@ static int send_request(struct request *req)
|
||||
u16 viocmd;
|
||||
HvLpEvent_Rc hvrc;
|
||||
struct vioblocklpevent *bevent;
|
||||
struct HvLpEvent *hev;
|
||||
struct scatterlist sg[VIOMAXBLOCKDMA];
|
||||
int sgindex;
|
||||
int statindex;
|
||||
@ -347,22 +348,19 @@ static int send_request(struct request *req)
|
||||
* token so we can match the response up later
|
||||
*/
|
||||
memset(bevent, 0, sizeof(struct vioblocklpevent));
|
||||
bevent->event.xFlags.xValid = 1;
|
||||
bevent->event.xFlags.xFunction = HvLpEvent_Function_Int;
|
||||
bevent->event.xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
|
||||
bevent->event.xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
|
||||
bevent->event.xType = HvLpEvent_Type_VirtualIo;
|
||||
bevent->event.xSubtype = viocmd;
|
||||
bevent->event.xSourceLp = HvLpConfig_getLpIndex();
|
||||
bevent->event.xTargetLp = viopath_hostLp;
|
||||
bevent->event.xSizeMinus1 =
|
||||
hev = &bevent->event;
|
||||
hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DO_ACK |
|
||||
HV_LP_EVENT_INT;
|
||||
hev->xType = HvLpEvent_Type_VirtualIo;
|
||||
hev->xSubtype = viocmd;
|
||||
hev->xSourceLp = HvLpConfig_getLpIndex();
|
||||
hev->xTargetLp = viopath_hostLp;
|
||||
hev->xSizeMinus1 =
|
||||
offsetof(struct vioblocklpevent, u.rw_data.dma_info) +
|
||||
(sizeof(bevent->u.rw_data.dma_info[0]) * nsg) - 1;
|
||||
bevent->event.xSourceInstanceId =
|
||||
viopath_sourceinst(viopath_hostLp);
|
||||
bevent->event.xTargetInstanceId =
|
||||
viopath_targetinst(viopath_hostLp);
|
||||
bevent->event.xCorrelationToken = (u64)req;
|
||||
hev->xSourceInstanceId = viopath_sourceinst(viopath_hostLp);
|
||||
hev->xTargetInstanceId = viopath_targetinst(viopath_hostLp);
|
||||
hev->xCorrelationToken = (u64)req;
|
||||
bevent->version = VIOVERSION;
|
||||
bevent->disk = DEVICE_NO(d);
|
||||
bevent->u.rw_data.offset = start;
|
||||
@ -649,10 +647,10 @@ static void handle_block_event(struct HvLpEvent *event)
|
||||
/* Notification that a partition went away! */
|
||||
return;
|
||||
/* First, we should NEVER get an int here...only acks */
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
printk(VIOD_KERN_WARNING
|
||||
"Yikes! got an int in viodasd event handler!\n");
|
||||
if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
|
||||
if (hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
@ -695,7 +693,7 @@ static void handle_block_event(struct HvLpEvent *event)
|
||||
|
||||
default:
|
||||
printk(VIOD_KERN_WARNING "invalid subtype!");
|
||||
if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
|
||||
if (hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
|
@ -542,10 +542,10 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
|
||||
/* Notification that a partition went away! */
|
||||
return;
|
||||
/* First, we should NEVER get an int here...only acks */
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
printk(VIOCD_KERN_WARNING
|
||||
"Yikes! got an int in viocd event handler!\n");
|
||||
if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
|
||||
if (hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
@ -616,7 +616,7 @@ return_complete:
|
||||
printk(VIOCD_KERN_WARNING
|
||||
"message with invalid subtype %0x04X!\n",
|
||||
event->xSubtype & VIOMINOR_SUBTYPE_MASK);
|
||||
if (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck) {
|
||||
if (hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
|
@ -476,19 +476,19 @@ static struct port_info *get_port_data(struct tty_struct *tty)
|
||||
*/
|
||||
static void initDataEvent(struct viocharlpevent *viochar, HvLpIndex lp)
|
||||
{
|
||||
struct HvLpEvent *hev = &viochar->event;
|
||||
|
||||
memset(viochar, 0, sizeof(struct viocharlpevent));
|
||||
|
||||
viochar->event.xFlags.xValid = 1;
|
||||
viochar->event.xFlags.xFunction = HvLpEvent_Function_Int;
|
||||
viochar->event.xFlags.xAckInd = HvLpEvent_AckInd_NoAck;
|
||||
viochar->event.xFlags.xAckType = HvLpEvent_AckType_DeferredAck;
|
||||
viochar->event.xType = HvLpEvent_Type_VirtualIo;
|
||||
viochar->event.xSubtype = viomajorsubtype_chario | viochardata;
|
||||
viochar->event.xSourceLp = HvLpConfig_getLpIndex();
|
||||
viochar->event.xTargetLp = lp;
|
||||
viochar->event.xSizeMinus1 = sizeof(struct viocharlpevent);
|
||||
viochar->event.xSourceInstanceId = viopath_sourceinst(lp);
|
||||
viochar->event.xTargetInstanceId = viopath_targetinst(lp);
|
||||
hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK |
|
||||
HV_LP_EVENT_INT;
|
||||
hev->xType = HvLpEvent_Type_VirtualIo;
|
||||
hev->xSubtype = viomajorsubtype_chario | viochardata;
|
||||
hev->xSourceLp = HvLpConfig_getLpIndex();
|
||||
hev->xTargetLp = lp;
|
||||
hev->xSizeMinus1 = sizeof(struct viocharlpevent);
|
||||
hev->xSourceInstanceId = viopath_sourceinst(lp);
|
||||
hev->xTargetInstanceId = viopath_targetinst(lp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -752,7 +752,7 @@ static void vioHandleOpenEvent(struct HvLpEvent *event)
|
||||
struct port_info *pi;
|
||||
int reject = 0;
|
||||
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Ack) {
|
||||
if (hvlpevent_is_ack(event)) {
|
||||
if (port >= VTTY_PORTS)
|
||||
return;
|
||||
|
||||
@ -788,7 +788,7 @@ static void vioHandleOpenEvent(struct HvLpEvent *event)
|
||||
}
|
||||
|
||||
/* This had better require an ack, otherwise complain */
|
||||
if (event->xFlags.xAckInd != HvLpEvent_AckInd_DoAck) {
|
||||
if (!hvlpevent_need_ack(event)) {
|
||||
printk(VIOCONS_KERN_WARN "viocharopen without ack bit!\n");
|
||||
return;
|
||||
}
|
||||
@ -856,7 +856,7 @@ static void vioHandleCloseEvent(struct HvLpEvent *event)
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
u8 port = cevent->virtual_device;
|
||||
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
|
||||
if (hvlpevent_is_int(event)) {
|
||||
if (port >= VTTY_PORTS) {
|
||||
printk(VIOCONS_KERN_WARN
|
||||
"close message from invalid virtual device.\n");
|
||||
@ -1056,8 +1056,7 @@ static void vioHandleCharEvent(struct HvLpEvent *event)
|
||||
vioHandleConfig(event);
|
||||
break;
|
||||
default:
|
||||
if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
|
||||
(event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
|
||||
if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
|
@ -590,9 +590,9 @@ static void veth_handle_event(struct HvLpEvent *event, struct pt_regs *regs)
|
||||
{
|
||||
struct veth_lpevent *veth_event = (struct veth_lpevent *)event;
|
||||
|
||||
if (event->xFlags.xFunction == HvLpEvent_Function_Ack)
|
||||
if (hvlpevent_is_ack(event))
|
||||
veth_handle_ack(veth_event);
|
||||
else if (event->xFlags.xFunction == HvLpEvent_Function_Int)
|
||||
else
|
||||
veth_handle_int(veth_event);
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,8 @@
|
||||
* partitions through PLIC.
|
||||
*/
|
||||
|
||||
struct HvEventFlags {
|
||||
u8 xValid:1; /* Indicates a valid request x00-x00 */
|
||||
u8 xRsvd1:4; /* Reserved ... */
|
||||
u8 xAckType:1; /* Immediate or deferred ... */
|
||||
u8 xAckInd:1; /* Indicates if ACK required ... */
|
||||
u8 xFunction:1; /* Interrupt or Acknowledge ... */
|
||||
};
|
||||
|
||||
|
||||
struct HvLpEvent {
|
||||
struct HvEventFlags xFlags; /* Event flags x00-x00 */
|
||||
u8 flags; /* Event flags x00-x00 */
|
||||
u8 xType; /* Type of message x01-x01 */
|
||||
u16 xSubtype; /* Subtype for event x02-x03 */
|
||||
u8 xSourceLp; /* Source LP x04-x04 */
|
||||
@ -126,6 +117,11 @@ extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
|
||||
#define HvLpEvent_AckType_ImmediateAck 0
|
||||
#define HvLpEvent_AckType_DeferredAck 1
|
||||
|
||||
#define HV_LP_EVENT_INT 0x01
|
||||
#define HV_LP_EVENT_DO_ACK 0x02
|
||||
#define HV_LP_EVENT_DEFERRED_ACK 0x04
|
||||
#define HV_LP_EVENT_VALID 0x80
|
||||
|
||||
#define HvLpDma_Direction_LocalToRemote 0
|
||||
#define HvLpDma_Direction_RemoteToLocal 1
|
||||
|
||||
@ -139,4 +135,29 @@ extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
|
||||
#define HvLpDma_Rc_InvalidAddress 4
|
||||
#define HvLpDma_Rc_InvalidLength 5
|
||||
|
||||
static inline int hvlpevent_is_valid(struct HvLpEvent *h)
|
||||
{
|
||||
return h->flags & HV_LP_EVENT_VALID;
|
||||
}
|
||||
|
||||
static inline void hvlpevent_invalidate(struct HvLpEvent *h)
|
||||
{
|
||||
h->flags &= ~ HV_LP_EVENT_VALID;
|
||||
}
|
||||
|
||||
static inline int hvlpevent_is_int(struct HvLpEvent *h)
|
||||
{
|
||||
return h->flags & HV_LP_EVENT_INT;
|
||||
}
|
||||
|
||||
static inline int hvlpevent_is_ack(struct HvLpEvent *h)
|
||||
{
|
||||
return !hvlpevent_is_int(h);
|
||||
}
|
||||
|
||||
static inline int hvlpevent_need_ack(struct HvLpEvent *h)
|
||||
{
|
||||
return h->flags & HV_LP_EVENT_DO_ACK;
|
||||
}
|
||||
|
||||
#endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user