Skip to contentSkip to conversation

nvidiafb: detect the hardware support before removing console.

PATCH In review Dave Airlie 4 participants 10 messages Feb 5, 2023 – Feb 9, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvidiafb: detect the hardware support before removing console.

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Signature · 1 line
2.38.1
#1 lore raw

Dear Dave

Thank you for your patch.

Quoted 180 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -40
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
--
Quoted 1 line

2.38.1

This patch fails for me.

sudo patch -p1 < /tmp/patch
Passwort:
patching file drivers/video/fbdev/nvidia/nvidia.c
Hunk #1 FAILED at 1197.
Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file
drivers/video/fbdev/nvidia/nvidia.c.rej

See attachments.

Best
Zeno

video/fbdev/nvidia/nvidia.c +42 -39
@@ -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;
 }
 
#2 lore raw
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Dave.

Quoted 18 lines

sudo patch -p1 < /tmp/patch
Passwort:
patching file drivers/video/fbdev/nvidia/nvidia.c
Hunk #1 FAILED at 1197.
Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file
drivers/video/fbdev/nvidia/nvidia.c.rej

See attachments.

Best
Zeno

#3 lore raw

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Am I doing something wrong?

/usr/src/linux> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "stable"]
url = https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable
fetch = +refs/heads/*:refs/remotes/stable/*

I am pulling from the "master" branch.

Best
Zeno

#4 lore raw
Quoted 201 lines · Zeno Davatz

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

Quoted 7 lines

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Am I doing something wrong?

What is your top of tree commit? (git log)

have you got any commits on top?

git reset --hard origin/master should reset your tree to Linus top.

Dave.

#5 lore raw

Dear Dave

Quoted 209 lines · Dave Airlie
Quoted 207 lines · Zeno Davatz

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Quoted 7 lines
Quoted 1 line

Am I doing something wrong?

What is your top of tree commit? (git log)

have you got any commits on top?

git reset --hard origin/master should reset your tree to Linus top.

1. git log shows "d2d11f342b179f1894a901f143ec7c008caba43e"
2. No, no patches on top.
3. I am doing the following steps:
/usr/src/linux> sudo git reset --hard origin/master Passwort:
HEAD ist jetzt bei d2d11f342b17 Merge branch 'fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
/usr/src/linux> sudo patch -p1 < /tmp/patch patching file drivers/video/fbdev/nvidia/nvidia.c Hunk #1 FAILED at 1197.
Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file drivers/video/fbdev/nvidia/nvidia.c.rej

Best
Zeno

#6 lore raw
Quoted 231 lines · Zeno Davatz

Dear Dave

Quoted 209 lines · Dave Airlie
Quoted 207 lines · Zeno Davatz

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Quoted 7 lines
Quoted 1 line

Am I doing something wrong?

What is your top of tree commit? (git log)

have you got any commits on top?

git reset --hard origin/master should reset your tree to Linus top.

1. git log shows "d2d11f342b179f1894a901f143ec7c008caba43e"
2. No, no patches on top.
3. I am doing the following steps:
/usr/src/linux> sudo git reset --hard origin/master Passwort:
HEAD ist jetzt bei d2d11f342b17 Merge branch 'fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
/usr/src/linux> sudo patch -p1 < /tmp/patch patching file drivers/video/fbdev/nvidia/nvidia.c Hunk #1 FAILED at 1197.

Quoted 9 lines

Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file
drivers/video/fbdev/nvidia/nvidia.c.rej

Are you pulling the patch from email? I guess your email service or something is mangling it.

I've attached it to see if that helps.

Dave.

From 58d8c4e59179c76fe7fb10cacfacdc95edc43c63 Mon Sep 17 00:00:00 2001
From: Dave Airlie <[email protected]>
Date: Mon, 6 Feb 2023 07:05:28 +1000
Subject: [PATCH] nvidiafb: detect the hardware support before removing
console.

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Signature · 1 line
2.38.1
#7 lore raw

Dear Dave

Quoted 242 lines · David Airlie
Quoted 231 lines · Zeno Davatz

Dear Dave

Quoted 209 lines · Dave Airlie
Quoted 207 lines · Zeno Davatz

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
 drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
 1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Quoted 7 lines
Quoted 1 line

Am I doing something wrong?

What is your top of tree commit? (git log)

have you got any commits on top?

git reset --hard origin/master should reset your tree to Linus top.

1. git log shows "d2d11f342b179f1894a901f143ec7c008caba43e"
2. No, no patches on top.
3. I am doing the following steps:
/usr/src/linux> sudo git reset --hard origin/master Passwort:
HEAD ist jetzt bei d2d11f342b17 Merge branch 'fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
/usr/src/linux> sudo patch -p1 < /tmp/patch patching file drivers/video/fbdev/nvidia/nvidia.c Hunk #1 FAILED at 1197.

Quoted 9 lines

Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file
drivers/video/fbdev/nvidia/nvidia.c.rej

Quoted 4 lines

Are you pulling the patch from email? I guess your email service or something is mangling it.

I've attached it to see if that helps.

Thank you! This patch works and I am booting perfectly well now!

~/.backup> uname -a
Linux zenogentoo 6.2.0-rc7-00002-gd2d11f342b17-dirty #144 SMP PREEMPT_DYNAMIC Mon Feb 6 09:42:58 CET 2023 x86_64 Intel(R) Core(TM) i7 CPU 960 @ 3.20GHz GenuineIntel GNU/Linux

Please let me know if the patch makes it into mainline for the 6.2 release ;).

Best
Zeno

#8 lore raw

Hi

Am 06.02.23 um 09:54 schrieb Zeno Davatz:

Quoted 250 lines

Dear Dave

Quoted 242 lines · David Airlie
Quoted 231 lines · Zeno Davatz

Dear Dave

Quoted 209 lines · Dave Airlie
Quoted 207 lines · Zeno Davatz

Dear Dave

Quoted 187 lines · Dave Airlie
Quoted 185 lines · Zeno Davatz

Dear Dave

Thank you for your patch.

Quoted 179 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

---
  drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
  1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
  }
 
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.38.1

This patch fails for me.

I've based the patch on 6.2-rc7, please make sure to not have the previous revert committed, this is to replace that patch.

Can you guide me through the steps please?

I done:

1. cd /usr/src/linux
2. sudo git pull
3. then I applied your patch.

Quoted 7 lines
Quoted 1 line

Am I doing something wrong?

What is your top of tree commit? (git log)

have you got any commits on top?

git reset --hard origin/master should reset your tree to Linus top.

1. git log shows "d2d11f342b179f1894a901f143ec7c008caba43e"
2. No, no patches on top.
3. I am doing the following steps:
/usr/src/linux> sudo git reset --hard origin/master Passwort:
HEAD ist jetzt bei d2d11f342b17 Merge branch 'fixes' of
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
/usr/src/linux> sudo patch -p1 < /tmp/patch patching file drivers/video/fbdev/nvidia/nvidia.c Hunk #1 FAILED at 1197.

Quoted 9 lines

Hunk #2 FAILED at 1220.
Hunk #3 FAILED at 1278.
Hunk #4 FAILED at 1298.
Hunk #5 FAILED at 1318.
Hunk #6 FAILED at 1401.
Hunk #7 FAILED at 1415.
7 out of 7 hunks FAILED -- saving rejects to file
drivers/video/fbdev/nvidia/nvidia.c.rej

Quoted 4 lines

Are you pulling the patch from email? I guess your email service or something is mangling it.

I've attached it to see if that helps.

Quoted 8 lines

Thank you! This patch works and I am booting perfectly well now!

~/.backup> uname -a
Linux zenogentoo 6.2.0-rc7-00002-gd2d11f342b17-dirty #144 SMP PREEMPT_DYNAMIC Mon Feb 6 09:42:58 CET 2023 x86_64 Intel(R) Core(TM) i7 CPU 960 @ 3.20GHz GenuineIntel GNU/Linux

Please let me know if the patch makes it into mainline for the 6.2 release ;).

Queued up in drm-misc-fixes. The patch should be in 6.1 and 6.2 soon.

Best regards
Thomas

Quoted 3 lines

Best
Zeno

Signature · 6 lines
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
Tested-by Reviewed-by on v1 1/1
#9 lore raw
In reply to Dave Airlie

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:

Quoted 9 lines

From: Dave Airlie <[email protected]>

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.

Fixes 145eed48de27 ("fbdev: Remove conflicting devices on PCI bus")
Quoted 169 lines
---
  drivers/video/fbdev/nvidia/nvidia.c | 81 +++++++++++++++--------------
  1 file changed, 42 insertions(+), 39 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +42 -39
index 1960916098d4..e60a276b4855 100644
@@ -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;
  }
 
Signature · 6 lines
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