Skip to content

Commit 6530343

Browse files
committed
agp/intel-gtt: Add intel_gmch_gtt_read_entry()
JIRA: https://issues.redhat.com/browse/RHEL-113204 commit 8f0d361 Author: Ville Syrjälä <ville.syrjala@linux.intel.com> Date: Thu Mar 13 16:08:31 2025 +0200 agp/intel-gtt: Add intel_gmch_gtt_read_entry() i915 wants to read out the PTE(s) populated by the BIOS/GOP to verify that the framebuffer is in the correct location. Introduce intel_gmch_gtt_read_entry() that reads out the PTE and decodes it to a somewhat abstract form. For now we just return the dma_addr, present bit, and local memory bit. I didn't bother with the snoop bit/etc. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250313140838.29742-4-ville.syrjala@linux.intel.com Reviewed-by: Jouni Högander <jouni.hogander@intel.com> Signed-off-by: José Expósito <jexposit@redhat.com>
1 parent 8c3c7aa commit 6530343

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

drivers/char/agp/intel-gtt.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct intel_gtt_driver {
5353
* of the mmio register file, that's done in the generic code. */
5454
void (*cleanup)(void);
5555
void (*write_entry)(dma_addr_t addr, unsigned int entry, unsigned int flags);
56+
dma_addr_t (*read_entry)(unsigned int entry, bool *is_present, bool *is_local);
5657
/* Flags is a more or less chipset specific opaque value.
5758
* For chipsets that need to support old ums (non-gem) code, this
5859
* needs to be identical to the various supported agp memory types! */
@@ -336,6 +337,19 @@ static void i810_write_entry(dma_addr_t addr, unsigned int entry,
336337
writel_relaxed(addr | pte_flags, intel_private.gtt + entry);
337338
}
338339

340+
static dma_addr_t i810_read_entry(unsigned int entry,
341+
bool *is_present, bool *is_local)
342+
{
343+
u32 val;
344+
345+
val = readl(intel_private.gtt + entry);
346+
347+
*is_present = val & I810_PTE_VALID;
348+
*is_local = val & I810_PTE_LOCAL;
349+
350+
return val & ~0xfff;
351+
}
352+
339353
static resource_size_t intel_gtt_stolen_size(void)
340354
{
341355
u16 gmch_ctrl;
@@ -741,6 +755,19 @@ static void i830_write_entry(dma_addr_t addr, unsigned int entry,
741755
writel_relaxed(addr | pte_flags, intel_private.gtt + entry);
742756
}
743757

758+
static dma_addr_t i830_read_entry(unsigned int entry,
759+
bool *is_present, bool *is_local)
760+
{
761+
u32 val;
762+
763+
val = readl(intel_private.gtt + entry);
764+
765+
*is_present = val & I810_PTE_VALID;
766+
*is_local = false;
767+
768+
return val & ~0xfff;
769+
}
770+
744771
bool intel_gmch_enable_gtt(void)
745772
{
746773
u8 __iomem *reg;
@@ -878,6 +905,13 @@ void intel_gmch_gtt_insert_sg_entries(struct sg_table *st,
878905
}
879906
EXPORT_SYMBOL(intel_gmch_gtt_insert_sg_entries);
880907

908+
dma_addr_t intel_gmch_gtt_read_entry(unsigned int pg,
909+
bool *is_present, bool *is_local)
910+
{
911+
return intel_private.driver->read_entry(pg, is_present, is_local);
912+
}
913+
EXPORT_SYMBOL(intel_gmch_gtt_read_entry);
914+
881915
#if IS_ENABLED(CONFIG_AGP_INTEL)
882916
static void intel_gmch_gtt_insert_pages(unsigned int first_entry,
883917
unsigned int num_entries,
@@ -1126,6 +1160,19 @@ static void i965_write_entry(dma_addr_t addr,
11261160
writel_relaxed(addr | pte_flags, intel_private.gtt + entry);
11271161
}
11281162

1163+
static dma_addr_t i965_read_entry(unsigned int entry,
1164+
bool *is_present, bool *is_local)
1165+
{
1166+
u64 val;
1167+
1168+
val = readl(intel_private.gtt + entry);
1169+
1170+
*is_present = val & I810_PTE_VALID;
1171+
*is_local = false;
1172+
1173+
return ((val & 0xf0) << 28) | (val & ~0xfff);
1174+
}
1175+
11291176
static int i9xx_setup(void)
11301177
{
11311178
phys_addr_t reg_addr;
@@ -1187,13 +1234,15 @@ static const struct intel_gtt_driver i81x_gtt_driver = {
11871234
.cleanup = i810_cleanup,
11881235
.check_flags = i830_check_flags,
11891236
.write_entry = i810_write_entry,
1237+
.read_entry = i810_read_entry,
11901238
};
11911239
static const struct intel_gtt_driver i8xx_gtt_driver = {
11921240
.gen = 2,
11931241
.has_pgtbl_enable = 1,
11941242
.setup = i830_setup,
11951243
.cleanup = i830_cleanup,
11961244
.write_entry = i830_write_entry,
1245+
.read_entry = i830_read_entry,
11971246
.dma_mask_size = 32,
11981247
.check_flags = i830_check_flags,
11991248
.chipset_flush = i830_chipset_flush,
@@ -1205,6 +1254,7 @@ static const struct intel_gtt_driver i915_gtt_driver = {
12051254
.cleanup = i9xx_cleanup,
12061255
/* i945 is the last gpu to need phys mem (for overlay and cursors). */
12071256
.write_entry = i830_write_entry,
1257+
.read_entry = i830_read_entry,
12081258
.dma_mask_size = 32,
12091259
.check_flags = i830_check_flags,
12101260
.chipset_flush = i9xx_chipset_flush,
@@ -1215,6 +1265,7 @@ static const struct intel_gtt_driver g33_gtt_driver = {
12151265
.setup = i9xx_setup,
12161266
.cleanup = i9xx_cleanup,
12171267
.write_entry = i965_write_entry,
1268+
.read_entry = i965_read_entry,
12181269
.dma_mask_size = 36,
12191270
.check_flags = i830_check_flags,
12201271
.chipset_flush = i9xx_chipset_flush,
@@ -1225,6 +1276,7 @@ static const struct intel_gtt_driver pineview_gtt_driver = {
12251276
.setup = i9xx_setup,
12261277
.cleanup = i9xx_cleanup,
12271278
.write_entry = i965_write_entry,
1279+
.read_entry = i965_read_entry,
12281280
.dma_mask_size = 36,
12291281
.check_flags = i830_check_flags,
12301282
.chipset_flush = i9xx_chipset_flush,
@@ -1235,6 +1287,7 @@ static const struct intel_gtt_driver i965_gtt_driver = {
12351287
.setup = i9xx_setup,
12361288
.cleanup = i9xx_cleanup,
12371289
.write_entry = i965_write_entry,
1290+
.read_entry = i965_read_entry,
12381291
.dma_mask_size = 36,
12391292
.check_flags = i830_check_flags,
12401293
.chipset_flush = i9xx_chipset_flush,
@@ -1244,6 +1297,7 @@ static const struct intel_gtt_driver g4x_gtt_driver = {
12441297
.setup = i9xx_setup,
12451298
.cleanup = i9xx_cleanup,
12461299
.write_entry = i965_write_entry,
1300+
.read_entry = i965_read_entry,
12471301
.dma_mask_size = 36,
12481302
.check_flags = i830_check_flags,
12491303
.chipset_flush = i9xx_chipset_flush,
@@ -1254,6 +1308,7 @@ static const struct intel_gtt_driver ironlake_gtt_driver = {
12541308
.setup = i9xx_setup,
12551309
.cleanup = i9xx_cleanup,
12561310
.write_entry = i965_write_entry,
1311+
.read_entry = i965_read_entry,
12571312
.dma_mask_size = 36,
12581313
.check_flags = i830_check_flags,
12591314
.chipset_flush = i9xx_chipset_flush,

include/drm/intel/intel-gtt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ void intel_gmch_gtt_insert_sg_entries(struct sg_table *st,
2828
unsigned int pg_start,
2929
unsigned int flags);
3030
void intel_gmch_gtt_clear_range(unsigned int first_entry, unsigned int num_entries);
31+
dma_addr_t intel_gmch_gtt_read_entry(unsigned int pg,
32+
bool *is_present, bool *is_local);
3133

3234
/* Special gtt memory types */
3335
#define AGP_DCACHE_MEMORY 1

0 commit comments

Comments
 (0)