linux-snps-arc.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Helge Deller <deller@gmx.de>,
	arnd@arndb.de, javierm@redhat.com, sui.jingfeng@linux.dev
Cc: linux-arch@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-fbdev@vger.kernel.org, sparclinux@vger.kernel.org,
	linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, loongarch@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"David S. Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2 2/3] arch: Remove struct fb_info from video helpers
Date: Thu, 28 Mar 2024 14:33:00 +0100	[thread overview]
Message-ID: <9db306b2-b102-4bf5-a120-e1d279269fe9@suse.de> (raw)
In-Reply-To: <b5a8bc60-ad16-407d-9e57-c224467c3f06@gmx.de>

Hi

Am 28.03.24 um 12:04 schrieb Helge Deller:
> On 3/27/24 21:41, Thomas Zimmermann wrote:
>> The per-architecture video helpers do not depend on struct fb_info
>> or anything else from fbdev. Remove it from the interface and replace
>> fb_is_primary_device() with video_is_primary_device(). The new helper
>
> Since you rename this function, wouldn't something similar to
>
> device_is_primary_display()
>     or
> device_is_primary_console()
>     or
> is_primary_graphics_device()
>     or
> is_primary_display_device()
>
> be a better name?

The video_ prefix is there to signal that the code is part of the video 
subsystem.

But there's too much code that tried to figure out a default video 
device. So I actually have different plans for this function. I'd like 
to replace it with a helper that returns the default device instead of 
just testing for it. Sample code for x86 is already in vgaarb.c. [1] The 
function's name would then be video_default_device() and return the 
appropriate struct device*. video_is_primary device() will be removed. 
This rename here is the easiest step towards the new helper. Ok?

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.8/source/drivers/pci/vgaarb.c#L559

