svn commit: r342061 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:00:01 2018
New Revision: 342061
URL: https://svnweb.freebsd.org/changeset/base/342061

Log:
  This patch will add support for divert bitmap in RAID map. Divert bitmap is 
supported for
  SAS3.5 adapters only.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h
  head/sys/dev/mrsas/mrsas_cam.c
  head/sys/dev/mrsas/mrsas_fp.c

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 07:59:09 2018(r342060)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:00:01 2018(r342061)
@@ -1589,8 +1589,8 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t M
cmd_mpt = sc->mpt_cmd_list[smid - 1];
scsi_io_req = (MRSAS_RAID_SCSI_IO_REQUEST *) 
cmd_mpt->io_request;
 
-   status = scsi_io_req->RaidContext.status;
-   extStatus = scsi_io_req->RaidContext.exStatus;
+   status = scsi_io_req->RaidContext.raid_context.status;
+   extStatus = scsi_io_req->RaidContext.raid_context.exStatus;
 
switch (scsi_io_req->Function) {
case MPI2_FUNCTION_SCSI_TASK_MGMT:
@@ -1614,8 +1614,8 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t M
case MRSAS_MPI2_FUNCTION_LD_IO_REQUEST:
mrsas_map_mpt_cmd_status(cmd_mpt, status, extStatus);
mrsas_cmd_done(sc, cmd_mpt);
-   scsi_io_req->RaidContext.status = 0;
-   scsi_io_req->RaidContext.exStatus = 0;
+   scsi_io_req->RaidContext.raid_context.status = 0;
+   scsi_io_req->RaidContext.raid_context.exStatus = 0;
mrsas_atomic_dec(&sc->fw_outstanding);
break;
case MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST:   /* MFI command 
*/
@@ -3214,7 +3214,7 @@ mrsas_complete_outstanding_ioctls(struct mrsas_softc *
if (cmd_mfi->sync_cmd && cmd_mfi->frame->hdr.cmd != 
MFI_CMD_ABORT) {
for (MSIxIndex = 0; MSIxIndex < count; 
MSIxIndex++)
mrsas_complete_mptmfi_passthru(sc, 
cmd_mfi,
-   
cmd_mpt->io_request->RaidContext.status);
+   
cmd_mpt->io_request->RaidContext.raid_context.status);
}
}
}

Modified: head/sys/dev/mrsas/mrsas.h
==
--- head/sys/dev/mrsas/mrsas.h  Fri Dec 14 07:59:09 2018(r342060)
+++ head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:00:01 2018(r342061)
@@ -179,7 +179,54 @@ typedef struct _RAID_CONTEXT {
u_int8_t resvd2;/* 0x1F */
 }  RAID_CONTEXT;
 
+/*
+ * Raid Context structure which describes ventura MegaRAID specific IO 
Paramenters
+ * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
+ */
+typedef struct _RAID_CONTEXT_G35 {
+   u_int16_t Type:4;
+   u_int16_t nseg:4;
+   u_int16_t resvd0:8;
+   u_int16_t timeoutValue;
+   union {
+   struct {
+   u_int16_t reserved:1;
+   u_int16_t sld:1;
+   u_int16_t c2f:1;
+   u_int16_t fwn:1;
+   u_int16_t sqn:1;
+   u_int16_t sbs:1;
+   u_int16_t rw:1;
+   u_int16_t log:1;
+   u_int16_t cpuSel:4;
+   u_int16_t setDivert:4;
+   }   bits;
+   u_int16_t s;
+   }   routingFlags;
+   u_int16_t VirtualDiskTgtId;
+   u_int64_t regLockRowLBA;
+   u_int32_t regLockLength;
+   union {
+   u_int16_t nextLMId;
+   u_int16_t peerSMID;
+   }   smid;
+   u_int8_t exStatus;
+   u_int8_t status;
+   u_int8_t RAIDFlags;
+   u_int8_t spanArm;
+   u_int16_t configSeqNum;
+   u_int16_t numSGE:12;
+   u_int16_t reserved:3;
+   u_int16_t streamDetected:1;
+   u_int8_t resvd2[2];
+}  RAID_CONTEXT_G35;
 
+typedef union _RAID_CONTEXT_UNION {
+   RAID_CONTEXT raid_context;
+   RAID_CONTEXT_G35 raid_context_g35;
+}  RAID_CONTEXT_UNION, *PRAID_CONTEXT_UNION;
+
+
 /*
  * MPI2 Defines
  /
@@ -439,7 +486,7 @@ typedef struct _MPI2_RAID_SCSI_IO_REQUEST {
u_int8_t LUN[8];/* 0x34 */
u_int32_t Control;  /* 0x3C */
MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */
-   RAID_C

svn commit: r342062 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:00:45 2018
New Revision: 342062
URL: https://svnweb.freebsd.org/changeset/base/342062

Log:
  This patch will add new interface to support more than 256 JBODs.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h
  head/sys/dev/mrsas/mrsas_cam.c

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:00:01 2018(r342061)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:00:45 2018(r342062)
@@ -2272,6 +2272,9 @@ mrsas_init_fw(struct mrsas_softc *sc)
if (sc->use_seqnum_jbod_fp)
device_printf(sc->mrsas_dev, "FW supports JBOD Map \n");
 
+   if (sc->support_morethan256jbod)
+   device_printf(sc->mrsas_dev, "FW supports JBOD Map Ext \n");
+
if (mrsas_setup_raidmap(sc) != SUCCESS) {
device_printf(sc->mrsas_dev, "Error: RAID map setup FAILED !!! "
"There seems to be some problem in the controller\n"
@@ -3381,6 +3384,9 @@ mrsas_get_ctrl_info(struct mrsas_softc *sc)
 
sc->use_seqnum_jbod_fp =
sc->ctrl_info->adapterOperations3.useSeqNumJbodFP;
+   sc->support_morethan256jbod =
+   sc->ctrl_info->adapterOperations4.supportPdMapTargetId;
+
sc->disableOnlineCtrlReset =
sc->ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
 

Modified: head/sys/dev/mrsas/mrsas.h
==
--- head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:00:01 2018(r342061)
+++ head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:00:45 2018(r342062)
@@ -1023,7 +1023,8 @@ struct MR_PD_CFG_SEQ {
u_int8_t tmCapable:1;
u_int8_t reserved:7;
} capability;
-   u_int8_t reserved[3];
+   u_int8_t reserved;
+   u_int16_t pdTargetId;
 } __packed;
 
 struct MR_PD_CFG_SEQ_NUM_SYNC {
@@ -2197,7 +2198,21 @@ struct mrsas_ctrl_info {
u_int32_t reserved:7;
}   adapterOperations3;
 
-   u_int8_t pad[0x800 - 0x7EC];/* 0x7EC */
+   u_int8_t pad_cpld[16];
+
+   struct {
+   u_int16_t ctrlInfoExtSupported:1;
+   u_int16_t supportIbuttonLess:1;
+   u_int16_t supportedEncAlgo:1;
+   u_int16_t supportEncryptedMfc:1;
+   u_int16_t imageUploadSupported:1;
+   u_int16_t supportSESCtrlInMultipathCfg:1;
+   u_int16_t supportPdMapTargetId:1;
+   u_int16_t FWSwapsBBUVPDInfo:1;
+   u_int16_t reserved:8;
+   }   adapterOperations4;
+
+   u_int8_t pad[0x800 - 0x7FE];/* 0x7FE */
 } __packed;
 
 /*
@@ -3042,6 +3057,8 @@ struct mrsas_softc {
u_int8_t mrsas_gen3_ctrl;
u_int8_t secure_jbod_support;
u_int8_t use_seqnum_jbod_fp;
+   /* FW suport for more than 256 PD/JBOD */
+   u_int32_t support_morethan256jbod;
u_int8_t max256vdSupport;
u_int16_t fw_supported_vd_count;
u_int16_t fw_supported_pd_count;

Modified: head/sys/dev/mrsas/mrsas_cam.c
==
--- head/sys/dev/mrsas/mrsas_cam.c  Fri Dec 14 08:00:01 2018
(r342061)
+++ head/sys/dev/mrsas/mrsas_cam.c  Fri Dec 14 08:00:45 2018
(r342062)
@@ -1084,7 +1084,13 @@ mrsas_build_syspdio(struct mrsas_softc *sc, struct mrs
//printf("Using Drv seq num\n");
pd_sync = (void *)sc->jbodmap_mem[(sc->pd_seq_map_id - 1) & 1];
cmd->tmCapable = pd_sync->seq[device_id].capability.tmCapable;
-   io_request->RaidContext.raid_context.VirtualDiskTgtId = 
device_id + 255;
+   /* More than 256 PD/JBOD support for Ventura */
+   if (sc->support_morethan256jbod)
+   io_request->RaidContext.raid_context.VirtualDiskTgtId =
+   pd_sync->seq[device_id].pdTargetId;
+   else
+   io_request->RaidContext.raid_context.VirtualDiskTgtId =
+   device_id + 255;
io_request->RaidContext.raid_context.configSeqNum = 
pd_sync->seq[device_id].seqNum;
io_request->DevHandle = pd_sync->seq[device_id].devHandle;
if (sc->is_ventura)
___
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: r342063 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:01:49 2018
New Revision: 342063
URL: https://svnweb.freebsd.org/changeset/base/342063

Log:
  Detect sequential Write IOs and pass the hint that it is part of sequential
  stream to help HBA Firmware do the Full Stripe Writes. For read IOs on
  certain RAID volumes like Read Ahead volumes,this will help driver to
  send it to Firmware even if the IOs can potentially be sent to
  hardware directly (called fast path) bypassing firmware.
  
  Design: 8 streams are maintained per RAID volume as per the combined
  firmware/driver design. When there is no stream detected the LRU stream
  is used for next potential stream and LRU/MRU map is updated to make this
  as MRU stream. Every time a stream is detected the MRU map
  is updated to make the current stream as MRU stream.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h
  head/sys/dev/mrsas/mrsas_cam.c
  head/sys/dev/mrsas/mrsas_fp.c

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:00:45 2018(r342062)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:01:49 2018(r342063)
@@ -442,7 +442,10 @@ mrsas_setup_sysctl(struct mrsas_softc *sc)
OID_AUTO, "block_sync_cache", CTLFLAG_RW,
&sc->block_sync_cache, 0,
"Block SYNC CACHE at driver. ");
-
+   SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+   OID_AUTO, "stream detection", CTLFLAG_RW,
+   &sc->drv_stream_detection, 0,
+   "Disable/Enable Stream detection. ");
 }
 
 /*
@@ -463,6 +466,7 @@ mrsas_get_tunables(struct mrsas_softc *sc)
sc->reset_count = 0;
sc->reset_in_progress = 0;
sc->block_sync_cache = 0;
+   sc->drv_stream_detection = 1;
 
/*
 * Grab the global variables.
@@ -882,6 +886,7 @@ mrsas_attach(device_t dev)
mtx_init(&sc->mpt_cmd_pool_lock, "mrsas_mpt_cmd_pool_lock", NULL, 
MTX_DEF);
mtx_init(&sc->mfi_cmd_pool_lock, "mrsas_mfi_cmd_pool_lock", NULL, 
MTX_DEF);
mtx_init(&sc->raidmap_lock, "mrsas_raidmap_lock", NULL, MTX_DEF);
+   mtx_init(&sc->stream_lock, "mrsas_stream_lock", NULL, MTX_DEF);
 
/* Intialize linked list */
TAILQ_INIT(&sc->mrsas_mpt_cmd_list_head);
@@ -948,6 +953,7 @@ attach_fail_fw:
mtx_destroy(&sc->mpt_cmd_pool_lock);
mtx_destroy(&sc->mfi_cmd_pool_lock);
mtx_destroy(&sc->raidmap_lock);
+   mtx_destroy(&sc->stream_lock);
 attach_fail:
