drivers/gpu/drm/loongson/lsdc_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/loongson/lsdc_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/loongson/lsdc_debugfs.c
Extension
.c
Size
3008 bytes
Lines
112
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2023 Loongson Technology Corporation Limited
 */

#include <drm/drm_debugfs.h>
#include <drm/drm_print.h>

#include "lsdc_benchmark.h"
#include "lsdc_drv.h"
#include "lsdc_gem.h"
#include "lsdc_probe.h"
#include "lsdc_ttm.h"

/* device level debugfs */

static int lsdc_identify(struct seq_file *m, void *arg)
{
	struct drm_info_node *node = (struct drm_info_node *)m->private;
	struct lsdc_device *ldev = (struct lsdc_device *)node->info_ent->data;
	const struct loongson_gfx_desc *gfx = to_loongson_gfx(ldev->descp);
	u8 impl, rev;

	loongson_cpu_get_prid(&impl, &rev);

	seq_printf(m, "Running on cpu 0x%x, cpu revision: 0x%x\n",
		   impl, rev);

	seq_printf(m, "Contained in: %s\n", gfx->model);

	return 0;
}

static int lsdc_show_mm(struct seq_file *m, void *arg)
{
	struct drm_info_node *node = (struct drm_info_node *)m->private;
	struct drm_device *ddev = node->minor->dev;
	struct drm_printer p = drm_seq_file_printer(m);

	drm_mm_print(&ddev->vma_offset_manager->vm_addr_space_mm, &p);

	return 0;
}

static int lsdc_show_gfxpll_clock(struct seq_file *m, void *arg)
{
	struct drm_info_node *node = (struct drm_info_node *)m->private;
	struct lsdc_device *ldev = (struct lsdc_device *)node->info_ent->data;
	struct drm_printer printer = drm_seq_file_printer(m);
	struct loongson_gfxpll *gfxpll = ldev->gfxpll;

	gfxpll->funcs->print(gfxpll, &printer, true);

	return 0;
}

static int lsdc_show_benchmark(struct seq_file *m, void *arg)
{
	struct drm_info_node *node = (struct drm_info_node *)m->private;
	struct lsdc_device *ldev = (struct lsdc_device *)node->info_ent->data;
	struct drm_printer printer = drm_seq_file_printer(m);

	lsdc_show_benchmark_copy(ldev, &printer);

	return 0;
}

static int lsdc_pdev_enable_io_mem(struct seq_file *m, void *arg)
{
	struct drm_info_node *node = (struct drm_info_node *)m->private;
	struct lsdc_device *ldev = (struct lsdc_device *)node->info_ent->data;
	u16 cmd;

	pci_read_config_word(ldev->dc, PCI_COMMAND, &cmd);

	seq_printf(m, "PCI_COMMAND: 0x%x\n", cmd);

	cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_IO;

	pci_write_config_word(ldev->dc, PCI_COMMAND, cmd);

	pci_read_config_word(ldev->dc, PCI_COMMAND, &cmd);

	seq_printf(m, "PCI_COMMAND: 0x%x\n", cmd);

	return 0;
}

static struct drm_info_list lsdc_debugfs_list[] = {
	{ "benchmark",   lsdc_show_benchmark, 0, NULL },

Annotation

Implementation Notes