drm/nouveau/pci: merge agp handling from nouveau drm
authorBen Skeggs <bskeggs@redhat.com>
Thu, 20 Aug 2015 04:54:23 +0000 (14:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:40:49 +0000 (12:40 +1000)
This commit reinstates the pre-DEVINIT AGP fiddling that was broken in
an earlier commit.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
18 files changed:
drivers/gpu/drm/nouveau/Kbuild
drivers/gpu/drm/nouveau/include/nvif/device.h
drivers/gpu/drm/nouveau/include/nvif/os.h
drivers/gpu/drm/nouveau/include/nvkm/core/option.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h
drivers/gpu/drm/nouveau/nouveau_abi16.c
drivers/gpu/drm/nouveau/nouveau_agp.c [deleted file]
drivers/gpu/drm/nouveau/nouveau_agp.h [deleted file]
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_drm.h
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/nouveau/nvkm/core/option.c
drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/pci/base.c

index 2b76566..a34b437 100644 (file)
@@ -18,7 +18,6 @@ nouveau-y += $(nvkm-y)
 ifdef CONFIG_X86
 nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
 endif
-nouveau-y += nouveau_agp.o
 nouveau-$(CONFIG_DEBUG_FS) += nouveau_debugfs.o
 nouveau-y += nouveau_drm.o
 nouveau-y += nouveau_hwmon.o
index 900e492..700a9b2 100644 (file)
@@ -45,6 +45,7 @@ u64  nvif_device_time(struct nvif_device *);
 #include <subdev/i2c.h>
 #include <subdev/timer.h>
 #include <subdev/therm.h>
+#include <subdev/pci.h>
 
 #define nvxx_device(a) ({                                                      \
        struct nvif_device *_device = (a);                                     \
index 54492cb..97317f7 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/power_supply.h>
 #include <linux/clk.h>
 #include <linux/regulator/consumer.h>
+#include <linux/agp_backend.h>
 
 #include <asm/unaligned.h>
 
index 532bfa8..80fdc14 100644 (file)
@@ -4,6 +4,7 @@
 
 const char *nvkm_stropt(const char *optstr, const char *opt, int *len);
 bool nvkm_boolopt(const char *optstr, const char *opt, bool value);
+long nvkm_longopt(const char *optstr, const char *opt, long value);
 int  nvkm_dbgopt(const char *optstr, const char *sub);
 
 /* compares unterminated string 'str' with zero-terminated string 'cmp' */
index ac14fdf..5b3c054 100644 (file)
@@ -7,6 +7,17 @@ struct nvkm_pci {
        struct nvkm_subdev subdev;
        struct pci_dev *pdev;
        int irq;
+
+       struct {
+               struct agp_bridge_data *bridge;
+               u32 mode;
+               u64 base;
+               u64 size;
+               int mtrr;
+               bool cma;
+               bool acquired;
+       } agp;
+
        bool msi;
 };
 
index 4252e77..d336c22 100644 (file)
@@ -498,7 +498,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
                args.start += chan->ntfy_vma.offset;
                args.limit += chan->ntfy_vma.offset;
        } else