>
> Helge
>
>> is similar in functionality, but can operate on non-fbdev devices.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
>> Cc: Helge Deller <deller@gmx.de>
>> Cc: "David S. Miller" <davem@davemloft.net>
>> Cc: Andreas Larsson <andreas@gaisler.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: Borislav Petkov <bp@alien8.de>
>> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>> Cc: x86@kernel.org
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> ---
>>   arch/parisc/include/asm/fb.h     |  8 +++++---
>>   arch/parisc/video/fbdev.c        |  9 +++++----
>>   arch/sparc/include/asm/fb.h      |  7 ++++---
>>   arch/sparc/video/fbdev.c         | 17 ++++++++---------
>>   arch/x86/include/asm/fb.h        |  8 +++++---
>>   arch/x86/video/fbdev.c           | 18 +++++++-----------
>>   drivers/video/fbdev/core/fbcon.c |  2 +-
>>   include/asm-generic/fb.h         | 11 ++++++-----
>>   8 files changed, 41 insertions(+), 39 deletions(-)
>>
>> diff --git a/arch/parisc/include/asm/fb.h b/arch/parisc/include/asm/fb.h
>> index 658a8a7dc5312..ed2a195a3e762 100644
>> --- a/arch/parisc/include/asm/fb.h
>> +++ b/arch/parisc/include/asm/fb.h
>> @@ -2,11 +2,13 @@
>>   #ifndef _ASM_FB_H_
>>   #define _ASM_FB_H_
>>
>> -struct fb_info;
>> +#include <linux/types.h>
>> +
>> +struct device;
>>
>>   #if defined(CONFIG_STI_CORE)
>> -int fb_is_primary_device(struct fb_info *info);
>> -#define fb_is_primary_device fb_is_primary_device
>> +bool video_is_primary_device(struct device *dev);
>> +#define video_is_primary_device video_is_primary_device
>>   #endif
>>
>>   #include <asm-generic/fb.h>
>> diff --git a/arch/parisc/video/fbdev.c b/arch/parisc/video/fbdev.c
>> index e4f8ac99fc9e0..540fa0c919d59 100644
>> --- a/arch/parisc/video/fbdev.c
>> +++ b/arch/parisc/video/fbdev.c
>> @@ -5,12 +5,13 @@
>>    * Copyright (C) 2001-2002 Thomas Bogendoerfer 
>> <tsbogend@alpha.franken.de>
>>    */
>>
>> -#include <linux/fb.h>
>>   #include <linux/module.h>
>>
>>   #include <video/sticore.h>
>>
>> -int fb_is_primary_device(struct fb_info *info)
>> +#include <asm/fb.h>
>> +
>> +bool video_is_primary_device(struct device *dev)
>>   {
>>       struct sti_struct *sti;
>>
>> @@ -21,6 +22,6 @@ int fb_is_primary_device(struct fb_info *info)
>>           return true;
>>
>>       /* return true if it's the default built-in framebuffer driver */
>> -    return (sti->dev == info->device);
>> +    return (sti->dev == dev);
>>   }
>> -EXPORT_SYMBOL(fb_is_primary_device);
>> +EXPORT_SYMBOL(video_is_primary_device);
>> diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
>> index 24440c0fda490..07f0325d6921c 100644
>> --- a/arch/sparc/include/asm/fb.h
>> +++ b/arch/sparc/include/asm/fb.h
>> @@ -3,10 +3,11 @@
>>   #define _SPARC_FB_H_
>>
>>   #include <linux/io.h>
>> +#include <linux/types.h>
>>
>>   #include <asm/page.h>
>>
>> -struct fb_info;
>> +struct device;
>>
>>   #ifdef CONFIG_SPARC32
>>   static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
>> @@ -18,8 +19,8 @@ static inline pgprot_t pgprot_framebuffer(pgprot_t 
>> prot,
>>   #define pgprot_framebuffer pgprot_framebuffer
>>   #endif
>>
>> -int fb_is_primary_device(struct fb_info *info);
>> -#define fb_is_primary_device fb_is_primary_device
>> +bool video_is_primary_device(struct device *dev);
>> +#define video_is_primary_device video_is_primary_device
>>
>>   static inline void fb_memcpy_fromio(void *to, const volatile void 
>> __iomem *from, size_t n)
>>   {
>> diff --git a/arch/sparc/video/fbdev.c b/arch/sparc/video/fbdev.c
>> index bff66dd1909a4..e46f0499c2774 100644
>> --- a/arch/sparc/video/fbdev.c
>> +++ b/arch/sparc/video/fbdev.c
>> @@ -1,26 +1,25 @@
>>   // SPDX-License-Identifier: GPL-2.0
>>
>>   #include <linux/console.h>
>> -#include <linux/fb.h>
>> +#include <linux/device.h>
>>   #include <linux/module.h>
>>
>> +#include <asm/fb.h>
>>   #include <asm/prom.h>
>>
>> -int fb_is_primary_device(struct fb_info *info)
>> +bool video_is_primary_device(struct device *dev)
>>   {
>> -    struct device *dev = info->device;
>> -    struct device_node *node;
>> +    struct device_node *node = dev->of_node;
>>
>>       if (console_set_on_cmdline)
>> -        return 0;
>> +        return false;
>>
>> -    node = dev->of_node;
>>       if (node && node == of_console_device)
>> -        return 1;
>> +        return true;
>>
>> -    return 0;
>> +    return false;
>>   }
>> -EXPORT_SYMBOL(fb_is_primary_device);
>> +EXPORT_SYMBOL(video_is_primary_device);
>>
>>   MODULE_DESCRIPTION("Sparc fbdev helpers");
>>   MODULE_LICENSE("GPL");
>> diff --git a/arch/x86/include/asm/fb.h b/arch/x86/include/asm/fb.h
>> index c3b9582de7efd..999db33792869 100644
>> --- a/arch/x86/include/asm/fb.h
>> +++ b/arch/x86/include/asm/fb.h
>> @@ -2,17 +2,19 @@
>>   #ifndef _ASM_X86_FB_H
>>   #define _ASM_X86_FB_H
>>
>> +#include <linux/types.h>
>> +
>>   #include <asm/page.h>
>>
>> -struct fb_info;
>> +struct device;
>>
>>   pgprot_t pgprot_framebuffer(pgprot_t prot,
>>                   unsigned long vm_start, unsigned long vm_end,
>>                   unsigned long offset);
>>   #define pgprot_framebuffer pgprot_framebuffer
>>
>> -int fb_is_primary_device(struct fb_info *info);
>> -#define fb_is_primary_device fb_is_primary_device
>> +bool video_is_primary_device(struct device *dev);
>> +#define video_is_primary_device video_is_primary_device
>>
>>   #include <asm-generic/fb.h>
>>
>> diff --git a/arch/x86/video/fbdev.c b/arch/x86/video/fbdev.c
>> index 1dd6528cc947c..4d87ce8e257fe 100644
>> --- a/arch/x86/video/fbdev.c
>> +++ b/arch/x86/video/fbdev.c
>> @@ -7,7 +7,6 @@
>>    *
>>    */
>>
>> -#include <linux/fb.h>
>>   #include <linux/module.h>
>>   #include <linux/pci.h>
>>   #include <linux/vgaarb.h>
>> @@ -25,20 +24,17 @@ pgprot_t pgprot_framebuffer(pgprot_t prot,
>>   }
>>   EXPORT_SYMBOL(pgprot_framebuffer);
>>
>> -int fb_is_primary_device(struct fb_info *info)
>> +bool video_is_primary_device(struct device *dev)
>>   {
>> -    struct device *device = info->device;
>> -    struct pci_dev *pci_dev;
>> +    struct pci_dev *pdev;
>>
>> -    if (!device || !dev_is_pci(device))
>> -        return 0;
>> +    if (!dev_is_pci(dev))
>> +        return false;
>>
>> -    pci_dev = to_pci_dev(device);
>> +    pdev = to_pci_dev(dev);
>>
>> -    if (pci_dev == vga_default_device())
>> -        return 1;
>> -    return 0;
>> +    return (pdev == vga_default_device());
>>   }
>> -EXPORT_SYMBOL(fb_is_primary_device);
>> +EXPORT_SYMBOL(video_is_primary_device);
>>
>>   MODULE_LICENSE("GPL");
>> diff --git a/drivers/video/fbdev/core/fbcon.c 
>> b/drivers/video/fbdev/core/fbcon.c
>> index 46823c2e2ba12..85c5c8cbc680a 100644
>> --- a/drivers/video/fbdev/core/fbcon.c
>> +++ b/drivers/video/fbdev/core/fbcon.c
>> @@ -2939,7 +2939,7 @@ void fbcon_remap_all(struct fb_info *info)
>>   static void fbcon_select_primary(struct fb_info *info)
>>   {
>>       if (!map_override && primary_device == -1 &&
>> -        fb_is_primary_device(info)) {
>> +        video_is_primary_device(info->device)) {
>>           int i;
>>
>>           printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n",
>> diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
>> index 6ccabb400aa66..4788c1e1c6bc0 100644
>> --- a/include/asm-generic/fb.h
>> +++ b/include/asm-generic/fb.h
>> @@ -10,8 +10,9 @@
>>   #include <linux/io.h>
>>   #include <linux/mm_types.h>
>>   #include <linux/pgtable.h>
>> +#include <linux/types.h>
>>
>> -struct fb_info;
>> +struct device;
>>
>>   #ifndef pgprot_framebuffer
>>   #define pgprot_framebuffer pgprot_framebuffer
>> @@ -23,11 +24,11 @@ static inline pgprot_t 
>> pgprot_framebuffer(pgprot_t prot,
>>   }
>>   #endif
>>
>> -#ifndef fb_is_primary_device
>> -#define fb_is_primary_device fb_is_primary_device
>> -static inline int fb_is_primary_device(struct fb_info *info)
>> +#ifndef video_is_primary_device
>> +#define video_is_primary_device video_is_primary_device
>> +static inline bool video_is_primary_device(struct device *dev)
>>   {
>> -    return 0;
>> +    return false;
>>   }
>>   #endif
>>
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

  reply	other threads:[~2024-03-28 13:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 20:41 [PATCH v2 0/3] arch: Remove fbdev dependency from video helpers Thomas Zimmermann
2024-03-27 20:41 ` [PATCH v2 1/3] arch: Select fbdev helpers with CONFIG_VIDEO Thomas Zimmermann
2024-03-28  7:24   ` Sam Ravnborg
2024-03-28 12:39   ` Helge Deller
2024-03-28 13:21     ` Thomas Zimmermann
2024-03-27 20:41 ` [PATCH v2 2/3] arch: Remove struct fb_info from video helpers Thomas Zimmermann
2024-03-28  7:25   ` Sam Ravnborg
2024-03-28 11:04   ` Helge Deller
2024-03-28 13:33     ` Thomas Zimmermann [this message]
2024-03-28 14:59       ` Helge Deller
2024-03-27 20:41 ` [PATCH v2 3/3] arch: Rename fbdev header and source files Thomas Zimmermann
2024-03-28  7:23   ` Sam Ravnborg
2024-03-28 12:46   ` Helge Deller
2024-03-28 12:51     ` Arnd Bergmann
2024-03-28 13:23       ` Thomas Zimmermann
2024-03-28 13:15   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9db306b2-b102-4bf5-a120-e1d279269fe9@suse.de \
    --to=tzimmermann@suse.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=andreas@gaisler.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hpa@zytor.com \
    --cc=javierm@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=sui.jingfeng@linux.dev \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).