Commit 359088d5 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau: remove trivial cases of nvxx_device() usage

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 920d2b5e
...@@ -185,29 +185,33 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) ...@@ -185,29 +185,33 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
getparam->value = device->info.chipset; getparam->value = device->info.chipset;
break; break;
case NOUVEAU_GETPARAM_PCI_VENDOR: case NOUVEAU_GETPARAM_PCI_VENDOR:
if (nvxx_device(device)->func->pci) if (device->info.platform != NV_DEVICE_INFO_V0_SOC)
getparam->value = dev->pdev->vendor; getparam->value = dev->pdev->vendor;
else else
getparam->value = 0; getparam->value = 0;
break; break;
case NOUVEAU_GETPARAM_PCI_DEVICE: case NOUVEAU_GETPARAM_PCI_DEVICE:
if (nvxx_device(device)->func->pci) if (device->info.platform != NV_DEVICE_INFO_V0_SOC)
getparam->value = dev->pdev->device; getparam->value = dev->pdev->device;
else else
getparam->value = 0; getparam->value = 0;
break; break;
case NOUVEAU_GETPARAM_BUS_TYPE: case NOUVEAU_GETPARAM_BUS_TYPE:
if (!nvxx_device(device)->func->pci) switch (device->info.platform) {
getparam->value = 3; case NV_DEVICE_INFO_V0_AGP : getparam->value = 0; break;
else case NV_DEVICE_INFO_V0_PCI : getparam->value = 1; break;
if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP)) case NV_DEVICE_INFO_V0_PCIE: getparam->value = 2; break;
getparam->value = 0; case NV_DEVICE_INFO_V0_SOC : getparam->value = 3; break;
else case NV_DEVICE_INFO_V0_IGP :
if (!pci_is_pcie(dev->pdev)) if (!pci_is_pcie(dev->pdev))
getparam->value = 1; getparam->value = 1;
else else
getparam->value = 2; getparam->value = 2;
break; break;
default:
WARN_ON(1);
break;
}
case NOUVEAU_GETPARAM_FB_SIZE: case NOUVEAU_GETPARAM_FB_SIZE:
getparam->value = drm->gem.vram_available; getparam->value = drm->gem.vram_available;
break; break;
......
...@@ -50,8 +50,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg, ...@@ -50,8 +50,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg,
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
int i = reg - drm->tile.reg; int i = reg - drm->tile.reg;
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_fb *fb = nvxx_fb(&drm->client.device);
struct nvkm_fb *fb = device->fb;
struct nvkm_fb_tile *tile = &fb->tile.region[i]; struct nvkm_fb_tile *tile = &fb->tile.region[i];
nouveau_fence_unref(&reg->fence); nouveau_fence_unref(&reg->fence);
...@@ -459,7 +458,6 @@ void ...@@ -459,7 +458,6 @@ void
nouveau_bo_sync_for_device(struct nouveau_bo *nvbo) nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
{ {
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
struct nvkm_device *device = nvxx_device(&drm->client.device);
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm; struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i; int i;
...@@ -471,7 +469,8 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo) ...@@ -471,7 +469,8 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
return; return;
for (i = 0; i < ttm_dma->ttm.num_pages; i++) for (i = 0; i < ttm_dma->ttm.num_pages; i++)
dma_sync_single_for_device(device->dev, ttm_dma->dma_address[i], dma_sync_single_for_device(drm->dev->dev,
ttm_dma->dma_address[i],
PAGE_SIZE, DMA_TO_DEVICE); PAGE_SIZE, DMA_TO_DEVICE);
} }
...@@ -479,7 +478,6 @@ void ...@@ -479,7 +478,6 @@ void
nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo) nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
{ {
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
struct nvkm_device *device = nvxx_device(&drm->client.device);
struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm; struct ttm_dma_tt *ttm_dma = (struct ttm_dma_tt *)nvbo->bo.ttm;
int i; int i;
...@@ -491,7 +489,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo) ...@@ -491,7 +489,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
return; return;
for (i = 0; i < ttm_dma->ttm.num_pages; i++) for (i = 0; i < ttm_dma->ttm.num_pages; i++)
dma_sync_single_for_cpu(device->dev, ttm_dma->dma_address[i], dma_sync_single_for_cpu(drm->dev->dev, ttm_dma->dma_address[i],
PAGE_SIZE, DMA_FROM_DEVICE); PAGE_SIZE, DMA_FROM_DEVICE);
} }
...@@ -1468,9 +1466,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) ...@@ -1468,9 +1466,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
{ {
struct ttm_dma_tt *ttm_dma = (void *)ttm; struct ttm_dma_tt *ttm_dma = (void *)ttm;
struct nouveau_drm *drm; struct nouveau_drm *drm;
struct nvkm_device *device; struct device *dev;
struct drm_device *dev;
struct device *pdev;
unsigned i; unsigned i;
int r; int r;
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
...@@ -1487,9 +1483,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) ...@@ -1487,9 +1483,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
} }
drm = nouveau_bdev(ttm->bdev); drm = nouveau_bdev(ttm->bdev);
device = nvxx_device(&drm->client.device); dev = drm->dev->dev;
dev = drm->dev;
pdev = device->dev;
#if IS_ENABLED(CONFIG_AGP) #if IS_ENABLED(CONFIG_AGP)
if (drm->agp.bridge) { if (drm->agp.bridge) {
...@@ -1499,7 +1493,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) ...@@ -1499,7 +1493,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
if (swiotlb_nr_tbl()) { if (swiotlb_nr_tbl()) {
return ttm_dma_populate((void *)ttm, dev->dev); return ttm_dma_populate((void *)ttm, dev);
} }
#endif #endif
...@@ -1511,12 +1505,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) ...@@ -1511,12 +1505,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
for (i = 0; i < ttm->num_pages; i++) { for (i = 0; i < ttm->num_pages; i++) {
dma_addr_t addr; dma_addr_t addr;
addr = dma_map_page(pdev, ttm->pages[i], 0, PAGE_SIZE, addr = dma_map_page(dev, ttm->pages[i], 0, PAGE_SIZE,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (dma_mapping_error(pdev, addr)) { if (dma_mapping_error(dev, addr)) {
while (i--) { while (i--) {
dma_unmap_page(pdev, ttm_dma->dma_address[i], dma_unmap_page(dev, ttm_dma->dma_address[i],
PAGE_SIZE, DMA_BIDIRECTIONAL); PAGE_SIZE, DMA_BIDIRECTIONAL);
ttm_dma->dma_address[i] = 0; ttm_dma->dma_address[i] = 0;
} }
...@@ -1534,9 +1528,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) ...@@ -1534,9 +1528,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
{ {
struct ttm_dma_tt *ttm_dma = (void *)ttm; struct ttm_dma_tt *ttm_dma = (void *)ttm;
struct nouveau_drm *drm; struct nouveau_drm *drm;
struct nvkm_device *device; struct device *dev;
struct drm_device *dev;
struct device *pdev;
unsigned i; unsigned i;
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
...@@ -1544,9 +1536,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) ...@@ -1544,9 +1536,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
return; return;
drm = nouveau_bdev(ttm->bdev); drm = nouveau_bdev(ttm->bdev);
device = nvxx_device(&drm->client.device); dev = drm->dev->dev;
dev = drm->dev;
pdev = device->dev;
#if IS_ENABLED(CONFIG_AGP) #if IS_ENABLED(CONFIG_AGP)
if (drm->agp.bridge) { if (drm->agp.bridge) {
...@@ -1557,14 +1547,14 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) ...@@ -1557,14 +1547,14 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
if (swiotlb_nr_tbl()) { if (swiotlb_nr_tbl()) {
ttm_dma_unpopulate((void *)ttm, dev->dev); ttm_dma_unpopulate((void *)ttm, dev);
return; return;
} }
#endif #endif
for (i = 0; i < ttm->num_pages; i++) { for (i = 0; i < ttm->num_pages; i++) {
if (ttm_dma->dma_address[i]) { if (ttm_dma->dma_address[i]) {
dma_unmap_page(pdev, ttm_dma->dma_address[i], PAGE_SIZE, dma_unmap_page(dev, ttm_dma->dma_address[i], PAGE_SIZE,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
} }
} }
......
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