Skip to content

Commit

Permalink
Merge branch 'linux-5.2' of git://github.com/skeggsb/linux into drm-next
Browse files Browse the repository at this point in the history
No major changes ready for this round, but a few misc fixes instead.

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Ben Skeggs <skeggsb@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/CACAvsv7+Ch=r9pt+kPRP8obo_uLscL9Hrg3xq4s92StLvgy=Mw@mail.gmail.com
  • Loading branch information
Dave Airlie committed May 1, 2019
2 parents 7c13e5c + 30df16b commit 989eea6
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 17 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct nvkm_i2c_bus {
struct mutex mutex;
struct list_head head;
struct i2c_adapter i2c;
u8 enabled;
};

int nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *);
Expand All @@ -57,6 +58,7 @@ struct nvkm_i2c_aux {
struct mutex mutex;
struct list_head head;
struct i2c_adapter i2c;
u8 enabled;

u32 intr;
};
Expand Down
9 changes: 0 additions & 9 deletions drivers/gpu/drm/nouveau/nouveau_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,6 @@ nouveau_display_hpd_work(struct work_struct *work)

#ifdef CONFIG_ACPI

/*
* Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch
* to the acpi subsys to move it there from drivers/acpi/acpi_video.c .
* This should be dropped once that is merged.
*/
#ifndef ACPI_VIDEO_NOTIFY_PROBE
#define ACPI_VIDEO_NOTIFY_PROBE 0x81
#endif

static int
nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,
void *data)
Expand Down
12 changes: 11 additions & 1 deletion drivers/gpu/drm/nouveau/nouveau_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,15 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
static int
nouveau_do_resume(struct drm_device *dev, bool runtime)
{
int ret = 0;
struct nouveau_drm *drm = nouveau_drm(dev);

NV_DEBUG(drm, "resuming object tree...\n");
nvif_client_resume(&drm->master.base);
ret = nvif_client_resume(&drm->master.base);
if (ret) {
NV_ERROR(drm, "Client resume failed with error: %d\n", ret);
return ret;
}

NV_DEBUG(drm, "resuming fence...\n");
if (drm->fence && nouveau_fence(drm)->resume)
Expand Down Expand Up @@ -925,6 +930,7 @@ nouveau_pmops_runtime_resume(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev);
struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvif_device *device = &nouveau_drm(drm_dev)->client.device;
int ret;

Expand All @@ -941,6 +947,10 @@ nouveau_pmops_runtime_resume(struct device *dev)
pci_set_master(pdev);

ret = nouveau_do_resume(drm_dev, true);
if (ret) {
NV_ERROR(drm, "resume failed with: %d\n", ret);
return ret;
}

/* do magic */
nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ gf100_bar_oneinit_bar(struct gf100_bar *bar, struct gf100_barN *bar_vm,
return ret;

bar_len = device->func->resource_size(device, bar_nr);
if (!bar_len)
return -ENOMEM;
if (bar_nr == 3 && bar->bar2_halve)
bar_len >>= 1;

Expand Down
14 changes: 11 additions & 3 deletions drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ nv50_bar_oneinit(struct nvkm_bar *base)
struct nvkm_device *device = bar->base.subdev.device;
static struct lock_class_key bar1_lock;
static struct lock_class_key bar2_lock;
u64 start, limit;
u64 start, limit, size;
int ret;

ret = nvkm_gpuobj_new(device, 0x20000, 0, false, NULL, &bar->mem);
Expand All @@ -127,7 +127,10 @@ nv50_bar_oneinit(struct nvkm_bar *base)

/* BAR2 */
start = 0x0100000000ULL;
limit = start + device->func->resource_size(device, 3);
size = device->func->resource_size(device, 3);
if (!size)
return -ENOMEM;
limit = start + size;

ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
&bar2_lock, "bar2", &bar->bar2_vmm);
Expand Down Expand Up @@ -164,10 +167,15 @@ nv50_bar_oneinit(struct nvkm_bar *base)

/* BAR1 */
start = 0x0000000000ULL;
limit = start + device->func->resource_size(device, 1);
size = device->func->resource_size(device, 1);
if (!size)
return -ENOMEM;
limit = start + size;

ret = nvkm_vmm_new(device, start, limit-- - start, NULL, 0,
&bar1_lock, "bar1", &bar->bar1_vmm);
if (ret)
return ret;

atomic_inc(&bar->bar1_vmm->engref[NVKM_SUBDEV_BAR]);
bar->bar1_vmm->debug = bar->base.subdev.debug;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgk104.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ gk104_ram_calc_xits(struct gk104_ram *ram, struct nvkm_ram_data *next)
nvkm_error(subdev, "unable to calc plls\n");
return -EINVAL;
}
nvkm_debug(subdev, "sucessfully calced PLLs for clock %i kHz"
nvkm_debug(subdev, "successfully calced PLLs for clock %i kHz"
" (refclock: %i kHz)\n", next->freq, ret);
} else {
/* calculate refpll coefficients */
Expand Down
26 changes: 25 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ nvkm_i2c_aux_acquire(struct nvkm_i2c_aux *aux)
{
struct nvkm_i2c_pad *pad = aux->pad;
int ret;

AUX_TRACE(aux, "acquire");
mutex_lock(&aux->mutex);
ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_AUX);

if (aux->enabled)
ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_AUX);
else
ret = -EIO;

if (ret)
mutex_unlock(&aux->mutex);
return ret;
Expand Down Expand Up @@ -145,6 +151,24 @@ nvkm_i2c_aux_del(struct nvkm_i2c_aux **paux)
}
}

void
nvkm_i2c_aux_init(struct nvkm_i2c_aux *aux)
{
AUX_TRACE(aux, "init");
mutex_lock(&aux->mutex);
aux->enabled = true;
mutex_unlock(&aux->mutex);
}

void
nvkm_i2c_aux_fini(struct nvkm_i2c_aux *aux)
{
AUX_TRACE(aux, "fini");
mutex_lock(&aux->mutex);
aux->enabled = false;
mutex_unlock(&aux->mutex);
}

int
nvkm_i2c_aux_ctor(const struct nvkm_i2c_aux_func *func,
struct nvkm_i2c_pad *pad, int id,
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int nvkm_i2c_aux_ctor(const struct nvkm_i2c_aux_func *, struct nvkm_i2c_pad *,
int nvkm_i2c_aux_new_(const struct nvkm_i2c_aux_func *, struct nvkm_i2c_pad *,
int id, struct nvkm_i2c_aux **);
void nvkm_i2c_aux_del(struct nvkm_i2c_aux **);
void nvkm_i2c_aux_init(struct nvkm_i2c_aux *);
void nvkm_i2c_aux_fini(struct nvkm_i2c_aux *);
int nvkm_i2c_aux_xfer(struct nvkm_i2c_aux *, bool retry, u8 type,
u32 addr, u8 *data, u8 *size);

Expand Down
15 changes: 15 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,18 @@ nvkm_i2c_fini(struct nvkm_subdev *subdev, bool suspend)
{
struct nvkm_i2c *i2c = nvkm_i2c(subdev);
struct nvkm_i2c_pad *pad;
struct nvkm_i2c_bus *bus;
struct nvkm_i2c_aux *aux;
u32 mask;

list_for_each_entry(aux, &i2c->aux, head) {
nvkm_i2c_aux_fini(aux);
}

list_for_each_entry(bus, &i2c->bus, head) {
nvkm_i2c_bus_fini(bus);
}

if ((mask = (1 << i2c->func->aux) - 1), i2c->func->aux_stat) {
i2c->func->aux_mask(i2c, NVKM_I2C_ANY, mask, 0);
i2c->func->aux_stat(i2c, &mask, &mask, &mask, &mask);
Expand All @@ -180,6 +190,7 @@ nvkm_i2c_init(struct nvkm_subdev *subdev)
struct nvkm_i2c *i2c = nvkm_i2c(subdev);
struct nvkm_i2c_bus *bus;
struct nvkm_i2c_pad *pad;
struct nvkm_i2c_aux *aux;

list_for_each_entry(pad, &i2c->pad, head) {
nvkm_i2c_pad_init(pad);
Expand All @@ -189,6 +200,10 @@ nvkm_i2c_init(struct nvkm_subdev *subdev)
nvkm_i2c_bus_init(bus);
}

list_for_each_entry(aux, &i2c->aux, head) {
nvkm_i2c_aux_init(aux);
}

return 0;
}

Expand Down
21 changes: 20 additions & 1 deletion drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ nvkm_i2c_bus_init(struct nvkm_i2c_bus *bus)
BUS_TRACE(bus, "init");
if (bus->func->init)
bus->func->init(bus);

mutex_lock(&bus->mutex);
bus->enabled = true;
mutex_unlock(&bus->mutex);
}

void
nvkm_i2c_bus_fini(struct nvkm_i2c_bus *bus)
{
BUS_TRACE(bus, "fini");
mutex_lock(&bus->mutex);
bus->enabled = false;
mutex_unlock(&bus->mutex);
}

void
Expand All @@ -126,9 +139,15 @@ nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *bus)
{
struct nvkm_i2c_pad *pad = bus->pad;
int ret;

BUS_TRACE(bus, "acquire");
mutex_lock(&bus->mutex);
ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_I2C);

if (bus->enabled)
ret = nvkm_i2c_pad_acquire(pad, NVKM_I2C_PAD_I2C);
else
ret = -EIO;

if (ret)
mutex_unlock(&bus->mutex);
return ret;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int nvkm_i2c_bus_new_(const struct nvkm_i2c_bus_func *, struct nvkm_i2c_pad *,
int id, struct nvkm_i2c_bus **);
void nvkm_i2c_bus_del(struct nvkm_i2c_bus **);
void nvkm_i2c_bus_init(struct nvkm_i2c_bus *);
void nvkm_i2c_bus_fini(struct nvkm_i2c_bus *);

int nvkm_i2c_bit_xfer(struct nvkm_i2c_bus *, struct i2c_msg *, int);

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ nvkm_vmm_get(struct nvkm_vmm *vmm, u8 page, u64 size, struct nvkm_vma **pvma)
void
nvkm_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst)
{
if (inst && vmm->func->part) {
if (inst && vmm && vmm->func->part) {
mutex_lock(&vmm->mutex);
vmm->func->part(vmm, inst);
mutex_unlock(&vmm->mutex);
Expand Down

0 comments on commit 989eea6

Please sign in to comment.