Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26c9e8ef authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/device: remove pci/platform_device from common struct



Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent c7af0ff0
Loading
Loading
Loading
Loading
+10 −30
Original line number Diff line number Diff line
@@ -47,13 +47,21 @@ enum nvkm_devidx {
	NVKM_ENGINE_SEC,
	NVKM_ENGINE_MSPDEC,

	NVKM_SUBDEV_NR,
	NVKM_SUBDEV_NR
};

enum nvkm_device_type {
	NVKM_DEVICE_PCI,
	NVKM_DEVICE_AGP,
	NVKM_DEVICE_PCIE,
	NVKM_DEVICE_TEGRA,
};

struct nvkm_device {
	const struct nvkm_device_func *func;
	const struct nvkm_device_quirk *quirk;
	struct device *dev;
	enum nvkm_device_type type;
	u64 handle;
	const char *name;
	const char *cfgopt;
@@ -63,9 +71,6 @@ struct nvkm_device {
	struct mutex mutex;
	int refcount;

	struct pci_dev *pdev;
	struct platform_device *platformdev;

	void __iomem *pri;

	struct nvkm_event event;
@@ -150,6 +155,7 @@ struct nvkm_device_func {
	void (*fini)(struct nvkm_device *, bool suspend);
	resource_size_t (*resource_addr)(struct nvkm_device *, unsigned bar);
	resource_size_t (*resource_size)(struct nvkm_device *, unsigned bar);
	bool cpu_coherent;
};

struct nvkm_device_quirk {
@@ -220,32 +226,6 @@ int nvkm_device_list(u64 *name, int size);
	_temp;                                                                 \
})

static inline bool
nv_device_is_pci(struct nvkm_device *device)
{
	return device->pdev != NULL;
}

static inline bool
nv_device_is_cpu_coherent(struct nvkm_device *device)
{
	return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device));
}

static inline struct device *
nv_device_base(struct nvkm_device *device)
{
	return nv_device_is_pci(device) ? &device->pdev->dev :
					  &device->platformdev->dev;
}

struct platform_device;

enum nv_bus_type {
	NVKM_BUS_PCI,
	NVKM_BUS_PLATFORM,
};

void nvkm_device_del(struct nvkm_device **);

struct nvkm_device_oclass {
+3 −3
Original line number Diff line number Diff line
@@ -174,19 +174,19 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
		getparam->value = device->info.chipset;
		break;
	case NOUVEAU_GETPARAM_PCI_VENDOR:
		if (nv_device_is_pci(nvxx_device(device)))
		if (nvxx_device(device)->func->pci)
			getparam->value = dev->pdev->vendor;
		else
			getparam->value = 0;
		break;
	case NOUVEAU_GETPARAM_PCI_DEVICE:
		if (nv_device_is_pci(nvxx_device(device)))
		if (nvxx_device(device)->func->pci)
			getparam->value = dev->pdev->device;
		else
			getparam->value = 0;
		break;
	case NOUVEAU_GETPARAM_BUS_TYPE:
		if (!nv_device_is_pci(nvxx_device(device)))
		if (!nvxx_device(device)->func->pci)
			getparam->value = 3;
		else
		if (drm_pci_device_is_agp(dev))
+2 −2
Original line number Diff line number Diff line
@@ -372,12 +372,12 @@ static int nouveau_rom_call(acpi_handle rom_handle, uint8_t *bios,
	return len;
}

bool nouveau_acpi_rom_supported(struct pci_dev *pdev)
bool nouveau_acpi_rom_supported(struct device *dev)
{
	acpi_status status;
	acpi_handle dhandle, rom_handle;

	dhandle = ACPI_HANDLE(&pdev->dev);
	dhandle = ACPI_HANDLE(dev);
	if (!dhandle)
		return false;

+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ void nouveau_register_dsm_handler(void);
void nouveau_unregister_dsm_handler(void);
void nouveau_switcheroo_optimus_dsm(void);
int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len);
bool nouveau_acpi_rom_supported(struct pci_dev *pdev);
bool nouveau_acpi_rom_supported(struct device *);
void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *);
#else
static inline bool nouveau_is_optimus(void) { return false; };
@@ -18,7 +18,7 @@ static inline bool nouveau_is_v1_dsm(void) { return false; };
static inline void nouveau_register_dsm_handler(void) {}
static inline void nouveau_unregister_dsm_handler(void) {}
static inline void nouveau_switcheroo_optimus_dsm(void) {}
static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; }
static inline bool nouveau_acpi_rom_supported(struct device *dev) { return false; }
static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }
static inline void *nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return NULL; }
#endif
+5 −2
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
#include "nouveau_agp.h"
#include "nouveau_reg.h"

#include <core/pci.h>

#if __OS_HAS_AGP
MODULE_PARM_DESC(agpmode, "AGP mode (0 to disable AGP)");
static int nouveau_agpmode = -1;
@@ -28,6 +30,7 @@ static unsigned long
get_agp_mode(struct nouveau_drm *drm, const struct drm_agp_info *info)
{
	struct nvif_device *device = &drm->device;
	struct pci_dev *pdev = nvxx_device(device)->func->pci(nvxx_device(device))->pdev;
	struct nouveau_agpmode_quirk *quirk = nouveau_agpmode_quirk_list;
	int agpmode = nouveau_agpmode;
	unsigned long mode = info->mode;
@@ -45,8 +48,8 @@ get_agp_mode(struct nouveau_drm *drm, const struct drm_agp_info *info)
	while (agpmode == -1 && quirk->hostbridge_vendor) {
		if (info->id_vendor == quirk->hostbridge_vendor &&
		    info->id_device == quirk->hostbridge_device &&
		    nvxx_device(device)->pdev->vendor == quirk->chip_vendor &&
		    nvxx_device(device)->pdev->device == quirk->chip_device) {
		    pdev->vendor == quirk->chip_vendor &&
		    pdev->device == quirk->chip_device) {
			agpmode = quirk->mode;
			NV_INFO(drm, "Forcing agp mode to %dX. Use agpmode to override.\n",
				agpmode);
Loading