Re: rmap and nvidia?

Eyal Lebedinsky
2002-12-15T01:15:39Z

Rik van Riel wrote:
>
> On Sat, 14 Dec 2002, mdew wrote:
> > On Sat, 2002-12-14 at 22:38, William Lee Irwin III wrote:
> > > On Sat, Dec 14, 2002 at 10:36:10PM +1300, mdew wrote:
> > > > nv.c: In function `nv_get_phys_address':
> > > > nv.c:2182: warning: implicit declaration of function `pte_offset'
> > > > nv.c:2182: invalid type argument of `unary *'
> > >
> > > Use pte_offset_map() with a corresponding pte_unmap().
> >
> > err pardon?
>
> wli just gave you the information you need to create a patch
> for the nvidia driver.

The replies for people in the know (Rik, wli) give a clue but not an
answer. Use mere mortals want a proper patch in order to build and
use this kernel.

I will summarise my understanding so far; The original code says:

unsigned long
nv_get_phys_address(unsigned long address)
{
pgd_t *pg_dir;
pmd_t *pg_mid_dir;
pte_t *pte__, pte;
.....
#if defined (pte_offset_atomic)
pte__ = pte_offset_atomic(pg_mid_dir, address);
pte = *pte__;
pte_kunmap(pte__);
#else
pte__ = NULL;
pte = *pte_offset(pg_mid_dir, address);
#endif

if (!pte_present(pte))
goto failed;

return ((pte_val(pte) & KERN_PAGE_MASK) | NV_MASK_OFFSET(address));
.....
}

The last line above is the problem. So far I could see two possible
changes that will compile, but I do not know which will function
correctly. The first replacement option:
pte = *pte_offset(pg_mid_dir, address);

The second replacement option is more involved:
pte__ = pte_offset_map(pg_mid_dir, address);
pte = *pte__;

if (!pte_present(pte))
goto failed;

pte_unmap(pte__);

Reading the patch itself I see places where the first approach is used,
while elsewhere the second is used. I do not know what pte_val(pte)
requires though. Can we do the pte_unmap(pte__) earlier or is the
mapping
necessary for pte_present(pte)? Will this work:
pte__ = pte_offset_map(pg_mid_dir, address);
pte = *pte__;
pte_unmap(pte__);

In summary, you can see that for someone who is not intimately involved
the answers so far do not provide a working patch.

Thanks everybody.

--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>