3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
19 #include <linux/kernel.h>
20 #include <linux/module.h>
26 /* this is shorter than using __FILE__ (full path name) in
27 * debug/info/error messages */
28 #define CURRENT_FILE_PC UISLIB_PC_uisqueue_c
29 #define __MYFILE__ "uisqueue.c"
31 #define CHECK_CACHE_ALIGN 0
33 /*****************************************************/
34 /* Exported functions */
35 /*****************************************************/
37 uisqueue_InterlockedOr(unsigned long long __iomem
*Target
,
38 unsigned long long Set
)
46 j
= uislibcmpxchg64((__force
unsigned long long *)Target
,
47 i
, i
| Set
, sizeof(*(Target
)));
53 EXPORT_SYMBOL_GPL(uisqueue_InterlockedOr
);
56 uisqueue_InterlockedAnd(unsigned long long __iomem
*Target
,
57 unsigned long long Set
)
65 j
= uislibcmpxchg64((__force
unsigned long long *)Target
,
66 i
, i
& Set
, sizeof(*(Target
)));
72 EXPORT_SYMBOL_GPL(uisqueue_InterlockedAnd
);
75 do_locked_client_insert(struct uisqueue_info
*queueinfo
,
76 unsigned int whichqueue
,
79 unsigned char issueInterruptIfEmpty
,
80 U64 interruptHandle
, u8
*channelId
)
83 unsigned char queueWasEmpty
;
84 unsigned int locked
= 0;
85 unsigned int acquired
= 0;
88 spin_lock_irqsave(lock
, flags
);
91 if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(queueinfo
->chan
, channelId
, NULL
))
96 queueWasEmpty
= visor_signalqueue_empty(queueinfo
->chan
, whichqueue
);
97 if (!visor_signal_insert(queueinfo
->chan
, whichqueue
, pSignal
))
99 ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo
->chan
, channelId
, NULL
);
101 spin_unlock_irqrestore(lock
, flags
);
104 queueinfo
->packets_sent
++;
109 ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo
->chan
, channelId
,
114 spin_unlock_irqrestore((spinlock_t
*) lock
, flags
);
122 uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info
*queueinfo
,
123 struct uiscmdrsp
*cmdrsp
,
124 unsigned int whichqueue
,
126 unsigned char issueInterruptIfEmpty
,
128 char oktowait
, u8
*channelId
)
130 while (!do_locked_client_insert(queueinfo
, whichqueue
, cmdrsp
,
131 (spinlock_t
*) insertlock
,
132 issueInterruptIfEmpty
,
133 interruptHandle
, channelId
)) {
134 if (oktowait
!= OK_TO_WAIT
) {
135 LOGERR("****FAILED visor_signal_insert failed; cannot wait; insert aborted\n");
136 return 0; /* failed to queue */
139 LOGERR("****FAILED visor_signal_insert failed; waiting to try again\n");
140 set_current_state(TASK_INTERRUPTIBLE
);
141 schedule_timeout(msecs_to_jiffies(10));
145 EXPORT_SYMBOL_GPL(uisqueue_put_cmdrsp_with_lock_client
);
147 /* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
148 * returns NULL if queue is empty */
150 uisqueue_get_cmdrsp(struct uisqueue_info
*queueinfo
,
151 void *cmdrsp
, unsigned int whichqueue
)
153 if (!visor_signal_remove(queueinfo
->chan
, whichqueue
, cmdrsp
))
156 queueinfo
->packets_received
++;
158 return 1; /* Success */
160 EXPORT_SYMBOL_GPL(uisqueue_get_cmdrsp
);