2009-12-11 09:24:15 +00:00
|
|
|
/*
|
2012-07-11 05:58:56 +00:00
|
|
|
* Copyright 2012 Red Hat Inc.
|
2009-12-11 09:24:15 +00:00
|
|
|
*
|
2012-07-11 05:58:56 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2009-12-11 09:24:15 +00:00
|
|
|
*
|
2012-07-11 05:58:56 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
2009-12-11 09:24:15 +00:00
|
|
|
*
|
2012-07-11 05:58:56 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
2009-12-11 09:24:15 +00:00
|
|
|
*
|
2012-07-11 05:58:56 +00:00
|
|
|
* Authors: Ben Skeggs
|
2009-12-11 09:24:15 +00:00
|
|
|
*/
|
2015-08-20 04:54:21 +00:00
|
|
|
#include "priv.h"
|
2012-07-11 05:58:56 +00:00
|
|
|
|
2015-01-14 05:08:21 +00:00
|
|
|
const struct nvkm_mc_intr
|
2012-07-11 05:58:56 +00:00
|
|
|
nv50_mc_intr[] = {
|
drm/nv50-/mc: fix kms pageflip events by reordering irq handling order.
Whenever a single nouveau_mc_intr() main gpu irq-handler invocation was
responsible for calling both, the vblank-irq handler (display engine irq)
and kms-pageflip completion handler (from fifo irq), the order of
invocation was wrong. nouveau_finish_flip() was called before
drm_handle_vblank() for the vblank of pageflip completion, so the
emitted pageflip event contained stale vblank count and timestamp
from previous vblank. This caused failure in userspace to timestamp
properly.
Reorder order of invocation of engine irq handlers: Put
NVDEV_ENGINE_DISP always on top, and thereby before NVDEV_ENGINE_FIFO,
so that drm_handle_vblank() gets called to update vblank timestamps
and count before potential pageflip events make use of that
information.
This works on nv-50 and later, where kms-pageflip completion triggers
an irq either after a separate vblank irq, or both pageflip and vblank
trigger one common irq invocation, but never before vblank irqs.
v2 (Ben):
- removed mods for nv04-nv40, it doesn't help there anyway
- this is considered a hack, and a better solution should be found
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Cc: <stable@vger.kernel.org> # 3.13+
2014-03-19 07:12:51 +00:00
|
|
|
{ 0x04000000, NVDEV_ENGINE_DISP }, /* DISP before FIFO, so pageflip-timestamping works! */
|
2012-07-11 05:58:56 +00:00
|
|
|
{ 0x00000001, NVDEV_ENGINE_MPEG },
|
|
|
|
{ 0x00000100, NVDEV_ENGINE_FIFO },
|
|
|
|
{ 0x00001000, NVDEV_ENGINE_GR },
|
2015-01-14 00:46:55 +00:00
|
|
|
{ 0x00004000, NVDEV_ENGINE_CIPHER }, /* NV84- */
|
2012-07-11 05:58:56 +00:00
|
|
|
{ 0x00008000, NVDEV_ENGINE_BSP }, /* NV84- */
|
2013-06-27 04:12:46 +00:00
|
|
|
{ 0x00020000, NVDEV_ENGINE_VP }, /* NV84- */
|
2012-07-11 05:58:56 +00:00
|
|
|
{ 0x00100000, NVDEV_SUBDEV_TIMER },
|
2014-05-13 04:36:49 +00:00
|
|
|
{ 0x00200000, NVDEV_SUBDEV_GPIO }, /* PMGR->GPIO */
|
|
|
|
{ 0x00200000, NVDEV_SUBDEV_I2C }, /* PMGR->I2C/AUX */
|
2012-11-04 00:01:53 +00:00
|
|
|
{ 0x10000000, NVDEV_SUBDEV_BUS },
|
2012-07-11 05:58:56 +00:00
|
|
|
{ 0x80000000, NVDEV_ENGINE_SW },
|
2013-07-27 04:26:59 +00:00
|
|
|
{ 0x0002d101, NVDEV_SUBDEV_FB },
|
2012-07-11 05:58:56 +00:00
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
2013-10-14 04:58:16 +00:00
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_mc_msi_rearm(struct nvkm_mc *mc)
|
2013-10-14 04:58:16 +00:00
|
|
|
{
|
2015-08-20 04:54:09 +00:00
|
|
|
struct nvkm_device *device = mc->subdev.device;
|
2013-10-14 04:58:16 +00:00
|
|
|
pci_write_config_byte(device->pdev, 0x68, 0xff);
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:21 +00:00
|
|
|
void
|
|
|
|
nv50_mc_init(struct nvkm_mc *mc)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:09 +00:00
|
|
|
struct nvkm_device *device = mc->subdev.device;
|
|
|
|
nvkm_wr32(device, 0x000200, 0xffffffff); /* everything on */
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
2012-07-11 05:58:56 +00:00
|
|
|
|
2015-08-20 04:54:21 +00:00
|
|
|
static const struct nvkm_mc_func
|
|
|
|
nv50_mc = {
|
|
|
|
.init = nv50_mc_init,
|
2013-10-11 05:34:08 +00:00
|
|
|
.intr = nv50_mc_intr,
|
2013-10-14 04:58:16 +00:00
|
|
|
.msi_rearm = nv50_mc_msi_rearm,
|
2015-08-20 04:54:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
nv50_mc_new(struct nvkm_device *device, int index, struct nvkm_mc **pmc)
|
|
|
|
{
|
|
|
|
return nvkm_mc_new_(&nv50_mc, device, index, pmc);
|
|
|
|
}
|