Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

J Freyensee and committed by
Greg Kroah-Hartman
8168e9c2 fc360ee7

+62 -40
+60 -39
drivers/misc/pti.c
··· 146 146 /** 147 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 150 - * built a control frame. 149 + * @mc: The master / channel structure on which the function 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 154 * To be able to post process the PTI contents on host side, a control frame 153 155 * is added before sending any PTI content. So the host side knows on 154 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 159 * This function builds this frame and sends it to a master ID CONTROL_ID. 157 160 * The overhead is only 32 bytes since the driver only writes to HW 158 161 * in 32 byte chunks. 159 162 */ 160 - 161 - static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc) 163 + static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc, 164 + const char *thread_name) 162 165 { 163 166 struct pti_masterchannel mccontrol = {.master = CONTROL_ID, 164 167 .channel = 0}; 168 + const char *thread_name_p; 165 169 const char *control_format = "%3d %3d %s"; 166 170 u8 control_frame[CONTROL_FRAME_LEN]; 167 171 168 - /* 169 - * Since we access the comm member in current's task_struct, 170 - * we only need to be as large as what 'comm' in that 171 - * structure is. 172 - */ 173 - char comm[TASK_COMM_LEN]; 172 + if (!thread_name) { 173 + /* 174 + * Since we access the comm member in current's task_struct, 175 + * we only need to be as large as what 'comm' in that 176 + * structure is. 177 + */ 178 + char comm[TASK_COMM_LEN]; 174 179 175 - if (!in_interrupt()) 176 - get_task_comm(comm, current); 177 - else 178 - strncpy(comm, "Interrupt", TASK_COMM_LEN); 180 + if (!in_interrupt()) 181 + get_task_comm(comm, current); 182 + else 183 + strncpy(comm, "Interrupt", TASK_COMM_LEN); 179 184 180 - /* Absolutely ensure our buffer is zero terminated. */ 181 - comm[TASK_COMM_LEN-1] = 0; 185 + /* Absolutely ensure our buffer is zero terminated. */ 186 + comm[TASK_COMM_LEN-1] = 0; 187 + thread_name_p = comm; 188 + } else { 189 + thread_name_p = thread_name; 190 + } 182 191 183 192 mccontrol.channel = pti_control_channel; 184 193 pti_control_channel = (pti_control_channel + 1) & 0x7f; 185 194 186 195 snprintf(control_frame, CONTROL_FRAME_LEN, control_format, mc->master, 187 - mc->channel, comm); 196 + mc->channel, thread_name_p); 188 197 pti_write_to_aperture(&mccontrol, control_frame, strlen(control_frame)); 189 198 } 190 199 ··· 215 206 const unsigned char *buf, 216 207 int len) 217 208 { 218 - pti_control_frame_built_and_sent(mc); 209 + pti_control_frame_built_and_sent(mc, NULL); 219 210 pti_write_to_aperture(mc, (u8 *)buf, len); 220 211 } 221 212 222 213 /** 223 214 * get_id()- Allocate a master and channel ID. 224 215 * 225 - * @id_array: an array of bits representing what channel 226 - * id's are allocated for writing. 227 - * @max_ids: The max amount of available write IDs to use. 228 - * @base_id: The starting SW channel ID, based on the Intel 229 - * PTI arch. 216 + * @id_array: an array of bits representing what channel 217 + * id's are allocated for writing. 218 + * @max_ids: The max amount of available write IDs to use. 219 + * @base_id: The starting SW channel ID, based on the Intel 220 + * PTI arch. 221 + * @thread_name: The thread name associated with the master / channel or 222 + * 'NULL' if using the 'current' global variable. 230 223 * 231 224 * Returns: 232 225 * pti_masterchannel struct with master, channel ID address ··· 238 227 * channel id. The bit is one if the id is taken and 0 if free. For 239 228 * every master there are 128 channel id's. 240 229 */ 241 - static struct pti_masterchannel *get_id(u8 *id_array, int max_ids, int base_id) 230 + static struct pti_masterchannel *get_id(u8 *id_array, 231 + int max_ids, 232 + int base_id, 233 + const char *thread_name) 242 234 { 243 235 struct pti_masterchannel *mc; 244 236 int i, j, mask; ··· 271 257 mc->master = base_id; 272 258 mc->channel = ((i & 0xf)<<3) + j; 273 259 /* write new master Id / channel Id allocation to channel control */ 274 - pti_control_frame_built_and_sent(mc); 260 + pti_control_frame_built_and_sent(mc, thread_name); 275 261 return mc; 276 262 } 277 263 ··· 287 273 * a master, channel ID address 288 274 * to write to PTI HW. 289 275 * 290 - * @type: 0- request Application master, channel aperture ID write address. 291 - * 1- request OS master, channel aperture ID write 292 - * address. 293 - * 2- request Modem master, channel aperture ID 294 - * write address. 295 - * Other values, error. 276 + * @type: 0- request Application master, channel aperture ID 277 + * write address. 278 + * 1- request OS master, channel aperture ID write 279 + * address. 280 + * 2- request Modem master, channel aperture ID 281 + * write address. 282 + * Other values, error. 283 + * @thread_name: The thread name associated with the master / channel or 284 + * 'NULL' if using the 'current' global variable. 296 285 * 297 286 * Returns: 298 287 * pti_masterchannel struct 299 288 * 0 for error 300 289 */ 301 - struct pti_masterchannel *pti_request_masterchannel(u8 type) 290 + struct pti_masterchannel *pti_request_masterchannel(u8 type, 291 + const char *thread_name) 302 292 { 303 293 struct pti_masterchannel *mc; 304 294 ··· 311 293 switch (type) { 312 294 313 295 case 0: 314 - mc = get_id(drv_data->ia_app, MAX_APP_IDS, APP_BASE_ID); 296 + mc = get_id(drv_data->ia_app, MAX_APP_IDS, 297 + APP_BASE_ID, thread_name); 315 298 break; 316 299 317 300 case 1: 318 - mc = get_id(drv_data->ia_os, MAX_OS_IDS, OS_BASE_ID); 301 + mc = get_id(drv_data->ia_os, MAX_OS_IDS, 302 + OS_BASE_ID, thread_name); 319 303 break; 320 304 321 305 case 2: 322 - mc = get_id(drv_data->ia_modem, MAX_MODEM_IDS, MODEM_BASE_ID); 306 + mc = get_id(drv_data->ia_modem, MAX_MODEM_IDS, 307 + MODEM_BASE_ID, thread_name); 323 308 break; 324 309 default: 325 310 mc = NULL; ··· 492 471 return -ENOMEM; 493 472 494 473 if (idx == PTITTY_MINOR_START) 495 - pti_tty_data->mc = pti_request_masterchannel(0); 474 + pti_tty_data->mc = pti_request_masterchannel(0, NULL); 496 475 else 497 - pti_tty_data->mc = pti_request_masterchannel(2); 476 + pti_tty_data->mc = pti_request_masterchannel(2, NULL); 498 477 499 478 if (pti_tty_data->mc == NULL) 500 479 return -ENXIO; ··· 581 560 * before assigning the value to filp->private_data. 582 561 * Slightly easier to debug if this driver needs debugging. 583 562 */ 584 - mc = pti_request_masterchannel(0); 563 + mc = pti_request_masterchannel(0, NULL); 585 564 if (mc == NULL) 586 565 return -ENOMEM; 587 566 filp->private_data = mc;
+2 -1
include/linux/pti.h
··· 36 36 37 37 /* the following functions are defined in misc/pti.c */ 38 38 void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count); 39 - struct pti_masterchannel *pti_request_masterchannel(u8 type); 39 + struct pti_masterchannel *pti_request_masterchannel(u8 type, 40 + const char *thread_name); 40 41 void pti_release_masterchannel(struct pti_masterchannel *mc); 41 42 42 43 #endif /*PTI_H_*/