aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ Freyensee <james_p_freyensee@linux.intel.com>2011-06-17 18:09:53 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-01 18:39:38 -0400
commit8168e9c2de7383c497aff9cd906dd475f9b42b2c (patch)
treec22775a1d4ae33a04d0ed87c3661262425c22688
parentfc360ee7a75da5ef96e7fca145b05024bfce4c72 (diff)
PTI feature to allow user to name and mark masterchannel request.
This feature addition provides a new parameter in pti_request_masterchannel() to allow the user to provide their own name to mark the request when the trace is viewed in a PTI SW trace viewer (like MPTA). If a name is not provided and NULL is provided, the 'current' process name is used. API function header documentation documents this. Signed-off-by: Jeremy Rocher <rocher.jeremy@gmail.com> Signed-off-by: J Freyensee <james_p_freyensee@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/misc/pti.c99
-rw-r--r--include/linux/pti.h3
2 files changed, 62 insertions, 40 deletions
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index bb6f9255c17c..96a25e3b4847 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;
@@ -471,9 +492,9 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
471 return -ENOMEM; 492 return -ENOMEM;
472 493
473 if (idx == PTITTY_MINOR_START) 494 if (idx == PTITTY_MINOR_START)
474 pti_tty_data->mc = pti_request_masterchannel(0); 495 pti_tty_data->mc = pti_request_masterchannel(0, NULL);
475 else 496 else
476 pti_tty_data->mc = pti_request_masterchannel(2); 497 pti_tty_data->mc = pti_request_masterchannel(2, NULL);
477 498
478 if (pti_tty_data->mc == NULL) 499 if (pti_tty_data->mc == NULL)
479 return -ENXIO; 500 return -ENXIO;
@@ -560,7 +581,7 @@ static int pti_char_open(struct inode *inode, struct file *filp)
560 * before assigning the value to filp->private_data. 581 * before assigning the value to filp->private_data.
561 * Slightly easier to debug if this driver needs debugging. 582 * Slightly easier to debug if this driver needs debugging.
562 */ 583 */
563 mc = pti_request_masterchannel(0); 584 mc = pti_request_masterchannel(0, NULL);
564 if (mc == NULL) 585 if (mc == NULL)
565 return -ENOMEM; 586 return -ENOMEM;
566 filp->private_data = mc; 587 filp->private_data = mc;
diff --git a/include/linux/pti.h b/include/linux/pti.h
index 81af667bb2d5..b3ea01a3197e 100644
--- a/include/linux/pti.h
+++ b/include/linux/pti.h
@@ -36,7 +36,8 @@ struct pti_masterchannel {
36 36
37/* the following functions are defined in misc/pti.c */ 37/* the following functions are defined in misc/pti.c */
38void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count); 38void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count);
39struct pti_masterchannel *pti_request_masterchannel(u8 type); 39struct pti_masterchannel *pti_request_masterchannel(u8 type,
40 const char *thread_name);
40void pti_release_masterchannel(struct pti_masterchannel *mc); 41void pti_release_masterchannel(struct pti_masterchannel *mc);
41 42
42#endif /*PTI_H_*/ 43#endif /*PTI_H_*/