timecounters

2021-11-12 Thread Emmanuel Dreyfus
Hello

The NetBSD kernel can use multiple timecounters for time keeping, the
choices available are shown by sysctl kern.timecounter.choice, and
the chosen timecounter is decided by kern.timecounter.hardware.

It seems the alternatives, their pros and cons, are not documented.
Did I miss it? All I found is PHK's paper referenced from timecounter(9),
which documents TSC, i8254 and ACPI. I think it would be nice to add
a few words about the available timecounters.

x86 TSC: cycle count from CPU register. Very quick to read, but unreliable if 
CPU frequency changes because of power saving. Also each CPU has its own
value (how do we cope with that?)

x86 i8254: Plain old Intel clock chip, slow but reliable and needs locking
to read.

ACPI-Fast, ACPI-Safe: Needs multiple read to get a good value. 
I have to read more of the paper to understand why. Also the
difference between ACPI-Fast and ACPI-Safe is not yet clear to me.

dummy: not documented. sys/kern/kern_tc.c says it is a fake timecounter
for bootstrap, before a real one is used. .

clockinterrupt: not documented at all?  See sys/kern/kern_clock.c

lapic: not quite documented in lapic(4)

xen_system_time, Hyper-V, Hyper-V-TSC: clocks provided by a hypervisor

Then we have the specialized clock chips:

ichlpcib: loosely documented in ichlpcib(4)

hpet: documented in hpet(4)

Ans that is only the beginning. grep tc_name sys/kern/arch sys/dev yields
a lot of results. For instance, arm has  bcm2835_tmr, clpssoc, a9tmr, gtmr, 
dc21285_fclk, gpt, digctl, mvsoctmr, dmtimer, saost_count, MCT, hstimer, Timer 
2, LOSC, timer2, timer3, tmr1_count

Does it make sense to document all of theat?
-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: timecounters

2021-11-12 Thread Izumi Tsutsui
manu@ wrote:

> The NetBSD kernel can use multiple timecounters for time keeping, the
> choices available are shown by sysctl kern.timecounter.choice, and
> the chosen timecounter is decided by kern.timecounter.hardware.
> 
> It seems the alternatives, their pros and cons, are not documented.
> Did I miss it? All I found is PHK's paper referenced from timecounter(9),
> which documents TSC, i8254 and ACPI. I think it would be nice to add
> a few words about the available timecounters.

IIUC, the essencial part about these counters is in timecounter(9):

>> A timecounter is a binary counter which has two properties:
>>   o   it runs at a fixed, known frequency; and
>>   o   it has sufficient bits to not roll over in less than
>>   approximately max(2 msec, 2/HZ seconds) (the value 2 here is
>>   really 1 + delta, for some indeterminate value of delta).

I.e.
- All MD counters have these properties
- Impliclitly higher frequency and larger bits are preferred
- tc_quality in each struct timecounter implicitly describes priorities

> clockinterrupt: not documented at all?  See sys/kern/kern_clock.c

This seems a rough counter by hardclock(9). It's avaliable on
all systems, so used as timecouneter(9) on machines that have no
MD binary counters.


Describing all MD counters is not so bad idea, but maybe we rather
want proper documentation in www.netbsd.org or timecounter(9)?

