svn commit: r304746 - in head/sys/arm64: arm64 include

2016-08-24 Thread Andrew Turner
Author: andrew
Date: Wed Aug 24 12:32:18 2016
New Revision: 304746
URL: https://svnweb.freebsd.org/changeset/base/304746

Log:
  Teach the parts of the arm64 pmap that need to iterate over pages to also
  iterate over superpages. We don't yet create these, but soon will.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/include/pmap.h

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Wed Aug 24 11:35:49 2016(r304745)
+++ head/sys/arm64/arm64/pmap.c Wed Aug 24 12:32:18 2016(r304746)
@@ -106,6 +106,7 @@ __FBSDID("$FreeBSD$");
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -134,6 +135,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -176,6 +178,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #definepmap_l2_pindex(v)   ((v) >> L2_SHIFT)
+#definepa_to_pvh(pa)   (_table[pmap_l2_pindex(pa)])
 
 #defineNPV_LIST_LOCKS  MAXCPU
 
@@ -218,6 +221,14 @@ vm_offset_t kernel_vm_end = 0;
 
 struct msgbuf *msgbufp = NULL;
 
+/*
+ * Data for the pv entry allocation mechanism.
+ * Updates to pv_invl_gen are protected by the pv_list_locks[]
+ * elements, but reads are not.
+ */
+static struct md_page *pv_table;
+static struct md_page pv_dummy;
+
 vm_paddr_t dmap_phys_base; /* The start of the dmap region */
 vm_paddr_t dmap_phys_max;  /* The limit of the dmap region */
 vm_offset_t dmap_max_addr; /* The virtual address limit of the dmap */
@@ -855,7 +866,8 @@ pmap_page_init(vm_page_t m)
 void
 pmap_init(void)
 {
-   int i;
+   vm_size_t s;
+   int i, pv_npg;
 
/*
 * Are large page mappings enabled?
@@ -872,6 +884,22 @@ pmap_init(void)
 */
for (i = 0; i < NPV_LIST_LOCKS; i++)
rw_init(_list_locks[i], "pmap pv list");
+
+   /*
+* Calculate the size of the pv head table for superpages.
+*/
+   pv_npg = howmany(vm_phys_segs[vm_phys_nsegs - 1].end, L2_SIZE);
+
+   /*
+* Allocate memory for the pv head table for superpages.
+*/
+   s = (vm_size_t)(pv_npg * sizeof(struct md_page));
+   s = round_page(s);
+   pv_table = (struct md_page *)kmem_malloc(kernel_arena, s,
+   M_WAITOK | M_ZERO);
+   for (i = 0; i < pv_npg; i++)
+   TAILQ_INIT(_table[i].pv_list);
+   TAILQ_INIT(_dummy.pv_list);
 }
 
 static SYSCTL_NODE(_vm_pmap, OID_AUTO, l2, CTLFLAG_RD, 0,
@@ -1399,6 +1427,7 @@ pmap_pinit0(pmap_t pmap)
PMAP_LOCK_INIT(pmap);
bzero(>pm_stats, sizeof(pmap->pm_stats));
pmap->pm_l0 = kernel_pmap->pm_l0;
+   pmap->pm_root.rt_root = 0;
 }
 
 int
@@ -1420,6 +1449,7 @@ pmap_pinit(pmap_t pmap)
if ((l0pt->flags & PG_ZERO) == 0)
pagezero(pmap->pm_l0);
 
+   pmap->pm_root.rt_root = 0;
bzero(>pm_stats, sizeof(pmap->pm_stats));
 
return (1);
@@ -1643,6 +1673,8 @@ pmap_release(pmap_t pmap)
KASSERT(pmap->pm_stats.resident_count == 0,
("pmap_release: pmap resident count %ld != 0",
pmap->pm_stats.resident_count));
+   KASSERT(vm_radix_is_empty(>pm_root),
+   ("pmap_release: pmap has reserved page table page(s)"));
 
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_l0));
 
@@ -1991,6 +2023,7 @@ static int
 pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va,
 pd_entry_t l2e, struct spglist *free, struct rwlock **lockp)
 {
+   struct md_page *pvh;
pt_entry_t old_l3;
vm_page_t m;
 
@@ -2011,6 +2044,12 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *
vm_page_aflag_set(m, PGA_REFERENCED);
CHANGE_PV_LIST_LOCK_TO_VM_PAGE(lockp, m);
pmap_pvh_free(>md, pmap, va);
+   if (TAILQ_EMPTY(>md.pv_list) &&
+   (m->flags & PG_FICTITIOUS) == 0) {
+   pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m));
+   if (TAILQ_EMPTY(>pv_list))
+   vm_page_aflag_clear(m, PGA_WRITEABLE);
+   }
}
return (pmap_unuse_l3(pmap, va, l2e, free));
 }
@@ -2147,28 +2186,56 @@ pmap_remove(pmap_t pmap, vm_offset_t sva
 void
 pmap_remove_all(vm_page_t m)
 {
+   struct md_page *pvh;
pv_entry_t pv;
pmap_t pmap;
struct rwlock *lock;
pd_entry_t *pde, tpde;
pt_entry_t *pte, tpte;
+   vm_offset_t va;
struct spglist free;
-   int lvl, md_gen;
+   int lvl, pvh_gen, md_gen;
 
KASSERT((m->oflags & VPO_UNMANAGED) == 0,
("pmap_remove_all: page %p is not managed", m));
SLIST_INIT();
lock = VM_PAGE_TO_PV_LIST_LOCK(m);
+   pvh = (m->flags & PG_FICTITIOUS) != 0 ? _dummy :
+   pa_to_pvh(VM_PAGE_TO_PHYS(m));
 retry:
  

svn commit: r304689 - head/sys/arm64/arm64

2016-08-23 Thread Andrew Turner
Author: andrew
Date: Tue Aug 23 16:37:34 2016
New Revision: 304689
URL: https://svnweb.freebsd.org/changeset/base/304689

Log:
  Also adjust the virtual address passed to vm_page_pa_tryrelock.
  
  Reported by:  alc
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug 23 16:20:56 2016(r304688)
+++ head/sys/arm64/arm64/pmap.c Tue Aug 23 16:37:34 2016(r304689)
@@ -1028,7 +1028,8 @@ retry:
default:
off = 0;
}
-   if (vm_page_pa_tryrelock(pmap, tpte & ~ATTR_MASK, ))
+   if (vm_page_pa_tryrelock(pmap,
+   (tpte & ~ATTR_MASK) | off, ))
goto retry;
m = PHYS_TO_VM_PAGE((tpte & ~ATTR_MASK) | off);
vm_page_hold(m);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304688 - head/sys/arm64/arm64

2016-08-23 Thread Andrew Turner
Author: andrew
Date: Tue Aug 23 16:20:56 2016
New Revision: 304688
URL: https://svnweb.freebsd.org/changeset/base/304688

Log:
  Map memory as read-only in pmap_enter_quick_locked as is done in other
  pmap implementations.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug 23 16:12:25 2016(r304687)
+++ head/sys/arm64/arm64/pmap.c Tue Aug 23 16:20:56 2016(r304688)
@@ -2794,7 +2794,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_
pmap_resident_count_inc(pmap, 1);
 
pa = VM_PAGE_TO_PHYS(m) | ATTR_DEFAULT | ATTR_IDX(m->md.pv_memattr) |
-   ATTR_AP(ATTR_AP_RW) | L3_PAGE;
+   ATTR_AP(ATTR_AP_RO) | L3_PAGE;
 
/*
 * Now validate mapping with RO protection
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304687 - head/sys/arm64/arm64

2016-08-23 Thread Andrew Turner
Author: andrew
Date: Tue Aug 23 16:12:25 2016
New Revision: 304687
URL: https://svnweb.freebsd.org/changeset/base/304687

Log:
  If we find we have a superpage in pmap_enter_quick_locked return without
  trying to add a new level 3 page.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug 23 15:49:31 2016(r304686)
+++ head/sys/arm64/arm64/pmap.c Tue Aug 23 16:12:25 2016(r304687)
@@ -2696,7 +2696,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_
 {
struct spglist free;
pd_entry_t *pde;
-   pt_entry_t *l3;
+   pt_entry_t *l2, *l3;
vm_paddr_t pa;
int lvl;
 
@@ -2731,6 +2731,12 @@ pmap_enter_quick_locked(pmap_t pmap, vm_
 * attempt to allocate a page table page.  If this
 * attempt fails, we don't retry.  Instead, we give up.
 */
+   if (lvl == 1) {
+   l2 = pmap_l1_to_l2(pde, va);
+   if ((pmap_load(l2) & ATTR_DESCR_MASK) ==
+   L2_BLOCK)
+   return (NULL);
+   }
if (lvl == 2 && pmap_load(pde) != 0) {
mpte =
PHYS_TO_VM_PAGE(pmap_load(pde) & 
~ATTR_MASK);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304685 - head/sys/arm64/arm64

2016-08-23 Thread Andrew Turner
Author: andrew
Date: Tue Aug 23 15:48:27 2016
New Revision: 304685
URL: https://svnweb.freebsd.org/changeset/base/304685

Log:
  Include the offset the virtual address is within an L1 or L2 block when
  finding the vm_page_t in pmap_extract_and_hold. Previously it would return
  the vm_page_t of the first page in a block. This would cause issues when,
  for example, fsck reads from a device into the middle of a superpage. In
  this case the read call would write to the start of the block, and not to
  the buffer passed in.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug 23 15:46:20 2016(r304684)
+++ head/sys/arm64/arm64/pmap.c Tue Aug 23 15:48:27 2016(r304685)
@@ -995,6 +995,7 @@ vm_page_t
 pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
 {
pt_entry_t *pte, tpte;
+   vm_offset_t off;
vm_paddr_t pa;
vm_page_t m;
int lvl;
@@ -1016,9 +1017,20 @@ retry:
 tpte & ATTR_DESCR_MASK));
if (((tpte & ATTR_AP_RW_BIT) == ATTR_AP(ATTR_AP_RW)) ||
((prot & VM_PROT_WRITE) == 0)) {
+   switch(lvl) {
+   case 1:
+   off = va & L1_OFFSET;
+   break;
+   case 2:
+   off = va & L2_OFFSET;
+   break;
+   case 3:
+   default:
+   off = 0;
+   }
if (vm_page_pa_tryrelock(pmap, tpte & ~ATTR_MASK, ))
goto retry;
-   m = PHYS_TO_VM_PAGE(tpte & ~ATTR_MASK);
+   m = PHYS_TO_VM_PAGE((tpte & ~ATTR_MASK) | off);
vm_page_hold(m);
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304625 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 19:05:11 2016
New Revision: 304625
URL: https://svnweb.freebsd.org/changeset/base/304625

Log:
  Fix the arm64 non-SMP build, active_irq is a uint64_t so cast it through
  a uintmax_t.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3.c

Modified: head/sys/arm64/arm64/gic_v3.c
==
--- head/sys/arm64/arm64/gic_v3.c   Mon Aug 22 18:50:57 2016
(r304624)
+++ head/sys/arm64/arm64/gic_v3.c   Mon Aug 22 19:05:11 2016
(r304625)
@@ -408,8 +408,8 @@ arm_gic_v3_intr(void *arg)
 #ifdef SMP
intr_ipi_dispatch(sgi_to_ipi[gi->gi_irq], tf);
 #else
-   device_printf(sc->dev, "SGI %u on UP system detected\n",
-   active_irq - GIC_FIRST_SGI);
+   device_printf(sc->dev, "SGI %ju on UP system 
detected\n",
+   (uintmax_t)(active_irq - GIC_FIRST_SGI));
 #endif
} else if (active_irq >= GIC_FIRST_PPI &&
active_irq <= GIC_LAST_SPI) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304622 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 18:19:46 2016
New Revision: 304622
URL: https://svnweb.freebsd.org/changeset/base/304622

Log:
  Ensure map is valid, even before userland exists and the fault address
  register points to an address in the userland range.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 week
  Sponsored by: the FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Mon Aug 22 18:17:29 2016(r304621)
+++ head/sys/arm64/arm64/trap.c Mon Aug 22 18:19:46 2016(r304622)
@@ -184,10 +184,13 @@ data_abort(struct trapframe *frame, uint
map = >p_vmspace->vm_map;
else {
/* The top bit tells us which range to use */
-   if ((far >> 63) == 1)
+   if ((far >> 63) == 1) {
map = kernel_map;
-   else
+   } else {
map = >p_vmspace->vm_map;
+   if (map == NULL)
+   map = kernel_map;
+   }
}
 
if (pmap_fault(map->pmap, esr, far) == KERN_SUCCESS)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304620 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 18:12:44 2016
New Revision: 304620
URL: https://svnweb.freebsd.org/changeset/base/304620

Log:
  Fix pmap_update_entry, pmap_invalidate_range takes the end address, not
  the size.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 18:12:24 2016(r304619)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 18:12:44 2016(r304620)
@@ -2290,7 +2290,7 @@ pmap_update_entry(pmap_t pmap, pd_entry_
/* Clear the old mapping */
pmap_load_clear(pte);
PTE_SYNC(pte);
-   pmap_invalidate_range(pmap, va, size);
+   pmap_invalidate_range(pmap, va, va + size);
 
/* Create the new mapping */
pmap_load_store(pte, newpte);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304604 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 14:53:39 2016
New Revision: 304604
URL: https://svnweb.freebsd.org/changeset/base/304604

Log:
  Use switch statements in pmap_remove_pages. While only one level of
  pagetable is supported more will be added soon to support removing
  superpages.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 14:51:09 2016(r304603)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 14:53:39 2016(r304604)
@@ -3115,14 +3115,21 @@ pmap_remove_pages(pmap_t pmap)
pde = pmap_pde(pmap, pv->pv_va, );
KASSERT(pde != NULL,
("Attempting to remove an unmapped page"));
-   KASSERT(lvl == 2,
-   ("Invalid page directory level: %d", lvl));
 
-   pte = pmap_l2_to_l3(pde, pv->pv_va);
-   KASSERT(pte != NULL,
-   ("Attempting to remove an unmapped page"));
-
-   tpte = pmap_load(pte);
+   switch(lvl) {
+   case 2:
+   pte = pmap_l2_to_l3(pde, pv->pv_va);
+   tpte = pmap_load(pte);
+   KASSERT((tpte & ATTR_DESCR_MASK) ==
+   L3_PAGE,
+   ("Attempting to remove an invalid "
+"page: %lx", tpte));
+   break;
+   default:
+   panic(
+   "Invalid page directory level: %d",
+   lvl);
+   }
 
 /*
  * We cannot remove wired pages from a process' mapping at this time
@@ -3156,18 +3163,27 @@ pmap_remove_pages(pmap_t pmap)
/*
 * Update the vm_page_t clean/reference bits.
 */
-   if ((tpte & ATTR_AP_RW_BIT) == 
ATTR_AP(ATTR_AP_RW))
-   vm_page_dirty(m);
+   if ((tpte & ATTR_AP_RW_BIT) ==
+   ATTR_AP(ATTR_AP_RW)) {
+   switch (lvl) {
+   case 2:
+   vm_page_dirty(m);
+   break;
+   }
+   }
 
CHANGE_PV_LIST_LOCK_TO_VM_PAGE(, m);
 
/* Mark free */
pc->pc_map[field] |= bitmask;
-
-   pmap_resident_count_dec(pmap, 1);
-   TAILQ_REMOVE(>md.pv_list, pv, pv_next);
-   m->md.pv_gen++;
-
+   switch (lvl) {
+   case 2:
+   pmap_resident_count_dec(pmap, 1);
+   TAILQ_REMOVE(>md.pv_list, pv,
+   pv_next);
+   m->md.pv_gen++;
+   break;
+   }
pmap_unuse_l3(pmap, pv->pv_va, pmap_load(pde),
);
freed++;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304600 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 12:56:40 2016
New Revision: 304600
URL: https://svnweb.freebsd.org/changeset/base/304600

Log:
  Use pmap_update_entry in pmap_enter when updating an entry with a new
  physical address. This is required when either mapping is writeable.
  
  While here remove an unneeded call to pmap_pde, we already have the pde
  from earlier in the function.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 12:17:40 2016(r304599)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 12:56:40 2016(r304600)
@@ -2429,7 +2429,6 @@ pmap_enter(pmap_t pmap, vm_offset_t va, 
 
l3 = pmap_l2_to_l3(pde, va);
} else {
-   pde = pmap_pde(pmap, va, );
/*
 * If we get a level 2 pde it must point to a level 3 entry
 * otherwise we will need to create the intermediate tables
@@ -2572,10 +2571,11 @@ havel3:
 */
if (orig_l3 != 0) {
 validate:
-   orig_l3 = pmap_load_store(l3, new_l3);
+   orig_l3 = pmap_load(l3);
opa = orig_l3 & ~ATTR_MASK;
 
if (opa != pa) {
+   pmap_update_entry(pmap, l3, new_l3, va, PAGE_SIZE);
if ((orig_l3 & ATTR_SW_MANAGED) != 0) {
om = PHYS_TO_VM_PAGE(opa);
if (pmap_page_dirty(orig_l3))
@@ -2585,8 +2585,11 @@ validate:
CHANGE_PV_LIST_LOCK_TO_PHYS(, opa);
pmap_pvh_free(>md, pmap, va);
}
-   } else if (pmap_page_dirty(orig_l3)) {
-   if ((orig_l3 & ATTR_SW_MANAGED) != 0)
+   } else {
+   pmap_load_store(l3, new_l3);
+   PTE_SYNC(l3);
+   pmap_invalidate_page(pmap, va);
+   if (pmap_page_dirty(orig_l3) && (orig_l3 & 
ATTR_SW_MANAGED) != 0)
vm_page_dirty(m);
}
} else {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304599 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 12:17:40 2016
New Revision: 304599
URL: https://svnweb.freebsd.org/changeset/base/304599

Log:
  Add sysctls to report on superpages statistics. While here add extra
  logging to these paths.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 10:50:30 2016(r304598)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 12:17:40 2016(r304599)
@@ -874,6 +874,21 @@ pmap_init(void)
rw_init(_list_locks[i], "pmap pv list");
 }
 
+static SYSCTL_NODE(_vm_pmap, OID_AUTO, l2, CTLFLAG_RD, 0,
+"2MB page mapping counters");
+
+static u_long pmap_l2_demotions;
+SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, demotions, CTLFLAG_RD,
+_l2_demotions, 0, "2MB page demotions");
+
+static u_long pmap_l2_p_failures;
+SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, p_failures, CTLFLAG_RD,
+_l2_p_failures, 0, "2MB page promotion failures");
+
+static u_long pmap_l2_promotions;
+SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, promotions, CTLFLAG_RD,
+_l2_promotions, 0, "2MB page promotions");
+
 /*
  * Invalidate a single TLB entry.
  */
@@ -2309,14 +2324,22 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t 
return;
 
/* Check the alingment is valid */
-   if (((newl2 & ~ATTR_MASK) & L2_OFFSET) != 0)
+   if (((newl2 & ~ATTR_MASK) & L2_OFFSET) != 0) {
+   atomic_add_long(_l2_p_failures, 1);
+   CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx"
+   " in pmap %p", va, pmap);
return;
+   }
 
pa = newl2 + L2_SIZE - PAGE_SIZE;
for (l3 = firstl3 + NL3PG - 1; l3 > firstl3; l3--) {
oldl3 = pmap_load(l3);
-   if (oldl3 != pa)
+   if (oldl3 != pa) {
+   atomic_add_long(_l2_p_failures, 1);
+   CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx"
+   " in pmap %p", va, pmap);
return;
+   }
pa -= PAGE_SIZE;
}
 
@@ -2324,6 +2347,8 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t 
newl2 |= L2_BLOCK;
 
