linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Dave Airlie <airlied@gmail.com>, linux-fbdev@vger.kernel.org
Cc: Dave Airlie <airlied@redhat.com>, Zeno Davatz <zdavatz@gmail.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] nvidiafb: detect the hardware support before removing console.
Date: Mon, 6 Feb 2023 10:05:48 +0100	[thread overview]
Message-ID: <d76a8946-e898-2e18-a2b5-04db696040ab@suse.de> (raw)
In-Reply-To: <20230205210751.3842103-1-airlied@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 6626 bytes --]

Hi Dave,

thanks a lot. I was able to reproduce the problem and get it fixed by 
the patch. As expected, there's still the warning about 'unknown 
NV_ARCH', but the firmware display remains active.  Applies cleanly to 
drm-tip BTW.

Am 05.02.23 um 22:07 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> This driver removed the console, but hasn't yet decided if it could
> take over the console yet. Instead of doing that, probe the hw for
> support and then remove the console afterwards.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=216859
> Reported-by: Zeno Davatz <zdavatz@gmail.com>

Tested-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 145eed48de27 ("fbdev: Remove conflicting devices on PCI bus")


> ---
>   drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
>   1 file changed, 42 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
> index 1960916098d4..e60a276b4855 100644
> --- a/drivers/video/fbdev/nvidia/nvidia.c
> +++ b/drivers/video/fbdev/nvidia/nvidia.c
> @@ -1197,17 +1197,17 @@ static int nvidia_set_fbinfo(struct fb_info *info)
>   	return nvidiafb_check_var(&info->var, info);
>   }
>   
> -static u32 nvidia_get_chipset(struct fb_info *info)
> +static u32 nvidia_get_chipset(struct pci_dev *pci_dev,
> +			      volatile u32 __iomem *REGS)
>   {
> -	struct nvidia_par *par = info->par;
> -	u32 id = (par->pci_dev->vendor << 16) | par->pci_dev->device;
> +	u32 id = (pci_dev->vendor << 16) | pci_dev->device;
>   
>   	printk(KERN_INFO PFX "Device ID: %x \n", id);
>   
>   	if ((id & 0xfff0) == 0x00f0 ||
>   	    (id & 0xfff0) == 0x02e0) {
>   		/* pci-e */
> -		id = NV_RD32(par->REGS, 0x1800);
> +		id = NV_RD32(REGS, 0x1800);
>   
>   		if ((id & 0x0000ffff) == 0x000010DE)
>   			id = 0x10DE0000 | (id >> 16);
> @@ -1220,12 +1220,11 @@ static u32 nvidia_get_chipset(struct fb_info *info)
>   	return id;
>   }
>   
> -static u32 nvidia_get_arch(struct fb_info *info)
> +static u32 nvidia_get_arch(u32 Chipset)
>   {
> -	struct nvidia_par *par = info->par;
>   	u32 arch = 0;
>   
> -	switch (par->Chipset & 0x0ff0) {
> +	switch (Chipset & 0x0ff0) {
>   	case 0x0100:		/* GeForce 256 */
>   	case 0x0110:		/* GeForce2 MX */
>   	case 0x0150:		/* GeForce2 */
> @@ -1278,16 +1277,44 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
>   	struct fb_info *info;
>   	unsigned short cmd;
>   	int ret;
> +	volatile u32 __iomem *REGS;
> +	int Chipset;
> +	u32 Architecture;
>   
>   	NVTRACE_ENTER();
>   	assert(pd != NULL);
>   
> +	if (pci_enable_device(pd)) {
> +		printk(KERN_ERR PFX "cannot enable PCI device\n");
> +		return -ENODEV;
> +	}
> +
> +	/* enable IO and mem if not already done */
> +	pci_read_config_word(pd, PCI_COMMAND, &cmd);
> +	cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
> +	pci_write_config_word(pd, PCI_COMMAND, cmd);
> +
> +	nvidiafb_fix.mmio_start = pci_resource_start(pd, 0);
> +	nvidiafb_fix.mmio_len = pci_resource_len(pd, 0);
> +
> +	REGS = ioremap(nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len);
> +	if (!REGS) {
> +		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
> +		return -ENODEV;
> +	}
> +
> +	Chipset = nvidia_get_chipset(pd, REGS);
> +	Architecture = nvidia_get_arch(Chipset);
> +	if (Architecture == 0) {
> +		printk(KERN_ERR PFX "unknown NV_ARCH\n");
> +		goto err_out;
> +	}
> +
>   	ret = aperture_remove_conflicting_pci_devices(pd, "nvidiafb");
>   	if (ret)
> -		return ret;
> +		goto err_out;
>   
>   	info = framebuffer_alloc(sizeof(struct nvidia_par), &pd->dev);
> -
>   	if (!info)
>   		goto err_out;
>   
> @@ -1298,11 +1325,6 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
>   	if (info->pixmap.addr == NULL)
>   		goto err_out_kfree;
>   
> -	if (pci_enable_device(pd)) {
> -		printk(KERN_ERR PFX "cannot enable PCI device\n");
> -		goto err_out_enable;
> -	}
> -
>   	if (pci_request_regions(pd, "nvidiafb")) {
>   		printk(KERN_ERR PFX "cannot request PCI regions\n");
>   		goto err_out_enable;
> @@ -1318,34 +1340,17 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
>   	par->paneltweak = paneltweak;
>   	par->reverse_i2c = reverse_i2c;
>   
> -	/* enable IO and mem if not already done */
> -	pci_read_config_word(pd, PCI_COMMAND, &cmd);
> -	cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
> -	pci_write_config_word(pd, PCI_COMMAND, cmd);
> -
> -	nvidiafb_fix.mmio_start = pci_resource_start(pd, 0);
>   	nvidiafb_fix.smem_start = pci_resource_start(pd, 1);
> -	nvidiafb_fix.mmio_len = pci_resource_len(pd, 0);
> -
> -	par->REGS = ioremap(nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len);
>   
> -	if (!par->REGS) {
> -		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
> -		goto err_out_free_base0;
> -	}
> +	par->REGS = REGS;
>   
> -	par->Chipset = nvidia_get_chipset(info);
> -	par->Architecture = nvidia_get_arch(info);
> -
> -	if (par->Architecture == 0) {
> -		printk(KERN_ERR PFX "unknown NV_ARCH\n");
> -		goto err_out_arch;
> -	}
> +	par->Chipset = Chipset;
> +	par->Architecture = Architecture;
>   
>   	sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
>   
>   	if (NVCommonSetup(info))
> -		goto err_out_arch;
> +		goto err_out_free_base0;
>   
>   	par->FbAddress = nvidiafb_fix.smem_start;
>   	par->FbMapSize = par->RamAmountKBytes * 1024;
> @@ -1401,7 +1406,6 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
>   		goto err_out_iounmap_fb;
>   	}
>   
> -
>   	printk(KERN_INFO PFX
>   	       "PCI nVidia %s framebuffer (%dMB @ 0x%lX)\n",
>   	       info->fix.id,
> @@ -1415,15 +1419,14 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
>   err_out_free_base1:
>   	fb_destroy_modedb(info->monspecs.modedb);
>   	nvidia_delete_i2c_busses(par);
> -err_out_arch:
> -	iounmap(par->REGS);
> - err_out_free_base0:
> +err_out_free_base0:
>   	pci_release_regions(pd);
>   err_out_enable:
>   	kfree(info->pixmap.addr);
>   err_out_kfree:
>   	framebuffer_release(info);
>   err_out:
> +	iounmap(REGS);
>   	return -ENODEV;
>   }
>   

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

      parent reply	other threads:[~2023-02-06  9:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05 21:07 [PATCH] nvidiafb: detect the hardware support before removing console Dave Airlie
2023-02-06  7:52 ` Zeno Davatz
2023-02-06  7:54   ` Dave Airlie
2023-02-06  8:01     ` Zeno Davatz
2023-02-06  8:09       ` Dave Airlie
2023-02-06  8:37         ` Zeno Davatz
2023-02-06  8:40           ` David Airlie
2023-02-06  8:54             ` Zeno Davatz
2023-02-09  9:07               ` Thomas Zimmermann
2023-02-06  9:05 ` Thomas Zimmermann [this message]

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=d76a8946-e898-2e18-a2b5-04db696040ab@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zdavatz@gmail.com \
    /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).