Skip to content

Commit 54bdafd

Browse files
tdzardbiesheuvel
authored andcommitted
efi: sysfb_efi: Reduce number of references to global screen_info
Replace usage of global screen_info with local pointers. This will later reduce churn when screen_info is being moved. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Richard Lyu <richard.lyu@suse.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent b868070 commit 54bdafd

4 files changed

Lines changed: 47 additions & 41 deletions

File tree

drivers/firmware/efi/sysfb_efi.c

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
9292
})
9393

9494
#ifdef CONFIG_EFI
95-
static int __init efifb_set_system(const struct dmi_system_id *id)
95+
static int __init efifb_set_system(struct screen_info *si, const struct dmi_system_id *id)
9696
{
9797
struct efifb_dmi_info *info = id->driver_data;
9898

@@ -101,14 +101,14 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
101101
return 0;
102102

103103
/* Trust the bootloader over the DMI tables */
104-
if (screen_info.lfb_base == 0) {
104+
if (si->lfb_base == 0) {
105105
#if defined(CONFIG_PCI)
106106
struct pci_dev *dev = NULL;
107107
int found_bar = 0;
108108
#endif
109109
if (info->base) {
110-
screen_info.lfb_base = choose_value(info->base,
111-
screen_info.lfb_base, OVERRIDE_BASE,
110+
si->lfb_base = choose_value(info->base,
111+
si->lfb_base, OVERRIDE_BASE,
112112
info->flags);
113113

114114
#if defined(CONFIG_PCI)
@@ -135,49 +135,53 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
135135

136136
start = pci_resource_start(dev, i);
137137
end = pci_resource_end(dev, i);
138-
if (screen_info.lfb_base >= start &&
139-
screen_info.lfb_base < end) {
138+
if (si->lfb_base >= start && si->lfb_base < end) {
140139
found_bar = 1;
141140
break;
142141
}
143142
}
144143
}
145144
if (!found_bar)
146-
screen_info.lfb_base = 0;
145+
si->lfb_base = 0;
147146
#endif
148147
}
149148
}
150-
if (screen_info.lfb_base) {
151-
screen_info.lfb_linelength = choose_value(info->stride,
152-
screen_info.lfb_linelength, OVERRIDE_STRIDE,
149+
if (si->lfb_base) {
150+
si->lfb_linelength = choose_value(info->stride,
151+
si->lfb_linelength, OVERRIDE_STRIDE,
153152
info->flags);
154-
screen_info.lfb_width = choose_value(info->width,
155-
screen_info.lfb_width, OVERRIDE_WIDTH,
153+
si->lfb_width = choose_value(info->width,
154+
si->lfb_width, OVERRIDE_WIDTH,
156155
info->flags);
157-
screen_info.lfb_height = choose_value(info->height,
158-
screen_info.lfb_height, OVERRIDE_HEIGHT,
156+
si->lfb_height = choose_value(info->height,
157+
si->lfb_height, OVERRIDE_HEIGHT,
159158
info->flags);
160-
if (screen_info.orig_video_isVGA == 0)
161-
screen_info.orig_video_isVGA = VIDEO_TYPE_EFI;
159+
if (si->orig_video_isVGA == 0)
160+
si->orig_video_isVGA = VIDEO_TYPE_EFI;
162161
} else {
163-
screen_info.lfb_linelength = 0;
164-
screen_info.lfb_width = 0;
165-
screen_info.lfb_height = 0;
166-
screen_info.orig_video_isVGA = 0;
162+
si->lfb_linelength = 0;
163+
si->lfb_width = 0;
164+
si->lfb_height = 0;
165+
si->orig_video_isVGA = 0;
167166
return 0;
168167
}
169168

170169
printk(KERN_INFO "efifb: dmi detected %s - framebuffer at 0x%08x "
171170
"(%dx%d, stride %d)\n", id->ident,
172-
screen_info.lfb_base, screen_info.lfb_width,
173-
screen_info.lfb_height, screen_info.lfb_linelength);
171+
si->lfb_base, si->lfb_width,
172+
si->lfb_height, si->lfb_linelength);
174173

175174
return 1;
176175
}
177176

177+
static int __init efifb_set_system_callback(const struct dmi_system_id *id)
178+
{
179+
return efifb_set_system(&screen_info, id);
180+
}
181+
178182
#define EFIFB_DMI_SYSTEM_ID(vendor, name, enumid) \
179183
{ \
180-
efifb_set_system, \
184+
efifb_set_system_callback, \
181185
name, \
182186
{ \
183187
DMI_MATCH(DMI_BIOS_VENDOR, vendor), \
@@ -347,12 +351,13 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
347351
{},
348352
};
349353

350-
static bool efifb_overlaps_pci_range(const struct of_pci_range *range)
354+
static bool efifb_overlaps_pci_range(const struct screen_info *si,
355+
const struct of_pci_range *range)
351356
{
352-
u64 fb_base = screen_info.lfb_base;
357+
u64 fb_base = si->lfb_base;
353358

354-
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
355-
fb_base |= (u64)(unsigned long)screen_info.ext_lfb_base << 32;
359+
if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
360+
fb_base |= (u64)(unsigned long)si->ext_lfb_base << 32;
356361

357362
return fb_base >= range->cpu_addr &&
358363
fb_base < (range->cpu_addr + range->size);
@@ -374,7 +379,7 @@ static struct device_node *find_pci_overlap_node(void)
374379
}
375380

376381
for_each_of_pci_range(&parser, &range)
377-
if (efifb_overlaps_pci_range(&range))
382+
if (efifb_overlaps_pci_range(&screen_info, &range))
378383
return np;
379384
}
380385
return NULL;
@@ -412,19 +417,19 @@ static const struct fwnode_operations efifb_fwnode_ops = {
412417

413418
static struct fwnode_handle efifb_fwnode;
414419

415-
__init void sysfb_apply_efi_quirks(void)
420+
__init void sysfb_apply_efi_quirks(struct screen_info *si)
416421
{
417-
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI ||
418-
!(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
422+
if (si->orig_video_isVGA != VIDEO_TYPE_EFI ||
423+
!(si->capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
419424
dmi_check_system(efifb_dmi_system_table);
420425

421-
if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI)
426+
if (si->orig_video_isVGA == VIDEO_TYPE_EFI)
422427
dmi_check_system(efifb_dmi_swap_width_height);
423428
}
424429

425-
__init void sysfb_set_efifb_fwnode(struct platform_device *pd)
430+
__init void sysfb_set_efifb_fwnode(const struct screen_info *si, struct platform_device *pd)
426431
{
427-
if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI && IS_ENABLED(CONFIG_PCI)) {
432+
if (si->orig_video_isVGA == VIDEO_TYPE_EFI && IS_ENABLED(CONFIG_PCI)) {
428433
fwnode_init(&efifb_fwnode, &efifb_fwnode_ops);
429434
pd->dev.fwnode = &efifb_fwnode;
430435
}

drivers/firmware/sysfb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static __init int sysfb_init(void)
155155
if (disabled)
156156
goto unlock_mutex;
157157

158-
sysfb_apply_efi_quirks();
158+
sysfb_apply_efi_quirks(si);
159159

160160
parent = sysfb_parent_dev(si);
161161
if (IS_ERR(parent)) {
@@ -200,7 +200,7 @@ static __init int sysfb_init(void)
200200

201201
pd->dev.parent = parent;
202202

203-
sysfb_set_efifb_fwnode(pd);
203+
sysfb_set_efifb_fwnode(si, pd);
204204

205205
ret = platform_device_add_data(pd, si, sizeof(*si));
206206
if (ret)

drivers/firmware/sysfb_simplefb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ __init struct platform_device *sysfb_create_simplefb(const struct screen_info *s
117117

118118
pd->dev.parent = parent;
119119

120-
sysfb_set_efifb_fwnode(pd);
120+
sysfb_set_efifb_fwnode(si, pd);
121121

122122
ret = platform_device_add_resources(pd, &res, 1);
123123
if (ret)

include/linux/sysfb.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,17 @@ static inline bool sysfb_handles_screen_info(void)
8282
#ifdef CONFIG_EFI
8383

8484
extern struct efifb_dmi_info efifb_dmi_list[];
85-
void sysfb_apply_efi_quirks(void);
86-
void sysfb_set_efifb_fwnode(struct platform_device *pd);
85+
void sysfb_apply_efi_quirks(struct screen_info *si);
86+
void sysfb_set_efifb_fwnode(const struct screen_info *si, struct platform_device *pd);
8787

8888
#else /* CONFIG_EFI */
8989

90-
static inline void sysfb_apply_efi_quirks(void)
90+
static inline void sysfb_apply_efi_quirks(struct screen_info *si)
9191
{
9292
}
9393

94-
static inline void sysfb_set_efifb_fwnode(struct platform_device *pd)
94+
static inline void sysfb_set_efifb_fwnode(const struct screen_info *si,
95+
struct platform_device *pd)
9596
{
9697
}
9798

0 commit comments

Comments
 (0)