[Nouveau] [Bug 93557] New: Kernel Panic on Linux Kernel 4.4 when loading KDE/KDM on Nvidia GeForce 7025 / nForce 630a

2016-01-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93557

Bug ID: 93557
   Summary: Kernel Panic on Linux Kernel 4.4 when loading KDE/KDM
on Nvidia GeForce 7025 / nForce 630a
   Product: xorg
   Version: unspecified
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: blocker
  Priority: medium
 Component: Driver/nouveau
  Assignee: nouveau@lists.freedesktop.org
  Reporter: xgfwt...@sharklasers.com
QA Contact: xorg-t...@lists.x.org

As imirkin told me in the irc i should fill up a bugreport.

System: Clean install of debian testing from 1.1.2016 dailybuild with kde
chosen. Kernel 4.4.0-rc6 installed from experimental.

The main needed information is this kernel panic captured with netconsole:

[ 1059.265197] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b020
[ 1059.265516] nouveau :00:0d.0: bus: MMIO write of 010d0001 FAULT at
00b010
[ 1060.724984] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b010
[ 1060.847845] nouveau :00:0d.0: bus: MMIO write of 010a0001 FAULT at
00b010
[ 1060.848340] nouveau :00:0d.0: bus: MMIO write of 010c0001 FAULT at
00b020
[ 1061.073132] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b010
[ 1061.073350] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b020
[ 1061.265858] nouveau :00:0d.0: bus: MMIO write of 01890001 FAULT at
00b010
[ 1061.266331] nouveau :00:0d.0: bus: MMIO write of 018c0001 FAULT at
00b020
[ 1061.266954] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b010
[ 1068.679841] nouveau :00:0d.0: bus: MMIO write of 01890001 FAULT at
00b010
[ 1068.691605] nouveau :00:0d.0: bus: MMIO write of 018b0001 FAULT at
00b030
[ 1069.007856] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b010
[ 1069.008076] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b030
[ 1069.009128] nouveau :00:0d.0: bus: MMIO write of 0421 FAULT at
00b010
[ 1071.267098] nouveau :00:0d.0: bus: MMIO write of 01890001 FAULT at
00b030
[ 1071.267686] nouveau :00:0d.0: bus: MMIO write of 018b0001 FAULT at
00b040
[ 1075.811130] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b030
[ 1075.811472] nouveau :00:0d.0: bus: MMIO write of  FAULT at
00b040
[ 1079.219933] BUG: unable to handle kernel NULL pointer dereference at
0020
[ 1079.21] IP: [] nv40_gr_intr+0x1fd/0x380 [nouveau]
[ 1079.220079] PGD 6a5b2067 PUD 6a5b1067 PMD 0 
[ 1079.220109] Oops:  [#1] SMP 
[ 1079.220130] Modules linked in: netconsole snd_hda_codec_via
snd_hda_codec_generic joydev pcspkr hid_roccat_koneplus hid_roccat
hid_roccat_common nouveau evdev kvm_amd kvm serio_raw snd_hda_intel mxm_wmi
snd_hda_codec irqbypass wmi k10temp snd_hda_core video snd_hwdep ttm snd_pcm
edac_mce_amd edac_core drm_kms_helper snd_timer sg drm i2c_algo_bit shpchp
i2c_nforce2 button snd soundcore 8250_fintek acpi_cpufreq tpm_tis tpm processor
parport_pc ppdev lp parport autofs4 ext4 crc16 mbcache jbd2 configfs sd_mod
sr_mod cdrom usbhid hid ata_generic ohci_pci pata_amd sata_nv forcedeth libata
scsi_mod ehci_pci ohci_hcd ehci_hcd usbcore usb_common
[ 1079.220909] CPU: 0 PID: 987 Comm: kwin_x11 Not tainted 4.4.0-rc6-amd64 #1
Debian 4.4~rc6-1~exp1
[ 1079.220953] Hardware name: To Be Filled By O.E.M. To Be Filled By
O.E.M./N68-S3 UCC, BIOS P1.60 09/19/2011
[ 1079.220999] task: 880069d0c480 ti: 880069db task.ti:
880069db
[ 1079.221035] RIP: 0010:[]  []
nv40_gr_intr+0x1fd/0x380 [nouveau]
[ 1079.221101] RSP: :88006fc03c58  EFLAGS: 00010016
[ 1079.221128] RAX: 0003 RBX: 88006bb1f140 RCX:

[ 1079.221162] RDX:  RSI: 000c RDI:

[ 1079.221252] RBP: 880055090ac0 R08:  R09:
00064000
[ 1079.221286] R10: 7ff87985d250 R11: 01a05010 R12:
0010
[ 1079.221320] R13: 88006bb1f198 R14: 88006c66cc00 R15:
6400
[ 1079.221355] FS:  7ff87985c940() GS:88006fc0()
knlGS:
[ 1079.221393] CS:  0010 DS:  ES:  CR0: 80050033
[ 1079.221421] CR2: 0020 CR3: 0004 CR4:
06f0
[ 1079.221455] Stack:
[ 1079.221467]   6d715f11 810b244e
00010086
[ 1079.221508]  880069f466c8 0046 0001
0001
[ 1079.221549]   88006c0351a8 0096
0202
[ 1079.221590] Call Trace:
[ 1079.221604]   
[ 1079.221618]  [] ? __wake_up_common+0x4e/0x90
[ 1079.221665]  [] ? drm_handle_vblank+0x1c6/0x280 [drm]
[ 1079.221719]  [] ? nouveau_display_vblank_handler+0x14/0x20
[nouveau]
[ 1079.221768]  [] ? nvif_notify+0x9e/0x180 [nouveau]
[ 1079.221819]  [] ? nvkm_sw_mthd+0x8d/0xe0 [nouveau]
[ 1079.221862]  [] ? nvkm_event_get+0x71/0x80 [nouveau]
[ 

[Nouveau] [Bug 93557] Kernel Panic on Linux Kernel 4.4 when loading KDE/KDM on Nvidia GeForce 7025 / nForce 630a

2016-01-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93557

--- Comment #1 from xgfwt...@sharklasers.com ---
Reading symbols from
/lib/modules/4.4.0-rc6-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko...(no
debugging symbols found)...done.
(gdb) disassemble nv40_gr_intr
Dump of assembler code for function nv40_gr_intr:
   0x000712c0 <+0>:callq  0x712c5 
   0x000712c5 <+5>:push   %r15
   0x000712c7 <+7>:push   %r14
   0x000712c9 <+9>:push   %r13
   0x000712cb <+11>:push   %r12
   0x000712cd <+13>:push   %rbp
   0x000712ce <+14>:push   %rbx
   0x000712cf <+15>:mov%rdi,%rbx
   0x000712d2 <+18>:lea0x58(%rbx),%r13
   0x000712d6 <+22>:sub$0x208,%rsp
   0x000712dd <+29>:mov0x18(%rdi),%r14
   0x000712e1 <+33>:mov%gs:0x28,%rax
   0x000712ea <+42>:mov%rax,0x200(%rsp)
   0x000712f2 <+50>:xor%eax,%eax
   0x000712f4 <+52>:mov0x80(%r14),%rax
   0x000712fb <+59>:lea0x400100(%rax),%rdi
   0x00071302 <+66>:callq  0x71307 
   0x00071307 <+71>:mov%eax,%r12d
   0x0007130a <+74>:mov0x80(%r14),%rax
   0x00071311 <+81>:lea0x400108(%rax),%rdi
   0x00071318 <+88>:callq  0x7131d 
   0x0007131d <+93>:mov%eax,0x58(%rsp)
   0x00071321 <+97>:mov0x80(%r14),%rax
   0x00071328 <+104>:lea0x400104(%rax),%rdi
   0x0007132f <+111>:callq  0x71334 
   0x00071334 <+116>:mov%eax,0x5c(%rsp)
   0x00071338 <+120>:mov0x80(%r14),%rax
   0x0007133f <+127>:lea0x40032c(%rax),%rdi
   0x00071346 <+134>:callq  0x7134b 
   0x0007134b <+139>:and$0xf,%eax
   0x00071350 <+144>:mov%eax,%r15d
   0x00071353 <+147>:mov0x80(%r14),%rax
   0x0007135a <+154>:lea0x400704(%rax),%rdi
   0x00071361 <+161>:callq  0x71366 
   0x00071366 <+166>:mov%eax,0x60(%rsp)
   0x0007136a <+170>:mov%eax,%ebp
   0x0007136c <+172>:mov0x80(%r14),%rax
   0x00071373 <+179>:and$0x7,%ebp
   0x00071379 <+185>:shr$0x10,%ebp
   0x0007137c <+188>:lea0x400708(%rax),%rdi
   0x00071383 <+195>:mov%ebp,0x64(%rsp)
   0x00071387 <+199>:callq  0x7138c 
   0x0007138c <+204>:lea0x400160(,%rbp,4),%edi
   0x00071393 <+211>:add0x80(%r14),%rdi
   0x0007139a <+218>:mov%eax,0x68(%rsp)
   0x0007139e <+222>:callq  0x713a3 
   0x000713a3 <+227>:mov%r13,%rdi
   0x000713a6 <+230>:mov%eax,0x6c(%rsp)
   0x000713aa <+234>:callq  0x713af 
   0x000713af <+239>:mov%rax,0x50(%rsp)
   0x000713b4 <+244>:mov0x68(%rbx),%rax
   0x000713b8 <+248>:lea0x68(%rbx),%rsi
   0x000713bc <+252>:cmp%rsi,%rax
---Type  to continue, or q  to quit---
   0x000713bf <+255>:je 0x713fd 
   0x000713c1 <+257>:mov-0x8(%rax),%edx
   0x000713c4 <+260>:lea-0x88(%rax),%rbp
   0x000713cb <+267>:shr$0x4,%edx
   0x000713ce <+270>:cmp%edx,%r15d
   0x000713d1 <+273>:jne0x713e7 
   0x000713d3 <+275>:jmpq   0x715c2 
   0x000713d8 <+280>:mov-0x8(%rdx),%edx
   0x000713db <+283>:shr$0x4,%edx
   0x000713de <+286>:cmp%edx,%r15d
   0x000713e1 <+289>:je 0x715c2 
   0x000713e7 <+295>:mov0x88(%rbp),%rdx
   0x000713ee <+302>:cmp%rsi,%rdx
   0x000713f1 <+305>:lea-0x88(%rdx),%rbp
   0x000713f8 <+312>:mov%rdx,%rax
   0x000713fb <+315>:jne0x713d8 
   0x000713fd <+317>:xor%ebp,%ebp
   0x000713ff <+319>:test   $0x10,%r12d
   0x00071406 <+326>:je 0x7158a 
   0x0007140c <+332>:testl  $0x1,0x58(%rsp)
   0x00071414 <+340>:jne0x715ef 
   0x0007141a <+346>:mov0x80(%r14),%rax
   0x00071421 <+353>:mov%r12d,%edi
   0x00071424 <+356>:lea0x400100(%rax),%rsi
   0x0007142b <+363>:callq  0x71430 
   0x00071430 <+368>:mov0x80(%r14),%rsi
   0x00071437 <+375>:mov$0x1,%edi
   0x0007143c <+380>:add$0x400720,%rsi
   0x00071443 <+387>:callq  0x71448 
   

[Nouveau] [Bug 93458] page allocation failure: order:5, mode:0x240c0c0

2016-01-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93458

--- Comment #2 from Sven Joachim  ---
Same here on kernel 4.4.0-rc7, NV86 (GeForce 8500 GT). Right now even glxgears
produces the error:

[160746.465409] glxgears: page allocation failure: order:5, mode:0x26040c0
[160746.465415] CPU: 0 PID: 18218 Comm: glxgears Not tainted 4.4.0-rc7-nouveau
#1
[160746.465416] Hardware name: . ./I-45C(Intel i945GC-ICH7), BIOS 6.00 PG
09/18/2008
[160746.465418]   4a0928fb 811f4533
026040c0
[160746.465422]  810d6eb5 8842 0002
026240c0ffe0
[160746.465424]  815797a0 0020 4a0928fb
0002
[160746.465426] Call Trace:
[160746.465434]  [] ? dump_stack+0x40/0x5d
[160746.465439]  [] ? warn_alloc_failed+0xf5/0x150
[160746.465442]  [] ? __alloc_pages_nodemask+0x163/0x820
[160746.465446]  [] ? cache_alloc_refill+0x2ed/0x530
[160746.465448]  [] ? __kmalloc+0x90/0xd0
[160746.465479]  [] ? nvkm_ramht_new+0x3b/0xe0 [nouveau]
[160746.465495]  [] ? g84_fifo_chan_ctor+0x13a/0x170
[nouveau]
[160746.465508]  [] ? g84_fifo_gpfifo_new+0xb9/0x2e0
[nouveau]
[160746.465521]  [] ? nvkm_udevice_child_get+0x70/0x110
[nouveau]
[160746.465530]  [] ? nvkm_ioctl_new+0x147/0x290 [nouveau]
[160746.465543]  [] ? nvkm_udevice_map+0x40/0x40 [nouveau]
[160746.465552]  [] ? nvkm_ioctl+0xf7/0x240 [nouveau]
[160746.465565]  [] ? nouveau_channel_prep+0x1b8/0x2c0
[nouveau]
[160746.465573]  [] ? nvif_object_init+0xb5/0x120 [nouveau]
[160746.465584]  [] ? nouveau_channel_new+0xb8/0x680
[nouveau]
[160746.465595]  [] ?
nouveau_abi16_ioctl_channel_alloc+0xd3/0x2d0 [nouveau]
[160746.465603]  [] ? drm_copy_field+0x38/0x50 [drm]
[160746.465607]  [] ? drm_ioctl+0x12c/0x4b0 [drm]
[160746.465618]  [] ? nouveau_abi16_ioctl_setparam+0x10/0x10
[nouveau]
[160746.465629]  [] ? nouveau_drm_ioctl+0x5b/0xb0 [nouveau]
[160746.465641]  [] ? nouveau_compat_ioctl+0xb/0x20 [nouveau]
[160746.465644]  [] ? compat_SyS_ioctl+0xb1/0x1110
[160746.465646]  [] ? vfs_getattr_nosec+0x2b/0x30
[160746.465648]  [] ? vfs_fstat+0x28/0x50
[160746.465651]  [] ? do_fast_syscall_32+0x91/0x140
[160746.465655]  [] ? sysenter_flags_fixed+0x8/0x12
[160746.465656] Mem-Info:
[160746.465660] active_anon:32765 inactive_anon:43188 isolated_anon:0
[160746.465660]  active_file:262031 inactive_file:229737 isolated_file:0
[160746.465660]  unevictable:0 dirty:1 writeback:0 unstable:0
[160746.465660]  slab_reclaimable:76470 slab_unreclaimable:6333
[160746.465660]  mapped:28713 shmem:1115 pagetables:919 bounce:0
[160746.465660]  free:174183 free_pcp:96 free_cma:0
[160746.465668] DMA free:13032kB min:32kB low:40kB high:48kB active_anon:64kB
inactive_anon:460kB active_file:1128kB inactive_file:564kB unevictable:0kB
isolated(anon):0kB isolated(file):0kB present:15992kB managed:15908kB
mlocked:0kB dirty:0kB writeback:0kB mapped:608kB shmem:84kB
slab_reclaimable:116kB slab_unreclaimable:64kB kernel_stack:16kB pagetables:4kB
unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no
[160746.465669] lowmem_reserve[]: 0 3251 3251 3251
[160746.465676] DMA32 free:683700kB min:7280kB low:9100kB high:10920kB
active_anon:130996kB inactive_anon:172292kB active_file:1046996kB
inactive_file:918384kB unevictable:0kB isolated(anon):0kB isolated(file):0kB
present:3390396kB managed:3330656kB mlocked:0kB dirty:4kB writeback:0kB
mapped:114244kB shmem:4376kB slab_reclaimable:305764kB
slab_unreclaimable:25268kB kernel_stack:2896kB pagetables:3672kB unstable:0kB
bounce:0kB free_pcp:384kB local_pcp:0kB free_cma:0kB writeback_tmp:0kB
pages_scanned:640 all_unreclaimable? no
[160746.465677] lowmem_reserve[]: 0 0 0 0
[160746.465680] DMA: 6*4kB (UME) 2*8kB (ME) 2*16kB (UM) 3*32kB (UM) 1*64kB (M)
2*128kB (UE) 3*256kB (UME) 3*512kB (UME) 2*1024kB (ME) 2*2048kB (UE) 1*4096kB
(M) = 13032kB
[160746.465692] DMA32: 67543*4kB (UME) 31650*8kB (UME) 7187*16kB (UME)
1124*32kB (UME) 149*64kB (UM) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB
0*4096kB = 683868kB
[160746.465700] 493070 total pagecache pages
[160746.465702] 164 pages in swap cache
[160746.465704] Swap cache stats: add 11080, delete 10916, find 520799/521195
[160746.465705] Free swap  = 3695116kB
[160746.465706] Total swap = 3719040kB
[160746.465707] 851597 pages RAM
[160746.465708] 0 pages HighMem/MovableOnly
[160746.465709] 14956 pages reserved

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [Bug 93458] page allocation failure: order:5, mode:0x240c0c0

2016-01-01 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93458

--- Comment #3 from Pierre Moreau  ---
I have seen this one as well on my G96 and MCP79, running 4.3.3. It seems to
happen once RAM has been filled (should it be with buffers kept around or by
applications currently running), even if SWAP is completely empty.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v4 1/9] pci: add gk104 variant

2016-01-01 Thread Karol Herbst
v2: change email used in header
v4: change Copyright information

Signed-off-by: Karol Herbst 
---
 drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drm/nouveau/nvkm/engine/device/base.c | 20 +-
 drm/nouveau/nvkm/subdev/pci/Kbuild|  1 +
 drm/nouveau/nvkm/subdev/pci/gk104.c   | 38 +++
 4 files changed, 50 insertions(+), 10 deletions(-)
 create mode 100644 drm/nouveau/nvkm/subdev/pci/gk104.c

diff --git a/drm/nouveau/include/nvkm/subdev/pci.h 
b/drm/nouveau/include/nvkm/subdev/pci.h
index fee0a97..1cf5f72 100644
--- a/drm/nouveau/include/nvkm/subdev/pci.h
+++ b/drm/nouveau/include/nvkm/subdev/pci.h
@@ -34,4 +34,5 @@ int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci 
**);
 int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 #endif
diff --git a/drm/nouveau/nvkm/engine/device/base.c 
b/drm/nouveau/nvkm/engine/device/base.c
index 7476ac2..e4e3ee5 100644
--- a/drm/nouveau/nvkm/engine/device/base.c
+++ b/drm/nouveau/nvkm/engine/device/base.c
@@ -1669,7 +1669,7 @@ nve4_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk104_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1706,7 +1706,7 @@ nve6_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk104_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1743,7 +1743,7 @@ nve7_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk104_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1804,7 +1804,7 @@ nvf0_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk110_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1840,7 +1840,7 @@ nvf1_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk110_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1876,7 +1876,7 @@ nv106_chipset = {
.mc = gk20a_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk208_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1912,7 +1912,7 @@ nv108_chipset = {
.mc = gk20a_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gk208_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
@@ -1948,7 +1948,7 @@ nv117_chipset = {
.mc = gk20a_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gm107_pmu_new,
.therm = gm107_therm_new,
.timer = gk20a_timer_new,
@@ -1979,7 +1979,7 @@ nv124_chipset = {
.mc = gk20a_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gm107_pmu_new,
.timer = gk20a_timer_new,
.volt = gk104_volt_new,
@@ -2010,7 +2010,7 @@ nv126_chipset = {
.mc = gk20a_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gk104_pci_new,
.pmu = gm107_pmu_new,
.timer = gk20a_timer_new,
.volt = gk104_volt_new,
diff --git a/drm/nouveau/nvkm/subdev/pci/Kbuild 
b/drm/nouveau/nvkm/subdev/pci/Kbuild
index 4476ef7..1a29869 100644
--- a/drm/nouveau/nvkm/subdev/pci/Kbuild
+++ b/drm/nouveau/nvkm/subdev/pci/Kbuild
@@ -7,3 +7,4 @@ nvkm-y += nvkm/subdev/pci/nv4c.o
 nvkm-y += nvkm/subdev/pci/g84.o
 nvkm-y += nvkm/subdev/pci/g94.o
 nvkm-y += nvkm/subdev/pci/gf100.o
+nvkm-y += nvkm/subdev/pci/gk104.o
diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c 
b/drm/nouveau/nvkm/subdev/pci/gk104.c
new file mode 100644
index 000..d0c6fef
--- /dev/null
+++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015 The Nouveau community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, 

[Nouveau] [PATCH v4 3/9] pci: implement generic code for PCIe speed change

2016-01-01 Thread Karol Herbst
v2: rename and group functions
v4: change copyright information
move printing of pcie speeds into oneinit,
rename all pcie functions to nvkm_pcie_*
don't try to raise the pcie version when no higher one is supported

Signed-off-by: Karol Herbst 
---
 drm/nouveau/include/nvkm/subdev/pci.h |  14 +++
 drm/nouveau/nvkm/subdev/pci/Kbuild|   1 +
 drm/nouveau/nvkm/subdev/pci/base.c|  14 +++
 drm/nouveau/nvkm/subdev/pci/pcie.c| 182 ++
 drm/nouveau/nvkm/subdev/pci/priv.h|  16 +++
 5 files changed, 227 insertions(+)
 create mode 100644 drm/nouveau/nvkm/subdev/pci/pcie.c

diff --git a/drm/nouveau/include/nvkm/subdev/pci.h 
b/drm/nouveau/include/nvkm/subdev/pci.h
index 17fe7b7..ab9d5cc 100644
--- a/drm/nouveau/include/nvkm/subdev/pci.h
+++ b/drm/nouveau/include/nvkm/subdev/pci.h
@@ -2,6 +2,12 @@
 #define __NVKM_PCI_H__
 #include 
 
+enum nvkm_pcie_speed {
+   NVKM_PCIE_SPEED_2_5,
+   NVKM_PCIE_SPEED_5_0,
+   NVKM_PCIE_SPEED_8_0,
+};
+
 struct nvkm_pci {
const struct nvkm_pci_func *func;
struct nvkm_subdev subdev;
@@ -18,6 +24,11 @@ struct nvkm_pci {
bool acquired;
} agp;
 
+   struct {
+   enum nvkm_pcie_speed last_speed;
+   u8 last_width;
+   } pcie;
+
bool msi;
 };
 
@@ -36,4 +47,7 @@ int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci 
**);
 int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+
+/* pcie functions */
+int nvkm_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8 width);
 #endif
diff --git a/drm/nouveau/nvkm/subdev/pci/Kbuild 
b/drm/nouveau/nvkm/subdev/pci/Kbuild
index 724afd4..3c2519f 100644
--- a/drm/nouveau/nvkm/subdev/pci/Kbuild
+++ b/drm/nouveau/nvkm/subdev/pci/Kbuild
@@ -1,5 +1,6 @@
 nvkm-y += nvkm/subdev/pci/agp.o
 nvkm-y += nvkm/subdev/pci/base.o
+nvkm-y += nvkm/subdev/pci/pcie.o
 nvkm-y += nvkm/subdev/pci/nv04.o
 nvkm-y += nvkm/subdev/pci/nv40.o
 nvkm-y += nvkm/subdev/pci/nv46.o
diff --git a/drm/nouveau/nvkm/subdev/pci/base.c 
b/drm/nouveau/nvkm/subdev/pci/base.c
index d671dcf..475fb6d 100644
--- a/drm/nouveau/nvkm/subdev/pci/base.c
+++ b/drm/nouveau/nvkm/subdev/pci/base.c
@@ -107,6 +107,15 @@ nvkm_pci_preinit(struct nvkm_subdev *subdev)
 }
 
 static int
+nvkm_pci_oneinit(struct nvkm_subdev *subdev)
+{
+   struct nvkm_pci *pci = nvkm_pci(subdev);
+   if (pci_is_pcie(pci->pdev))
+   return nvkm_pcie_oneinit(pci);
+   return 0;
+}
+
+static int
 nvkm_pci_init(struct nvkm_subdev *subdev)
 {
struct nvkm_pci *pci = nvkm_pci(subdev);
@@ -117,6 +126,8 @@ nvkm_pci_init(struct nvkm_subdev *subdev)
ret = nvkm_agp_init(pci);
if (ret)
return ret;
+   } else if (pci_is_pcie(pci->pdev)) {
+   nvkm_pcie_init(pci);
}
 
if (pci->func->init)
@@ -143,6 +154,7 @@ nvkm_pci_dtor(struct nvkm_subdev *subdev)
 static const struct nvkm_subdev_func
 nvkm_pci_func = {
.dtor = nvkm_pci_dtor,
+   .oneinit = nvkm_pci_oneinit,
.preinit = nvkm_pci_preinit,
.init = nvkm_pci_init,
.fini = nvkm_pci_fini,
@@ -160,6 +172,8 @@ nvkm_pci_new_(const struct nvkm_pci_func *func, struct 
nvkm_device *device,
pci->func = func;
pci->pdev = device->func->pci(device)->pdev;
pci->irq = -1;
+   pci->pcie.last_speed = -1;
+   pci->pcie.last_width = -1;
 
if (device->type == NVKM_DEVICE_AGP)
nvkm_agp_ctor(pci);
diff --git a/drm/nouveau/nvkm/subdev/pci/pcie.c 
b/drm/nouveau/nvkm/subdev/pci/pcie.c
new file mode 100644
index 000..cbc8c1c
--- /dev/null
+++ b/drm/nouveau/nvkm/subdev/pci/pcie.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2015 The Nouveau community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * 

[Nouveau] [PATCH v4 7/9] bios/perf: parse the pci speed from the bios for tesla and newer cards

2016-01-01 Thread Karol Herbst
Signed-off-by: Karol Herbst 
---
 drm/nouveau/include/nvkm/subdev/bios/perf.h |  2 ++
 drm/nouveau/nvkm/subdev/bios/perf.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drm/nouveau/include/nvkm/subdev/bios/perf.h 
b/drm/nouveau/include/nvkm/subdev/bios/perf.h
index 7cc2bec..d3bd250 100644
--- a/drm/nouveau/include/nvkm/subdev/bios/perf.h
+++ b/drm/nouveau/include/nvkm/subdev/bios/perf.h
@@ -13,6 +13,8 @@ struct nvbios_perfE {
u32 vdec;
u32 disp;
u32 script;
+   u8  pcie_speed;
+   u8  pcie_width;
 };
 
 u16 nvbios_perf_entry(struct nvkm_bios *, int idx,
diff --git a/drm/nouveau/nvkm/subdev/bios/perf.c 
b/drm/nouveau/nvkm/subdev/bios/perf.c
index aa7e33b..636bfb6 100644
--- a/drm/nouveau/nvkm/subdev/bios/perf.c
+++ b/drm/nouveau/nvkm/subdev/bios/perf.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 u16
 nvbios_perf_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr,
@@ -145,6 +146,21 @@ nvbios_perfEp(struct nvkm_bios *bios, int idx,
break;
case 0x40:
info->voltage  = nvbios_rd08(bios, perf + 0x02);
+   switch (nvbios_rd08(bios, perf + 0xb) & 0x3) {
+   case 0:
+   info->pcie_speed = NVKM_PCIE_SPEED_5_0;
+   break;
+   case 3:
+   case 1:
+   info->pcie_speed = NVKM_PCIE_SPEED_2_5;
+   break;
+   case 2:
+   info->pcie_speed = NVKM_PCIE_SPEED_8_0;
+   break;
+   default:
+   break;
+   }
+   info->pcie_width = 0xff;
break;
default:
return 0x;
-- 
2.6.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v4 4/9] pci: implement pcie speed change for tesla

2016-01-01 Thread Karol Herbst
v2: rename functions and simplify init
v3: give g84/6 their own implementation

Signed-off-by: Karol Herbst 
---
 drm/nouveau/nvkm/subdev/pci/g84.c   | 97 +
 drm/nouveau/nvkm/subdev/pci/g94.c   | 18 +++
 drm/nouveau/nvkm/subdev/pci/gf100.c |  5 ++
 drm/nouveau/nvkm/subdev/pci/gf106.c |  5 ++
 drm/nouveau/nvkm/subdev/pci/gk104.c |  2 +
 drm/nouveau/nvkm/subdev/pci/priv.h  | 10 
 6 files changed, 137 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/pci/g84.c 
b/drm/nouveau/nvkm/subdev/pci/g84.c
index 3faa6bf..521f9c2 100644
--- a/drm/nouveau/nvkm/subdev/pci/g84.c
+++ b/drm/nouveau/nvkm/subdev/pci/g84.c
@@ -25,6 +25,86 @@
 
 #include 
 
+static int
+g84_pcie_version_supported(struct nvkm_pci *pci)
+{
+   /* g84 and g86 report wrong information about what they support */
+   return 1;
+}
+
+int
+g84_pcie_version(struct nvkm_pci *pci)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   return (nvkm_rd32(device, 0x00154c) & 0x1) + 1;
+}
+
+void
+g84_pcie_set_version(struct nvkm_pci *pci, u8 ver)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   nvkm_mask(device, 0x00154c, 0x1, (ver >= 2 ? 0x1 : 0x0));
+}
+
+static void
+g84_pcie_set_cap_speed(struct nvkm_pci *pci, bool full_speed)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   nvkm_mask(device, 0x00154c, 0x80, full_speed ? 0x80 : 0x0);
+}
+
+enum nvkm_pcie_speed
+g84_pcie_cur_speed(struct nvkm_pci *pci)
+{
+   u32 reg_v = nvkm_pci_rd32(pci, 0x88) & 0x3;
+   switch (reg_v) {
+   case 0x3:
+   return NVKM_PCIE_SPEED_8_0;
+   case 0x2:
+   return NVKM_PCIE_SPEED_5_0;
+   case 0x1:
+   default:
+   return NVKM_PCIE_SPEED_2_5;
+   }
+}
+
+enum nvkm_pcie_speed
+g84_pcie_max_speed(struct nvkm_pci *pci)
+{
+   u32 reg_v = nvkm_pci_rd32(pci, 0x460) & 0x3300;
+   if (reg_v == 0x2200)
+   return NVKM_PCIE_SPEED_5_0;
+   return NVKM_PCIE_SPEED_2_5;
+}
+
+void
+g84_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
+{
+   u32 mask_value;
+
+   if (speed == NVKM_PCIE_SPEED_5_0)
+   mask_value = 0x20;
+   else
+   mask_value = 0x10;
+
+   nvkm_pci_mask(pci, 0x460, 0x30, mask_value);
+   nvkm_pci_mask(pci, 0x460, 0x1, 0x1);
+}
+
+int
+g84_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed req_speed,
+   u8 req_width)
+{
+   if (req_speed == NVKM_PCIE_SPEED_5_0)
+   g84_pcie_set_cap_speed(pci, true);
+   else
+   g84_pcie_set_cap_speed(pci, false);
+
+   g84_pcie_set_link_speed(pci, req_speed);
+
+   return 0;
+}
+
 void
 g84_pci_init(struct nvkm_pci *pci)
 {
@@ -48,6 +128,13 @@ g84_pci_init(struct nvkm_pci *pci)
nvkm_pci_mask(pci, 0x041c, 0x0060, 0x);
 }
 
+int
+g84_pcie_init(struct nvkm_pci *pci)
+{
+   g84_pcie_set_cap_speed(pci, g84_pcie_cur_speed(pci) == 
NVKM_PCIE_SPEED_5_0);
+   return 0;
+}
+
 static const struct nvkm_pci_func
 g84_pci_func = {
.init = g84_pci_init,
@@ -55,6 +142,16 @@ g84_pci_func = {
.wr08 = nv40_pci_wr08,
.wr32 = nv40_pci_wr32,
.msi_rearm = nv46_pci_msi_rearm,
+
+   .pcie.init = g84_pcie_init,
+   .pcie.set_link = g84_pcie_set_link,
+
+   .pcie.max_speed = g84_pcie_max_speed,
+   .pcie.cur_speed = g84_pcie_cur_speed,
+
+   .pcie.set_version = g84_pcie_set_version,
+   .pcie.version = g84_pcie_version,
+   .pcie.version_supported = g84_pcie_version_supported,
 };
 
 int
diff --git a/drm/nouveau/nvkm/subdev/pci/g94.c 
b/drm/nouveau/nvkm/subdev/pci/g94.c
index cd311ee..4344412 100644
--- a/drm/nouveau/nvkm/subdev/pci/g94.c
+++ b/drm/nouveau/nvkm/subdev/pci/g94.c
@@ -23,6 +23,14 @@
  */
 #include "priv.h"
 
+int
+g94_pcie_version_supported(struct nvkm_pci *pci)
+{
+   if ((nvkm_pci_rd32(pci, 0x460) & 0x200) == 0x200)
+   return 2;
+   return 1;
+}
+
 static const struct nvkm_pci_func
 g94_pci_func = {
.init = g84_pci_init,
@@ -30,6 +38,16 @@ g94_pci_func = {
.wr08 = nv40_pci_wr08,
.wr32 = nv40_pci_wr32,
.msi_rearm = nv40_pci_msi_rearm,
+
+   .pcie.init = g84_pcie_init,
+   .pcie.set_link = g84_pcie_set_link,
+
+   .pcie.max_speed = g84_pcie_max_speed,
+   .pcie.cur_speed = g84_pcie_cur_speed,
+
+   .pcie.set_version = g84_pcie_set_version,
+   .pcie.version = g84_pcie_version,
+   .pcie.version_supported = g94_pcie_version_supported,
 };
 
 int
diff --git a/drm/nouveau/nvkm/subdev/pci/gf100.c 
b/drm/nouveau/nvkm/subdev/pci/gf100.c
index 25e1ae7..5e57c0b 100644
--- a/drm/nouveau/nvkm/subdev/pci/gf100.c
+++ b/drm/nouveau/nvkm/subdev/pci/gf100.c
@@ -36,6 +36,11 @@ gf100_pci_func = {
.wr08 = nv40_pci_wr08,
.wr32 = nv40_pci_wr32,
.msi_rearm = gf100_pci_msi_rearm,

[Nouveau] [PATCH v4 8/9] perf: add fields for pci speed and width and use it for the pstates

2016-01-01 Thread Karol Herbst
Signed-off-by: Karol Herbst 
---
 drm/nouveau/include/nvkm/subdev/clk.h | 3 +++
 drm/nouveau/nvkm/subdev/clk/base.c| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drm/nouveau/include/nvkm/subdev/clk.h 
b/drm/nouveau/include/nvkm/subdev/clk.h
index 8708f0a..e9c4a81 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -2,6 +2,7 @@
 #define __NVKM_CLK_H__
 #include 
 #include 
+#include 
 struct nvbios_pll;
 struct nvkm_pll_vals;
 
@@ -59,6 +60,8 @@ struct nvkm_pstate {
struct nvkm_cstate base;
u8 pstate;
u8 fanspeed;
+   enum nvkm_pcie_speed pcie_speed;
+   u8 pcie_width;
 };
 
 struct nvkm_domain {
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c 
b/drm/nouveau/nvkm/subdev/clk/base.c
index dc8682c..c769aff 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -330,6 +330,8 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx)
 
pstate->pstate = perfE.pstate;
pstate->fanspeed = perfE.fanspeed;
+   pstate->pcie_speed = perfE.pcie_speed;
+   pstate->pcie_width = perfE.pcie_width;
cstate->voltage = perfE.voltage;
cstate->domain[nv_clk_src_core] = perfE.core;
cstate->domain[nv_clk_src_shader] = perfE.shader;
-- 
2.6.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v4 5/9] pci: implement pcie speed change on Fermi

2016-01-01 Thread Karol Herbst
v2: rename functions and simplify code a little

Signed-off-by: Karol Herbst 
---
 drm/nouveau/nvkm/subdev/pci/gf100.c | 59 +
 drm/nouveau/nvkm/subdev/pci/gf106.c |  5 
 drm/nouveau/nvkm/subdev/pci/gk104.c |  3 ++
 drm/nouveau/nvkm/subdev/pci/priv.h  |  7 +
 4 files changed, 74 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/pci/gf100.c 
b/drm/nouveau/nvkm/subdev/pci/gf100.c
index 5e57c0b..cfc866e 100644
--- a/drm/nouveau/nvkm/subdev/pci/gf100.c
+++ b/drm/nouveau/nvkm/subdev/pci/gf100.c
@@ -29,6 +29,60 @@ gf100_pci_msi_rearm(struct nvkm_pci *pci)
nvkm_pci_wr08(pci, 0x0704, 0xff);
 }
 
+void
+gf100_pcie_set_version(struct nvkm_pci *pci, u8 ver)
+{
+   struct nvkm_device *device = pci->subdev.device;
+
+   if (ver > 1)
+   ver = 1;
+   else
+   ver = 0;
+
+   nvkm_mask(device, 0x02241c, 0x1, ver);
+}
+
+int
+gf100_pcie_version(struct nvkm_pci *pci)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   return (nvkm_rd32(device, 0x02241c) & 0x1) + 1;
+}
+
+void
+gf100_pcie_set_cap_speed(struct nvkm_pci *pci, bool full_speed)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   nvkm_mask(device, 0x02241c, 0x80, full_speed ? 0x80 : 0x0);
+}
+
+int
+gf100_pcie_cap_speed(struct nvkm_pci *pci)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   u8 punits_pci_cap_speed = nvkm_rd32(device, 0x02241c) & 0x80;
+   if (punits_pci_cap_speed == 0x80)
+   return 1;
+   return 0;
+}
+
+int
+gf100_pcie_init(struct nvkm_pci *pci)
+{
+   gf100_pcie_set_cap_speed(pci,
+   g84_pcie_cur_speed(pci) == NVKM_PCIE_SPEED_5_0);
+   return 0;
+}
+
+int
+gf100_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed req_speed,
+   u8 req_width)
+{
+   gf100_pcie_set_cap_speed(pci, req_speed == NVKM_PCIE_SPEED_5_0);
+   g84_pcie_set_link_speed(pci, req_speed);
+   return 0;
+}
+
 static const struct nvkm_pci_func
 gf100_pci_func = {
.init = g84_pci_init,
@@ -37,9 +91,14 @@ gf100_pci_func = {
.wr32 = nv40_pci_wr32,
.msi_rearm = gf100_pci_msi_rearm,
 
+   .pcie.init = gf100_pcie_init,
+   .pcie.set_link = gf100_pcie_set_link,
+
.pcie.max_speed = g84_pcie_max_speed,
.pcie.cur_speed = g84_pcie_cur_speed,
 
+   .pcie.set_version = gf100_pcie_set_version,
+   .pcie.version = gf100_pcie_version,
.pcie.version_supported = g94_pcie_version_supported,
 };
 
diff --git a/drm/nouveau/nvkm/subdev/pci/gf106.c 
b/drm/nouveau/nvkm/subdev/pci/gf106.c
index 8ee197a..fbbddab 100644
--- a/drm/nouveau/nvkm/subdev/pci/gf106.c
+++ b/drm/nouveau/nvkm/subdev/pci/gf106.c
@@ -30,9 +30,14 @@ gf106_pci_func = {
.wr32 = nv40_pci_wr32,
.msi_rearm = nv40_pci_msi_rearm,
 
+   .pcie.init = gf100_pcie_init,
+   .pcie.set_link = gf100_pcie_set_link,
+
.pcie.max_speed = g84_pcie_max_speed,
.pcie.cur_speed = g84_pcie_cur_speed,
 
+   .pcie.set_version = gf100_pcie_set_version,
+   .pcie.version = gf100_pcie_version,
.pcie.version_supported = g94_pcie_version_supported,
 };
 
diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c 
b/drm/nouveau/nvkm/subdev/pci/gk104.c
index f24fdd8..47c4736 100644
--- a/drm/nouveau/nvkm/subdev/pci/gk104.c
+++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
@@ -31,6 +31,9 @@ gk104_pci_func = {
.msi_rearm = nv40_pci_msi_rearm,
 
.pcie.cur_speed = g84_pcie_cur_speed,
+
+   .pcie.set_version = gf100_pcie_set_version,
+   .pcie.version = gf100_pcie_version,
 };
 
 int
diff --git a/drm/nouveau/nvkm/subdev/pci/priv.h 
b/drm/nouveau/nvkm/subdev/pci/priv.h
index 8c389a6..23de318 100644
--- a/drm/nouveau/nvkm/subdev/pci/priv.h
+++ b/drm/nouveau/nvkm/subdev/pci/priv.h
@@ -46,6 +46,13 @@ int g84_pcie_set_link(struct nvkm_pci *, enum 
nvkm_pcie_speed, u8);
 
 int g94_pcie_version_supported(struct nvkm_pci *);
 
+void gf100_pcie_set_version(struct nvkm_pci *, u8);
+int gf100_pcie_version(struct nvkm_pci *);
+void gf100_pcie_set_cap_speed(struct nvkm_pci *, bool);
+int gf100_pcie_cap_speed(struct nvkm_pci *);
+int gf100_pcie_init(struct nvkm_pci *);
+int gf100_pcie_set_link(struct nvkm_pci *, enum nvkm_pcie_speed, u8);
+
 int nvkm_pcie_oneinit(struct nvkm_pci *);
 int nvkm_pcie_init(struct nvkm_pci *);
 #endif
-- 
2.6.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau


[Nouveau] [PATCH v4 6/9] pci: implement PCIe speed change for kepler+

2016-01-01 Thread Karol Herbst
v2: rename functions
v3: remove pcie2 accessors

Signed-off-by: Karol Herbst 
---
 drm/nouveau/nvkm/subdev/pci/gk104.c | 186 
 1 file changed, 186 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/pci/gk104.c 
b/drm/nouveau/nvkm/subdev/pci/gk104.c
index 47c4736..e88817c 100644
--- a/drm/nouveau/nvkm/subdev/pci/gk104.c
+++ b/drm/nouveau/nvkm/subdev/pci/gk104.c
@@ -23,6 +23,187 @@
  */
 #include "priv.h"
 
+static int
+gk104_pcie_version_supported(struct nvkm_pci *pci)
+{
+   return (nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x4) == 0x4 ? 2 : 1;
+}
+
+static void
+gk104_pcie_set_cap_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
+{
+   struct nvkm_device *device = pci->subdev.device;
+
+   switch (speed) {
+   case NVKM_PCIE_SPEED_2_5:
+   gf100_pcie_set_cap_speed(pci, false);
+   nvkm_mask(device, 0x8c1c0, 0x3, 0x1);
+   break;
+   case NVKM_PCIE_SPEED_5_0:
+   gf100_pcie_set_cap_speed(pci, true);
+   nvkm_mask(device, 0x8c1c0, 0x3, 0x2);
+   break;
+   case NVKM_PCIE_SPEED_8_0:
+   gf100_pcie_set_cap_speed(pci, true);
+   nvkm_mask(device, 0x8c1c0, 0x3, 0x3);
+   break;
+   }
+}
+
+static enum nvkm_pcie_speed
+gk104_pcie_cap_speed(struct nvkm_pci *pci)
+{
+   int speed = gf100_pcie_cap_speed(pci);
+   if (speed < 0)
+   return speed;
+
+   if (speed == 0)
+   return NVKM_PCIE_SPEED_2_5;
+
+   if (speed >= 1) {
+   int speed2 = nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x3;
+   switch (speed2) {
+   case 0x0:
+   case 0x1:
+   return NVKM_PCIE_SPEED_2_5;
+   case 0x2:
+   return NVKM_PCIE_SPEED_5_0;
+   case 0x3:
+   return NVKM_PCIE_SPEED_8_0;
+   }
+   }
+   return -EINVAL;
+}
+
+static void
+gk104_pcie_set_lnkctl_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
+{
+   u8 reg_v = 0;
+   switch (speed) {
+   case NVKM_PCIE_SPEED_2_5:
+   reg_v = 1;
+   break;
+   case NVKM_PCIE_SPEED_5_0:
+   reg_v = 2;
+   break;
+   case NVKM_PCIE_SPEED_8_0:
+   reg_v = 3;
+   break;
+   }
+   nvkm_pci_mask(pci, 0xa8, 0x3, reg_v);
+}
+
+static enum nvkm_pcie_speed
+gk104_pcie_lnkctl_speed(struct nvkm_pci *pci)
+{
+   u8 reg_v = nvkm_pci_rd32(pci, 0xa8) & 0x3;
+   switch (reg_v) {
+   case 0:
+   case 1:
+   return NVKM_PCIE_SPEED_2_5;
+   case 2:
+   return NVKM_PCIE_SPEED_5_0;
+   case 3:
+   return NVKM_PCIE_SPEED_8_0;
+   }
+   return -1;
+}
+
+static enum nvkm_pcie_speed
+gk104_pcie_max_speed(struct nvkm_pci *pci)
+{
+   u32 max_speed = nvkm_rd32(pci->subdev.device, 0x8c1c0) & 0x30;
+   switch (max_speed) {
+   case 0x00:
+   return NVKM_PCIE_SPEED_8_0;
+   case 0x10:
+   return NVKM_PCIE_SPEED_5_0;
+   case 0x20:
+   return NVKM_PCIE_SPEED_2_5;
+   }
+   return NVKM_PCIE_SPEED_2_5;
+}
+
+static void
+gk104_pcie_set_link_speed(struct nvkm_pci *pci, enum nvkm_pcie_speed speed)
+{
+   struct nvkm_device *device = pci->subdev.device;
+   u32 mask_value;
+
+   switch (speed) {
+   default:
+   case NVKM_PCIE_SPEED_2_5:
+   mask_value = 0x8;
+   break;
+   case NVKM_PCIE_SPEED_5_0:
+   mask_value = 0x4;
+   break;
+   case NVKM_PCIE_SPEED_8_0:
+   mask_value = 0x0;
+   break;
+   }
+   nvkm_mask(device, 0x8c040, 0xc, mask_value);
+   nvkm_mask(device, 0x8c040, 0x1, 0x1);
+}
+
+static int
+gk104_pcie_init(struct nvkm_pci * pci)
+{
+   if (!pci_is_pcie(pci->pdev))
+   return -ENODEV;
+
+   if (gf100_pcie_version(pci) > 1) {
+   enum nvkm_pcie_speed
+   lnkctl_speed = gk104_pcie_lnkctl_speed(pci),
+   max_speed = gk104_pcie_max_speed(pci),
+   cap_speed = gk104_pcie_cap_speed(pci);
+
+   if (cap_speed != max_speed) {
+   nvkm_debug(>subdev, "adjusting cap speed to max 
speed\n");
+   gk104_pcie_set_cap_speed(pci, max_speed);
+   cap_speed = gk104_pcie_cap_speed(pci);
+   if (cap_speed != max_speed)
+   nvkm_error(>subdev, "couldn't adjust cap 
speed\n");
+   }
+
+   if (lnkctl_speed != max_speed) {
+   nvkm_debug(>subdev,
+   "adjusting link control speed to max speed\n");
+   gk104_pcie_set_lnkctl_speed(pci, 

[Nouveau] [PATCH v4 2/9] pci: add gf106 variant

2016-01-01 Thread Karol Herbst
v2: change email used in header
v4: change Copyright information

Signed-off-by: Karol Herbst 
---
 drm/nouveau/include/nvkm/subdev/pci.h |  1 +
 drm/nouveau/nvkm/engine/device/base.c | 10 -
 drm/nouveau/nvkm/subdev/pci/Kbuild|  1 +
 drm/nouveau/nvkm/subdev/pci/gf106.c   | 38 +++
 4 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 drm/nouveau/nvkm/subdev/pci/gf106.c

diff --git a/drm/nouveau/include/nvkm/subdev/pci.h 
b/drm/nouveau/include/nvkm/subdev/pci.h
index 1cf5f72..17fe7b7 100644
--- a/drm/nouveau/include/nvkm/subdev/pci.h
+++ b/drm/nouveau/include/nvkm/subdev/pci.h
@@ -34,5 +34,6 @@ int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci 
**);
 int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
+int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 int gk104_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
 #endif
diff --git a/drm/nouveau/nvkm/engine/device/base.c 
b/drm/nouveau/nvkm/engine/device/base.c
index e4e3ee5..8532810 100644
--- a/drm/nouveau/nvkm/engine/device/base.c
+++ b/drm/nouveau/nvkm/engine/device/base.c
@@ -1388,7 +1388,7 @@ nvc1_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gf106_pci_new,
.pmu = gf100_pmu_new,
.therm = gt215_therm_new,
.timer = nv41_timer_new,
@@ -1423,7 +1423,7 @@ nvc3_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gf106_pci_new,
.pmu = gf100_pmu_new,
.therm = gt215_therm_new,
.timer = nv41_timer_new,
@@ -1566,7 +1566,7 @@ nvcf_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gf106_pci_new,
.pmu = gf100_pmu_new,
.therm = gt215_therm_new,
.timer = nv41_timer_new,
@@ -1601,7 +1601,7 @@ nvd7_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gf106_pci_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
.ce[0] = gf100_ce_new,
@@ -1634,7 +1634,7 @@ nvd9_chipset = {
.mc = gf100_mc_new,
.mmu = gf100_mmu_new,
.mxm = nv50_mxm_new,
-   .pci = g94_pci_new,
+   .pci = gf106_pci_new,
.pmu = gf119_pmu_new,
.therm = gf119_therm_new,
.timer = nv41_timer_new,
diff --git a/drm/nouveau/nvkm/subdev/pci/Kbuild 
b/drm/nouveau/nvkm/subdev/pci/Kbuild
index 1a29869..724afd4 100644
--- a/drm/nouveau/nvkm/subdev/pci/Kbuild
+++ b/drm/nouveau/nvkm/subdev/pci/Kbuild
@@ -7,4 +7,5 @@ nvkm-y += nvkm/subdev/pci/nv4c.o
 nvkm-y += nvkm/subdev/pci/g84.o
 nvkm-y += nvkm/subdev/pci/g94.o
 nvkm-y += nvkm/subdev/pci/gf100.o
+nvkm-y += nvkm/subdev/pci/gf106.o
 nvkm-y += nvkm/subdev/pci/gk104.o
diff --git a/drm/nouveau/nvkm/subdev/pci/gf106.c 
b/drm/nouveau/nvkm/subdev/pci/gf106.c
new file mode 100644
index 000..ad42c82
--- /dev/null
+++ b/drm/nouveau/nvkm/subdev/pci/gf106.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015 The Nouveau community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Karol Herbst 
+ */
+#include "priv.h"
+
+static const struct nvkm_pci_func
+gf106_pci_func = {
+   .rd32 = nv40_pci_rd32,
+   .wr08 = nv40_pci_wr08,
+   .wr32 = nv40_pci_wr32,
+   .msi_rearm = nv40_pci_msi_rearm,
+};
+
+int
+gf106_pci_new(struct nvkm_device *device, int index, struct nvkm_pci **ppci)
+{
+   return nvkm_pci_new_(_pci_func, device, index, ppci);
+}
-- 
2.6.4

___
Nouveau mailing list

[Nouveau] [PATCH v4 9/9] perf: change pcie speed on pstate change

2016-01-01 Thread Karol Herbst
v2: remove error and only set link for pcie devices

Signed-off-by: Karol Herbst 
---
 drm/nouveau/nvkm/subdev/clk/base.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drm/nouveau/nvkm/subdev/clk/base.c 
b/drm/nouveau/nvkm/subdev/clk/base.c
index c769aff..004882d 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -176,6 +176,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
 {
struct nvkm_subdev *subdev = >subdev;
struct nvkm_ram *ram = subdev->device->fb->ram;
+   struct nvkm_pci *pci = subdev->device->pci;
struct nvkm_pstate *pstate;
int ret, idx = 0;
 
@@ -187,6 +188,9 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
nvkm_debug(subdev, "setting performance state %d\n", pstatei);
clk->pstate = pstatei;
 
+   if (pci && pci_is_pcie(pci->pdev))
+   nvkm_pcie_set_link(pci, pstate->pcie_speed, pstate->pcie_width);
+
if (ram && ram->func->calc) {
int khz = pstate->base.domain[nv_clk_src_mem];
do {
-- 
2.6.4

___
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau