svn commit: r353778 - head/sys/dev/e1000

2019-10-20 Thread Marius Strobl
Author: marius
Date: Sun Oct 20 17:40:50 2019
New Revision: 353778
URL: https://svnweb.freebsd.org/changeset/base/353778

Log:
  - In em_intr(), just call em_handle_link() instead of duplicating it.
  - In em_msix_link(), properly handle IGB-class devices after the iflib(4)
conversion again by only setting EM_MSIX_LINK for the EM-class 82574
and by re-arming link interrupts unconditionally, i. e. not only in
case of spurious interrupts. This fixes the interface link state change
detection for the IGB-class. [1]
  - In em_if_update_admin_status(), only re-arm the link state change
interrupt for 82574 and also only if such a device uses MSI-X, i. e.
takes advantage of autoclearing. In case of INTx and MSI as well as
for LEM- and IGB-class devices, re-arming isn't appropriate here and
setting EM_MSIX_LINK isn't either.
While at it, consistently take advantage of the hw variable.
  
  PR:   236724 [1]
  Differential Revision:https://reviews.freebsd.org/D21924

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Sun Oct 20 15:50:33 2019(r353777)
+++ head/sys/dev/e1000/if_em.c  Sun Oct 20 17:40:50 2019(r353778)
@@ -1395,10 +1395,8 @@ em_intr(void *arg)
IFDI_INTR_DISABLE(ctx);
 
/* Link status change */
-   if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
-   adapter->hw.mac.get_link_status = 1;
-   iflib_admin_intr_deferred(ctx);
-   }
+   if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))
+   em_handle_link(ctx);
 
if (reg_icr & E1000_ICR_RXO)
adapter->rx_overruns++;
@@ -1481,22 +1479,24 @@ em_msix_link(void *arg)
 
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
em_handle_link(adapter->ctx);
-   } else {
-   E1000_WRITE_REG(>hw, E1000_IMS,
-   EM_MSIX_LINK | E1000_IMS_LSC);
-   if (adapter->hw.mac.type >= igb_mac_min)
-   E1000_WRITE_REG(>hw, E1000_EIMS, 
adapter->link_mask);
+   } else if (adapter->hw.mac.type == e1000_82574) {
+   /* Only re-arm 82574 if em_if_update_admin_status() won't. */
+   E1000_WRITE_REG(>hw, E1000_IMS, EM_MSIX_LINK |
+   E1000_IMS_LSC);
}
 
-   /*
-* Because we must read the ICR for this interrupt
-* it may clear other causes using autoclear, for
-* this reason we simply create a soft interrupt
-* for all these vectors.
-*/
-   if (reg_icr && adapter->hw.mac.type < igb_mac_min) {
-   E1000_WRITE_REG(>hw,
-   E1000_ICS, adapter->ims);
+   if (adapter->hw.mac.type == e1000_82574) {
+   /*
+* Because we must read the ICR for this interrupt it may
+* clear other causes using autoclear, for this reason we
+* simply create a soft interrupt for all these vectors.
+*/
+   if (reg_icr)
+   E1000_WRITE_REG(>hw, E1000_ICS, adapter->ims);
+   } else {
+   /* Re-arm unconditionally */
+   E1000_WRITE_REG(>hw, E1000_IMS, E1000_IMS_LSC);
+   E1000_WRITE_REG(>hw, E1000_EIMS, adapter->link_mask);
}
 
return (FILTER_HANDLED);
@@ -1512,7 +1512,6 @@ em_handle_link(void *context)
iflib_admin_intr_deferred(ctx);
 }
 
-
 /*
  *
  *  Media Ioctl callback
@@ -1829,14 +1828,15 @@ em_if_update_admin_status(if_ctx_t ctx)
em_update_stats_counters(adapter);
 
/* Reset LAA into RAR[0] on 82571 */
-   if ((adapter->hw.mac.type == e1000_82571) &&
-   e1000_get_laa_state_82571(>hw))
-   e1000_rar_set(>hw, adapter->hw.mac.addr, 0);
+   if (hw->mac.type == e1000_82571 && e1000_get_laa_state_82571(hw))
+   e1000_rar_set(hw, hw->mac.addr, 0);
 
-   if (adapter->hw.mac.type < em_mac_min)
+   if (hw->mac.type < em_mac_min)
lem_smartspeed(adapter);
-
-   E1000_WRITE_REG(>hw, E1000_IMS, EM_MSIX_LINK | E1000_IMS_LSC);
+   else if (hw->mac.type == e1000_82574 &&
+   adapter->intr_type == IFLIB_INTR_MSIX)
+   E1000_WRITE_REG(>hw, E1000_IMS, EM_MSIX_LINK |
+   E1000_IMS_LSC);
 }
 
 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"


svn commit: r349414 - head/sys/net

2019-06-26 Thread Marius Strobl
Author: marius
Date: Wed Jun 26 15:28:21 2019
New Revision: 349414
URL: https://svnweb.freebsd.org/changeset/base/349414

Log:
  o In iflib_txq_drain():
- Remove desc_used, which is only ever written to.
- Remove a dead store to reclaimed.
- Don't recycle avail.
- Sort variables according to style(9).
These changes will make a subsequent commit easier to read.
  o In iflib_tx_credits_update(), don't bother checking whether the
ift_txd_credits_update method pointer is NULL; _iflib_pre_assert()
asserts upfront that this method has been assigned and functions
like iflib_{fast_intr_rxtx,netmap_timer_adjust,txq_can_drain}()
and _task_fn_tx() were already unconditionally relying on the
method being callable.

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Jun 26 15:16:23 2019(r349413)
+++ head/sys/net/iflib.cWed Jun 26 15:28:21 2019(r349414)
@@ -3580,10 +3580,10 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui
iflib_txq_t txq = r->cookie;
if_ctx_t ctx = txq->ift_ctx;
if_t ifp = ctx->ifc_ifp;
-   struct mbuf **mp, *m;
-   int i, count, consumed, pkt_sent, bytes_sent, mcast_sent, avail;
-   int reclaimed, err, in_use_prev, desc_used;
-   bool do_prefetch, ring, rang;
+   struct mbuf *m, **mp;
+   int avail, bytes_sent, consumed, count, err, i, in_use_prev;
+   int mcast_sent, pkt_sent, reclaimed, txq_avail;
+   bool do_prefetch, rang, ring;
 
if (__predict_false(!(if_getdrvflags(ifp) & IFF_DRV_RUNNING) ||
!LINK_ACTIVE(ctx))) {
@@ -3621,16 +3621,15 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui
   avail, ctx->ifc_flags, TXQ_AVAIL(txq));
 #endif
