diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2013-12-31 15:55:39 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2014-01-06 10:44:16 -0500 |
commit | 7f256020cc599bc0b736c57d702b864dbbefcefb (patch) | |
tree | a6eb6a8f1d809cf98c058ff7272a6eddf51ca57f | |
parent | 2771374d47220c7ec271281437625e9519505bb2 (diff) |
xen/grants: Remove gnttab_max_grant_frames dependency on gnttab_init.
The function gnttab_max_grant_frames() returns the maximum amount
of frames (pages) of grants we can have. Unfortunatly it was
dependent on gnttab_init() having been run before to initialize
the boot max value (boot_max_nr_grant_frames).
This meant that users of gnttab_max_grant_frames would always
get a zero value if they called before gnttab_init() - such as
'platform_pci_init' (drivers/xen/platform-pci.c).
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
-rw-r--r-- | drivers/xen/grant-table.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index aa846a48f400..99399cb0fd1c 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -62,7 +62,6 @@ | |||
62 | 62 | ||
63 | static grant_ref_t **gnttab_list; | 63 | static grant_ref_t **gnttab_list; |
64 | static unsigned int nr_grant_frames; | 64 | static unsigned int nr_grant_frames; |
65 | static unsigned int boot_max_nr_grant_frames; | ||
66 | static int gnttab_free_count; | 65 | static int gnttab_free_count; |
67 | static grant_ref_t gnttab_free_head; | 66 | static grant_ref_t gnttab_free_head; |
68 | static DEFINE_SPINLOCK(gnttab_list_lock); | 67 | static DEFINE_SPINLOCK(gnttab_list_lock); |
@@ -827,6 +826,11 @@ static unsigned int __max_nr_grant_frames(void) | |||
827 | unsigned int gnttab_max_grant_frames(void) | 826 | unsigned int gnttab_max_grant_frames(void) |
828 | { | 827 | { |
829 | unsigned int xen_max = __max_nr_grant_frames(); | 828 | unsigned int xen_max = __max_nr_grant_frames(); |
829 | static unsigned int boot_max_nr_grant_frames; | ||
830 | |||
831 | /* First time, initialize it properly. */ | ||
832 | if (!boot_max_nr_grant_frames) | ||
833 | boot_max_nr_grant_frames = __max_nr_grant_frames(); | ||
830 | 834 | ||
831 | if (xen_max > boot_max_nr_grant_frames) | 835 | if (xen_max > boot_max_nr_grant_frames) |
832 | return boot_max_nr_grant_frames; | 836 | return boot_max_nr_grant_frames; |
@@ -1227,13 +1231,12 @@ int gnttab_init(void) | |||
1227 | 1231 | ||
1228 | gnttab_request_version(); | 1232 | gnttab_request_version(); |
1229 | nr_grant_frames = 1; | 1233 | nr_grant_frames = 1; |
1230 | boot_max_nr_grant_frames = __max_nr_grant_frames(); | ||
1231 | 1234 | ||
1232 | /* Determine the maximum number of frames required for the | 1235 | /* Determine the maximum number of frames required for the |
1233 | * grant reference free list on the current hypervisor. | 1236 | * grant reference free list on the current hypervisor. |
1234 | */ | 1237 | */ |
1235 | BUG_ON(grefs_per_grant_frame == 0); | 1238 | BUG_ON(grefs_per_grant_frame == 0); |
1236 | max_nr_glist_frames = (boot_max_nr_grant_frames * | 1239 | max_nr_glist_frames = (gnttab_max_grant_frames() * |
1237 | grefs_per_grant_frame / RPP); | 1240 | grefs_per_grant_frame / RPP); |
1238 | 1241 | ||
1239 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), | 1242 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), |