Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 09-08-08, 01:32 AM   #1
jazzychad
bootstrapped user
 
Join Date: Sep 2008
Posts: 4
Default nvclock: map_dev_mem (mmap) returning -1

Hi All,

I am trying to run nvclock on my system so that I can slow down the fans on my two GeForce 6600's (which currently sound like jet engines). I downloaded the latest source and compiled it. When it ran I always got a segfault. I narrowed down the problem to the map_dev_mem function in src/backend/back_linux.c It is always returning -1 (error code EINVAL). Of course this causes a segfault when something tries to access the mapped data (there is no check for invalid mmap return in the code).

Here are the relevant bits of code and the output it creates:

Code:
static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size)
{
        void *base;
        int mapflags = MAP_SHARED;
        unsigned long realBase, alignOff;

        realBase = (Base & ~((unsigned long)getpagesize() - 1));
        alignOff = Base - realBase;


        CBE_FPRINTF(stderr, "...getpagesize is %u - mask is 0x%x...\n", getpagesize(), ~(getpagesize() - 1));
        CBE_FPRINTF(stderr, "...sizeof(Base) = %d...\n", sizeof(Base));
        CBE_FPRINTF(stderr, "...calling mmap with the following args: \n\t 0, %u, %d, %u (0x%x) - Base %u (0x%x)...\n", Size, fd, realBase, realBase, Base, Base);

        base = mmap((void  *)0, Size + alignOff, PROT_READ|PROT_WRITE,
                    mapflags, fd, (off_t)realBase);

        CBE_FPRINTF(stderr, "...map_dev_mem returning %p + %u...\n", base, alignOff);

        return (void *) ((char *)base + alignOff);
}
Output:

Code:
...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 4096, 3, 3356495872 (0xc8101000) - Base 3356495872 (0xc8101000)...
...map_dev_mem returning 0xffffffff + 0...

...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 4096, 3, 3356491776 (0xc8100000) - Base 3356491776 (0xc8100000)...
...map_dev_mem returning 0xffffffff + 0...

...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 196607, 3, 3355443200 (0xc8000000) - Base 3355443200 (0xc8000000)...
...map_dev_mem returning 0xffffffff + 0...

...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 8192, 3, 3361738752 (0xc8601000) - Base 3361738752 (0xc8601000)...
...map_dev_mem returning 0xffffffff + 0...

...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 8192, 3, 3362258944 (0xc8680000) - Base 3362258944 (0xc8680000)...
...map_dev_mem returning 0xffffffff + 0...

...getpagesize is 4096 - mask is 0xfffff000...
...sizeof(Base) = 4...
...calling mmap with the following args: 
         0, 65535, 3, 3358588928 (0xc8300000) - Base 3358588928 (0xc8300000)...
...map_dev_mem returning 0xffffffff + 0...
... where 0xffffffff of course means -1.

strace confirms the error (output for last mmap call):
Code:
mmap2(NULL, 65535, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0xc8300) = -1 EINVAL (Invalid argument)
Does anyone have any clue why this would be happening? /dev/nvidia0 and /dev/nvidia1 both exist and have rw permissions for everybody

System specs:
Ubuntu 7.10 i686
AMD Athlon XP 2400+
2GB RAM
Asus A8N-SLI Deluxe mobo
2x PNY nVidia GeForce 6600 SLI cards
nVidia drivers: 100.14.19

My overall goal is just to be able to control the fan speeds on the 6600's, but I haven't found any other methods except for everyone raving about nvclock.

Any help is appreciated. Thanks!
jazzychad is offline   Reply With Quote
Old 09-09-08, 03:33 AM   #2
Thunderbird
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 2,105
Default Re: nvclock: map_dev_mem (mmap) returning -1

Nvclock uses /dev/nvidia0 when it is available. The file is created when you load the nvidia kernel module but it is only activated when you enter X. If you don't have X running you could get this behavior. Nvclock can also use /dev/mem in such a case but that requires root ..
Thunderbird is offline   Reply With Quote
Old 09-09-08, 09:17 AM   #3
jazzychad
bootstrapped user
 
Join Date: Sep 2008
Posts: 4
Default Re: nvclock: map_dev_mem (mmap) returning -1

Hi Thunderbird,

Thanks for the reply.

I am in an X session when running nvclock. Doing an ls -al on /dev/nvidia0 and /dev/nvidia1 shows a size of 195. (I'm not sure if the size reported by ls on character devices is reliable, though). How can I tell if these files are "activated"? Just by their existence?

Code:
chad@svr-lnx:~$ ls -al /dev/nvi*
crw-rw-rw- 1 root root 195,   0 2008-09-09 10:12 /dev/nvidia0
crw-rw-rw- 1 root root 195,   1 2008-09-09 10:13 /dev/nvidia1
crw-rw-rw- 1 root root 195, 255 2008-09-09 10:12 /dev/nvidiactl
chad@svr-lnx:~$
Is there a way to force it to use /dev/mem?

Thanks for the help,
-Chad
jazzychad is offline   Reply With Quote
Old 09-09-08, 10:09 AM   #4
jazzychad
bootstrapped user
 
Join Date: Sep 2008
Posts: 4
Default Re: nvclock: map_dev_mem (mmap) returning -1

well, I figured out how to force /dev/mem

for those interested...

in backend/backend_linux.c around line 170, change the switch statement to switch(0) to force /dev/mem:

Code:
 switch(0) //check_driver()                                                                                                                               
{
       case 0:
           nvclock.card[i].dev_name = (char*)strdup("/dev/mem");
           nvclock.card[i].reg_address = reg_addr;
           break;
        case 1:
           nvclock.card[i].dev_name = calloc(13, sizeof(char));
           sprintf(nvclock.card[i].dev_name, "/dev/nvidia%d", nvclock.card[i].number);
           nvclock.card[i].reg_address = 0;
           break;
         case 2:
           nvclock.card[i].dev_name = calloc(13, sizeof(char));
           sprintf(nvclock.card[i].dev_name, "/dev/nvidia%d", nvclock.card[i].number);
           nvclock.card[i].reg_address = reg_addr;
           break;
}
After that, the mmaps worked fine, and I was able to get the info on my cards.

Unfortunately, my 6600's don't support fanspeed adjustment as I was greeted an error message when I tried to slow them down. Bummer.

Oh well, I can always replace the fans, or just upgrade cards...

Thanks again for the help!
jazzychad is offline   Reply With Quote
Old 09-09-08, 02:30 PM   #5
Thunderbird
 
Join Date: Jul 2002
Location: Netherlands, Europe
Posts: 2,105
Default Re: nvclock: map_dev_mem (mmap) returning -1

Note that I don't support all fanspeed methods in nvclock. If it is supported on Windows I can offer it in nvclock as long as I know what register to modify. Wait a second you are using an SLI system. In that case for some reason /dev/nvidia1 is the primary card. When SLI is disabled /dev/nvidia0 is not active. I don't support this properly yet in the code.
Thunderbird is offline   Reply With Quote
Old 09-09-08, 02:39 PM   #6
jazzychad
bootstrapped user
 
Join Date: Sep 2008
Posts: 4
Default Re: nvclock: map_dev_mem (mmap) returning -1

Hmm, I have SLI enabled on the system (set to "AFR" in xorg.conf). But, I haven't been able to control fanspeed under Windows either using RivaTuner or otherwise (using the same exact cards). So, I'm starting to wonder whether it is possible to change fanspeeds at all on these cards. However, after much googling and not finding a single statement that it is impossible to alter fanspeeds on 6600's, I am still somewhat hopeful there must be a way.
jazzychad is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:59 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.