14d2e26a3SMauro Carvalho Chehab=================================== 24d2e26a3SMauro Carvalho ChehabDSCR (Data Stream Control Register) 34d2e26a3SMauro Carvalho Chehab=================================== 44d2e26a3SMauro Carvalho Chehab 54d2e26a3SMauro Carvalho ChehabDSCR register in powerpc allows user to have some control of prefetch of data 64d2e26a3SMauro Carvalho Chehabstream in the processor. Please refer to the ISA documents or related manual 74d2e26a3SMauro Carvalho Chehabfor more detailed information regarding how to use this DSCR to attain this 84d2e26a3SMauro Carvalho Chehabcontrol of the prefetches . This document here provides an overview of kernel 9*d56b699dSBjorn Helgaassupport for DSCR, related kernel objects, its functionalities and exported 104d2e26a3SMauro Carvalho Chehabuser interface. 114d2e26a3SMauro Carvalho Chehab 124d2e26a3SMauro Carvalho Chehab(A) Data Structures: 134d2e26a3SMauro Carvalho Chehab 144d2e26a3SMauro Carvalho Chehab (1) thread_struct:: 154d2e26a3SMauro Carvalho Chehab 164d2e26a3SMauro Carvalho Chehab dscr /* Thread DSCR value */ 174d2e26a3SMauro Carvalho Chehab dscr_inherit /* Thread has changed default DSCR */ 184d2e26a3SMauro Carvalho Chehab 194d2e26a3SMauro Carvalho Chehab (2) PACA:: 204d2e26a3SMauro Carvalho Chehab 214d2e26a3SMauro Carvalho Chehab dscr_default /* per-CPU DSCR default value */ 224d2e26a3SMauro Carvalho Chehab 234d2e26a3SMauro Carvalho Chehab (3) sysfs.c:: 244d2e26a3SMauro Carvalho Chehab 254d2e26a3SMauro Carvalho Chehab dscr_default /* System DSCR default value */ 264d2e26a3SMauro Carvalho Chehab 274d2e26a3SMauro Carvalho Chehab(B) Scheduler Changes: 284d2e26a3SMauro Carvalho Chehab 294d2e26a3SMauro Carvalho Chehab Scheduler will write the per-CPU DSCR default which is stored in the 304d2e26a3SMauro Carvalho Chehab CPU's PACA value into the register if the thread has dscr_inherit value 314d2e26a3SMauro Carvalho Chehab cleared which means that it has not changed the default DSCR till now. 324d2e26a3SMauro Carvalho Chehab If the dscr_inherit value is set which means that it has changed the 334d2e26a3SMauro Carvalho Chehab default DSCR value, scheduler will write the changed value which will 344d2e26a3SMauro Carvalho Chehab now be contained in thread struct's dscr into the register instead of 354d2e26a3SMauro Carvalho Chehab the per-CPU default PACA based DSCR value. 364d2e26a3SMauro Carvalho Chehab 374d2e26a3SMauro Carvalho Chehab NOTE: Please note here that the system wide global DSCR value never 384d2e26a3SMauro Carvalho Chehab gets used directly in the scheduler process context switch at all. 394d2e26a3SMauro Carvalho Chehab 404d2e26a3SMauro Carvalho Chehab(C) SYSFS Interface: 414d2e26a3SMauro Carvalho Chehab 424d2e26a3SMauro Carvalho Chehab - Global DSCR default: /sys/devices/system/cpu/dscr_default 434d2e26a3SMauro Carvalho Chehab - CPU specific DSCR default: /sys/devices/system/cpu/cpuN/dscr 444d2e26a3SMauro Carvalho Chehab 454d2e26a3SMauro Carvalho Chehab Changing the global DSCR default in the sysfs will change all the CPU 464d2e26a3SMauro Carvalho Chehab specific DSCR defaults immediately in their PACA structures. Again if 474d2e26a3SMauro Carvalho Chehab the current process has the dscr_inherit clear, it also writes the new 484d2e26a3SMauro Carvalho Chehab value into every CPU's DSCR register right away and updates the current 494d2e26a3SMauro Carvalho Chehab thread's DSCR value as well. 504d2e26a3SMauro Carvalho Chehab 514d2e26a3SMauro Carvalho Chehab Changing the CPU specific DSCR default value in the sysfs does exactly 524d2e26a3SMauro Carvalho Chehab the same thing as above but unlike the global one above, it just changes 534d2e26a3SMauro Carvalho Chehab stuff for that particular CPU instead for all the CPUs on the system. 544d2e26a3SMauro Carvalho Chehab 554d2e26a3SMauro Carvalho Chehab(D) User Space Instructions: 564d2e26a3SMauro Carvalho Chehab 574d2e26a3SMauro Carvalho Chehab The DSCR register can be accessed in the user space using any of these 584d2e26a3SMauro Carvalho Chehab two SPR numbers available for that purpose. 594d2e26a3SMauro Carvalho Chehab 604d2e26a3SMauro Carvalho Chehab (1) Problem state SPR: 0x03 (Un-privileged, POWER8 only) 614d2e26a3SMauro Carvalho Chehab (2) Privileged state SPR: 0x11 (Privileged) 624d2e26a3SMauro Carvalho Chehab 634d2e26a3SMauro Carvalho Chehab Accessing DSCR through privileged SPR number (0x11) from user space 644d2e26a3SMauro Carvalho Chehab works, as it is emulated following an illegal instruction exception 654d2e26a3SMauro Carvalho Chehab inside the kernel. Both mfspr and mtspr instructions are emulated. 664d2e26a3SMauro Carvalho Chehab 674d2e26a3SMauro Carvalho Chehab Accessing DSCR through user level SPR (0x03) from user space will first 684d2e26a3SMauro Carvalho Chehab create a facility unavailable exception. Inside this exception handler 694d2e26a3SMauro Carvalho Chehab all mfspr instruction based read attempts will get emulated and returned 704d2e26a3SMauro Carvalho Chehab where as the first mtspr instruction based write attempts will enable 714d2e26a3SMauro Carvalho Chehab the DSCR facility for the next time around (both for read and write) by 724d2e26a3SMauro Carvalho Chehab setting DSCR facility in the FSCR register. 734d2e26a3SMauro Carvalho Chehab 744d2e26a3SMauro Carvalho Chehab(E) Specifics about 'dscr_inherit': 754d2e26a3SMauro Carvalho Chehab 764d2e26a3SMauro Carvalho Chehab The thread struct element 'dscr_inherit' represents whether the thread 774d2e26a3SMauro Carvalho Chehab in question has attempted and changed the DSCR itself using any of the 784d2e26a3SMauro Carvalho Chehab following methods. This element signifies whether the thread wants to 794d2e26a3SMauro Carvalho Chehab use the CPU default DSCR value or its own changed DSCR value in the 804d2e26a3SMauro Carvalho Chehab kernel. 814d2e26a3SMauro Carvalho Chehab 824d2e26a3SMauro Carvalho Chehab (1) mtspr instruction (SPR number 0x03) 834d2e26a3SMauro Carvalho Chehab (2) mtspr instruction (SPR number 0x11) 844d2e26a3SMauro Carvalho Chehab (3) ptrace interface (Explicitly set user DSCR value) 854d2e26a3SMauro Carvalho Chehab 864d2e26a3SMauro Carvalho Chehab Any child of the process created after this event in the process inherits 874d2e26a3SMauro Carvalho Chehab this same behaviour as well. 88