aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/pti.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:09:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:09:27 -0400
commitd5ef642355bdd9b383ff5c18cbc6102a06eecbaf (patch)
treefcf78d33c1790c6c24efbfd0c3695f7874f053d7 /drivers/misc/pti.c
parentf549953c15deab4c54708b39af86d4edecc6cddc (diff)
parentdef90f4239f094f3846c108c1c41a4cd55c33e8e (diff)
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (26 commits) amba pl011: workaround for uart registers lockup n_gsm: fix the wrong FCS handling pch_uart: add missing comment about OKI ML7223 pch_uart: Add MSI support tty: fix "IRQ45: nobody cared" PTI feature to allow user to name and mark masterchannel request. 0 for o PTI Makefile bug. tty: serial: samsung.c remove legacy PM code. SERIAL: SC26xx: Fix link error. serial: mrst_max3110: initialize waitqueue earlier mrst_max3110: Change max missing message priority. tty: s5pv210: Add delay loop on fifo reset function for UART tty/serial: Fix XSCALE serial ports, e.g. ce4100 serial: bfin_5xx: fix off-by-one with resource size drivers/tty: use printk_ratelimited() instead of printk_ratelimit() tty: n_gsm: Added refcount usage to gsm_mux and gsm_dlci structs tty: n_gsm: Add raw-ip support tty: n_gsm: expose gsmtty device nodes at ldisc open time pch_phub: Fix register miss-setting issue serial: 8250, increase PASS_LIMIT ...
Diffstat (limited to 'drivers/misc/pti.c')
-rw-r--r--drivers/misc/pti.c99
1 files changed, 60 insertions, 39 deletions
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index e5f295a38a34..8653bd0b1a33 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -146,45 +146,54 @@ static void pti_write_to_aperture(struct pti_masterchannel *mc,
146/** 146/**
147 * pti_control_frame_built_and_sent()- control frame build and send function. 147 * pti_control_frame_built_and_sent()- control frame build and send function.
148 * 148 *
149 * @mc: The master / channel structure on which the function 149 * @mc: The master / channel structure on which the function
150 * built a control frame. 150 * built a control frame.
151 * @thread_name: The thread name associated with the master / channel or
152 * 'NULL' if using the 'current' global variable.
151 * 153 *
152 * To be able to post process the PTI contents on host side, a control frame 154 * To be able to post process the PTI contents on host side, a control frame
153 * is added before sending any PTI content. So the host side knows on 155 * is added before sending any PTI content. So the host side knows on
154 * each PTI frame the name of the thread using a dedicated master / channel. 156 * each PTI frame the name of the thread using a dedicated master / channel.
155 * The thread name is retrieved from the 'current' global variable. 157 * The thread name is retrieved from 'current' global variable if 'thread_name'
158 * is 'NULL', else it is retrieved from 'thread_name' parameter.
156 * This function builds this frame and sends it to a master ID CONTROL_ID. 159 * This function builds this frame and sends it to a master ID CONTROL_ID.
157 * The overhead is only 32 bytes since the driver only writes to HW 160 * The overhead is only 32 bytes since the driver only writes to HW
158 * in 32 byte chunks. 161 * in 32 byte chunks.
159 */ 162 */
160 163static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc,
161static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc) 164 const char *thread_name)
162{ 165{
163 struct pti_masterchannel mccontrol = {.master = CONTROL_ID, 166 struct pti_masterchannel mccontrol = {.master = CONTROL_ID,
164 .channel = 0}; 167 .channel = 0};
168 const char *thread_name_p;
165 const char *control_format = "%3d %3d %s"; 169 const char *control_format = "%3d %3d %s";
166 u8 control_frame[CONTROL_FRAME_LEN]; 170 u8 control_frame[CONTROL_FRAME_LEN];
167 171
168 /* 172 if (!thread_name) {
169 * Since we access the comm member in current's task_struct, 173 /*
170 * we only need to be as large as what 'comm' in that 174 * Since we access the comm member in current's task_struct,
171 * structure is. 175 * we only need to be as large as what 'comm' in that
172 */ 176 * structure is.
173 char comm[TASK_COMM_LEN]; 177 */
178 char comm[TASK_COMM_LEN];
174 179
175 if (!in_interrupt()) 180 if (!in_interrupt())
176 get_task_comm(comm, current); 181 get_task_comm(comm, current);
177 else 182 else
178 strncpy(comm, "Interrupt", TASK_COMM_LEN); 183 strncpy(comm, "Interrupt", TASK_COMM_LEN);
179 184
180 /* Absolutely ensure our buffer is zero terminated. */ 185 /* Absolutely ensure our buffer is zero terminated. */
181 comm[TASK_COMM_LEN-1] = 0; 186 comm[TASK_COMM_LEN-1] = 0;
187 thread_name_p = comm;
188 } else {
189 thread_name_p = thread_name;
190 }
182 191
183 mccontrol.channel = pti_control_channel; 192 mccontrol.channel = pti_control_channel;
184 pti_control_channel = (pti_control_channel + 1) & 0x7f; 193 pti_control_channel = (pti_control_channel + 1) & 0x7f;
185 194
186 snprintf(control_frame, CONTROL_FRAME_LEN, control_format, mc->master, 195 snprintf(control_frame, CONTROL_FRAME_LEN, control_format, mc->master,
187 mc->channel, comm); 196 mc->channel, thread_name_p);
188 pti_write_to_aperture(&mccontrol, control_frame, strlen(control_frame)); 197 pti_write_to_aperture(&mccontrol, control_frame, strlen(control_frame));
189} 198}
190 199
@@ -206,18 +215,20 @@ static void pti_write_full_frame_to_aperture(struct pti_masterchannel *mc,
206 const unsigned char *buf, 215 const unsigned char *buf,
207 int len) 216 int len)
208{ 217{
209 pti_control_frame_built_and_sent(mc); 218 pti_control_frame_built_and_sent(mc, NULL);
210 pti_write_to_aperture(mc, (u8 *)buf, len); 219 pti_write_to_aperture(mc, (u8 *)buf, len);
211} 220}
212 221
213/** 222/**
214 * get_id()- Allocate a master and channel ID. 223 * get_id()- Allocate a master and channel ID.
215 * 224 *
216 * @id_array: an array of bits representing what channel 225 * @id_array: an array of bits representing what channel
217 * id's are allocated for writing. 226 * id's are allocated for writing.
218 * @max_ids: The max amount of available write IDs to use. 227 * @max_ids: The max amount of available write IDs to use.
219 * @base_id: The starting SW channel ID, based on the Intel 228 * @base_id: The starting SW channel ID, based on the Intel
220 * PTI arch. 229 * PTI arch.
230 * @thread_name: The thread name associated with the master / channel or
231 * 'NULL' if using the 'current' global variable.
221 * 232 *
222 * Returns: 233 * Returns:
223 * pti_masterchannel struct with master, channel ID address 234 * pti_masterchannel struct with master, channel ID address
@@ -227,7 +238,10 @@ static void pti_write_full_frame_to_aperture(struct pti_masterchannel *mc,
227 * channel id. The bit is one if the id is taken and 0 if free. For 238 * channel id. The bit is one if the id is taken and 0 if free. For
228 * every master there are 128 channel id's. 239 * every master there are 128 channel id's.
229 */ 240 */
230static struct pti_masterchannel *get_id(u8 *id_array, int max_ids, int base_id) 241static struct pti_masterchannel *get_id(u8 *id_array,
242 int max_ids,
243 int base_id,
244 const char *thread_name)
231{ 245{
232 struct pti_masterchannel *mc; 246 struct pti_masterchannel *mc;
233 int i, j, mask; 247 int i, j, mask;
@@ -257,7 +271,7 @@ static struct pti_masterchannel *get_id(u8 *id_array, int max_ids, int base_id)
257 mc->master = base_id; 271 mc->master = base_id;
258 mc->channel = ((i & 0xf)<<3) + j; 272 mc->channel = ((i & 0xf)<<3) + j;
259 /* write new master Id / channel Id allocation to channel control */ 273 /* write new master Id / channel Id allocation to channel control */
260 pti_control_frame_built_and_sent(mc); 274 pti_control_frame_built_and_sent(mc, thread_name);
261 return mc; 275 return mc;
262} 276}
263 277
@@ -273,18 +287,22 @@ static struct pti_masterchannel *get_id(u8 *id_array, int max_ids, int base_id)
273 * a master, channel ID address 287 * a master, channel ID address
274 * to write to PTI HW. 288 * to write to PTI HW.
275 * 289 *
276 * @type: 0- request Application master, channel aperture ID write address. 290 * @type: 0- request Application master, channel aperture ID
277 * 1- request OS master, channel aperture ID write 291 * write address.
278 * address. 292 * 1- request OS master, channel aperture ID write
279 * 2- request Modem master, channel aperture ID 293 * address.
280 * write address. 294 * 2- request Modem master, channel aperture ID
281 * Other values, error. 295 * write address.
296 * Other values, error.
297 * @thread_name: The thread name associated with the master / channel or
298 * 'NULL' if using the 'current' global variable.
282 * 299 *
283 * Returns: 300 * Returns:
284 * pti_masterchannel struct 301 * pti_masterchannel struct
285 * 0 for error 302 * 0 for error
286 */ 303 */
287struct pti_masterchannel *pti_request_masterchannel(u8 type) 304struct pti_masterchannel *pti_request_masterchannel(u8 type,
305 const char *thread_name)
288{ 306{
289 struct pti_masterchannel *mc; 307 struct pti_masterchannel *mc;
290 308
@@ -293,15 +311,18 @@ struct pti_masterchannel *pti_request_masterchannel(u8 type)
293 switch (type) { 311 switch (type) {
294 312
295 case 0: 313 case 0:
296 mc = get_id(drv_data->ia_app, MAX_APP_IDS, APP_BASE_ID); 314 mc = get_id(drv_data->ia_app, MAX_APP_IDS,
315 APP_BASE_ID, thread_name);
297 break; 316 break;
298 317
299 case 1: 318 case 1:
300 mc = get_id(drv_data->ia_os, MAX_OS_IDS, OS_BASE_ID); 319 mc = get_id(drv_data->ia_os, MAX_OS_IDS,
320 OS_BASE_ID, thread_name);
301 break; 321 break;
302 322
303 case 2: 323 case 2:
304 mc = get_id(drv_data->ia_modem, MAX_MODEM_IDS, MODEM_BASE_ID); 324 mc = get_id(drv_data->ia_modem, MAX_MODEM_IDS,
325 MODEM_BASE_ID, thread_name);
305 break; 326 break;
306 default: 327 default:
307 mc = NULL; 328 mc = NULL;
@@ -472,9 +493,9 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
472 return -ENOMEM; 493 return -ENOMEM;
473 494
474 if (idx == PTITTY_MINOR_START) 495 if (idx == PTITTY_MINOR_START)
475 pti_tty_data->mc = pti_request_masterchannel(0); 496 pti_tty_data->mc = pti_request_masterchannel(0, NULL);
476 else 497 else
477 pti_tty_data->mc = pti_request_masterchannel(2); 498 pti_tty_data->mc = pti_request_masterchannel(2, NULL);
478 499
479 if (pti_tty_data->mc == NULL) { 500 if (pti_tty_data->mc == NULL) {
480 kfree(pti_tty_data); 501 kfree(pti_tty_data);
@@ -563,7 +584,7 @@ static int pti_char_open(struct inode *inode, struct file *filp)
563 * before assigning the value to filp->private_data. 584 * before assigning the value to filp->private_data.
564 * Slightly easier to debug if this driver needs debugging. 585 * Slightly easier to debug if this driver needs debugging.
565 */ 586 */
566 mc = pti_request_masterchannel(0); 587 mc = pti_request_masterchannel(0, NULL);
567 if (mc == NULL) 588 if (mc == NULL)
568 return -ENOMEM; 589 return -ENOMEM;
569 filp->private_data = mc; 590 filp->private_data = mc;