Commit 8fd4a62d authored by Dave Airlie's avatar Dave Airlie

Merge branch 'linux-4.11' of git://github.com/skeggsb/linux into drm-next

- Rework of the secure boot code, in preparation for GP10x secure boot.
- Improvements to channel recovery
- Initial power budget code
- Some preparation for an upcoming MMU rework (probably 4.12)
- Misc other fixes.

* 'linux-4.11' of git://github.com/skeggsb/linux: (88 commits)
  drm/nouveau/tmr: provide backtrace when a timeout is hit
  drm/nouveau/pci/g92: Fix rearm
  drm/nouveau/drm/therm/fan: add a fallback if no fan control is specified in the vbios
  drm/nouveau/hwmon: expose power_max and power_crit
  drm/nouveau/iccsense: Parse max and crit power level
  drm/nouveau/bios/power_budget: Add basic power budget parsing
  drm/nouveau/fifo/gk104-: preempt recovery
  drm/nouveau/fifo/gk104-: trigger mmu fault before attempting engine recovery
  drm/nouveau/fifo/gk104-: ACK SCHED_ERROR before attempting CTXSW_TIMEOUT recovery
  drm/nouveau/fifo/gk104-: directly use new recovery code for ctxsw timeout
  drm/nouveau/fifo/gk104-: directly use new recovery code for mmu faults
  drm/nouveau/fifo/gk104-: reset all engines a killed channel is still active on
  drm/nouveau/fifo/gk104-: refactor recovery code
  drm/nouveau/fifo/gk104-: better detection of chid when parsing engine status
  drm/nouveau/fifo/gk104-: separate out engine status parsing
  drm/nouveau/fifo: add an api for initiating channel recovery
  drm/nouveau/top: add function to translate subdev index to mmu fault id
  drm/nouveau/gr/gf100-: implement chsw_load() method
  drm/nouveau/gr: implement chsw_load() method
  drm/nouveau/core: add engine method to assist in determining chsw direction
  ...