-       if (drm->agp.stat == ENABLED) {
+       if (drm->agp.bridge) {
                args.target = NV_DMA_V0_TARGET_AGP;
                args.access = NV_DMA_V0_ACCESS_RDWR;
                args.start += drm->agp.base + chan->ntfy->bo.offset;
diff --git a/drivers/gpu/drm/nouveau/nouveau_agp.c b/drivers/gpu/drm/nouveau/nouveau_agp.c
deleted file mode 100644 (file)
index c3f3e49..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-#include <linux/module.h>
-
-#include "nouveau_drm.h"
-#include "nouveau_agp.h"
-#include "nouveau_reg.h"
-
-#include <core/pci.h>
-
-#if __OS_HAS_AGP
-MODULE_PARM_DESC(agpmode, "AGP mode (0 to disable AGP)");
-static int nouveau_agpmode = -1;
-module_param_named(agpmode, nouveau_agpmode, int, 0400);
-
-struct nouveau_agpmode_quirk {
-       u16 hostbridge_vendor;
-       u16 hostbridge_device;
-       u16 chip_vendor;
-       u16 chip_device;
-       int mode;
-};
-
-static struct nouveau_agpmode_quirk nouveau_agpmode_quirk_list[] = {
-       /* VIA Apollo PRO133x / GeForce FX 5600 Ultra, max agpmode 2, fdo #20341 */
-       { PCI_VENDOR_ID_VIA, 0x0691, PCI_VENDOR_ID_NVIDIA, 0x0311, 2 },
-
-       {},
-};
-
-static unsigned long
-get_agp_mode(struct nouveau_drm *drm, const struct drm_agp_info *info)
-{
-       struct nvif_device *device = &drm->device;
-       struct pci_dev *pdev = nvxx_device(device)->func->pci(nvxx_device(device))->pdev;
-       struct nouveau_agpmode_quirk *quirk = nouveau_agpmode_quirk_list;
-       int agpmode = nouveau_agpmode;
-       unsigned long mode = info->mode;
-
-       /*
-        * FW seems to be broken on nv18, it makes the card lock up
-        * randomly.
-        */
-       if (device->info.chipset == 0x18)
-               mode &= ~PCI_AGP_COMMAND_FW;
-
-       /*
-        * Go through the quirks list and adjust the agpmode accordingly.
-        */
-       while (agpmode == -1 && quirk->hostbridge_vendor) {
-               if (info->id_vendor == quirk->hostbridge_vendor &&
-                   info->id_device == quirk->hostbridge_device &&
-                   pdev->vendor == quirk->chip_vendor &&
-                   pdev->device == quirk->chip_device) {
-                       agpmode = quirk->mode;
-                       NV_INFO(drm, "Forcing agp mode to %dX. Use agpmode to override.\n",
-                               agpmode);
-                       break;
-               }
-               ++quirk;
-       }
-
-       /*
-        * AGP mode set in the command line.
-        */
-       if (agpmode > 0) {
-               bool agpv3 = mode & 0x8;
-               int rate = agpv3 ? agpmode / 4 : agpmode;
-
-               mode = (mode & ~0x7) | (rate & 0x7);
-       }
-
-       return mode;
-}
-
-static bool
-nouveau_agp_enabled(struct nouveau_drm *drm)
-{
-       struct drm_device *dev = drm->dev;
-
-       if (!dev->pdev || !drm_pci_device_is_agp(dev) || !dev->agp)
-               return false;
-
-       if (drm->agp.stat == UNKNOWN) {
-               if (!nouveau_agpmode)
-                       return false;
-#ifdef __powerpc__
-               /* Disable AGP by default on all PowerPC machines for
-                * now -- At least some UniNorth-2 AGP bridges are
-                * known to be broken: DMA from the host to the card
-                * works just fine, but writeback from the card to the
-                * host goes straight to memory untranslated bypassing
-                * the GATT somehow, making them quite painful to deal
-                * with...
-                */
-               if (nouveau_agpmode == -1)
-                       return false;
-#endif
-               return true;
-       }
-
-       return (drm->agp.stat == ENABLED);
-}
-#endif
-
-void
-nouveau_agp_reset(struct nouveau_drm *drm)
-{
-#if __OS_HAS_AGP
-       struct nvif_object *device = &drm->device.object;
-       struct drm_device *dev = drm->dev;
-       u32 save[2];
-       int ret;
-
-       if (!nouveau_agp_enabled(drm))
-               return;
-
-       /* First of all, disable fast writes, otherwise if it's
-        * already enabled in the AGP bridge and we disable the card's
-        * AGP controller we might be locking ourselves out of it. */
-       if ((nvif_rd32(device, NV04_PBUS_PCI_NV_19) |
-            dev->agp->mode) & PCI_AGP_COMMAND_FW) {
-               struct drm_agp_info info;
-               struct drm_agp_mode mode;
-
-               ret = drm_agp_info(dev, &info);
-               if (ret)
-                       return;
-
-               mode.mode  = get_agp_mode(drm, &info);
-               mode.mode &= ~PCI_AGP_COMMAND_FW;
-
-               ret = drm_agp_enable(dev, mode);
-               if (ret)
-                       return;
-       }
-
-
-       /* clear busmaster bit, and disable AGP */
-       save[0] = nvif_mask(device, NV04_PBUS_PCI_NV_1, 0x00000004, 0x00000000);
-       nvif_wr32(device, NV04_PBUS_PCI_NV_19, 0);
-
-       /* reset PGRAPH, PFIFO and PTIMER */
-       save[1] = nvif_mask(device, 0x000200, 0x00011100, 0x00000000);
-       nvif_mask(device, 0x000200, 0x00011100, save[1]);
-
-       /* and restore bustmaster bit (gives effect of resetting AGP) */
-       nvif_wr32(device, NV04_PBUS_PCI_NV_1, save[0]);
-#endif
-}
-
-void
-nouveau_agp_init(struct nouveau_drm *drm)
-{
-#if __OS_HAS_AGP
-       struct drm_device *dev = drm->dev;
-       struct drm_agp_info info;
-       struct drm_agp_mode mode;
-       int ret;
-
-       if (!nouveau_agp_enabled(drm))
-               return;
-       drm->agp.stat = DISABLE;
-
-       ret = drm_agp_acquire(dev);
-       if (ret) {
-               NV_ERROR(drm, "unable to acquire AGP: %d\n", ret);
-               return;
-       }
-
-       ret = drm_agp_info(dev, &info);
-       if (ret) {
-               NV_ERROR(drm, "unable to get AGP info: %d\n", ret);
-               return;
-       }
-
-       /* see agp.h for the AGPSTAT_* modes available */
-       mode.mode = get_agp_mode(drm, &info);
-
-       ret = drm_agp_enable(dev, mode);
-       if (ret) {
-               NV_ERROR(drm, "unable to enable AGP: %d\n", ret);
-               return;
-       }
-
-       drm->agp.stat = ENABLED;
-       drm->agp.base = info.aperture_base;
-       drm->agp.size = info.aperture_size;
-#endif
-}
-
-void
-nouveau_agp_fini(struct nouveau_drm *drm)
-{
-#if __OS_HAS_AGP
-       struct drm_device *dev = drm->dev;
-       if (dev->agp && dev->agp->acquired)
-               drm_agp_release(dev);
-#endif
-}
diff --git a/drivers/gpu/drm/nouveau/nouveau_agp.h b/drivers/gpu/drm/nouveau/nouveau_agp.h
deleted file mode 100644 (file)
index b55c086..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __NOUVEAU_AGP_H__
-#define __NOUVEAU_AGP_H__
-
-struct nouveau_drm;
-
-void nouveau_agp_reset(struct nouveau_drm *);
-void nouveau_agp_init(struct nouveau_drm *);
-void nouveau_agp_fini(struct nouveau_drm *);
-
-#endif
Simple merge
Simple merge
Simple merge
Simple merge