do_prefetch = (ctx->ifc_flags & IFC_PREFETCH);
-   avail = TXQ_AVAIL(txq);
+   txq_avail = TXQ_AVAIL(txq);
err = 0;
-   for (desc_used = i = 0; i < count && avail > MAX_TX_DESC(ctx) + 2; i++) 
{
+   for (i = 0; i < count && txq_avail > MAX_TX_DESC(ctx) + 2; i++) {
int rem = do_prefetch ? count - i : 0;
 
mp = _ring_peek_one(r, cidx, i, rem);
MPASS(mp != NULL && *mp != NULL);
if (__predict_false(*mp == (struct mbuf *)txq)) {
consumed++;
-   reclaimed++;
continue;
}
in_use_prev = txq->ift_in_use;
@@ -3649,10 +3648,9 @@ iflib_txq_drain(struct ifmp_ring *r, uint32_t cidx, ui
DBG_COUNTER_INC(tx_sent);
bytes_sent += m->m_pkthdr.len;
mcast_sent += !!(m->m_flags & M_MCAST);
-   avail = TXQ_AVAIL(txq);
+   txq_avail = TXQ_AVAIL(txq);
 
txq->ift_db_pending += (txq->ift_in_use - in_use_prev);
-   desc_used += (txq->ift_in_use - in_use_prev);
ETHER_BPF_MTAP(ifp, m);
if (__predict_false(!(ifp->if_drv_flags & IFF_DRV_RUNNING)))
break;
@@ -6154,9 +6152,6 @@ iflib_tx_credits_update(if_ctx_t ctx, iflib_txq_t txq)
 #ifdef INVARIANTS
int credits_pre = txq->ift_cidx_processed;
 #endif
-
-   if (ctx->isc_txd_credits_update == NULL)
-   return (0);
 
bus_dmamap_sync(txq->ift_ifdi->idi_tag, txq->ift_ifdi->idi_map,
BUS_DMASYNC_POSTREAD);
___
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: r349055 - head/sys/net

2019-06-15 Thread Marius Strobl
On Sat, Jun 15, 2019 at 09:08:05AM -0400, Andrew Gallatin wrote:
> On 2019-06-15 07:07, Marius Strobl wrote:
> > Author: marius
> > Date: Sat Jun 15 11:07:41 2019
> > New Revision: 349055
> 
> > Log:
> >- Replace unused and only ever written to members of public iflib(9)
> >  structs with placeholders (in the latter case, IFLIB_MAX_TX_BYTES
> >  etc. are also only ever used for these write-only members if at all,
> >  so both these macros and members can just go). Using these spares
> >  may render it possible to merge certain iflib(9) fixes to stable/12.
> >  Otherwise, changes extending struct if_irq or struct if_shared_ctx
> >  in any way would break KBI as instances of these are allocated by
> >  the driver front-ends (by contrast, struct if_pkt_info as well as
> >  struct if_softc_ctx instances are provided by iflib(9) and, thus,
> >  may grow at least at the end without breaking KBI).
> 
> Given the above, why replace ipi_tcp_sum in if_pkt_info with a spare? 
> Given that if_pkt_info can grow, I would also expect it to be able to 
> shrink.  So I don't quite see why the spare is needed here.
> 
> I also worry about carrying the other spares around forever.

Yes, KBI-wise it should be also safe for instances of structures allocated
by iflib(9) to shrink at the end (though shrinking structures usually isn't
a concern when MFCing as such parts may just be omitted); changes altering
the offsets of members would be a problem regarding KBI.
Still, I don't like changing the size of publicly visible structures in
stable branches without a real good reason even if such a change doesn't
strictly break the KBI. So the plan is to MFC the spares but then to get
rid of the ones whose removal doesn't break KBI in head.

Marius

___
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: r349055 - head/sys/net

2019-06-15 Thread Marius Strobl
Author: marius
Date: Sat Jun 15 11:07:41 2019
New Revision: 349055
URL: https://svnweb.freebsd.org/changeset/base/349055

Log:
  - Replace unused and only ever written to members of public iflib(9)
structs with placeholders (in the latter case, IFLIB_MAX_TX_BYTES
etc. are also only ever used for these write-only members if at all,
so both these macros and members can just go). Using these spares
may render it possible to merge certain iflib(9) fixes to stable/12.
Otherwise, changes extending struct if_irq or struct if_shared_ctx
in any way would break KBI as instances of these are allocated by
the driver front-ends (by contrast, struct if_pkt_info as well as
struct if_softc_ctx instances are provided by iflib(9) and, thus,
may grow at least at the end without breaking KBI).
  - Make the pvi_name in struct pci_vendor_info const char * as device
identifiers in hardware lookup tables aren't to be expected to ever
change at runtime.
  - Similarly, make the pci_vendor_info_t of struct if_shared_ctx which
is used to point to the struct pci_vendor_info arrays provided by
the driver front-ends const.
  - Remove the ETH_ADDR_LEN macro from iflib.h; this was duplicating
ETHER_ADDR_LEN of  with iflib(9) actually only
consuming the latter macro.
  - Make the name argument of iflib_io_tqg_attach(9) const, matching
the taskqgroup_attach_cpu(9) this function wraps as well as e. g.
iflib_config_gtask_init(9).
  - Remove the orphaned iflib_qset_lock_get() prototype.
  - Remove some extraneous empty lines.

Modified:
  head/sys/net/iflib.c
  head/sys/net/iflib.h
  head/sys/net/iflib_private.h

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSat Jun 15 09:45:00 2019(r349054)
+++ head/sys/net/iflib.cSat Jun 15 11:07:41 2019(r349055)
@@ -376,7 +376,6 @@ struct iflib_fl {
uint64_tifl_cl_dequeued;
 #endif
/* implicit pad */
-
bitstr_t*ifl_rx_bitmap;
qidx_t  ifl_fragidx;
/* constant */
@@ -1250,7 +1249,6 @@ iflib_netmap_timer_adjust(if_ctx_t ctx, iflib_txq_t tx
 #define netmap_rx_irq(ifp, qid, budget) (0)
 #define netmap_tx_irq(ifp, qid) do {} while (0)
 #define iflib_netmap_timer_adjust(ctx, txq, reset_on)
-
 #endif
 
 #if defined(__i386__) || defined(__amd64__)
@@ -1537,17 +1535,17 @@ _iflib_irq_alloc(if_ctx_t ctx, if_irq_t irq, int rid,
 driver_filter_t filter, driver_intr_t handler, void *arg,
 const char *name)
 {
-   int rc, flags;
struct resource *res;
void *tag = NULL;
device_t dev = ctx->ifc_dev;
+   int flags, i, rc;
 
flags = RF_ACTIVE;
if (ctx->ifc_flags & IFC_LEGACY)
flags |= RF_SHAREABLE;
MPASS(rid < 512);
-   irq->ii_rid = rid;
-   res = bus_alloc_resource_any(dev, SYS_RES_IRQ, >ii_rid, flags);
+   i = rid;
+   res = bus_alloc_resource_any(dev, SYS_RES_IRQ, , flags);
if (res == NULL) {
device_printf(dev,
"failed to allocate IRQ for rid %d, name %s.\n", rid, name);
@@ -1569,7 +1567,6 @@ _iflib_irq_alloc(if_ctx_t ctx, if_irq_t irq, int rid,
return (0);
 }
 
-
 /*
  *
  *  Allocate DMA resources for TX buffers as well as memory for the TX
@@ -4332,12 +4329,10 @@ iflib_led_func(void *arg, int onoff)
 int
 iflib_device_probe(device_t dev)
 {
-   pci_vendor_info_t *ent;
-
-   uint16_tpci_vendor_id, pci_device_id;
-   uint16_tpci_subvendor_id, pci_subdevice_id;
-   uint16_tpci_rev_id;
+   const pci_vendor_info_t *ent;
if_shared_ctx_t sctx;
+   uint16_t pci_device_id, pci_rev_id, pci_subdevice_id, pci_subvendor_id;
+   uint16_t pci_vendor_id;
 
if ((sctx = DEVICE_REGISTER(dev)) == NULL || sctx->isc_magic != 
IFLIB_MAGIC)
return (ENOTSUP);
@@ -4397,8 +4392,6 @@ iflib_reset_qvalues(if_ctx_t ctx)
device_t dev = ctx->ifc_dev;
int i;
 
-   scctx->isc_txrx_budget_bytes_max = IFLIB_MAX_TX_BYTES;
-   scctx->isc_tx_qdepth = IFLIB_DEFAULT_TX_QDEPTH;
if (ctx->ifc_sysctl_ntxqs != 0)
scctx->isc_ntxqsets = ctx->ifc_sysctl_ntxqs;
if (ctx->ifc_sysctl_nrxqs != 0)
@@ -6037,15 +6030,14 @@ iflib_legacy_setup(if_ctx_t ctx, driver_filter_t filte
struct resource *res;
struct taskqgroup *tqg;
gtask_fn_t *fn;
-   int tqrid;
void *q;
-   int err;
+   int err, tqrid;
 
q = >ifc_rxqs[0];
info = [0].ifr_filter_info;
gtask = [0].ifr_task;
tqg = qgroup_if_io_tqg;
-   tqrid = irq->ii_rid = *rid;
+   tqrid = *rid;
fn = _task_fn_rx;
 
ctx->ifc_flags |= IFC_LEGACY;
@@ -6112,7 +6104,7 @@ iflib_iov_intr_deferred(if_ctx_t ctx)
 }
 
 void

svn commit: r349054 - head/tools/build

2019-06-15 Thread Marius Strobl
Author: marius
Date: Sat Jun 15 09:45:00 2019
New Revision: 349054
URL: https://svnweb.freebsd.org/changeset/base/349054

Log:
  Add  required for libnv to SYSINCS, too, apparently missed
  in r336335.

Modified:
  head/tools/build/Makefile

Modified: head/tools/build/Makefile
==
--- head/tools/build/Makefile   Sat Jun 15 09:30:11 2019(r349053)
+++ head/tools/build/Makefile   Sat Jun 15 09:45:00 2019(r349054)
@@ -70,7 +70,8 @@ SUBDIR=   cross-build
 .endif
 
 # Needed to build config (since it uses libnv)
-SYSINCS+=  ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h
+SYSINCS+=  ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \
+   ${SRCTOP}/sys/sys/dnv.h
 
 # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
 # accidentally run tools that are incompatible but happen to be in $PATH.
___
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: r347390 - head/sys/net

2019-05-09 Thread Marius Strobl
Author: marius
Date: Thu May  9 11:34:46 2019
New Revision: 347390
URL: https://svnweb.freebsd.org/changeset/base/347390

Log:
  - Merge r338254 from cxgbe(4):
Use fcmpset instead of cmpset when appropriate.
  - Revert r277226 of cxgbe(4), obsolete since r334320.

Modified:
  head/sys/net/mp_ring.c

Modified: head/sys/net/mp_ring.c
==
--- head/sys/net/mp_ring.c  Thu May  9 11:04:10 2019(r347389)
+++ head/sys/net/mp_ring.c  Thu May  9 11:34:46 2019(r347390)
@@ -36,12 +36,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
-#if defined(__i386__)
-#define atomic_cmpset_acq_64 atomic_cmpset_64
-#define atomic_cmpset_rel_64 atomic_cmpset_64
-#endif
-
 #include 
 
 union ring_state {
@@ -195,11 +189,12 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st
n = r->drain(r, cidx, pidx);
if (n == 0) {
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = STALLED;
-   } while (atomic_cmpset_64(>state, os.state,
+   } while (atomic_fcmpset_64(>state, ,
ns.state) == 0);
critical_exit();
if (prev != STALLED)
@@ -222,11 +217,13 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_st
if (cidx != pidx && pending < 64 && total < budget)
continue;
critical_enter();
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.cidx = cidx;
ns.flags = state_to_flags(ns, total >= budget);
-   } while (atomic_cmpset_acq_64(>state, os.state, ns.state) == 
0);
+   } while (atomic_fcmpset_acq_64(>state, ,
+   ns.state) == 0);
critical_exit();
 
if (ns.flags == ABDICATED)
@@ -379,10 +376,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
if (abdicate) {
if (os.flags == IDLE)
ns.flags = ABDICATED;
-   }
-   else {
+   } else
ns.flags = BUSY;
-   }
r->state = ns.state;
counter_u64_add(r->enqueues, n);
 
@@ -398,7 +393,6 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
mtx_unlock(>lock);
return (0);
 }
-
 #else
 int
 ifmp_ring_enqueue(struct ifmp_ring *r, void **items, int n, int budget, int 
abdicate)
@@ -414,8 +408,8 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
 * Reserve room for the new items.  Our reservation, if successful, is
 * from 'pidx_start' to 'pidx_stop'.
 */
+   os.state = r->state;
for (;;) {
-   os.state = r->state;
if (n >= space_available(r, os)) {
counter_u64_add(r->drops, n);
MPASS(os.flags != IDLE);
@@ -426,7 +420,7 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
ns.state = os.state;
ns.pidx_head = increment_idx(r, os.pidx_head, n);
critical_enter();
-   if (atomic_cmpset_64(>state, os.state, ns.state))
+   if (atomic_fcmpset_64(>state, , ns.state))
break;
critical_exit();
cpu_spinwait();
@@ -456,17 +450,16 @@ ifmp_ring_enqueue(struct ifmp_ring *r, void **items, i
 * Update the ring's pidx_tail.  The release style atomic guarantees
 * that the items are visible to any thread that sees the updated pidx.
 */
+   os.state = r->state;
do {
-   os.state = ns.state = r->state;
+   ns.state = os.state;
ns.pidx_tail = pidx_stop;
if (abdicate) {
if (os.flags == IDLE)
ns.flags = ABDICATED;
-   }
-   else {
+   } else
ns.flags = BUSY;
-   }
-   } while (atomic_cmpset_rel_64(>state, os.state, ns.state) == 0);
+   } while (atomic_fcmpset_rel_64(>state, , ns.state) == 0);
critical_exit();
counter_u64_add(r->enqueues, n);
 
___
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: r347221 - head/sys/net

2019-05-08 Thread Marius Strobl
On Tue, May 07, 2019 at 08:38:57PM -0700, Conrad Meyer wrote:
> Hi Marius,
> 
> This change seems to break LINT-NOIP tinderbox builds; one reference
> to tcp_lro_free() is covered by #if defined(INET) || defined(INET6),
> but the one added in iflib_rx_structures_free() is not.

Ah, thanks for the hint!

Marius

___
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: r347245 - head/sys/net

2019-05-08 Thread Marius Strobl
Author: marius
Date: Wed May  8 09:03:43 2019
New Revision: 347245
URL: https://svnweb.freebsd.org/changeset/base/347245

Log:
  Allow to build without INET and INET6 again after r347221.
  
  Submitted by: cam

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed May  8 08:43:15 2019(r347244)
+++ head/sys/net/iflib.cWed May  8 09:03:43 2019(r347245)
@@ -5694,8 +5694,10 @@ iflib_rx_structures_free(if_ctx_t ctx)
 
for (i = 0; i < ctx->ifc_softc_ctx.isc_nrxqsets; i++, rxq++) {
iflib_rx_sds_free(rxq);
+#if defined(INET6) || defined(INET)
if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO)
tcp_lro_free(>ifr_lc);
+#endif
}
free(ctx->ifc_rxqs, M_IFLIB);
ctx->ifc_rxqs = 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: r347222 - head/sys/dev/e1000

2019-05-07 Thread Marius Strobl
Author: marius
Date: Tue May  7 08:31:54 2019
New Revision: 347222
URL: https://svnweb.freebsd.org/changeset/base/347222

Log:
  o Avoid determining the MAC class (LEM/EM or IGB) - possibly even multiple
times - on every interrupt by using an own set of device methods for the
IGB class. This translates to introducing igb_if_intr_{disable,enable}()
and igb_if_{rx,tx}_queue_intr_enable() with that IGB-specific code moved
out of their EM counterparts and otherwise continuing to use the EM IFDI
methods also for IGB.
Note that igb_if_intr_{disable,enable}() also issue E1000_WRITE_FLUSH as
lost with the conversion of igb(4) to iflib(4).
Also note, that the em_if_{disable,enable}_intr() methods are renamed to
em_if_intr_{disable,enable}() for consistency with the names used in the
interface declaration.
  o In em_intr():
- Don't bother to bail out if the interrupt type is "legacy", i. e. INTx
  or MSI, as iflib(4) doesn't use ift_legacy_intr methods for MSI-X. All
  other iflib(4)-based drivers avoid this check, too.
- Given that only the MSI-X interrupts have one-shot behavior (by taking
  advantage of the EIAC register), explicitly disable interrupts. Hence,
  em_intr() now matches what {em,igb}_irq_fast() previously did (in case
  of igb(4) supposedly also to work around MSI message reordering errata
  on certain systems).
  o In em_if_intr_disable():
- Clear the EIAC register unconditionally for 82574 and not just in case
  of MSI-X, matching em_if_intr_enable() and bringing back the last hunk
  of r206437 lost with the iflib(4) conversion.
- Write to EM_EIAC for clearing said register instead of to the IGB-only
  E1000_EIAC used ever since the iflib(4) conversion.
  
  Reviewed by:  shurd
  Differential Revision:https://reviews.freebsd.org/D20176

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Tue May  7 08:28:35 2019(r347221)
+++ head/sys/dev/e1000/if_em.c  Tue May  7 08:31:54 2019(r347222)
@@ -261,10 +261,14 @@ static intem_setup_msix(if_ctx_t ctx);
 static voidem_initialize_transmit_unit(if_ctx_t ctx);
 static voidem_initialize_receive_unit(if_ctx_t ctx);
 
-static voidem_if_enable_intr(if_ctx_t ctx);
-static voidem_if_disable_intr(if_ctx_t ctx);
+static voidem_if_intr_enable(if_ctx_t ctx);
+static voidem_if_intr_disable(if_ctx_t ctx);
+static voidigb_if_intr_enable(if_ctx_t ctx);
+static voidigb_if_intr_disable(if_ctx_t ctx);
 static int em_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid);
 static int em_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid);
+static int igb_if_rx_queue_intr_enable(if_ctx_t ctx, uint16_t rxqid);
+static int igb_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqid);
 static voidem_if_multi_set(if_ctx_t ctx);
 static voidem_if_update_admin_status(if_ctx_t ctx);
 static voidem_if_debug(if_ctx_t ctx);
@@ -375,8 +379,8 @@ static device_method_t em_if_methods[] = {
DEVMETHOD(ifdi_init, em_if_init),
DEVMETHOD(ifdi_stop, em_if_stop),
DEVMETHOD(ifdi_msix_intr_assign, em_if_msix_intr_assign),
-   DEVMETHOD(ifdi_intr_enable, em_if_enable_intr),
-   DEVMETHOD(ifdi_intr_disable, em_if_disable_intr),
+   DEVMETHOD(ifdi_intr_enable, em_if_intr_enable),
+   DEVMETHOD(ifdi_intr_disable, em_if_intr_disable),
DEVMETHOD(ifdi_tx_queues_alloc, em_if_tx_queues_alloc),
DEVMETHOD(ifdi_rx_queues_alloc, em_if_rx_queues_alloc),
DEVMETHOD(ifdi_queues_free, em_if_queues_free),
@@ -398,14 +402,47 @@ static device_method_t em_if_methods[] = {
DEVMETHOD_END
 };
 
-/*
- * note that if (adapter->msix_mem) is replaced by:
- * if (adapter->intr_type == IFLIB_INTR_MSIX)
- */
 static driver_t em_if_driver = {
"em_if", em_if_methods, sizeof(struct adapter)
 };
 
+static device_method_t igb_if_methods[] = {
+   DEVMETHOD(ifdi_attach_pre, em_if_attach_pre),
+   DEVMETHOD(ifdi_attach_post, em_if_attach_post),
+   DEVMETHOD(ifdi_detach, em_if_detach),
+   DEVMETHOD(ifdi_shutdown, em_if_shutdown),
+   DEVMETHOD(ifdi_suspend, em_if_suspend),
+   DEVMETHOD(ifdi_resume, em_if_resume),
+   DEVMETHOD(ifdi_init, em_if_init),
+   DEVMETHOD(ifdi_stop, em_if_stop),
+   DEVMETHOD(ifdi_msix_intr_assign, em_if_msix_intr_assign),
+   DEVMETHOD(ifdi_intr_enable, igb_if_intr_enable),
+   DEVMETHOD(ifdi_intr_disable, igb_if_intr_disable),
+   DEVMETHOD(ifdi_tx_queues_alloc, em_if_tx_queues_alloc),
+   DEVMETHOD(ifdi_rx_queues_alloc, em_if_rx_queues_alloc),
+   DEVMETHOD(ifdi_queues_free, em_if_queues_free),
+   DEVMETHOD(ifdi_update_admin_status, em_if_update_admin_status),
+   DEVMETHOD(ifdi_multi_set, em_if_multi_set),
+   DEVMETHOD(ifdi_media_status, 

svn commit: r347221 - head/sys/net

2019-05-07 Thread Marius Strobl
Author: marius
Date: Tue May  7 08:28:35 2019
New Revision: 347221
URL: https://svnweb.freebsd.org/changeset/base/347221

Log:
  o Use iflib_fast_intr_rxtx() also for "legacy" interrupts, i. e. INTx and
MSI. Unlike as with iflib_fast_intr_ctx(), the former will also enqueue
_task_fn_tx() in addition to _task_fn_rx() if appropriate, bringing TCP
TX throughput of EM-class devices on par with the MSI-X case and, thus,
close to wirespeed/pre-iflib(4) times again. [1]
Note that independently of the interrupt type, the UDP performance with
these MACs still is abysmal and nowhere near to where it was before the
conversion of em(4) to iflib(4).
  o In iflib_init_locked(), announce which free list failed to set up.
  o In _task_fn_tx() when running netmap(4), issue ifdi_intr_enable instead
of the ifdi_tx_queue_intr_enable method in case of a "legacy" interrupt
as the latter is valid with MSI-X only.
  o Instead of adding the missing - and apparently convoluted enough that a
DBG_COUNTER_INC was put into a wrong spot in _task_fn_rx() - checks for
ifdi_{r,t}x_queue_intr_enable being available in the MSI-X case also to
iflib_fast_intr_rxtx(), factor these out to iflib_device_register() and
make the checks fail gracefully rather than panic. This avoids invoking
the checks at runtime over and over again in iflib_fast_intr_rxtx() and
_task_fn_{r,t}x() - even if it's just in case of INVARIANTS - and makes
these functions more readable.
  o In iflib_rx_structures_setup(), only initialize LRO resources if device
and driver have LRO capability in order to not waste memory. Also, free
the LRO resources again if setting them up fails for one of the queues.
However, don't bother invoking iflib_rx_sds_free() in that case because
iflib_rx_structures_setup() doesn't call iflib_rxsd_alloc() either (and
iflib_{device,pseudo}_register() will issue iflib_rx_sds_free() in case
of failure via iflib_rx_structures_free(), but there definitely is some
asymmetry left to be fixed, though).
  o Similarly, free LRO resources again in iflib_rx_structures_free().
  o In iflib_irq_set_affinity(), handle get_core_offset() errors gracefully
instead of panicing (but only in case of INVARIANTS). This is a follow-
up to r344132, as such driver bugs shouldn't be fatal.
  o Likewise, handle unknown iflib_intr_type_t in iflib_irq_alloc_generic()
gracefully, too.
  o Bring yet more sanity to iflib_msix_init():
- If the device doesn't provide enough MSI-X vectors or not all vectors
  can be allocate so the expected number of queues in addition to admin
  interrupts can't be supported, try MSI next (and then INTx) as proper
  MSI-X vector distribution can't be assured in such cases. In essence,
  this change brings r254008 forward to iflib(4). Also, this is the fix
  alluded to in the commit message of r343934.
- If the MSI-X allocation has failed, don't prematurely announce MSI is
  going to be used as the latter in fact may not be available either.
- When falling back to MSI, only release the MSI-X table resource again
  if it was allocated in iflib_msix_init(), i. e. isn't supplied by the
  driver, in the first place.
  o In mp_ndesc_handler(), handle unknown type arguments gracefully, too.
  
  PR:   235031 (likely) [1]
  Reviewed by:  shurd
  Differential Revision:https://reviews.freebsd.org/D20175

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cTue May  7 08:14:30 2019(r347220)
+++ head/sys/net/iflib.cTue May  7 08:28:35 2019(r347221)
@@ -1461,6 +1461,7 @@ iflib_fast_intr_rxtx(void *arg)
void *sc;
int i, cidx, result;
qidx_t txqid;
+   bool intr_enable, intr_legacy;
 
if (!iflib_started)
return (FILTER_STRAY);
@@ -1474,6 +1475,8 @@ iflib_fast_intr_rxtx(void *arg)
 
ctx = rxq->ifr_ctx;
sc = ctx->ifc_softc;
+   intr_enable = false;
+   intr_legacy = !!(ctx->ifc_flags & IFC_LEGACY);
MPASS(rxq->ifr_ntxqirq);
for (i = 0; i < rxq->ifr_ntxqirq; i++) {
txqid = rxq->ifr_txqid[i];
@@ -1481,7 +1484,10 @@ iflib_fast_intr_rxtx(void *arg)
bus_dmamap_sync(txq->ift_ifdi->idi_tag, txq->ift_ifdi->idi_map,
BUS_DMASYNC_POSTREAD);
if (!ctx->isc_txd_credits_update(sc, txqid, false)) {
-   IFDI_TX_QUEUE_INTR_ENABLE(ctx, txqid);
+   if (intr_legacy)
+   intr_enable = true;
+   else
+   IFDI_TX_QUEUE_INTR_ENABLE(ctx, txqid);
continue;
}
GROUPTASK_ENQUEUE(>ift_task);
@@ -1493,9 +1499,14 @@ iflib_fast_intr_rxtx(void *arg)
if 

svn commit: r347211 - head/sys/net

2019-05-06 Thread Marius Strobl
Author: marius
Date: Mon May  6 20:56:41 2019
New Revision: 347211
URL: https://svnweb.freebsd.org/changeset/base/347211

Log:
  - Remove the unused ifc_link_irq and ifc_mtx_name members of struct iflib_ctx.
  - Remove the only ever written to ift_db_mtx_name member of struct iflib_txq.
  - Remove the unused or only ever written to ifr_size, ifr_cq_pidx, ifr_cq_gen
and ifr_lro_enabled members of struct iflib_rxq.
  - Consistently spell DMA, RX and TX uppercase in comments, messages etc.
instead of mixing with some lowercase variants.
  - Consistently use if_t instead of a mix of if_t and struct ifnet pointers.
  - Bring the function comments of _iflib_fl_refill(), iflib_rx_sds_free() and
iflib_fl_setup() in line with reality.
  - Judging problem reports, people are wondering what on earth messages like:
"TX(0) desc avail = 1024, pidx = 0"
are trying to indicate. Thus, extend this string to be more like that of
non-iflib(4) Ethernet MAC drivers, notifying about a watchdog timeout due
to which the interface will be reset.
  - Take advantage of the M_HAS_VLANTAG macro.
  - Use false/true rather than FALSE/TRUE for variables of type bool.
  - Use FALLTHROUGH as advocated by style(9).

Modified:
  head/sys/net/iflib.c
  head/sys/net/iflib.h
  head/sys/net/iflib_clone.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cMon May  6 20:48:27 2019(r347210)
+++ head/sys/net/iflib.cMon May  6 20:56:41 2019(r347211)
@@ -172,7 +172,6 @@ struct iflib_ctx {
uint32_t ifc_rx_mbuf_sz;
 
int ifc_link_state;
-   int ifc_link_irq;
int ifc_watchdog_events;
struct cdev *ifc_led_dev;
struct resource *ifc_msix_mem;
@@ -210,10 +209,8 @@ struct iflib_ctx {
eventhandler_tag ifc_vlan_attach_event;
eventhandler_tag ifc_vlan_detach_event;
struct ether_addr ifc_mac;
-   char ifc_mtx_name[16];
 };
 
-
 void *
 iflib_get_softc(if_ctx_t ctx)
 {
@@ -289,7 +286,6 @@ typedef struct iflib_sw_tx_desc_array {
struct mbuf**ifsd_m;   /* pkthdr mbufs */
 } if_txsd_vec_t;
 
-
 /* magic number that should be high enough for any hardware */
 #define IFLIB_MAX_TX_SEGS  128
 #define IFLIB_RX_COPY_THRESH   128
@@ -308,10 +304,10 @@ typedef struct iflib_sw_tx_desc_array {
 
 #define IFLIB_RESTART_BUDGET   8
 
-
 #define CSUM_OFFLOAD   (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
 CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
 CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP)
+
 struct iflib_txq {
qidx_t  ift_in_use;
qidx_t  ift_cidx;
@@ -361,7 +357,6 @@ struct iflib_txq {
iflib_dma_info_tift_ifdi;
 #define MTX_NAME_LEN 16
charift_mtx_name[MTX_NAME_LEN];
-   charift_db_mtx_name[MTX_NAME_LEN];
bus_dma_segment_t   ift_segs[IFLIB_MAX_TX_SEGS]  
__aligned(CACHE_LINE_SIZE);
 #ifdef IFLIB_DIAGNOSTICS
uint64_t ift_cpu_exec_count[256];
@@ -424,25 +419,20 @@ get_inuse(int size, qidx_t cidx, qidx_t pidx, uint8_t 
((head) >= (tail) ? (head) - (tail) : (wrap) - (tail) + (head))
 
 struct iflib_rxq {
-   /* If there is a separate completion queue -
-* these are the cq cidx and pidx. Otherwise
-* these are unused.
-*/
-   qidx_t  ifr_size;
-   qidx_t  ifr_cq_cidx;
-   qidx_t  ifr_cq_pidx;
-   uint8_t ifr_cq_gen;
-   uint8_t ifr_fl_offset;
-
if_ctx_tifr_ctx;
iflib_fl_t  ifr_fl;
uint64_tifr_rx_irq;
struct pfil_head*pfil;
+   /*
+* If there is a separate completion queue (IFLIB_HAS_RXCQ), this is
+* the command queue consumer index.  Otherwise it's unused.
+*/
+   qidx_t  ifr_cq_cidx;
uint16_tifr_id;
-   uint8_t ifr_lro_enabled;
uint8_t ifr_nfl;
uint8_t ifr_ntxqirq;
uint8_t ifr_txqid[IFLIB_MAX_TX_SHARED_INTR];
+   uint8_t ifr_fl_offset;
struct lro_ctrl ifr_lc;
struct grouptaskifr_task;
struct iflib_filter_info ifr_filter_info;
@@ -540,14 +530,11 @@ rxd_info_zero(if_rxd_info_t ri)
 #define CTX_UNLOCK(ctx) sx_xunlock(&(ctx)->ifc_ctx_sx)
 #define CTX_LOCK_DESTROY(ctx) sx_destroy(&(ctx)->ifc_ctx_sx)
 
-
 #define STATE_LOCK_INIT(_sc, _name)  mtx_init(&(_sc)->ifc_state_mtx, _name, 
"iflib state lock", MTX_DEF)
 #define STATE_LOCK(ctx) mtx_lock(&(ctx)->ifc_state_mtx)
 #define STATE_UNLOCK(ctx) mtx_unlock(&(ctx)->ifc_state_mtx)
 #define STATE_LOCK_DESTROY(ctx) mtx_destroy(&(ctx)->ifc_state_mtx)
 
-
-
 #define CALLOUT_LOCK(txq)  mtx_lock(>ift_mtx)
 #define CALLOUT_UNLOCK(txq)mtx_unlock(>ift_mtx)
 
@@ -610,15 +597,15 @@ 

svn commit: r344069 - head/sys/modules/hwpmc

2019-02-12 Thread Marius Strobl
Author: marius
Date: Tue Feb 12 23:39:18 2019
New Revision: 344069
URL: https://svnweb.freebsd.org/changeset/base/344069

Log:
  With r344062 in place, hwpmc_mod.c generally needs bus_if.h and
  device_if.h.

Modified:
  head/sys/modules/hwpmc/Makefile

Modified: head/sys/modules/hwpmc/Makefile
==
--- head/sys/modules/hwpmc/Makefile Tue Feb 12 23:37:20 2019
(r344068)
+++ head/sys/modules/hwpmc/Makefile Tue Feb 12 23:39:18 2019
(r344069)
@@ -6,7 +6,8 @@
 
 KMOD=  hwpmc
 
-SRCS=  hwpmc_mod.c hwpmc_logging.c hwpmc_soft.c vnode_if.h
+SRCS=  bus_if.h device_if.h hwpmc_mod.c hwpmc_logging.c hwpmc_soft.c
+SRCS+= vnode_if.h
 
 .if ${MACHINE_CPUARCH} == "aarch64"
 SRCS+=  hwpmc_arm64.c hwpmc_arm64_md.c
@@ -15,7 +16,6 @@ SRCS+=  hwpmc_arm64.c hwpmc_arm64_md.c
 .if ${MACHINE_CPUARCH} == "amd64"
 SRCS+= hwpmc_amd.c hwpmc_core.c hwpmc_intel.c hwpmc_tsc.c
 SRCS+= hwpmc_x86.c hwpmc_uncore.c
-SRCS+= device_if.h bus_if.h
 .endif
 
 .if ${MACHINE_CPUARCH} == "arm"
@@ -25,7 +25,6 @@ SRCS+=hwpmc_arm.c
 .if ${MACHINE_CPUARCH} == "i386"
 SRCS+= hwpmc_amd.c hwpmc_core.c hwpmc_intel.c
 SRCS+= hwpmc_tsc.c hwpmc_x86.c hwpmc_uncore.c
-SRCS+= device_if.h bus_if.h
 .endif
 
 .if ${MACHINE_CPUARCH} == "powerpc"
___
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: r344064 - head/sys/net

2019-02-12 Thread Marius Strobl
Author: marius
Date: Tue Feb 12 22:33:17 2019
New Revision: 344064
URL: https://svnweb.freebsd.org/changeset/base/344064

Log:
  Fix the build with ALTQ after r344060.

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cTue Feb 12 22:29:41 2019(r344063)
+++ head/sys/net/iflib.cTue Feb 12 22:33:17 2019(r344064)
@@ -3658,6 +3658,9 @@ _task_fn_tx(void *context)
 {
iflib_txq_t txq = context;
if_ctx_t ctx = txq->ift_ctx;
+#if defined(ALTQ) || defined(DEV_NETMAP)
+   if_t ifp = ctx->ifc_ifp;
+#endif
int abdicate = ctx->ifc_sysctl_tx_abdicate;
 
 #ifdef IFLIB_DIAGNOSTICS
@@ -3666,11 +3669,11 @@ _task_fn_tx(void *context)
if (!(if_getdrvflags(ctx->ifc_ifp) & IFF_DRV_RUNNING))
return;
 #ifdef DEV_NETMAP
-   if (if_getcapenable(ctx->ifc_ifp) & IFCAP_NETMAP) {
+   if (if_getcapenable(ifp) & IFCAP_NETMAP) {
bus_dmamap_sync(txq->ift_ifdi->idi_tag, txq->ift_ifdi->idi_map,
BUS_DMASYNC_POSTREAD);
if (ctx->isc_txd_credits_update(ctx->ifc_softc, txq->ift_id, 
false))
-   netmap_tx_irq(ctx->ifc_ifp, txq->ift_id);
+   netmap_tx_irq(ifp, txq->ift_id);
IFDI_TX_QUEUE_INTR_ENABLE(ctx, txq->ift_id);
return;
}
___
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: r344062 - in head/sys: compat/linuxkpi/common/src kern net sys

2019-02-12 Thread Marius Strobl
Author: marius
Date: Tue Feb 12 21:23:59 2019
New Revision: 344062
URL: https://svnweb.freebsd.org/changeset/base/344062

Log:
  Make taskqgroup_attach{,_cpu}(9) work across architectures
  
  So far, intr_{g,s}etaffinity(9) take a single int for identifying
  a device interrupt. This approach doesn't work on all architectures
  supported, as a single int isn't sufficient to globally specify a
  device interrupt. In particular, with multiple interrupt controllers
  in one system as found on e. g. arm and arm64 machines, an interrupt
  number as returned by rman_get_start(9) may be only unique relative
  to the bus and, thus, interrupt controller, a certain device hangs
  off from.
  In turn, this makes taskqgroup_attach{,_cpu}(9) and - internal to
  the gtaskqueue implementation - taskqgroup_attach_deferred{,_cpu}()
  not work across architectures. Yet in turn, iflib(4) as gtaskqueue
  consumer so far doesn't fit architectures where interrupt numbers
  aren't globally unique.
  However, at least for intr_setaffinity(..., CPU_WHICH_IRQ, ...) as
  employed by the gtaskqueue implementation to bind an interrupt to a
  particular CPU, using bus_bind_intr(9) instead is equivalent from
  a functional point of view, with bus_bind_intr(9) taking the device
  and interrupt resource arguments required for uniquely specifying a
  device interrupt.
  Thus, change the gtaskqueue implementation to employ bus_bind_intr(9)
  instead and intr_{g,s}etaffinity(9) to take the device and interrupt
  resource arguments required respectively. This change also moves
  struct grouptask from  to  and wraps
  struct gtask along with the gtask_fn_t typedef into #ifdef _KERNEL
  as userland likes to include  or indirectly drags it
  in - for better or worse also with _KERNEL defined -, which with
  device_t and struct resource dependencies otherwise is no longer
  as easily possible now.
  The userland inclusion problem probably can be improved a bit by
  introducing a _WANT_TASK (as well as a _WANT_MOUNT) akin to the
  existing _WANT_PRISON etc., which is orthogonal to this change,
  though, and likely needs an exp-run.
  
  While at it:
  - Change the gt_cpu member in the grouptask structure to be of type
int as used elswhere for specifying CPUs (an int16_t may be too
narrow sooner or later),
  - move the gtaskqueue_enqueue_fn typedef from  to
the gtaskqueue implementation as it's only used and needed there,
  - change the GTASK_INIT macro to use "gtask" rather than "task" as
argument given that it actually operates on a struct gtask rather
than a struct task, and
  - let subr_gtaskqueue.c consistently use __func__ to print functions
names.
  
  Reported by:  mmel
  Reviewed by:  mmel
  Differential Revision:https://reviews.freebsd.org/D19139

Modified:
  head/sys/compat/linuxkpi/common/src/linux_tasklet.c
  head/sys/kern/subr_epoch.c
  head/sys/kern/subr_gtaskqueue.c
  head/sys/net/iflib.c
  head/sys/sys/_task.h
  head/sys/sys/gtaskqueue.h
  head/sys/sys/param.h

Modified: head/sys/compat/linuxkpi/common/src/linux_tasklet.c
==
--- head/sys/compat/linuxkpi/common/src/linux_tasklet.c Tue Feb 12 21:22:57 
2019(r344061)
+++ head/sys/compat/linuxkpi/common/src/linux_tasklet.c Tue Feb 12 21:23:59 
2019(r344062)
@@ -109,7 +109,7 @@ tasklet_subsystem_init(void *arg __unused)
GROUPTASK_INIT(>gtask, 0, tasklet_handler, tw);
snprintf(buf, sizeof(buf), "softirq%d", i);
taskqgroup_attach_cpu(qgroup_softirq, >gtask,
-   "tasklet", i, -1, buf);
+   "tasklet", i, NULL, NULL, buf);
}
 }
 SYSINIT(linux_tasklet, SI_SUB_TASKQ, SI_ORDER_THIRD, tasklet_subsystem_init, 
NULL);

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Tue Feb 12 21:22:57 2019(r344061)
+++ head/sys/kern/subr_epoch.c  Tue Feb 12 21:23:59 2019(r344062)
@@ -147,7 +147,7 @@ epoch_init(void *arg __unused)
GROUPTASK_INIT(DPCPU_ID_PTR(cpu, epoch_cb_task), 0,
epoch_call_task, NULL);
taskqgroup_attach_cpu(qgroup_softirq,
-   DPCPU_ID_PTR(cpu, epoch_cb_task), NULL, cpu, -1,
+   DPCPU_ID_PTR(cpu, epoch_cb_task), NULL, cpu, NULL, NULL,
"epoch call task");
}
inited = 1;

Modified: head/sys/kern/subr_gtaskqueue.c
==
--- head/sys/kern/subr_gtaskqueue.c Tue Feb 12 21:22:57 2019
(r344061)
+++ head/sys/kern/subr_gtaskqueue.c Tue Feb 12 21:23:59 2019
(r344062)
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -64,6 +63,8 @@ struct gtaskqueue_busy {
 
 static struct gtask * const 

svn commit: r344060 - head/sys/net

2019-02-12 Thread Marius Strobl
Author: marius
Date: Tue Feb 12 21:08:44 2019
New Revision: 344060
URL: https://svnweb.freebsd.org/changeset/base/344060

Log:
  Further correct and optimize the bus_dma(9) usage of iflib(4):
  o Correct the obvious bugs in the netmap(4) parts:
- No longer check for the existence of DMA maps as bus_dma(9)
  is used unconditionally in iflib(4) since r341095.
- Supply the correct DMA tag and map pairs to bus_dma(9)
  functions (see also the commit message of r343753).
- In iflib_netmap_timer_adjust(), add synchronization of the
  TX descriptors before calling the ift_txd_credits_update
  method as the latter evaluates the TX descriptors possibly
  updated by the MAC.
- In _task_fn_tx(), wrap the netmap(4)-specific bits in
  #ifdef DEV_NETMAP just as done in _task_fn_admin() and
  _task_fn_rx() respectively.
  o In iflib_fast_intr_rxtx(), synchronize the TX rather than
the RX descriptors before calling the ift_txd_credits_update
method (see also above).
  o There's no need to synchronize an RX buffer that is going to
be recycled in iflib_rxd_pkt_get(), yet; it's sufficient to
do that as late as passing RX buffers to the MAC via the
ift_rxd_refill method. Hence, combine that synchronization
with the synchronization of new buffers into a common spot
in _iflib_fl_refill().
  o There's no need to synchronize the RX descriptors of a free
list in preparation of the MAC updating their statuses with
every invocation of rxd_frag_to_sd(); it's enough to do this
once before handing control over to the MAC, i. e. before
calling ift_rxd_flush method in _iflib_fl_refill(), which
already performs the necessary synchronization.
  o Given that the ift_rxd_available method evaluates the RX
descriptors which possibly have been altered by the MAC,
synchronize as appropriate beforehand. Most notably this
is now done in iflib_rxd_avail(), which in turn means that
we don't need to issue the same synchronization yet again
before calling the ift_rxd_pkt_get method in iflib_rxeof().
  o In iflib_txd_db_check(), synchronize the TX descriptors
before handing them over to the MAC for transmission via
the ift_txd_flush method.
  o In iflib_encap(), move the TX buffer synchronization after
the invocation of the ift_txd_encap() method. If the MAC
driver fails to encapsulate the packet and we retry with
a defragmented mbuf chain or finally fail, the cycles for
TX buffer synchronization have been wasted. Synchronizing
afterwards matches what non-iflib(4) drivers typically do
and is sufficient as the MAC will not actually start with
the transmission before - in this case - the ift_txd_flush
method is called.
Moreover, for the latter reason the synchronization of the
TX descriptors in iflib_encap() can go as it's enough to
synchronize them before passing control over to the MAC by
issuing the ift_txd_flush() method (see above).
  o In iflib_txq_can_drain(), only synchronize TX descriptors
if the ift_txd_credits_update method accessing these is
actually called.
  
  Differential Revision:https://reviews.freebsd.org/D19081

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cTue Feb 12 21:06:07 2019(r344059)
+++ head/sys/net/iflib.cTue Feb 12 21:08:44 2019(r344060)
@@ -845,11 +845,13 @@ netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring 
return netmap_ring_reinit(kring);
 
fl->ifl_vm_addrs[tmp_pidx] = addr;
-   if (__predict_false(init) && map) {
-   netmap_load_map(na, fl->ifl_ifdi->idi_tag, 
map[nic_i], addr);
-   } else if (map && (slot->flags & NS_BUF_CHANGED)) {
+   if (__predict_false(init)) {
+   netmap_load_map(na, fl->ifl_buf_tag,
+   map[nic_i], addr);
+   } else if (slot->flags & NS_BUF_CHANGED) {
/* buffer has changed, reload map */
-   netmap_reload_map(na, fl->ifl_ifdi->idi_tag, 
map[nic_i], addr);
+   netmap_reload_map(na, fl->ifl_buf_tag,
+   map[nic_i], addr);
}
slot->flags &= ~NS_BUF_CHANGED;
 
@@ -861,13 +863,9 @@ netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring 
iru.iru_pidx = refill_pidx;
iru.iru_count = tmp_pidx+1;
ctx->isc_rxd_refill(ctx->ifc_softc, );
-
refill_pidx = nic_i;
-   if (map == NULL)
-   continue;
-
for (int n = 0; n < 

svn commit: r343979 - head/sys/opencrypto

2019-02-10 Thread Marius Strobl
Author: marius
Date: Sun Feb 10 21:27:03 2019
New Revision: 343979
URL: https://svnweb.freebsd.org/changeset/base/343979

Log:
  As struct cryptop is wrapped in #ifdef _KERNEL, userland doesn't
  need to drag in  either.

Modified:
  head/sys/opencrypto/cryptodev.h

Modified: head/sys/opencrypto/cryptodev.h
==
--- head/sys/opencrypto/cryptodev.h Sun Feb 10 21:22:55 2019
(r343978)
+++ head/sys/opencrypto/cryptodev.h Sun Feb 10 21:27:03 2019
(r343979)
@@ -63,10 +63,10 @@
 #define _CRYPTO_CRYPTO_H_
 
 #include 
-#include 
 
 #ifdef _KERNEL
 #include 
+#include 
 #endif
 
 /* Some initial values */
___
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: r343934 - head/sys/dev/e1000

2019-02-09 Thread Marius Strobl
Author: marius
Date: Sat Feb  9 11:58:40 2019
New Revision: 343934
URL: https://svnweb.freebsd.org/changeset/base/343934

Log:
  - Remove the redundant device disabled hint handling; ever since
r241119 that's performed globally by device_attach(9).
  - As for the EM-class of devices, em(4) supports multiple queues
and MSI-X respectively only with 82574 devices. However, since
the conversion to iflib(4), em(4) relies on the interrupt type
fallback mechanism, i. e. MSI-X -> MSI -> INTx, of iflib(4) to
figure out the interrupt type to use for the EM-class (as well
as the IGB-class) of MACs. Moreover, despite the datasheet for
82583V not mentioning any support of MSI-X, there actually are
82583V devices out there that report a varying number of MSI-X
messages as supported. The interrupt type fallback of iflib(4)
is causing two failure modes depending on the actual number of
MSI-X messages supported for such instances of 82583V:
1) With only one MSI-X message supported, none is left for the
   RX/TX queues as that one message gets assigned to the admin
   interrupt. Worse, later on - which will be addressed with a
   separate fix - iflib(4) interprets that one messages as MSI
   or INTx to be set up, but fails to actually do so as it has
   previously called pci_alloc_msix(9). [1, 2]
2) With more message supported, their distribution is okay but
   then em_if_msix_intr_assign() doesn't work for 82583V, with
   the interface being left in a non-working state, too. [3]
Thus, let em_if_attach_pre() indicate to iflib(4) to try MSI-X
with 82574 only, and at most MSI for the remainder of EM-class
devices.
While at it, remove "try_second_bar" as it's polarity inverted
and not actually needed.
  - Remove code from em_if_timer() that effectively is a NOP since
the conversion to iflib(4) ("trigger" is no longer read).
While at it, let the comment for em_if_timer() reflect reality
after said conversion.
  - Implement an ifdi_watchdog_reset method which only updates the
em(4) "watchdog_events" counter but doesn't perform any reset,
so that the em(4) "watchdog_timeouts" SYSCTL (iflib(4) doesn't
provide a counterpart) reflects reality and these timeouts add
to IFCOUNTER_OERRORS again after the iflib(4) conversion.
  - Remove the "mbuf_defrag_fail" and "tx_dma_fail" SYSCTLS; since
the iflib(4) conversion, associated counters are disconnected,
but iflib(4) provides "mbuf_defrag_failed" and "tx_map_failed"
respectively as equivalents.
  - Move the description preceding lem_smartspeed() to the correct
spot before em_reset() and bring back appropriate comments for
{igb,em}_initialize_rss_mapping() and lem_smartspeed() lost in
the iflib(4) conversion.
  - Adapt some other function descriptions and INIT_DEBUGOUT() use
to match reality after the iflib(4) conversion.
  - Put the debugging message of em_enable_vectors_82574() (missed
in r343578) under bootverbose, too.
  
  PR:   219428 [1], 235246 [2], 235147 [3]
  Reviewed by:  erj (previous version)
  Differential Revision:https://reviews.freebsd.org/D19108

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_em.h

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Sat Feb  9 11:51:59 2019(r343933)
+++ head/sys/dev/e1000/if_em.c  Sat Feb  9 11:58:40 2019(r343934)
@@ -249,6 +249,7 @@ static int  em_if_mtu_set(if_ctx_t ctx, uint32_t mtu);
 static voidem_if_timer(if_ctx_t ctx, uint16_t qid);
 static voidem_if_vlan_register(if_ctx_t ctx, u16 vtag);
 static voidem_if_vlan_unregister(if_ctx_t ctx, u16 vtag);
+static voidem_if_watchdog_reset(if_ctx_t ctx);
 
 static voidem_identify_hardware(if_ctx_t ctx);
 static int em_allocate_pci_resources(if_ctx_t ctx);
@@ -386,6 +387,7 @@ static device_method_t em_if_methods[] = {
DEVMETHOD(ifdi_mtu_set, em_if_mtu_set),
DEVMETHOD(ifdi_promisc_set, em_if_set_promisc),
DEVMETHOD(ifdi_timer, em_if_timer),
+   DEVMETHOD(ifdi_watchdog_reset, em_if_watchdog_reset),
DEVMETHOD(ifdi_vlan_register, em_if_vlan_register),
DEVMETHOD(ifdi_vlan_unregister, em_if_vlan_unregister),
DEVMETHOD(ifdi_get_counter, em_if_get_counter),
@@ -721,7 +723,6 @@ em_set_num_queues(if_ctx_t ctx)
  *
  *  return 0 on success, positive on failure
  */
-
 static int
 em_if_attach_pre(if_ctx_t ctx)
 {
@@ -731,15 +732,10 @@ em_if_attach_pre(if_ctx_t ctx)
struct e1000_hw *hw;
int error = 0;
 
-   INIT_DEBUGOUT("em_if_attach_pre begin");
+   INIT_DEBUGOUT("em_if_attach_pre: begin");
dev = iflib_get_dev(ctx);
adapter = iflib_get_softc(ctx);
 
-   if (resource_disabled("em", device_get_unit(dev))) {
-

Re: svn commit: r343772 - head/sys/dev/netmap

2019-02-07 Thread Marius Strobl
On Tue, Feb 05, 2019 at 12:10:49PM +, Vincenzo Maffione wrote:
> Author: vmaffione
> Date: Tue Feb  5 12:10:48 2019
> New Revision: 343772
> URL: https://svnweb.freebsd.org/changeset/base/343772
> 
> Log:
>   netmap: refactor logging macros and pipes
>   
>   Changelist:
>   - Replace ND, D and RD macros with nm_prdis, nm_prinf, nm_prerr
> and nm_prlim, to avoid possible naming conflicts.
>   - Add netmap_krings_mode_commit() helper function and use that
> to reduce code duplication.
>   - Refactor pipes control code to export some functions that
> can be reused by the veth driver (on Linux) and epair(4).
>   - Add check to reject API requests with version less than 11.
>   - Small code refactoring for the null adapter.

Hello Vincenzo,

this change causes interface attachment output to look somewhat
deformed ("000.000395 [3717] netmap_attach_ext" debug info and
an extra newline):
em0:  port 0xe000-0xe01f mem 
0xf7d0-0xf7d1,0xf7d2-0xf7d23fff irq 17 at device 0.0 on pci3
em0: Using 1024 TX descriptors and 1024 RX descriptors
em0: Using 2 RX queues 2 TX queues
em0: Using MSI-X interrupts with 3 vectors
em0: Ethernet address: 60:a4:4c:24:0b:4c
000.000395 [3717] netmap_attach_ext em0: netmap queues/slots: TX 
2/1024, RX 2/1024

pcib5:  irq 19 at device 28.7 on pci0

Could we please get this part back to match the pre-r343772
output again?

Marius

___
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: r342634 - in head/sys: arm/broadcom/bcm2835 arm/nvidia arm/ti dev/sdhci

2019-02-06 Thread Marius Strobl
On Tue, Feb 05, 2019 at 05:45:06PM -0500, Ed Maste wrote:
> On Sun, 30 Dec 2018 at 18:08, Marius Strobl  wrote:
> >
> > Author: marius
> > Date: Sun Dec 30 23:08:06 2018
> > New Revision: 342634
> > URL: https://svnweb.freebsd.org/changeset/base/342634
> >
> > Log:
> >   o Don't allocate resources for SDMA in sdhci(4) if the controller or the
> ...
> 
> It seems this change introduced a panic on boot on the Jetson TK1
> platform, see PR 235542. Can you please take a look at the PR and
> suggest next steps for debugging?

Done, however, to the best of my knowledge, that panic is due to a
bug in the ARMv6 bus_dma(9) implementation an ARM maintainer needs
to look at.

Marius

___
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: r343753 - head/sys/net

2019-02-04 Thread Marius Strobl
Author: marius
Date: Mon Feb  4 20:46:57 2019
New Revision: 343753
URL: https://svnweb.freebsd.org/changeset/base/343753

Log:
  o As illustrated by e. g. figure 7-14 of the Intel 82599 10 GbE
controller datasheet revision 3.3, in the context of Ethernet
MACs the control data describing the packet buffers typically
are named "descriptors". Each of these descriptors references
one buffer, multiple of which a packet can be composed of.
By contrast, in comments, messages and the names of structure
members, iflib(4) refers to DMA resources employed for RX and
TX buffers (rather than control data) as "desc(riptors)".
This odd naming convention of iflib(4) made reviewing r343085
and identifying wrong and missing bus_dmamap_sync(9) calls in
particular way harder than it already is. This convention may
also explain why the netmap(4) part of iflib(4) pairs the DMA
tags for control data with DMA maps of buffers and vice versa
in calls to bus_dma(9) functions.
Therefore, change iflib(4) to refer to buf(fers) when buffers
and not the usual understanding of descriptors is meant. This
change does not include corrections to the DMA resources used
in the netmap(4) parts. However, it revises error messages to
state which kind of allocation/creation failed. Specifically,
the "Unable to allocate tx_buffer (map) memory" copy & pasted
inappropriately on several occasions was replaced with proper
messages.
  o Enhance some other error messages to indicate which half - RX
or TX - they apply to instead of using identical text in both
cases and generally canonicalize them.
  o Correct the descriptions of iflib_{r,t}xsd_alloc() to reflect
reality; current code doesn't use {r,t}x_buffer structures.
  o In iflib_queues_alloc():
- Remove redundant BUS_DMA_NOWAIT of iflib_dma_alloc() calls,
- change the M_WAITOK from malloc(9) calls into M_NOWAIT. The
  return values are already checked, deferred DMA allocations
  not being an option at this point, BUS_DMA_NOWAIT has to be
  used anyway and prior malloc(9) calls in this function also
  specify M_NOWAIT.
  
  Reviewed by:  shurd
  Differential Revision:https://reviews.freebsd.org/D19067

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cMon Feb  4 20:09:22 2019(r343752)
+++ head/sys/net/iflib.cMon Feb  4 20:46:57 2019(r343753)
@@ -353,8 +353,8 @@ struct iflib_txq {
uint8_t ift_closed;
uint8_t ift_update_freq;
struct iflib_filter_info ift_filter_info;
-   bus_dma_tag_t   ift_desc_tag;
-   bus_dma_tag_t   ift_tso_desc_tag;
+   bus_dma_tag_t   ift_buf_tag;
+   bus_dma_tag_t   ift_tso_buf_tag;
iflib_dma_info_tift_ifdi;
 #define MTX_NAME_LEN 16
charift_mtx_name[MTX_NAME_LEN];
@@ -389,7 +389,7 @@ struct iflib_fl {
iflib_rxsd_array_t  ifl_sds;
iflib_rxq_t ifl_rxq;
uint8_t ifl_id;
-   bus_dma_tag_t   ifl_desc_tag;
+   bus_dma_tag_t   ifl_buf_tag;
iflib_dma_info_tifl_ifdi;
uint64_tifl_bus_addrs[IFLIB_MAX_RX_REFRESH] 
__aligned(CACHE_LINE_SIZE);
caddr_t ifl_vm_addrs[IFLIB_MAX_RX_REFRESH];
@@ -922,10 +922,9 @@ iflib_netmap_txsync(struct netmap_kring *kring, int fl
if_ctx_t ctx = ifp->if_softc;
iflib_txq_t txq = >ifc_txqs[kring->ring_id];
 
-   bus_dmamap_sync(txq->ift_desc_tag, txq->ift_ifdi->idi_map,
+   bus_dmamap_sync(txq->ift_buf_tag, txq->ift_ifdi->idi_map,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
-
/*
 * First part: process new packets to send.
 * nm_i is the current index in the netmap kring,
@@ -992,7 +991,8 @@ iflib_netmap_txsync(struct netmap_kring *kring, int fl
 
if (slot->flags & NS_BUF_CHANGED) {
/* buffer has changed, reload map */
-   netmap_reload_map(na, 
txq->ift_desc_tag, txq->ift_sds.ifsd_map[nic_i], addr);
+   netmap_reload_map(na, txq->ift_buf_tag,
+   txq->ift_sds.ifsd_map[nic_i], addr);
}
/* make sure changes to the buffer are synced */
bus_dmamap_sync(txq->ift_ifdi->idi_tag, 
txq->ift_sds.ifsd_map[nic_i],
@@ -1005,7 +1005,7 @@ iflib_netmap_txsync(struct netmap_kring *kring, int fl
kring->nr_hwcur = nm_i;
 
/* synchronize the NIC ring */
-   bus_dmamap_sync(txq->ift_desc_tag, txq->ift_ifdi->idi_map,
+   bus_dmamap_sync(txq->ift_buf_tag, txq->ift_ifdi->idi_map,

Re: svn commit: r343578 - in head/sys: dev/e1000 dev/ixgbe dev/ixl dev/vmware/vmxnet3 net

2019-01-30 Thread Marius Strobl
On Wed, Jan 30, 2019 at 06:47:44AM -0800, Rodney W. Grimes wrote:
> > Author: marius
> > Date: Wed Jan 30 13:21:26 2019
> > New Revision: 343578
> > URL: https://svnweb.freebsd.org/changeset/base/343578
> > 
> > Log:
> >   - Stop iflib(4) from leaking MSI messages on detachment by calling
> > bus_teardown_intr(9) before pci_release_msi(9).
> >   - Ensure that iflib(4) and associated drivers pass correct RIDs to
> > bus_release_resource(9) by obtaining the RIDs via rman_get_rid(9)
> > on the corresponding resources instead of using the RIDs initially
> > passed to bus_alloc_resource_any(9) as the latter function may
> > change those RIDs. Solely em(4) for the ioport resource (but not
> > others) and bnxt(4) were using the correct RIDs by caching the ones
> > returned by bus_alloc_resource_any(9).
> >   - Change the logic of iflib_msix_init() around to only map the MSI-X
> > BAR if MSI-X is actually supported, i. e. pci_msix_count(9) returns
> > > 0. Otherwise the "Unable to map MSIX table " message triggers for
> > devices that simply don't support MSI-X and the user may think that
> > something is wrong while in fact everything works as expected.
> >   - Put some (mostly redundant) debug messages emitted by iflib(4)
> > and em(4) during attachment under bootverbose. The non-verbose
> > output of em(4) seen during attachment now is close to the one
> > prior to the conversion to iflib(4).
> >   - Replace various variants of spelling "MSI-X" (several in messages)
> > with "MSI-X" as used in the PCI specifications.
> >   - Remove some trailing whitespace from messages emitted by iflib(4)
> > and change them to consistently start with uppercase.
> >   - Remove some obsolete comments about releasing interrupts from
> > drivers and correct a few others.
> >   
> >   Reviewed by:  erj, Jacob Keller, shurd
> >   Differential Revision:https://reviews.freebsd.org/D18980
> 
> MFC intentions?
> I am sure you mean to, just not sure how soon.

Probably after the 3 days minimum so we finally can start with trying
to wrap up an iflib EN for 12.0.

> Does this effect any of the PR's open against em(4)/iflib(9)?

The above revision addresses the "Unable to map MSIX table " part
of PR 234766, but not its core problem of the interface wedging.
The previous switch to using bus_dma(9) and associated fixes may
or may not solve the remainder of PR 234766 and some of the other
PRs filed against em(4) in 12.0.

PR 228827 is about device attachment with iflib(4) but misses
details. Several problems with that attachment (apart from the
above, e. g. also interrupt method fallback) have been fixed
since that PR was filed, though.

Marius

___
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: r343578 - in head/sys: dev/e1000 dev/ixgbe dev/ixl dev/vmware/vmxnet3 net

2019-01-30 Thread Marius Strobl
Author: marius
Date: Wed Jan 30 13:21:26 2019
New Revision: 343578
URL: https://svnweb.freebsd.org/changeset/base/343578

Log:
  - Stop iflib(4) from leaking MSI messages on detachment by calling
bus_teardown_intr(9) before pci_release_msi(9).
  - Ensure that iflib(4) and associated drivers pass correct RIDs to
bus_release_resource(9) by obtaining the RIDs via rman_get_rid(9)
on the corresponding resources instead of using the RIDs initially
passed to bus_alloc_resource_any(9) as the latter function may
change those RIDs. Solely em(4) for the ioport resource (but not
others) and bnxt(4) were using the correct RIDs by caching the ones
returned by bus_alloc_resource_any(9).
  - Change the logic of iflib_msix_init() around to only map the MSI-X
BAR if MSI-X is actually supported, i. e. pci_msix_count(9) returns
> 0. Otherwise the "Unable to map MSIX table " message triggers for
devices that simply don't support MSI-X and the user may think that
something is wrong while in fact everything works as expected.
  - Put some (mostly redundant) debug messages emitted by iflib(4)
and em(4) during attachment under bootverbose. The non-verbose
output of em(4) seen during attachment now is close to the one
prior to the conversion to iflib(4).
  - Replace various variants of spelling "MSI-X" (several in messages)
with "MSI-X" as used in the PCI specifications.
  - Remove some trailing whitespace from messages emitted by iflib(4)
and change them to consistently start with uppercase.
  - Remove some obsolete comments about releasing interrupts from
drivers and correct a few others.
  
  Reviewed by:  erj, Jacob Keller, shurd
  Differential Revision:https://reviews.freebsd.org/D18980

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_em.h
  head/sys/dev/ixgbe/if_ix.c
  head/sys/dev/ixgbe/if_ixv.c
  head/sys/dev/ixl/if_iavf.c
  head/sys/dev/ixl/if_ixl.c
  head/sys/dev/ixl/ixl_iw.c
  head/sys/dev/ixl/ixl_pf_main.c
  head/sys/dev/vmware/vmxnet3/if_vmx.c
  head/sys/net/iflib.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Wed Jan 30 13:19:05 2019(r343577)
+++ head/sys/dev/e1000/if_em.c  Wed Jan 30 13:21:26 2019(r343578)
@@ -293,7 +293,7 @@ static void em_disable_aspm(struct adapter *);
 intem_intr(void *arg);
 static voidem_disable_promisc(if_ctx_t ctx);
 
-/* MSIX handlers */
+/* MSI-X handlers */
 static int em_if_msix_intr_assign(if_ctx_t, int);
 static int em_msix_link(void *);
 static voidem_handle_link(void *context);
@@ -780,7 +780,9 @@ em_if_attach_pre(if_ctx_t ctx)
scctx->isc_msix_bar = PCIR_BAR(EM_MSIX_BAR);
scctx->isc_tx_nsegments = EM_MAX_SCATTER;
scctx->isc_nrxqsets_max = scctx->isc_ntxqsets_max = 
em_set_num_queues(ctx);
-   device_printf(dev, "attach_pre capping queues at %d\n", 
scctx->isc_ntxqsets_max);
+   if (bootverbose)
+   device_printf(dev, "attach_pre capping queues at %d\n",
+   scctx->isc_ntxqsets_max);
 
if (adapter->hw.mac.type >= igb_mac_min) {
int try_second_bar;
@@ -1301,7 +1303,7 @@ em_if_init(if_ctx_t ctx)
em_if_set_promisc(ctx, IFF_PROMISC);
e1000_clear_hw_cntrs_base_generic(>hw);
 
-   /* MSI/X configuration for 82574 */
+   /* MSI-X configuration for 82574 */
if (adapter->hw.mac.type == e1000_82574) {
int tmp = E1000_READ_REG(>hw, E1000_CTRL_EXT);
 
@@ -1427,7 +1429,7 @@ em_if_tx_queue_intr_enable(if_ctx_t ctx, uint16_t txqi
 
 /*
  *
- *  MSIX RX Interrupt Service routine
+ *  MSI-X RX Interrupt Service routine
  *
  **/
 static int
@@ -1442,7 +1444,7 @@ em_msix_que(void *arg)
 
 /*
  *
- *  MSIX Link Fast Interrupt Service routine
+ *  MSI-X Link Fast Interrupt Service routine
  *
  **/
 static int
@@ -1912,7 +1914,6 @@ em_allocate_pci_resources(if_ctx_t ctx)
for (rid = PCIR_BAR(0); rid < PCIR_CIS;) {
val = pci_read_config(dev, rid, 4);
if (EM_BAR_TYPE(val) == EM_BAR_TYPE_IO) {
-   adapter->io_rid = rid;
break;
}
rid += 4;
@@ -1924,8 +1925,8 @@ em_allocate_pci_resources(if_ctx_t ctx)
device_printf(dev, "Unable to locate IO BAR\n");
return (ENXIO);
}
-   adapter->ioport = bus_alloc_resource_any(dev,
-   SYS_RES_IOPORT, >io_rid, RF_ACTIVE);
+   adapter->ioport = bus_alloc_resource_any(dev, 

svn commit: r343481 - head/sys/net

2019-01-26 Thread Marius Strobl
Author: marius
Date: Sat Jan 26 21:35:51 2019
New Revision: 343481
URL: https://svnweb.freebsd.org/changeset/base/343481

Log:
  - In _iflib_fl_refill(), don't mark an RX buffer as available in the
corresponding bitmap before adding an mbuf has actually succeeded.
Previously, m_gethdr(M_NOWAIT, ...) failing caused a "hole" in the
RX ring but not in its bitmap. One implication of such a hole was
that in a subsequent call to _iflib_fl_refill() with the RX buffer
accounting still indicating another reclaimable buffer, bit_ffc(3)
nevertheless returned -1 in frag_idx which in turn caused havoc
when used as an index. Thus, additionally assert that frag_idx is
0 or greater.
Another possible consequence of a hole in the RX ring was a NULL-
dereference when trying to use the unallocated mbuf, for example
in iflib_rxd_pkt_get().
  
While at it, make the variable declarations in _iflib_fl_refill()
conform to style(9) and remove redundant checks already performed
by bit_ffc{,_at}(3).
  
  - In iflib_queues_alloc(), don't pass redundant M_ZERO to bit_alloc(3).
  
  Reported and tested by: pho

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSat Jan 26 21:30:26 2019(r343480)
+++ head/sys/net/iflib.cSat Jan 26 21:35:51 2019(r343481)
@@ -1921,27 +1921,27 @@ _rxq_refill_cb(void *arg, bus_dma_segment_t *segs, int
 static void
 _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int count)
 {
+   struct if_rxd_update iru;
+   struct rxq_refill_cb_arg cb_arg;
struct mbuf *m;
-   int idx, frag_idx = fl->ifl_fragidx;
-int pidx = fl->ifl_pidx;
caddr_t cl, *sd_cl;
struct mbuf **sd_m;
-   struct if_rxd_update iru;
-   struct rxq_refill_cb_arg cb_arg;
bus_dmamap_t *sd_map;
-   int n, i = 0;
bus_addr_t bus_addr, *sd_ba;
-   int err;
+   int err, frag_idx, i, idx, n, pidx;
qidx_t credits;
 
sd_m = fl->ifl_sds.ifsd_m;
sd_map = fl->ifl_sds.ifsd_map;
sd_cl = fl->ifl_sds.ifsd_cl;
sd_ba = fl->ifl_sds.ifsd_ba;
+   pidx = fl->ifl_pidx;
idx = pidx;
+   frag_idx = fl->ifl_fragidx;
credits = fl->ifl_credits;
 
-   n  = count;
+   i = 0;
+   n = count;
MPASS(n > 0);
MPASS(credits + n <= fl->ifl_size);
 
@@ -1963,9 +1963,11 @@ _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int coun
 *
 * If the cluster is still set then we know a minimum sized 
packet was received
 */
-   bit_ffc_at(fl->ifl_rx_bitmap, frag_idx, fl->ifl_size,  
_idx);
-   if ((frag_idx < 0) || (frag_idx >= fl->ifl_size))
-   bit_ffc(fl->ifl_rx_bitmap, fl->ifl_size, _idx);
+   bit_ffc_at(fl->ifl_rx_bitmap, frag_idx, fl->ifl_size,
+   _idx);
+   if (frag_idx < 0)
+   bit_ffc(fl->ifl_rx_bitmap, fl->ifl_size, _idx);
+   MPASS(frag_idx >= 0);
if ((cl = sd_cl[frag_idx]) == NULL) {
if ((cl = m_cljget(NULL, M_NOWAIT, fl->ifl_buf_size)) 
== NULL)
break;
@@ -1995,12 +1997,12 @@ _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int coun
bus_addr = sd_ba[frag_idx];
}
 
-   bit_set(fl->ifl_rx_bitmap, frag_idx);
MPASS(sd_m[frag_idx] == NULL);
if ((m = m_gethdr(M_NOWAIT, MT_NOINIT)) == NULL) {
break;
}
sd_m[frag_idx] = m;
+   bit_set(fl->ifl_rx_bitmap, frag_idx);
 #if MEMORY_LOGGING
fl->ifl_m_enqueued++;
 #endif
@@ -2025,7 +2027,6 @@ _iflib_fl_refill(if_ctx_t ctx, iflib_fl_t fl, int coun
fl->ifl_pidx = idx;
fl->ifl_credits = credits;
}
-
}
 
if (i) {
@@ -4896,7 +4897,6 @@ iflib_device_deregister(if_ctx_t ctx)
 
for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++)
free(fl->ifl_rx_bitmap, M_IFLIB);
-   
}
tqg = qgroup_if_config_tqg;
if (ctx->ifc_admin_task.gt_uniq != NULL)
@@ -5304,7 +5304,8 @@ iflib_queues_alloc(if_ctx_t ctx)
}
 
for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++) 
-   fl->ifl_rx_bitmap = bit_alloc(fl->ifl_size, M_IFLIB, 
M_WAITOK|M_ZERO);
+   fl->ifl_rx_bitmap = bit_alloc(fl->ifl_size, M_IFLIB,
+   M_WAITOK);
}
 
/* TXQs */
___
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: r342634 - in head/sys: arm/broadcom/bcm2835 arm/nvidia arm/ti dev/sdhci

2018-12-30 Thread Marius Strobl
Author: marius
Date: Sun Dec 30 23:08:06 2018
New Revision: 342634
URL: https://svnweb.freebsd.org/changeset/base/342634

Log:
  o Don't allocate resources for SDMA in sdhci(4) if the controller or the
front-end doesn't support SDMA or the latter implements a platform-
specific transfer method instead. While at it, factor out allocation
and freeing of SDMA resources to sdhci_dma_{alloc,free}() in order to
keep the code more readable when adding support for ADMA variants.
  
  o Base the size of the SDMA bounce buffer on MAXPHYS up to the maximum
of 512 KiB instead of using a fixed 4-KiB-buffer. With the default
MAXPHYS of 128 KiB and depending on the controller and medium, this
reduces the number of SDHCI interrupts by a factor of ~16 to ~32 on
sequential reads while an increase of throughput of up to ~84 % was
seen.
  
Front-ends for broken controllers that only support an SDMA buffer
boundary of a specific size may set SDHCI_QUIRK_BROKEN_SDMA_BOUNDARY
and supply a size via struct sdhci_slot. According to Linux, only
Qualcomm MSM-type SDHCI controllers are affected by this, though.
  
Requested by: Shreyank Amartya (unconditional bump to 512 KiB)
  
  o Introduce a SDHCI_DEPEND macro for specifying the dependency of the
front-end modules on the sdhci(4) one and bump the module version
of sdhci(4) to 2 via an also newly introduced SDHCI_VERSION in order
to ensure that all components are in sync WRT struct sdhci_slot.
  
  o In sdhci(4):
- Make pointers const were applicable,
- replace a few device_printf(9) calls with slot_printf() for
  consistency, and
- sync some local functions with their prototypes WRT static.

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c
  head/sys/arm/nvidia/tegra_sdhci.c
  head/sys/arm/ti/ti_sdhci.c
  head/sys/dev/sdhci/fsl_sdhci.c
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_fdt.c
  head/sys/dev/sdhci/sdhci_pci.c
  head/sys/dev/sdhci/sdhci_xenon.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Sun Dec 30 23:04:02 
2018(r342633)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Sun Dec 30 23:08:06 
2018(r342634)
@@ -683,7 +683,7 @@ static driver_t bcm_sdhci_driver = {
 
 DRIVER_MODULE(sdhci_bcm, simplebus, bcm_sdhci_driver, bcm_sdhci_devclass,
 NULL, NULL);
-MODULE_DEPEND(sdhci_bcm, sdhci, 1, 1, 1);
+SDHCI_DEPEND(sdhci_bcm);
 #ifndef MMCCAM
 MMC_DECLARE_BRIDGE(sdhci_bcm);
 #endif

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c  Sun Dec 30 23:04:02 
2018(r342633)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c  Sun Dec 30 23:08:06 
2018(r342634)
@@ -1287,7 +1287,7 @@ static driver_t bcm_sdhost_driver = {
 
 DRIVER_MODULE(sdhost_bcm, simplebus, bcm_sdhost_driver, bcm_sdhost_devclass,
 NULL, NULL);
-MODULE_DEPEND(sdhost_bcm, sdhci, 1, 1, 1);
+SDHCI_DEPEND(sdhost_bcm);
 #ifndef MMCCAM
 MMC_DECLARE_BRIDGE(sdhost_bcm);
 #endif

Modified: head/sys/arm/nvidia/tegra_sdhci.c
==
--- head/sys/arm/nvidia/tegra_sdhci.c   Sun Dec 30 23:04:02 2018
(r342633)
+++ head/sys/arm/nvidia/tegra_sdhci.c   Sun Dec 30 23:08:06 2018
(r342634)
@@ -465,7 +465,7 @@ static DEFINE_CLASS_0(sdhci, tegra_sdhci_driver, tegra
 sizeof(struct tegra_sdhci_softc));
 DRIVER_MODULE(sdhci_tegra, simplebus, tegra_sdhci_driver, tegra_sdhci_devclass,
 NULL, NULL);
-MODULE_DEPEND(sdhci_tegra, sdhci, 1, 1, 1);
+SDHCI_DEPEND(sdhci_tegra);
 #ifndef MMCCAM
 MMC_DECLARE_BRIDGE(sdhci);
 #endif

Modified: head/sys/arm/ti/ti_sdhci.c
==
--- head/sys/arm/ti/ti_sdhci.c  Sun Dec 30 23:04:02 2018(r342633)
+++ head/sys/arm/ti/ti_sdhci.c  Sun Dec 30 23:08:06 2018(r342634)
@@ -755,7 +755,7 @@ static driver_t ti_sdhci_driver = {
 
 DRIVER_MODULE(sdhci_ti, simplebus, ti_sdhci_driver, ti_sdhci_devclass, NULL,
 NULL);
-MODULE_DEPEND(sdhci_ti, sdhci, 1, 1, 1);
+SDHCI_DEPEND(sdhci_ti);
 
 #ifndef MMCCAM
 MMC_DECLARE_BRIDGE(sdhci_ti);

Modified: head/sys/dev/sdhci/fsl_sdhci.c
==
--- head/sys/dev/sdhci/fsl_sdhci.c  Sun Dec 30 23:04:02 2018
(r342633)
+++ head/sys/dev/sdhci/fsl_sdhci.c  Sun Dec 30 23:08:06 2018
(r342634)
@@ -1005,7 +1005,7 @@ static driver_t fsl_sdhci_driver = {
 
 DRIVER_MODULE(sdhci_fsl, simplebus, fsl_sdhci_driver, fsl_sdhci_devclass,
 NULL, NULL);
-MODULE_DEPEND(sdhci_fsl, sdhci, 1, 1, 

svn commit: r341041 - head/sys/contrib/ck/include/gcc/sparcv9

2018-11-27 Thread Marius Strobl
Author: marius
Date: Tue Nov 27 12:35:51 2018
New Revision: 341041
URL: https://svnweb.freebsd.org/changeset/base/341041

Log:
  Import CK as of 21d3e319407d19dece16ee317c757ffc54a452bc, which makes its
  sparcv9 atomics compatible with the FreeBSD kernel by using instructions
  which access the appropriate address space.
  Atomic operations within the kernel must access the nucleus address space
  instead of the default primary one. Without this change but the increased
  use of CK in the kernel, machines started to panic after some minutes of
  uptime due to an unresolvable fault in ck_pr_cas_64_value().

Modified:
  head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h
Directory Properties:
  head/sys/contrib/ck/   (props changed)

Modified: head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h
==
--- head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h Tue Nov 27 12:32:32 
2018(r341040)
+++ head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h Tue Nov 27 12:35:51 
2018(r341041)
@@ -136,11 +136,26 @@ CK_PR_STORE_S(int, int, "stsw")
 #undef CK_PR_STORE_S
 #undef CK_PR_STORE
 
+/* Use the appropriate address space for atomics within the FreeBSD kernel. */
+#if defined(__FreeBSD__) && defined(_KERNEL)
+#include 
+#include 
+#define CK_PR_INS_CAS "casa"
+#define CK_PR_INS_CASX "casxa"
+#define CK_PR_INS_SWAP "swapa"
+#define CK_PR_ASI_ATOMIC __XSTRING(__ASI_ATOMIC)
+#else
+#define CK_PR_INS_CAS "cas"
+#define CK_PR_INS_CASX "casx"
+#define CK_PR_INS_SWAP "swap"
+#define CK_PR_ASI_ATOMIC ""
+#endif
+
 CK_CC_INLINE static bool
 ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t 
*value)
 {
 
-   __asm__ __volatile__("casx [%1], %2, %0"
+   __asm__ __volatile__(CK_PR_INS_CASX " [%1] " CK_PR_ASI_ATOMIC ", %2, %0"
: "+" (set)
: "r"   (target),
  "r"   (compare)
@@ -154,7 +169,7 @@ CK_CC_INLINE static bool
 ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set)
 {
 
-   __asm__ __volatile__("casx [%1], %2, %0"
+   __asm__ __volatile__(CK_PR_INS_CASX " [%1] " CK_PR_ASI_ATOMIC ", %2, %0"
: "+" (set)
: "r" (target),
  "r" (compare)
@@ -181,7 +196,7 @@ ck_pr_cas_ptr_value(void *target, void *compare, void 
CK_CC_INLINE static bool\
ck_pr_cas_##N##_value(T *target, T compare, T set, T *value)\
{   \
-   __asm__ __volatile__("cas [%1], %2, %0" \
+   __asm__ __volatile__(CK_PR_INS_CAS " [%1] " CK_PR_ASI_ATOMIC ", 
%2, %0" \
: "+" (set)   \
: "r"   (target),   \
  "r"   (compare)   \
@@ -192,7 +207,7 @@ ck_pr_cas_ptr_value(void *target, void *compare, void 
CK_CC_INLINE static bool\
ck_pr_cas_##N(T *target, T compare, T set)  \
{   \
-   __asm__ __volatile__("cas [%1], %2, %0" \
+   __asm__ __volatile__(CK_PR_INS_CAS " [%1] " CK_PR_ASI_ATOMIC ", 
%2, %0" \
: "+" (set)   \
: "r" (target), \
  "r" (compare) \
@@ -211,7 +226,7 @@ CK_PR_CAS(int, int)
ck_pr_fas_##N(T *target, T update)  \
{   \
\
-   __asm__ __volatile__("swap [%1], %0"\
+   __asm__ __volatile__(CK_PR_INS_SWAP " [%1] " CK_PR_ASI_ATOMIC 
", %0"\
: "+" (update)\
: "r"   (target)\
: "memory");\
@@ -223,6 +238,11 @@ CK_PR_FAS(uint, unsigned int)
 CK_PR_FAS(32, uint32_t)
 
 #undef CK_PR_FAS
+
+#undef CK_PR_INS_CAS
+#undef CK_PR_INS_CASX
+#undef CK_PR_INS_SWAP
+#undef CK_PR_ASI_ATOMIC
 
 #endif /* CK_PR_SPARCV9_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: r341016 - in head: . sys/modules/iavf

2018-11-27 Thread Marius Strobl
Author: marius
Date: Tue Nov 27 12:11:16 2018
New Revision: 341016
URL: https://svnweb.freebsd.org/changeset/base/341016

Log:
  - Add a belated UPDATING entry for the ixlv(4) -> iavf(4) rename in r339338.
  - Likewise, add ixlv.4.gz to OLD_FILES,
  - and link if_ixlv.ko to if_iavf.ko in order to aid a bit in the transition.

Modified:
  head/ObsoleteFiles.inc
  head/UPDATING
  head/sys/modules/iavf/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Tue Nov 27 11:55:43 2018(r341015)
+++ head/ObsoleteFiles.inc  Tue Nov 27 12:11:16 2018(r341016)
@@ -67,6 +67,8 @@ OLD_LIBS+=usr/lib32/libcap_pwd.so.0
 OLD_LIBS+=usr/lib32/libcap_random.so.0
 OLD_LIBS+=usr/lib32/libcap_dns.so.0
 OLD_LIBS+=usr/lib32/libcap_syslog.so.0
+# 20181012: rename of ixlv(4) to iavf(4)
+OLD_FILES+=usr/share/man/man4/ixlv.4.gz
 # 20181009: OpenSSL 1.1.1
 OLD_FILES+=usr/include/openssl/des_old.h
 OLD_FILES+=usr/include/openssl/dso.h

Modified: head/UPDATING
==
--- head/UPDATING   Tue Nov 27 11:55:43 2018(r341015)
+++ head/UPDATING   Tue Nov 27 12:11:16 2018(r341016)
@@ -83,6 +83,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
loading from X11 startup. These will become the defaults in 13-current
shortly.
 
+20181012:
+   The ixlv(4) driver has been renamed to iavf(4).  As a consequence,
+   custom kernel and module loading configuration files must be updated
+   accordingly.  Moreover, interfaces previous presented as ixlvN to the
+   system are now exposed as iavfN and network configuration files must
+   be adjusted as necessary.
+
 20181009:
OpenSSL has been updated to version 1.1.1.  This update included
additional various API changes througout the base system.  It is

Modified: head/sys/modules/iavf/Makefile
==
--- head/sys/modules/iavf/Makefile  Tue Nov 27 11:55:43 2018
(r341015)
+++ head/sys/modules/iavf/Makefile  Tue Nov 27 12:11:16 2018
(r341016)
@@ -15,4 +15,6 @@ SRCS+= i40e_common.c i40e_nvm.c i40e_adminq.c
 # Enable asserts and other debugging facilities
 # CFLAGS += -DINVARIANTS -DINVARIANTS_SUPPORT -DWITNESS
 
+LINKS= ${KMODDIR}/${KMOD}.ko ${KMODDIR}/if_ixlv.ko
+
 .include 
___
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: r340656 - head/sys/sparc64/sparc64

2018-11-19 Thread Marius Strobl
Author: marius
Date: Tue Nov 20 00:08:33 2018
New Revision: 340656
URL: https://svnweb.freebsd.org/changeset/base/340656

Log:
  Given that the idea of D15374 was to "make memmove a first class citizen",
  provide a _MEMMOVE extension of _MEMCPY that deals with overlap based on
  the previous bcopy(9) implementation and use the former for bcopy(9) and
  memmove(9). This addresses my D15374 review comment, avoiding extra MOVs
  in case of memmove(9) and trashing the stack pointer.

Modified:
  head/sys/sparc64/sparc64/support.S

Modified: head/sys/sparc64/sparc64/support.S
==
--- head/sys/sparc64/sparc64/support.S  Tue Nov 20 00:06:53 2018
(r340655)
+++ head/sys/sparc64/sparc64/support.S  Tue Nov 20 00:08:33 2018
(r340656)
@@ -207,6 +207,30 @@ __FBSDID("$FreeBSD$");
 6:
 
 /*
+ * Extension of _MEMCPY dealing with overlap, but unaware of ASIs.
+ * Used for bcopy() and memmove().
+ */
+#define_MEMMOVE(dst, src, len) \
+   /* Check for overlap, and copy backwards if so. */ \
+   sub dst, src, %g1 ; \
+   cmp %g1, len ; \
+   bgeu,a,pt %xcc, 2f ; \
+nop ; \
+   /* Copy backwards. */ \
+   add src, len, src ; \
+   add dst, len, dst ; \
+1: deccc   1, len ; \
+   bl,pn   %xcc, 3f ; \
+dec1, src ; \
+   ldub[src], %g1 ; \
+   dec 1, dst ; \
+   ba  %xcc, 1b ; \
+stb%g1, [dst] ; \
+2: /* Do the fast version. */ \
+   _MEMCPY(dst, src, len, EMPTY, EMPTY, EMPTY, EMPTY) ; \
+3:
+
+/*
  * void ascopy(u_long asi, vm_offset_t src, vm_offset_t dst, size_t len)
  */
 ENTRY(ascopy)
@@ -265,49 +289,14 @@ ENTRY(bcmp)
 END(bcmp)
 
 /*
- * void *memmove(void *dst, const void *src, size_t len)
  * void bcopy(const void *src, void *dst, size_t len)
  */
-ENTRY(memmove)
-   /*
-* Swap src/dst for memmove/bcopy differences
-*/
-   mov %o0, %o6
-   mov %o1, %o0
-   mov %o6, %o1
-ALTENTRY(bcopy)
-   /*
-* Check for overlap, and copy backwards if so.
-*/
-   sub %o1, %o0, %g1
-   cmp %g1, %o2
-   bgeu,a,pt %xcc, 3f
+ENTRY(bcopy)
+   _MEMMOVE(%o1, %o0, %o2)
+   retl
 nop
+END(bcopy)
 
-   /*
-* Copy backwards.
-*/
-   add %o0, %o2, %o0
-   add %o1, %o2, %o1
-1: deccc   1, %o2
-   bl,a,pn %xcc, 2f
-nop
-   dec 1, %o0
-   ldub[%o0], %g1
-   dec 1, %o1
-   ba  %xcc, 1b
-stb%g1, [%o1]
-2: retl
-mov%o6, %o0
-
-   /*
-* Do the fast version.
-*/
-3: _MEMCPY(%o1, %o0, %o2, EMPTY, EMPTY, EMPTY, EMPTY)
-   retl
-mov%o6, %o0
-END(memmove)
-
 /*
  * void bzero(void *b, size_t len)
  */
@@ -335,6 +324,16 @@ ENTRY(memcpy)
retl
 nop
 END(memcpy)
+
+/*
+ * void *memmove(void *dst, const void *src, size_t len)
+ */
+ENTRY(memmove)
+   mov %o0, %o3
+   _MEMMOVE(%o3, %o1, %o2)
+   retl
+nop
+END(memmove)
 
 /*
  * void *memset(void *b, int c, size_t len)
___
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: r340654 - head/sys/dev/sdhci

2018-11-19 Thread Marius Strobl
Author: marius
Date: Mon Nov 19 23:56:33 2018
New Revision: 340654
URL: https://svnweb.freebsd.org/changeset/base/340654

Log:
  For consistency within the front-end, prefer SDHCI_{READ,WRITE}_{2,4}()
  to sdhci_acpi_{read,write}_{2,4}() in the sdhci_acpi_set_uhs_timing()
  added in r340543.

Modified:
  head/sys/dev/sdhci/sdhci_acpi.c

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Mon Nov 19 23:54:49 2018
(r340653)
+++ head/sys/dev/sdhci/sdhci_acpi.c Mon Nov 19 23:56:33 2018
(r340654)
@@ -203,7 +203,7 @@ sdhci_acpi_set_uhs_timing(device_t dev, struct sdhci_s
enum mmc_bus_timing timing;
 
bus = slot->bus;
-   old_timing = sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2);
+   old_timing = SDHCI_READ_2(bus, slot, SDHCI_HOST_CONTROL2);
old_timing &= SDHCI_CTRL2_UHS_MASK;
sdhci_generic_set_uhs_timing(dev, slot);
 
@@ -220,19 +220,19 @@ sdhci_acpi_set_uhs_timing(device_t dev, struct sdhci_s
timing = ios->timing;
if (old_timing == SDHCI_CTRL2_UHS_SDR104 &&
timing == bus_timing_hs)
-   sdhci_acpi_write_2(bus, slot, SDHCI_HOST_CONTROL2,
-   sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2) &
+   SDHCI_WRITE_2(bus, slot, SDHCI_HOST_CONTROL2,
+   SDHCI_READ_2(bus, slot, SDHCI_HOST_CONTROL2) &
~SDHCI_CTRL2_SAMPLING_CLOCK);
if (ios->clock > SD_SDR50_MAX &&
old_timing != SDHCI_CTRL2_MMC_HS400 &&
timing == bus_timing_mmc_hs400) {
-   sdhci_acpi_write_2(bus, slot, SDHCI_HOST_CONTROL2,
-   sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2) |
+   SDHCI_WRITE_2(bus, slot, SDHCI_HOST_CONTROL2,
+   SDHCI_READ_2(bus, slot, SDHCI_HOST_CONTROL2) |
SDHCI_CTRL2_SAMPLING_CLOCK);
-   sdhci_acpi_write_4(bus, slot, SDHCI_AMD_RESET_DLL_REG,
+   SDHCI_WRITE_4(bus, slot, SDHCI_AMD_RESET_DLL_REG,
0x40003210);
DELAY(20);
-   sdhci_acpi_write_4(bus, slot, SDHCI_AMD_RESET_DLL_REG,
+   SDHCI_WRITE_4(bus, slot, SDHCI_AMD_RESET_DLL_REG,
0x40033210);
}
}
___
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: r340543 - head/sys/dev/sdhci

2018-11-17 Thread Marius Strobl
Author: marius
Date: Sun Nov 18 00:52:27 2018
New Revision: 340543
URL: https://svnweb.freebsd.org/changeset/base/340543

Log:
  Add a quirk handling for AMDI0040 controllers allowing them to do HS400.
  
  Submitted by: Shreyank Amartya (original version)

Modified:
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h
  head/sys/dev/sdhci/sdhci_acpi.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Sun Nov 18 00:35:36 2018(r340542)
+++ head/sys/dev/sdhci/sdhci.c  Sun Nov 18 00:52:27 2018(r340543)
@@ -898,6 +898,9 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
if (slot->quirks & SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 &&
caps2 & SDHCI_CAN_MMC_HS400)
host_caps |= MMC_CAP_MMC_HS400;
+   if (slot->quirks & SDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 &&
+   caps2 & SDHCI_CAN_SDR104)
+   host_caps |= MMC_CAP_MMC_HS400;
 
/*
 * Disable UHS-I and eMMC modes if the set_uhs_timing method is the

Modified: head/sys/dev/sdhci/sdhci.h
==
--- head/sys/dev/sdhci/sdhci.h  Sun Nov 18 00:35:36 2018(r340542)
+++ head/sys/dev/sdhci/sdhci.h  Sun Nov 18 00:52:27 2018(r340543)
@@ -93,6 +93,8 @@
 #defineSDHCI_QUIRK_PRESET_VALUE_BROKEN (1 << 27)
 /* Controller does not support or the support for ACMD12 is broken. */
 #defineSDHCI_QUIRK_BROKEN_AUTO_STOP(1 << 28)
+/* Controller supports eMMC HS400 mode if SDHCI_CAN_SDR104 is set. */
+#defineSDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 (1 << 29)
 
 /*
  * Controller registers

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Sun Nov 18 00:35:36 2018
(r340542)
+++ head/sys/dev/sdhci/sdhci_acpi.c Sun Nov 18 00:52:27 2018
(r340543)
@@ -45,12 +45,15 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 
 #include 
 
 #include "mmcbr_if.h"
 #include "sdhci_if.h"
 
+#defineSDHCI_AMD_RESET_DLL_REG 0x908
+
 static const struct sdhci_acpi_device {
const char* hid;
int uid;
@@ -80,7 +83,8 @@ static const struct sdhci_acpi_device {
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ "AMDI0040",   0, "AMD eMMC 5.0 Controller",
-   SDHCI_QUIRK_32BIT_DMA_SIZE },
+   SDHCI_QUIRK_32BIT_DMA_SIZE |
+   SDHCI_QUIRK_MMC_HS400_IF_CAN_SDR104 },
{ NULL, 0, NULL, 0}
 };
 
@@ -94,12 +98,11 @@ static char *sdhci_ids[] = {
 };
 
 struct sdhci_acpi_softc {
-   u_int   quirks; /* Chip specific quirks */
-   struct resource *irq_res;   /* IRQ resource */
-   void*intrhand;  /* Interrupt handle */
-
struct sdhci_slot slot;
struct resource *mem_res;   /* Memory resource */
+   struct resource *irq_res;   /* IRQ resource */
+   void*intrhand;  /* Interrupt handle */
+   const struct sdhci_acpi_device *acpi_dev;
 };
 
 static void sdhci_acpi_intr(void *arg);
@@ -189,6 +192,52 @@ sdhci_acpi_write_multi_4(device_t dev, struct sdhci_sl
bus_write_multi_stream_4(sc->mem_res, off, data, count);
 }
 
+static void
+sdhci_acpi_set_uhs_timing(device_t dev, struct sdhci_slot *slot)
+{
+   const struct sdhci_acpi_softc *sc;
+   const struct sdhci_acpi_device *acpi_dev;
+   const struct mmc_ios *ios;
+   device_t bus;
+   uint16_t old_timing;
+   enum mmc_bus_timing timing;
+
+   bus = slot->bus;
+   old_timing = sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2);
+   old_timing &= SDHCI_CTRL2_UHS_MASK;
+   sdhci_generic_set_uhs_timing(dev, slot);
+
+   sc = device_get_softc(dev);
+   acpi_dev = sc->acpi_dev;
+   /*
+* AMDI0040 controllers require SDHCI_CTRL2_SAMPLING_CLOCK to be
+* disabled when switching from HS200 to high speed and to always
+* be turned on again when tuning for HS400.  In the later case,
+* an AMD-specific DLL reset additionally is needed.
+*/
+   if (strcmp(acpi_dev->hid, "AMDI0040") == 0 && acpi_dev->uid == 0) {
+   ios = >host.ios;
+   timing = ios->timing;
+   if (old_timing == SDHCI_CTRL2_UHS_SDR104 &&
+   timing == bus_timing_hs)
+   sdhci_acpi_write_2(bus, slot, SDHCI_HOST_CONTROL2,
+   sdhci_acpi_read_2(bus, slot, SDHCI_HOST_CONTROL2) &
+   ~SDHCI_CTRL2_SAMPLING_CLOCK);
+   if (ios->clock > SD_SDR50_MAX &&
+   old_timing != SDHCI_CTRL2_MMC_HS400 &&
+   timing == bus_timing_mmc_hs400) {
+   

svn commit: r340495 - head/sys/dev/mmc

2018-11-17 Thread Marius Strobl
Author: marius
Date: Sat Nov 17 17:21:36 2018
New Revision: 340495
URL: https://svnweb.freebsd.org/changeset/base/340495

Log:
  - Restore setting the clock for devices which support the default/legacy
transfer mode only (lost with r321385). [1]
  - Similarly, don't try to set the power class on MMC devices that comply
to version 4.0 of the system specification but are operated in default/
legacy transfer or 1-bit bus mode as no power class is specified for
these cases. Trying to set a power class nevertheless resulted in an -
albeit harmless - error message.
  
  PR:   231713 [1]

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Sat Nov 17 16:13:09 2018(r340494)
+++ head/sys/dev/mmc/mmc.c  Sat Nov 17 17:21:36 2018(r340495)
@@ -830,9 +830,14 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
const uint8_t *ext_csd;
uint32_t clock;
uint8_t value;
+   enum mmc_bus_timing timing;
+   enum mmc_bus_width bus_width;
 
dev = sc->dev;
-   if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4)
+   timing = mmcbr_get_timing(dev);
+   bus_width = ivar->bus_width;
+   if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4 ||
+   timing == bus_timing_normal || bus_width == bus_width_1)
return (MMC_ERR_NONE);
 
value = 0;
@@ -843,8 +848,8 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_195];
else if (clock <= MMC_TYPE_HS_52_MAX) {
-   if (mmcbr_get_timing(dev) >= bus_timing_mmc_ddr52 &&
-   ivar->bus_width >= bus_width_4)
+   if (timing >= bus_timing_mmc_ddr52 &&
+   bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_195_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_195];
@@ -863,13 +868,13 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_360];
else if (clock <= MMC_TYPE_HS_52_MAX) {
-   if (mmcbr_get_timing(dev) == bus_timing_mmc_ddr52 &&
-   ivar->bus_width >= bus_width_4)
+   if (timing == bus_timing_mmc_ddr52 &&
+   bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_360];
} else if (clock <= MMC_TYPE_HS200_HS400ES_MAX) {
-   if (ivar->bus_width == bus_width_8)
+   if (bus_width == bus_width_8)
value = ext_csd[EXT_CSD_PWR_CL_200_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_200_360];
@@ -881,7 +886,7 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_i
return (MMC_ERR_INVALID);
}
 
-   if (ivar->bus_width == bus_width_8)
+   if (bus_width == bus_width_8)
value = (value & EXT_CSD_POWER_CLASS_8BIT_MASK) >>
EXT_CSD_POWER_CLASS_8BIT_SHIFT;
else
@@ -2164,7 +2169,7 @@ mmc_calculate_clock(struct mmc_softc *sc)
for (i = 0; i < sc->child_count; i++) {
ivar = device_get_ivars(sc->child_list[i]);
if ((ivar->timings & ~(1 << bus_timing_normal)) == 0)
-   continue;
+   goto clock;
 
rca = ivar->rca;
if (mmc_select_card(sc, rca) != MMC_ERR_NONE) {
@@ -2230,6 +2235,7 @@ mmc_calculate_clock(struct mmc_softc *sc)
}
}
 
+clock:
/* Set clock (must be done before initial tuning). */
mmcbr_set_clock(dev, max_dtr);
mmcbr_update_ios(dev);
___
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: r338513 - head/sys/dev/mmc

2018-09-06 Thread Marius Strobl
Author: marius
Date: Thu Sep  6 21:24:14 2018
New Revision: 338513
URL: https://svnweb.freebsd.org/changeset/base/338513

Log:
  Avoid uninitialized read of ext_csd.
  
  Reported by:Coverity
  CID:1395275
  Approved by:  re (gjb, kib)

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Thu Sep  6 21:09:54 2018(r338512)
+++ head/sys/dev/mmc/mmc.c  Thu Sep  6 21:24:14 2018(r338513)
@@ -1591,6 +1591,7 @@ mmc_discover_cards(struct mmc_softc *sc)
int err, host_caps, i, newcard;
uint32_t resp, sec_count, status;
uint16_t rca = 2;
+   int16_t rev;
uint8_t card_type;
 
host_caps = mmcbr_get_caps(sc->dev);
@@ -1779,6 +1780,7 @@ mmc_discover_cards(struct mmc_softc *sc)
goto free_ivar;
}
 
+   rev = -1;
/* Only MMC >= 4.x devices support EXT_CSD. */
if (ivar->csd.spec_vers >= 4) {
err = mmc_send_ext_csd(sc->dev, sc->dev,
@@ -1789,6 +1791,7 @@ mmc_discover_cards(struct mmc_softc *sc)
goto free_ivar;
}
ext_csd = ivar->raw_ext_csd;
+   rev = ext_csd[EXT_CSD_REV];
/* Handle extended capacity from EXT_CSD */
sec_count = le32dec(_csd[EXT_CSD_SEC_CNT]);
if (sec_count != 0) {
@@ -1859,7 +1862,7 @@ mmc_discover_cards(struct mmc_softc *sc)
 * units of 10 ms), defaulting to 500 ms.
 */
ivar->cmd6_time = 500 * 1000;
-   if (ext_csd[EXT_CSD_REV] >= 6)
+   if (rev >= 6)
ivar->cmd6_time = 10 *
ext_csd[EXT_CSD_GEN_CMD6_TIME];
/* Handle HC erase sector size. */
@@ -1880,8 +1883,7 @@ mmc_discover_cards(struct mmc_softc *sc)
}
}
 
-   mmc_decode_cid_mmc(ivar->raw_cid, >cid,
-   ext_csd[EXT_CSD_REV] >= 5);
+   mmc_decode_cid_mmc(ivar->raw_cid, >cid, rev >= 5);
 
 child_common:
for (quirk = _quirks[0]; quirk->mid != 0x0; quirk++) {
___
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: r338512 - head/sys/dev/sdhci

2018-09-06 Thread Marius Strobl
Author: marius
Date: Thu Sep  6 21:09:54 2018
New Revision: 338512
URL: https://svnweb.freebsd.org/changeset/base/338512

Log:
  - Explicitly compare a pointer to NULL. The __builtin_expect() of clang
3.4.1 otherwise isn't able to cope with the expression.
  - Fix a nearby whitespace bug.
  
  Approved by:  re (gjb, kib)

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Thu Sep  6 20:29:40 2018(r338511)
+++ head/sys/dev/sdhci/sdhci.c  Thu Sep  6 21:09:54 2018(r338512)
@@ -1575,11 +1575,10 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, struc
 #ifdef MMCCAM
slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION &&
 #else
-   slot->req->stop &&
+   slot->req->stop != NULL &&
 #endif
!(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)))
mode |= SDHCI_TRNS_ACMD12;
-
}
if (data->flags & MMC_DATA_READ)
mode |= SDHCI_TRNS_READ;
___
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: r338304 - head/sys/dev/mmc

2018-08-24 Thread Marius Strobl
Author: marius
Date: Fri Aug 24 21:08:05 2018
New Revision: 338304
URL: https://svnweb.freebsd.org/changeset/base/338304

Log:
  The read accessors generated by __BUS_ACCESSOR() have the problem that
  they don't check the result of BUS_READ_IVAR(9) and silently return stack
  garbage on failure in case a bus doesn't implement a particular instance
  variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ,
  yet, this in turn can cause mmc(4) to get into a state in which re-tuning
  seems to be necessary but is inappropriate, causing mmc_wait_for_request()
  to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and
  instead provide a version of the latter which returns retune_req_none if
  reading MMCBR_IVAR_RETUNE_REQ fails.
  One more straight-forward solution would have been to change mmc(4) to not
  call mmcbr_get_retune_req() if the current transfer mode doesn't require
  re-tuning to begin with. However, for modes such as SDR50, it depends on
  the controller whether periodic re-tuning is need. Therefore, knowledge of
  whether a particular transfer mode does require re-tuning should be kept
  to the bridge drivers.
  This change is the generic version of r338271, as intended not requiring
  bridge drivers to be touched (unless transfer modes beyond high speed are
  to be supported that is).
  
  Approved by:  re (gjb)

Modified:
  head/sys/dev/mmc/mmcbrvar.h

Modified: head/sys/dev/mmc/mmcbrvar.h
==
--- head/sys/dev/mmc/mmcbrvar.h Fri Aug 24 20:44:58 2018(r338303)
+++ head/sys/dev/mmc/mmcbrvar.h Fri Aug 24 21:08:05 2018(r338304)
@@ -97,7 +97,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int)
 MMCBR_ACCESSOR(mode, MODE, int)
 MMCBR_ACCESSOR(ocr, OCR, int)
 MMCBR_ACCESSOR(power_mode, POWER_MODE, int)
-MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int)
 MMCBR_ACCESSOR(vdd, VDD, int)
 MMCBR_ACCESSOR(vccq, VCCQ, int)
 MMCBR_ACCESSOR(caps, CAPS, int)
@@ -105,6 +104,20 @@ MMCBR_ACCESSOR(timing, TIMING, int)
 MMCBR_ACCESSOR(max_data, MAX_DATA, int)
 MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int)
 
+static int __inline
+mmcbr_get_retune_req(device_t dev)
+{
+   uintptr_t v;
+
+   if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev,
+   MMCBR_IVAR_RETUNE_REQ, ) != 0))
+   return (retune_req_none);
+   return ((int)v);
+}
+
+/*
+ * Convenience wrappers for the mmcbr interface
+ */
 static int __inline
 mmcbr_update_ios(device_t dev)
 {
___
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: r338283 - head/tools/boot

2018-08-23 Thread Marius Strobl
Author: marius
Date: Thu Aug 23 22:57:42 2018
New Revision: 338283
URL: https://svnweb.freebsd.org/changeset/base/338283

Log:
  Following r335259, don't copy boot1 from the running system for sparc64
  either.

Modified:
  head/tools/boot/rootgen.sh

Modified: head/tools/boot/rootgen.sh
==
--- head/tools/boot/rootgen.sh  Thu Aug 23 22:50:11 2018(r338282)
+++ head/tools/boot/rootgen.sh  Thu Aug 23 22:57:42 2018(r338283)
@@ -792,8 +792,6 @@ DESTDIR=${OBJDIR}/boot-tree
 rm -rf ${DESTDIR}
 mkdir -p ${DESTDIR}/boot/defaults
 mkdir -p ${DESTDIR}/boot/kernel
-# XXX boot1 exists only on sparc64
-cp /boot/boot1 ${DESTDIR}/boot
 cp /boot/kernel/kernel ${DESTDIR}/boot/kernel
 echo -h -D -S115200 > ${DESTDIR}/boot.config
 cat > ${DESTDIR}/boot/loader.conf 

svn commit: r338280 - head/sys/dev/mmc

2018-08-23 Thread Marius Strobl
Author: marius
Date: Thu Aug 23 21:26:58 2018
New Revision: 338280
URL: https://svnweb.freebsd.org/changeset/base/338280

Log:
  - Use le32dec(9) for decoding EXT_CSD values where it makes sense. [1]
  - Locally cache some instance variable values in mmc_discover_cards()
in order to improve the code readability a bit.
  
  Obtained from:NetBSD [1]

Modified:
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Thu Aug 23 21:24:22 2018(r338279)
+++ head/sys/dev/mmc/mmc.c  Thu Aug 23 21:26:58 2018(r338280)
@@ -1586,10 +1586,12 @@ mmc_discover_cards(struct mmc_softc *sc)
uint32_t raw_cid[4];
struct mmc_ivars *ivar = NULL;
const struct mmc_quirk *quirk;
+   const uint8_t *ext_csd;
device_t child;
int err, host_caps, i, newcard;
uint32_t resp, sec_count, status;
uint16_t rca = 2;
+   uint8_t card_type;
 
host_caps = mmcbr_get_caps(sc->dev);
if (bootverbose || mmc_debug)
@@ -1786,11 +1788,9 @@ mmc_discover_cards(struct mmc_softc *sc)
"Error reading EXT_CSD %d\n", err);
goto free_ivar;
}
+   ext_csd = ivar->raw_ext_csd;
/* Handle extended capacity from EXT_CSD */
-   sec_count = ivar->raw_ext_csd[EXT_CSD_SEC_CNT] +
-   (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 1] << 8) +
-   (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 2] << 16) +
-   (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
+   sec_count = le32dec(_csd[EXT_CSD_SEC_CNT]);
if (sec_count != 0) {
ivar->sec_count = sec_count;
ivar->high_cap = 1;
@@ -1798,65 +1798,56 @@ mmc_discover_cards(struct mmc_softc *sc)
/* Find maximum supported bus width. */
ivar->bus_width = mmc_test_bus_width(sc);
/* Get device speeds beyond normal mode. */
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_HS_52) != 0) {
+   card_type = ext_csd[EXT_CSD_CARD_TYPE];
+   if ((card_type & EXT_CSD_CARD_TYPE_HS_52) != 0) {
setbit(>timings, bus_timing_hs);
ivar->hs_tran_speed = MMC_TYPE_HS_52_MAX;
-   } else if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_HS_26) != 0) {
+   } else if ((card_type & EXT_CSD_CARD_TYPE_HS_26) != 0) {
setbit(>timings, bus_timing_hs);
ivar->hs_tran_speed = MMC_TYPE_HS_26_MAX;
}
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_DDR_52_1_2V) != 0 &&
+   if ((card_type & EXT_CSD_CARD_TYPE_DDR_52_1_2V) != 0 &&
(host_caps & MMC_CAP_SIGNALING_120) != 0) {
setbit(>timings, bus_timing_mmc_ddr52);
setbit(>vccq_120, bus_timing_mmc_ddr52);
}
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_DDR_52_1_8V) != 0 &&
+   if ((card_type & EXT_CSD_CARD_TYPE_DDR_52_1_8V) != 0 &&
(host_caps & MMC_CAP_SIGNALING_180) != 0) {
setbit(>timings, bus_timing_mmc_ddr52);
setbit(>vccq_180, bus_timing_mmc_ddr52);
}
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_HS200_1_2V) != 0 &&
+   if ((card_type & EXT_CSD_CARD_TYPE_HS200_1_2V) != 0 &&
(host_caps & MMC_CAP_SIGNALING_120) != 0) {
setbit(>timings, bus_timing_mmc_hs200);
setbit(>vccq_120, bus_timing_mmc_hs200);
}
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_HS200_1_8V) != 0 &&
+   if ((card_type & EXT_CSD_CARD_TYPE_HS200_1_8V) != 0 &&
(host_caps & MMC_CAP_SIGNALING_180) != 0) {
setbit(>timings, bus_timing_mmc_hs200);
setbit(>vccq_180, bus_timing_mmc_hs200);
}
-   if ((ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] &
-   EXT_CSD_CARD_TYPE_HS400_1_2V) 

svn commit: r338275 - head/sys/dev/mmc

2018-08-23 Thread Marius Strobl
Author: marius
Date: Thu Aug 23 20:25:27 2018
New Revision: 338275
URL: https://svnweb.freebsd.org/changeset/base/338275

Log:
  Obtain the bus mode (MMC or SD) from the directly superordinated
  bus rather than reaching up to the bridge and use the cached mode
  in mmcsd_delete(), too.

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cThu Aug 23 19:58:24 2018(r338274)
+++ head/sys/dev/mmc/mmcsd.cThu Aug 23 20:25:27 2018(r338275)
@@ -247,7 +247,7 @@ mmcsd_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
sc->mmcbus = mmcbus = device_get_parent(dev);
-   sc->mode = mmcbr_get_mode(mmcbus);
+   sc->mode = mmc_get_card_type(dev);
/*
 * Note that in principle with an SDHCI-like re-tuning implementation,
 * the maximum data size can change at runtime due to a device removal/
@@ -1315,7 +1315,7 @@ mmcsd_delete(struct mmcsd_part *part, struct bio *bp)
memset(, 0, sizeof(cmd));
cmd.mrq = 
req.cmd = 
-   if (mmc_get_card_type(dev) == mode_sd)
+   if (sc->mode == mode_sd)
cmd.opcode = SD_ERASE_WR_BLK_START;
else
cmd.opcode = MMC_ERASE_GROUP_START;
@@ -1334,7 +1334,7 @@ mmcsd_delete(struct mmcsd_part *part, struct bio *bp)
memset(, 0, sizeof(req));
memset(, 0, sizeof(cmd));
req.cmd = 
-   if (mmc_get_card_type(dev) == mode_sd)
+   if (sc->mode == mode_sd)
cmd.opcode = SD_ERASE_WR_BLK_END;
else
cmd.opcode = MMC_ERASE_GROUP_END;
___
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: r338264 - head/sys/dev/ixl

2018-08-23 Thread Marius Strobl
Author: marius
Date: Thu Aug 23 18:11:55 2018
New Revision: 338264
URL: https://svnweb.freebsd.org/changeset/base/338264

Log:
  Remove a duplicated interface capability bit missed in r336313.

Modified:
  head/sys/dev/ixl/ixl.h

Modified: head/sys/dev/ixl/ixl.h
==
--- head/sys/dev/ixl/ixl.h  Thu Aug 23 18:06:31 2018(r338263)
+++ head/sys/dev/ixl/ixl.h  Thu Aug 23 18:11:55 2018(r338264)
@@ -260,7 +260,7 @@
 IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6 | \
 IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | \
 IFCAP_VLAN_HWFILTER | IFCAP_VLAN_HWTSO | \
-IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO | \
+IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM | \
 IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU | IFCAP_LRO)
 
 #define IXL_CSUM_TCP \
___
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: r338261 - head/sys/dev/sdhci

2018-08-23 Thread Marius Strobl
Author: marius
Date: Thu Aug 23 17:50:41 2018
New Revision: 338261
URL: https://svnweb.freebsd.org/changeset/base/338261

Log:
  - According to section 2.2.5 of the SDHCI specification version 4.20,
SDHCI_TRNS_ACMD12 is to be set only for multiple-block read/write
commands without data length information, so don't unconditionally
set this bit. The result matches what e. g. Linux does.
  - Section 2.2.19 of the SDHCI specification version 4.20 states that
SDHCI_ACMD12_ERR should be only valid if SDHCI_INT_ACMD12ERR is set
and hardware may clear SDHCI_ACMD12_ERR when SDHCI_INT_ACMD12ERR is
cleared (differing silicon behavior is specifically allowed, though).
Thus, read SDHCI_ACMD12_ERR before clearing SDHCI_INT_ACMD12ERR.
While at it, use the 16-bit accessor rather than the 32-bit one for
reading the 16-bit SDHCI_ACMD12_ERR.
  - SDHCI_INT_TUNEERR isn't one of the ROC bits in SDHCI_INT_STATUS so
clear it explicitly.
  - Add missing prototypes and sort them.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Thu Aug 23 17:41:39 2018(r338260)
+++ head/sys/dev/sdhci/sdhci.c  Thu Aug 23 17:50:41 2018(r338261)
@@ -90,27 +90,49 @@ SYSCTL_INT(_hw_sdhci, OID_AUTO, quirk_set, CTLFLAG_RWT
 #defineWR_MULTI_4(slot, off, ptr, count)   \
 SDHCI_WRITE_MULTI_4((slot)->bus, (slot), (off), (ptr), (count))
 
+static void sdhci_acmd_irq(struct sdhci_slot *slot, uint16_t acmd_err);
 static void sdhci_card_poll(void *arg);
 static void sdhci_card_task(void *arg, int pending);
+static void sdhci_cmd_irq(struct sdhci_slot *slot, uint32_t intmask);
+static void sdhci_data_irq(struct sdhci_slot *slot, uint32_t intmask);
 static int sdhci_exec_tuning(struct sdhci_slot *slot, bool reset);
+static void sdhci_handle_card_present_locked(struct sdhci_slot *slot,
+bool is_present);
+static void sdhci_finish_command(struct sdhci_slot *slot);
+static void sdhci_init(struct sdhci_slot *slot);
+static void sdhci_read_block_pio(struct sdhci_slot *slot);
+static void sdhci_req_done(struct sdhci_slot *slot);
 static void sdhci_req_wakeup(struct mmc_request *req);
+static void sdhci_reset(struct sdhci_slot *slot, uint8_t mask);
 static void sdhci_retune(void *arg);
 static void sdhci_set_clock(struct sdhci_slot *slot, uint32_t clock);
+static void sdhci_set_power(struct sdhci_slot *slot, u_char power);
+static void sdhci_set_transfer_mode(struct sdhci_slot *slot,
+   struct mmc_data *data);
 static void sdhci_start(struct sdhci_slot *slot);
+static void sdhci_timeout(void *arg);
+static void sdhci_start_command(struct sdhci_slot *slot,
+   struct mmc_command *cmd);
 static void sdhci_start_data(struct sdhci_slot *slot, struct mmc_data *data);
+static void sdhci_write_block_pio(struct sdhci_slot *slot);
+static void sdhci_transfer_pio(struct sdhci_slot *slot);
 
 #ifdef MMCCAM
 /* CAM-related */
-int sdhci_cam_get_possible_host_clock(struct sdhci_slot *slot, int 
proposed_clock);
-static int sdhci_cam_update_ios(struct sdhci_slot *slot);
-static int sdhci_cam_request(struct sdhci_slot *slot, union ccb *ccb);
 static void sdhci_cam_action(struct cam_sim *sim, union ccb *ccb);
+static int sdhci_cam_get_possible_host_clock(struct sdhci_slot *slot,
+int proposed_clock);
+static void sdhci_cam_handle_mmcio(struct cam_sim *sim, union ccb *ccb);
 static void sdhci_cam_poll(struct cam_sim *sim);
+static int sdhci_cam_request(struct sdhci_slot *slot, union ccb *ccb);
 static int sdhci_cam_settran_settings(struct sdhci_slot *slot, union ccb *ccb);
+static int sdhci_cam_update_ios(struct sdhci_slot *slot);
 #endif
 
 /* helper routines */
 static void sdhci_dumpregs(struct sdhci_slot *slot);
+static void sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs,
+int error);
 static int slot_printf(struct sdhci_slot *slot, const char * fmt, ...)
 __printflike(2, 3);
 static uint32_t sdhci_tuning_intmask(struct sdhci_slot *slot);
@@ -1547,20 +1569,20 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, struc
return;
 
mode = SDHCI_TRNS_BLK_CNT_EN;
-   if (data->len > 512)
+   if (data->len > 512) {
mode |= SDHCI_TRNS_MULTI;
-   if (data->flags & MMC_DATA_READ)
-   mode |= SDHCI_TRNS_READ;
+   if (__predict_true(
 #ifdef MMCCAM
-   struct ccb_mmcio *mmcio;
-   mmcio = >ccb->mmcio;
-   if (mmcio->stop.opcode == MMC_STOP_TRANSMISSION
-   && !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))
-   mode |= SDHCI_TRNS_ACMD12;
+   slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION &&
 #else
-   if (slot->req->stop && !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))
-   mode |= SDHCI_TRNS_ACMD12;
+   slot->req->stop &&
 #endif
+   !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)))
+ 

svn commit: r337726 - head/sys/dev/e1000

2018-08-13 Thread Marius Strobl
Author: marius
Date: Mon Aug 13 20:29:39 2018
New Revision: 337726
URL: https://svnweb.freebsd.org/changeset/base/337726

Log:
  Remove the duplicated CSUM_IP6_TCP introduced in r311849 from the TX
  checksum capabilities of IGB-class MACs. While at it, fix the line
  wrapping.
  
  PR:   230571

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Mon Aug 13 19:59:42 2018(r337725)
+++ head/sys/dev/e1000/if_em.c  Mon Aug 13 20:29:39 2018(r337726)
@@ -793,8 +793,8 @@ em_if_attach_pre(if_ctx_t ctx)
scctx->isc_tx_tso_size_max = EM_TSO_SIZE;
scctx->isc_tx_tso_segsize_max = EM_TSO_SEG_SIZE;
scctx->isc_capabilities = scctx->isc_capenable = IGB_CAPS;
-   scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP | CSUM_TSO | 
CSUM_IP6_TCP \
-   | CSUM_IP6_UDP | CSUM_IP6_TCP;
+   scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP | CSUM_TSO |
+CSUM_IP6_TCP | CSUM_IP6_UDP;
if (adapter->hw.mac.type != e1000_82575)
scctx->isc_tx_csum_flags |= CSUM_SCTP | CSUM_IP6_SCTP;
 
___
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: r337434 - head/sys/compat/linuxkpi/common/include/asm

2018-08-07 Thread Marius Strobl
Author: marius
Date: Tue Aug  7 18:59:02 2018
New Revision: 337434
URL: https://svnweb.freebsd.org/changeset/base/337434

Log:
  Update the list of architectures having atomic_fcmpset_{8,16,64}(9) and
  atomic_swap_{64,int}(9) respectively as of r337433.

Modified:
  head/sys/compat/linuxkpi/common/include/asm/atomic.h
  head/sys/compat/linuxkpi/common/include/asm/atomic64.h

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic.hTue Aug  7 
18:56:51 2018(r337433)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic.hTue Aug  7 
18:59:02 2018(r337434)
@@ -129,9 +129,7 @@ atomic_clear_mask(unsigned int mask, atomic_t *v)
 static inline int
 atomic_xchg(atomic_t *v, int i)
 {
-#if defined(__i386__) || defined(__amd64__) || \
-defined(__arm__) || defined(__aarch64__) || \
-defined(__powerpc__)
+#if !defined(__mips__)
return (atomic_swap_int(>counter, i));
 #else
int ret;
@@ -159,7 +157,7 @@ atomic_cmpxchg(atomic_t *v, int old, int new)
return (ret);
 }
 
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__amd64__) || defined(__arm64__) || defined(__i386__)
 #defineLINUXKPI_ATOMIC_8(...) __VA_ARGS__
 #defineLINUXKPI_ATOMIC_16(...) __VA_ARGS__
 #else
@@ -167,8 +165,9 @@ atomic_cmpxchg(atomic_t *v, int old, int new)
 #defineLINUXKPI_ATOMIC_16(...)
 #endif
 
-#if defined(__amd64__) || (defined(__ARM_ARCH) && (__ARM_ARCH >= 6)) ||
\
-defined(__aarch64__) || defined(__powerpc64__) || defined(__riscv)
+#if !(defined(i386) || (defined(__mips__) && !(defined(__mips_n32) ||  \
+defined(__mips_n64))) || (defined(__powerpc__) &&  \
+!defined(__powerpc64__)))
 #defineLINUXKPI_ATOMIC_64(...) __VA_ARGS__
 #else
 #defineLINUXKPI_ATOMIC_64(...)

Modified: head/sys/compat/linuxkpi/common/include/asm/atomic64.h
==
--- head/sys/compat/linuxkpi/common/include/asm/atomic64.h  Tue Aug  7 
18:56:51 2018(r337433)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic64.h  Tue Aug  7 
18:59:02 2018(r337434)
@@ -107,9 +107,8 @@ atomic64_add_unless(atomic64_t *v, int64_t a, int64_t 
 static inline int64_t
 atomic64_xchg(atomic64_t *v, int64_t i)
 {
-#if defined(__i386__) || defined(__amd64__) || \
-defined(__arm__) || defined(__aarch64__) || \
-defined(__powerpc64__)
+#if !((defined(__mips__) && !(defined(__mips_n32) || defined(__mips_n64))) || \
+(defined(__powerpc__) && !defined(__powerpc64__)))
return (atomic_swap_64(>counter, i));
 #else
int64_t 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: r337433 - head/sys/riscv/include

2018-08-07 Thread Marius Strobl
Author: marius
Date: Tue Aug  7 18:56:51 2018
New Revision: 337433
URL: https://svnweb.freebsd.org/changeset/base/337433

Log:
  Implement atomic_swap_{int,long,ptr}(9).

Modified:
  head/sys/riscv/include/atomic.h

Modified: head/sys/riscv/include/atomic.h
==
--- head/sys/riscv/include/atomic.h Tue Aug  7 18:56:01 2018
(r337432)
+++ head/sys/riscv/include/atomic.h Tue Aug  7 18:56:51 2018
(r337433)
@@ -412,6 +412,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
return (old);
 }
 
+#defineatomic_swap_int atomic_swap_32
+
 #defineatomic_add_long atomic_add_64
 #defineatomic_clear_long   atomic_clear_64
 #defineatomic_cmpset_long  atomic_cmpset_64
@@ -420,6 +422,7 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
 #defineatomic_readandclear_longatomic_readandclear_64
 #defineatomic_set_long atomic_set_64
 #defineatomic_subtract_longatomic_subtract_64
+#defineatomic_swap_longatomic_swap_64
 
 #defineatomic_add_ptr  atomic_add_64
 #defineatomic_clear_ptratomic_clear_64
@@ -429,6 +432,7 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val)
 #defineatomic_readandclear_ptr atomic_readandclear_64
 #defineatomic_set_ptr  atomic_set_64
 #defineatomic_subtract_ptr atomic_subtract_64
+#defineatomic_swap_ptr atomic_swap_64
 
 ATOMIC_ACQ_REL(set, 64)
 ATOMIC_ACQ_REL(clear, 64)
___
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: r337432 - head/sys/arm/include

2018-08-07 Thread Marius Strobl
Author: marius
Date: Tue Aug  7 18:56:01 2018
New Revision: 337432
URL: https://svnweb.freebsd.org/changeset/base/337432

Log:
  Implement atomic_swap_64(9).

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

Modified: head/sys/arm/include/atomic-v4.h
==
--- head/sys/arm/include/atomic-v4.hTue Aug  7 18:29:10 2018
(r337431)
+++ head/sys/arm/include/atomic-v4.hTue Aug  7 18:56:01 2018
(r337432)
@@ -249,6 +249,19 @@ atomic_subtract_64(volatile u_int64_t *p, u_int64_t va
__with_interrupts_disabled(*p -= val);
 }
 
+static __inline uint64_t
+atomic_swap_64(volatile uint64_t *p, uint64_t v)
+{
+   uint64_t value;
+
+   __with_interrupts_disabled(
+   {
+   value = *p;
+   *p = v;
+   });
+   return (value);
+}
+
 #else /* !_KERNEL */
 
 static __inline 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: r336832 - head/sys/sparc64/include

2018-07-28 Thread Marius Strobl
Author: marius
Date: Sat Jul 28 15:42:57 2018
New Revision: 336832
URL: https://svnweb.freebsd.org/changeset/base/336832

Log:
  Implement atomic_swap_{32,64,int,long,ptr}(9).

Modified:
  head/sys/sparc64/include/atomic.h

Modified: head/sys/sparc64/include/atomic.h
==
--- head/sys/sparc64/include/atomic.h   Sat Jul 28 12:53:10 2018
(r336831)
+++ head/sys/sparc64/include/atomic.h   Sat Jul 28 15:42:57 2018
(r336832)
@@ -154,14 +154,15 @@
e;  \
 })
 
-#defineatomic_st(p, v, sz) do {
\
+#defineatomic_st(p, v, sz) ({  
\
itype(sz) e, r; \
for (e = *(volatile itype(sz) *)(p);; e = r) {  \
r = atomic_cas((p), e, (v), sz);\
if (r == e) \
break;  \
}   \
-} while (0)
+   e;  \
+})
 
 #defineatomic_st_acq(p, v, sz) do {
\
atomic_st((p), (v), sz);\
@@ -310,6 +311,12 @@ static __inline void   
\
 atomic_store_rel_ ## name(volatile ptype p, vtype v)   \
 {  \
atomic_st_rel((p), (v), sz);\
+}  \
+   \
+static __inline vtype  \
+atomic_swap_ ## name(volatile ptype p, vtype v)
\
+{  \
+   return ((vtype)atomic_st((p), (v), sz));\
 }
 
 static __inline 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: r336690 - head/sys/net

2018-07-24 Thread Marius Strobl
Author: marius
Date: Tue Jul 24 23:40:27 2018
New Revision: 336690
URL: https://svnweb.freebsd.org/changeset/base/336690

Log:
  Since r336611, n is only used for INET in iflib_parse_header().
  Reported by:  rpokala

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cTue Jul 24 22:05:55 2018(r336689)
+++ head/sys/net/iflib.cTue Jul 24 23:40:27 2018(r336690)
@@ -2874,7 +2874,7 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, 
 {
if_shared_ctx_t sctx = txq->ift_ctx->ifc_sctx;
struct ether_vlan_header *eh;
-   struct mbuf *m, *n;
+   struct mbuf *m;
 
m = *mp;
if ((sctx->isc_flags & IFLIB_NEED_SCRATCH) &&
@@ -2910,6 +2910,7 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, 
 #ifdef INET
case ETHERTYPE_IP:
{
+   struct mbuf *n;
struct ip *ip = NULL;
struct tcphdr *th = NULL;
int minthlen;
___
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: r336313 - in head/sys: dev/bnxt dev/e1000 dev/ixgbe dev/ixl net sys

2018-07-22 Thread Marius Strobl
On Wed, Jul 18, 2018 at 10:33:13PM +0200, Alexander Leidinger wrote:
> Quoting Marius Strobl  (from Sun, 15 Jul 2018  
> 19:04:23 + (UTC)):
> 
> > Author: marius
> > Date: Sun Jul 15 19:04:23 2018
> > New Revision: 336313
> > URL: https://svnweb.freebsd.org/changeset/base/336313
> >
> > Log:
> >   Assorted TSO fixes for em(4)/iflib(9) and dead code removal:
> [...]
> >   Okayed by:sbruno@ at 201806 DevSummit Transport Working Group [1]
> >   Reviewed by:  sbruno (earlier version), erj
> >   PR:   219428 (part of; comment #10) [1], 220997 (part of; comment #3)
> 
> Hi Marius,
> 
> thanks a lot for this change, it improves the situation (PR 220997) a  
> lot. The system is running at r336329, as such I don't have your  
> change r336356 yet on the system. Maybe the 2 panics (more below) I've  
> seen are fixed by this. Before I try your second change (surely not  
> before the WE), here at least the report in case it is related to your  
> changes and not related to r336313:
> 
> I got 2 panics, both within 6 minutes (based upon the timestamp of the  
> coredumps in the filesystem):
> 
> 1)
> panic: Assertion ifsd_m[next] == NULL failed at /usr/src/sys/net/iflib.c:3151
> cpuid = 2
> time = 1531944124
> KDB: stack backtrace:
> db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfe008af85850
> vpanic() at vpanic+0x1a3/frame 0xfe008af858b0
> doadump() at doadump/frame 0xfe008af85930
> iflib_txq_drain() at iflib_txq_drain+0xe58/frame 0xfe008af85aa0
> ifmp_ring_check_drainage() at ifmp_ring_check_drainage+0x16c/frame  
> 0xfe008af85b00
> _task_fn_tx() at _task_fn_tx+0x76/frame 0xfe008af85b30
> gtaskqueue_run_locked() at gtaskqueue_run_locked+0x139/frame  
> 0xfe008af85b80
> gtaskqueue_thread_loop() at gtaskqueue_thread_loop+0x88/frame  
> 0xfe008af85bb0
> fork_exit() at fork_exit+0x84/frame 0xfe008af85bf0
> fork_trampoline() at fork_trampoline+0xe/frame 0xfe008af85bf0
> --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> Uptime: 1d22h51m17s
> Dumping 2990 out of 8037 MB:..1%..11%..21%..31%..41%..51%..61%..71%..81%..91%
> 
> __curthread () at ./machine/pcpu.h:230
> 230 __asm("movq %%gs:%1,%0" : "=r" (td)
> (kgdb) #0  __curthread () at ./machine/pcpu.h:230
> #1  doadump (textdump=1) at /usr/src/sys/kern/kern_shutdown.c:366
> #2  0x80485ea1 in kern_reboot (howto=260)
>  at /usr/src/sys/kern/kern_shutdown.c:446
> #3  0x80486483 in vpanic (fmt=, ap=0xfe008af858f0)
>  at /usr/src/sys/kern/kern_shutdown.c:863
> #4  0x804861f0 in kassert_panic (
>  fmt=0x807e085f "Assertion %s failed at %s:%d")
>  at /usr/src/sys/kern/kern_shutdown.c:749
> #5  0x8059cd78 in iflib_busdma_load_mbuf_sg (flags=0,
>  txq=, tag=, map=,
>  m0=, segs=, nsegs=,
>  max_segs=) at /usr/src/sys/net/iflib.c:3151
> #6  iflib_encap (txq=0xf800028dc000, m_headp=0xfe00959bdd30)
>  at /usr/src/sys/net/iflib.c:3321
> #7  iflib_txq_drain (r=0xfe00959ba000, cidx=,
>  pidx=41319936) at /usr/src/sys/net/iflib.c:3636
> #8  0x805a0f4c in drain_ring_lockless (r=, os=...,
>  prev=, budget=)
>  at /usr/src/sys/net/mp_ring.c:199
> #9  ifmp_ring_check_drainage (r=, budget=32)
>  at /usr/src/sys/net/mp_ring.c:502
> #10 0x80599c46 in _task_fn_tx (context=)
>  at /usr/src/sys/net/iflib.c:3747
> #11 0x804cd2c9 in gtaskqueue_run_locked (queue=0xf800025e0d00)
>  at /usr/src/sys/kern/subr_gtaskqueue.c:332
> #12 0x804cd048 in gtaskqueue_thread_loop (arg=)
>  at /usr/src/sys/kern/subr_gtaskqueue.c:507
> #13 0x8044cc34 in fork_exit (
>  callout=0x804ccfc0 ,
>  arg=0xfe0007ffd038, frame=0xfe008af85c00)
>  at /usr/src/sys/kern/kern_fork.c:1057
> (kgdb) up 5
> #5  0x8059cd78 in iflib_busdma_load_mbuf_sg (flags=0,  
> txq=, tag=,
>  map=, m0=, segs=,  
> nsegs=, max_segs=)
>  at /usr/src/sys/net/iflib.c:3151
> 3151MPASS(ifsd_m[next] == NULL);
> (kgdb) list
> 3146/*
> 3147 * see if we can't be smarter about physically
> 3148 * contiguous mappings
> 3149 */
> 3150next = (pidx + count) & (ntxd-1);
> 3151MPASS(ifsd_m[next] == NULL);
> 3152#if MEMORY_LOGGING
> 3153txq->ift_enqueued++;
> 3154#endif
> 3155ifsd_m[next] = m;
> (kgdb) print ifsd_m
> $1 = (struct mbuf **) 0xfe00959b8

svn commit: r336612 - head/sys/net

2018-07-22 Thread Marius Strobl
Author: marius
Date: Sun Jul 22 17:51:11 2018
New Revision: 336612
URL: https://svnweb.freebsd.org/changeset/base/336612

Log:
  Use the maximum of isc_tx_{nsegments,tso_segments_max} for MAX_TX_DESC.
  Since r336313, TSO support for LEM-class devices is removed again as it
  was before the conversion of {l,}em(4) to iflib(4) in r311849 and as a
  result, isc_tx_tso_segments_max is 0 for LEM-class devices now. Thus,
  inappropriate watermarks were used for this class.
  
  This is really only a band-aid, though, because so far iflib(9) doesn't
  fully take into account that DMA engines can support different maxima
  of segments for transfers of TSO and non-TSO packets. For example, the
  DESC_RECLAIMABLE macro is based on isc_tx_nsegments while MAX_TX_DESC
  used isc_tx_tso_segments_max only. For most in-tree consumers that
  doesn't make a difference as the maxima are the same for both kinds of
  transfers (that is, apart from the fact that TSO may require up to 2
  sentinel descriptors but also not with every MAC supported). However,
  isc_tx_nsegments is 8 but isc_tx_tso_segments_max is 85 by default
  with ixl(4).

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSun Jul 22 17:45:44 2018(r336611)
+++ head/sys/net/iflib.cSun Jul 22 17:51:11 2018(r336612)
@@ -2831,7 +2831,8 @@ txq_max_rs_deferred(iflib_txq_t txq)
 
 /* XXX we should be setting this to something other than zero */
 #define RECLAIM_THRESH(ctx) ((ctx)->ifc_sctx->isc_tx_reclaim_thresh)
-#define MAX_TX_DESC(ctx) ((ctx)->ifc_softc_ctx.isc_tx_tso_segments_max)
+#defineMAX_TX_DESC(ctx) 
max((ctx)->ifc_softc_ctx.isc_tx_tso_segments_max, \
+(ctx)->ifc_softc_ctx.isc_tx_nsegments)
 
 static inline bool
 iflib_txd_db_check(if_ctx_t ctx, iflib_txq_t txq, int ring, qidx_t in_use)
___
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: r336611 - head/sys/net

2018-07-22 Thread Marius Strobl
Author: marius
Date: Sun Jul 22 17:45:44 2018
New Revision: 336611
URL: https://svnweb.freebsd.org/changeset/base/336611

Log:
  - Given that the controlling expression of the receive loop in iflib_rxeof()
tests for avail > 0, avail can never be 0 within that loop. Thus, move
decrementing avail and budget_left into the loop and before the code which
checks for additional descriptors having become available in case all the
previous ones have been processed but there still is budget left so the
latter code works as expected. [1]
  - In iflib_{busdma_load_mbuf_sg,parse_header}(), remove dead stores to m
and n respectively. [2, 3]
  - In collapse_pkthdr(), ensure that m_next isn't NULL before dereferencing
it. [4]
  - Remove a duplicate assignment of segs in iflib_encap().
  
  Reported by:  Coverity
  CID:  1356027 [1], 1356047 [2], 1368205 [3], 1356028 [4]

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSun Jul 22 17:40:13 2018(r336610)
+++ head/sys/net/iflib.cSun Jul 22 17:45:44 2018(r336611)
@@ -2663,7 +2663,7 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
return (false);
}
 
-   for (budget_left = budget; (budget_left > 0) && (avail > 0); 
budget_left--, avail--) {
+   for (budget_left = budget; budget_left > 0 && avail > 0;) {
if (__predict_false(!CTX_ACTIVE(ctx))) {
DBG_COUNTER_INC(rx_ctx_inactive);
break;
@@ -2697,6 +2697,8 @@ iflib_rxeof(iflib_rxq_t rxq, qidx_t budget)
 
/* will advance the cidx on the corresponding free lists */
m = iflib_rxd_pkt_get(rxq, );
+   avail--;
+   budget_left--;
if (avail == 0 && budget_left)
avail = iflib_rxd_avail(ctx, rxq, *cidxp, budget_left);
 
@@ -2873,14 +2875,14 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, 
struct ether_vlan_header *eh;
struct mbuf *m, *n;
 
-   n = m = *mp;
+   m = *mp;
if ((sctx->isc_flags & IFLIB_NEED_SCRATCH) &&
M_WRITABLE(m) == 0) {
if ((m = m_dup(m, M_NOWAIT)) == NULL) {
return (ENOMEM);
} else {
m_freem(*mp);
-   n = *mp = m;
+   *mp = m;
}
}
 
@@ -3048,6 +3050,8 @@ collapse_pkthdr(struct mbuf *m0)
}
m = m0;
m->m_next = m_next;
+   if (m_next == NULL)
+   return (m);
if ((m_next->m_flags & M_EXT) == 0) {
m = m_defrag(m, M_NOWAIT);
} else {
@@ -3108,7 +3112,7 @@ iflib_busdma_load_mbuf_sg(iflib_txq_t txq, bus_dma_tag
 * Please don't ever do this
 */
if (__predict_false(m->m_len == 0))
-   *m0 = m = collapse_pkthdr(m);
+   *m0 = collapse_pkthdr(m);
 
ctx = txq->ift_ctx;
sctx = ctx->ifc_sctx;
@@ -3285,7 +3289,6 @@ iflib_encap(iflib_txq_t txq, struct mbuf **m_headp)
int err, nsegs, ndesc, max_segs, pidx, cidx, next, ntxd;
bus_dma_tag_t desc_tag;
 
-   segs = txq->ift_segs;
ctx = txq->ift_ctx;
sctx = ctx->ifc_sctx;
scctx = >ifc_softc_ctx;
___
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: r336610 - head/sys/dev/e1000

2018-07-22 Thread Marius Strobl
Author: marius
Date: Sun Jul 22 17:40:13 2018
New Revision: 336610
URL: https://svnweb.freebsd.org/changeset/base/336610

Log:
  o In em_if_update_admin_status():
- Don't bother calling if_setbaudrate(9) as iflib_link_state_change(9)
  takes care of that,
- correctly check for E1000_CTRL_EXT_LINK_MODE_GMII in E1000_CTRL_EXT [1],
- properly convert the uint16_t link_speed to a uint64_t baudrate by
  using IF_Mbps() which contains an appropriate cast [2],
- remove the duplicate link down announcement when bootverbose isn't
  zero and bring the remaining one in line with the other link state
  messages.
  o Remove a dead store to rid in em_if_msix_intr_assign(). [3]
  o Or in the DMA coalescing Rx threshold so the other bits set in E1000_DMACR
remain intact as intended in igb_init_dmac(). [4]
  
  Reported by:  Coverity
  CID:  1378464 [1], 1368765 [2], 1381681 [3], 1304929 [4]

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Sun Jul 22 17:10:12 2018(r336609)
+++ head/sys/dev/e1000/if_em.c  Sun Jul 22 17:40:13 2018(r336610)
@@ -1722,7 +1722,6 @@ em_if_update_admin_status(if_ctx_t ctx)
 {
struct adapter *adapter = iflib_get_softc(ctx);
struct e1000_hw *hw = >hw;
-   struct ifnet *ifp = iflib_get_ifp(ctx);
device_t dev = iflib_get_dev(ctx);
u32 link_check, thstat, ctrl;
 
@@ -1786,8 +1785,8 @@ em_if_update_admin_status(if_ctx_t ctx)
"Full Duplex" : "Half Duplex"));
adapter->link_active = 1;
adapter->smartspeed = 0;
-   if_setbaudrate(ifp, adapter->link_speed * 100);
-   if ((ctrl & E1000_CTRL_EXT_LINK_MODE_GMII) &&
+   if ((ctrl & E1000_CTRL_EXT_LINK_MODE_MASK) ==
+   E1000_CTRL_EXT_LINK_MODE_GMII &&
(thstat & E1000_THSTAT_LINK_THROTTLE))
device_printf(dev, "Link: thermal downshift\n");
/* Delay Link Up for Phy update */
@@ -1802,17 +1801,15 @@ em_if_update_admin_status(if_ctx_t ctx)
adapter->flags |= IGB_MEDIA_RESET;
em_reset(ctx);
}
-   iflib_link_state_change(ctx, LINK_STATE_UP, ifp->if_baudrate);
+   iflib_link_state_change(ctx, LINK_STATE_UP,
+   IF_Mbps(adapter->link_speed));
printf("Link state changed to up\n");
} else if (!link_check && (adapter->link_active == 1)) {
-   if_setbaudrate(ifp, 0);
adapter->link_speed = 0;
adapter->link_duplex = 0;
-   if (bootverbose)
-   device_printf(dev, "Link is Down\n");
adapter->link_active = 0;
-   iflib_link_state_change(ctx, LINK_STATE_DOWN, ifp->if_baudrate);
-   printf("link state changed to down\n");
+   iflib_link_state_change(ctx, LINK_STATE_DOWN, 0);
+   printf("Link state changed to down\n");
}
em_update_stats_counters(adapter);
 
@@ -1985,7 +1982,6 @@ em_if_msix_intr_assign(if_ctx_t ctx, int msix)
 
vector = 0;
for (i = 0; i < adapter->tx_num_queues; i++, tx_que++, vector++) {
-   rid = vector + 1;
snprintf(buf, sizeof(buf), "txq%d", i);
tx_que = >tx_queues[i];
iflib_softirq_alloc_generic(ctx,
@@ -2324,7 +2320,7 @@ igb_init_dmac(struct adapter *adapter, u32 pba)
dmac = pba - 10;
reg = E1000_READ_REG(hw, E1000_DMACR);
reg &= ~E1000_DMACR_DMACTHR_MASK;
-   reg = ((dmac << E1000_DMACR_DMACTHR_SHIFT)
+   reg |= ((dmac << E1000_DMACR_DMACTHR_SHIFT)
& E1000_DMACR_DMACTHR_MASK);
 
/* transition to L0x or L1 if available..*/
___
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: r336356 - head/sys/dev/e1000

2018-07-16 Thread Marius Strobl
Author: marius
Date: Mon Jul 16 19:47:57 2018
New Revision: 336356
URL: https://svnweb.freebsd.org/changeset/base/336356

Log:
  Update igb_sctx_init for r336313, missed when incorporating shurd@'s
  feedback on the initial D15720.
  
  Reported by:  kib

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Mon Jul 16 19:47:29 2018(r336355)
+++ head/sys/dev/e1000/if_em.c  Mon Jul 16 19:47:57 2018(r336356)
@@ -507,12 +507,13 @@ static struct if_shared_ctx em_sctx_init = {
 
 if_shared_ctx_t em_sctx = _sctx_init;
 
-
 static struct if_shared_ctx igb_sctx_init = {
.isc_magic = IFLIB_MAGIC,
.isc_q_align = PAGE_SIZE,
-   .isc_tx_maxsize = EM_TSO_SIZE,
+   .isc_tx_maxsize = EM_TSO_SIZE + sizeof(struct ether_vlan_header),
.isc_tx_maxsegsize = PAGE_SIZE,
+   .isc_tso_maxsize = EM_TSO_SIZE + sizeof(struct ether_vlan_header),
+   .isc_tso_maxsegsize = EM_TSO_SEG_SIZE,
.isc_rx_maxsize = MJUM9BYTES,
.isc_rx_nsegments = 1,
.isc_rx_maxsegsize = MJUM9BYTES,
___
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: r336313 - in head/sys: dev/bnxt dev/e1000 dev/ixgbe dev/ixl net sys

2018-07-15 Thread Marius Strobl
Author: marius
Date: Sun Jul 15 19:04:23 2018
New Revision: 336313
URL: https://svnweb.freebsd.org/changeset/base/336313

Log:
  Assorted TSO fixes for em(4)/iflib(9) and dead code removal:
  - Ever since the workaround for the silicon bug of TSO4 causing MAC hangs
was committed in r295133, CSUM_TSO always got disabled unconditionally
by em(4) on the first invocation of em_init_locked(). However, even with
that problem fixed, it turned out that for at least e. g. 82579 not all
necessary TSO workarounds are in place, still causing MAC hangs even at
Gigabit speed. Thus, for stable/11, TSO usage was deliberately disabled
in r323292 (r323293 for stable/10) for the EM-class by default, allowing
users to turn it on if it happens to work with their particular EM MAC
in a Gigabit-only environment.
In head, the TSO workaround for speeds other than Gigabit was lost with
the conversion to iflib(9) in r311849 (possibly along with another one
or two TSO workarounds). Yet at the same time, for EM-class MACs TSO4
got enabled by default again, causing device hangs. Therefore, change the
default for this hardware class back to have TSO4 off, allowing users
to turn it on manually if it happens to work in their environment as
we do in stable/{10,11}. An alternative would be to add a whitelist of
EM-class devices where TSO4 actually is reliable with the workarounds in
place, but given that the advantage of TSO at Gigabit speed is rather
limited - especially with the overhead of these workarounds -, that's
really not worth it. [1]
This change includes the addition of an isc_capabilities to struct
if_softc_ctx so iflib(9) can also handle interface capabilities that
shouldn't be enabled by default which is used to handle the default-off
capabilities of e1000 as suggested by shurd@ and moving their handling
from em_setup_interface() to em_if_attach_pre() accordingly.
  - Although 82543 support TSO4 in theory, the former lem(4) didn't have
support for TSO4, presumably because TSO4 is even more broken in the
LEM-class of MACs than the later EM ones. Still, TSO4 for LEM-class
devices was enabled as part of the conversion to iflib(9) in r311849,
causing device hangs. So revert back to the pre-r311849 behavior of
not supporting TSO4 for LEM-class at all, which includes not creating
a TSO DMA tag in iflib(9) for devices not having IFCAP_TSO4 set. [2]
  - In fact, the FreeBSD TCP stack can handle a TSO size of IP_MAXPACKET
(65535) rather than FREEBSD_TSO_SIZE_MAX (65518). However, the TSO
DMA must have a maxsize of the maximum TSO size plus the size of a
VLAN header for software VLAN tagging. The iflib(9) converted em(4),
thus, first correctly sets scctx->isc_tx_tso_size_max to EM_TSO_SIZE
in em_if_attach_pre(), but later on overrides it with IP_MAXPACKET
in em_setup_interface() (apparently, left-over from pre-iflib(9)
times). So remove the later and correct iflib(9) to correctly cap
the maximum TSO size reported to the stack at IP_MAXPACKET. While at
it, let iflib(9) use if_sethwtsomax*().
This change includes the addition of isc_tso_max{seg,}size DMA engine
constraints for the TSO DMA tag to struct if_shared_ctx and letting
iflib_txsd_alloc() automatically adjust the maxsize of that tag in case
IFCAP_VLAN_MTU is supported as requested by shurd@.
  - Move the if_setifheaderlen(9) call for adjusting the maximum Ethernet
header length from {ixgbe,ixl,ixlv,ixv,em}_setup_interface() to iflib(9)
so adjustment is automatically done in case IFCAP_VLAN_MTU is supported.
As a consequence, this adjustment now is also done in case of bnxt(4)
which missed it previously.
  - Move the reduction of the maximum TSO segment count reported to the
stack by the number of m_pullup(9) calls (which in the worst case,
can add another mbuf and, thus, the requirement for another DMA
segment each) in the transmit path for performance reasons from
em_setup_interface() to iflib_txsd_alloc() as these pull-ups are now
done in iflib_parse_header() rather than in the no longer existing
em_xmit(). Moreover, this optimization applies to all drivers using
iflib(9) and not just em(4); all in-tree iflib(9) consumers still
have enough room to handle full size TSO packets. Also, reduce the
adjustment to the maximum number of m_pullup(9)'s now performed in
iflib_parse_header().
  - Prior to the conversion of em(4)/igb(4)/lem(4) and ixl(4) to iflib(9)
in r311849 and r335338 respectively, these drivers didn't enable
IFCAP_VLAN_HWFILTER by default due to VLAN events not being passed
through by lagg(4). With iflib(9), IFCAP_VLAN_HWFILTER was turned on
by default but also lagg(4) was fixed in that regard in r203548. So
just remove the now redundant and defunct IFCAP_VLAN_HWFILTER handling
in {em,ixl,ixlv}_setup_interface().
  - Nuke 

svn commit: r336311 - head/sys/dev/ixgbe

2018-07-15 Thread Marius Strobl
Author: marius
Date: Sun Jul 15 18:03:56 2018
New Revision: 336311
URL: https://svnweb.freebsd.org/changeset/base/336311

Log:
  Remove code to disable IFCAP_VLAN_HWFILTER by default for ixgbe(4) as VLAN
  events are passed through by lagg(4) ever since r203548. Deactivation of
  this capability by default due to lagg(4) was already not done for ixgbev(4)
  and has been - although inadvertently - broken when em(4)/igb(4)/lem(4) and
  ixl(4) were converted to iflib(9) in r311849 and r335338 respectively.
  
  Reviewed by:  erj
  Differential Revision:https://reviews.freebsd.org/D15720 (part of)

Modified:
  head/sys/dev/ixgbe/if_ix.c

Modified: head/sys/dev/ixgbe/if_ix.c
==
--- head/sys/dev/ixgbe/if_ix.c  Sun Jul 15 18:03:19 2018(r336310)
+++ head/sys/dev/ixgbe/if_ix.c  Sun Jul 15 18:03:56 2018(r336311)
@@ -1180,15 +1180,6 @@ ixgbe_setup_interface(if_ctx_t ctx)
 
adapter->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
 
-   /*
-* Don't turn this on by default, if vlans are
-* created on another pseudo device (eg. lagg)
-* then vlan events are not passed thru, breaking
-* operation, but with HW FILTER off it works. If
-* using vlans directly on the ixgbe driver you can
-* enable this and get full hardware tag filtering.
-*/
-   if_setcapenablebit(ifp, 0, IFCAP_VLAN_HWFILTER);
adapter->phy_layer = ixgbe_get_supported_physical_layer(>hw);
 
ixgbe_add_media_types(ctx);
___
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: r336309 - head/sys/dev/ixl

2018-07-15 Thread Marius Strobl
Author: marius
Date: Sun Jul 15 18:02:50 2018
New Revision: 336309
URL: https://svnweb.freebsd.org/changeset/base/336309

Log:
  As suggested by a comment in ixl_initialize_vsi(), use if_getcapenable(9)
  instead of directly interrogating ifp->if_capenable.
  
  Reviewed by:  erj (ixl_initialize_vsi())
  Differential Revision:https://reviews.freebsd.org/D15720 (part of)

Modified:
  head/sys/dev/ixl/ixl_pf_main.c
  head/sys/dev/ixl/ixl_txrx.c

Modified: head/sys/dev/ixl/ixl_pf_main.c
==
--- head/sys/dev/ixl/ixl_pf_main.c  Sun Jul 15 17:31:50 2018
(r336308)
+++ head/sys/dev/ixl/ixl_pf_main.c  Sun Jul 15 18:02:50 2018
(r336309)
@@ -1219,8 +1219,7 @@ ixl_initialize_vsi(struct ixl_vsi *vsi)
/* Set VLAN receive stripping mode */
ctxt.info.valid_sections |= I40E_AQ_VSI_PROP_VLAN_VALID;
ctxt.info.port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL;
-   // TODO: Call function to get this cap bit, instead
-   if (vsi->ifp->if_capenable & IFCAP_VLAN_HWTAGGING)
+   if (if_getcapenable(vsi->ifp) & IFCAP_VLAN_HWTAGGING)
ctxt.info.port_vlan_flags |= I40E_AQ_VSI_PVLAN_EMOD_STR_BOTH;
else
ctxt.info.port_vlan_flags |= I40E_AQ_VSI_PVLAN_EMOD_NOTHING;

Modified: head/sys/dev/ixl/ixl_txrx.c
==
--- head/sys/dev/ixl/ixl_txrx.c Sun Jul 15 17:31:50 2018(r336308)
+++ head/sys/dev/ixl/ixl_txrx.c Sun Jul 15 18:02:50 2018(r336309)
@@ -687,7 +687,7 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri)
rxr->packets++;
rxr->rx_packets++;
 
-   if ((vsi->ifp->if_capenable & IFCAP_RXCSUM) != 0)
+   if ((if_getcapenable(vsi->ifp) & IFCAP_RXCSUM) != 0)
ixl_rx_checksum(ri, status, error, ptype);
ri->iri_flowid = le32toh(cur->wb.qword0.hi_dword.rss);
ri->iri_rsstype = ixl_ptype_to_hash(ptype);
___
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: r335303 - head/sys/net

2018-06-17 Thread Marius Strobl
Author: marius
Date: Sun Jun 17 20:33:02 2018
New Revision: 335303
URL: https://svnweb.freebsd.org/changeset/base/335303

Log:
  Assorted fixes to MSI-X/MSI/INTx setup in iflib(9):
  - In iflib_msix_init(), VMMs with broken MSI-X activation are trying
to be worked around by manually enabling PCIM_MSIXCTRL_MSIX_ENABLE
before calling pci_alloc_msix(9). Apart from constituting a layering
violation, this has the problem of leaving PCIM_MSIXCTRL_MSIX_ENABLE
enabled when falling back to MSI or INTx when e. g. MSI-X is black-
listed and initially also when disabled via hw.pci.enable_msix. The
later in turn was incorrectly worked around in r325166.
Since r310806, pci(4) itself has code to deal with broken MSI-X
handling of VMMs, so all of these workarounds in iflib(9) can go,
fixing non-working interrupts when falling back to MSI/INTx. In
any case, possibly further adjustments to broken MSI-X activation
of VMMs like enabling r310806 by default in VM environments need to
be placed into pci(4), not iflib(9). [1]
  - Also remove the pci_enable_busmaster(9) call from iflib_msix_init(),
which is already more properly invoked from iflib_device_attach().
  - When falling back to MSI/INTx, release the MSI-X BAR resource again.
  - When falling back to INTx, ensure scctx->isc_vectors is set to 1 and
not to something higher from a device with more than one MSI message
supported.
  - Make the nearby ring_state(s) stuff (static) const.
  
  Discussed with:   jhb at BSDCan 2018 [1]
  Reviewed by:  imp, jhb
  Differential Revision:https://reviews.freebsd.org/D15729

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cSun Jun 17 20:32:43 2018(r335302)
+++ head/sys/net/iflib.cSun Jun 17 20:33:02 2018(r335303)
@@ -5879,49 +5879,11 @@ iflib_msix_init(if_ctx_t ctx)
 
bar = ctx->ifc_softc_ctx.isc_msix_bar;
admincnt = sctx->isc_admin_intrcnt;
-   /* Override by global tuneable */
-   {
-   int i;
-   size_t len = sizeof(i);
-   err = kernel_sysctlbyname(curthread, "hw.pci.enable_msix", , 
, NULL, 0, NULL, 0);
-   if (err == 0) {
-   if (i == 0)
-   goto msi;
-   }
-   else {
-   device_printf(dev, "unable to read 
hw.pci.enable_msix.");
-   }
-   }
/* Override by tuneable */
if (scctx->isc_disable_msix)
goto msi;
 
/*
-   ** When used in a virtualized environment
-   ** PCI BUSMASTER capability may not be set
-   ** so explicity set it here and rewrite
-   ** the ENABLE in the MSIX control register
-   ** at this point to cause the host to
-   ** successfully initialize us.
-   */
-   {
-   int msix_ctrl, rid;
-
-   pci_enable_busmaster(dev);
-   rid = 0;
-   if (pci_find_cap(dev, PCIY_MSIX, ) == 0 && rid != 0) {
-   rid += PCIR_MSIX_CTRL;
-   msix_ctrl = pci_read_config(dev, rid, 2);
-   msix_ctrl |= PCIM_MSIXCTRL_MSIX_ENABLE;
-   pci_write_config(dev, rid, msix_ctrl, 2);
-   } else {
-   device_printf(dev, "PCIY_MSIX capability not found; "
-  "or rid %d == 0.\n", rid);
-   goto msi;
-   }
-   }
-
-   /*
 * bar == -1 => "trust me I know what I'm doing"
 * Some drivers are for hardware that is so shoddily
 * documented that no one knows which bars are which
@@ -6007,6 +5969,9 @@ iflib_msix_init(if_ctx_t ctx)
return (vectors);
} else {
device_printf(dev, "failed to allocate %d msix vectors, err: %d 
- using MSI\n", vectors, err);
+   bus_release_resource(dev, SYS_RES_MEMORY, bar,
+   ctx->ifc_msix_mem);
+   ctx->ifc_msix_mem = NULL;
}
 msi:
vectors = pci_msi_count(dev);
@@ -6017,6 +5982,7 @@ msi:
device_printf(dev,"Using an MSI interrupt\n");
scctx->isc_intr = IFLIB_INTR_MSI;
} else {
+   scctx->isc_vectors = 1;
device_printf(dev,"Using a Legacy interrupt\n");
scctx->isc_intr = IFLIB_INTR_LEGACY;
}
@@ -6024,7 +5990,7 @@ msi:
return (vectors);
 }
 
-char * ring_states[] = { "IDLE", "BUSY", "STALLED", "ABDICATED" };
+static const char *ring_states[] = { "IDLE", "BUSY", "STALLED", "ABDICATED" };
 
 static int
 mp_ring_state_handler(SYSCTL_HANDLER_ARGS)
@@ -6032,7 +5998,7 @@ mp_ring_state_handler(SYSCTL_HANDLER_ARGS)
int rc;
uint16_t *state = ((uint16_t *)oidp->oid_arg1);
struct sbuf *sb;
-   

svn commit: r334805 - head/release/amd64

2018-06-07 Thread Marius Strobl
Author: marius
Date: Thu Jun  7 18:24:25 2018
New Revision: 334805
URL: https://svnweb.freebsd.org/changeset/base/334805

Log:
  - Once we have shifted arguments up to thrice, base-bits-dir is $1 rather
than $4. Introduce $BASEBITSDIR for clarity and to avoid repeating this
mistake in the future. Fixing this ensures that we pick up newly built
boot bits native to the target rather for/from the host.
  - Apply some of the argument quoting fixes done in r287635 but missing in
later revisions.

Modified:
  head/release/amd64/mkisoimages.sh

Modified: head/release/amd64/mkisoimages.sh
==
--- head/release/amd64/mkisoimages.sh   Thu Jun  7 18:18:13 2018
(r334804)
+++ head/release/amd64/mkisoimages.sh   Thu Jun  7 18:24:25 2018
(r334805)
@@ -36,8 +36,9 @@ if [ -z $MKIMG ]; then
 fi
 
 if [ "$1" = "-b" ]; then
+   BASEBITSDIR="$4"
# This is highly x86-centric and will be used directly below.
-   bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot"
+   bootable="-o bootimage=i386;$BASEBITSDIR/boot/cdboot -o no-emul-boot"
 
# Make EFI system partition (should be done with makefs in the future)
dd if=/dev/zero of=efiboot.img bs=4k count=200
@@ -46,7 +47,7 @@ if [ "$1" = "-b" ]; then
mkdir efi
mount -t msdosfs /dev/$device efi
mkdir -p efi/efi/boot
-   cp "$4/boot/loader.efi" efi/efi/boot/bootx64.efi
+   cp -p "$BASEBITSDIR/boot/loader.efi" efi/efi/boot/bootx64.efi
umount efi
rmdir efi
mdconfig -d -u $device
@@ -54,6 +55,7 @@ if [ "$1" = "-b" ]; then

shift
 else
+   BASEBITSDIR="$3"
bootable=""
 fi
 
@@ -66,9 +68,9 @@ LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
 NAME="$1"; shift
 
 publisher="The FreeBSD Project.  https://www.FreeBSD.org/;
-echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$1/etc/fstab"
+echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
 $MAKEFS -t cd9660 $bootable -o rockridge -o label="$LABEL" -o 
publisher="$publisher" "$NAME" "$@"
-rm -f "$1/etc/fstab"
+rm -f "$BASEBITSDIR/etc/fstab"
 rm -f efiboot.img
 
 if [ "$bootable" != "" ]; then
@@ -84,15 +86,15 @@ if [ "$bootable" != "" ]; then
done
 
# Create a GPT image containing the partitions we need for hybrid boot.
-   imgsize=`stat -f %z $NAME`
+   imgsize=`stat -f %z "$NAME"`
$MKIMG -s gpt \
--capacity $imgsize \
-   -b $4/boot/pmbr \
+   -b "$BASEBITSDIR/boot/pmbr" \
$espparam \
-   -p freebsd-boot:=$4/boot/isoboot \
+   -p freebsd-boot:="$BASEBITSDIR/boot/isoboot" \
-o hybrid.img
 
# Drop the PMBR, GPT, and boot code into the System Area of the ISO.
-   dd if=hybrid.img of=$NAME bs=32k count=1 conv=notrunc
+   dd if=hybrid.img of="$NAME" bs=32k count=1 conv=notrunc
rm -f hybrid.img
 fi
___
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: r334293 - head/sys/dev/usb/controller

2018-05-28 Thread Marius Strobl
Author: marius
Date: Mon May 28 19:55:51 2018
New Revision: 334293
URL: https://svnweb.freebsd.org/changeset/base/334293

Log:
  Describe Fresco Logic FL1100 USB 3.0 controllers.

Modified:
  head/sys/dev/usb/controller/xhci_pci.c

Modified: head/sys/dev/usb/controller/xhci_pci.c
==
--- head/sys/dev/usb/controller/xhci_pci.c  Mon May 28 18:34:16 2018
(r334292)
+++ head/sys/dev/usb/controller/xhci_pci.c  Mon May 28 19:55:51 2018
(r334293)
@@ -113,6 +113,8 @@ xhci_pci_match(device_t self)
 
case 0x10001b73:
return ("Fresco Logic FL1000G USB 3.0 controller");
+   case 0x11001b73:
+   return ("Fresco Logic FL1100 USB 3.0 controller");
 
case 0x10421b21:
return ("ASMedia ASM1042 USB 3.0 controller");
___
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: r333955 - in head/stand: common ofw/libofw sparc64/loader

2018-05-20 Thread Marius Strobl
Author: marius
Date: Mon May 21 01:20:19 2018
New Revision: 333955
URL: https://svnweb.freebsd.org/changeset/base/333955

Log:
  - Unbreak booting sparc64 kernels after the metadata unification in
r329190; sparc64 kernels are always 64-bit but with that revision
in place, the loader was treating them as 32-bit ones.
  - In order to reduce the likelihood of this kind of breakage in the
future, #ifdef out md_load() on sparc64 and make md_load_dual() -
which is currently local to metadata.c anyway - static.
  - Make md_getboothowto() - also local to metadata.c - static.
  - Get rid of the unused DTB pointer on sparc64.

Modified:
  head/stand/common/metadata.c
  head/stand/ofw/libofw/libofw.h
  head/stand/sparc64/loader/main.c

Modified: head/stand/common/metadata.c
==
--- head/stand/common/metadata.cMon May 21 01:16:26 2018
(r333954)
+++ head/stand/common/metadata.cMon May 21 01:20:19 2018
(r333955)
@@ -94,7 +94,7 @@ md_bootserial(void)
 }
 #endif
 
-int
+static int
 md_getboothowto(char *kargs)
 {
 char   *cp;
@@ -307,7 +307,7 @@ md_copymodules(vm_offset_t addr, int kern64)
  * - The kernel environment is copied into kernel space.
  * - Module metadata are formatted and placed in kernel space.
  */
-int
+static int
 md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64)
 {
 struct preloaded_file  *kfp;
@@ -460,13 +460,15 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs
 return(0);
 }
 
+#if !defined(__sparc64__)
 int
 md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb)
 {
 return (md_load_dual(args, modulep, dtb, 0));
 }
+#endif
 
-#if defined(__mips__) || defined(__powerpc__)
+#if defined(__mips__) || defined(__powerpc__) || defined(__sparc64__)
 int
 md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb)
 {

Modified: head/stand/ofw/libofw/libofw.h
==
--- head/stand/ofw/libofw/libofw.h  Mon May 21 01:16:26 2018
(r333954)
+++ head/stand/ofw/libofw/libofw.h  Mon May 21 01:20:19 2018
(r333955)
@@ -62,7 +62,9 @@ struct preloaded_file;
 struct file_format;
 
 /* MD code implementing MI interfaces */
+#if !defined(__sparc64__)
 vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
+#endif
 vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
 
 extern voidreboot(void);

Modified: head/stand/sparc64/loader/main.c
==
--- head/stand/sparc64/loader/main.cMon May 21 01:16:26 2018
(r333954)
+++ head/stand/sparc64/loader/main.cMon May 21 01:20:19 2018
(r333955)
@@ -339,7 +339,7 @@ static int
 __elfN(exec)(struct preloaded_file *fp)
 {
struct file_metadata *fmp;
-   vm_offset_t mdp, dtbp;
+   vm_offset_t mdp;
Elf_Addr entry;
Elf_Ehdr *e;
int error;
@@ -348,7 +348,7 @@ __elfN(exec)(struct preloaded_file *fp)
return (EFTYPE);
e = (Elf_Ehdr *)>md_data;
 
-   if ((error = md_load(fp->f_args, , )) != 0)
+   if ((error = md_load64(fp->f_args, , NULL)) != 0)
return (error);
 
printf("jumping to kernel entry at %#lx.\n", e->e_entry);
___
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: r333647 - head/sys/dev/mmc

2018-05-15 Thread Marius Strobl
Author: marius
Date: Tue May 15 21:15:09 2018
New Revision: 333647
URL: https://svnweb.freebsd.org/changeset/base/333647

Log:
  - If present, take advantage of the R/W cache of eMMC revision 1.5 and
later devices. These caches work akin to the ones found in HDDs/SSDs
that ada(4)/da(4) also enable if existent, but likewise increase the
likelihood of data loss in case of a sudden power outage etc. On the
other hand, write performance is up to twice as high for e. g. 1 GiB
files depending on the actual chip and transfer mode employed.
For maximum data integrity, the usage of eMMC caches can be disabled
via the hw.mmcsd.cache tunable.
  - Get rid of the NOP mmcsd_open().

Modified:
  head/sys/dev/mmc/mmcreg.h
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcreg.h
==
--- head/sys/dev/mmc/mmcreg.h   Tue May 15 21:07:11 2018(r333646)
+++ head/sys/dev/mmc/mmcreg.h   Tue May 15 21:15:09 2018(r333647)
@@ -357,6 +357,8 @@ struct mmc_request {
 /*
  * EXT_CSD fields
  */
+#defineEXT_CSD_FLUSH_CACHE 32  /* W/E */
+#defineEXT_CSD_CACHE_CTRL  33  /* R/W/E */
 #defineEXT_CSD_EXT_PART_ATTR   52  /* R/W, 2 bytes */
 #defineEXT_CSD_ENH_START_ADDR  136 /* R/W, 4 bytes */
 #defineEXT_CSD_ENH_SIZE_MULT   140 /* R/W, 3 bytes */
@@ -390,12 +392,19 @@ struct mmc_request {
 #defineEXT_CSD_PWR_CL_200_360  237 /* RO */
 #defineEXT_CSD_PWR_CL_52_195_DDR 238   /* RO */
 #defineEXT_CSD_PWR_CL_52_360_DDR 239   /* RO */
+#defineEXT_CSD_CACHE_FLUSH_POLICY 249  /* RO */
 #defineEXT_CSD_GEN_CMD6_TIME   248 /* RO */
+#defineEXT_CSD_CACHE_SIZE  249 /* RO, 4 bytes */
 #defineEXT_CSD_PWR_CL_200_360_DDR 253  /* RO */
 
 /*
  * EXT_CSD field definitions
  */
+#defineEXT_CSD_FLUSH_CACHE_FLUSH   0x01
+#defineEXT_CSD_FLUSH_CACHE_BARRIER 0x02
+
+#defineEXT_CSD_CACHE_CTRL_CACHE_EN 0x01
+
 #defineEXT_CSD_EXT_PART_ATTR_DEFAULT   0x0
 #defineEXT_CSD_EXT_PART_ATTR_SYSTEMCODE0x1
 #defineEXT_CSD_EXT_PART_ATTR_NPERSISTENT   0x2
@@ -474,6 +483,8 @@ struct mmc_request {
 #defineEXT_CSD_SEC_FEATURE_SUPPORT_BD_BLK_EN   0x04
 #defineEXT_CSD_SEC_FEATURE_SUPPORT_GB_CL_EN0x10
 #defineEXT_CSD_SEC_FEATURE_SUPPORT_SANITIZE0x40
+
+#defineEXT_CSD_CACHE_FLUSH_POLICY_FIFO 0x01
 
 /*
  * Vendor specific EXT_CSD fields

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cTue May 15 21:07:11 2018(r333646)
+++ head/sys/dev/mmc/mmcsd.cTue May 15 21:15:09 2018(r333647)
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -132,6 +133,8 @@ struct mmcsd_softc {
uint32_t flags;
 #defineMMCSD_INAND_CMD38   0x0001
 #defineMMCSD_USE_TRIM  0x0002
+#defineMMCSD_FLUSH_CACHE   0x0004
+#defineMMCSD_DIRTY 0x0008
uint32_t cmd6_time; /* Generic switch timeout [us] */
uint32_t part_time; /* Partition switch timeout [us] */
off_t enh_base; /* Enhanced user data area slice base ... */
@@ -152,12 +155,19 @@ static const char *errmsg[] =
"NO MEMORY"
 };
 
+static SYSCTL_NODE(_hw, OID_AUTO, mmcsd, CTLFLAG_RD, NULL, "mmcsd driver");
+
+static int mmcsd_cache = 1;
+SYSCTL_INT(_hw_mmcsd, OID_AUTO, cache, CTLFLAG_RDTUN, _cache, 0,
+"Device R/W cache enabled if present");
+
 #defineLOG_PPS 5 /* Log no more than 5 errors per second. */
 
 /* bus entry points */
 static int mmcsd_attach(device_t dev);
 static int mmcsd_detach(device_t dev);
 static int mmcsd_probe(device_t dev);
+static int mmcsd_shutdown(device_t dev);
 
 /* disk routines */
 static int mmcsd_close(struct disk *dp);
@@ -166,7 +176,6 @@ static int mmcsd_dump(void *arg, void *virtual, vm_off
 static int mmcsd_getattr(struct bio *);
 static int mmcsd_ioctl_disk(struct disk *disk, u_long cmd, void *data,
 int fflag, struct thread *td);
-static int mmcsd_open(struct disk *dp);
 static void mmcsd_strategy(struct bio *bp);
 static void mmcsd_task(void *arg);
 
@@ -179,6 +188,7 @@ static void mmcsd_add_part(struct mmcsd_softc *sc, u_i
 static int mmcsd_bus_bit_width(device_t dev);
 static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp);
 static const char *mmcsd_errmsg(int e);
+static int mmcsd_flush_cache(struct mmcsd_softc *sc);
 static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data,
 int fflag, struct thread *td);
 static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic,
@@ -297,6 +307,31 @@ mmcsd_attach(device_t dev)
rev = ext_csd[EXT_CSD_REV];
 
/*
+* With revision 1.5 (MMC 

svn commit: r333646 - head/sys/dev/mmc

2018-05-15 Thread Marius Strobl
Author: marius
Date: Tue May 15 21:07:11 2018
New Revision: 333646
URL: https://svnweb.freebsd.org/changeset/base/333646

Log:
  Restore style(9) conformance after r320844 (actually requested pre-
  commit) and bring the r320844 additions in line with existing bits.

Modified:
  head/sys/dev/mmc/mmcreg.h

Modified: head/sys/dev/mmc/mmcreg.h
==
--- head/sys/dev/mmc/mmcreg.h   Tue May 15 20:28:50 2018(r333645)
+++ head/sys/dev/mmc/mmcreg.h   Tue May 15 21:07:11 2018(r333646)
@@ -159,34 +159,35 @@ struct mmc_command {
 #defineR1_STATE_PRG7
 #defineR1_STATE_DIS8
 
-/* R4 response (SDIO) */
-#define R4_IO_NUM_FUNCTIONS(ocr)   (((ocr) >> 28) & 0x3)
-#define R4_IO_MEM_PRESENT  (0x1<<27)
-#define R4_IO_OCR_MASK 0x00f0
+/* R4 responses (SDIO) */
+#defineR4_IO_NUM_FUNCTIONS(ocr)(((ocr) >> 28) & 0x3)
+#defineR4_IO_MEM_PRESENT   (0x1 << 27)
+#defineR4_IO_OCR_MASK  0x00f0
 
 /*
  * R5 responses
  *
  * Types (per SD 2.0 standard)
- *e : error bit
- *s : status bit
- *r : detected and set for the actual command response
- *x : Detected and set during command execution.  The host can get
- *the status by issuing a command with R1 response.
+ * e : error bit
+ * s : status bit
+ * r : detected and set for the actual command response
+ * x : Detected and set during command execution.  The host can get
+ * the status by issuing a command with R1 response.
  *
  * Clear Condition (per SD 2.0 standard)
- *a : according to the card current state.
- *b : always related to the previous command.  reception of a valid
- *command will clear it (with a delay of one command).
- *c : clear by read
+ * a : according to the card current state.
+ * b : always related to the previous command.  reception of a valid
+ * command will clear it (with a delay of one command).
+ * c : clear by read
  */
-#define R5_COM_CRC_ERROR   (1u << 15)/* er, b */
-#define R5_ILLEGAL_COMMAND (1u << 14)/* er, b */
-#define R5_IO_CURRENT_STATE_MASK   (3u << 12)/* s, b */
-#define R5_IO_CURRENT_STATE(x) (((x) & 
R5_IO_CURRENT_STATE_MASK) >> 12)
-#define R5_ERROR   (1u << 11)/* erx, c */
-#define R5_FUNCTION_NUMBER (1u << 9)/* er, c */
-#define R5_OUT_OF_RANGE(1u << 8)/* er, c */
+#defineR5_COM_CRC_ERROR(1u << 15)  /* er, b */
+#defineR5_ILLEGAL_COMMAND  (1u << 14)  /* er, b */
+#defineR5_IO_CURRENT_STATE_MASK(3u << 12)  /* s, b */
+#defineR5_IO_CURRENT_STATE(x)  (((x) & 
R5_IO_CURRENT_STATE_MASK) >> 12)
+#defineR5_ERROR(1u << 11)  /* erx, c */
+#defineR5_FUNCTION_NUMBER  (1u << 9)   /* er, c */
+#defineR5_OUT_OF_RANGE (1u << 8)   /* er, c */
+
 struct mmc_data {
size_t len; /* size of the data */
size_t xfer_len;
@@ -219,7 +220,7 @@ struct mmc_request {
 #defineSD_SEND_RELATIVE_ADDR   3
 #defineMMC_SET_DSR 4
 #defineMMC_SLEEP_AWAKE 5
-#define IO_SEND_OP_COND5
+#defineIO_SEND_OP_COND 5
 #defineMMC_SWITCH_FUNC 6
 #define MMC_SWITCH_FUNC_CMDS0
 #define MMC_SWITCH_FUNC_SET 1
@@ -310,30 +311,30 @@ struct mmc_request {
 /* Class 9: I/O cards (sd) */
 #defineSD_IO_RW_DIRECT 52
 /* CMD52 arguments */
-#define  SD_ARG_CMD52_READ (0<<31)
-#define  SD_ARG_CMD52_WRITE(1<<31)
-#define  SD_ARG_CMD52_FUNC_SHIFT   28
-#define  SD_ARG_CMD52_FUNC_MASK0x7
-#define  SD_ARG_CMD52_EXCHANGE (1<<27)
-#define  SD_ARG_CMD52_REG_SHIFT9
-#define  SD_ARG_CMD52_REG_MASK 0x1
-#define  SD_ARG_CMD52_DATA_SHIFT   0
-#define  SD_ARG_CMD52_DATA_MASK0xff
-#define  SD_R5_DATA(resp)  ((resp)[0] & 0xff)
+#define SD_ARG_CMD52_READ  (0 << 31)
+#define SD_ARG_CMD52_WRITE (1 << 31)
+#define SD_ARG_CMD52_FUNC_SHIFT28
+#define SD_ARG_CMD52_FUNC_MASK 0x7
+#define SD_ARG_CMD52_EXCHANGE  (1 << 27)
+#define SD_ARG_CMD52_REG_SHIFT 9
+#define SD_ARG_CMD52_REG_MASK  0x1
+#define SD_ARG_CMD52_DATA_SHIFT0
+#define SD_ARG_CMD52_DATA_MASK 0xff
+#define SD_R5_DATA(resp)   ((resp)[0] & 0xff)
 
 #defineSD_IO_RW_EXTENDED   53
 /* CMD53 arguments */
-#define  SD_ARG_CMD53_READ (0<<31)
-#define  SD_ARG_CMD53_WRITE(1<<31)
-#define  SD_ARG_CMD53_FUNC_SHIFT   28
-#define  

svn commit: r333614 - head/sys/dev/mmc

2018-05-14 Thread Marius Strobl
Author: marius
Date: Mon May 14 21:57:45 2018
New Revision: 333614
URL: https://svnweb.freebsd.org/changeset/base/333614

Log:
  Let mmcsd_ioctl() ensure appropriate privileges via priv_check(9).

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cMon May 14 21:46:06 2018(r333613)
+++ head/sys/dev/mmc/mmcsd.cMon May 14 21:57:45 2018(r333614)
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -179,7 +180,7 @@ static int mmcsd_bus_bit_width(device_t dev);
 static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp);
 static const char *mmcsd_errmsg(int e);
 static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data,
-int fflag);
+int fflag, struct thread *td);
 static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic,
 int fflag);
 static uintmax_t mmcsd_pretty_size(off_t size, char *unit);
@@ -771,22 +772,23 @@ mmcsd_strategy(struct bio *bp)
 
 static int
 mmcsd_ioctl_rpmb(struct cdev *dev, u_long cmd, caddr_t data,
-int fflag, struct thread *td __unused)
+int fflag, struct thread *td)
 {
 
-   return (mmcsd_ioctl(dev->si_drv1, cmd, data, fflag));
+   return (mmcsd_ioctl(dev->si_drv1, cmd, data, fflag, td));
 }
 
 static int
 mmcsd_ioctl_disk(struct disk *disk, u_long cmd, void *data, int fflag,
-struct thread *td __unused)
+struct thread *td)
 {
 
-   return (mmcsd_ioctl(disk->d_drv1, cmd, data, fflag));
+   return (mmcsd_ioctl(disk->d_drv1, cmd, data, fflag, td));
 }
 
 static int
-mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag)
+mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag,
+struct thread *td)
 {
struct mmc_ioc_cmd *mic;
struct mmc_ioc_multi_cmd *mimc;
@@ -795,6 +797,10 @@ mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void 
 
if ((fflag & FREAD) == 0)
return (EBADF);
+
+   err = priv_check(td, PRIV_DRIVER);
+   if (err != 0)
+   return (err);
 
err = 0;
switch (cmd) {
___
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: r333613 - head/sys/dev/sdhci

2018-05-14 Thread Marius Strobl
Author: marius
Date: Mon May 14 21:46:06 2018
New Revision: 333613
URL: https://svnweb.freebsd.org/changeset/base/333613

Log:
  The broken DDR52 support of Intel Bay Trail eMMC controllers rumored
  in the commit log of r321385 has been confirmed via the public VLI54
  erratum. Thus, stop advertising DDR52 for these controllers.
  Note that this change should hardly make a difference in practice as
  eMMC chips from the same era as these SoCs most likely support HS200
  at least, probably even up to HS400ES.

Modified:
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Mon May 14 20:06:49 2018
(r333612)
+++ head/sys/dev/sdhci/sdhci_acpi.c Mon May 14 21:46:06 2018
(r333613)
@@ -60,7 +60,6 @@ static const struct sdhci_acpi_device {
{ "80860F14",   1, "Intel Bay Trail/Braswell eMMC 4.5/4.5.1 Controller",
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
-   SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ "80860F14",   3, "Intel Bay Trail/Braswell SDXC Controller",
@@ -261,11 +260,16 @@ sdhci_acpi_attach(device_t dev)
return (ENOMEM);
}
 
-   /* Intel Braswell eMMC 4.5.1 controller quirk */
+   /*
+* Intel Bay Trail and Braswell eMMC controllers share the same IDs,
+* but while with these former DDR52 is affected by the VLI54 erratum,
+* these latter require the timeout clock to be hardcoded to 1 MHz.
+*/
if (strcmp(acpi_dev->hid, "80860F14") == 0 && acpi_dev->uid == 1 &&
SDHCI_READ_4(dev, >slot, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
SDHCI_READ_4(dev, >slot, SDHCI_CAPABILITIES2) == 0x0807)
-   sc->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_1MHZ;
+   sc->quirks |= SDHCI_QUIRK_MMC_DDR52 |
+   SDHCI_QUIRK_DATA_TIMEOUT_1MHZ;
sc->quirks &= ~sdhci_quirk_clear;
sc->quirks |= sdhci_quirk_set;
sc->slot.quirks = sc->quirks;

Modified: head/sys/dev/sdhci/sdhci_pci.c
==
--- head/sys/dev/sdhci/sdhci_pci.c  Mon May 14 20:06:49 2018
(r333612)
+++ head/sys/dev/sdhci/sdhci_pci.c  Mon May 14 21:46:06 2018
(r333613)
@@ -108,18 +108,18 @@ static const struct sdhci_device {
{ 0x16bc14e4,   0x, "Broadcom BCM577xx SDXC/MMC Card Reader",
SDHCI_QUIRK_BCM577XX_400KHZ_CLKSRC },
{ 0x0f148086,   0x, "Intel Bay Trail eMMC 4.5 Controller",
+   /* DDR52 is supported but affected by the VLI54 erratum */
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
-   SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN},
{ 0x0f158086,   0x, "Intel Bay Trail SDXC Controller",
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x0f508086,   0x, "Intel Bay Trail eMMC 4.5 Controller",
+   /* DDR52 is supported but affected by the VLI54 erratum */
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
-   SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x19db8086,   0x, "Intel Denverton eMMC 5.0 Controller",
___
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: r327314 - head/sys/x86/x86

2018-03-14 Thread Marius Strobl
On Wed, Mar 14, 2018 at 07:18:41PM -0400, Ed Maste wrote:
> On 28 December 2017 at 16:46, Marius Strobl <mar...@freebsd.org> wrote:
> > Author: marius
> > Date: Thu Dec 28 21:46:09 2017
> > New Revision: 327314
> > URL: https://svnweb.freebsd.org/changeset/base/327314
> >
> > Log:
> >   With the advent of interrupt remapping, Intel has repurposed bit 11
> >   (now: Interrupt_Index[15]) and assigned the previously reserved bits
> >   ...
> 
> Will you MFC this to stable/11 so it can arrive in 11.2?

Yes, in fact I was working on the MFCs when your e-mail arrived but
am struggling with some unrelated build fuck-ups.

Marius

___
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: r329758 - head/stand/sparc64/loader

2018-02-21 Thread Marius Strobl
Author: marius
Date: Wed Feb 21 22:24:49 2018
New Revision: 329758
URL: https://svnweb.freebsd.org/changeset/base/329758

Log:
  Fix compilation with LOADER_DEBUG defined after r329725.

Modified:
  head/stand/sparc64/loader/main.c

Modified: head/stand/sparc64/loader/main.c
==
--- head/stand/sparc64/loader/main.cWed Feb 21 22:14:19 2018
(r329757)
+++ head/stand/sparc64/loader/main.cWed Feb 21 22:24:49 2018
(r329758)
@@ -938,7 +938,7 @@ static const char *const page_sizes[] = {
 
 static void
 pmap_print_tte_sun4u(tte_t tag, tte_t tte)
-
+{
 
printf("%s %s ",
page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_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: r328865 - head/tools/boot

2018-02-04 Thread Marius Strobl
Author: marius
Date: Mon Feb  5 00:18:21 2018
New Revision: 328865
URL: https://svnweb.freebsd.org/changeset/base/328865

Log:
  Flesh out the creation of sparc64 UFS images. This has only been verified
  to yield working images in a native build as rootgen.sh generally doesn't
  support cross-testing so far.

Modified:
  head/tools/boot/install-boot.sh
  head/tools/boot/rootgen.sh

Modified: head/tools/boot/install-boot.sh
==
--- head/tools/boot/install-boot.sh Sun Feb  4 23:01:48 2018
(r328864)
+++ head/tools/boot/install-boot.sh Mon Feb  5 00:18:21 2018
(r328865)
@@ -78,12 +78,22 @@ boot_nogeli_mbr_ufs_legacy() {
 doit gpart bootcode -b ${mbr0} ${dev}
 s=$(findpart $dev "freebsd-ufs")
 if [ -z "$s" ] ; then
-   die "No freebsd-zfs slice found"
+   die "No freebsd-ufs slice found"
 fi
 doit gpart bootcode -p ${mbr2} ${dev}s${s}
 exit 0
 }
 
+boot_nogeli_vtoc8_ufs_ofw() {
+dev=$1
+dst=$2
+
+# For non-native builds, ensure that geom_part(4) supports VTOC8.
+kldload geom_part_vtoc8.ko
+doit gpart bootcode -p ${vtoc8} ${dev}
+exit 0
+}
+
 DESTDIR=/
 
 # Note: we really don't support geli boot in this script yet.
@@ -127,6 +137,9 @@ gptzfs2=${DESTDIR}/boot/gptzfsboot
 # For MBR, we have lots of choices, but select boot0
 mbr0=${DESTDIR}/boot/boot0
 mbr2=${DESTDIR}/boot/boot
+
+# VTOC8
+vtoc8=${DESTDIR}/boot/boot1
 
 # sanity check here
 

Modified: head/tools/boot/rootgen.sh
==
--- head/tools/boot/rootgen.sh  Sun Feb  4 23:01:48 2018(r328864)
+++ head/tools/boot/rootgen.sh  Mon Feb  5 00:18:21 2018(r328865)
@@ -193,6 +193,29 @@ mk_geli_mbr_zfs_both() {
 # u-boot
 # powerpc
 
+mk_sparc64_nogeli_vtoc8_ufs_ofw() {
+src=$1
+img=$2
+mntpt=$3
+geli=$4
+scheme=$5
+fs=$6
+bios=$7
+
+cat > ${src}/etc/fstab  ${DESTDIR}/boot.config
 # XXX
@@ -396,18 +420,21 @@ for arch in powerpc powerpc64; do
 done
 
 for arch in sparc64; do
-for scheme in sun; do
-   fs=ufs
-   for bios in ofw; do
-   # Create sparse file and mount newly created filesystem(s) on it
-   img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
-   sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
-   echo "vv   Creating $img  
vvv"
-   rm -f ${img}*
-   eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} 
${geli} ${scheme} ${fs} ${bios}
-   eval qemu_${arch}_${bios} ${img} ${sh}
-   [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
-   echo "^^   Creating $img  
^^^"
+for geli in nogeli; do
+   for scheme in vtoc8; do
+   for fs in ufs; do
+   for bios in ofw; do
+   # Create sparse file and mount newly created filesystem(s) 
on it
+   img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
+   sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+   echo "vv   Creating $img  
vvv"
+   rm -f ${img}*
+   eval mk_${arch}_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} 
${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
+   eval qemu_${arch}_${bios} ${img} ${sh}
+   [ -n "${SUDO_USER}" ] && chown ${SUDO_USER} ${img}*
+   echo "^^   Creating $img  
^^^"
+   done
+   done
done
 done
 done
___
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: r328834 - in head: lib/libc/sparc64/sys libexec/rtld-elf libexec/rtld-elf/aarch64 libexec/rtld-elf/amd64 libexec/rtld-elf/arm libexec/rtld-elf/i386 libexec/rtld-elf/mips libexec/rtld-el...

2018-02-03 Thread Marius Strobl
Author: marius
Date: Sat Feb  3 23:14:11 2018
New Revision: 328834
URL: https://svnweb.freebsd.org/changeset/base/328834

Log:
  o Let rtld(1) set up psABI user trap handlers prior to executing the
objects' init functions instead of doing the setup via a constructor
in libc as the init functions may already depend on these handlers
to be in place. This gets us rid of:
- the undefined order in which libc constructors as __guard_setup()
  and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
- the requirement to link libc last so __sparc_utrap_setup() gets
  called prior to constructors in other libraries (see r122883).
For static binaries, crt1.o still sets up the user trap handlers.
  o Move misplaced prototypes for MD functions in to the MD prototype
section of rtld.h.
  o Sprinkle nitems().

Modified:
  head/lib/libc/sparc64/sys/__sparc_utrap_setup.c
  head/libexec/rtld-elf/aarch64/reloc.c
  head/libexec/rtld-elf/amd64/reloc.c
  head/libexec/rtld-elf/arm/reloc.c
  head/libexec/rtld-elf/i386/reloc.c
  head/libexec/rtld-elf/mips/reloc.c
  head/libexec/rtld-elf/powerpc/reloc.c
  head/libexec/rtld-elf/powerpc64/reloc.c
  head/libexec/rtld-elf/riscv/reloc.c
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/rtld.h
  head/libexec/rtld-elf/sparc64/reloc.c

Modified: head/lib/libc/sparc64/sys/__sparc_utrap_setup.c
==
--- head/lib/libc/sparc64/sys/__sparc_utrap_setup.c Sat Feb  3 21:56:38 
2018(r328833)
+++ head/lib/libc/sparc64/sys/__sparc_utrap_setup.c Sat Feb  3 23:14:11 
2018(r328834)
@@ -29,13 +29,11 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
+#include 
 
 #include 
 #include 
 
-#include 
-
 #include "__sparc_utrap_private.h"
 
 static const struct sparc_utrap_args ua[] = {
@@ -47,10 +45,10 @@ static const struct sparc_utrap_args ua[] = {
 };
 
 static const struct sparc_utrap_install_args uia[] = {
-   { sizeof (ua) / sizeof (*ua), ua }
+   { nitems(ua), ua }
 };
 
-void __sparc_utrap_setup(void) __attribute__((constructor));
+void __sparc_utrap_setup(void);
 
 void
 __sparc_utrap_setup(void)

Modified: head/libexec/rtld-elf/aarch64/reloc.c
==
--- head/libexec/rtld-elf/aarch64/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/aarch64/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -306,6 +306,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 /*

Modified: head/libexec/rtld-elf/amd64/reloc.c
==
--- head/libexec/rtld-elf/amd64/reloc.c Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/amd64/reloc.c Sat Feb  3 23:14:11 2018
(r328834)
@@ -487,6 +487,12 @@ ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] 
 }
 
 void
+pre_init(void)
+{
+
+}
+
+void
 allocate_initial_tls(Obj_Entry *objs)
 {
 /*

Modified: head/libexec/rtld-elf/arm/reloc.c
==
--- head/libexec/rtld-elf/arm/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/arm/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -478,6 +478,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 void

Modified: head/libexec/rtld-elf/i386/reloc.c
==
--- head/libexec/rtld-elf/i386/reloc.c  Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/i386/reloc.c  Sat Feb  3 23:14:11 2018
(r328834)
@@ -473,6 +473,12 @@ ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] 
 }
 
 void
+pre_init(void)
+{
+
+}
+
+void
 allocate_initial_tls(Obj_Entry *objs)
 {
 void* tls;

Modified: head/libexec/rtld-elf/mips/reloc.c
==
--- head/libexec/rtld-elf/mips/reloc.c  Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/mips/reloc.c  Sat Feb  3 23:14:11 2018
(r328834)
@@ -745,6 +745,13 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const 
 void
 ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
+
+}
+
+void
+pre_init(void)
+{
+
 }
 
 void

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Sat Feb  3 21:56:38 2018
(r328833)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Sat Feb  3 23:14:11 2018
(r328834)
@@ -628,6 +628,13 @@ init_pltgot(Obj_Entry *obj)
 void
 ifunc_init(Elf_Auxinfo 

svn commit: r328639 - in head/contrib/jemalloc: . include/jemalloc

2018-01-31 Thread Marius Strobl
Author: marius
Date: Wed Jan 31 21:56:23 2018
New Revision: 328639
URL: https://svnweb.freebsd.org/changeset/base/328639

Log:
  Account for the fact that jemalloc 5.0.0 dropped STATIC_PAGE_SHIFT
  in favor for using LG_PAGE directly and, thus, for the fact that
  host and target don't necessarily use pages of the same sizes.
  
  Approved by:  jasone

Modified:
  head/contrib/jemalloc/FREEBSD-diffs
  head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h

Modified: head/contrib/jemalloc/FREEBSD-diffs
==
--- head/contrib/jemalloc/FREEBSD-diffs Wed Jan 31 21:46:37 2018
(r328638)
+++ head/contrib/jemalloc/FREEBSD-diffs Wed Jan 31 21:56:23 2018
(r328639)
@@ -153,7 +153,7 @@ index ..355b565c
 + * each supported architecture.
 + */
 +#undef JEMALLOC_TLS_MODEL
-+#undef STATIC_PAGE_SHIFT
++#undef LG_PAGE
 +#undef LG_VADDR
 +#undef LG_SIZEOF_PTR
 +#undef LG_SIZEOF_INT
@@ -212,7 +212,7 @@ index ..355b565c
 +#  define JEMALLOC_TLS_MODEL  /* Default. */
 +#endif
 +
-+#define   STATIC_PAGE_SHIFT   PAGE_SHIFT
++#define   LG_PAGE PAGE_SHIFT
 +#define   LG_SIZEOF_INT   2
 +#define   LG_SIZEOF_LONG  LG_SIZEOF_PTR
 +#define   LG_SIZEOF_INTMAX_T  3

Modified: head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
==
--- head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h   Wed Jan 31 
21:46:37 2018(r328638)
+++ head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h   Wed Jan 31 
21:56:23 2018(r328639)
@@ -17,7 +17,7 @@
  * each supported architecture.
  */
 #undef JEMALLOC_TLS_MODEL
-#undef STATIC_PAGE_SHIFT
+#undef LG_PAGE
 #undef LG_VADDR
 #undef LG_SIZEOF_PTR
 #undef LG_SIZEOF_INT
@@ -76,7 +76,7 @@
 #  define JEMALLOC_TLS_MODEL   /* Default. */
 #endif
 
-#defineSTATIC_PAGE_SHIFT   PAGE_SHIFT
+#defineLG_PAGE PAGE_SHIFT
 #defineLG_SIZEOF_INT   2
 #defineLG_SIZEOF_LONG  LG_SIZEOF_PTR
 #defineLG_SIZEOF_INTMAX_T  3
___
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: r327950 - in head/sys/powerpc: aim include powerpc ps3

2018-01-16 Thread Marius Strobl
On Mon, Jan 15, 2018 at 03:20:49PM -0800, Nathan Whitehorn wrote:
> 
> 
> On 01/15/18 09:53, Konstantin Belousov wrote:
> > On Mon, Jan 15, 2018 at 09:32:56AM -0800, Nathan Whitehorn wrote:
> >> That seems fine to me. I don't think a less-clumsy way that does not
> >> involve extra indirection is possible. The PHYS_TO_DMAP() returning NULL
> >> is about the best thing I can come up with from a clumsiness standpoint
> >> since plenty of code checks for null pointers already, but doesn't
> >> cleanly handle the rarer case where you want to test for the existence
> >> of direct maps in general without testing some potemkin address.
> >>
> >> My one reservation about PMAP_HAS_DMAP or the like as a selector is that
> >> it does not encode the full shape of the problem: one could imagine
> >> having a direct map that only covers a limited range of RAM (I am not
> >> sure whether the existence of dmaplimit on amd64 implies this can happen
> >> with non-device memory in real life), for example. These cases are
> >> currently covered by an assert() in PHYS_TO_DMAP(), whereas having
> >> PHYS_TO_DMAP() return NULL allows a more flexible signalling and the
> >> potential for the calling code to do something reasonable to handle the
> >> error. A single global flag can't convey information at this kind of
> >> granularity. Is this a reasonable concern? Or am I overthinking things?
> > IMO it is overreaction.  amd64 assumes that all normal memory is covered
> > by DMAP.  It must never fail.   See, for instance, the implementation
> > of the sf bufs for it.
> >
> > If device memory not covered by DMAP can exists, it is the driver problem.
> > For instance, for NVDIMMs I wrote specific mapping code which establishes
> > kernel mapping for it, when not covered by EFI memory map and 
> > correspondingly
> > not included into DMAP.
> >
> 
> Fair enough. Here's a patch with a new flag (DIRECT_MAP_AVAILABLE). I've 
> also retooled the sfbuf code to use this rather than its own flags that 
> mean the same things. The sparc64 part of the patch is untested.
> -Nathan
> Index: sparc64/include/vmparam.h
> ===
> --- sparc64/include/vmparam.h (revision 328006)
> +++ sparc64/include/vmparam.h (working copy)
> @@ -240,10 +240,12 @@
>   */
>  #define  ZERO_REGION_SIZEPAGE_SIZE
>  
> +#include 
> +
>  #define  SFBUF
>  #define  SFBUF_MAP
> -#define  SFBUF_OPTIONAL_DIRECT_MAP   dcache_color_ignore
> -#include 
> -#define  SFBUF_PHYS_DMAP(x)  TLB_PHYS_TO_DIRECT(x)
>  
> +#define DIRECT_MAP_AVAILABLE dcache_color_ignore
> +#define  PHYS_TO_DMAP(x) (DIRECT_MAP_AVAILABLE ? (TLB_PHYS_TO_DIRECT(x) 
> : 0)

What dcache_color_ignore actually indicates is the presence of
hardware unaliasing support, in other words the ability to enter
duplicate cacheable mappings into the MMU. While a direct map is
available and used by MD code on all supported CPUs down to US-I,
the former feature is only implemented in the line of Fujitsu SPARC64
processors. IIRC, the sfbuf(9) code can't guarantee that there isn't
already a cacheable mapping from a different VA to the same PA,
which is why it employs dcache_color_ignore. Is that a general
constraint of all MI PHYS_TO_DMAP users or are there consumers
which can guarantee that they are the only users of a mapping
to the same PA?

Marius
___
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: r327929 - head/sys/dev/mmc

2018-01-13 Thread Marius Strobl
Author: marius
Date: Sat Jan 13 17:36:11 2018
New Revision: 327929
URL: https://svnweb.freebsd.org/changeset/base/327929

Log:
  Use the correct revision specifier (EXT_CSD revision rather than
  system specification version) for deciding whether the EXT_CSD
  register includes the EXT_CSD_GEN_CMD6_TIME field.
  
  Submitted by: Masanobu SAITOH

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Sat Jan 13 17:25:48 2018(r327928)
+++ head/sys/dev/mmc/mmc.c  Sat Jan 13 17:36:11 2018(r327929)
@@ -1868,7 +1868,7 @@ mmc_discover_cards(struct mmc_softc *sc)
 * units of 10 ms), defaulting to 500 ms.
 */
ivar->cmd6_time = 500 * 1000;
-   if (ivar->csd.spec_vers >= 6)
+   if (ivar->raw_ext_csd[EXT_CSD_REV] >= 6)
ivar->cmd6_time = 10 *
ivar->raw_ext_csd[EXT_CSD_GEN_CMD6_TIME];
/* Handle HC erase sector 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: r327926 - head/sys/dev/mmc

2018-01-13 Thread Marius Strobl
Author: marius
Date: Sat Jan 13 16:32:09 2018
New Revision: 327926
URL: https://svnweb.freebsd.org/changeset/base/327926

Log:
  Fix a bug introduced in r327355; in mmcsd_ioctl_cmd() when ensuring
  that userland doesn't switch partitions on its own, compare against
  the partition mmcsd_ioctl_cmd() is going to switch to (based on the
  device node used) rather than the currently selected partition.

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cSat Jan 13 16:31:07 2018(r327925)
+++ head/sys/dev/mmc/mmcsd.cSat Jan 13 16:32:09 2018(r327926)
@@ -920,7 +920,7 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io
 */
if (cmd.opcode == MMC_SWITCH_FUNC && dp != NULL &&
(((uint8_t *)dp)[EXT_CSD_PART_CONFIG] &
-   EXT_CSD_PART_CONFIG_ACC_MASK) != sc->part_curr) {
+   EXT_CSD_PART_CONFIG_ACC_MASK) != part->type) {
err = EINVAL;
goto out;
}
___
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: r327924 - head/sys/dev/sdhci

2018-01-13 Thread Marius Strobl
Author: marius
Date: Sat Jan 13 16:21:13 2018
New Revision: 327924
URL: https://svnweb.freebsd.org/changeset/base/327924

Log:
  Fix a bug introduced in r327339; at the point in time re-tuning is
  executed, the interrupt aggregation code might have disabled the
  SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE bits in slot->intmask
  and the SDHCI_SIGNAL_ENABLE register respectively. So when restoring
  the interrupt masks based on the previous contents of slot->intmask
  in sdhci_exec_tuning(), ensure that the SDHCI_INT_ENABLE register
  doesn't lose these two bits.
  While at it and in the spirit of r327339, let sdhci_tuning_intmask()
  set the tuning error and re-tuning interrupt bits based on the
  SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag
  being set, i. e. only when (re-)tuning is actually used. Currently,
  this changes makes no net difference, though.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Sat Jan 13 14:14:50 2018(r327923)
+++ head/sys/dev/sdhci/sdhci.c  Sat Jan 13 16:21:13 2018(r327924)
@@ -273,7 +273,7 @@ sdhci_tuning_intmask(struct sdhci_slot *slot)
uint32_t intmask;
 
intmask = 0;
-   if (slot->opt & SDHCI_TUNING_SUPPORTED) {
+   if (slot->opt & SDHCI_TUNING_ENABLED) {
intmask |= SDHCI_INT_TUNEERR;
if (slot->retune_mode == SDHCI_RETUNE_MODE_2 ||
slot->retune_mode == SDHCI_RETUNE_MODE_3)
@@ -1439,9 +1439,17 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset)
DELAY(1000);
}
 
+   /*
+* Restore DMA usage and interrupts.
+* Note that the interrupt aggregation code might have cleared
+* SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE in slot->intmask
+* and SDHCI_SIGNAL_ENABLE respectively so ensure SDHCI_INT_ENABLE
+* doesn't lose these.
+*/
slot->opt = opt;
slot->intmask = intmask;
-   WR4(slot, SDHCI_INT_ENABLE, intmask);
+   WR4(slot, SDHCI_INT_ENABLE, intmask | SDHCI_INT_DMA_END |
+   SDHCI_INT_RESPONSE);
WR4(slot, SDHCI_SIGNAL_ENABLE, intmask);
 
if ((hostctrl2 & (SDHCI_CTRL2_EXEC_TUNING |
___
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: r327355 - head/sys/dev/mmc

2017-12-29 Thread Marius Strobl
Author: marius
Date: Fri Dec 29 19:07:50 2017
New Revision: 327355
URL: https://svnweb.freebsd.org/changeset/base/327355

Log:
  - Don't allow userland to switch partitions; it's next to impossible
to recover from that, especially when something goes wrong.
  - When userland changes EXT_CSD, update the kernel copy before using
relevant EXT_CSD bits in mmcsd_switch_part().

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cFri Dec 29 19:05:07 2017(r327354)
+++ head/sys/dev/mmc/mmcsd.cFri Dec 29 19:07:50 2017(r327355)
@@ -914,6 +914,16 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io
default:
break;
}
+   /*
+* No partition switching in userland; it's almost impossible
+* to recover from that, especially if things go wrong.
+*/
+   if (cmd.opcode == MMC_SWITCH_FUNC && dp != NULL &&
+   (((uint8_t *)dp)[EXT_CSD_PART_CONFIG] &
+   EXT_CSD_PART_CONFIG_ACC_MASK) != sc->part_curr) {
+   err = EINVAL;
+   goto out;
+   }
}
dev = sc->dev;
mmcbus = sc->mmcbus;
@@ -934,7 +944,7 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io
if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
/*
 * If the request went to the RPMB partition, try to ensure
-* that the command actually has completed ...
+* that the command actually has completed.
 */
retries = MMCSD_CMD_RETRIES;
do {
@@ -946,13 +956,6 @@ mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_io
break;
DELAY(1000);
} while (retries-- > 0);
-
-switch_back:
-   /* ... and always switch back to the default partition. */
-   err = mmcsd_switch_part(mmcbus, dev, rca,
-   EXT_CSD_PART_CONFIG_ACC_DEFAULT);
-   if (err != MMC_ERR_NONE)
-   goto release;
}
/*
 * If EXT_CSD was changed, our copy is outdated now.  Specifically,
@@ -961,6 +964,17 @@ switch_back:
 */
if (cmd.opcode == MMC_SWITCH_FUNC) {
err = mmc_send_ext_csd(mmcbus, dev, sc->ext_csd);
+   if (err != MMC_ERR_NONE)
+   goto release;
+   }
+switch_back:
+   if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) {
+   /*
+* If the request went to the RPMB partition, always switch
+* back to the default partition (see mmcsd_switch_part()).
+*/
+   err = mmcsd_switch_part(mmcbus, dev, rca,
+   EXT_CSD_PART_CONFIG_ACC_DEFAULT);
if (err != MMC_ERR_NONE)
goto release;
}
___
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: r327339 - head/sys/dev/sdhci

2017-12-29 Thread Marius Strobl
Author: marius
Date: Fri Dec 29 12:48:19 2017
New Revision: 327339
URL: https://svnweb.freebsd.org/changeset/base/327339

Log:
  - There is no need to keep the tuning error and re-tuning interrupts
enabled (though, no interrupt generation enabled for them) all the
time as soon as (re-)tuning is supported; only enable them and let
them generate interrupts when actually using (re-)tuning.
  - Also disable all interrupts except SDHCI_INT_DATA_AVAIL ones while
executing tuning and not just their signaling.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Fri Dec 29 12:47:23 2017(r327338)
+++ head/sys/dev/sdhci/sdhci.c  Fri Dec 29 12:48:19 2017(r327339)
@@ -301,7 +301,7 @@ sdhci_init(struct sdhci_slot *slot)
slot->intmask |= SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT;
}
 
-   WR4(slot, SDHCI_INT_ENABLE, slot->intmask | sdhci_tuning_intmask(slot));
+   WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
 }
 
@@ -654,6 +654,7 @@ sdhci_card_task(void *arg, int pending __unused)
xpt_rescan(ccb);
 #else
slot->intmask &= ~sdhci_tuning_intmask(slot);
+   WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
slot->opt &= ~SDHCI_TUNING_ENABLED;
SDHCI_UNLOCK(slot);
@@ -1338,6 +1339,7 @@ sdhci_generic_tune(device_t brdev __unused, device_t r
if (err == 0) {
slot->opt |= SDHCI_TUNING_ENABLED;
slot->intmask |= sdhci_tuning_intmask(slot);
+   WR4(slot, SDHCI_INT_ENABLE, slot->intmask);
WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask);
if (slot->retune_ticks) {
callout_reset(>retune_callout, slot->retune_ticks,
@@ -1406,6 +1408,7 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset)
 */
intmask = slot->intmask;
slot->intmask = SDHCI_INT_DATA_AVAIL;
+   WR4(slot, SDHCI_INT_ENABLE, SDHCI_INT_DATA_AVAIL);
WR4(slot, SDHCI_SIGNAL_ENABLE, SDHCI_INT_DATA_AVAIL);
 
hostctrl2 = RD2(slot, SDHCI_HOST_CONTROL2);
@@ -1438,6 +1441,7 @@ sdhci_exec_tuning(struct sdhci_slot *slot, bool reset)
 
slot->opt = opt;
slot->intmask = intmask;
+   WR4(slot, SDHCI_INT_ENABLE, intmask);
WR4(slot, SDHCI_SIGNAL_ENABLE, intmask);
 
if ((hostctrl2 & (SDHCI_CTRL2_EXEC_TUNING |
___
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: r327315 - head/sys/dev/sdhci

2017-12-28 Thread Marius Strobl
Author: marius
Date: Thu Dec 28 22:03:08 2017
New Revision: 327315
URL: https://svnweb.freebsd.org/changeset/base/327315

Log:
  Probe Intel Denverton eMMC 5.0 controllers.

Modified:
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/sdhci/sdhci_pci.c
==
--- head/sys/dev/sdhci/sdhci_pci.c  Thu Dec 28 21:46:09 2017
(r327314)
+++ head/sys/dev/sdhci/sdhci_pci.c  Thu Dec 28 22:03:08 2017
(r327315)
@@ -122,6 +122,12 @@ static const struct sdhci_device {
SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
+   { 0x19db8086,   0x, "Intel Denverton eMMC 5.0 Controller",
+   SDHCI_QUIRK_INTEL_POWER_UP_RESET |
+   SDHCI_QUIRK_WAIT_WHILE_BUSY |
+   SDHCI_QUIRK_MMC_DDR52 |
+   SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
+   SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x22948086,   0x, "Intel Braswell eMMC 4.5.1 Controller",
SDHCI_QUIRK_DATA_TIMEOUT_1MHZ |
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
___
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: r327314 - head/sys/x86/x86

2017-12-28 Thread Marius Strobl
Author: marius
Date: Thu Dec 28 21:46:09 2017
New Revision: 327314
URL: https://svnweb.freebsd.org/changeset/base/327314

Log:
  With the advent of interrupt remapping, Intel has repurposed bit 11
  (now: Interrupt_Index[15]) and assigned the previously reserved bits
  55:48 (Interrupt_Index[14:0] goes into 63:49 while Destination Field
  used 63:56 and bit 48 now is Interrupt_Format) in the IO redirection
  tables (see the VT-d specification, "5.1.5.1 I/OxAPIC Programming").
  Thus, when not using interrupt remapping, ensure that all previously
  reserved bits in the high part of the RTEs are zero instead of doing
  a read-modify-write for their Destination Field bits only.
  Otherwise, on machines based on Apollo Lake and its derivatives such
  as Denverton, typically some of the previously preserved bits remain
  set after boot when not employing interrupt remapping. The result is
  that INTx interrupts are not getting delivered.
  Note: With an AMD IOMMU, interrupt remapping apparently bypasses the
  IO APIC altogether.
  
  Submitted by: loos (modulo comment)
  Reviewed by:  jhb (modulo comment)

Modified:
  head/sys/x86/x86/io_apic.c

Modified: head/sys/x86/x86/io_apic.c
==
--- head/sys/x86/x86/io_apic.c  Thu Dec 28 21:35:53 2017(r327313)
+++ head/sys/x86/x86/io_apic.c  Thu Dec 28 21:46:09 2017(r327314)
@@ -308,7 +308,7 @@ static void
 ioapic_program_intpin(struct ioapic_intsrc *intpin)
 {
struct ioapic *io = (struct ioapic *)intpin->io_intsrc.is_pic;
-   uint32_t low, high, value;
+   uint32_t low, high;
 #ifdef ACPI_DMAR
int error;
 #endif
@@ -354,7 +354,11 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin)
}
 #endif
 
-   /* Set the destination. */
+   /*
+* Set the destination.  Note that with Intel interrupt remapping,
+* the previously reserved bits 55:48 now have a purpose so ensure
+* these are zero.
+*/
low = IOART_DESTPHY;
high = intpin->io_cpu << APIC_ID_SHIFT;
 
@@ -392,10 +396,7 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin)
}
 
/* Write the values to the APIC. */
-   value = ioapic_read(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin));
-   value &= ~IOART_DEST;
-   value |= high;
-   ioapic_write(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin), value);
+   ioapic_write(io->io_addr, IOAPIC_REDTBL_HI(intpin->io_intpin), high);
intpin->io_lowreg = low;
ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(intpin->io_intpin), low);
 }
___
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: r324776 - head/sys/dev/mmc

2017-10-19 Thread Marius Strobl
Author: marius
Date: Thu Oct 19 21:57:14 2017
New Revision: 324776
URL: https://svnweb.freebsd.org/changeset/base/324776

Log:
  Correct an inverted conditional for determining the multiplier of
  the user data area size.

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cThu Oct 19 21:34:53 2017(r324775)
+++ head/sys/dev/mmc/mmcsd.cThu Oct 19 21:57:14 2017(r324776)
@@ -327,7 +327,7 @@ mmcsd_attach(device_t dev)
(ext_csd[EXT_CSD_ENH_START_ADDR + 1] << 8) +
(ext_csd[EXT_CSD_ENH_START_ADDR + 2] << 16) +
(ext_csd[EXT_CSD_ENH_START_ADDR + 3] << 24)) *
-   (sc->high_cap != 0 ? MMC_SECTOR_SIZE : 1);
+   (sc->high_cap == 0 ? MMC_SECTOR_SIZE : 1);
} else if (bootverbose)
device_printf(dev,
"enhanced user data area spans entire device\n");
___
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: r323382 - head/contrib/zlib

2017-09-09 Thread Marius Strobl
Author: marius
Date: Sun Sep 10 01:25:15 2017
New Revision: 323382
URL: https://svnweb.freebsd.org/changeset/base/323382

Log:
  MFV: r323381
  
  Permit a deflateParams() parameter change as soon as possible.
  
  This change fixes compression errors seen when the embedded Tomcat
  web server of a UniFi Controller zlib compresses responses. Given
  that Tomcat just uses Java/OpenJDK which in turn employs zlib for
  its compression/decompression support, this bug might very well
  affect other applications, too.
  
  PR:   222136

Modified:
  head/contrib/zlib/deflate.c
  head/contrib/zlib/zlib.h
Directory Properties:
  head/contrib/zlib/   (props changed)

Modified: head/contrib/zlib/deflate.c
==
--- head/contrib/zlib/deflate.c Sun Sep 10 00:56:28 2017(r323381)
+++ head/contrib/zlib/deflate.c Sun Sep 10 01:25:15 2017(r323382)
@@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm)
 s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
 #endif
 adler32(0L, Z_NULL, 0);
-s->last_flush = Z_NO_FLUSH;
+s->last_flush = -2;
 
 _tr_init(s);
 
@@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy)
 func = configuration_table[s->level].func;
 
 if ((strategy != s->strategy || func != configuration_table[level].func) &&
-s->high_water) {
+s->last_flush != -2) {
 /* Flush the last buffer: */
 int err = deflate(strm, Z_BLOCK);
 if (err == Z_STREAM_ERROR)
 return err;
-if (strm->avail_out == 0)
+if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
 return Z_BUF_ERROR;
 }
 if (s->level != level) {

Modified: head/contrib/zlib/zlib.h
==
--- head/contrib/zlib/zlib.hSun Sep 10 00:56:28 2017(r323381)
+++ head/contrib/zlib/zlib.hSun Sep 10 01:25:15 2017(r323382)
@@ -712,11 +712,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
-   strategy is changed, and if any input has been consumed in a previous
-   deflate() call, then the input available so far is compressed with the old
-   level and strategy using deflate(strm, Z_BLOCK).  There are three approaches
-   for the compression levels 0, 1..3, and 4..9 respectively.  The new level
-   and strategy will take effect at the next call of deflate().
+   strategy is changed, and if there have been any deflate() calls since the
+   state was initialized or reset, then the input available so far is
+   compressed with the old level and strategy using deflate(strm, Z_BLOCK).
+   There are three approaches for the compression levels 0, 1..3, and 4..9
+   respectively.  The new level and strategy will take effect at the next call
+   of deflate().
 
  If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will 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: r322986 - head/sys/dev/e1000

2017-08-28 Thread Marius Strobl
Author: marius
Date: Mon Aug 28 22:09:12 2017
New Revision: 322986
URL: https://svnweb.freebsd.org/changeset/base/322986

Log:
  Don't set any WOL enabling hardware bits if WOL isn't requested
  according to the enabled interface capability bits. Also remove
  some dead code, which tried to preserve already set contents of
  E1000_WUC while that register is completely overwritten shortly
  after in all cases.

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Mon Aug 28 21:44:25 2017(r322985)
+++ head/sys/dev/e1000/if_em.c  Mon Aug 28 22:09:12 2017(r322986)
@@ -3639,34 +3639,13 @@ em_enable_wakeup(if_ctx_t ctx)
struct adapter *adapter = iflib_get_softc(ctx);
device_t dev = iflib_get_dev(ctx);
if_t ifp = iflib_get_ifp(ctx);
-   u32 pmc, ctrl, ctrl_ext, rctl, wuc;
+   int error = 0;
+   u32 pmc, ctrl, ctrl_ext, rctl;
u16 status;
 
-   if ((pci_find_cap(dev, PCIY_PMG, ) != 0))
+   if (pci_find_cap(dev, PCIY_PMG, ) != 0)
return;
 
-   /* Advertise the wakeup capability */
-   ctrl = E1000_READ_REG(>hw, E1000_CTRL);
-   ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3);
-   E1000_WRITE_REG(>hw, E1000_CTRL, ctrl);
-   wuc = E1000_READ_REG(>hw, E1000_WUC);
-   wuc |= (E1000_WUC_PME_EN | E1000_WUC_APME);
-   E1000_WRITE_REG(>hw, E1000_WUC, wuc);
-
-   if ((adapter->hw.mac.type == e1000_ich8lan) ||
-   (adapter->hw.mac.type == e1000_pchlan) ||
-   (adapter->hw.mac.type == e1000_ich9lan) ||
-   (adapter->hw.mac.type == e1000_ich10lan))
-   e1000_suspend_workarounds_ich8lan(>hw);
-
-   /* Keep the laser running on Fiber adapters */
-   if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
-   adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
-   ctrl_ext = E1000_READ_REG(>hw, E1000_CTRL_EXT);
-   ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
-   E1000_WRITE_REG(>hw, E1000_CTRL_EXT, ctrl_ext);
-   }
-
/*
 * Determine type of Wakeup: note that wol
 * is set with all bits on by default.
@@ -3685,10 +3664,34 @@ em_enable_wakeup(if_ctx_t ctx)
E1000_WRITE_REG(>hw, E1000_RCTL, rctl);
}
 
+   if (!(adapter->wol & (E1000_WUFC_EX | E1000_WUFC_MAG | E1000_WUFC_MC)))
+   goto pme;
+
+   /* Advertise the wakeup capability */
+   ctrl = E1000_READ_REG(>hw, E1000_CTRL);
+   ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3);
+   E1000_WRITE_REG(>hw, E1000_CTRL, ctrl);
+
+   /* Keep the laser running on Fiber adapters */
+   if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
+   adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
+   ctrl_ext = E1000_READ_REG(>hw, E1000_CTRL_EXT);
+   ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
+   E1000_WRITE_REG(>hw, E1000_CTRL_EXT, ctrl_ext);
+   }
+
+   if ((adapter->hw.mac.type == e1000_ich8lan) ||
+   (adapter->hw.mac.type == e1000_pchlan) ||
+   (adapter->hw.mac.type == e1000_ich9lan) ||
+   (adapter->hw.mac.type == e1000_ich10lan))
+   e1000_suspend_workarounds_ich8lan(>hw);
+
if ( adapter->hw.mac.type >= e1000_pchlan) {
-   if (em_enable_phy_wakeup(adapter))
-   return;
+   error = em_enable_phy_wakeup(adapter);
+   if (error)
+   goto pme;
} else {
+   /* Enable wakeup by the MAC */
E1000_WRITE_REG(>hw, E1000_WUC, E1000_WUC_PME_EN);
E1000_WRITE_REG(>hw, E1000_WUFC, adapter->wol);
}
@@ -3696,10 +3699,10 @@ em_enable_wakeup(if_ctx_t ctx)
if (adapter->hw.phy.type == e1000_phy_igp_3)
e1000_igp3_phy_powerdown_workaround_ich8lan(>hw);
 
-   /* Request PME */
+pme:
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
-   if (if_getcapenable(ifp) & IFCAP_WOL)
+   if (!error && (if_getcapenable(ifp) & IFCAP_WOL))
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 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: r322726 - head/etc/periodic/daily

2017-08-20 Thread Marius Strobl
Author: marius
Date: Sun Aug 20 20:38:15 2017
New Revision: 322726
URL: https://svnweb.freebsd.org/changeset/base/322726

Log:
  Bring back the much more readable unified format for differences in
  /etc/{group,master.passwd}. This was originally turned on for all of
  /etc/{aliases,group,master.passwd} in r55196, but then backed out
  only for the latter two in r56697, as the adaption of the sed(1)ing
  done in r56308 was incorrect. This left us with inconsistent diff(1)
  formats in the daily output of periodic(8) ever since, despite in
  r56697 having been promised to be revisited. So properly adapt the
  password hash filtering to the unified format and turn the later on
  again for /etc/{group,master.passwd}, too.

Modified:
  head/etc/periodic/daily/200.backup-passwd

Modified: head/etc/periodic/daily/200.backup-passwd
==
--- head/etc/periodic/daily/200.backup-passwd   Sun Aug 20 19:21:06 2017
(r322725)
+++ head/etc/periodic/daily/200.backup-passwd   Sun Aug 20 20:38:15 2017
(r322726)
@@ -41,8 +41,8 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host passwd diffs:"
-   diff -I '^#' $bak/master.passwd.bak /etc/master.passwd |\
-   sed 's/^\([<>] [^:]*\):[^:]*:/\1:(password):/'
+   diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\
+   sed 's/^\([-+][^-+:]*\):[^:]*:/\1:(password):/'
mv $bak/master.passwd.bak $bak/master.passwd.bak2
cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3
fi
@@ -58,7 +58,7 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host group diffs:"
-   diff $bak/group.bak /etc/group
+   diff -u $bak/group.bak /etc/group
mv $bak/group.bak $bak/group.bak2
cp -p /etc/group $bak/group.bak || rc=3
fi
___
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: r322209 - head/sys/dev/mmc

2017-08-07 Thread Marius Strobl
Author: marius
Date: Mon Aug  7 23:33:05 2017
New Revision: 322209
URL: https://svnweb.freebsd.org/changeset/base/322209

Log:
  - If available, use TRIM instead of ERASE for implementing BIO_DELETE.
This also involves adding a quirk table as TRIM is broken for some
Kingston eMMC devices, though. Compared to ERASE (declared "legacy"
in the eMMC specification v5.1), TRIM has the advantage of operating
on write sectors rather than on erase sectors, which typically are
of a much larger size. Thus, employing TRIM, we don't need to fiddle
with coalescing BIO_DELETE requests that are also of (write) sector
units into erase sectors, which might not even add up in all cases.
  - For some SanDisk iNAND devices, the CMD38 argument, e. g. ERASE,
TRIM etc., has to be specified via EXT_CSD[113], which now is also
handled via a quirk.
  - My initial understanding was that for eMMC partitions, the granularity
should be used as erase sector size, e. g. 128 KB for boot partitions.
However, rereading the relevant parts of the eMMC specification v5.1,
this isn't actually correct. So drop the code which used partition
granularities for delmaxsize and stripesize. For the most part, this
change is a NOP, though, because a) for ERASE, mmcsd_delete() used
the erase sector size unconditionally for all partitions anyway and
b) g_disk_limit() doesn't actually take the stripesize into account.
  - Take some more advantage of mmcsd_errmsg() in mmcsd(4) for making
