Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fa9061a authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/mc: handle irq-related setup ourselves



We need to be able to process interrupts before the DRM code is able to
actually enable them, set it up ourselves.  Also, it's less convoluted
to *not* use the DRM wrappers it appears...

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 1a646342
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -213,7 +213,7 @@ nouveau-y += core/engine/vp/nve0.o


# drm/core
# drm/core
nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o
nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o
nouveau-y += nouveau_irq.o nouveau_vga.o nouveau_agp.o
nouveau-y += nouveau_vga.o nouveau_agp.o
nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o
nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o
nouveau-y += nouveau_prime.o nouveau_abi16.o
nouveau-y += nouveau_prime.o nouveau_abi16.o
nouveau-y += nv04_fence.o nv10_fence.o nv17_fence.o
nouveau-y += nv04_fence.o nv10_fence.o nv17_fence.o
+16 −14
Original line number Original line Diff line number Diff line
@@ -21,18 +21,22 @@ nouveau_mc(void *obj)
}
}


#define nouveau_mc_create(p,e,o,d)                                             \
#define nouveau_mc_create(p,e,o,d)                                             \
	nouveau_subdev_create_((p), (e), (o), 0, "PMC", "master",              \
	nouveau_mc_create_((p), (e), (o), sizeof(**d), (void **)d)
			       sizeof(**d), (void **)d)
#define nouveau_mc_destroy(p) ({                                               \
#define nouveau_mc_destroy(p)                                                  \
	struct nouveau_mc *pmc = (p); _nouveau_mc_dtor(nv_object(pmc));        \
	nouveau_subdev_destroy(&(p)->base)
})
#define nouveau_mc_init(p)                                                     \
#define nouveau_mc_init(p) ({                                                  \
	nouveau_subdev_init(&(p)->base)
	struct nouveau_mc *pmc = (p); _nouveau_mc_init(nv_object(pmc));        \
#define nouveau_mc_fini(p,s)                                                   \
})
	nouveau_subdev_fini(&(p)->base, (s))
#define nouveau_mc_fini(p,s) ({                                                \

	struct nouveau_mc *pmc = (p); _nouveau_mc_fini(nv_object(pmc), (s));   \
#define _nouveau_mc_dtor _nouveau_subdev_dtor
})
#define _nouveau_mc_init _nouveau_subdev_init

#define _nouveau_mc_fini _nouveau_subdev_fini
int  nouveau_mc_create_(struct nouveau_object *, struct nouveau_object *,
			struct nouveau_oclass *, int, void **);
void _nouveau_mc_dtor(struct nouveau_object *);
int  _nouveau_mc_init(struct nouveau_object *);
int  _nouveau_mc_fini(struct nouveau_object *, bool);


extern struct nouveau_oclass nv04_mc_oclass;
extern struct nouveau_oclass nv04_mc_oclass;
extern struct nouveau_oclass nv44_mc_oclass;
extern struct nouveau_oclass nv44_mc_oclass;
@@ -40,8 +44,6 @@ extern struct nouveau_oclass nv50_mc_oclass;
extern struct nouveau_oclass nv98_mc_oclass;
extern struct nouveau_oclass nv98_mc_oclass;
extern struct nouveau_oclass nvc0_mc_oclass;
extern struct nouveau_oclass nvc0_mc_oclass;


void nouveau_mc_intr(struct nouveau_subdev *);

extern const struct nouveau_mc_intr nv04_mc_intr[];
extern const struct nouveau_mc_intr nv04_mc_intr[];
int nv04_mc_init(struct nouveau_object *);
int nv04_mc_init(struct nouveau_object *);
int nv50_mc_init(struct nouveau_object *);
int nv50_mc_init(struct nouveau_object *);
+1 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/acpi.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/dmi.h>
#include <linux/reboot.h>
#include <linux/reboot.h>
#include <linux/interrupt.h>


#include <asm/unaligned.h>
#include <asm/unaligned.h>


+56 −4
Original line number Original line Diff line number Diff line
@@ -24,10 +24,10 @@


#include <subdev/mc.h>
#include <subdev/mc.h>


void
static irqreturn_t
nouveau_mc_intr(struct nouveau_subdev *subdev)
nouveau_mc_intr(int irq, void *arg)
{
{
	struct nouveau_mc *pmc = nouveau_mc(subdev);
	struct nouveau_mc *pmc = arg;
	const struct nouveau_mc_intr *map = pmc->intr_map;
	const struct nouveau_mc_intr *map = pmc->intr_map;
	struct nouveau_subdev *unit;
	struct nouveau_subdev *unit;
	u32 stat, intr;
	u32 stat, intr;
@@ -35,7 +35,7 @@ nouveau_mc_intr(struct nouveau_subdev *subdev)
	intr = stat = nv_rd32(pmc, 0x000100);
	intr = stat = nv_rd32(pmc, 0x000100);
	while (stat && map->stat) {
	while (stat && map->stat) {
		if (stat & map->stat) {
		if (stat & map->stat) {
			unit = nouveau_subdev(subdev, map->unit);
			unit = nouveau_subdev(pmc, map->unit);
			if (unit && unit->intr)
			if (unit && unit->intr)
				unit->intr(unit);
				unit->intr(unit);
			intr &= ~map->stat;
			intr &= ~map->stat;
@@ -46,4 +46,56 @@ nouveau_mc_intr(struct nouveau_subdev *subdev)
	if (intr) {
	if (intr) {
		nv_error(pmc, "unknown intr 0x%08x\n", stat);
		nv_error(pmc, "unknown intr 0x%08x\n", stat);
	}
	}

	return stat ? IRQ_HANDLED : IRQ_NONE;
}

int
_nouveau_mc_fini(struct nouveau_object *object, bool suspend)
{
	struct nouveau_mc *pmc = (void *)object;
	nv_wr32(pmc, 0x000140, 0x00000000);
	return nouveau_subdev_fini(&pmc->base, suspend);
}

int
_nouveau_mc_init(struct nouveau_object *object)
{
	struct nouveau_mc *pmc = (void *)object;
	int ret = nouveau_subdev_init(&pmc->base);
	if (ret)
		return ret;
	nv_wr32(pmc, 0x000140, 0x00000001);
	return 0;
}

void
_nouveau_mc_dtor(struct nouveau_object *object)
{
	struct nouveau_device *device = nv_device(object);
	struct nouveau_mc *pmc = (void *)object;
	free_irq(device->pdev->irq, pmc);
	nouveau_subdev_destroy(&pmc->base);
}

int
nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,
		   struct nouveau_oclass *oclass, int length, void **pobject)
{
	struct nouveau_device *device = nv_device(parent);
	struct nouveau_mc *pmc;
	int ret;

	ret = nouveau_subdev_create_(parent, engine, oclass, 0, "PMC",
				     "master", length, pobject);
	pmc = *pobject;
	if (ret)
		return ret;

	ret = request_irq(device->pdev->irq, nouveau_mc_intr,
			  IRQF_SHARED, "nouveau", pmc);
	if (ret < 0)
		return ret;

	return 0;
}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -55,7 +55,6 @@ nv04_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
	if (ret)
	if (ret)
		return ret;
		return ret;


	nv_subdev(priv)->intr = nouveau_mc_intr;
	priv->base.intr_map = nv04_mc_intr;
	priv->base.intr_map = nv04_mc_intr;
	return 0;
	return 0;
}
}
Loading