diff mbox series

[v2,1/4] fbdev/efifb: Replace references to global screen_info by local pointer

Message ID 20231204092812.2612-2-tzimmermann@suse.de
State Superseded
Headers show
Series fbdev: Remove global screen_info in efifb/vesafb | expand

Commit Message

Thomas Zimmermann Dec. 4, 2023, 9:27 a.m. UTC
Get the global screen_info's address once and access the data via
this pointer. Limits the use of global state.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
---
 drivers/video/fbdev/efifb.c | 113 ++++++++++++++++++------------------
 1 file changed, 58 insertions(+), 55 deletions(-)

Comments

Sui Jingfeng Dec. 4, 2023, 7:53 p.m. UTC | #1
Hi,


On 2023/12/4 17:27, Thomas Zimmermann wrote:
> Get the global screen_info's address once and access the data via
> this pointer. Limits the use of global state.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>


I have applied the whole series and do a simple test with efifb:
Yeah, still works!

$ dmesg | grep efifb

[    0.373800] efifb: probing for efifb
[    0.373816] efifb: framebuffer at 0xe0030000000, using 5120k, total 5120k
[    0.373818] efifb: mode is 1280x1024x32, linelength=5120, pages=1
[    0.373820] efifb: scrolling: redraw
[    0.373821] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0


> ---
>   drivers/video/fbdev/efifb.c | 113 ++++++++++++++++++------------------
>   1 file changed, 58 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index f9b4ddd592ce4..6cbb65bbe1110 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -147,10 +147,9 @@ static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
>   }
>   #endif
>   
> -static void efifb_show_boot_graphics(struct fb_info *info)
> +static void efifb_show_boot_graphics(struct fb_info *info, struct screen_info *si)

I think, we probably can add a const modifier for the function
which doesn't modify our local the screen_info instance in the future.

static void efifb_show_boot_graphics(struct fb_info *info, const struct screen_info *si)

Since screen_info is mostly used to provide information.


>   {
>   	u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
> -	struct screen_info *si = &screen_info;
>   	struct bmp_file_header *file_header;
>   	struct bmp_dib_header *dib_header;
>   	void *bgrt_image = NULL;
> @@ -282,7 +281,7 @@ static const struct fb_ops efifb_ops = {
>   	.fb_setcolreg	= efifb_setcolreg,
>   };
>   
> -static int efifb_setup(char *options)
> +static int efifb_setup(struct screen_info *si, char *options)
>   {
>   	char *this_opt;
>   
> @@ -290,16 +289,16 @@ static int efifb_setup(char *options)
>   		while ((this_opt = strsep(&options, ",")) != NULL) {
>   			if (!*this_opt) continue;
>   
> -			efifb_setup_from_dmi(&screen_info, this_opt);
> +			efifb_setup_from_dmi(si, this_opt);
>   
>   			if (!strncmp(this_opt, "base:", 5))
> -				screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
> +				si->lfb_base = simple_strtoul(this_opt+5, NULL, 0);
>   			else if (!strncmp(this_opt, "stride:", 7))
> -				screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
> +				si->lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
>   			else if (!strncmp(this_opt, "height:", 7))
> -				screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
> +				si->lfb_height = simple_strtoul(this_opt+7, NULL, 0);
>   			else if (!strncmp(this_opt, "width:", 6))
> -				screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
> +				si->lfb_width = simple_strtoul(this_opt+6, NULL, 0);
>   			else if (!strcmp(this_opt, "nowc"))
>   				mem_flags &= ~EFI_MEMORY_WC;
>   			else if (!strcmp(this_opt, "nobgrt"))
> @@ -310,15 +309,15 @@ static int efifb_setup(char *options)
>   	return 0;
>   }
>   
> -static inline bool fb_base_is_valid(void)
> +static inline bool fb_base_is_valid(struct screen_info *si)
>   {
> -	if (screen_info.lfb_base)
> +	if (si->lfb_base)
>   		return true;
>   
> -	if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
> +	if (!(si->capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>   		return false;
>   
> -	if (screen_info.ext_lfb_base)
> +	if (si->ext_lfb_base)
>   		return true;
>   
>   	return false;
> @@ -329,7 +328,10 @@ static ssize_t name##_show(struct device *dev,				\
>   			   struct device_attribute *attr,		\
>   			   char *buf)					\
>   {									\
> -	return sprintf(buf, fmt "\n", (screen_info.lfb_##name));	\
> +	struct screen_info *si = dev_get_platdata(dev);			\
> +	if (!si)							\
> +		return -ENODEV;						\
> +	return sprintf(buf, fmt "\n", (si->lfb_##name));		\
>   }									\
>   static DEVICE_ATTR_RO(name)
>   
> @@ -356,6 +358,7 @@ static u64 bar_offset;
>   
>   static int efifb_probe(struct platform_device *dev)
>   {
> +	struct screen_info *si = &screen_info;
>   	struct fb_info *info;
>   	struct efifb_par *par;
>   	int err, orientation;
> @@ -365,48 +368,48 @@ static int efifb_probe(struct platform_device *dev)
>   	char *option = NULL;
>   	efi_memory_desc_t md;
>   
> -	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
> +	if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
>   		return -ENODEV;
>   
>   	if (fb_get_options("efifb", &option))
>   		return -ENODEV;
> -	efifb_setup(option);
> +	efifb_setup(si, option);
>   
>   	/* We don't get linelength from UGA Draw Protocol, only from
>   	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
>   	 * passed in from the user, we really can't use the framebuffer.
>   	 */
> -	if (!screen_info.lfb_linelength)
> +	if (!si->lfb_linelength)
>   		return -ENODEV;
>   
> -	if (!screen_info.lfb_depth)
> -		screen_info.lfb_depth = 32;
> -	if (!screen_info.pages)
> -		screen_info.pages = 1;
> -	if (!fb_base_is_valid()) {
> +	if (!si->lfb_depth)
> +		si->lfb_depth = 32;
> +	if (!si->pages)
> +		si->pages = 1;
> +	if (!fb_base_is_valid(si)) {
>   		printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
>   		return -ENODEV;
>   	}
>   	printk(KERN_INFO "efifb: probing for efifb\n");
>   
>   	/* just assume they're all unset if any are */
> -	if (!screen_info.blue_size) {
> -		screen_info.blue_size = 8;
> -		screen_info.blue_pos = 0;
> -		screen_info.green_size = 8;
> -		screen_info.green_pos = 8;
> -		screen_info.red_size = 8;
> -		screen_info.red_pos = 16;
> -		screen_info.rsvd_size = 8;
> -		screen_info.rsvd_pos = 24;
> +	if (!si->blue_size) {
> +		si->blue_size = 8;
> +		si->blue_pos = 0;
> +		si->green_size = 8;
> +		si->green_pos = 8;
> +		si->red_size = 8;
> +		si->red_pos = 16;
> +		si->rsvd_size = 8;
> +		si->rsvd_pos = 24;
>   	}


Yeah, Here the efifb modified our local screen_info instance, but this is not relevant to your patch.


>   
> -	efifb_fix.smem_start = screen_info.lfb_base;
> +	efifb_fix.smem_start = si->lfb_base;
>   
> -	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
> +	if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>   		u64 ext_lfb_base;
>   
> -		ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base << 32;
> +		ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
>   		efifb_fix.smem_start |= ext_lfb_base;
>   	}
>   
> @@ -417,10 +420,10 @@ static int efifb_probe(struct platform_device *dev)
>   		efifb_fix.smem_start = bar_resource->start + bar_offset;
>   	}
>   
> -	efifb_defined.bits_per_pixel = screen_info.lfb_depth;
> -	efifb_defined.xres = screen_info.lfb_width;
> -	efifb_defined.yres = screen_info.lfb_height;
> -	efifb_fix.line_length = screen_info.lfb_linelength;
> +	efifb_defined.bits_per_pixel = si->lfb_depth;
> +	efifb_defined.xres = si->lfb_width;
> +	efifb_defined.yres = si->lfb_height;
> +	efifb_fix.line_length = si->lfb_linelength;
>   
>   	/*   size_vmode -- that is the amount of memory needed for the
>   	 *                 used video mode, i.e. the minimum amount of
> @@ -430,7 +433,7 @@ static int efifb_probe(struct platform_device *dev)
>   	/*   size_total -- all video memory we have. Used for
>   	 *                 entries, ressource allocation and bounds
>   	 *                 checking. */
> -	size_total = screen_info.lfb_size;
> +	size_total = si->lfb_size;
>   	if (size_total < size_vmode)
>   		size_total = size_vmode;
>   
> @@ -512,7 +515,7 @@ static int efifb_probe(struct platform_device *dev)
>   	pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
>   	       efifb_defined.xres, efifb_defined.yres,
>   	       efifb_defined.bits_per_pixel, efifb_fix.line_length,
> -	       screen_info.pages);
> +	       si->pages);
>   
>   	efifb_defined.xres_virtual = efifb_defined.xres;
>   	efifb_defined.yres_virtual = efifb_fix.smem_len /
> @@ -526,26 +529,26 @@ static int efifb_probe(struct platform_device *dev)
>   	efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
>   	efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
>   
> -	efifb_defined.red.offset    = screen_info.red_pos;
> -	efifb_defined.red.length    = screen_info.red_size;
> -	efifb_defined.green.offset  = screen_info.green_pos;
> -	efifb_defined.green.length  = screen_info.green_size;
> -	efifb_defined.blue.offset   = screen_info.blue_pos;
> -	efifb_defined.blue.length   = screen_info.blue_size;
> -	efifb_defined.transp.offset = screen_info.rsvd_pos;
> -	efifb_defined.transp.length = screen_info.rsvd_size;
> +	efifb_defined.red.offset    = si->red_pos;
> +	efifb_defined.red.length    = si->red_size;
> +	efifb_defined.green.offset  = si->green_pos;
> +	efifb_defined.green.length  = si->green_size;
> +	efifb_defined.blue.offset   = si->blue_pos;
> +	efifb_defined.blue.length   = si->blue_size;
> +	efifb_defined.transp.offset = si->rsvd_pos;
> +	efifb_defined.transp.length = si->rsvd_size;
>   
>   	pr_info("efifb: %s: "
>   	       "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
>   	       "Truecolor",
> -	       screen_info.rsvd_size,
> -	       screen_info.red_size,
> -	       screen_info.green_size,
> -	       screen_info.blue_size,
> -	       screen_info.rsvd_pos,
> -	       screen_info.red_pos,
> -	       screen_info.green_pos,
> -	       screen_info.blue_pos);
> +	       si->rsvd_size,
> +	       si->red_size,
> +	       si->green_size,
> +	       si->blue_size,
> +	       si->rsvd_pos,
> +	       si->red_pos,
> +	       si->green_pos,
> +	       si->blue_pos);
>   
>   	efifb_fix.ypanstep  = 0;
>   	efifb_fix.ywrapstep = 0;
kernel test robot Dec. 6, 2023, 12:19 a.m. UTC | #2
Hi Thomas,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.7-rc4 next-20231205]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/fbdev-efifb-Replace-references-to-global-screen_info-by-local-pointer/20231204-173019
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20231204092812.2612-2-tzimmermann%40suse.de
patch subject: [PATCH v2 1/4] fbdev/efifb: Replace references to global screen_info by local pointer
config: x86_64-randconfig-006-20231206 (https://download.01.org/0day-ci/archive/20231206/202312060820.0Kjx88on-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060820.0Kjx88on-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312060820.0Kjx88on-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/video/fbdev/efifb.c: In function 'efifb_probe':
>> drivers/video/fbdev/efifb.c:511:2: error: too few arguments to function 'efifb_show_boot_graphics'
     efifb_show_boot_graphics(info);
     ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/video/fbdev/efifb.c:150:13: note: declared here
    static void efifb_show_boot_graphics(struct fb_info *info, struct screen_info *si)
                ^~~~~~~~~~~~~~~~~~~~~~~~


vim +/efifb_show_boot_graphics +511 drivers/video/fbdev/efifb.c

dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  358  
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  359  static int efifb_probe(struct platform_device *dev)
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  360  {
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  361  	struct screen_info *si = &screen_info;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  362  	struct fb_info *info;
82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  363  	struct efifb_par *par;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  364  	int err, orientation;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  365  	unsigned int size_vmode;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  366  	unsigned int size_remap;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  367  	unsigned int size_total;
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  368  	char *option = NULL;
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  369  	efi_memory_desc_t md;
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  370  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  371  	if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  372  		return -ENODEV;
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  373  
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  374  	if (fb_get_options("efifb", &option))
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  375  		return -ENODEV;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  376  	efifb_setup(si, option);
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  377  
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  378  	/* We don't get linelength from UGA Draw Protocol, only from
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  379  	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  380  	 * passed in from the user, we really can't use the framebuffer.
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  381  	 */
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  382  	if (!si->lfb_linelength)
e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  383  		return -ENODEV;
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  384  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  385  	if (!si->lfb_depth)
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  386  		si->lfb_depth = 32;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  387  	if (!si->pages)
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  388  		si->pages = 1;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  389  	if (!fb_base_is_valid(si)) {
133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  390  		printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  391  		return -ENODEV;
133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  392  	}
133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  393  	printk(KERN_INFO "efifb: probing for efifb\n");
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  394  
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  395  	/* just assume they're all unset if any are */
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  396  	if (!si->blue_size) {
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  397  		si->blue_size = 8;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  398  		si->blue_pos = 0;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  399  		si->green_size = 8;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  400  		si->green_pos = 8;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  401  		si->red_size = 8;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  402  		si->red_pos = 16;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  403  		si->rsvd_size = 8;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  404  		si->rsvd_pos = 24;
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  405  	}
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  406  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  407  	efifb_fix.smem_start = si->lfb_base;
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  408  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  409  	if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  410  		u64 ext_lfb_base;
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  411  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  412  		ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  413  		efifb_fix.smem_start |= ext_lfb_base;
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  414  	}
ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  415  
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  416  	if (bar_resource &&
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  417  	    bar_resource->start + bar_offset != efifb_fix.smem_start) {
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  418  		dev_info(&efifb_pci_dev->dev,
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  419  			 "BAR has moved, updating efifb address\n");
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  420  		efifb_fix.smem_start = bar_resource->start + bar_offset;
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  421  	}
dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  422  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  423  	efifb_defined.bits_per_pixel = si->lfb_depth;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  424  	efifb_defined.xres = si->lfb_width;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  425  	efifb_defined.yres = si->lfb_height;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  426  	efifb_fix.line_length = si->lfb_linelength;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  427  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  428  	/*   size_vmode -- that is the amount of memory needed for the
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  429  	 *                 used video mode, i.e. the minimum amount of
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  430  	 *                 memory we need. */
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  431  	size_vmode = efifb_defined.yres * efifb_fix.line_length;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  432  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  433  	/*   size_total -- all video memory we have. Used for
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  434  	 *                 entries, ressource allocation and bounds
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  435  	 *                 checking. */
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  436  	size_total = si->lfb_size;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  437  	if (size_total < size_vmode)
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  438  		size_total = size_vmode;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  439  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  440  	/*   size_remap -- the amount of video memory we are going to
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  441  	 *                 use for efifb.  With modern cards it is no
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  442  	 *                 option to simply use size_total as that
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  443  	 *                 wastes plenty of kernel address space. */
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  444  	size_remap  = size_vmode * 2;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  445  	if (size_remap > size_total)
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  446  		size_remap = size_total;
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  447  	if (size_remap % PAGE_SIZE)
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  448  		size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  449  	efifb_fix.smem_len = size_remap;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  450  
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  451  	if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
da0241f12bf785 drivers/video/efifb.c       Andy Lutomirski   2011-05-26  452  		request_mem_succeeded = true;
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  453  	} else {
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  454  		/* We cannot make this fatal. Sometimes this comes from magic
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  455  		   spaces our resource handlers simply don't know about */
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  456  		pr_warn("efifb: cannot reserve video memory at 0x%lx\n",
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  457  			efifb_fix.smem_start);
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  458  	}
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  459  
82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  460  	info = framebuffer_alloc(sizeof(*par), &dev->dev);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  461  	if (!info) {
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  462  		err = -ENOMEM;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  463  		goto err_release_mem;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  464  	}
65b4021ed67622 drivers/video/efifb.c       David Rheinsberg  2014-01-23  465  	platform_set_drvdata(dev, info);
82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  466  	par = info->par;
82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  467  	info->pseudo_palette = par->pseudo_palette;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  468  
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  469  	par->base = efifb_fix.smem_start;
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  470  	par->size = size_remap;
4410f3910947dc drivers/video/efifb.c       Dave Airlie       2009-06-16  471  
6163a985e50cb1 drivers/video/fbdev/efifb.c Juergen Gross     2020-07-10  472  	if (efi_enabled(EFI_MEMMAP) &&
c2999c281ea2d2 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-03-28  473  	    !efi_mem_desc_lookup(efifb_fix.smem_start, &md)) {
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  474  		if ((efifb_fix.smem_start + efifb_fix.smem_len) >
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  475  		    (md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) {
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  476  			pr_err("efifb: video memory @ 0x%lx spans multiple EFI memory regions\n",
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  477  			       efifb_fix.smem_start);
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  478  			err = -EIO;
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  479  			goto err_release_fb;
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  480  		}
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  481  		/*
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  482  		 * If the UEFI memory map covers the efifb region, we may only
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  483  		 * remap it using the attributes the memory map prescribes.
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  484  		 */
f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  485  		md.attribute &= EFI_MEMORY_UC | EFI_MEMORY_WC |
f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  486  				EFI_MEMORY_WT | EFI_MEMORY_WB;
f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  487  		if (md.attribute) {
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  488  			mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  489  			mem_flags &= md.attribute;
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  490  		}
f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  491  	}
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  492  	if (mem_flags & EFI_MEMORY_WC)
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  493  		info->screen_base = ioremap_wc(efifb_fix.smem_start,
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  494  					       efifb_fix.smem_len);
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  495  	else if (mem_flags & EFI_MEMORY_UC)
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  496  		info->screen_base = ioremap(efifb_fix.smem_start,
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  497  					    efifb_fix.smem_len);
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  498  	else if (mem_flags & EFI_MEMORY_WT)
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  499  		info->screen_base = memremap(efifb_fix.smem_start,
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  500  					     efifb_fix.smem_len, MEMREMAP_WT);
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  501  	else if (mem_flags & EFI_MEMORY_WB)
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  502  		info->screen_base = memremap(efifb_fix.smem_start,
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  503  					     efifb_fix.smem_len, MEMREMAP_WB);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  504  	if (!info->screen_base) {
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  505  		pr_err("efifb: abort, cannot remap video memory 0x%x @ 0x%lx\n",
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  506  			efifb_fix.smem_len, efifb_fix.smem_start);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  507  		err = -EIO;
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  508  		goto err_release_fb;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  509  	}
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  510  
34db50e5565662 drivers/video/fbdev/efifb.c Hans de Goede     2018-07-03 @511  	efifb_show_boot_graphics(info);
34db50e5565662 drivers/video/fbdev/efifb.c Hans de Goede     2018-07-03  512  
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  513  	pr_info("efifb: framebuffer at 0x%lx, using %dk, total %dk\n",
a53dd258279c1e drivers/video/fbdev/efifb.c Andy Lutomirski   2016-05-11  514  	       efifb_fix.smem_start, size_remap/1024, size_total/1024);
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  515  	pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  516  	       efifb_defined.xres, efifb_defined.yres,
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  517  	       efifb_defined.bits_per_pixel, efifb_fix.line_length,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  518  	       si->pages);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  519  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  520  	efifb_defined.xres_virtual = efifb_defined.xres;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  521  	efifb_defined.yres_virtual = efifb_fix.smem_len /
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  522  					efifb_fix.line_length;
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  523  	pr_info("efifb: scrolling: redraw\n");
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  524  	efifb_defined.yres_virtual = efifb_defined.yres;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  525  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  526  	/* some dummy values for timing to make fbset happy */
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  527  	efifb_defined.pixclock     = 10000000 / efifb_defined.xres *
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  528  					1000 / efifb_defined.yres;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  529  	efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  530  	efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  531  
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  532  	efifb_defined.red.offset    = si->red_pos;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  533  	efifb_defined.red.length    = si->red_size;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  534  	efifb_defined.green.offset  = si->green_pos;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  535  	efifb_defined.green.length  = si->green_size;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  536  	efifb_defined.blue.offset   = si->blue_pos;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  537  	efifb_defined.blue.length   = si->blue_size;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  538  	efifb_defined.transp.offset = si->rsvd_pos;
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  539  	efifb_defined.transp.length = si->rsvd_size;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  540  
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  541  	pr_info("efifb: %s: "
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  542  	       "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  543  	       "Truecolor",
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  544  	       si->rsvd_size,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  545  	       si->red_size,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  546  	       si->green_size,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  547  	       si->blue_size,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  548  	       si->rsvd_pos,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  549  	       si->red_pos,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  550  	       si->green_pos,
c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  551  	       si->blue_pos);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  552  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  553  	efifb_fix.ypanstep  = 0;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  554  	efifb_fix.ywrapstep = 0;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  555  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  556  	info->fbops = &efifb_ops;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  557  	info->var = efifb_defined;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  558  	info->fix = efifb_fix;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  559  
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  560  	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  561  						      efifb_defined.yres);
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  562  	switch (orientation) {
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  563  	default:
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  564  		info->fbcon_rotate_hint = FB_ROTATE_UR;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  565  		break;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  566  	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  567  		info->fbcon_rotate_hint = FB_ROTATE_UD;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  568  		break;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  569  	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  570  		info->fbcon_rotate_hint = FB_ROTATE_CCW;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  571  		break;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  572  	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  573  		info->fbcon_rotate_hint = FB_ROTATE_CW;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  574  		break;
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  575  	}
028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  576  
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  577  	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  578  	if (err) {
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  579  		pr_err("efifb: cannot add sysfs attrs\n");
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  580  		goto err_unmap;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  581  	}
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  582  	err = fb_alloc_cmap(&info->cmap, 256, 0);
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  583  	if (err < 0) {
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  584  		pr_err("efifb: cannot allocate colormap\n");
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  585  		goto err_groups;
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  586  	}
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  587  
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  588  	if (efifb_pci_dev)
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  589  		WARN_ON(pm_runtime_get_sync(&efifb_pci_dev->dev) < 0);
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  590  
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  591  	err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  592  	if (err) {
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  593  		pr_err("efifb: cannot acquire aperture\n");
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  594  		goto err_put_rpm_ref;
7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  595  	}
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  596  	err = register_framebuffer(info);
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  597  	if (err < 0) {
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  598  		pr_err("efifb: cannot register framebuffer\n");
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  599  		goto err_put_rpm_ref;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  600  	}
31b6780c15a4e3 drivers/video/efifb.c       Joe Perches       2013-09-19  601  	fb_info(info, "%s frame buffer device\n", info->fix.id);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  602  	return 0;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  603  
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  604  err_put_rpm_ref:
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  605  	if (efifb_pci_dev)
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  606  		pm_runtime_put(&efifb_pci_dev->dev);
55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  607  
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  608  	fb_dealloc_cmap(&info->cmap);
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  609  err_groups:
753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  610  	sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  611  err_unmap:
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  612  	if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  613  		iounmap(info->screen_base);
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  614  	else
38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  615  		memunmap(info->screen_base);
7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  616  err_release_fb:
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  617  	framebuffer_release(info);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  618  err_release_mem:
da0241f12bf785 drivers/video/efifb.c       Andy Lutomirski   2011-05-26  619  	if (request_mem_succeeded)
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  620  		release_mem_region(efifb_fix.smem_start, size_total);
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  621  	return err;
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  622  }
7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  623
Thomas Zimmermann Dec. 6, 2023, 8:32 a.m. UTC | #3
Hi

Am 06.12.23 um 01:19 schrieb kernel test robot:
> Hi Thomas,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on drm-misc/drm-misc-next]
> [also build test ERROR on linus/master v6.7-rc4 next-20231205]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/fbdev-efifb-Replace-references-to-global-screen_info-by-local-pointer/20231204-173019
> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
> patch link:    https://lore.kernel.org/r/20231204092812.2612-2-tzimmermann%40suse.de
> patch subject: [PATCH v2 1/4] fbdev/efifb: Replace references to global screen_info by local pointer
> config: x86_64-randconfig-006-20231206 (https://download.01.org/0day-ci/archive/20231206/202312060820.0Kjx88on-lkp@intel.com/config)
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060820.0Kjx88on-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202312060820.0Kjx88on-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>     drivers/video/fbdev/efifb.c: In function 'efifb_probe':
>>> drivers/video/fbdev/efifb.c:511:2: error: too few arguments to function 'efifb_show_boot_graphics'
>       efifb_show_boot_graphics(info);
>       ^~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/video/fbdev/efifb.c:150:13: note: declared here
>      static void efifb_show_boot_graphics(struct fb_info *info, struct screen_info *si)
>                  ^~~~~~~~~~~~~~~~~~~~~~~~

I had deferred takeover disabled, so I didn't notice. Will be fixed 
before merging the patchset.

Best regards
Thomas

> 
> 
> vim +/efifb_show_boot_graphics +511 drivers/video/fbdev/efifb.c
> 
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  358
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  359  static int efifb_probe(struct platform_device *dev)
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  360  {
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  361  	struct screen_info *si = &screen_info;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  362  	struct fb_info *info;
> 82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  363  	struct efifb_par *par;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  364  	int err, orientation;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  365  	unsigned int size_vmode;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  366  	unsigned int size_remap;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  367  	unsigned int size_total;
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  368  	char *option = NULL;
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  369  	efi_memory_desc_t md;
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  370
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  371  	if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  372  		return -ENODEV;
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  373
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  374  	if (fb_get_options("efifb", &option))
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  375  		return -ENODEV;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  376  	efifb_setup(si, option);
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  377
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  378  	/* We don't get linelength from UGA Draw Protocol, only from
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  379  	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  380  	 * passed in from the user, we really can't use the framebuffer.
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  381  	 */
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  382  	if (!si->lfb_linelength)
> e6816a8d855494 drivers/video/efifb.c       David Rheinsberg  2013-08-02  383  		return -ENODEV;
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  384
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  385  	if (!si->lfb_depth)
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  386  		si->lfb_depth = 32;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  387  	if (!si->pages)
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  388  		si->pages = 1;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  389  	if (!fb_base_is_valid(si)) {
> 133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  390  		printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
> 133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  391  		return -ENODEV;
> 133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  392  	}
> 133bb070e94ab4 drivers/video/efifb.c       Matthew Garrett   2009-04-13  393  	printk(KERN_INFO "efifb: probing for efifb\n");
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  394
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  395  	/* just assume they're all unset if any are */
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  396  	if (!si->blue_size) {
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  397  		si->blue_size = 8;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  398  		si->blue_pos = 0;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  399  		si->green_size = 8;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  400  		si->green_pos = 8;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  401  		si->red_size = 8;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  402  		si->red_pos = 16;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  403  		si->rsvd_size = 8;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  404  		si->rsvd_pos = 24;
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  405  	}
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  406
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  407  	efifb_fix.smem_start = si->lfb_base;
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  408
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  409  	if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  410  		u64 ext_lfb_base;
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  411
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  412  		ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  413  		efifb_fix.smem_start |= ext_lfb_base;
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  414  	}
> ae2ee627dc87a7 drivers/video/fbdev/efifb.c Matt Fleming      2015-08-25  415
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  416  	if (bar_resource &&
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  417  	    bar_resource->start + bar_offset != efifb_fix.smem_start) {
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  418  		dev_info(&efifb_pci_dev->dev,
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  419  			 "BAR has moved, updating efifb address\n");
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  420  		efifb_fix.smem_start = bar_resource->start + bar_offset;
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  421  	}
> dcf8f5ce316565 drivers/video/fbdev/efifb.c Ard Biesheuvel    2017-08-18  422
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  423  	efifb_defined.bits_per_pixel = si->lfb_depth;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  424  	efifb_defined.xres = si->lfb_width;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  425  	efifb_defined.yres = si->lfb_height;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  426  	efifb_fix.line_length = si->lfb_linelength;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  427
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  428  	/*   size_vmode -- that is the amount of memory needed for the
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  429  	 *                 used video mode, i.e. the minimum amount of
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  430  	 *                 memory we need. */
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  431  	size_vmode = efifb_defined.yres * efifb_fix.line_length;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  432
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  433  	/*   size_total -- all video memory we have. Used for
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  434  	 *                 entries, ressource allocation and bounds
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  435  	 *                 checking. */
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  436  	size_total = si->lfb_size;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  437  	if (size_total < size_vmode)
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  438  		size_total = size_vmode;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  439
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  440  	/*   size_remap -- the amount of video memory we are going to
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  441  	 *                 use for efifb.  With modern cards it is no
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  442  	 *                 option to simply use size_total as that
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  443  	 *                 wastes plenty of kernel address space. */
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  444  	size_remap  = size_vmode * 2;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  445  	if (size_remap > size_total)
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  446  		size_remap = size_total;
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  447  	if (size_remap % PAGE_SIZE)
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  448  		size_remap += PAGE_SIZE - (size_remap % PAGE_SIZE);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  449  	efifb_fix.smem_len = size_remap;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  450
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  451  	if (request_mem_region(efifb_fix.smem_start, size_remap, "efifb")) {
> da0241f12bf785 drivers/video/efifb.c       Andy Lutomirski   2011-05-26  452  		request_mem_succeeded = true;
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  453  	} else {
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  454  		/* We cannot make this fatal. Sometimes this comes from magic
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  455  		   spaces our resource handlers simply don't know about */
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  456  		pr_warn("efifb: cannot reserve video memory at 0x%lx\n",
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  457  			efifb_fix.smem_start);
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  458  	}
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  459
> 82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  460  	info = framebuffer_alloc(sizeof(*par), &dev->dev);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  461  	if (!info) {
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  462  		err = -ENOMEM;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  463  		goto err_release_mem;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  464  	}
> 65b4021ed67622 drivers/video/efifb.c       David Rheinsberg  2014-01-23  465  	platform_set_drvdata(dev, info);
> 82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  466  	par = info->par;
> 82dcb90b651bcb drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  467  	info->pseudo_palette = par->pseudo_palette;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  468
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  469  	par->base = efifb_fix.smem_start;
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  470  	par->size = size_remap;
> 4410f3910947dc drivers/video/efifb.c       Dave Airlie       2009-06-16  471
> 6163a985e50cb1 drivers/video/fbdev/efifb.c Juergen Gross     2020-07-10  472  	if (efi_enabled(EFI_MEMMAP) &&
> c2999c281ea2d2 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-03-28  473  	    !efi_mem_desc_lookup(efifb_fix.smem_start, &md)) {
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  474  		if ((efifb_fix.smem_start + efifb_fix.smem_len) >
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  475  		    (md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) {
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  476  			pr_err("efifb: video memory @ 0x%lx spans multiple EFI memory regions\n",
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  477  			       efifb_fix.smem_start);
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  478  			err = -EIO;
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  479  			goto err_release_fb;
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  480  		}
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  481  		/*
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  482  		 * If the UEFI memory map covers the efifb region, we may only
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  483  		 * remap it using the attributes the memory map prescribes.
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  484  		 */
> f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  485  		md.attribute &= EFI_MEMORY_UC | EFI_MEMORY_WC |
> f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  486  				EFI_MEMORY_WT | EFI_MEMORY_WB;
> f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  487  		if (md.attribute) {
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  488  			mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  489  			mem_flags &= md.attribute;
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  490  		}
> f8585539df0a15 drivers/video/fbdev/efifb.c Ard Biesheuvel    2019-05-16  491  	}
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  492  	if (mem_flags & EFI_MEMORY_WC)
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  493  		info->screen_base = ioremap_wc(efifb_fix.smem_start,
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  494  					       efifb_fix.smem_len);
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  495  	else if (mem_flags & EFI_MEMORY_UC)
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  496  		info->screen_base = ioremap(efifb_fix.smem_start,
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  497  					    efifb_fix.smem_len);
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  498  	else if (mem_flags & EFI_MEMORY_WT)
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  499  		info->screen_base = memremap(efifb_fix.smem_start,
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  500  					     efifb_fix.smem_len, MEMREMAP_WT);
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  501  	else if (mem_flags & EFI_MEMORY_WB)
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  502  		info->screen_base = memremap(efifb_fix.smem_start,
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  503  					     efifb_fix.smem_len, MEMREMAP_WB);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  504  	if (!info->screen_base) {
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  505  		pr_err("efifb: abort, cannot remap video memory 0x%x @ 0x%lx\n",
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  506  			efifb_fix.smem_len, efifb_fix.smem_start);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  507  		err = -EIO;
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  508  		goto err_release_fb;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  509  	}
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  510
> 34db50e5565662 drivers/video/fbdev/efifb.c Hans de Goede     2018-07-03 @511  	efifb_show_boot_graphics(info);
> 34db50e5565662 drivers/video/fbdev/efifb.c Hans de Goede     2018-07-03  512
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  513  	pr_info("efifb: framebuffer at 0x%lx, using %dk, total %dk\n",
> a53dd258279c1e drivers/video/fbdev/efifb.c Andy Lutomirski   2016-05-11  514  	       efifb_fix.smem_start, size_remap/1024, size_total/1024);
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  515  	pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  516  	       efifb_defined.xres, efifb_defined.yres,
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  517  	       efifb_defined.bits_per_pixel, efifb_fix.line_length,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  518  	       si->pages);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  519
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  520  	efifb_defined.xres_virtual = efifb_defined.xres;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  521  	efifb_defined.yres_virtual = efifb_fix.smem_len /
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  522  					efifb_fix.line_length;
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  523  	pr_info("efifb: scrolling: redraw\n");
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  524  	efifb_defined.yres_virtual = efifb_defined.yres;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  525
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  526  	/* some dummy values for timing to make fbset happy */
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  527  	efifb_defined.pixclock     = 10000000 / efifb_defined.xres *
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  528  					1000 / efifb_defined.yres;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  529  	efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  530  	efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  531
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  532  	efifb_defined.red.offset    = si->red_pos;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  533  	efifb_defined.red.length    = si->red_size;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  534  	efifb_defined.green.offset  = si->green_pos;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  535  	efifb_defined.green.length  = si->green_size;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  536  	efifb_defined.blue.offset   = si->blue_pos;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  537  	efifb_defined.blue.length   = si->blue_size;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  538  	efifb_defined.transp.offset = si->rsvd_pos;
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  539  	efifb_defined.transp.length = si->rsvd_size;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  540
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  541  	pr_info("efifb: %s: "
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  542  	       "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  543  	       "Truecolor",
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  544  	       si->rsvd_size,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  545  	       si->red_size,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  546  	       si->green_size,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  547  	       si->blue_size,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  548  	       si->rsvd_pos,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  549  	       si->red_pos,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  550  	       si->green_pos,
> c1c324fc4ecca7 drivers/video/fbdev/efifb.c Thomas Zimmermann 2023-12-04  551  	       si->blue_pos);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  552
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  553  	efifb_fix.ypanstep  = 0;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  554  	efifb_fix.ywrapstep = 0;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  555
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  556  	info->fbops = &efifb_ops;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  557  	info->var = efifb_defined;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  558  	info->fix = efifb_fix;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  559
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  560  	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  561  						      efifb_defined.yres);
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  562  	switch (orientation) {
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  563  	default:
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  564  		info->fbcon_rotate_hint = FB_ROTATE_UR;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  565  		break;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  566  	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  567  		info->fbcon_rotate_hint = FB_ROTATE_UD;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  568  		break;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  569  	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  570  		info->fbcon_rotate_hint = FB_ROTATE_CCW;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  571  		break;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  572  	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  573  		info->fbcon_rotate_hint = FB_ROTATE_CW;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  574  		break;
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  575  	}
> 028b186f4489dc drivers/video/fbdev/efifb.c Hans de Goede     2017-11-25  576
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  577  	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  578  	if (err) {
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  579  		pr_err("efifb: cannot add sysfs attrs\n");
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  580  		goto err_unmap;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  581  	}
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  582  	err = fb_alloc_cmap(&info->cmap, 256, 0);
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  583  	if (err < 0) {
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  584  		pr_err("efifb: cannot allocate colormap\n");
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  585  		goto err_groups;
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  586  	}
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  587
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  588  	if (efifb_pci_dev)
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  589  		WARN_ON(pm_runtime_get_sync(&efifb_pci_dev->dev) < 0);
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  590
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  591  	err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  592  	if (err) {
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  593  		pr_err("efifb: cannot acquire aperture\n");
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  594  		goto err_put_rpm_ref;
> 7191ec8015f363 drivers/video/fbdev/efifb.c Thomas Zimmermann 2022-12-19  595  	}
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  596  	err = register_framebuffer(info);
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  597  	if (err < 0) {
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  598  		pr_err("efifb: cannot register framebuffer\n");
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  599  		goto err_put_rpm_ref;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  600  	}
> 31b6780c15a4e3 drivers/video/efifb.c       Joe Perches       2013-09-19  601  	fb_info(info, "%s frame buffer device\n", info->fix.id);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  602  	return 0;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  603
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  604  err_put_rpm_ref:
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  605  	if (efifb_pci_dev)
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  606  		pm_runtime_put(&efifb_pci_dev->dev);
> 55285e21f04517 drivers/video/fbdev/efifb.c Imre Deak         2021-08-09  607
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  608  	fb_dealloc_cmap(&info->cmap);
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  609  err_groups:
> 753375a881caa0 drivers/video/fbdev/efifb.c Peter Jones       2016-10-18  610  	sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  611  err_unmap:
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  612  	if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  613  		iounmap(info->screen_base);
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  614  	else
> 38ac0287b7f4f3 drivers/video/fbdev/efifb.c Ard Biesheuvel    2018-07-11  615  		memunmap(info->screen_base);
> 7c08c9ae0c1458 drivers/video/efifb.c       Peter Jones       2008-10-15  616  err_release_fb:
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  617  	framebuffer_release(info);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  618  err_release_mem:
> da0241f12bf785 drivers/video/efifb.c       Andy Lutomirski   2011-05-26  619  	if (request_mem_succeeded)
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  620  		release_mem_region(efifb_fix.smem_start, size_total);
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  621  	return err;
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  622  }
> 7c83172b98e569 drivers/video/efifb.c       Huang, Ying       2007-11-28  623
>
Thomas Zimmermann Dec. 6, 2023, 8:50 a.m. UTC | #4
Hi

Am 04.12.23 um 20:53 schrieb Sui Jingfeng:
> Hi,
> 
> 
> On 2023/12/4 17:27, Thomas Zimmermann wrote:
>> Get the global screen_info's address once and access the data via
>> this pointer. Limits the use of global state.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
> 
> 
> I have applied the whole series and do a simple test with efifb:
> Yeah, still works!
> 
> $ dmesg | grep efifb
> 
> [    0.373800] efifb: probing for efifb
> [    0.373816] efifb: framebuffer at 0xe0030000000, using 5120k, total 
> 5120k
> [    0.373818] efifb: mode is 1280x1024x32, linelength=5120, pages=1
> [    0.373820] efifb: scrolling: redraw
> [    0.373821] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> 
>> ---
>>   drivers/video/fbdev/efifb.c | 113 ++++++++++++++++++------------------
>>   1 file changed, 58 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>> index f9b4ddd592ce4..6cbb65bbe1110 100644
>> --- a/drivers/video/fbdev/efifb.c
>> +++ b/drivers/video/fbdev/efifb.c
>> @@ -147,10 +147,9 @@ static bool efifb_bgrt_sanity_check(struct 
>> screen_info *si, u32 bmp_width)
>>   }
>>   #endif
>> -static void efifb_show_boot_graphics(struct fb_info *info)
>> +static void efifb_show_boot_graphics(struct fb_info *info, struct 
>> screen_info *si)
> 
> I think, we probably can add a const modifier for the function
> which doesn't modify our local the screen_info instance in the future.

Good point. All our source code is traditionally sloppy with const 
correctness.

Best regards
Thomas

> 
> static void efifb_show_boot_graphics(struct fb_info *info, const struct 
> screen_info *si)
> 
> Since screen_info is mostly used to provide information.
> 
> 
>>   {
>>       u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
>> -    struct screen_info *si = &screen_info;
>>       struct bmp_file_header *file_header;
>>       struct bmp_dib_header *dib_header;
>>       void *bgrt_image = NULL;
>> @@ -282,7 +281,7 @@ static const struct fb_ops efifb_ops = {
>>       .fb_setcolreg    = efifb_setcolreg,
>>   };
>> -static int efifb_setup(char *options)
>> +static int efifb_setup(struct screen_info *si, char *options)
>>   {
>>       char *this_opt;
>> @@ -290,16 +289,16 @@ static int efifb_setup(char *options)
>>           while ((this_opt = strsep(&options, ",")) != NULL) {
>>               if (!*this_opt) continue;
>> -            efifb_setup_from_dmi(&screen_info, this_opt);
>> +            efifb_setup_from_dmi(si, this_opt);
>>               if (!strncmp(this_opt, "base:", 5))
>> -                screen_info.lfb_base = simple_strtoul(this_opt+5, 
>> NULL, 0);
>> +                si->lfb_base = simple_strtoul(this_opt+5, NULL, 0);
>>               else if (!strncmp(this_opt, "stride:", 7))
>> -                screen_info.lfb_linelength = 
>> simple_strtoul(this_opt+7, NULL, 0) * 4;
>> +                si->lfb_linelength = simple_strtoul(this_opt+7, NULL, 
>> 0) * 4;
>>               else if (!strncmp(this_opt, "height:", 7))
>> -                screen_info.lfb_height = simple_strtoul(this_opt+7, 
>> NULL, 0);
>> +                si->lfb_height = simple_strtoul(this_opt+7, NULL, 0);
>>               else if (!strncmp(this_opt, "width:", 6))
>> -                screen_info.lfb_width = simple_strtoul(this_opt+6, 
>> NULL, 0);
>> +                si->lfb_width = simple_strtoul(this_opt+6, NULL, 0);
>>               else if (!strcmp(this_opt, "nowc"))
>>                   mem_flags &= ~EFI_MEMORY_WC;
>>               else if (!strcmp(this_opt, "nobgrt"))
>> @@ -310,15 +309,15 @@ static int efifb_setup(char *options)
>>       return 0;
>>   }
>> -static inline bool fb_base_is_valid(void)
>> +static inline bool fb_base_is_valid(struct screen_info *si)
>>   {
>> -    if (screen_info.lfb_base)
>> +    if (si->lfb_base)
>>           return true;
>> -    if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>> +    if (!(si->capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>>           return false;
>> -    if (screen_info.ext_lfb_base)
>> +    if (si->ext_lfb_base)
>>           return true;
>>       return false;
>> @@ -329,7 +328,10 @@ static ssize_t name##_show(struct device 
>> *dev,                \
>>                  struct device_attribute *attr,        \
>>                  char *buf)                    \
>>   {                                    \
>> -    return sprintf(buf, fmt "\n", (screen_info.lfb_##name));    \
>> +    struct screen_info *si = dev_get_platdata(dev);            \
>> +    if (!si)                            \
>> +        return -ENODEV;                        \
>> +    return sprintf(buf, fmt "\n", (si->lfb_##name));        \
>>   }                                    \
>>   static DEVICE_ATTR_RO(name)
>> @@ -356,6 +358,7 @@ static u64 bar_offset;
>>   static int efifb_probe(struct platform_device *dev)
>>   {
>> +    struct screen_info *si = &screen_info;
>>       struct fb_info *info;
>>       struct efifb_par *par;
>>       int err, orientation;
>> @@ -365,48 +368,48 @@ static int efifb_probe(struct platform_device *dev)
>>       char *option = NULL;
>>       efi_memory_desc_t md;
>> -    if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || 
>> pci_dev_disabled)
>> +    if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
>>           return -ENODEV;
>>       if (fb_get_options("efifb", &option))
>>           return -ENODEV;
>> -    efifb_setup(option);
>> +    efifb_setup(si, option);
>>       /* We don't get linelength from UGA Draw Protocol, only from
>>        * EFI Graphics Protocol.  So if it's not in DMI, and it's not
>>        * passed in from the user, we really can't use the framebuffer.
>>        */
>> -    if (!screen_info.lfb_linelength)
>> +    if (!si->lfb_linelength)
>>           return -ENODEV;
>> -    if (!screen_info.lfb_depth)
>> -        screen_info.lfb_depth = 32;
>> -    if (!screen_info.pages)
>> -        screen_info.pages = 1;
>> -    if (!fb_base_is_valid()) {
>> +    if (!si->lfb_depth)
>> +        si->lfb_depth = 32;
>> +    if (!si->pages)
>> +        si->pages = 1;
>> +    if (!fb_base_is_valid(si)) {
>>           printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
>>           return -ENODEV;
>>       }
>>       printk(KERN_INFO "efifb: probing for efifb\n");
>>       /* just assume they're all unset if any are */
>> -    if (!screen_info.blue_size) {
>> -        screen_info.blue_size = 8;
>> -        screen_info.blue_pos = 0;
>> -        screen_info.green_size = 8;
>> -        screen_info.green_pos = 8;
>> -        screen_info.red_size = 8;
>> -        screen_info.red_pos = 16;
>> -        screen_info.rsvd_size = 8;
>> -        screen_info.rsvd_pos = 24;
>> +    if (!si->blue_size) {
>> +        si->blue_size = 8;
>> +        si->blue_pos = 0;
>> +        si->green_size = 8;
>> +        si->green_pos = 8;
>> +        si->red_size = 8;
>> +        si->red_pos = 16;
>> +        si->rsvd_size = 8;
>> +        si->rsvd_pos = 24;
>>       }
> 
> 
> Yeah, Here the efifb modified our local screen_info instance, but this 
> is not relevant to your patch.
> 
> 
>> -    efifb_fix.smem_start = screen_info.lfb_base;
>> +    efifb_fix.smem_start = si->lfb_base;
>> -    if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>> +    if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>>           u64 ext_lfb_base;
>> -        ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base 
>> << 32;
>> +        ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
>>           efifb_fix.smem_start |= ext_lfb_base;
>>       }
>> @@ -417,10 +420,10 @@ static int efifb_probe(struct platform_device *dev)
>>           efifb_fix.smem_start = bar_resource->start + bar_offset;
>>       }
>> -    efifb_defined.bits_per_pixel = screen_info.lfb_depth;
>> -    efifb_defined.xres = screen_info.lfb_width;
>> -    efifb_defined.yres = screen_info.lfb_height;
>> -    efifb_fix.line_length = screen_info.lfb_linelength;
>> +    efifb_defined.bits_per_pixel = si->lfb_depth;
>> +    efifb_defined.xres = si->lfb_width;
>> +    efifb_defined.yres = si->lfb_height;
>> +    efifb_fix.line_length = si->lfb_linelength;
>>       /*   size_vmode -- that is the amount of memory needed for the
>>        *                 used video mode, i.e. the minimum amount of
>> @@ -430,7 +433,7 @@ static int efifb_probe(struct platform_device *dev)
>>       /*   size_total -- all video memory we have. Used for
>>        *                 entries, ressource allocation and bounds
>>        *                 checking. */
>> -    size_total = screen_info.lfb_size;
>> +    size_total = si->lfb_size;
>>       if (size_total < size_vmode)
>>           size_total = size_vmode;
>> @@ -512,7 +515,7 @@ static int efifb_probe(struct platform_device *dev)
>>       pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
>>              efifb_defined.xres, efifb_defined.yres,
>>              efifb_defined.bits_per_pixel, efifb_fix.line_length,
>> -           screen_info.pages);
>> +           si->pages);
>>       efifb_defined.xres_virtual = efifb_defined.xres;
>>       efifb_defined.yres_virtual = efifb_fix.smem_len /
>> @@ -526,26 +529,26 @@ static int efifb_probe(struct platform_device *dev)
>>       efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
>>       efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
>> -    efifb_defined.red.offset    = screen_info.red_pos;
>> -    efifb_defined.red.length    = screen_info.red_size;
>> -    efifb_defined.green.offset  = screen_info.green_pos;
>> -    efifb_defined.green.length  = screen_info.green_size;
>> -    efifb_defined.blue.offset   = screen_info.blue_pos;
>> -    efifb_defined.blue.length   = screen_info.blue_size;
>> -    efifb_defined.transp.offset = screen_info.rsvd_pos;
>> -    efifb_defined.transp.length = screen_info.rsvd_size;
>> +    efifb_defined.red.offset    = si->red_pos;
>> +    efifb_defined.red.length    = si->red_size;
>> +    efifb_defined.green.offset  = si->green_pos;
>> +    efifb_defined.green.length  = si->green_size;
>> +    efifb_defined.blue.offset   = si->blue_pos;
>> +    efifb_defined.blue.length   = si->blue_size;
>> +    efifb_defined.transp.offset = si->rsvd_pos;
>> +    efifb_defined.transp.length = si->rsvd_size;
>>       pr_info("efifb: %s: "
>>              "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
>>              "Truecolor",
>> -           screen_info.rsvd_size,
>> -           screen_info.red_size,
>> -           screen_info.green_size,
>> -           screen_info.blue_size,
>> -           screen_info.rsvd_pos,
>> -           screen_info.red_pos,
>> -           screen_info.green_pos,
>> -           screen_info.blue_pos);
>> +           si->rsvd_size,
>> +           si->red_size,
>> +           si->green_size,
>> +           si->blue_size,
>> +           si->rsvd_pos,
>> +           si->red_pos,
>> +           si->green_pos,
>> +           si->blue_pos);
>>       efifb_fix.ypanstep  = 0;
>>       efifb_fix.ywrapstep = 0;
Thomas Zimmermann Dec. 6, 2023, 9:45 a.m. UTC | #5
Hi

Am 04.12.23 um 20:53 schrieb Sui Jingfeng:
> Hi,
> 
> 
> On 2023/12/4 17:27, Thomas Zimmermann wrote:
>> Get the global screen_info's address once and access the data via
>> this pointer. Limits the use of global state.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
> 
> 
> I have applied the whole series and do a simple test with efifb:
> Yeah, still works!

Can I take this as Tested-by: for the efifb patches ?

Best regards
Thomas

> 
> $ dmesg | grep efifb
> 
> [    0.373800] efifb: probing for efifb
> [    0.373816] efifb: framebuffer at 0xe0030000000, using 5120k, total 
> 5120k
> [    0.373818] efifb: mode is 1280x1024x32, linelength=5120, pages=1
> [    0.373820] efifb: scrolling: redraw
> [    0.373821] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
> 
> 
>> ---
>>   drivers/video/fbdev/efifb.c | 113 ++++++++++++++++++------------------
>>   1 file changed, 58 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>> index f9b4ddd592ce4..6cbb65bbe1110 100644
>> --- a/drivers/video/fbdev/efifb.c
>> +++ b/drivers/video/fbdev/efifb.c
>> @@ -147,10 +147,9 @@ static bool efifb_bgrt_sanity_check(struct 
>> screen_info *si, u32 bmp_width)
>>   }
>>   #endif
>> -static void efifb_show_boot_graphics(struct fb_info *info)
>> +static void efifb_show_boot_graphics(struct fb_info *info, struct 
>> screen_info *si)
> 
> I think, we probably can add a const modifier for the function
> which doesn't modify our local the screen_info instance in the future.
> 
> static void efifb_show_boot_graphics(struct fb_info *info, const struct 
> screen_info *si)
> 
> Since screen_info is mostly used to provide information.
> 
> 
>>   {
>>       u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
>> -    struct screen_info *si = &screen_info;
>>       struct bmp_file_header *file_header;
>>       struct bmp_dib_header *dib_header;
>>       void *bgrt_image = NULL;
>> @@ -282,7 +281,7 @@ static const struct fb_ops efifb_ops = {
>>       .fb_setcolreg    = efifb_setcolreg,
>>   };
>> -static int efifb_setup(char *options)
>> +static int efifb_setup(struct screen_info *si, char *options)
>>   {
>>       char *this_opt;
>> @@ -290,16 +289,16 @@ static int efifb_setup(char *options)
>>           while ((this_opt = strsep(&options, ",")) != NULL) {
>>               if (!*this_opt) continue;
>> -            efifb_setup_from_dmi(&screen_info, this_opt);
>> +            efifb_setup_from_dmi(si, this_opt);
>>               if (!strncmp(this_opt, "base:", 5))
>> -                screen_info.lfb_base = simple_strtoul(this_opt+5, 
>> NULL, 0);
>> +                si->lfb_base = simple_strtoul(this_opt+5, NULL, 0);
>>               else if (!strncmp(this_opt, "stride:", 7))
>> -                screen_info.lfb_linelength = 
>> simple_strtoul(this_opt+7, NULL, 0) * 4;
>> +                si->lfb_linelength = simple_strtoul(this_opt+7, NULL, 
>> 0) * 4;
>>               else if (!strncmp(this_opt, "height:", 7))
>> -                screen_info.lfb_height = simple_strtoul(this_opt+7, 
>> NULL, 0);
>> +                si->lfb_height = simple_strtoul(this_opt+7, NULL, 0);
>>               else if (!strncmp(this_opt, "width:", 6))
>> -                screen_info.lfb_width = simple_strtoul(this_opt+6, 
>> NULL, 0);
>> +                si->lfb_width = simple_strtoul(this_opt+6, NULL, 0);
>>               else if (!strcmp(this_opt, "nowc"))
>>                   mem_flags &= ~EFI_MEMORY_WC;
>>               else if (!strcmp(this_opt, "nobgrt"))
>> @@ -310,15 +309,15 @@ static int efifb_setup(char *options)
>>       return 0;
>>   }
>> -static inline bool fb_base_is_valid(void)
>> +static inline bool fb_base_is_valid(struct screen_info *si)
>>   {
>> -    if (screen_info.lfb_base)
>> +    if (si->lfb_base)
>>           return true;
>> -    if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>> +    if (!(si->capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>>           return false;
>> -    if (screen_info.ext_lfb_base)
>> +    if (si->ext_lfb_base)
>>           return true;
>>       return false;
>> @@ -329,7 +328,10 @@ static ssize_t name##_show(struct device 
>> *dev,                \
>>                  struct device_attribute *attr,        \
>>                  char *buf)                    \
>>   {                                    \
>> -    return sprintf(buf, fmt "\n", (screen_info.lfb_##name));    \
>> +    struct screen_info *si = dev_get_platdata(dev);            \
>> +    if (!si)                            \
>> +        return -ENODEV;                        \
>> +    return sprintf(buf, fmt "\n", (si->lfb_##name));        \
>>   }                                    \
>>   static DEVICE_ATTR_RO(name)
>> @@ -356,6 +358,7 @@ static u64 bar_offset;
>>   static int efifb_probe(struct platform_device *dev)
>>   {
>> +    struct screen_info *si = &screen_info;
>>       struct fb_info *info;
>>       struct efifb_par *par;
>>       int err, orientation;
>> @@ -365,48 +368,48 @@ static int efifb_probe(struct platform_device *dev)
>>       char *option = NULL;
>>       efi_memory_desc_t md;
>> -    if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || 
>> pci_dev_disabled)
>> +    if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
>>           return -ENODEV;
>>       if (fb_get_options("efifb", &option))
>>           return -ENODEV;
>> -    efifb_setup(option);
>> +    efifb_setup(si, option);
>>       /* We don't get linelength from UGA Draw Protocol, only from
>>        * EFI Graphics Protocol.  So if it's not in DMI, and it's not
>>        * passed in from the user, we really can't use the framebuffer.
>>        */
>> -    if (!screen_info.lfb_linelength)
>> +    if (!si->lfb_linelength)
>>           return -ENODEV;
>> -    if (!screen_info.lfb_depth)
>> -        screen_info.lfb_depth = 32;
>> -    if (!screen_info.pages)
>> -        screen_info.pages = 1;
>> -    if (!fb_base_is_valid()) {
>> +    if (!si->lfb_depth)
>> +        si->lfb_depth = 32;
>> +    if (!si->pages)
>> +        si->pages = 1;
>> +    if (!fb_base_is_valid(si)) {
>>           printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
>>           return -ENODEV;
>>       }
>>       printk(KERN_INFO "efifb: probing for efifb\n");
>>       /* just assume they're all unset if any are */
>> -    if (!screen_info.blue_size) {
>> -        screen_info.blue_size = 8;
>> -        screen_info.blue_pos = 0;
>> -        screen_info.green_size = 8;
>> -        screen_info.green_pos = 8;
>> -        screen_info.red_size = 8;
>> -        screen_info.red_pos = 16;
>> -        screen_info.rsvd_size = 8;
>> -        screen_info.rsvd_pos = 24;
>> +    if (!si->blue_size) {
>> +        si->blue_size = 8;
>> +        si->blue_pos = 0;
>> +        si->green_size = 8;
>> +        si->green_pos = 8;
>> +        si->red_size = 8;
>> +        si->red_pos = 16;
>> +        si->rsvd_size = 8;
>> +        si->rsvd_pos = 24;
>>       }
> 
> 
> Yeah, Here the efifb modified our local screen_info instance, but this 
> is not relevant to your patch.
> 
> 
>> -    efifb_fix.smem_start = screen_info.lfb_base;
>> +    efifb_fix.smem_start = si->lfb_base;
>> -    if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>> +    if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>>           u64 ext_lfb_base;
>> -        ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base 
>> << 32;
>> +        ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
>>           efifb_fix.smem_start |= ext_lfb_base;
>>       }
>> @@ -417,10 +420,10 @@ static int efifb_probe(struct platform_device *dev)
>>           efifb_fix.smem_start = bar_resource->start + bar_offset;
>>       }
>> -    efifb_defined.bits_per_pixel = screen_info.lfb_depth;
>> -    efifb_defined.xres = screen_info.lfb_width;
>> -    efifb_defined.yres = screen_info.lfb_height;
>> -    efifb_fix.line_length = screen_info.lfb_linelength;
>> +    efifb_defined.bits_per_pixel = si->lfb_depth;
>> +    efifb_defined.xres = si->lfb_width;
>> +    efifb_defined.yres = si->lfb_height;
>> +    efifb_fix.line_length = si->lfb_linelength;
>>       /*   size_vmode -- that is the amount of memory needed for the
>>        *                 used video mode, i.e. the minimum amount of
>> @@ -430,7 +433,7 @@ static int efifb_probe(struct platform_device *dev)
>>       /*   size_total -- all video memory we have. Used for
>>        *                 entries, ressource allocation and bounds
>>        *                 checking. */
>> -    size_total = screen_info.lfb_size;
>> +    size_total = si->lfb_size;
>>       if (size_total < size_vmode)
>>           size_total = size_vmode;
>> @@ -512,7 +515,7 @@ static int efifb_probe(struct platform_device *dev)
>>       pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
>>              efifb_defined.xres, efifb_defined.yres,
>>              efifb_defined.bits_per_pixel, efifb_fix.line_length,
>> -           screen_info.pages);
>> +           si->pages);
>>       efifb_defined.xres_virtual = efifb_defined.xres;
>>       efifb_defined.yres_virtual = efifb_fix.smem_len /
>> @@ -526,26 +529,26 @@ static int efifb_probe(struct platform_device *dev)
>>       efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
>>       efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
>> -    efifb_defined.red.offset    = screen_info.red_pos;
>> -    efifb_defined.red.length    = screen_info.red_size;
>> -    efifb_defined.green.offset  = screen_info.green_pos;
>> -    efifb_defined.green.length  = screen_info.green_size;
>> -    efifb_defined.blue.offset   = screen_info.blue_pos;
>> -    efifb_defined.blue.length   = screen_info.blue_size;
>> -    efifb_defined.transp.offset = screen_info.rsvd_pos;
>> -    efifb_defined.transp.length = screen_info.rsvd_size;
>> +    efifb_defined.red.offset    = si->red_pos;
>> +    efifb_defined.red.length    = si->red_size;
>> +    efifb_defined.green.offset  = si->green_pos;
>> +    efifb_defined.green.length  = si->green_size;
>> +    efifb_defined.blue.offset   = si->blue_pos;
>> +    efifb_defined.blue.length   = si->blue_size;
>> +    efifb_defined.transp.offset = si->rsvd_pos;
>> +    efifb_defined.transp.length = si->rsvd_size;
>>       pr_info("efifb: %s: "
>>              "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
>>              "Truecolor",
>> -           screen_info.rsvd_size,
>> -           screen_info.red_size,
>> -           screen_info.green_size,
>> -           screen_info.blue_size,
>> -           screen_info.rsvd_pos,
>> -           screen_info.red_pos,
>> -           screen_info.green_pos,
>> -           screen_info.blue_pos);
>> +           si->rsvd_size,
>> +           si->red_size,
>> +           si->green_size,
>> +           si->blue_size,
>> +           si->rsvd_pos,
>> +           si->red_pos,
>> +           si->green_pos,
>> +           si->blue_pos);
>>       efifb_fix.ypanstep  = 0;
>>       efifb_fix.ywrapstep = 0;
Sui Jingfeng Dec. 6, 2023, 10:46 a.m. UTC | #6
Hi,

On 2023/12/6 17:45, Thomas Zimmermann wrote:
> Hi
>
> Am 04.12.23 um 20:53 schrieb Sui Jingfeng:
>> Hi,
>>
>>
>> On 2023/12/4 17:27, Thomas Zimmermann wrote:
>>> Get the global screen_info's address once and access the data via
>>> this pointer. Limits the use of global state.
>>>
>>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>>
>> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
>>
>>
>> I have applied the whole series and do a simple test with efifb:
>> Yeah, still works!
>
> Can I take this as Tested-by: for the efifb patches ?
>
No problem, with the warning reported by testing robot fixed, please!
I have tested this on a non primary arch, compiled with a normal default config.
Not noticed the line "static inline void efifb_show_boot_graphics(struct fb_info *info) {}".


> Best regards
> Thomas
>
>>
>> $ dmesg | grep efifb
>>
>> [    0.373800] efifb: probing for efifb
>> [    0.373816] efifb: framebuffer at 0xe0030000000, using 5120k, 
>> total 5120k
>> [    0.373818] efifb: mode is 1280x1024x32, linelength=5120, pages=1
>> [    0.373820] efifb: scrolling: redraw
>> [    0.373821] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
>>
>>
>>> ---
>>>   drivers/video/fbdev/efifb.c | 113 
>>> ++++++++++++++++++------------------
>>>   1 file changed, 58 insertions(+), 55 deletions(-)
>>>
>>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>>> index f9b4ddd592ce4..6cbb65bbe1110 100644
>>> --- a/drivers/video/fbdev/efifb.c
>>> +++ b/drivers/video/fbdev/efifb.c
>>> @@ -147,10 +147,9 @@ static bool efifb_bgrt_sanity_check(struct 
>>> screen_info *si, u32 bmp_width)
>>>   }
>>>   #endif
>>> -static void efifb_show_boot_graphics(struct fb_info *info)
>>> +static void efifb_show_boot_graphics(struct fb_info *info, struct 
>>> screen_info *si)
>>
>> I think, we probably can add a const modifier for the function
>> which doesn't modify our local the screen_info instance in the future.
>>
>> static void efifb_show_boot_graphics(struct fb_info *info, const 
>> struct screen_info *si)
>>
>> Since screen_info is mostly used to provide information.
>>
>>
>>>   {
>>>       u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
>>> -    struct screen_info *si = &screen_info;
>>>       struct bmp_file_header *file_header;
>>>       struct bmp_dib_header *dib_header;
>>>       void *bgrt_image = NULL;
>>> @@ -282,7 +281,7 @@ static const struct fb_ops efifb_ops = {
>>>       .fb_setcolreg    = efifb_setcolreg,
>>>   };
>>> -static int efifb_setup(char *options)
>>> +static int efifb_setup(struct screen_info *si, char *options)
>>>   {
>>>       char *this_opt;
>>> @@ -290,16 +289,16 @@ static int efifb_setup(char *options)
>>>           while ((this_opt = strsep(&options, ",")) != NULL) {
>>>               if (!*this_opt) continue;
>>> -            efifb_setup_from_dmi(&screen_info, this_opt);
>>> +            efifb_setup_from_dmi(si, this_opt);
>>>               if (!strncmp(this_opt, "base:", 5))
>>> -                screen_info.lfb_base = simple_strtoul(this_opt+5, 
>>> NULL, 0);
>>> +                si->lfb_base = simple_strtoul(this_opt+5, NULL, 0);
>>>               else if (!strncmp(this_opt, "stride:", 7))
>>> -                screen_info.lfb_linelength = 
>>> simple_strtoul(this_opt+7, NULL, 0) * 4;
>>> +                si->lfb_linelength = simple_strtoul(this_opt+7, 
>>> NULL, 0) * 4;
>>>               else if (!strncmp(this_opt, "height:", 7))
>>> -                screen_info.lfb_height = simple_strtoul(this_opt+7, 
>>> NULL, 0);
>>> +                si->lfb_height = simple_strtoul(this_opt+7, NULL, 0);
>>>               else if (!strncmp(this_opt, "width:", 6))
>>> -                screen_info.lfb_width = simple_strtoul(this_opt+6, 
>>> NULL, 0);
>>> +                si->lfb_width = simple_strtoul(this_opt+6, NULL, 0);
>>>               else if (!strcmp(this_opt, "nowc"))
>>>                   mem_flags &= ~EFI_MEMORY_WC;
>>>               else if (!strcmp(this_opt, "nobgrt"))
>>> @@ -310,15 +309,15 @@ static int efifb_setup(char *options)
>>>       return 0;
>>>   }
>>> -static inline bool fb_base_is_valid(void)
>>> +static inline bool fb_base_is_valid(struct screen_info *si)
>>>   {
>>> -    if (screen_info.lfb_base)
>>> +    if (si->lfb_base)
>>>           return true;
>>> -    if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>>> +    if (!(si->capabilities & VIDEO_CAPABILITY_64BIT_BASE))
>>>           return false;
>>> -    if (screen_info.ext_lfb_base)
>>> +    if (si->ext_lfb_base)
>>>           return true;
>>>       return false;
>>> @@ -329,7 +328,10 @@ static ssize_t name##_show(struct device 
>>> *dev,                \
>>>                  struct device_attribute *attr,        \
>>>                  char *buf)                    \
>>>   {                                    \
>>> -    return sprintf(buf, fmt "\n", (screen_info.lfb_##name));    \
>>> +    struct screen_info *si = dev_get_platdata(dev);            \
>>> +    if (!si)                            \
>>> +        return -ENODEV;                        \
>>> +    return sprintf(buf, fmt "\n", (si->lfb_##name));        \
>>>   }                                    \
>>>   static DEVICE_ATTR_RO(name)
>>> @@ -356,6 +358,7 @@ static u64 bar_offset;
>>>   static int efifb_probe(struct platform_device *dev)
>>>   {
>>> +    struct screen_info *si = &screen_info;
>>>       struct fb_info *info;
>>>       struct efifb_par *par;
>>>       int err, orientation;
>>> @@ -365,48 +368,48 @@ static int efifb_probe(struct platform_device 
>>> *dev)
>>>       char *option = NULL;
>>>       efi_memory_desc_t md;
>>> -    if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || 
>>> pci_dev_disabled)
>>> +    if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
>>>           return -ENODEV;
>>>       if (fb_get_options("efifb", &option))
>>>           return -ENODEV;
>>> -    efifb_setup(option);
>>> +    efifb_setup(si, option);
>>>       /* We don't get linelength from UGA Draw Protocol, only from
>>>        * EFI Graphics Protocol.  So if it's not in DMI, and it's not
>>>        * passed in from the user, we really can't use the framebuffer.
>>>        */
>>> -    if (!screen_info.lfb_linelength)
>>> +    if (!si->lfb_linelength)
>>>           return -ENODEV;
>>> -    if (!screen_info.lfb_depth)
>>> -        screen_info.lfb_depth = 32;
>>> -    if (!screen_info.pages)
>>> -        screen_info.pages = 1;
>>> -    if (!fb_base_is_valid()) {
>>> +    if (!si->lfb_depth)
>>> +        si->lfb_depth = 32;
>>> +    if (!si->pages)
>>> +        si->pages = 1;
>>> +    if (!fb_base_is_valid(si)) {
>>>           printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
>>>           return -ENODEV;
>>>       }
>>>       printk(KERN_INFO "efifb: probing for efifb\n");
>>>       /* just assume they're all unset if any are */
>>> -    if (!screen_info.blue_size) {
>>> -        screen_info.blue_size = 8;
>>> -        screen_info.blue_pos = 0;
>>> -        screen_info.green_size = 8;
>>> -        screen_info.green_pos = 8;
>>> -        screen_info.red_size = 8;
>>> -        screen_info.red_pos = 16;
>>> -        screen_info.rsvd_size = 8;
>>> -        screen_info.rsvd_pos = 24;
>>> +    if (!si->blue_size) {
>>> +        si->blue_size = 8;
>>> +        si->blue_pos = 0;
>>> +        si->green_size = 8;
>>> +        si->green_pos = 8;
>>> +        si->red_size = 8;
>>> +        si->red_pos = 16;
>>> +        si->rsvd_size = 8;
>>> +        si->rsvd_pos = 24;
>>>       }
>>
>>
>> Yeah, Here the efifb modified our local screen_info instance, but 
>> this is not relevant to your patch.
>>
>>
>>> -    efifb_fix.smem_start = screen_info.lfb_base;
>>> +    efifb_fix.smem_start = si->lfb_base;
>>> -    if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>>> +    if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
>>>           u64 ext_lfb_base;
>>> -        ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base 
>>> << 32;
>>> +        ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
>>>           efifb_fix.smem_start |= ext_lfb_base;
>>>       }
>>> @@ -417,10 +420,10 @@ static int efifb_probe(struct platform_device 
>>> *dev)
>>>           efifb_fix.smem_start = bar_resource->start + bar_offset;
>>>       }
>>> -    efifb_defined.bits_per_pixel = screen_info.lfb_depth;
>>> -    efifb_defined.xres = screen_info.lfb_width;
>>> -    efifb_defined.yres = screen_info.lfb_height;
>>> -    efifb_fix.line_length = screen_info.lfb_linelength;
>>> +    efifb_defined.bits_per_pixel = si->lfb_depth;
>>> +    efifb_defined.xres = si->lfb_width;
>>> +    efifb_defined.yres = si->lfb_height;
>>> +    efifb_fix.line_length = si->lfb_linelength;
>>>       /*   size_vmode -- that is the amount of memory needed for the
>>>        *                 used video mode, i.e. the minimum amount of
>>> @@ -430,7 +433,7 @@ static int efifb_probe(struct platform_device *dev)
>>>       /*   size_total -- all video memory we have. Used for
>>>        *                 entries, ressource allocation and bounds
>>>        *                 checking. */
>>> -    size_total = screen_info.lfb_size;
>>> +    size_total = si->lfb_size;
>>>       if (size_total < size_vmode)
>>>           size_total = size_vmode;
>>> @@ -512,7 +515,7 @@ static int efifb_probe(struct platform_device *dev)
>>>       pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
>>>              efifb_defined.xres, efifb_defined.yres,
>>>              efifb_defined.bits_per_pixel, efifb_fix.line_length,
>>> -           screen_info.pages);
>>> +           si->pages);
>>>       efifb_defined.xres_virtual = efifb_defined.xres;
>>>       efifb_defined.yres_virtual = efifb_fix.smem_len /
>>> @@ -526,26 +529,26 @@ static int efifb_probe(struct platform_device 
>>> *dev)
>>>       efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
>>>       efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
>>> -    efifb_defined.red.offset    = screen_info.red_pos;
>>> -    efifb_defined.red.length    = screen_info.red_size;
>>> -    efifb_defined.green.offset  = screen_info.green_pos;
>>> -    efifb_defined.green.length  = screen_info.green_size;
>>> -    efifb_defined.blue.offset   = screen_info.blue_pos;
>>> -    efifb_defined.blue.length   = screen_info.blue_size;
>>> -    efifb_defined.transp.offset = screen_info.rsvd_pos;
>>> -    efifb_defined.transp.length = screen_info.rsvd_size;
>>> +    efifb_defined.red.offset    = si->red_pos;
>>> +    efifb_defined.red.length    = si->red_size;
>>> +    efifb_defined.green.offset  = si->green_pos;
>>> +    efifb_defined.green.length  = si->green_size;
>>> +    efifb_defined.blue.offset   = si->blue_pos;
>>> +    efifb_defined.blue.length   = si->blue_size;
>>> +    efifb_defined.transp.offset = si->rsvd_pos;
>>> +    efifb_defined.transp.length = si->rsvd_size;
>>>       pr_info("efifb: %s: "
>>>              "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
>>>              "Truecolor",
>>> -           screen_info.rsvd_size,
>>> -           screen_info.red_size,
>>> -           screen_info.green_size,
>>> -           screen_info.blue_size,
>>> -           screen_info.rsvd_pos,
>>> -           screen_info.red_pos,
>>> -           screen_info.green_pos,
>>> -           screen_info.blue_pos);
>>> +           si->rsvd_size,
>>> +           si->red_size,
>>> +           si->green_size,
>>> +           si->blue_size,
>>> +           si->rsvd_pos,
>>> +           si->red_pos,
>>> +           si->green_pos,
>>> +           si->blue_pos);
>>>       efifb_fix.ypanstep  = 0;
>>>       efifb_fix.ywrapstep = 0;
>
diff mbox series

Patch

diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
index f9b4ddd592ce4..6cbb65bbe1110 100644
--- a/drivers/video/fbdev/efifb.c
+++ b/drivers/video/fbdev/efifb.c
@@ -147,10 +147,9 @@  static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)
 }
 #endif
 
-static void efifb_show_boot_graphics(struct fb_info *info)
+static void efifb_show_boot_graphics(struct fb_info *info, struct screen_info *si)
 {
 	u32 bmp_width, bmp_height, bmp_pitch, dst_x, y, src_y;
-	struct screen_info *si = &screen_info;
 	struct bmp_file_header *file_header;
 	struct bmp_dib_header *dib_header;
 	void *bgrt_image = NULL;
@@ -282,7 +281,7 @@  static const struct fb_ops efifb_ops = {
 	.fb_setcolreg	= efifb_setcolreg,
 };
 
-static int efifb_setup(char *options)
+static int efifb_setup(struct screen_info *si, char *options)
 {
 	char *this_opt;
 
@@ -290,16 +289,16 @@  static int efifb_setup(char *options)
 		while ((this_opt = strsep(&options, ",")) != NULL) {
 			if (!*this_opt) continue;
 
-			efifb_setup_from_dmi(&screen_info, this_opt);
+			efifb_setup_from_dmi(si, this_opt);
 
 			if (!strncmp(this_opt, "base:", 5))
-				screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
+				si->lfb_base = simple_strtoul(this_opt+5, NULL, 0);
 			else if (!strncmp(this_opt, "stride:", 7))
-				screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
+				si->lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
 			else if (!strncmp(this_opt, "height:", 7))
-				screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
+				si->lfb_height = simple_strtoul(this_opt+7, NULL, 0);
 			else if (!strncmp(this_opt, "width:", 6))
-				screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
+				si->lfb_width = simple_strtoul(this_opt+6, NULL, 0);
 			else if (!strcmp(this_opt, "nowc"))
 				mem_flags &= ~EFI_MEMORY_WC;
 			else if (!strcmp(this_opt, "nobgrt"))
@@ -310,15 +309,15 @@  static int efifb_setup(char *options)
 	return 0;
 }
 
-static inline bool fb_base_is_valid(void)
+static inline bool fb_base_is_valid(struct screen_info *si)
 {
-	if (screen_info.lfb_base)
+	if (si->lfb_base)
 		return true;
 
-	if (!(screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE))
+	if (!(si->capabilities & VIDEO_CAPABILITY_64BIT_BASE))
 		return false;
 
-	if (screen_info.ext_lfb_base)
+	if (si->ext_lfb_base)
 		return true;
 
 	return false;
@@ -329,7 +328,10 @@  static ssize_t name##_show(struct device *dev,				\
 			   struct device_attribute *attr,		\
 			   char *buf)					\
 {									\
-	return sprintf(buf, fmt "\n", (screen_info.lfb_##name));	\
+	struct screen_info *si = dev_get_platdata(dev);			\
+	if (!si)							\
+		return -ENODEV;						\
+	return sprintf(buf, fmt "\n", (si->lfb_##name));		\
 }									\
 static DEVICE_ATTR_RO(name)
 
@@ -356,6 +358,7 @@  static u64 bar_offset;
 
 static int efifb_probe(struct platform_device *dev)
 {
+	struct screen_info *si = &screen_info;
 	struct fb_info *info;
 	struct efifb_par *par;
 	int err, orientation;
@@ -365,48 +368,48 @@  static int efifb_probe(struct platform_device *dev)
 	char *option = NULL;
 	efi_memory_desc_t md;
 
-	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
+	if (si->orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
 		return -ENODEV;
 
 	if (fb_get_options("efifb", &option))
 		return -ENODEV;
-	efifb_setup(option);
+	efifb_setup(si, option);
 
 	/* We don't get linelength from UGA Draw Protocol, only from
 	 * EFI Graphics Protocol.  So if it's not in DMI, and it's not
 	 * passed in from the user, we really can't use the framebuffer.
 	 */
-	if (!screen_info.lfb_linelength)
+	if (!si->lfb_linelength)
 		return -ENODEV;
 
-	if (!screen_info.lfb_depth)
-		screen_info.lfb_depth = 32;
-	if (!screen_info.pages)
-		screen_info.pages = 1;
-	if (!fb_base_is_valid()) {
+	if (!si->lfb_depth)
+		si->lfb_depth = 32;
+	if (!si->pages)
+		si->pages = 1;
+	if (!fb_base_is_valid(si)) {
 		printk(KERN_DEBUG "efifb: invalid framebuffer address\n");
 		return -ENODEV;
 	}
 	printk(KERN_INFO "efifb: probing for efifb\n");
 
 	/* just assume they're all unset if any are */
-	if (!screen_info.blue_size) {
-		screen_info.blue_size = 8;
-		screen_info.blue_pos = 0;
-		screen_info.green_size = 8;
-		screen_info.green_pos = 8;
-		screen_info.red_size = 8;
-		screen_info.red_pos = 16;
-		screen_info.rsvd_size = 8;
-		screen_info.rsvd_pos = 24;
+	if (!si->blue_size) {
+		si->blue_size = 8;
+		si->blue_pos = 0;
+		si->green_size = 8;
+		si->green_pos = 8;
+		si->red_size = 8;
+		si->red_pos = 16;
+		si->rsvd_size = 8;
+		si->rsvd_pos = 24;
 	}
 
-	efifb_fix.smem_start = screen_info.lfb_base;
+	efifb_fix.smem_start = si->lfb_base;
 
-	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
+	if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE) {
 		u64 ext_lfb_base;
 
-		ext_lfb_base = (u64)(unsigned long)screen_info.ext_lfb_base << 32;
+		ext_lfb_base = (u64)(unsigned long)si->ext_lfb_base << 32;
 		efifb_fix.smem_start |= ext_lfb_base;
 	}
 
@@ -417,10 +420,10 @@  static int efifb_probe(struct platform_device *dev)
 		efifb_fix.smem_start = bar_resource->start + bar_offset;
 	}
 
-	efifb_defined.bits_per_pixel = screen_info.lfb_depth;
-	efifb_defined.xres = screen_info.lfb_width;
-	efifb_defined.yres = screen_info.lfb_height;
-	efifb_fix.line_length = screen_info.lfb_linelength;
+	efifb_defined.bits_per_pixel = si->lfb_depth;
+	efifb_defined.xres = si->lfb_width;
+	efifb_defined.yres = si->lfb_height;
+	efifb_fix.line_length = si->lfb_linelength;
 
 	/*   size_vmode -- that is the amount of memory needed for the
 	 *                 used video mode, i.e. the minimum amount of
@@ -430,7 +433,7 @@  static int efifb_probe(struct platform_device *dev)
 	/*   size_total -- all video memory we have. Used for
 	 *                 entries, ressource allocation and bounds
 	 *                 checking. */
-	size_total = screen_info.lfb_size;
+	size_total = si->lfb_size;
 	if (size_total < size_vmode)
 		size_total = size_vmode;
 
@@ -512,7 +515,7 @@  static int efifb_probe(struct platform_device *dev)
 	pr_info("efifb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
 	       efifb_defined.xres, efifb_defined.yres,
 	       efifb_defined.bits_per_pixel, efifb_fix.line_length,
-	       screen_info.pages);
+	       si->pages);
 
 	efifb_defined.xres_virtual = efifb_defined.xres;
 	efifb_defined.yres_virtual = efifb_fix.smem_len /
@@ -526,26 +529,26 @@  static int efifb_probe(struct platform_device *dev)
 	efifb_defined.left_margin  = (efifb_defined.xres / 8) & 0xf8;
 	efifb_defined.hsync_len    = (efifb_defined.xres / 8) & 0xf8;
 
-	efifb_defined.red.offset    = screen_info.red_pos;
-	efifb_defined.red.length    = screen_info.red_size;
-	efifb_defined.green.offset  = screen_info.green_pos;
-	efifb_defined.green.length  = screen_info.green_size;
-	efifb_defined.blue.offset   = screen_info.blue_pos;
-	efifb_defined.blue.length   = screen_info.blue_size;
-	efifb_defined.transp.offset = screen_info.rsvd_pos;
-	efifb_defined.transp.length = screen_info.rsvd_size;
+	efifb_defined.red.offset    = si->red_pos;
+	efifb_defined.red.length    = si->red_size;
+	efifb_defined.green.offset  = si->green_pos;
+	efifb_defined.green.length  = si->green_size;
+	efifb_defined.blue.offset   = si->blue_pos;
+	efifb_defined.blue.length   = si->blue_size;
+	efifb_defined.transp.offset = si->rsvd_pos;
+	efifb_defined.transp.length = si->rsvd_size;
 
 	pr_info("efifb: %s: "
 	       "size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n",
 	       "Truecolor",
-	       screen_info.rsvd_size,
-	       screen_info.red_size,
-	       screen_info.green_size,
-	       screen_info.blue_size,
-	       screen_info.rsvd_pos,
-	       screen_info.red_pos,
-	       screen_info.green_pos,
-	       screen_info.blue_pos);
+	       si->rsvd_size,
+	       si->red_size,
+	       si->green_size,
+	       si->blue_size,
+	       si->rsvd_pos,
+	       si->red_pos,
+	       si->green_pos,
+	       si->blue_pos);
 
 	efifb_fix.ypanstep  = 0;
 	efifb_fix.ywrapstep = 0;