[Intel-gfx] [PATCH v2 02/37] drm/i915: introduce intel_memory_region
Chris Wilson
chris at chris-wilson.co.uk
Fri Jun 28 08:09:36 UTC 2019
Quoting Matthew Auld (2019-06-27 21:55:58)
> @@ -0,0 +1,107 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2019 Intel Corporation
> + */
> +
> +#ifndef __INTEL_MEMORY_REGION_H__
> +#define __INTEL_MEMORY_REGION_H__
> +
> +#include <linux/ioport.h>
> +#include <linux/mutex.h>
> +#include <linux/io-mapping.h>
> +
> +#include "i915_buddy.h"
> +
> +struct drm_i915_private;
> +struct drm_i915_gem_object;
> +struct intel_memory_region;
> +struct sg_table;
> +
> +/**
> + * Base memory type
> + */
> +enum intel_memory_type {
> + INTEL_SMEM = 0,
> + INTEL_LMEM,
> + INTEL_STOLEN,
> +};
> +
> +enum intel_region_id {
> + INTEL_MEMORY_SMEM = 0,
> + INTEL_MEMORY_LMEM,
> + INTEL_MEMORY_STOLEN,
> + INTEL_MEMORY_UKNOWN, /* Should be last */
> +};
> +
> +#define REGION_SMEM BIT(INTEL_MEMORY_SMEM)
> +#define REGION_LMEM BIT(INTEL_MEMORY_LMEM)
> +#define REGION_STOLEN BIT(INTEL_MEMORY_STOLEN)
> +
> +#define INTEL_MEMORY_TYPE_SHIFT 16
> +
> +#define MEMORY_TYPE_FROM_REGION(r) (ilog2(r >> INTEL_MEMORY_TYPE_SHIFT))
> +#define MEMORY_INSTANCE_FROM_REGION(r) (ilog2(r & 0xffff))
> +
> +/**
> + * Memory regions encoded as type | instance
> + */
> +static const u32 intel_region_map[] = {
> + [INTEL_MEMORY_SMEM] = BIT(INTEL_SMEM + INTEL_MEMORY_TYPE_SHIFT) | BIT(0),
> + [INTEL_MEMORY_LMEM] = BIT(INTEL_LMEM + INTEL_MEMORY_TYPE_SHIFT) | BIT(0),
> + [INTEL_MEMORY_STOLEN] = BIT(INTEL_STOLEN + INTEL_MEMORY_TYPE_SHIFT) | BIT(0),
> +};
You put this array into the header, ergo a separate instance is created
for every compilation unit pulling in this header. Incoming build
failure report :-p
-Chris
More information about the Intel-gfx
mailing list