Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/cortex Allow non-power of 2 counts, and support...
details: https://anonhg.NetBSD.org/src/rev/ec44e4d3a7a4
branches: trunk
changeset: 994943:ec44e4d3a7a4
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Nov 28 22:54:11 2018 +0000
description:
Allow non-power of 2 counts, and support alloc/release/alloc patterns for a device as long as the ITT size is sufficient
diffstat:
sys/arch/arm/cortex/gicv3_its.c | 21 ++++++++++++---------
sys/arch/arm/cortex/gicv3_its.h | 3 ++-
2 files changed, 14 insertions(+), 10 deletions(-)
diffs (68 lines):
diff -r de0965a16059 -r ec44e4d3a7a4 sys/arch/arm/cortex/gicv3_its.c
--- a/sys/arch/arm/cortex/gicv3_its.c Wed Nov 28 22:29:36 2018 +0000
+++ b/sys/arch/arm/cortex/gicv3_its.c Wed Nov 28 22:54:11 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.8 2018/11/24 15:40:57 skrll Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.9 2018/11/28 22:54:11 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#define _INTR_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.8 2018/11/24 15:40:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.9 2018/11/28 22:54:11 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -293,22 +293,25 @@
gicv3_its_device_map(struct gicv3_its *its, uint32_t devid, u_int count)
{
struct gicv3_its_device *dev;
+ u_int vectors;
- LIST_FOREACH(dev, &its->its_devices, dev_list)
- if (dev->dev_id == devid)
- return EEXIST;
-
- const u_int vectors = MAX(2, count);
- if (!powerof2(vectors))
- return EINVAL;
+ vectors = MAX(2, count);
+ while (!powerof2(vectors))
+ vectors++;
const uint64_t typer = gits_read_8(its, GITS_TYPER);
const u_int id_bits = __SHIFTOUT(typer, GITS_TYPER_ID_bits) + 1;
const u_int itt_entry_size = __SHIFTOUT(typer, GITS_TYPER_ITT_entry_size) + 1;
const u_int itt_size = roundup(vectors * itt_entry_size, GITS_ITT_ALIGN);
+ LIST_FOREACH(dev, &its->its_devices, dev_list)
+ if (dev->dev_id == devid) {
+ return itt_size <= dev->dev_size ? 0 : EEXIST;
+ }
+
dev = kmem_alloc(sizeof(*dev), KM_SLEEP);
dev->dev_id = devid;
+ dev->dev_size = itt_size;
gicv3_dma_alloc(its->its_gic, &dev->dev_itt, itt_size, GITS_ITT_ALIGN);
LIST_INSERT_HEAD(&its->its_devices, dev, dev_list);
diff -r de0965a16059 -r ec44e4d3a7a4 sys/arch/arm/cortex/gicv3_its.h
--- a/sys/arch/arm/cortex/gicv3_its.h Wed Nov 28 22:29:36 2018 +0000
+++ b/sys/arch/arm/cortex/gicv3_its.h Wed Nov 28 22:54:11 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.h,v 1.3 2018/11/24 22:08:53 jakllsch Exp $ */
+/* $NetBSD: gicv3_its.h,v 1.4 2018/11/28 22:54:11 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
struct gicv3_its_device {
uint32_t dev_id;
+ u_int dev_size;
struct gicv3_dma dev_itt;
LIST_ENTRY(gicv3_its_device) dev_list;
Home |
Main Index |
Thread Index |
Old Index