parents 9ca70356 eb875d87
...@@ -198,7 +198,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp, ...@@ -198,7 +198,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
int *burst, int *lwm) int *burst, int *lwm)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nv_fifo_info fifo_data; struct nv_fifo_info fifo_data;
struct nv_sim_state sim_data; struct nv_sim_state sim_data;
int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY); int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY);
...@@ -227,7 +227,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp, ...@@ -227,7 +227,7 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1); sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
} }
if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT)
nv04_calc_arb(&fifo_data, &sim_data); nv04_calc_arb(&fifo_data, &sim_data);
else else
nv10_calc_arb(&fifo_data, &sim_data); nv10_calc_arb(&fifo_data, &sim_data);
...@@ -254,7 +254,7 @@ nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm ...@@ -254,7 +254,7 @@ nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (drm->device.info.family < NV_DEVICE_INFO_V0_KELVIN) if (drm->client.device.info.family < NV_DEVICE_INFO_V0_KELVIN)
nv04_update_arb(dev, vclk, bpp, burst, lwm); nv04_update_arb(dev, vclk, bpp, burst, lwm);
else if ((dev->pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ || else if ((dev->pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ ||
(dev->pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) { (dev->pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) {
......
...@@ -113,8 +113,8 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod ...@@ -113,8 +113,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->device); struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
struct nvkm_clk *clk = nvxx_clk(&drm->device); struct nvkm_clk *clk = nvxx_clk(&drm->client.device);
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];
...@@ -138,7 +138,7 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod ...@@ -138,7 +138,7 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
* has yet been observed in allowing the use a single stage pll on all * has yet been observed in allowing the use a single stage pll on all
* nv43 however. the behaviour of single stage use is untested on nv40 * nv43 however. the behaviour of single stage use is untested on nv40
*/ */
if (drm->device.info.chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2)) if (drm->client.device.info.chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2))
memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2)); memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2));
...@@ -148,10 +148,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod ...@@ -148,10 +148,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK; state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK;
/* The blob uses this always, so let's do the same */ /* The blob uses this always, so let's do the same */
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE; state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE;
/* again nv40 and some nv43 act more like nv3x as described above */ /* again nv40 and some nv43 act more like nv3x as described above */
if (drm->device.info.chipset < 0x41) if (drm->client.device.info.chipset < 0x41)
state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL | state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL |
NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL; NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL;
state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK;
...@@ -270,7 +270,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) ...@@ -270,7 +270,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
horizEnd = horizTotal - 2; horizEnd = horizTotal - 2;
horizBlankEnd = horizTotal + 4; horizBlankEnd = horizTotal + 4;
#if 0 #if 0
if (dev->overlayAdaptor && drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) if (dev->overlayAdaptor && drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
/* This reportedly works around some video overlay bandwidth problems */ /* This reportedly works around some video overlay bandwidth problems */
horizTotal += 2; horizTotal += 2;
#endif #endif
...@@ -505,7 +505,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) ...@@ -505,7 +505,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 | regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 |
NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 | NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 |
NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM; NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM;
if (drm->device.info.chipset >= 0x11) if (drm->client.device.info.chipset >= 0x11)
regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32; regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN) if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE; regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE;
...@@ -546,26 +546,26 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) ...@@ -546,26 +546,26 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
* 1 << 30 on 0x60.830), for no apparent reason */ * 1 << 30 on 0x60.830), for no apparent reason */
regp->CRTC[NV_CIO_CRE_59] = off_chip_digital; regp->CRTC[NV_CIO_CRE_59] = off_chip_digital;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1; regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1;
regp->crtc_830 = mode->crtc_vdisplay - 3; regp->crtc_830 = mode->crtc_vdisplay - 3;
regp->crtc_834 = mode->crtc_vdisplay - 1; regp->crtc_834 = mode->crtc_vdisplay - 1;
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
/* This is what the blob does */ /* This is what the blob does */
regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850); regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850);
if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE)
regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT); regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT);
if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC; regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC;
else else
regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC; regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC;
/* Some misc regs */ /* Some misc regs */
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) { if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
regp->CRTC[NV_CIO_CRE_85] = 0xFF; regp->CRTC[NV_CIO_CRE_85] = 0xFF;
regp->CRTC[NV_CIO_CRE_86] = 0x1; regp->CRTC[NV_CIO_CRE_86] = 0x1;
} }
...@@ -577,7 +577,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) ...@@ -577,7 +577,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
/* Generic PRAMDAC regs */ /* Generic PRAMDAC regs */
if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS)
/* Only bit that bios and blob set. */ /* Only bit that bios and blob set. */
regp->nv10_cursync = (1 << 25); regp->nv10_cursync = (1 << 25);
...@@ -586,7 +586,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) ...@@ -586,7 +586,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON; NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON;
if (fb->format->depth == 16) if (fb->format->depth == 16)
regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL; regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL;
if (drm->device.info.chipset >= 0x11) if (drm->client.device.info.chipset >= 0x11)
regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG; regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG;
regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */ regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */
...@@ -649,7 +649,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, ...@@ -649,7 +649,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
nv_crtc_mode_set_vga(crtc, adjusted_mode); nv_crtc_mode_set_vga(crtc, adjusted_mode);
/* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk); NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk);
nv_crtc_mode_set_regs(crtc, adjusted_mode); nv_crtc_mode_set_regs(crtc, adjusted_mode);
nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock);
...@@ -710,7 +710,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc) ...@@ -710,7 +710,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc)
/* Some more preparation. */ /* Some more preparation. */
NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA); NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA);
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) { if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE) {
uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900); uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900);
NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000); NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000);
} }
...@@ -886,7 +886,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, ...@@ -886,7 +886,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX);
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX);
if (drm->device.info.family >= NV_DEVICE_INFO_V0_KELVIN) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KELVIN) {
regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8; regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8;
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47);
} }
...@@ -967,7 +967,7 @@ static void nv11_cursor_upload(struct drm_device *dev, struct nouveau_bo *src, ...@@ -967,7 +967,7 @@ static void nv11_cursor_upload(struct drm_device *dev, struct nouveau_bo *src,
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (drm->device.info.chipset == 0x11) { if (drm->client.device.info.chipset == 0x11) {
pixel = ((pixel & 0x000000ff) << 24) | pixel = ((pixel & 0x000000ff) << 24) |
((pixel & 0x0000ff00) << 8) | ((pixel & 0x0000ff00) << 8) |
((pixel & 0x00ff0000) >> 8) | ((pixel & 0x00ff0000) >> 8) |
...@@ -1008,7 +1008,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, ...@@ -1008,7 +1008,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
if (ret) if (ret)
goto out; goto out;
if (drm->device.info.chipset >= 0x11) if (drm->client.device.info.chipset >= 0x11)
nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
else else
nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo);
...@@ -1124,8 +1124,9 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num) ...@@ -1124,8 +1124,9 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs); drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs);
drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256); drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(&nouveau_drm(dev)->client, 64*64*4, 0x100,
0, 0x0000, NULL, NULL, &nv_crtc->cursor.nvbo); TTM_PL_FLAG_VRAM, 0, 0x0000, NULL, NULL,
&nv_crtc->cursor.nvbo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM, false); ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM, false);
if (!ret) { if (!ret) {
......
...@@ -55,7 +55,7 @@ nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) ...@@ -55,7 +55,7 @@ nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset)
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX);
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX);
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX); crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_HCUR_ADDR2_INDEX);
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
nv_fix_nv40_hw_cursor(dev, nv_crtc->index); nv_fix_nv40_hw_cursor(dev, nv_crtc->index);
} }
......
...@@ -66,7 +66,7 @@ int nv04_dac_output_offset(struct drm_encoder *encoder) ...@@ -66,7 +66,7 @@ int nv04_dac_output_offset(struct drm_encoder *encoder)
static int sample_load_twice(struct drm_device *dev, bool sense[2]) static int sample_load_twice(struct drm_device *dev, bool sense[2])
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -80,19 +80,19 @@ static int sample_load_twice(struct drm_device *dev, bool sense[2]) ...@@ -80,19 +80,19 @@ static int sample_load_twice(struct drm_device *dev, bool sense[2])
* use a 10ms timeout (guards against crtc being inactive, in * use a 10ms timeout (guards against crtc being inactive, in
* which case blank state would never change) * which case blank state would never change)
*/ */
if (nvif_msec(&drm->device, 10, if (nvif_msec(&drm->client.device, 10,
if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1)) if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
break; break;
) < 0) ) < 0)
return -EBUSY; return -EBUSY;
if (nvif_msec(&drm->device, 10, if (nvif_msec(&drm->client.device, 10,
if ( (nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1)) if ( (nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
break; break;
) < 0) ) < 0)
return -EBUSY; return -EBUSY;
if (nvif_msec(&drm->device, 10, if (nvif_msec(&drm->client.device, 10,
if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1)) if (!(nvif_rd32(device, NV_PRMCIO_INP0__COLOR) & 1))
break; break;
) < 0) ) < 0)
...@@ -133,7 +133,7 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder, ...@@ -133,7 +133,7 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
struct drm_connector *connector) struct drm_connector *connector)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode; uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode;
uint8_t saved_palette0[3], saved_palette_mask; uint8_t saved_palette0[3], saved_palette_mask;
...@@ -236,8 +236,8 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder) ...@@ -236,8 +236,8 @@ 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)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nvkm_gpio *gpio = nvxx_gpio(&drm->device); struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
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,
...@@ -288,7 +288,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder) ...@@ -288,7 +288,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
/* nv driver and nv31 use 0xfffffeee, nv34 and 6600 use 0xfffffece */ /* nv driver and nv31 use 0xfffffeee, nv34 and 6600 use 0xfffffece */
routput = (saved_routput & 0xfffffece) | head << 8; routput = (saved_routput & 0xfffffece) | head << 8;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_CURIE) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE) {
if (dcb->type == DCB_OUTPUT_TV) if (dcb->type == DCB_OUTPUT_TV)
routput |= 0x1a << 16; routput |= 0x1a << 16;
else else
...@@ -403,7 +403,7 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder, ...@@ -403,7 +403,7 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder,
} }
/* This could use refinement for flatpanels, but it should work this way */ /* This could use refinement for flatpanels, but it should work this way */
if (drm->device.info.chipset < 0x44) if (drm->client.device.info.chipset < 0x44)
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000); NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
else else
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000); NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
......
...@@ -281,7 +281,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder, ...@@ -281,7 +281,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
...@@ -417,7 +417,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder, ...@@ -417,7 +417,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
if ((nv_connector->dithering_mode == DITHERING_MODE_ON) || if ((nv_connector->dithering_mode == DITHERING_MODE_ON) ||
(nv_connector->dithering_mode == DITHERING_MODE_AUTO && (nv_connector->dithering_mode == DITHERING_MODE_AUTO &&
fb->format->depth > connector->display_info.bpc * 3)) { fb->format->depth > connector->display_info.bpc * 3)) {
if (drm->device.info.chipset == 0x11) if (drm->client.device.info.chipset == 0x11)
regp->dither = savep->dither | 0x00010000; regp->dither = savep->dither | 0x00010000;
else { else {
int i; int i;
...@@ -428,7 +428,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder, ...@@ -428,7 +428,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
} }
} }
} else { } else {
if (drm->device.info.chipset != 0x11) { if (drm->client.device.info.chipset != 0x11) {
/* reset them */ /* reset them */
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
...@@ -464,7 +464,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder) ...@@ -464,7 +464,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL); NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL);
/* This could use refinement for flatpanels, but it should work this way */ /* This could use refinement for flatpanels, but it should work this way */
if (drm->device.info.chipset < 0x44) if (drm->client.device.info.chipset < 0x44)
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000); NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0xf0000000);
else else
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000); NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000);
...@@ -486,7 +486,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode) ...@@ -486,7 +486,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
{ {
#ifdef __powerpc__ #ifdef __powerpc__
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
/* BIOS scripts usually take care of the backlight, thanks /* BIOS scripts usually take care of the backlight, thanks
* Apple for your consistency. * Apple for your consistency.
...@@ -624,7 +624,7 @@ static void nv04_tmds_slave_init(struct drm_encoder *encoder) ...@@ -624,7 +624,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->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
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[] = {
{ {
......
...@@ -35,7 +35,7 @@ int ...@@ -35,7 +35,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->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
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;
...@@ -48,7 +48,7 @@ nv04_display_create(struct drm_device *dev) ...@@ -48,7 +48,7 @@ nv04_display_create(struct drm_device *dev)
if (!disp) if (!disp)
return -ENOMEM; return -ENOMEM;
nvif_object_map(&drm->device.object); nvif_object_map(&drm->client.device.object);
nouveau_display(dev)->priv = disp; nouveau_display(dev)->priv = disp;
nouveau_display(dev)->dtor = nv04_display_destroy; nouveau_display(dev)->dtor = nv04_display_destroy;
...@@ -139,7 +139,7 @@ nv04_display_destroy(struct drm_device *dev) ...@@ -139,7 +139,7 @@ nv04_display_destroy(struct drm_device *dev)
nouveau_display(dev)->priv = NULL; nouveau_display(dev)->priv = NULL;
kfree(disp); kfree(disp);
nvif_object_unmap(&drm->device.object); nvif_object_unmap(&drm->client.device.object);
} }
int int
......
...@@ -129,7 +129,7 @@ nv_two_heads(struct drm_device *dev) ...@@ -129,7 +129,7 @@ nv_two_heads(struct drm_device *dev)
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
const int impl = dev->pdev->device & 0x0ff0; const int impl = dev->pdev->device & 0x0ff0;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 && if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 &&
impl != 0x0150 && impl != 0x01a0 && impl != 0x0200) impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)
return true; return true;
...@@ -148,7 +148,7 @@ nv_two_reg_pll(struct drm_device *dev) ...@@ -148,7 +148,7 @@ nv_two_reg_pll(struct drm_device *dev)
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
const int impl = dev->pdev->device & 0x0ff0; const int impl = dev->pdev->device & 0x0ff0;
if (impl == 0x0310 || impl == 0x0340 || drm->device.info.family >= NV_DEVICE_INFO_V0_CURIE) if (impl == 0x0310 || impl == 0x0340 || drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE)
return true; return true;
return false; return false;
} }
...@@ -170,7 +170,7 @@ nouveau_bios_run_init_table(struct drm_device *dev, u16 table, ...@@ -170,7 +170,7 @@ nouveau_bios_run_init_table(struct drm_device *dev, u16 table,
struct dcb_output *outp, int crtc) struct dcb_output *outp, int crtc)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_bios *bios = nvxx_bios(&drm->device); struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
struct nvbios_init init = { struct nvbios_init init = {
.subdev = &bios->subdev, .subdev = &bios->subdev,
.bios = bios, .bios = bios,
......
This diff is collapsed.
...@@ -60,7 +60,7 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp, ...@@ -60,7 +60,7 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp,
static inline uint32_t NVReadCRTC(struct drm_device *dev, static inline uint32_t NVReadCRTC(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
uint32_t val; uint32_t val;
if (head) if (head)
reg += NV_PCRTC0_SIZE; reg += NV_PCRTC0_SIZE;
...@@ -71,7 +71,7 @@ static inline uint32_t NVReadCRTC(struct drm_device *dev, ...@@ -71,7 +71,7 @@ static inline uint32_t NVReadCRTC(struct drm_device *dev,
static inline void NVWriteCRTC(struct drm_device *dev, static inline void NVWriteCRTC(struct drm_device *dev,
int head, uint32_t reg, uint32_t val) int head, uint32_t reg, uint32_t val)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
if (head) if (head)
reg += NV_PCRTC0_SIZE; reg += NV_PCRTC0_SIZE;
nvif_wr32(device, reg, val); nvif_wr32(device, reg, val);
...@@ -80,7 +80,7 @@ static inline void NVWriteCRTC(struct drm_device *dev, ...@@ -80,7 +80,7 @@ static inline void NVWriteCRTC(struct drm_device *dev,
static inline uint32_t NVReadRAMDAC(struct drm_device *dev, static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
uint32_t val; uint32_t val;
if (head) if (head)
reg += NV_PRAMDAC0_SIZE; reg += NV_PRAMDAC0_SIZE;
...@@ -91,7 +91,7 @@ static inline uint32_t NVReadRAMDAC(struct drm_device *dev, ...@@ -91,7 +91,7 @@ static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
static inline void NVWriteRAMDAC(struct drm_device *dev, static inline void NVWriteRAMDAC(struct drm_device *dev,
int head, uint32_t reg, uint32_t val) int head, uint32_t reg, uint32_t val)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
if (head) if (head)
reg += NV_PRAMDAC0_SIZE; reg += NV_PRAMDAC0_SIZE;
nvif_wr32(device, reg, val); nvif_wr32(device, reg, val);
...@@ -120,7 +120,7 @@ static inline void nv_write_tmds(struct drm_device *dev, ...@@ -120,7 +120,7 @@ static inline void nv_write_tmds(struct drm_device *dev,
static inline void NVWriteVgaCrtc(struct drm_device *dev, static inline void NVWriteVgaCrtc(struct drm_device *dev,
int head, uint8_t index, uint8_t value) int head, uint8_t index, uint8_t value)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value);
} }
...@@ -128,7 +128,7 @@ static inline void NVWriteVgaCrtc(struct drm_device *dev, ...@@ -128,7 +128,7 @@ static inline void NVWriteVgaCrtc(struct drm_device *dev,
static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, static inline uint8_t NVReadVgaCrtc(struct drm_device *dev,
int head, uint8_t index) int head, uint8_t index)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
uint8_t val; uint8_t val;
nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE);
...@@ -165,13 +165,13 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_ ...@@ -165,13 +165,13 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_
static inline uint8_t NVReadPRMVIO(struct drm_device *dev, static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
uint8_t val; uint8_t val;
/* Only NV4x have two pvio ranges; other twoHeads cards MUST call /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
* NVSetOwner for the relevant head to be programmed */ * NVSetOwner for the relevant head to be programmed */
if (head && drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (head && drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
reg += NV_PRMVIO_SIZE; reg += NV_PRMVIO_SIZE;
val = nvif_rd08(device, reg); val = nvif_rd08(device, reg);
...@@ -181,12 +181,12 @@ static inline uint8_t NVReadPRMVIO(struct drm_device *dev, ...@@ -181,12 +181,12 @@ static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
static inline void NVWritePRMVIO(struct drm_device *dev, static inline void NVWritePRMVIO(struct drm_device *dev,
int head, uint32_t reg, uint8_t value) int head, uint32_t reg, uint8_t value)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
/* Only NV4x have two pvio ranges; other twoHeads cards MUST call /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
* NVSetOwner for the relevant head to be programmed */ * NVSetOwner for the relevant head to be programmed */
if (head && drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (head && drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
reg += NV_PRMVIO_SIZE; reg += NV_PRMVIO_SIZE;
nvif_wr08(device, reg, value); nvif_wr08(device, reg, value);
...@@ -194,14 +194,14 @@ static inline void NVWritePRMVIO(struct drm_device *dev, ...@@ -194,14 +194,14 @@ static inline void NVWritePRMVIO(struct drm_device *dev,
static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20);
} }
static inline bool NVGetEnablePalette(struct drm_device *dev, int head) static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20);
} }
...@@ -209,7 +209,7 @@ static inline bool NVGetEnablePalette(struct drm_device *dev, int head) ...@@ -209,7 +209,7 @@ static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
static inline void NVWriteVgaAttr(struct drm_device *dev, static inline void NVWriteVgaAttr(struct drm_device *dev,
int head, uint8_t index, uint8_t value) int head, uint8_t index, uint8_t value)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
if (NVGetEnablePalette(dev, head)) if (NVGetEnablePalette(dev, head))
index &= ~0x20; index &= ~0x20;
else else
...@@ -223,7 +223,7 @@ static inline void NVWriteVgaAttr(struct drm_device *dev, ...@@ -223,7 +223,7 @@ static inline void NVWriteVgaAttr(struct drm_device *dev,
static inline uint8_t NVReadVgaAttr(struct drm_device *dev, static inline uint8_t NVReadVgaAttr(struct drm_device *dev,
int head, uint8_t index) int head, uint8_t index)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
uint8_t val; uint8_t val;
if (NVGetEnablePalette(dev, head)) if (NVGetEnablePalette(dev, head))
index &= ~0x20; index &= ~0x20;
...@@ -259,10 +259,10 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect) ...@@ -259,10 +259,10 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect)
static inline bool static inline bool
nv_heads_tied(struct drm_device *dev) nv_heads_tied(struct drm_device *dev)
{ {
struct nvif_object *device = &nouveau_drm(dev)->device.object; struct nvif_object *device = &nouveau_drm(dev)->client.device.object;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (drm->device.info.chipset == 0x11) if (drm->client.device.info.chipset == 0x11)
return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28)); return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28));
return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4;
...@@ -318,7 +318,7 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock) ...@@ -318,7 +318,7 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock)
NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX, NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX,
lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE); lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE);
/* NV11 has independently lockable extended crtcs, except when tied */ /* NV11 has independently lockable extended crtcs, except when tied */
if (drm->device.info.chipset == 0x11 && !nv_heads_tied(dev)) if (drm->client.device.info.chipset == 0x11 && !nv_heads_tied(dev))
NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX, NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX,
lock ? NV_CIO_SR_LOCK_VALUE : lock ? NV_CIO_SR_LOCK_VALUE :
NV_CIO_SR_UNLOCK_RW_VALUE); NV_CIO_SR_UNLOCK_RW_VALUE);
...@@ -335,7 +335,7 @@ static inline int nv_cursor_width(struct drm_device *dev) ...@@ -335,7 +335,7 @@ static inline int nv_cursor_width(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
return drm->device.info.family >= NV_DEVICE_INFO_V0_CELSIUS ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE; return drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
} }
static inline void static inline void
...@@ -357,7 +357,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) ...@@ -357,7 +357,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
NVWriteCRTC(dev, head, NV_PCRTC_START, offset); NVWriteCRTC(dev, head, NV_PCRTC_START, offset);
if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT) { if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT) {
/* /*
* Hilarious, the 24th bit doesn't want to stick to * Hilarious, the 24th bit doesn't want to stick to
* PCRTC_START... * PCRTC_START...
...@@ -382,7 +382,7 @@ nv_show_cursor(struct drm_device *dev, int head, bool show) ...@@ -382,7 +382,7 @@ nv_show_cursor(struct drm_device *dev, int head, bool show)
*curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE);
NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1); NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1);
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
nv_fix_nv40_hw_cursor(dev, head); nv_fix_nv40_hw_cursor(dev, head);
} }
...@@ -398,7 +398,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) ...@@ -398,7 +398,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp)
bpp = 8; bpp = 8;
/* Alignment requirements taken from the Haiku driver */ /* Alignment requirements taken from the Haiku driver */
if (drm->device.info.family == NV_DEVICE_INFO_V0_TNT) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_TNT)
mask = 128 / bpp - 1; mask = 128 / bpp - 1;
else else
mask = 512 / bpp - 1; mask = 512 / bpp - 1;
......
...@@ -97,7 +97,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -97,7 +97,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct nouveau_drm *drm = nouveau_drm(plane->dev); struct nouveau_drm *drm = nouveau_drm(plane->dev);
struct nvif_object *dev = &drm->device.object; struct nvif_object *dev = &drm->client.device.object;
struct nouveau_plane *nv_plane = struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base); container_of(plane, struct nouveau_plane, base);
struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
...@@ -119,7 +119,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -119,7 +119,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
if (format > 0xffff) if (format > 0xffff)
return -ERANGE; return -ERANGE;
if (drm->device.info.chipset >= 0x30) { if (drm->client.device.info.chipset >= 0x30) {
if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1)) if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
return -ERANGE; return -ERANGE;
} else { } else {
...@@ -174,7 +174,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -174,7 +174,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
static int static int
nv10_disable_plane(struct drm_plane *plane) nv10_disable_plane(struct drm_plane *plane)
{ {
struct nvif_object *dev = &nouveau_drm(plane->dev)->device.object; struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
struct nouveau_plane *nv_plane = struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base); container_of(plane, struct nouveau_plane, base);
...@@ -198,7 +198,7 @@ nv_destroy_plane(struct drm_plane *plane) ...@@ -198,7 +198,7 @@ nv_destroy_plane(struct drm_plane *plane)
static void static void
nv10_set_params(struct nouveau_plane *plane) nv10_set_params(struct nouveau_plane *plane)
{ {
struct nvif_object *dev = &nouveau_drm(plane->base.dev)->device.object; struct nvif_object *dev = &nouveau_drm(plane->base.dev)->client.device.object;
u32 luma = (plane->brightness - 512) << 16 | plane->contrast; u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) | u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
(cos_mul(plane->hue, plane->saturation) & 0xffff); (cos_mul(plane->hue, plane->saturation) & 0xffff);
...@@ -268,7 +268,7 @@ nv10_overlay_init(struct drm_device *device) ...@@ -268,7 +268,7 @@ nv10_overlay_init(struct drm_device *device)
if (!plane) if (!plane)
return; return;
switch (drm->device.info.chipset) { switch (drm->client.device.info.chipset) {
case 0x10: case 0x10:
case 0x11: case 0x11:
case 0x15: case 0x15:
...@@ -347,7 +347,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -347,7 +347,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_x, uint32_t src_y, uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h) uint32_t src_w, uint32_t src_h)
{ {
struct nvif_object *dev = &nouveau_drm(plane->dev)->device.object; struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
struct nouveau_plane *nv_plane = struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base); container_of(plane, struct nouveau_plane, base);
struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
...@@ -427,7 +427,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -427,7 +427,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
static int static int
nv04_disable_plane(struct drm_plane *plane) nv04_disable_plane(struct drm_plane *plane)
{ {
struct nvif_object *dev = &nouveau_drm(plane->dev)->device.object; struct nvif_object *dev = &nouveau_drm(plane->dev)->client.device.object;
struct nouveau_plane *nv_plane = struct nouveau_plane *nv_plane =
container_of(plane, struct nouveau_plane, base); container_of(plane, struct nouveau_plane, base);
...@@ -495,7 +495,7 @@ nv04_overlay_init(struct drm_device *device) ...@@ -495,7 +495,7 @@ nv04_overlay_init(struct drm_device *device)
void void
nouveau_overlay_init(struct drm_device *device) nouveau_overlay_init(struct drm_device *device)
{ {
struct nvif_device *dev = &nouveau_drm(device)->device; struct nvif_device *dev = &nouveau_drm(device)->client.device;
if (dev->info.chipset < 0x10) if (dev->info.chipset < 0x10)
nv04_overlay_init(device); nv04_overlay_init(device);
else if (dev->info.chipset <= 0x40) else if (dev->info.chipset <= 0x40)
......
...@@ -54,7 +54,7 @@ static struct nvkm_i2c_bus_probe nv04_tv_encoder_info[] = { ...@@ -54,7 +54,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->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
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",
...@@ -206,7 +206,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_output *entry) ...@@ -206,7 +206,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->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
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;
......
...@@ -46,7 +46,7 @@ static uint32_t nv42_tv_sample_load(struct drm_encoder *encoder) ...@@ -46,7 +46,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->device); struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
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;
...@@ -130,7 +130,7 @@ static bool ...@@ -130,7 +130,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->device); struct nvkm_device *device = nvxx_device(&drm->client.device);
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;
...@@ -154,8 +154,8 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector) ...@@ -154,8 +154,8 @@ nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector)
return connector_status_disconnected; return connector_status_disconnected;
if (reliable) { if (reliable) {
if (drm->device.info.chipset == 0x42 || if (drm->client.device.info.chipset == 0x42 ||
drm->device.info.chipset == 0x43) drm->client.device.info.chipset == 0x43)
tv_enc->pin_mask = tv_enc->pin_mask =
nv42_tv_sample_load(encoder) >> 28 & 0xe; nv42_tv_sample_load(encoder) >> 28 & 0xe;
else else
...@@ -362,7 +362,7 @@ static void nv17_tv_dpms(struct drm_encoder *encoder, int mode) ...@@ -362,7 +362,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->device); struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
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);
...@@ -435,7 +435,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder) ...@@ -435,7 +435,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder)
/* Set the DACCLK register */ /* Set the DACCLK register */
dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1; dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1;
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE)
dacclk |= 0x1a << 16; dacclk |= 0x1a << 16;
if (tv_norm->kind == CTV_ENC_MODE) { if (tv_norm->kind == CTV_ENC_MODE) {
...@@ -492,7 +492,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder, ...@@ -492,7 +492,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder,
tv_regs->ptv_614 = 0x13; tv_regs->ptv_614 = 0x13;
} }
if (drm->device.info.family >= NV_DEVICE_INFO_V0_RANKINE) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_RANKINE) {
tv_regs->ptv_500 = 0xe8e0; tv_regs->ptv_500 = 0xe8e0;
tv_regs->ptv_504 = 0x1710; tv_regs->ptv_504 = 0x1710;
tv_regs->ptv_604 = 0x0; tv_regs->ptv_604 = 0x0;
...@@ -587,7 +587,7 @@ static void nv17_tv_commit(struct drm_encoder *encoder) ...@@ -587,7 +587,7 @@ static void nv17_tv_commit(struct drm_encoder *encoder)
nv17_tv_state_load(dev, &to_tv_enc(encoder)->state); nv17_tv_state_load(dev, &to_tv_enc(encoder)->state);
/* This could use refinement for flatpanels, but it should work */ /* This could use refinement for flatpanels, but it should work */
if (drm->device.info.chipset < 0x44) if (drm->client.device.info.chipset < 0x44)
NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL +
nv04_dac_output_offset(encoder), nv04_dac_output_offset(encoder),
0xf0000000); 0xf0000000);
......
...@@ -130,13 +130,13 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder); ...@@ -130,13 +130,13 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg, static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
uint32_t val) uint32_t val)
{ {
struct nvif_device *device = &nouveau_drm(dev)->device; struct nvif_device *device = &nouveau_drm(dev)->client.device;
nvif_wr32(&device->object, reg, val); nvif_wr32(&device->object, reg, val);
} }
static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg) static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
{ {
struct nvif_device *device = &nouveau_drm(dev)->device; struct nvif_device *device = &nouveau_drm(dev)->client.device;
return nvif_rd32(&device->object, reg); return nvif_rd32(&device->object, reg);
} }
......
...@@ -10,5 +10,5 @@ struct g82_channel_dma_v0 { ...@@ -10,5 +10,5 @@ struct g82_channel_dma_v0 {
__u64 offset; __u64 offset;
}; };
#define G82_CHANNEL_DMA_V0_NTFY_UEVENT 0x00 #define NV826E_V0_NTFY_NON_STALL_INTERRUPT 0x00
#endif #endif
...@@ -11,5 +11,5 @@ struct g82_channel_gpfifo_v0 { ...@@ -11,5 +11,5 @@ struct g82_channel_gpfifo_v0 {
__u64 vm; __u64 vm;
}; };
#define G82_CHANNEL_GPFIFO_V0_NTFY_UEVENT 0x00 #define NV826F_V0_NTFY_NON_STALL_INTERRUPT 0x00
#endif #endif
...@@ -10,5 +10,6 @@ struct fermi_channel_gpfifo_v0 { ...@@ -10,5 +10,6 @@ struct fermi_channel_gpfifo_v0 {
__u64 vm; __u64 vm;
}; };
#define FERMI_CHANNEL_GPFIFO_V0_NTFY_UEVENT 0x00 #define NV906F_V0_NTFY_NON_STALL_INTERRUPT 0x00
#define NV906F_V0_NTFY_KILLED 0x01
#endif #endif
...@@ -25,5 +25,6 @@ struct kepler_channel_gpfifo_a_v0 { ...@@ -25,5 +25,6 @@ struct kepler_channel_gpfifo_a_v0 {
__u64 vm; __u64 vm;
}; };
#define NVA06F_V0_NTFY_UEVENT 0x00 #define NVA06F_V0_NTFY_NON_STALL_INTERRUPT 0x00
#define NVA06F_V0_NTFY_KILLED 0x01
#endif #endif
...@@ -2,23 +2,31 @@ ...@@ -2,23 +2,31 @@
#define __NVIF_CLASS_H__ #define __NVIF_CLASS_H__
/* these class numbers are made up by us, and not nvidia-assigned */ /* these class numbers are made up by us, and not nvidia-assigned */
#define NVIF_CLASS_CONTROL /* if0001.h */ -1 #define NVIF_CLASS_CLIENT /* if0000.h */ -0x00000000
#define NVIF_CLASS_PERFMON /* if0002.h */ -2
#define NVIF_CLASS_PERFDOM /* if0003.h */ -3 #define NVIF_CLASS_CONTROL /* if0001.h */ -0x00000001
#define NVIF_CLASS_SW_NV04 /* if0004.h */ -4
#define NVIF_CLASS_SW_NV10 /* if0005.h */ -5 #define NVIF_CLASS_PERFMON /* if0002.h */ -0x00000002
#define NVIF_CLASS_SW_NV50 /* if0005.h */ -6 #define NVIF_CLASS_PERFDOM /* if0003.h */ -0x00000003
#define NVIF_CLASS_SW_GF100 /* if0005.h */ -7
#define NVIF_CLASS_SW_NV04 /* if0004.h */ -0x00000004
#define NVIF_CLASS_SW_NV10 /* if0005.h */ -0x00000005
#define NVIF_CLASS_SW_NV50 /* if0005.h */ -0x00000006
#define NVIF_CLASS_SW_GF100 /* if0005.h */ -0x00000007
/* the below match nvidia-assigned (either in hw, or sw) class numbers */ /* the below match nvidia-assigned (either in hw, or sw) class numbers */
#define NV_NULL_CLASS 0x00000030
#define NV_DEVICE /* cl0080.h */ 0x00000080 #define NV_DEVICE /* cl0080.h */ 0x00000080
#define NV_DMA_FROM_MEMORY /* cl0002.h */ 0x00000002 #define NV_DMA_FROM_MEMORY /* cl0002.h */ 0x00000002
#define NV_DMA_TO_MEMORY /* cl0002.h */ 0x00000003 #define NV_DMA_TO_MEMORY /* cl0002.h */ 0x00000003
#define NV_DMA_IN_MEMORY /* cl0002.h */ 0x0000003d #define NV_DMA_IN_MEMORY /* cl0002.h */ 0x0000003d
#define NV50_TWOD 0x0000502d
#define FERMI_TWOD_A 0x0000902d #define FERMI_TWOD_A 0x0000902d
#define NV50_MEMORY_TO_MEMORY_FORMAT 0x00005039
#define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x00009039 #define FERMI_MEMORY_TO_MEMORY_FORMAT_A 0x00009039
#define KEPLER_INLINE_TO_MEMORY_A 0x0000a040 #define KEPLER_INLINE_TO_MEMORY_A 0x0000a040
...@@ -99,6 +107,12 @@ ...@@ -99,6 +107,12 @@
#define GF110_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000907e #define GF110_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000907e
#define GK104_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000917e #define GK104_DISP_OVERLAY_CONTROL_DMA /* cl507e.h */ 0x0000917e
#define NV50_TESLA 0x00005097
#define G82_TESLA 0x00008297
#define GT200_TESLA 0x00008397
#define GT214_TESLA 0x00008597
#define GT21A_TESLA 0x00008697
#define FERMI_A /* cl9097.h */ 0x00009097 #define FERMI_A /* cl9097.h */ 0x00009097
#define FERMI_B /* cl9097.h */ 0x00009197 #define FERMI_B /* cl9097.h */ 0x00009197
#define FERMI_C /* cl9097.h */ 0x00009297 #define FERMI_C /* cl9097.h */ 0x00009297
...@@ -140,6 +154,8 @@ ...@@ -140,6 +154,8 @@
#define FERMI_DECOMPRESS 0x000090b8 #define FERMI_DECOMPRESS 0x000090b8
#define NV50_COMPUTE 0x000050c0
#define GT214_COMPUTE 0x000085c0
#define FERMI_COMPUTE_A 0x000090c0 #define FERMI_COMPUTE_A 0x000090c0
#define FERMI_COMPUTE_B 0x000091c0 #define FERMI_COMPUTE_B 0x000091c0
#define KEPLER_COMPUTE_A 0x0000a0c0 #define KEPLER_COMPUTE_A 0x0000a0c0
......
...@@ -11,8 +11,7 @@ struct nvif_client { ...@@ -11,8 +11,7 @@ struct nvif_client {
bool super; bool super;
}; };
int nvif_client_init(const char *drv, const char *name, u64 device, int nvif_client_init(struct nvif_client *parent, const char *name, u64 device,
const char *cfg, const char *dbg,
struct nvif_client *); struct nvif_client *);
void nvif_client_fini(struct nvif_client *); void nvif_client_fini(struct nvif_client *);
int nvif_client_ioctl(struct nvif_client *, void *, u32); int nvif_client_ioctl(struct nvif_client *, void *, u32);
......
#ifndef __NVIF_DRIVER_H__ #ifndef __NVIF_DRIVER_H__
#define __NVIF_DRIVER_H__ #define __NVIF_DRIVER_H__
#include <nvif/os.h>
struct nvif_client;
struct nvif_driver { struct nvif_driver {
const char *name; const char *name;
...@@ -14,9 +16,11 @@ struct nvif_driver { ...@@ -14,9 +16,11 @@ struct nvif_driver {
bool keep; bool keep;
}; };
int nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
const char *name, u64 device, struct nvif_client *);
extern const struct nvif_driver nvif_driver_nvkm; extern const struct nvif_driver nvif_driver_nvkm;
extern const struct nvif_driver nvif_driver_drm; extern const struct nvif_driver nvif_driver_drm;
extern const struct nvif_driver nvif_driver_lib; extern const struct nvif_driver nvif_driver_lib;
extern const struct nvif_driver nvif_driver_null; extern const struct nvif_driver nvif_driver_null;
#endif #endif
#ifndef __NVIF_IF0000_H__ #ifndef __NVIF_IF0000_H__
#define __NVIF_IF0000_H__ #define __NVIF_IF0000_H__
#define NV_CLIENT_DEVLIST 0x00 struct nvif_client_v0 {
__u8 version;
__u8 pad01[7];
__u64 device;
char name[32];
};
#define NVIF_CLIENT_V0_DEVLIST 0x00
struct nv_client_devlist_v0 { struct nvif_client_devlist_v0 {
__u8 version; __u8 version;
__u8 count; __u8 count;
__u8 pad02[6]; __u8 pad02[6];
......
#ifndef __NVKM_CLIENT_H__ #ifndef __NVKM_CLIENT_H__
#define __NVKM_CLIENT_H__ #define __NVKM_CLIENT_H__
#define nvkm_client(p) container_of((p), struct nvkm_client, object)
#include <core/object.h> #include <core/object.h>
struct nvkm_client { struct nvkm_client {
...@@ -8,9 +9,8 @@ struct nvkm_client { ...@@ -8,9 +9,8 @@ struct nvkm_client {
u64 device; u64 device;
u32 debug; u32 debug;
struct nvkm_client_notify *notify[16]; struct nvkm_client_notify *notify[32];
struct rb_root objroot; struct rb_root objroot;
struct rb_root dmaroot;
bool super; bool super;
void *data; void *data;
...@@ -19,15 +19,11 @@ struct nvkm_client { ...@@ -19,15 +19,11 @@ struct nvkm_client {
struct nvkm_vm *vm; struct nvkm_vm *vm;
}; };
bool nvkm_client_insert(struct nvkm_client *, struct nvkm_object *);
void nvkm_client_remove(struct nvkm_client *, struct nvkm_object *);
struct nvkm_object *nvkm_client_search(struct nvkm_client *, u64 object);
int nvkm_client_new(const char *name, u64 device, const char *cfg, int nvkm_client_new(const char *name, u64 device, const char *cfg,
const char *dbg, struct nvkm_client **); const char *dbg,
void nvkm_client_del(struct nvkm_client **); int (*)(const void *, u32, const void *, u32),
int nvkm_client_init(struct nvkm_client *); struct nvkm_client **);
int nvkm_client_fini(struct nvkm_client *, bool suspend); struct nvkm_client *nvkm_client_search(struct nvkm_client *, u64 handle);
int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *, int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
void *data, u32 size); void *data, u32 size);
...@@ -37,8 +33,8 @@ int nvkm_client_notify_put(struct nvkm_client *, int index); ...@@ -37,8 +33,8 @@ int nvkm_client_notify_put(struct nvkm_client *, int index);
/* logging for client-facing objects */ /* logging for client-facing objects */
#define nvif_printk(o,l,p,f,a...) do { \ #define nvif_printk(o,l,p,f,a...) do { \
struct nvkm_object *_object = (o); \ const struct nvkm_object *_object = (o); \
struct nvkm_client *_client = _object->client; \ const struct nvkm_client *_client = _object->client; \
if (_client->debug >= NV_DBG_##l) \ if (_client->debug >= NV_DBG_##l) \
printk(KERN_##p "nouveau: %s:%08x:%08x: "f, _client->name, \ printk(KERN_##p "nouveau: %s:%08x:%08x: "f, _client->name, \
_object->handle, _object->oclass, ##a); \ _object->handle, _object->oclass, ##a); \
......
...@@ -262,7 +262,7 @@ extern const struct nvkm_sclass nvkm_udevice_sclass; ...@@ -262,7 +262,7 @@ extern const struct nvkm_sclass nvkm_udevice_sclass;
/* device logging */ /* device logging */
#define nvdev_printk_(d,l,p,f,a...) do { \ #define nvdev_printk_(d,l,p,f,a...) do { \
struct nvkm_device *_device = (d); \ const struct nvkm_device *_device = (d); \
if (_device->debug >= (l)) \ if (_device->debug >= (l)) \
dev_##p(_device->dev, f, ##a); \ dev_##p(_device->dev, f, ##a); \
} while(0) } while(0)
......
...@@ -20,6 +20,7 @@ struct nvkm_engine_func { ...@@ -20,6 +20,7 @@ struct nvkm_engine_func {
int (*fini)(struct nvkm_engine *, bool suspend); int (*fini)(struct nvkm_engine *, bool suspend);
void (*intr)(struct nvkm_engine *); void (*intr)(struct nvkm_engine *);
void (*tile)(struct nvkm_engine *, int region, struct nvkm_fb_tile *); void (*tile)(struct nvkm_engine *, int region, struct nvkm_fb_tile *);
bool (*chsw_load)(struct nvkm_engine *);
struct { struct {
int (*sclass)(struct nvkm_oclass *, int index, int (*sclass)(struct nvkm_oclass *, int index,
...@@ -44,4 +45,5 @@ int nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *, ...@@ -44,4 +45,5 @@ int nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *,
struct nvkm_engine *nvkm_engine_ref(struct nvkm_engine *); struct nvkm_engine *nvkm_engine_ref(struct nvkm_engine *);
void nvkm_engine_unref(struct nvkm_engine **); void nvkm_engine_unref(struct nvkm_engine **);
void nvkm_engine_tile(struct nvkm_engine *, int region); void nvkm_engine_tile(struct nvkm_engine *, int region);
bool nvkm_engine_chsw_load(struct nvkm_engine *);
#endif #endif
...@@ -6,9 +6,10 @@ struct nvkm_vma; ...@@ -6,9 +6,10 @@ struct nvkm_vma;
struct nvkm_vm; struct nvkm_vm;
enum nvkm_memory_target { enum nvkm_memory_target {
NVKM_MEM_TARGET_INST, NVKM_MEM_TARGET_INST, /* instance memory */
NVKM_MEM_TARGET_VRAM, NVKM_MEM_TARGET_VRAM, /* video memory */
NVKM_MEM_TARGET_HOST, NVKM_MEM_TARGET_HOST, /* coherent system memory */
NVKM_MEM_TARGET_NCOH, /* non-coherent system memory */
}; };
struct nvkm_memory { struct nvkm_memory {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
struct nvkm_mm_node { struct nvkm_mm_node {
struct list_head nl_entry; struct list_head nl_entry;
struct list_head fl_entry; struct list_head fl_entry;
struct list_head rl_entry; struct nvkm_mm_node *next;
#define NVKM_MM_HEAP_ANY 0x00 #define NVKM_MM_HEAP_ANY 0x00
u8 heap; u8 heap;
...@@ -38,4 +38,10 @@ int nvkm_mm_tail(struct nvkm_mm *, u8 heap, u8 type, u32 size_max, ...@@ -38,4 +38,10 @@ int nvkm_mm_tail(struct nvkm_mm *, u8 heap, u8 type, u32 size_max,
u32 size_min, u32 align, struct nvkm_mm_node **); u32 size_min, u32 align, struct nvkm_mm_node **);
void nvkm_mm_free(struct nvkm_mm *, struct nvkm_mm_node **); void nvkm_mm_free(struct nvkm_mm *, struct nvkm_mm_node **);
void nvkm_mm_dump(struct nvkm_mm *, const char *); void nvkm_mm_dump(struct nvkm_mm *, const char *);
static inline bool
nvkm_mm_contiguous(struct nvkm_mm_node *node)
{
return !node->next;
}
#endif #endif
...@@ -62,6 +62,11 @@ int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32 data); ...@@ -62,6 +62,11 @@ int nvkm_object_wr32(struct nvkm_object *, u64 addr, u32 data);
int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align, int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
struct nvkm_gpuobj **); struct nvkm_gpuobj **);
bool nvkm_object_insert(struct nvkm_object *);
void nvkm_object_remove(struct nvkm_object *);
struct nvkm_object *nvkm_object_search(struct nvkm_client *, u64 object,
const struct nvkm_object_func *);
struct nvkm_sclass { struct nvkm_sclass {
int minver; int minver;
int maxver; int maxver;
......
...@@ -32,7 +32,7 @@ void nvkm_subdev_intr(struct nvkm_subdev *); ...@@ -32,7 +32,7 @@ void nvkm_subdev_intr(struct nvkm_subdev *);
/* subdev logging */ /* subdev logging */
#define nvkm_printk_(s,l,p,f,a...) do { \ #define nvkm_printk_(s,l,p,f,a...) do { \
struct nvkm_subdev *_subdev = (s); \ const struct nvkm_subdev *_subdev = (s); \
if (_subdev->debug >= (l)) { \ if (_subdev->debug >= (l)) { \
dev_##p(_subdev->device->dev, "%s: "f, \ dev_##p(_subdev->device->dev, "%s: "f, \
nvkm_subdev_name[_subdev->index], ##a); \ nvkm_subdev_name[_subdev->index], ##a); \
......
...@@ -12,9 +12,6 @@ struct nvkm_dmaobj { ...@@ -12,9 +12,6 @@ struct nvkm_dmaobj {
u32 access; u32 access;
u64 start; u64 start;
u64 limit; u64 limit;
struct rb_node rb;
u64 handle; /*XXX HANDLE MERGE */
}; };
struct nvkm_dma { struct nvkm_dma {
...@@ -22,8 +19,7 @@ struct nvkm_dma { ...@@ -22,8 +19,7 @@ struct nvkm_dma {
struct nvkm_engine engine; struct nvkm_engine engine;
}; };
struct nvkm_dmaobj * struct nvkm_dmaobj *nvkm_dmaobj_search(struct nvkm_client *, u64 object);
nvkm_dma_search(struct nvkm_dma *, struct nvkm_client *, u64 object);
int nv04_dma_new(struct nvkm_device *, int, struct nvkm_dma **); int nv04_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
int nv50_dma_new(struct nvkm_device *, int, struct nvkm_dma **); int nv50_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
......
...@@ -4,13 +4,26 @@ ...@@ -4,13 +4,26 @@
#include <core/engine.h> #include <core/engine.h>
struct nvkm_fifo_chan; struct nvkm_fifo_chan;
enum nvkm_falcon_dmaidx {
FALCON_DMAIDX_UCODE = 0,
FALCON_DMAIDX_VIRT = 1,
FALCON_DMAIDX_PHYS_VID = 2,
FALCON_DMAIDX_PHYS_SYS_COH = 3,
FALCON_DMAIDX_PHYS_SYS_NCOH = 4,
};
struct nvkm_falcon { struct nvkm_falcon {
const struct nvkm_falcon_func *func; const struct nvkm_falcon_func *func;
struct nvkm_engine engine; const struct nvkm_subdev *owner;
const char *name;
u32 addr; u32 addr;
u8 version;
u8 secret; struct mutex mutex;
const struct nvkm_subdev *user;
u8 version;
u8 secret;
bool debug;
struct nvkm_memory *core; struct nvkm_memory *core;
bool external; bool external;
...@@ -19,15 +32,25 @@ struct nvkm_falcon { ...@@ -19,15 +32,25 @@ struct nvkm_falcon {
u32 limit; u32 limit;
u32 *data; u32 *data;
u32 size; u32 size;
u8 ports;
} code; } code;
struct { struct {
u32 limit; u32 limit;
u32 *data; u32 *data;
u32 size; u32 size;
u8 ports;
} data; } data;
struct nvkm_engine engine;
}; };
int nvkm_falcon_v1_new(struct nvkm_subdev *owner, const char *name, u32 addr,
struct nvkm_falcon **);
void nvkm_falcon_del(struct nvkm_falcon **);
int nvkm_falcon_get(struct nvkm_falcon *, const struct nvkm_subdev *);
void nvkm_falcon_put(struct nvkm_falcon *, const struct nvkm_subdev *);
int nvkm_falcon_new_(const struct nvkm_falcon_func *, struct nvkm_device *, int nvkm_falcon_new_(const struct nvkm_falcon_func *, struct nvkm_device *,
int index, bool enable, u32 addr, struct nvkm_engine **); int index, bool enable, u32 addr, struct nvkm_engine **);
...@@ -42,6 +65,51 @@ struct nvkm_falcon_func { ...@@ -42,6 +65,51 @@ struct nvkm_falcon_func {
} data; } data;
void (*init)(struct nvkm_falcon *); void (*init)(struct nvkm_falcon *);
void (*intr)(struct nvkm_falcon *, struct nvkm_fifo_chan *); void (*intr)(struct nvkm_falcon *, struct nvkm_fifo_chan *);
void (*load_imem)(struct nvkm_falcon *, void *, u32, u32, u16, u8, bool);
void (*load_dmem)(struct nvkm_falcon *, void *, u32, u32, u8);
void (*read_dmem)(struct nvkm_falcon *, u32, u32, u8, void *);
void (*bind_context)(struct nvkm_falcon *, struct nvkm_gpuobj *);
int (*wait_for_halt)(struct nvkm_falcon *, u32);
int (*clear_interrupt)(struct nvkm_falcon *, u32);
void (*set_start_addr)(struct nvkm_falcon *, u32 start_addr);
void (*start)(struct nvkm_falcon *);
int (*enable)(struct nvkm_falcon *falcon);
void (*disable)(struct nvkm_falcon *falcon);
struct nvkm_sclass sclass[]; struct nvkm_sclass sclass[];
}; };
static inline u32
nvkm_falcon_rd32(struct nvkm_falcon *falcon, u32 addr)
{
return nvkm_rd32(falcon->owner->device, falcon->addr + addr);
}
static inline void
nvkm_falcon_wr32(struct nvkm_falcon *falcon, u32 addr, u32 data)
{
nvkm_wr32(falcon->owner->device, falcon->addr + addr, data);
}
static inline u32
nvkm_falcon_mask(struct nvkm_falcon *falcon, u32 addr, u32 mask, u32 val)
{
struct nvkm_device *device = falcon->owner->device;
return nvkm_mask(device, falcon->addr + addr, mask, val);
}
void nvkm_falcon_load_imem(struct nvkm_falcon *, void *, u32, u32, u16, u8,
bool);
void nvkm_falcon_load_dmem(struct nvkm_falcon *, void *, u32, u32, u8);
void nvkm_falcon_read_dmem(struct nvkm_falcon *, u32, u32, u8, void *);
void nvkm_falcon_bind_context(struct nvkm_falcon *, struct nvkm_gpuobj *);
void nvkm_falcon_set_start_addr(struct nvkm_falcon *, u32);
void nvkm_falcon_start(struct nvkm_falcon *);
int nvkm_falcon_wait_for_halt(struct nvkm_falcon *, u32);
int nvkm_falcon_clear_interrupt(struct nvkm_falcon *, u32);
int nvkm_falcon_enable(struct nvkm_falcon *);
void nvkm_falcon_disable(struct nvkm_falcon *);
int nvkm_falcon_reset(struct nvkm_falcon *);
#endif #endif
...@@ -40,6 +40,7 @@ struct nvkm_fifo { ...@@ -40,6 +40,7 @@ struct nvkm_fifo {
struct nvkm_event uevent; /* async user trigger */ struct nvkm_event uevent; /* async user trigger */
struct nvkm_event cevent; /* channel creation event */ struct nvkm_event cevent; /* channel creation event */
struct nvkm_event kevent; /* channel killed */
}; };
void nvkm_fifo_pause(struct nvkm_fifo *, unsigned long *); void nvkm_fifo_pause(struct nvkm_fifo *, unsigned long *);
......
#ifndef __NVBIOS_POWER_BUDGET_H__
#define __NVBIOS_POWER_BUDGET_H__
#include <nvkm/subdev/bios.h>
struct nvbios_power_budget_entry {
u32 min_w;
u32 avg_w;
u32 max_w;
};
struct nvbios_power_budget {
u32 offset;
u8 ver;
u8 hlen;
u8 elen;
u8 ecount;
u8 cap_entry;
};
int nvbios_power_budget_header(struct nvkm_bios *,
struct nvbios_power_budget *);
int nvbios_power_budget_entry(struct nvkm_bios *, struct nvbios_power_budget *,
u8 idx, struct nvbios_power_budget_entry *);
#endif
...@@ -29,7 +29,7 @@ struct nvkm_mem { ...@@ -29,7 +29,7 @@ struct nvkm_mem {
u8 page_shift; u8 page_shift;
struct nvkm_mm_node *tag; struct nvkm_mm_node *tag;
struct list_head regions; struct nvkm_mm_node *mem;
dma_addr_t *pages; dma_addr_t *pages;
u32 memtype; u32 memtype;
u64 offset; u64 offset;
......
...@@ -8,6 +8,9 @@ struct nvkm_iccsense { ...@@ -8,6 +8,9 @@ struct nvkm_iccsense {
bool data_valid; bool data_valid;
struct list_head sensors; struct list_head sensors;
struct list_head rails; struct list_head rails;
u32 power_w_max;
u32 power_w_crit;
}; };
int gf100_iccsense_new(struct nvkm_device *, int index, struct nvkm_iccsense **); int gf100_iccsense_new(struct nvkm_device *, int index, struct nvkm_iccsense **);
......
...@@ -9,6 +9,7 @@ struct nvkm_mc { ...@@ -9,6 +9,7 @@ struct nvkm_mc {
void nvkm_mc_enable(struct nvkm_device *, enum nvkm_devidx); void nvkm_mc_enable(struct nvkm_device *, enum nvkm_devidx);
void nvkm_mc_disable(struct nvkm_device *, enum nvkm_devidx); void nvkm_mc_disable(struct nvkm_device *, enum nvkm_devidx);
bool nvkm_mc_enabled(struct nvkm_device *, enum nvkm_devidx);
void nvkm_mc_reset(struct nvkm_device *, enum nvkm_devidx); void nvkm_mc_reset(struct nvkm_device *, enum nvkm_devidx);
void nvkm_mc_intr(struct nvkm_device *, bool *handled); void nvkm_mc_intr(struct nvkm_device *, bool *handled);
void nvkm_mc_intr_unarm(struct nvkm_device *); void nvkm_mc_intr_unarm(struct nvkm_device *);
......
...@@ -43,6 +43,7 @@ int nv40_pci_new(struct nvkm_device *, int, struct nvkm_pci **); ...@@ -43,6 +43,7 @@ int nv40_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv46_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int nv46_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int g84_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g92_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int g94_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int gf100_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **); int gf106_pci_new(struct nvkm_device *, int, struct nvkm_pci **);
......
#ifndef __NVKM_PMU_H__ #ifndef __NVKM_PMU_H__
#define __NVKM_PMU_H__ #define __NVKM_PMU_H__
#include <core/subdev.h> #include <core/subdev.h>
#include <engine/falcon.h>
struct nvkm_pmu { struct nvkm_pmu {
const struct nvkm_pmu_func *func; const struct nvkm_pmu_func *func;
struct nvkm_subdev subdev; struct nvkm_subdev subdev;
struct nvkm_falcon *falcon;
struct { struct {
u32 base; u32 base;
...@@ -35,6 +37,7 @@ int gk110_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); ...@@ -35,6 +37,7 @@ int gk110_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gk208_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); int gk208_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gk20a_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); int gk20a_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gm107_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); int gm107_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gm20b_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gp100_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); int gp100_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
int gp102_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **); int gp102_pmu_new(struct nvkm_device *, int, struct nvkm_pmu **);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <core/subdev.h> #include <core/subdev.h>
enum nvkm_secboot_falcon { enum nvkm_secboot_falcon {
NVKM_SECBOOT_FALCON_PMU = 0, NVKM_SECBOOT_FALCON_PMU = 0,
NVKM_SECBOOT_FALCON_RESERVED = 1, NVKM_SECBOOT_FALCON_RESERVED = 1,
NVKM_SECBOOT_FALCON_FECS = 2, NVKM_SECBOOT_FALCON_FECS = 2,
NVKM_SECBOOT_FALCON_GPCCS = 3, NVKM_SECBOOT_FALCON_GPCCS = 3,
...@@ -35,22 +35,23 @@ enum nvkm_secboot_falcon { ...@@ -35,22 +35,23 @@ enum nvkm_secboot_falcon {
}; };
/** /**
* @base: base IO address of the falcon performing secure boot * @wpr_set: whether the WPR region is currently set
* @irq_mask: IRQ mask of the falcon performing secure boot
* @enable_mask: enable mask of the falcon performing secure boot
*/ */
struct nvkm_secboot { struct nvkm_secboot {
const struct nvkm_secboot_func *func; const struct nvkm_secboot_func *func;
struct nvkm_acr *acr;
struct nvkm_subdev subdev; struct nvkm_subdev subdev;
struct nvkm_falcon *boot_falcon;
enum nvkm_devidx devidx; u64 wpr_addr;
u32 base; u32 wpr_size;
bool wpr_set;
}; };
#define nvkm_secboot(p) container_of((p), struct nvkm_secboot, subdev) #define nvkm_secboot(p) container_of((p), struct nvkm_secboot, subdev)
bool nvkm_secboot_is_managed(struct nvkm_secboot *, enum nvkm_secboot_falcon); bool nvkm_secboot_is_managed(struct nvkm_secboot *, enum nvkm_secboot_falcon);
int nvkm_secboot_reset(struct nvkm_secboot *, u32 falcon); int nvkm_secboot_reset(struct nvkm_secboot *, enum nvkm_secboot_falcon);
int nvkm_secboot_start(struct nvkm_secboot *, u32 falcon);
int gm200_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **); int gm200_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **);
int gm20b_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **); int gm20b_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **);
......
...@@ -48,10 +48,8 @@ void nvkm_timer_alarm_cancel(struct nvkm_timer *, struct nvkm_alarm *); ...@@ -48,10 +48,8 @@ void nvkm_timer_alarm_cancel(struct nvkm_timer *, struct nvkm_alarm *);
} while (_taken = nvkm_timer_read(_tmr) - _time0, _taken < _nsecs); \ } while (_taken = nvkm_timer_read(_tmr) - _time0, _taken < _nsecs); \
\ \
if (_taken >= _nsecs) { \ if (_taken >= _nsecs) { \
if (_warn) { \ if (_warn) \
dev_warn(_device->dev, "timeout at %s:%d/%s()!\n", \ dev_WARN(_device->dev, "timeout\n"); \
__FILE__, __LINE__, __func__); \
} \
_taken = -ETIMEDOUT; \ _taken = -ETIMEDOUT; \
} \ } \
_taken; \ _taken; \
......
...@@ -11,6 +11,7 @@ struct nvkm_top { ...@@ -11,6 +11,7 @@ struct nvkm_top {
u32 nvkm_top_reset(struct nvkm_device *, enum nvkm_devidx); u32 nvkm_top_reset(struct nvkm_device *, enum nvkm_devidx);
u32 nvkm_top_intr(struct nvkm_device *, u32 intr, u64 *subdevs); u32 nvkm_top_intr(struct nvkm_device *, u32 intr, u64 *subdevs);
u32 nvkm_top_intr_mask(struct nvkm_device *, enum nvkm_devidx); u32 nvkm_top_intr_mask(struct nvkm_device *, enum nvkm_devidx);
int nvkm_top_fault_id(struct nvkm_device *, enum nvkm_devidx);
enum nvkm_devidx nvkm_top_fault(struct nvkm_device *, int fault); enum nvkm_devidx nvkm_top_fault(struct nvkm_device *, int fault);
enum nvkm_devidx nvkm_top_engine(struct nvkm_device *, int, int *runl, int *engn); enum nvkm_devidx nvkm_top_engine(struct nvkm_device *, int, int *runl, int *engn);
......
...@@ -87,7 +87,7 @@ nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) ...@@ -87,7 +87,7 @@ nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
s32 s32
nouveau_abi16_swclass(struct nouveau_drm *drm) nouveau_abi16_swclass(struct nouveau_drm *drm)
{ {
switch (drm->device.info.family) { switch (drm->client.device.info.family) {
case NV_DEVICE_INFO_V0_TNT: case NV_DEVICE_INFO_V0_TNT:
return NVIF_CLASS_SW_NV04; return NVIF_CLASS_SW_NV04;
case NV_DEVICE_INFO_V0_CELSIUS: case NV_DEVICE_INFO_V0_CELSIUS:
...@@ -175,7 +175,7 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) ...@@ -175,7 +175,7 @@ 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->device; struct nvif_device *device = &drm->client.device;
struct nvkm_gr *gr = nvxx_gr(device); struct nvkm_gr *gr = nvxx_gr(device);
struct drm_nouveau_getparam *getparam = data; struct drm_nouveau_getparam *getparam = data;
...@@ -321,7 +321,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) ...@@ -321,7 +321,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
} }
/* Named memory object area */ /* Named memory object area */
ret = nouveau_gem_new(dev, PAGE_SIZE, 0, NOUVEAU_GEM_DOMAIN_GART, ret = nouveau_gem_new(cli, PAGE_SIZE, 0, NOUVEAU_GEM_DOMAIN_GART,
0, 0, &chan->ntfy); 0, 0, &chan->ntfy);
if (ret == 0) if (ret == 0)
ret = nouveau_bo_pin(chan->ntfy, TTM_PL_FLAG_TT, false); ret = nouveau_bo_pin(chan->ntfy, TTM_PL_FLAG_TT, false);
......
...@@ -65,7 +65,7 @@ static int ...@@ -65,7 +65,7 @@ static int
nv40_get_intensity(struct backlight_device *bd) nv40_get_intensity(struct backlight_device *bd)
{ {
struct nouveau_drm *drm = bl_get_data(bd); struct nouveau_drm *drm = bl_get_data(bd);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int val = (nvif_rd32(device, NV40_PMC_BACKLIGHT) & int val = (nvif_rd32(device, NV40_PMC_BACKLIGHT) &
NV40_PMC_BACKLIGHT_MASK) >> 16; NV40_PMC_BACKLIGHT_MASK) >> 16;
...@@ -76,7 +76,7 @@ static int ...@@ -76,7 +76,7 @@ static int
nv40_set_intensity(struct backlight_device *bd) nv40_set_intensity(struct backlight_device *bd)
{ {
struct nouveau_drm *drm = bl_get_data(bd); struct nouveau_drm *drm = bl_get_data(bd);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int val = bd->props.brightness; int val = bd->props.brightness;
int reg = nvif_rd32(device, NV40_PMC_BACKLIGHT); int reg = nvif_rd32(device, NV40_PMC_BACKLIGHT);
...@@ -96,7 +96,7 @@ static int ...@@ -96,7 +96,7 @@ static int
nv40_backlight_init(struct drm_connector *connector) nv40_backlight_init(struct drm_connector *connector)
{ {
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
struct backlight_properties props; struct backlight_properties props;
struct backlight_device *bd; struct backlight_device *bd;
struct backlight_connector bl_connector; struct backlight_connector bl_connector;
...@@ -133,7 +133,7 @@ nv50_get_intensity(struct backlight_device *bd) ...@@ -133,7 +133,7 @@ nv50_get_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div = 1025; u32 div = 1025;
u32 val; u32 val;
...@@ -148,7 +148,7 @@ nv50_set_intensity(struct backlight_device *bd) ...@@ -148,7 +148,7 @@ nv50_set_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div = 1025; u32 div = 1025;
u32 val = (bd->props.brightness * div) / 100; u32 val = (bd->props.brightness * div) / 100;
...@@ -169,7 +169,7 @@ nva3_get_intensity(struct backlight_device *bd) ...@@ -169,7 +169,7 @@ nva3_get_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div, val; u32 div, val;
...@@ -187,7 +187,7 @@ nva3_set_intensity(struct backlight_device *bd) ...@@ -187,7 +187,7 @@ nva3_set_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div, val; u32 div, val;
...@@ -213,7 +213,7 @@ static int ...@@ -213,7 +213,7 @@ static int
nv50_backlight_init(struct drm_connector *connector) nv50_backlight_init(struct drm_connector *connector)
{ {
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
struct nouveau_encoder *nv_encoder; struct nouveau_encoder *nv_encoder;
struct backlight_properties props; struct backlight_properties props;
struct backlight_device *bd; struct backlight_device *bd;
...@@ -231,9 +231,9 @@ nv50_backlight_init(struct drm_connector *connector) ...@@ -231,9 +231,9 @@ nv50_backlight_init(struct drm_connector *connector)
if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or)))
return 0; return 0;
if (drm->device.info.chipset <= 0xa0 || if (drm->client.device.info.chipset <= 0xa0 ||
drm->device.info.chipset == 0xaa || drm->client.device.info.chipset == 0xaa ||
drm->device.info.chipset == 0xac) drm->client.device.info.chipset == 0xac)
ops = &nv50_bl_ops; ops = &nv50_bl_ops;
else else
ops = &nva3_bl_ops; ops = &nva3_bl_ops;
...@@ -265,7 +265,7 @@ int ...@@ -265,7 +265,7 @@ int
nouveau_backlight_init(struct drm_device *dev) nouveau_backlight_init(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
struct drm_connector *connector; struct drm_connector *connector;
if (apple_gmux_present()) { if (apple_gmux_present()) {
......
...@@ -215,7 +215,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head ...@@ -215,7 +215,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head
*/ */
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
struct nvbios *bios = &drm->vbios; struct nvbios *bios = &drm->vbios;
uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer]; uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer];
uint32_t sel_clk_binding, sel_clk; uint32_t sel_clk_binding, sel_clk;
...@@ -319,7 +319,7 @@ static int ...@@ -319,7 +319,7 @@ static int
get_fp_strap(struct drm_device *dev, struct nvbios *bios) get_fp_strap(struct drm_device *dev, struct nvbios *bios)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
/* /*
* The fp strap is normally dictated by the "User Strap" in * The fp strap is normally dictated by the "User Strap" in
...@@ -333,10 +333,10 @@ get_fp_strap(struct drm_device *dev, struct nvbios *bios) ...@@ -333,10 +333,10 @@ get_fp_strap(struct drm_device *dev, struct nvbios *bios)
if (bios->major_version < 5 && bios->data[0x48] & 0x4) if (bios->major_version < 5 && bios->data[0x48] & 0x4)
return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf; return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_MAXWELL) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_MAXWELL)
return nvif_rd32(device, 0x001800) & 0x0000000f; return nvif_rd32(device, 0x001800) & 0x0000000f;
else else
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 24) & 0xf; return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 24) & 0xf;
else else
return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 16) & 0xf; return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 16) & 0xf;
...@@ -638,7 +638,7 @@ int run_tmds_table(struct drm_device *dev, struct dcb_output *dcbent, int head, ...@@ -638,7 +638,7 @@ int run_tmds_table(struct drm_device *dev, struct dcb_output *dcbent, int head,
*/ */
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
struct nvbios *bios = &drm->vbios; struct nvbios *bios = &drm->vbios;
int cv = bios->chip_version; int cv = bios->chip_version;
uint16_t clktable = 0, scriptptr; uint16_t clktable = 0, scriptptr;
...@@ -1255,7 +1255,7 @@ olddcb_table(struct drm_device *dev) ...@@ -1255,7 +1255,7 @@ olddcb_table(struct drm_device *dev)
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
u8 *dcb = NULL; u8 *dcb = NULL;
if (drm->device.info.family > NV_DEVICE_INFO_V0_TNT) if (drm->client.device.info.family > NV_DEVICE_INFO_V0_TNT)
dcb = ROMPTR(dev, drm->vbios.data[0x36]); dcb = ROMPTR(dev, drm->vbios.data[0x36]);
if (!dcb) { if (!dcb) {
NV_WARN(drm, "No DCB data found in VBIOS\n"); NV_WARN(drm, "No DCB data found in VBIOS\n");
...@@ -1918,7 +1918,7 @@ static int load_nv17_hwsq_ucode_entry(struct drm_device *dev, struct nvbios *bio ...@@ -1918,7 +1918,7 @@ static int load_nv17_hwsq_ucode_entry(struct drm_device *dev, struct nvbios *bio
*/ */
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
uint8_t bytes_to_write; uint8_t bytes_to_write;
uint16_t hwsq_entry_offset; uint16_t hwsq_entry_offset;
int i; int i;
...@@ -2012,7 +2012,7 @@ uint8_t *nouveau_bios_embedded_edid(struct drm_device *dev) ...@@ -2012,7 +2012,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->device); struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
struct nvbios *legacy = &drm->vbios; struct nvbios *legacy = &drm->vbios;
memset(legacy, 0, sizeof(struct nvbios)); memset(legacy, 0, sizeof(struct nvbios));
...@@ -2064,7 +2064,7 @@ nouveau_bios_posted(struct drm_device *dev) ...@@ -2064,7 +2064,7 @@ nouveau_bios_posted(struct drm_device *dev)
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
unsigned htotal; unsigned htotal;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
return true; return true;
htotal = NVReadVgaCrtc(dev, 0, 0x06); htotal = NVReadVgaCrtc(dev, 0, 0x06);
......
This diff is collapsed.
...@@ -26,6 +26,8 @@ struct nouveau_bo { ...@@ -26,6 +26,8 @@ struct nouveau_bo {
struct list_head vma_list; struct list_head vma_list;
unsigned page_shift; unsigned page_shift;
struct nouveau_cli *cli;
u32 tile_mode; u32 tile_mode;
u32 tile_flags; u32 tile_flags;
struct nouveau_drm_tile *tile; struct nouveau_drm_tile *tile;
...@@ -69,7 +71,7 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) ...@@ -69,7 +71,7 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
extern struct ttm_bo_driver nouveau_bo_driver; extern struct ttm_bo_driver nouveau_bo_driver;
void nouveau_bo_move_init(struct nouveau_drm *); void nouveau_bo_move_init(struct nouveau_drm *);
int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags, int nouveau_bo_new(struct nouveau_cli *, u64 size, int align, u32 flags,
u32 tile_mode, u32 tile_flags, struct sg_table *sg, u32 tile_mode, u32 tile_flags, struct sg_table *sg,
struct reservation_object *robj, struct reservation_object *robj,
struct nouveau_bo **); struct nouveau_bo **);
......
...@@ -45,10 +45,20 @@ MODULE_PARM_DESC(vram_pushbuf, "Create DMA push buffers in VRAM"); ...@@ -45,10 +45,20 @@ MODULE_PARM_DESC(vram_pushbuf, "Create DMA push buffers in VRAM");
int nouveau_vram_pushbuf; int nouveau_vram_pushbuf;
module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400); module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
static int
nouveau_channel_killed(struct nvif_notify *ntfy)
{
struct nouveau_channel *chan = container_of(ntfy, typeof(*chan), kill);
struct nouveau_cli *cli = (void *)chan->user.client;
NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
atomic_set(&chan->killed, 1);
return NVIF_NOTIFY_DROP;
}
int int
nouveau_channel_idle(struct nouveau_channel *chan) nouveau_channel_idle(struct nouveau_channel *chan)
{ {
if (likely(chan && chan->fence)) { if (likely(chan && chan->fence && !atomic_read(&chan->killed))) {
struct nouveau_cli *cli = (void *)chan->user.client; struct nouveau_cli *cli = (void *)chan->user.client;
struct nouveau_fence *fence = NULL; struct nouveau_fence *fence = NULL;
int ret; int ret;
...@@ -78,6 +88,7 @@ nouveau_channel_del(struct nouveau_channel **pchan) ...@@ -78,6 +88,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
nvif_object_fini(&chan->nvsw); nvif_object_fini(&chan->nvsw);
nvif_object_fini(&chan->gart); nvif_object_fini(&chan->gart);
nvif_object_fini(&chan->vram); nvif_object_fini(&chan->vram);
nvif_notify_fini(&chan->kill);
nvif_object_fini(&chan->user); nvif_object_fini(&chan->user);
nvif_object_fini(&chan->push.ctxdma); nvif_object_fini(&chan->push.ctxdma);
nouveau_bo_vma_del(chan->push.buffer, &chan->push.vma); nouveau_bo_vma_del(chan->push.buffer, &chan->push.vma);
...@@ -107,13 +118,14 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, ...@@ -107,13 +118,14 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
chan->device = device; chan->device = device;
chan->drm = drm; chan->drm = drm;
atomic_set(&chan->killed, 0);
/* allocate memory for dma push buffer */ /* allocate memory for dma push buffer */
target = TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED; target = TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED;
if (nouveau_vram_pushbuf) if (nouveau_vram_pushbuf)
target = TTM_PL_FLAG_VRAM; target = TTM_PL_FLAG_VRAM;
ret = nouveau_bo_new(drm->dev, size, 0, target, 0, 0, NULL, NULL, ret = nouveau_bo_new(cli, size, 0, target, 0, 0, NULL, NULL,
&chan->push.buffer); &chan->push.buffer);
if (ret == 0) { if (ret == 0) {
ret = nouveau_bo_pin(chan->push.buffer, target, false); ret = nouveau_bo_pin(chan->push.buffer, target, false);
...@@ -301,12 +313,26 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart) ...@@ -301,12 +313,26 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
{ {
struct nvif_device *device = chan->device; struct nvif_device *device = chan->device;
struct nouveau_cli *cli = (void *)chan->user.client; struct nouveau_cli *cli = (void *)chan->user.client;
struct nouveau_drm *drm = chan->drm;
struct nvkm_mmu *mmu = nvxx_mmu(device); struct nvkm_mmu *mmu = nvxx_mmu(device);
struct nv_dma_v0 args = {}; struct nv_dma_v0 args = {};
int ret, i; int ret, i;
nvif_object_map(&chan->user); nvif_object_map(&chan->user);
if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO) {
ret = nvif_notify_init(&chan->user, nouveau_channel_killed,
true, NV906F_V0_NTFY_KILLED,
NULL, 0, 0, &chan->kill);
if (ret == 0)
ret = nvif_notify_get(&chan->kill);
if (ret) {
NV_ERROR(drm, "Failed to request channel kill "
"notification: %d\n", ret);
return ret;
}
}
/* allocate dma objects to cover all allowed vram, and gart */ /* allocate dma objects to cover all allowed vram, and gart */
if (device->info.family < NV_DEVICE_INFO_V0_FERMI) { if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
......
#ifndef __NOUVEAU_CHAN_H__ #ifndef __NOUVEAU_CHAN_H__
#define __NOUVEAU_CHAN_H__ #define __NOUVEAU_CHAN_H__
#include <nvif/object.h> #include <nvif/object.h>
#include <nvif/notify.h>
struct nvif_device; struct nvif_device;
struct nouveau_channel { struct nouveau_channel {
...@@ -38,6 +38,9 @@ struct nouveau_channel { ...@@ -38,6 +38,9 @@ struct nouveau_channel {
u32 user_put; u32 user_put;
struct nvif_object user; struct nvif_object user;
struct nvif_notify kill;
atomic_t killed;
}; };
......
...@@ -419,7 +419,7 @@ nouveau_connector_ddc_detect(struct drm_connector *connector) ...@@ -419,7 +419,7 @@ nouveau_connector_ddc_detect(struct drm_connector *connector)
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_connector *nv_connector = nouveau_connector(connector);
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_gpio *gpio = nvxx_gpio(&drm->device); struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
struct nouveau_encoder *nv_encoder; struct nouveau_encoder *nv_encoder;
struct drm_encoder *encoder; struct drm_encoder *encoder;
int i, panel = -ENODEV; int i, panel = -ENODEV;
...@@ -521,7 +521,7 @@ nouveau_connector_set_encoder(struct drm_connector *connector, ...@@ -521,7 +521,7 @@ nouveau_connector_set_encoder(struct drm_connector *connector,
return; return;
nv_connector->detected_encoder = nv_encoder; nv_connector->detected_encoder = nv_encoder;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
connector->interlace_allowed = true; connector->interlace_allowed = true;
connector->doublescan_allowed = true; connector->doublescan_allowed = true;
} else } else
...@@ -531,8 +531,8 @@ nouveau_connector_set_encoder(struct drm_connector *connector, ...@@ -531,8 +531,8 @@ nouveau_connector_set_encoder(struct drm_connector *connector,
connector->interlace_allowed = false; connector->interlace_allowed = false;
} else { } else {
connector->doublescan_allowed = true; connector->doublescan_allowed = true;
if (drm->device.info.family == NV_DEVICE_INFO_V0_KELVIN || if (drm->client.device.info.family == NV_DEVICE_INFO_V0_KELVIN ||
(drm->device.info.family == NV_DEVICE_INFO_V0_CELSIUS && (drm->client.device.info.family == NV_DEVICE_INFO_V0_CELSIUS &&
(dev->pdev->device & 0x0ff0) != 0x0100 && (dev->pdev->device & 0x0ff0) != 0x0100 &&
(dev->pdev->device & 0x0ff0) != 0x0150)) (dev->pdev->device & 0x0ff0) != 0x0150))
/* HW is broken */ /* HW is broken */
...@@ -984,17 +984,17 @@ get_tmds_link_bandwidth(struct drm_connector *connector, bool hdmi) ...@@ -984,17 +984,17 @@ get_tmds_link_bandwidth(struct drm_connector *connector, bool hdmi)
/* Note: these limits are conservative, some Fermi's /* Note: these limits are conservative, some Fermi's
* can do 297 MHz. Unclear how this can be determined. * can do 297 MHz. Unclear how this can be determined.
*/ */
if (drm->device.info.family >= NV_DEVICE_INFO_V0_KEPLER) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_KEPLER)
return 297000; return 297000;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_FERMI) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
return 225000; return 225000;
} }
if (dcb->location != DCB_LOC_ON_CHIP || if (dcb->location != DCB_LOC_ON_CHIP ||
drm->device.info.chipset >= 0x46) drm->client.device.info.chipset >= 0x46)
return 165000; return 165000;
else if (drm->device.info.chipset >= 0x40) else if (drm->client.device.info.chipset >= 0x40)
return 155000; return 155000;
else if (drm->device.info.chipset >= 0x18) else if (drm->client.device.info.chipset >= 0x18)
return 135000; return 135000;
else else
return 112000; return 112000;
...@@ -1041,7 +1041,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector, ...@@ -1041,7 +1041,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
clock = clock * (connector->display_info.bpc * 3) / 10; clock = clock * (connector->display_info.bpc * 3) / 10;
break; break;
default: default:
BUG_ON(1); BUG();
return MODE_BAD; return MODE_BAD;
} }
......
...@@ -259,8 +259,9 @@ nouveau_debugfs_init(struct nouveau_drm *drm) ...@@ -259,8 +259,9 @@ nouveau_debugfs_init(struct nouveau_drm *drm)
if (!drm->debugfs) if (!drm->debugfs)
return -ENOMEM; return -ENOMEM;
ret = nvif_object_init(&drm->device.object, 0, NVIF_CLASS_CONTROL, ret = nvif_object_init(&drm->client.device.object, 0,
NULL, 0, &drm->debugfs->ctrl); NVIF_CLASS_CONTROL, NULL, 0,
&drm->debugfs->ctrl);
if (ret) if (ret)
return ret; return ret;
......
...@@ -495,7 +495,7 @@ int ...@@ -495,7 +495,7 @@ int
nouveau_display_create(struct drm_device *dev) nouveau_display_create(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_device *device = nvxx_device(&drm->device); struct nvkm_device *device = nvxx_device(&drm->client.device);
struct nouveau_display *disp; struct nouveau_display *disp;
int ret; int ret;
...@@ -512,15 +512,15 @@ nouveau_display_create(struct drm_device *dev) ...@@ -512,15 +512,15 @@ nouveau_display_create(struct drm_device *dev)
dev->mode_config.min_width = 0; dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0; dev->mode_config.min_height = 0;
if (drm->device.info.family < NV_DEVICE_INFO_V0_CELSIUS) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_CELSIUS) {
dev->mode_config.max_width = 2048; dev->mode_config.max_width = 2048;
dev->mode_config.max_height = 2048; dev->mode_config.max_height = 2048;
} else } else
if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
dev->mode_config.max_width = 4096; dev->mode_config.max_width = 4096;
dev->mode_config.max_height = 4096; dev->mode_config.max_height = 4096;
} else } else
if (drm->device.info.family < NV_DEVICE_INFO_V0_FERMI) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI) {
dev->mode_config.max_width = 8192; dev->mode_config.max_width = 8192;
dev->mode_config.max_height = 8192; dev->mode_config.max_height = 8192;
} else { } else {
...@@ -531,7 +531,7 @@ nouveau_display_create(struct drm_device *dev) ...@@ -531,7 +531,7 @@ nouveau_display_create(struct drm_device *dev)
dev->mode_config.preferred_depth = 24; dev->mode_config.preferred_depth = 24;
dev->mode_config.prefer_shadow = 1; dev->mode_config.prefer_shadow = 1;
if (drm->device.info.chipset < 0x11) if (drm->client.device.info.chipset < 0x11)
dev->mode_config.async_page_flip = false; dev->mode_config.async_page_flip = false;
else else
dev->mode_config.async_page_flip = true; dev->mode_config.async_page_flip = true;
...@@ -558,7 +558,7 @@ nouveau_display_create(struct drm_device *dev) ...@@ -558,7 +558,7 @@ nouveau_display_create(struct drm_device *dev)
int i; int i;
for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) { for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
ret = nvif_object_init(&drm->device.object, 0, ret = nvif_object_init(&drm->client.device.object, 0,
oclass[i], NULL, 0, &disp->disp); oclass[i], NULL, 0, &disp->disp);
} }
...@@ -1057,6 +1057,7 @@ int ...@@ -1057,6 +1057,7 @@ int
nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev, nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
{ {
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct nouveau_bo *bo; struct nouveau_bo *bo;
uint32_t domain; uint32_t domain;
int ret; int ret;
...@@ -1066,12 +1067,12 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev, ...@@ -1066,12 +1067,12 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
args->size = roundup(args->size, PAGE_SIZE); args->size = roundup(args->size, PAGE_SIZE);
/* Use VRAM if there is any ; otherwise fallback to system memory */ /* Use VRAM if there is any ; otherwise fallback to system memory */
if (nouveau_drm(dev)->device.info.ram_size != 0) if (nouveau_drm(dev)->client.device.info.ram_size != 0)
domain = NOUVEAU_GEM_DOMAIN_VRAM; domain = NOUVEAU_GEM_DOMAIN_VRAM;
else else
domain = NOUVEAU_GEM_DOMAIN_GART; domain = NOUVEAU_GEM_DOMAIN_GART;
ret = nouveau_gem_new(dev, args->size, 0, domain, 0, 0, &bo); ret = nouveau_gem_new(cli, args->size, 0, domain, 0, 0, &bo);
if (ret) if (ret)
return ret; return ret;
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <core/pci.h> #include <core/pci.h>
#include <core/tegra.h> #include <core/tegra.h>
#include <nvif/driver.h>
#include <nvif/class.h> #include <nvif/class.h>
#include <nvif/cl0002.h> #include <nvif/cl0002.h>
#include <nvif/cla06f.h> #include <nvif/cla06f.h>
...@@ -109,35 +111,53 @@ nouveau_name(struct drm_device *dev) ...@@ -109,35 +111,53 @@ nouveau_name(struct drm_device *dev)
return nouveau_platform_name(dev->platformdev); return nouveau_platform_name(dev->platformdev);
} }
static void
nouveau_cli_fini(struct nouveau_cli *cli)
{
nvkm_vm_ref(NULL, &nvxx_client(&cli->base)->vm, NULL);
usif_client_fini(cli);
nvif_device_fini(&cli->device);
nvif_client_fini(&cli->base);
}
static int static int
nouveau_cli_create(struct drm_device *dev, const char *sname, nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
int size, void **pcli) struct nouveau_cli *cli)
{ {
struct nouveau_cli *cli = *pcli = kzalloc(size, GFP_KERNEL); u64 device = nouveau_name(drm->dev);
int ret; int ret;
if (cli) {
snprintf(cli->name, sizeof(cli->name), "%s", sname);
cli->dev = dev;
ret = nvif_client_init(NULL, cli->name, nouveau_name(dev), snprintf(cli->name, sizeof(cli->name), "%s", sname);
nouveau_config, nouveau_debug, cli->dev = drm->dev;
mutex_init(&cli->mutex);
usif_client_init(cli);
if (cli == &drm->client) {
ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
cli->name, device, &cli->base);
} else {
ret = nvif_client_init(&drm->client.base, cli->name, device,
&cli->base); &cli->base);
if (ret == 0) {
mutex_init(&cli->mutex);
usif_client_init(cli);
}
return ret;
} }
return -ENOMEM; if (ret) {
} NV_ERROR(drm, "Client allocation failed: %d\n", ret);
goto done;
}
static void ret = nvif_device_init(&cli->base.object, 0, NV_DEVICE,
nouveau_cli_destroy(struct nouveau_cli *cli) &(struct nv_device_v0) {
{ .device = ~0,
nvkm_vm_ref(NULL, &nvxx_client(&cli->base)->vm, NULL); }, sizeof(struct nv_device_v0),
nvif_client_fini(&cli->base); &cli->device);
usif_client_fini(cli); if (ret) {
kfree(cli); NV_ERROR(drm, "Device allocation failed: %d\n", ret);
goto done;
}
done:
if (ret)
nouveau_cli_fini(cli);
return ret;
} }
static void static void
...@@ -161,7 +181,7 @@ nouveau_accel_fini(struct nouveau_drm *drm) ...@@ -161,7 +181,7 @@ nouveau_accel_fini(struct nouveau_drm *drm)
static void static void
nouveau_accel_init(struct nouveau_drm *drm) nouveau_accel_init(struct nouveau_drm *drm)
{ {
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
struct nvif_sclass *sclass; struct nvif_sclass *sclass;
u32 arg0, arg1; u32 arg0, arg1;
int ret, i, n; int ret, i, n;
...@@ -215,7 +235,7 @@ nouveau_accel_init(struct nouveau_drm *drm) ...@@ -215,7 +235,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
} }
if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) { if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
ret = nouveau_channel_new(drm, &drm->device, ret = nouveau_channel_new(drm, &drm->client.device,
NVA06F_V0_ENGINE_CE0 | NVA06F_V0_ENGINE_CE0 |
NVA06F_V0_ENGINE_CE1, NVA06F_V0_ENGINE_CE1,
0, &drm->cechan); 0, &drm->cechan);
...@@ -228,7 +248,7 @@ nouveau_accel_init(struct nouveau_drm *drm) ...@@ -228,7 +248,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
if (device->info.chipset >= 0xa3 && if (device->info.chipset >= 0xa3 &&
device->info.chipset != 0xaa && device->info.chipset != 0xaa &&
device->info.chipset != 0xac) { device->info.chipset != 0xac) {
ret = nouveau_channel_new(drm, &drm->device, ret = nouveau_channel_new(drm, &drm->client.device,
NvDmaFB, NvDmaTT, &drm->cechan); NvDmaFB, NvDmaTT, &drm->cechan);
if (ret) if (ret)
NV_ERROR(drm, "failed to create ce channel, %d\n", ret); NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
...@@ -240,7 +260,8 @@ nouveau_accel_init(struct nouveau_drm *drm) ...@@ -240,7 +260,8 @@ nouveau_accel_init(struct nouveau_drm *drm)
arg1 = NvDmaTT; arg1 = NvDmaTT;
} }
ret = nouveau_channel_new(drm, &drm->device, arg0, arg1, &drm->channel); ret = nouveau_channel_new(drm, &drm->client.device,
arg0, arg1, &drm->channel);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to create kernel channel, %d\n", ret); NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
nouveau_accel_fini(drm); nouveau_accel_fini(drm);
...@@ -280,8 +301,8 @@ nouveau_accel_init(struct nouveau_drm *drm) ...@@ -280,8 +301,8 @@ nouveau_accel_init(struct nouveau_drm *drm)
} }
if (device->info.family < NV_DEVICE_INFO_V0_FERMI) { if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
ret = nvkm_gpuobj_new(nvxx_device(&drm->device), 32, 0, false, ret = nvkm_gpuobj_new(nvxx_device(&drm->client.device), 32, 0,
NULL, &drm->notify); false, NULL, &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_fini(drm); nouveau_accel_fini(drm);
...@@ -407,12 +428,17 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -407,12 +428,17 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
struct nouveau_drm *drm; struct nouveau_drm *drm;
int ret; int ret;
ret = nouveau_cli_create(dev, "DRM", sizeof(*drm), (void **)&drm); if (!(drm = kzalloc(sizeof(*drm), GFP_KERNEL)))
return -ENOMEM;
dev->dev_private = drm;
drm->dev = dev;
ret = nouveau_cli_init(drm, "DRM", &drm->client);
if (ret) if (ret)
return ret; return ret;
dev->dev_private = drm; dev->irq_enabled = true;
drm->dev = dev;
nvxx_client(&drm->client.base)->debug = nvxx_client(&drm->client.base)->debug =
nvkm_dbgopt(nouveau_debug, "DRM"); nvkm_dbgopt(nouveau_debug, "DRM");
...@@ -421,33 +447,24 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -421,33 +447,24 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
nouveau_get_hdmi_dev(drm); nouveau_get_hdmi_dev(drm);
ret = nvif_device_init(&drm->client.base.object, 0, NV_DEVICE,
&(struct nv_device_v0) {
.device = ~0,
}, sizeof(struct nv_device_v0),
&drm->device);
if (ret)
goto fail_device;
dev->irq_enabled = true;
/* workaround an odd issue on nvc1 by disabling the device's /* workaround an odd issue on nvc1 by disabling the device's
* nosnoop capability. hopefully won't cause issues until a * nosnoop capability. hopefully won't cause issues until a
* better fix is found - assuming there is one... * better fix is found - assuming there is one...
*/ */
if (drm->device.info.chipset == 0xc1) if (drm->client.device.info.chipset == 0xc1)
nvif_mask(&drm->device.object, 0x00088080, 0x00000800, 0x00000000); nvif_mask(&drm->client.device.object, 0x00088080, 0x00000800, 0x00000000);
nouveau_vga_init(drm); nouveau_vga_init(drm);
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
if (!nvxx_device(&drm->device)->mmu) { if (!nvxx_device(&drm->client.device)->mmu) {
ret = -ENOSYS; ret = -ENOSYS;
goto fail_device; goto fail_device;
} }
ret = nvkm_vm_new(nvxx_device(&drm->device), 0, (1ULL << 40), ret = nvkm_vm_new(nvxx_device(&drm->client.device),
0x1000, NULL, &drm->client.vm); 0, (1ULL << 40), 0x1000, NULL,
&drm->client.vm);
if (ret) if (ret)
goto fail_device; goto fail_device;
...@@ -497,8 +514,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -497,8 +514,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
fail_ttm: fail_ttm:
nouveau_vga_fini(drm); nouveau_vga_fini(drm);
fail_device: fail_device:
nvif_device_fini(&drm->device); nouveau_cli_fini(&drm->client);
nouveau_cli_destroy(&drm->client); kfree(drm);
return ret; return ret;
} }
...@@ -527,10 +544,10 @@ nouveau_drm_unload(struct drm_device *dev) ...@@ -527,10 +544,10 @@ nouveau_drm_unload(struct drm_device *dev)
nouveau_ttm_fini(drm); nouveau_ttm_fini(drm);
nouveau_vga_fini(drm); nouveau_vga_fini(drm);
nvif_device_fini(&drm->device);
if (drm->hdmi_device) if (drm->hdmi_device)
pci_dev_put(drm->hdmi_device); pci_dev_put(drm->hdmi_device);
nouveau_cli_destroy(&drm->client); nouveau_cli_fini(&drm->client);
kfree(drm);
} }
void void
...@@ -560,7 +577,6 @@ static int ...@@ -560,7 +577,6 @@ static int
nouveau_do_suspend(struct drm_device *dev, bool runtime) nouveau_do_suspend(struct drm_device *dev, bool runtime)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_cli *cli;
int ret; int ret;
nouveau_led_suspend(dev); nouveau_led_suspend(dev);
...@@ -590,7 +606,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) ...@@ -590,7 +606,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
goto fail_display; goto fail_display;
} }
NV_INFO(drm, "suspending client object trees...\n"); NV_INFO(drm, "suspending fence...\n");
if (drm->fence && nouveau_fence(drm)->suspend) { if (drm->fence && nouveau_fence(drm)->suspend) {
if (!nouveau_fence(drm)->suspend(drm)) { if (!nouveau_fence(drm)->suspend(drm)) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -598,13 +614,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) ...@@ -598,13 +614,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
} }
} }
list_for_each_entry(cli, &drm->clients, head) { NV_INFO(drm, "suspending object tree...\n");
ret = nvif_client_suspend(&cli->base);
if (ret)
goto fail_client;
}
NV_INFO(drm, "suspending kernel object tree...\n");
ret = nvif_client_suspend(&drm->client.base); ret = nvif_client_suspend(&drm->client.base);
if (ret) if (ret)
goto fail_client; goto fail_client;
...@@ -612,10 +622,6 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) ...@@ -612,10 +622,6 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime)
return 0; return 0;
fail_client: fail_client:
list_for_each_entry_continue_reverse(cli, &drm->clients, head) {
nvif_client_resume(&cli->base);
}
if (drm->fence && nouveau_fence(drm)->resume) if (drm->fence && nouveau_fence(drm)->resume)
nouveau_fence(drm)->resume(drm); nouveau_fence(drm)->resume(drm);
...@@ -631,19 +637,14 @@ static int ...@@ -631,19 +637,14 @@ static int
nouveau_do_resume(struct drm_device *dev, bool runtime) nouveau_do_resume(struct drm_device *dev, bool runtime)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_cli *cli;
NV_INFO(drm, "resuming kernel object tree...\n"); NV_INFO(drm, "resuming object tree...\n");
nvif_client_resume(&drm->client.base); nvif_client_resume(&drm->client.base);
NV_INFO(drm, "resuming client object trees...\n"); NV_INFO(drm, "resuming fence...\n");
if (drm->fence && nouveau_fence(drm)->resume) if (drm->fence && nouveau_fence(drm)->resume)
nouveau_fence(drm)->resume(drm); nouveau_fence(drm)->resume(drm);
list_for_each_entry(cli, &drm->clients, head) {
nvif_client_resume(&cli->base);
}
nouveau_run_vbios_init(dev); nouveau_run_vbios_init(dev);
if (dev->mode_config.num_crtc) { if (dev->mode_config.num_crtc) {
...@@ -758,7 +759,7 @@ nouveau_pmops_runtime_resume(struct device *dev) ...@@ -758,7 +759,7 @@ nouveau_pmops_runtime_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
struct nvif_device *device = &nouveau_drm(drm_dev)->device; struct nvif_device *device = &nouveau_drm(drm_dev)->client.device;
int ret; int ret;
if (nouveau_runtime_pm == 0) if (nouveau_runtime_pm == 0)
...@@ -841,20 +842,20 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) ...@@ -841,20 +842,20 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
get_task_comm(tmpname, current); get_task_comm(tmpname, current);
snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid)); snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
ret = nouveau_cli_create(dev, name, sizeof(*cli), (void **)&cli); if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL)))
return ret;
ret = nouveau_cli_init(drm, name, cli);
if (ret) if (ret)
goto out_suspend; goto done;
cli->base.super = false; cli->base.super = false;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
ret = nvkm_vm_new(nvxx_device(&drm->device), 0, (1ULL << 40), ret = nvkm_vm_new(nvxx_device(&drm->client.device), 0,
0x1000, NULL, &cli->vm); (1ULL << 40), 0x1000, NULL, &cli->vm);
if (ret) { if (ret)
nouveau_cli_destroy(cli); goto done;
goto out_suspend;
}
nvxx_client(&cli->base)->vm = cli->vm; nvxx_client(&cli->base)->vm = cli->vm;
} }
...@@ -865,10 +866,14 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) ...@@ -865,10 +866,14 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
list_add(&cli->head, &drm->clients); list_add(&cli->head, &drm->clients);
mutex_unlock(&drm->client.mutex); mutex_unlock(&drm->client.mutex);
out_suspend: done:
if (ret && cli) {
nouveau_cli_fini(cli);
kfree(cli);
}
pm_runtime_mark_last_busy(dev->dev); pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev); pm_runtime_put_autosuspend(dev->dev);
return ret; return ret;
} }
...@@ -895,7 +900,8 @@ static void ...@@ -895,7 +900,8 @@ static void
nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv) nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
{ {
struct nouveau_cli *cli = nouveau_cli(fpriv); struct nouveau_cli *cli = nouveau_cli(fpriv);
nouveau_cli_destroy(cli); nouveau_cli_fini(cli);
kfree(cli);
pm_runtime_mark_last_busy(dev->dev); pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev); pm_runtime_put_autosuspend(dev->dev);
} }
......
...@@ -86,14 +86,17 @@ enum nouveau_drm_handle { ...@@ -86,14 +86,17 @@ enum nouveau_drm_handle {
struct nouveau_cli { struct nouveau_cli {
struct nvif_client base; struct nvif_client base;
struct drm_device *dev;
struct mutex mutex;
struct nvif_device device;
struct nvkm_vm *vm; /*XXX*/ struct nvkm_vm *vm; /*XXX*/
struct list_head head; struct list_head head;
struct mutex mutex;
void *abi16; void *abi16;
struct list_head objects; struct list_head objects;
struct list_head notifys; struct list_head notifys;
char name[32]; char name[32];
struct drm_device *dev;
}; };
static inline struct nouveau_cli * static inline struct nouveau_cli *
...@@ -111,7 +114,6 @@ struct nouveau_drm { ...@@ -111,7 +114,6 @@ struct nouveau_drm {
struct nouveau_cli client; struct nouveau_cli client;
struct drm_device *dev; struct drm_device *dev;
struct nvif_device device;
struct list_head clients; struct list_head clients;
struct { struct {
......
...@@ -60,7 +60,7 @@ nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect) ...@@ -60,7 +60,7 @@ nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev); struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
int ret; int ret;
if (info->state != FBINFO_STATE_RUNNING) if (info->state != FBINFO_STATE_RUNNING)
...@@ -92,7 +92,7 @@ nouveau_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *image) ...@@ -92,7 +92,7 @@ nouveau_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *image)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev); struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
int ret; int ret;
if (info->state != FBINFO_STATE_RUNNING) if (info->state != FBINFO_STATE_RUNNING)
...@@ -124,7 +124,7 @@ nouveau_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -124,7 +124,7 @@ nouveau_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev); struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
int ret; int ret;
if (info->state != FBINFO_STATE_RUNNING) if (info->state != FBINFO_STATE_RUNNING)
...@@ -266,10 +266,10 @@ nouveau_fbcon_accel_init(struct drm_device *dev) ...@@ -266,10 +266,10 @@ nouveau_fbcon_accel_init(struct drm_device *dev)
struct fb_info *info = fbcon->helper.fbdev; struct fb_info *info = fbcon->helper.fbdev;
int ret; int ret;
if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA)
ret = nv04_fbcon_accel_init(info); ret = nv04_fbcon_accel_init(info);
else else
if (drm->device.info.family < NV_DEVICE_INFO_V0_FERMI) if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI)
ret = nv50_fbcon_accel_init(info); ret = nv50_fbcon_accel_init(info);
else else
ret = nvc0_fbcon_accel_init(info); ret = nvc0_fbcon_accel_init(info);
...@@ -324,7 +324,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -324,7 +324,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
container_of(helper, struct nouveau_fbdev, helper); container_of(helper, struct nouveau_fbdev, helper);
struct drm_device *dev = fbcon->helper.dev; struct drm_device *dev = fbcon->helper.dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
struct fb_info *info; struct fb_info *info;
struct nouveau_framebuffer *fb; struct nouveau_framebuffer *fb;
struct nouveau_channel *chan; struct nouveau_channel *chan;
...@@ -341,8 +341,9 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -341,8 +341,9 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
sizes->surface_depth); sizes->surface_depth);
ret = nouveau_gem_new(dev, mode_cmd.pitches[0] * mode_cmd.height, ret = nouveau_gem_new(&drm->client, mode_cmd.pitches[0] *
0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0x0000, &nvbo); mode_cmd.height, 0, NOUVEAU_GEM_DOMAIN_VRAM,
0, 0x0000, &nvbo);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to allocate framebuffer\n"); NV_ERROR(drm, "failed to allocate framebuffer\n");
goto out; goto out;
...@@ -515,10 +516,10 @@ nouveau_fbcon_init(struct drm_device *dev) ...@@ -515,10 +516,10 @@ nouveau_fbcon_init(struct drm_device *dev)
if (ret) if (ret)
goto fini; goto fini;
if (drm->device.info.ram_size <= 32 * 1024 * 1024) if (drm->client.device.info.ram_size <= 32 * 1024 * 1024)
preferred_bpp = 8; preferred_bpp = 8;
else else
if (drm->device.info.ram_size <= 64 * 1024 * 1024) if (drm->client.device.info.ram_size <= 64 * 1024 * 1024)
preferred_bpp = 16; preferred_bpp = 16;
else else
preferred_bpp = 32; preferred_bpp = 32;
......
...@@ -190,7 +190,7 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha ...@@ -190,7 +190,7 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
return; return;
ret = nvif_notify_init(&chan->user, nouveau_fence_wait_uevent_handler, ret = nvif_notify_init(&chan->user, nouveau_fence_wait_uevent_handler,
false, G82_CHANNEL_DMA_V0_NTFY_UEVENT, false, NV826E_V0_NTFY_NON_STALL_INTERRUPT,
&(struct nvif_notify_uevent_req) { }, &(struct nvif_notify_uevent_req) { },
sizeof(struct nvif_notify_uevent_req), sizeof(struct nvif_notify_uevent_req),
sizeof(struct nvif_notify_uevent_rep), sizeof(struct nvif_notify_uevent_rep),
......
...@@ -175,11 +175,11 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) ...@@ -175,11 +175,11 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
} }
int int
nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain, nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,
uint32_t tile_mode, uint32_t tile_flags, uint32_t tile_mode, uint32_t tile_flags,
struct nouveau_bo **pnvbo) struct nouveau_bo **pnvbo)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(cli->dev);
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
u32 flags = 0; u32 flags = 0;
int ret; int ret;
...@@ -194,7 +194,7 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain, ...@@ -194,7 +194,7 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain,
if (domain & NOUVEAU_GEM_DOMAIN_COHERENT) if (domain & NOUVEAU_GEM_DOMAIN_COHERENT)
flags |= TTM_PL_FLAG_UNCACHED; flags |= TTM_PL_FLAG_UNCACHED;
ret = nouveau_bo_new(dev, size, align, flags, tile_mode, ret = nouveau_bo_new(cli, size, align, flags, tile_mode,
tile_flags, NULL, NULL, pnvbo); tile_flags, NULL, NULL, pnvbo);
if (ret) if (ret)
return ret; return ret;
...@@ -206,12 +206,12 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain, ...@@ -206,12 +206,12 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain,
*/ */
nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_VRAM | nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_VRAM |
NOUVEAU_GEM_DOMAIN_GART; NOUVEAU_GEM_DOMAIN_GART;
if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
nvbo->valid_domains &= domain; nvbo->valid_domains &= domain;
/* Initialize the embedded gem-object. We return a single gem-reference /* Initialize the embedded gem-object. We return a single gem-reference
* to the caller, instead of a normal nouveau_bo ttm reference. */ * to the caller, instead of a normal nouveau_bo ttm reference. */
ret = drm_gem_object_init(dev, &nvbo->gem, nvbo->bo.mem.size); ret = drm_gem_object_init(drm->dev, &nvbo->gem, nvbo->bo.mem.size);
if (ret) { if (ret) {
nouveau_bo_ref(NULL, pnvbo); nouveau_bo_ref(NULL, pnvbo);
return -ENOMEM; return -ENOMEM;
...@@ -257,7 +257,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data, ...@@ -257,7 +257,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_cli *cli = nouveau_cli(file_priv);
struct nvkm_fb *fb = nvxx_fb(&drm->device); struct nvkm_fb *fb = nvxx_fb(&drm->client.device);
struct drm_nouveau_gem_new *req = data; struct drm_nouveau_gem_new *req = data;
struct nouveau_bo *nvbo = NULL; struct nouveau_bo *nvbo = NULL;
int ret = 0; int ret = 0;
...@@ -267,7 +267,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data, ...@@ -267,7 +267,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
ret = nouveau_gem_new(dev, req->info.size, req->align, ret = nouveau_gem_new(cli, req->info.size, req->align,
req->info.domain, req->info.tile_mode, req->info.domain, req->info.tile_mode,
req->info.tile_flags, &nvbo); req->info.tile_flags, &nvbo);
if (ret) if (ret)
...@@ -496,7 +496,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli, ...@@ -496,7 +496,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
return ret; return ret;
} }
if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
if (nvbo->bo.offset == b->presumed.offset && if (nvbo->bo.offset == b->presumed.offset &&
((nvbo->bo.mem.mem_type == TTM_PL_VRAM && ((nvbo->bo.mem.mem_type == TTM_PL_VRAM &&
b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) || b->presumed.domain & NOUVEAU_GEM_DOMAIN_VRAM) ||
...@@ -767,7 +767,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, ...@@ -767,7 +767,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
push[i].length); push[i].length);
} }
} else } else
if (drm->device.info.chipset >= 0x25) { if (drm->client.device.info.chipset >= 0x25) {
ret = RING_SPACE(chan, req->nr_push * 2); ret = RING_SPACE(chan, req->nr_push * 2);
if (ret) { if (ret) {
NV_PRINTK(err, cli, "cal_space: %d\n", ret); NV_PRINTK(err, cli, "cal_space: %d\n", ret);
...@@ -840,7 +840,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, ...@@ -840,7 +840,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
req->suffix0 = 0x00000000; req->suffix0 = 0x00000000;
req->suffix1 = 0x00000000; req->suffix1 = 0x00000000;
} else } else
if (drm->device.info.chipset >= 0x25) { if (drm->client.device.info.chipset >= 0x25) {
req->suffix0 = 0x00020000; req->suffix0 = 0x00020000;
req->suffix1 = 0x00000000; req->suffix1 = 0x00000000;
} else { } else {
......
...@@ -16,7 +16,7 @@ nouveau_gem_object(struct drm_gem_object *gem) ...@@ -16,7 +16,7 @@ nouveau_gem_object(struct drm_gem_object *gem)
} }
/* nouveau_gem.c */ /* nouveau_gem.c */
extern int nouveau_gem_new(struct drm_device *, int size, int align, extern int nouveau_gem_new(struct nouveau_cli *, u64 size, int align,
uint32_t domain, uint32_t tile_mode, uint32_t domain, uint32_t tile_mode,
uint32_t tile_flags, struct nouveau_bo **); uint32_t tile_flags, struct nouveau_bo **);
extern void nouveau_gem_object_del(struct drm_gem_object *); extern void nouveau_gem_object_del(struct drm_gem_object *);
......
This diff is collapsed.
...@@ -38,7 +38,7 @@ nouveau_led_get_brightness(struct led_classdev *led) ...@@ -38,7 +38,7 @@ nouveau_led_get_brightness(struct led_classdev *led)
{ {
struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev; struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev;
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
u32 div, duty; u32 div, duty;
div = nvif_rd32(device, 0x61c880) & 0x00ffffff; div = nvif_rd32(device, 0x61c880) & 0x00ffffff;
...@@ -55,7 +55,7 @@ nouveau_led_set_brightness(struct led_classdev *led, enum led_brightness value) ...@@ -55,7 +55,7 @@ nouveau_led_set_brightness(struct led_classdev *led, enum led_brightness value)
{ {
struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev; struct drm_device *drm_dev = container_of(led, struct nouveau_led, led)->dev;
struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nouveau_drm *drm = nouveau_drm(drm_dev);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
u32 input_clk = 27e6; /* PDISPLAY.SOR[1].PWM is connected to the crystal */ u32 input_clk = 27e6; /* PDISPLAY.SOR[1].PWM is connected to the crystal */
u32 freq = 100; /* this is what nvidia uses and it should be good-enough */ u32 freq = 100; /* this is what nvidia uses and it should be good-enough */
...@@ -78,7 +78,7 @@ int ...@@ -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->device); struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device);
struct dcb_gpio_func logo_led; struct dcb_gpio_func logo_led;
int ret; int ret;
...@@ -102,6 +102,7 @@ nouveau_led_init(struct drm_device *dev) ...@@ -102,6 +102,7 @@ nouveau_led_init(struct drm_device *dev)
ret = led_classdev_register(dev->dev, &drm->led->led); ret = led_classdev_register(dev->dev, &drm->led->led);
if (ret) { if (ret) {
kfree(drm->led); kfree(drm->led);
drm->led = NULL;
return ret; return ret;
} }
......
...@@ -60,20 +60,15 @@ nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack) ...@@ -60,20 +60,15 @@ nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
static int static int
nvkm_client_resume(void *priv) nvkm_client_resume(void *priv)
{ {
return nvkm_client_init(priv); struct nvkm_client *client = priv;
return nvkm_object_init(&client->object);
} }
static int static int
nvkm_client_suspend(void *priv) nvkm_client_suspend(void *priv)
{
return nvkm_client_fini(priv, true);
}
static void
nvkm_client_driver_fini(void *priv)
{ {
struct nvkm_client *client = priv; struct nvkm_client *client = priv;
nvkm_client_del(&client); return nvkm_object_fini(&client->object, true);
} }
static int static int
...@@ -108,23 +103,14 @@ static int ...@@ -108,23 +103,14 @@ static int
nvkm_client_driver_init(const char *name, u64 device, const char *cfg, nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
const char *dbg, void **ppriv) const char *dbg, void **ppriv)
{ {
struct nvkm_client *client; return nvkm_client_new(name, device, cfg, dbg, nvkm_client_ntfy,
int ret; (struct nvkm_client **)ppriv);
ret = nvkm_client_new(name, device, cfg, dbg, &client);
*ppriv = client;
if (ret)
return ret;
client->ntfy = nvkm_client_ntfy;
return 0;
} }
const struct nvif_driver const struct nvif_driver
nvif_driver_nvkm = { nvif_driver_nvkm = {
.name = "nvkm", .name = "nvkm",
.init = nvkm_client_driver_init, .init = nvkm_client_driver_init,
.fini = nvkm_client_driver_fini,
.suspend = nvkm_client_suspend, .suspend = nvkm_client_suspend,
.resume = nvkm_client_resume, .resume = nvkm_client_resume,
.ioctl = nvkm_client_ioctl, .ioctl = nvkm_client_ioctl,
......
...@@ -60,6 +60,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, ...@@ -60,6 +60,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct dma_buf_attachment *attach,
struct sg_table *sg) struct sg_table *sg)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
struct reservation_object *robj = attach->dmabuf->resv; struct reservation_object *robj = attach->dmabuf->resv;
u32 flags = 0; u32 flags = 0;
...@@ -68,7 +69,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, ...@@ -68,7 +69,7 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev,
flags = TTM_PL_FLAG_TT; flags = TTM_PL_FLAG_TT;
ww_mutex_lock(&robj->lock, NULL); ww_mutex_lock(&robj->lock, NULL);
ret = nouveau_bo_new(dev, attach->dmabuf->size, 0, flags, 0, 0, ret = nouveau_bo_new(&drm->client, attach->dmabuf->size, 0, flags, 0, 0,
sg, robj, &nvbo); sg, robj, &nvbo);
ww_mutex_unlock(&robj->lock); ww_mutex_unlock(&robj->lock);
if (ret) if (ret)
......
...@@ -24,10 +24,10 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm) ...@@ -24,10 +24,10 @@ nouveau_sgdma_destroy(struct ttm_tt *ttm)
} }
static int static int
nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem) nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
{ {
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
struct nvkm_mem *node = mem->mm_node; struct nvkm_mem *node = reg->mm_node;
if (ttm->sg) { if (ttm->sg) {
node->sg = ttm->sg; node->sg = ttm->sg;
...@@ -36,7 +36,7 @@ nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem) ...@@ -36,7 +36,7 @@ nv04_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
node->sg = NULL; node->sg = NULL;
node->pages = nvbe->ttm.dma_address; node->pages = nvbe->ttm.dma_address;
} }
node->size = (mem->num_pages << PAGE_SHIFT) >> 12; node->size = (reg->num_pages << PAGE_SHIFT) >> 12;
nvkm_vm_map(&node->vma[0], node); nvkm_vm_map(&node->vma[0], node);
nvbe->node = node; nvbe->node = node;
...@@ -58,10 +58,10 @@ static struct ttm_backend_func nv04_sgdma_backend = { ...@@ -58,10 +58,10 @@ static struct ttm_backend_func nv04_sgdma_backend = {
}; };
static int static int
nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem) nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *reg)
{ {
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
struct nvkm_mem *node = mem->mm_node; struct nvkm_mem *node = reg->mm_node;
/* noop: bound in move_notify() */ /* noop: bound in move_notify() */
if (ttm->sg) { if (ttm->sg) {
...@@ -71,7 +71,7 @@ nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem) ...@@ -71,7 +71,7 @@ nv50_sgdma_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem)
node->sg = NULL; node->sg = NULL;
node->pages = nvbe->ttm.dma_address; node->pages = nvbe->ttm.dma_address;
} }
node->size = (mem->num_pages << PAGE_SHIFT) >> 12; node->size = (reg->num_pages << PAGE_SHIFT) >> 12;
return 0; return 0;
} }
...@@ -100,7 +100,7 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, ...@@ -100,7 +100,7 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
if (!nvbe) if (!nvbe)
return NULL; return NULL;
if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA)
nvbe->ttm.ttm.func = &nv04_sgdma_backend; nvbe->ttm.ttm.func = &nv04_sgdma_backend;
else else
nvbe->ttm.ttm.func = &nv50_sgdma_backend; nvbe->ttm.ttm.func = &nv50_sgdma_backend;
......
...@@ -36,7 +36,7 @@ static int ...@@ -36,7 +36,7 @@ static int
nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long psize) nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long psize)
{ {
struct nouveau_drm *drm = nouveau_bdev(man->bdev); struct nouveau_drm *drm = nouveau_bdev(man->bdev);
struct nvkm_fb *fb = nvxx_fb(&drm->device); struct nvkm_fb *fb = nvxx_fb(&drm->client.device);
man->priv = fb; man->priv = fb;
return 0; return 0;
} }
...@@ -64,45 +64,45 @@ nvkm_mem_node_cleanup(struct nvkm_mem *node) ...@@ -64,45 +64,45 @@ nvkm_mem_node_cleanup(struct nvkm_mem *node)
static void static void
nouveau_vram_manager_del(struct ttm_mem_type_manager *man, nouveau_vram_manager_del(struct ttm_mem_type_manager *man,
struct ttm_mem_reg *mem) struct ttm_mem_reg *reg)
{ {
struct nouveau_drm *drm = nouveau_bdev(man->bdev); struct nouveau_drm *drm = nouveau_bdev(man->bdev);
struct nvkm_ram *ram = nvxx_fb(&drm->device)->ram; struct nvkm_ram *ram = nvxx_fb(&drm->client.device)->ram;
nvkm_mem_node_cleanup(mem->mm_node); nvkm_mem_node_cleanup(reg->mm_node);
ram->func->put(ram, (struct nvkm_mem **)&mem->mm_node); ram->func->put(ram, (struct nvkm_mem **)&reg->mm_node);
} }
static int static int
nouveau_vram_manager_new(struct ttm_mem_type_manager *man, nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
struct ttm_buffer_object *bo, struct ttm_buffer_object *bo,
const struct ttm_place *place, const struct ttm_place *place,
struct ttm_mem_reg *mem) struct ttm_mem_reg *reg)
{ {
struct nouveau_drm *drm = nouveau_bdev(man->bdev); struct nouveau_drm *drm = nouveau_bdev(man->bdev);
struct nvkm_ram *ram = nvxx_fb(&drm->device)->ram; struct nvkm_ram *ram = nvxx_fb(&drm->client.device)->ram;
struct nouveau_bo *nvbo = nouveau_bo(bo); struct nouveau_bo *nvbo = nouveau_bo(bo);
struct nvkm_mem *node; struct nvkm_mem *node;
u32 size_nc = 0; u32 size_nc = 0;
int ret; int ret;
if (drm->device.info.ram_size == 0) if (drm->client.device.info.ram_size == 0)
return -ENOMEM; return -ENOMEM;
if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG)
size_nc = 1 << nvbo->page_shift; size_nc = 1 << nvbo->page_shift;
ret = ram->func->get(ram, mem->num_pages << PAGE_SHIFT, ret = ram->func->get(ram, reg->num_pages << PAGE_SHIFT,
mem->page_alignment << PAGE_SHIFT, size_nc, reg->page_alignment << PAGE_SHIFT, size_nc,
(nvbo->tile_flags >> 8) & 0x3ff, &node); (nvbo->tile_flags >> 8) & 0x3ff, &node);
if (ret) { if (ret) {
mem->mm_node = NULL; reg->mm_node = NULL;
return (ret == -ENOSPC) ? 0 : ret; return (ret == -ENOSPC) ? 0 : ret;
} }
node->page_shift = nvbo->page_shift; node->page_shift = nvbo->page_shift;
mem->mm_node = node; reg->mm_node = node;
mem->start = node->offset >> PAGE_SHIFT; reg->start = node->offset >> PAGE_SHIFT;
return 0; return 0;
} }
...@@ -127,18 +127,18 @@ nouveau_gart_manager_fini(struct ttm_mem_type_manager *man) ...@@ -127,18 +127,18 @@ nouveau_gart_manager_fini(struct ttm_mem_type_manager *man)
static void static void
nouveau_gart_manager_del(struct ttm_mem_type_manager *man, nouveau_gart_manager_del(struct ttm_mem_type_manager *man,
struct ttm_mem_reg *mem) struct ttm_mem_reg *reg)
{ {
nvkm_mem_node_cleanup(mem->mm_node); nvkm_mem_node_cleanup(reg->mm_node);
kfree(mem->mm_node); kfree(reg->mm_node);
mem->mm_node = NULL; reg->mm_node = NULL;
} }
static int static int
nouveau_gart_manager_new(struct ttm_mem_type_manager *man, nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
struct ttm_buffer_object *bo, struct ttm_buffer_object *bo,
const struct ttm_place *place, const struct ttm_place *place,
struct ttm_mem_reg *mem) struct ttm_mem_reg *reg)
{ {
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);
...@@ -150,7 +150,7 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, ...@@ -150,7 +150,7 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
node->page_shift = 12; node->page_shift = 12;
switch (drm->device.info.family) { switch (drm->client.device.info.family) {
case NV_DEVICE_INFO_V0_TNT: case NV_DEVICE_INFO_V0_TNT:
case NV_DEVICE_INFO_V0_CELSIUS: case NV_DEVICE_INFO_V0_CELSIUS:
case NV_DEVICE_INFO_V0_KELVIN: case NV_DEVICE_INFO_V0_KELVIN:
...@@ -158,7 +158,7 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, ...@@ -158,7 +158,7 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
case NV_DEVICE_INFO_V0_CURIE: case NV_DEVICE_INFO_V0_CURIE:
break; break;
case NV_DEVICE_INFO_V0_TESLA: case NV_DEVICE_INFO_V0_TESLA:
if (drm->device.info.chipset != 0x50) if (drm->client.device.info.chipset != 0x50)
node->memtype = (nvbo->tile_flags & 0x7f00) >> 8; node->memtype = (nvbo->tile_flags & 0x7f00) >> 8;
break; break;
case NV_DEVICE_INFO_V0_FERMI: case NV_DEVICE_INFO_V0_FERMI:
...@@ -169,12 +169,12 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, ...@@ -169,12 +169,12 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
break; break;
default: default:
NV_WARN(drm, "%s: unhandled family type %x\n", __func__, NV_WARN(drm, "%s: unhandled family type %x\n", __func__,
drm->device.info.family); drm->client.device.info.family);
break; break;
} }
mem->mm_node = node; reg->mm_node = node;
mem->start = 0; reg->start = 0;
return 0; return 0;
} }
...@@ -197,7 +197,7 @@ static int ...@@ -197,7 +197,7 @@ static int
nv04_gart_manager_init(struct ttm_mem_type_manager *man, unsigned long psize) nv04_gart_manager_init(struct ttm_mem_type_manager *man, unsigned long psize)
{ {
struct nouveau_drm *drm = nouveau_bdev(man->bdev); struct nouveau_drm *drm = nouveau_bdev(man->bdev);
struct nvkm_mmu *mmu = nvxx_mmu(&drm->device); struct nvkm_mmu *mmu = nvxx_mmu(&drm->client.device);
struct nv04_mmu *priv = (void *)mmu; struct nv04_mmu *priv = (void *)mmu;
struct nvkm_vm *vm = NULL; struct nvkm_vm *vm = NULL;
nvkm_vm_ref(priv->vm, &vm, NULL); nvkm_vm_ref(priv->vm, &vm, NULL);
...@@ -215,20 +215,20 @@ nv04_gart_manager_fini(struct ttm_mem_type_manager *man) ...@@ -215,20 +215,20 @@ nv04_gart_manager_fini(struct ttm_mem_type_manager *man)
} }
static void static void
nv04_gart_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) nv04_gart_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)
{ {
struct nvkm_mem *node = mem->mm_node; struct nvkm_mem *node = reg->mm_node;
if (node->vma[0].node) if (node->vma[0].node)
nvkm_vm_put(&node->vma[0]); nvkm_vm_put(&node->vma[0]);
kfree(mem->mm_node); kfree(reg->mm_node);
mem->mm_node = NULL; reg->mm_node = NULL;
} }
static int static int
nv04_gart_manager_new(struct ttm_mem_type_manager *man, nv04_gart_manager_new(struct ttm_mem_type_manager *man,
struct ttm_buffer_object *bo, struct ttm_buffer_object *bo,
const struct ttm_place *place, const struct ttm_place *place,
struct ttm_mem_reg *mem) struct ttm_mem_reg *reg)
{ {
struct nvkm_mem *node; struct nvkm_mem *node;
int ret; int ret;
...@@ -239,15 +239,15 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, ...@@ -239,15 +239,15 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,
node->page_shift = 12; node->page_shift = 12;
ret = nvkm_vm_get(man->priv, mem->num_pages << 12, node->page_shift, ret = nvkm_vm_get(man->priv, reg->num_pages << 12, node->page_shift,
NV_MEM_ACCESS_RW, &node->vma[0]); NV_MEM_ACCESS_RW, &node->vma[0]);
if (ret) { if (ret) {
kfree(node); kfree(node);
return ret; return ret;
} }
mem->mm_node = node; reg->mm_node = node;
mem->start = node->vma[0].offset >> PAGE_SHIFT; reg->start = node->vma[0].offset >> PAGE_SHIFT;
return 0; return 0;
} }
...@@ -339,7 +339,7 @@ nouveau_ttm_global_release(struct nouveau_drm *drm) ...@@ -339,7 +339,7 @@ nouveau_ttm_global_release(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->device); struct nvkm_device *device = nvxx_device(&drm->client.device);
struct nvkm_pci *pci = device->pci; struct nvkm_pci *pci = device->pci;
struct drm_device *dev = drm->dev; struct drm_device *dev = drm->dev;
u8 bits; u8 bits;
...@@ -352,8 +352,8 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -352,8 +352,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
drm->agp.cma = pci->agp.cma; drm->agp.cma = pci->agp.cma;
} }
bits = nvxx_mmu(&drm->device)->dma_bits; bits = nvxx_mmu(&drm->client.device)->dma_bits;
if (nvxx_device(&drm->device)->func->pci) { if (nvxx_device(&drm->client.device)->func->pci) {
if (drm->agp.bridge) if (drm->agp.bridge)
bits = 32; bits = 32;
} else if (device->func->tegra) { } else if (device->func->tegra) {
...@@ -396,7 +396,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -396,7 +396,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
} }
/* VRAM init */ /* VRAM init */
drm->gem.vram_available = drm->device.info.ram_user; drm->gem.vram_available = drm->client.device.info.ram_user;
arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1), arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1),
device->func->resource_size(device, 1)); device->func->resource_size(device, 1));
...@@ -413,7 +413,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -413,7 +413,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
/* GART init */ /* GART init */
if (!drm->agp.bridge) { if (!drm->agp.bridge) {
drm->gem.gart_available = nvxx_mmu(&drm->device)->limit; drm->gem.gart_available = nvxx_mmu(&drm->client.device)->limit;
} else { } else {
drm->gem.gart_available = drm->agp.size; drm->gem.gart_available = drm->agp.size;
} }
...@@ -433,7 +433,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -433,7 +433,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->device); struct nvkm_device *device = nvxx_device(&drm->client.device);
ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM); ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM);
ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT); ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT);
......
...@@ -103,7 +103,7 @@ usif_notify(const void *header, u32 length, const void *data, u32 size) ...@@ -103,7 +103,7 @@ usif_notify(const void *header, u32 length, const void *data, u32 size)
} }
break; break;
default: default:
BUG_ON(1); BUG();
break; break;
} }
......
...@@ -13,13 +13,13 @@ static unsigned int ...@@ -13,13 +13,13 @@ static unsigned int
nouveau_vga_set_decode(void *priv, bool state) nouveau_vga_set_decode(void *priv, bool state)
{ {
struct nouveau_drm *drm = nouveau_drm(priv); struct nouveau_drm *drm = nouveau_drm(priv);
struct nvif_object *device = &drm->device.object; struct nvif_object *device = &drm->client.device.object;
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE && if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE &&
drm->device.info.chipset >= 0x4c) drm->client.device.info.chipset >= 0x4c)
nvif_wr32(device, 0x088060, state); nvif_wr32(device, 0x088060, state);
else else
if (drm->device.info.chipset >= 0x40) if (drm->client.device.info.chipset >= 0x40)
nvif_wr32(device, 0x088054, state); nvif_wr32(device, 0x088054, state);
else else
nvif_wr32(device, 0x001854, state); nvif_wr32(device, 0x001854, state);
......
...@@ -136,7 +136,7 @@ nv04_fbcon_accel_init(struct fb_info *info) ...@@ -136,7 +136,7 @@ nv04_fbcon_accel_init(struct fb_info *info)
struct drm_device *dev = nfbdev->helper.dev; struct drm_device *dev = nfbdev->helper.dev;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
int surface_fmt, pattern_fmt, rect_fmt; int surface_fmt, pattern_fmt, rect_fmt;
int ret; int ret;
......
...@@ -76,9 +76,9 @@ nv17_fence_context_new(struct nouveau_channel *chan) ...@@ -76,9 +76,9 @@ nv17_fence_context_new(struct nouveau_channel *chan)
{ {
struct nv10_fence_priv *priv = chan->drm->fence; struct nv10_fence_priv *priv = chan->drm->fence;
struct nv10_fence_chan *fctx; struct nv10_fence_chan *fctx;
struct ttm_mem_reg *mem = &priv->bo->bo.mem; struct ttm_mem_reg *reg = &priv->bo->bo.mem;
u32 start = mem->start * PAGE_SIZE; u32 start = reg->start * PAGE_SIZE;
u32 limit = start + mem->size - 1; u32 limit = start + reg->size - 1;
int ret = 0; int ret = 0;
fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL); fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
...@@ -129,7 +129,7 @@ nv17_fence_create(struct nouveau_drm *drm) ...@@ -129,7 +129,7 @@ nv17_fence_create(struct nouveau_drm *drm)
priv->base.context_base = dma_fence_context_alloc(priv->base.contexts); priv->base.context_base = dma_fence_context_alloc(priv->base.contexts);
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
ret = nouveau_bo_new(drm->dev, 4096, 0x1000, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, NULL, &priv->bo); 0, 0x0000, NULL, NULL, &priv->bo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false); ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false);
......
...@@ -447,18 +447,18 @@ nv50_dmac_ctxdma_new(struct nv50_dmac *dmac, struct nouveau_framebuffer *fb) ...@@ -447,18 +447,18 @@ nv50_dmac_ctxdma_new(struct nv50_dmac *dmac, struct nouveau_framebuffer *fb)
args.base.target = NV_DMA_V0_TARGET_VRAM; args.base.target = NV_DMA_V0_TARGET_VRAM;
args.base.access = NV_DMA_V0_ACCESS_RDWR; args.base.access = NV_DMA_V0_ACCESS_RDWR;
args.base.start = 0; args.base.start = 0;
args.base.limit = drm->device.info.ram_user - 1; args.base.limit = drm->client.device.info.ram_user - 1;
if (drm->device.info.chipset < 0x80) { if (drm->client.device.info.chipset < 0x80) {
args.nv50.part = NV50_DMA_V0_PART_256; args.nv50.part = NV50_DMA_V0_PART_256;
argc += sizeof(args.nv50); argc += sizeof(args.nv50);
} else } else
if (drm->device.info.chipset < 0xc0) { if (drm->client.device.info.chipset < 0xc0) {
args.nv50.part = NV50_DMA_V0_PART_256; args.nv50.part = NV50_DMA_V0_PART_256;
args.nv50.kind = kind; args.nv50.kind = kind;
argc += sizeof(args.nv50); argc += sizeof(args.nv50);
} else } else
if (drm->device.info.chipset < 0xd0) { if (drm->client.device.info.chipset < 0xd0) {
args.gf100.kind = kind; args.gf100.kind = kind;
argc += sizeof(args.gf100); argc += sizeof(args.gf100);
} else { } else {
...@@ -848,7 +848,7 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, ...@@ -848,7 +848,7 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw,
asyw->image.kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8; asyw->image.kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8;
if (asyw->image.kind) { if (asyw->image.kind) {
asyw->image.layout = 0; asyw->image.layout = 0;
if (drm->device.info.chipset >= 0xc0) if (drm->client.device.info.chipset >= 0xc0)
asyw->image.block = fb->nvbo->tile_mode >> 4; asyw->image.block = fb->nvbo->tile_mode >> 4;
else else
asyw->image.block = fb->nvbo->tile_mode; asyw->image.block = fb->nvbo->tile_mode;
...@@ -1397,7 +1397,7 @@ nv50_base_ntfy_wait_begun(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) ...@@ -1397,7 +1397,7 @@ nv50_base_ntfy_wait_begun(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{ {
struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev); struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
struct nv50_disp *disp = nv50_disp(wndw->plane.dev); struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
if (nvif_msec(&drm->device, 2000ULL, if (nvif_msec(&drm->client.device, 2000ULL,
u32 data = nouveau_bo_rd32(disp->sync, asyw->ntfy.offset / 4); u32 data = nouveau_bo_rd32(disp->sync, asyw->ntfy.offset / 4);
if ((data & 0xc0000000) == 0x40000000) if ((data & 0xc0000000) == 0x40000000)
break; break;
...@@ -1522,7 +1522,7 @@ nv50_base_new(struct nouveau_drm *drm, struct nv50_head *head, ...@@ -1522,7 +1522,7 @@ nv50_base_new(struct nouveau_drm *drm, struct nv50_head *head,
return ret; return ret;
} }
ret = nv50_base_create(&drm->device, disp->disp, base->id, ret = nv50_base_create(&drm->client.device, disp->disp, base->id,
disp->sync->bo.offset, &base->chan); disp->sync->bo.offset, &base->chan);
if (ret) if (ret)
return ret; return ret;
...@@ -2394,7 +2394,7 @@ static int ...@@ -2394,7 +2394,7 @@ static int
nv50_head_create(struct drm_device *dev, int index) nv50_head_create(struct drm_device *dev, int index)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvif_device *device = &drm->device; struct nvif_device *device = &drm->client.device;
struct nv50_disp *disp = nv50_disp(dev); struct nv50_disp *disp = nv50_disp(dev);
struct nv50_head *head; struct nv50_head *head;
struct nv50_base *base; struct nv50_base *base;
...@@ -2428,7 +2428,7 @@ nv50_head_create(struct drm_device *dev, int index) ...@@ -2428,7 +2428,7 @@ nv50_head_create(struct drm_device *dev, int index)
drm_crtc_helper_add(crtc, &nv50_head_help); drm_crtc_helper_add(crtc, &nv50_head_help);
drm_mode_crtc_set_gamma_size(crtc, 256); drm_mode_crtc_set_gamma_size(crtc, 256);
ret = nouveau_bo_new(dev, 8192, 0x100, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(&drm->client, 8192, 0x100, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, NULL, &head->base.lut.nvbo); 0, 0x0000, NULL, NULL, &head->base.lut.nvbo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM, true); ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM, true);
...@@ -2667,7 +2667,7 @@ static int ...@@ -2667,7 +2667,7 @@ static int
nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe) nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
{ {
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
struct nvkm_i2c_bus *bus; struct nvkm_i2c_bus *bus;
struct nouveau_encoder *nv_encoder; struct nouveau_encoder *nv_encoder;
struct drm_encoder *encoder; struct drm_encoder *encoder;
...@@ -3623,7 +3623,7 @@ nv50_sor_enable(struct drm_encoder *encoder) ...@@ -3623,7 +3623,7 @@ nv50_sor_enable(struct drm_encoder *encoder)
nv50_audio_enable(encoder, mode); nv50_audio_enable(encoder, mode);
break; break;
default: default:
BUG_ON(1); BUG();
break; break;
} }
...@@ -3657,7 +3657,7 @@ nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe) ...@@ -3657,7 +3657,7 @@ nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe)
{ {
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->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
struct nouveau_encoder *nv_encoder; struct nouveau_encoder *nv_encoder;
struct drm_encoder *encoder; struct drm_encoder *encoder;
int type, ret; int type, ret;
...@@ -3796,7 +3796,7 @@ nv50_pior_enable(struct drm_encoder *encoder) ...@@ -3796,7 +3796,7 @@ nv50_pior_enable(struct drm_encoder *encoder)
proto = 0x0; proto = 0x0;
break; break;
default: default:
BUG_ON(1); BUG();
break; break;
} }
...@@ -3842,7 +3842,7 @@ static int ...@@ -3842,7 +3842,7 @@ static int
nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe) nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
{ {
struct nouveau_drm *drm = nouveau_drm(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nvkm_i2c *i2c = nvxx_i2c(&drm->device); struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
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;
...@@ -3915,7 +3915,7 @@ nv50_disp_atomic_commit_core(struct nouveau_drm *drm, u32 interlock) ...@@ -3915,7 +3915,7 @@ nv50_disp_atomic_commit_core(struct nouveau_drm *drm, u32 interlock)
evo_data(push, 0x00000000); evo_data(push, 0x00000000);
nouveau_bo_wr32(disp->sync, 0, 0x00000000); nouveau_bo_wr32(disp->sync, 0, 0x00000000);
evo_kick(push, core); evo_kick(push, core);
if (nvif_msec(&drm->device, 2000ULL, if (nvif_msec(&drm->client.device, 2000ULL,
if (nouveau_bo_rd32(disp->sync, 0)) if (nouveau_bo_rd32(disp->sync, 0))
break; break;
usleep_range(1, 2); usleep_range(1, 2);
...@@ -4427,7 +4427,7 @@ module_param_named(atomic, nouveau_atomic, int, 0400); ...@@ -4427,7 +4427,7 @@ module_param_named(atomic, nouveau_atomic, int, 0400);
int int
nv50_display_create(struct drm_device *dev) nv50_display_create(struct drm_device *dev)
{ {
struct nvif_device *device = &nouveau_drm(dev)->device; struct nvif_device *device = &nouveau_drm(dev)->client.device;
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct dcb_table *dcb = &drm->vbios.dcb; struct dcb_table *dcb = &drm->vbios.dcb;
struct drm_connector *connector, *tmp; struct drm_connector *connector, *tmp;
...@@ -4451,7 +4451,7 @@ nv50_display_create(struct drm_device *dev) ...@@ -4451,7 +4451,7 @@ nv50_display_create(struct drm_device *dev)
dev->driver->driver_features |= DRIVER_ATOMIC; dev->driver->driver_features |= DRIVER_ATOMIC;
/* small shared memory area we use for notifiers and semaphores */ /* small shared memory area we use for notifiers and semaphores */
ret = nouveau_bo_new(dev, 4096, 0x1000, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, NULL, &disp->sync); 0, 0x0000, NULL, NULL, &disp->sync);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM, true); ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM, true);
......
...@@ -37,9 +37,9 @@ nv50_fence_context_new(struct nouveau_channel *chan) ...@@ -37,9 +37,9 @@ nv50_fence_context_new(struct nouveau_channel *chan)
{ {
struct nv10_fence_priv *priv = chan->drm->fence; struct nv10_fence_priv *priv = chan->drm->fence;
struct nv10_fence_chan *fctx; struct nv10_fence_chan *fctx;
struct ttm_mem_reg *mem = &priv->bo->bo.mem; struct ttm_mem_reg *reg = &priv->bo->bo.mem;
u32 start = mem->start * PAGE_SIZE; u32 start = reg->start * PAGE_SIZE;
u32 limit = start + mem->size - 1; u32 limit = start + reg->size - 1;
int ret; int ret;
fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL); fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
...@@ -82,7 +82,7 @@ nv50_fence_create(struct nouveau_drm *drm) ...@@ -82,7 +82,7 @@ nv50_fence_create(struct nouveau_drm *drm)
priv->base.context_base = dma_fence_context_alloc(priv->base.contexts); priv->base.context_base = dma_fence_context_alloc(priv->base.contexts);
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
ret = nouveau_bo_new(drm->dev, 4096, 0x1000, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, NULL, &priv->bo); 0, 0x0000, NULL, NULL, &priv->bo);
if (!ret) { if (!ret) {
ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false); ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false);
......
...@@ -193,7 +193,7 @@ nv84_fence_destroy(struct nouveau_drm *drm) ...@@ -193,7 +193,7 @@ nv84_fence_destroy(struct nouveau_drm *drm)
int int
nv84_fence_create(struct nouveau_drm *drm) nv84_fence_create(struct nouveau_drm *drm)
{ {
struct nvkm_fifo *fifo = nvxx_fifo(&drm->device); struct nvkm_fifo *fifo = nvxx_fifo(&drm->client.device);
struct nv84_fence_priv *priv; struct nv84_fence_priv *priv;
u32 domain; u32 domain;
int ret; int ret;
...@@ -213,14 +213,14 @@ nv84_fence_create(struct nouveau_drm *drm) ...@@ -213,14 +213,14 @@ nv84_fence_create(struct nouveau_drm *drm)
priv->base.uevent = true; priv->base.uevent = true;
/* Use VRAM if there is any ; otherwise fallback to system memory */ /* Use VRAM if there is any ; otherwise fallback to system memory */
domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM : domain = drm->client.device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
/* /*
* fences created in sysmem must be non-cached or we * fences created in sysmem must be non-cached or we
* will lose CPU/GPU coherency! * will lose CPU/GPU coherency!
*/ */
TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED; TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED;
ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, domain, 0, ret = nouveau_bo_new(&drm->client, 16 * priv->base.contexts, 0,
0, NULL, NULL, &priv->bo); domain, 0, 0, NULL, NULL, &priv->bo);
if (ret == 0) { if (ret == 0) {
ret = nouveau_bo_pin(priv->bo, domain, false); ret = nouveau_bo_pin(priv->bo, domain, false);
if (ret == 0) { if (ret == 0) {
...@@ -233,7 +233,7 @@ nv84_fence_create(struct nouveau_drm *drm) ...@@ -233,7 +233,7 @@ nv84_fence_create(struct nouveau_drm *drm)
} }
if (ret == 0) if (ret == 0)
ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, ret = nouveau_bo_new(&drm->client, 16 * priv->base.contexts, 0,
TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED, 0, TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED, 0,
0, NULL, NULL, &priv->bo_gart); 0, NULL, NULL, &priv->bo_gart);
if (ret == 0) { if (ret == 0) {
......
nvif-y := nvif/object.o nvif-y := nvif/object.o
nvif-y += nvif/client.o nvif-y += nvif/client.o
nvif-y += nvif/device.o nvif-y += nvif/device.o
nvif-y += nvif/driver.o
nvif-y += nvif/notify.o nvif-y += nvif/notify.o
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include <nvif/driver.h> #include <nvif/driver.h>
#include <nvif/ioctl.h> #include <nvif/ioctl.h>
#include <nvif/class.h>
#include <nvif/if0000.h>
int int
nvif_client_ioctl(struct nvif_client *client, void *data, u32 size) nvif_client_ioctl(struct nvif_client *client, void *data, u32 size)
{ {
...@@ -47,37 +50,29 @@ nvif_client_resume(struct nvif_client *client) ...@@ -47,37 +50,29 @@ nvif_client_resume(struct nvif_client *client)
void void
nvif_client_fini(struct nvif_client *client) nvif_client_fini(struct nvif_client *client)
{ {
nvif_object_fini(&client->object);
if (client->driver) { if (client->driver) {
client->driver->fini(client->object.priv); if (client->driver->fini)
client->driver->fini(client->object.priv);
client->driver = NULL; client->driver = NULL;
client->object.client = NULL;
nvif_object_fini(&client->object);
} }
} }
static const struct nvif_driver *
nvif_drivers[] = {
#ifdef __KERNEL__
&nvif_driver_nvkm,
#else
&nvif_driver_drm,
&nvif_driver_lib,
&nvif_driver_null,
#endif
NULL
};
int int
nvif_client_init(const char *driver, const char *name, u64 device, nvif_client_init(struct nvif_client *parent, const char *name, u64 device,
const char *cfg, const char *dbg, struct nvif_client *client) struct nvif_client *client)
{ {
struct nvif_client_v0 args = { .device = device };
struct { struct {
struct nvif_ioctl_v0 ioctl; struct nvif_ioctl_v0 ioctl;
struct nvif_ioctl_nop_v0 nop; struct nvif_ioctl_nop_v0 nop;
} args = {}; } nop = {};
int ret, i; int ret;
ret = nvif_object_init(NULL, 0, 0, NULL, 0, &client->object); strncpy(args.name, name, sizeof(args.name));
ret = nvif_object_init(parent != client ? &parent->object : NULL,
0, NVIF_CLASS_CLIENT, &args, sizeof(args),
&client->object);
if (ret) if (ret)
return ret; return ret;
...@@ -85,19 +80,11 @@ nvif_client_init(const char *driver, const char *name, u64 device, ...@@ -85,19 +80,11 @@ nvif_client_init(const char *driver, const char *name, u64 device,
client->object.handle = ~0; client->object.handle = ~0;
client->route = NVIF_IOCTL_V0_ROUTE_NVIF; client->route = NVIF_IOCTL_V0_ROUTE_NVIF;
client->super = true; client->super = true;
client->driver = parent->driver;
for (i = 0, ret = -EINVAL; (client->driver = nvif_drivers[i]); i++) {
if (!driver || !strcmp(client->driver->name, driver)) {
ret = client->driver->init(name, device, cfg, dbg,
&client->object.priv);
if (!ret || driver)
break;
}
}
if (ret == 0) { if (ret == 0) {
ret = nvif_client_ioctl(client, &args, sizeof(args)); ret = nvif_client_ioctl(client, &nop, sizeof(nop));
client->version = args.nop.version; client->version = nop.nop.version;
} }
if (ret) if (ret)
......
/*
* Copyright 2016 Red Hat Inc.
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*
* Authors: Ben Skeggs
*/
#include <nvif/driver.h>
#include <nvif/client.h>
static const struct nvif_driver *
nvif_driver[] = {
#ifdef __KERNEL__
&nvif_driver_nvkm,
#else
&nvif_driver_drm,
&nvif_driver_lib,
&nvif_driver_null,
#endif
NULL
};
int
nvif_driver_init(const char *drv, const char *cfg, const char *dbg,
const char *name, u64 device, struct nvif_client *client)
{
int ret = -EINVAL, i;
for (i = 0; (client->driver = nvif_driver[i]); i++) {
if (!drv || !strcmp(client->driver->name, drv)) {
ret = client->driver->init(name, device, cfg, dbg,
&client->object.priv);
if (ret == 0)
break;
client->driver->fini(client->object.priv);
}
}
if (ret == 0)
ret = nvif_client_init(client, name, device, client);
return ret;
}
include $(src)/nvkm/core/Kbuild include $(src)/nvkm/core/Kbuild
include $(src)/nvkm/falcon/Kbuild
include $(src)/nvkm/subdev/Kbuild include $(src)/nvkm/subdev/Kbuild
include $(src)/nvkm/engine/Kbuild include $(src)/nvkm/engine/Kbuild
...@@ -31,6 +31,43 @@ ...@@ -31,6 +31,43 @@
#include <nvif/if0000.h> #include <nvif/if0000.h>
#include <nvif/unpack.h> #include <nvif/unpack.h>
static int
nvkm_uclient_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
struct nvkm_object **pobject)
{
union {
struct nvif_client_v0 v0;
} *args = argv;
struct nvkm_client *client;
int ret = -ENOSYS;
if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))){
args->v0.name[sizeof(args->v0.name) - 1] = 0;
ret = nvkm_client_new(args->v0.name, args->v0.device, NULL,
NULL, oclass->client->ntfy, &client);
if (ret)
return ret;
} else
return ret;
client->object.client = oclass->client;
client->object.handle = oclass->handle;
client->object.route = oclass->route;
client->object.token = oclass->token;
client->object.object = oclass->object;
client->debug = oclass->client->debug;
*pobject = &client->object;
return 0;
}
const struct nvkm_sclass
nvkm_uclient_sclass = {
.oclass = NVIF_CLASS_CLIENT,
.minver = 0,
.maxver = 0,
.ctor = nvkm_uclient_new,
};
struct nvkm_client_notify { struct nvkm_client_notify {
struct nvkm_client *client; struct nvkm_client *client;
struct nvkm_notify n; struct nvkm_notify n;
...@@ -138,17 +175,30 @@ nvkm_client_notify_new(struct nvkm_object *object, ...@@ -138,17 +175,30 @@ nvkm_client_notify_new(struct nvkm_object *object,
return ret; return ret;
} }
static const struct nvkm_object_func nvkm_client;
struct nvkm_client *
nvkm_client_search(struct nvkm_client *client, u64 handle)
{
struct nvkm_object *object;
object = nvkm_object_search(client, handle, &nvkm_client);
if (IS_ERR(object))
return (void *)object;
return nvkm_client(object);
}
static int static int
nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size) nvkm_client_mthd_devlist(struct nvkm_client *client, void *data, u32 size)
{ {
union { union {
struct nv_client_devlist_v0 v0; struct nvif_client_devlist_v0 v0;
} *args = data; } *args = data;
int ret = -ENOSYS; int ret = -ENOSYS;
nvif_ioctl(object, "client devlist size %d\n", size); nvif_ioctl(&client->object, "client devlist size %d\n", size);
if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) { if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
nvif_ioctl(object, "client devlist vers %d count %d\n", nvif_ioctl(&client->object, "client devlist vers %d count %d\n",
args->v0.version, args->v0.count); args->v0.version, args->v0.count);
if (size == sizeof(args->v0.device[0]) * args->v0.count) { if (size == sizeof(args->v0.device[0]) * args->v0.count) {
ret = nvkm_device_list(args->v0.device, args->v0.count); ret = nvkm_device_list(args->v0.device, args->v0.count);
...@@ -167,9 +217,10 @@ nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size) ...@@ -167,9 +217,10 @@ nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size)
static int static int
nvkm_client_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) nvkm_client_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
{ {
struct nvkm_client *client = nvkm_client(object);
switch (mthd) { switch (mthd) {
case NV_CLIENT_DEVLIST: case NVIF_CLIENT_V0_DEVLIST:
return nvkm_client_mthd_devlist(object, data, size); return nvkm_client_mthd_devlist(client, data, size);
default: default:
break; break;
} }
...@@ -190,7 +241,8 @@ nvkm_client_child_get(struct nvkm_object *object, int index, ...@@ -190,7 +241,8 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
const struct nvkm_sclass *sclass; const struct nvkm_sclass *sclass;
switch (index) { switch (index) {
case 0: sclass = &nvkm_udevice_sclass; break; case 0: sclass = &nvkm_uclient_sclass; break;
case 1: sclass = &nvkm_udevice_sclass; break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -200,110 +252,54 @@ nvkm_client_child_get(struct nvkm_object *object, int index, ...@@ -200,110 +252,54 @@ nvkm_client_child_get(struct nvkm_object *object, int index,
return 0; return 0;
} }
static const struct nvkm_object_func static int
nvkm_client_object_func = { nvkm_client_fini(struct nvkm_object *object, bool suspend)
.mthd = nvkm_client_mthd,
.sclass = nvkm_client_child_get,
};
void
nvkm_client_remove(struct nvkm_client *client, struct nvkm_object *object)
{
if (!RB_EMPTY_NODE(&object->node))
rb_erase(&object->node, &client->objroot);
}
bool
nvkm_client_insert(struct nvkm_client *client, struct nvkm_object *object)
{
struct rb_node **ptr = &client->objroot.rb_node;
struct rb_node *parent = NULL;
while (*ptr) {
struct nvkm_object *this =
container_of(*ptr, typeof(*this), node);
parent = *ptr;
if (object->object < this->object)
ptr = &parent->rb_left;
else
if (object->object > this->object)
ptr = &parent->rb_right;
else
return false;
}
rb_link_node(&object->node, parent, ptr);
rb_insert_color(&object->node, &client->objroot);
return true;
}
struct nvkm_object *
nvkm_client_search(struct nvkm_client *client, u64 handle)
{
struct rb_node *node = client->objroot.rb_node;
while (node) {
struct nvkm_object *object =
container_of(node, typeof(*object), node);
if (handle < object->object)
node = node->rb_left;
else
if (handle > object->object)
node = node->rb_right;
else
return object;
}
return NULL;
}
int
nvkm_client_fini(struct nvkm_client *client, bool suspend)
{ {
struct nvkm_object *object = &client->object; struct nvkm_client *client = nvkm_client(object);
const char *name[2] = { "fini", "suspend" }; const char *name[2] = { "fini", "suspend" };
int i; int i;
nvif_debug(object, "%s notify\n", name[suspend]); nvif_debug(object, "%s notify\n", name[suspend]);
for (i = 0; i < ARRAY_SIZE(client->notify); i++) for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_notify_put(client, i); nvkm_client_notify_put(client, i);
return nvkm_object_fini(&client->object, suspend); return 0;
}
int
nvkm_client_init(struct nvkm_client *client)
{
return nvkm_object_init(&client->object);
} }
void static void *
nvkm_client_del(struct nvkm_client **pclient) nvkm_client_dtor(struct nvkm_object *object)
{ {
struct nvkm_client *client = *pclient; struct nvkm_client *client = nvkm_client(object);
int i; int i;
if (client) { for (i = 0; i < ARRAY_SIZE(client->notify); i++)
nvkm_client_fini(client, false); nvkm_client_notify_del(client, i);
for (i = 0; i < ARRAY_SIZE(client->notify); i++) return client;
nvkm_client_notify_del(client, i);
nvkm_object_dtor(&client->object);
kfree(*pclient);
*pclient = NULL;
}
} }
static const struct nvkm_object_func
nvkm_client = {
.dtor = nvkm_client_dtor,
.fini = nvkm_client_fini,
.mthd = nvkm_client_mthd,
.sclass = nvkm_client_child_get,
};
int int
nvkm_client_new(const char *name, u64 device, const char *cfg, nvkm_client_new(const char *name, u64 device, const char *cfg,
const char *dbg, struct nvkm_client **pclient) const char *dbg,
int (*ntfy)(const void *, u32, const void *, u32),
struct nvkm_client **pclient)
{ {
struct nvkm_oclass oclass = {}; struct nvkm_oclass oclass = { .base = nvkm_uclient_sclass };
struct nvkm_client *client; struct nvkm_client *client;
if (!(client = *pclient = kzalloc(sizeof(*client), GFP_KERNEL))) if (!(client = *pclient = kzalloc(sizeof(*client), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
oclass.client = client; oclass.client = client;
nvkm_object_ctor(&nvkm_client_object_func, &oclass, &client->object); nvkm_object_ctor(&nvkm_client, &oclass, &client->object);
snprintf(client->name, sizeof(client->name), "%s", name); snprintf(client->name, sizeof(client->name), "%s", name);
client->device = device; client->device = device;
client->debug = nvkm_dbgopt(dbg, "CLIENT"); client->debug = nvkm_dbgopt(dbg, "CLIENT");
client->objroot = RB_ROOT; client->objroot = RB_ROOT;
client->dmaroot = RB_ROOT; client->ntfy = ntfy;
return 0; return 0;
} }
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
#include <subdev/fb.h> #include <subdev/fb.h>
bool
nvkm_engine_chsw_load(struct nvkm_engine *engine)
{
if (engine->func->chsw_load)
return engine->func->chsw_load(engine);
return false;
}
void void
nvkm_engine_unref(struct nvkm_engine **pengine) nvkm_engine_unref(struct nvkm_engine **pengine)
{ {
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include <nvif/ioctl.h> #include <nvif/ioctl.h>
static int static int
nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_nop(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_nop_v0 v0; struct nvif_ioctl_nop_v0 v0;
...@@ -46,7 +47,8 @@ nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size) ...@@ -46,7 +47,8 @@ nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_sclass(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_sclass(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_sclass_v0 v0; struct nvif_ioctl_sclass_v0 v0;
...@@ -78,12 +80,12 @@ nvkm_ioctl_sclass(struct nvkm_object *object, void *data, u32 size) ...@@ -78,12 +80,12 @@ nvkm_ioctl_sclass(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size) nvkm_ioctl_new(struct nvkm_client *client,
struct nvkm_object *parent, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_new_v0 v0; struct nvif_ioctl_new_v0 v0;
} *args = data; } *args = data;
struct nvkm_client *client = parent->client;
struct nvkm_object *object = NULL; struct nvkm_object *object = NULL;
struct nvkm_oclass oclass; struct nvkm_oclass oclass;
int ret = -ENOSYS, i = 0; int ret = -ENOSYS, i = 0;
...@@ -104,9 +106,11 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size) ...@@ -104,9 +106,11 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
do { do {
memset(&oclass, 0x00, sizeof(oclass)); memset(&oclass, 0x00, sizeof(oclass));
oclass.client = client;
oclass.handle = args->v0.handle; oclass.handle = args->v0.handle;
oclass.route = args->v0.route;
oclass.token = args->v0.token;
oclass.object = args->v0.object; oclass.object = args->v0.object;
oclass.client = client;
oclass.parent = parent; oclass.parent = parent;
ret = parent->func->sclass(parent, i++, &oclass); ret = parent->func->sclass(parent, i++, &oclass);
if (ret) if (ret)
...@@ -125,10 +129,7 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size) ...@@ -125,10 +129,7 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
ret = nvkm_object_init(object); ret = nvkm_object_init(object);
if (ret == 0) { if (ret == 0) {
list_add(&object->head, &parent->tree); list_add(&object->head, &parent->tree);
object->route = args->v0.route; if (nvkm_object_insert(object)) {
object->token = args->v0.token;
object->object = args->v0.object;
if (nvkm_client_insert(client, object)) {
client->data = object; client->data = object;
return 0; return 0;
} }
...@@ -142,7 +143,8 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size) ...@@ -142,7 +143,8 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
} }
static int static int
nvkm_ioctl_del(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_del(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_del none; struct nvif_ioctl_del none;
...@@ -156,11 +158,12 @@ nvkm_ioctl_del(struct nvkm_object *object, void *data, u32 size) ...@@ -156,11 +158,12 @@ nvkm_ioctl_del(struct nvkm_object *object, void *data, u32 size)
nvkm_object_del(&object); nvkm_object_del(&object);
} }
return ret; return ret ? ret : 1;
} }
static int static int
nvkm_ioctl_mthd(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_mthd(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_mthd_v0 v0; struct nvif_ioctl_mthd_v0 v0;
...@@ -179,7 +182,8 @@ nvkm_ioctl_mthd(struct nvkm_object *object, void *data, u32 size) ...@@ -179,7 +182,8 @@ nvkm_ioctl_mthd(struct nvkm_object *object, void *data, u32 size)
static int static int
nvkm_ioctl_rd(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_rd(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_rd_v0 v0; struct nvif_ioctl_rd_v0 v0;
...@@ -218,7 +222,8 @@ nvkm_ioctl_rd(struct nvkm_object *object, void *data, u32 size) ...@@ -218,7 +222,8 @@ nvkm_ioctl_rd(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_wr(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_wr(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_wr_v0 v0; struct nvif_ioctl_wr_v0 v0;
...@@ -246,7 +251,8 @@ nvkm_ioctl_wr(struct nvkm_object *object, void *data, u32 size) ...@@ -246,7 +251,8 @@ nvkm_ioctl_wr(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_map(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_map_v0 v0; struct nvif_ioctl_map_v0 v0;
...@@ -264,7 +270,8 @@ nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size) ...@@ -264,7 +270,8 @@ nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_unmap(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_unmap none; struct nvif_ioctl_unmap none;
...@@ -280,7 +287,8 @@ nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size) ...@@ -280,7 +287,8 @@ nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_ntfy_new(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_ntfy_new(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
union { union {
struct nvif_ioctl_ntfy_new_v0 v0; struct nvif_ioctl_ntfy_new_v0 v0;
...@@ -306,9 +314,9 @@ nvkm_ioctl_ntfy_new(struct nvkm_object *object, void *data, u32 size) ...@@ -306,9 +314,9 @@ nvkm_ioctl_ntfy_new(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_ntfy_del(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_ntfy_del(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
struct nvkm_client *client = object->client;
union { union {
struct nvif_ioctl_ntfy_del_v0 v0; struct nvif_ioctl_ntfy_del_v0 v0;
} *args = data; } *args = data;
...@@ -325,9 +333,9 @@ nvkm_ioctl_ntfy_del(struct nvkm_object *object, void *data, u32 size) ...@@ -325,9 +333,9 @@ nvkm_ioctl_ntfy_del(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_ntfy_get(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_ntfy_get(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
struct nvkm_client *client = object->client;
union { union {
struct nvif_ioctl_ntfy_get_v0 v0; struct nvif_ioctl_ntfy_get_v0 v0;
} *args = data; } *args = data;
...@@ -344,9 +352,9 @@ nvkm_ioctl_ntfy_get(struct nvkm_object *object, void *data, u32 size) ...@@ -344,9 +352,9 @@ nvkm_ioctl_ntfy_get(struct nvkm_object *object, void *data, u32 size)
} }
static int static int
nvkm_ioctl_ntfy_put(struct nvkm_object *object, void *data, u32 size) nvkm_ioctl_ntfy_put(struct nvkm_client *client,
struct nvkm_object *object, void *data, u32 size)
{ {
struct nvkm_client *client = object->client;
union { union {
struct nvif_ioctl_ntfy_put_v0 v0; struct nvif_ioctl_ntfy_put_v0 v0;
} *args = data; } *args = data;
...@@ -364,7 +372,7 @@ nvkm_ioctl_ntfy_put(struct nvkm_object *object, void *data, u32 size) ...@@ -364,7 +372,7 @@ nvkm_ioctl_ntfy_put(struct nvkm_object *object, void *data, u32 size)
static struct { static struct {
int version; int version;
int (*func)(struct nvkm_object *, void *, u32); int (*func)(struct nvkm_client *, struct nvkm_object *, void *, u32);
} }
nvkm_ioctl_v0[] = { nvkm_ioctl_v0[] = {
{ 0x00, nvkm_ioctl_nop }, { 0x00, nvkm_ioctl_nop },
...@@ -389,13 +397,10 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type, ...@@ -389,13 +397,10 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
struct nvkm_object *object; struct nvkm_object *object;
int ret; int ret;
if (handle) object = nvkm_object_search(client, handle, NULL);
object = nvkm_client_search(client, handle); if (IS_ERR(object)) {
else
object = &client->object;
if (unlikely(!object)) {
nvif_ioctl(&client->object, "object not found\n"); nvif_ioctl(&client->object, "object not found\n");
return -ENOENT; return PTR_ERR(object);
} }
if (owner != NVIF_IOCTL_V0_OWNER_ANY && owner != object->route) { if (owner != NVIF_IOCTL_V0_OWNER_ANY && owner != object->route) {
...@@ -407,7 +412,7 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type, ...@@ -407,7 +412,7 @@ nvkm_ioctl_path(struct nvkm_client *client, u64 handle, u32 type,
if (ret = -EINVAL, type < ARRAY_SIZE(nvkm_ioctl_v0)) { if (ret = -EINVAL, type < ARRAY_SIZE(nvkm_ioctl_v0)) {
if (nvkm_ioctl_v0[type].version == 0) if (nvkm_ioctl_v0[type].version == 0)
ret = nvkm_ioctl_v0[type].func(object, data, size); ret = nvkm_ioctl_v0[type].func(client, object, data, size);
} }
return ret; return ret;
...@@ -436,12 +441,13 @@ nvkm_ioctl(struct nvkm_client *client, bool supervisor, ...@@ -436,12 +441,13 @@ nvkm_ioctl(struct nvkm_client *client, bool supervisor,
&args->v0.route, &args->v0.token); &args->v0.route, &args->v0.token);
} }
nvif_ioctl(object, "return %d\n", ret); if (ret != 1) {
if (hack) { nvif_ioctl(object, "return %d\n", ret);
*hack = client->data; if (hack) {
client->data = NULL; *hack = client->data;
client->data = NULL;
}
} }
client->super = false;
return ret; return ret;
} }
...@@ -147,6 +147,7 @@ nvkm_mm_head(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min, ...@@ -147,6 +147,7 @@ nvkm_mm_head(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min,
if (!this) if (!this)
return -ENOMEM; return -ENOMEM;
this->next = NULL;
this->type = type; this->type = type;
list_del(&this->fl_entry); list_del(&this->fl_entry);
*pnode = this; *pnode = this;
...@@ -225,6 +226,7 @@ nvkm_mm_tail(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min, ...@@ -225,6 +226,7 @@ nvkm_mm_tail(struct nvkm_mm *mm, u8 heap, u8 type, u32 size_max, u32 size_min,
if (!this) if (!this)
return -ENOMEM; return -ENOMEM;
this->next = NULL;
this->type = type; this->type = type;
list_del(&this->fl_entry); list_del(&this->fl_entry);
*pnode = this; *pnode = this;
......
...@@ -25,6 +25,65 @@ ...@@ -25,6 +25,65 @@
#include <core/client.h> #include <core/client.h>
#include <core/engine.h> #include <core/engine.h>
struct nvkm_object *
nvkm_object_search(struct nvkm_client *client, u64 handle,
const struct nvkm_object_func *func)
{
struct nvkm_object *object;
if (handle) {
struct rb_node *node = client->objroot.rb_node;
while (node) {
object = rb_entry(node, typeof(*object), node);
if (handle < object->object)
node = node->rb_left;
else
if (handle > object->object)
node = node->rb_right;
else
goto done;
}
return ERR_PTR(-ENOENT);
} else {
object = &client->object;
}
done:
if (unlikely(func && object->func != func))
return ERR_PTR(-EINVAL);
return object;
}
void
nvkm_object_remove(struct nvkm_object *object)
{
if (!RB_EMPTY_NODE(&object->node))
rb_erase(&object->node, &object->client->objroot);
}
bool
nvkm_object_insert(struct nvkm_object *object)
{
struct rb_node **ptr = &object->client->objroot.rb_node;
struct rb_node *parent = NULL;
while (*ptr) {
struct nvkm_object *this = rb_entry(*ptr, typeof(*this), node);
parent = *ptr;
if (object->object < this->object)
ptr = &parent->rb_left;
else
if (object->object > this->object)
ptr = &parent->rb_right;
else
return false;
}
rb_link_node(&object->node, parent, ptr);
rb_insert_color(&object->node, &object->client->objroot);
return true;
}
int int
nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
{ {
...@@ -214,7 +273,7 @@ nvkm_object_del(struct nvkm_object **pobject) ...@@ -214,7 +273,7 @@ nvkm_object_del(struct nvkm_object **pobject)
struct nvkm_object *object = *pobject; struct nvkm_object *object = *pobject;
if (object && !WARN_ON(!object->func)) { if (object && !WARN_ON(!object->func)) {
*pobject = nvkm_object_dtor(object); *pobject = nvkm_object_dtor(object);
nvkm_client_remove(object->client, object); nvkm_object_remove(object);
list_del(&object->head); list_del(&object->head);
kfree(*pobject); kfree(*pobject);
*pobject = NULL; *pobject = NULL;
...@@ -230,6 +289,9 @@ nvkm_object_ctor(const struct nvkm_object_func *func, ...@@ -230,6 +289,9 @@ nvkm_object_ctor(const struct nvkm_object_func *func,
object->engine = nvkm_engine_ref(oclass->engine); object->engine = nvkm_engine_ref(oclass->engine);
object->oclass = oclass->base.oclass; object->oclass = oclass->base.oclass;
object->handle = oclass->handle; object->handle = oclass->handle;
object->route = oclass->route;
object->token = oclass->token;
object->object = oclass->object;
INIT_LIST_HEAD(&object->head); INIT_LIST_HEAD(&object->head);
INIT_LIST_HEAD(&object->tree); INIT_LIST_HEAD(&object->tree);
RB_CLEAR_NODE(&object->node); RB_CLEAR_NODE(&object->node);
......
...@@ -993,7 +993,7 @@ nv92_chipset = { ...@@ -993,7 +993,7 @@ nv92_chipset = {
.mc = g84_mc_new, .mc = g84_mc_new,
.mmu = nv50_mmu_new, .mmu = nv50_mmu_new,
.mxm = nv50_mxm_new, .mxm = nv50_mxm_new,
.pci = g84_pci_new, .pci = g92_pci_new,
.therm = g84_therm_new, .therm = g84_therm_new,
.timer = nv41_timer_new, .timer = nv41_timer_new,
.volt = nv40_volt_new, .volt = nv40_volt_new,
...@@ -2138,6 +2138,7 @@ nv12b_chipset = { ...@@ -2138,6 +2138,7 @@ nv12b_chipset = {
.ltc = gm200_ltc_new, .ltc = gm200_ltc_new,
.mc = gk20a_mc_new, .mc = gk20a_mc_new,
.mmu = gf100_mmu_new, .mmu = gf100_mmu_new,
.pmu = gm20b_pmu_new,
.secboot = gm20b_secboot_new, .secboot = gm20b_secboot_new,
.timer = gk20a_timer_new, .timer = gk20a_timer_new,
.top = gk104_top_new, .top = gk104_top_new,
......
...@@ -137,7 +137,6 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func, ...@@ -137,7 +137,6 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
const struct nvkm_oclass *oclass, const struct nvkm_oclass *oclass,
struct nvkm_object **pobject) struct nvkm_object **pobject)
{ {
struct nvkm_device *device = root->disp->base.engine.subdev.device;
struct nvkm_client *client = oclass->client; struct nvkm_client *client = oclass->client;
struct nvkm_dmaobj *dmaobj; struct nvkm_dmaobj *dmaobj;
struct nv50_disp_dmac *chan; struct nv50_disp_dmac *chan;
...@@ -153,9 +152,9 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func, ...@@ -153,9 +152,9 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
if (ret) if (ret)
return ret; return ret;
dmaobj = nvkm_dma_search(device->dma, client, push); dmaobj = nvkm_dmaobj_search(client, push);
if (!dmaobj) if (IS_ERR(dmaobj))
return -ENOENT; return PTR_ERR(dmaobj);
if (dmaobj->limit - dmaobj->start != 0xfff) if (dmaobj->limit - dmaobj->start != 0xfff)
return -EINVAL; return -EINVAL;
......
...@@ -38,13 +38,6 @@ g94_sor_loff(struct nvkm_output_dp *outp) ...@@ -38,13 +38,6 @@ g94_sor_loff(struct nvkm_output_dp *outp)
return g94_sor_soff(outp) + !(outp->base.info.sorconf.link & 1) * 0x80; return g94_sor_soff(outp) + !(outp->base.info.sorconf.link & 1) * 0x80;
} }
/*******************************************************************************
* TMDS/LVDS
******************************************************************************/
static const struct nvkm_output_func
g94_sor_output_func = {
};
/******************************************************************************* /*******************************************************************************
* DisplayPort * DisplayPort
******************************************************************************/ ******************************************************************************/
......
...@@ -28,24 +28,6 @@ ...@@ -28,24 +28,6 @@
#include <nvif/class.h> #include <nvif/class.h>
struct nvkm_dmaobj *
nvkm_dma_search(struct nvkm_dma *dma, struct nvkm_client *client, u64 object)
{
struct rb_node *node = client->dmaroot.rb_node;
while (node) {
struct nvkm_dmaobj *dmaobj =
container_of(node, typeof(*dmaobj), rb);
if (object < dmaobj->handle)
node = node->rb_left;
else
if (object > dmaobj->handle)
node = node->rb_right;
else
return dmaobj;
}
return NULL;
}
static int static int
nvkm_dma_oclass_new(struct nvkm_device *device, nvkm_dma_oclass_new(struct nvkm_device *device,
const struct nvkm_oclass *oclass, void *data, u32 size, const struct nvkm_oclass *oclass, void *data, u32 size,
...@@ -53,34 +35,12 @@ nvkm_dma_oclass_new(struct nvkm_device *device, ...@@ -53,34 +35,12 @@ nvkm_dma_oclass_new(struct nvkm_device *device,
{ {
struct nvkm_dma *dma = nvkm_dma(oclass->engine); struct nvkm_dma *dma = nvkm_dma(oclass->engine);
struct nvkm_dmaobj *dmaobj = NULL; struct nvkm_dmaobj *dmaobj = NULL;
struct nvkm_client *client = oclass->client;
struct rb_node **ptr = &client->dmaroot.rb_node;
struct rb_node *parent = NULL;
int ret; int ret;
ret = dma->func->class_new(dma, oclass, data, size, &dmaobj); ret = dma->func->class_new(dma, oclass, data, size, &dmaobj);
if (dmaobj) if (dmaobj)
*pobject = &dmaobj->object; *pobject = &dmaobj->object;
if (ret) return ret;
return ret;
dmaobj->handle = oclass->object;
while (*ptr) {
struct nvkm_dmaobj *obj = container_of(*ptr, typeof(*obj), rb);
parent = *ptr;
if (dmaobj->handle < obj->handle)
ptr = &parent->rb_left;
else
if (dmaobj->handle > obj->handle)
ptr = &parent->rb_right;
else
return -EEXIST;
}
rb_link_node(&dmaobj->rb, parent, ptr);
rb_insert_color(&dmaobj->rb, &client->dmaroot);
return 0;
} }
static const struct nvkm_device_oclass static const struct nvkm_device_oclass
......
...@@ -31,6 +31,19 @@ ...@@ -31,6 +31,19 @@
#include <nvif/cl0002.h> #include <nvif/cl0002.h>
#include <nvif/unpack.h> #include <nvif/unpack.h>
static const struct nvkm_object_func nvkm_dmaobj_func;
struct nvkm_dmaobj *
nvkm_dmaobj_search(struct nvkm_client *client, u64 handle)
{
struct nvkm_object *object;
object = nvkm_object_search(client, handle, &nvkm_dmaobj_func);
if (IS_ERR(object))
return (void *)object;
return nvkm_dmaobj(object);
}
static int static int
nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj, nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
int align, struct nvkm_gpuobj **pgpuobj) int align, struct nvkm_gpuobj **pgpuobj)
...@@ -42,10 +55,7 @@ nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj, ...@@ -42,10 +55,7 @@ nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
static void * static void *
nvkm_dmaobj_dtor(struct nvkm_object *base) nvkm_dmaobj_dtor(struct nvkm_object *base)
{ {
struct nvkm_dmaobj *dmaobj = nvkm_dmaobj(base); return nvkm_dmaobj(base);
if (!RB_EMPTY_NODE(&dmaobj->rb))
rb_erase(&dmaobj->rb, &dmaobj->object.client->dmaroot);
return dmaobj;
} }
static const struct nvkm_object_func static const struct nvkm_object_func
...@@ -74,7 +84,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma, ...@@ -74,7 +84,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object); nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object);
dmaobj->func = func; dmaobj->func = func;
dmaobj->dma = dma; dmaobj->dma = dma;
RB_CLEAR_NODE(&dmaobj->rb);
nvif_ioctl(parent, "create dma size %d\n", *psize); nvif_ioctl(parent, "create dma size %d\n", *psize);
if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) { if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
......
...@@ -31,6 +31,17 @@ ...@@ -31,6 +31,17 @@
#include <nvif/event.h> #include <nvif/event.h>
#include <nvif/unpack.h> #include <nvif/unpack.h>
void
nvkm_fifo_recover_chan(struct nvkm_fifo *fifo, int chid)
{
unsigned long flags;
if (WARN_ON(!fifo->func->recover_chan))
return;
spin_lock_irqsave(&fifo->lock, flags);
fifo->func->recover_chan(fifo, chid);
spin_unlock_irqrestore(&fifo->lock, flags);
}
void void
nvkm_fifo_pause(struct nvkm_fifo *fifo, unsigned long *flags) nvkm_fifo_pause(struct nvkm_fifo *fifo, unsigned long *flags)
{ {
...@@ -55,19 +66,29 @@ nvkm_fifo_chan_put(struct nvkm_fifo *fifo, unsigned long flags, ...@@ -55,19 +66,29 @@ nvkm_fifo_chan_put(struct nvkm_fifo *fifo, unsigned long flags,
} }
struct nvkm_fifo_chan * struct nvkm_fifo_chan *
nvkm_fifo_chan_inst(struct nvkm_fifo *fifo, u64 inst, unsigned long *rflags) nvkm_fifo_chan_inst_locked(struct nvkm_fifo *fifo, u64 inst)
{ {
struct nvkm_fifo_chan *chan; struct nvkm_fifo_chan *chan;
unsigned long flags;
spin_lock_irqsave(&fifo->lock, flags);
list_for_each_entry(chan, &fifo->chan, head) { list_for_each_entry(chan, &fifo->chan, head) {
if (chan->inst->addr == inst) { if (chan->inst->addr == inst) {
list_del(&chan->head); list_del(&chan->head);
list_add(&chan->head, &fifo->chan); list_add(&chan->head, &fifo->chan);
*rflags = flags;
return chan; return chan;
} }
} }
return NULL;
}
struct nvkm_fifo_chan *
nvkm_fifo_chan_inst(struct nvkm_fifo *fifo, u64 inst, unsigned long *rflags)
{
struct nvkm_fifo_chan *chan;
unsigned long flags;
spin_lock_irqsave(&fifo->lock, flags);
if ((chan = nvkm_fifo_chan_inst_locked(fifo, inst))) {
*rflags = flags;
return chan;
}
spin_unlock_irqrestore(&fifo->lock, flags); spin_unlock_irqrestore(&fifo->lock, flags);
return NULL; return NULL;
} }
...@@ -90,9 +111,34 @@ nvkm_fifo_chan_chid(struct nvkm_fifo *fifo, int chid, unsigned long *rflags) ...@@ -90,9 +111,34 @@ nvkm_fifo_chan_chid(struct nvkm_fifo *fifo, int chid, unsigned long *rflags)
return NULL; return NULL;
} }
void
nvkm_fifo_kevent(struct nvkm_fifo *fifo, int chid)
{
nvkm_event_send(&fifo->kevent, 1, chid, NULL, 0);
}
static int static int
nvkm_fifo_event_ctor(struct nvkm_object *object, void *data, u32 size, nvkm_fifo_kevent_ctor(struct nvkm_object *object, void *data, u32 size,
struct nvkm_notify *notify) struct nvkm_notify *notify)
{
struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
if (size == 0) {
notify->size = 0;
notify->types = 1;
notify->index = chan->chid;
return 0;
}
return -ENOSYS;
}
static const struct nvkm_event_func
nvkm_fifo_kevent_func = {
.ctor = nvkm_fifo_kevent_ctor,
};
static int
nvkm_fifo_cevent_ctor(struct nvkm_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{ {
if (size == 0) { if (size == 0) {
notify->size = 0; notify->size = 0;
...@@ -104,10 +150,16 @@ nvkm_fifo_event_ctor(struct nvkm_object *object, void *data, u32 size, ...@@ -104,10 +150,16 @@ nvkm_fifo_event_ctor(struct nvkm_object *object, void *data, u32 size,
} }
static const struct nvkm_event_func static const struct nvkm_event_func
nvkm_fifo_event_func = { nvkm_fifo_cevent_func = {
.ctor = nvkm_fifo_event_ctor, .ctor = nvkm_fifo_cevent_ctor,
}; };
void
nvkm_fifo_cevent(struct nvkm_fifo *fifo)
{
nvkm_event_send(&fifo->cevent, 1, 0, NULL, 0);
}
static void static void
nvkm_fifo_uevent_fini(struct nvkm_event *event, int type, int index) nvkm_fifo_uevent_fini(struct nvkm_event *event, int type, int index)
{ {
...@@ -241,6 +293,7 @@ nvkm_fifo_dtor(struct nvkm_engine *engine) ...@@ -241,6 +293,7 @@ nvkm_fifo_dtor(struct nvkm_engine *engine)
void *data = fifo; void *data = fifo;
if (fifo->func->dtor) if (fifo->func->dtor)
data = fifo->func->dtor(fifo); data = fifo->func->dtor(fifo);
nvkm_event_fini(&fifo->kevent);
nvkm_event_fini(&fifo->cevent); nvkm_event_fini(&fifo->cevent);
nvkm_event_fini(&fifo->uevent); nvkm_event_fini(&fifo->uevent);
return data; return data;
...@@ -283,5 +336,9 @@ nvkm_fifo_ctor(const struct nvkm_fifo_func *func, struct nvkm_device *device, ...@@ -283,5 +336,9 @@ nvkm_fifo_ctor(const struct nvkm_fifo_func *func, struct nvkm_device *device,
return ret; return ret;
} }
return nvkm_event_init(&nvkm_fifo_event_func, 1, 1, &fifo->cevent); ret = nvkm_event_init(&nvkm_fifo_cevent_func, 1, 1, &fifo->cevent);
if (ret)
return ret;
return nvkm_event_init(&nvkm_fifo_kevent_func, 1, nr, &fifo->kevent);
} }
...@@ -29,5 +29,5 @@ struct nvkm_fifo_chan_oclass { ...@@ -29,5 +29,5 @@ struct nvkm_fifo_chan_oclass {
struct nvkm_sclass base; struct nvkm_sclass base;
}; };
int g84_fifo_chan_ntfy(struct nvkm_fifo_chan *, u32, struct nvkm_event **); int gf100_fifo_chan_ntfy(struct nvkm_fifo_chan *, u32, struct nvkm_event **);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment