/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/umem.c

  • Committer: Suren A. Chilingaryan
  • Date: 2017-06-14 01:33:43 UTC
  • Revision ID: csa@suren.me-20170614013343-u5en58l91ihj6zg8
Support kernels up to 4.9 (patch provided by Timo)

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
    /* Get the page information */
83
83
    down_read(&current->mm->mmap_sem);
84
 
    res = get_user_pages(
85
 
              current,
86
 
              current->mm,
87
 
              umem_handle->vma,
88
 
              nr_pages,
89
 
              1,
90
 
              0,  /* do not force, FIXME: shall I? */
91
 
              pages,
92
 
              NULL );
 
84
    res = get_user_pages_compat(umem_handle->vma, nr_pages, pages);
93
85
    up_read(&current->mm->mmap_sem);
94
86
 
95
87
    /* Error, not all pages mapped */
106
98
    /* Lock the pages, then populate the SG list with the pages */
107
99
    /* page0 is different */
108
100
    if ( !PageReserved(pages[0]) )
109
 
        __set_page_locked(pages[0]);
 
101
        lock_page(pages[0]);
110
102
 
111
103
    offset = (umem_handle->vma & ~PAGE_MASK);
112
104
    length = (umem_handle->size > (PAGE_SIZE-offset) ? (PAGE_SIZE-offset) : umem_handle->size);
117
109
    for(i=1; i<nr_pages; i++) {
118
110
        /* Lock page first */
119
111
        if ( !PageReserved(pages[i]) )
120
 
            __set_page_locked(pages[i]);
 
112
            lock_page(pages[i]);
121
113
 
122
114
        /* Populate the list */
123
115
        sg_set_page(&sg[i], pages[i], ((count > PAGE_SIZE) ? PAGE_SIZE : count), 0);
166
158
    if (nr_pages > 0) {
167
159
        for(i=0; i<nr_pages; i++) {
168
160
            if (PageLocked(pages[i]))
169
 
                __clear_page_locked(pages[i]);
 
161
                unlock_page(pages[i]);
170
162
            if (!PageReserved(pages[i]))
171
163
                set_page_dirty(pages[i]);
172
 
            page_cache_release(pages[i]);
 
164
            put_page(pages[i]);
173
165
        }
174
166
    }
175
167
    vfree(sg);
198
190
            /* Mark pages as Dirty and unlock it */
199
191
            if ( !PageReserved( umem_entry->pages[i] )) {
200
192
                SetPageDirty( umem_entry->pages[i] );
201
 
                __clear_page_locked(umem_entry->pages[i]);
 
193
                unlock_page(umem_entry->pages[i]);
202
194
            }
203
195
            /* and release it from the cache */
204
 
            page_cache_release( umem_entry->pages[i] );
 
196
            put_page( umem_entry->pages[i] );
205
197
        }
206
198
    }
207
199