error codes human readable.

Modified:
  head/sys/dev/mmc/bridge.h
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcreg.h
  head/sys/dev/mmc/mmcsd.c
  head/sys/dev/mmc/mmcvar.h

Modified: head/sys/dev/mmc/bridge.h
==
--- head/sys/dev/mmc/bridge.h   Mon Aug  7 23:32:00 2017(r322208)
+++ head/sys/dev/mmc/bridge.h   Mon Aug  7 23:33:05 2017(r322209)
@@ -180,7 +180,7 @@ struct mmc_host {
 extern driver_t   mmc_driver;
 extern devclass_t mmc_devclass;
 
-#defineMMC_VERSION 4
+#defineMMC_VERSION 5
 
 #defineMMC_DECLARE_BRIDGE(name)
\
 DRIVER_MODULE(mmc, name, mmc_driver, mmc_devclass, NULL, NULL);\

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Mon Aug  7 23:32:00 2017(r322208)
+++ head/sys/dev/mmc/mmc.c  Mon Aug  7 23:33:05 2017(r322209)
@@ -104,12 +104,34 @@ struct mmc_ivars {
uint32_t hs_tran_speed; /* Max speed in high speed mode */
uint32_t erase_sector;  /* Card native erase sector size */
uint32_t cmd6_time; /* Generic switch timeout [us] */
+   uint32_t quirks;/* Quirks as per mmc_quirk->quirks */
char card_id_string[64];/* Formatted CID info (serial, MFG, etc) */
char card_sn_string[16];/* Formatted serial # for disk->d_ident */
 };
 
 #defineCMD_RETRIES 3
 
+static const struct mmc_quirk mmc_quirks[] = {
+   /*
+* For some SanDisk iNAND devices, the CMD38 argument needs to be
+* provided in EXT_CSD[113].
+*/
+   { 0x2, 0x100,   "SEM02G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM04G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM08G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM16G", MMC_QUIRK_INAND_CMD38 },
+   { 0x2, 0x100,   "SEM32G", MMC_QUIRK_INAND_CMD38 },
+
+   /*
+* Disable TRIM for Kingston eMMCs where a firmware bug can lead to
+* unrecoverable data corruption.
+*/
+   { 0x70, MMC_QUIRK_OID_ANY,  "V10008", MMC_QUIRK_BROKEN_TRIM },
+   { 0x70, MMC_QUIRK_OID_ANY,  "V10016", MMC_QUIRK_BROKEN_TRIM },
+
+   { 0x0, 0x0, NULL, 0x0 }
+};
+
 static SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, NULL, "mmc driver");
 
 static int mmc_debug;
