From a9c80a534a49619c89a8889b7cd0c70b7ae7e9e9 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Tue, 8 Oct 2013 19:18:02 +0000 Subject: [PATCH 01/13] Properly fix out of memory handling in the iSCSI target. Approved by: re (glebius) Sponsored by: FreeBSD Foundation --- sys/cam/ctl/ctl_frontend_iscsi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 46eaf08e667a..e8e2d33a42dd 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2301,7 +2302,8 @@ cfiscsi_datamove_in(union ctl_io *io) if (response == NULL) { CFISCSI_SESSION_WARN(cs, "failed to " "allocate memory; dropping connection"); - icl_pdu_free(request); + ctl_set_busy(&io->scsiio); + io->scsiio.be_move_done(io); cfiscsi_session_terminate(cs); return; } @@ -2330,8 +2332,9 @@ cfiscsi_datamove_in(union ctl_io *io) if (error != 0) { CFISCSI_SESSION_WARN(cs, "failed to " "allocate memory; dropping connection"); - icl_pdu_free(request); icl_pdu_free(response); + ctl_set_busy(&io->scsiio); + io->scsiio.be_move_done(io); cfiscsi_session_terminate(cs); return; } @@ -2428,8 +2431,10 @@ cfiscsi_datamove_out(union ctl_io *io) if (cdw == NULL) { CFISCSI_SESSION_WARN(cs, "failed to " "allocate memory; dropping connection"); - icl_pdu_free(request); + ctl_set_busy(&io->scsiio); + io->scsiio.be_move_done(io); cfiscsi_session_terminate(cs); + return; } cdw->cdw_ctl_io = io; cdw->cdw_target_transfer_tag = htonl(target_transfer_tag); @@ -2462,8 +2467,10 @@ cfiscsi_datamove_out(union ctl_io *io) if (response == NULL) { CFISCSI_SESSION_WARN(cs, "failed to " "allocate memory; dropping connection"); - icl_pdu_free(request); + ctl_set_busy(&io->scsiio); + io->scsiio.be_move_done(io); cfiscsi_session_terminate(cs); + return; } bhsr2t = (struct iscsi_bhs_r2t *)response->ip_bhs; bhsr2t->bhsr2t_opcode = ISCSI_BHS_OPCODE_R2T; From cdb9cd7ad21619b0e1dca1df2ef7092239e59d49 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 8 Oct 2013 19:39:21 +0000 Subject: [PATCH 02/13] In usr.sbin/bhyve/pci_ahci.c, fix several gcc warnings of the form "assignment makes pointer from integer without a cast", by changing the cmd_lst and rbis members of struct ahci_port from integers to pointers. Also surround a pow-of-2 test expression with parentheses to clarify it, and avoid another gcc warning. Approved by: re (glebius) Reviewed by: grehan, mav --- usr.sbin/bhyve/pci_ahci.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c index d50d8f4922e0..f69f1277ff41 100644 --- a/usr.sbin/bhyve/pci_ahci.c +++ b/usr.sbin/bhyve/pci_ahci.c @@ -119,8 +119,8 @@ struct ahci_ioreq { struct ahci_port { struct blockif_ctxt *bctx; struct pci_ahci_softc *pr_sc; - uint64_t cmd_lst; - uint64_t rfis; + uint8_t *cmd_lst; + uint8_t *rfis; int atapi; int reset; int mult_sectors; @@ -222,7 +222,7 @@ ahci_write_fis(struct ahci_port *p, enum sata_fis_type ft, uint8_t *fis) { int offset, len, irq; - if (p->rfis == 0 || !(p->cmd & AHCI_P_CMD_FRE)) + if (p->rfis == NULL || !(p->cmd & AHCI_P_CMD_FRE)) return; switch (ft) { @@ -396,7 +396,7 @@ ahci_handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t done, sc = p->pr_sc; prdt = (struct ahci_prdt_entry *)(cfis + 0x80); - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); ncq = 0; readop = 1; @@ -508,7 +508,7 @@ write_prdt(struct ahci_port *p, int slot, uint8_t *cfis, void *from; int i, len; - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); len = size; from = buf; prdt = (struct ahci_prdt_entry *)(cfis + 0x80); @@ -528,7 +528,7 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis) { struct ahci_cmd_hdr *hdr; - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); if (p->atapi || hdr->prdtl == 0) { p->tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; p->is |= AHCI_P_IX_TFE; @@ -869,7 +869,7 @@ atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, sc = p->pr_sc; acmd = cfis + 0x40; - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); prdt = (struct ahci_prdt_entry *)(cfis + 0x80); prdt += seek; @@ -1178,7 +1178,7 @@ ahci_handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis) } case ATA_SET_MULTI: if (cfis[12] != 0 && - (cfis[12] > 128 || (cfis[12] & cfis[12] - 1))) { + (cfis[12] > 128 || (cfis[12] & (cfis[12] - 1)))) { p->tfd = ATA_S_ERROR | ATA_S_READY; p->tfd |= (ATA_ERROR_ABORT << 8); } else { @@ -1241,7 +1241,7 @@ ahci_handle_slot(struct ahci_port *p, int slot) int cfl; sc = p->pr_sc; - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); cfl = (hdr->flags & 0x1f) * 4; cfis = paddr_guest2host(ahci_ctx(sc), hdr->ctba, 0x80 + hdr->prdtl * sizeof(struct ahci_prdt_entry)); @@ -1318,7 +1318,7 @@ ata_ioreq_cb(struct blockif_req *br, int err) slot = aior->slot; pending = aior->prdtl; sc = p->pr_sc; - hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE); if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || cfis[2] == ATA_READ_FPDMA_QUEUED) @@ -1380,7 +1380,7 @@ atapi_ioreq_cb(struct blockif_req *br, int err) slot = aior->slot; pending = aior->prdtl; sc = p->pr_sc; - hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; + hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + aior->slot * AHCI_CL_SIZE); pthread_mutex_lock(&sc->mtx); From 9cba9d0157236b370572230cc067e298270da8d5 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 8 Oct 2013 20:04:35 +0000 Subject: [PATCH 03/13] In sys/amd64/amd64/pmap.c, fix several gcc warnings about uninitialized variables in reclaim_pv_chunk(). Approved by: re (marius) Reviewed by: neel, kib X-MFC-With: r256072 --- sys/amd64/amd64/pmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 74d3d13eee9b..c0af020bb63c 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -2705,6 +2705,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp) KASSERT(lockp != NULL, ("reclaim_pv_chunk: lockp is NULL")); pmap = NULL; m_pc = NULL; + PG_G = PG_A = PG_M = PG_RW = 0; SLIST_INIT(&free); TAILQ_INIT(&new_tail); mtx_lock(&pv_chunks_mutex); From b85baffde35cdd27a3792724c892de40d7463093 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 8 Oct 2013 20:39:38 +0000 Subject: [PATCH 04/13] Remove mention of [fixed] known issue not-specific to updating. Vendor update to [c]dialog-1.2-20130925 has fixed known problems. Vendor update SVN revisions: 255917-255917, 255852, and 255958. Reviewed by: gjb Approved by: re (gjb) --- UPDATING | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/UPDATING b/UPDATING index ebf000bab9e0..e9f0251e068f 100644 --- a/UPDATING +++ b/UPDATING @@ -77,19 +77,6 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW: has been updated to use this support. A new gcc is required to build the aesni module on both i386 and amd64. -20130827: - Thomas Dickey (vendor author thereof) reports that dialog(1) since - 2011/10/18 has a bug in handling --hline. Testers and I noticed the - --hline is not ignored but displayed as a NULL string, regardless of - value. This will cause confusion in some bsdconfig dialogs where the - --hline is used to inform users which keybindings to use. This will - likewise affect any other persons relying on --hline. It also looks - rather strange seeing "[]" at the bottom of dialog(1) widgets when - passing --hline "anything". Thomas said he will have a look in a few - weeks. NOTE: The "[]" brackets appear with the left-edge where it - would normally appear given the width of text to display, but the - displayed text is not there (part of the bug). - 20130821: The PADLOCK_RNG and RDRAND_RNG kernel options are now devices. Thus "device padlock_rng" and "device rdrand_rng" should be From 8a959ae073230c7186c6f470cdd2bbfd57fb4ff3 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 8 Oct 2013 23:23:04 +0000 Subject: [PATCH 05/13] Fix the LINT build. Approved by: re (implicit) MFC after: 1 week --- sys/dev/nvme/nvme_ns.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index e22f5bd0435b..24e07795c1ca 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include From 57778cfec4929531a497102b00f73a7abfbd0570 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 00:21:21 +0000 Subject: [PATCH 06/13] Add two new MIPS CPU families - mips24k and mips74k. They're both different cores: * mips24k is an 8-stage pipeline, mips32r1 ABI, non-superscalar core. * mips74k is a dual-issue 15-stage superscalar design, mips32r2 ABI. They have different sets of quirks and bugs; these #define entries will be used to work around these. Now, strictly speaking, we should have CPU ABI families (mips32r1, mips32r2, etc) and CPU core types (mips4k, mips24k, mips74k, etc.) But this is the starting point of that particular tidy-up. Reviewed by: imp@ Approved by: re@ (gjb) --- sys/conf/options.mips | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/conf/options.mips b/sys/conf/options.mips index 1435a6eac6c9..b159723ef7ee 100644 --- a/sys/conf/options.mips +++ b/sys/conf/options.mips @@ -29,6 +29,8 @@ # $FreeBSD$ CPU_MIPS4KC opt_global.h +CPU_MIPS24KC opt_global.h +CPU_MIPS74KC opt_global.h CPU_MIPS32 opt_global.h CPU_MIPS64 opt_global.h CPU_SENTRY5 opt_global.h From 2e2f21556eb7174358fe712c43f4e54e6a2c709f Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 00:22:21 +0000 Subject: [PATCH 07/13] Shuffle the includes around so they occur after opt_global.h is included; this way the CPU ABI / core #define items are there. Reviewed by: imp@ Approved by: re@ (gjb) --- sys/mips/mips/elf_trampoline.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/mips/mips/elf_trampoline.c b/sys/mips/mips/elf_trampoline.c index 7d8324a733bf..7be26bbe62b5 100644 --- a/sys/mips/mips/elf_trampoline.c +++ b/sys/mips/mips/elf_trampoline.c @@ -32,10 +32,6 @@ __FBSDID("$FreeBSD$"); #else #include #endif -#include -#include -#include -#include /* * Since we are compiled outside of the normal kernel build process, we @@ -43,6 +39,11 @@ __FBSDID("$FreeBSD$"); */ #include "opt_global.h" +#include +#include +#include +#include + #ifndef KERNNAME #error Kernel name not provided #endif From 4cfbfdd4b37ba16b29a13a924663002c960213c8 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 00:27:12 +0000 Subject: [PATCH 08/13] Add "better" MIPS24k and MIPS74k barriers. * the mips74k cores only need EHB (which is 'sll $0, $0, 3') here; NOPs don't actually work. * add EHB as the last NOP for the default barriers/hazards; that is "better" behaviour and should work on a wider variety of processors. This allows the existing (icky) TLB code to work, allowing the AR9344 SoC (mips74k) to actually get through kernel startup. Tested: * AR9344 SoC - (mips74k) * AR9331 SoC - (mips24k) TODO: * test on mips4k CPUs, just to be sure. * document that sll $0, $0, 3 is actually "EHB" and that it falls back to being a NOP for pre-mips32r1. * mips24k has an errata that we currently don't correctly explicitly state - ie, that after DERET/ERET, the only valid instruction is a NOP. Reviewed by: imp@ Approved by: re@ (gjb) --- sys/mips/include/asm.h | 7 +++++-- sys/mips/include/cpuregs.h | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/mips/include/asm.h b/sys/mips/include/asm.h index 790024ff60d4..551d02c1cd51 100644 --- a/sys/mips/include/asm.h +++ b/sys/mips/include/asm.h @@ -725,9 +725,12 @@ _C_LABEL(x): #elif defined(CPU_RMI) #define HAZARD_DELAY #define ITLBNOPFIX +#elif defined(CPU_MIPS74KC) +#define HAZARD_DELAY sll $0,$0,3 +#define ITLBNOPFIX sll $0,$0,3 #else -#define ITLBNOPFIX nop;nop;nop;nop;nop;nop;nop;nop;nop;nop; -#define HAZARD_DELAY nop;nop;nop;nop;nop; +#define ITLBNOPFIX nop;nop;nop;nop;nop;nop;nop;nop;nop;sll $0,$0,3; +#define HAZARD_DELAY nop;nop;nop;nop;sll $0,$0,3; #endif #endif /* !_MACHINE_ASM_H_ */ diff --git a/sys/mips/include/cpuregs.h b/sys/mips/include/cpuregs.h index 436a980785c4..be8414f8fc32 100644 --- a/sys/mips/include/cpuregs.h +++ b/sys/mips/include/cpuregs.h @@ -149,6 +149,11 @@ #define MIPS_CCA_CC 0x05 /* Cacheable Coherent. */ #endif +#if defined(CPU_MIPS74KC) +#define MIPS_CCA_UNCACHED 0x02 +#define MIPS_CCA_CACHED 0x00 +#endif + #ifndef MIPS_CCA_UNCACHED #define MIPS_CCA_UNCACHED MIPS_CCA_UC #endif @@ -204,12 +209,14 @@ #define COP0_SYNC .word 0xc0 /* ehb */ #elif defined(CPU_SB1) #define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop +#elif defined(CPU_MIPS74KC) +#define COP0_SYNC .word 0xc0 /* ehb */ #else /* * Pick a reasonable default based on the "typical" spacing described in the * "CP0 Hazards" chapter of MIPS Architecture Book Vol III. */ -#define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop +#define COP0_SYNC ssnop; ssnop; ssnop; ssnop; .word 0xc0; #endif #define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; From 83220b2e9f02765ff1acfeffddd9d6e0d119d7b1 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 00:27:33 +0000 Subject: [PATCH 09/13] Mark AR934x based boards to be mips74k. Reviewed by: imp@ Approved by: re@ (gjb) --- sys/mips/conf/AR934X_BASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/mips/conf/AR934X_BASE b/sys/mips/conf/AR934X_BASE index 4e07eebc1def..22ba0b8a9d81 100644 --- a/sys/mips/conf/AR934X_BASE +++ b/sys/mips/conf/AR934X_BASE @@ -12,7 +12,7 @@ machine mips mips ident AR934X_BASE -cpu CPU_MIPS4KC +cpu CPU_MIPS74KC makeoptions KERNLOADADDR=0x80050000 options HZ=1000 From 50c55142271e40c6e58fecf7361ec776dd63b254 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 02:01:20 +0000 Subject: [PATCH 10/13] Fix interrupt handling from the APB periperals (ie, UART) - it also requires an explicit acknowledgement. Tested: * AR9344 (DB120) SoC Approved by: re@ (gjb) --- sys/mips/atheros/apb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/mips/atheros/apb.c b/sys/mips/atheros/apb.c index ef44e0ad47fe..94cb1aa58e1e 100644 --- a/sys/mips/atheros/apb.c +++ b/sys/mips/atheros/apb.c @@ -359,6 +359,9 @@ apb_filter(void *arg) case AR71XX_SOC_AR7242: case AR71XX_SOC_AR9330: case AR71XX_SOC_AR9331: + case AR71XX_SOC_AR9341: + case AR71XX_SOC_AR9342: + case AR71XX_SOC_AR9344: /* Ack/clear the irq on status register for AR724x */ ATH_WRITE_REG(AR71XX_MISC_INTR_STATUS, reg & ~(1 << irq)); From 490cbcd9cba948ed2aa3eee28e307f9f5d26748f Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 9 Oct 2013 03:19:05 +0000 Subject: [PATCH 11/13] Add some missing AR934x register definitions. These are needed for ethernet bootstrap. Approved by: re@ (gjb) --- sys/mips/atheros/ar71xxreg.h | 12 ++++++++++++ sys/mips/atheros/ar934xreg.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/sys/mips/atheros/ar71xxreg.h b/sys/mips/atheros/ar71xxreg.h index 7d6d6b2f5a4c..5e3505be23ef 100644 --- a/sys/mips/atheros/ar71xxreg.h +++ b/sys/mips/atheros/ar71xxreg.h @@ -336,6 +336,7 @@ typedef enum { #define MAC_MII_CFG_SCAN_AUTO_INC (1 << 5) #define MAC_MII_CFG_PREAMBLE_SUP (1 << 4) #define MAC_MII_CFG_CLOCK_SELECT_MASK 0x7 +#define MAC_MII_CFG_CLOCK_SELECT_MASK_AR933X 0xf #define MAC_MII_CFG_CLOCK_DIV_4 0 #define MAC_MII_CFG_CLOCK_DIV_6 2 #define MAC_MII_CFG_CLOCK_DIV_8 3 @@ -343,6 +344,17 @@ typedef enum { #define MAC_MII_CFG_CLOCK_DIV_14 5 #define MAC_MII_CFG_CLOCK_DIV_20 6 #define MAC_MII_CFG_CLOCK_DIV_28 7 + +/* .. and the AR933x/AR934x extensions */ +#define MAC_MII_CFG_CLOCK_DIV_34 8 +#define MAC_MII_CFG_CLOCK_DIV_42 9 +#define MAC_MII_CFG_CLOCK_DIV_50 10 +#define MAC_MII_CFG_CLOCK_DIV_58 11 +#define MAC_MII_CFG_CLOCK_DIV_66 12 +#define MAC_MII_CFG_CLOCK_DIV_74 13 +#define MAC_MII_CFG_CLOCK_DIV_82 14 +#define MAC_MII_CFG_CLOCK_DIV_98 15 + #define AR71XX_MAC_MII_CMD 0x24 #define MAC_MII_CMD_SCAN_CYCLE (1 << 1) #define MAC_MII_CMD_READ 1 diff --git a/sys/mips/atheros/ar934xreg.h b/sys/mips/atheros/ar934xreg.h index 3b0381f8f7f1..2aa3f46ca843 100644 --- a/sys/mips/atheros/ar934xreg.h +++ b/sys/mips/atheros/ar934xreg.h @@ -29,6 +29,8 @@ #ifndef __AR934X_REG_H__ #define __AR934X_REG_H__ +#define AR934X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000) +#define AR934X_GMAC_SIZE 0x14 #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000) #define AR934X_WMAC_SIZE 0x20000 #define AR934X_EHCI_BASE 0x1b000000 @@ -36,6 +38,23 @@ #define AR934X_SRIF_BASE (AR71XX_APB_BASE + 0x00116000) #define AR934X_SRIF_SIZE 0x1000 +/* AR934x GMAC configuration */ +#define AR934X_GMAC_REG_ETH_CFG (AR934X_GMAC_BASE + 0x00) + +#define AR934X_ETH_CFG_RGMII_GMAC0 (1 << 0) +#define AR934X_ETH_CFG_MII_GMAC0 (1 << 1) +#define AR934X_ETH_CFG_GMII_GMAC0 (1 << 2) +#define AR934X_ETH_CFG_MII_GMAC0_MASTER (1 << 3) +#define AR934X_ETH_CFG_MII_GMAC0_SLAVE (1 << 4) +#define AR934X_ETH_CFG_MII_GMAC0_ERR_EN (1 << 5) +#define AR934X_ETH_CFG_SW_ONLY_MODE (1 << 6) +#define AR934X_ETH_CFG_SW_PHY_SWAP (1 << 7) +#define AR934X_ETH_CFG_SW_APB_ACCESS (1 << 9) +#define AR934X_ETH_CFG_RMII_GMAC0 (1 << 10) +#define AR933X_ETH_CFG_MII_CNTL_SPEED (1 << 11) +#define AR934X_ETH_CFG_RMII_GMAC0_MASTER (1 << 12) +#define AR934X_ETH_CFG_SW_ACC_MSB_FIRST (1 << 13) + #define AR934X_DDR_REG_FLUSH_GE0 (AR71XX_APB_BASE + 0x9c) #define AR934X_DDR_REG_FLUSH_GE1 (AR71XX_APB_BASE + 0xa0) #define AR934X_DDR_REG_FLUSH_USB (AR71XX_APB_BASE + 0xa4) @@ -45,6 +64,9 @@ #define AR934X_PLL_CPU_CONFIG_REG (AR71XX_PLL_CPU_BASE + 0x00) #define AR934X_PLL_DDR_CONFIG_REG (AR71XX_PLL_CPU_BASE + 0x04) #define AR934X_PLL_CPU_DDR_CLK_CTRL_REG (AR71XX_PLL_CPU_BASE + 0x08) +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_REG (AR71XX_PLL_CPU_BASE + 0x24) +#define AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL (1 << 6) +#define AR934X_PLL_ETH_XMII_CONTROL_REG (AR71XX_PLL_CPU_BASE + 0x2c) #define AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT 0 #define AR934X_PLL_CPU_CONFIG_NFRAC_MASK 0x3f @@ -81,7 +103,13 @@ #define AR934X_RESET_REG_BOOTSTRAP (AR71XX_RST_BLOCK_BASE + 0xb0) #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS (AR71XX_RST_BLOCK_BASE + 0xac) +#define AR934X_RESET_GE1_MDIO (1 << 23) +#define AR934X_RESET_GE0_MDIO (1 << 22) +#define AR934X_RESET_GE1_MAC (1 << 13) +#define AR934X_RESET_ETH_SWITCH_ANALOG (1 << 12) #define AR934X_RESET_USB_PHY_ANALOG (1 << 11) +#define AR934X_RESET_GE0_MAC (1 << 9) +#define AR934X_RESET_ETH_SWITCH (1 << 8) #define AR934X_RESET_USB_HOST (1 << 5) #define AR934X_RESET_USB_PHY (1 << 4) #define AR934X_RESET_USBSUS_OVERRIDE (1 << 3) @@ -153,4 +181,9 @@ #define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13 #define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7 +/* XXX verify! */ +#define AR934X_PLL_VAL_1000 0x16000000 +#define AR934X_PLL_VAL_100 0x00000101 +#define AR934X_PLL_VAL_10 0x00001616 + #endif /* __AR934X_REG_H__ */ From 200758f11496ab1a22a3fcf135a128a960ef9213 Mon Sep 17 00:00:00 2001 From: Neel Natu Date: Wed, 9 Oct 2013 03:56:07 +0000 Subject: [PATCH 12/13] Parse the memory size parameter using expand_number() to allow specifying the memory size more intuitively (e.g. 512M, 4G etc). Submitted by: rodrigc Reviewed by: grehan Approved by: re (blanket) --- lib/libvmmapi/vmmapi.c | 27 +++++++++++++++++++++++++++ lib/libvmmapi/vmmapi.h | 1 + share/examples/bhyve/vmrun.sh | 4 ++-- usr.sbin/bhyve/Makefile | 4 ++-- usr.sbin/bhyve/bhyverun.c | 6 +++++- usr.sbin/bhyvectl/Makefile | 4 ++-- usr.sbin/bhyveload/Makefile | 4 ++-- usr.sbin/bhyveload/bhyveload.8 | 26 +++++++++++++++++++++----- usr.sbin/bhyveload/bhyveload.c | 7 +++++-- 9 files changed, 67 insertions(+), 16 deletions(-) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 55598036d58a..810b39eb9a81 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -43,11 +43,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include "vmmapi.h" +#define MB (1024 * 1024UL) #define GB (1024 * 1024 * 1024UL) struct vmctx { @@ -123,6 +126,30 @@ vm_destroy(struct vmctx *vm) free(vm); } +int +vm_parse_memsize(const char *optarg, size_t *ret_memsize) +{ + char *endptr; + size_t optval; + int error; + + optval = strtoul(optarg, &endptr, 0); + if (*optarg != '\0' && *endptr == '\0') { + /* + * For the sake of backward compatibility if the memory size + * specified on the command line is less than a megabyte then + * it is interpreted as being in units of MB. + */ + if (optval < MB) + optval *= MB; + *ret_memsize = optval; + error = 0; + } else + error = expand_number(optarg, ret_memsize); + + return (error); +} + int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len, int *wired) diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h index 8b53ae0cd59a..0720e2edfa25 100644 --- a/lib/libvmmapi/vmmapi.h +++ b/lib/libvmmapi/vmmapi.h @@ -45,6 +45,7 @@ enum vm_mmap_style { int vm_create(const char *name); struct vmctx *vm_open(const char *name); void vm_destroy(struct vmctx *ctx); +int vm_parse_memsize(const char *optarg, size_t *memsize); int vm_get_memory_seg(struct vmctx *ctx, vm_paddr_t gpa, size_t *ret_len, int *wired); int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); diff --git a/share/examples/bhyve/vmrun.sh b/share/examples/bhyve/vmrun.sh index 73a716298e41..2e1bb38cd9df 100755 --- a/share/examples/bhyve/vmrun.sh +++ b/share/examples/bhyve/vmrun.sh @@ -31,7 +31,7 @@ LOADER=/usr/sbin/bhyveload BHYVECTL=/usr/sbin/bhyvectl FBSDRUN=/usr/sbin/bhyve -DEFAULT_MEMSIZE=512 +DEFAULT_MEMSIZE=512M DEFAULT_CPUS=2 DEFAULT_TAPDEV=tap0 @@ -47,7 +47,7 @@ usage() { echo " -g: listen for connection from kgdb at " echo " -i: force boot of the Installation CDROM image" echo " -I: Installation CDROM image location (default is ${DEFAULT_ISOFILE})" - echo " -m: memory size in MB (default is ${DEFAULT_MEMSIZE}MB)" + echo " -m: memory size (default is ${DEFAULT_MEMSIZE})" echo " -t: tap device for virtio-net (default is $DEFAULT_TAPDEV)" echo "" echo " This script needs to be executed with superuser privileges" diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index ff9425f9a1a5..0644ed754696 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -17,8 +17,8 @@ SRCS+= vmm_instruction_emul.c NO_MAN= -DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} -LDADD= -lvmmapi -lmd -lpthread +DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBUTIL} ${LIBPTHREAD} +LDADD= -lvmmapi -lmd -lutil -lpthread WARNS?= 2 diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 01a5d07cb0b4..535944274aa2 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -37,12 +37,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -529,7 +531,9 @@ main(int argc, char *argv[]) else break; case 'm': - memsize = strtoul(optarg, NULL, 0) * MB; + error = vm_parse_memsize(optarg, &memsize); + if (error) + errx(EX_USAGE, "invalid memsize '%s'", optarg); break; case 'H': guest_vmexit_on_hlt = 1; diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile index 9fde12ccc233..df3f19c56c3c 100644 --- a/usr.sbin/bhyvectl/Makefile +++ b/usr.sbin/bhyvectl/Makefile @@ -7,8 +7,8 @@ SRCS= bhyvectl.c NO_MAN= -DPADD= ${LIBVMMAPI} -LDADD= -lvmmapi +DPADD= ${LIBVMMAPI} ${LIBUTIL} +LDADD= -lvmmapi -lutil WARNS?= 3 diff --git a/usr.sbin/bhyveload/Makefile b/usr.sbin/bhyveload/Makefile index 7b0081836a35..e7b19bd82883 100644 --- a/usr.sbin/bhyveload/Makefile +++ b/usr.sbin/bhyveload/Makefile @@ -4,8 +4,8 @@ PROG= bhyveload SRCS= bhyveload.c MAN= bhyveload.8 -DPADD+= ${LIBVMMAPI} -LDADD+= -lvmmapi +DPADD+= ${LIBVMMAPI} ${LIBUTIL} +LDADD+= -lvmmapi -lutil WARNS?= 3 diff --git a/usr.sbin/bhyveload/bhyveload.8 b/usr.sbin/bhyveload/bhyveload.8 index f2e5e3590d14..2c0edace9045 100644 --- a/usr.sbin/bhyveload/bhyveload.8 +++ b/usr.sbin/bhyveload/bhyveload.8 @@ -1,4 +1,4 @@ -.\" +\" .\" Copyright (c) 2012 NetApp Inc .\" All rights reserved. .\" @@ -60,13 +60,29 @@ and will be created if it does not already exist. .Sh OPTIONS The following options are available: .Bl -tag -width indent -.It Fl m Ar mem-size +.It Fl m Ar mem-size Xo +.Sm off +.Op Cm K | k | M | m | G | g | T | t +.Xc +.Sm on .Ar mem-size -is the amount of memory allocated to the guest in units of megabytes. +is the amount of memory allocated to the guest. +.Pp +The +.Ar mem-size +argument may be suffixed with one of +.Cm K , +.Cm M , +.Cm G +or +.Cm T +(either upper or lower case) to indicate a multiple of +Kilobytes, Megabytes, Gigabytes or Terabytes +respectively. .Pp The default value of .Ar mem-size -is 256. +is 256M. .It Fl d Ar disk-path The .Ar disk-path @@ -83,7 +99,7 @@ that boots off the ISO image .Pa /freebsd/release.iso and has 1GB memory allocated to it: .Pp -.Dl "bhyveload -m 1024 -d /freebsd/release.iso freebsd-vm" +.Dl "bhyveload -m 1G -d /freebsd/release.iso freebsd-vm" .Sh SEE ALSO .Xr bhyve 4 , .Xr bhyve 8 , diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c index c4bafd3a595c..6e541e8cc389 100644 --- a/usr.sbin/bhyveload/bhyveload.c +++ b/usr.sbin/bhyveload/bhyveload.c @@ -67,12 +67,14 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -581,9 +583,10 @@ main(int argc, char** argv) break; case 'm': - mem_size = strtoul(optarg, NULL, 0) * MB; + error = vm_parse_memsize(optarg, &mem_size); + if (error != 0) + errx(EX_USAGE, "Invalid memsize '%s'", optarg); break; - case '?': usage(); } From cb53fc2dad443a912fa509972213996d8527ee95 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 9 Oct 2013 07:02:03 +0000 Subject: [PATCH 13/13] Remove redundant declaration of cmclass in sys/ofed/drivers/infiniband/core/ucm.c, to silence a gcc warning. Approved by: re (kib) X-MFC-With: r255932 --- sys/ofed/drivers/infiniband/core/ucm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/ofed/drivers/infiniband/core/ucm.c b/sys/ofed/drivers/infiniband/core/ucm.c index 90e0b31368e9..860d0a5c2de3 100644 --- a/sys/ofed/drivers/infiniband/core/ucm.c +++ b/sys/ofed/drivers/infiniband/core/ucm.c @@ -104,9 +104,6 @@ enum { IB_UCM_MAX_DEVICES = 32 }; -/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */ -extern struct class cm_class; - #define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR) static void ib_ucm_add_one(struct ib_device *device);