(Note I asked kardel@ about timecounter implementation many years ago
 and that was the reason why I imported and updated timecouneter(9)
 man pages per OpenBSD's tc_init(9)..)

---
Izumi Tsutsui 


Re: Trying to access the Expansion ROM of a video card

2021-11-12 Thread Riza Dindir
Hello All,

I am replying to this thread here, including all that have
participated in the message thread. I do not know if that is
appropriate, or if I should open another thread...

Anyways, I am trying to make the radeon r7 m265 device run on NetBSD
9.2 (amd64). When inspecting the dmesg output, atht ehvery beginning I
have this:

[ 1.00] timecounter: Timecounter "i8254" frequency 1193182 Hz
quality 100
[ 1.03] efi: systbl at pa 8f6bef18
[ 1.03] Acer Aspire E5-551G (V1.08)
[ 1.03] mainbus0 (root)
[ 1.03] ACPI: RSDP 0x8FBFE014 24 (v02 ACRSYS)
[ 1.03] ACPI: XSDT 0x8FBFE120 C4 (v01 ACRSYS
ACRPRDCT 0001  0113)
[ 1.03] ACPI: FACP 0x8FBFC000 00010C (v05 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: DSDT 0x8FBEB000 00C377 (v01 ACRSYS
ACRPRDCT F000 1025 0004)
[ 1.03] ACPI: FACS 0x8FB65000 40
[ 1.03] ACPI: UEFI 0x8FBFD000 000236 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: HPET 0x8FBFB000 38 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: APIC 0x8FBFA000 90 (v03 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: MCFG 0x8FBF9000 3C (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: ASF! 0x8FBF8000 A5 (v32 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: BOOT 0x8FBEA000 28 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: WDRT 0x8FBE9000 47 (v01 ACRSYS
ACRPRDCT  1025 0004)
[ 1.03] ACPI: WDAT 0x8FBE8000 0001AC (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: FPDT 0x8FBE6000 44 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: MSDM 0x8FBE5000 55 (v03 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBE4000 000B9C (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBDA000 009AC7 (v02 ACRSYS
ACRPRDCT 0002 1025 0004)
[ 1.03] ACPI: CRAT 0x8FBD9000 0005A0 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: VFCT 0x8FBC9000 00F684 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBC7000 000418 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBC5000 001401 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBC4000 00082B (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: SSDT 0x8FBC2000 001138 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: BGRT 0x8FBC8000 38 (v01 ACRSYS
ACRPRDCT 0001 1025 0004)
[ 1.03] ACPI: 7 ACPI AML tables successfully acquired and loaded

Here I have an entry that is labeled VFCT. I remembered that the
radeon_bios.c file contained a function that uses VFCT I thought the
rom might be in there, in that table. I have dumped the data using
"apcidump -dt", which I added below.

  VFCT: Length=63108, Revision=1, Checksum=97,
OEMID=ACRSYS, OEM Table ID=ACRPRDCT, OEM Revision=0x1,
Creator ID=1025, Creator Revision=0x4

Data={
 56 46 43 54 84 f6 00 0001 61 41 43 52 53 59 53
 41 43 52 50 52 44 43 5401 00 00 00 31 30 32 35
 00 00 04 00 32 9b a3 5dbd c6 cf 49 95 a6 e8 e4
 2e cd 79 a7 4c 00 00 0000 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00
 01 00 00 00 00 00 00 0002 10 09 13 00 00 00 00
 01 00 00 00 00 f6 00 0055 aa 7b e9 19 02 00 00
 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00
 cc 01 00 00 00 00 49 424d 16 fa a1 00 00 00 00
 00 00 00 00 00 00 00 0420 37 36 31 32 39 35 35
 32 30 00 00 00 00 00 0011 02 00 00 00 00 00 00
 a6 01 00 00 00 00 00 0030 33 2f 30 36 2f 31 34
 2c 30 34 3a 31 34 3a 3038 00 00 00 e9 0e 03 00
 e9 1d 03 00 00 00 80 0000 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 0042 52 34 35 33 39 39 2e
 30 30 31 00 53 50 45 4354 52 45 00 50 43 49 5f
 45 58 50 52 45 53 53 0044 44 52 33 00 0d 0a 42
 52 34 35 33 39 39 2e 3030 31 20 53 50 45 43 54
 52 45 20 44 44 52 33 2032 30 30 65 2f 20 20 20
 20 20 20 20 20 20 20 2020 20 20 20 20 20 20 20
 20 20 20 20 20 20 20 2020 20 20 20 20 20 20 20
 20 20 20 20 20 20 20 2020 20 20 0d 0a 00 0d 0a
 20 0d 0a 00 28 43 29 2031 39 38 38 2d 32 30 31
 30 2c 20 41 64 76 61 6e63 65 64 20 4d 69 63 72
 6f 20 44 65 76 69 63 6573 2c 20 49 6e 63 2e 0