@@ -1109,7 +1131,7 @@ mmc_format_card_id_string(struct mmc_ivars *ivar)
/*
 * Format a card ID string for use by the mmcsd driver, it's what
 * appears between the <> in the following:
-* mmcsd0: 968MB  at mmc0
+* mmcsd0: 968MB  at mmc0
 * 22.5MHz/4bit/128-block
 *
 * Also format just the card serial number, which the mmcsd driver will
@@ -1547,6 +1569,7 @@ mmc_log_card(device_t dev, struct mmc_ivars *ivar, int
break;
}
}
+   device_printf(dev, " quirks: %b\n", ivar->quirks, MMC_QUIRKS_FMT);
device_printf(dev, " bus: %ubit, %uMHz (%s timing)\n",
(ivar->bus_width == bus_width_1 ? 1 :
(ivar->bus_width == bus_width_4 ? 4 : 8)),
@@ -1563,6 +1586,7 @@ mmc_discover_cards(struct mmc_softc *sc)
u_char switch_res[64];
uint32_t raw_cid[4];
struct mmc_ivars *ivar = NULL;
+

svn commit: r322203 - head/usr.sbin/tzsetup

2017-08-07 Thread Marius Strobl
Author: marius
Date: Mon Aug  7 21:38:10 2017
New Revision: 322203
URL: https://svnweb.freebsd.org/changeset/base/322203

Log:
  Revert the parts of r322097 related to /etc/wall_cmos_clock handling as
  the previous behavior actually is required for setting up configurations
  in which the RTC is using UTC but the timezone is not. Still, besides
  uniform error handling, that file should get the same treatment in the
  non-interactive variants supported by tzsetup(8).

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Mon Aug  7 21:29:55 2017
(r322202)
+++ head/usr.sbin/tzsetup/tzsetup.c Mon Aug  7 21:38:10 2017
(r322203)
@@ -866,48 +866,10 @@ install_zoneinfo_file(const char *zoneinfo_file)
 static int
 install_zoneinfo(const char *zoneinfo)
 {
-   int fd, rv;
+   int rv;
FILE*f;
charpath_zoneinfo_file[MAXPATHLEN];
-   charprompt[SILLY_BUFFER_SIZE], title[64];
 
-   if (reallydoit) {
-   if (strcmp(zoneinfo, "UTC") == 0) {
-   if (unlink(path_wall_cmos_clock) < 0 &&
-   errno != ENOENT) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-   "Could not delete %s: %s",
-   path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-#endif
-   fprintf(stderr, "%s\n", prompt);
-
-   return (DITEM_FAILURE | DITEM_RECREATE);
-   }
-   } else {
-   fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT |
-   O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
-   if (fd < 0) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-   "Could not create %s: %s",
-   path_wall_cmos_clock, strerror(errno));
-#ifdef HAVE_DIALOG
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-#endif
-   fprintf(stderr, "%s\n", prompt);
-   return (DITEM_FAILURE | DITEM_RECREATE);
-   }
-   close(fd);
-   }
-   }
-
if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file),
"%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file))
errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo);
@@ -938,6 +900,7 @@ main(int argc, char **argv)
 {
 #ifdef HAVE_DIALOG
chartitle[64], prompt[128];
+   int fd;
 #endif
int c, rv, skiputc;
charvm_guest[16] = "";
@@ -992,7 +955,6 @@ main(int argc, char **argv)
_PATH_WALL_CMOS_CLOCK);
}
 
-
/* Override the user-supplied umask. */
(void)umask(S_IWGRP | S_IWOTH);
 
@@ -1059,11 +1021,19 @@ main(int argc, char **argv)
yesno = dialog_yesno(title, prompt, 7, 73);
dlg_restore_vars(_vars);
if (!yesno) {
+   if (reallydoit)
+   unlink(path_wall_cmos_clock);
+   } else {
if (reallydoit) {
-   rv = install_zoneinfo("UTC");
-   dlg_clear();
-   end_dialog();
-   exit(rv & ~DITEM_LEAVE_MENU);
+   fd = open(path_wall_cmos_clock,
+   O_WRONLY | O_CREAT | O_TRUNC,
+   S_IRUSR | S_IRGRP | S_IROTH);
+   if (fd < 0) {
+   end_dialog();
+   err(1, "create %s",
+   path_wall_cmos_clock);
+   }
+   close(fd);
}
}
dlg_clear();
___
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: r322097 - head/usr.sbin/tzsetup

2017-08-05 Thread Marius Strobl
Author: marius
Date: Sat Aug  5 12:59:03 2017
New Revision: 322097
URL: https://svnweb.freebsd.org/changeset/base/322097

Log:
  - Move creation and unlinking of /etc/wall_cmos_clock from the handling
of the initial UTC dialog to install_zoneinfo() so that file gets the
necessary treatment also when that dialog is skipped via "-s", when
selecting UTC from the time zone menu or on the command-line instead
etc.
  - Make the initial UTC dialog actually work by giving the relevant files
the necessary treatment and then exit when choosing "Yes" there instead
of moving on to the time zone menu regardless.
  - Since r301131, /etc/localtime is also installed when selecting UTC in
interactive configurations (which previously meant only via the time
zone menu, though). Thus, the code added in r230298 which treats a
NULL zone file name as UTC and removes /etc/localtime in that case can
go again.
  - Consistently refer to "could not delete" (as chosen by the oldest such
code in here) when unlink(2) fails instead of a to mixture of "delete"
and "unlink" in error messages.

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Sat Aug  5 12:54:07 2017
(r322096)
+++ head/usr.sbin/tzsetup/tzsetup.c Sat Aug  5 12:59:03 2017
(r322097)
@@ -107,7 +107,7 @@ xdialog_count_rows(const char *p)
rows++;
}
 
-   return rows ? rows : 1;
+   return (rows ? rows : 1);
 }
 
 static int
@@ -124,7 +124,7 @@ xdialog_count_columns(const char *p)
 
len = strlen(p);
max_len = MAX(max_len, len);
-   return max_len;
+   return (max_len);
 }
 
 static int
@@ -164,7 +164,8 @@ xdialog_menu(const char *title, const char *cprompt, i
tag_x = MAX(tag_x, l + k + 2);
}
}
-   width = MAX(xdialog_count_columns(cprompt), title != NULL ? 
xdialog_count_columns(title) : 0);
+   width = MAX(xdialog_count_columns(cprompt), title != NULL ?
+   xdialog_count_columns(title) : 0);
width = MAX(width, tag_x + 4) + 4;
}
width = MAX(width, 24);
@@ -199,7 +200,7 @@ again:
 
free(listitems);
dlg_restore_vars(_vars);
-   return result;
+   return (result);
 }
 
 static int usedialog = 1;
@@ -269,7 +270,7 @@ continent_country_menu(dialogMenuItem *continent)
int rv;
 
if (strcmp(continent->title, "UTC") == 0)
-   return set_zone_utc();
+   return (set_zone_utc());
 
/* Short cut -- if there's only one country, don't post a menu. */
if (contp->nitems == 1)
@@ -642,7 +643,7 @@ set_zone_menu(dialogMenuItem *dmi)
 static int
 set_zone_utc(void)
 {
-   if (!confirm_zone(NULL))
+   if (!confirm_zone("UTC"))
return (DITEM_FAILURE | DITEM_RECREATE);
 
return (install_zoneinfo("UTC"));
@@ -656,7 +657,7 @@ confirm_zone(const char *filename)
struct tm   *tm;
int rv;
 
-   setenv("TZ", filename == NULL ? "" : filename, 1);
+   setenv("TZ", filename, 1);
tzset();
tm = localtime();
 
@@ -714,11 +715,8 @@ install_zoneinfo_file(const char *zoneinfo_file)
 
 #ifdef VERBOSE
snprintf(title, sizeof(title), "Info");
-   if (zoneinfo_file == NULL)
+   if (copymode)
snprintf(prompt, sizeof(prompt),
-   "Removing %s", path_localtime);
-   else if (copymode)
-   snprintf(prompt, sizeof(prompt),
"Copying %s to %s", zoneinfo_file, path_localtime);
else
snprintf(prompt, sizeof(prompt),
@@ -733,49 +731,6 @@ install_zoneinfo_file(const char *zoneinfo_file)
 #endif
 
if (reallydoit) {
-   if (zoneinfo_file == NULL) {
-   if (unlink(path_localtime) < 0 && errno != ENOENT) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-"Could not delete %s: %s", path_localtime,
-strerror(errno));
-#ifdef HAVE_DIALOG
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-#endif
-   fprintf(stderr, "%s\n", prompt);
-
-   return (DITEM_FAILURE | DITEM_RECREATE);
-   }
-   if (unlink(path_db) < 0 && errno != ENOENT) {
-   snprintf(title, sizeof(title), "Error");
-   snprintf(prompt, sizeof(prompt),
-"Could not delete %s: %s", 

svn commit: r321948 - head/sys/dev/mmc

2017-08-02 Thread Marius Strobl
Author: marius
Date: Wed Aug  2 21:11:51 2017
New Revision: 321948
URL: https://svnweb.freebsd.org/changeset/base/321948

Log:
  - Correct the remainder of confusing and error prone mix-ups between
"br" or "bridge" where - according to the terminology outlined in
comments of bridge.h and mmcbr_if.m  around since their addition in
r163516 - the bus is meant and used instead. Some of these instances
are also rather old, while those in e. g. mmc_subr.c are as new as
r315430 and were caused by choosing mmc_wait_for_request(), i. e. the
one pre-r315430 outliner existing in mmc.c, as template for function
parameters in mmc_subr.c inadvertently. This correction translates to
renaming "brdev" to "busdev" and "mmcbr" to "mmcbus" respectively as
appropriate.
While at it, also rename "reqdev" to just "dev" in mmc_subr.[c,h]
for consistency with was already used in mmm.c pre-r315430, again
modulo mmc_wait_for_request() that is.
  - Remove comment lines from bridge.h incorrectly suggesting that there
would be a MMC bridge base class driver.
  - Update comments in bridge.h regarding the star topology of SD and SDIO;
since version 3.00 of the SDHCI specification, for eSD and eSDIO bus
topologies are actually possible in form of so called "shared buses"
(in some subcontext later on renamed to "embedded" buses).

Modified:
  head/sys/dev/mmc/bridge.h
  head/sys/dev/mmc/mmc_subr.c
  head/sys/dev/mmc/mmc_subr.h
  head/sys/dev/mmc/mmcbus_if.m
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/bridge.h
==
--- head/sys/dev/mmc/bridge.h   Wed Aug  2 20:42:39 2017(r321947)
+++ head/sys/dev/mmc/bridge.h   Wed Aug  2 21:11:51 2017(r321948)
@@ -65,12 +65,10 @@
  * linux/mmc/host.h file.
  *
  * A mmc bridge is a chipset that can have one or more mmc and/or sd
- * cards attached to it.  mmc cards are attached on a bus topology,
- * while sd and sdio cards are attached using a star topology (meaning
- * in practice each sd card has its own, independent slot).  Each
- * mmcbr is assumed to be derived from the mmcbr.  This is done to
- * allow for easier addition of bridges (as each bridge does not need
- * to be added to the mmcbus file).
+ * cards attached to it.  mmc devices are attached on a bus topology,
+ * while sd and sdio cards usually are attached using a star topology
+ * (meaning in practice each sd card has its own, independent slot).
+ * Since SDHCI v3.00, buses for esd and esdio are possible, though.
  *
  * Attached to the mmc bridge is an mmcbus.  The mmcbus is described
  * in dev/mmc/mmcbus_if.m.

Modified: head/sys/dev/mmc/mmc_subr.c
==
--- head/sys/dev/mmc/mmc_subr.c Wed Aug  2 20:42:39 2017(r321947)
+++ head/sys/dev/mmc/mmc_subr.c Wed Aug  2 21:11:51 2017(r321948)
@@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
 #defineLOG_PPS 5 /* Log no more than 5 errors per second. */
 
 int
-mmc_wait_for_cmd(device_t brdev, device_t reqdev, struct mmc_command *cmd,
+mmc_wait_for_cmd(device_t busdev, device_t dev, struct mmc_command *cmd,
 int retries)
 {
struct mmc_request mreq;
@@ -87,14 +87,14 @@ mmc_wait_for_cmd(device_t brdev, device_t reqdev, stru
if (cmd->data != NULL)
cmd->data->mrq = 
mreq.cmd = cmd;
-   if (MMCBUS_WAIT_FOR_REQUEST(brdev, reqdev, ) != 0)
+   if (MMCBUS_WAIT_FOR_REQUEST(busdev, dev, ) != 0)
err = MMC_ERR_FAILED;
else
err = cmd->error;
} while (err != MMC_ERR_NONE && retries-- > 0);
 
-   if (err != MMC_ERR_NONE && brdev == reqdev) {
-   sc = device_get_softc(brdev);
+   if (err != MMC_ERR_NONE && busdev == dev) {
+   sc = device_get_softc(busdev);
if (sc->squelched == 0 && ppsratecheck(>log_time,
>log_count, LOG_PPS)) {
device_printf(sc->dev, "CMD%d failed, RESULT: %d\n",
@@ -106,14 +106,14 @@ mmc_wait_for_cmd(device_t brdev, device_t reqdev, stru
 }
 
 int
-mmc_wait_for_app_cmd(device_t brdev, device_t reqdev, uint16_t rca,
+mmc_wait_for_app_cmd(device_t busdev, device_t dev, uint16_t rca,
 struct mmc_command *cmd, int retries)
 {
struct mmc_command appcmd;
struct mmc_softc *sc;
int err;
 
-   sc = device_get_softc(brdev);
+   sc = device_get_softc(busdev);
 
/* Squelch error reporting at lower levels, we report below. */
sc->squelched++;
@@ -122,14 +122,14 @@ mmc_wait_for_app_cmd(device_t brdev, device_t reqdev, 
appcmd.opcode = MMC_APP_CMD;
appcmd.arg = (uint32_t)rca << 16;
appcmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
-   if (mmc_wait_for_cmd(brdev, reqdev, , 0) != 0)
+   if 

svn commit: r321589 - head/sys/dev/sdhci

2017-07-26 Thread Marius Strobl
Author: marius
Date: Wed Jul 26 22:04:23 2017
New Revision: 321589
URL: https://svnweb.freebsd.org/changeset/base/321589

Log:
  - Check the slot type capability, set SDHCI_SLOT_{EMBEDDED,NON_REMOVABLE}
for embedded slots. Fail in the sdhci(4) initialization for slot type
shared, which is completely unsupported by this driver at the moment. [1]
For Intel eMMC controllers, taking the embedded slot type into account
obsoltes setting SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE so remove these quirk
entries.
  - Hide the 1.8 V VDD capability when the slot is detected as non-embedded,
as the SDHCI specification explicitly states that 1.8 V VDD is applicable
to embedded slots only. [2]
  - Define some easy bits of the SDHCI specification v4.20. [3]
  - Don't leak bus_dma(9) resources in failure paths of sdhci_init_slot().
  
  Obtained from:DragonFlyBSD 65704a46 [1], 7ba10b88 [2], 0df14648 [3]

Modified:
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Wed Jul 26 21:59:37 2017(r321588)
+++ head/sys/dev/sdhci/sdhci.c  Wed Jul 26 22:04:23 2017(r321589)
@@ -742,6 +742,7 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
BUS_DMA_NOWAIT, >dmamap);
if (err != 0) {
device_printf(dev, "Can't alloc DMA memory\n");
+   bus_dma_tag_destroy(slot->dmatag);
SDHCI_LOCK_DESTROY(slot);
return (err);
}
@@ -751,6 +752,8 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
sdhci_getaddr, >paddr, 0);
if (err != 0 || slot->paddr == 0) {
device_printf(dev, "Can't load DMA memory\n");
+   bus_dmamem_free(slot->dmatag, slot->dmamem, slot->dmamap);
+   bus_dma_tag_destroy(slot->dmatag);
SDHCI_LOCK_DESTROY(slot);
if (err)
return (err);
@@ -770,6 +773,22 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
else
caps2 = 0;
}
+   if (slot->version >= SDHCI_SPEC_300) {
+   if ((caps & SDHCI_SLOTTYPE_MASK) != SDHCI_SLOTTYPE_REMOVABLE &&
+   (caps & SDHCI_SLOTTYPE_MASK) != SDHCI_SLOTTYPE_EMBEDDED) {
+   device_printf(dev,
+   "Driver doesn't support shared bus slots\n");
+   bus_dmamap_unload(slot->dmatag, slot->dmamap);
+   bus_dmamem_free(slot->dmatag, slot->dmamem,
+   slot->dmamap);
+   bus_dma_tag_destroy(slot->dmatag);
+   SDHCI_LOCK_DESTROY(slot);
+   return (ENXIO);
+   } else if ((caps & SDHCI_SLOTTYPE_MASK) ==
+   SDHCI_SLOTTYPE_EMBEDDED) {
+   slot->opt |= SDHCI_SLOT_EMBEDDED | SDHCI_NON_REMOVABLE;
+   }
+   }
/* Calculate base clock frequency. */
if (slot->version >= SDHCI_SPEC_300)
freq = (caps & SDHCI_CLOCK_V3_BASE_MASK) >>
@@ -819,7 +838,8 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot,
slot->host.host_ocr |= MMC_OCR_320_330 | MMC_OCR_330_340;
if (caps & SDHCI_CAN_VDD_300)
slot->host.host_ocr |= MMC_OCR_290_300 | MMC_OCR_300_310;
-   if (caps & SDHCI_CAN_VDD_180)
+   /* 1.8V VDD is not supposed to be used for removable cards. */
+   if ((caps & SDHCI_CAN_VDD_180) && (slot->opt & SDHCI_SLOT_EMBEDDED))
slot->host.host_ocr |= MMC_OCR_LOW_VOLTAGE;
if (slot->host.host_ocr == 0) {
device_printf(dev, "Hardware doesn't report any "
@@ -966,20 +986,24 @@ no_tuning:
 
if (bootverbose || sdhci_debug) {
slot_printf(slot,
-   "%uMHz%s %s VDD:%s%s%s VCCQ: 3.3V%s%s DRV: B%s%s%s %s\n",
+   "%uMHz%s %s VDD:%s%s%s VCCQ: 3.3V%s%s DRV: B%s%s%s %s %s\n",
slot->max_clk / 100,
(caps & SDHCI_CAN_DO_HISPD) ? " HS" : "",
(host_caps & MMC_CAP_8_BIT_DATA) ? "8bits" :
((host_caps & MMC_CAP_4_BIT_DATA) ? "4bits" : "1bit"),
(caps & SDHCI_CAN_VDD_330) ? " 3.3V" : "",
(caps & SDHCI_CAN_VDD_300) ? " 3.0V" : "",
-   (caps & SDHCI_CAN_VDD_180) ? " 1.8V" : "",
+   ((caps & SDHCI_CAN_VDD_180) &&
+   (slot->opt & SDHCI_SLOT_EMBEDDED)) ? " 1.8V" : "",
(host_caps & MMC_CAP_SIGNALING_180) ? " 1.8V" : "",
(host_caps & MMC_CAP_SIGNALING_120) ? " 1.2V" : "",
(host_caps & MMC_CAP_DRIVER_TYPE_A) ? "A" : "",
(host_caps & MMC_CAP_DRIVER_TYPE_C) ? "C" : "",
 

svn commit: r321588 - head/sys/dev/mmc

2017-07-26 Thread Marius Strobl
Author: marius
Date: Wed Jul 26 21:59:37 2017
New Revision: 321588
URL: https://svnweb.freebsd.org/changeset/base/321588

Log:
  Correctly use the size of a pointer rather than that of a pointer to a
  pointer.
  
  Reported by:  Coverity
  CID:  1378432

Modified:
  head/sys/dev/mmc/mmc.c

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Wed Jul 26 21:23:09 2017(r321587)
+++ head/sys/dev/mmc/mmc.c  Wed Jul 26 21:59:37 2017(r321588)
@@ -1892,7 +1892,7 @@ child_common:
if (child != NULL) {
device_set_ivars(child, ivar);
sc->child_list = realloc(sc->child_list,
-   sizeof(device_t *) * sc->child_count + 1,
+   sizeof(device_t) * sc->child_count + 1,
M_DEVBUF, M_WAITOK);
sc->child_list[sc->child_count++] = child;
} else
@@ -1934,7 +1934,7 @@ mmc_update_child_list(struct mmc_softc *sc)
if (i != j)
sc->child_list[i] = child;
}
-   sc->child_list = realloc(sc->child_list, sizeof(device_t *) *
+   sc->child_list = realloc(sc->child_list, sizeof(device_t) *
sc->child_count, M_DEVBUF, M_WAITOK);
 }
 
___
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: r321490 - head/sys/dev/mmc

2017-07-25 Thread Marius Strobl
Author: marius
Date: Tue Jul 25 20:36:44 2017
New Revision: 321490
URL: https://svnweb.freebsd.org/changeset/base/321490

Log:
  Improve the clarity of a comment added in r321385 by not referring to
  volatile SDHCI specification lingo.

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==
--- head/sys/dev/mmc/mmcsd.cTue Jul 25 17:39:06 2017(r321489)
+++ head/sys/dev/mmc/mmcsd.cTue Jul 25 20:36:44 2017(r321490)
@@ -235,7 +235,7 @@ mmcsd_attach(device_t dev)
 * insertion that results in switches to/from a transfer mode involving
 * re-tuning, iff there are multiple devices on a given bus.  Until now
 * mmc(4) lacks support for rescanning already attached buses, however,
-* and sdhci(4) has no support for embedded/shared buses in the first
+* and sdhci(4) to date has no support for shared buses in the first
 * place either.
 */
sc->max_data = mmc_get_max_data(dev);
___
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: r321385 - in head/sys/dev: mmc sdhci

2017-07-23 Thread Marius Strobl
Author: marius
Date: Sun Jul 23 16:11:47 2017
New Revision: 321385
URL: https://svnweb.freebsd.org/changeset/base/321385

Log:
  o Add support for eMMC HS200 and HS400 bus speed modes at 200 MHz to
sdhci(4), mmc(4) and mmcsd(4). For the most part, this consists of:
- Correcting and extending the infrastructure for negotiating and
  enabling post-DDR52 modes already added as part of r315598. In
  fact, HS400ES now should work as well but hasn't been activated
  due to lack of corresponding hardware.
- Adding support executing standard SDHCI initial tuning as well
  as re-tuning as required for eMMC HS200/HS400 and the fast UHS-I
  SD card modes. Currently, corresponding methods are only hooked
  up to the ACPI and PCI front-ends of sdhci(4), though. Moreover,
  sdhci(4) won't offer any modes requiring (re-)tuning to the MMC/SD
  layer in order to not break operations with other sdhci(4) front-
  ends. Likewise, sdhci(4) now no longer offers modes requiring the
  set_uhs_timing method introduced in r315598 to be implemented/
  hooked up (previously, this method was used with DDR52 only, which
  in turn is only available with Intel controllers so far, i. e. no
  such limitation was necessary before). Similarly for 1.2/1.8 V VCCQ
  support and the switch_vccq method.
- Addition of locking to the IOCTL half of mmcsd(4) to prevent races
  with detachment and suspension, especially since it's required to
  immediately switch away from RPMB partitions again after an access
  to these (so re-tuning can take place anew, given that the current
  eMMC specification v5.1 doesn't allow tuning commands to be issued
  with a RPMB partition selected). Therefore, the existing part_mtx
  lock in the mmcsd(4) softc is additionally renamed to disk_mtx in
  order to denote that it only refers to the disk(9) half, likewise
  for corresponding macros.
  
On the system where the addition of DDR52 support increased the read
throughput to ~80 MB/s (from ~45 MB/s at high speed), HS200 yields
~154 MB/s and HS400 ~187 MB/s, i. e. performance now has more than
quadrupled compared to pre-r315598.
  
Also, with the advent of (re-)tuning support, most infrastructure
necessary for SD card UHS-I modes up to SDR104 now is also in place.
Note, though, that the standard SDHCI way of (re-)tuning is special
in several ways, which also is why sending the actual tuning requests
to the device is part of sdhci(4). SDHCI implementations not following
the specification, MMC and non-SDHCI SD card controllers likely will
use a generic implementation in the MMC/SD layer for executing tuning,
which hasn't been written so far, though.
  
However, in fact this isn't a feature-only change; there are boards
based on Intel Bay Trail where DDR52 is problematic and the suggested
workaround is to use HS200 mode instead. So far exact details are
unknown, however, i. e. whether that's due to a defect in these SoCs
or on the boards.
  
Moreover, due to the above changes requiring to be aware of possible
MMC siblings in the fast path of mmc(4), corresponding information
now is cached in mmc_softc. As a side-effect, mmc_calculate_clock(),
mmc_delete_cards(), mmc_discover_cards() and mmc_rescan_cards() now
all are guaranteed to operate on the same set of devices as there no
longer is any use of device_get_children(9), which can fail in low
memory situations. Likewise, mmc_calculate_clock() now longer will
trigger a panic due to the latter.
  
  o Fix a bug in the failure reporting of mmcsd_delete(); in case of an
error when the starting block of a previously stored erase request
is used (in order to be able to erase a full erase sector worth of
data), the starting block of the newly supplied bio_pblkno has to be
returned for indicating no progress. Otherwise, upper layers might
be told that a negative number of BIOs have been completed, leading
to a panic.
  
  o Fix 2 bugs on resume:
- Things done in fork1(9) like the acquisition of an SX lock or the
  sleepable memory allocation are incompatible with a MTX_DEF taken.
  Thus, mmcsd_resume() must not call kproc_create(9), which in turn
  uses fork1(9), with the disk_mtx (formerly part_mtx) held.
- In mmc_suspend(), the bus is powered down, which in the typical
  case of a device being selected at the time of suspension, causes
  the device deselection as part of the bus acquisition by mmc(4) in
  mmc_scan() to fail as the bus isn't powered up again before later
  in mmc_go_discovery(). Thus, power down with the bus acquired in
  mmc_suspend(), which will trigger the deselection up-front.
  
  o Fix a memory leak in mmcsd_ioctl() in case copyin(9) fails. [1]
  
  o Fix missing variable initialization in mmc_switch_status(). [2]
  
  o Fix R1_SWITCH_ERROR 

Re: svn commit: r320844 - in head: etc/mtree include lib/libcam sys/amd64/conf sys/arm/broadcom/bcm2835 sys/arm/conf sys/arm/ti sys/cam sys/cam/mmc sys/cam/scsi sys/conf sys/dev/mmc sys/dev/sdhci sys/

2017-07-09 Thread Marius Strobl
On Sun, Jul 09, 2017 at 02:49:56PM -0600, Warner Losh wrote:
> On Sun, Jul 9, 2017 at 2:40 PM, Warner Losh <i...@bsdimp.com> wrote:
> 
> >
> >
> > On Sun, Jul 9, 2017 at 12:42 PM, Marius Strobl <mar...@freebsd.org> wrote:
> >
> >> On Sun, Jul 09, 2017 at 04:57:24PM +, Warner Losh wrote:
> >> > Author: imp
> >> > Date: Sun Jul  9 16:57:24 2017
> >> > New Revision: 320844
> >> > URL: https://svnweb.freebsd.org/changeset/base/320844
> >> >
> >> > Log:
> >> >   An MMC/SD/SDIO stack using CAM
> >> >
> >> >   Implement the MMC/SD/SDIO protocol within a CAM framework. CAM's
> >> >   flexible queueing will make it easier to write non-storage drivers
> >> >   than the legacy stack. SDIO drivers from both the kernel and as
> >> >   userland daemons are possible, though much of that functionality will
> >> >   come later.
> >>
> >> At least with a non-MMCCAM kernel, with this revision in place I get
> >> an endless storm of "unexpected" SDHCI_INT_CARD_INT interrupts during
> >> boot. Apparently this is due to the fact that sdhci(4) now enables
> >> these interrupts, but sdhci_generic_intr() neither actually handles
> >> them nor clears them from intmask.
> >>
> >
> > OK. I'll look into it. Since I don't have an SDHCI card in the system I
> > tested it in, I never saw these...
> >
> 
> Looking at the code, the problem is obvious. It looks like it came in on a
> late commit to the mmccam integration branch. I'll revert which should
> solve your problem.

Thanks, I can confirm that r320850 allows booting again. Compared to
pre-r320844, sdhci(4) now still is incredibly noisy in the non-MMCCAM
path, though. Can we get this removed again or at least put under
sdhci_debug, along with removing the memory overhead for the non-MMCCAM
case and some of the style(9) violations/inconsistencies (re-)introduced,
using something like the attached patch?

> Looking at my notes and test systems, I did test this
> on a NUC, but it was an older version w/o the patch I just reverted. Sorry
> for the hassle. r320850

Well, I might have given a different impression, but I don't actually
care about NUCs as such; they are just a relatively cheap way of
obtaining various combinations of Intel MMC/SDXC controllers and eMMC
chips and are an acceptable loss should I ever manage to kill an eMMC
chip during development.

Marius

Index: sdhci.c
===
--- sdhci.c	(revision 320850)
+++ sdhci.c	(working copy)
@@ -91,7 +91,7 @@ static void sdhci_start_data(struct sdhci_slot *sl
 static void sdhci_card_poll(void *);
 static void sdhci_card_task(void *, int);
 
-/* CAM-related */
+#ifdef MMCCAM
 int sdhci_cam_get_possible_host_clock(struct sdhci_slot *slot, int proposed_clock);
 static int sdhci_cam_update_ios(struct sdhci_slot *slot);
 static int sdhci_cam_request(struct sdhci_slot *slot, union ccb *ccb);
@@ -98,6 +98,7 @@ static int sdhci_cam_request(struct sdhci_slot *sl
 static void sdhci_cam_action(struct cam_sim *sim, union ccb *ccb);
 static void sdhci_cam_poll(struct cam_sim *sim);
 static int sdhci_cam_settran_settings(struct sdhci_slot *slot, union ccb *ccb);
+#endif
 
 /* helper routines */
 static void sdhci_dumpregs(struct sdhci_slot *slot);
@@ -1021,10 +1022,6 @@ sdhci_generic_update_ios(device_t brdev, device_t
 	struct sdhci_slot *slot = device_get_ivars(reqdev);
 	struct mmc_ios *ios = >host.ios;
 
-	device_printf(brdev,  "This is a bridge device\n");
-	device_printf(reqdev, "This is a request device\n");
-
-	slot_printf(slot, " <--- The locking slot is this\n");
 	SDHCI_LOCK(slot);
 	/* Do full reset on bus power down to clear from any state. */
 	if (ios->power_mode == power_off) {
@@ -1121,8 +1118,9 @@ static void
 sdhci_req_done(struct sdhci_slot *slot)
 {
 union ccb *ccb;
+
 	if (sdhci_debug > 1)
-		slot_printf(slot, "sdhci_req_done()\n");
+		slot_printf(slot, "%s\n", __func_);
 	if (slot->ccb != NULL && slot->curcmd != NULL) {
 		callout_stop(>timeout_callout);
 ccb = slot->ccb;
@@ -1139,7 +1137,7 @@ sdhci_req_done(struct sdhci_slot *slot)
 	}
 }
 #else
-static void 
+static void
 sdhci_req_done(struct sdhci_slot *slot)
 {
 	struct mmc_request *req;
@@ -1320,7 +1318,7 @@ sdhci_finish_command(struct sdhci_slot *slot)
 
 	if (sdhci_debug > 1)
 		slot_printf(slot, "%s: called, err %d flags %d\n",
-			__func__, slot->curcmd->error, slot->curcmd->flags);
+		__func__, slot->curcmd->error, slot->curcmd->flags);
 	slot->cmd_done = 1;
 	/*
 	 * Interrupt aggregation: Restore command interrupt.
@@ -1356,8 +

Re: svn commit: r320844 - in head: etc/mtree include lib/libcam sys/amd64/conf sys/arm/broadcom/bcm2835 sys/arm/conf sys/arm/ti sys/cam sys/cam/mmc sys/cam/scsi sys/conf sys/dev/mmc sys/dev/sdhci sys/

2017-07-09 Thread Marius Strobl
On Sun, Jul 09, 2017 at 04:57:24PM +, Warner Losh wrote:
> Author: imp
> Date: Sun Jul  9 16:57:24 2017
> New Revision: 320844
> URL: https://svnweb.freebsd.org/changeset/base/320844
> 
> Log:
>   An MMC/SD/SDIO stack using CAM
>   
>   Implement the MMC/SD/SDIO protocol within a CAM framework. CAM's
>   flexible queueing will make it easier to write non-storage drivers
>   than the legacy stack. SDIO drivers from both the kernel and as
>   userland daemons are possible, though much of that functionality will
>   come later.

At least with a non-MMCCAM kernel, with this revision in place I get
an endless storm of "unexpected" SDHCI_INT_CARD_INT interrupts during
boot. Apparently this is due to the fact that sdhci(4) now enables
these interrupts, but sdhci_generic_intr() neither actually handles
them nor clears them from intmask.

Btw., were mmc.ko and mmcsd.ko disconnected on purpose with this commit?

Marius

___
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: r320620 - head/sys/dev/sdhci

2017-07-03 Thread Marius Strobl
Author: marius
Date: Mon Jul  3 20:47:32 2017
New Revision: 320620
URL: https://svnweb.freebsd.org/changeset/base/320620

Log:
  Correct a typo in the comment part of r320577, later on copied into
  the commit message; as actually implemented, the intent is to retry
  up to 2 ms for controllers to enable bus power.
  Noticed by: ian@, rgrimes@
  
  Additional note: Among others, the problem addressed by r320577 is
  the APL32 ("Storage Controllers May Not Be Power Gated") erratum.
  Hopefully, along with r318282, r320577 works around the remaining
  problems seen with Intel Apollo Lake eMMC and SDXC controllers.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Mon Jul  3 20:44:01 2017(r320619)
+++ head/sys/dev/sdhci/sdhci.c  Mon Jul  3 20:47:32 2017(r320620)
@@ -398,7 +398,7 @@ sdhci_set_power(struct sdhci_slot *slot, u_char power)
/*
 * Turn on VDD1 power.  Note that at least some Intel controllers can
 * fail to enable bus power on the first try after transiting from D3
-* to D0, so we give them up to 20 ms.
+* to D0, so we give them up to 2 ms.
 */
pwr |= SDHCI_POWER_ON;
for (i = 0; i < 20; 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: r320577 - head/sys/dev/sdhci

2017-07-02 Thread Marius Strobl
Author: marius
Date: Sun Jul  2 19:13:01 2017
New Revision: 320577
URL: https://svnweb.freebsd.org/changeset/base/320577

Log:
  Retry up to 20 ms to enable bus power as at least with some Intel
  SDHCI/eMMC controllers the first attempt after a D3 to D0 transition,
  i. e. when the firmware has put the devices into D3 state before,
  can fail.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Sun Jul  2 16:20:49 2017(r320576)
+++ head/sys/dev/sdhci/sdhci.c  Sun Jul  2 19:13:01 2017(r320577)
@@ -366,6 +366,7 @@ sdhci_set_clock(struct sdhci_slot *slot, uint32_t cloc
 static void
 sdhci_set_power(struct sdhci_slot *slot, u_char power)
 {
+   int i;
uint8_t pwr;
 
if (slot->power == power)
@@ -394,9 +395,20 @@ sdhci_set_power(struct sdhci_slot *slot, u_char power)
break;
}
WR1(slot, SDHCI_POWER_CONTROL, pwr);
-   /* Turn on the power. */
+   /*
+* Turn on VDD1 power.  Note that at least some Intel controllers can
+* fail to enable bus power on the first try after transiting from D3
+* to D0, so we give them up to 20 ms.
+*/
pwr |= SDHCI_POWER_ON;
-   WR1(slot, SDHCI_POWER_CONTROL, pwr);
+   for (i = 0; i < 20; i++) {
+   WR1(slot, SDHCI_POWER_CONTROL, pwr);
+   if (RD1(slot, SDHCI_POWER_CONTROL) & SDHCI_POWER_ON)
+   break;
+   DELAY(100);
+   }
+   if (!(RD1(slot, SDHCI_POWER_CONTROL) & SDHCI_POWER_ON))
+   slot_printf(slot, "Bus power failed to enable");
 
if (slot->quirks & SDHCI_QUIRK_INTEL_POWER_UP_RESET) {
WR1(slot, SDHCI_POWER_CONTROL, pwr | 0x10);
___
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: r318282 - head/sys/dev/sdhci

2017-05-14 Thread Marius Strobl
Author: marius
Date: Sun May 14 21:33:01 2017
New Revision: 318282
URL: https://svnweb.freebsd.org/changeset/base/318282

Log:
  - Unlike as in the PCI case, when attached to ACPI, Intel Bay Trail
and Braswell eMMC and SDXC controllers share the same IDs. Like in
the PCI case, Braswell eMMC needs the SDHCI_QUIRK_DATA_TIMEOUT_1MHZ
quirk (see r311794 for the corresponding change to the sdhci(4) PCI
PCI front-end), though. However, due to the shared ACPI IDs, this
is trickier to do.
  - Intel Apollo Lake eMMC and SDXC controllers are affected by the
APL18 ("Using 32-bit Addressing Mode With SD/eMMC Controller May
Lead to Unpredictable System Behavior") silicon bug [1]. When this
erratum hits, typically both SDHCI and XHCI controllers wedge.
According to Intel, using ADMA2 with 64-bit addressing and 96-bit
descriptors serves as a workaround. Until such times when sdhci(4)
has ADMA2 support, flag DMA as broken for affected interfaces.
This turns out to work around the problem, too, at the cost of
performance.
  - In the sdhci(4) ACPI front-end, probe the Intel Apollo Lake eMMC
and SDXC controllers, too.
  
  1: 
http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/pentium-celeron-n-series-j-series-datasheet-spec-update.pdf

Modified:
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Sun May 14 21:18:01 2017
(r318281)
+++ head/sys/dev/sdhci/sdhci_acpi.c Sun May 14 21:33:01 2017
(r318282)
@@ -57,25 +57,39 @@ static const struct sdhci_acpi_device {
const char  *desc;
u_int   quirks;
 } sdhci_acpi_devices[] = {
-   { "80860F14",   1,  "Intel Bay Trail eMMC 4.5 Controller",
+   { "80860F14",   1, "Intel Bay Trail/Braswell eMMC 4.5/4.5.1 Controller",
SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
-   { "80860F14",   3,  "Intel Bay Trail SDXC Controller",
+   { "80860F14",   3, "Intel Bay Trail/Braswell SDXC Controller",
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
-   { "80860F16",   0,  "Intel Bay Trail SDXC Controller",
+   { "80860F16",   0, "Intel Bay Trail/Braswell SDXC Controller",
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
+   { "80865ACA",   0, "Intel Apollo Lake SDXC Controller",
+   SDHCI_QUIRK_BROKEN_DMA |/* APL18 erratum */
+   SDHCI_QUIRK_WAIT_WHILE_BUSY |
+   SDHCI_QUIRK_PRESET_VALUE_BROKEN },
+   { "80865ACC",   0, "Intel Apollo Lake eMMC 5.0 Controller",
+   SDHCI_QUIRK_BROKEN_DMA |/* APL18 erratum */
+   SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
+   SDHCI_QUIRK_INTEL_POWER_UP_RESET |
+   SDHCI_QUIRK_WAIT_WHILE_BUSY |
+   SDHCI_QUIRK_MMC_DDR52 |
+   SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
+   SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ NULL, 0, NULL, 0}
 };
 
 static char *sdhci_ids[] = {
"80860F14",
"80860F16",
+   "80865ACA",
+   "80865ACC",
NULL
 };
 
@@ -249,6 +263,11 @@ sdhci_acpi_attach(device_t dev)
return (ENOMEM);
}
 
+   /* Intel Braswell eMMC 4.5.1 controller quirk */
+   if (strcmp(acpi_dev->hid, "80860F14") == 0 && acpi_dev->uid == 1 &&
+   SDHCI_READ_4(dev, >slot, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
+   SDHCI_READ_4(dev, >slot, SDHCI_CAPABILITIES2) == 0x0807)
+   sc->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_1MHZ;
sc->quirks &= ~sdhci_quirk_clear;
sc->quirks |= sdhci_quirk_set;
sc->slot.quirks = sc->quirks;

Modified: head/sys/dev/sdhci/sdhci_pci.c
==
--- head/sys/dev/sdhci/sdhci_pci.c  Sun May 14 21:18:01 2017
(r318281)
+++ head/sys/dev/sdhci/sdhci_pci.c  Sun May 14 21:33:01 2017
(r318282)
@@ -132,9 +132,11 @@ static const struct sdhci_device {
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x5aca8086,   0x, "Intel Apollo Lake SDXC Controller",
+   SDHCI_QUIRK_BROKEN_DMA |/* APL18 erratum */
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x5acc8086,   0x, "Intel Apollo Lake eMMC 5.0 Controller",
+   SDHCI_QUIRK_BROKEN_DMA |/* APL18 erratum */
SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
@@ -340,6 +342,7 @@ 

svn commit: r318276 - head/sys/dev/usb/controller

2017-05-14 Thread Marius Strobl
Author: marius
Date: Sun May 14 14:27:59 2017
New Revision: 318276
URL: https://svnweb.freebsd.org/changeset/base/318276

Log:
  Describe Intel Apollo Lake and Braswell USB 3.0 controllers.

Modified:
  head/sys/dev/usb/controller/xhci_pci.c

Modified: head/sys/dev/usb/controller/xhci_pci.c
==
--- head/sys/dev/usb/controller/xhci_pci.c  Sun May 14 14:21:11 2017
(r318275)
+++ head/sys/dev/usb/controller/xhci_pci.c  Sun May 14 14:27:59 2017
(r318276)
@@ -116,6 +116,10 @@ xhci_pci_match(device_t self)
case 0x9c318086:
case 0x1e318086:
return ("Intel Panther Point USB 3.0 controller");
+   case 0x22b58086:
+   return ("Intel Braswell USB 3.0 controller");
+   case 0x5aa88086:
+   return ("Intel Apollo Lake USB 3.0 controller");
case 0x8c318086:
return ("Intel Lynx Point USB 3.0 controller");
case 0x8cb18086:
___
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: r317982 - in head/sys: kern sys

2017-05-08 Thread Marius Strobl
Author: marius
Date: Mon May  8 21:08:39 2017
New Revision: 317982
URL: https://svnweb.freebsd.org/changeset/base/317982

Log:
  - Also outside of the KOBJOPLOOKUP macro - which in turn is used by
the code auto-generated for *.m - kobj_lookup_method(9) is useful;
for example in back-ends or base class device drivers in order to
determine whether a default method has been overridden. Thus, allow
for the kobj_method_t pointer argument - used by KOBJOPLOOKUP in
order to update the cache entry - of kobj_lookup_method(9), to be
NULL. Actually, that pointer is redundant as it's just set to the
same kobj_method_t that the kobj_lookup_method(9) function returns
in the first place, but probably it serves to reduce the number of
instructions generated for KOBJOPLOOKUP.
  - For the same reason, move updating kobj_lookup_{hits,misses} (if
KOBJ_STATS is defined) from kobj_lookup_method(9) to KOBJOPLOOKUP.
As a side-effect, this gets rid of the convoluted approach of always
incrementing kobj_lookup_hits in KOBJOPLOOKUP and then in case of
a cache miss, decrementing it in kobj_lookup_method(9) again.

Modified:
  head/sys/kern/subr_kobj.c
  head/sys/sys/kobj.h

Modified: head/sys/kern/subr_kobj.c
==
--- head/sys/kern/subr_kobj.c   Mon May  8 20:58:32 2017(r317981)
+++ head/sys/kern/subr_kobj.c   Mon May  8 21:08:39 2017(r317982)
@@ -213,19 +213,11 @@ kobj_lookup_method(kobj_class_t cls,
 {
kobj_method_t *ce;
 
-#ifdef KOBJ_STATS
-   /*
-* Correct for the 'hit' assumption in KOBJOPLOOKUP and record
-* a 'miss'.
-*/
-   kobj_lookup_hits--;
-   kobj_lookup_misses++;
-#endif
-
ce = kobj_lookup_method_mi(cls, desc);
if (!ce)
ce = >deflt;
-   *cep = ce;
+   if (cep)
+   *cep = ce;
return ce;
 }
 

Modified: head/sys/sys/kobj.h
==
--- head/sys/sys/kobj.h Mon May  8 20:58:32 2017(r317981)
+++ head/sys/sys/kobj.h Mon May  8 21:08:39 2017(r317982)
@@ -226,10 +226,12 @@ extern u_int kobj_lookup_misses;
kobj_method_t **_cep =  \
>cache[_desc->id & (KOBJ_CACHE_SIZE-1)];   \
kobj_method_t *_ce = *_cep; \
-   kobj_lookup_hits++; /* assume hit */\
-   if (_ce->desc != _desc) \
+   if (_ce->desc != _desc) {   \
_ce = kobj_lookup_method(OPS->cls,  \
 _cep, _desc);  \
+   kobj_lookup_misses++;   \
+   } else  \
+   kobj_lookup_hits++; \
_m = _ce->func; \
 } while(0)
 #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: r317981 - head/sys/modules/mmcsd

2017-05-08 Thread Marius Strobl
Author: marius
Date: Mon May  8 20:58:32 2017
New Revision: 317981
URL: https://svnweb.freebsd.org/changeset/base/317981

Log:
  Revise r315430; there's no need to build mmc_subr.c into both mmc.ko
  and mmcsd.ko.

Modified:
  head/sys/modules/mmcsd/Makefile

Modified: head/sys/modules/mmcsd/Makefile
==
--- head/sys/modules/mmcsd/Makefile Mon May  8 20:44:21 2017
(r317980)
+++ head/sys/modules/mmcsd/Makefile Mon May  8 20:58:32 2017
(r317981)
@@ -3,6 +3,6 @@
 .PATH: ${SRCTOP}/sys/dev/mmc
 
 KMOD=  mmcsd
-SRCS=  bus_if.h device_if.h mmc_subr.c mmcbr_if.h mmcbus_if.h mmcsd.c
+SRCS=  bus_if.h device_if.h mmcbr_if.h mmcbus_if.h mmcsd.c
 
 .include 
___
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: r317578 - head/sys/sparc64/pci

2017-04-28 Thread Marius Strobl
Author: marius
Date: Sat Apr 29 00:53:17 2017
New Revision: 317578
URL: https://svnweb.freebsd.org/changeset/base/317578

Log:
  Fix a bug introduced as part of r287726; use the right device_t for
  determining the softc of the bridge in psycho_route_interrupt(). [1]
  While at it, update the corresponding comment that the code in
  question is also necessary for U30s in addition to E450s (a fact
  that has been known for ages).
  
  PR:   218478
  Submitted by: Yoshihiko Iwama

Modified:
  head/sys/sparc64/pci/psycho.c

Modified: head/sys/sparc64/pci/psycho.c
==
--- head/sys/sparc64/pci/psycho.c   Sat Apr 29 00:46:51 2017
(r317577)
+++ head/sys/sparc64/pci/psycho.c   Sat Apr 29 00:53:17 2017
(r317578)
@@ -944,14 +944,14 @@ psycho_route_interrupt(device_t bridge, 
if (pin > 4)
return (pin);
/*
-* Guess the INO; we always assume that this is a non-OBIO
-* device, and that pin is a "real" intpin number.  Determine
-* the mapping register to be used by the slot number.
-* We only need to do this on E450s, it seems; here, the slot numbers
-* for bus A are one-based, while those for bus B seemingly have an
-* offset of 2 (hence the factor of 3 below).
+* Guess the INO; we always assume that this is a non-OBIO device,
+* and that pin is a "real" intpin number.  Determine the mapping
+* register to be used by the slot number.
+* We only need to do this on E450s and U30s, though; here, the
+* slot numbers for bus A are one-based, while those for bus B
+* seemingly have an offset of 2 (hence the factor of 3 below).
 */
-   sc = device_get_softc(dev);
+   sc = device_get_softc(bridge);
intrmap = PSR_PCIA0_INT_MAP +
8 * (pci_get_slot(dev) - 1 + 3 * sc->sc_half);
mintr = INTINO(PSYCHO_READ8(sc, intrmap)) + pin - 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: r317343 - head/sbin/ipfw

2017-04-23 Thread Marius Strobl
Author: marius
Date: Sun Apr 23 21:17:59 2017
New Revision: 317343
URL: https://svnweb.freebsd.org/changeset/base/317343

Log:
  In fill_ip6(), the value of the pointer av changes before it is
  free(3)ed. Thus, introduce a new variable to track the original
  value.
  
  Submitted by: Tom Rix
  Differential Revision:https://reviews.freebsd.org/D9962

Modified:
  head/sbin/ipfw/ipv6.c

Modified: head/sbin/ipfw/ipv6.c
==
--- head/sbin/ipfw/ipv6.c   Sun Apr 23 20:32:46 2017(r317342)
+++ head/sbin/ipfw/ipv6.c   Sun Apr 23 21:17:59 2017(r317343)
@@ -339,6 +339,7 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, i
 {
int len = 0;
struct in6_addr *d = &(cmd->addr6);
+   char *oav;
/*
 * Needed for multiple address.
 * Note d[1] points to struct in6_add r mask6 of cmd
@@ -365,7 +366,7 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, i
return (1);
}
 
-   av = strdup(av);
+   oav = av = strdup(av);
while (av) {
/*
 * After the address we can have '/' indicating a mask,
@@ -446,7 +447,7 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, i
if (len + 1 > F_LEN_MASK)
errx(EX_DATAERR, "address list too long");
cmd->o.len |= len+1;
-   free(av);
+   free(oav);
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: r315760 - head/sys/arm/nvidia

2017-03-22 Thread Marius Strobl
Author: marius
Date: Thu Mar 23 00:41:33 2017
New Revision: 315760
URL: https://svnweb.freebsd.org/changeset/base/315760

Log:
  Correct the dependency of mmc(4) on sdhci_tegra(4) after r314887.

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

Modified: head/sys/arm/nvidia/tegra_sdhci.c
==
--- head/sys/arm/nvidia/tegra_sdhci.c   Wed Mar 22 23:47:15 2017
(r315759)
+++ head/sys/arm/nvidia/tegra_sdhci.c   Thu Mar 23 00:41:33 2017
(r315760)
@@ -459,7 +459,7 @@ static device_method_t tegra_sdhci_metho
 };
 
 static devclass_t tegra_sdhci_devclass;
-static DEFINE_CLASS_0(sdhci, tegra_sdhci_driver, tegra_sdhci_methods,
+static DEFINE_CLASS_0(sdhci_tegra, tegra_sdhci_driver, tegra_sdhci_methods,
 sizeof(struct tegra_sdhci_softc));
 DRIVER_MODULE(sdhci_tegra, simplebus, tegra_sdhci_driver, tegra_sdhci_devclass,
 NULL, 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: r315598 - in head/sys/dev: mmc sdhci

2017-03-19 Thread Marius Strobl
do UHS SDR12 */
+#defineMMC_CAP_UHS_SDR25   (1 <<  7) /* Can do UHS SDR25 */
+#defineMMC_CAP_UHS_SDR50   (1 <<  8) /* Can do UHS SDR50 */
+#defineMMC_CAP_UHS_SDR104  (1 <<  9) /* Can do UHS SDR104 */
+#defineMMC_CAP_UHS_DDR50   (1 << 10) /* Can do UHS DDR50 */
+#defineMMC_CAP_MMC_DDR52_120   (1 << 11) /* Can do eMMC DDR52 at 1.2 V 
*/
+#defineMMC_CAP_MMC_DDR52_180   (1 << 12) /* Can do eMMC DDR52 at 1.8 V 
*/
+#defineMMC_CAP_MMC_DDR52   (MMC_CAP_MMC_DDR52_120 | 
MMC_CAP_MMC_DDR52_180)
+#defineMMC_CAP_MMC_HS200_120   (1 << 13) /* Can do eMMC HS200 at 1.2 V 
*/
+#defineMMC_CAP_MMC_HS200_180   (1 << 14) /* Can do eMMC HS200 at 1.8 V 
*/
+#defineMMC_CAP_MMC_HS200   (MMC_CAP_MMC_HS200_120| 
MMC_CAP_MMC_HS200_180)
+#defineMMC_CAP_MMC_HS400_120   (1 << 15) /* Can do eMMC HS400 at 1.2 V 
*/
+#defineMMC_CAP_MMC_HS400_180   (1 << 16) /* Can do eMMC HS400 at 1.8 V 
*/
+#defineMMC_CAP_MMC_HS400   (MMC_CAP_MMC_HS400_120 | 
MMC_CAP_MMC_HS400_180)
+#defineMMC_CAP_MMC_HSX00_120   (MMC_CAP_MMC_HS200_120 | 
MMC_CAP_MMC_HS400_120)
+#defineMMC_CAP_MMC_ENH_STROBE  (1 << 17) /* Can do eMMC Enhanced 
Strobe */
+#defineMMC_CAP_SIGNALING_120   (1 << 18) /* Can do signaling at 1.2 V 
*/
+#defineMMC_CAP_SIGNALING_180   (1 << 19) /* Can do signaling at 1.8 V 
*/
+#defineMMC_CAP_SIGNALING_330   (1 << 20) /* Can do signaling at 3.3 V 
*/
+#defineMMC_CAP_DRIVER_TYPE_A   (1 << 21) /* Can do Driver Type A */
+#defineMMC_CAP_DRIVER_TYPE_C   (1 << 22) /* Can do Driver Type C */
+#defineMMC_CAP_DRIVER_TYPE_D   (1 << 23) /* Can do Driver Type D */
enum mmc_card_mode mode;
struct mmc_ios ios; /* Current state of the host */
 };
@@ -141,7 +177,7 @@ struct mmc_host {
 extern driver_t   mmc_driver;
 extern devclass_t mmc_devclass;
 
-#defineMMC_VERSION 2
+#defineMMC_VERSION 3
 
 #defineMMC_DECLARE_BRIDGE(name)
\
 DRIVER_MODULE(mmc, name, mmc_driver, mmc_devclass, NULL, NULL);\

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Sun Mar 19 23:06:11 2017(r315597)
+++ head/sys/dev/mmc/mmc.c  Sun Mar 19 23:27:17 2017(r315598)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2006 Bernd Walter.  All rights reserved.
  * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
+ * Copyright (c) 2017 Marius Strobl <mar...@freebsd.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -75,6 +76,8 @@ __FBSDID("$FreeBSD$");
 #include "mmcbr_if.h"
 #include "mmcbus_if.h"
 
+CTASSERT(bus_timing_max <= sizeof(uint32_t) * NBBY);
+
 /*
  * Per-card data
  */
@@ -92,9 +95,11 @@ struct mmc_ivars {
struct mmc_sd_status sd_status; /* SD_STATUS decoded */
u_char read_only;   /* True when the device is read-only */
u_char bus_width;   /* Bus width to use */
-   u_char timing;  /* Bus timing support */
u_char high_cap;/* High Capacity card (block addressed) */
uint32_t sec_count; /* Card capacity in 512byte blocks */
+   uint32_t timings;   /* Mask of bus timings supported */
+   uint32_t vccq_120;  /* Mask of bus timings at VCCQ of 1.2 V */
+   uint32_t vccq_180;  /* Mask of bus timings at VCCQ of 1.8 V */
uint32_t tran_speed;/* Max speed in normal mode */
uint32_t hs_tran_speed; /* Max speed in high speed mode */
uint32_t erase_sector;  /* Card native erase sector size */
@@ -105,8 +110,6 @@ struct mmc_ivars {
 
 #defineCMD_RETRIES 3
 
-#defineCARD_ID_FREQUENCY 40 /* Spec requires 400kHz max during ID 
phase. */
-
 static SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, NULL, "mmc driver");
 
 static int mmc_debug;
@@ -180,12 +183,15 @@ static int mmc_send_op_cond(struct mmc_s
 uint32_t *rocr);
 static int mmc_send_relative_addr(struct mmc_softc *sc, uint32_t *resp);
 static int mmc_set_blocklen(struct mmc_softc *sc, uint32_t len);
-static int mmc_set_card_bus_width(struct mmc_softc *sc,
-struct mmc_ivars *ivar);
+static int mmc_set_card_bus_width(struct mmc_softc *sc, struct mmc_ivars 
*ivar);
+static int mmc_set_power_class(struct mmc_softc *sc, struct mmc_ivars *ivar);
 static int mmc_set_relative_addr(struct mmc_softc *sc, uint16_t resp);
 static int mmc_set_timing(struct mmc_softc *sc, struct mmc_ivars *ivar,
-int timing);
+enum mmc_bus_timing timing);
 static int mmc_test_bus_width(struct mmc_softc *sc);
+static uint32_t mmc_timing_to_dtr(struct mmc_ivars *ivar,

Re: svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
On Fri, Mar 17, 2017 at 05:09:26PM -0600, Ian Lepore wrote:
> On Fri, 2017-03-17 at 22:57 +0000, Marius Strobl wrote:
> > Author: marius
> > Date: Fri Mar 17 22:57:37 2017
> > New Revision: 315466
> > URL: https://svnweb.freebsd.org/changeset/base/315466
> > 
> > Log:
> >   Again, fixes regarding style(4), to comments, includes and unused
> >   parameters.
> > 
> > Modified:
> >   head/sys/dev/mmc/bridge.h
> >   head/sys/dev/mmc/mmc.c
> >   head/sys/dev/mmc/mmcbr_if.m
> >   head/sys/dev/sdhci/sdhci.c
> >   head/sys/dev/sdhci/sdhci_acpi.c
> >   head/sys/dev/sdhci/sdhci_if.m
> >   head/sys/dev/sdhci/sdhci_pci.c
> > 
> > Modified: head/sys/dev/mmc/bridge.h
> > =
> > =
> > --- head/sys/dev/mmc/bridge.h   Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/mmc/bridge.h   Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -111,7 +111,7 @@ enum mmc_bus_timing {
> >  
> >  struct mmc_ios {
> >     uint32_tclock;  /* Speed of the clock in Hz to
> > move data */
> > -   enum mmc_vddvdd;/* Voltage to apply to the
> > power pins/ */
> > +   enum mmc_vddvdd;/* Voltage to apply to the
> > power pins */
> >     enum mmc_bus_mode bus_mode;
> >     enum mmc_chip_select chip_select;
> >     enum mmc_bus_width bus_width;
> > 
> > Modified: head/sys/dev/mmc/mmc.c
> > =
> > =
> > --- head/sys/dev/mmc/mmc.c  Fri Mar 17 22:02:02 2017(r3
> > 15465)
> > +++ head/sys/dev/mmc/mmc.c  Fri Mar 17 22:57:37 2017(r3
> > 15466)
> > @@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
> >     const int i = (bit_len / 32) - (start / 32) - 1;
> >     const int shift = start & 31;
> >     uint32_t retval = bits[i] >> shift;
> > +
> >     if (size + shift > 32)
> >     retval |= bits[i - 1] << (32 - shift);
> >     return (retval & ((1llu << size) - 1));
> > @@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
> >     return;
> >     for (i = 0; i < devcount; i++) {
> >     ivar = device_get_ivars(devlist[i]);
> > -   if (mmc_select_card(sc, ivar->rca)) {
> > +   if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE)
> > {
> >     if (bootverbose || mmc_debug)
> >     device_printf(sc->dev,
> >     "Card at relative address %d
> > lost.\n",
> > 
> > Modified: head/sys/dev/mmc/mmcbr_if.m
> > =
> > =
> > --- head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -65,8 +65,9 @@
> >  INTERFACE mmcbr;
> >  
> >  #
> > -# Called by the mmcbus to setup the IO pins correctly, the voltage
> > to use
> > -# for the card, the type of selects, power modes and bus width.
> > +# Called by the mmcbus to set up the IO pins correctly, the
> > common/core
> > +# supply voltage (VDD/VCC) to use for the device, the clock
> > frequency, the
> > +# type of SPI chip select, power mode and bus width.
> >  #
> >  METHOD int update_ios {
> >     device_tbrdev;
> > @@ -76,8 +77,8 @@ METHOD int update_ios {
> >  #
> >  # Called by the mmcbus or its children to schedule a mmc
> > request.  These
> >  # requests are queued.  Time passes.  The bridge then gets
> > notification
> > -# of the status of request, who then notifies the requesting device
> > via
> > -# the xfer_done mmcbus method.
> > +# of the status of the request, who then notifies the requesting
> > device
> > +# by calling the completion function supplied as part of the
> > request.
> >  #
> >  METHOD int request {
> >     device_tbrdev;
> > 
> > Modified: head/sys/dev/sdhci/sdhci.c
> > =
> > =
> > --- head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:02:02 2017
> > (r315465)
> > +++ head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:57:37 2017
> > (r315466)
> > @@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
> >     }
> >     /* Di

Re: svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
On Sat, Mar 18, 2017 at 12:39:47AM +0100, Marius Strobl wrote:
> On Fri, Mar 17, 2017 at 05:09:26PM -0600, Ian Lepore wrote:
> > On Fri, 2017-03-17 at 22:57 +0000, Marius Strobl wrote:
> > > Author: marius
> > > Date: Fri Mar 17 22:57:37 2017
> > > New Revision: 315466
> > > URL: https://svnweb.freebsd.org/changeset/base/315466
> > > 
> > > Log:
> > >   Again, fixes regarding style(4), to comments, includes and unused
> > >   parameters.
> > > 
> > > Modified:
> > >   head/sys/dev/mmc/bridge.h
> > >   head/sys/dev/mmc/mmc.c
> > >   head/sys/dev/mmc/mmcbr_if.m
> > >   head/sys/dev/sdhci/sdhci.c
> > >   head/sys/dev/sdhci/sdhci_acpi.c
> > >   head/sys/dev/sdhci/sdhci_if.m
> > >   head/sys/dev/sdhci/sdhci_pci.c
> > > 
> > > Modified: head/sys/dev/mmc/bridge.h
> > > =
> > > =
> > > --- head/sys/dev/mmc/bridge.h Fri Mar 17 22:02:02 2017
> > > (r315465)
> > > +++ head/sys/dev/mmc/bridge.h Fri Mar 17 22:57:37 2017
> > > (r315466)
> > > @@ -111,7 +111,7 @@ enum mmc_bus_timing {
> > >  
> > >  struct mmc_ios {
> > >   uint32_tclock;  /* Speed of the clock in Hz to
> > > move data */
> > > - enum mmc_vddvdd;/* Voltage to apply to the
> > > power pins/ */
> > > + enum mmc_vddvdd;/* Voltage to apply to the
> > > power pins */
> > >   enum mmc_bus_mode bus_mode;
> > >   enum mmc_chip_select chip_select;
> > >   enum mmc_bus_width bus_width;
> > > 
> > > Modified: head/sys/dev/mmc/mmc.c
> > > =
> > > =
> > > --- head/sys/dev/mmc/mmc.cFri Mar 17 22:02:02 2017(r3
> > > 15465)
> > > +++ head/sys/dev/mmc/mmc.cFri Mar 17 22:57:37 2017(r3
> > > 15466)
> > > @@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
> > >   const int i = (bit_len / 32) - (start / 32) - 1;
> > >   const int shift = start & 31;
> > >   uint32_t retval = bits[i] >> shift;
> > > +
> > >   if (size + shift > 32)
> > >   retval |= bits[i - 1] << (32 - shift);
> > >   return (retval & ((1llu << size) - 1));
> > > @@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
> > >   return;
> > >   for (i = 0; i < devcount; i++) {
> > >   ivar = device_get_ivars(devlist[i]);
> > > - if (mmc_select_card(sc, ivar->rca)) {
> > > + if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE)
> > > {
> > >   if (bootverbose || mmc_debug)
> > >   device_printf(sc->dev,
> > >   "Card at relative address %d
> > > lost.\n",
> > > 
> > > Modified: head/sys/dev/mmc/mmcbr_if.m
> > > =
> > > =
> > > --- head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:02:02 2017
> > > (r315465)
> > > +++ head/sys/dev/mmc/mmcbr_if.m   Fri Mar 17 22:57:37 2017
> > > (r315466)
> > > @@ -65,8 +65,9 @@
> > >  INTERFACE mmcbr;
> > >  
> > >  #
> > > -# Called by the mmcbus to setup the IO pins correctly, the voltage
> > > to use
> > > -# for the card, the type of selects, power modes and bus width.
> > > +# Called by the mmcbus to set up the IO pins correctly, the
> > > common/core
> > > +# supply voltage (VDD/VCC) to use for the device, the clock
> > > frequency, the
> > > +# type of SPI chip select, power mode and bus width.
> > >  #
> > >  METHOD int update_ios {
> > >   device_tbrdev;
> > > @@ -76,8 +77,8 @@ METHOD int update_ios {
> > >  #
> > >  # Called by the mmcbus or its children to schedule a mmc
> > > request.  These
> > >  # requests are queued.  Time passes.  The bridge then gets
> > > notification
> > > -# of the status of request, who then notifies the requesting device
> > > via
> > > -# the xfer_done mmcbus method.
> > > +# of the status of the request, who then notifies the requesting
> > > device
> > > +# by calling the completion function supplied as part of the
> > > request.
> > >

svn commit: r315466 - in head/sys/dev: mmc sdhci

2017-03-17 Thread Marius Strobl
Author: marius
Date: Fri Mar 17 22:57:37 2017
New Revision: 315466
URL: https://svnweb.freebsd.org/changeset/base/315466

Log:
  Again, fixes regarding style(4), to comments, includes and unused
  parameters.

Modified:
  head/sys/dev/mmc/bridge.h
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcbr_if.m
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci_acpi.c
  head/sys/dev/sdhci/sdhci_if.m
  head/sys/dev/sdhci/sdhci_pci.c

Modified: head/sys/dev/mmc/bridge.h
==
--- head/sys/dev/mmc/bridge.h   Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/bridge.h   Fri Mar 17 22:57:37 2017(r315466)
@@ -111,7 +111,7 @@ enum mmc_bus_timing {
 
 struct mmc_ios {
uint32_tclock;  /* Speed of the clock in Hz to move data */
-   enum mmc_vddvdd;/* Voltage to apply to the power pins/ */
+   enum mmc_vddvdd;/* Voltage to apply to the power pins */
enum mmc_bus_mode bus_mode;
enum mmc_chip_select chip_select;
enum mmc_bus_width bus_width;

Modified: head/sys/dev/mmc/mmc.c
==
--- head/sys/dev/mmc/mmc.c  Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/mmc.c  Fri Mar 17 22:57:37 2017(r315466)
@@ -792,6 +792,7 @@ mmc_get_bits(uint32_t *bits, int bit_len
const int i = (bit_len / 32) - (start / 32) - 1;
const int shift = start & 31;
uint32_t retval = bits[i] >> shift;
+
if (size + shift > 32)
retval |= bits[i - 1] << (32 - shift);
return (retval & ((1llu << size) - 1));
@@ -1464,7 +1465,7 @@ mmc_rescan_cards(struct mmc_softc *sc)
return;
for (i = 0; i < devcount; i++) {
ivar = device_get_ivars(devlist[i]);
-   if (mmc_select_card(sc, ivar->rca)) {
+   if (mmc_select_card(sc, ivar->rca) != MMC_ERR_NONE) {
if (bootverbose || mmc_debug)
device_printf(sc->dev,
"Card at relative address %d lost.\n",

Modified: head/sys/dev/mmc/mmcbr_if.m
==
--- head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/mmc/mmcbr_if.m Fri Mar 17 22:57:37 2017(r315466)
@@ -65,8 +65,9 @@
 INTERFACE mmcbr;
 
 #
-# Called by the mmcbus to setup the IO pins correctly, the voltage to use
-# for the card, the type of selects, power modes and bus width.
+# Called by the mmcbus to set up the IO pins correctly, the common/core
+# supply voltage (VDD/VCC) to use for the device, the clock frequency, the
+# type of SPI chip select, power mode and bus width.
 #
 METHOD int update_ios {
device_tbrdev;
@@ -76,8 +77,8 @@ METHOD int update_ios {
 #
 # Called by the mmcbus or its children to schedule a mmc request.  These
 # requests are queued.  Time passes.  The bridge then gets notification
-# of the status of request, who then notifies the requesting device via
-# the xfer_done mmcbus method.
+# of the status of the request, who then notifies the requesting device
+# by calling the completion function supplied as part of the request.
 #
 METHOD int request {
device_tbrdev;

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:02:02 2017(r315465)
+++ head/sys/dev/sdhci/sdhci.c  Fri Mar 17 22:57:37 2017(r315466)
@@ -309,9 +309,8 @@ sdhci_set_clock(struct sdhci_slot *slot,
}
/* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80 ... */
div >>= 1;
-   }
-   else {
-   /* Version 3.0 divisors are multiples of two up to 1023*2 */
+   } else {
+   /* Version 3.0 divisors are multiples of two up to 1023 * 2 */
if (clock >= clk_base)
div = 0;
else {
@@ -1349,7 +1348,7 @@ sdhci_data_irq(struct sdhci_slot *slot, 
if (intmask & SDHCI_INT_DMA_END) {
data = slot->curcmd->data;
 
-   /* Unload DMA buffer... */
+   /* Unload DMA buffer ... */
left = data->len - slot->offset;
if (data->flags & MMC_DATA_READ) {
bus_dmamap_sync(slot->dmatag, slot->dmamap,

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Fri Mar 17 22:02:02 2017
(r315465)
+++ head/sys/dev/sdhci/sdhci_acpi.c Fri Mar 17 22:57:37 2017
(r315466)
@@ -87,7 +87,8 @@ static void sdhci_acpi_intr(void *arg);
 static int sdhci_acpi_detach(device_t dev);
 
 static uint8_t
-sdhci_acpi_read_1(device_t dev, struct sdhci_slot *slot, 

  1   2   3   4   5   6   7   8   >