if (sc->reg_res) {
bus_release_resource(sc->mrsas_dev, SYS_RES_MEMORY,
@@ -1070,6 +1076,14 @@ mrsas_detach(device_t dev)
mrsas_flush_cache(sc);
mrsas_shutdown_ctlr(sc, MR_DCMD_CTRL_SHUTDOWN);
mrsas_disable_intr(sc);
+
+   if (sc->is_ventura && sc->streamDetectByLD) {
+   for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i)
+   free(sc->streamDetectByLD[i], M_MRSAS);
+   free(sc->streamDetectByLD, M_MRSAS);
+   sc->streamDetectByLD = NULL;
+   }
+
mrsas_cam_detach(sc);
mrsas_teardown_intr(sc);
mrsas_free_mem(sc);
@@ -1081,6 +1095,7 @@ mrsas_detach(device_t dev)
mtx_destroy(&sc->mpt_cmd_pool_lock);
mtx_destroy(&sc->mfi_cmd_pool_lock);
mtx_destroy(&sc->raidmap_lock);
+   mtx_destroy(&sc->stream_lock);
 
/* Wait for all the semaphores to be released */
while (sema_value(&sc->ioctl_count_sema) != MRSAS_MAX_IOCTL_CMDS)
@@ -2166,6 +2181,7 @@ mrsas_init_fw(struct mrsas_softc *sc)
u_int32_t scratch_pad_2, scratch_pad_3;
int msix_enable = 0;
int fw_msix_count = 0;
+   int i, j;
 
/* Make sure Firmware is ready */
ret = mrsas_transition_to_ready(sc, ocr);
@@ -2294,6 +2310,30 @@ mrsas_init_fw(struct mrsas_softc *sc)
device_printf(sc->mrsas_dev, "Get LD lsit failed.\n");
return (1);
}
+
+   if (sc->is_ventura && sc->drv_stream_detection) {
+   sc->streamDetectByLD = malloc(sizeof(PTR_LD_STREAM_DETECT) *
+   MAX_LOGICAL_DRIVES_EXT, 
M_MRSAS, M_NOWAIT);
+   if (!sc->streamDetectByLD) {
+   device_printf(sc->mrsas_dev,
+   "unable to allocate stream detection for pool 
of LDs\n");
+   return (1);
+   }
+   for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) {
+   sc->streamDetectByLD[i] = 
malloc(sizeof(LD_STREAM_DETECT), M_MRSAS, M_NOWAIT);
+   if (!sc->streamDetectByLD[i]) {
+   device_printf(sc->mrsas_dev, "unable to 
allocate stream detect by LD\n");
+   for (j = 0; j <

svn commit: r342064 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:02:44 2018
New Revision: 342064
URL: https://svnweb.freebsd.org/changeset/base/342064

Log:
  To improve RAID 1/10 Write performance, OS drivers need to issue the
  required Write IOs as Fast Path IOs (after the appropriate checks
  allowing Fast Path to be used) to the appropriate physical drives
  (translated from the OS logical IO) and wait for all Write IOs to complete.
  
  Design: A write IO on RAID volume will be examined if it can be sent in
  Fast Path based on IO size and starting LBA and ending LBA falling on to
  a Physical Drive boundary. If the underlying RAID volume is a RAID 1/10,
  driver issues two fast path write IOs one for each corresponding physical
  drive after computing the corresponding start LBA for each physical drive.
  Both write IOs will have the same payload and are posted to HW such that
  replies land in the same reply queue.
  
  If there are no resources available for sending two IOs, driver will send
  the original IO from upper layer to RAID volume through the Firmware.
  
  When both IOs are completed by HW, the resources will be released
  and SCSI IO completion handler will be called.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h
  head/sys/dev/mrsas/mrsas_cam.c
  head/sys/dev/mrsas/mrsas_fp.c

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:01:49 2018(r342063)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:02:44 2018(r342064)
@@ -141,9 +141,6 @@ voidmrsas_free_ctlr_info_cmd(struct mrsas_softc 
*sc);
 void
 mrsas_complete_mptmfi_passthru(struct mrsas_softc *sc,
 struct mrsas_mfi_cmd *cmd, u_int8_t status);
-void
-mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, u_int8_t status,
-u_int8_t extStatus);
 struct mrsas_mfi_cmd *mrsas_get_mfi_cmd(struct mrsas_softc *sc);
 
 MRSAS_REQUEST_DESCRIPTOR_UNION *mrsas_build_mpt_cmd
@@ -167,7 +164,13 @@ mrsas_get_request_desc(struct mrsas_softc *sc,
 extern int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
 static int mrsas_alloc_evt_log_info_cmd(struct mrsas_softc *sc);
 static void mrsas_free_evt_log_info_cmd(struct mrsas_softc *sc);
+void   mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
 
+void mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd,
+   union ccb *ccb_ptr, u_int8_t status, u_int8_t extStatus,
+   u_int32_t data_length, u_int8_t *sense);
+
+
 SYSCTL_NODE(_hw, OID_AUTO, mrsas, CTLFLAG_RD, 0, "MRSAS Driver Parameters");
 
 /*
@@ -1125,7 +1128,7 @@ void
 mrsas_free_mem(struct mrsas_softc *sc)
 {
int i;
-   u_int32_t max_cmd;
+   u_int32_t max_fw_cmds;
struct mrsas_mfi_cmd *mfi_cmd;
struct mrsas_mpt_cmd *mpt_cmd;
 
@@ -1227,9 +1230,9 @@ mrsas_free_mem(struct mrsas_softc *sc)
/*
 * Free MPT internal command list
 */
-   max_cmd = sc->max_fw_cmds;
+   max_fw_cmds = sc->max_fw_cmds;
if (sc->mpt_cmd_list) {
-   for (i = 0; i < max_cmd; i++) {
+   for (i = 0; i < max_fw_cmds; i++) {
mpt_cmd = sc->mpt_cmd_list[i];
bus_dmamap_destroy(sc->data_tag, mpt_cmd->data_dmamap);
free(sc->mpt_cmd_list[i], M_MRSAS);
@@ -1569,14 +1572,14 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t M
Mpi2ReplyDescriptorsUnion_t *desc;
MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR *reply_desc;
MRSAS_RAID_SCSI_IO_REQUEST *scsi_io_req;
-   struct mrsas_mpt_cmd *cmd_mpt;
+   struct mrsas_mpt_cmd *cmd_mpt, *r1_cmd = NULL;
struct mrsas_mfi_cmd *cmd_mfi;
-   u_int8_t reply_descript_type;
+   u_int8_t reply_descript_type, *sense;
u_int16_t smid, num_completed;
u_int8_t status, extStatus;
union desc_value desc_val;
PLD_LOAD_BALANCE_INFO lbinfo;
-   u_int32_t device_id;
+   u_int32_t device_id, data_length;
int threshold_reply_count = 0;
 #if TM_DEBUG
MR_TASK_MANAGE_REQUEST *mr_tm_req;
@@ -1606,6 +1609,8 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t M
 
status = scsi_io_req->RaidContext.raid_context.status;
extStatus = scsi_io_req->RaidContext.raid_context.exStatus;
+   sense = cmd_mpt->sense;
+   data_length = scsi_io_req->DataLength;
 
switch (scsi_io_req->Function) {
case MPI2_FUNCTION_SCSI_TASK_MGMT:
@@ -1621,16 +1626,45 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t M
case MPI2_FUNCTION_SCSI_IO_REQUEST: /* Fast Path IO. */
device_id = cmd_mpt->ccb_ptr->ccb_h.target_id;
lbinfo = &sc->load_balance_info[device_id];
+   /* R1 load balanc

svn commit: r342065 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:03:28 2018
New Revision: 342065
URL: https://svnweb.freebsd.org/changeset/base/342065

Log:
  This patch will add support for new DCMD to get PD information and a single 
data structure
  to specify LD and JBOD.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:02:44 2018(r342064)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:03:28 2018(r342065)
@@ -90,6 +90,8 @@ static void mrsas_update_ext_vd_details(struct mrsas_s
 static int
 mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc,
 struct mrsas_mfi_cmd *cmd_to_abort);
+static void
+mrsas_get_pd_info(struct mrsas_softc *sc, u_int16_t device_id);
 static struct mrsas_softc *
 mrsas_get_softc_instance(struct cdev *dev,
 u_long cmd, caddr_t arg);
@@ -971,6 +973,7 @@ attach_fail:
 static void
 mrsas_ich_startup(void *arg)
 {
+   int i = 0;
struct mrsas_softc *sc = (struct mrsas_softc *)arg;
 
/*
@@ -1006,6 +1009,13 @@ mrsas_ich_startup(void *arg)
/* Enable Interrupts */
mrsas_enable_intr(sc);
 
+   /* Call DCMD get_pd_info for all system PDs */
+   for (i = 0; i < MRSAS_MAX_PD; i++) {
+   if ((sc->target_list[i].target_id != 0x) &&
+   sc->pd_info_mem)
+   mrsas_get_pd_info(sc, sc->target_list[i].target_id);
+   }
+
/* Initiate AEN (Asynchronous Event Notification) */
if (mrsas_start_aen(sc)) {
device_printf(sc->mrsas_dev, "Error: AEN registration FAILED 
!!! "
@@ -1216,6 +1226,16 @@ mrsas_free_mem(struct mrsas_softc *sc)
bus_dma_tag_destroy(sc->evt_detail_tag);
 
/*
+* Free PD info memory
+*/
+   if (sc->pd_info_phys_addr)
+   bus_dmamap_unload(sc->pd_info_tag, sc->pd_info_dmamap);
+   if (sc->pd_info_mem != NULL)
+   bus_dmamem_free(sc->pd_info_tag, sc->pd_info_mem, 
sc->pd_info_dmamap);
+   if (sc->pd_info_tag != NULL)
+   bus_dma_tag_destroy(sc->pd_info_tag);
+
+   /*
 * Free MFI frames
 */
if (sc->mfi_cmd_list) {
@@ -1808,7 +1828,7 @@ static int
 mrsas_alloc_mem(struct mrsas_softc *sc)
 {
u_int32_t verbuf_size, io_req_size, reply_desc_size, sense_size, 
chain_frame_size,
-   evt_detail_size, count;
+   evt_detail_size, count, pd_info_size;
 
/*
 * Allocate parent DMA tag
@@ -2009,7 +2029,39 @@ mrsas_alloc_mem(struct mrsas_softc *sc)
device_printf(sc->mrsas_dev, "Cannot load Event detail buffer 
memory\n");
return (ENOMEM);
}
+
/*
+* Allocate for PD INFO structure
+*/
+   pd_info_size = sizeof(struct mrsas_pd_info);
+   if (bus_dma_tag_create(sc->mrsas_parent_tag,
+   1, 0,
+   BUS_SPACE_MAXADDR_32BIT,
+   BUS_SPACE_MAXADDR,
+   NULL, NULL,
+   pd_info_size,
+   1,
+   pd_info_size,
+   BUS_DMA_ALLOCNOW,
+   NULL, NULL,
+   &sc->pd_info_tag)) {
+   device_printf(sc->mrsas_dev, "Cannot create PD INFO tag\n");
+   return (ENOMEM);
+   }
+   if (bus_dmamem_alloc(sc->pd_info_tag, (void **)&sc->pd_info_mem,
+   BUS_DMA_NOWAIT, &sc->pd_info_dmamap)) {
+   device_printf(sc->mrsas_dev, "Cannot alloc PD INFO buffer 
memory\n");
+   return (ENOMEM);
+   }
+   bzero(sc->pd_info_mem, pd_info_size);
+   if (bus_dmamap_load(sc->pd_info_tag, sc->pd_info_dmamap,
+   sc->pd_info_mem, pd_info_size, mrsas_addr_cb,
+   &sc->pd_info_phys_addr, BUS_DMA_NOWAIT)) {
+   device_printf(sc->mrsas_dev, "Cannot load PD INFO buffer 
memory\n");
+   return (ENOMEM);
+   }
+
+   /*
 * Create a dma tag for data buffers; size will be the maximum
 * possible I/O size (280kB).
 */
@@ -2297,6 +2349,7 @@ mrsas_init_fw(struct mrsas_softc *sc)
device_printf(sc->mrsas_dev, "Adapter initialize Fail.\n");
return (1);
}
+
/* Allocate internal commands for pass-thru */
if (mrsas_alloc_mfi_cmds(sc) != SUCCESS) {
device_printf(sc->mrsas_dev, "Allocate MFI cmd failed.\n");
@@ -2334,6 +2387,12 @@ mrsas_init_fw(struct mrsas_softc *sc)
}
megasas_setup_jbod_map(sc);
 
+
+   memset(sc->target_list, 0,
+   MRSAS_MAX_TM_TARGETS * sizeof(struct mrsas_target));
+   for (i = 0; i < MRSAS_MAX_TM_TARGETS; i++)
+   sc->target_list[i].target_id = 0x;
+
/* For pass-thru, get PD/LD list and controller info */
memset(sc->pd

svn commit: r342066 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:04:16 2018
New Revision: 342066
URL: https://svnweb.freebsd.org/changeset/base/342066

Log:
  This patch will add support for NVME PRPs creation by driver for fastpath
  capable IOs. NVME specification supports specific type of scatter gather list
  called as PRP (Physical Region Page) for IO data buffers. Since NVME drive is
  connected behind SAS3.5 tri-mode adapter, MegaRAID driver/firmware has to 
convert
  OS SGLs in native NVMe PRP format. For IOs sent to firmware, MegaRAID firmware
  does this job of OS SGLs to PRP translation and send PRPs to backend NVME 
device.
  For fastpath IOs, driver will do this OS SGLs to PRP translation.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h
  head/sys/dev/mrsas/mrsas_cam.c
  head/sys/dev/mrsas/mrsas_fp.c

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:03:28 2018(r342065)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:04:16 2018(r342066)
@@ -451,6 +451,12 @@ mrsas_setup_sysctl(struct mrsas_softc *sc)
OID_AUTO, "stream detection", CTLFLAG_RW,
&sc->drv_stream_detection, 0,
"Disable/Enable Stream detection. ");
+   SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+   OID_AUTO, "prp_count", CTLFLAG_RD,
+   &sc->prp_count.val_rdonly, 0, "Number of IOs for which PRPs are 
built");
+   SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+   OID_AUTO, "SGE holes", CTLFLAG_RD,
+   &sc->sge_holes.val_rdonly, 0, "Number of IOs with holes in SGEs");
 }
 
 /*
@@ -899,6 +905,8 @@ mrsas_attach(device_t dev)
 
mrsas_atomic_set(&sc->fw_outstanding, 0);
mrsas_atomic_set(&sc->target_reset_outstanding, 0);
+   mrsas_atomic_set(&sc->prp_count, 0);
+   mrsas_atomic_set(&sc->sge_holes, 0);
 
sc->io_cmds_highwater = 0;
 
@@ -2266,7 +2274,7 @@ mrsas_init_fw(struct mrsas_softc *sc)
u_int32_t max_sectors_1;
u_int32_t max_sectors_2;
u_int32_t tmp_sectors;
-   u_int32_t scratch_pad_2, scratch_pad_3;
+   u_int32_t scratch_pad_2, scratch_pad_3, scratch_pad_4;
int msix_enable = 0;
int fw_msix_count = 0;
int i, j;
@@ -2350,6 +2358,15 @@ mrsas_init_fw(struct mrsas_softc *sc)
return (1);
}
 
+   if (sc->is_ventura) {
+   scratch_pad_4 = mrsas_read_reg(sc, offsetof(mrsas_reg_set,
+   outbound_scratch_pad_4));
+   if ((scratch_pad_4 & MR_NVME_PAGE_SIZE_MASK) >= 
MR_DEFAULT_NVME_PAGE_SHIFT)
+   sc->nvme_page_size = 1 << (scratch_pad_4 & 
MR_NVME_PAGE_SIZE_MASK);
+
+   device_printf(sc->mrsas_dev, "NVME page size\t: (%d)\n", 
sc->nvme_page_size);
+   }
+
/* Allocate internal commands for pass-thru */
if (mrsas_alloc_mfi_cmds(sc) != SUCCESS) {
device_printf(sc->mrsas_dev, "Allocate MFI cmd failed.\n");
@@ -2652,6 +2669,7 @@ mrsas_ioc_init(struct mrsas_softc *sc)
IOCInitMsg->ReplyDescriptorPostQueueAddress = sc->reply_desc_phys_addr;
IOCInitMsg->SystemRequestFrameBaseAddress = sc->io_request_phys_addr;
IOCInitMsg->HostMSIxVectors = (sc->msix_vectors > 0 ? sc->msix_vectors 
: 0);
+   IOCInitMsg->HostPageSize = MR_DEFAULT_NVME_PAGE_SHIFT;
 
init_frame = (struct mrsas_init_frame *)sc->ioc_init_mem;
init_frame->cmd = MFI_CMD_INIT;

Modified: head/sys/dev/mrsas/mrsas.h
==
--- head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:03:28 2018(r342065)
+++ head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:04:16 2018(r342066)
@@ -694,7 +694,7 @@ typedef struct _MPI2_IOC_INIT_REQUEST {
u_int16_t HeaderVersion;/* 0x0E */
u_int32_t Reserved5;/* 0x10 */
u_int16_t Reserved6;/* 0x14 */
-   u_int8_t Reserved7; /* 0x16 */
+   u_int8_t HostPageSize;  /* 0x16 */
u_int8_t HostMSIxVectors;   /* 0x17 */
u_int16_t Reserved8;/* 0x18 */
u_int16_t SystemRequestFrameSize;   /* 0x1A */
@@ -763,7 +763,7 @@ Mpi2IOCInitRequest_t, MPI2_POINTER pMpi2IOCInitRequest
 typedef struct _MR_DEV_HANDLE_INFO {
u_int16_t curDevHdl;
u_int8_t validHandles;
-   u_int8_t reserved;
+   u_int8_t interfaceType;
u_int16_t devHandle[2];
 }  MR_DEV_HANDLE_INFO;
 
@@ -1017,6 +1017,7 @@ struct IO_REQUEST_INFO {
u_int16_t ldTgtId;
u_int8_t isRead;
u_int16_t devHandle;
+   u_int8_t pdInterface;
u_int64_t pdBlock;
u_int8_t fpOkForIo;
u_int8_t IoforUnevenSpan;
@@ -1164,6 +1165,22 @@ typedef struct _MR_FW

svn commit: r342067 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:05:01 2018
New Revision: 342067
URL: https://svnweb.freebsd.org/changeset/base/342067

Log:
  Change IOC INIT wait time to 180 secs to keep it inline with timeout
  used by internal DCMDs.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas.c
  head/sys/dev/mrsas/mrsas.h

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:04:16 2018(r342066)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:05:01 2018(r342067)
@@ -2641,7 +2641,7 @@ mrsas_ioc_init(struct mrsas_softc *sc)
struct mrsas_init_frame *init_frame;
pMpi2IOCInitRequest_t IOCInitMsg;
MRSAS_REQUEST_DESCRIPTOR_UNION req_desc;
-   u_int8_t max_wait = MRSAS_IOC_INIT_WAIT_TIME;
+   u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME;
bus_addr_t phys_addr;
int i, retcode = 0;
u_int32_t scratch_pad_2;

Modified: head/sys/dev/mrsas/mrsas.h
==
--- head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:04:16 2018(r342066)
+++ head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:05:01 2018(r342067)
@@ -2287,7 +2287,6 @@ struct mrsas_ctrl_info {
  */
 #defineMRSAS_RESET_WAIT_TIME   180
 #defineMRSAS_INTERNAL_CMD_WAIT_TIME180
-#defineMRSAS_IOC_INIT_WAIT_TIME60
 #defineMRSAS_RESET_NOTICE_INTERVAL 5
 #defineMRSAS_IOCTL_CMD 0
 #defineMRSAS_DEFAULT_CMD_TIMEOUT   90
___
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: r342068 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:05:49 2018
New Revision: 342068
URL: https://svnweb.freebsd.org/changeset/base/342068

Log:
  This patch will increase debug level as current logging level has
  very minimal prints and even few important messages will not get logged.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

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

Modified: head/sys/dev/mrsas/mrsas.c
==
--- head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:05:01 2018(r342067)
+++ head/sys/dev/mrsas/mrsas.c  Fri Dec 14 08:05:49 2018(r342068)
@@ -471,7 +471,8 @@ mrsas_get_tunables(struct mrsas_softc *sc)
char tmpstr[80];
 
/* XXX default to some debugging for now */
-   sc->mrsas_debug = MRSAS_FAULT;
+   sc->mrsas_debug =
+   (MRSAS_FAULT | MRSAS_OCR | MRSAS_INFO | MRSAS_TRACE | 
MRSAS_AEN);
sc->mrsas_io_timeout = MRSAS_IO_TIMEOUT;
sc->mrsas_fw_fault_check_delay = 1;
sc->reset_count = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342069 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 08:06:39 2018
New Revision: 342069
URL: https://svnweb.freebsd.org/changeset/base/342069

Log:
  Driver version upgrade 07.708.02.00-fbsd
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

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

Modified: head/sys/dev/mrsas/mrsas.h
==
--- head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:05:49 2018(r342068)
+++ head/sys/dev/mrsas/mrsas.h  Fri Dec 14 08:06:39 2018(r342069)
@@ -110,7 +110,7 @@ __FBSDID("$FreeBSD$");
  */
 #defineBYTE_ALIGNMENT  1
 #defineMRSAS_MAX_NAME_LENGTH   32
-#defineMRSAS_VERSION   
"06.712.04.00-fbsd"
+#defineMRSAS_VERSION   
"07.708.02.00-fbsd"
 #defineMRSAS_ULONG_MAX 
0x
 #defineMRSAS_DEFAULT_TIMEOUT   0x14/* Temporarily 
set */
 #defineDONE0
___
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: r342020 - in head/sys: arm/mv arm64/conf conf

2018-12-14 Thread Marcin Wojtas
Hi Manu,

Imo the new driver is adding code duplication - please check
sys/arm/mv/armada/thermal.c. It contains support for armada38x (which
has BTW exactly same coefficients as CP110). Basically it would be
enough to add 2 structures for ap806 and cp110.

Best regards,
Marcinśr., 12 gru 2018 o 23:33 Emmanuel Vadot  napisał(a):
>
> Author: manu
> Date: Wed Dec 12 22:33:05 2018
> New Revision: 342020
> URL: https://svnweb.freebsd.org/changeset/base/342020
>
> Log:
>   mv_thermal: Add thermal driver for AP806 and CP110 thermal sensor
>
>   Sponsored by: Rubicon Communications, LLC ("Netgate")
>
> Added:
>   head/sys/arm/mv/mv_thermal.c   (contents, props changed)
> Modified:
>   head/sys/arm64/conf/GENERIC
>   head/sys/conf/files.arm64
>
> Added: head/sys/arm/mv/mv_thermal.c
> ==
> --- /dev/null   00:00:00 1970   (empty, because file is newly added)
> +++ head/sys/arm/mv/mv_thermal.cWed Dec 12 22:33:05 2018
> (r342020)
> @@ -0,0 +1,381 @@
> +/*-
> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
> + *
> + * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + *
> + * $FreeBSD$
> + */
> +
> +#include 
> +__FBSDID("$FreeBSD$");
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +
> +#defineCONTROL00x00
> +#define CONTROL0_TSEN_START(1 << 0)
> +#define CONTROL0_TSEN_RESET(1 << 1)
> +#define CONTROL0_TSEN_EN   (1 << 2)
> +#define CONTROL0_CHANNEL_SHIFT 13
> +#define CONTROL0_CHANNEL_MASK  0xF
> +#define CONTROL0_OSR_SHIFT 24
> +#define CONTROL0_OSR_MAX   3   /* OSR = 512 * 4uS = ~2mS */
> +#define CONTROL0_MODE_SHIFT30
> +#define CONTROL0_MODE_EXTERNAL 0x2
> +#define CONTROL0_MODE_MASK 0x3
> +
> +#defineCONTROL10x04
> +/* This doesn't seems to work */
> +#defineCONTROL1_TSEN_SENS_SHIFT21
> +#defineCONTROL1_TSEN_SENS_MASK 0x7
> +
> +#defineSTATUS  0x00
> +#defineSTATUS_TEMP_MASK0x3FF
> +
> +enum mv_thermal_type {
> +   MV_AP806 = 1,
> +   MV_CP110,
> +};
> +
> +struct mv_thermal_config {
> +   enum mv_thermal_typetype;
> +   int ncpus;
> +   int64_t calib_mul;
> +   int64_t calib_add;
> +   int64_t calib_div;
> +   uint32_tvalid_mask;
> +   boolsigned_value;
> +};
> +
> +struct mv_thermal_softc {
> +   device_tdev;
> +   struct resource *res[2];
> +   struct mtx  mtx;
> +
> +   struct mv_thermal_config*config;
> +   int cur_sensor;
> +};
> +
> +static struct mv_thermal_config mv_ap806_config = {
> +   .type = MV_AP806,
> +   .ncpus = 4,
> +   .calib_mul = 423,
> +   .calib_add = -15,
> +   .calib_div = 100,
> +   .valid_mask = (1 << 16),
> +   .signed_value = true,
> +};
> +
> +static struct mv_thermal_config mv_cp110_config = {
> +   .type = MV_CP110,
> +   .calib_mul = 296,
> +   .calib_add = 1172499100,
> +   .calib_div = 420100,
> +   .valid_mask = (1 << 10),
> +   .signed_value = false,
> +};
> +
> +static struct resource_spec mv_thermal_res_spec[] = {
> +   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
> +   

svn commit: r342071 - head/share/man/man4

2018-12-14 Thread Eugene Grosbein
Author: eugen
Date: Fri Dec 14 09:24:14 2018
New Revision: 342071
URL: https://svnweb.freebsd.org/changeset/base/342071

Log:
  ng_bpf.4: fix EXAMPLES: do not activate promiscuous mode
  
  PR:   102719
  MFC after:3 days

Modified:
  head/share/man/man4/ng_bpf.4

Modified: head/share/man/man4/ng_bpf.4
==
--- head/share/man/man4/ng_bpf.4Fri Dec 14 09:06:56 2018
(r342070)
+++ head/share/man/man4/ng_bpf.4Fri Dec 14 09:24:14 2018
(r342071)
@@ -156,7 +156,7 @@ INHOOK="hook1"
 MATCHHOOK="hook2"
 NOTMATCHHOOK="hook3"
 
-BPFPROG=$( tcpdump -s 8192 -ddd ${PATTERN} | \\
+BPFPROG=$( tcpdump -s 8192 -p -ddd ${PATTERN} | \\
( read len ; \\
  echo -n "bpf_prog_len=$len" ; \\
  echo -n "bpf_prog=[" ; \\
___
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: r342072 - head/sys/dev/ichwd

2018-12-14 Thread Andriy Gapon
Author: avg
Date: Fri Dec 14 09:28:20 2018
New Revision: 342072
URL: https://svnweb.freebsd.org/changeset/base/342072

Log:
  ichwd: add support for clearing No Reboot bit in TCOv4
  
  This is based on a patch developed by
  Tetsuya Uemura .
  Many thanks!
  
  Submitted by: Tetsuya Uemura  (earlier version)
  Tested by:Tetsuya Uemura 
  MFC after:2 weeks

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/dev/ichwd/ichwd.h

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:24:14 2018(r342071)
+++ head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:28:20 2018(r342072)
@@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include 
+#include 
+#include 
+
 static struct ichwd_device ichwd_devices[] = {
{ DEVICEID_82801AA,  "Intel 82801AA watchdog timer",1, 1 },
{ DEVICEID_82801AB,  "Intel 82801AB watchdog timer",1, 1 },
@@ -309,6 +313,8 @@ static devclass_t ichwd_devclass;
 /* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
 #define ichwd_read_pmc_4(sc, off) \
bus_read_4((sc)->gcs_res, (off))
+#define ichwd_read_gc_4(sc, off) \
+   bus_read_4((sc)->gc_res, (off))
 
 #define ichwd_write_tco_1(sc, off, val) \
bus_write_1((sc)->tco_res, (off), (val))
@@ -323,6 +329,8 @@ static devclass_t ichwd_devclass;
 /* NB: TCO version 3 devices use the gcs_res resource for the PMC register. */
 #define ichwd_write_pmc_4(sc, off, val) \
bus_write_4((sc)->gcs_res, (off), (val))
+#define ichwd_write_gc_4(sc, off, val) \
+   bus_write_4((sc)->gc_res, (off), (val))
 
 #define ichwd_verbose_printf(dev, ...) \
do {\
@@ -495,9 +503,12 @@ ichwd_clear_noreboot(struct ichwd_softc *sc)
rc = EIO;
break;
case 4:
-   /*
-* TODO.  This needs access to a hidden PCI device at 31:1.
-*/
+   status = ichwd_read_gc_4(sc, 0);
+   status &= ~SMB_GC_NO_REBOOT;
+   ichwd_write_gc_4(sc, 0, status);
+   status = ichwd_read_gc_4(sc, 0);
+   if (status & SMB_GC_NO_REBOOT)
+   rc = EIO;
break;
default:
ichwd_verbose_printf(sc->device,
@@ -611,6 +622,7 @@ ichwd_identify(driver_t *driver, device_t parent)
struct ichwd_device *id_p;
device_t ich, smb;
device_t dev;
+   uint64_t base_address64;
uint32_t base_address;
uint32_t ctl;
int rc;
@@ -671,6 +683,33 @@ ichwd_identify(driver_t *driver, device_t parent)
"Can not set TCO v%d I/O resource (err = %d)\n",
id_p->tco_version, rc);
}
+
+   /*
+* Unhide Primary to Sideband Bridge (P2SB) PCI device, so that
+* we can discover the base address of Private Configuration
+* Space via the bridge's BAR.
+* Then hide back the bridge.
+*/
+   pci_cfgregwrite(0, 31, 1, 0xe1, 0, 1);
+   base_address64 = pci_cfgregread(0, 31, 1, SBREG_BAR + 4, 4);
+   base_address64 <<= 32;
+   base_address64 |= pci_cfgregread(0, 31, 1, SBREG_BAR, 4);
+   base_address64 &= ~0xfull;
+   pci_cfgregwrite(0, 31, 1, 0xe1, 1, 1);
+
+   /*
+* No Reboot bit is in General Control register, offset 0xc,
+* within the SMBus target port, ID 0xc6.
+*/
+   base_address64 += PCR_REG_OFF(SMB_PORT_ID, SMB_GC_REG);
+   rc = bus_set_resource(dev, SYS_RES_MEMORY, 1, base_address64,
+   SMB_GC_SIZE);
+   if (rc != 0) {
+   ichwd_verbose_printf(dev,
+   "Can not set TCO v%d PCR I/O resource (err = %d)\n",
+   id_p->tco_version, rc);
+   }
+
break;
default:
ichwd_verbose_printf(dev,
@@ -723,6 +762,18 @@ ichwd_smb_attach(device_t dev)
return (ENXIO);
}
 
+   /*
+* Allocate General Control I/O register in PCH
+* Private Configuration Space (PCR).
+*/
+   sc->gc_rid = 1;
+   sc->gc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->gc_rid,
+   RF_ACTIVE | RF_SHAREABLE);
+   if (sc->gc_res == NULL) {
+   device_printf(dev, "unable to reserve hidden P2SB registers\n");
+   return (ENXIO);
+   }
+
/* Get ACPI base address. */
isab = device_get_parent(device_get_parent(dev));
pmdev = pci_find_dbsf(pci_get_domain(isab), pci_get_bus(isab), 31, 2);
@@ -737,7 +788,7 @@ ichwd_smb_attach(device_t dev)
}
 
/* Allocate SMI control I/O register space. */
-

svn commit: r342073 - head/sys/dev/ichwd

2018-12-14 Thread Andriy Gapon
Author: avg
Date: Fri Dec 14 09:30:43 2018
New Revision: 342073
URL: https://svnweb.freebsd.org/changeset/base/342073

Log:
  ichwd: add Sunrise Point-LP ID
  
  Submitted by: Tetsuya Uemura 
  Tested by:Tetsuya Uemura 
  MFC after:2 weeks
  Relnotes: maybe

Modified:
  head/sys/dev/ichwd/ichwd.c
  head/sys/dev/ichwd/ichwd.h

Modified: head/sys/dev/ichwd/ichwd.c
==
--- head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:28:20 2018(r342072)
+++ head/sys/dev/ichwd/ichwd.c  Fri Dec 14 09:30:43 2018(r342073)
@@ -295,6 +295,7 @@ static struct ichwd_device ichwd_devices[] = {
 
 static struct ichwd_device ichwd_smb_devices[] = {
{ DEVICEID_LEWISBURG_SMB, "Lewisburg watchdog timer",   10, 4 },
+   { DEVICEID_SRPTLP_SMB,"Sunrise Point-LP watchdog timer",10, 4 },
{ 0, NULL, 0, 0 },
 };
 

Modified: head/sys/dev/ichwd/ichwd.h
==
--- head/sys/dev/ichwd/ichwd.h  Fri Dec 14 09:28:20 2018(r342072)
+++ head/sys/dev/ichwd/ichwd.h  Fri Dec 14 09:30:43 2018(r342073)
@@ -276,6 +276,7 @@ struct ichwd_softc {
 #defineDEVICEID_WCPT_LP7   0x9cc7
 #defineDEVICEID_WCPT_LP9   0x9cc9
 #defineDEVICEID_LEWISBURG_SMB  0xa1a3
+#defineDEVICEID_SRPTLP_SMB 0x9d23
 
 /* ICH LPC Interface Bridge Registers (ICH5 and older) */
 #defineICH_GEN_STA 0xd4
___
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: r342076 - head/sys/arm/allwinner

2018-12-14 Thread Emmanuel Vadot
Author: manu
Date: Fri Dec 14 10:26:17 2018
New Revision: 342076
URL: https://svnweb.freebsd.org/changeset/base/342076

Log:
  arm64: allwinner: axp81x: Fix double invertion for FLDO1
  
  This fix booting on A64 boards when disabling the unused regulators at boot.
  We did disable all the regulator handled by register 0x13 which of course 
contain
  mandatory regulators for the board to be up.
  
  Reported by:  Mark Millard 
  X-MFC-With:   r340848

Modified:
  head/sys/arm/allwinner/axp81x.c

Modified: head/sys/arm/allwinner/axp81x.c
==
--- head/sys/arm/allwinner/axp81x.c Fri Dec 14 10:25:22 2018
(r342075)
+++ head/sys/arm/allwinner/axp81x.c Fri Dec 14 10:26:17 2018
(r342076)
@@ -437,7 +437,7 @@ static struct axp8xx_regdef axp8xx_common_regdefs[] = 
.id = AXP8XX_REG_ID_FLDO1,
.name = "fldo1",
.enable_reg = AXP_POWERCTL3,
-   .enable_mask = (uint8_t) ~AXP_POWERCTL3_FLDO1,
+   .enable_mask = (uint8_t) AXP_POWERCTL3_FLDO1,
.enable_value = AXP_POWERCTL3_FLDO1,
.voltage_min = 700,
.voltage_max = 1450,
___
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: r342020 - in head/sys: arm/mv arm64/conf conf

2018-12-14 Thread Emmanuel Vadot


 Hi Marcin,

On Fri, 14 Dec 2018 09:43:49 +0100
Marcin Wojtas  wrote:

> Hi Manu,
> 
> Imo the new driver is adding code duplication - please check
> sys/arm/mv/armada/thermal.c. It contains support for armada38x (which
> has BTW exactly same coefficients as CP110). Basically it would be
> enough to add 2 structures for ap806 and cp110.
> 
> Best regards,


 Oops, I somehow miss this driver when I added this one, I'll make the
AP806 and CP110 work with this one and revert mine soon.
 Thanks for reporting.

> Marcin?r., 12 gru 2018 o 23:33 Emmanuel Vadot  napisa?(a):
> >
> > Author: manu
> > Date: Wed Dec 12 22:33:05 2018
> > New Revision: 342020
> > URL: https://svnweb.freebsd.org/changeset/base/342020
> >
> > Log:
> >   mv_thermal: Add thermal driver for AP806 and CP110 thermal sensor
> >
> >   Sponsored by: Rubicon Communications, LLC ("Netgate")
> >
> > Added:
> >   head/sys/arm/mv/mv_thermal.c   (contents, props changed)
> > Modified:
> >   head/sys/arm64/conf/GENERIC
> >   head/sys/conf/files.arm64
> >
> > Added: head/sys/arm/mv/mv_thermal.c
> > ==
> > --- /dev/null   00:00:00 1970   (empty, because file is newly added)
> > +++ head/sys/arm/mv/mv_thermal.cWed Dec 12 22:33:05 2018
> > (r342020)
> > @@ -0,0 +1,381 @@
> > +/*-
> > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
> > + *
> > + * Copyright (c) 2018 Rubicon Communications, LLC (Netgate)
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> > + * modification, are permitted provided that the following conditions
> > + * are met:
> > + * 1. Redistributions of source code must retain the above copyright
> > + *notice, this list of conditions and the following disclaimer.
> > + * 2. Redistributions in binary form must reproduce the above copyright
> > + *notice, this list of conditions and the following disclaimer in the
> > + *documentation and/or other materials provided with the distribution.
> > + *
> > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> > PURPOSE
> > + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> > CONSEQUENTIAL
> > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
> > STRICT
> > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 
> > WAY
> > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > + * SUCH DAMAGE.
> > + *
> > + * $FreeBSD$
> > + */
> > +
> > +#include 
> > +__FBSDID("$FreeBSD$");
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#defineCONTROL00x00
> > +#define CONTROL0_TSEN_START(1 << 0)
> > +#define CONTROL0_TSEN_RESET(1 << 1)
> > +#define CONTROL0_TSEN_EN   (1 << 2)
> > +#define CONTROL0_CHANNEL_SHIFT 13
> > +#define CONTROL0_CHANNEL_MASK  0xF
> > +#define CONTROL0_OSR_SHIFT 24
> > +#define CONTROL0_OSR_MAX   3   /* OSR = 512 * 4uS = ~2mS */
> > +#define CONTROL0_MODE_SHIFT30
> > +#define CONTROL0_MODE_EXTERNAL 0x2
> > +#define CONTROL0_MODE_MASK 0x3
> > +
> > +#defineCONTROL10x04
> > +/* This doesn't seems to work */
> > +#defineCONTROL1_TSEN_SENS_SHIFT21
> > +#defineCONTROL1_TSEN_SENS_MASK 0x7
> > +
> > +#defineSTATUS  0x00
> > +#defineSTATUS_TEMP_MASK0x3FF
> > +
> > +enum mv_thermal_type {
> > +   MV_AP806 = 1,
> > +   MV_CP110,
> > +};
> > +
> > +struct mv_thermal_config {
> > +   enum mv_thermal_typetype;
> > +   int ncpus;
> > +   int64_t calib_mul;
> > +   int64_t calib_add;
> > +   int64_t calib_div;
> > +   uint32_tvalid_mask;
> > +   boolsigned_value;
> > +};
> > +
> > +struct mv_thermal_softc {
> > +   device_tdev;
> > +   struct resource *res[2];
> > +   struct mtx  mtx;
> > +
> > +   struct mv_thermal_config*config;
> > +   int cur_sensor;
> > +};
> > +
> > +static struct mv_thermal_config mv_ap806_config = {
> > +   .type = MV_AP806,
> > +   .ncpus = 4,
> > +   .calib_mul = 423,
> >

svn commit: r342079 - head/sys/dev/mrsas

2018-12-14 Thread Kashyap D Desai
Author: kadesai
Date: Fri Dec 14 10:49:48 2018
New Revision: 342079
URL: https://svnweb.freebsd.org/changeset/base/342079

Log:
  Compilation failure on ppc and mips due to Revision 342066.
  Adding extra memset on chain frame.
  
  Submitted by: Sumit Saxena 
  Reviewed by:  Kashyap Desai 
  Approved by:  ken
  MFC after:  3 days
  Sponsored by:   Broadcom Inc

Modified:
  head/sys/dev/mrsas/mrsas_cam.c

Modified: head/sys/dev/mrsas/mrsas_cam.c
==
--- head/sys/dev/mrsas/mrsas_cam.c  Fri Dec 14 10:45:46 2018
(r342078)
+++ head/sys/dev/mrsas/mrsas_cam.c  Fri Dec 14 10:49:48 2018
(r342079)
@@ -1577,7 +1577,8 @@ static void mrsas_build_prp_nvme(struct mrsas_mpt_cmd 
struct mrsas_softc *sc = cmd->sc;
int sge_len, offset, num_prp_in_chain = 0;
pMpi25IeeeSgeChain64_t main_chain_element, ptr_first_sgl, sgl_ptr;
-   u_int64_t *ptr_sgl, *ptr_sgl_phys;
+   u_int64_t *ptr_sgl;
+   bus_addr_t ptr_sgl_phys;
u_int64_t sge_addr;
u_int32_t page_mask, page_mask_result, i = 0;
u_int32_t first_prp_len;
@@ -1600,14 +1601,15 @@ static void mrsas_build_prp_nvme(struct mrsas_mpt_cmd 
 */
page_mask = mr_nvme_pg_size - 1;
ptr_sgl = (u_int64_t *) cmd->chain_frame;
-   ptr_sgl_phys = (u_int64_t *) cmd->chain_frame_phys_addr;;
+   ptr_sgl_phys = cmd->chain_frame_phys_addr;
+   memset(ptr_sgl, 0, sc->max_chain_frame_sz);
 
/* Build chain frame element which holds all PRPs except first*/
main_chain_element = (pMpi25IeeeSgeChain64_t)
((u_int8_t *)sgl_ptr + sizeof(MPI25_IEEE_SGE_CHAIN64));
 
 
-   main_chain_element->Address = (u_int64_t) ptr_sgl_phys;
+   main_chain_element->Address = cmd->chain_frame_phys_addr;
main_chain_element->NextChainOffset = 0;
main_chain_element->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT |
IEEE_SGE_FLAGS_SYSTEM_ADDR |
___
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: r342084 - in head/sys: conf dev/tpm

2018-12-14 Thread Marcin Wojtas
Author: mw
Date: Fri Dec 14 16:14:36 2018
New Revision: 342084
URL: https://svnweb.freebsd.org/changeset/base/342084

Log:
  Introduce driver for TPM 2.0 in CRB and FIFO (TIS) modes
  
  It was written basing on:
  TCG PC Client Platform TPM Profile (PTP) Specification Version 22, Revision 
1.03.
  It only supports Locality 0. Interrupts are only supported in FIFO mode.
  
  The driver in FIFO mode was tested on x86 with Infineon SLB9665 discrete TPM 
chip.
  Driver in both modes was also tested on qemu with swtpm running on host.
  
  Submitted by: Kornel Duleba 
  Obtained from: Semihalf
  Sponsored by: Stormshield
  Differential Revision: https://reviews.freebsd.org/D18048

Added:
  head/sys/dev/tpm/tpm20.c   (contents, props changed)
  head/sys/dev/tpm/tpm20.h   (contents, props changed)
  head/sys/dev/tpm/tpm_crb.c   (contents, props changed)
  head/sys/dev/tpm/tpm_tis.c   (contents, props changed)
Modified:
  head/sys/conf/files.amd64

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Fri Dec 14 14:49:04 2018(r342083)
+++ head/sys/conf/files.amd64   Fri Dec 14 16:14:36 2018(r342084)
@@ -491,6 +491,9 @@ dev/syscons/scvesactl.c optionalsc vga 
vesa
 dev/syscons/scvgarndr.coptionalsc vga
 dev/syscons/scvtb.coptionalsc
 dev/tpm/tpm.c  optionaltpm
+dev/tpm/tpm20.coptionaltpm
+dev/tpm/tpm_crb.c  optionaltpm acpi
+dev/tpm/tpm_tis.c  optionaltpm acpi
 dev/tpm/tpm_acpi.c optionaltpm acpi
 dev/tpm/tpm_isa.c  optionaltpm isa
 dev/uart/uart_cpu_x86.coptionaluart

Added: head/sys/dev/tpm/tpm20.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/tpm/tpm20.cFri Dec 14 16:14:36 2018(r342084)
@@ -0,0 +1,260 @@
+/*-
+ * Copyright (c) 2018 Stormshield.
+ * Copyright (c) 2018 Semihalf.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "tpm20.h"
+
+MALLOC_DECLARE(M_TPM20);
+MALLOC_DEFINE(M_TPM20, "tpm_buffer", "buffer for tpm 2.0 driver");
+
+static void tpm20_discard_buffer(void *arg);
+static int tpm20_save_state(device_t dev, bool suspend);
+
+int
+tpm20_read(struct cdev *dev, struct uio *uio, int flags)
+{
+   struct tpm_sc *sc;
+   size_t bytes_to_transfer;
+   int result = 0;
+
+   sc = (struct tpm_sc *)dev->si_drv1;
+
+   callout_stop(&sc->discard_buffer_callout);
+   sx_xlock(&sc->dev_lock);
+
+   bytes_to_transfer = MIN(sc->pending_data_length, uio->uio_resid);
+   if (bytes_to_transfer > 0) {
+   result = uiomove((caddr_t) sc->buf, bytes_to_transfer, uio);
+   memset(sc->buf, 0, TPM_BUFSIZE);
+   sc->pending_data_length = 0;
+   cv_signal(&sc->buf_cv);
+   } else {
+   result = ETIMEDOUT;
+   }
+
+   sx_xunlock(&sc->dev_lock);
+
+   return (result);
+}
+
+int
+tpm20_write(struct cdev *dev, struct uio *uio, int flags)
+{
+   struct tpm_sc *sc;
+   size_t byte_count;
+   int result = 0;
+
+   sc = (struct tpm_sc *)dev->si_drv1;
+
+   byte_count = uio->uio_resid;
+   if (byte_count < TPM_HEADER_SIZE) {
+   device_printf(sc->dev,
+   "Requested transfer is too small\n");
+   return (EINVAL);
+   }
+
+   if (byte_count > TPM_BUFSIZE) {
+   device_printf(sc->dev,
+   "Requested transfer 

svn commit: r342085 - head/sys/dev/tpm

2018-12-14 Thread Marcin Wojtas
Author: mw
Date: Fri Dec 14 17:43:35 2018
New Revision: 342085
URL: https://svnweb.freebsd.org/changeset/base/342085

Log:
  Fix TPM driver compilation from r342084
  
  Include recent ACPI_ID_PROBE API change.

Modified:
  head/sys/dev/tpm/tpm_crb.c
  head/sys/dev/tpm/tpm_tis.c

Modified: head/sys/dev/tpm/tpm_crb.c
==
--- head/sys/dev/tpm/tpm_crb.c  Fri Dec 14 16:14:36 2018(r342084)
+++ head/sys/dev/tpm/tpm_crb.c  Fri Dec 14 17:43:35 2018(r342085)
@@ -107,7 +107,7 @@ tpmcrb_acpi_probe(device_t dev)
int rid = 0;
uint32_t caps;
 
-   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids) == NULL)
+   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL) == 
NULL)
return (ENXIO);
 
/* Check if device is in CRB mode */

Modified: head/sys/dev/tpm/tpm_tis.c
==
--- head/sys/dev/tpm/tpm_tis.c  Fri Dec 14 16:14:36 2018(r342084)
+++ head/sys/dev/tpm/tpm_tis.c  Fri Dec 14 17:43:35 2018(r342085)
@@ -104,7 +104,7 @@ tpmtis_acpi_probe(device_t dev)
int rid = 0;
uint32_t caps;
 
-   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids) == NULL)
+   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids, NULL) == 
NULL)
return (ENXIO);
 
/* Check if device is in TPM 2.0 TIS mode */
___
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: r342085 - head/sys/dev/tpm

2018-12-14 Thread John Baldwin
On 12/14/18 9:43 AM, Marcin Wojtas wrote:
> Author: mw
> Date: Fri Dec 14 17:43:35 2018
> New Revision: 342085
> URL: https://svnweb.freebsd.org/changeset/base/342085
> 
> Log:
>   Fix TPM driver compilation from r342084
>   
>   Include recent ACPI_ID_PROBE API change.
> 
> Modified:
>   head/sys/dev/tpm/tpm_crb.c
>   head/sys/dev/tpm/tpm_tis.c
> 
> Modified: head/sys/dev/tpm/tpm_crb.c
> ==
> --- head/sys/dev/tpm/tpm_crb.cFri Dec 14 16:14:36 2018
> (r342084)
> +++ head/sys/dev/tpm/tpm_crb.cFri Dec 14 17:43:35 2018
> (r342085)
> @@ -107,7 +107,7 @@ tpmcrb_acpi_probe(device_t dev)
>   int rid = 0;
>   uint32_t caps;
>  
> - if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids) == NULL)
> + if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL) == 
> NULL)
>   return (ENXIO);

I think it doesn't return a pointer anymore either.  I think you want to use
its return value as the return value from probe to honor the relative priority
of CID vs HID matches, so something like:

 int error;

 error = ACPI_ID_PROBE(...);
 if (error > 0)
 return (error);

 ...

 return (error);

Instead of 'return (BUS_GENERIC_PROBE)' or some such.

-- 
John Baldwin


___
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: r342086 - head/sys/dev/nfe

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 18:16:35 2018
New Revision: 342086
URL: https://svnweb.freebsd.org/changeset/base/342086

Log:
  Add support for the nForce MCP89 adapter.
  
  PR:   234015
  Submitted by: Andrejs Bogdanovs 
  MFC after:1 week

Modified:
  head/sys/dev/nfe/if_nfe.c
  head/sys/dev/nfe/if_nfereg.h

Modified: head/sys/dev/nfe/if_nfe.c
==
--- head/sys/dev/nfe/if_nfe.c   Fri Dec 14 17:43:35 2018(r342085)
+++ head/sys/dev/nfe/if_nfe.c   Fri Dec 14 18:16:35 2018(r342086)
@@ -265,6 +265,8 @@ static struct nfe_type nfe_devs[] = {
"NVIDIA nForce MCP79 Networking Adapter"},
{PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP79_LAN4,
"NVIDIA nForce MCP79 Networking Adapter"},
+   {PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP89_LAN,
+   "NVIDIA nForce MCP89 Networking Adapter"},
{0, 0, NULL}
 };
 
@@ -531,6 +533,7 @@ nfe_attach(device_t dev)
case PCI_PRODUCT_NVIDIA_MCP79_LAN2:
case PCI_PRODUCT_NVIDIA_MCP79_LAN3:
case PCI_PRODUCT_NVIDIA_MCP79_LAN4:
+   case PCI_PRODUCT_NVIDIA_MCP89_LAN:
/* XXX flow control */
sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM |
NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_MIB_V3;

Modified: head/sys/dev/nfe/if_nfereg.h
==
--- head/sys/dev/nfe/if_nfereg.hFri Dec 14 17:43:35 2018
(r342085)
+++ head/sys/dev/nfe/if_nfereg.hFri Dec 14 18:16:35 2018
(r342086)
@@ -338,6 +338,7 @@ struct nfe_desc64 {
 #definePCI_PRODUCT_NVIDIA_MCP79_LAN2   0x0ab1
 #definePCI_PRODUCT_NVIDIA_MCP79_LAN3   0x0ab2
 #definePCI_PRODUCT_NVIDIA_MCP79_LAN4   0x0ab3
+#definePCI_PRODUCT_NVIDIA_MCP89_LAN0x0d7d
 
 #definePCI_PRODUCT_NVIDIA_NFORCE3_LAN2 
PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN1
 #definePCI_PRODUCT_NVIDIA_NFORCE3_LAN3 
PCI_PRODUCT_NVIDIA_NFORCE2_400_LAN2
___
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: r342057 - head/crypto/openssl/crypto/engine

2018-12-14 Thread Jung-uk Kim
On 18. 12. 13., Kubilay Kocak wrote:
> On 14/12/2018 12:06 pm, Jung-uk Kim wrote:
>> Author: jkim
>> Date: Fri Dec 14 01:06:34 2018
>> New Revision: 342057
>> URL: https://svnweb.freebsd.org/changeset/base/342057
>>
>> Log:
>>    Do not complain when /dev/crypto does not exist.
>>       Now the new devcrypto engine is enabled since r342009, many
>> users started
>>    seeing "Could not open /dev/crypto: No such file or directory". 
>> Disable
>>    the annoying error message as it is not very useful anyway.
>>       Note the patch was submitted upstream.
>>       https://github.com/openssl/openssl/pull/7896
>>
>> Modified:
>>    head/crypto/openssl/crypto/engine/eng_devcrypto.c
>>
>> Modified: head/crypto/openssl/crypto/engine/eng_devcrypto.c
>> ==
>>
>> --- head/crypto/openssl/crypto/engine/eng_devcrypto.c    Fri Dec 14
>> 00:40:38 2018    (r342056)
>> +++ head/crypto/openssl/crypto/engine/eng_devcrypto.c    Fri Dec 14
>> 01:06:34 2018    (r342057)
>> @@ -24,6 +24,8 @@
>>     #include "internal/engine.h"
>>   +/* #define ENGINE_DEVCRYPTO_DEBUG */
>> +
>>   #ifdef CRYPTO_ALGORITHM_MIN
>>   # define CHECK_BSD_STYLE_MACROS
>>   #endif
>> @@ -615,6 +617,9 @@ void engine_load_devcrypto_int()
>>   ENGINE *e = NULL;
>>     if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
>> +#ifndef ENGINE_DEVCRYPTO_DEBUG
>> +    if (errno != ENOENT)
>> +#endif
>>   fprintf(stderr, "Could not open /dev/crypto: %s\n",
>> strerror(errno));
>>   return;
>>   }
> 
> How trivially could devcrypto_debug  be modified to be a runtime
> configuration (say sysctl) setting?

This file came from OpenSSL and we will not implement any
FreeBSD-specific code like that.

Jung-uk Kim



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r342057 - head/crypto/openssl/crypto/engine

2018-12-14 Thread Jung-uk Kim
On 18. 12. 13., Kevin Bowling wrote:
> But why, you can trivially see the open() call with truss or more
> advanced tracers if you are debugging this

Sure.  I just followed OpenSSL coding style.

Jung-uk Kim

> On Thu, Dec 13, 2018 at 6:39 PM Kubilay Kocak  > wrote:
> 
> On 14/12/2018 12:06 pm, Jung-uk Kim wrote:
> > Author: jkim
> > Date: Fri Dec 14 01:06:34 2018
> > New Revision: 342057
> > URL: https://svnweb.freebsd.org/changeset/base/342057
> >
> > Log:
> >    Do not complain when /dev/crypto does not exist.
> >   
> >    Now the new devcrypto engine is enabled since r342009, many
> users started
> >    seeing "Could not open /dev/crypto: No such file or
> directory".  Disable
> >    the annoying error message as it is not very useful anyway.
> >   
> >    Note the patch was submitted upstream.
> >   
> >    https://github.com/openssl/openssl/pull/7896
> >
> > Modified:
> >    head/crypto/openssl/crypto/engine/eng_devcrypto.c
> >
> > Modified: head/crypto/openssl/crypto/engine/eng_devcrypto.c
> >
> 
> ==
> > --- head/crypto/openssl/crypto/engine/eng_devcrypto.c Fri Dec 14
> 00:40:38 2018        (r342056)
> > +++ head/crypto/openssl/crypto/engine/eng_devcrypto.c Fri Dec 14
> 01:06:34 2018        (r342057)
> > @@ -24,6 +24,8 @@
> >   
> >   #include "internal/engine.h"
> >   
> > +/* #define ENGINE_DEVCRYPTO_DEBUG */
> > +
> >   #ifdef CRYPTO_ALGORITHM_MIN
> >   # define CHECK_BSD_STYLE_MACROS
> >   #endif
> > @@ -615,6 +617,9 @@ void engine_load_devcrypto_int()
> >       ENGINE *e = NULL;
> >   
> >       if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
> > +#ifndef ENGINE_DEVCRYPTO_DEBUG
> > +        if (errno != ENOENT)
> > +#endif
> >           fprintf(stderr, "Could not open /dev/crypto: %s\n",
> strerror(errno));
> >           return;
> >       }
> 
> How trivially could devcrypto_debug  be modified to be a runtime
> configuration (say sysctl) setting?



signature.asc
Description: OpenPGP digital signature


svn commit: r342087 - in head: sys/arm/allwinner sys/dev/pwm sys/sys usr.sbin/pwm

2018-12-14 Thread Emmanuel Vadot
Author: manu
Date: Fri Dec 14 18:37:26 2018
New Revision: 342087
URL: https://svnweb.freebsd.org/changeset/base/342087

Log:
  pwm: Convert period and duty to unsigned int
  
  We don't need a 64 bits value to store nanoseconds
  
  Discused with:ian, jhibbits

Modified:
  head/sys/arm/allwinner/aw_pwm.c
  head/sys/dev/pwm/pwm_if.m
  head/sys/dev/pwm/pwmbus.c
  head/sys/dev/pwm/pwmbus_if.m
  head/sys/sys/pwm.h
  head/usr.sbin/pwm/pwm.c

Modified: head/sys/arm/allwinner/aw_pwm.c
==
--- head/sys/arm/allwinner/aw_pwm.c Fri Dec 14 18:16:35 2018
(r342086)
+++ head/sys/arm/allwinner/aw_pwm.c Fri Dec 14 18:37:26 2018
(r342087)
@@ -87,8 +87,8 @@ struct aw_pwm_softc {
struct resource *res;
 
uint64_tclk_freq;
-   uint64_tperiod;
-   uint64_tduty;
+   unsigned intperiod;
+   unsigned intduty;
uint32_tflags;
boolenabled;
 };
@@ -191,7 +191,7 @@ aw_pwm_channel_max(device_t dev, int *nchannel)
 }
 
 static int
-aw_pwm_channel_config(device_t dev, int channel, uint64_t period, uint64_t 
duty)
+aw_pwm_channel_config(device_t dev, int channel, unsigned int period, unsigned 
int duty)
 {
struct aw_pwm_softc *sc;
uint64_t period_freq, duty_freq;
@@ -254,7 +254,7 @@ aw_pwm_channel_config(device_t dev, int channel, uint6
 }
 
 static int
-aw_pwm_channel_get_config(device_t dev, int channel, uint64_t *period, 
uint64_t *duty)
+aw_pwm_channel_get_config(device_t dev, int channel, unsigned int *period, 
unsigned int *duty)
 {
struct aw_pwm_softc *sc;
 

Modified: head/sys/dev/pwm/pwm_if.m
==
--- head/sys/dev/pwm/pwm_if.m   Fri Dec 14 18:16:35 2018(r342086)
+++ head/sys/dev/pwm/pwm_if.m   Fri Dec 14 18:37:26 2018(r342087)
@@ -46,8 +46,8 @@ METHOD device_t get_bus {
 METHOD int channel_config {
device_t dev;
int channel;
-   uint64_t period;
-   uint64_t duty;
+   unsigned int period;
+   unsigned duty;
 };
 
 #
@@ -57,8 +57,8 @@ METHOD int channel_config {
 METHOD int channel_get_config {
device_t dev;
int channel;
-   uint64_t *period;
-   uint64_t *duty;
+   unsigned int *period;
+   unsigned int *duty;
 };
 
 #

Modified: head/sys/dev/pwm/pwmbus.c
==
--- head/sys/dev/pwm/pwmbus.c   Fri Dec 14 18:16:35 2018(r342086)
+++ head/sys/dev/pwm/pwmbus.c   Fri Dec 14 18:37:26 2018(r342087)
@@ -138,7 +138,7 @@ pwmbus_detach(device_t dev)
 }
 
 static int
-pwmbus_channel_config(device_t bus, int channel, uint64_t period, uint64_t 
duty)
+pwmbus_channel_config(device_t bus, int channel, unsigned int period, unsigned 
int duty)
 {
struct pwmbus_softc *sc;
 
@@ -151,7 +151,7 @@ pwmbus_channel_config(device_t bus, int channel, uint6
 }
 
 static int
-pwmbus_channel_get_config(device_t bus, int channel, uint64_t *period, 
uint64_t *duty)
+pwmbus_channel_get_config(device_t bus, int channel, unsigned int *period, 
unsigned int *duty)
 {
struct pwmbus_softc *sc;
 

Modified: head/sys/dev/pwm/pwmbus_if.m
==
--- head/sys/dev/pwm/pwmbus_if.mFri Dec 14 18:16:35 2018
(r342086)
+++ head/sys/dev/pwm/pwmbus_if.mFri Dec 14 18:37:26 2018
(r342087)
@@ -59,8 +59,8 @@ HEADER {
 METHOD int channel_config {
device_t bus;
int channel;
-   uint64_t period;
-   uint64_t duty;
+   unsigned int period;
+   unsigned int duty;
 };
 
 #
@@ -70,8 +70,8 @@ METHOD int channel_config {
 METHOD int channel_get_config {
device_t bus;
int channel;
-   uint64_t *period;
-   uint64_t *duty;
+   unsigned int *period;
+   unsigned int *duty;
 };
 
 #

Modified: head/sys/sys/pwm.h
==
--- head/sys/sys/pwm.h  Fri Dec 14 18:16:35 2018(r342086)
+++ head/sys/sys/pwm.h  Fri Dec 14 18:37:26 2018(r342087)
@@ -35,8 +35,8 @@
 
 struct pwm_state {
int channel;
-   uint64_tperiod;
-   uint64_tduty;
+   unsigned intperiod;
+   unsigned intduty;
uint32_tflags;
boolenable;
 };

Modified: head/usr.sbin/pwm/pwm.c
==
--- head/usr.sbin/pwm/pwm.c Fri Dec 14 18:16:35 2018(r342086)
+++ head/usr.sbin/pwm/pwm.c Fri Dec 14 18:37:26 2018(r342087)
@@ -190,9 +190,9 @@ main(int argc, char *argv[])
}
break;
case PWM_SHOW_CONFIG:
-   printf("period: %ju\nduty: %ju\nenabled:%d\n",
-   (uintmax_t) state.peri

svn commit: r342088 - head/usr.sbin/pwm

2018-12-14 Thread Emmanuel Vadot
Author: manu
Date: Fri Dec 14 18:38:10 2018
New Revision: 342088
URL: https://svnweb.freebsd.org/changeset/base/342088

Log:
  pwm(8): Add percentage value support for duty cycle

Modified:
  head/usr.sbin/pwm/pwm.8
  head/usr.sbin/pwm/pwm.c

Modified: head/usr.sbin/pwm/pwm.8
==
--- head/usr.sbin/pwm/pwm.8 Fri Dec 14 18:37:26 2018(r342087)
+++ head/usr.sbin/pwm/pwm.8 Fri Dec 14 18:38:10 2018(r342088)
@@ -67,7 +67,7 @@ Show the configuration of the pwm channel
 .It Fl p Ar period
 Configure the period (in nanoseconds) of the pwm channel
 .It Fl d Ar duty
-Configure the duty (in nanoseconds) of the pwm channel
+Configure the duty (in nanoseconds or percentage) of the pwm channel
 .El
 .Sh EXAMPLES
 .Bl -bullet
@@ -76,9 +76,13 @@ Show the configuration of the pwm channel:
 .Pp
 pwm -f /dev/pwmc0 -C
 .It
-Configure a 5 ns period and a 25000 duty cycles:
+Configure a 5 ns period and a 25000 duty cycle:
 .Pp
 pwm -f /dev/pwmc0 -p 5 -d 25000
+.It
+Configure a 50% duty cycle:
+.Pp
+pwm -f /dev/pwmc0 -d 50%
 .El
 .Sh SEE ALSO
 .Xr pwm 9 ,

Modified: head/usr.sbin/pwm/pwm.c
==
--- head/usr.sbin/pwm/pwm.c Fri Dec 14 18:37:26 2018(r342087)
+++ head/usr.sbin/pwm/pwm.c Fri Dec 14 18:38:10 2018(r342088)
@@ -71,6 +71,7 @@ main(int argc, char *argv[])
int action, ch;
cap_rights_t right_ioctl;
const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE, 
PWMMAXCHANNEL};
+   char *percent;
 
action = 0;
fd = -1;
@@ -104,7 +105,9 @@ main(int argc, char *argv[])
if (action & ~(PWM_PERIOD | PWM_DUTY))
usage();
action = PWM_DUTY;
-   duty = strtol(optarg, NULL, 10);
+   duty = strtol(optarg, &percent, 10);
+   if (*percent != '\0' && *percent != '%')
+   usage();
break;
case 'c':
if (channel != -1)
@@ -199,8 +202,12 @@ main(int argc, char *argv[])
case PWM_DUTY:
if (period != -1)
state.period = period;
-   if (duty != -1)
-   state.duty = duty;
+   if (duty != -1) {
+   if (*percent != '\0')
+   state.duty = state.period * duty / 100;
+   else
+   state.duty = duty;
+   }
if (ioctl(fd, PWMSETSTATE, &state) == -1) {
fprintf(stderr,
  "Cannot configure the pwm controller\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: r342091 - head/sys/arm/allwinner

2018-12-14 Thread Emmanuel Vadot
Author: manu
Date: Fri Dec 14 18:39:17 2018
New Revision: 342091
URL: https://svnweb.freebsd.org/changeset/base/342091

Log:
  allwinner: aw_pwm: Read value at attach
  
  The booloaded might have configured the pwm controller so read the values.

Modified:
  head/sys/arm/allwinner/aw_pwm.c

Modified: head/sys/arm/allwinner/aw_pwm.c
==
--- head/sys/arm/allwinner/aw_pwm.c Fri Dec 14 18:39:06 2018
(r342090)
+++ head/sys/arm/allwinner/aw_pwm.c Fri Dec 14 18:39:17 2018
(r342091)
@@ -136,7 +136,8 @@ static int
 aw_pwm_attach(device_t dev)
 {
struct aw_pwm_softc *sc;
-   /* uint32_t reg; */
+   uint64_t clk_freq;
+   uint32_t reg;
int error;
 
sc = device_get_softc(dev);
@@ -160,6 +161,26 @@ aw_pwm_attach(device_t dev)
if ((sc->busdev = pwmbus_attach_bus(dev)) == NULL)
device_printf(dev, "Cannot attach pwm bus\n");
 
+   /* Read the configuration left by U-Boot */
+   reg = AW_PWM_READ(sc, AW_PWM_CTRL);
+   if (reg & (AW_PWM_CTRL_GATE | AW_PWM_CTRL_EN))
+   sc->enabled = true;
+
+   reg = AW_PWM_READ(sc, AW_PWM_CTRL);
+   reg &= AW_PWM_CTRL_PRESCALE_MASK;
+   if (reg > nitems(aw_pwm_clk_prescaler)) {
+   device_printf(dev, "Bad prescaler %x, cannot guess current 
settings\n", reg);
+   goto out;
+   }
+   clk_freq = sc->clk_freq / aw_pwm_clk_prescaler[reg];
+
+   reg = AW_PWM_READ(sc, AW_PWM_PERIOD);
+   sc->period = NS_PER_SEC /
+   (clk_freq / ((reg >> AW_PWM_PERIOD_TOTAL_SHIFT) & 
AW_PWM_PERIOD_TOTAL_MASK));
+   sc->duty = NS_PER_SEC /
+   (clk_freq / ((reg >> AW_PWM_PERIOD_ACTIVE_SHIFT) & 
AW_PWM_PERIOD_ACTIVE_MASK));
+
+out:
return (0);
 
 fail:
___
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: r342093 - head/sys/riscv/riscv

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 18:50:32 2018
New Revision: 342093
URL: https://svnweb.freebsd.org/changeset/base/342093

Log:
  Clean up the riscv pmap_bootstrap() implementation.
  
  - Build up phys_avail[] in a single loop, excluding memory used by
the loaded kernel.
  - Fix an array indexing bug in the aforementioned phys_avail[]
initialization.[1]
  - Remove some unneeded code copied from the arm64 implementation.
  
  PR:   231515 [1]
  Reviewed by:  jhb
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18464

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

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Fri Dec 14 18:40:08 2018(r342092)
+++ head/sys/riscv/riscv/pmap.c Fri Dec 14 18:50:32 2018(r342093)
@@ -211,7 +211,7 @@ __FBSDID("$FreeBSD$");
 
 /* The list of all the user pmaps */
 LIST_HEAD(pmaplist, pmap);
-static struct pmaplist allpmaps;
+static struct pmaplist allpmaps = LIST_HEAD_INITIALIZER();
 
 struct pmap kernel_pmap_store;
 
@@ -508,17 +508,12 @@ pmap_bootstrap_l3(vm_offset_t l1pt, vm_offset_t va, vm
 void
 pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen)
 {
-   u_int l1_slot, l2_slot, avail_slot, map_slot, used_map_slot;
-   uint64_t kern_delta;
-   pt_entry_t *l2;
-   vm_offset_t va, freemempos;
+   u_int l1_slot, l2_slot, avail_slot, map_slot;
+   vm_offset_t freemempos;
vm_offset_t dpcpu, msgbufpv;
-   vm_paddr_t pa, min_pa, max_pa;
+   vm_paddr_t end, max_pa, min_pa, pa, start;
int i;
 
-   kern_delta = KERNBASE - kernstart;
-   physmem = 0;
-
printf("pmap_bootstrap %lx %lx %lx\n", l1pt, kernstart, kernlen);
printf("%lx\n", l1pt);
printf("%lx\n", (KERNBASE >> L1_SHIFT) & Ln_ADDR_MASK);
@@ -527,21 +522,16 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart,
kernel_pmap_store.pm_l1 = (pd_entry_t *)l1pt;
PMAP_LOCK_INIT(kernel_pmap);
 
-   /*
-* Initialize the global pv list lock.
-*/
rw_init(&pvh_global_lock, "pmap pv global");
 
-   LIST_INIT(&allpmaps);
+   /* Assume the address we were loaded to is a valid physical address. */
+   min_pa = max_pa = kernstart;
 
-   /* Assume the address we were loaded to is a valid physical address */
-   min_pa = max_pa = KERNBASE - kern_delta;
-
/*
 * Find the minimum physical address. physmap is sorted,
 * but may contain empty ranges.
 */
-   for (i = 0; i < (physmap_idx * 2); i += 2) {
+   for (i = 0; i < physmap_idx * 2; i += 2) {
if (physmap[i] == physmap[i + 1])
continue;
if (physmap[i] <= min_pa)
@@ -556,67 +546,18 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart,
/* Create a direct map region early so we can use it for pa -> va */
pmap_bootstrap_dmap(l1pt, min_pa, max_pa);
 
-   va = KERNBASE;
-   pa = KERNBASE - kern_delta;
-
/*
-* Start to initialize phys_avail by copying from physmap
-* up to the physical address KERNBASE points at.
-*/
-   map_slot = avail_slot = 0;
-   for (; map_slot < (physmap_idx * 2); map_slot += 2) {
-   if (physmap[map_slot] == physmap[map_slot + 1])
-   continue;
-
-   if (physmap[map_slot] <= pa &&
-   physmap[map_slot + 1] > pa)
-   break;
-
-   phys_avail[avail_slot] = physmap[map_slot];
-   phys_avail[avail_slot + 1] = physmap[map_slot + 1];
-   physmem += (phys_avail[avail_slot + 1] -
-   phys_avail[avail_slot]) >> PAGE_SHIFT;
-   avail_slot += 2;
-   }
-
-   /* Add the memory before the kernel */
-   if (physmap[avail_slot] < pa) {
-   phys_avail[avail_slot] = physmap[map_slot];
-   phys_avail[avail_slot + 1] = pa;
-   physmem += (phys_avail[avail_slot + 1] -
-   phys_avail[avail_slot]) >> PAGE_SHIFT;
-   avail_slot += 2;
-   }
-   used_map_slot = map_slot;
-
-   /*
 * Read the page table to find out what is already mapped.
 * This assumes we have mapped a block of memory from KERNBASE
 * using a single L1 entry.
 */
-   l2 = pmap_early_page_idx(l1pt, KERNBASE, &l1_slot, &l2_slot);
+   (void)pmap_early_page_idx(l1pt, KERNBASE, &l1_slot, &l2_slot);
 
/* Sanity check the index, KERNBASE should be the first VA */
KASSERT(l2_slot == 0, ("The L2 index is non-zero"));
 
-   /* Find how many pages we have mapped */
-   for (; l2_slot < Ln_ENTRIES; l2_slot++) {
-   if ((l2[l2_slot] & PTE_V) == 0)
-   break;
+   freemempos = roundup2(KERNBASE + kernlen, PA

svn commit: r342094 - head/sys/mips/include

2018-12-14 Thread Warner Losh
Author: imp
Date: Fri Dec 14 19:14:51 2018
New Revision: 342094
URL: https://svnweb.freebsd.org/changeset/base/342094

Log:
  atomic_fcmpset* return int, not the type of *.
  
  fcmpset returns true/false as a int, so make the return types and
  variables match the int to be consistent with other arch.
  
  Reviewed by: cognet@
  Differential Revision: https://reviews.freebsd.org/D18557

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

Modified: head/sys/mips/include/atomic.h
==
--- head/sys/mips/include/atomic.h  Fri Dec 14 18:50:32 2018
(r342093)
+++ head/sys/mips/include/atomic.h  Fri Dec 14 19:14:51 2018
(r342094)
@@ -392,10 +392,10 @@ atomic_cmpset_rel_32(__volatile uint32_t *p, uint32_t 
return (atomic_cmpset_32(p, cmpval, newval));
 }
 
-static __inline uint32_t
+static __inline int
 atomic_fcmpset_32(__volatile uint32_t *p, uint32_t *cmpval, uint32_t newval)
 {
-   uint32_t ret;
+   int ret;
 
__asm __volatile (
"1:\n\t"
@@ -415,7 +415,7 @@ atomic_fcmpset_32(__volatile uint32_t *p, uint32_t *cm
return ret;
 }
 
-static __inline uint32_t
+static __inline int
 atomic_fcmpset_acq_32(__volatile uint32_t *p, uint32_t *cmpval, uint32_t 
newval)
 {
int retval;
@@ -425,7 +425,7 @@ atomic_fcmpset_acq_32(__volatile uint32_t *p, uint32_t
return (retval);
 }
 
-static __inline uint32_t
+static __inline int
 atomic_fcmpset_rel_32(__volatile uint32_t *p, uint32_t *cmpval, uint32_t 
newval)
 {
mips_sync();
@@ -502,10 +502,10 @@ atomic_cmpset_rel_64(__volatile uint64_t *p, uint64_t 
return (atomic_cmpset_64(p, cmpval, newval));
 }
 
-static __inline uint32_t
+static __inline int
 atomic_fcmpset_64(__volatile uint64_t *p, uint64_t *cmpval, uint64_t newval)
 {
-uint32_t ret;
+int ret;
 
 __asm __volatile (
 "1:\n\t"
@@ -526,7 +526,7 @@ atomic_fcmpset_64(__volatile uint64_t *p, uint64_t *cm
return ret;
 }
 
-static __inline uint64_t
+static __inline int
 atomic_fcmpset_acq_64(__volatile uint64_t *p, uint64_t *cmpval, uint64_t 
newval)
 {
int retval;
@@ -536,7 +536,7 @@ atomic_fcmpset_acq_64(__volatile uint64_t *p, uint64_t
return (retval);
 }
 
-static __inline uint64_t
+static __inline int
 atomic_fcmpset_rel_64(__volatile uint64_t *p, uint64_t *cmpval, uint64_t 
newval)
 {
mips_sync();
___
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: r342095 - head/sys/mips/include

2018-12-14 Thread Warner Losh
Author: imp
Date: Fri Dec 14 19:48:42 2018
New Revision: 342095
URL: https://svnweb.freebsd.org/changeset/base/342095

Log:
  atomic_cmpset return value is also an int.

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

Modified: head/sys/mips/include/atomic.h
==
--- head/sys/mips/include/atomic.h  Fri Dec 14 19:14:51 2018
(r342094)
+++ head/sys/mips/include/atomic.h  Fri Dec 14 19:48:42 2018
(r342095)
@@ -348,10 +348,10 @@ ATOMIC_STORE_LOAD(64)
  * two values are equal, update the value of *p with newval. Returns
  * zero if the compare failed, nonzero otherwise.
  */
-static __inline uint32_t
+static __inline int
 atomic_cmpset_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
 {
-   uint32_t ret;
+   int ret;
 
__asm __volatile (
"1:\tll %0, %4\n\t" /* load old value */
@@ -375,7 +375,7 @@ atomic_cmpset_32(__volatile uint32_t *p, uint32_t cmpv
  * two values are equal, update the value of *p with newval. Returns
  * zero if the compare failed, nonzero otherwise.
  */
-static __inline uint32_t
+static __inline int
 atomic_cmpset_acq_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
 {
int retval;
@@ -385,7 +385,7 @@ atomic_cmpset_acq_32(__volatile uint32_t *p, uint32_t 
return (retval);
 }
 
-static __inline uint32_t
+static __inline int
 atomic_cmpset_rel_32(__volatile uint32_t *p, uint32_t cmpval, uint32_t newval)
 {
mips_sync();
@@ -457,10 +457,10 @@ atomic_fetchadd_32(__volatile uint32_t *p, uint32_t v)
  * two values are equal, update the value of *p with newval. Returns
  * zero if the compare failed, nonzero otherwise.
  */
-static __inline uint64_t
+static __inline int
 atomic_cmpset_64(__volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
 {
-   uint64_t ret;
+   int ret;
 
__asm __volatile (
"1:\n\t"
@@ -485,7 +485,7 @@ atomic_cmpset_64(__volatile uint64_t *p, uint64_t cmpv
  * two values are equal, update the value of *p with newval. Returns
  * zero if the compare failed, nonzero otherwise.
  */
-static __inline uint64_t
+static __inline int
 atomic_cmpset_acq_64(__volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
 {
int retval;
@@ -495,7 +495,7 @@ atomic_cmpset_acq_64(__volatile uint64_t *p, uint64_t 
return (retval);
 }
 
-static __inline uint64_t
+static __inline int
 atomic_cmpset_rel_64(__volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
 {
mips_sync();
___
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: r342096 - head/sys/riscv/conf

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 20:57:57 2018
New Revision: 342096
URL: https://svnweb.freebsd.org/changeset/base/342096

Log:
  Enable witness(4) in the RISC-V GENERIC config.
  
  Reviewed by:  jhb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18559

Modified:
  head/sys/riscv/conf/GENERIC

Modified: head/sys/riscv/conf/GENERIC
==
--- head/sys/riscv/conf/GENERIC Fri Dec 14 19:48:42 2018(r342095)
+++ head/sys/riscv/conf/GENERIC Fri Dec 14 20:57:57 2018(r342096)
@@ -120,7 +120,7 @@ options DDB # Support DDB.
 optionsDEADLKRES   # Enable the deadlock resolver
 optionsINVARIANTS  # Enable calls of extra sanity checking
 optionsINVARIANT_SUPPORT   # Extra sanity checks of internal 
structures, required by INVARIANTS
-# options  WITNESS # Enable checks to detect deadlocks and 
cycles
+optionsWITNESS # Enable checks to detect deadlocks and 
cycles
 # options  WITNESS_SKIPSPIN# Don't run witness on spinlocks for 
speed
 optionsMALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
 # options  EARLY_PRINTF
___
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: r342097 - head/sys/riscv/conf

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 21:00:41 2018
New Revision: 342097
URL: https://svnweb.freebsd.org/changeset/base/342097

Log:
  Add a QEMU config for RISC-V.
  
  Reviewed by:  jhb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18560

Added:
  head/sys/riscv/conf/QEMU   (contents, props changed)

Added: head/sys/riscv/conf/QEMU
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/riscv/conf/QEMUFri Dec 14 21:00:41 2018(r342097)
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+#NO_UNIVERSE
+
+include "GENERIC"
+
+ident QEMU
+
+optionsROOTDEVNAME=\"ufs:/dev/vtbd0\"
___
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: r342098 - head/sys/riscv/riscv

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 21:03:01 2018
New Revision: 342098
URL: https://svnweb.freebsd.org/changeset/base/342098

Log:
  Assume that pmap_l1() will return a PTE.
  
  pmaps on RISC-V always have an L1 page table page, so we don't need to
  check for this when performing lookups.
  
  Reviewed by:  jhb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18563

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

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Fri Dec 14 21:00:41 2018(r342097)
+++ head/sys/riscv/riscv/pmap.c Fri Dec 14 21:03:01 2018(r342098)
@@ -316,8 +316,6 @@ pmap_l2(pmap_t pmap, vm_offset_t va)
pd_entry_t *l1;
 
l1 = pmap_l1(pmap, va);
-   if (l1 == NULL)
-   return (NULL);
if ((pmap_load(l1) & PTE_V) == 0)
return (NULL);
if ((pmap_load(l1) & PTE_RX) != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r342099 - head/sys/riscv/riscv

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 21:04:30 2018
New Revision: 342099
URL: https://svnweb.freebsd.org/changeset/base/342099

Log:
  Avoid needless TLB invalidations in pmap_remove_pages().
  
  pmap_remove_pages() is called during process termination, when it is
  guaranteed that no other CPU may access the mappings being torn down.
  In particular, it unnecessary to invalidate each mapping individually
  since we do a pmap_invalidate_all() at the end of the function.
  
  Also don't call pmap_invalidate_all() while holding a PV list lock, the
  global pvh lock is sufficient.
  
  Reviewed by:  jhb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18562

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

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Fri Dec 14 21:03:01 2018(r342098)
+++ head/sys/riscv/riscv/pmap.c Fri Dec 14 21:04:30 2018(r342099)
@@ -2721,9 +2721,10 @@ pmap_remove_pages(pmap_t pmap)
l3 = pmap_l2_to_l3(l2, pv->pv_va);
tl3 = pmap_load(l3);
 
-/*
- * We cannot remove wired pages from a process' mapping at this time
- */
+   /*
+* We cannot remove wired pages from a
+* process' mapping at this time.
+*/
if (tl3 & PTE_SW_WIRED) {
allfree = 0;
continue;
@@ -2742,7 +2743,6 @@ pmap_remove_pages(pmap_t pmap)
(uintmax_t)tl3));
 
pmap_load_clear(l3);
-   pmap_invalidate_page(pmap, pv->pv_va);
 
/*
 * Update the vm_page_t clean/reference bits.
@@ -2771,9 +2771,9 @@ pmap_remove_pages(pmap_t pmap)
free_pv_chunk(pc);
}
}
-   pmap_invalidate_all(pmap);
if (lock != NULL)
rw_wunlock(lock);
+   pmap_invalidate_all(pmap);
rw_runlock(&pvh_global_lock);
PMAP_UNLOCK(pmap);
vm_page_free_pages_toq(&free, false);
___
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: r342100 - head/sys/riscv/riscv

2018-12-14 Thread Mark Johnston
Author: markj
Date: Fri Dec 14 21:07:12 2018
New Revision: 342100
URL: https://svnweb.freebsd.org/changeset/base/342100

Log:
  Add some more checking to the RISC-V page fault handler.
  
  - Panic immediately if witness says we're holding non-sleepable locks.
This helps ensure that we don't recurse on the pmap lock in
pmap_fault_fixup().
  - Panic if the kernel faults on a user address without setting an
onfault handler.
  - Panic if the fault occurred in a critical section or interrupt
handler, like we do on other platforms.
  - Fix some style issues in trap_pfault().
  
  Reviewed by:  jhb
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18561

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

Modified: head/sys/riscv/riscv/trap.c
==
--- head/sys/riscv/riscv/trap.c Fri Dec 14 21:04:30 2018(r342099)
+++ head/sys/riscv/riscv/trap.c Fri Dec 14 21:07:12 2018(r342100)
@@ -167,7 +167,7 @@ svc_handler(struct trapframe *frame)
 }
 
 static void
-data_abort(struct trapframe *frame, int lower)
+data_abort(struct trapframe *frame, int usermode)
 {
struct vm_map *map;
uint64_t sbadaddr;
@@ -176,9 +176,7 @@ data_abort(struct trapframe *frame, int lower)
vm_prot_t ftype;
vm_offset_t va;
struct proc *p;
-   int ucode;
-   int error;
-   int sig;
+   int error, sig, ucode;
 
 #ifdef KDB
if (kdb_active) {
@@ -188,19 +186,23 @@ data_abort(struct trapframe *frame, int lower)
 #endif
 
td = curthread;
+   p = td->td_proc;
pcb = td->td_pcb;
sbadaddr = frame->tf_sbadaddr;
 
-   p = td->td_proc;
+   if (td->td_critnest != 0 || td->td_intr_nesting_level != 0 ||
+   WITNESS_CHECK(WARN_SLEEPOK | WARN_GIANTOK, NULL,
+   "Kernel page fault") != 0)
+   goto fatal;
 
-   if (lower)
+   if (usermode)
map = &td->td_proc->p_vmspace->vm_map;
+   else if (sbadaddr >= VM_MAX_USER_ADDRESS)
+   map = kernel_map;
else {
-   /* The top bit tells us which range to use */
-   if ((sbadaddr >> 63) == 1)
-   map = kernel_map;
-   else
-   map = &td->td_proc->p_vmspace->vm_map;
+   if (pcb->pcb_onfault == 0)
+   goto fatal;
+   map = &td->td_proc->p_vmspace->vm_map;
}
 
va = trunc_page(sbadaddr);
@@ -241,7 +243,7 @@ data_abort(struct trapframe *frame, int lower)
}
 
if (error != KERN_SUCCESS) {
-   if (lower) {
+   if (usermode) {
sig = SIGSEGV;
if (error == KERN_PROTECTION_FAILURE)
ucode = SEGV_ACCERR;
@@ -249,21 +251,23 @@ data_abort(struct trapframe *frame, int lower)
ucode = SEGV_MAPERR;
call_trapsignal(td, sig, ucode, (void *)sbadaddr);
} else {
-   if (td->td_intr_nesting_level == 0 &&
-   pcb->pcb_onfault != 0) {
+   if (pcb->pcb_onfault != 0) {
frame->tf_a[0] = error;
frame->tf_sepc = pcb->pcb_onfault;
return;
}
-   dump_regs(frame);
-   panic("vm_fault failed: %lx, va 0x%016lx",
-   frame->tf_sepc, sbadaddr);
+   goto fatal;
}
}
 
 done:
-   if (lower)
+   if (usermode)
userret(td, frame);
+   return;
+
+fatal:
+   dump_regs(frame);
+   panic("Fatal page fault at %#lx: %#016lx", frame->tf_sepc, sbadaddr);
 }
 
 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: r342101 - head/lib/libnv

2018-12-14 Thread Alex Richardson
Author: arichardson
Date: Fri Dec 14 21:16:04 2018
New Revision: 342101
URL: https://svnweb.freebsd.org/changeset/base/342101

Log:
  Allow bootstrapping libnv on macOS and Linux
  
  MacOS/Linux do not define struct cmsgcred but we need to bootstrap libnv
  when building on non-FreeBSD systems. Since they are not used during
  bootstrap we can just omit these two functions there.
  
  Reviewed By:  emaste
  Differential Revision: https://reviews.freebsd.org/D18472

Modified:
  head/lib/libnv/msgio.c

Modified: head/lib/libnv/msgio.c
==
--- head/lib/libnv/msgio.c  Fri Dec 14 21:07:12 2018(r342100)
+++ head/lib/libnv/msgio.c  Fri Dec 14 21:16:04 2018(r342101)
@@ -157,6 +157,14 @@ msg_send(int sock, const struct msghdr *msg)
return (0);
 }
 
+/*
+ * MacOS/Linux do not define struct cmsgcred but we need to bootstrap libnv
+ * when building on non-FreeBSD systems. Since they are not used during
+ * bootstrap we can just omit these two functions there.
+ */
+#ifndef __FreeBSD__
+#warning "cred_send() not supported on non-FreeBSD systems"
+#else
 int
 cred_send(int sock)
 {
@@ -232,6 +240,7 @@ cred_recv(int sock, struct cmsgcred *cred)
 
return (0);
 }
+#endif
 
 static int
 fd_package_send(int sock, const int *fds, size_t nfds)
___
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: r342102 - head/sys/dev/iicbus/twsi

2018-12-14 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Dec 14 21:17:42 2018
New Revision: 342102
URL: https://svnweb.freebsd.org/changeset/base/342102

Log:
  [twsi] Make extres/clk part conditional based on the EXT_RESOURCES option 
value
  
  This should fix kernel build for ARMADA38X and possibly some other ARM configs
  
  Approved by:  manu

Modified:
  head/sys/dev/iicbus/twsi/mv_twsi.c
  head/sys/dev/iicbus/twsi/twsi.h

Modified: head/sys/dev/iicbus/twsi/mv_twsi.c
==
--- head/sys/dev/iicbus/twsi/mv_twsi.c  Fri Dec 14 21:16:04 2018
(r342101)
+++ head/sys/dev/iicbus/twsi/mv_twsi.c  Fri Dec 14 21:17:42 2018
(r342102)
@@ -61,7 +61,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef EXT_RESOURCES
 #include 
+#endif
 
 #include 
 #include 

Modified: head/sys/dev/iicbus/twsi/twsi.h
==
--- head/sys/dev/iicbus/twsi/twsi.h Fri Dec 14 21:16:04 2018
(r342101)
+++ head/sys/dev/iicbus/twsi/twsi.h Fri Dec 14 21:17:42 2018
(r342102)
@@ -34,7 +34,9 @@
 #ifndef _TWSI_H_
 #define_TWSI_H_
 
+#ifdef EXT_RESOURCES
 #include 
+#endif
 
 struct twsi_baud_rate {
uint32_traw;
@@ -48,8 +50,10 @@ struct twsi_softc {
struct resource *res[1];/* SYS_RES_MEMORY */
struct mtx  mutex;
device_tiicbus;
+#ifdef EXT_RESOURCES
clk_t   clk_core;
clk_t   clk_reg;
+#endif
 
bus_size_t  reg_data;
bus_size_t  reg_slave_addr;
___
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: r342104 - head/sys/dev/tpm

2018-12-14 Thread Marcin Wojtas
Author: mw
Date: Fri Dec 14 22:22:43 2018
New Revision: 342104
URL: https://svnweb.freebsd.org/changeset/base/342104

Log:
  Fix error check for ACPI_ID_PROBE in the TPM2.0 driver
  
  Updated API does not return pointer, so adjust the
  TPM2.0 driver accordingly.
  
  Reported by: jhb
  Obtained from: Semihalf
  Sponsored by: Stormshield

Modified:
  head/sys/dev/tpm/tpm_crb.c
  head/sys/dev/tpm/tpm_tis.c

Modified: head/sys/dev/tpm/tpm_crb.c
==
--- head/sys/dev/tpm/tpm_crb.c  Fri Dec 14 21:30:34 2018(r342103)
+++ head/sys/dev/tpm/tpm_crb.c  Fri Dec 14 22:22:43 2018(r342104)
@@ -104,11 +104,12 @@ static int
 tpmcrb_acpi_probe(device_t dev)
 {
struct resource *res;
-   int rid = 0;
+   int err, rid = 0;
uint32_t caps;
 
-   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL) == 
NULL)
-   return (ENXIO);
+   err = ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL);
+   if (err > 0)
+   return (err);
 
/* Check if device is in CRB mode */
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);

Modified: head/sys/dev/tpm/tpm_tis.c
==
--- head/sys/dev/tpm/tpm_tis.c  Fri Dec 14 21:30:34 2018(r342103)
+++ head/sys/dev/tpm/tpm_tis.c  Fri Dec 14 22:22:43 2018(r342104)
@@ -101,11 +101,12 @@ static int
 tpmtis_acpi_probe(device_t dev)
 {
struct resource *res;
-   int rid = 0;
+   int err, rid = 0;
uint32_t caps;
 
-   if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids, NULL) == 
NULL)
-   return (ENXIO);
+   err = ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids, NULL);
+   if (err > 0)
+   return (err);
 
/* Check if device is in TPM 2.0 TIS mode */
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
___
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: r342085 - head/sys/dev/tpm

2018-12-14 Thread Marcin Wojtas
Hi John,

pt., 14 gru 2018 o 18:57 John Baldwin  napisał(a):
>
> On 12/14/18 9:43 AM, Marcin Wojtas wrote:
> > Author: mw
> > Date: Fri Dec 14 17:43:35 2018
> > New Revision: 342085
> > URL: https://svnweb.freebsd.org/changeset/base/342085
> >
> > Log:
> >   Fix TPM driver compilation from r342084
> >
> >   Include recent ACPI_ID_PROBE API change.
> >
> > Modified:
> >   head/sys/dev/tpm/tpm_crb.c
> >   head/sys/dev/tpm/tpm_tis.c
> >
> > Modified: head/sys/dev/tpm/tpm_crb.c
> > ==
> > --- head/sys/dev/tpm/tpm_crb.cFri Dec 14 16:14:36 2018
> > (r342084)
> > +++ head/sys/dev/tpm/tpm_crb.cFri Dec 14 17:43:35 2018
> > (r342085)
> > @@ -107,7 +107,7 @@ tpmcrb_acpi_probe(device_t dev)
> >   int rid = 0;
> >   uint32_t caps;
> >
> > - if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids) == NULL)
> > + if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL) == 
> > NULL)
> >   return (ENXIO);
>
> I think it doesn't return a pointer anymore either.  I think you want to use
> its return value as the return value from probe to honor the relative priority
> of CID vs HID matches, so something like:
>
>  int error;
>
>  error = ACPI_ID_PROBE(...);
>  if (error > 0)
>  return (error);
>
>  ...
>
>  return (error);
>
> Instead of 'return (BUS_GENERIC_PROBE)' or some such.
>

Thank you for pointing this, I addressed your remark in r342104.

Best regards,
Marcin
___
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: r342105 - head/sys/tools/fdt

2018-12-14 Thread Alex Richardson
Author: arichardson
Date: Fri Dec 14 23:53:28 2018
New Revision: 342105
URL: https://svnweb.freebsd.org/changeset/base/342105

Log:
  make_dtb.sh: Use $CPP instead of assuming that cpp is in $PATH
  
  This fixes building in CheriBSD with a strict tmp path since we don't
  bootstrap a cpp but pass the full path to clang-cpp instead.
  
  While touching this file also fix all shellcheck warnings in make_dtb.sh.
  
  Reviewed By:  manu
  Differential Revision: https://reviews.freebsd.org/D18376

Modified:
  head/sys/tools/fdt/make_dtb.sh
  head/sys/tools/fdt/make_dtbo.sh

Modified: head/sys/tools/fdt/make_dtb.sh
==
--- head/sys/tools/fdt/make_dtb.sh  Fri Dec 14 22:22:43 2018
(r342104)
+++ head/sys/tools/fdt/make_dtb.sh  Fri Dec 14 23:53:28 2018
(r342105)
@@ -16,12 +16,13 @@ if [ -z "${MACHINE}" ]; then
 MACHINE=$(uname -m)
 fi
 
-: ${DTC:=dtc}
-: ${ECHO:=echo}
+: "${DTC:=dtc}"
+: "${ECHO:=echo}"
+: "${CPP:=cpp}"
 
 for d in ${dts}; do
-dtb=${dtb_path}/`basename $d .dts`.dtb
+dtb="${dtb_path}/$(basename "$d" .dts).dtb"
 ${ECHO} "converting $d -> $dtb"
-cpp -P -x assembler-with-cpp -I $S/gnu/dts/include -I $S/dts/${MACHINE} -I 
$S/gnu/dts/${MACHINE} -I $S/gnu/dts/ -include $d /dev/null | 
-   ${DTC} -@ -O dtb -o $dtb -b 0 -p 1024 -i $S/dts/${MACHINE} -i 
$S/gnu/dts/${MACHINE} -i $S/gnu/dts/
+${CPP} -P -x assembler-with-cpp -I "$S/gnu/dts/include" -I 
"$S/dts/${MACHINE}" -I "$S/gnu/dts/${MACHINE}" -I "$S/gnu/dts/" -include "$d" 
/dev/null |
+   ${DTC} -@ -O dtb -o "$dtb" -b 0 -p 1024 -i "$S/dts/${MACHINE}" -i 
"$S/gnu/dts/${MACHINE}" -i "$S/gnu/dts/"
 done

Modified: head/sys/tools/fdt/make_dtbo.sh
==
--- head/sys/tools/fdt/make_dtbo.sh Fri Dec 14 22:22:43 2018
(r342104)
+++ head/sys/tools/fdt/make_dtbo.sh Fri Dec 14 23:53:28 2018
(r342105)
@@ -16,12 +16,13 @@ if [ -z "${MACHINE}" ]; then
 MACHINE=$(uname -m)
 fi
 
-: ${DTC:=dtc}
-: ${ECHO:=echo}
+: "${DTC:=dtc}"
+: "${ECHO:=echo}"
+: "${CPP:=cpp}"
 
 for d in ${dtso}; do
-dtb=${dtbo_path}/`basename $d .dtso`.dtbo
+dtb="${dtbo_path}/$(basename "$d" .dtso).dtbo"
 ${ECHO} "converting $d -> $dtb"
-cpp -P -x assembler-with-cpp -I $S/gnu/dts/include -I $S/dts/${MACHINE} -I 
$S/gnu/dts/${MACHINE} -include $d /dev/null | 
-   ${DTC} -@ -O dtb -o $dtb -i $S/dts/${MACHINE} -i $S/gnu/dts/${MACHINE}
+${CPP} -P -x assembler-with-cpp -I "$S/gnu/dts/include" -I 
"$S/dts/${MACHINE}" -I "$S/gnu/dts/${MACHINE}" -include "$d" /dev/null |
+   ${DTC} -@ -O dtb -o "$dtb" -i "$S/dts/${MACHINE}" -i 
"$S/gnu/dts/${MACHINE}"
 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"


Re: svn commit: r342084 - in head/sys: conf dev/tpm

2018-12-14 Thread Konstantin Belousov
On Fri, Dec 14, 2018 at 04:14:36PM +, Marcin Wojtas wrote:
> Author: mw
> Date: Fri Dec 14 16:14:36 2018
> New Revision: 342084
> URL: https://svnweb.freebsd.org/changeset/base/342084
> 
> Log:
>   Introduce driver for TPM 2.0 in CRB and FIFO (TIS) modes
>   
>   It was written basing on:
>   TCG PC Client Platform TPM Profile (PTP) Specification Version 22, Revision 
> 1.03.
>   It only supports Locality 0. Interrupts are only supported in FIFO mode.
>   
>   The driver in FIFO mode was tested on x86 with Infineon SLB9665 discrete 
> TPM chip.
>   Driver in both modes was also tested on qemu with swtpm running on host.
>   
>   Submitted by: Kornel Duleba 
>   Obtained from: Semihalf
>   Sponsored by: Stormshield
>   Differential Revision: https://reviews.freebsd.org/D18048
> 
> Added:
>   head/sys/dev/tpm/tpm20.c   (contents, props changed)
>   head/sys/dev/tpm/tpm20.h   (contents, props changed)
>   head/sys/dev/tpm/tpm_crb.c   (contents, props changed)
>   head/sys/dev/tpm/tpm_tis.c   (contents, props changed)
> Modified:
>   head/sys/conf/files.amd64
Don't you need to update sys/modules/tpm/Makefile ?
___
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: r342106 - head/sys/arm/mv

2018-12-14 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Dec 15 02:35:48 2018
New Revision: 342106
URL: https://svnweb.freebsd.org/changeset/base/342106

Log:
  [mv_pci] Do not attempt to attach disabled PCI ports
  
  Fail probe for PCI port if the respective FDT node is not enabled
  
  Differential Revision:https://reviews.freebsd.org/D18385

Modified:
  head/sys/arm/mv/mv_pci.c

Modified: head/sys/arm/mv/mv_pci.c
==
--- head/sys/arm/mv/mv_pci.cFri Dec 14 23:53:28 2018(r342105)
+++ head/sys/arm/mv/mv_pci.cSat Dec 15 02:35:48 2018(r342106)
@@ -429,6 +429,9 @@ mv_pcib_probe(device_t self)
OF_parent(node), "marvell,armada-370-pcie")))
return (ENXIO);
 
+   if (!ofw_bus_status_okay(self))
+   return (ENXIO);
+
device_set_desc(self, "Marvell Integrated PCI/PCI-E Controller");
return (BUS_PROBE_DEFAULT);
 }
___
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"