Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
3bbd038f
Commit
3bbd038f
authored
Feb 27, 2004
by
Ben Collins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IEEE1394(r1168): Add on a mempool for packet allocation, in addition to the kmem_cache.
parent
713d8db7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
drivers/ieee1394/ieee1394_core.c
drivers/ieee1394/ieee1394_core.c
+16
-5
No files found.
drivers/ieee1394/ieee1394_core.c
View file @
3bbd038f
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include <linux/moduleparam.h>
#include <linux/moduleparam.h>
#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/kdev_t.h>
#include <linux/kdev_t.h>
#include <linux/mempool.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>
#include <asm/semaphore.h>
#include <asm/semaphore.h>
...
@@ -56,6 +57,7 @@ MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality.");
...
@@ -56,6 +57,7 @@ MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality.");
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
static
kmem_cache_t
*
hpsb_packet_cache
;
static
kmem_cache_t
*
hpsb_packet_cache
;
static
mempool_t
*
hpsb_packet_mempool
;
/* Some globals used */
/* Some globals used */
const
char
*
hpsb_speedto_str
[]
=
{
"S100"
,
"S200"
,
"S400"
,
"S800"
,
"S1600"
,
"S3200"
};
const
char
*
hpsb_speedto_str
[]
=
{
"S100"
,
"S200"
,
"S400"
,
"S800"
,
"S1600"
,
"S3200"
};
...
@@ -92,7 +94,7 @@ static void queue_packet_complete(struct hpsb_packet *packet);
...
@@ -92,7 +94,7 @@ static void queue_packet_complete(struct hpsb_packet *packet);
void
hpsb_set_packet_complete_task
(
struct
hpsb_packet
*
packet
,
void
hpsb_set_packet_complete_task
(
struct
hpsb_packet
*
packet
,
void
(
*
routine
)(
void
*
),
void
*
data
)
void
(
*
routine
)(
void
*
),
void
*
data
)
{
{
BUG
_ON
(
packet
->
complete_routine
!=
NULL
);
WARN
_ON
(
packet
->
complete_routine
!=
NULL
);
packet
->
complete_routine
=
routine
;
packet
->
complete_routine
=
routine
;
packet
->
complete_data
=
data
;
packet
->
complete_data
=
data
;
return
;
return
;
...
@@ -123,14 +125,15 @@ struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
...
@@ -123,14 +125,15 @@ struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
struct
hpsb_packet
*
packet
=
NULL
;
struct
hpsb_packet
*
packet
=
NULL
;
void
*
data
=
NULL
;
void
*
data
=
NULL
;
packet
=
kmem_cache_alloc
(
hpsb_packet_cache
,
GFP_ATOMIC
);
packet
=
mempool_alloc
(
hpsb_packet_mempool
,
GFP_ATOMIC
);
if
(
packet
==
NULL
)
if
(
packet
==
NULL
)
return
NULL
;
return
NULL
;
if
(
data_size
)
{
if
(
data_size
)
{
data_size
=
(
data_size
+
3
)
&
~
3
;
data
=
kmalloc
(
data_size
+
8
,
GFP_ATOMIC
);
data
=
kmalloc
(
data_size
+
8
,
GFP_ATOMIC
);
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
kmem_cache_free
(
hpsb_packet_cache
,
packet
);
mempool_free
(
packet
,
hpsb_packet_mempool
);
return
NULL
;
return
NULL
;
}
}
...
@@ -152,7 +155,7 @@ void hpsb_free_packet(struct hpsb_packet *packet)
...
@@ -152,7 +155,7 @@ void hpsb_free_packet(struct hpsb_packet *packet)
{
{
if
(
packet
&&
atomic_dec_and_test
(
&
packet
->
refcnt
))
{
if
(
packet
&&
atomic_dec_and_test
(
&
packet
->
refcnt
))
{
kfree
(
packet
->
data
);
kfree
(
packet
->
data
);
kmem_cache_free
(
hpsb_packet_cache
,
packet
);
mempool_free
(
packet
,
hpsb_packet_mempool
);
}
}
}
}
...
@@ -1065,7 +1068,14 @@ static int __init ieee1394_init(void)
...
@@ -1065,7 +1068,14 @@ static int __init ieee1394_init(void)
devfs_mk_dir
(
"ieee1394"
);
devfs_mk_dir
(
"ieee1394"
);
hpsb_packet_cache
=
kmem_cache_create
(
"hpsb_packet"
,
sizeof
(
struct
hpsb_packet
),
hpsb_packet_cache
=
kmem_cache_create
(
"hpsb_packet"
,
sizeof
(
struct
hpsb_packet
),
0
,
0
,
hpsb_packet_ctor
,
NULL
);
0
,
SLAB_HWCACHE_ALIGN
,
hpsb_packet_ctor
,
NULL
);
/* Our memory pool keeps 32 packets allocated at all times. The
* default callbacks use the hpsb_packet_cache for the allocation,
* and the hpsb_packet_ctor call back makes sure that the packets
* are setup properly. Smooooth. */
hpsb_packet_mempool
=
mempool_create
(
32
,
mempool_alloc_slab
,
mempool_free_slab
,
hpsb_packet_cache
);
bus_register
(
&
ieee1394_bus_type
);
bus_register
(
&
ieee1394_bus_type
);
for
(
i
=
0
;
fw_bus_attrs
[
i
];
i
++
)
for
(
i
=
0
;
fw_bus_attrs
[
i
];
i
++
)
...
@@ -1102,6 +1112,7 @@ static void __exit ieee1394_cleanup(void)
...
@@ -1102,6 +1112,7 @@ static void __exit ieee1394_cleanup(void)
wait_for_completion
(
&
khpsbpkt_complete
);
wait_for_completion
(
&
khpsbpkt_complete
);
}
}
mempool_destroy
(
hpsb_packet_mempool
);
kmem_cache_destroy
(
hpsb_packet_cache
);
kmem_cache_destroy
(
hpsb_packet_cache
);
unregister_chrdev_region
(
IEEE1394_CORE_DEV
,
256
);
unregister_chrdev_region
(
IEEE1394_CORE_DEV
,
256
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment