drm/nouveau: move nvxx_* definitions to nouveau_drv.h

These are some dodgy "convenience" macros for the DRM driver to peek
into NVKM state.  They're still used in a few places, but don't belong
in nvif/device.h in any case.

Move them to nouveau_drv.h, and modify callers to pass a nouveau_drm
instead of an nvif_device.

v2:
- use drm->nvkm pointer for nvxx_*() macros, removing some void*
v3:
- add some explanation of the nvxx_*() macros

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240726043828.58966-28-bskeggs@nvidia.com
This commit is contained in:
Ben Skeggs 2024-07-26 14:38:18 +10:00 committed by Danilo Krummrich
parent 8d7b2d3a7e
commit 6901f1d647
20 changed files with 92 additions and 90 deletions

View File

@ -118,8 +118,8 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_bios *bios = nvxx_bios(&drm->client.device); struct nvkm_bios *bios = nvxx_bios(drm);
struct nvkm_clk *clk = nvxx_clk(&drm->client.device); struct nvkm_clk *clk = nvxx_clk(drm);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; struct nv04_mode_state *state = &nv04_display(dev)->mode_reg;
struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index];

View File

@ -237,7 +237,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &nouveau_drm(dev)->client.device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device); struct nvkm_gpio *gpio = nvxx_gpio(drm);
struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder); uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput, uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput,

View File

@ -626,7 +626,7 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder)
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI);
struct nvkm_i2c_bus_probe info[] = { struct nvkm_i2c_bus_probe info[] = {
{ {

View File

@ -211,7 +211,7 @@ int
nv04_display_create(struct drm_device *dev) nv04_display_create(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct dcb_table *dcb = &drm->vbios.dcb; struct dcb_table *dcb = &drm->vbios.dcb;
struct drm_connector *connector, *ct; struct drm_connector *connector, *ct;
struct drm_encoder *encoder; struct drm_encoder *encoder;

View File

@ -176,7 +176,7 @@ static inline void
nouveau_bios_run_init_table(struct drm_device *dev, u16 table, nouveau_bios_run_init_table(struct drm_device *dev, u16 table,
struct dcb_output *outp, int crtc) struct dcb_output *outp, int crtc)
{ {
nvbios_init(&nvxx_bios(&nouveau_drm(dev)->client.device)->subdev, table, nvbios_init(&nvxx_bios(nouveau_drm(dev))->subdev, table,
init.outp = outp; init.outp = outp;
init.head = crtc; init.head = crtc;
); );

View File

@ -166,7 +166,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->client.device.object; struct nvif_object *device = &drm->client.device.object;
struct nvkm_bios *bios = nvxx_bios(&drm->client.device); struct nvkm_bios *bios = nvxx_bios(drm);
uint32_t reg1, pll1, pll2 = 0; uint32_t reg1, pll1, pll2 = 0;
struct nvbios_pll pll_lim; struct nvbios_pll pll_lim;
int ret; int ret;
@ -258,9 +258,8 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
*/ */
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->client.device; struct nvkm_clk *clk = nvxx_clk(drm);
struct nvkm_clk *clk = nvxx_clk(device); struct nvkm_bios *bios = nvxx_bios(drm);
struct nvkm_bios *bios = nvxx_bios(device);
struct nvbios_pll pll_lim; struct nvbios_pll pll_lim;
struct nvkm_pll_vals pv; struct nvkm_pll_vals pv;
enum nvbios_pll_type pll = head ? PLL_VPLL1 : PLL_VPLL0; enum nvbios_pll_type pll = head ? PLL_VPLL1 : PLL_VPLL0;
@ -470,7 +469,7 @@ nv_load_state_ramdac(struct drm_device *dev, int head,
struct nv04_mode_state *state) struct nv04_mode_state *state)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_clk *clk = nvxx_clk(&drm->client.device); struct nvkm_clk *clk = nvxx_clk(drm);
struct nv04_crtc_reg *regp = &state->crtc_reg[head]; struct nv04_crtc_reg *regp = &state->crtc_reg[head];
uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF; uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF;
int i; int i;

View File

@ -53,7 +53,7 @@ static struct nvkm_i2c_bus_probe nv04_tv_encoder_info[] = {
int nv04_tv_identify(struct drm_device *dev, int i2c_index) int nv04_tv_identify(struct drm_device *dev, int i2c_index)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, i2c_index);
if (bus) { if (bus) {
return nvkm_i2c_bus_probe(bus, "TV encoder", return nvkm_i2c_bus_probe(bus, "TV encoder",
@ -205,7 +205,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry)
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, entry->i2c_index); struct nvkm_i2c_bus *bus = nvkm_i2c_bus_find(i2c, entry->i2c_index);
int type, ret; int type, ret;

View File

@ -47,7 +47,7 @@ static uint32_t nv42_tv_sample_load(struct drm_encoder *encoder)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device); struct nvkm_gpio *gpio = nvxx_gpio(drm);
uint32_t testval, regoffset = nv04_dac_output_offset(encoder); uint32_t testval, regoffset = nv04_dac_output_offset(encoder);
uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end, uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end,
fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c; fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c;
@ -131,7 +131,7 @@ static bool
get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask) get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(drm);
if (device->quirk && device->quirk->tv_pin_mask) { if (device->quirk && device->quirk->tv_pin_mask) {
*pin_mask = device->quirk->tv_pin_mask; *pin_mask = device->quirk->tv_pin_mask;
@ -363,7 +363,7 @@ static void nv17_tv_dpms(struct drm_encoder *encoder, int mode)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device); struct nvkm_gpio *gpio = nvxx_gpio(drm);
struct nv17_tv_state *regs = &to_tv_enc(encoder)->state; struct nv17_tv_state *regs = &to_tv_enc(encoder)->state;
struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);

View File

@ -561,7 +561,7 @@ nv50_dac_create(struct nouveau_encoder *nv_encoder)
{ {
struct drm_connector *connector = &nv_encoder->conn->base; struct drm_connector *connector = &nv_encoder->conn->base;
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct nvkm_i2c_bus *bus; struct nvkm_i2c_bus *bus;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct dcb_output *dcbe = nv_encoder->dcb; struct dcb_output *dcbe = nv_encoder->dcb;
@ -1884,7 +1884,7 @@ nv50_sor_create(struct nouveau_encoder *nv_encoder)
struct drm_connector *connector = &nv_encoder->conn->base; struct drm_connector *connector = &nv_encoder->conn->base;
struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_connector *nv_connector = nouveau_connector(connector);
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct dcb_output *dcbe = nv_encoder->dcb; struct dcb_output *dcbe = nv_encoder->dcb;
struct nv50_disp *disp = nv50_disp(connector->dev); struct nv50_disp *disp = nv50_disp(connector->dev);
@ -2051,7 +2051,7 @@ nv50_pior_create(struct nouveau_encoder *nv_encoder)
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nv50_disp *disp = nv50_disp(dev); struct nv50_disp *disp = nv50_disp(dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device); struct nvkm_i2c *i2c = nvxx_i2c(drm);
struct nvkm_i2c_bus *bus = NULL; struct nvkm_i2c_bus *bus = NULL;
struct nvkm_i2c_aux *aux = NULL; struct nvkm_i2c_aux *aux = NULL;
struct i2c_adapter *ddc; struct i2c_adapter *ddc;

View File

@ -22,37 +22,4 @@ int nvif_device_ctor(struct nvif_client *, const char *name, struct nvif_device
void nvif_device_dtor(struct nvif_device *); void nvif_device_dtor(struct nvif_device *);
int nvif_device_map(struct nvif_device *); int nvif_device_map(struct nvif_device *);
u64 nvif_device_time(struct nvif_device *); u64 nvif_device_time(struct nvif_device *);
/*XXX*/
#include <subdev/bios.h>
#include <subdev/fb.h>
#include <subdev/bar.h>
#include <subdev/gpio.h>
#include <subdev/clk.h>
#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); \
struct { \
struct nvkm_object object; \
struct nvkm_device *device; \
} *_udevice = _device->object.priv; \
_udevice->device; \
})
#define nvxx_bios(a) nvxx_device(a)->bios
#define nvxx_fb(a) nvxx_device(a)->fb
#define nvxx_gpio(a) nvxx_device(a)->gpio
#define nvxx_clk(a) nvxx_device(a)->clk
#define nvxx_i2c(a) nvxx_device(a)->i2c
#define nvxx_iccsense(a) nvxx_device(a)->iccsense
#define nvxx_therm(a) nvxx_device(a)->therm
#define nvxx_volt(a) nvxx_device(a)->volt
#include <engine/fifo.h>
#include <engine/gr.h>
#define nvxx_gr(a) nvxx_device(a)->gr
#endif #endif

View File

@ -249,8 +249,8 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_cli *cli = nouveau_cli(file_priv);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->client.device; struct nvif_device *device = &drm->client.device;
struct nvkm_device *nvkm_device = nvxx_device(&drm->client.device); struct nvkm_device *nvkm_device = nvxx_device(drm);
struct nvkm_gr *gr = nvxx_gr(device); struct nvkm_gr *gr = nvxx_gr(drm);
struct drm_nouveau_getparam *getparam = data; struct drm_nouveau_getparam *getparam = data;
struct pci_dev *pdev = to_pci_dev(dev->dev); struct pci_dev *pdev = to_pci_dev(dev->dev);

View File

@ -2020,7 +2020,7 @@ uint8_t *nouveau_bios_embedded_edid(struct drm_device *dev)
static bool NVInitVBIOS(struct drm_device *dev) static bool NVInitVBIOS(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_bios *bios = nvxx_bios(&drm->client.device); struct nvkm_bios *bios = nvxx_bios(drm);
struct nvbios *legacy = &drm->vbios; struct nvbios *legacy = &drm->vbios;
memset(legacy, 0, sizeof(struct nvbios)); memset(legacy, 0, sizeof(struct nvbios));
@ -2091,7 +2091,7 @@ nouveau_bios_init(struct drm_device *dev)
/* only relevant for PCI devices */ /* only relevant for PCI devices */
if (!dev_is_pci(dev->dev) || if (!dev_is_pci(dev->dev) ||
nvkm_gsp_rm(nvxx_device(&drm->client.device)->gsp)) nvkm_gsp_rm(nvxx_device(drm)->gsp))
return 0; return 0;
if (!NVInitVBIOS(dev)) if (!NVInitVBIOS(dev))

View File

@ -48,6 +48,7 @@ struct bit_entry {
int bit_table(struct drm_device *, u8 id, struct bit_entry *); int bit_table(struct drm_device *, u8 id, struct bit_entry *);
#include <subdev/bios.h>
#include <subdev/bios/dcb.h> #include <subdev/bios/dcb.h>
#include <subdev/bios/conn.h> #include <subdev/bios/conn.h>

View File

@ -58,7 +58,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg,
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
int i = reg - drm->tile.reg; int i = reg - drm->tile.reg;
struct nvkm_fb *fb = nvxx_fb(&drm->client.device); struct nvkm_fb *fb = nvxx_fb(drm);
struct nvkm_fb_tile *tile = &fb->tile.region[i]; struct nvkm_fb_tile *tile = &fb->tile.region[i];
nouveau_fence_unref(&reg->fence); nouveau_fence_unref(&reg->fence);
@ -109,7 +109,7 @@ nv10_bo_set_tiling(struct drm_device *dev, u32 addr,
u32 size, u32 pitch, u32 zeta) u32 size, u32 pitch, u32 zeta)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_fb *fb = nvxx_fb(&drm->client.device); struct nvkm_fb *fb = nvxx_fb(drm);
struct nouveau_drm_tile *tile, *found = NULL; struct nouveau_drm_tile *tile, *found = NULL;
int i; int i;
@ -1171,7 +1171,7 @@ static int
nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg) nouveau_ttm_io_mem_reserve(struct ttm_device *bdev, struct ttm_resource *reg)
{ {
struct nouveau_drm *drm = nouveau_bdev(bdev); struct nouveau_drm *drm = nouveau_bdev(bdev);
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(drm);
struct nouveau_mem *mem = nouveau_mem(reg); struct nouveau_mem *mem = nouveau_mem(reg);
struct nvif_mmu *mmu = &drm->client.mmu; struct nvif_mmu *mmu = &drm->client.mmu;
int ret; int ret;
@ -1291,7 +1291,7 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
{ {
struct nouveau_drm *drm = nouveau_bdev(bo->bdev); struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
struct nouveau_bo *nvbo = nouveau_bo(bo); struct nouveau_bo *nvbo = nouveau_bo(bo);
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(drm);
u32 mappable = device->func->resource_size(device, 1) >> PAGE_SHIFT; u32 mappable = device->func->resource_size(device, 1) >> PAGE_SHIFT;
int i, ret; int i, ret;

View File

@ -218,8 +218,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
*/ */
args.target = NV_DMA_V0_TARGET_PCI; args.target = NV_DMA_V0_TARGET_PCI;
args.access = NV_DMA_V0_ACCESS_RDWR; args.access = NV_DMA_V0_ACCESS_RDWR;
args.start = nvxx_device(device)->func-> args.start = nvxx_device(drm)->func->resource_addr(nvxx_device(drm), 1);
resource_addr(nvxx_device(device), 1);
args.limit = args.start + device->info.ram_user - 1; args.limit = args.start + device->info.ram_user - 1;
} else { } else {
args.target = NV_DMA_V0_TARGET_VRAM; args.target = NV_DMA_V0_TARGET_VRAM;

View File

@ -424,8 +424,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
* any GPU where it's possible we'll end up using M2MF for BO moves. * any GPU where it's possible we'll end up using M2MF for BO moves.
*/ */
if (device->info.family < NV_DEVICE_INFO_V0_FERMI) { if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
ret = nvkm_gpuobj_new(nvxx_device(device), 32, 0, false, NULL, ret = nvkm_gpuobj_new(nvxx_device(drm), 32, 0, false, NULL, &drm->notify);
&drm->notify);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to allocate notifier, %d\n", ret); NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
nouveau_accel_gr_fini(drm); nouveau_accel_gr_fini(drm);

View File

@ -360,4 +360,41 @@ void nouveau_drm_device_remove(struct nouveau_drm *);
extern int nouveau_modeset; extern int nouveau_modeset;
/*XXX: Don't use these in new code.
*
* These accessors are used in a few places (mostly older code paths)
* to get direct access to NVKM structures, where a more well-defined
* interface doesn't exist. Outside of the current use, these should
* not be relied on, and instead be implemented as NVIF.
*
* This is especially important when considering GSP-RM, as a lot the
* modules don't exist, or are "stub" implementations that just allow
* the GSP-RM paths to be bootstrapped.
*/
#include <subdev/bios.h>
#include <subdev/fb.h>
#include <subdev/gpio.h>
#include <subdev/clk.h>
#include <subdev/i2c.h>
#include <subdev/timer.h>
#include <subdev/therm.h>
static inline struct nvkm_device *
nvxx_device(struct nouveau_drm *drm)
{
return drm->nvkm;
}
#define nvxx_bios(a) nvxx_device(a)->bios
#define nvxx_fb(a) nvxx_device(a)->fb
#define nvxx_gpio(a) nvxx_device(a)->gpio
#define nvxx_clk(a) nvxx_device(a)->clk
#define nvxx_i2c(a) nvxx_device(a)->i2c
#define nvxx_iccsense(a) nvxx_device(a)->iccsense
#define nvxx_therm(a) nvxx_device(a)->therm
#define nvxx_volt(a) nvxx_device(a)->volt
#include <engine/gr.h>
#define nvxx_gr(a) nvxx_device(a)->gr
#endif #endif

View File

@ -52,7 +52,7 @@ nouveau_hwmon_temp1_auto_point1_temp(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
return sysfs_emit(buf, "%d\n", return sysfs_emit(buf, "%d\n",
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000); therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST) * 1000);
@ -64,7 +64,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
long value; long value;
if (kstrtol(buf, 10, &value)) if (kstrtol(buf, 10, &value))
@ -85,7 +85,7 @@ nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
return sysfs_emit(buf, "%d\n", return sysfs_emit(buf, "%d\n",
therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000); therm->attr_get(therm, NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
@ -97,7 +97,7 @@ nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
long value; long value;
if (kstrtol(buf, 10, &value)) if (kstrtol(buf, 10, &value))
@ -118,7 +118,7 @@ nouveau_hwmon_get_pwm1_max(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
int ret; int ret;
ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY); ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MAX_DUTY);
@ -134,7 +134,7 @@ nouveau_hwmon_get_pwm1_min(struct device *d,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
int ret; int ret;
ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY); ret = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MIN_DUTY);
@ -150,7 +150,7 @@ nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
long value; long value;
int ret; int ret;
@ -173,7 +173,7 @@ nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a,
{ {
struct drm_device *dev = dev_get_drvdata(d); struct drm_device *dev = dev_get_drvdata(d);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
long value; long value;
int ret; int ret;
@ -247,7 +247,7 @@ static umode_t
nouveau_power_is_visible(const void *data, u32 attr, int channel) nouveau_power_is_visible(const void *data, u32 attr, int channel)
{ {
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
if (!iccsense || !iccsense->data_valid || list_empty(&iccsense->rails)) if (!iccsense || !iccsense->data_valid || list_empty(&iccsense->rails))
return 0; return 0;
@ -272,7 +272,7 @@ static umode_t
nouveau_temp_is_visible(const void *data, u32 attr, int channel) nouveau_temp_is_visible(const void *data, u32 attr, int channel)
{ {
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_get || nvkm_therm_temp_get(therm) < 0) if (!therm || !therm->attr_get || nvkm_therm_temp_get(therm) < 0)
return 0; return 0;
@ -296,7 +296,7 @@ static umode_t
nouveau_pwm_is_visible(const void *data, u32 attr, int channel) nouveau_pwm_is_visible(const void *data, u32 attr, int channel)
{ {
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_get || !therm->fan_get || if (!therm || !therm->attr_get || !therm->fan_get ||
therm->fan_get(therm) < 0) therm->fan_get(therm) < 0)
@ -315,7 +315,7 @@ static umode_t
nouveau_input_is_visible(const void *data, u32 attr, int channel) nouveau_input_is_visible(const void *data, u32 attr, int channel)
{ {
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_volt *volt = nvxx_volt(&drm->client.device); struct nvkm_volt *volt = nvxx_volt(drm);
if (!volt || nvkm_volt_get(volt) < 0) if (!volt || nvkm_volt_get(volt) < 0)
return 0; return 0;
@ -335,7 +335,7 @@ static umode_t
nouveau_fan_is_visible(const void *data, u32 attr, int channel) nouveau_fan_is_visible(const void *data, u32 attr, int channel)
{ {
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_get || nvkm_therm_fan_sense(therm) < 0) if (!therm || !therm->attr_get || nvkm_therm_fan_sense(therm) < 0)
return 0; return 0;
@ -367,7 +367,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
int ret; int ret;
if (!therm || !therm->attr_get) if (!therm || !therm->attr_get)
@ -416,7 +416,7 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm) if (!therm)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -439,7 +439,7 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_volt *volt = nvxx_volt(&drm->client.device); struct nvkm_volt *volt = nvxx_volt(drm);
int ret; int ret;
if (!volt) if (!volt)
@ -470,7 +470,7 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_get || !therm->fan_get) if (!therm || !therm->attr_get || !therm->fan_get)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -496,7 +496,7 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
if (!iccsense) if (!iccsense)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -525,7 +525,7 @@ nouveau_temp_write(struct device *dev, u32 attr, int channel, long val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_set) if (!therm || !therm->attr_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -559,7 +559,7 @@ nouveau_pwm_write(struct device *dev, u32 attr, int channel, long val)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
if (!therm || !therm->attr_set) if (!therm || !therm->attr_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -664,9 +664,9 @@ nouveau_hwmon_init(struct drm_device *dev)
{ {
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); struct nvkm_iccsense *iccsense = nvxx_iccsense(drm);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(drm);
struct nvkm_volt *volt = nvxx_volt(&drm->client.device); struct nvkm_volt *volt = nvxx_volt(drm);
const struct attribute_group *special_groups[N_ATTR_GROUPS]; const struct attribute_group *special_groups[N_ATTR_GROUPS];
struct nouveau_hwmon *hwmon; struct nouveau_hwmon *hwmon;
struct device *hwmon_dev; struct device *hwmon_dev;

View File

@ -78,7 +78,7 @@ int
nouveau_led_init(struct drm_device *dev) nouveau_led_init(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device); struct nvkm_gpio *gpio = nvxx_gpio(drm);
struct dcb_gpio_func logo_led; struct dcb_gpio_func logo_led;
int ret; int ret;

View File

@ -261,7 +261,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
int int
nouveau_ttm_init(struct nouveau_drm *drm) nouveau_ttm_init(struct nouveau_drm *drm)
{ {
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(drm);
struct nvkm_pci *pci = device->pci; struct nvkm_pci *pci = device->pci;
struct nvif_mmu *mmu = &drm->client.mmu; struct nvif_mmu *mmu = &drm->client.mmu;
struct drm_device *dev = drm->dev; struct drm_device *dev = drm->dev;
@ -348,7 +348,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
void void
nouveau_ttm_fini(struct nouveau_drm *drm) nouveau_ttm_fini(struct nouveau_drm *drm)
{ {
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(drm);
nouveau_ttm_fini_vram(drm); nouveau_ttm_fini_vram(drm);
nouveau_ttm_fini_gtt(drm); nouveau_ttm_fini_gtt(drm);