From 1c055e55a242a33e574e48be530e06770a210dcd Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 19 Feb 2024 03:26:26 +0000 Subject: [PATCH] add r8169 read mac form eeprom --- kernel/drivers/dma-buf/heaps/page_pool.c | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/kernel/drivers/dma-buf/heaps/page_pool.c b/kernel/drivers/dma-buf/heaps/page_pool.c index f4a144c..9d3ddb5 100644 --- a/kernel/drivers/dma-buf/heaps/page_pool.c +++ b/kernel/drivers/dma-buf/heaps/page_pool.c @@ -8,13 +8,18 @@ * Copyright (C) 2011 Google, Inc. */ -#include <linux/module.h> #include <linux/freezer.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/spinlock.h> #include <linux/swap.h> #include <linux/sched/signal.h> #include "page_pool.h" + +struct dmabuf_page_pool_with_spinlock { + struct dmabuf_page_pool pool; + struct spinlock spinlock; +}; static LIST_HEAD(pool_list); static DEFINE_MUTEX(pool_list_lock); @@ -36,34 +41,41 @@ static void dmabuf_page_pool_add(struct dmabuf_page_pool *pool, struct page *page) { int index; + struct dmabuf_page_pool_with_spinlock *container_pool = + container_of(pool, struct dmabuf_page_pool_with_spinlock, pool); if (PageHighMem(page)) index = POOL_HIGHPAGE; else index = POOL_LOWPAGE; - mutex_lock(&pool->mutex); + spin_lock(&container_pool->spinlock); list_add_tail(&page->lru, &pool->items[index]); pool->count[index]++; + spin_unlock(&container_pool->spinlock); mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, 1 << pool->order); - mutex_unlock(&pool->mutex); } static struct page *dmabuf_page_pool_remove(struct dmabuf_page_pool *pool, int index) { struct page *page; + struct dmabuf_page_pool_with_spinlock *container_pool = + container_of(pool, struct dmabuf_page_pool_with_spinlock, pool); - mutex_lock(&pool->mutex); + spin_lock(&container_pool->spinlock); page = list_first_entry_or_null(&pool->items[index], struct page, lru); if (page) { pool->count[index]--; list_del(&page->lru); + spin_unlock(&container_pool->spinlock); mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, -(1 << pool->order)); + goto out; } - mutex_unlock(&pool->mutex); + spin_unlock(&container_pool->spinlock); +out: return page; } @@ -114,11 +126,16 @@ struct dmabuf_page_pool *dmabuf_page_pool_create(gfp_t gfp_mask, unsigned int order) { - struct dmabuf_page_pool *pool = kmalloc(sizeof(*pool), GFP_KERNEL); + struct dmabuf_page_pool *pool; + struct dmabuf_page_pool_with_spinlock *container_pool = + kmalloc(sizeof(*container_pool), GFP_KERNEL); int i; - if (!pool) + if (!container_pool) return NULL; + + spin_lock_init(&container_pool->spinlock); + pool = &container_pool->pool; for (i = 0; i < POOL_TYPE_SIZE; i++) { pool->count[i] = 0; @@ -126,7 +143,7 @@ } pool->gfp_mask = gfp_mask | __GFP_COMP; pool->order = order; - mutex_init(&pool->mutex); + mutex_init(&pool->mutex); /* No longer used! */ mutex_lock(&pool_list_lock); list_add(&pool->list, &pool_list); @@ -139,6 +156,7 @@ void dmabuf_page_pool_destroy(struct dmabuf_page_pool *pool) { struct page *page; + struct dmabuf_page_pool_with_spinlock *container_pool; int i; /* Remove us from the pool list */ @@ -152,7 +170,8 @@ dmabuf_page_pool_free_pages(pool, page); } - kfree(pool); + container_pool = container_of(pool, struct dmabuf_page_pool_with_spinlock, pool); + kfree(container_pool); } EXPORT_SYMBOL_GPL(dmabuf_page_pool_destroy); @@ -245,4 +264,4 @@ return register_shrinker(&pool_shrinker); } module_init(dmabuf_page_pool_init_shrinker); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); -- Gitblit v1.6.2