pmap_update_entry(pmap, l2, newl2, sva, L2_SIZE);
+
+   atomic_add_long(_l2_promotions, 1);
 }
 
 /*
@@ -3745,6 +3770,10 @@ pmap_demote_l2_locked(pmap_t pmap, pt_en
 
pmap_update_entry(pmap, l2, l3phys | L2_TABLE, va, PAGE_SIZE);
 
+   atomic_add_long(_l2_demotions, 1);
+   CTR3(KTR_PMAP, "pmap_demote_l2: success for va %#lx"
+   " in pmap %p %lx", va, pmap, l3[0]);
+
if (tmpl2 != 0) {
pmap_kremove(tmpl2);
kva_free(tmpl2, PAGE_SIZE);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304598 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 10:50:30 2016
New Revision: 304598
URL: https://svnweb.freebsd.org/changeset/base/304598

Log:
  Add a size argument to pmap_update_entry.
  Make use of this in pmap_promote_l2.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 10:21:25 2016(r304597)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 10:50:30 2016(r304598)
@@ -2258,7 +2258,7 @@ pmap_protect(pmap_t pmap, vm_offset_t sv
  */
 static void
 pmap_update_entry(pmap_t pmap, pd_entry_t *pte, pd_entry_t newpte,
-vm_offset_t va)
+vm_offset_t va, vm_size_t size)
 {
register_t intr;
 
@@ -2275,7 +2275,7 @@ pmap_update_entry(pmap_t pmap, pd_entry_
/* Clear the old mapping */
pmap_load_clear(pte);
PTE_SYNC(pte);
-   pmap_invalidate_page(pmap, va);
+   pmap_invalidate_range(pmap, va, size);
 
/* Create the new mapping */
pmap_load_store(pte, newpte);
@@ -2297,11 +2297,12 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t 
 struct rwlock **lockp)
 {
pt_entry_t *firstl3, *l3, newl2, oldl3, pa;
-   register_t intr;
+   vm_offset_t sva;
 
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
 
-   firstl3 = (pt_entry_t *)PHYS_TO_DMAP(pmap_load(l2) & ~ATTR_MASK);
+   sva = va & ~L2_OFFSET;
+   firstl3 = pmap_l2_to_l3(l2, sva);
newl2 = pmap_load(firstl3);
/* Ignore managed pages for now */
if ((newl2 & ATTR_SW_MANAGED) != 0)
@@ -2322,26 +2323,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t 
newl2 &= ~ATTR_DESCR_MASK;
newl2 |= L2_BLOCK;
 
-   /*
-* Ensure we don't get switched out with the page table in an
-* inconsistent state. We also need to ensure no interrupts fire
-* as they may make use of an address we are about to invalidate.
-*/
-   intr = intr_disable();
-   critical_enter();
-
-   /* Clear the old mapping */
-   pmap_load_clear(l2);
-   PTE_SYNC(l2);
-   pmap_invalidate_range(pmap, rounddown2(va, L2_SIZE),
-   roundup2(va, L2_SIZE));
-
-   /* Create the new mapping */
-   pmap_load_store(l2, newl2);
-   PTE_SYNC(l2);
-
-   critical_exit();
-   intr_restore(intr);
+   pmap_update_entry(pmap, l2, newl2, sva, L2_SIZE);
 }
 
 /*
@@ -3621,7 +3603,8 @@ pmap_change_attr_locked(vm_offset_t va, 
l3 &= ~ATTR_IDX_MASK;
l3 |= ATTR_IDX(mode);
 
-   pmap_update_entry(kernel_pmap, pte, l3, tmpva);
+   pmap_update_entry(kernel_pmap, pte, l3, tmpva,
+   PAGE_SIZE);
 
/*
 * If moving to a non-cacheable entry flush
@@ -3693,7 +3676,7 @@ pmap_demote_l1(pmap_t pmap, pt_entry_t *
l1 = (pt_entry_t *)(tmpl1 + ((vm_offset_t)l1 & PAGE_MASK));
}
 
-   pmap_update_entry(pmap, l1, l2phys | L1_TABLE, va);
+   pmap_update_entry(pmap, l1, l2phys | L1_TABLE, va, PAGE_SIZE);
 
if (tmpl1 != 0) {
pmap_kremove(tmpl1);
@@ -3760,7 +3743,7 @@ pmap_demote_l2_locked(pmap_t pmap, pt_en
l2 = (pt_entry_t *)(tmpl2 + ((vm_offset_t)l2 & PAGE_MASK));
}
 
-   pmap_update_entry(pmap, l2, l3phys | L2_TABLE, va);
+   pmap_update_entry(pmap, l2, l3phys | L2_TABLE, va, PAGE_SIZE);
 
if (tmpl2 != 0) {
pmap_kremove(tmpl2);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304596 - head/sys/arm64/arm64

2016-08-22 Thread Andrew Turner
Author: andrew
Date: Mon Aug 22 10:21:09 2016
New Revision: 304596
URL: https://svnweb.freebsd.org/changeset/base/304596

Log:
  Add KASSERTS in pmap_alloc_l3 to ensure we are not encountering superpages
  when we don't yet expect them;
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Mon Aug 22 08:00:14 2016(r304595)
+++ head/sys/arm64/arm64/pmap.c Mon Aug 22 10:21:09 2016(r304596)
@@ -1537,6 +1537,9 @@ pmap_alloc_l3(pmap_t pmap, vm_offset_t v
 {
vm_pindex_t ptepindex;
pd_entry_t *pde, tpde;
+#ifdef INVARIANTS
+   pt_entry_t *pte;
+#endif
vm_page_t m;
int lvl;
 
@@ -1555,13 +1558,33 @@ retry:
 * and activate it. If we get a level 2 pde it will point to a level 3
 * table.
 */
-   if (lvl == 2) {
+   switch (lvl) {
+   case -1:
+   break;
+   case 0:
+#ifdef INVARIANTS
+   pte = pmap_l0_to_l1(pde, va);
+   KASSERT(pmap_load(pte) == 0,
+   ("pmap_alloc_l3: TODO: l0 superpages"));
+#endif
+   break;
+   case 1:
+#ifdef INVARIANTS
+   pte = pmap_l1_to_l2(pde, va);
+   KASSERT(pmap_load(pte) == 0,
+   ("pmap_alloc_l3: TODO: l1 superpages"));
+#endif
+   break;
+   case 2:
tpde = pmap_load(pde);
if (tpde != 0) {
m = PHYS_TO_VM_PAGE(tpde & ~ATTR_MASK);
m->wire_count++;
return (m);
}
+   break;
+   default:
+   panic("pmap_alloc_l3: Invalid level %d", lvl);
}
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304140 - in head/sys/arm64: arm64 include

2016-08-15 Thread Andrew Turner
Author: andrew
Date: Mon Aug 15 09:23:08 2016
New Revision: 304140
URL: https://svnweb.freebsd.org/changeset/base/304140

Log:
  Add the ARMv8.1 identification registers to the list we print when booting.
  
  MFC after:1 week
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm64/arm64/identcpu.c
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/identcpu.c
==
--- head/sys/arm64/arm64/identcpu.c Mon Aug 15 09:19:26 2016
(r304139)
+++ head/sys/arm64/arm64/identcpu.c Mon Aug 15 09:23:08 2016
(r304140)
@@ -188,6 +188,27 @@ print_cpu_features(u_int cpu)
if (cpu == 0 || (cpu_print_regs & PRINT_ID_AA64_ISAR0) != 0) {
printed = 0;
printf(" Instruction Set Attributes 0 = <");
+
+   switch (ID_AA64ISAR0_RDM(cpu_desc[cpu].id_aa64isar0)) {
+   case ID_AA64ISAR0_RDM_NONE:
+   break;
+   case ID_AA64ISAR0_RDM_IMPL:
+   printf("%sRDM", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown RDM", SEP_STR);
+   }
+
+   switch (ID_AA64ISAR0_ATOMIC(cpu_desc[cpu].id_aa64isar0)) {
+   case ID_AA64ISAR0_ATOMIC_NONE:
+   break;
+   case ID_AA64ISAR0_ATOMIC_IMPL:
+   printf("%sAtomic", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown Atomic", SEP_STR);
+   }
+
switch (ID_AA64ISAR0_AES(cpu_desc[cpu].id_aa64isar0)) {
case ID_AA64ISAR0_AES_NONE:
break;
@@ -466,8 +487,82 @@ print_cpu_features(u_int cpu)
 
/* AArch64 Memory Model Feature Register 1 */
if (cpu == 0 || (cpu_print_regs & PRINT_ID_AA64_MMFR1) != 0) {
-   printf("  Memory Model Features 1 = <%#lx>\n",
-   cpu_desc[cpu].id_aa64mmfr1);
+   printed = 0;
+   printf("  Memory Model Features 1 = <");
+
+   switch (ID_AA64MMFR1_PAN(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_PAN_NONE:
+   break;
+   case ID_AA64MMFR1_PAN_IMPL:
+   printf("%sPAN", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown PAN", SEP_STR);
+   break;
+   }
+
+   switch (ID_AA64MMFR1_LO(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_LO_NONE:
+   break;
+   case ID_AA64MMFR1_LO_IMPL:
+   printf("%sLO", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown LO", SEP_STR);
+   break;
+   }
+
+   switch (ID_AA64MMFR1_HPDS(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_HPDS_NONE:
+   break;
+   case ID_AA64MMFR1_HPDS_IMPL:
+   printf("%sHPDS", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown HPDS", SEP_STR);
+   break;
+   }
+
+   switch (ID_AA64MMFR1_VH(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_VH_NONE:
+   break;
+   case ID_AA64MMFR1_VH_IMPL:
+   printf("%sVHE", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown VHE", SEP_STR);
+   break;
+   }
+
+   switch (ID_AA64MMFR1_VMIDBITS(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_VMIDBITS_8:
+   break;
+   case ID_AA64MMFR1_VMIDBITS_16:
+   printf("%s16 VMID bits", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown VMID bits", SEP_STR);
+   break;
+   }
+
+   switch (ID_AA64MMFR1_HAFDBS(cpu_desc[cpu].id_aa64mmfr1)) {
+   case ID_AA64MMFR1_HAFDBS_NONE:
+   break;
+   case ID_AA64MMFR1_HAFDBS_AF:
+   printf("%sAF", SEP_STR);
+   break;
+   case ID_AA64MMFR1_HAFDBS_AF_DBS:
+   printf("%sAF+DBS", SEP_STR);
+   break;
+   default:
+   printf("%sUnknown Hardware update AF/DBS", SEP_STR);
+   break;
+   }
+
+   if ((cpu_desc[cpu].id_aa64mmfr1 & ~ID_AA64MMFR1_MASK) != 0)
+   printf("%s%#lx", SEP_STR,
+   cpu_desc[cpu].id_aa64mmfr1 & ~ID_AA64MMFR1_MASK);
+   printf(">\n");
  

svn commit: r304004 - in head/sys/arm64: arm64 include

2016-08-12 Thread Andrew Turner
Author: andrew
Date: Fri Aug 12 10:29:34 2016
New Revision: 304004
URL: https://svnweb.freebsd.org/changeset/base/304004

Log:
  Implement promotions and demotions in the arm64 pmap code. For now we don't
  promote memory as I am not sure all the demotion cases are handled, however
  it is useful to implement pmap_page_set_memattr. This is used, for example,
  when mapping uncached memory for bus_dma(9).
  
  pmap_page_set_memattr needs to demote the DMAP region as on ARM we need to
  ensure all mappings to the same physical address have the same attributes.
  
  Reviewed by:  kib
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6987

Modified:
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/arm64/trap.c
  head/sys/arm64/include/pmap.h

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Fri Aug 12 08:50:05 2016(r304003)
+++ head/sys/arm64/arm64/pmap.c Fri Aug 12 10:29:34 2016(r304004)
@@ -229,6 +229,13 @@ CTASSERT((DMAP_MAX_ADDRESS  & ~L0_OFFSET
 #defineDMAP_TABLES ((DMAP_MAX_ADDRESS - DMAP_MIN_ADDRESS) >> 
L0_SHIFT)
 extern pt_entry_t pagetable_dmap[];
 
+static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters");
+
+static int superpages_enabled = 1;
+SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled,
+CTLFLAG_RDTUN | CTLFLAG_NOFETCH, _enabled, 0,
+"Are large page mappings enabled?");
+
 /*
  * Data for the pv entry allocation mechanism
  */
@@ -243,6 +250,13 @@ static vm_page_t reclaim_pv_chunk(pmap_t
 static voidpmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va);
 static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap,
vm_offset_t va);
+
+static int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
+static int pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode);
+static pt_entry_t *pmap_demote_l1(pmap_t pmap, pt_entry_t *l1, vm_offset_t va);
+static pt_entry_t *pmap_demote_l2_locked(pmap_t pmap, pt_entry_t *l2,
+vm_offset_t va, struct rwlock **lockp);
+static pt_entry_t *pmap_demote_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t va);
 static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va,
 vm_page_t m, vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp);
 static int pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t sva,
@@ -422,6 +436,13 @@ pmap_pte(pmap_t pmap, vm_offset_t va, in
return (l3);
 }
 
+static inline bool
+pmap_superpages_enabled(void)
+{
+
+   return (superpages_enabled != 0);
+}
+
 bool
 pmap_get_tables(pmap_t pmap, vm_offset_t va, pd_entry_t **l0, pd_entry_t **l1,
 pd_entry_t **l2, pt_entry_t **l3)
@@ -837,6 +858,11 @@ pmap_init(void)
int i;
 
/*
+* Are large page mappings enabled?
+*/
+   TUNABLE_INT_FETCH("vm.pmap.superpages_enabled", _enabled);
+
+   /*
 * Initialize the pv chunk list mutex.
 */
mtx_init(_chunks_mutex, "pmap pv chunk list", NULL, MTX_DEF);
@@ -2000,6 +2026,15 @@ pmap_remove(pmap_t pmap, vm_offset_t sva
 
l3_paddr = pmap_load(l2);
 
+   if ((l3_paddr & ATTR_DESCR_MASK) == L2_BLOCK) {
+   KASSERT((l3_paddr & ATTR_SW_MANAGED) == 0,
+   ("%s: TODO: Demote managed pages", __func__));
+   if (pmap_demote_l2_locked(pmap, l2, sva & ~L2_OFFSET,
+   ) == NULL)
+   continue;
+   l3_paddr = pmap_load(l2);
+   }
+
/*
 * Weed out invalid mappings.
 */
@@ -2194,6 +2229,99 @@ pmap_protect(pmap_t pmap, vm_offset_t sv
 }
 
 /*
+ * Performs a break-before-make update of a pmap entry. This is needed when
+ * either promoting or demoting pages to ensure the TLB doesn't get into an
+ * inconsistent state.
+ */
+static void
+pmap_update_entry(pmap_t pmap, pd_entry_t *pte, pd_entry_t newpte,
+vm_offset_t va)
+{
+   register_t intr;
+
+   PMAP_LOCK_ASSERT(pmap, MA_OWNED);
+
+   /*
+* Ensure we don't get switched out with the page table in an
+* inconsistent state. We also need to ensure no interrupts fire
+* as they may make use of an address we are about to invalidate.
+*/
+   intr = intr_disable();
+   critical_enter();
+
+   /* Clear the old mapping */
+   pmap_load_clear(pte);
+   PTE_SYNC(pte);
+   pmap_invalidate_page(pmap, va);
+
+   /* Create the new mapping */
+   pmap_load_store(pte, newpte);
+   PTE_SYNC(pte);
+
+   critical_exit();
+   intr_restore(intr);
+}
+
+/*
+ * Tries to promote the 512, contiguous 4KB page mappings that are within a
+ * single level 2 table entry to a single 2MB page mapping.  For promotion
+ * to occur, 

svn commit: r303904 - head/sys/arm64/arm64

2016-08-10 Thread Andrew Turner
Author: andrew
Date: Wed Aug 10 10:36:11 2016
New Revision: 303904
URL: https://svnweb.freebsd.org/changeset/base/303904

Log:
  Uncomment the vm.kvm_size and vm.kvm_free sysctls. These work as expected so
  there is no reason to leave them commented out.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Wed Aug 10 10:13:34 2016(r303903)
+++ head/sys/arm64/arm64/pmap.c Wed Aug 10 10:36:11 2016(r303904)
@@ -1574,7 +1574,6 @@ pmap_release(pmap_t pmap)
vm_page_free_zero(m);
 }
 
-#if 0
 static int
 kvm_size(SYSCTL_HANDLER_ARGS)
 {
@@ -1594,7 +1593,6 @@ kvm_free(SYSCTL_HANDLER_ARGS)
 }
 SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG|CTLFLAG_RD,
 0, 0, kvm_free, "LU", "Amount of KVM free");
-#endif /* 0 */
 
 /*
  * grow the number of kernel page table entries, if needed
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303903 - head/sys/arm64/arm64

2016-08-10 Thread Andrew Turner
Author: andrew
Date: Wed Aug 10 10:13:34 2016
New Revision: 303903
URL: https://svnweb.freebsd.org/changeset/base/303903

Log:
  Implement pmap_align_superpage on arm64 based on the amd64 implementation.
  This will be needed when superpage support is added.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Wed Aug 10 08:05:48 2016(r303902)
+++ head/sys/arm64/arm64/pmap.c Wed Aug 10 10:13:34 2016(r303903)
@@ -3490,6 +3490,20 @@ void
 pmap_align_superpage(vm_object_t object, vm_ooffset_t offset,
 vm_offset_t *addr, vm_size_t size)
 {
+   vm_offset_t superpage_offset;
+
+   if (size < L2_SIZE)
+   return;
+   if (object != NULL && (object->flags & OBJ_COLORED) != 0)
+   offset += ptoa(object->pg_color);
+   superpage_offset = offset & L2_OFFSET;
+   if (size - ((L2_SIZE - superpage_offset) & L2_OFFSET) < L2_SIZE ||
+   (*addr & L2_OFFSET) == superpage_offset)
+   return;
+   if ((*addr & L2_OFFSET) < superpage_offset)
+   *addr = (*addr & ~L2_OFFSET) + superpage_offset;
+   else
+   *addr = ((*addr + L2_OFFSET) & ~L2_OFFSET) + superpage_offset;
 }
 
 /**
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303744 - head/sys/arm64/arm64

2016-08-04 Thread Andrew Turner
Author: andrew
Date: Thu Aug  4 13:49:36 2016
New Revision: 303744
URL: https://svnweb.freebsd.org/changeset/base/303744

Log:
  Remove the pvh_global_lock lock from the arm64 pmap. It is unneeded on arm64
  as invalidation will have completed before the pmap_invalidate_* functions
  have complete.
  
  Discussed with:   alc, kib
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Thu Aug  4 13:45:18 2016(r303743)
+++ head/sys/arm64/arm64/pmap.c Thu Aug  4 13:49:36 2016(r303744)
@@ -218,8 +218,6 @@ vm_offset_t kernel_vm_end = 0;
 
 struct msgbuf *msgbufp = NULL;
 
-static struct rwlock_padalign pvh_global_lock;
-
 vm_paddr_t dmap_phys_base; /* The start of the dmap region */
 vm_paddr_t dmap_phys_max;  /* The limit of the dmap region */
 vm_offset_t dmap_max_addr; /* The virtual address limit of the dmap */
@@ -671,11 +669,6 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offs
kernel_pmap_store.pm_l0 = (pd_entry_t *)l0pt;
PMAP_LOCK_INIT(kernel_pmap);
 
-   /*
-* Initialize the global pv list lock.
-*/
-   rw_init(_global_lock, "pmap pv global");
-
/* Assume the address we were loaded to is a valid physical address */
min_pa = max_pa = KERNBASE - kern_delta;
 
@@ -1404,9 +1397,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t 
if (lockp != NULL) {
RELEASE_PV_LIST_LOCK(lockp);
PMAP_UNLOCK(pmap);
-   rw_runlock(_global_lock);
VM_WAIT;
-   rw_rlock(_global_lock);
PMAP_LOCK(pmap);
}
 
@@ -1748,7 +1739,6 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
struct pv_chunk *pc;
int idx, field, bit;
 
-   rw_assert(_global_lock, RA_LOCKED);
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
PV_STAT(atomic_add_long(_entry_frees, 1));
PV_STAT(atomic_add_int(_entry_spare, 1));
@@ -1805,7 +1795,6 @@ get_pv_entry(pmap_t pmap, struct rwlock 
struct pv_chunk *pc;
vm_page_t m;
 
-   rw_assert(_global_lock, RA_LOCKED);
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
PV_STAT(atomic_add_long(_entry_allocs, 1));
 retry:
@@ -1873,7 +1862,6 @@ pmap_pvh_remove(struct md_page *pvh, pma
 {
pv_entry_t pv;
 
-   rw_assert(_global_lock, RA_LOCKED);
TAILQ_FOREACH(pv, >pv_list, pv_next) {
if (pmap == PV_PMAP(pv) && va == pv->pv_va) {
TAILQ_REMOVE(>pv_list, pv, pv_next);
@@ -1909,7 +1897,6 @@ pmap_try_insert_pv_entry(pmap_t pmap, vm
 {
pv_entry_t pv;
 
-   rw_assert(_global_lock, RA_LOCKED);
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
/* Pass NULL instead of the lock pointer to disable reclamation. */
if ((pv = get_pv_entry(pmap, NULL)) != NULL) {
@@ -1978,7 +1965,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva
anyvalid = 0;
SLIST_INIT();
 
-   rw_rlock(_global_lock);
PMAP_LOCK(pmap);
 
lock = NULL;
@@ -2057,7 +2043,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva
rw_wunlock(lock);
if (anyvalid)
pmap_invalidate_all(pmap);
-   rw_runlock(_global_lock);
PMAP_UNLOCK(pmap);
pmap_free_zero_pages();
 }
@@ -2080,18 +2065,31 @@ pmap_remove_all(vm_page_t m)
 {
pv_entry_t pv;
pmap_t pmap;
+   struct rwlock *lock;
pd_entry_t *pde, tpde;
pt_entry_t *pte, tpte;
struct spglist free;
-   int lvl;
+   int lvl, md_gen;
 
KASSERT((m->oflags & VPO_UNMANAGED) == 0,
("pmap_remove_all: page %p is not managed", m));
SLIST_INIT();
-   rw_wlock(_global_lock);
+   lock = VM_PAGE_TO_PV_LIST_LOCK(m);
+retry:
+   rw_wlock(lock);
while ((pv = TAILQ_FIRST(>md.pv_list)) != NULL) {
pmap = PV_PMAP(pv);
-   PMAP_LOCK(pmap);
+   if (!PMAP_TRYLOCK(pmap)) {
+   md_gen = m->md.pv_gen;
+   rw_wunlock(lock);
+   PMAP_LOCK(pmap);
+   rw_wlock(lock);
+   if (md_gen != m->md.pv_gen) {
+   rw_wunlock(lock);
+   PMAP_UNLOCK(pmap);
+   goto retry;
+   }
+   }
pmap_resident_count_dec(pmap, 1);
 
pde = pmap_pde(pmap, pv->pv_va, );
@@ -2126,7 +2124,7 @@ pmap_remove_all(vm_page_t m)
PMAP_UNLOCK(pmap);
}
vm_page_aflag_clear(m, PGA_WRITEABLE);
-   rw_wunlock(_global_lock);
+   rw_wunlock(lock);
pmap_free_zero_pages();
 }
 
@@ -2241,7 +2239,6 @@ pmap_enter(pmap_t pmap, 

svn commit: r303661 - head/sys/arm64/arm64

2016-08-02 Thread Andrew Turner
Author: andrew
Date: Tue Aug  2 15:26:46 2016
New Revision: 303661
URL: https://svnweb.freebsd.org/changeset/base/303661

Log:
  Remove trailing whitespace from the arm64 pmap
  
  Obtained from:ABT Systems Ltd
  MFC after:3 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Aug  2 14:50:14 2016(r303660)
+++ head/sys/arm64/arm64/pmap.c Tue Aug  2 15:26:46 2016(r303661)
@@ -782,7 +782,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offs
virtual_avail = roundup2(freemempos, L1_SIZE);
virtual_end = VM_MAX_KERNEL_ADDRESS - L2_SIZE;
kernel_vm_end = virtual_avail;
-   
+
pa = pmap_early_vtophys(l1pt, freemempos);
 
/* Finish initialising physmap */
@@ -908,7 +908,7 @@ pmap_invalidate_all(pmap_t pmap)
  * Extract the physical page address associated
  * with the given map/virtual_address pair.
  */
-vm_paddr_t 
+vm_paddr_t
 pmap_extract(pmap_t pmap, vm_offset_t va)
 {
pt_entry_t *pte, tpte;
@@ -1243,7 +1243,7 @@ pmap_add_delayed_free_list(vm_page_t m, 
m->flags &= ~PG_ZERO;
SLIST_INSERT_HEAD(free, m, plinks.s.ss);
 }
-   
+
 /*
  * Decrements a page table page's wire count, which is used to record the
  * number of valid page table entries within the page.  If the wire count
@@ -1321,7 +1321,7 @@ _pmap_unwire_l3(pmap_t pmap, vm_offset_t
 */
atomic_subtract_rel_int(_cnt.v_wire_count, 1);
 
-   /* 
+   /*
 * Put page on a list so that it is released after
 * *ALL* TLB shootdown is done
 */
@@ -1591,7 +1591,7 @@ kvm_size(SYSCTL_HANDLER_ARGS)
 
return sysctl_handle_long(oidp, , 0, req);
 }
-SYSCTL_PROC(_vm, OID_AUTO, kvm_size, CTLTYPE_LONG|CTLFLAG_RD, 
+SYSCTL_PROC(_vm, OID_AUTO, kvm_size, CTLTYPE_LONG|CTLFLAG_RD,
 0, 0, kvm_size, "LU", "Size of KVM");
 
 static int
@@ -1601,7 +1601,7 @@ kvm_free(SYSCTL_HANDLER_ARGS)
 
return sysctl_handle_long(oidp, , 0, req);
 }
-SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG|CTLFLAG_RD, 
+SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG|CTLFLAG_RD,
 0, 0, kvm_free, "LU", "Amount of KVM free");
 #endif /* 0 */
 
@@ -1645,7 +1645,7 @@ pmap_growkernel(vm_offset_t addr)
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
-   break;   
+   break;
}
continue;
}
@@ -1665,7 +1665,7 @@ pmap_growkernel(vm_offset_t addr)
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= kernel_map->max_offset) {
kernel_vm_end = kernel_map->max_offset;
-   break;   
+   break;
}
}
 }
@@ -1926,7 +1926,7 @@ pmap_try_insert_pv_entry(pmap_t pmap, vm
  * pmap_remove_l3: do the things to unmap a page in a process
  */
 static int
-pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va, 
+pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va,
 pd_entry_t l2e, struct spglist *free, struct rwlock **lockp)
 {
pt_entry_t old_l3;
@@ -2057,7 +2057,7 @@ pmap_remove(pmap_t pmap, vm_offset_t sva
rw_wunlock(lock);
if (anyvalid)
pmap_invalidate_all(pmap);
-   rw_runlock(_global_lock);   
+   rw_runlock(_global_lock);
PMAP_UNLOCK(pmap);
pmap_free_zero_pages();
 }
@@ -2724,7 +2724,7 @@ pmap_zero_page(vm_page_t m)
 }
 
 /*
- * pmap_zero_page_area zeros the specified hardware page by mapping 
+ * pmap_zero_page_area zeros the specified hardware page by mapping
  * the page into KVM and using bzero to clear its contents.
  *
  * off and size may not cover an area beyond a single hardware page.
@@ -2741,7 +2741,7 @@ pmap_zero_page_area(vm_page_t m, int off
 }
 
 /*
- * pmap_zero_page_idle zeros the specified hardware page by mapping 
+ * pmap_zero_page_idle zeros the specified hardware page by mapping
  * the page into KVM and using bzero to clear its contents.  This
  * is intended to be called from the vm_pagezero process only and
  * outside of Giant.
@@ -2902,7 +2902,7 @@ restart:
  * Destroy all managed, non-wired mappings in the given user-space
  * pmap.  This pmap cannot be active on any processor besides the
  * caller.
- * 
   
+ *
  * This function cannot be applied to the kernel pmap.  Moreover, it
  * is not intended for general use.  It is only to be used during
  * 

svn commit: r303622 - in head/sys: arm/arm conf

2016-08-01 Thread Andrew Turner
),
-   DEVMETHOD(ofw_bus_get_compat,   ofw_bus_gen_get_compat),
-   DEVMETHOD(ofw_bus_get_model,ofw_bus_gen_get_model),
-   DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
-   DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
-   DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
-
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, arm_gic_disable_intr),
DEVMETHOD(pic_enable_intr,  arm_gic_enable_intr),
@@ -1532,18 +1315,8 @@ static device_method_t arm_gic_methods[]
{ 0, 0 }
 };
 
-static driver_t arm_gic_driver = {
-   "gic",
-   arm_gic_methods,
-   sizeof(struct arm_gic_softc),
-};
-
-static devclass_t arm_gic_devclass;
-
-EARLY_DRIVER_MODULE(gic, simplebus, arm_gic_driver, arm_gic_devclass, 0, 0,
-BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
-EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic_driver, arm_gic_devclass, 0, 0,
-BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
+DEFINE_CLASS_0(gic, arm_gic_driver, arm_gic_methods,
+sizeof(struct arm_gic_softc));
 
 #ifdef INTRNG
 /*
@@ -1556,34 +1329,7 @@ EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic
 #defineGICv2M_MSI_SETSPI_NS0x040
 #defineGICV2M_MSI_IIDR 0xFCC
 
-struct arm_gicv2m_softc {
-   struct resource *sc_mem;
-   struct mtx  sc_mutex;
-   u_int   sc_spi_start;
-   u_int   sc_spi_end;
-   u_int   sc_spi_count;
-};
-
-static struct ofw_compat_data gicv2m_compat_data[] = {
-   {"arm,gic-v2m-frame",   true},
-   {NULL,  false}
-};
-
-static int
-arm_gicv2m_probe(device_t dev)
-{
-
-   if (!ofw_bus_status_okay(dev))
-   return (ENXIO);
-
-   if (!ofw_bus_search_compatible(dev, gicv2m_compat_data)->ocd_data)
-   return (ENXIO);
-
-   device_set_desc(dev, "ARM Generic Interrupt Controller MSI/MSIX");
-   return (BUS_PROBE_DEFAULT);
-}
-
-static int
+int
 arm_gicv2m_attach(device_t dev)
 {
struct arm_gicv2m_softc *sc;
@@ -1613,7 +1359,7 @@ arm_gicv2m_attach(device_t dev)
 
mtx_init(>sc_mutex, "GICv2m lock", "", MTX_DEF);
 
-   intr_msi_register(dev, gic_xref(dev));
+   intr_msi_register(dev, sc->sc_xref);
 
if (bootverbose)
device_printf(dev, "using spi %u to %u\n", sc->sc_spi_start,
@@ -1782,7 +1528,6 @@ arm_gicv2m_map_msi(device_t dev, device_
 
 static device_method_t arm_gicv2m_methods[] = {
/* Device interface */
-   DEVMETHOD(device_probe, arm_gicv2m_probe),
DEVMETHOD(device_attach,arm_gicv2m_attach),
 
/* MSI/MSI-X */
@@ -1798,9 +1543,4 @@ static device_method_t arm_gicv2m_method
 
 DEFINE_CLASS_0(gicv2m, arm_gicv2m_driver, arm_gicv2m_methods,
 sizeof(struct arm_gicv2m_softc));
-
-static devclass_t arm_gicv2m_devclass;
-
-EARLY_DRIVER_MODULE(gicv2m, gic, arm_gicv2m_driver,
-arm_gicv2m_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
 #endif

Added: head/sys/arm/arm/gic.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/arm/gic.h  Mon Aug  1 16:29:04 2016(r303622)
@@ -0,0 +1,106 @@
+/*-
+ * Copyright (c) 2011,2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Developed by Damjan Marion <damjan.mar...@gmail.com>
+ *
+ * Based on OMAP4 GIC code by Ben Gray
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the company nor the name of the author may be used to
+ *endorse or promote products derived from this software without specific
+ *prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGL

svn commit: r303614 - in head/sys/arm64: arm64 include

2016-08-01 Thread Andrew Turner
Author: andrew
Date: Mon Aug  1 12:17:44 2016
New Revision: 303614
URL: https://svnweb.freebsd.org/changeset/base/303614

Log:
  Add a kernel variable to let the user to select their preferred order
  between ACPI and FDT. This will be needed on machines with both, e.g. the
  SoftIron Overdrive 3000. The kernel will accept one or more comma separated
  values of either 'acpi' or 'fdt'. Any other values are skipped.
  
  To set it the user can either set it on the loader command line, or
  in loader.conf e.g. in loader.conf:
  kern.cfg.order=acpi,fdt
  
  This will try using ACPI then FDT. If none of the selected options work the
  kernel tries to use one to get the serial console, then panics.
  
  Reviewed by:  emaste (earlier version)
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7274

Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/arm64/mp_machdep.c
  head/sys/arm64/arm64/nexus.c
  head/sys/arm64/include/machdep.h

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Mon Aug  1 12:14:21 2016
(r303613)
+++ head/sys/arm64/arm64/machdep.c  Mon Aug  1 12:17:44 2016
(r303614)
@@ -25,6 +25,7 @@
  *
  */
 
+#include "opt_acpi.h"
 #include "opt_platform.h"
 #include "opt_ddb.h"
 
@@ -82,11 +83,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+#ifdef DEV_ACPI
+#include 
+#include 
+#endif
+
 #ifdef FDT
 #include 
 #include 
 #endif
 
+
+enum arm64_bus arm64_bus_method = ARM64_BUS_NONE;
+
 struct pcpu __pcpu[MAXCPU];
 
 static struct trapframe proc0_tf;
@@ -802,6 +811,61 @@ try_load_dtb(caddr_t kmdp)
 }
 #endif
 
+static bool
+bus_probe(void)
+{
+   bool has_acpi, has_fdt;
+   char *order, *env;
+
+   has_acpi = has_fdt = false;
+
+#ifdef FDT
+   has_fdt = (OF_peer(0) != 0);
+#endif
+#ifdef DEV_ACPI
+   has_acpi = (acpi_find_table(ACPI_SIG_SPCR) != 0);
+#endif
+
+   env = kern_getenv("kern.cfg.order");
+   if (env != NULL) {
+   order = env;
+   while (order != NULL) {
+   if (has_acpi &&
+   strncmp(order, "acpi", 4) == 0 &&
+   (order[4] == ',' || order[4] == '\0')) {
+   arm64_bus_method = ARM64_BUS_ACPI;
+   break;
+   }
+   if (has_fdt &&
+   strncmp(order, "fdt", 3) == 0 &&
+   (order[3] == ',' || order[3] == '\0')) {
+   arm64_bus_method = ARM64_BUS_FDT;
+   break;
+   }
+   order = strchr(order, ',');
+   }
+   freeenv(env);
+
+   /* If we set the bus method it is valid */
+   if (arm64_bus_method != ARM64_BUS_NONE)
+   return (true);
+   }
+   /* If no order or an invalid order was set use the default */
+   if (arm64_bus_method == ARM64_BUS_NONE) {
+   if (has_fdt)
+   arm64_bus_method = ARM64_BUS_FDT;
+   else if (has_acpi)
+   arm64_bus_method = ARM64_BUS_ACPI;
+   }
+
+   /*
+* If no option was set the default is valid, otherwise we are
+* setting one to get cninit() working, then calling panic to tell
+* the user about the invalid bus setup.
+*/
+   return (env == NULL);
+}
+
 static void
 cache_setup(void)
 {
@@ -849,6 +913,7 @@ initarm(struct arm64_bootparams *abp)
vm_offset_t lastaddr;
caddr_t kmdp;
vm_paddr_t mem_len;
+   bool valid;
int i;
 
/* Set the module data location */
@@ -921,8 +986,14 @@ initarm(struct arm64_bootparams *abp)
 
devmap_bootstrap(0, NULL);
 
+   valid = bus_probe();
+
cninit();
 
+   if (!valid)
+   panic("Invalid bus configuration: %s",
+   kern_getenv("kern.cfg.order"));
+
init_proc0(abp->kern_stack);
msgbufinit(msgbufp, msgbufsize);
mutex_init();

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Mon Aug  1 12:14:21 2016
(r303613)
+++ head/sys/arm64/arm64/mp_machdep.c   Mon Aug  1 12:17:44 2016
(r303614)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #ifdef VFP
@@ -90,13 +91,6 @@ boolean_t ofw_cpu_reg(phandle_t node, u_
 
 extern struct pcpu __pcpu[];
 
-static enum {
-   CPUS_UNKNOWN,
-#ifdef FDT
-   CPUS_FDT,
-#endif
-} cpu_enum_method;
-
 static device_identify_t arm64_cpu_identify;
 static device_probe_t arm64_cpu_probe;
 static device_attach_t arm64_cpu_attach;
@@ 

svn commit: r303610 - head/sys/arm64/include

2016-08-01 Thread Andrew Turner
Author: andrew
Date: Mon Aug  1 10:36:58 2016
New Revision: 303610
URL: https://svnweb.freebsd.org/changeset/base/303610

Log:
  Add the fields for the PAR_EL1 register. This is used when performing an
  address lookup with the AT instructions.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Mon Aug  1 06:59:35 2016
(r303609)
+++ head/sys/arm64/include/armreg.h Mon Aug  1 10:36:58 2016
(r303610)
@@ -312,6 +312,27 @@
 #defineMAIR_ATTR_MASK(idx) (0xff << ((n)* 8))
 #defineMAIR_ATTR(attr, idx) ((attr) << ((idx) * 8))
 
+/* PAR_EL1 - Physical Address Register */
+#definePAR_F_SHIFT 0
+#definePAR_F   (0x1 << PAR_F_SHIFT)
+#definePAR_SUCCESS(x)  (((x) & PAR_F) == 0)
+/* When PAR_F == 0 (success) */
+#definePAR_SH_SHIFT7
+#definePAR_SH_MASK (0x3 << PAR_SH_SHIFT)
+#definePAR_NS_SHIFT9
+#definePAR_NS_MASK (0x3 << PAR_NS_SHIFT)
+#definePAR_PA_SHIFT12
+#definePAR_PA_MASK 0xf000
+#definePAR_ATTR_SHIFT  56
+#definePAR_ATTR_MASK   (0xff << PAR_ATTR_SHIFT)
+/* When PAR_F == 1 (aborted) */
+#definePAR_FST_SHIFT   1
+#definePAR_FST_MASK(0x3f << PAR_FST_SHIFT)
+#definePAR_PTW_SHIFT   8
+#definePAR_PTW_MASK(0x1 << PAR_PTW_SHIFT)
+#definePAR_S_SHIFT 9
+#definePAR_S_MASK  (0x1 << PAR_S_SHIFT)
+
 /* SCTLR_EL1 - System Control Register */
 #defineSCTLR_RES0  0xc8222400  /* Reserved, write 0 */
 #defineSCTLR_RES1  0x30d00800  /* Reserved, write 1 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303594 - head/sys/arm64/include

2016-07-31 Thread Andrew Turner
Author: andrew
Date: Sun Jul 31 18:58:20 2016
New Revision: 303594
URL: https://svnweb.freebsd.org/changeset/base/303594

Log:
  Add the Data Fault Status Code values to the ESR_ELx registers for when the
  fault code is a Data Abort.
  
  Obtained from:AT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Sun Jul 31 18:14:42 2016
(r303593)
+++ head/sys/arm64/include/armreg.h Sun Jul 31 18:58:20 2016
(r303594)
@@ -90,6 +90,32 @@
 #define ISS_INSN_S1PTW (0x01 << 7)
 #define ISS_DATa_WnR   (0x01 << 6)
 #define ISS_DATA_DFSC_MASK (0x1f << 0)
+#define ISS_DATA_DFSC_ASF_L0   (0x00 << 0)
+#define ISS_DATA_DFSC_ASF_L1   (0x01 << 0)
+#define ISS_DATA_DFSC_ASF_L2   (0x02 << 0)
+#define ISS_DATA_DFSC_ASF_L3   (0x03 << 0)
+#define ISS_DATA_DFSC_TF_L0(0x04 << 0)
+#define ISS_DATA_DFSC_TF_L1(0x05 << 0)
+#define ISS_DATA_DFSC_TF_L2(0x06 << 0)
+#define ISS_DATA_DFSC_TF_L3(0x07 << 0)
+#define ISS_DATA_DFSC_AFF_L1   (0x09 << 0)
+#define ISS_DATA_DFSC_AFF_L2   (0x0a << 0)
+#define ISS_DATA_DFSC_AFF_L3   (0x0b << 0)
+#define ISS_DATA_DFSC_PF_L1(0x0d << 0)
+#define ISS_DATA_DFSC_PF_L2(0x0e << 0)
+#define ISS_DATA_DFSC_PF_L3(0x0f << 0)
+#define ISS_DATA_DFSC_EXT  (0x10 << 0)
+#define ISS_DATA_DFSC_EXT_L0   (0x14 << 0)
+#define ISS_DATA_DFSC_EXT_L1   (0x15 << 0)
+#define ISS_DATA_DFSC_EXT_L2   (0x16 << 0)
+#define ISS_DATA_DFSC_EXT_L3   (0x17 << 0)
+#define ISS_DATA_DFSC_ECC  (0x18 << 0)
+#define ISS_DATA_DFSC_ECC_L0   (0x1c << 0)
+#define ISS_DATA_DFSC_ECC_L1   (0x1d << 0)
+#define ISS_DATA_DFSC_ECC_L2   (0x1e << 0)
+#define ISS_DATA_DFSC_ECC_L3   (0x1f << 0)
+#define ISS_DATA_DFSC_ALIGN(0x21 << 0)
+#define ISS_DATA_DFSC_TLB_CONFLICT (0x28 << 0)
 #defineESR_ELx_IL  (0x01 << 25)
 #defineESR_ELx_EC_SHIFT26
 #defineESR_ELx_EC_MASK (0x3f << 26)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303592 - head/sys/arm64/arm64

2016-07-31 Thread Andrew Turner
Author: andrew
Date: Sun Jul 31 17:53:09 2016
New Revision: 303592
URL: https://svnweb.freebsd.org/changeset/base/303592

Log:
  Extract the common parts of pmap_kenter_device to a new function. This will
  be used when superpage support is added.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Sun Jul 31 15:15:27 2016(r303591)
+++ head/sys/arm64/arm64/pmap.c Sun Jul 31 17:53:09 2016(r303592)
@@ -1037,8 +1037,8 @@ pmap_kextract(vm_offset_t va)
  * Low level mapping routines.
  ***/
 
-void
-pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm_paddr_t pa)
+static void
+pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode)
 {
pd_entry_t *pde;
pt_entry_t *pte;
@@ -1046,23 +1046,22 @@ pmap_kenter_device(vm_offset_t sva, vm_s
int lvl;
 
KASSERT((pa & L3_OFFSET) == 0,
-  ("pmap_kenter_device: Invalid physical address"));
+  ("pmap_kenter: Invalid physical address"));
KASSERT((sva & L3_OFFSET) == 0,
-  ("pmap_kenter_device: Invalid virtual address"));
+  ("pmap_kenter: Invalid virtual address"));
KASSERT((size & PAGE_MASK) == 0,
-   ("pmap_kenter_device: Mapping is not page-sized"));
+   ("pmap_kenter: Mapping is not page-sized"));
 
va = sva;
while (size != 0) {
pde = pmap_pde(kernel_pmap, va, );
KASSERT(pde != NULL,
-   ("pmap_kenter_device: Invalid page entry, va: 0x%lx", va));
-   KASSERT(lvl == 2,
-   ("pmap_kenter_device: Invalid level %d", lvl));
+   ("pmap_kenter: Invalid page entry, va: 0x%lx", va));
+   KASSERT(lvl == 2, ("pmap_kenter: Invalid level %d", lvl));
 
pte = pmap_l2_to_l3(pde, va);
pmap_load_store(pte, (pa & ~L3_OFFSET) | ATTR_DEFAULT |
-   ATTR_IDX(DEVICE_MEMORY) | L3_PAGE);
+   ATTR_IDX(mode) | L3_PAGE);
PTE_SYNC(pte);
 
va += PAGE_SIZE;
@@ -1072,6 +1071,13 @@ pmap_kenter_device(vm_offset_t sva, vm_s
pmap_invalidate_range(kernel_pmap, sva, va);
 }
 
+void
+pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm_paddr_t pa)
+{
+
+   pmap_kenter(sva, size, pa, DEVICE_MEMORY);
+}
+
 /*
  * Remove a page from the kernel pagetables.
  */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303587 - head/sys/arm64/arm64

2016-07-31 Thread Andrew Turner
Author: andrew
Date: Sun Jul 31 14:59:44 2016
New Revision: 303587
URL: https://svnweb.freebsd.org/changeset/base/303587

Log:
  Fix the comment above pmap_invalidate_page. tlbi will invalidate the tlb
  on all CPUs.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Sun Jul 31 13:11:34 2016(r303586)
+++ head/sys/arm64/arm64/pmap.c Sun Jul 31 14:59:44 2016(r303587)
@@ -856,8 +856,7 @@ pmap_init(void)
 }
 
 /*
- * Normal, non-SMP, invalidation functions.
- * We inline these within pmap.c for speed.
+ * Invalidate a single TLB entry.
  */
 PMAP_INLINE void
 pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303585 - head/sys/arm64/arm64

2016-07-31 Thread Andrew Turner
Author: andrew
Date: Sun Jul 31 12:59:10 2016
New Revision: 303585
URL: https://svnweb.freebsd.org/changeset/base/303585

Log:
  Relax the barriers around a TLB invalidation to only wait on
  inner-shareable memory accesses. There is no need for full system barriers.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Sun Jul 31 12:11:55 2016(r303584)
+++ head/sys/arm64/arm64/pmap.c Sun Jul 31 12:59:10 2016(r303585)
@@ -865,9 +865,9 @@ pmap_invalidate_page(pmap_t pmap, vm_off
 
sched_pin();
__asm __volatile(
-   "dsb  sy\n"
+   "dsb  ishst \n"
"tlbi vaae1is, %0   \n"
-   "dsb  sy\n"
+   "dsb  ish   \n"
"isb\n"
: : "r"(va >> PAGE_SHIFT));
sched_unpin();
@@ -879,13 +879,13 @@ pmap_invalidate_range(pmap_t pmap, vm_of
vm_offset_t addr;
 
sched_pin();
-   __asm __volatile("dsb   sy");
+   dsb(ishst);
for (addr = sva; addr < eva; addr += PAGE_SIZE) {
__asm __volatile(
"tlbi vaae1is, %0" : : "r"(addr >> PAGE_SHIFT));
}
__asm __volatile(
-   "dsb  sy\n"
+   "dsb  ish   \n"
"isb\n");
sched_unpin();
 }
@@ -896,9 +896,9 @@ pmap_invalidate_all(pmap_t pmap)
 
sched_pin();
__asm __volatile(
-   "dsb  sy\n"
+   "dsb  ishst \n"
"tlbi vmalle1is \n"
-   "dsb  sy\n"
+   "dsb  ish   \n"
"isb\n");
sched_unpin();
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303475 - in head/sys: arm64/conf conf dev/usb/controller

2016-07-29 Thread Andrew Turner
Author: andrew
Date: Fri Jul 29 08:50:36 2016
New Revision: 303475
URL: https://svnweb.freebsd.org/changeset/base/303475

Log:
  Add a generic EHCI USB driver based on the Allwinner A10 driver. It is ACPI
  only for now, but wouldn't be too difficult to add support for FDT.
  
  Reviewed by:  hselasky
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7352

Added:
  head/sys/dev/usb/controller/generic_ehci.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Fri Jul 29 06:22:11 2016(r303474)
+++ head/sys/arm64/conf/GENERIC Fri Jul 29 08:50:36 2016(r303475)
@@ -131,6 +131,7 @@ device  pl011
 optionsUSB_DEBUG   # enable debug msgs
 device dwcotg  # DWC OTG controller
 device ohci# OHCI PCI->USB interface
+device ehci# EHCI PCI->USB interface (USB 2.0)
 device xhci# XHCI PCI->USB interface (USB 3.0)
 device usb # USB Bus (required)
 device ukbd# Keyboard

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Fri Jul 29 06:22:11 2016(r303474)
+++ head/sys/conf/files.arm64   Fri Jul 29 08:50:36 2016(r303475)
@@ -69,6 +69,7 @@ dev/psci/psci_arm64.S optionalpsci
 dev/uart/uart_cpu_fdt.coptionaluart fdt
 dev/uart/uart_dev_pl011.c  optionaluart pl011
 dev/usb/controller/dwc_otg_hisi.c optional dwcotg fdt soc_hisi_hi6220
+dev/usb/controller/generic_ehci.c optional ehci acpi
 dev/usb/controller/generic_ohci.c optional ohci fdt
 dev/usb/controller/generic_usb_if.m optional   ohci fdt
 dev/vnic/mrml_bridge.c optionalvnic fdt

Added: head/sys/dev/usb/controller/generic_ehci.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/usb/controller/generic_ehci.c  Fri Jul 29 08:50:36 2016
(r303475)
@@ -0,0 +1,220 @@
+/*-
+ * Copyright (c) 2012 Ganbold Tsagaankhuu <ganb...@freebsd.org>
+ * Copyright (c) 2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Generic EHCI driver based on the Allwinner A10 EHCI driver
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_bus.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static device_attach_t generic_ehci_attach;
+static device_detach_t generic_ehci_detach;
+
+static int
+generic_ehci_probe(device_t self)
+{
+   ACPI_HANDLE h;
+
+   if ((h = acpi_get_handle(self)) == NULL ||
+   !acpi_MatchHid(h, "PNP0D20"))
+   return (ENXIO);
+
+   device_set_desc(self, "Generic EHCI Controller");
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+generic_ehci_attach(device_t self)
+{
+   ehci_softc_t *sc = device_get_softc(self);
+   int err;
+   int rid;
+
+   /* initial

svn commit: r303309 - head/sys/arm64/arm64

2016-07-25 Thread Andrew Turner
Author: andrew
Date: Mon Jul 25 16:18:20 2016
New Revision: 303309
URL: https://svnweb.freebsd.org/changeset/base/303309

Log:
  Remove an unused variable.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 15:59:31 2016
(r303308)
+++ head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 16:18:20 2016
(r303309)
@@ -112,9 +112,6 @@ static int ipi_handler(void *arg);
 struct mtx ap_boot_mtx;
 struct pcb stoppcbs[MAXCPU];
 
-#ifdef INVARIANTS
-static uint32_t cpu_reg[MAXCPU][2];
-#endif
 static device_t cpu_list[MAXCPU];
 
 /*
@@ -443,13 +440,6 @@ cpu_init_fdt(u_int id, phandle_t node, u
 
KASSERT(id < MAXCPU, ("Too many CPUs"));
 
-   KASSERT(addr_size == 1 || addr_size == 2, ("Invalid register size"));
-#ifdef INVARIANTS
-   cpu_reg[id][0] = reg[0];
-   if (addr_size == 2)
-   cpu_reg[id][1] = reg[1];
-#endif
-
/* We are already running on cpu 0 */
if (id == cpu0)
return (1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303308 - head/sys/arm64/arm64

2016-07-25 Thread Andrew Turner
Author: andrew
Date: Mon Jul 25 15:59:31 2016
New Revision: 303308
URL: https://svnweb.freebsd.org/changeset/base/303308

Log:
  Fix a typo in a string in a KASSERT to sanity check the CPU IDs.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 15:57:13 2016
(r303307)
+++ head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 15:59:31 2016
(r303308)
@@ -441,7 +441,7 @@ cpu_init_fdt(u_int id, phandle_t node, u
if (id > mp_maxid)
return (0);
 
-   KASSERT(id < MAXCPU, ("Too mant CPUs"));
+   KASSERT(id < MAXCPU, ("Too many CPUs"));
 
KASSERT(addr_size == 1 || addr_size == 2, ("Invalid register size"));
 #ifdef INVARIANTS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303307 - head/sys/arm64/arm64

2016-07-25 Thread Andrew Turner
Author: andrew
Date: Mon Jul 25 15:57:13 2016
New Revision: 303307
URL: https://svnweb.freebsd.org/changeset/base/303307

Log:
  Rework how we number CPUs on arm64 to try and keep clusters together.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 15:56:37 2016
(r303306)
+++ head/sys/arm64/arm64/mp_machdep.c   Mon Jul 25 15:57:13 2016
(r303307)
@@ -454,9 +454,16 @@ cpu_init_fdt(u_int id, phandle_t node, u
if (id == cpu0)
return (1);
 
+   /*
+* Rotate the CPU IDs to put the boot CPU as CPU 0. We keep the other
+* CPUs ordered as the are likely grouped into clusters so it can be
+* useful to keep that property, e.g. for the GICv3 driver to send
+* an IPI to all CPUs in the cluster.
+*/
cpuid = id;
if (cpuid < cpu0)
-   cpuid++;
+   cpuid += mp_maxid + 1;
+   cpuid -= cpu0;
 
pcpup = &__pcpu[cpuid];
pcpu_init(pcpup, cpuid, sizeof(struct pcpu));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303299 - head/sys/arm64/conf

2016-07-25 Thread Andrew Turner
Author: andrew
Date: Mon Jul 25 14:49:15 2016
New Revision: 303299
URL: https://svnweb.freebsd.org/changeset/base/303299

Log:
  Enable the generic OHCI driver on arm64
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Relnotes: yes
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/conf/GENERIC

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Mon Jul 25 14:45:48 2016(r303298)
+++ head/sys/arm64/conf/GENERIC Mon Jul 25 14:49:15 2016(r303299)
@@ -130,6 +130,7 @@ device  pl011
 # USB support
 optionsUSB_DEBUG   # enable debug msgs
 device dwcotg  # DWC OTG controller
+device ohci# OHCI PCI->USB interface
 device xhci# XHCI PCI->USB interface (USB 3.0)
 device usb # USB Bus (required)
 device ukbd# Keyboard
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303259 - head/sys/dev/uart

2016-07-24 Thread Andrew Turner
Author: andrew
Date: Sun Jul 24 08:52:49 2016
New Revision: 303259
URL: https://svnweb.freebsd.org/changeset/base/303259

Log:
  Remove now unused functions from the FDT uart cpu driver.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  X-MFC with:   r303100
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/uart/uart_cpu_fdt.c

Modified: head/sys/dev/uart/uart_cpu_fdt.c
==
--- head/sys/dev/uart/uart_cpu_fdt.cSun Jul 24 08:35:45 2016
(r303258)
+++ head/sys/dev/uart/uart_cpu_fdt.cSun Jul 24 08:52:49 2016
(r303259)
@@ -70,53 +70,6 @@ uart_cpu_eqres(struct uart_bas *b1, stru
return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0);
 }
 
-static int
-phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node)
-{
-   char buf[64];
-
-   if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0)
-   return (ENXIO);
-   if ((*node = OF_finddevice(buf)) == -1)
-   return (ENXIO);
-   
-   return (0);
-}
-
-static const struct ofw_compat_data *
-uart_fdt_find_compatible(phandle_t node, const struct ofw_compat_data *cd)
-{
-   const struct ofw_compat_data *ocd;
-
-   for (ocd = cd; ocd->ocd_str != NULL; ocd++) {
-   if (fdt_is_compatible(node, ocd->ocd_str))
-   return (ocd);
-   }
-   return (NULL);
-}
-
-static uintptr_t
-uart_fdt_find_by_node(phandle_t node, int class_list)
-{
-   struct ofw_compat_data **cd;
-   const struct ofw_compat_data *ocd;
-
-   if (class_list) {
-   SET_FOREACH(cd, uart_fdt_class_set) {
-   ocd = uart_fdt_find_compatible(node, *cd);
-   if ((ocd != NULL) && (ocd->ocd_data != 0))
-   return (ocd->ocd_data);
-   }
-   } else {
-   SET_FOREACH(cd, uart_fdt_class_and_device_set) {
-   ocd = uart_fdt_find_compatible(node, *cd);
-   if ((ocd != NULL) && (ocd->ocd_data != 0))
-   return (ocd->ocd_data);
-   }
-   }
-   return (0);
-}
-
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r303253 - head/sys/arm/ti

2016-07-24 Thread Andrew Turner
On Sun, 24 Jul 2016 01:31:41 + (UTC)
Luiz Otavio O Souza  wrote:

> Author: loos
> Date: Sun Jul 24 01:31:41 2016
> New Revision: 303253
> URL: https://svnweb.freebsd.org/changeset/base/303253
> 
> Log:
>   Allow the use of micphy on am335x devices.
>   
>   The Micrel PHYs reads the optional external delays from DTB.
>   
>   Tested and used by uBMC and uFW.
>   
>   Sponsored by:   Rubicon Communications (Netgate)
> 
> Modified:
>   head/sys/arm/ti/files.ti
> 
> Modified: head/sys/arm/ti/files.ti
> ==
> --- head/sys/arm/ti/files.ti  Sat Jul 23 22:50:59 2016
> (r303252) +++ head/sys/arm/ti/files.tiSun Jul 24 01:31:41
> 2016  (r303253) @@ -20,6 +20,7 @@
> arm/ti/ti_i2c.c
> optional  ti_i2c arm/ti/ti_sdhci.c
>   optionalsdhci
> arm/ti/ti_spi.c
> optional  ti_spi
> +dev/mii/micphy.c optional
> micphy

Why add it here and not sys/conf/files? It doesn't seem to be Ti
specific.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r301453 - in head/sys: arm/arm arm64/arm64 dev/fdt dev/gpio dev/iicbus dev/ofw dev/pci dev/vnic kern mips/mips sys

2016-07-22 Thread Andrew Turner
On Fri, 22 Jul 2016 13:19:32 -0700
John Baldwin <j...@freebsd.org> wrote:

> On Thursday, July 21, 2016 10:51:20 PM Nathan Whitehorn wrote:
> > 
> > On 07/21/16 14:35, John Baldwin wrote:  
> > > On Thursday, July 21, 2016 01:37:42 PM Andrew Turner wrote:  
> > >> On Wed, 20 Jul 2016 13:28:53 +0200
> > >> Michal Meloun <m...@freebsd.org> wrote:  
> > >>> Dne 19.07.2016 v 17:06 Nathan Whitehorn napsal(a):  
> > >>>> 2. It partially duplicates the functionality of
> > >>>> OFW_BUS_MAP_INTR(), but is both problematically more general
> > >>>> and less flexible (it has requirements on timing of PIC
> > >>>> attachment vs. driver resource allocation)  
> > >>> OFW_BUS_MAP_INTR()  can parse only OFW  based data and expect
> > >>> that parsed data are magicaly stored within the call.
> > >>> The new method, bus_map_intr(),  can parse data from multiple
> > >>> sources (OFW, UEFI / ACPI, synthetic[gpio device + pin
> > >>> number]).  It also returns parsed data back to caller.
> > >>> And no, it  doesn't  add any additional timing requirements .  
> > >> I've been looking at ACPI on arm64. So far I have not found the
> > >> need for this with ACPI as we don't need to send the data to the
> > >> interrupt controller driver to be parsed in the way OFW/FDT
> > >> needs to.  
> > > ACPI though has a gross hack where we call BUS_CONFIG_INTR on the
> > > IRQ in bus_alloc_resource().  
> > 
> > I hadn't realized that. It looks like you could do essentially the
> > same thing we do on PowerPC to clean this up by explicitly mapping
> > the ACPI interrupt domains to different PICs with varying default
> > interrupt properties.
> >   
> > > What I had advocated in the discussions
> > > leading up to this was to have some sort of opaque structure
> > > containing a set of properties (the sort of thing
> > > bus_map_resource and make_dev_s use) that was passed up at
> > > bus_setup_intr() time.  
> >   
> > > I think it should now
> > > be passed up at bus_alloc_resource() time instead, but it would
> > > allow bus drivers to "decorate" a SYS_RES_IRQ request as it goes
> > > up the device tree with properties that the interrupt controller
> > > can then associate with the IRQ cookie it allocates in its own
> > > code.  
> > 
> > 
> > We used to do this on PPC and MIPS, and the current code still
> > supports it, but it turned out not to be useful in the end for
> > IRQs. The hierarchy for IRQs rarely (read: almost never) follows
> > the bus hierarchy and often is enumerated in a different order. I
> > have hardware, for example, where the children of a single parent
> > bus are all wired to different interrupt controllers and sometimes
> > to a mixture of interrupt controllers. Those controllers are
> > cascaded in ways that cross the newbus tree laterally and, on some
> > of them, the parent device from the bus topology has interrupts
> > handled by its own (bus) children. Trying to make the newbus
> > parents do something sensible with all of this would be crazy and,
> > in the case where parents depend on resources provided by their own
> > children, impossible.
> > 
> > This is all to say that, since you want the interrupts to be
> > decorated along a path that usually has nothing to do with the
> > newbus hierarchy, it doesn't add much to add extra features to
> > resource allocation. ofw_bus_map_intr() is a newbus method to
> > support this kind of thing but, on all supported platforms, it is
> > implemented only in nexus and no cases have appeared where anyone
> > ever wanted anything at the intermediate layers.  
> 
> Mmm.  Another idea that has been bandied about is to create a separate
> "plane" in new-bus for an interrupt hierarchy and allow devices to
> have "interrupt" parents that are not the same as the "bus" parent.
> (Additional planes for power and clocks might also make sense.)  The
> idea is borrowed from IOKit on Darwin which has multiple planes.  The
> "bus" plane is always fully populated, but the other planes (Darwin
> has one for power for example) can be sparse.  ACPI has methods that
> effectively describe the power plane on x86.

For some planes the structure would look more like a directed
graph. Devices can have multiple clock parents, e.g. one for the
register interface, and another to drive the external bus.

I can also imagine the case where a device could have multiple
interrupt parents, an MMC/SD controller comes to mind where it may have
an interrupt on a GPIO line to detect the card being inserted, with
another for command completion, etc. In this case one parent would be
the standard interrupt controller, with the other being the GPIO
controller.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303143 - in head/sys: dev/uart modules/uart

2016-07-21 Thread Andrew Turner
Author: andrew
Date: Thu Jul 21 13:01:35 2016
New Revision: 303143
URL: https://svnweb.freebsd.org/changeset/base/303143

Log:
  Fix the build:
   * Add acpi_if.h to the SRC list in the uart module
   * Only include new acpi headers when they are needed
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/uart/uart_bus_acpi.c
  head/sys/modules/uart/Makefile

Modified: head/sys/dev/uart/uart_bus_acpi.c
==
--- head/sys/dev/uart/uart_bus_acpi.c   Thu Jul 21 12:53:36 2016
(r303142)
+++ head/sys/dev/uart/uart_bus_acpi.c   Thu Jul 21 13:01:35 2016
(r303143)
@@ -41,9 +41,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef __aarch64__
 #include 
 #include 
 #include 
+#endif
 
 static int uart_acpi_probe(device_t dev);
 

Modified: head/sys/modules/uart/Makefile
==
--- head/sys/modules/uart/Makefile  Thu Jul 21 12:53:36 2016
(r303142)
+++ head/sys/modules/uart/Makefile  Thu Jul 21 13:01:35 2016
(r303143)
@@ -32,7 +32,8 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} u
uart_dev_z8530.c \
uart_if.c uart_if.h uart_subr.c uart_tty.c
 
-SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \
+SRCS+= acpi_if.h bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} \
+   pci_if.h \
power_if.h pccarddevs.h serdev_if.h
 SRCS+= opt_platform.h opt_uart.h
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r301453 - in head/sys: arm/arm arm64/arm64 dev/fdt dev/gpio dev/iicbus dev/ofw dev/pci dev/vnic kern mips/mips sys

2016-07-21 Thread Andrew Turner
On Wed, 20 Jul 2016 13:28:53 +0200
Michal Meloun  wrote:
> Dne 19.07.2016 v 17:06 Nathan Whitehorn napsal(a):
> > 2. It partially duplicates the functionality of OFW_BUS_MAP_INTR(),
> > but is both problematically more general and less flexible (it has
> > requirements on timing of PIC attachment vs. driver resource
> > allocation)  
> OFW_BUS_MAP_INTR()  can parse only OFW  based data and expect that
> parsed data are magicaly stored within the call.
> The new method, bus_map_intr(),  can parse data from multiple sources 
> (OFW, UEFI / ACPI, synthetic[gpio device + pin number]).  It also
> returns parsed data back to caller.
> And no, it  doesn't  add any additional timing requirements .

I've been looking at ACPI on arm64. So far I have not found the need
for this with ACPI as we don't need to send the data to the interrupt
controller driver to be parsed in the way OFW/FDT needs to.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r303133 - head/sys/dev/uart

2016-07-21 Thread Andrew Turner
On Thu, 21 Jul 2016 09:32:56 + (UTC)
Andrew Turner <and...@freebsd.org> wrote:

> Author: andrew
> Date: Thu Jul 21 09:32:55 2016
> New Revision: 303133
> URL: https://svnweb.freebsd.org/changeset/base/303133
> 
> Log:
>   Add support for arm64 to uart_dev_acpi by using the _HID property
> to find the uart class to use in a similar way as the fdt driver.
>   

Reviewed by: jhb

>   Obtained from:  ABT Systems Ltd
>   MFC after:  1 month
>   Sponsored by:   The FreeBSD Foundation
>   Differential Revision:  https://reviews.freebsd.org/D7248

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303133 - head/sys/dev/uart

2016-07-21 Thread Andrew Turner
Author: andrew
Date: Thu Jul 21 09:32:55 2016
New Revision: 303133
URL: https://svnweb.freebsd.org/changeset/base/303133

Log:
  Add support for arm64 to uart_dev_acpi by using the _HID property to find
  the uart class to use in a similar way as the fdt driver.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7248

Added:
  head/sys/dev/uart/uart_cpu_acpi.h   (contents, props changed)
Modified:
  head/sys/dev/uart/uart_bus_acpi.c
  head/sys/dev/uart/uart_dev_pl011.c

Modified: head/sys/dev/uart/uart_bus_acpi.c
==
--- head/sys/dev/uart/uart_bus_acpi.c   Thu Jul 21 08:22:25 2016
(r303132)
+++ head/sys/dev/uart/uart_bus_acpi.c   Thu Jul 21 09:32:55 2016
(r303133)
@@ -39,6 +39,11 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
+
+#include 
+#include 
+#include 
 
 static int uart_acpi_probe(device_t dev);
 
@@ -57,6 +62,7 @@ static driver_t uart_acpi_driver = {
sizeof(struct uart_softc),
 };
 
+#if defined(__i386__) || defined(__amd64__)
 static struct isa_pnp_id acpi_ns8250_ids[] = {
{0x0005d041, "Standard PC COM port"},   /* PNP0500 */
{0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */
@@ -67,6 +73,27 @@ static struct isa_pnp_id acpi_ns8250_ids
{0xe502aa1a, "Wacom Tablet at FuS Lifebook T"}, /* FUJ02E5 */
{0}
 };
+#endif
+
+#ifdef __aarch64__
+static struct uart_class *
+uart_acpi_find_device(device_t dev)
+{
+   struct acpi_uart_compat_data **cd;
+   ACPI_HANDLE h;
+
+   if ((h = acpi_get_handle(dev)) == NULL)
+   return (NULL);
+
+   SET_FOREACH(cd, uart_acpi_class_and_device_set) {
+   if (acpi_MatchHid(h, (*cd)->hid)) {
+   return ((*cd)->clas);
+   }
+   }
+
+   return (NULL);
+}
+#endif
 
 static int
 uart_acpi_probe(device_t dev)
@@ -77,12 +104,18 @@ uart_acpi_probe(device_t dev)
parent = device_get_parent(dev);
sc = device_get_softc(dev);
 
+#if defined(__i386__) || defined(__amd64__)
if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) {
sc->sc_class = _ns8250_class;
return (uart_bus_probe(dev, 0, 0, 0, 0));
}
 
/* Add checks for non-ns8250 IDs here. */
+#elif defined(__aarch64__)
+   if ((sc->sc_class = uart_acpi_find_device(dev)) != NULL)
+   return (uart_bus_probe(dev, 2, 0, 0, 0));
+#endif
+
return (ENXIO);
 }
 

Added: head/sys/dev/uart/uart_cpu_acpi.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/uart/uart_cpu_acpi.h   Thu Jul 21 09:32:55 2016
(r303133)
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2015 Michal Meloun
+ * Copyright (c) 2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _DEV_UART_CPU_ACPI_H_
+#define _DEV_UART_CPU_ACPI_H_
+
+#include 
+
+struct uart_class;
+
+struct acpi_uart_compat_data {
+   const char *hid;
+   struct uart_class *clas;
+};
+
+/*
+ * If your UART driver implements only uart_class and uses uart_cpu_acpi.c
+ * for device instantiation, then use UART_ACPI_CLASS_AND_DEVICE for its
+ * declaration
+ */
+SET_DECLARE(uart_acpi_class_and_device_set, struct acpi_uart_compat_data);
+#define UART_ACPI_CLASS_AND_DEVICE(da

Re: svn commit: r303123 - head/sys/cam

2016-07-21 Thread Andrew Turner
On Thu, 21 Jul 2016 03:11:35 + (UTC)
Warner Losh  wrote:

> Author: imp
> Date: Thu Jul 21 03:11:35 2016
> New Revision: 303123
> URL: https://svnweb.freebsd.org/changeset/base/303123
> 
> Log:
>   Fix mismerge and include the nvme support.
>   Also, print out the name of any CCB's functions that's not
> supported. 
>   MFC after: 1 week
> 
> Modified:
>   head/sys/cam/cam_xpt.c
> 
> Modified: head/sys/cam/cam_xpt.c
> ==
> --- head/sys/cam/cam_xpt.cThu Jul 21 00:53:14 2016
> (r303122) +++ head/sys/cam/cam_xpt.c  Thu Jul 21 03:11:35
> 2016  (r303123) @@ -1033,6 +1033,8 @@
> xpt_announce_periph(struct cam_periph *p else if
> (path->device->protocol == PROTO_SEMB) semb_print_ident(
>   (struct sep_identify_data
> *)>device->ident_data);
> + else if (path->device->protocol == PROTO_NVME)
> + nvme_print_ident(path->device->nvme_cdata,
> path->device->nvme_data);
This breaks kernel configs with scbus but not nvme. This seems to be
most of the non-x86 configs.

linking kernel.full
cam_xpt.o: In function `xpt_announce_periph':
/usr/home/andrew/freebsd/repo/head-svn/sys/cam/cam_xpt.c:1037: undefined 
reference to `nvme_print_ident'
cam_xpt.o: In function `xpt_denounce_periph':
/usr/home/andrew/freebsd/repo/head-svn/sys/cam/cam_xpt.c:1092: undefined 
reference to `nvme_print_ident'
cam_xpt.o: In function `xpt_run_devq':
/usr/home/andrew/freebsd/repo/head-svn/sys/cam/cam_xpt.c:3331: undefined 
reference to `nvme_op_string'
/usr/home/andrew/freebsd/repo/head-svn/sys/cam/cam_xpt.c:3331: undefined 
reference to `nvme_cmd_string'
cam_xpt.o: In function `xpt_bus_register':
/usr/home/andrew/freebsd/repo/head-svn/sys/cam/cam_xpt.c:3927: undefined 
reference to `nvme_get_xport'
--- kernel.full ---
*** [kernel.full] Error code 1


Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303102 - head/sys/conf

2016-07-20 Thread Andrew Turner
Author: andrew
Date: Wed Jul 20 17:46:33 2016
New Revision: 303102
URL: https://svnweb.freebsd.org/changeset/base/303102

Log:
  Mark the Designware MMC and USB OTG drivers as FDT only. These are normally
  found on arm64 devices that use FDT.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/conf/files.arm64

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Wed Jul 20 17:20:22 2016(r303101)
+++ head/sys/conf/files.arm64   Wed Jul 20 17:46:33 2016(r303102)
@@ -59,8 +59,8 @@ dev/acpica/acpi_if.m  optionalacpi
 dev/ahci/ahci_generic.coptional ahci fdt
 dev/hwpmc/hwpmc_arm64.coptionalhwpmc
 dev/hwpmc/hwpmc_arm64_md.c optionalhwpmc
-dev/mmc/host/dwmmc.c   optionaldwmmc
-dev/mmc/host/dwmmc_hisi.c  optionaldwmmc soc_hisi_hi6220
+dev/mmc/host/dwmmc.c   optionaldwmmc fdt
+dev/mmc/host/dwmmc_hisi.c  optionaldwmmc fdt soc_hisi_hi6220
 dev/ofw/ofw_cpu.c  optionalfdt
 dev/ofw/ofwpci.c   optionalfdt pci
 dev/pci/pci_host_generic.c optionalpci fdt
@@ -68,7 +68,7 @@ dev/psci/psci.c   optionalpsci
 dev/psci/psci_arm64.S  optionalpsci
 dev/uart/uart_cpu_fdt.coptionaluart fdt
 dev/uart/uart_dev_pl011.c  optionaluart pl011
-dev/usb/controller/dwc_otg_hisi.c optional dwcotg soc_hisi_hi6220
+dev/usb/controller/dwc_otg_hisi.c optional dwcotg fdt soc_hisi_hi6220
 dev/usb/controller/generic_ohci.c optional ohci fdt
 dev/usb/controller/generic_usb_if.m optional   ohci fdt
 dev/vnic/mrml_bridge.c optionalvnic fdt
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303100 - head/sys/dev/uart

2016-07-20 Thread Andrew Turner
Author: andrew
Date: Wed Jul 20 17:19:47 2016
New Revision: 303100
URL: https://svnweb.freebsd.org/changeset/base/303100

Log:
  We will be switching to a new arm64 uart cpu driver that handles both FDT
  and ACPI. As such pull out what will be the common parts of the FDT cpu
  detection to a new function that can be shared between them.
  
  Reviewed by:  manu
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D7262

Modified:
  head/sys/dev/uart/uart_bus_fdt.c
  head/sys/dev/uart/uart_cpu_fdt.c
  head/sys/dev/uart/uart_cpu_fdt.h

Modified: head/sys/dev/uart/uart_bus_fdt.c
==
--- head/sys/dev/uart/uart_bus_fdt.cWed Jul 20 16:59:36 2016
(r303099)
+++ head/sys/dev/uart/uart_bus_fdt.cWed Jul 20 17:19:47 2016
(r303100)
@@ -105,6 +105,129 @@ uart_fdt_find_device(device_t dev)
 }
 
 static int
+phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node)
+{
+   char buf[64];
+
+   if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0)
+   return (ENXIO);
+   if ((*node = OF_finddevice(buf)) == -1)
+   return (ENXIO);
+
+   return (0);
+}
+
+static const struct ofw_compat_data *
+uart_fdt_find_compatible(phandle_t node, const struct ofw_compat_data *cd)
+{
+   const struct ofw_compat_data *ocd;
+
+   for (ocd = cd; ocd->ocd_str != NULL; ocd++) {
+   if (fdt_is_compatible(node, ocd->ocd_str))
+   return (ocd);
+   }
+   return (NULL);
+}
+
+static uintptr_t
+uart_fdt_find_by_node(phandle_t node, int class_list)
+{
+   struct ofw_compat_data **cd;
+   const struct ofw_compat_data *ocd;
+
+   if (class_list) {
+   SET_FOREACH(cd, uart_fdt_class_set) {
+   ocd = uart_fdt_find_compatible(node, *cd);
+   if ((ocd != NULL) && (ocd->ocd_data != 0))
+   return (ocd->ocd_data);
+   }
+   } else {
+   SET_FOREACH(cd, uart_fdt_class_and_device_set) {
+   ocd = uart_fdt_find_compatible(node, *cd);
+   if ((ocd != NULL) && (ocd->ocd_data != 0))
+   return (ocd->ocd_data);
+   }
+   }
+
+   return (0);
+}
+
+int
+uart_cpu_fdt_probe(struct uart_class **classp, bus_space_tag_t *bst,
+bus_space_handle_t *bsh, int *baud, u_int *rclk, u_int *shiftp)
+{
+   const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout",
+   "stdin-path", "stdin", NULL};
+   const char **name;
+   struct uart_class *class;
+   phandle_t node, chosen;
+   pcell_t br, clk, shift;
+   char *cp;
+   int err;
+
+   /* Has the user forced a specific device node? */
+   cp = kern_getenv("hw.fdt.console");
+   if (cp == NULL) {
+   /*
+* Retrieve /chosen/std{in,out}.
+*/
+   node = -1;
+   if ((chosen = OF_finddevice("/chosen")) != -1) {
+   for (name = propnames; *name != NULL; name++) {
+   if (phandle_chosen_propdev(chosen, *name,
+   ) == 0)
+   break;
+   }
+   }
+   if (chosen == -1 || *name == NULL)
+   node = OF_finddevice("serial0"); /* Last ditch */
+   } else {
+   node = OF_finddevice(cp);
+   }
+
+   if (node == -1)
+   return (ENXIO);
+
+   /*
+* Check old style of UART definition first. Unfortunately, the common
+* FDT processing is not possible if we have clock, power domains and
+* pinmux stuff.
+*/
+   class = (struct uart_class *)uart_fdt_find_by_node(node, 0);
+   if (class != NULL) {
+   if ((err = uart_fdt_get_clock(node, )) != 0)
+   return (err);
+   } else {
+   /* Check class only linker set */
+   class =
+   (struct uart_class *)uart_fdt_find_by_node(node, 1);
+   if (class == NULL)
+   return (ENXIO);
+   clk = 0;
+   }
+
+   /*
+* Retrieve serial attributes.
+*/
+   if (uart_fdt_get_shift(node, ) != 0)
+   shift = uart_getregshift(class);
+
+   if (OF_getencprop(node, "current-speed", , sizeof(br)) <= 0)
+   br = 0;
+
+   err = OF_decode_addr(node, 0, bst, bsh, NULL);
+   if (err != 0)
+   return (err);
+
+   *classp = class;
+   *baud = br;
+   *rclk = clk;
+   *shiftp = shift;
+
+   return (0);
+}
+
+static int
 uart_fdt_probe(device_t dev)
 {
struct uart_softc *sc;

Modified: head/sys/dev/uart/uart_cpu_fdt.c

svn commit: r303026 - head/usr.sbin/acpi/acpidump

2016-07-19 Thread Andrew Turner
Author: andrew
Date: Tue Jul 19 16:02:07 2016
New Revision: 303026
URL: https://svnweb.freebsd.org/changeset/base/303026

Log:
  Add missing flags from acpidump. These are defined in the header, but not
  printed. The HW_REDUCED flag is useful as it should be set on arm64 to
  comply with the ARM Server Base Boot Requirements.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/acpi/acpidump/acpi.c

Modified: head/usr.sbin/acpi/acpidump/acpi.c
==
--- head/usr.sbin/acpi/acpidump/acpi.c  Tue Jul 19 11:16:44 2016
(r303025)
+++ head/usr.sbin/acpi/acpidump/acpi.c  Tue Jul 19 16:02:07 2016
(r303026)
@@ -1177,6 +1177,7 @@ acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
PRINTFLAG(fadt->BootFlags, NO_VGA);
PRINTFLAG(fadt->BootFlags, NO_MSI);
PRINTFLAG(fadt->BootFlags, NO_ASPM);
+   PRINTFLAG(fadt->BootFlags, NO_CMOS_RTC);
PRINTFLAG_END();
 
printf("\tFlags=");
@@ -1200,6 +1201,8 @@ acpi_print_fadt(ACPI_TABLE_HEADER *sdp)
PRINTFLAG(fadt->Flags, REMOTE_POWER_ON);
PRINTFLAG(fadt->Flags, APIC_CLUSTER);
PRINTFLAG(fadt->Flags, APIC_PHYSICAL);
+   PRINTFLAG(fadt->Flags, HW_REDUCED);
+   PRINTFLAG(fadt->Flags, LOW_POWER_S0);
PRINTFLAG_END();
 
 #undef PRINTFLAG
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302896 - head/sys/arm64/arm64

2016-07-15 Thread Andrew Turner
Author: andrew
Date: Fri Jul 15 13:25:47 2016
New Revision: 302896
URL: https://svnweb.freebsd.org/changeset/base/302896

Log:
  Implement bus_print_child to print the resources used by the ITS driver.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3_fdt.c

Modified: head/sys/arm64/arm64/gic_v3_fdt.c
==
--- head/sys/arm64/arm64/gic_v3_fdt.c   Fri Jul 15 09:44:48 2016
(r302895)
+++ head/sys/arm64/arm64/gic_v3_fdt.c   Fri Jul 15 13:25:47 2016
(r302896)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
  */
 static int gic_v3_fdt_probe(device_t);
 static int gic_v3_fdt_attach(device_t);
+static int gic_v3_fdt_print_child(device_t, device_t);
 
 static struct resource *gic_v3_ofw_bus_alloc_res(device_t, device_t, int, int 
*,
 rman_res_t, rman_res_t, rman_res_t, u_int);
@@ -64,6 +65,7 @@ static device_method_t gic_v3_fdt_method
DEVMETHOD(device_attach,gic_v3_fdt_attach),
 
/* Bus interface */
+   DEVMETHOD(bus_print_child,  gic_v3_fdt_print_child),
DEVMETHOD(bus_alloc_resource,   gic_v3_ofw_bus_alloc_res),
DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
 
@@ -183,6 +185,20 @@ struct gic_v3_ofw_devinfo {
struct resource_listdi_rl;
 };
 
+static int
+gic_v3_fdt_print_child(device_t bus, device_t child)
+{
+   struct gic_v3_ofw_devinfo *di = device_get_ivars(child);
+   struct resource_list *rl = >di_rl;
+   int retval = 0;
+
+   retval += bus_print_child_header(bus, child);
+   retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx");
+   retval += bus_print_child_footer(bus, child);
+
+   return (retval);
+}
+
 static const struct ofw_bus_devinfo *
 gic_v3_ofw_get_devinfo(device_t bus __unused, device_t child)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302853 - in head/sys/arm64: arm64 include

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 17:31:29 2016
New Revision: 302853
URL: https://svnweb.freebsd.org/changeset/base/302853

Log:
  Finish removing the non-INTRNG support from sys/arm64.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/autoconf.c
  head/sys/arm64/arm64/mp_machdep.c
  head/sys/arm64/arm64/nexus.c
  head/sys/arm64/include/intr.h

Modified: head/sys/arm64/arm64/autoconf.c
==
--- head/sys/arm64/arm64/autoconf.c Thu Jul 14 17:23:49 2016
(r302852)
+++ head/sys/arm64/arm64/autoconf.c Thu Jul 14 17:31:29 2016
(r302853)
@@ -81,12 +81,8 @@ static void
 configure_final(void *dummy)
 {
 
-#ifdef INTRNG
/* Enable interrupt reception on this CPU */
intr_enable();
-#else
-   arm_enable_intr();
-#endif
cninit_finish(); 
 
if (bootverbose)

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Thu Jul 14 17:23:49 2016
(r302852)
+++ head/sys/arm64/arm64/mp_machdep.c   Thu Jul 14 17:31:29 2016
(r302853)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#ifdef INTRNG
 #include "pic_if.h"
 
 typedef void intr_ipi_send_t(void *, cpuset_t, u_int);
@@ -86,7 +85,6 @@ static struct intr_ipi ipi_sources[INTR_
 static struct intr_ipi *intr_ipi_lookup(u_int);
 static void intr_pic_ipi_setup(u_int, const char *, intr_ipi_handler_t *,
 void *);
-#endif /* INTRNG */
 
 boolean_t ofw_cpu_reg(phandle_t node, u_int, cell_t *);
 
@@ -214,18 +212,12 @@ release_aps(void *dummy __unused)
 {
int cpu, i;
 
-#ifdef INTRNG
intr_pic_ipi_setup(IPI_AST, "ast", ipi_ast, NULL);
intr_pic_ipi_setup(IPI_PREEMPT, "preempt", ipi_preempt, NULL);
intr_pic_ipi_setup(IPI_RENDEZVOUS, "rendezvous", ipi_rendezvous, NULL);
intr_pic_ipi_setup(IPI_STOP, "stop", ipi_stop, NULL);
intr_pic_ipi_setup(IPI_STOP_HARD, "stop hard", ipi_stop, NULL);
intr_pic_ipi_setup(IPI_HARDCLOCK, "hardclock", ipi_hardclock, NULL);
-#else
-   /* Setup the IPI handler */
-   for (i = 0; i < INTR_IPI_COUNT; i++)
-   arm_setup_ipihandler(ipi_handler, i);
-#endif
 
atomic_store_rel_int(_ready, 1);
/* Wake up the other CPUs */
@@ -253,9 +245,6 @@ void
 init_secondary(uint64_t cpu)
 {
struct pcpu *pcpup;
-#ifndef INTRNG
-   int i;
-#endif
 
pcpup = &__pcpu[cpu];
/*
@@ -282,15 +271,7 @@ init_secondary(uint64_t cpu)
 */
identify_cpu();
 
-#ifdef INTRNG
intr_pic_init_secondary();
-#else
-   /* Configure the interrupt controller */
-   arm_init_secondary();
-
-   for (i = 0; i < INTR_IPI_COUNT; i++)
-   arm_unmask_ipi(i);
-#endif
 
/* Start per-CPU event timers. */
cpu_initclocks_ap();
@@ -322,7 +303,6 @@ init_secondary(uint64_t cpu)
/* NOTREACHED */
 }
 
-#ifdef INTRNG
 /*
  *  Send IPI thru interrupt controller.
  */
@@ -378,7 +358,6 @@ intr_ipi_send(cpuset_t cpus, u_int ipi)
 
ii->ii_send(ii->ii_send_arg, cpus, ipi);
 }
-#endif
 
 static void
 ipi_ast(void *dummy __unused)
@@ -432,44 +411,6 @@ ipi_stop(void *dummy __unused)
CTR0(KTR_SMP, "IPI_STOP (restart)");
 }
 
-#ifndef INTRNG
-static int
-ipi_handler(void *arg)
-{
-   u_int cpu, ipi;
-
-   arg = (void *)((uintptr_t)arg & ~(1 << 16));
-   KASSERT((uintptr_t)arg < INTR_IPI_COUNT,
-   ("Invalid IPI %ju", (uintptr_t)arg));
-
-   cpu = PCPU_GET(cpuid);
-   ipi = (uintptr_t)arg;
-
-   switch(ipi) {
-   case IPI_AST:
-   ipi_ast(NULL);
-   break;
-   case IPI_PREEMPT:
-   ipi_preempt(NULL);
-   break;
-   case IPI_RENDEZVOUS:
-   ipi_rendezvous(NULL);
-   break;
-   case IPI_STOP:
-   case IPI_STOP_HARD:
-   ipi_stop(NULL);
-   break;
-   case IPI_HARDCLOCK:
-   ipi_hardclock(NULL);
-   break;
-   default:
-   panic("Unknown IPI %#0x on cpu %d", ipi, curcpu);
-   }
-
-   return (FILTER_HANDLED);
-}
-#endif
-
 struct cpu_group *
 cpu_topo(void)
 {
@@ -624,7 +565,6 @@ cpu_mp_setmaxid(void)
mp_maxid = 0;
 }
 
-#ifdef INTRNG
 /*
  *  Lookup IPI source.
  */
@@ -768,4 +708,3 @@ ipi_selected(cpuset_t cpus, u_int ipi)
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
intr_ipi_send(cpus, ipi);
 }
-#endif /* INTRNG */

Modified: head/sys/arm64/arm64/nexus.c
==
--- head/sys/arm64/arm64/nexus.cThu Jul 14 17:23:49 2016
(r302852)
+++ head/sys/arm64/arm64/nexus.cThu Jul 14 17:31:29 2016
(r302853)
@@ -271,13 +271,9 @@ nexus_config_intr(device_t dev, int irq,
 enum 

svn commit: r302852 - head/sys/arm64/cavium

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 17:23:49 2016
New Revision: 302852
URL: https://svnweb.freebsd.org/changeset/base/302852

Log:
  Remove the non-INTRNG support from the ThunderX PCIe drivers.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/cavium/thunder_pcie_pem_fdt.c

Modified: head/sys/arm64/cavium/thunder_pcie_pem_fdt.c
==
--- head/sys/arm64/cavium/thunder_pcie_pem_fdt.cThu Jul 14 17:16:51 
2016(r302851)
+++ head/sys/arm64/cavium/thunder_pcie_pem_fdt.cThu Jul 14 17:23:49 
2016(r302852)
@@ -109,7 +109,6 @@ thunder_pem_fdt_probe(device_t dev)
return (ENXIO);
 }
 
-#ifdef INTRNG
 static int
 thunder_pem_fdt_alloc_msi(device_t pci, device_t child, int count, int 
maxcount,
 int *irqs)
@@ -162,44 +161,6 @@ thunder_pem_fdt_map_msi(device_t pci, de
NULL);
return (intr_map_msi(pci, child, msi_parent, irq, addr, data));
 }
-#else
-static int
-thunder_pem_fdt_alloc_msi(device_t pci, device_t child, int count, int 
maxcount,
-int *irqs)
-{
-
-   return (arm_alloc_msi(pci, child, count, maxcount, irqs));
-}
-
-static int
-thunder_pem_fdt_release_msi(device_t pci, device_t child, int count, int *irqs)
-{
-
-   return (arm_release_msi(pci, child, count, irqs));
-}
-
-static int
-thunder_pem_fdt_alloc_msix(device_t pci, device_t child, int *irq)
-{
-
-   return (arm_alloc_msix(pci, child, irq));
-}
-
-static int
-thunder_pem_fdt_release_msix(device_t pci, device_t child, int irq)
-{
-
-   return (arm_release_msix(pci, child, irq));
-}
-
-static int
-thunder_pem_fdt_map_msi(device_t pci, device_t child, int irq, uint64_t *addr,
-uint32_t *data)
-{
-
-   return (arm_map_msi(pci, child, irq, addr, data));
-}
-#endif
 
 static int
 thunder_pem_fdt_get_id(device_t dev, device_t child, enum pci_id_type type,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302851 - head/sys/arm64/arm64

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 17:16:51 2016
New Revision: 302851
URL: https://svnweb.freebsd.org/changeset/base/302851

Log:
  Move gic_v3_irqsrc into the GICv3 driver source as it's only needed there.
  Remove unused macros from the GICv3 header.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3.c
  head/sys/arm64/arm64/gic_v3_var.h

Modified: head/sys/arm64/arm64/gic_v3.c
==
--- head/sys/arm64/arm64/gic_v3.c   Thu Jul 14 17:16:10 2016
(r302850)
+++ head/sys/arm64/arm64/gic_v3.c   Thu Jul 14 17:16:51 2016
(r302851)
@@ -134,6 +134,13 @@ enum gic_v3_xdist {
REDIST,
 };
 
+struct gic_v3_irqsrc {
+   struct intr_irqsrc  gi_isrc;
+   uint32_tgi_irq;
+   enum intr_polarity  gi_pol;
+   enum intr_trigger   gi_trig;
+};
+
 /* Helper routines starting with gic_v3_ */
 static int gic_v3_dist_init(struct gic_v3_softc *);
 static int gic_v3_redist_alloc(struct gic_v3_softc *);

Modified: head/sys/arm64/arm64/gic_v3_var.h
==
--- head/sys/arm64/arm64/gic_v3_var.h   Thu Jul 14 17:16:10 2016
(r302850)
+++ head/sys/arm64/arm64/gic_v3_var.h   Thu Jul 14 17:16:51 2016
(r302851)
@@ -36,12 +36,7 @@
 
 DECLARE_CLASS(gic_v3_driver);
 
-struct gic_v3_irqsrc {
-   struct intr_irqsrc  gi_isrc;
-   uint32_tgi_irq;
-   enum intr_polarity  gi_pol;
-   enum intr_trigger   gi_trig;
-};
+struct gic_v3_irqsrc;
 
 struct redist_lpis {
vm_offset_t conf_base;
@@ -140,27 +135,4 @@ void gic_r_write_8(device_t, bus_size_t,
reg, val);  \
 })
 
-#definePCI_DEVID_GENERIC(pci_dev)  \
-({ \
-   ((pci_get_domain(pci_dev) << PCI_RID_DOMAIN_SHIFT) |\
-   (pci_get_bus(pci_dev) << PCI_RID_BUS_SHIFT) |   \
-   (pci_get_slot(pci_dev) << PCI_RID_SLOT_SHIFT) | \
-   (pci_get_function(pci_dev) << PCI_RID_FUNC_SHIFT)); \
-})
-
-/*
- * Request number of maximum MSI-X vectors for this device.
- * Device can ask for less vectors than maximum supported but not more.
- */
-#definePCI_MSIX_NUM(pci_dev)   \
-({ \
-   struct pci_devinfo *dinfo;  \
-   pcicfgregs *cfg;\
-   \
-   dinfo = device_get_ivars(pci_dev);  \
-   cfg = >cfg;  \
-   \
-   cfg->msix.msix_msgnum;  \
-})
-
 #endif /* _GIC_V3_VAR_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302849 - head/sys/arm64/arm64

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 17:10:54 2016
New Revision: 302849
URL: https://svnweb.freebsd.org/changeset/base/302849

Log:
  Move structures only used by the GICv3 ITS driver from a shared header to
  the ITS driver file. There is no need for other drivers to need to know
  about these structures.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3_var.h
  head/sys/arm64/arm64/gicv3_its.c

Modified: head/sys/arm64/arm64/gic_v3_var.h
==
--- head/sys/arm64/arm64/gic_v3_var.h   Thu Jul 14 17:05:25 2016
(r302848)
+++ head/sys/arm64/arm64/gic_v3_var.h   Thu Jul 14 17:10:54 2016
(r302849)
@@ -108,87 +108,6 @@ void gic_r_write_4(device_t, bus_size_t,
 void gic_r_write_8(device_t, bus_size_t, uint64_t var);
 
 /*
- * ITS
- */
-
-/* LPI chunk owned by ITS device */
-struct lpi_chunk {
-   u_int   lpi_base;
-   u_int   lpi_free;   /* First free LPI in set */
-   u_int   lpi_num;/* Total number of LPIs in chunk */
-   u_int   lpi_busy;   /* Number of busy LPIs in chink */
-};
-
-/* ITS device */
-struct its_dev {
-   TAILQ_ENTRY(its_dev)entry;
-   /* PCI device */
-   device_tpci_dev;
-   /* Device ID (i.e. PCI device ID) */
-   uint32_tdevid;
-   /* List of assigned LPIs */
-   struct lpi_chunklpis;
-   /* Virtual address of ITT */
-   vm_offset_t itt;
-   size_t  itt_size;
-};
-
-/*
- * ITS command descriptor.
- * Idea for command description passing taken from Linux.
- */
-struct its_cmd_desc {
-   uint8_t cmd_type;
-
-   union {
-   struct {
-   struct its_dev *its_dev;
-   struct its_col *col;
-   uint32_t id;
-   } cmd_desc_movi;
-
-   struct {
-   struct its_col *col;
-   } cmd_desc_sync;
-
-   struct {
-   struct its_col *col;
-   uint8_t valid;
-   } cmd_desc_mapc;
-
-   struct {
-   struct its_dev *its_dev;
-   struct its_col *col;
-   uint32_t pid;
-   uint32_t id;
-   } cmd_desc_mapvi;
-
-   struct {
-   struct its_dev *its_dev;
-   struct its_col *col;
-   uint32_t pid;
-   } cmd_desc_mapi;
-
-   struct {
-   struct its_dev *its_dev;
-   uint8_t valid;
-   } cmd_desc_mapd;
-
-   struct {
-   struct its_dev *its_dev;
-   struct its_col *col;
-   uint32_t pid;
-   } cmd_desc_inv;
-
-   struct {
-   struct its_col *col;
-   } cmd_desc_invall;
-   };
-};
-
-#defineITS_TARGET_NONE 0xFBADBEEF
-
-/*
  * GIC Distributor accessors.
  * Notice that only GIC sofc can be passed.
  */

Modified: head/sys/arm64/arm64/gicv3_its.c
==
--- head/sys/arm64/arm64/gicv3_its.cThu Jul 14 17:05:25 2016
(r302848)
+++ head/sys/arm64/arm64/gicv3_its.cThu Jul 14 17:10:54 2016
(r302849)
@@ -123,6 +123,83 @@ MALLOC_DEFINE(M_GICV3_ITS, "GICv3 ITS",
 #defineCMD_VALID_SHIFT (63)
 #defineCMD_VALID_MASK  (1UL << CMD_VALID_SHIFT)
 
+#defineITS_TARGET_NONE 0xFBADBEEF
+
+/* LPI chunk owned by ITS device */
+struct lpi_chunk {
+   u_int   lpi_base;
+   u_int   lpi_free;   /* First free LPI in set */
+   u_int   lpi_num;/* Total number of LPIs in chunk */
+   u_int   lpi_busy;   /* Number of busy LPIs in chink */
+};
+
+/* ITS device */
+struct its_dev {
+   TAILQ_ENTRY(its_dev)entry;
+   /* PCI device */
+   device_tpci_dev;
+   /* Device ID (i.e. PCI device ID) */
+   uint32_tdevid;
+   /* List of assigned LPIs */
+   struct lpi_chunklpis;
+   /* Virtual address of ITT */
+   vm_offset_t itt;
+   size_t  itt_size;
+};
+
+/*
+ * ITS command descriptor.
+ * Idea for command description passing taken from Linux.
+ */
+struct its_cmd_desc {
+   uint8_t cmd_type;
+
+   union {
+   struct {
+   struct its_dev *its_dev;
+   struct its_col *col;
+   uint32_t id;
+   } cmd_desc_movi;
+
+   struct {
+   struct its_col *col;
+   } cmd_desc_sync;
+
+   struct {
+   struct its_col *col;

svn commit: r302848 - head/sys/arm64/arm64

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 17:05:25 2016
New Revision: 302848
URL: https://svnweb.freebsd.org/changeset/base/302848

Log:
  Remove the non-INTRNG support from the GICv3 interrupt controller driver.
  This is no longer needed.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3.c
  head/sys/arm64/arm64/gic_v3_fdt.c
  head/sys/arm64/arm64/gic_v3_var.h

Modified: head/sys/arm64/arm64/gic_v3.c
==
--- head/sys/arm64/arm64/gic_v3.c   Thu Jul 14 16:52:18 2016
(r302847)
+++ head/sys/arm64/arm64/gic_v3.c   Thu Jul 14 17:05:25 2016
(r302848)
@@ -69,7 +69,6 @@ __FBSDID("$FreeBSD$");
 
 static bus_read_ivar_t gic_v3_read_ivar;
 
-#ifdef INTRNG
 static pic_disable_intr_t gic_v3_disable_intr;
 static pic_enable_intr_t gic_v3_enable_intr;
 static pic_map_intr_t gic_v3_map_intr;
@@ -90,18 +89,6 @@ static u_int gic_irq_cpu;
 static u_int sgi_to_ipi[GIC_LAST_SGI - GIC_FIRST_SGI + 1];
 static u_int sgi_first_unused = GIC_FIRST_SGI;
 #endif
-#else
-/* Device and PIC methods */
-static int gic_v3_bind(device_t, u_int, u_int);
-static void gic_v3_dispatch(device_t, struct trapframe *);
-static void gic_v3_eoi(device_t, u_int);
-static void gic_v3_mask_irq(device_t, u_int);
-static void gic_v3_unmask_irq(device_t, u_int);
-#ifdef SMP
-static void gic_v3_init_secondary(device_t);
-static void gic_v3_ipi_send(device_t, cpuset_t, u_int);
-#endif
-#endif
 
 static device_method_t gic_v3_methods[] = {
/* Device interface */
@@ -110,7 +97,6 @@ static device_method_t gic_v3_methods[] 
/* Bus interface */
DEVMETHOD(bus_read_ivar,gic_v3_read_ivar),
 
-#ifdef INTRNG
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, gic_v3_disable_intr),
DEVMETHOD(pic_enable_intr,  gic_v3_enable_intr),
@@ -126,18 +112,6 @@ static device_method_t gic_v3_methods[] 
DEVMETHOD(pic_ipi_send, gic_v3_ipi_send),
DEVMETHOD(pic_ipi_setup,gic_v3_ipi_setup),
 #endif
-#else
-   /* PIC interface */
-   DEVMETHOD(pic_bind, gic_v3_bind),
-   DEVMETHOD(pic_dispatch, gic_v3_dispatch),
-   DEVMETHOD(pic_eoi,  gic_v3_eoi),
-   DEVMETHOD(pic_mask, gic_v3_mask_irq),
-   DEVMETHOD(pic_unmask,   gic_v3_unmask_irq),
-#ifdef SMP
-   DEVMETHOD(pic_init_secondary,   gic_v3_init_secondary),
-   DEVMETHOD(pic_ipi_send, gic_v3_ipi_send),
-#endif
-#endif
 
/* End */
DEVMETHOD_END
@@ -188,7 +162,6 @@ static gic_v3_initseq_t gic_v3_secondary
 };
 #endif
 
-#ifdef INTRNG
 uint32_t
 gic_r_read_4(device_t dev, bus_size_t offset)
 {
@@ -224,7 +197,6 @@ gic_r_write_8(device_t dev, bus_size_t o
sc = device_get_softc(dev);
bus_write_8(sc->gic_redists.pcpu[PCPU_GET(cpuid)], offset, val);
 }
-#endif
 
 /*
  * Device interface.
@@ -238,10 +210,8 @@ gic_v3_attach(device_t dev)
int rid;
int err;
size_t i;
-#ifdef INTRNG
u_int irq;
const char *name;
-#endif
 
sc = device_get_softc(dev);
sc->gic_registered = FALSE;
@@ -290,7 +260,6 @@ gic_v3_attach(device_t dev)
if (sc->gic_nirqs > GIC_I_NUM_MAX)
sc->gic_nirqs = GIC_I_NUM_MAX;
 
-#ifdef INTRNG
sc->gic_irqs = malloc(sizeof(*sc->gic_irqs) * sc->gic_nirqs,
M_GIC_V3, M_WAITOK | M_ZERO);
name = device_get_nameunit(dev);
@@ -318,7 +287,6 @@ gic_v3_attach(device_t dev)
return (err);
}
}
-#endif
 
/* Get the number of supported interrupt identifier bits */
sc->gic_idbits = GICD_TYPER_IDBITS(typer);
@@ -334,14 +302,6 @@ gic_v3_attach(device_t dev)
if (err != 0)
return (err);
}
-   /*
-* Full success.
-* Now register PIC to the interrupts handling layer.
-*/
-#ifndef INTRNG
-   arm_register_root_pic(dev, sc->gic_nirqs);
-   sc->gic_registered = TRUE;
-#endif
 
return (0);
 }
@@ -394,7 +354,6 @@ gic_v3_read_ivar(device_t dev, device_t 
return (ENOENT);
 }
 
-#ifdef INTRNG
 int
 arm_gic_v3_intr(void *arg)
 {
@@ -914,215 +873,6 @@ gic_v3_ipi_setup(device_t dev, u_int ipi
return (0);
 }
 #endif /* SMP */
-#else /* INTRNG */
-/*
- * PIC interface.
- */
-
-static int
-gic_v3_bind(device_t dev, u_int irq, u_int cpuid)
-{
-   uint64_t aff;
-   struct gic_v3_softc *sc;
-
-   sc = device_get_softc(dev);
-
-   if (irq <= GIC_LAST_PPI) {
-   /* Can't bind PPI to another CPU but it's not an error */
-   return (0);
-   } else if (irq >= GIC_FIRST_SPI && irq <= GIC_LAST_SPI) {
-   aff = CPU_AFFINITY(cpuid);
-   gic_d_write(sc, 4, GICD_IROUTER(irq), aff);
-   return (0);
-   } else if (irq >= 

svn commit: r302847 - head/sys/dev/pci

2016-07-14 Thread Andrew Turner
Author: andrew
Date: Thu Jul 14 16:52:18 2016
New Revision: 302847
URL: https://svnweb.freebsd.org/changeset/base/302847

Log:
  Remove support for the arm64 pre-INTRNG interrupt framework from the PCI
  driver. Support for this was removed in r302375.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/pci/pci_host_generic.c

Modified: head/sys/dev/pci/pci_host_generic.c
==
--- head/sys/dev/pci/pci_host_generic.c Thu Jul 14 15:39:31 2016
(r302846)
+++ head/sys/dev/pci/pci_host_generic.c Thu Jul 14 16:52:18 2016
(r302847)
@@ -724,8 +724,6 @@ generic_pcie_alloc_msi(device_t pci, dev
NULL);
return (intr_alloc_msi(pci, child, msi_parent, count, maxcount,
irqs));
-#elif defined(__aarch64__)
-   return (arm_alloc_msi(pci, child, count, maxcount, irqs));
 #else
return (ENXIO);
 #endif
@@ -740,8 +738,6 @@ generic_pcie_release_msi(device_t pci, d
ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), _parent,
NULL);
return (intr_release_msi(pci, child, msi_parent, count, irqs));
-#elif defined(__aarch64__)
-   return (arm_release_msi(pci, child, count, irqs));
 #else
return (ENXIO);
 #endif
@@ -757,8 +753,6 @@ generic_pcie_map_msi(device_t pci, devic
ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), _parent,
NULL);
return (intr_map_msi(pci, child, msi_parent, irq, addr, data));
-#elif defined(__aarch64__)
-   return (arm_map_msi(pci, child, irq, addr, data));
 #else
return (ENXIO);
 #endif
@@ -773,8 +767,6 @@ generic_pcie_alloc_msix(device_t pci, de
ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), _parent,
NULL);
return (intr_alloc_msix(pci, child, msi_parent, irq));
-#elif defined(__aarch64__)
-   return (arm_alloc_msix(pci, child, irq));
 #else
return (ENXIO);
 #endif
@@ -789,8 +781,6 @@ generic_pcie_release_msix(device_t pci, 
ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), _parent,
NULL);
return (intr_release_msix(pci, child, msi_parent, irq));
-#elif defined(__aarch64__)
-   return (arm_release_msix(pci, child, irq));
 #else
return (ENXIO);
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302789 - in head/sys/arm64: arm64 include

2016-07-13 Thread Andrew Turner
Author: andrew
Date: Wed Jul 13 23:03:34 2016
New Revision: 302789
URL: https://svnweb.freebsd.org/changeset/base/302789

Log:
  Add memmmap on arm64 so we can mmap /dev/mem and /dev/kmem.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mem.c
  head/sys/arm64/include/memdev.h

Modified: head/sys/arm64/arm64/mem.c
==
--- head/sys/arm64/arm64/mem.c  Wed Jul 13 22:53:30 2016(r302788)
+++ head/sys/arm64/arm64/mem.c  Wed Jul 13 23:03:34 2016(r302789)
@@ -114,3 +114,19 @@ memrw(struct cdev *dev, struct uio *uio,
return (error);
 }
 
+/*
+ * allow user processes to MMAP some memory sections
+ * instead of going through read/write
+ */
+/* ARGSUSED */
+int
+memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
+int prot __unused, vm_memattr_t *memattr __unused)
+{
+   if (dev2unit(dev) == CDEV_MINOR_MEM)
+   *paddr = offset;
+   else if (dev2unit(dev) == CDEV_MINOR_KMEM)
+   *paddr = vtophys(offset);
+   /* else panic! */
+   return (0);
+}

Modified: head/sys/arm64/include/memdev.h
==
--- head/sys/arm64/include/memdev.h Wed Jul 13 22:53:30 2016
(r302788)
+++ head/sys/arm64/include/memdev.h Wed Jul 13 23:03:34 2016
(r302789)
@@ -35,6 +35,6 @@
 d_open_t   memopen;
 d_read_t   memrw;
 #definememioctl(d_ioctl_t *)NULL
-#definememmmap (d_mmap_t *)NULL
+d_mmap_t   memmmap;
 
 #endif /* _MACHINE_MEMDEV_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302788 - head/usr.sbin/acpi/acpidump

2016-07-13 Thread Andrew Turner
Author: andrew
Date: Wed Jul 13 22:53:30 2016
New Revision: 302788
URL: https://svnweb.freebsd.org/changeset/base/302788

Log:
  Fix the type used to hold the value returned from getopt. On arm64 char is
  unsigned so will never be -1.
  
  Obtained from:ABT Systems Ltd
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/acpi/acpidump/acpidump.c

Modified: head/usr.sbin/acpi/acpidump/acpidump.c
==
--- head/usr.sbin/acpi/acpidump/acpidump.c  Wed Jul 13 21:27:10 2016
(r302787)
+++ head/usr.sbin/acpi/acpidump/acpidump.c  Wed Jul 13 22:53:30 2016
(r302788)
@@ -55,7 +55,8 @@ int
 main(int argc, char *argv[])
 {
ACPI_TABLE_HEADER *rsdt, *sdt;
-   charc, *progname;
+   int c;
+   char*progname;
char*dsdt_input_file, *dsdt_output_file;
 
dsdt_input_file = dsdt_output_file = NULL;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302601 - in head/sys: arm/include arm64/include

2016-07-12 Thread Andrew Turner
On Tue, 12 Jul 2016 00:37:48 + (UTC)
"Andrey A. Chernov"  wrote:

> Author: ache
> Date: Tue Jul 12 00:37:48 2016
> New Revision: 302601
> URL: https://svnweb.freebsd.org/changeset/base/302601
> 
> Log:
>   I don't know why unsigned int is choosed for wchar_t here, but
> WCHAR_MAX should be <= WINT_MAX. It is bigger, __UINT_MAX > INT32_MAX

Because the ABI either requires us to use an unsigned int [1], or the
preferred type is unsigned int [2]. In the latter case the other choice
is unsigned short, it would seem this is for Windows.

Andrew

[1]
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055c/IHI0055C_beta_aapcs64.pdf
[2]
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302498 - head/sys/arm/nvidia

2016-07-09 Thread Andrew Turner
Author: andrew
Date: Sat Jul  9 13:27:14 2016
New Revision: 302498
URL: https://svnweb.freebsd.org/changeset/base/302498

Log:
  Remove an unneeded call to fdt_get_unit, the return value is unused.
  
  MFC after:1 month
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/nvidia/tegra_pcie.c

Modified: head/sys/arm/nvidia/tegra_pcie.c
==
--- head/sys/arm/nvidia/tegra_pcie.cSat Jul  9 12:17:01 2016
(r302497)
+++ head/sys/arm/nvidia/tegra_pcie.cSat Jul  9 13:27:14 2016
(r302498)
@@ -1355,7 +1355,7 @@ tegra_pcib_set_bar(struct tegra_pcib_sof
 }
 
 static int
-tegra_pcib_enable(struct tegra_pcib_softc *sc, uint32_t port)
+tegra_pcib_enable(struct tegra_pcib_softc *sc)
 {
int rv;
int i;
@@ -1495,7 +1495,6 @@ tegra_pcib_attach(device_t dev)
 {
struct tegra_pcib_softc *sc;
phandle_t node;
-   uint32_t unit;
int rv;
int rid;
int nranges;
@@ -1505,7 +1504,6 @@ tegra_pcib_attach(device_t dev)
 
sc = device_get_softc(dev);
sc->dev = dev;
-   unit = fdt_get_unit(dev);
mtx_init(>mtx, "msi_mtx", NULL, MTX_DEF);
 
 
@@ -1618,7 +1616,7 @@ tegra_pcib_attach(device_t dev)
/*
 * Enable PCIE device.
 */
-   rv = tegra_pcib_enable(sc, unit);
+   rv = tegra_pcib_enable(sc);
if (rv != 0)
goto out;
for (i = 0; i < TEGRA_PCIB_MAX_PORTS; i++) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302391 - head

2016-07-07 Thread Andrew Turner
Author: andrew
Date: Thu Jul  7 15:25:14 2016
New Revision: 302391
URL: https://svnweb.freebsd.org/changeset/base/302391

Log:
  Stop deleting ofwdump.8.gz on arm and arm64 when running make delete-old,
  it is installed on these architectures.
  
  Approved by:  re (kib)
  Sponsored by: ABT Systems Ltd

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Jul  7 14:29:23 2016(r302390)
+++ head/ObsoleteFiles.inc  Thu Jul  7 15:25:14 2016(r302391)
@@ -8014,7 +8014,9 @@ OLD_FILES+=usr/share/man/man5/usbd.conf.
 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
 OLD_FILES+=usr/share/man/man8/boot_i386.8.gz
 .endif
-.if ${TARGET_ARCH} != "powerpc" && ${TARGET_ARCH} != "powerpc64" && 
${TARGET_ARCH} != "sparc64"
+.if ${TARGET_ARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm" && \
+${TARGET_ARCH} != "powerpc" && ${TARGET_ARCH} != "powerpc64" && \
+${TARGET_ARCH} != "sparc64"
 OLD_FILES+=usr/share/man/man8/ofwdump.8.gz
 .endif
 OLD_FILES+=usr/share/man/man8/mount_reiserfs.8.gz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302372 - in head/sys: amd64/include cddl/compat/opensolaris/sys dev/cpuctl i386/include kern net netinet powerpc/include powerpc/powerpc vm

2016-07-06 Thread Andrew Turner
On Wed, 6 Jul 2016 10:00:08 -0700
Nathan Whitehorn <nwhiteh...@freebsd.org> wrote:

> On 07/06/16 09:57, Andrew Turner wrote:
> > On Wed, 6 Jul 2016 14:09:49 + (UTC)
> > Nathan Whitehorn <nwhiteh...@freebsd.org> wrote:
> >  
> >> Author: nwhitehorn
> >> Date: Wed Jul  6 14:09:49 2016
> >> New Revision: 302372
> >> URL: https://svnweb.freebsd.org/changeset/base/302372
> >>
> >> Log:
> >>Replace a number of conflations of mp_ncpus and mp_maxid with
> >> either mp_maxid or CPU_FOREACH() as appropriate. This fixes a
> >> number of places in the kernel that assumed CPU IDs are dense in
> >> [0, mp_ncpus) and would try, for example, to run tasks on CPUs
> >> that did not exist or to allocate too few buffers on systems with
> >> sparse CPU IDs in which there are holes in the range and mp_maxid
> >> > mp_ncpus. Such circumstances generally occur on systems with
> >> > SMT, but on which SMT
> >> is disabled. This patch restores system operation at least on
> >> POWER8 systems configured in this way.
> >>There are a number of other places in the kernel with potential
> >> problems in these situations, but where sparse CPU IDs are not
> >> currently known to occur, mostly in the ARM machine-dependent code.
> >> These will be fixed in a follow-up commit after the stable/11
> >> branch. 
> > ...  
> >> Modified: head/sys/net/flowtable.c
> >> ==
> >> --- head/sys/net/flowtable.c   Wed Jul  6 10:57:04 2016
> >> (r302371) +++ head/sys/net/flowtable.c Wed Jul  6 14:09:49
> >> 2016   (r302372) @@ -746,7 +746,7 @@ flowtable_alloc(struct
> >> flowtable *ft) ft->ft_table[i] = uma_zalloc(pcpu_zone_ptr,
> >> M_WAITOK | M_ZERO);
> >>ft->ft_masks = uma_zalloc(pcpu_zone_ptr, M_WAITOK);
> >> -  for (int i = 0; i < mp_ncpus; i++) {
> >> +  CPU_FOREACH(i) {  
> > This is broken, it removed the declaration of i.
> >
> > Andrew
> >  
> 
> You are right. Somehow my build tests succeeded anyway. Will fix
> quickly. -Nathan
> 

It only seems to be enabled in LINT.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r302372 - in head/sys: amd64/include cddl/compat/opensolaris/sys dev/cpuctl i386/include kern net netinet powerpc/include powerpc/powerpc vm

2016-07-06 Thread Andrew Turner
On Wed, 6 Jul 2016 14:09:49 + (UTC)
Nathan Whitehorn  wrote:

> Author: nwhitehorn
> Date: Wed Jul  6 14:09:49 2016
> New Revision: 302372
> URL: https://svnweb.freebsd.org/changeset/base/302372
> 
> Log:
>   Replace a number of conflations of mp_ncpus and mp_maxid with either
>   mp_maxid or CPU_FOREACH() as appropriate. This fixes a number of
> places in the kernel that assumed CPU IDs are dense in [0, mp_ncpus)
> and would try, for example, to run tasks on CPUs that did not exist
> or to allocate too few buffers on systems with sparse CPU IDs in
> which there are holes in the range and mp_maxid > mp_ncpus. Such
> circumstances generally occur on systems with SMT, but on which SMT
> is disabled. This patch restores system operation at least on POWER8
> systems configured in this way. 
>   There are a number of other places in the kernel with potential
> problems in these situations, but where sparse CPU IDs are not
> currently known to occur, mostly in the ARM machine-dependent code.
> These will be fixed in a follow-up commit after the stable/11 branch.
>   
...
> Modified: head/sys/net/flowtable.c
> ==
> --- head/sys/net/flowtable.c  Wed Jul  6 10:57:04 2016
> (r302371) +++ head/sys/net/flowtable.cWed Jul  6 14:09:49
> 2016  (r302372) @@ -746,7 +746,7 @@ flowtable_alloc(struct
> flowtable *ft) ft->ft_table[i] = uma_zalloc(pcpu_zone_ptr, M_WAITOK |
> M_ZERO); 
>   ft->ft_masks = uma_zalloc(pcpu_zone_ptr, M_WAITOK);
> - for (int i = 0; i < mp_ncpus; i++) {
> + CPU_FOREACH(i) {

This is broken, it removed the declaration of i.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302375 - in head/sys: arm64/arm64 conf

2016-07-06 Thread Andrew Turner
Author: andrew
Date: Wed Jul  6 16:20:10 2016
New Revision: 302375
URL: https://svnweb.freebsd.org/changeset/base/302375

Log:
  Remove the old pre-INTRNG arm64 interrupt framework. GENERIC was switched
  to INTRNG in r301565 with the old code no longer being built by default with
  no reports of issues on any supported hardware.
  
  Approved by:  re (gjb)
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Deleted:
  head/sys/arm64/arm64/gic.c
  head/sys/arm64/arm64/gic_acpi.c
  head/sys/arm64/arm64/gic_fdt.c
  head/sys/arm64/arm64/gic_v3_its.c
  head/sys/arm64/arm64/intr_machdep.c
  head/sys/arm64/arm64/pic_if.m
Modified:
  head/sys/conf/files.arm64

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Wed Jul  6 16:17:13 2016(r302374)
+++ head/sys/conf/files.arm64   Wed Jul  6 16:20:10 2016(r302375)
@@ -25,15 +25,10 @@ arm64/arm64/disassem.c  optionalddb
 arm64/arm64/dump_machdep.c standard
 arm64/arm64/elf_machdep.c  standard
 arm64/arm64/exception.Sstandard
-arm64/arm64/gic.c  optional!intrng
 arm64/arm64/gicv3_its.coptionalintrng
-arm64/arm64/gic_acpi.c optional!intrng acpi
-arm64/arm64/gic_fdt.c  optional!intrng fdt
 arm64/arm64/gic_v3.c   standard
 arm64/arm64/gic_v3_fdt.c   optionalfdt
-arm64/arm64/gic_v3_its.c   optional!intrng
 arm64/arm64/identcpu.c standard
-arm64/arm64/intr_machdep.c optional!intrng
 arm64/arm64/in_cksum.c optionalinet | inet6
 arm64/arm64/locore.S   standardno-obj
 arm64/arm64/machdep.c  standard
@@ -42,7 +37,6 @@ arm64/arm64/minidump_machdep.cstandard
 arm64/arm64/mp_machdep.c   optionalsmp
 arm64/arm64/nexus.cstandard
 arm64/arm64/ofw_machdep.c  optionalfdt
-arm64/arm64/pic_if.m   optional!intrng
 arm64/arm64/pmap.c standard
 arm64/arm64/stack_machdep.coptionalddb | stack
 arm64/arm64/support.S  standard
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302084 - head/sys/arm64/arm64

2016-06-22 Thread Andrew Turner
Author: andrew
Date: Wed Jun 22 12:05:08 2016
New Revision: 302084
URL: https://svnweb.freebsd.org/changeset/base/302084

Log:
  Fix a race when the hardware has raised an exception with an unknown or
  uncategorised reason. We need to read the fault address register before
  enabling interrupts as the interrupt handler may cause this register to
  change.
  
  Approved by:  re (marius, kib)
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Wed Jun 22 11:45:30 2016(r302083)
+++ head/sys/arm64/arm64/trap.c Wed Jun 22 12:05:08 2016(r302084)
@@ -313,13 +313,11 @@ do_el1h_sync(struct trapframe *frame)
  * instruction results in an exception with an unknown reason.
  */
 static void
-el0_excp_unknown(struct trapframe *frame)
+el0_excp_unknown(struct trapframe *frame, uint64_t far)
 {
struct thread *td;
-   uint64_t far;
 
td = curthread;
-   far = READ_SPECIALREG(far_el1);
call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far);
userret(td, frame);
 }
@@ -342,6 +340,7 @@ do_el0_sync(struct trapframe *frame)
esr = READ_SPECIALREG(esr_el1);
exception = ESR_ELx_EXCEPTION(esr);
switch (exception) {
+   case EXCP_UNKNOWN:
case EXCP_INSN_ABORT_L:
case EXCP_DATA_ABORT_L:
case EXCP_DATA_ABORT:
@@ -371,7 +370,7 @@ do_el0_sync(struct trapframe *frame)
data_abort(frame, esr, far, 1);
break;
case EXCP_UNKNOWN:
-   el0_excp_unknown(frame);
+   el0_excp_unknown(frame, far);
break;
case EXCP_SP_ALIGN:
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301890 - head/sys/arm/arm

2016-06-14 Thread Andrew Turner
Author: andrew
Date: Tue Jun 14 16:41:39 2016
New Revision: 301890
URL: https://svnweb.freebsd.org/changeset/base/301890

Log:
  Move the arm call to intr_pic_init_secondary earlier in the secondary CPU
  initialisation. This ensures it will complete before signalling to the boot
  CPU it has booted. This fixes a race with the GIC where the arm_gic_map may
  not be populated before it is used to bind interrupts leading to some
  interrupts becoming bound to no CPUs.
  
  Approved by:  re (kib)
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/arm/mp_machdep.c

Modified: head/sys/arm/arm/mp_machdep.c
==
--- head/sys/arm/arm/mp_machdep.c   Tue Jun 14 16:20:25 2016
(r301889)
+++ head/sys/arm/arm/mp_machdep.c   Tue Jun 14 16:41:39 2016
(r301890)
@@ -199,6 +199,9 @@ init_secondary(int cpu)
vfp_init();
 #endif
 
+   /* Configure the interrupt controller */
+   intr_pic_init_secondary();
+
mtx_lock_spin(_boot_mtx);
 
atomic_add_rel_32(_cpus, 1);
@@ -237,7 +240,6 @@ init_secondary(int cpu)
cpu_initclocks_ap();
 
CTR0(KTR_SMP, "go into scheduler");
-   intr_pic_init_secondary();
 
/* Enter the scheduler */
sched_throw(NULL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r301706 - head/sys/boot/efi

2016-06-09 Thread Andrew Turner
On Wed, 8 Jun 2016 22:30:15 -0400
Warner Losh <wl...@bsdimp.com> wrote:

> > On Jun 8, 2016, at 7:23 PM, Andrew Turner <and...@freebsd.org>
> > wrote:
> > 
> > Author: andrew
> > Date: Wed Jun  8 23:23:16 2016
> > New Revision: 301706
> > URL: https://svnweb.freebsd.org/changeset/base/301706
> > 
> > Log:
> >  Also set -fshort-wchar on arm64, this fixes parsing strings from
> > UEFI, e.g. on the command line.  
> 
> Maybe this could be used to fix the %S issue instead of the kludge
> we’re now doing…

It may still be needed for arm. The linker checks the compatibility of
the attributes so we would need to set -fshort-wchar on all the loader
components meaning it would need to be set on all arm loader
implementations.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r301706 - head/sys/boot/efi

2016-06-08 Thread Andrew Turner
Author: andrew
Date: Wed Jun  8 23:23:16 2016
New Revision: 301706
URL: https://svnweb.freebsd.org/changeset/base/301706

Log:
  Also set -fshort-wchar on arm64, this fixes parsing strings from UEFI,
  e.g. on the command line.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/boot/efi/Makefile.inc

Modified: head/sys/boot/efi/Makefile.inc
==
--- head/sys/boot/efi/Makefile.inc  Wed Jun  8 23:22:59 2016
(r301705)
+++ head/sys/boot/efi/Makefile.inc  Wed Jun  8 23:23:16 2016
(r301706)
@@ -18,4 +18,8 @@ CFLAGS+=  -mno-red-zone
 CFLAGS+=   -mno-aes
 .endif
 
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+=   -fshort-wchar
+.endif
+
 .include "../Makefile.inc"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301703 - head/sys/boot/efi/libefi

2016-06-08 Thread Andrew Turner
Author: andrew
Date: Wed Jun  8 23:13:20 2016
New Revision: 301703
URL: https://svnweb.freebsd.org/changeset/base/301703

Log:
  Print the newline character along with the carriage return when TERM_EMU is
  disabled. Without this we print all lines over top of each other.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/boot/efi/libefi/efi_console.c

Modified: head/sys/boot/efi/libefi/efi_console.c
==
--- head/sys/boot/efi/libefi/efi_console.c  Wed Jun  8 22:36:55 2016
(r301702)
+++ head/sys/boot/efi/libefi/efi_console.c  Wed Jun  8 23:13:20 2016
(r301703)
@@ -139,8 +139,7 @@ efi_cons_rawputchar(int c)
 #ifndefTERM_EMU
if (c == '\n')
efi_cons_efiputchar('\r');
-   else
-   efi_cons_efiputchar(c);
+   efi_cons_efiputchar(c);
 #else
switch (c) {
case '\r':
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301702 - head/sys/boot/efi/libefi

2016-06-08 Thread Andrew Turner
Author: andrew
Date: Wed Jun  8 22:36:55 2016
New Revision: 301702
URL: https://svnweb.freebsd.org/changeset/base/301702

Log:
  Allow libefi to be built with TERM_EMU undefined. There were a few places
  where we assumed TERM_EMU was defined but didn't check. Fix these by also
  including them under the ifdefs.
  
  As HO is called from loader we need a null implementation so loader.efi
  doesn't need to know which version of libefi it is building against.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/boot/efi/libefi/efi_console.c

Modified: head/sys/boot/efi/libefi/efi_console.c
==
--- head/sys/boot/efi/libefi/efi_console.c  Wed Jun  8 22:30:21 2016
(r301701)
+++ head/sys/boot/efi/libefi/efi_console.c  Wed Jun  8 22:36:55 2016
(r301702)
@@ -111,9 +111,9 @@ efi_cons_probe(struct console *cp)
 static int
 efi_cons_init(int arg)
 {
+#ifdef TERM_EMU
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
DEFAULT_BGCOLOR));
-#ifdef TERM_EMU
end_term();
get_pos(, );
curs_move(, , curx, cury);
@@ -178,6 +178,7 @@ efi_cons_rawputchar(int c)
}
 }
 
+#ifdef TERM_EMU
 /* Gracefully exit ESC-sequence processing in case of misunderstanding. */
 static void
 bail_out(int c)
@@ -412,6 +413,12 @@ efi_term_emu(int c)
break;
}
 }
+#else
+void
+HO(void)
+{
+}
+#endif
 
 void
 efi_cons_putchar(int c)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301700 - in head/sys/arm: arm include

2016-06-08 Thread Andrew Turner
Author: andrew
Date: Wed Jun  8 22:29:30 2016
New Revision: 301700
URL: https://svnweb.freebsd.org/changeset/base/301700

Log:
  Remove the ARMv4/ARMv5 userland atomic support from struct proc on armv6.
  Nothing should use this on armv6 as we use the atomic instructions added in
  ARMv6k.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/arm/genassym.c
  head/sys/arm/include/proc.h

Modified: head/sys/arm/arm/genassym.c
==
--- head/sys/arm/arm/genassym.c Wed Jun  8 22:28:57 2016(r301699)
+++ head/sys/arm/arm/genassym.c Wed Jun  8 22:29:30 2016(r301700)
@@ -101,8 +101,10 @@ ASSYM(TD_PROC, offsetof(struct thread, t
 ASSYM(TD_MD, offsetof(struct thread, td_md));
 ASSYM(TD_LOCK, offsetof(struct thread, td_lock));
 ASSYM(MD_TP, offsetof(struct mdthread, md_tp));
+#if __ARM_ARCH < 6
 ASSYM(MD_RAS_START, offsetof(struct mdthread, md_ras_start));
 ASSYM(MD_RAS_END, offsetof(struct mdthread, md_ras_end));
+#endif
 
 ASSYM(TF_SPSR, offsetof(struct trapframe, tf_spsr));
 ASSYM(TF_R0, offsetof(struct trapframe, tf_r0));

Modified: head/sys/arm/include/proc.h
==
--- head/sys/arm/include/proc.h Wed Jun  8 22:28:57 2016(r301699)
+++ head/sys/arm/include/proc.h Wed Jun  8 22:29:30 2016(r301700)
@@ -54,8 +54,10 @@ struct mdthread {
int md_ptrace_instr_alt;
int md_ptrace_addr_alt;
register_t md_tp;
+#if __ARM_ARCH < 6
void *md_ras_start;
void *md_ras_end;
+#endif
 };
 
 struct mdproc {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301565 - head/sys/arm64/conf

2016-06-07 Thread Andrew Turner
Author: andrew
Date: Tue Jun  7 20:14:08 2016
New Revision: 301565
URL: https://svnweb.freebsd.org/changeset/base/301565

Log:
  Switch arm64 to use intrng by default. The old interrupt handling code can
  still be used, however this is expected to be removed soon.
  
  Obtained from:ABT Systems Ltd
  Relnotes: yes
  Sponsored by: The FreeBSD Foundation

Deleted:
  head/sys/arm64/conf/GENERIC-INTRNG
Modified:
  head/sys/arm64/conf/GENERIC

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Tue Jun  7 20:00:20 2016(r301564)
+++ head/sys/arm64/conf/GENERIC Tue Jun  7 20:14:08 2016(r301565)
@@ -70,6 +70,7 @@ options   RACCT   # Resource accounting f
 optionsRACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
 optionsRCTL# Resource limits
 optionsSMP
+optionsINTRNG
 
 # Debugging support.  Always need this:
 optionsKDB # Enable kernel debugger support.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301561 - in head/sys/arm: arm include

2016-06-07 Thread Andrew Turner
Author: andrew
Date: Tue Jun  7 18:50:36 2016
New Revision: 301561
URL: https://svnweb.freebsd.org/changeset/base/301561

Log:
  Start to clean MIDR values using the CPUID scheme. We don't need to know
  the exact CPU we are running on to set the cpu functions. Relax the check
  to ignore the CPU revision. Even so this may still be too specific.
  
  Reviewed by:  mmel
  Sponsored by: ABT Systems Ltd
  Differential Revision:https://reviews.freebsd.org/D6504

Modified:
  head/sys/arm/arm/cpufunc.c
  head/sys/arm/include/armreg.h

Modified: head/sys/arm/arm/cpufunc.c
==
--- head/sys/arm/arm/cpufunc.c  Tue Jun  7 18:23:22 2016(r301560)
+++ head/sys/arm/arm/cpufunc.c  Tue Jun  7 18:50:36 2016(r301561)
@@ -761,25 +761,19 @@ set_cpufuncs()
}
 #endif /* CPU_ARM1176 */
 #if defined(CPU_CORTEXA) || defined(CPU_KRAIT)
-   if (cputype == CPU_ID_CORTEXA5 ||
-   cputype == CPU_ID_CORTEXA7 ||
-   cputype == CPU_ID_CORTEXA8R1 ||
-   cputype == CPU_ID_CORTEXA8R2 ||
-   cputype == CPU_ID_CORTEXA8R3 ||
-   cputype == CPU_ID_CORTEXA9R1 ||
-   cputype == CPU_ID_CORTEXA9R2 ||
-   cputype == CPU_ID_CORTEXA9R3 ||
-   cputype == CPU_ID_CORTEXA9R4 ||
-   cputype == CPU_ID_CORTEXA12R0 ||
-   cputype == CPU_ID_CORTEXA15R0 ||
-   cputype == CPU_ID_CORTEXA15R1 ||
-   cputype == CPU_ID_CORTEXA15R2 ||
-   cputype == CPU_ID_CORTEXA15R3 ||
-   cputype == CPU_ID_KRAIT300R0 ||
-   cputype == CPU_ID_KRAIT300R1 ) {
+   switch(cputype & CPU_ID_SCHEME_MASK) {
+   case CPU_ID_CORTEXA5:
+   case CPU_ID_CORTEXA7:
+   case CPU_ID_CORTEXA8:
+   case CPU_ID_CORTEXA9:
+   case CPU_ID_CORTEXA12:
+   case CPU_ID_CORTEXA15:
+   case CPU_ID_KRAIT300:
cpufuncs = cortexa_cpufuncs;
get_cachetype_cp15();
goto out;
+   default:
+   break;
}
 #endif /* CPU_CORTEXA */
 

Modified: head/sys/arm/include/armreg.h
==
--- head/sys/arm/include/armreg.h   Tue Jun  7 18:23:22 2016
(r301560)
+++ head/sys/arm/include/armreg.h   Tue Jun  7 18:50:36 2016
(r301561)
@@ -72,10 +72,16 @@
 #define CPU_ID_IMPLEMENTOR_MASK0xff00
 #define CPU_ID_ARM_LTD 0x4100 /* 'A' */
 #define CPU_ID_DEC 0x4400 /* 'D' */
-#define CPU_ID_INTEL   0x6900 /* 'i' */
+#defineCPU_ID_MOTOROLA 0x4D00 /* 'M' */
+#defineCPU_ID_QUALCOM  0x5100 /* 'Q' */
 #defineCPU_ID_TI   0x5400 /* 'T' */
+#defineCPU_ID_MARVELL  0x5600 /* 'V' */
+#defineCPU_ID_INTEL0x6900 /* 'i' */
 #defineCPU_ID_FARADAY  0x6600 /* 'f' */
 
+#defineCPU_ID_VARIANT_SHIFT20
+#defineCPU_ID_VARIANT_MASK 0x00f0
+
 /* How to decide what format the CPUID is in. */
 #define CPU_ID_ISOLD(x)(((x) & 0xf000) == 0x)
 #define CPU_ID_IS7(x)  (((x) & 0xf000) == 0x7000)
@@ -92,7 +98,6 @@
 #define CPU_ID_ARCH_V5TEJ  0x0006
 #define CPU_ID_ARCH_V6 0x0007
 #define CPU_ID_CPUID_SCHEME0x000f
-#define CPU_ID_VARIANT_MASK0x00f0
 
 /* Next three nybbles are part number */
 #define CPU_ID_PARTNO_MASK 0xfff0
@@ -123,22 +128,35 @@
 #define CPU_ID_ARM1136JS   0x4107b360
 #define CPU_ID_ARM1136JSR1 0x4117b360
 #define CPU_ID_ARM1176JZS  0x410fb760
-#define CPU_ID_CORTEXA50x410fc050
-#define CPU_ID_CORTEXA70x410fc070
-#define CPU_ID_CORTEXA8R1  0x411fc080
-#define CPU_ID_CORTEXA8R2  0x412fc080
-#define CPU_ID_CORTEXA8R3  0x413fc080
-#define CPU_ID_CORTEXA9R1  0x411fc090
-#define CPU_ID_CORTEXA9R2  0x412fc090
-#define CPU_ID_CORTEXA9R3  0x413fc090
-#define CPU_ID_CORTEXA9R4  0x414fc090
-#define CPU_ID_CORTEXA12R0 0x410fc0d0
-#define CPU_ID_CORTEXA15R0 0x410fc0f0
-#define CPU_ID_CORTEXA15R1 0x411fc0f0
-#define CPU_ID_CORTEXA15R2 0x412fc0f0
-#define CPU_ID_CORTEXA15R3 0x413fc0f0
-#defineCPU_ID_KRAIT300R0   0x510f06f0 /* Snapdragon S4 Pro/APQ8064 
*/
-#defineCPU_ID_KRAIT300R1   0x511f06f0
+
+/* CPUs that follow the CPUID scheme */
+#defineCPU_ID_SCHEME_MASK  \
+(CPU_ID_IMPLEMENTOR_MASK | CPU_ID_ARCH_MASK | CPU_ID_PARTNO_MASK)
+
+#defineCPU_ID_CORTEXA5 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 
0xc050)
+#defineCPU_ID_CORTEXA7 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 
0xc070)
+#defineCPU_ID_CORTEXA8 (CPU_ID_ARM_LTD | CPU_ID_CPUID_SCHEME | 
0xc080)
+#define CPU_ID_CORTEXA8R1  (CPU_ID_CORTEXA8 | (1 << 
CPU_ID_VARIANT_SHIFT))
+#define CPU_ID_CORTEXA8R2  (CPU_ID_CORTEXA8 | (2 << 

svn commit: r301306 - in head/sys/boot/efi: include libefi loader loader/arch/amd64 loader/arch/arm loader/arch/arm64 loader/arch/i386

2016-06-04 Thread Andrew Turner
Author: andrew
Date: Sat Jun  4 08:47:45 2016
New Revision: 301306
URL: https://svnweb.freebsd.org/changeset/base/301306

Log:
  Use the UEFI event timer to update the time on arm and arm64. The current
  code uses the GetTime function from the Runtime Service, however this has
  been shown to not return a useable time on many arm64 UEFI implementations.
  
  Reviewed by:  jhb, smh
  Sponsored by: ABT Systems Ltd
  Differential Revision:https://reviews.freebsd.org/D6709

Added:
  head/sys/boot/efi/libefi/time_event.c   (contents, props changed)
Modified:
  head/sys/boot/efi/include/efilib.h
  head/sys/boot/efi/libefi/Makefile
  head/sys/boot/efi/libefi/time.c
  head/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
  head/sys/boot/efi/loader/arch/arm/exec.c
  head/sys/boot/efi/loader/arch/arm64/exec.c
  head/sys/boot/efi/loader/arch/i386/elf32_freebsd.c
  head/sys/boot/efi/loader/main.c

Modified: head/sys/boot/efi/include/efilib.h
==
--- head/sys/boot/efi/include/efilib.h  Sat Jun  4 07:29:10 2016
(r301305)
+++ head/sys/boot/efi/include/efilib.h  Sat Jun  4 08:47:45 2016
(r301306)
@@ -55,6 +55,9 @@ void efi_free_devpath_name(CHAR16 *);
 
 int efi_status_to_errno(EFI_STATUS);
 
+void efi_time_init(void);
+void efi_time_fini(void);
+
 EFI_STATUS main(int argc, CHAR16 *argv[]);
 void exit(EFI_STATUS status);
 void delay(int usecs);

Modified: head/sys/boot/efi/libefi/Makefile
==
--- head/sys/boot/efi/libefi/Makefile   Sat Jun  4 07:29:10 2016
(r301305)
+++ head/sys/boot/efi/libefi/Makefile   Sat Jun  4 08:47:45 2016
(r301306)
@@ -5,7 +5,13 @@ INTERNALLIB=
 WARNS?=2
 
 SRCS=  delay.c devpath.c efi_console.c efinet.c efipart.c env.c errno.c \
-   handles.c libefi.c time.c
+   handles.c libefi.c
+
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+SRCS+= time.c
+.elif ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
+SRCS+= time_event.c
+.endif
 
 # We implement a slightly non-standard %S in that it always takes a
 # CHAR16 that's common in UEFI-land instead of a wchar_t. This only

Modified: head/sys/boot/efi/libefi/time.c
==
--- head/sys/boot/efi/libefi/time.c Sat Jun  4 07:29:10 2016
(r301305)
+++ head/sys/boot/efi/libefi/time.c Sat Jun  4 08:47:45 2016
(r301306)
@@ -58,6 +58,16 @@ __FBSDID("$FreeBSD$");
 #define SECSPERHOUR ( 60*60 )
 #define SECSPERDAY (24 * SECSPERHOUR)
 
+void
+efi_time_init(void)
+{
+}
+
+void
+efi_time_fini(void)
+{
+}
+
 static time_t
 efi_time(EFI_TIME *ETime)
 {

Added: head/sys/boot/efi/libefi/time_event.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/boot/efi/libefi/time_event.c   Sat Jun  4 08:47:45 2016
(r301306)
@@ -0,0 +1,82 @@
+/*-
+ * Copyright (c) 2016 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+
+#include 
+#include 
+
+static EFI_EVENT time_event;
+static uint64_t curtime;
+
+static void
+time_update(EFI_EVENT event, void *context)
+{
+
+   curtime += 10;
+}
+
+void
+efi_time_init(void)
+{
+
+   /* Create a timer event */
+   BS->CreateEvent(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+   time_update, 0, _event);
+   /* Use a 10ms timer */
+   BS->SetTimer(

Re: svn commit: r301266 - head/sys/arm/freescale/imx

2016-06-03 Thread Andrew Turner
On Fri, 3 Jun 2016 11:05:55 + (UTC)
Svatopluk Kraus  wrote:

> Author: skra
> Date: Fri Jun  3 11:05:55 2016
> New Revision: 301266
> URL: https://svnweb.freebsd.org/changeset/base/301266
> 
> Log:
>   Postpone allocation of IRQ resource to the time when interrupt
>   controller devices are attached. This has already been done for
>   bus_setup_intr().
>   
>   There was no doubt that if someone wants to setup an interrupt,
>   corresponding interrupt controller device must already be attached.
>   However, the same must be valid for allocation of an interrupt
> resource unless the allocation is done blindly, without any
> information that such interrupt even exists. While it was done this
> blind way before, it won't be possible after next INTRNG change.
> 
> Modified:
>   head/sys/arm/freescale/imx/imx6_anatop.c
> 
> Modified: head/sys/arm/freescale/imx/imx6_anatop.c
> ==
> --- head/sys/arm/freescale/imx/imx6_anatop.c  Fri Jun  3
> 10:28:06 2016 (r301265) +++
> head/sys/arm/freescale/imx/imx6_anatop.c  Fri Jun  3 11:05:55
> 2016  (r301266) @@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$"); 
>  static struct resource_spec imx6_anatop_spec[] = {
>   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
> - { SYS_RES_IRQ,  0,  RF_ACTIVE },

Why not mark it as optional?

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301265 - in head/sys: arm64/arm64 arm64/include conf

2016-06-03 Thread Andrew Turner
lpi_unmask_irq(device_t, uint32_t);
 void lpi_mask_irq(device_t, uint32_t);
+#endif
 /*
  * GIC Distributor accessors.
  * Notice that only GIC sofc can be passed.

Added: head/sys/arm64/arm64/gicv3_its.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm64/arm64/gicv3_its.cFri Jun  3 10:28:06 2016    
(r301265)
@@ -0,0 +1,1585 @@
+/*-
+ * Copyright (c) 2015-2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "opt_platform.h"
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#ifdef FDT
+#include 
+#include 
+#include 
+#endif
+#include 
+#include 
+
+#include "pcib_if.h"
+#include "pic_if.h"
+#include "msi_if.h"
+
+MALLOC_DEFINE(M_GICV3_ITS, "GICv3 ITS",
+"ARM GICv3 Interrupt Translation Service");
+
+#defineLPI_NIRQS   (64 * 1024)
+
+/* The size and alignment of the command circular buffer */
+#defineITS_CMDQ_SIZE   (64 * 1024) /* Must be a multiple 
of 4K */
+#defineITS_CMDQ_ALIGN  (64 * 1024)
+
+#defineLPI_CONFTAB_SIZELPI_NIRQS
+#defineLPI_CONFTAB_ALIGN   (64 * 1024)
+#defineLPI_CONFTAB_MAX_ADDR((1ul << 48) - 1) /* We need a 47 bit 
PA */
+
+/* 1 bit per SPI, PPI, and SGI (8k), and 1 bit per LPI (LPI_CONFTAB_SIZE) */
+#defineLPI_PENDTAB_SIZE((LPI_NIRQS + GIC_FIRST_LPI) / 8)
+#defineLPI_PENDTAB_ALIGN   (64 * 1024)
+#defineLPI_PENDTAB_MAX_ADDR((1ul << 48) - 1) /* We need a 47 bit 
PA */
+
+#defineLPI_INT_TRANS_TAB_ALIGN 256
+#defineLPI_INT_TRANS_TAB_MAX_ADDR ((1ul << 48) - 1)
+
+/* ITS commands encoding */
+#defineITS_CMD_MOVI(0x01)
+#defineITS_CMD_SYNC(0x05)
+#defineITS_CMD_MAPD(0x08)
+#defineITS_CMD_MAPC(0x09)
+#defineITS_CMD_MAPTI   (0x0a)
+#defineITS_CMD_MAPI(0x0b)
+#defineITS_CMD_INV (0x0c)
+#defineITS_CMD_INVALL  (0x0d)
+/* Command */
+#defineCMD_COMMAND_MASK(0xFFUL)
+/* PCI device ID */
+#defineCMD_DEVID_SHIFT (32)
+#defineCMD_DEVID_MASK  (0xUL << CMD_DEVID_SHIFT)
+/* Size of IRQ ID bitfield */
+#defineCMD_SIZE_MASK   (0xFFUL)
+/* Virtual LPI ID */
+#defineCMD_ID_MASK (0xUL)
+/* Physical LPI ID */
+#defineCMD_PID_SHIFT   (32)
+#defineCMD_PID_MASK(0xUL << CMD_PID_SHIFT)
+/* Collection */
+#defineCMD_COL_MASK(0xUL)
+/* Target (CPU or Re-Distributor) */
+#defineCMD_TARGET_SHIFT(16)
+#defineCMD_TARGET_MASK (0xUL << CMD_TARGET_SHIFT)
+/* Interrupt Translation Table address */
+#defineCMD_ITT_MASK(0xFF00UL)
+/* Valid command bit */
+#defineCMD_VALID_SHIFT (63)
+#defineCMD_VALID_MASK  (1UL << CMD_VALID_SHIFT)
+
+/* ITS command. Each command is 32 bytes long */
+struct its_cmd {
+   uint64_tc

svn commit: r301263 - in head/sys: kern sys

2016-06-03 Thread Andrew Turner
Author: andrew
Date: Fri Jun  3 10:13:18 2016
New Revision: 301263
URL: https://svnweb.freebsd.org/changeset/base/301263

Log:
  Add an interface to handle interrupt controllers that have a contiguous
  range of interrupts they pass to a second controller driver to handle.
  The parent driver is expected to detect when one of these interrupts has
  been triggered and call intr_child_irq_handler to pass the interrupt to
  a child. The children controllers are then expected to manage the range
  by allocating interrupts as needed.
  
  This will initially be used by the ARM GICv3 driver, but is is expected to
  be useful for other driver where this type of allocation applies.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6436

Modified:
  head/sys/kern/subr_intr.c
  head/sys/sys/intr.h

Modified: head/sys/kern/subr_intr.c
==
--- head/sys/kern/subr_intr.c   Fri Jun  3 09:17:22 2016(r301262)
+++ head/sys/kern/subr_intr.c   Fri Jun  3 10:13:18 2016(r301263)
@@ -98,6 +98,15 @@ static intr_irq_filter_t *irq_root_filte
 static void *irq_root_arg;
 static u_int irq_root_ipicount;
 
+struct intr_pic_child {
+   SLIST_ENTRY(intr_pic_child)  pc_next;
+   struct intr_pic *pc_pic;
+   intr_child_irq_filter_t *pc_filter;
+   void*pc_filter_arg;
+   uintptr_tpc_start;
+   uintptr_tpc_length;
+};
+
 /* Interrupt controller definition. */
 struct intr_pic {
SLIST_ENTRY(intr_pic)   pic_next;
@@ -106,6 +115,8 @@ struct intr_pic {
 #defineFLAG_PIC(1 << 0)
 #defineFLAG_MSI(1 << 1)
u_int   pic_flags;
+   struct mtx  pic_child_lock;
+   SLIST_HEAD(, intr_pic_child) pic_children;
 };
 
 static struct mtx pic_list_lock;
@@ -323,6 +334,29 @@ intr_irq_handler(struct trapframe *tf)
 #endif
 }
 
+int
+intr_child_irq_handler(struct intr_pic *parent, uintptr_t irq)
+{
+   struct intr_pic_child *child;
+   bool found;
+
+   found = false;
+   mtx_lock_spin(>pic_child_lock);
+   SLIST_FOREACH(child, >pic_children, pc_next) {
+   if (child->pc_start <= irq &&
+   irq < (child->pc_start + child->pc_length)) {
+   found = true;
+   break;
+   }
+   }
+   mtx_unlock_spin(>pic_child_lock);
+
+   if (found)
+   return (child->pc_filter(child->pc_filter_arg, irq));
+
+   return (FILTER_STRAY);
+}
+
 /*
  *  interrupt controller dispatch function for interrupts. It should
  *  be called straight from the interrupt controller, when associated interrupt
@@ -892,6 +926,7 @@ pic_create(device_t dev, intptr_t xref)
}
pic->pic_xref = xref;
pic->pic_dev = dev;
+   mtx_init(>pic_child_lock, "pic child lock", NULL, MTX_SPIN);
SLIST_INSERT_HEAD(_list, pic, pic_next);
mtx_unlock(_list_lock);
 
@@ -1001,6 +1036,44 @@ intr_pic_claim_root(device_t dev, intptr
return (0);
 }
 
+/*
+ * Add a handler to manage a sub range of a parents interrupts.
+ */
+struct intr_pic *
+intr_pic_add_handler(device_t parent, struct intr_pic *pic,
+intr_child_irq_filter_t *filter, void *arg, uintptr_t start,
+uintptr_t length)
+{
+   struct intr_pic *parent_pic;
+   struct intr_pic_child *newchild;
+#ifdef INVARIANTS
+   struct intr_pic_child *child;
+#endif
+
+   parent_pic = pic_lookup(parent, 0);
+   if (parent_pic == NULL)
+   return (NULL);
+
+   newchild = malloc(sizeof(*newchild), M_INTRNG, M_WAITOK | M_ZERO);
+   newchild->pc_pic = pic;
+   newchild->pc_filter = filter;
+   newchild->pc_filter_arg = arg;
+   newchild->pc_start = start;
+   newchild->pc_length = length;
+
+   mtx_lock_spin(_pic->pic_child_lock);
+#ifdef INVARIANTS
+   SLIST_FOREACH(child, _pic->pic_children, pc_next) {
+   KASSERT(child->pc_pic != pic, ("%s: Adding a child PIC twice",
+   __func__));
+   }
+#endif
+   SLIST_INSERT_HEAD(_pic->pic_children, newchild, pc_next);
+   mtx_unlock_spin(_pic->pic_child_lock);
+
+   return (pic);
+}
+
 int
 intr_map_irq(device_t dev, intptr_t xref, struct intr_map_data *data,
 u_int *irqp)

Modified: head/sys/sys/intr.h
==
--- head/sys/sys/intr.h Fri Jun  3 09:17:22 2016(r301262)
+++ head/sys/sys/intr.h Fri Jun  3 10:13:18 2016(r301263)
@@ -74,6 +74,7 @@ typedef int intr_irq_filter_t(void *arg,
 #else
 typedef int intr_irq_filter_t(void *arg);
 #endif
+typedef int intr_child_irq_filter_t(void *arg, uintptr_t irq);
 
 #define INTR_ISRC_NAMELEN  (MAXCOMLEN + 1)
 
@@ -81,6 +82,8 @@ 

svn commit: r301060 - head/sys/arm/arm

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 17:49:47 2016
New Revision: 301060
URL: https://svnweb.freebsd.org/changeset/base/301060

Log:
  Bin interrupts to the correct CPU when we boot on a non-zero CPU.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm/arm/gic.c

Modified: head/sys/arm/arm/gic.c
==
--- head/sys/arm/arm/gic.c  Tue May 31 17:30:08 2016(r301059)
+++ head/sys/arm/arm/gic.c  Tue May 31 17:49:47 2016(r301060)
@@ -968,7 +968,7 @@ gic_bind(struct arm_gic_softc *sc, u_int
 
for (mask = 0, cpu = 0; cpu < end; cpu++)
if (CPU_ISSET(cpu, cpus))
-   mask |= 1 << cpu;
+   mask |= 1 << arm_gic_map[cpu];
 
gic_d_write_1(sc, GICD_ITARGETSR(0) + irq, mask);
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301062 - head/sys/arm/arm

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 18:05:17 2016
New Revision: 301062
URL: https://svnweb.freebsd.org/changeset/base/301062

Log:
  arm_gic_map is a mask not the CPUs ID, there is no need to shift it.
  
  Pointy-hat to:andrew
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm/arm/gic.c

Modified: head/sys/arm/arm/gic.c
==
--- head/sys/arm/arm/gic.c  Tue May 31 18:04:16 2016(r301061)
+++ head/sys/arm/arm/gic.c  Tue May 31 18:05:17 2016(r301062)
@@ -968,7 +968,7 @@ gic_bind(struct arm_gic_softc *sc, u_int
 
for (mask = 0, cpu = 0; cpu < end; cpu++)
if (CPU_ISSET(cpu, cpus))
-   mask |= 1 << arm_gic_map[cpu];
+   mask |= arm_gic_map[cpu];
 
gic_d_write_1(sc, GICD_ITARGETSR(0) + irq, mask);
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301072 - head/sys/arm64/arm64

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 19:17:32 2016
New Revision: 301072
URL: https://svnweb.freebsd.org/changeset/base/301072

Log:
  dpcpu_init should have also passed in the calculated cpuid, not the
  devicetree ID.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Tue May 31 19:05:41 2016
(r301071)
+++ head/sys/arm64/arm64/mp_machdep.c   Tue May 31 19:17:32 2016
(r301072)
@@ -522,7 +522,7 @@ cpu_init_fdt(u_int id, phandle_t node, u
 
dpcpu[cpuid - 1] = (void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
M_WAITOK | M_ZERO);
-   dpcpu_init(dpcpu[cpuid - 1], id);
+   dpcpu_init(dpcpu[cpuid - 1], cpuid);
 
target_cpu = reg[0];
if (addr_size == 2) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301070 - head/sys/arm64/arm64

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 18:45:52 2016
New Revision: 301070
URL: https://svnweb.freebsd.org/changeset/base/301070

Log:
  Allow the kernel to boot on a CPU where the devicetree has numbered it with
  a non-zero ID. To do this we increment the cpuid of any CPUs with a smaller
  devicetree ID by one to stop them conflicting with the boot CPU.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/mp_machdep.c

Modified: head/sys/arm64/arm64/mp_machdep.c
==
--- head/sys/arm64/arm64/mp_machdep.c   Tue May 31 18:44:33 2016
(r301069)
+++ head/sys/arm64/arm64/mp_machdep.c   Tue May 31 18:45:52 2016
(r301070)
@@ -119,6 +119,13 @@ static uint32_t cpu_reg[MAXCPU][2];
 #endif
 static device_t cpu_list[MAXCPU];
 
+/*
+ * Not all systems boot from the first CPU in the device tree. To work around
+ * this we need to find which CPU we have booted from so when we later
+ * enable the secondary CPUs we skip this one.
+ */
+static int cpu0 = -1;
+
 void mpentry(unsigned long cpuid);
 void init_secondary(uint64_t);
 
@@ -486,6 +493,7 @@ cpu_init_fdt(u_int id, phandle_t node, u
uint64_t target_cpu;
struct pcpu *pcpup;
vm_paddr_t pa;
+   u_int cpuid;
int err;
 
/* Check we are able to start this cpu */
@@ -502,16 +510,19 @@ cpu_init_fdt(u_int id, phandle_t node, u
 #endif
 
/* We are already running on cpu 0 */
-   if (id == 0)
+   if (id == cpu0)
return (1);
 
+   cpuid = id;
+   if (cpuid < cpu0)
+   cpuid++;
 
-   pcpup = &__pcpu[id];
-   pcpu_init(pcpup, id, sizeof(struct pcpu));
+   pcpup = &__pcpu[cpuid];
+   pcpu_init(pcpup, cpuid, sizeof(struct pcpu));
 
-   dpcpu[id - 1] = (void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
+   dpcpu[cpuid - 1] = (void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
M_WAITOK | M_ZERO);
-   dpcpu_init(dpcpu[id - 1], id);
+   dpcpu_init(dpcpu[cpuid - 1], id);
 
target_cpu = reg[0];
if (addr_size == 2) {
@@ -519,21 +530,23 @@ cpu_init_fdt(u_int id, phandle_t node, u
target_cpu |= reg[1];
}
 
-   printf("Starting CPU %u (%lx)\n", id, target_cpu);
+   printf("Starting CPU %u (%lx)\n", cpuid, target_cpu);
pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry);
 
-   err = psci_cpu_on(target_cpu, pa, id);
+   err = psci_cpu_on(target_cpu, pa, cpuid);
if (err != PSCI_RETVAL_SUCCESS) {
/* Panic here if INVARIANTS are enabled */
-   KASSERT(0, ("Failed to start CPU %u (%lx)\n", id, target_cpu));
+   KASSERT(0, ("Failed to start CPU %u (%lx)\n", id,
+   target_cpu));
 
pcpu_destroy(pcpup);
-   kmem_free(kernel_arena, (vm_offset_t)dpcpu[id - 1], DPCPU_SIZE);
-   dpcpu[id - 1] = NULL;
+   kmem_free(kernel_arena, (vm_offset_t)dpcpu[cpuid - 1],
+   DPCPU_SIZE);
+   dpcpu[cpuid - 1] = NULL;
/* Notify the user that the CPU failed to start */
printf("Failed to start CPU %u (%lx)\n", id, target_cpu);
} else
-   CPU_SET(id, _cpus);
+   CPU_SET(cpuid, _cpus);
 
return (1);
 }
@@ -551,6 +564,7 @@ cpu_mp_start(void)
switch(cpu_enum_method) {
 #ifdef FDT
case CPUS_FDT:
+   KASSERT(cpu0 >= 0, ("Current CPU was not found"));
ofw_cpu_early_foreach(cpu_init_fdt, true);
break;
 #endif
@@ -565,13 +579,34 @@ cpu_mp_announce(void)
 {
 }
 
+static boolean_t
+cpu_find_cpu0_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
+{
+   uint64_t mpidr_fdt, mpidr_reg;
+
+   if (cpu0 < 0) {
+   mpidr_fdt = reg[0];
+   if (addr_size == 2) {
+   mpidr_fdt <<= 32;
+   mpidr_fdt |= reg[1];
+   }
+
+   mpidr_reg = READ_SPECIALREG(mpidr_el1);
+
+   if ((mpidr_reg & 0xff00fful) == mpidr_fdt)
+   cpu0 = id;
+   }
+
+   return (TRUE);
+}
+
 void
 cpu_mp_setmaxid(void)
 {
 #ifdef FDT
int cores;
 
-   cores = ofw_cpu_early_foreach(NULL, false);
+   cores = ofw_cpu_early_foreach(cpu_find_cpu0_fdt, false);
if (cores > 0) {
cores = MIN(cores, MAXCPU);
if (bootverbose)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301073 - head/sys/conf

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 19:19:21 2016
New Revision: 301073
URL: https://svnweb.freebsd.org/changeset/base/301073

Log:
  Attach the generic USB OHCI driver to the arm64 build.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/conf/files.arm64

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Tue May 31 19:17:32 2016(r301072)
+++ head/sys/conf/files.arm64   Tue May 31 19:19:21 2016(r301073)
@@ -74,6 +74,8 @@ dev/psci/psci_arm64.S optionalpsci
 dev/uart/uart_cpu_fdt.coptionaluart fdt
 dev/uart/uart_dev_pl011.c  optionaluart pl011
 dev/usb/controller/dwc_otg_hisi.c optional dwcotg soc_hisi_hi6220
+dev/usb/controller/generic_ohci.c optional ohci fdt
+dev/usb/controller/generic_usb_if.m optional   ohci fdt
 dev/vnic/mrml_bridge.c optionalvnic fdt
 dev/vnic/nic_main.coptionalvnic pci
 dev/vnic/nicvf_main.c  optionalvnic pci pci_iov
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301045 - head/sys/arm64/arm64

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 16:28:56 2016
New Revision: 301045
URL: https://svnweb.freebsd.org/changeset/base/301045

Log:
  Enable setting BF_COHERENT on DMA tags. This allows the kernel to start
  using the cache handling functions.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/busdma_bounce.c

Modified: head/sys/arm64/arm64/busdma_bounce.c
==
--- head/sys/arm64/arm64/busdma_bounce.cTue May 31 16:23:56 2016
(r301044)
+++ head/sys/arm64/arm64/busdma_bounce.cTue May 31 16:28:56 2016
(r301045)
@@ -184,10 +184,8 @@ bounce_bus_dma_tag_create(bus_dma_tag_t 
newtag->map_count = 0;
newtag->segments = NULL;
 
-#ifdef notyet
if ((flags & BUS_DMA_COHERENT) != 0)
newtag->bounce_flags |= BF_COHERENT;
-#endif
 
if (parent != NULL) {
if ((newtag->common.filter != NULL ||
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301034 - head/sys/cddl/dev/dtrace/aarch64

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 11:32:09 2016
New Revision: 301034
URL: https://svnweb.freebsd.org/changeset/base/301034

Log:
  Set oldfp so the check for fp == oldfp works as expected.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c

Modified: head/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c
==
--- head/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c   Tue May 31 11:32:07 
2016(r301033)
+++ head/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c   Tue May 31 11:32:09 
2016(r301034)
@@ -119,7 +119,7 @@ dtrace_getustack_common(uint64_t *pcstac
volatile uint16_t *flags =
(volatile uint16_t *)_core[curcpu].cpuc_dtrace_flags;
int ret = 0;
-   uintptr_t oldfp;
+   uintptr_t oldfp = fp;
 
ASSERT(pcstack == NULL || pcstack_limit > 0);
 
@@ -168,6 +168,8 @@ dtrace_getustack_common(uint64_t *pcstac
*flags &= ~CPU_DTRACE_FAULT;
break;
}
+
+   oldfp = fp;
}
 
return (ret);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r301032 - head/sys/dev/pci

2016-05-31 Thread Andrew Turner
Author: andrew
Date: Tue May 31 09:24:16 2016
New Revision: 301032
URL: https://svnweb.freebsd.org/changeset/base/301032

Log:
  Move a device_printf under bootverbose where it should have been.
  
  Reported by:  bz
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/pci/pci_host_generic.c

Modified: head/sys/dev/pci/pci_host_generic.c
==
--- head/sys/dev/pci/pci_host_generic.c Tue May 31 09:15:21 2016
(r301031)
+++ head/sys/dev/pci/pci_host_generic.c Tue May 31 09:24:16 2016
(r301032)
@@ -185,7 +185,7 @@ pci_host_generic_attach(device_t dev)
if (sc->coherent == 0) {
sc->coherent = OF_hasprop(node, "dma-coherent");
}
-   //if (bootverbose)
+   if (bootverbose)
device_printf(dev, "Bus is%s cache-coherent\n",
sc->coherent ? "" : " not");
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300902 - head/sys/dev/hwpmc

2016-05-28 Thread Andrew Turner
Author: andrew
Date: Sat May 28 13:05:39 2016
New Revision: 300902
URL: https://svnweb.freebsd.org/changeset/base/300902

Log:
  Don't panic in hwpmc when stopping sampling.
  
  When hwpmc stops sampling it will set the pm_state to something other
  than PMC_STATE_RUNNING. This means the following sequence can happen:
  
  CPU 0: Enter the interrupt handler
  CPU 0: Set the thread TDP_CALLCHAIN pflag
  CPU 1: Stop sampling
  CPU 0: Call pmc_process_samples, sampling is stopped so clears ps_nsamples
  CPU 0: Finishes interrupt processing with the TDP_CALLCHAIN flag set
  CPU 0: Call pmc_capture_user_callchain to capture the user call chain
  CPU 0: Find all the pmc sample are free so no call chains need to be captured
  CPU 0: KASSERT because of this
  
  This fixes the issue by checking if any of the samples have been stopped
  and including this in te KASSERT.
  
  PR:   204273
  Reviewed by:  bz, gnn
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6581

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==
--- head/sys/dev/hwpmc/hwpmc_mod.c  Sat May 28 08:32:15 2016
(r300901)
+++ head/sys/dev/hwpmc/hwpmc_mod.c  Sat May 28 13:05:39 2016
(r300902)
@@ -4199,6 +4199,7 @@ pmc_capture_user_callchain(int cpu, int 
struct pmc_samplebuffer *psb;
 #ifdef INVARIANTS
int ncallchains;
+   int nfree;
 #endif
 
psb = pmc_pcpu[cpu]->pc_sb[ring];
@@ -4210,6 +4211,7 @@ pmc_capture_user_callchain(int cpu, int 
 
 #ifdef INVARIANTS
ncallchains = 0;
+   nfree = 0;
 #endif
 
/*
@@ -4221,6 +4223,10 @@ pmc_capture_user_callchain(int cpu, int 
ps = psb->ps_read;
ps_end = psb->ps_write;
do {
+#ifdef INVARIANTS
+   if (ps->ps_pmc->pm_state != PMC_STATE_RUNNING)
+   nfree++;
+#endif
if (ps->ps_nsamples != PMC_SAMPLE_INUSE)
goto next;
if (ps->ps_td != td)
@@ -4256,7 +4262,7 @@ next:
ps = psb->ps_samples;
} while (ps != ps_end);
 
-   KASSERT(ncallchains > 0,
+   KASSERT(ncallchains > 0 || nfree > 0,
("[pmc,%d] cpu %d didn't find a sample to collect", __LINE__,
cpu));
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300850 - head/sys/cddl/dev/dtrace/aarch64

2016-05-27 Thread Andrew Turner
Author: andrew
Date: Fri May 27 12:02:12 2016
New Revision: 300850
URL: https://svnweb.freebsd.org/changeset/base/300850

Log:
  Fix dtrace_interrupt_disable and dtrace_interrupt_enable by having the
  former return the current status for the latter to use. Without this we
  could enable interrupts when they shouldn't be.
  
  It's still not quite right as it should only update the bits we care about,
  bit should be good enough until the correct fix can be tested.
  
  PR:   204270
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S

Modified: head/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S
==
--- head/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S   Fri May 27 11:50:26 
2016(r300849)
+++ head/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S   Fri May 27 12:02:12 
2016(r300850)
@@ -55,6 +55,7 @@ END(dtrace_membar_consumer)
 dtrace_icookie_t dtrace_interrupt_disable(void)
 */
 ENTRY(dtrace_interrupt_disable)
+   mrs x0, daif
msr daifset, #2
RET
 END(dtrace_interrupt_disable)
@@ -63,7 +64,7 @@ END(dtrace_interrupt_disable)
 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
 */
 ENTRY(dtrace_interrupt_enable)
-   msr daifclr, #2
+   msr daif, x0
RET
 END(dtrace_interrupt_enable)
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300611 - head/sys/cddl/dev/dtrace/aarch64

2016-05-24 Thread Andrew Turner
Author: andrew
Date: Tue May 24 13:57:23 2016
New Revision: 300611
URL: https://svnweb.freebsd.org/changeset/base/300611

Log:
  Mark all memory before the kernel as toxic to DTrace.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c

Modified: head/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c
==
--- head/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c  Tue May 24 12:40:03 
2016(r300610)
+++ head/sys/cddl/dev/dtrace/aarch64/dtrace_subr.c  Tue May 24 13:57:23 
2016(r300611)
@@ -120,7 +120,7 @@ void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
 
-   printf("IMPLEMENT ME: dtrace_toxic_ranges\n");
+   (*func)(0, (uintptr_t)VM_MIN_KERNEL_ADDRESS);
 }
 
 void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300604 - head/sys/kern

2016-05-24 Thread Andrew Turner
Author: andrew
Date: Tue May 24 12:06:56 2016
New Revision: 300604
URL: https://svnweb.freebsd.org/changeset/base/300604

Log:
  Limit calling pmc_hook to when the interrupt comes while running userspace.
  We may enable interrupts from within the callback, e.g. in a data abort
  during copyin. If we receive an interrupt at that time pmc_hook will be
  called again and, as it is handling userspace stack tracing, will hit a
  KASSERT as it checks if the trapframe is from userland.
  
  With this I can run hwpmc with intrng on a ThunderX and have it trace all
  CPUs.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/subr_intr.c

Modified: head/sys/kern/subr_intr.c
==
--- head/sys/kern/subr_intr.c   Tue May 24 11:47:14 2016(r300603)
+++ head/sys/kern/subr_intr.c   Tue May 24 12:06:56 2016(r300604)
@@ -317,7 +317,8 @@ intr_irq_handler(struct trapframe *tf)
td->td_intr_frame = oldframe;
critical_exit();
 #ifdef HWPMC_HOOKS
-   if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
+   if (pmc_hook && TRAPF_USERMODE(tf) &&
+   (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, tf);
 #endif
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300510 - head/sys/kern

2016-05-23 Thread Andrew Turner
Author: andrew
Date: Mon May 23 15:26:35 2016
New Revision: 300510
URL: https://svnweb.freebsd.org/changeset/base/300510

Log:
  Add the needed hwpmc hooks to subr_intr.c. This is needed for the correct
  operation of hwpmc on, for example, arm64 with intrng.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/subr_intr.c

Modified: head/sys/kern/subr_intr.c
==
--- head/sys/kern/subr_intr.c   Mon May 23 15:11:01 2016(r300509)
+++ head/sys/kern/subr_intr.c   Mon May 23 15:26:35 2016(r300510)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 
 #include "opt_acpi.h"
 #include "opt_ddb.h"
+#include "opt_hwpmc_hooks.h"
 #include "opt_platform.h"
 
 #include 
@@ -53,6 +54,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifdef HWPMC_HOOKS
+#include 
+#endif
+
 #include 
 #include 
 #include 
@@ -311,6 +316,10 @@ intr_irq_handler(struct trapframe *tf)
irq_root_filter(irq_root_arg);
td->td_intr_frame = oldframe;
critical_exit();
+#ifdef HWPMC_HOOKS
+   if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
+   pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, tf);
+#endif
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300348 - head

2016-05-23 Thread Andrew Turner
On Mon, 23 May 2016 11:34:00 +0100
Andrew Turner <and...@fubar.geek.nz> wrote:

> On Sat, 21 May 2016 01:32:04 + (UTC)
> Bryan Drewery <bdrew...@freebsd.org> wrote:
> 
> > Author: bdrewery
> > Date: Sat May 21 01:32:04 2016
> > New Revision: 300348
> > URL: https://svnweb.freebsd.org/changeset/base/300348
> > 
> > Log:
> >   Move external toolchain support earlier.
> >   
> >   This is to consolidate external toolchain and
> > WITHOUT_CROSS_COMPILER support. 
> >   Reviewed by:  brooks, bapt
> >   Sponsored by: EMC / Isilon Storage Division
> >   Differential Revision:https://reviews.freebsd.org/D6353
> >   
> 
> This seems to have broken the arm64 build. My guess is the wrong
> linker is being used, but I haven't looked into the issue too far.

The issue is you moved a block that depends on BROKEN_OPTIONS being
defined to before the point we include share/mk/src.opts.mk, the place
it is defined.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300348 - head

2016-05-23 Thread Andrew Turner
On Sat, 21 May 2016 01:32:04 + (UTC)
Bryan Drewery  wrote:

> Author: bdrewery
> Date: Sat May 21 01:32:04 2016
> New Revision: 300348
> URL: https://svnweb.freebsd.org/changeset/base/300348
> 
> Log:
>   Move external toolchain support earlier.
>   
>   This is to consolidate external toolchain and
> WITHOUT_CROSS_COMPILER support. 
>   Reviewed by:brooks, bapt
>   Sponsored by:   EMC / Isilon Storage Division
>   Differential Revision:  https://reviews.freebsd.org/D6353
> 

This seems to have broken the arm64 build. My guess is the wrong linker
is being used, but I haven't looked into the issue too far.

Andrew

--
>>> stage 4.2: building libraries
--
===> gnu/lib/libssp/libssp_nonshared (obj,all,install)
===> gnu/lib/libgcc (obj,all,install)
===> lib/libcompiler_rt (obj,all,install)
===> gnu/lib/csu (obj,all,install)
===> lib/csu (obj,all,install)
===> lib/libcompiler_rt (obj,all,install)
===> lib/libc (obj,all,install)
===> lib/libc_nonshared (obj,all,install)
===> lib/csu/aarch64 (obj)
===> lib/csu/aarch64 (all)
===> lib/csu/aarch64 (install)
/scratch/tmp/andrew/obj/arm64.aarch64/scratch/tmp/andrew/head-git/tmp/usr/lib/crti.o:
 file not recognized: File format not recognized
cc: error: linker command failed with exit code 1 (use -v to see invocation)
--- libc.so.7.full ---
*** [libc.so.7.full] Error code 1

make[4]: stopped in /scratch/tmp/andrew/head-git/lib/libc
1 error

make[4]: stopped in /scratch/tmp/andrew/head-git/lib/libc
--- lib/libc__L ---
*** [lib/libc__L] Error code 2

make[3]: stopped in /scratch/tmp/andrew/head-git
1 error

make[3]: stopped in /scratch/tmp/andrew/head-git
--- libraries ---
*** [libraries] Error code 2

make[2]: stopped in /scratch/tmp/andrew/head-git
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300406 - head/lib/csu/aarch64

2016-05-22 Thread Andrew Turner
Author: andrew
Date: Sun May 22 08:20:30 2016
New Revision: 300406
URL: https://svnweb.freebsd.org/changeset/base/300406

Log:
  Stop dereferencing _end in crt1.c. This was only needed for brk/sbrk so is
  no longer needed.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/lib/csu/aarch64/crt1.c

Modified: head/lib/csu/aarch64/crt1.c
==
--- head/lib/csu/aarch64/crt1.c Sun May 22 07:50:10 2016(r300405)
+++ head/lib/csu/aarch64/crt1.c Sun May 22 08:20:30 2016(r300406)
@@ -71,17 +71,8 @@ __start(int argc, char *argv[], char *en
 
if (&_DYNAMIC != NULL)
atexit(cleanup);
-   else {
-   /*
-* Hack to resolve _end so we read the correct symbol.
-* Without this it will resolve to the copy in the library
-* that firsts requests it. We should fix the toolchain,
-* however this is is needed until this can take place.
-*/
-   *(volatile long *)&_end;
-
+   else
_init_tls();
-   }
 
 #ifdef GCRT
atexit(_mcleanup);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300308 - head/sys/arm64/arm64

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 15:43:51 2016
New Revision: 300308
URL: https://svnweb.freebsd.org/changeset/base/300308

Log:
  Extract the correct bits from the GICD_TYPER register. The interrupt count
  is encoded in the bottom 5 bits.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3_reg.h

Modified: head/sys/arm64/arm64/gic_v3_reg.h
==
--- head/sys/arm64/arm64/gic_v3_reg.h   Fri May 20 15:41:05 2016
(r300307)
+++ head/sys/arm64/arm64/gic_v3_reg.h   Fri May 20 15:43:51 2016
(r300308)
@@ -67,7 +67,7 @@
 
 #defineGICD_TYPER  (0x0004)
 #defineGICD_TYPER_IDBITS(n)n) >> 19) & 0x1F) + 1)
-#defineGICD_TYPER_I_NUM(n) n) & 0xF1) + 1) * 32)
+#defineGICD_TYPER_I_NUM(n) n) & 0x1F) + 1) * 32)
 
 #defineGICD_ISENABLER(n)   (0x0100 + (((n) >> 5) * 4))
 #defineGICD_I_PER_ISENABLERn   (32)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300303 - in head: . contrib/netbsd-tests/lib/libc/gen contrib/netbsd-tests/lib/libc/sys lib/libc/aarch64 lib/libc/aarch64/sys sys/sys

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 15:04:48 2016
New Revision: 300303
URL: https://svnweb.freebsd.org/changeset/base/300303

Log:
  Remove brk and sbrk from arm64. They were defined in The Single UNIX
  Specification, Version 2, but marked as legacy, and have been removed from
  later specifications. After 12 years it is time to remove them from new
  architectures when the main use for sbrk is an invalid method to attempt
  to find how much memory has been allocated from malloc.
  
  There are a few places in the tree that still call sbrk, however they are
  not used on arm64. They will need to be fixed to cross build from arm64,
  but these will be fixed in a follow up commit.
  
  Old copies of binutils from ports called into sbrk, however this has been
  fixed around 6 weeks ago. It is advised to update binutils on arm64 before
  installing a world that includes this change.
  
  Reviewed by:  brooks, emaste
  Obtained from:brooks
  Relnotes: yes
  Sponsored by: ABT Systems Ltd
  Differential Revision:https://reviews.freebsd.org/D6464

Deleted:
  head/lib/libc/aarch64/sys/brk.S
  head/lib/libc/aarch64/sys/sbrk.S
Modified:
  head/UPDATING
  head/contrib/netbsd-tests/lib/libc/gen/t_dir.c
  head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
  head/lib/libc/aarch64/Symbol.map
  head/lib/libc/aarch64/sys/Makefile.inc
  head/sys/sys/param.h

Modified: head/UPDATING
==
--- head/UPDATING   Fri May 20 15:00:12 2016(r300302)
+++ head/UPDATING   Fri May 20 15:04:48 2016(r300303)
@@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20160520:
+   The brk and sbrk functions have been removed from libc on arm64.
+   Binutils from ports has been updated to not link to these
+   functions and should be updated to the latest version before
+   installing a new libc.
+
 20160517:
The armv6 port now defaults to hard float ABI. Limited support
for running both hardfloat and soft float on the same system

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_dir.c
==
--- head/contrib/netbsd-tests/lib/libc/gen/t_dir.c  Fri May 20 15:00:12 
2016(r300302)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_dir.c  Fri May 20 15:04:48 
2016(r300303)
@@ -111,6 +111,7 @@ ATF_TC_BODY(seekdir_basic, tc)
closedir(dp);
 }
 
+#ifndef __aarch64__ /* There is no sbrk on AArch64 */
 ATF_TC(telldir_leak);
 ATF_TC_HEAD(telldir_leak, tc)
 {
@@ -154,12 +155,15 @@ ATF_TC_BODY(telldir_leak, tc)
(void)printf("OK: used %td bytes\n", (char *)(sbrk(0))-memused);
}
 }
+#endif
 
 ATF_TP_ADD_TCS(tp)
 {
 
ATF_TP_ADD_TC(tp, seekdir_basic);
+#ifndef __aarch64__
ATF_TP_ADD_TC(tp, telldir_leak);
+#endif
 
return atf_no_error();
 }

Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
==
--- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.cFri May 20 15:00:12 
2016(r300302)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.cFri May 20 15:04:48 
2016(r300303)
@@ -176,7 +176,9 @@ ATF_TC_BODY(mlock_err, tc)
unsigned long vmin = 0;
size_t len = sizeof(vmin);
 #endif
+#ifndef __aarch64__
void *invalid_ptr;
+#endif
int null_errno = ENOMEM;/* error expected for NULL */
 
 #ifdef __FreeBSD__
@@ -212,6 +214,7 @@ ATF_TC_BODY(mlock_err, tc)
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, munlock((char *)-1, page) == -1);
 
+#ifndef __aarch64__ /* There is no sbrk on AArch64 */
/*
 * Try to create a pointer to an unmapped page - first after current
 * brk will likely do.
@@ -224,6 +227,7 @@ ATF_TC_BODY(mlock_err, tc)
 
errno = 0;
ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1);
+#endif
 }
 
 #ifdef __FreeBSD__

Modified: head/lib/libc/aarch64/Symbol.map
==
--- head/lib/libc/aarch64/Symbol.mapFri May 20 15:00:12 2016
(r300302)
+++ head/lib/libc/aarch64/Symbol.mapFri May 20 15:04:48 2016
(r300303)
@@ -28,8 +28,6 @@ FBSD_1.0 {
ntohl;
ntohs;
vfork;
-   brk;
-   sbrk;
makecontext;
 };
 

Modified: head/lib/libc/aarch64/sys/Makefile.inc
==
--- head/lib/libc/aarch64/sys/Makefile.inc  Fri May 20 15:00:12 2016
(r300302)
+++ head/lib/libc/aarch64/sys/Makefile.inc  Fri May 20 15:04:48 2016
(r300303)
@@ -5,10 +5,8 @@ MIASM:=${MIASM:Nfreebsd[467]_*}
 SRCS+= __vdso_gettc.c
 
 #MDASM= ptrace.S
-MDASM= brk.S \
-   

svn commit: r300300 - head/sys/arm64/arm64

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 13:11:07 2016
New Revision: 300300
URL: https://svnweb.freebsd.org/changeset/base/300300

Log:
  Add more useful GICv3 register definitions. While here fix
  GITS_CBASER_CACHE_MASK to use the correct shift macro.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3_reg.h

Modified: head/sys/arm64/arm64/gic_v3_reg.h
==
--- head/sys/arm64/arm64/gic_v3_reg.h   Fri May 20 12:38:48 2016
(r300299)
+++ head/sys/arm64/arm64/gic_v3_reg.h   Fri May 20 13:11:07 2016
(r300300)
@@ -142,6 +142,8 @@
 #defineGICR_PROPBASER_CACHE_NIWAWB 0x5UL
 #defineGICR_PROPBASER_CACHE_NIRAWAWT   0x6UL
 #defineGICR_PROPBASER_CACHE_NIRAWAWB   0x7UL
+#defineGICR_PROPBASER_CACHE_MASK   \
+   (0x7UL << GICR_PROPBASER_CACHE_SHIFT)
 
 /*
  * Shareability
@@ -179,6 +181,8 @@
 #defineGICR_PENDBASER_CACHE_NIWAWB 0x5UL
 #defineGICR_PENDBASER_CACHE_NIRAWAWT   0x6UL
 #defineGICR_PENDBASER_CACHE_NIRAWAWB   0x7UL
+#defineGICR_PENDBASER_CACHE_MASK   \
+   (0x7UL << GICR_PENDBASER_CACHE_SHIFT)
 
 /*
  * Shareability
@@ -217,6 +221,26 @@
 #defineGITS_CTLR   (0x)
 #defineGITS_CTLR_EN(1 << 0)
 
+#defineGITS_IIDR   (0x0004)
+#define GITS_IIDR_PRODUCT_SHIFT24
+#define GITS_IIDR_PRODUCT_MASK (0xff << 
GITS_IIDR_PRODUCT_SHIFT)
+#define GITS_IIDR_VARIANT_SHIFT16
+#define GITS_IIDR_VARIANT_MASK (0xf << GITS_IIDR_VARIANT_SHIFT)
+#define GITS_IIDR_REVISION_SHIFT   12
+#define GITS_IIDR_REVISION_MASK(0xf << 
GITS_IIDR_REVISION_SHIFT)
+#define GITS_IIDR_IMPLEMENTOR_SHIFT0
+#define GITS_IIDR_IMPLEMENTOR_MASK (0xfff << 
GITS_IIDR_IMPLEMENTOR_SHIFT)
+
+#define GITS_IIDR_RAW(impl, prod, var, rev)\
+((prod) << GITS_IIDR_PRODUCT_SHIFT |   \
+ (var) << GITS_IIDR_VARIANT_SHIFT |\
+ (rev) << GITS_IIDR_REVISION_SHIFT |   \
+ (impl) << GITS_IIDR_IMPLEMENTOR_SHIFT)
+
+#define GITS_IIDR_IMPL_CAVIUM  (0x34c)
+#define GITS_IIDR_PROD_THUNDER (0xa1)
+#define GITS_IIDR_VAR_THUNDER_1(0x0)
+
 #defineGITS_CBASER (0x0080)
 #defineGITS_CBASER_VALID   (1UL << 63)
 /*
@@ -239,7 +263,7 @@
 #defineGITS_CBASER_CACHE_NIWAWB0x5UL
 #defineGITS_CBASER_CACHE_NIRAWAWT  0x6UL
 #defineGITS_CBASER_CACHE_NIRAWAWB  0x7UL
-#defineGITS_CBASER_CACHE_MASK  (0x7UL << 
GITS_CBASER_TYPE_SHIFT)
+#defineGITS_CBASER_CACHE_MASK  (0x7UL << 
GITS_CBASER_CACHE_SHIFT)
 /*
  * Shareability
  * 0x0 - Non-shareable
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300299 - head/sys/arm64/arm64

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 12:38:48 2016
New Revision: 300299
URL: https://svnweb.freebsd.org/changeset/base/300299

Log:
  Filter out BUS_DMASYNC_POSTWRITE sync operations, there is nothing for us
  to do on these.
  
  Reported by:  wma
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/busdma_bounce.c

Modified: head/sys/arm64/arm64/busdma_bounce.c
==
--- head/sys/arm64/arm64/busdma_bounce.cFri May 20 12:17:40 2016
(r300298)
+++ head/sys/arm64/arm64/busdma_bounce.cFri May 20 12:38:48 2016
(r300299)
@@ -955,6 +955,9 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma
struct sync_list *sl, *end;
vm_offset_t datavaddr, tempvaddr;
 
+   if (op == BUS_DMASYNC_POSTWRITE)
+   return;
+
if ((op & BUS_DMASYNC_POSTREAD) != 0) {
/*
 * Wait for any DMA operations to complete before the bcopy.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r299683 - in head/sys/arm64: arm64 include

2016-05-20 Thread Andrew Turner
On Fri, 20 May 2016 11:44:44 +0200
Wojciech Macek  wrote:

> Where can I find any details about how was this change tested or
> reviewed? Apparently it breaks AHCI on armv8. Log below.
> 
> Wojtek
> 
> 
> mountroot> ufs:/dev/ada0s2
> > Trying to mount root from ufs:/dev/ada0s2 []...
> > warning: no time-of-day clock registered, system time will not be
> > set accurately
> > Setting hostuuid: 701a2acc-d0a0-11e5-8550-001517169365.
> > Setting hostid: 0x2abffeca.
> > No suitable dump device was found.
> > Starting file system checks:
> > /dev/ada0s2: FILE SYSTEM CLEAN; SKIPPING CHECKS
> > /dev/ada0s2: clean, 16575173 free (25325 frags, 2068731 blocks, 0.1%
> > fragmentation)
> > panic: unsupported combination of sync operations: 0x0008  

How were you getting into dma_dcache_sync? That should only happen when
map->sync_count != 0, this should only be possible when the BF_COHERENT
flag is set. This flag should never get set.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300291 - head/sys/arm64/conf

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 08:43:18 2016
New Revision: 300291
URL: https://svnweb.freebsd.org/changeset/base/300291

Log:
  Enable NEW_PCIB on arm64.
  
  Obtained from:ABT Systems Ltd
  Relnotes: yes
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/conf/DEFAULTS

Modified: head/sys/arm64/conf/DEFAULTS
==
--- head/sys/arm64/conf/DEFAULTSFri May 20 08:29:00 2016
(r300290)
+++ head/sys/arm64/conf/DEFAULTSFri May 20 08:43:18 2016
(r300291)
@@ -12,3 +12,4 @@ devicemem # Memory and kernel 
memory 
 optionsGEOM_PART_BSD
 optionsGEOM_PART_MBR
 
+optionsNEW_PCIB
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300290 - in head/sys: arm64/cavium dev/pci

2016-05-20 Thread Andrew Turner
Author: andrew
Date: Fri May 20 08:29:00 2016
New Revision: 300290
URL: https://svnweb.freebsd.org/changeset/base/300290

Log:
  Handle PCI_RES_BUS on the generic and ThunderX PCIe drivers. This has been
  tested on the Pass 1.1 and 2.0 ThunderX machines in the Netperf cluster.
  
  Reviewed by:  jhb
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6453

Modified:
  head/sys/arm64/cavium/thunder_pcie_pem.c
  head/sys/dev/pci/pci_host_generic.c

Modified: head/sys/arm64/cavium/thunder_pcie_pem.c
==
--- head/sys/arm64/cavium/thunder_pcie_pem.cFri May 20 08:28:11 2016
(r300289)
+++ head/sys/arm64/cavium/thunder_pcie_pem.cFri May 20 08:29:00 2016
(r300290)
@@ -313,6 +313,10 @@ thunder_pem_adjust_resource(device_t dev
struct rman *rm;
 
sc = device_get_softc(dev);
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type == PCI_RES_BUS)
+   return (pci_domain_adjust_bus(sc->id, child, res, start, end));
+#endif
 
rm = thunder_pem_rman(sc, type);
if (rm == NULL)
@@ -619,6 +623,11 @@ thunder_pem_alloc_resource(device_t dev,
struct resource *res;
device_t parent_dev;
 
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type == PCI_RES_BUS)
+   return (pci_domain_alloc_bus(sc->id, child, rid, start,  end,
+   count, flags));
+#endif
rm = thunder_pem_rman(sc, type);
if (rm == NULL) {
/* Find parent device. On ThunderX we know an exact path. */
@@ -675,7 +684,12 @@ thunder_pem_release_resource(device_t de
 struct resource *res)
 {
device_t parent_dev;
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   struct thunder_pem_softc *sc = device_get_softc(dev);
 
+   if (type == PCI_RES_BUS)
+   return (pci_domain_release_bus(sc->id, child, rid, res));
+#endif
/* Find parent device. On ThunderX we know an exact path. */
parent_dev = device_get_parent(device_get_parent(dev));
 

Modified: head/sys/dev/pci/pci_host_generic.c
==
--- head/sys/dev/pci/pci_host_generic.c Fri May 20 08:28:11 2016
(r300289)
+++ head/sys/dev/pci/pci_host_generic.c Fri May 20 08:29:00 2016
(r300290)
@@ -501,7 +501,14 @@ static int
 generic_pcie_release_resource(device_t dev, device_t child, int type,
 int rid, struct resource *res)
 {
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   struct generic_pcie_softc *sc;
 
+   if (type == PCI_RES_BUS) {
+   sc = device_get_softc(dev);
+   return (pci_domain_release_bus(sc->ecam, child, rid, res));
+   }
+#endif
/* For PCIe devices that do not have FDT nodes, use PCIB method */
if ((int)ofw_bus_get_node(child) <= 0) {
return (generic_pcie_release_resource_pcie(dev,
@@ -517,7 +524,15 @@ struct resource *
 pci_host_generic_alloc_resource(device_t dev, device_t child, int type, int 
*rid,
 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 {
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   struct generic_pcie_softc *sc;
 
+   if (type == PCI_RES_BUS) {
+   sc = device_get_softc(dev);
+   return (pci_domain_alloc_bus(sc->ecam, child, rid, start, end,
+   count, flags));
+   }
+#endif
/* For PCIe devices that do not have FDT nodes, use PCIB method */
if ((int)ofw_bus_get_node(child) <= 0)
return (generic_pcie_alloc_resource_pcie(dev, child, type, rid,
@@ -579,6 +594,11 @@ generic_pcie_adjust_resource(device_t de
struct rman *rm;
 
sc = device_get_softc(dev);
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+   if (type == PCI_RES_BUS)
+   return (pci_domain_adjust_bus(sc->ecam, child, res, start,
+   end));
+#endif
 
rm = generic_pcie_rman(sc, type);
if (rm != NULL)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300206 - head/sys/arm64/include

2016-05-19 Thread Andrew Turner
On Thu, 19 May 2016 07:22:51 -0700
John Baldwin <j...@freebsd.org> wrote:

> On Thursday, May 19, 2016 02:00:18 PM Andrew Turner wrote:
> > Author: andrew
> > Date: Thu May 19 14:00:18 2016
> > New Revision: 300206
> > URL: https://svnweb.freebsd.org/changeset/base/300206
> > 
> > Log:
> >   Define PCI_RES_BUS for NEW_PCIB
> >   
> >   Obtained from:ABT Systems Ltd
> >   Sponsored by: The FreeBSD Foundation  
> 
> Does it work? :)  You'd need to handle it explicitly in non-ACPI
> Host-PCI bridge drivers.
> 

See https://reviews.freebsd.org/D6453 for the review.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300206 - head/sys/arm64/include

2016-05-19 Thread Andrew Turner
Author: andrew
Date: Thu May 19 14:00:18 2016
New Revision: 300206
URL: https://svnweb.freebsd.org/changeset/base/300206

Log:
  Define PCI_RES_BUS for NEW_PCIB
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/include/resource.h

Modified: head/sys/arm64/include/resource.h
==
--- head/sys/arm64/include/resource.h   Thu May 19 13:52:12 2016
(r300205)
+++ head/sys/arm64/include/resource.h   Thu May 19 14:00:18 2016
(r300206)
@@ -42,5 +42,8 @@
 #defineSYS_RES_MEMORY  3   /* i/o memory */
 #defineSYS_RES_IOPORT  4   /* i/o ports */
 #defineSYS_RES_GPIO5   /* general purpose i/o */
+#ifdef NEW_PCIB
+#definePCI_RES_BUS 6   /* PCI bus numbers */
+#endif
 
 #endif /* !_MACHINE_RESOURCE_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r300149 - in head/sys: arm/allwinner arm/allwinner/a10 arm/arm arm/broadcom/bcm2835 arm/mv arm/nvidia arm/ti arm/ti/omap4 arm64/arm64 kern mips/mediatek mips/mips sys

2016-05-18 Thread Andrew Turner
On Wed, 18 May 2016 17:15:10 +0200
Zbigniew Bodek <z...@semihalf.com> wrote:

> 2016-05-18 17:05 GMT+02:00 Andrew Turner <and...@freebsd.org>:
...
> >  #ifdef INTRNG
> > xref = OF_xref_from_node(ofw_bus_get_node(dev));
> > -   if (intr_pic_register(dev, xref) != 0) {
> > +   if (intr_pic_register(dev, xref) == NULL) {
> > device_printf(dev, "could not register PIC\n");
> > goto error;
> > }
> > @@ -172,7 +172,7 @@ error:
> > /* Failure so free resources */
> > gic_v3_detach(dev);
> >
> > -   return (err);
> > +   return (ENXIO);
> >  
> 
> 
> Few line above we have:
> err = gic_v3_attach(dev);
> if (err != 0)
> goto error;
> 
> So now we would not return error code from gic_v3_attach() but always
> ENXIO...

The error value doesn't matter, as long as it's non-zero. This also
fixes the return value in the intrng case if either of
intr_pic_register or intr_pic_claim_root fail. You might get a little
information from the return value being printed, however it would be
more useful to have verbose logging to print an error message.

In all of these failure cases there isn't much we can do as there is no
root interrupt controller, the boot will fail later on when we enable
interrupts.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300149 - in head/sys: arm/allwinner arm/allwinner/a10 arm/arm arm/broadcom/bcm2835 arm/mv arm/nvidia arm/ti arm/ti/omap4 arm64/arm64 kern mips/mediatek mips/mips sys

2016-05-18 Thread Andrew Turner
Author: andrew
Date: Wed May 18 15:05:44 2016
New Revision: 300149
URL: https://svnweb.freebsd.org/changeset/base/300149

Log:
  Return the struct intr_pic pointer from intr_pic_register. This will be
  needed in later changes where we may not be able to lock the pic list lock
  to perform a lookup, e.g. from within interrupt context.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm/allwinner/a10/a10_intc.c
  head/sys/arm/allwinner/aw_nmi.c
  head/sys/arm/arm/gic.c
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
  head/sys/arm/broadcom/bcm2835/bcm2836.c
  head/sys/arm/mv/mpic.c
  head/sys/arm/nvidia/tegra_gpio.c
  head/sys/arm/nvidia/tegra_lic.c
  head/sys/arm/ti/aintc.c
  head/sys/arm/ti/omap4/omap4_wugen.c
  head/sys/arm/ti/ti_gpio.c
  head/sys/arm64/arm64/gic_v3_fdt.c
  head/sys/kern/subr_intr.c
  head/sys/mips/mediatek/mtk_gpio_v1.c
  head/sys/mips/mediatek/mtk_gpio_v2.c
  head/sys/mips/mediatek/mtk_intr_gic.c
  head/sys/mips/mediatek/mtk_intr_v1.c
  head/sys/mips/mediatek/mtk_intr_v2.c
  head/sys/mips/mediatek/mtk_pcie.c
  head/sys/mips/mips/mips_pic.c
  head/sys/sys/intr.h

Modified: head/sys/arm/allwinner/a10/a10_intc.c
==
--- head/sys/arm/allwinner/a10/a10_intc.c   Wed May 18 14:43:17 2016
(r300148)
+++ head/sys/arm/allwinner/a10/a10_intc.c   Wed May 18 15:05:44 2016
(r300149)
@@ -250,6 +250,7 @@ a10_intr(void *arg)
 static int
 a10_intr_pic_attach(struct a10_aintc_softc *sc)
 {
+   struct intr_pic *pic;
int error;
uint32_t irq;
const char *name;
@@ -266,9 +267,9 @@ a10_intr_pic_attach(struct a10_aintc_sof
}
 
xref = OF_xref_from_node(ofw_bus_get_node(sc->sc_dev));
-   error = intr_pic_register(sc->sc_dev, xref);
-   if (error != 0)
-   return (error);
+   pic = intr_pic_register(sc->sc_dev, xref);
+   if (pic == NULL)
+   return (ENXIO);
 
return (intr_pic_claim_root(sc->sc_dev, xref, a10_intr, sc, 0));
 }

Modified: head/sys/arm/allwinner/aw_nmi.c
==
--- head/sys/arm/allwinner/aw_nmi.c Wed May 18 14:43:17 2016
(r300148)
+++ head/sys/arm/allwinner/aw_nmi.c Wed May 18 15:05:44 2016
(r300149)
@@ -362,7 +362,7 @@ aw_nmi_attach(device_t dev)
  device_get_nameunit(sc->dev), sc->intr.irq) != 0)
goto error;
 
-   if (intr_pic_register(dev, (intptr_t)xref) != 0) {
+   if (intr_pic_register(dev, (intptr_t)xref) == NULL) {
device_printf(dev, "could not register pic\n");
goto error;
}

Modified: head/sys/arm/arm/gic.c
==
--- head/sys/arm/arm/gic.c  Wed May 18 14:43:17 2016(r300148)
+++ head/sys/arm/arm/gic.c  Wed May 18 15:05:44 2016(r300149)
@@ -711,7 +711,7 @@ arm_gic_attach(device_t dev)
 * Now, when everything is initialized, it's right time to
 * register interrupt controller to interrupt framefork.
 */
-   if (intr_pic_register(dev, xref) != 0) {
+   if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.cWed May 18 14:43:17 
2016(r300148)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.cWed May 18 15:05:44 
2016(r300149)
@@ -1045,8 +1045,11 @@ bcm_gpio_pic_attach(struct bcm_gpio_soft
if (error != 0)
return (error); /* XXX deregister ISRCs */
}
-   return (intr_pic_register(sc->sc_dev,
-   OF_xref_from_node(ofw_bus_get_node(sc->sc_dev;
+   if (intr_pic_register(sc->sc_dev,
+   OF_xref_from_node(ofw_bus_get_node(sc->sc_dev))) == NULL)
+   return (ENXIO);
+
+   return (0);
 }
 
 static int

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_intr.cWed May 18 14:43:17 
2016(r300148)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_intr.cWed May 18 15:05:44 
2016(r300149)
@@ -341,7 +341,10 @@ bcm_intc_pic_register(struct bcm_intc_so
if (error != 0)
return (error);
}
-   return (intr_pic_register(sc->sc_dev, xref));
+   if (intr_pic_register(sc->sc_dev, xref) == NULL)
+   return (ENXIO);
+
+   return (0);
 }
 #endif
 

Modified: head/sys/arm/broadcom/bcm2835/bcm2836.c

svn commit: r300144 - head/sys/arm/include

2016-05-18 Thread Andrew Turner
Author: andrew
Date: Wed May 18 13:09:52 2016
New Revision: 300144
URL: https://svnweb.freebsd.org/changeset/base/300144

Log:
  Implement atomic_cmpset_acq_64 and atomic_cmpset_rel_64 on arm and armeb.
  This should allow r300113 to build there.
  
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm/include/atomic-v4.h

Modified: head/sys/arm/include/atomic-v4.h
==
--- head/sys/arm/include/atomic-v4.hWed May 18 12:53:21 2016
(r300143)
+++ head/sys/arm/include/atomic-v4.hWed May 18 13:09:52 2016
(r300144)
@@ -372,6 +372,8 @@ atomic_swap_32(volatile u_int32_t *p, u_
 
 #define atomic_cmpset_rel_32   atomic_cmpset_32
 #define atomic_cmpset_acq_32   atomic_cmpset_32
+#define atomic_cmpset_rel_64   atomic_cmpset_64
+#define atomic_cmpset_acq_64   atomic_cmpset_64
 #define atomic_set_rel_32  atomic_set_32
 #define atomic_set_acq_32  atomic_set_32
 #define atomic_clear_rel_32atomic_clear_32
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r300048 - head/sys/arm64/arm64

2016-05-17 Thread Andrew Turner
Author: andrew
Date: Tue May 17 12:46:50 2016
New Revision: 300048
URL: https://svnweb.freebsd.org/changeset/base/300048

Log:
  Clean up the GICv3 intrng code:
   * In gic_v3_attach free the correct data on failure.
   * Implement gic_v3_teardown_intr.
   * Update the panic string when enabling/disabling an invalid interrupt.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/gic_v3.c

Modified: head/sys/arm64/arm64/gic_v3.c
==
--- head/sys/arm64/arm64/gic_v3.c   Tue May 17 12:04:39 2016
(r300047)
+++ head/sys/arm64/arm64/gic_v3.c   Tue May 17 12:46:50 2016
(r300048)
@@ -267,7 +267,7 @@ gic_v3_attach(device_t dev)
}
if (err != 0) {
/* XXX call intr_isrc_deregister() */
-   free(irqs, M_DEVBUF);
+   free(sc->gic_irqs, M_DEVBUF);
return (err);
}
}
@@ -611,8 +611,14 @@ static int
 gic_v3_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
 struct resource *res, struct intr_map_data *data)
 {
+   struct gic_v3_irqsrc *gi = (struct gic_v3_irqsrc *)isrc;
+
+   if (isrc->isrc_handlers == 0) {
+   gi->gi_pol = INTR_POLARITY_CONFORM;
+   gi->gi_trig = INTR_TRIGGER_CONFORM;
+   }
 
-   panic("gic_v3_teardown_intr");
+   return (0);
 }
 
 static void
@@ -636,7 +642,7 @@ gic_v3_disable_intr(device_t dev, struct
gic_d_write(sc, 4, GICD_ICENABLER(irq), GICD_I_MASK(irq));
gic_v3_wait_for_rwp(sc, DIST);
} else
-   panic("gic_v3_disable_intr");
+   panic("%s: Unsupported IRQ %u", __func__, irq);
 }
 
 static void
@@ -660,7 +666,7 @@ gic_v3_enable_intr(device_t dev, struct 
gic_d_write(sc, 4, GICD_ISENABLER(irq), GICD_I_MASK(irq));
gic_v3_wait_for_rwp(sc, DIST);
} else
-   panic("gic_v3_enable_intr");
+   panic("%s: Unsupported IRQ %u", __func__, irq);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r299944 - in head/sys: arm64/arm64 conf

2016-05-17 Thread Andrew Turner
On Mon, 16 May 2016 18:08:49 +0200
Zbigniew Bodek <z...@semihalf.com> wrote:

> Hello Andrew,
> 
> I think committing this code should be preceded by at least brief
> review. Few remarks to the code found on the first glance below.

See below for comments.

> 
> Kind regards
> zbb
> 
> 2016-05-16 16:07 GMT+02:00 Andrew Turner <and...@freebsd.org>:
> 
> > Author: andrew
> > Date: Mon May 16 14:07:43 2016
> > New Revision: 299944
> > URL: https://svnweb.freebsd.org/changeset/base/299944
> >
> > Log:
> >   Add intrng support to the GICv3 driver. It lacks ITS support so
> > won't handle
> >   MSI or MSI-X interrupts, however this is enought to boot FreeBSD
> > under the
> >   ARM Foundation Model with a GICv3 interrupt controller.
> >
> >   Approved by:  ABT Systems Ltd
> >   Relnotes: yes
> >   Sponsored by: The FreeBSD Foundation
...
> > +#ifdef INTRNG
> > +int
> > +arm_gic_v3_intr(void *arg)
> > +{
> > +   struct gic_v3_softc *sc = arg;
> > +   struct gic_v3_irqsrc *gi;
> > +   uint64_t active_irq;
> > +   struct trapframe *tf;
> > +   bool first;
> > +
> > +   first = true;
> > +
> > +   while (1) {
> > +   if (CPU_MATCH_ERRATA_CAVIUM_THUNDER_1_1) {
> > +   /*
> > +* Hardware:Cavium ThunderX
> > +* Chip revision:   Pass 1.0 (early
> > version)
> > +*  Pass 1.1
> > (production)
> > +* ERRATUM: 22978, 23154
> > +*/
> > +   __asm __volatile(
> > +   "nop;nop;nop;nop;nop;nop;nop;nop;   \n"
> > +   "mrs %0, ICC_IAR1_EL1   \n"
> > +   "nop;nop;nop;nop;   \n"
> > +   "dsb sy \n"
> > +   : "=" (active_irq));
> > +   } else {
> > +   active_irq = gic_icc_read(IAR1);
> > +   }
> > +
> > +   if (__predict_false(active_irq >= sc->gic_nirqs))
> > +   return (FILTER_HANDLED);
> >  
> 
> IMHO this is not true. Active IRQ could be much bigger than number of
> supported IRQs. We are asking for debugging in the future when we
> enable ITS.

It is correct, the ITS change to this file is missing so we are unable
to enable ITS interrupts.

...
> > +
> > +#ifdef FDT
> > +static int
> > +gic_map_fdt(device_t dev, u_int ncells, pcell_t *cells, u_int
> > *irqp,
> > +enum intr_polarity *polp, enum intr_trigger *trigp)
> >  
> 
> All other functions are called gic_v3 and this one is just gic_
> Why can't we move as much FDT code to the dedicated file which is
> gic_v3_fdt.c?

Unfortunately due to the current code in subr_intr.c this is needed for
simplicity. It it my understanding there is work to fix this, so for
now I would prefer to keep this.

...
> > +   /* Set the trigger and polarity */
> > +   if (irq <= GIC_LAST_PPI)
> > +   reg = gic_r_read(sc, 4,
> > +   GICR_SGI_BASE_SIZE + GICD_ICFGR(irq));
> > +   else
> > +   reg = gic_d_read(sc, 4, GICD_ICFGR(irq));
> > +   if (trig == INTR_TRIGGER_LEVEL)
> > +   reg &= ~(2 << ((irq % 16) * 2));
> > +   else
> > +   reg |= 2 << ((irq % 16) * 2);
> >  
> 
> The rule of not using magic numbers does not apply here ;-) ?

This is partially why this is still disabled by default, the code still
needs a little polish, however it will be needed to help with a future
review for changes to subr_intr.c.

...
> > +static void
> > +gic_v3_disable_intr(device_t dev, struct intr_irqsrc *isrc)
> > +{
> > +   struct gic_v3_softc *sc;
> > +   struct gic_v3_irqsrc *gi;
> > +   u_int irq;
> > +
> > +   sc = device_get_softc(dev);
> > +   gi = (struct gic_v3_irqsrc *)isrc;
> > +   irq = gi->gi_irq;
> > +
> > +   if (irq <= GIC_LAST_PPI) {
> > +   /* SGIs and PPIs in corresponding Re-Distributor */
> > +   gic_r_write(sc, 4, GICR_SGI_BASE_SIZE +
> > GICD_ICENABLER(irq),
> > +   GICD_I_MASK(irq));
> > +   gic_

<    3   4   5   6   7   8   9   10   11   12   >