svn commit: r368300 - head/cddl/contrib/opensolaris/cmd/dtrace
Author: avg Date: Thu Dec 3 11:59:40 2020 New Revision: 368300 URL: https://svnweb.freebsd.org/changeset/base/368300 Log: dtrace: honor LC_NUMERIC for %'d and alike, and LC_TIME for %T Note that the public documentation on dtrace.org fails to mention %T and incorrectly documents %Y. The latter actually uses format "%Y %b %e %T" where %b is always in C locale. Discussed with: markj MFC after:1 month Sponsored by: Panzura Modified: head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c Modified: head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c == --- head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c Thu Dec 3 11:15:49 2020(r368299) +++ head/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c Thu Dec 3 11:59:40 2020(r368300) @@ -51,6 +51,7 @@ #include #endif #ifdef __FreeBSD__ +#include #include #endif @@ -1315,6 +1316,14 @@ main(int argc, char *argv[]) char *p, **v; struct ps_prochandle *P; pid_t pid; + +#ifdef __FreeBSD__ + /* For %'d and the like. */ + (void) setlocale(LC_NUMERIC, ""); + + /* For %T. */ + (void) setlocale(LC_TIME, ""); +#endif g_pname = basename(argv[0]); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r367343 - in head/sys/contrib/openzfs/include/os: freebsd/zfs/sys linux/zfs/sys
On 04/11/2020 23:33, Mateusz Guzik wrote: > Well, should you check OpenZFS github you will find I post pull > request there as well. So whatever conflicts arise for people merging > stuff back are to be just whacked in favor in what's in upstream. I certainly would, but how would I know that I should? Any cross-reference would be of help both now and for the future code history archaeology. > On 11/4/20, Andriy Gapon wrote: >> On 04/11/2020 23:18, Mateusz Guzik wrote: >>> Author: mjg >>> Date: Wed Nov 4 21:18:51 2020 >>> New Revision: 367343 >>> URL: https://svnweb.freebsd.org/changeset/base/367343 >>> >>> Log: >>> zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros >>> >>> They are expected to fail only in corner cases. >>> >>> Modified: >>> head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h >>> head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h >> >> Picking a random commit of many, is this how we do ZFS/OpenZFS changes now? >> Can I do the same? >> Who will be resolving any merge conflicts resulting from my changes? >> >> -- >> Andriy Gapon >> > > -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r367343 - in head/sys/contrib/openzfs/include/os: freebsd/zfs/sys linux/zfs/sys
On 04/11/2020 23:18, Mateusz Guzik wrote: > Author: mjg > Date: Wed Nov 4 21:18:51 2020 > New Revision: 367343 > URL: https://svnweb.freebsd.org/changeset/base/367343 > > Log: > zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros > > They are expected to fail only in corner cases. > > Modified: > head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h > head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_znode_impl.h Picking a random commit of many, is this how we do ZFS/OpenZFS changes now? Can I do the same? Who will be resolving any merge conflicts resulting from my changes? -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367098 - stable/12/sys/arm/allwinner
Author: avg Date: Wed Oct 28 11:40:10 2020 New Revision: 367098 URL: https://svnweb.freebsd.org/changeset/base/367098 Log: MFC r365943: aw_usbphy: add support for device mode operation OTG mode is not supported still. It's easy to do it as a one-off detection, but the proper support requires continuous monitoring and communicating the current state to the USB layer. Also, fix phy0_route setting for H3. Remove duplicate register definitions. Modified: stable/12/sys/arm/allwinner/aw_usbphy.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_usbphy.c == --- stable/12/sys/arm/allwinner/aw_usbphy.c Wed Oct 28 08:29:31 2020 (r367097) +++ stable/12/sys/arm/allwinner/aw_usbphy.c Wed Oct 28 11:40:10 2020 (r367098) @@ -102,7 +102,7 @@ static const struct aw_usbphy_conf h3_usbphy_conf = { .num_phys = 4, .phy_type = AWUSBPHY_TYPE_H3, .pmu_unk1 = true, - .phy0_route = false, + .phy0_route = true, }; static const struct aw_usbphy_conf a64_usbphy_conf = { @@ -167,8 +167,10 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define FORCE_ID (0x3 << 14) #define FORCE_ID_SHIFT 14 #define FORCE_ID_LOW 2 +#define FORCE_ID_HIGH 3 #define FORCE_VBUS_VALID (0x3 << 12) #define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_LOW 2 #define FORCE_VBUS_VALID_HIGH 3 #define VBUS_CHANGE_DET(1 << 6) #define ID_CHANGE_DET (1 << 5) @@ -182,18 +184,6 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define PMU_ULPI_BYPASS(1 << 0) #definePMU_UNK_H3 0x10 #define PMU_UNK_H3_CLR 0x2 -#definePHY_CSR 0x00 -#define ID_PULLUP_EN (1 << 17) -#define DPDM_PULLUP_EN (1 << 16) -#define FORCE_ID (0x3 << 14) -#define FORCE_ID_SHIFT 14 -#define FORCE_ID_LOW 2 -#define FORCE_VBUS_VALID (0x3 << 12) -#define FORCE_VBUS_VALID_SHIFT 12 -#define FORCE_VBUS_VALID_HIGH 3 -#define VBUS_CHANGE_DET(1 << 6) -#define ID_CHANGE_DET (1 << 5) -#define DPDM_CHANGE_DET(1 << 4) static void awusbphy_configure(device_t dev, int phyno) @@ -327,7 +317,12 @@ awusbphy_vbus_detect(device_t dev, int *val) return (0); } - *val = 0; + /* TODO check vbus_power-supply. */ + + /* +* If there is no way to detect, assume present. +*/ + *val = 1; return (0); } @@ -361,10 +356,11 @@ awusbphy_phy_enable(struct phynode *phynode, bool enab if (error) goto out; - if (vbus_det == 1) { + /* TODO check vbus_power-supply as well. */ + if (sc->vbus_det_valid && vbus_det == 1) { if (bootverbose) - device_printf(dev, "External VBUS detected, not enabling the regulator\n"); - + device_printf(dev, "External VBUS detected, " + "not enabling the regulator\n"); return (0); } } @@ -418,37 +414,40 @@ awusbphy_set_mode(struct phynode *phynode, int mode) return (0); } + if (sc->mode == mode) + return (0); + if (mode == PHY_USB_MODE_OTG) /* TODO */ + return (EOPNOTSUPP); + + error = awusbphy_vbus_detect(dev, _det); + if (error != 0) + return (error); + + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_VBUS_VALID; + val |= (vbus_det ? FORCE_VBUS_VALID_HIGH : FORCE_VBUS_VALID_LOW) << + FORCE_VBUS_VALID_SHIFT; + val &= ~FORCE_ID; + switch (mode) { case PHY_USB_MODE_HOST: - val = bus_read_4(sc->phy_ctrl, PHY_CSR); - val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); - val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); - val &= ~FORCE_ID; val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); - val &= ~FORCE_VBUS_VALID; - val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); - bus_write_4(sc->phy_ctrl, PHY_CSR, val); - if (sc->phy_conf->phy0_route == true) { - error = awusbphy_vbus_detect(dev, _det); - if (error) - goto out; - if (vbus_det == 0) - CLR4(sc->phy_ctrl, OTG_PHY_CFG, -
svn commit: r366827 - stable/12/sys/dev/usb/controller
Author: avg Date: Mon Oct 19 07:03:04 2020 New Revision: 366827 URL: https://svnweb.freebsd.org/changeset/base/366827 Log: MFC r365402: musb/allwinner: add support for configuring phy as well as device mode At least on Orange Pi PC Plus even the host mode does not work without enabling the phy and setting it to the host mode. The driver will now parse dr_mode property and will try to configure itself and the phy accordingly. OTG mode is not supported yet, so it is treated as the device / peripheral mode. The phy is enabled -- powered on -- only for the host mode. The device mode requires support from a phy driver, e.g., aw_usbphy on Allwinner platform. aw_usbphy does not support the device mode, so it cannnot work yet. Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c == --- stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 19 06:44:07 2020(r366826) +++ stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 19 07:03:04 2020(r366827) @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #ifdef __arm__ #include @@ -121,6 +123,7 @@ struct awusbdrd_softc { struct resource *res[2]; clk_t clk; hwreset_t reset; + phy_t phy; struct bus_spacebs; int flags; }; @@ -382,7 +385,10 @@ awusbdrd_probe(device_t dev) static int awusbdrd_attach(device_t dev) { + char usb_mode[24]; struct awusbdrd_softc *sc; + uint8_t musb_mode; + int phy_mode; int error; sc = device_get_softc(dev); @@ -392,6 +398,31 @@ awusbdrd_attach(device_t dev) if (error != 0) return (error); + musb_mode = MUSB2_HOST_MODE;/* default */ + phy_mode = PHY_USB_MODE_HOST; + if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", + _mode, sizeof(usb_mode)) > 0) { + usb_mode[sizeof(usb_mode) - 1] = 0; + if (strcasecmp(usb_mode, "host") == 0) { + musb_mode = MUSB2_HOST_MODE; + phy_mode = PHY_USB_MODE_HOST; + } else if (strcasecmp(usb_mode, "peripheral") == 0) { + musb_mode = MUSB2_DEVICE_MODE; + phy_mode = PHY_USB_MODE_DEVICE; + } else if (strcasecmp(usb_mode, "otg") == 0) { + /* +* XXX phy has PHY_USB_MODE_OTG, but MUSB does not have +* it. It's not clear how to propagate mode changes +* from phy layer (that detects them) to MUSB. +*/ + musb_mode = MUSB2_DEVICE_MODE; + phy_mode = PHY_USB_MODE_DEVICE; + } else { + device_printf(dev, "Invalid FDT dr_mode: %s\n", + usb_mode); + } + } + /* AHB gate clock is required */ error = clk_get_by_ofw_index(dev, 0, 0, >clk); if (error != 0) @@ -415,6 +446,24 @@ awusbdrd_attach(device_t dev) } } + /* XXX not sure if this is universally needed. */ + (void)phy_get_by_ofw_name(dev, 0, "usb", >phy); + if (sc->phy != NULL) { + device_printf(dev, "setting phy mode %d\n", phy_mode); + if (musb_mode == MUSB2_HOST_MODE) { + error = phy_enable(sc->phy); + if (error != 0) { + device_printf(dev, "Could not enable phy\n"); + goto fail; + } + } + error = phy_usb_set_mode(sc->phy, phy_mode); + if (error != 0) { + device_printf(dev, "Could not set phy mode\n"); + goto fail; + } + } + sc->sc.sc_bus.parent = dev; sc->sc.sc_bus.devices = sc->sc.sc_devices; sc->sc.sc_bus.devices_max = MUSB2_MAX_DEVICES; @@ -457,7 +506,7 @@ awusbdrd_attach(device_t dev) device_set_ivars(sc->sc.sc_bus.bdev, >sc.sc_bus); sc->sc.sc_id = 0; sc->sc.sc_platform_data = sc; - sc->sc.sc_mode = MUSB2_HOST_MODE; /* XXX HOST vs DEVICE mode */ + sc->sc.sc_mode = musb_mode; if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) { sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3; sc->sc.sc_ep_max = DRD_EP_MAX_H3; @@ -497,8 +546,15 @@ awusbdrd_attach(device_t dev) return (0); fail: - if (sc->reset != NULL) + if (sc->phy != NULL) { + if (musb_mode == MUSB2_HOST_MODE) +
svn commit: r366826 - stable/12/sys/dev/usb/controller
Author: avg Date: Mon Oct 19 06:44:07 2020 New Revision: 366826 URL: https://svnweb.freebsd.org/changeset/base/366826 Log: MFC r365401: musb/allwinner: add H3 support Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c == --- stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 19 02:12:32 2020(r366825) +++ stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 19 06:44:07 2020(r366826) @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #endif #defineDRD_EP_MAX 5 +#defineDRD_EP_MAX_H3 4 #defineMUSB2_REG_AWIN_VEND00x0043 #defineVEND0_PIO_MODE 0 @@ -89,12 +90,13 @@ static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-musb", AWUSB_OKAY }, { "allwinner,sun6i-a31-musb", AWUSB_OKAY }, { "allwinner,sun8i-a33-musb", AWUSB_OKAY | AWUSB_NO_CONFDATA }, + { "allwinner,sun8i-h3-musb",AWUSB_OKAY | AWUSB_NO_CONFDATA }, { NULL, 0 } }; static const struct musb_otg_ep_cfg musbotg_ep_allwinner[] = { { - .ep_end = 5, + .ep_end = DRD_EP_MAX, .ep_fifosz_shift = 9, .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512, }, @@ -103,6 +105,17 @@ static const struct musb_otg_ep_cfg musbotg_ep_allwinn }, }; +static const struct musb_otg_ep_cfg musbotg_ep_allwinner_h3[] = { + { + .ep_end = DRD_EP_MAX_H3, + .ep_fifosz_shift = 9, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512, + }, + { + .ep_end = -1, + }, +}; + struct awusbdrd_softc { struct musbotg_softcsc; struct resource *res[2]; @@ -445,8 +458,13 @@ awusbdrd_attach(device_t dev) sc->sc.sc_id = 0; sc->sc.sc_platform_data = sc; sc->sc.sc_mode = MUSB2_HOST_MODE; /* XXX HOST vs DEVICE mode */ - sc->sc.sc_ep_max = DRD_EP_MAX; - sc->sc.sc_ep_cfg = musbotg_ep_allwinner; + if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) { + sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3; + sc->sc.sc_ep_max = DRD_EP_MAX_H3; + } else { + sc->sc.sc_ep_cfg = musbotg_ep_allwinner; + sc->sc.sc_ep_max = DRD_EP_MAX; + } error = bus_setup_intr(dev, sc->res[1], INTR_MPSAFE | INTR_TYPE_BIO, NULL, awusbdrd_intr, sc, >sc.sc_intr_hdl); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366746 - stable/12/sys/arm/allwinner
Author: avg Date: Fri Oct 16 06:42:25 2020 New Revision: 366746 URL: https://svnweb.freebsd.org/changeset/base/366746 Log: MFC r366140: aw_pwm: fix programming of the period The programmed value is biased by one: 0 means 1 cycle, 1 means 2 cycles, etc. Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cFri Oct 16 06:40:59 2020 (r366745) +++ stable/12/sys/arm/allwinner/aw_pwm.cFri Oct 16 06:42:25 2020 (r366746) @@ -314,7 +314,7 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i AW_PWM_WRITE(sc, AW_PWM_CTRL, reg); /* Write the total/active cycles */ - reg = ((clk_rate / period_freq) << AW_PWM_PERIOD_TOTAL_SHIFT) | + reg = ((clk_rate / period_freq - 1) << AW_PWM_PERIOD_TOTAL_SHIFT) | ((clk_rate / duty_freq) << AW_PWM_PERIOD_ACTIVE_SHIFT); AW_PWM_WRITE(sc, AW_PWM_PERIOD, reg); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366745 - stable/12/sys/arm/allwinner
Author: avg Date: Fri Oct 16 06:40:59 2020 New Revision: 366745 URL: https://svnweb.freebsd.org/changeset/base/366745 Log: MFC r366138: aw_pwm: remove the busy bit check The bit seems to always be set on my hardware, H3. However, programming the hardware seems to work just fine. Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cFri Oct 16 02:19:33 2020 (r366744) +++ stable/12/sys/arm/allwinner/aw_pwm.cFri Oct 16 06:40:59 2020 (r366745) @@ -300,10 +300,6 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i } reg = AW_PWM_READ(sc, AW_PWM_CTRL); - if (reg & AW_PWM_CTRL_PERIOD_BUSY) { - device_printf(sc->dev, "pwm busy\n"); - return (EBUSY); - } /* Write the prescalar */ reg &= ~AW_PWM_CTRL_PRESCALE_MASK; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366646 - stable/12/sys/dev/iicbus/twsi
Author: avg Date: Mon Oct 12 11:40:43 2020 New Revision: 366646 URL: https://svnweb.freebsd.org/changeset/base/366646 Log: MFC r365397: twsi: some variants clear interrupt flag by writing 0, others by writing 1 Make that distinction more explicit and regular in the code. The difference in behavior is documented in the respective datasheets. Previously, the code handled the distinction by writing the control register multiple times where at least one write was zero and another was one. This can be considered a follow-up to r363021 (MFC-ed as r366645). Modified: stable/12/sys/dev/iicbus/twsi/a10_twsi.c stable/12/sys/dev/iicbus/twsi/twsi.c stable/12/sys/dev/iicbus/twsi/twsi.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/twsi/a10_twsi.c == --- stable/12/sys/dev/iicbus/twsi/a10_twsi.cMon Oct 12 11:34:09 2020 (r366645) +++ stable/12/sys/dev/iicbus/twsi/a10_twsi.cMon Oct 12 11:40:43 2020 (r366646) @@ -122,6 +122,10 @@ a10_twsi_attach(device_t dev) sc->reg_soft_reset = TWI_SRST; sc->need_ack = true; + + if (ofw_bus_is_compatible(dev, "allwinner,sun6i-a31-i2c") || + ofw_bus_is_compatible(dev, "allwinner,sun6i-a83t-i2c")) + sc->iflag_w1c = true; return (twsi_attach(dev)); } Modified: stable/12/sys/dev/iicbus/twsi/twsi.c == --- stable/12/sys/dev/iicbus/twsi/twsi.cMon Oct 12 11:34:09 2020 (r366645) +++ stable/12/sys/dev/iicbus/twsi/twsi.cMon Oct 12 11:40:43 2020 (r366646) @@ -147,7 +147,11 @@ twsi_clear_iflg(struct twsi_softc *sc) { DELAY(1000); - twsi_control_clear(sc, TWSI_CONTROL_IFLG); + /* There are two ways of clearing IFLAG. */ + if (sc->iflag_w1c) + twsi_control_set(sc, TWSI_CONTROL_IFLG); + else + twsi_control_clear(sc, TWSI_CONTROL_IFLG); DELAY(1000); } @@ -667,13 +671,11 @@ twsi_intr(void *arg) } debugf(sc->dev, "Refresh reg_control\n"); - /* -* Fix silicon bug on > Allwinner A20 by doing a read and writing -* again to the control register + /* +* Newer Allwinner chips clear IFLG after writing 1 to it. */ - status = TWSI_READ(sc, sc->reg_status); - TWSI_WRITE(sc, sc->reg_control, - sc->control_val | TWSI_CONTROL_IFLG); + TWSI_WRITE(sc, sc->reg_control, sc->control_val | + (sc->iflag_w1c ? TWSI_CONTROL_IFLG : 0)); debugf(sc->dev, "Done with interrupts\n\n"); if (transfer_done == 1) { Modified: stable/12/sys/dev/iicbus/twsi/twsi.h == --- stable/12/sys/dev/iicbus/twsi/twsi.hMon Oct 12 11:34:09 2020 (r366645) +++ stable/12/sys/dev/iicbus/twsi/twsi.hMon Oct 12 11:40:43 2020 (r366646) @@ -66,6 +66,7 @@ struct twsi_softc { int error; uint32_tcontrol_val; boolneed_ack; + booliflag_w1c; bus_size_t reg_data; bus_size_t reg_slave_addr; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366645 - stable/12/sys/dev/iicbus/twsi
Author: avg Date: Mon Oct 12 11:34:09 2020 New Revision: 366645 URL: https://svnweb.freebsd.org/changeset/base/366645 Log: MFC r363021 by manu: twsi: Fix for > Allwinner A20 Every revision of twsi after the A20 have a bug where we need to write again the control register after each interrupts. We also need to add some delay before writing to this register, a simple read of the same register does the job so do that. Also fix the case when we have finish sending all the bytes, it only worked for 1 byte transfer (the same kind that we do for talking to the PMIC on A20 boards). While here add more debug messages and rework some of them. This was tested by talking to a AT23C32 eeprom and a DS3231 RTC from an H3 and A20 board. PR: 247576 Modified: stable/12/sys/dev/iicbus/twsi/twsi.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/twsi/twsi.c == --- stable/12/sys/dev/iicbus/twsi/twsi.cMon Oct 12 11:27:08 2020 (r366644) +++ stable/12/sys/dev/iicbus/twsi/twsi.cMon Oct 12 11:34:09 2020 (r366645) @@ -499,6 +499,10 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint sc->msg_idx = 0; sc->transfer = 1; +#ifdef TWSI_DEBUG + for (int i = 0; i < nmsgs; i++) + debugf(sc->dev, "msg %d is %d bytes long\n", i, msgs[i].len); +#endif /* Send start and re-enable interrupts */ sc->control_val = TWSI_CONTROL_TWSIEN | TWSI_CONTROL_INTEN | TWSI_CONTROL_ACK; @@ -535,13 +539,13 @@ twsi_intr(void *arg) debugf(sc->dev, "Got interrupt Current msg=%x\n", sc->msg_idx); status = TWSI_READ(sc, sc->reg_status); - debugf(sc->dev, "initial status=%x\n", status); + debugf(sc->dev, "reg control=%x\n", TWSI_READ(sc, sc->reg_control)); switch (status) { case TWSI_STATUS_START: case TWSI_STATUS_RPTD_START: /* Transmit the address */ - debugf(sc->dev, "Send the address\n"); + debugf(sc->dev, "Send the address (%x)", sc->msgs[sc->msg_idx].slave); if (sc->msgs[sc->msg_idx].flags & IIC_M_RD) TWSI_WRITE(sc, sc->reg_data, @@ -555,8 +559,10 @@ twsi_intr(void *arg) case TWSI_STATUS_ADDR_W_ACK: debugf(sc->dev, "Ack received after transmitting the address (write)\n"); /* Directly send the first byte */ - sc->sent_bytes = 0; - debugf(sc->dev, "Sending byte 0 = %x\n", sc->msgs[sc->msg_idx].buf[0]); + sc->sent_bytes = 1; + debugf(sc->dev, "Sending byte 0 (of %d) = %x\n", + sc->msgs[sc->msg_idx].len, + sc->msgs[sc->msg_idx].buf[0]); TWSI_WRITE(sc, sc->reg_data, sc->msgs[sc->msg_idx].buf[0]); TWSI_WRITE(sc, sc->reg_control, sc->control_val); @@ -580,7 +586,7 @@ twsi_intr(void *arg) case TWSI_STATUS_DATA_WR_ACK: debugf(sc->dev, "Ack received after transmitting data\n"); - if (sc->sent_bytes++ == (sc->msgs[sc->msg_idx].len - 1)) { + if (sc->sent_bytes == sc->msgs[sc->msg_idx].len) { debugf(sc->dev, "Done sending all the bytes for msg %d\n", sc->msg_idx); /* Send stop, no interrupts on stop */ if (!(sc->msgs[sc->msg_idx].flags & IIC_M_NOSTOP)) { @@ -595,30 +601,40 @@ twsi_intr(void *arg) if (sc->msg_idx == sc->nmsgs) { debugf(sc->dev, "transfer_done=1\n"); transfer_done = 1; + sc->error = 0; + } else { + debugf(sc->dev, "Send repeated start\n"); + TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START); } } else { - debugf(sc->dev, "Sending byte %d = %x\n", + debugf(sc->dev, "Sending byte %d (of %d) = %x\n", sc->sent_bytes, + sc->msgs[sc->msg_idx].len, sc->msgs[sc->msg_idx].buf[sc->sent_bytes]); TWSI_WRITE(sc, sc->reg_data, sc->msgs[sc->msg_idx].buf[sc->sent_bytes]); TWSI_WRITE(sc, sc->reg_control, sc->control_val); + sc->sent_bytes++; } break; case TWSI_STATUS_DATA_RD_ACK: debugf(sc->dev, "Ack received after receiving data\n"); - debugf(sc->dev, "msg_len=%d recv_bytes=%d\n", sc->msgs[sc->msg_idx].len, sc->recv_bytes); sc->msgs[sc->msg_idx].buf[sc->recv_bytes++] = TWSI_READ(sc,
svn commit: r366643 - stable/12/usr.sbin/pwm
Author: avg Date: Mon Oct 12 11:04:52 2020 New Revision: 366643 URL: https://svnweb.freebsd.org/changeset/base/366643 Log: MFC r366144: pwm(8): fix potential duty overflow, use unsigneds for period and duty Modified: stable/12/usr.sbin/pwm/pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/pwm/pwm.c == --- stable/12/usr.sbin/pwm/pwm.cMon Oct 12 11:03:26 2020 (r366642) +++ stable/12/usr.sbin/pwm/pwm.cMon Oct 12 11:04:52 2020 (r366643) @@ -76,7 +76,7 @@ main(int argc, char *argv[]) { struct pwm_state state; int fd; - int period, duty; + u_int period, duty; int action, ch; cap_rights_t right_ioctl; const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE}; @@ -109,16 +109,16 @@ main(int argc, char *argv[]) if (action & PWM_SHOW_CONFIG) usage(); action |= PWM_PERIOD; - period = strtol(optarg, NULL, 10); + period = strtoul(optarg, NULL, 10); break; case 'd': if (action & PWM_SHOW_CONFIG) usage(); action |= PWM_DUTY; - duty = strtol(optarg, , 10); + duty = strtoul(optarg, , 10); if (*percent == '%') { - if (duty < 0 || duty > 100) { - fprintf(stderr, + if (duty > 100) { + fprintf(stderr, "Invalid duty percentage\n"); usage(); } @@ -186,11 +186,11 @@ main(int argc, char *argv[]) state.period = period; if (action & PWM_DUTY) { if (*percent != '\0') - state.duty = state.period * duty / 100; + state.duty = (uint64_t)state.period * duty / 100; else state.duty = duty; } - + if (ioctl(fd, PWMSETSTATE, ) == -1) { fprintf(stderr, "Cannot configure the pwm controller\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366642 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Oct 12 11:03:26 2020 New Revision: 366642 URL: https://svnweb.freebsd.org/changeset/base/366642 Log: MFC r366142: aw_pwm: add a check and some comments related to long periods The hardware supports periods as long as 196 seconds[*] when using the maximal prescaling of 72000 and maximum cycle count of 2^16. But the code becomes incorrect when the period length approaches 1 second. That's because of things like NS_PER_SEC / period. [*] At the same time I must note that the KPI provides for maximum period of about 4 seconds (2^32 nanoseconds). Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 11:01:54 2020 (r366641) +++ stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 11:03:26 2020 (r366642) @@ -259,6 +259,20 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i period_freq = NS_PER_SEC / period; if (period_freq > AW_PWM_MAX_FREQ) return (EINVAL); + + /* +* FIXME. The hardware is capable of sub-Hz frequencies, that is, +* periods longer than a second. But the current code cannot deal +* with those properly. +*/ + if (period_freq == 0) + return (EINVAL); + + /* +* FIXME. There is a great loss of precision when the period and the +* duty are near 1 second. In some cases period_freq and duty_freq can +* be equal even if the period and the duty are significantly different. +*/ duty_freq = NS_PER_SEC / duty; if (duty_freq < period_freq) { device_printf(sc->dev, "duty < period\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366641 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Oct 12 11:01:54 2020 New Revision: 366641 URL: https://svnweb.freebsd.org/changeset/base/366641 Log: MFC r366141: aw_pwm: ensure sane configuration, just in case Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 10:57:59 2020 (r366640) +++ stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 11:01:54 2020 (r366641) @@ -294,6 +294,13 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i /* Write the prescalar */ reg &= ~AW_PWM_CTRL_PRESCALE_MASK; reg |= prescaler; + + reg &= ~AW_PWM_CTRL_MODE_MASK; + reg |= AW_PWM_CTRL_CYCLE_MODE; + + reg &= ~AW_PWM_CTRL_PULSE_START; + reg &= ~AW_PWM_CTRL_CLK_BYPASS; + AW_PWM_WRITE(sc, AW_PWM_CTRL, reg); /* Write the total/active cycles */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366640 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Oct 12 10:57:59 2020 New Revision: 366640 URL: https://svnweb.freebsd.org/changeset/base/366640 Log: MFC r366139: aw_pwm: fix selection of the prescaler Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 10:55:03 2020 (r366639) +++ stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 10:57:59 2020 (r366640) @@ -274,7 +274,7 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i for (i = 0; i < nitems(aw_pwm_clk_prescaler); i++) { if (aw_pwm_clk_prescaler[i] == 0) continue; - div = (AW_PWM_MAX_FREQ * aw_pwm_clk_prescaler[i]) / period_freq; + div = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i] / period_freq; if ((div - 1) < AW_PWM_PERIOD_TOTAL_MASK ) { prescaler = i; clk_rate = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i]; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366639 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Oct 12 10:55:03 2020 New Revision: 366639 URL: https://svnweb.freebsd.org/changeset/base/366639 Log: MFC r366137: aw_pwm: trivially add H3 support Modified: stable/12/sys/arm/allwinner/aw_pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_pwm.c == --- stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 10:53:35 2020 (r366638) +++ stable/12/sys/arm/allwinner/aw_pwm.cMon Oct 12 10:55:03 2020 (r366639) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); static struct ofw_compat_data compat_data[] = { { "allwinner,sun5i-a13-pwm",1 }, + { "allwinner,sun8i-h3-pwm", 1 }, { NULL, 0 } }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366638 - stable/12/sys/dev/usb/controller
Author: avg Date: Mon Oct 12 10:53:35 2020 New Revision: 366638 URL: https://svnweb.freebsd.org/changeset/base/366638 Log: MFC r365400: musb/allwinner: apply register filter in awusbdrd_bs_r_2() as well Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c == --- stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 12 10:51:34 2020(r366637) +++ stable/12/sys/dev/usb/controller/musb_otg_allwinner.c Mon Oct 12 10:53:35 2020(r366638) @@ -259,6 +259,8 @@ awusbdrd_bs_r_2(awusb_bs_tag t, bus_space_handle_t h, { const struct bus_space *bs = t; + if (awusbdrd_filt(o) != 0) + return (0); return bus_space_read_2(bs_parent_space(bs), h, awusbdrd_reg(o)); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366637 - in stable/12/sys: arm/allwinner arm64/conf conf dev/usb/controller
Author: avg Date: Mon Oct 12 10:51:34 2020 New Revision: 366637 URL: https://svnweb.freebsd.org/changeset/base/366637 Log: MFC r365398,r365399: Allwinner USB DRD support (musb_otg) Allwinner USB DRD is based on the Mentor USB OTG controller, with a different register layout and a few missing registers. The code is by Andrew Turner (andrew). Added: stable/12/sys/dev/usb/controller/musb_otg_allwinner.c - copied unchanged from r365399, head/sys/dev/usb/controller/musb_otg_allwinner.c Modified: stable/12/sys/arm/allwinner/aw_usbphy.c stable/12/sys/arm/allwinner/files.allwinner stable/12/sys/arm64/conf/GENERIC stable/12/sys/conf/files.arm64 Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_usbphy.c == --- stable/12/sys/arm/allwinner/aw_usbphy.c Mon Oct 12 10:42:33 2020 (r366636) +++ stable/12/sys/arm/allwinner/aw_usbphy.c Mon Oct 12 10:51:34 2020 (r366637) @@ -161,6 +161,18 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #defineCLR4(res, o, m) WR4(res, o, RD4(res, o) & ~(m)) #defineSET4(res, o, m) WR4(res, o, RD4(res, o) | (m)) +#definePHY_CSR 0x00 +#define ID_PULLUP_EN (1 << 17) +#define DPDM_PULLUP_EN (1 << 16) +#define FORCE_ID (0x3 << 14) +#define FORCE_ID_SHIFT 14 +#define FORCE_ID_LOW 2 +#define FORCE_VBUS_VALID (0x3 << 12) +#define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_HIGH 3 +#define VBUS_CHANGE_DET(1 << 6) +#define ID_CHANGE_DET (1 << 5) +#define DPDM_CHANGE_DET(1 << 4) #defineOTG_PHY_CFG 0x20 #define OTG_PHY_ROUTE_OTG (1 << 0) #definePMU_IRQ_ENABLE 0x00 @@ -206,6 +218,7 @@ awusbphy_init(device_t dev) struct awusbphy_softc *sc; phandle_t node; char pname[20]; + uint32_t val; int error, off, rid; regulator_t reg; hwreset_t rst; @@ -280,6 +293,16 @@ awusbphy_init(device_t dev) return (ENXIO); } } + + /* Enable OTG PHY for host mode */ + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_ID; + val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); + val &= ~FORCE_VBUS_VALID; + val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); + bus_write_4(sc->phy_ctrl, PHY_CSR, val); return (0); } Modified: stable/12/sys/arm/allwinner/files.allwinner == --- stable/12/sys/arm/allwinner/files.allwinner Mon Oct 12 10:42:33 2020 (r366636) +++ stable/12/sys/arm/allwinner/files.allwinner Mon Oct 12 10:51:34 2020 (r366637) @@ -27,6 +27,7 @@ dev/usb/controller/generic_ohci.c optionalohci dev/usb/controller/generic_usb_if.moptionalohci dev/usb/controller/generic_ehci.c optionalehci dev/usb/controller/generic_ehci_fdt.c optionalehci +dev/usb/controller/musb_otg_allwinner.coptionalmusb arm/allwinner/aw_sid.c optionalaw_sid arm/allwinner/aw_thermal.c optionalaw_thermal arm/allwinner/aw_cir.c optionalaw_cir evdev Modified: stable/12/sys/arm64/conf/GENERIC == --- stable/12/sys/arm64/conf/GENERICMon Oct 12 10:42:33 2020 (r366636) +++ stable/12/sys/arm64/conf/GENERICMon Oct 12 10:51:34 2020 (r366637) @@ -185,6 +185,7 @@ device aw_usbphy # Allwinner USB PHY device rk_usb2phy # Rockchip USB2PHY device rk_typec_phy# Rockchip TypeC PHY device dwcotg # DWC OTG controller +device musb# Mentor Graphics USB OTG controller device ohci# OHCI USB interface device ehci# EHCI USB interface (USB 2.0) device ehci_mv # Marvell EHCI USB interface Modified: stable/12/sys/conf/files.arm64 == --- stable/12/sys/conf/files.arm64 Mon Oct 12 10:42:33 2020 (r366636) +++ stable/12/sys/conf/files.arm64 Mon Oct 12 10:51:34 2020 (r366637) @@ -300,6 +300,7 @@ dev/usb/controller/generic_ehci_acpi.c optional ehci a dev/usb/controller/generic_ehci_fdt.c optional ehci fdt dev/usb/controller/generic_ohci.c optional ohci fdt dev/usb/controller/generic_usb_if.m optional ohci fdt +dev/usb/controller/musb_otg_allwinner.c
svn commit: r366359 - stable/12/usr.sbin/pwm
Author: avg Date: Fri Oct 2 12:49:27 2020 New Revision: 366359 URL: https://svnweb.freebsd.org/changeset/base/366359 Log: MFC r366143: pwm(8): do not exit with failure after successfully reading configuration Modified: stable/12/usr.sbin/pwm/pwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/pwm/pwm.c == --- stable/12/usr.sbin/pwm/pwm.cFri Oct 2 12:48:07 2020 (r366358) +++ stable/12/usr.sbin/pwm/pwm.cFri Oct 2 12:49:27 2020 (r366359) @@ -177,7 +177,6 @@ main(int argc, char *argv[]) state.period, state.duty, state.enable); - goto fail; } else { if (action & PWM_ENABLE) state.enable = true; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366358 - stable/12/sys/dev/iicbus/twsi
Author: avg Date: Fri Oct 2 12:48:07 2020 New Revision: 366358 URL: https://svnweb.freebsd.org/changeset/base/366358 Log: MFC r365396: twsi: use tsleep instead of pause for better responsiveness Modified: stable/12/sys/dev/iicbus/twsi/twsi.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/twsi/twsi.c == --- stable/12/sys/dev/iicbus/twsi/twsi.cFri Oct 2 12:46:28 2020 (r366357) +++ stable/12/sys/dev/iicbus/twsi/twsi.cFri Oct 2 12:48:07 2020 (r366358) @@ -506,7 +506,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint sc->control_val &= ~TWSI_CONTROL_ACK; TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START); while (sc->error == 0 && sc->transfer != 0) { - pause_sbt("twsi", SBT_1MS * 30, SBT_1MS, 0); + tsleep_sbt(sc, 0, "twsi", SBT_1MS * 30, SBT_1MS, 0); } debugf(sc->dev, "pause finish\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366357 - stable/12/sys/dev/iicbus
Author: avg Date: Fri Oct 2 12:46:28 2020 New Revision: 366357 URL: https://svnweb.freebsd.org/changeset/base/366357 Log: MFC r365290: move definition of hw.i2c sysctl node from iicbb to iicbus Modified: stable/12/sys/dev/iicbus/iicbb.c stable/12/sys/dev/iicbus/iicbus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/iicbb.c == --- stable/12/sys/dev/iicbus/iicbb.cFri Oct 2 10:03:17 2020 (r366356) +++ stable/12/sys/dev/iicbus/iicbb.cFri Oct 2 12:46:28 2020 (r366357) @@ -228,7 +228,7 @@ iicbb_print_child(device_t bus, device_t dev) #ifdef IICBB_DEBUG static int i2c_debug = 0; -static SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c debug"); +SYSCTL_DECL(_hw_i2c); SYSCTL_INT(_hw_i2c, OID_AUTO, iicbb_debug, CTLFLAG_RWTUN, _debug, 0, "Enable i2c bit-banging driver debug"); Modified: stable/12/sys/dev/iicbus/iicbus.c == --- stable/12/sys/dev/iicbus/iicbus.c Fri Oct 2 10:03:17 2020 (r366356) +++ stable/12/sys/dev/iicbus/iicbus.c Fri Oct 2 12:46:28 2020 (r366357) @@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$"); /* See comments below for why auto-scanning is a bad idea. */ #define SCAN_IICBUS 0 +SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c controls"); + static int iicbus_probe(device_t dev) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366144 - head/usr.sbin/pwm
Author: avg Date: Fri Sep 25 07:55:08 2020 New Revision: 366144 URL: https://svnweb.freebsd.org/changeset/base/366144 Log: pwm(8): fix potential duty overflow, use unsigneds for period and duty For a long period value and the duty specified as a percentage, there could be an overflow. Using unsigned integers aligns the code with struct pwm_state and allows to safely use periods up to 4 seconds where supported by drivers. MFC after:2 weeks Modified: head/usr.sbin/pwm/pwm.c Modified: head/usr.sbin/pwm/pwm.c == --- head/usr.sbin/pwm/pwm.c Fri Sep 25 07:54:38 2020(r366143) +++ head/usr.sbin/pwm/pwm.c Fri Sep 25 07:55:08 2020(r366144) @@ -75,7 +75,7 @@ main(int argc, char *argv[]) { struct pwm_state state; int fd; - int period, duty; + u_int period, duty; int action, ch; cap_rights_t right_ioctl; const unsigned long pwm_ioctls[] = {PWMGETSTATE, PWMSETSTATE}; @@ -108,16 +108,16 @@ main(int argc, char *argv[]) if (action & PWM_SHOW_CONFIG) usage(); action |= PWM_PERIOD; - period = strtol(optarg, NULL, 10); + period = strtoul(optarg, NULL, 10); break; case 'd': if (action & PWM_SHOW_CONFIG) usage(); action |= PWM_DUTY; - duty = strtol(optarg, , 10); + duty = strtoul(optarg, , 10); if (*percent == '%') { - if (duty < 0 || duty > 100) { - fprintf(stderr, + if (duty > 100) { + fprintf(stderr, "Invalid duty percentage\n"); usage(); } @@ -185,11 +185,11 @@ main(int argc, char *argv[]) state.period = period; if (action & PWM_DUTY) { if (*percent != '\0') - state.duty = state.period * duty / 100; + state.duty = (uint64_t)state.period * duty / 100; else state.duty = duty; } - + if (ioctl(fd, PWMSETSTATE, ) == -1) { fprintf(stderr, "Cannot configure the pwm controller\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366143 - head/usr.sbin/pwm
Author: avg Date: Fri Sep 25 07:54:38 2020 New Revision: 366143 URL: https://svnweb.freebsd.org/changeset/base/366143 Log: pwm(8): do not exit with failure after successfully reading configuration MFC after:1 week Modified: head/usr.sbin/pwm/pwm.c Modified: head/usr.sbin/pwm/pwm.c == --- head/usr.sbin/pwm/pwm.c Fri Sep 25 07:41:51 2020(r366142) +++ head/usr.sbin/pwm/pwm.c Fri Sep 25 07:54:38 2020(r366143) @@ -176,7 +176,6 @@ main(int argc, char *argv[]) state.period, state.duty, state.enable); - goto fail; } else { if (action & PWM_ENABLE) state.enable = true; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r366142 - head/sys/arm/allwinner
On 25/09/2020 10:41, Andriy Gapon wrote: > [*] At the same time I must note that the KPI provides for maximum > period of about 4 seconds (2^32 nanoseconds). Also, the KPI does not provide a way to invert active level of which some controllers are capable. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366141 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:40:56 2020 New Revision: 366141 URL: https://svnweb.freebsd.org/changeset/base/366141 Log: aw_pwm: ensure sane configuration, just in case Make sure that the hardware is configured to cycle mode and that the bypass is disabled. MFC after:2 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:26 2020 (r366140) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:56 2020 (r366141) @@ -290,6 +290,13 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i /* Write the prescalar */ reg &= ~AW_PWM_CTRL_PRESCALE_MASK; reg |= prescaler; + + reg &= ~AW_PWM_CTRL_MODE_MASK; + reg |= AW_PWM_CTRL_CYCLE_MODE; + + reg &= ~AW_PWM_CTRL_PULSE_START; + reg &= ~AW_PWM_CTRL_CLK_BYPASS; + AW_PWM_WRITE(sc, AW_PWM_CTRL, reg); /* Write the total/active cycles */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366142 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:41:51 2020 New Revision: 366142 URL: https://svnweb.freebsd.org/changeset/base/366142 Log: aw_pwm: add a check and some comments related to long periods The hardware supports periods as long as 196 seconds[*] when using the maximal prescaling of 72000 and maximum cycle count of 2^16. But the code becomes incorrect when the period length approaches 1 second. That's because of things like NS_PER_SEC / period. [*] At the same time I must note that the KPI provides for maximum period of about 4 seconds (2^32 nanoseconds). MFC after:2 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:56 2020 (r366141) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:41:51 2020 (r366142) @@ -259,6 +259,20 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i period_freq = NS_PER_SEC / period; if (period_freq > AW_PWM_MAX_FREQ) return (EINVAL); + + /* +* FIXME. The hardware is capable of sub-Hz frequencies, that is, +* periods longer than a second. But the current code cannot deal +* with those properly. +*/ + if (period_freq == 0) + return (EINVAL); + + /* +* FIXME. There is a great loss of precision when the period and the +* duty are near 1 second. In some cases period_freq and duty_freq can +* be equal even if the period and the duty are significantly different. +*/ duty_freq = NS_PER_SEC / duty; if (duty_freq < period_freq) { device_printf(sc->dev, "duty < period\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366139 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:40:02 2020 New Revision: 366139 URL: https://svnweb.freebsd.org/changeset/base/366139 Log: aw_pwm: fix selection of the prescaler Prescaling divides the frequency, not multiplies it. MFC after:2 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:39:41 2020 (r366138) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:02 2020 (r366139) @@ -274,7 +274,7 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i for (i = 0; i < nitems(aw_pwm_clk_prescaler); i++) { if (aw_pwm_clk_prescaler[i] == 0) continue; - div = (AW_PWM_MAX_FREQ * aw_pwm_clk_prescaler[i]) / period_freq; + div = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i] / period_freq; if ((div - 1) < AW_PWM_PERIOD_TOTAL_MASK ) { prescaler = i; clk_rate = AW_PWM_MAX_FREQ / aw_pwm_clk_prescaler[i]; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366140 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:40:26 2020 New Revision: 366140 URL: https://svnweb.freebsd.org/changeset/base/366140 Log: aw_pwm: fix programming of the period The programmed value is biased by one: 0 means 1 cycle, 1 means 2 cycles, etc. MFC after:3 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:02 2020 (r366139) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:40:26 2020 (r366140) @@ -293,7 +293,7 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i AW_PWM_WRITE(sc, AW_PWM_CTRL, reg); /* Write the total/active cycles */ - reg = ((clk_rate / period_freq) << AW_PWM_PERIOD_TOTAL_SHIFT) | + reg = ((clk_rate / period_freq - 1) << AW_PWM_PERIOD_TOTAL_SHIFT) | ((clk_rate / duty_freq) << AW_PWM_PERIOD_ACTIVE_SHIFT); AW_PWM_WRITE(sc, AW_PWM_PERIOD, reg); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366137 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:39:14 2020 New Revision: 366137 URL: https://svnweb.freebsd.org/changeset/base/366137 Log: aw_pwm: trivially add H3 support MFC after:2 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 04:16:28 2020 (r366136) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:39:14 2020 (r366137) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); static struct ofw_compat_data compat_data[] = { { "allwinner,sun5i-a13-pwm",1 }, + { "allwinner,sun8i-h3-pwm", 1 }, { NULL, 0 } }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r366138 - head/sys/arm/allwinner
Author: avg Date: Fri Sep 25 07:39:41 2020 New Revision: 366138 URL: https://svnweb.freebsd.org/changeset/base/366138 Log: aw_pwm: remove the busy bit check The bit seems to always be set on my hardware, H3. However, programming the hardware seems to work just fine. MFC after:3 weeks Modified: head/sys/arm/allwinner/aw_pwm.c Modified: head/sys/arm/allwinner/aw_pwm.c == --- head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:39:14 2020 (r366137) +++ head/sys/arm/allwinner/aw_pwm.c Fri Sep 25 07:39:41 2020 (r366138) @@ -286,10 +286,6 @@ aw_pwm_channel_config(device_t dev, u_int channel, u_i } reg = AW_PWM_READ(sc, AW_PWM_CTRL); - if (reg & AW_PWM_CTRL_PERIOD_BUSY) { - device_printf(sc->dev, "pwm busy\n"); - return (EBUSY); - } /* Write the prescalar */ reg &= ~AW_PWM_CTRL_PRESCALE_MASK; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365984 - head/usr.bin/calendar/calendars
On 22/09/2020 23:40, Scott Long wrote: > Second, there’s a vibe in parts of this thread that are passive-aggressively > disrespectful to Greg. I encourage those who might feel some personal > frustration towards Greg to talk to him directly. The Core team can help with > that communication if needed. Otherwise, it’s not not appropriate and not > welcome on the mailing lists. If you don’t feel it’s important enough to > resolve in a professional manner, then please keep it to yourself. That was me. I apologized to Greg directly. And I want to do the same in public. It was inappropriate. I apologize. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365984 - head/usr.bin/calendar/calendars
On 22/09/2020 06:06, Conrad Meyer wrote: > Big ol plus one from me. > > On Mon, Sep 21, 2020 at 4:16 PM Cy Schubert wrote: >> >> In message <202009212255.08lmtpsp078...@repo.freebsd.org>, Greg Lehey >> writes: >>> Author: grog >>> Date: Mon Sep 21 22:55:51 2020 >>> New Revision: 365984 >>> URL: https://svnweb.freebsd.org/changeset/base/365984 >>> >>> Log: >>> Remove claim that Allied Forces created "West Germany" in 1953. I can >>> find no historic substantiation for such a claim. The Federal >>> Republic of Germany was created by Germans on 23 May 1949, as also >>> noted in this file. >>> >>> Modified: >>> head/usr.bin/calendar/calendars/calendar.history >>> >>> Modified: head/usr.bin/calendar/calendars/calendar.history >>> = >>> = >>> --- head/usr.bin/calendar/calendars/calendar.history Mon Sep 21 22:52:57 >>> 202 >>> 0 (r365983) >>> +++ head/usr.bin/calendar/calendars/calendar.history Mon Sep 21 22:55:51 >>> 202 >>> 0 (r365984) >>> @@ -521,7 +521,6 @@ >>> 09/20Magellan leaves Spain on the first Round the World passage, >>> 151 >>> 9 >>> 09/20The Roxy Theater opens in Hollywood, 1973 >>> 09/21J. R. R. Tolkien's The Hobbit is published, 1937 >>> -09/22Allied forces form the independent nation West Germany, 1953 >>> 09/22US President Lincoln issues the Emancipation Proclamation, >>> 1862 >>> 09/22Special prosecutor Leon Jeworski subpoenas US President Nixon, >>> 1974 >>> 09/22The first Soviet atomic bomb explodes, 1949 >>> >> >> Does this file still need to be in FreeBSD? It may have been a novelty back >> in the day but IMO calendar.history has nothing to do with BSD, computers >> or anything else of interest to FreeBSD. At the very least this file should >> be moved to ports or better yet, removed entirely. I simply don't see the >> point of it being in the tree and distributed with an O/S, any O/S. I think that the only reason for this file's existence in the source tree is for Greg's staving off the commit bit reaper. No offense meant. P.S. And occasional flame wars, it seems. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365943 - head/sys/arm/allwinner
Author: avg Date: Mon Sep 21 10:02:11 2020 New Revision: 365943 URL: https://svnweb.freebsd.org/changeset/base/365943 Log: aw_usbphy: add support for device mode operation OTG mode is not supported still. It's easy to do it as a one-off detection, but the proper support requires continuous monitoring and communicating the current state to the USB layer. Also, fix phy0_route setting for H3. Remove duplicate register definitions. Tested on Orange Pi PC Plus with dr_mode="peripheral" using hw.usb.template=3 umodem_load="YES" Reviewed by: manu MFC after:5 weeks Differential Revision: https://reviews.freebsd.org/D26348 Modified: head/sys/arm/allwinner/aw_usbphy.c Modified: head/sys/arm/allwinner/aw_usbphy.c == --- head/sys/arm/allwinner/aw_usbphy.c Mon Sep 21 09:50:57 2020 (r365942) +++ head/sys/arm/allwinner/aw_usbphy.c Mon Sep 21 10:02:11 2020 (r365943) @@ -102,7 +102,7 @@ static const struct aw_usbphy_conf h3_usbphy_conf = { .num_phys = 4, .phy_type = AWUSBPHY_TYPE_H3, .pmu_unk1 = true, - .phy0_route = false, + .phy0_route = true, }; static const struct aw_usbphy_conf a64_usbphy_conf = { @@ -175,8 +175,10 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define FORCE_ID (0x3 << 14) #define FORCE_ID_SHIFT 14 #define FORCE_ID_LOW 2 +#define FORCE_ID_HIGH 3 #define FORCE_VBUS_VALID (0x3 << 12) #define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_LOW 2 #define FORCE_VBUS_VALID_HIGH 3 #define VBUS_CHANGE_DET(1 << 6) #define ID_CHANGE_DET (1 << 5) @@ -190,18 +192,6 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define PMU_ULPI_BYPASS(1 << 0) #definePMU_UNK_H3 0x10 #define PMU_UNK_H3_CLR 0x2 -#definePHY_CSR 0x00 -#define ID_PULLUP_EN (1 << 17) -#define DPDM_PULLUP_EN (1 << 16) -#define FORCE_ID (0x3 << 14) -#define FORCE_ID_SHIFT 14 -#define FORCE_ID_LOW 2 -#define FORCE_VBUS_VALID (0x3 << 12) -#define FORCE_VBUS_VALID_SHIFT 12 -#define FORCE_VBUS_VALID_HIGH 3 -#define VBUS_CHANGE_DET(1 << 6) -#define ID_CHANGE_DET (1 << 5) -#define DPDM_CHANGE_DET(1 << 4) static void awusbphy_configure(device_t dev, int phyno) @@ -335,7 +325,12 @@ awusbphy_vbus_detect(device_t dev, int *val) return (0); } - *val = 0; + /* TODO check vbus_power-supply. */ + + /* +* If there is no way to detect, assume present. +*/ + *val = 1; return (0); } @@ -369,10 +364,11 @@ awusbphy_phy_enable(struct phynode *phynode, bool enab if (error) goto out; - if (vbus_det == 1) { + /* TODO check vbus_power-supply as well. */ + if (sc->vbus_det_valid && vbus_det == 1) { if (bootverbose) - device_printf(dev, "External VBUS detected, not enabling the regulator\n"); - + device_printf(dev, "External VBUS detected, " + "not enabling the regulator\n"); return (0); } } @@ -426,36 +422,40 @@ awusbphy_set_mode(struct phynode *phynode, int mode) return (0); } + if (sc->mode == mode) + return (0); + if (mode == PHY_USB_MODE_OTG) /* TODO */ + return (EOPNOTSUPP); + + error = awusbphy_vbus_detect(dev, _det); + if (error != 0) + return (error); + + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_VBUS_VALID; + val |= (vbus_det ? FORCE_VBUS_VALID_HIGH : FORCE_VBUS_VALID_LOW) << + FORCE_VBUS_VALID_SHIFT; + val &= ~FORCE_ID; + switch (mode) { case PHY_USB_MODE_HOST: - val = bus_read_4(sc->phy_ctrl, PHY_CSR); - val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); - val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); - val &= ~FORCE_ID; val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); - val &= ~FORCE_VBUS_VALID; - val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); - bus_write_4(sc->phy_ctrl, PHY_CSR, val); - if (sc->phy_conf->phy0_route == true) { - error = awusbphy_vbus_detect(dev, _det); - if (error) -
svn commit: r365942 - in stable/12/sys: arm/allwinner/clkng dev/extres/clk
Author: avg Date: Mon Sep 21 09:50:57 2020 New Revision: 365942 URL: https://svnweb.freebsd.org/changeset/base/365942 Log: MFC r363887 (by manu), r365395: allwinner: clk: Fix nm clock calculation r363887: Use the right factor when finding the best frequency and compare the absolute value of the result. Submitted by: kibab r365395: aw_clk_nm: fix incorrect use of abs() abs() takes a (signed) int as input. Instead, it was used with unsigned 64-bit integers. So, add and use a new helper function to calculate a difference between two uint64_t-s. Modified: stable/12/sys/arm/allwinner/clkng/aw_clk_nm.c stable/12/sys/dev/extres/clk/clk.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/clkng/aw_clk_nm.c == --- stable/12/sys/arm/allwinner/clkng/aw_clk_nm.c Mon Sep 21 09:03:42 2020(r365941) +++ stable/12/sys/arm/allwinner/clkng/aw_clk_nm.c Mon Sep 21 09:50:57 2020(r365942) @@ -152,9 +152,10 @@ aw_clk_nm_find_best(struct aw_clk_nm_sc *sc, uint64_t min_n = aw_clk_factor_get_min(>n); for (m = min_m; m <= max_m; ) { - for (n = min_m; n <= max_n; ) { + for (n = min_n; n <= max_n; ) { cur = fparent / n / m; - if (abs(*fout - cur) < abs(*fout - best)) { + if (clk_freq_diff(*fout, cur) < + clk_freq_diff(*fout, best)) { best = cur; *factor_n = n; *factor_m = m; @@ -197,7 +198,8 @@ aw_clk_nm_set_freq(struct clknode *clk, uint64_t fpare clknode_get_freq(p_clk, ); cur = aw_clk_nm_find_best(sc, fparent, fout, , ); - if ((*fout - cur) < (*fout - best)) { + if (clk_freq_diff(*fout, cur) < + clk_freq_diff(*fout, best)) { best = cur; best_parent = p_idx; best_n = n; Modified: stable/12/sys/dev/extres/clk/clk.h == --- stable/12/sys/dev/extres/clk/clk.h Mon Sep 21 09:03:42 2020 (r365941) +++ stable/12/sys/dev/extres/clk/clk.h Mon Sep 21 09:50:57 2020 (r365942) @@ -135,6 +135,12 @@ int clk_get_parent(clk_t clk, clk_t *parent); int clk_set_parent_by_clk(clk_t clk, clk_t parent); const char *clk_get_name(clk_t clk); +static inline uint64_t +clk_freq_diff(uint64_t x, uint64_t y) +{ + return (x >= y ? x - y : y - x); +} + #ifdef FDT int clk_set_assigned(device_t dev, phandle_t node); int clk_get_by_ofw_index(device_t dev, phandle_t node, int idx, clk_t *clk); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365742 - stable/12/sys/cam/mmc
Author: avg Date: Tue Sep 15 05:51:03 2020 New Revision: 365742 URL: https://svnweb.freebsd.org/changeset/base/365742 Log: MFC r365447: mmc_da: universally use uint8_t for the partition index Modified: stable/12/sys/cam/mmc/mmc_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/mmc/mmc_da.c == --- stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 05:48:55 2020 (r365741) +++ stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 05:51:03 2020 (r365742) @@ -170,7 +170,6 @@ static void sdda_start_init(void *context, union ccb * static void sdda_start_init_task(void *context, int pending); static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *start_ccb); static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb); -static void sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part); static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca); static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return MMC_SECTOR_SIZE;} @@ -1658,10 +1657,13 @@ sdda_process_mmc_partitions(struct cam_periph *periph, * This function cannot fail, instead check switch errors in sddadone(). */ static void -sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part) { +sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, +uint8_t part) +{ struct sdda_softc *sc = (struct sdda_softc *)periph->softc; uint8_t value; + KASSERT(part < MMC_PART_MAX, ("%s: invalid partition index", __func__)); sc->part_requested = part; value = (sc->raw_ext_csd[EXT_CSD_PART_CONFIG] & @@ -1685,7 +1687,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ struct sdda_softc *softc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct mmc_params *mmcp = >path->device->mmc_ident_data; - int part_index; + uint8_t part_index; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddastart\n")); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365741 - stable/12/sys/cam/mmc
Author: avg Date: Tue Sep 15 05:48:55 2020 New Revision: 365741 URL: https://svnweb.freebsd.org/changeset/base/365741 Log: MFC r365445: mmc_da: make sure that part_index is not used uninitialized in sddastart Modified: stable/12/sys/cam/mmc/mmc_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/mmc/mmc_da.c == --- stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 05:46:51 2020 (r365740) +++ stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 05:48:55 2020 (r365741) @@ -1696,6 +1696,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ } /* Find partition that has outstanding commands. Prefer current partition. */ + part_index = softc->part_curr; part = softc->part[softc->part_curr]; bp = bioq_first(>bio_queue); if (bp == NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365740 - stable/12/sys/cam/mmc
Author: avg Date: Tue Sep 15 05:46:51 2020 New Revision: 365740 URL: https://svnweb.freebsd.org/changeset/base/365740 Log: MFC r365446: mmc_da: fix a typo and a too long line Modified: stable/12/sys/cam/mmc/mmc_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/mmc/mmc_da.c == --- stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 04:22:28 2020 (r365739) +++ stable/12/sys/cam/mmc/mmc_da.c Tue Sep 15 05:46:51 2020 (r365740) @@ -1847,7 +1847,8 @@ sddadone(struct cam_periph *periph, union ccb *done_cc /* Process result of switching MMC partitions */ if (softc->state == SDDA_STATE_PART_SWITCH) { CAM_DEBUG(path, CAM_DEBUG_TRACE, - ("Compteting partition switch to %d\n", softc->part_requested)); + ("Completing partition switch to %d\n", + softc->part_requested)); softc->outstanding_cmds--; /* Complete partition switch */ softc->state = SDDA_STATE_NORMAL; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]
On 09/09/2020 16:44, Mark Johnston wrote: > On Wed, Sep 09, 2020 at 08:49:01AM +0300, Andriy Gapon wrote: >> On 08/09/2020 15:48, Mark Johnston wrote: >>> I observed the same thing recently as well: the compiler catches >>> uninitialized variables only in simple cases. In my case, any uses of >>> goto within the function seemed to silence the warning, even if they >>> appeared after the uninitialized reference. >> >> I am running a kernel build now with this addition (for clang): >> CWARNEXTRA+= -Wconditional-uninitialized >> -Wno-error-conditional-uninitialized >> >> It produces a ton of warnings. >> Some of them are probably false positives, but some look quite reasonable. > > It has a lot of trouble with code patterns of the form: > > for (i = 0; i < 100; i++) { > val = foo(); > } > if (val != 0) /* may be uninitialized!!1 */ > bar(); > > or > > if (foo == bar) > val = baz(); > > if (foo == bar && val == 3) > > > The second example makes some sense to me since it's hard to prove that > foo == bar will not change between the first and second evaluations. I also noted the first pattern as the most common source of false positives. So, it seems that we cannot have what we want. Without -Wconditional-uninitialized clang is too conservative, with the option it's too "loose". I seem to recall that compilers used to be better than that. But maybe it's just false memories ("there used to be more snow in the winter", etc). >> E.g.: >> sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized >> when >> used here [-Wconditional-uninitialized] >> TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); >> >> Indeed, there is a conditional 'goto failure' before a first assignment to >> p_drv >> and the line is after the label. So, maybe the situation is impossible, but >> it >> is reasonable to warn about it. >> >> But the number of false positives (and "possible but impossible" situations) >> is >> too overwhelming. > > Yeah. I looked at maybe 30 warnings (out of hundreds) this morning > and they were all false positives. KMSAN will provide a new tool for > finding such bugs, but they will only be detected at runtime. > -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365556 - stable/12/sys/dev/iicbus/twsi
Author: avg Date: Thu Sep 10 09:10:33 2020 New Revision: 365556 URL: https://svnweb.freebsd.org/changeset/base/365556 Log: MFC r365288: twsi: replace a couple of errno codes with i2c error codes Modified: stable/12/sys/dev/iicbus/twsi/twsi.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/twsi/twsi.c == --- stable/12/sys/dev/iicbus/twsi/twsi.cThu Sep 10 09:01:59 2020 (r36) +++ stable/12/sys/dev/iicbus/twsi/twsi.cThu Sep 10 09:10:33 2020 (r365556) @@ -573,7 +573,7 @@ twsi_intr(void *arg) case TWSI_STATUS_ADDR_R_NACK: debugf(sc->dev, "No ack received after transmitting the address\n"); sc->transfer = 0; - sc->error = ETIMEDOUT; + sc->error = IIC_ENOACK; sc->control_val = 0; wakeup(sc); break; @@ -642,7 +642,7 @@ twsi_intr(void *arg) default: debugf(sc->dev, "status=%x hot handled\n", status); sc->transfer = 0; - sc->error = ENXIO; + sc->error = IIC_EBUSERR; sc->control_val = 0; wakeup(sc); break; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365555 - stable/12/sys/dev/iicbus/twsi
Author: avg Date: Thu Sep 10 09:01:59 2020 New Revision: 36 URL: https://svnweb.freebsd.org/changeset/base/36 Log: MFC r365289: twsi: no need to compare boolean with boolean constant Modified: stable/12/sys/dev/iicbus/twsi/twsi.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/twsi/twsi.c == --- stable/12/sys/dev/iicbus/twsi/twsi.cThu Sep 10 07:05:31 2020 (r365554) +++ stable/12/sys/dev/iicbus/twsi/twsi.cThu Sep 10 09:01:59 2020 (r36) @@ -484,7 +484,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint sc = device_get_softc(dev); - if (sc->have_intr == false) + if (!sc->have_intr) return (iicbus_transfer_gen(dev, msgs, nmsgs)); sc->error = 0; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365517 - head/sys/net/route
On 10/09/2020 00:45, Alexander V. Chernikov wrote: > Author: melifaro > Date: Wed Sep 9 21:45:18 2020 > New Revision: 365517 > URL: https://svnweb.freebsd.org/changeset/base/365517 > > Log: > Retain marking net.fibs sysctl as a tunable. > > Suggested by: avg > > Modified: > head/sys/net/route/route_tables.c > > Modified: head/sys/net/route/route_tables.c > == > --- head/sys/net/route/route_tables.c Wed Sep 9 21:44:59 2020 > (r365516) > +++ head/sys/net/route/route_tables.c Wed Sep 9 21:45:18 2020 > (r365517) > @@ -140,8 +140,8 @@ sysctl_fibs(SYSCTL_HANDLER_ARGS) > return (error); > } > SYSCTL_PROC(_net, OID_AUTO, fibs, > -CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0, > -_fibs, "IU", > +CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_NOFETCH | > CTLFLAG_MPSAFE, > +NULL, 0, _fibs, "IU", > "set number of fibs"); > > /* > Just upgraded and this version works perfectly. Thank you! -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364465 - in head/sys: conf net net/route
On 09/09/2020 00:50, Alexander V. Chernikov wrote: > 08.09.2020, 21:03, "Andriy Gapon" : >> On 22/08/2020 00:34, Alexander V. Chernikov wrote: >>> Â Author: melifaro >>> Â Date: Fri Aug 21 21:34:52 2020 >>> Â New Revision: 364465 >>> Â URL: https://svnweb.freebsd.org/changeset/base/364465 >>> >>> Â Log: >>> Â Â Â Make net.fibs growable. >>> >>> Â Â Â Allow to dynamically grow the amount of fibs in each vnet. >>> >>> Â Â Â This change alters current behavior. Currently, if one defines >>> ROUTETABLES > 1 in the kernel config, each vnet will be created >>> with the number of fibs defined in the kernel config. >>> After this commit vnets will be created with fibs=1. >>> >>> Â Â Â Dynamic net.fibs is not compatible with net.add_addr_allfibs. >>> The plan is to deprecate the latter and make >>> net.add_addr_allfibs=0 default behaviour. >>> >>> Â Â Â Reviewed by: glebius >>> Â Â Â Relnotes: yes >>> Â Â Â Differential Revision: https://reviews.freebsd.org/D26062 >> >> I wonder why no one reported a problem that I am seeing after upgrading past >> this revision. Maybe because I do have net.fibs=2 in my loader.conf? > Hi Andriy, > > Does r365475 fix the problem for you? > CTLFLAG_RWTUN flag got slipped through the cracks somewhere :-( I am not sure that it does, I haven't tried it, but I agree with Ryan's comment. In general, I would keep CTLFLAG_RWTUN as the knob is a tunable indeed and some tools query that flag. So, I would like to re-iterate my earlier suggestion to use CTLFLAG_NOFETCH paired with explicit TUNABLE_INT_FETCH (which seems to be there already). >> The problem -- unfortunately I only have a screenshot -- but it's a page >> fault >> trap in this call chain: >> sysctl_register_all -> sysctl_load_tunable_by_oid_locked -> sysctl_fibs -> >> _sx_xlock. >> >> The crash is on the RTABLES_LOCK() line. >> And it's kind of obvious why. >> >> The tunables, including net.fibs which is declared as RWTUN, are set at >> SI_SUB_TUNABLES stage, but RTABLES_LOCK_INIT() is not called until >> SI_SUB_PROTO_DOMAIN much later. In other words, sysctal_fibs can be called >> earlier than vnet_rtables_init. >> >> I think that the best way to handle the problem would be to add >> CTLFLAG_NOFETCH >> to the sysctl declaration and then to add -- if necessary at all -- an >> explicit >> query of the kenv. >> >> -- >> Andriy Gapon -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]
On 09/09/2020 08:49, Andriy Gapon wrote: > On 08/09/2020 15:48, Mark Johnston wrote: >> I observed the same thing recently as well: the compiler catches >> uninitialized variables only in simple cases. In my case, any uses of >> goto within the function seemed to silence the warning, even if they >> appeared after the uninitialized reference. > > I am running a kernel build now with this addition (for clang): > CWARNEXTRA+= -Wconditional-uninitialized > -Wno-error-conditional-uninitialized > > It produces a ton of warnings. > Some of them are probably false positives, but some look quite reasonable. > > E.g.: > sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized > when > used here [-Wconditional-uninitialized] > TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); > > Indeed, there is a conditional 'goto failure' before a first assignment to > p_drv > and the line is after the label. So, maybe the situation is impossible, but > it > is reasonable to warn about it. > > But the number of false positives (and "possible but impossible" situations) > is > too overwhelming. But but: /usr/devel/git//sys/cam/mmc/mmc_da.c:1824:6: warning: variable 'part_index' may be uninitialized when used here [-Wconditional-uninitialized] if (part_index != softc->part_curr) { ^~ /usr/devel/git//sys/cam/mmc/mmc_da.c:1800:16: note: initialize the variable 'part_index' to silence this warning int part_index; ^ = 0 1 warning generated. There are useful true positives as well. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]
On 08/09/2020 15:48, Mark Johnston wrote: > I observed the same thing recently as well: the compiler catches > uninitialized variables only in simple cases. In my case, any uses of > goto within the function seemed to silence the warning, even if they > appeared after the uninitialized reference. I am running a kernel build now with this addition (for clang): CWARNEXTRA+= -Wconditional-uninitialized -Wno-error-conditional-uninitialized It produces a ton of warnings. Some of them are probably false positives, but some look quite reasonable. E.g.: sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized when used here [-Wconditional-uninitialized] TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); Indeed, there is a conditional 'goto failure' before a first assignment to p_drv and the line is after the label. So, maybe the situation is impossible, but it is reasonable to warn about it. But the number of false positives (and "possible but impossible" situations) is too overwhelming. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364465 - in head/sys: conf net net/route
On 22/08/2020 00:34, Alexander V. Chernikov wrote: > Author: melifaro > Date: Fri Aug 21 21:34:52 2020 > New Revision: 364465 > URL: https://svnweb.freebsd.org/changeset/base/364465 > > Log: > Make net.fibs growable. > > Allow to dynamically grow the amount of fibs in each vnet. > > This change alters current behavior. Currently, if one defines >ROUTETABLES > 1 in the kernel config, each vnet will be created >with the number of fibs defined in the kernel config. >After this commit vnets will be created with fibs=1. > > Dynamic net.fibs is not compatible with net.add_addr_allfibs. >The plan is to deprecate the latter and make >net.add_addr_allfibs=0 default behaviour. > > Reviewed by:glebius > Relnotes: yes > Differential Revision: https://reviews.freebsd.org/D26062 I wonder why no one reported a problem that I am seeing after upgrading past this revision. Maybe because I do have net.fibs=2 in my loader.conf? The problem -- unfortunately I only have a screenshot -- but it's a page fault trap in this call chain: sysctl_register_all -> sysctl_load_tunable_by_oid_locked -> sysctl_fibs -> _sx_xlock. The crash is on the RTABLES_LOCK() line. And it's kind of obvious why. The tunables, including net.fibs which is declared as RWTUN, are set at SI_SUB_TUNABLES stage, but RTABLES_LOCK_INIT() is not called until SI_SUB_PROTO_DOMAIN much later. In other words, sysctal_fibs can be called earlier than vnet_rtables_init. I think that the best way to handle the problem would be to add CTLFLAG_NOFETCH to the sysctl declaration and then to add -- if necessary at all -- an explicit query of the kenv. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365445 - head/sys/cam/mmc
On 08/09/2020 10:10, Andriy Gapon wrote: > On 08/09/2020 08:46, Andriy Gapon wrote: >> Author: avg >> Date: Tue Sep 8 05:46:10 2020 >> New Revision: 365445 >> URL: https://svnweb.freebsd.org/changeset/base/365445 >> >> Log: >> mmc_da: make sure that part_index is not used uninitialized in sddastart > [snip] >> Modified: head/sys/cam/mmc/mmc_da.c >> == >> --- head/sys/cam/mmc/mmc_da.cTue Sep 8 04:44:37 2020 >> (r365444) >> +++ head/sys/cam/mmc/mmc_da.cTue Sep 8 05:46:10 2020 >> (r365445) >> @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ >> } >> >> /* Find partition that has outstanding commands. Prefer current >> partition. */ >> +part_index = softc->part_curr; >> part = softc->part[softc->part_curr]; >> bp = bioq_first(>bio_queue); >> if (bp == NULL) { >> > > One thing that concerns me is that it was obvious (to a human) that part_index > could be used uninitialized if bp was not NULL. > Yet, there was no warning or error from the compiler when I built that code > for > armv7. > > I wonder if we disable some relevant warnings for that architecture. > Or if the compiler (clang 11) could not figure that out. > FWIW, I've just tried GENERIC-MMCCAM on amd64 and didn't get any warning either (with a tree from before this commit). -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365445 - head/sys/cam/mmc
On 08/09/2020 08:46, Andriy Gapon wrote: > Author: avg > Date: Tue Sep 8 05:46:10 2020 > New Revision: 365445 > URL: https://svnweb.freebsd.org/changeset/base/365445 > > Log: > mmc_da: make sure that part_index is not used uninitialized in sddastart [snip] > Modified: head/sys/cam/mmc/mmc_da.c > == > --- head/sys/cam/mmc/mmc_da.c Tue Sep 8 04:44:37 2020(r365444) > +++ head/sys/cam/mmc/mmc_da.c Tue Sep 8 05:46:10 2020(r365445) > @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ > } > > /* Find partition that has outstanding commands. Prefer current > partition. */ > + part_index = softc->part_curr; > part = softc->part[softc->part_curr]; > bp = bioq_first(>bio_queue); > if (bp == NULL) { > One thing that concerns me is that it was obvious (to a human) that part_index could be used uninitialized if bp was not NULL. Yet, there was no warning or error from the compiler when I built that code for armv7. I wonder if we disable some relevant warnings for that architecture. Or if the compiler (clang 11) could not figure that out. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365447 - head/sys/cam/mmc
Author: avg Date: Tue Sep 8 06:19:23 2020 New Revision: 365447 URL: https://svnweb.freebsd.org/changeset/base/365447 Log: mmc_da: universally use uint8_t for the partition index Also, assert in sdda_init_switch_part() that the index is within the defined range. MFC after:1 week Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Sep 8 06:18:34 2020(r365446) +++ head/sys/cam/mmc/mmc_da.c Tue Sep 8 06:19:23 2020(r365447) @@ -182,7 +182,6 @@ static void sdda_start_init(void *context, union ccb * static void sdda_start_init_task(void *context, int pending); static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *start_ccb); static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb); -static void sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part); static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca); static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return MMC_SECTOR_SIZE;} @@ -1770,10 +1769,13 @@ sdda_process_mmc_partitions(struct cam_periph *periph, * This function cannot fail, instead check switch errors in sddadone(). */ static void -sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part) { +sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, +uint8_t part) +{ struct sdda_softc *sc = (struct sdda_softc *)periph->softc; uint8_t value; + KASSERT(part < MMC_PART_MAX, ("%s: invalid partition index", __func__)); sc->part_requested = part; value = (sc->raw_ext_csd[EXT_CSD_PART_CONFIG] & @@ -1797,7 +1799,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ struct sdda_softc *softc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct mmc_params *mmcp = >path->device->mmc_ident_data; - int part_index; + uint8_t part_index; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddastart\n")); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365446 - head/sys/cam/mmc
Author: avg Date: Tue Sep 8 06:18:34 2020 New Revision: 365446 URL: https://svnweb.freebsd.org/changeset/base/365446 Log: mmc_da: fix a typo and a too long line MFC after:1 week Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Sep 8 05:46:10 2020(r365445) +++ head/sys/cam/mmc/mmc_da.c Tue Sep 8 06:18:34 2020(r365446) @@ -1965,7 +1965,8 @@ sddadone(struct cam_periph *periph, union ccb *done_cc /* Process result of switching MMC partitions */ if (softc->state == SDDA_STATE_PART_SWITCH) { CAM_DEBUG(path, CAM_DEBUG_TRACE, - ("Compteting partition switch to %d\n", softc->part_requested)); + ("Completing partition switch to %d\n", + softc->part_requested)); softc->outstanding_cmds--; /* Complete partition switch */ softc->state = SDDA_STATE_NORMAL; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365445 - head/sys/cam/mmc
Author: avg Date: Tue Sep 8 05:46:10 2020 New Revision: 365445 URL: https://svnweb.freebsd.org/changeset/base/365445 Log: mmc_da: make sure that part_index is not used uninitialized in sddastart This is a fix to r334065. Without this change I once got stuck I/O with endless partition switching: (sdda0:aw_mmc_sim2:0:0:0): sddastart (sdda0:aw_mmc_sim2:0:0:0): Partition 0 -> -525703168 (sdda0:aw_mmc_sim2:0:0:0): xpt_action: func 0x91d XPT_MMC_IO (sdda0:aw_mmc_sim2:0:0:0): xpt_done: func= 0x91d XPT_MMC_IO status 0x1 (sdda0:aw_mmc_sim2:0:0:0): sddadone (sdda0:aw_mmc_sim2:0:0:0): Card status: (sdda0:aw_mmc_sim2:0:0:0): Current state: 4 (sdda0:aw_mmc_sim2:0:0:0): Compteting partition switch to 0 Note that -525703168 (an int) is 0xe0aa6800 in binary representation. The partition indexes are actually stored as uint8_t, so that value was converted / truncated to zero. MFC after:1 week Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Sep 8 04:44:37 2020(r365444) +++ head/sys/cam/mmc/mmc_da.c Tue Sep 8 05:46:10 2020(r365445) @@ -1808,6 +1808,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ } /* Find partition that has outstanding commands. Prefer current partition. */ + part_index = softc->part_curr; part = softc->part[softc->part_curr]; bp = bioq_first(>bio_queue); if (bp == NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365402 - head/sys/dev/usb/controller
Author: avg Date: Mon Sep 7 06:53:29 2020 New Revision: 365402 URL: https://svnweb.freebsd.org/changeset/base/365402 Log: musb/allwinner: add support for configuring phy as well as device mode At least on Orange Pi PC Plus even the host mode does not work without enabling the phy and setting it to the host mode. The driver will now parse dr_mode property and will try to configure itself and the phy accordingly. OTG mode is not supported yet, so it is treated as the device / peripheral mode. The phy is enabled -- powered on -- only for the host mode. The device mode requires support from a phy driver, e.g., aw_usbphy on Allwinner platform. aw_usbphy does not support the device mode, so it cannnot work yet. MFC after:6 weeks Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c == --- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:49:07 2020(r365401) +++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:53:29 2020(r365402) @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #ifdef __arm__ #include @@ -121,6 +123,7 @@ struct awusbdrd_softc { struct resource *res[2]; clk_t clk; hwreset_t reset; + phy_t phy; struct bus_spacebs; int flags; }; @@ -382,7 +385,10 @@ awusbdrd_probe(device_t dev) static int awusbdrd_attach(device_t dev) { + char usb_mode[24]; struct awusbdrd_softc *sc; + uint8_t musb_mode; + int phy_mode; int error; sc = device_get_softc(dev); @@ -392,6 +398,31 @@ awusbdrd_attach(device_t dev) if (error != 0) return (error); + musb_mode = MUSB2_HOST_MODE;/* default */ + phy_mode = PHY_USB_MODE_HOST; + if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", + _mode, sizeof(usb_mode)) > 0) { + usb_mode[sizeof(usb_mode) - 1] = 0; + if (strcasecmp(usb_mode, "host") == 0) { + musb_mode = MUSB2_HOST_MODE; + phy_mode = PHY_USB_MODE_HOST; + } else if (strcasecmp(usb_mode, "peripheral") == 0) { + musb_mode = MUSB2_DEVICE_MODE; + phy_mode = PHY_USB_MODE_DEVICE; + } else if (strcasecmp(usb_mode, "otg") == 0) { + /* +* XXX phy has PHY_USB_MODE_OTG, but MUSB does not have +* it. It's not clear how to propagate mode changes +* from phy layer (that detects them) to MUSB. +*/ + musb_mode = MUSB2_DEVICE_MODE; + phy_mode = PHY_USB_MODE_DEVICE; + } else { + device_printf(dev, "Invalid FDT dr_mode: %s\n", + usb_mode); + } + } + /* AHB gate clock is required */ error = clk_get_by_ofw_index(dev, 0, 0, >clk); if (error != 0) @@ -415,6 +446,24 @@ awusbdrd_attach(device_t dev) } } + /* XXX not sure if this is universally needed. */ + (void)phy_get_by_ofw_name(dev, 0, "usb", >phy); + if (sc->phy != NULL) { + device_printf(dev, "setting phy mode %d\n", phy_mode); + if (musb_mode == MUSB2_HOST_MODE) { + error = phy_enable(sc->phy); + if (error != 0) { + device_printf(dev, "Could not enable phy\n"); + goto fail; + } + } + error = phy_usb_set_mode(sc->phy, phy_mode); + if (error != 0) { + device_printf(dev, "Could not set phy mode\n"); + goto fail; + } + } + sc->sc.sc_bus.parent = dev; sc->sc.sc_bus.devices = sc->sc.sc_devices; sc->sc.sc_bus.devices_max = MUSB2_MAX_DEVICES; @@ -457,7 +506,7 @@ awusbdrd_attach(device_t dev) device_set_ivars(sc->sc.sc_bus.bdev, >sc.sc_bus); sc->sc.sc_id = 0; sc->sc.sc_platform_data = sc; - sc->sc.sc_mode = MUSB2_HOST_MODE; /* XXX HOST vs DEVICE mode */ + sc->sc.sc_mode = musb_mode; if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) { sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3; sc->sc.sc_ep_max = DRD_EP_MAX_H3; @@ -497,8 +546,15 @@ awusbdrd_attach(device_t dev) return (0); fail: - if (sc->reset != NULL) + if (sc->phy != NULL) { + if (musb_mode == MUSB2_HOST_MODE) + (void)phy_disable(sc->phy); +
svn commit: r365401 - head/sys/dev/usb/controller
Author: avg Date: Mon Sep 7 06:49:07 2020 New Revision: 365401 URL: https://svnweb.freebsd.org/changeset/base/365401 Log: musb/allwinner: add H3 support MFC after:6 weeks Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c == --- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:48:08 2020(r365400) +++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:49:07 2020(r365401) @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #endif #defineDRD_EP_MAX 5 +#defineDRD_EP_MAX_H3 4 #defineMUSB2_REG_AWIN_VEND00x0043 #defineVEND0_PIO_MODE 0 @@ -89,12 +90,13 @@ static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-musb", AWUSB_OKAY }, { "allwinner,sun6i-a31-musb", AWUSB_OKAY }, { "allwinner,sun8i-a33-musb", AWUSB_OKAY | AWUSB_NO_CONFDATA }, + { "allwinner,sun8i-h3-musb",AWUSB_OKAY | AWUSB_NO_CONFDATA }, { NULL, 0 } }; static const struct musb_otg_ep_cfg musbotg_ep_allwinner[] = { { - .ep_end = 5, + .ep_end = DRD_EP_MAX, .ep_fifosz_shift = 9, .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512, }, @@ -103,6 +105,17 @@ static const struct musb_otg_ep_cfg musbotg_ep_allwinn }, }; +static const struct musb_otg_ep_cfg musbotg_ep_allwinner_h3[] = { + { + .ep_end = DRD_EP_MAX_H3, + .ep_fifosz_shift = 9, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512, + }, + { + .ep_end = -1, + }, +}; + struct awusbdrd_softc { struct musbotg_softcsc; struct resource *res[2]; @@ -445,8 +458,13 @@ awusbdrd_attach(device_t dev) sc->sc.sc_id = 0; sc->sc.sc_platform_data = sc; sc->sc.sc_mode = MUSB2_HOST_MODE; /* XXX HOST vs DEVICE mode */ - sc->sc.sc_ep_max = DRD_EP_MAX; - sc->sc.sc_ep_cfg = musbotg_ep_allwinner; + if (ofw_bus_is_compatible(dev, "allwinner,sun8i-h3-musb")) { + sc->sc.sc_ep_cfg = musbotg_ep_allwinner_h3; + sc->sc.sc_ep_max = DRD_EP_MAX_H3; + } else { + sc->sc.sc_ep_cfg = musbotg_ep_allwinner; + sc->sc.sc_ep_max = DRD_EP_MAX; + } error = bus_setup_intr(dev, sc->res[1], INTR_MPSAFE | INTR_TYPE_BIO, NULL, awusbdrd_intr, sc, >sc.sc_intr_hdl); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365400 - head/sys/dev/usb/controller
Author: avg Date: Mon Sep 7 06:48:08 2020 New Revision: 365400 URL: https://svnweb.freebsd.org/changeset/base/365400 Log: musb/allwinner: apply register filter in awusbdrd_bs_r_2() as well Otherwise, I get this panic: panic: awusbdrd_reg: Invalid register 0x342 It looks that musb code both writes and reads at least MUSB2_REG_TXDBDIS. MFC after:5 weeks X-MFC after: r365399 Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c Modified: head/sys/dev/usb/controller/musb_otg_allwinner.c == --- head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:44:24 2020(r365399) +++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:48:08 2020(r365400) @@ -259,6 +259,8 @@ awusbdrd_bs_r_2(awusb_bs_tag t, bus_space_handle_t h, { const struct bus_space *bs = t; + if (awusbdrd_filt(o) != 0) + return (0); return bus_space_read_2(bs_parent_space(bs), h, awusbdrd_reg(o)); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365399 - head/sys/dev/usb/controller
Author: avg Date: Mon Sep 7 06:44:24 2020 New Revision: 365399 URL: https://svnweb.freebsd.org/changeset/base/365399 Log: fixup r365398: add a missed file with all the new Allwinner musb_otg code Obtained from:andrew MFC after:5 weeks X-MFC with: r365398 Added: head/sys/dev/usb/controller/musb_otg_allwinner.c (contents, props changed) Added: head/sys/dev/usb/controller/musb_otg_allwinner.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb/controller/musb_otg_allwinner.cMon Sep 7 06:44:24 2020(r365399) @@ -0,0 +1,543 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * Copyright (c) 2018 Andrew Turner + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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. + * + * $FreeBSD$ + */ + +/* + * Allwinner USB Dual-Role Device (DRD) controller + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef __arm__ +#include +#include +#endif + +#defineDRD_EP_MAX 5 + +#defineMUSB2_REG_AWIN_VEND00x0043 +#defineVEND0_PIO_MODE 0 + +#if defined(__arm__) +#definebs_parent_space(bs) ((bs)->bs_parent) +typedef bus_space_tag_tawusb_bs_tag; +#elif defined(__aarch64__) +#definebs_parent_space(bs) (bs) +typedef void * awusb_bs_tag; +#endif + +#defineAWUSB_OKAY 0x01 +#defineAWUSB_NO_CONFDATA 0x02 +static struct ofw_compat_data compat_data[] = { + { "allwinner,sun4i-a10-musb", AWUSB_OKAY }, + { "allwinner,sun6i-a31-musb", AWUSB_OKAY }, + { "allwinner,sun8i-a33-musb", AWUSB_OKAY | AWUSB_NO_CONFDATA }, + { NULL, 0 } +}; + +static const struct musb_otg_ep_cfg musbotg_ep_allwinner[] = { + { + .ep_end = 5, + .ep_fifosz_shift = 9, + .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512, + }, + { + .ep_end = -1, + }, +}; + +struct awusbdrd_softc { + struct musbotg_softcsc; + struct resource *res[2]; + clk_t clk; + hwreset_t reset; + struct bus_spacebs; + int flags; +}; + +static struct resource_spec awusbdrd_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +#defineREMAPFLAG 0x8000 +#defineREGDECL(a, b) [(a)] = ((b) | REMAPFLAG) + +/* Allwinner USB DRD register mappings */ +static const uint16_t awusbdrd_regmap[] = { + REGDECL(MUSB2_REG_EPFIFO(0),0x), + REGDECL(MUSB2_REG_EPFIFO(1),0x0004), + REGDECL(MUSB2_REG_EPFIFO(2),0x0008), + REGDECL(MUSB2_REG_EPFIFO(3),0x000c), + REGDECL(MUSB2_REG_EPFIFO(4),0x0010), + REGDECL(MUSB2_REG_EPFIFO(5),0x0014), + REGDECL(MUSB2_REG_POWER,0x0040), + REGDECL(MUSB2_REG_DEVCTL, 0x0041), + REGDECL(MUSB2_REG_EPINDEX, 0x0042), + REGDECL(MUSB2_REG_INTTX,0x0044), + REGDECL(MUSB2_REG_INTRX,0x0046), + REGDECL(MUSB2_REG_INTTXE, 0x0048), + REGDECL(MUSB2_REG_INTRXE, 0x004a), +
svn commit: r365398 - in head/sys: arm/allwinner arm64/conf conf
Author: avg Date: Mon Sep 7 06:39:00 2020 New Revision: 365398 URL: https://svnweb.freebsd.org/changeset/base/365398 Log: Allwinner USB DRD support (musb_otg) Allwinner USB DRD is based on the Mentor USB OTG controller, with a different register layout and a few missing registers. The code is by Andrew Turner (andrew). Reviewed by: hselasky, manu Obtained from:andrew MFC after:5 weeks Differential Revision: https://reviews.freebsd.org/D5881 Modified: head/sys/arm/allwinner/aw_usbphy.c head/sys/arm/allwinner/files.allwinner head/sys/arm64/conf/GENERIC head/sys/conf/files.arm64 Modified: head/sys/arm/allwinner/aw_usbphy.c == --- head/sys/arm/allwinner/aw_usbphy.c Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/arm/allwinner/aw_usbphy.c Mon Sep 7 06:39:00 2020 (r365398) @@ -169,6 +169,18 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #defineCLR4(res, o, m) WR4(res, o, RD4(res, o) & ~(m)) #defineSET4(res, o, m) WR4(res, o, RD4(res, o) | (m)) +#definePHY_CSR 0x00 +#define ID_PULLUP_EN (1 << 17) +#define DPDM_PULLUP_EN (1 << 16) +#define FORCE_ID (0x3 << 14) +#define FORCE_ID_SHIFT 14 +#define FORCE_ID_LOW 2 +#define FORCE_VBUS_VALID (0x3 << 12) +#define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_HIGH 3 +#define VBUS_CHANGE_DET(1 << 6) +#define ID_CHANGE_DET (1 << 5) +#define DPDM_CHANGE_DET(1 << 4) #defineOTG_PHY_CFG 0x20 #define OTG_PHY_ROUTE_OTG (1 << 0) #definePMU_IRQ_ENABLE 0x00 @@ -214,6 +226,7 @@ awusbphy_init(device_t dev) struct awusbphy_softc *sc; phandle_t node; char pname[20]; + uint32_t val; int error, off, rid; regulator_t reg; hwreset_t rst; @@ -288,6 +301,16 @@ awusbphy_init(device_t dev) return (ENXIO); } } + + /* Enable OTG PHY for host mode */ + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_ID; + val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); + val &= ~FORCE_VBUS_VALID; + val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); + bus_write_4(sc->phy_ctrl, PHY_CSR, val); return (0); } Modified: head/sys/arm/allwinner/files.allwinner == --- head/sys/arm/allwinner/files.allwinner Mon Sep 7 06:32:03 2020 (r365397) +++ head/sys/arm/allwinner/files.allwinner Mon Sep 7 06:39:00 2020 (r365398) @@ -27,6 +27,7 @@ dev/usb/controller/generic_ohci.c optionalohci dev/usb/controller/generic_usb_if.moptionalohci dev/usb/controller/generic_ehci.c optionalehci dev/usb/controller/generic_ehci_fdt.c optionalehci +dev/usb/controller/musb_otg_allwinner.coptionalmusb arm/allwinner/aw_sid.c optionalaw_sid arm/allwinner/aw_thermal.c optionalaw_thermal arm/allwinner/aw_cir.c optionalaw_cir evdev Modified: head/sys/arm64/conf/GENERIC == --- head/sys/arm64/conf/GENERIC Mon Sep 7 06:32:03 2020(r365397) +++ head/sys/arm64/conf/GENERIC Mon Sep 7 06:39:00 2020(r365398) @@ -222,6 +222,7 @@ device aw_usbphy # Allwinner USB PHY device rk_usb2phy # Rockchip USB2PHY device rk_typec_phy# Rockchip TypeC PHY device dwcotg # DWC OTG controller +device musb# Mentor Graphics USB OTG controller device ohci# OHCI USB interface device ehci# EHCI USB interface (USB 2.0) device ehci_mv # Marvell EHCI USB interface Modified: head/sys/conf/files.arm64 == --- head/sys/conf/files.arm64 Mon Sep 7 06:32:03 2020(r365397) +++ head/sys/conf/files.arm64 Mon Sep 7 06:39:00 2020(r365398) @@ -339,6 +339,7 @@ dev/usb/controller/generic_ehci_acpi.c optional ehci a dev/usb/controller/generic_ehci_fdt.c optional ehci fdt dev/usb/controller/generic_ohci.c optional ohci fdt dev/usb/controller/generic_usb_if.m optional ohci fdt +dev/usb/controller/musb_otg_allwinner.coptional musb fdt soc_allwinner_a64 dev/usb/controller/usb_nop_xceiv.c optional fdt ext_resources dev/usb/controller/generic_xhci.c optionalxhci
svn commit: r365397 - head/sys/dev/iicbus/twsi
Author: avg Date: Mon Sep 7 06:32:03 2020 New Revision: 365397 URL: https://svnweb.freebsd.org/changeset/base/365397 Log: twsi: some variants clear interrupt flag by writing 0, others by writing 1 Make that distinction more explicit and regular in the code. The difference in behavior is documented in the respective datasheets. Previously, the code handled the distinction by writing the control register multiple times where at least one write was zero and another was one. This can be considered a follow-up to r363021. Reviewed by: manu MFC after:4 weeks Differential Revision: https://reviews.freebsd.org/D26308 Modified: head/sys/dev/iicbus/twsi/a10_twsi.c head/sys/dev/iicbus/twsi/twsi.c head/sys/dev/iicbus/twsi/twsi.h Modified: head/sys/dev/iicbus/twsi/a10_twsi.c == --- head/sys/dev/iicbus/twsi/a10_twsi.c Mon Sep 7 06:29:41 2020 (r365396) +++ head/sys/dev/iicbus/twsi/a10_twsi.c Mon Sep 7 06:32:03 2020 (r365397) @@ -122,6 +122,10 @@ a10_twsi_attach(device_t dev) sc->reg_soft_reset = TWI_SRST; sc->need_ack = true; + + if (ofw_bus_is_compatible(dev, "allwinner,sun6i-a31-i2c") || + ofw_bus_is_compatible(dev, "allwinner,sun6i-a83t-i2c")) + sc->iflag_w1c = true; return (twsi_attach(dev)); } Modified: head/sys/dev/iicbus/twsi/twsi.c == --- head/sys/dev/iicbus/twsi/twsi.c Mon Sep 7 06:29:41 2020 (r365396) +++ head/sys/dev/iicbus/twsi/twsi.c Mon Sep 7 06:32:03 2020 (r365397) @@ -147,7 +147,11 @@ twsi_clear_iflg(struct twsi_softc *sc) { DELAY(1000); - twsi_control_clear(sc, TWSI_CONTROL_IFLG); + /* There are two ways of clearing IFLAG. */ + if (sc->iflag_w1c) + twsi_control_set(sc, TWSI_CONTROL_IFLG); + else + twsi_control_clear(sc, TWSI_CONTROL_IFLG); DELAY(1000); } @@ -667,13 +671,11 @@ twsi_intr(void *arg) } debugf(sc->dev, "Refresh reg_control\n"); - /* -* Fix silicon bug on > Allwinner A20 by doing a read and writing -* again to the control register + /* +* Newer Allwinner chips clear IFLG after writing 1 to it. */ - status = TWSI_READ(sc, sc->reg_status); - TWSI_WRITE(sc, sc->reg_control, - sc->control_val | TWSI_CONTROL_IFLG); + TWSI_WRITE(sc, sc->reg_control, sc->control_val | + (sc->iflag_w1c ? TWSI_CONTROL_IFLG : 0)); debugf(sc->dev, "Done with interrupts\n\n"); if (transfer_done == 1) { Modified: head/sys/dev/iicbus/twsi/twsi.h == --- head/sys/dev/iicbus/twsi/twsi.h Mon Sep 7 06:29:41 2020 (r365396) +++ head/sys/dev/iicbus/twsi/twsi.h Mon Sep 7 06:32:03 2020 (r365397) @@ -66,6 +66,7 @@ struct twsi_softc { int error; uint32_tcontrol_val; boolneed_ack; + booliflag_w1c; bus_size_t reg_data; bus_size_t reg_slave_addr; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365396 - head/sys/dev/iicbus/twsi
Author: avg Date: Mon Sep 7 06:29:41 2020 New Revision: 365396 URL: https://svnweb.freebsd.org/changeset/base/365396 Log: twsi: use tsleep instead of pause for better responsiveness wakeup() does not have any effect on pause(), so if a transfer was not finished by the time of the first check, then the thread would sleep full 30 ms. To do: protect the transfer and interrupt code with the mutex, switch from tsleep from msleep Reviewed by: manu MFC after:3 weeks Differential Revision: https://reviews.freebsd.org/D26309 Modified: head/sys/dev/iicbus/twsi/twsi.c Modified: head/sys/dev/iicbus/twsi/twsi.c == --- head/sys/dev/iicbus/twsi/twsi.c Mon Sep 7 06:27:18 2020 (r365395) +++ head/sys/dev/iicbus/twsi/twsi.c Mon Sep 7 06:29:41 2020 (r365396) @@ -510,7 +510,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint sc->control_val &= ~TWSI_CONTROL_ACK; TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START); while (sc->error == 0 && sc->transfer != 0) { - pause_sbt("twsi", SBT_1MS * 30, SBT_1MS, 0); + tsleep_sbt(sc, 0, "twsi", SBT_1MS * 30, SBT_1MS, 0); } debugf(sc->dev, "pause finish\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365395 - in head/sys: arm/allwinner/clkng dev/extres/clk
Author: avg Date: Mon Sep 7 06:27:18 2020 New Revision: 365395 URL: https://svnweb.freebsd.org/changeset/base/365395 Log: aw_clk_nm: fix incorrect use of abs() abs() takes a (signed) int as input. Instead, it was used with unsigned 64-bit integers. So, add and use a new helper function to calculate a difference between two uint64_t-s. Reviewed by: manu MFC after:2 weeks Differential Revision: https://reviews.freebsd.org/D26307 Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c head/sys/dev/extres/clk/clk.h Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c == --- head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Sep 7 06:22:30 2020 (r365394) +++ head/sys/arm/allwinner/clkng/aw_clk_nm.cMon Sep 7 06:27:18 2020 (r365395) @@ -153,7 +153,8 @@ aw_clk_nm_find_best(struct aw_clk_nm_sc *sc, uint64_t for (m = min_m; m <= max_m; ) { for (n = min_n; n <= max_n; ) { cur = fparent / n / m; - if (abs(*fout - cur) < abs(*fout - best)) { + if (clk_freq_diff(*fout, cur) < + clk_freq_diff(*fout, best)) { best = cur; *factor_n = n; *factor_m = m; @@ -196,7 +197,8 @@ aw_clk_nm_set_freq(struct clknode *clk, uint64_t fpare clknode_get_freq(p_clk, ); cur = aw_clk_nm_find_best(sc, fparent, fout, , ); - if (abs((*fout - cur)) < abs((*fout - best))) { + if (clk_freq_diff(*fout, cur) < + clk_freq_diff(*fout, best)) { best = cur; best_parent = p_idx; best_n = n; Modified: head/sys/dev/extres/clk/clk.h == --- head/sys/dev/extres/clk/clk.h Mon Sep 7 06:22:30 2020 (r365394) +++ head/sys/dev/extres/clk/clk.h Mon Sep 7 06:27:18 2020 (r365395) @@ -135,6 +135,12 @@ int clk_get_parent(clk_t clk, clk_t *parent); int clk_set_parent_by_clk(clk_t clk, clk_t parent); const char *clk_get_name(clk_t clk); +static inline uint64_t +clk_freq_diff(uint64_t x, uint64_t y) +{ + return (x >= y ? x - y : y - x); +} + #ifdef FDT int clk_set_assigned(device_t dev, phandle_t node); int clk_get_by_ofw_index(device_t dev, phandle_t node, int idx, clk_t *clk); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365394 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Sep 7 06:22:30 2020 New Revision: 365394 URL: https://svnweb.freebsd.org/changeset/base/365394 Log: MFC r364149: aw_cir: in pulse encoding actual length is one greater than value Modified: stable/12/sys/arm/allwinner/aw_cir.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_cir.c == --- stable/12/sys/arm/allwinner/aw_cir.cMon Sep 7 06:21:01 2020 (r365393) +++ stable/12/sys/arm/allwinner/aw_cir.cMon Sep 7 06:22:30 2020 (r365394) @@ -202,9 +202,9 @@ aw_ir_read_data(struct aw_ir_softc *sc) static unsigned long aw_ir_decode_packets(struct aw_ir_softc *sc) { - unsigned long len, code; - unsigned char val, last; + unsigned int len, code; unsigned int active_delay; + unsigned char val, last; int i, bitcount; if (bootverbose) @@ -215,11 +215,11 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) (AW_IR_ACTIVE_T_C_VAL != 0 ? 128 : 1); len = active_delay; if (bootverbose) - device_printf(sc->dev, "Initial len: %ld\n", len); + device_printf(sc->dev, "Initial len: %d\n", len); for (i = 0; i < sc->dcnt; i++) { val = sc->buf[i]; if (val & VAL_MASK) - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; else { if (len > AW_IR_L1_MIN) break; @@ -227,7 +227,7 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) } } if (bootverbose) - device_printf(sc->dev, "len = %ld\n", len); + device_printf(sc->dev, "len = %d\n", len); if ((val & VAL_MASK) || (len <= AW_IR_L1_MIN)) { if (bootverbose) device_printf(sc->dev, "Bit separator error\n"); @@ -243,7 +243,7 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) break; len = 0; } else - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; } if ((!(val & VAL_MASK)) || (len <= AW_IR_L0_MIN)) { if (bootverbose) @@ -260,23 +260,25 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) val = sc->buf[i]; if (last) { if (val & VAL_MASK) - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; else { if (len > AW_IR_PMAX) { if (bootverbose) device_printf(sc->dev, - "Pulse error\n"); + "Pulse error, len=%d\n", + len); goto error_code; } last = 0; - len = val & PERIOD_MASK; + len = (val & PERIOD_MASK) + 1; } } else { if (val & VAL_MASK) { if (len > AW_IR_DMAX) { if (bootverbose) device_printf(sc->dev, - "Distant error\n"); + "Distance error, len=%d\n", + len); goto error_code; } else { if (len > AW_IR_DMID) { @@ -288,9 +290,9 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) break; /* Finish decoding */ } last = 1; - len = val & PERIOD_MASK; + len = (val & PERIOD_MASK) + 1; } else - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; } } return (code); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365393 - stable/12/sys/arm/allwinner
Author: avg Date: Mon Sep 7 06:21:01 2020 New Revision: 365393 URL: https://svnweb.freebsd.org/changeset/base/365393 Log: MFC r364148: aw_cir: lower activation threshold to support NECx protocol Modified: stable/12/sys/arm/allwinner/aw_cir.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_cir.c == --- stable/12/sys/arm/allwinner/aw_cir.cMon Sep 7 06:14:42 2020 (r365392) +++ stable/12/sys/arm/allwinner/aw_cir.cMon Sep 7 06:21:01 2020 (r365393) @@ -126,8 +126,10 @@ __FBSDID("$FreeBSD$"); #defineAW_IR_DMAX 53 /* Active Thresholds */ -#defineAW_IR_ACTIVE_T ((0 & 0xff) << 16) -#defineAW_IR_ACTIVE_T_C((1 & 0xff) << 23) +#defineAW_IR_ACTIVE_T_VAL AW_IR_L1_MIN +#defineAW_IR_ACTIVE_T (((AW_IR_ACTIVE_T_VAL - 1) & 0xff) << 16) +#defineAW_IR_ACTIVE_T_C_VAL0 +#defineAW_IR_ACTIVE_T_C((AW_IR_ACTIVE_T_C_VAL & 0xff) << 23) /* Code masks */ #defineCODE_MASK 0x00ff00ff @@ -209,9 +211,9 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) device_printf(sc->dev, "sc->dcnt = %d\n", sc->dcnt); /* Find Lead 1 (bit separator) */ - active_delay = (AW_IR_ACTIVE_T + 1) * (AW_IR_ACTIVE_T_C != 0 ? 128 : 1); - len = 0; - len += (active_delay >> 1); + active_delay = AW_IR_ACTIVE_T_VAL * + (AW_IR_ACTIVE_T_C_VAL != 0 ? 128 : 1); + len = active_delay; if (bootverbose) device_printf(sc->dev, "Initial len: %ld\n", len); for (i = 0; i < sc->dcnt; i++) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365392 - stable/12/sys/dev/gpio
Author: avg Date: Mon Sep 7 06:14:42 2020 New Revision: 365392 URL: https://svnweb.freebsd.org/changeset/base/365392 Log: MFC r364145: gpiokeys: add evdev support Only linux,code is supported as it maps 1:1 to evdev key codes. No reverse mapping for freebsd,code yet. Modified: stable/12/sys/dev/gpio/gpiokeys.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/gpio/gpiokeys.c == --- stable/12/sys/dev/gpio/gpiokeys.c Sun Sep 6 20:32:13 2020 (r365391) +++ stable/12/sys/dev/gpio/gpiokeys.c Mon Sep 7 06:14:42 2020 (r365392) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "opt_platform.h" #include "opt_kbd.h" +#include "opt_evdev.h" #include #include @@ -56,6 +57,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #defineKBD_DRIVER_NAME "gpiokeys" #defineGPIOKEYS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -99,6 +105,9 @@ struct gpiokey struct resource *irq_res; void*intr_hl; struct mtx mtx; +#ifdef EVDEV_SUPPORT + uint32_tevcode; +#endif uint32_tkeycode; int autorepeat; struct callout debounce_callout; @@ -115,6 +124,9 @@ struct gpiokeys_softc struct gpiokey *sc_keys; int sc_total_keys; +#ifdef EVDEV_SUPPORT + struct evdev_dev*sc_evdev; +#endif keyboard_t sc_kbd; keymap_tsc_keymap; accentmap_t sc_accmap; @@ -171,26 +183,34 @@ gpiokeys_put_key(struct gpiokeys_softc *sc, uint32_t k } static void -gpiokeys_key_event(struct gpiokeys_softc *sc, uint16_t keycode, int pressed) +gpiokeys_key_event(struct gpiokeys_softc *sc, struct gpiokey *key, int pressed) { - uint32_t key; + uint32_t code; - - key = keycode & SCAN_KEYCODE_MASK; - - if (!pressed) - key |= KEY_RELEASE; - GPIOKEYS_LOCK(sc); - if (keycode & SCAN_PREFIX_E0) - gpiokeys_put_key(sc, 0xe0); - else if (keycode & SCAN_PREFIX_E1) - gpiokeys_put_key(sc, 0xe1); +#ifdef EVDEV_SUPPORT + if (key->evcode != GPIOKEY_NONE && + (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD) != 0) { + evdev_push_key(sc->sc_evdev, key->evcode, pressed); + evdev_sync(sc->sc_evdev); + } +#endif + if (key->keycode != GPIOKEY_NONE) { + code = key->keycode & SCAN_KEYCODE_MASK; + if (!pressed) + code |= KEY_RELEASE; - gpiokeys_put_key(sc, key); + if (key->keycode & SCAN_PREFIX_E0) + gpiokeys_put_key(sc, 0xe0); + else if (key->keycode & SCAN_PREFIX_E1) + gpiokeys_put_key(sc, 0xe1); + + gpiokeys_put_key(sc, code); + } GPIOKEYS_UNLOCK(sc); - gpiokeys_event_keyinput(sc); + if (key->keycode != GPIOKEY_NONE) + gpiokeys_event_keyinput(sc); } static void @@ -200,11 +220,8 @@ gpiokey_autorepeat(void *arg) key = arg; - if (key->keycode == GPIOKEY_NONE) - return; + gpiokeys_key_event(key->parent_sc, key, 1); - gpiokeys_key_event(key->parent_sc, key->keycode, 1); - callout_reset(>repeat_callout, key->repeat, gpiokey_autorepeat, key); } @@ -217,12 +234,9 @@ gpiokey_debounced_intr(void *arg) key = arg; - if (key->keycode == GPIOKEY_NONE) - return; - gpio_pin_is_active(key->pin, ); if (active) { - gpiokeys_key_event(key->parent_sc, key->keycode, 1); + gpiokeys_key_event(key->parent_sc, key, 1); if (key->autorepeat) { callout_reset(>repeat_callout, key->repeat_delay, gpiokey_autorepeat, key); @@ -232,7 +246,7 @@ gpiokey_debounced_intr(void *arg) if (key->autorepeat && callout_pending(>repeat_callout)) callout_stop(>repeat_callout); - gpiokeys_key_event(key->parent_sc, key->keycode, 0); + gpiokeys_key_event(key->parent_sc, key, 0); } } @@ -301,6 +315,10 @@ gpiokeys_attach_key(struct gpiokeys_softc *sc, phandle if (key->keycode == GPIOKEY_NONE) device_printf(sc->sc_dev, "<%s> failed to map linux,code value 0x%x\n", key_name, code); +#ifdef EVDEV_SUPPORT + key->evcode = code; + evdev_support_key(sc->sc_evdev, code); +#endif } else device_printf(sc->sc_dev, "<%s> no linux,code or freebsd,code property\n", @@ -365,7 +383,6 @@ gpiokeys_detach_key(struct gpiokeys_softc *sc, struct
svn commit: r365308 - head/sys/security/mac
Author: avg Date: Thu Sep 3 20:30:52 2020 New Revision: 365308 URL: https://svnweb.freebsd.org/changeset/base/365308 Log: mac_framework.h: fix build with DEBUG_VFS_LOCKS and !MAC I have such a custom kernel configuration and its build failed with: linking kernel.full ld: error: undefined symbol: mac_vnode_assert_locked >>> referenced by mac_framework.h:556 (/usr/devel/git/apu2c4/sys/security/mac/mac_framework.h:556) >>> tmpfs_vnops.o:(mac_vnode_check_stat) >>> referenced by mac_framework.h:556 (/usr/devel/git/apu2c4/sys/security/mac/mac_framework.h:556) >>> vfs_default.o:(mac_vnode_check_stat) >>> referenced by mac_framework.h:556 (/usr/devel/git/apu2c4/sys/security/mac/mac_framework.h:556) >>> ufs_vnops.o:(mac_vnode_check_stat) Modified: head/sys/security/mac/mac_framework.h Modified: head/sys/security/mac/mac_framework.h == --- head/sys/security/mac/mac_framework.h Thu Sep 3 18:34:01 2020 (r365307) +++ head/sys/security/mac/mac_framework.h Thu Sep 3 20:30:52 2020 (r365308) @@ -400,7 +400,7 @@ voidmac_sysvshm_init(struct shmid_kernel *); void mac_thread_userret(struct thread *td); -#ifdef DEBUG_VFS_LOCKS +#if defined(MAC) && defined(DEBUG_VFS_LOCKS) void mac_vnode_assert_locked(struct vnode *vp, const char *func); #else #define mac_vnode_assert_locked(vp, func) do { } while (0) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365290 - head/sys/dev/iicbus
Author: avg Date: Thu Sep 3 08:02:19 2020 New Revision: 365290 URL: https://svnweb.freebsd.org/changeset/base/365290 Log: move defintion of hw.i2c sysctl node from iicbb to iicbus MFC after:2 weeks Modified: head/sys/dev/iicbus/iicbb.c head/sys/dev/iicbus/iicbus.c Modified: head/sys/dev/iicbus/iicbb.c == --- head/sys/dev/iicbus/iicbb.c Thu Sep 3 08:01:21 2020(r365289) +++ head/sys/dev/iicbus/iicbb.c Thu Sep 3 08:02:19 2020(r365290) @@ -228,7 +228,7 @@ iicbb_print_child(device_t bus, device_t dev) #ifdef IICBB_DEBUG static int i2c_debug = 0; -static SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c debug"); +SYSCTL_DECL(_hw_i2c); SYSCTL_INT(_hw_i2c, OID_AUTO, iicbb_debug, CTLFLAG_RWTUN, _debug, 0, "Enable i2c bit-banging driver debug"); Modified: head/sys/dev/iicbus/iicbus.c == --- head/sys/dev/iicbus/iicbus.cThu Sep 3 08:01:21 2020 (r365289) +++ head/sys/dev/iicbus/iicbus.cThu Sep 3 08:02:19 2020 (r365290) @@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$"); /* See comments below for why auto-scanning is a bad idea. */ #define SCAN_IICBUS 0 +SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c controls"); + static int iicbus_probe(device_t dev) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365289 - head/sys/dev/iicbus/twsi
Author: avg Date: Thu Sep 3 08:01:21 2020 New Revision: 365289 URL: https://svnweb.freebsd.org/changeset/base/365289 Log: twsi: no need to compare boolean with boolean constant Testing the boolean directly is shorter and more idiomatic. MFC after:1 week Modified: head/sys/dev/iicbus/twsi/twsi.c Modified: head/sys/dev/iicbus/twsi/twsi.c == --- head/sys/dev/iicbus/twsi/twsi.c Thu Sep 3 07:42:53 2020 (r365288) +++ head/sys/dev/iicbus/twsi/twsi.c Thu Sep 3 08:01:21 2020 (r365289) @@ -484,7 +484,7 @@ twsi_transfer(device_t dev, struct iic_msg *msgs, uint sc = device_get_softc(dev); - if (sc->have_intr == false) + if (!sc->have_intr) return (iicbus_transfer_gen(dev, msgs, nmsgs)); sc->error = 0; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r365288 - head/sys/dev/iicbus/twsi
Author: avg Date: Thu Sep 3 07:42:53 2020 New Revision: 365288 URL: https://svnweb.freebsd.org/changeset/base/365288 Log: twsi: replace a couple of errno codes with i2c error codes Reviewed by: manu MFC after:1 week Modified: head/sys/dev/iicbus/twsi/twsi.c Modified: head/sys/dev/iicbus/twsi/twsi.c == --- head/sys/dev/iicbus/twsi/twsi.c Thu Sep 3 05:25:39 2020 (r365287) +++ head/sys/dev/iicbus/twsi/twsi.c Thu Sep 3 07:42:53 2020 (r365288) @@ -579,7 +579,7 @@ twsi_intr(void *arg) case TWSI_STATUS_ADDR_R_NACK: debugf(sc->dev, "No ack received after transmitting the address\n"); sc->transfer = 0; - sc->error = ETIMEDOUT; + sc->error = IIC_ENOACK; sc->control_val = 0; wakeup(sc); break; @@ -660,7 +660,7 @@ twsi_intr(void *arg) default: debugf(sc->dev, "status=%x hot handled\n", status); sc->transfer = 0; - sc->error = ENXIO; + sc->error = IIC_EBUSERR; sc->control_val = 0; wakeup(sc); break; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r365249 - head
On 02/09/2020 18:23, Ryan Moeller wrote: > > On 9/2/20 10:28 AM, Warner Losh wrote: >> Author: imp >> Date: Wed Sep 2 14:28:54 2020 >> New Revision: 365249 >> URL: https://svnweb.freebsd.org/changeset/base/365249 >> >> Log: >>   Add note about needing to manually import the zfs pools or update >>   /etc/rc.d due to the cache file moving to /etc. >> >> Modified: >>   head/UPDATING >> >> Modified: head/UPDATING >> == >> --- head/UPDATING   Wed Sep 2 12:57:34 2020   (r365248) >> +++ head/UPDATING   Wed Sep 2 14:28:54 2020   (r365249) >> @@ -36,6 +36,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: >>  scenarios have been tested and fixed, but rebuilding kernels without >>  rebuilding world may fail. >>  +   The ZFS cache file has moved from /boot to /etc to match the OpenZFS >> +   upstream default. This means your zpool won't auto import until you >> +   upgrade your /etc/rc.d files or you import them manually. >> + >>  20200824: >>  The resume code now notifies devd with the 'kernel' system >>  rather than the old 'kern' subsystem to be consistent with > Thanks, enough people seemed to be getting tripped up by this. I think that this is a very useful note. But I do not see a direct connection between the change of zpool.cache location and the new ZFS's not automatically importing zpool.cache pools on boot. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364989 - head/sys/dev/jedec_dimm
On 31/08/2020 18:03, Eric van Gyzen wrote: > Author: vangyzen > Date: Mon Aug 31 15:03:23 2020 > New Revision: 364989 > URL: https://svnweb.freebsd.org/changeset/base/364989 > > Log: > jedec_dimm: fix array overrun > > Coverity detected the overrunning of sc->part_str. > > Submitted by: bret_ketc...@dell.com > Reported by:Coverity > MFC after: 2 weeks > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D26145 > > Modified: > head/sys/dev/jedec_dimm/jedec_dimm.c > > Modified: head/sys/dev/jedec_dimm/jedec_dimm.c > == > --- head/sys/dev/jedec_dimm/jedec_dimm.c Mon Aug 31 14:47:23 2020 > (r364988) > +++ head/sys/dev/jedec_dimm/jedec_dimm.c Mon Aug 31 15:03:23 2020 > (r364989) > @@ -795,7 +795,7 @@ jedec_dimm_field_to_str(struct jedec_dimm_softc *sc, c > > /* If we're dealing with ASCII, convert trailing spaces to NULs. */ > if (ascii) { > - for (i = dstsz; i > 0; i--) { > + for (i = dstsz - 1; i > 0; i--) { If 'i' is an index into the array, then shouldn't the condition be greater-equal? > if (dst[i] == ' ') { > dst[i] = 0; > } else if (dst[i] == 0) { > -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364927 - head/sys/arm/allwinner/clkng
On 28/08/2020 21:25, Emmanuel Vadot wrote: > Author: manu > Date: Fri Aug 28 18:25:45 2020 > New Revision: 364927 > URL: https://svnweb.freebsd.org/changeset/base/364927 > > Log: > arm: allwinner: clk: Add printfs when we cannot set the correct freq > > For some unknown reason this seems to fix this function when we printf > the best variable. This isn't a delay problem as doing a printf without > it doesn't solve this problem. > This is way above my pay grade so add some printf that shouldn't be printed > in 99% of the case anyway. > Fix booting on most Allwinner boards as the mmc IP uses a NM clock. Just so that our IRC conversation does not get lost to time. I think that the real problem with the code is that it passes a difference between two uint64_t-s, which is uint64_t itself, to abs() which takes an int and returns an int. I am not sure what liberties compilers (especially, clang) can take with that incorrect code -- and they have some options, because abs() is an inline function -- and how the magic printf-s affect those liberties, but I think that it is better to make the code correct. I think that abs(x - y) can be replaced with a local function like: static inline uint64_t distance(uint64_t x, uint64_t y) { return (x >= y ? x - y : y - x); } > Reported by:Alexander Mishin > MFC after: 3 days > X-MFC-With: 363887 > > Modified: > head/sys/arm/allwinner/clkng/aw_clk_nm.c > > Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c > == > --- head/sys/arm/allwinner/clkng/aw_clk_nm.c Fri Aug 28 17:55:54 2020 > (r364926) > +++ head/sys/arm/allwinner/clkng/aw_clk_nm.c Fri Aug 28 18:25:45 2020 > (r364927) > @@ -221,11 +221,15 @@ aw_clk_nm_set_freq(struct clknode *clk, uint64_t fpare > if ((best < *fout) && > ((flags & CLK_SET_ROUND_DOWN) == 0)) { > *stop = 1; > + printf("best freq (%llu) < requested freq(%llu)\n", > + best, *fout); > return (ERANGE); > } > if ((best > *fout) && > ((flags & CLK_SET_ROUND_UP) == 0)) { > *stop = 1; > + printf("best freq (%llu) > requested freq(%llu)\n", > + best, *fout); > return (ERANGE); > } > > -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364917 - in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Author: avg Date: Fri Aug 28 13:15:13 2020 New Revision: 364917 URL: https://svnweb.freebsd.org/changeset/base/364917 Log: MFC r362047,r362048: rework how ZVOLs are updated in response to DSL operations Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c == --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Fri Aug 28 10:33:19 2020(r364916) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Fri Aug 28 13:15:13 2020(r364917) @@ -1053,6 +1053,9 @@ dmu_objset_create_sync(void *arg, dmu_tx_t *tx) doca->doca_cred, tx); } +#if defined(__FreeBSD__) && defined(_KERNEL) + zvol_create_minors(dp->dp_spa, doca->doca_name); +#endif spa_history_log_internal_ds(ds, "create", tx, ""); dsl_dataset_rele(ds, FTAG); dsl_dir_rele(pdd, FTAG); @@ -1148,6 +1151,9 @@ dmu_objset_clone_sync(void *arg, dmu_tx_t *tx) VERIFY0(dsl_dataset_hold_obj(pdd->dd_pool, obj, FTAG, )); dsl_dataset_name(origin, namebuf); +#if defined(__FreeBSD__) && defined(_KERNEL) + zvol_create_minors(dp->dp_spa, doca->doca_clone); +#endif spa_history_log_internal_ds(ds, "clone", tx, "origin=%s (%llu)", namebuf, origin->ds_object); dsl_dataset_rele(ds, FTAG); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c == --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Aug 28 10:33:19 2020(r364916) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Aug 28 13:15:13 2020(r364917) @@ -57,6 +57,9 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#endif #ifdef __FreeBSD__ #undef dump_write @@ -3445,6 +3448,11 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *tx) drc->drc_newsnapobj = dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj; } + +#if defined(__FreeBSD__) && defined(_KERNEL) + zvol_create_minors(dp->dp_spa, drc->drc_tofs); +#endif + /* * Release the hold from dmu_recv_begin. This must be done before * we return to open context, so that when we free the dataset's dnode, Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c == --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Aug 28 10:33:19 2020(r364916) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Aug 28 13:15:13 2020(r364917) @@ -1572,6 +1572,9 @@ dsl_dataset_snapshot_sync(void *arg, dmu_tx_t *tx) dsl_props_set_sync_impl(ds->ds_prev, ZPROP_SRC_LOCAL, ddsa->ddsa_props, tx); } +#if defined(__FreeBSD__) && defined(_KERNEL) + zvol_create_minors(dp->dp_spa, name); +#endif dsl_dataset_rele(ds, FTAG); } } @@ -1646,17 +1649,6 @@ dsl_dataset_snapshot(nvlist_t *snaps, nvlist_t *props, fnvlist_free(suspended); } -#ifdef __FreeBSD__ -#ifdef _KERNEL - if (error == 0) { - for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL; - pair = nvlist_next_nvpair(snaps, pair)) { - char *snapname = nvpair_name(pair); - zvol_create_minors(snapname); - } - } -#endif -#endif return (error); } @@ -2535,7 +2527,7 @@ dsl_dataset_rename_snapshot_sync_impl(dsl_pool_t *dp, snprintf(newname, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", ddrsa->ddrsa_fsname, ddrsa->ddrsa_newsnapname); zfsvfs_update_fromname(oldname, newname); - zvol_rename_minors(oldname, newname); + zvol_rename_minors(dp->dp_spa, oldname, newname); kmem_free(newname, ZFS_MAX_DATASET_NAME_LEN); kmem_free(oldname, ZFS_MAX_DATASET_NAME_LEN); #endif @@ -3087,9 +3079,6 @@ dsl_dataset_promote_sync(void
svn commit: r364916 - stable/12/sys/arm/allwinner
Author: avg Date: Fri Aug 28 10:33:19 2020 New Revision: 364916 URL: https://svnweb.freebsd.org/changeset/base/364916 Log: MFC r364147: aw_cir: minor cleanups Modified: stable/12/sys/arm/allwinner/aw_cir.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_cir.c == --- stable/12/sys/arm/allwinner/aw_cir.cFri Aug 28 10:32:03 2020 (r364915) +++ stable/12/sys/arm/allwinner/aw_cir.cFri Aug 28 10:33:19 2020 (r364916) @@ -368,7 +368,7 @@ aw_ir_intr(void *arg) device_printf(sc->dev, "IR code status: %d\n", stat); } - sc->dcnt = 0; + aw_ir_buf_reset(sc); } if (val & AW_IR_RXINT_ROI_EN) { /* RX FIFO overflow */ @@ -469,7 +469,8 @@ aw_ir_attach(device_t dev) >intrhand)) { bus_release_resources(dev, aw_ir_spec, sc->res); device_printf(dev, "cannot setup interrupt handler\n"); - return (ENXIO); + err = ENXIO; + goto error; } /* Enable CIR Mode */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364915 - stable/12/sys/arm/allwinner
Author: avg Date: Fri Aug 28 10:32:03 2020 New Revision: 364915 URL: https://svnweb.freebsd.org/changeset/base/364915 Log: MFC r364146: aw_cir: add support for allwinner,sun6i-a31-ir (found, e.g., on h3) Modified: stable/12/sys/arm/allwinner/aw_cir.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_cir.c == --- stable/12/sys/arm/allwinner/aw_cir.cFri Aug 28 10:30:39 2020 (r364914) +++ stable/12/sys/arm/allwinner/aw_cir.cFri Aug 28 10:32:03 2020 (r364915) @@ -134,8 +134,11 @@ __FBSDID("$FreeBSD$"); #defineINV_CODE_MASK 0xff00ff00 #defineVALID_CODE_MASK 0x00ff -#defineA10_IR 1 -#defineA13_IR 2 +enum { + A10_IR = 1, + A13_IR, + A31_IR, +}; #defineAW_IR_RAW_BUF_SIZE 128 @@ -158,6 +161,7 @@ static struct resource_spec aw_ir_spec[] = { static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-ir", A10_IR }, { "allwinner,sun5i-a13-ir", A13_IR }, + { "allwinner,sun6i-a31-ir", A31_IR }, { NULL, 0 } }; @@ -414,6 +418,7 @@ aw_ir_attach(device_t dev) sc->fifo_size = 16; break; case A13_IR: + case A31_IR: sc->fifo_size = 64; break; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364914 - stable/12/sys/dev/iicbus/mux
Author: avg Date: Fri Aug 28 10:30:39 2020 New Revision: 364914 URL: https://svnweb.freebsd.org/changeset/base/364914 Log: MFC r364344: iicmux: fix a sign error in comparison Modified: stable/12/sys/dev/iicbus/mux/iicmux.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/mux/iicmux.c == --- stable/12/sys/dev/iicbus/mux/iicmux.c Fri Aug 28 10:28:52 2020 (r364913) +++ stable/12/sys/dev/iicbus/mux/iicmux.c Fri Aug 28 10:30:39 2020 (r364914) @@ -283,7 +283,7 @@ iicmux_attach_children(struct iicmux_softc *sc) } sc->childdevs[idx] = device_add_child(sc->dev, "iicbus", -1); sc->childnodes[idx] = child; - if (sc->maxbus < idx) + if (sc->maxbus < (int)idx) sc->maxbus = idx; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364913 - stable/12/sys/modules/usb/cp2112
Author: avg Date: Fri Aug 28 10:28:52 2020 New Revision: 364913 URL: https://svnweb.freebsd.org/changeset/base/364913 Log: MFC r364269 by eugen: Unbreak building cp2112(8) as a module... outside of kernel build environment. Modified: stable/12/sys/modules/usb/cp2112/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/modules/usb/cp2112/Makefile == --- stable/12/sys/modules/usb/cp2112/Makefile Fri Aug 28 10:27:24 2020 (r364912) +++ stable/12/sys/modules/usb/cp2112/Makefile Fri Aug 28 10:28:52 2020 (r364913) @@ -31,7 +31,7 @@ S= ${SRCTOP}/sys KMOD= cp2112 SRCS= cp2112.c -SRCS+= opt_bus.h opt_usb.h +SRCS+= opt_bus.h opt_platform.h opt_usb.h SRCS+= device_if.h bus_if.h gpio_if.h iicbus_if.h usb_if.h usbdevs.h .include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364912 - in stable/12: share/man/man4 sys/conf sys/dev/usb/misc sys/modules/usb sys/modules/usb/cp2112
Author: avg Date: Fri Aug 28 10:27:24 2020 New Revision: 364912 URL: https://svnweb.freebsd.org/changeset/base/364912 Log: MFC r363951,r364143,r364144: cp2112: driver for the namesake GPIO and I2C master gadget Added: stable/12/share/man/man4/cp2112.4 - copied unchanged from r364144, head/share/man/man4/cp2112.4 stable/12/sys/dev/usb/misc/cp2112.c - copied, changed from r363951, head/sys/dev/usb/misc/cp2112.c stable/12/sys/modules/usb/cp2112/ - copied from r363951, head/sys/modules/usb/cp2112/ Modified: stable/12/sys/conf/files stable/12/sys/modules/usb/Makefile Directory Properties: stable/12/ (props changed) Copied: stable/12/share/man/man4/cp2112.4 (from r364144, head/share/man/man4/cp2112.4) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man4/cp2112.4 Fri Aug 28 10:27:24 2020 (r364912, copy of r364144, head/share/man/man4/cp2112.4) @@ -0,0 +1,87 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" 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$ +.\" +.Dd August 12, 2020 +.Dt CP2112 4 +.Os +.Sh NAME +.Nm cp2112 +.Nd driver for a USB GPIO and I2C peripheral device +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device cp2112" +.Cd "device usb" +.Cd "device gpio" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +cp2112_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for Silicon Labs CP2112 device. +The device has 8 general purpose I/O pins and an I2C controller that supports +a subset of the I2C protocol. +.Pp +All pins support both input and output modes. +An output pin can be configured either for open-drain or push-pull operation. +Pins 0, 1 and 7 support special functions: I2C transmit indication, +I2C receive indication and clock output respectively. +At the moment the +.Nm +driver does not provide a way to enable and configure the special functions. +.Pp +The I2C controller supports read transactions with up to 512 bytes of data, +write transactions with up to 61 bytes of data and a write followed by +the repeated start followed by a read transactions where the write can be +up to 16 bytes and the read can be up to 512 bytes. +Zero length transfers are not supported. +The +.Nm +driver creates a +.Xr gpio 4 +and +.Xr iicbus 4 +child buses to expose the respective functions. +.Sh SEE ALSO +.Xr gpio 4 , +.Xr iicbus 4 , +.Xr usb 4 +.Sh HISTORY +The +.Nm +driver and this manual page was written by +.An Andriy Gapon Aq Mt a...@freebsd.org . Modified: stable/12/sys/conf/files == --- stable/12/sys/conf/filesFri Aug 28 10:21:11 2020(r364911) +++ stable/12/sys/conf/filesFri Aug 28 10:27:24 2020(r364912) @@ -3438,6 +3438,7 @@ dev/usb/serial/usb_serial.c optional ucom | u3g | uar # # USB misc drivers # +dev/usb/misc/cp2112.c optional cp2112 dev/usb/misc/ufm.c optional ufm dev/usb/misc/udbp.coptional udbp dev/usb/misc/ugold.c optional ugold Copied and modified: stable/12/sys/dev/usb/misc/cp2112.c (from r363951, head/sys/dev/us
Re: svn commit: r364910 - stable/12/share/man/man4
On 28/08/2020 13:18, Andriy Gapon wrote: > Author: avg > Date: Fri Aug 28 10:18:30 2020 > New Revision: 364910 > URL: https://svnweb.freebsd.org/changeset/base/364910 > > Log: > MFC r364155: hook cp2112.4 to the build This was merged out-of-order. My apologies. > Modified: > stable/12/share/man/man4/Makefile > Directory Properties: > stable/12/ (props changed) > > Modified: stable/12/share/man/man4/Makefile > == > --- stable/12/share/man/man4/Makefile Fri Aug 28 10:17:09 2020 > (r364909) > +++ stable/12/share/man/man4/Makefile Fri Aug 28 10:18:30 2020 > (r364910) > @@ -119,6 +119,7 @@ MAN= aac.4 \ > cloudabi.4 \ > cmx.4 \ > ${_coretemp.4} \ > + cp2112.4 \ > ${_cpuctl.4} \ > cpufreq.4 \ > crypto.4 \ > -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364911 - stable/12/share/man/man4
Author: avg Date: Fri Aug 28 10:21:11 2020 New Revision: 364911 URL: https://svnweb.freebsd.org/changeset/base/364911 Log: MFC r364154: hook gpiokeys.4 to the build Modified: stable/12/share/man/man4/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile == --- stable/12/share/man/man4/Makefile Fri Aug 28 10:18:30 2020 (r364910) +++ stable/12/share/man/man4/Makefile Fri Aug 28 10:21:11 2020 (r364911) @@ -183,6 +183,7 @@ MAN=aac.4 \ gif.4 \ gpio.4 \ gpioiic.4 \ + gpiokeys.4 \ gpioled.4 \ gpioths.4 \ gre.4 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364910 - stable/12/share/man/man4
Author: avg Date: Fri Aug 28 10:18:30 2020 New Revision: 364910 URL: https://svnweb.freebsd.org/changeset/base/364910 Log: MFC r364155: hook cp2112.4 to the build Modified: stable/12/share/man/man4/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile == --- stable/12/share/man/man4/Makefile Fri Aug 28 10:17:09 2020 (r364909) +++ stable/12/share/man/man4/Makefile Fri Aug 28 10:18:30 2020 (r364910) @@ -119,6 +119,7 @@ MAN=aac.4 \ cloudabi.4 \ cmx.4 \ ${_coretemp.4} \ + cp2112.4 \ ${_cpuctl.4} \ cpufreq.4 \ crypto.4 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364909 - stable/12/sys/arm/allwinner/clkng
Author: avg Date: Fri Aug 28 10:17:09 2020 New Revision: 364909 URL: https://svnweb.freebsd.org/changeset/base/364909 Log: MFC r363948: ccu_sun8i_r: minor comment update Modified: stable/12/sys/arm/allwinner/clkng/ccu_sun8i_r.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/clkng/ccu_sun8i_r.c == --- stable/12/sys/arm/allwinner/clkng/ccu_sun8i_r.c Fri Aug 28 10:15:54 2020(r364908) +++ stable/12/sys/arm/allwinner/clkng/ccu_sun8i_r.c Fri Aug 28 10:17:09 2020(r364909) @@ -119,7 +119,7 @@ NM_CLK(r_ccu_ir_clk, "ir", r_ccu_ir_parents,/* names, parents */ 0x54, /* offset */ 0, 4, 0, 0,/* N factor */ -16, 2, 0, 0, /* M flags */ +16, 2, 0, 0, /* M factor */ 24, 2, /* mux */ 31,/* gate */ AW_CLK_HAS_MUX | AW_CLK_REPARENT | AW_CLK_HAS_GATE);/* flags */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364908 - stable/12/share/man/man4
Author: avg Date: Fri Aug 28 10:15:54 2020 New Revision: 364908 URL: https://svnweb.freebsd.org/changeset/base/364908 Log: MFC r363905: gpiokeys: add a basic manual page Added: stable/12/share/man/man4/gpiokeys.4 - copied unchanged from r363905, head/share/man/man4/gpiokeys.4 Modified: Directory Properties: stable/12/ (props changed) Copied: stable/12/share/man/man4/gpiokeys.4 (from r363905, head/share/man/man4/gpiokeys.4) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man4/gpiokeys.4 Fri Aug 28 10:15:54 2020 (r364908, copy of r363905, head/share/man/man4/gpiokeys.4) @@ -0,0 +1,152 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" 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$ +.\" +.Dd August 5, 2020 +.Dt GPIOKEYS 4 +.Os +.Sh NAME +.Nm gpiokeys +.Nd GPIO keys device driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "options FDT" +.Cd "device gpio" +.Cd "device gpiokeys" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +gpiokeys_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides a way to represent a set of general purpose inputs as a +.Xr keyboard 4 +device. +At the moment the driver supports only +.Xr FDT 4 +based systems. +The DTS determines what pins are mapped to buttons and what key codes are +generated for each virtual button. +The +.Xr keyboard 4 +device can be used from userland to monitor for input changes. +.Pp +On an +.Xr FDT 4 +based system +the DTS part for a +.Nm +device usually looks like: +.Bd -literal +/ { + + ... + + gpio_keys { + compatible = "gpio-keys"; + + btn1 { + label = "button1"; + linux,code = ; + gpios = < 0 3 GPIO_ACTIVE_LOW> + }; + + btn2 { + label = "button2"; + linux,code = ; + gpios = < 0 4 GPIO_ACTIVE_LOW> + }; + }; +}; +.Ed +.Pp +For more details about the +.Va gpios +property, please consult +.Pa /usr/src/sys/dts/bindings-gpio.txt . +.Pp +The +.Nm +driver supports two properties for specifying a key code. +.Pp +The property +.Va freebsd,code +specifies a +.Fx +native scancode compatible with +.Xr kbdmap 5 +keyboard maps. +.Pp +The property +.Va linux,code +specifies an evdev scancode. +That scancode is internally translated to a native scancode. +Note that not all evdev scancodes have corresponding native scancodes. +If a scancode cannot be translated, then a diagnostic message is printed +and the input is ignored. +.Pp +The property +.Va label +is a descriptive name of a button. +It is used for diagnostic messages only. +This property is optional. +If not set, the node name is used in its place. +.Pp +The property +.Va autorepeat +determines whether autorepeat is enabled for a button. +.Pp +The property +.Va debounce-interval +defines debouncing interval time in milliseconds. +If not specified the interval defaults to 5. +.Sh SEE ALSO +.Xr fdt 4 , +.Xr gpio 4 , +.Xr keyboard 4 , +.Xr kbdmap 5 +.Sh HISTORY +Th
svn commit: r364907 - stable/12/sys/cam
Author: avg Date: Fri Aug 28 10:01:03 2020 New Revision: 364907 URL: https://svnweb.freebsd.org/changeset/base/364907 Log: MFC r358864 by imp: Eliminate xpt_copy_path. Modified: stable/12/sys/cam/cam_xpt.c stable/12/sys/cam/cam_xpt.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/cam_xpt.c == --- stable/12/sys/cam/cam_xpt.c Fri Aug 28 08:54:27 2020(r364906) +++ stable/12/sys/cam/cam_xpt.c Fri Aug 28 10:01:03 2020(r364907) @@ -804,7 +804,8 @@ static void xpt_scanner_thread(void *dummy) { union ccb *ccb; - struct cam_path path; + struct mtx *mtx; + struct cam_ed *device; xpt_lock_buses(); for (;;) { @@ -816,15 +817,22 @@ xpt_scanner_thread(void *dummy) xpt_unlock_buses(); /* -* Since lock can be dropped inside and path freed -* by completion callback even before return here, -* take our own path copy for reference. +* We need to lock the device's mutex which we use as +* the path mutex. We can't do it directly because the +* cam_path in the ccb may wind up going away because +* the path lock may be dropped and the path retired in +* the completion callback. We do this directly to keep +* the reference counts in cam_path sane. We also have +* to copy the device pointer because ccb_h.path may +* be freed in the callback. */ - xpt_copy_path(, ccb->ccb_h.path); - xpt_path_lock(); + mtx = xpt_path_mtx(ccb->ccb_h.path); + device = ccb->ccb_h.path->device; + xpt_acquire_device(device); + mtx_lock(mtx); xpt_action(ccb); - xpt_path_unlock(); - xpt_release_path(); + mtx_unlock(mtx); + xpt_release_device(device); xpt_lock_buses(); } @@ -3701,15 +3709,6 @@ xpt_clone_path(struct cam_path **new_path_ptr, struct new_path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT); if (new_path == NULL) return(CAM_RESRC_UNAVAIL); - xpt_copy_path(new_path, path); - *new_path_ptr = new_path; - return (CAM_REQ_CMP); -} - -void -xpt_copy_path(struct cam_path *new_path, struct cam_path *path) -{ - *new_path = *path; if (path->bus != NULL) xpt_acquire_bus(path->bus); @@ -3717,6 +3716,8 @@ xpt_copy_path(struct cam_path *new_path, struct cam_pa xpt_acquire_target(path->target); if (path->device != NULL) xpt_acquire_device(path->device); + *new_path_ptr = new_path; + return (CAM_REQ_CMP); } void Modified: stable/12/sys/cam/cam_xpt.h == --- stable/12/sys/cam/cam_xpt.h Fri Aug 28 08:54:27 2020(r364906) +++ stable/12/sys/cam/cam_xpt.h Fri Aug 28 10:01:03 2020(r364907) @@ -140,8 +140,6 @@ cam_status xpt_compile_path(struct cam_path *new_path lun_id_t lun_id); cam_status xpt_clone_path(struct cam_path **new_path, struct cam_path *path); -void xpt_copy_path(struct cam_path *new_path, - struct cam_path *path); void xpt_release_path(struct cam_path *path); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364906 - stable/12/sys/cam
Author: avg Date: Fri Aug 28 08:54:27 2020 New Revision: 364906 URL: https://svnweb.freebsd.org/changeset/base/364906 Log: MFC r358662 by imp: xpt_async is submitting a CCB, not finishing it up, so use xpt_action() instead of xpt_done(). Modified: stable/12/sys/cam/cam_xpt.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/cam_xpt.c == --- stable/12/sys/cam/cam_xpt.c Fri Aug 28 08:52:00 2020(r364905) +++ stable/12/sys/cam/cam_xpt.c Fri Aug 28 08:54:27 2020(r364906) @@ -3171,6 +3171,10 @@ call_sim: start_ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(start_ccb); break; + case XPT_ASYNC: + start_ccb->ccb_h.status = CAM_REQ_CMP; + xpt_done(start_ccb); + break; default: case XPT_SDEV_TYPE: case XPT_TERM_IO: @@ -4462,7 +4466,7 @@ xpt_async(u_int32_t async_code, struct cam_path *path, xpt_freeze_devq(path, 1); else xpt_freeze_simq(path->bus->sim, 1); - xpt_done(ccb); + xpt_action(ccb); } static void ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364905 - stable/12/sys/cam/scsi
Author: avg Date: Fri Aug 28 08:52:00 2020 New Revision: 364905 URL: https://svnweb.freebsd.org/changeset/base/364905 Log: MFC r354668 by imp: Fix a race between daopen and damediapoll Modified: stable/12/sys/cam/scsi/scsi_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/scsi/scsi_da.c == --- stable/12/sys/cam/scsi/scsi_da.cFri Aug 28 08:50:07 2020 (r364904) +++ stable/12/sys/cam/scsi/scsi_da.cFri Aug 28 08:52:00 2020 (r364905) @@ -5929,6 +5929,7 @@ damediapoll(void *arg) if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) && (softc->flags & DA_FLAG_TUR_PENDING) == 0 && + softc->state == DA_STATE_NORMAL && LIST_EMPTY(>pending_ccbs)) { if (da_periph_acquire(periph, DA_REF_TUR) == 0) { cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364817 - head/libexec/rc/rc.d
On 27/08/2020 19:51, Brandon Bergren wrote: > FWIW, on powerpc64, using /etc/zfs/zpool.cache is great because it avoids the > problem of having to unmount /boot (which is an msdos filesystem because > peitiboot doesn't understand ufs or zfs) to update the copy of zpool.cache > that is on the root filesystem in /boot instead of only changing the one in > the runtime /boot (which was mounted on top, and is never useful because it's > not mounted at the time that zpool.cache is actually needed to import pools.) > > In any case, the correct way on ZFS to control where the cachefile is written > is to set the cachefile property on the zpool to the specific path. The > correct behavior regarding boot time auto import of pools is to honor that > property as found on the pool the boot filesystem was on, so that other pools > sharing the same cachefile path will be imported. Multiple cache files and > pools not actually listed in a cachefile are valid scenarios for pools. Just want to express my complete agreement. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364817 - head/libexec/rc/rc.d
On 2020-08-27 16:54, Cy Schubert wrote: > In message <202008271350.07rdogqn055...@slippy.cwsent.com>, Cy Schubert > writes: >> In message <7e55d429-482b-2277-b340-2b85c6874...@freebsd.org>, Andriy Gapon >> wri >> tes: >>> On 26/08/2020 16:13, Cy Schubert wrote: >>>> Author: cy >>>> Date: Wed Aug 26 13:13:57 2020 >>>> New Revision: 364817 >>>> URL: https://svnweb.freebsd.org/changeset/base/364817 >>>> >>>> Log: >>>> As of r364746 (OpenZFS import) existing ZPOOLs are not imported >>>> prior to zvol and mountcritlocal resulting in ZVOLs (swap and >>> >>> I probably missed some discussion, so I am curious why that is. >> >> This is because r364746 added the code below to rc.d/zfs and by then it was >> too late. I simply moved it to a new file that allowed rc.d/zvol and >> rc.d/mountcritlocal with legacy mounts to work again. This was copied from >> rc.d/zfs, which was added by r364746. There was no need for a zpool import >> under the previous version of ZFS, whereas it appears that OpenZFS requires >> it. > > Let me add, one could say this is a regression. Yes, I was actually curious about this change in ZFS driver behavior. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364817 - head/libexec/rc/rc.d
On 2020-08-27 17:06, Kyle Evans wrote: > On Thu, Aug 27, 2020 at 9:05 AM Kyle Evans wrote: >> >> On Thu, Aug 27, 2020 at 9:03 AM Cy Schubert >> wrote: >>> >>> What would you suggest in this case, where /etc/zfs/zpool.cache is newer >>> than /boot/zfs/zpool.cache? >>> >>> slippy$ lh /boot/zfs/zpool.cache /etc/zfs/zpool.cache >>> -rw-r--r-- 1 root wheel 4.6K Aug 25 07:19 /boot/zfs/zpool.cache >>> -rw-r--r-- 1 root wheel 4.7K Aug 27 06:20 /etc/zfs/zpool.cache >>> slippy$ >>> >>> Something like, for I in $(ls -t /etc/zfs/zpool.cache >>> /boot/zfs/zpool.cache) with the break? >>> >> >> /etc/zfs/zpool.cache is the new location and should generally be >> favored if it exists, I reckon. > > I retract the above. :-) ls -t makes sense. > I actually was about to agree with your first suggestion. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364865 - stable/12/sys/cam/scsi
Author: avg Date: Thu Aug 27 13:38:20 2020 New Revision: 364865 URL: https://svnweb.freebsd.org/changeset/base/364865 Log: MFC r354621-r354623 by imp: scsi_da state machine improvements r354621 Require and enforce that dareprobe() has to be called with the periph lock held. r354622 Update the softc state of the da driver before releasing the CCB. r354623 Add asserts for some state transitions Modified: stable/12/sys/cam/scsi/scsi_da.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/scsi/scsi_da.c == --- stable/12/sys/cam/scsi/scsi_da.cThu Aug 27 13:33:21 2020 (r364864) +++ stable/12/sys/cam/scsi/scsi_da.cThu Aug 27 13:38:20 2020 (r364865) @@ -2130,8 +2130,8 @@ daasync(void *callback_arg, u_int32_t code, "Capacity data has changed\n"); cam_periph_lock(periph); softc->flags &= ~DA_FLAG_PROBED; - cam_periph_unlock(periph); dareprobe(periph); + cam_periph_unlock(periph); } else if (asc == 0x28 && ascq == 0x00) { cam_periph_lock(periph); softc->flags &= ~DA_FLAG_PROBED; @@ -2142,8 +2142,8 @@ daasync(void *callback_arg, u_int32_t code, "INQUIRY data has changed\n"); cam_periph_lock(periph); softc->flags &= ~DA_FLAG_PROBED; - cam_periph_unlock(periph); dareprobe(periph); + cam_periph_unlock(periph); } } break; @@ -4593,6 +4593,14 @@ dadone_probewp(struct cam_periph *periph, union ccb *d cam_periph_assert(periph, MA_OWNED); + KASSERT(softc->state == DA_STATE_PROBE_WP, + ("State (%d) not PROBE_WP in dadone_probewp, periph %p ccb %p", + softc->state, periph, done_ccb)); +KASSERT((csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK) == DA_CCB_PROBE_WP, + ("CCB State (%lu) not PROBE_WP in dadone_probewp, periph %p ccb %p", + (unsigned long)csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK, periph, + done_ccb)); + if (softc->minimum_cmd_size > 6) { mode_hdr10 = (struct scsi_mode_header_10 *)csio->data_ptr; dev_spec = mode_hdr10->dev_spec; @@ -4625,11 +4633,11 @@ dadone_probewp(struct cam_periph *periph, union ccb *d } free(csio->data_ptr, M_SCSIDA); - xpt_release_ccb(done_ccb); if ((softc->flags & DA_FLAG_CAN_RC16) != 0) softc->state = DA_STATE_PROBE_RC16; else softc->state = DA_STATE_PROBE_RC; + xpt_release_ccb(done_ccb); xpt_schedule(periph, priority); return; } @@ -4653,6 +4661,13 @@ dadone_proberc(struct cam_periph *periph, union ccb *d csio = _ccb->csio; state = csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK; + KASSERT(softc->state == DA_STATE_PROBE_RC || softc->state == DA_STATE_PROBE_RC16, + ("State (%d) not PROBE_RC* in dadone_proberc, periph %p ccb %p", + softc->state, periph, done_ccb)); + KASSERT(state == DA_CCB_PROBE_RC || state == DA_CCB_PROBE_RC16, + ("CCB State (%lu) not PROBE_RC* in dadone_probewp, periph %p ccb %p", + (unsigned long)state, periph, done_ccb)); + lbp = 0; rdcap = NULL; rcaplong = NULL; @@ -4689,8 +4704,8 @@ dadone_proberc(struct cam_periph *periph, union ccb *d */ if (maxsector == 0x) { free(rdcap, M_SCSIDA); - xpt_release_ccb(done_ccb); softc->state = DA_STATE_PROBE_RC16; + xpt_release_ccb(done_ccb); xpt_schedule(periph, priority); return; } @@ -4796,8 +4811,8 @@ dadone_proberc(struct cam_periph *periph, union ccb *d cam_periph_assert(periph, MA_OWNED); softc->flags &= ~DA_FLAG_CAN_RC16; free(rdcap, M_SCSIDA); - xpt_release_ccb(done_ccb); softc->state = DA_STATE_PROBE_RC; + xpt_release_ccb(done_ccb); xpt_schedule(periph, priority); return; } @@ -4904,14 +4919,14 @@ dadone_proberc(struct cam_periph *periph, union ccb *d dadeleteflag(softc, DA_DELETE_WS10, 1);
Re: svn commit: r364817 - head/libexec/rc/rc.d
On 26/08/2020 16:13, Cy Schubert wrote: > Author: cy > Date: Wed Aug 26 13:13:57 2020 > New Revision: 364817 > URL: https://svnweb.freebsd.org/changeset/base/364817 > > Log: > As of r364746 (OpenZFS import) existing ZPOOLs are not imported > prior to zvol and mountcritlocal resulting in ZVOLs (swap and I probably missed some discussion, so I am curious why that is. > virtual machine UFS filesystems) being unavailable, leading to > boot failures. > We move the zpool import from zfs to a new zpool script, with the > -N option to avoid mounting datasets while making the ZPOOL's > datasets available for "legacy" mount (mountpoint=legacy) and ZVOLs > available for subsequent use for swap (in the zvol rc sript) or > for UFS or other filesystems in fstab(5), mounted by mountcritlocal. > > Reviewed by:freqlabs (previous version) > Differential Revision: https://reviews.freebsd.org/D26185 > > Added: > head/libexec/rc/rc.d/zpool (contents, props changed) [snip] > +zpool_start() > +{ > + local cachefile > + > + for cachefile in /boot/zfs/zpool.cache /etc/zfs/zpool.cache; do > + if [ -r $cachefile ]; then > + zpool import -c $cachefile -a -N I would add a break here, so that pools are imported either from one cache file or the other but not both. It makes sense to have two cache file definitions for migration, but I think that it does not make sense to split pools between the cache files. > + fi > + done > +} -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364344 - head/sys/dev/iicbus/mux
Author: avg Date: Tue Aug 18 12:14:01 2020 New Revision: 364344 URL: https://svnweb.freebsd.org/changeset/base/364344 Log: iicmux: fix a sign error in comparison Because pcell_t is unsigned both sides of the comparison were treated as such. Because of that error iicmux created all possible sub-buses even if only a subset was defined in the device tree. MFC after:1 week Modified: head/sys/dev/iicbus/mux/iicmux.c Modified: head/sys/dev/iicbus/mux/iicmux.c == --- head/sys/dev/iicbus/mux/iicmux.cTue Aug 18 11:36:38 2020 (r364343) +++ head/sys/dev/iicbus/mux/iicmux.cTue Aug 18 12:14:01 2020 (r364344) @@ -283,7 +283,7 @@ iicmux_attach_children(struct iicmux_softc *sc) } sc->childdevs[idx] = device_add_child(sc->dev, "iicbus", -1); sc->childnodes[idx] = child; - if (sc->maxbus < idx) + if (sc->maxbus < (int)idx) sc->maxbus = idx; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r364310 - in head/sys: kern vm
On 17/08/2020 18:37, Gleb Smirnoff wrote: > Author: glebius > Date: Mon Aug 17 15:37:08 2020 > New Revision: 364310 > URL: https://svnweb.freebsd.org/changeset/base/364310 > > Log: > With INVARIANTS panic immediately if M_WAITOK is requested in a > non-sleepable context. Previously only _sleep() would panic. > This will catch misuse of M_WAITOK at development stage rather > than at stress load stage. > > Reviewed by:markj > Differential Revision: https://reviews.freebsd.org/D26027 I think that there is going to be a lot of fallout from this. Will you handle it? A warning from WITNESS is one thing, a panic is another. -- Andriy Gapon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364155 - head/share/man/man4
Author: avg Date: Wed Aug 12 11:37:28 2020 New Revision: 364155 URL: https://svnweb.freebsd.org/changeset/base/364155 Log: hook cp2112.4 to the build Reported by: 0mp MFC after:1 week X-MFC with: r364144 Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileWed Aug 12 11:36:09 2020 (r364154) +++ head/share/man/man4/MakefileWed Aug 12 11:37:28 2020 (r364155) @@ -113,6 +113,7 @@ MAN=aac.4 \ cloudabi.4 \ cmx.4 \ ${_coretemp.4} \ + cp2112.4 \ ${_cpuctl.4} \ cpufreq.4 \ crypto.4 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364154 - head/share/man/man4
Author: avg Date: Wed Aug 12 11:36:09 2020 New Revision: 364154 URL: https://svnweb.freebsd.org/changeset/base/364154 Log: hook gpiokeys.4 to the build Reported by: 0mp MFC after:3 days X-MFC with: r363905 Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileWed Aug 12 10:17:17 2020 (r364153) +++ head/share/man/man4/MakefileWed Aug 12 11:36:09 2020 (r364154) @@ -171,6 +171,7 @@ MAN=aac.4 \ gif.4 \ gpio.4 \ gpioiic.4 \ + gpiokeys.4 \ gpioled.4 \ gpioths.4 \ gre.4 \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364149 - head/sys/arm/allwinner
Author: avg Date: Wed Aug 12 09:57:28 2020 New Revision: 364149 URL: https://svnweb.freebsd.org/changeset/base/364149 Log: aw_cir: in the pulse encoding the actual length is one greater than value While here change type of some variables from long to int, it's sufficient. Also, add length reporting to a couple of debug printfs. MFC after:3 weeks Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c == --- head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:56:21 2020 (r364148) +++ head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:57:28 2020 (r364149) @@ -202,9 +202,9 @@ aw_ir_read_data(struct aw_ir_softc *sc) static unsigned long aw_ir_decode_packets(struct aw_ir_softc *sc) { - unsigned long len, code; - unsigned char val, last; + unsigned int len, code; unsigned int active_delay; + unsigned char val, last; int i, bitcount; if (bootverbose) @@ -215,11 +215,11 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) (AW_IR_ACTIVE_T_C_VAL != 0 ? 128 : 1); len = active_delay; if (bootverbose) - device_printf(sc->dev, "Initial len: %ld\n", len); + device_printf(sc->dev, "Initial len: %d\n", len); for (i = 0; i < sc->dcnt; i++) { val = sc->buf[i]; if (val & VAL_MASK) - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; else { if (len > AW_IR_L1_MIN) break; @@ -227,7 +227,7 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) } } if (bootverbose) - device_printf(sc->dev, "len = %ld\n", len); + device_printf(sc->dev, "len = %d\n", len); if ((val & VAL_MASK) || (len <= AW_IR_L1_MIN)) { if (bootverbose) device_printf(sc->dev, "Bit separator error\n"); @@ -243,7 +243,7 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) break; len = 0; } else - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; } if ((!(val & VAL_MASK)) || (len <= AW_IR_L0_MIN)) { if (bootverbose) @@ -260,23 +260,25 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) val = sc->buf[i]; if (last) { if (val & VAL_MASK) - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; else { if (len > AW_IR_PMAX) { if (bootverbose) device_printf(sc->dev, - "Pulse error\n"); + "Pulse error, len=%d\n", + len); goto error_code; } last = 0; - len = val & PERIOD_MASK; + len = (val & PERIOD_MASK) + 1; } } else { if (val & VAL_MASK) { if (len > AW_IR_DMAX) { if (bootverbose) device_printf(sc->dev, - "Distant error\n"); + "Distance error, len=%d\n", + len); goto error_code; } else { if (len > AW_IR_DMID) { @@ -288,9 +290,9 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) break; /* Finish decoding */ } last = 1; - len = val & PERIOD_MASK; + len = (val & PERIOD_MASK) + 1; } else - len += val & PERIOD_MASK; + len += (val & PERIOD_MASK) + 1; } } return (code); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364148 - head/sys/arm/allwinner
Author: avg Date: Wed Aug 12 09:56:21 2020 New Revision: 364148 URL: https://svnweb.freebsd.org/changeset/base/364148 Log: aw_cir: lower activation threshold to support NECx protocol In NECx the leading mark has length of 8T as opposed to 16T in NEC, where T is 562.5 us. So, 4.5 ms. Our threshold was set to 128 * 42.7 us (derived from the sampling frequency of 3/128 MHz). So, ~5.5 ms. The new threshold is set to AW_IR_L1_MIN. I think that's a good enough lower bound for detecting the leading pulse. Also, calculations of active_delay (which is activation delay) are fixed. Previously they would be wrong if AW_IR_ACTIVE_T was anything but zero, because the value was already bit-shifted. Finally, I am not sure why the activation delay was divided by two when calculating the initial pulse length. I have not found anything that would explain or justify it. So, I removed that division. MFC after:3 weeks Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c == --- head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:52:39 2020 (r364147) +++ head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:56:21 2020 (r364148) @@ -126,8 +126,10 @@ __FBSDID("$FreeBSD$"); #defineAW_IR_DMAX 53 /* Active Thresholds */ -#defineAW_IR_ACTIVE_T ((0 & 0xff) << 16) -#defineAW_IR_ACTIVE_T_C((1 & 0xff) << 23) +#defineAW_IR_ACTIVE_T_VAL AW_IR_L1_MIN +#defineAW_IR_ACTIVE_T (((AW_IR_ACTIVE_T_VAL - 1) & 0xff) << 16) +#defineAW_IR_ACTIVE_T_C_VAL0 +#defineAW_IR_ACTIVE_T_C((AW_IR_ACTIVE_T_C_VAL & 0xff) << 23) /* Code masks */ #defineCODE_MASK 0x00ff00ff @@ -209,9 +211,9 @@ aw_ir_decode_packets(struct aw_ir_softc *sc) device_printf(sc->dev, "sc->dcnt = %d\n", sc->dcnt); /* Find Lead 1 (bit separator) */ - active_delay = (AW_IR_ACTIVE_T + 1) * (AW_IR_ACTIVE_T_C != 0 ? 128 : 1); - len = 0; - len += (active_delay >> 1); + active_delay = AW_IR_ACTIVE_T_VAL * + (AW_IR_ACTIVE_T_C_VAL != 0 ? 128 : 1); + len = active_delay; if (bootverbose) device_printf(sc->dev, "Initial len: %ld\n", len); for (i = 0; i < sc->dcnt; i++) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364147 - head/sys/arm/allwinner
Author: avg Date: Wed Aug 12 09:52:39 2020 New Revision: 364147 URL: https://svnweb.freebsd.org/changeset/base/364147 Log: aw_cir: minor cleanups MFC after:1 week Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c == --- head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:52:12 2020 (r364146) +++ head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:52:39 2020 (r364147) @@ -368,7 +368,7 @@ aw_ir_intr(void *arg) device_printf(sc->dev, "IR code status: %d\n", stat); } - sc->dcnt = 0; + aw_ir_buf_reset(sc); } if (val & AW_IR_RXINT_ROI_EN) { /* RX FIFO overflow */ @@ -469,7 +469,8 @@ aw_ir_attach(device_t dev) >intrhand)) { bus_release_resources(dev, aw_ir_spec, sc->res); device_printf(dev, "cannot setup interrupt handler\n"); - return (ENXIO); + err = ENXIO; + goto error; } /* Enable CIR Mode */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364146 - head/sys/arm/allwinner
Author: avg Date: Wed Aug 12 09:52:12 2020 New Revision: 364146 URL: https://svnweb.freebsd.org/changeset/base/364146 Log: aw_cir: add support for allwinner,sun6i-a31-ir (found, e.g., on h3) MFC after:1 week Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c == --- head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:49:25 2020 (r364145) +++ head/sys/arm/allwinner/aw_cir.c Wed Aug 12 09:52:12 2020 (r364146) @@ -134,8 +134,11 @@ __FBSDID("$FreeBSD$"); #defineINV_CODE_MASK 0xff00ff00 #defineVALID_CODE_MASK 0x00ff -#defineA10_IR 1 -#defineA13_IR 2 +enum { + A10_IR = 1, + A13_IR, + A31_IR, +}; #defineAW_IR_RAW_BUF_SIZE 128 @@ -158,6 +161,7 @@ static struct resource_spec aw_ir_spec[] = { static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-ir", A10_IR }, { "allwinner,sun5i-a13-ir", A13_IR }, + { "allwinner,sun6i-a31-ir", A31_IR }, { NULL, 0 } }; @@ -414,6 +418,7 @@ aw_ir_attach(device_t dev) sc->fifo_size = 16; break; case A13_IR: + case A31_IR: sc->fifo_size = 64; break; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364145 - head/sys/dev/gpio
Author: avg Date: Wed Aug 12 09:49:25 2020 New Revision: 364145 URL: https://svnweb.freebsd.org/changeset/base/364145 Log: gpiokeys: add evdev support Only linux,code is supported as it maps 1:1 to evdev key codes. No reverse mapping for freebsd,code yet. Reviewed by: wulf MFC after:3 weeks Differential Revision: https://reviews.freebsd.org/D25940 Modified: head/sys/dev/gpio/gpiokeys.c Modified: head/sys/dev/gpio/gpiokeys.c == --- head/sys/dev/gpio/gpiokeys.cWed Aug 12 09:42:05 2020 (r364144) +++ head/sys/dev/gpio/gpiokeys.cWed Aug 12 09:49:25 2020 (r364145) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "opt_platform.h" #include "opt_kbd.h" +#include "opt_evdev.h" #include #include @@ -56,6 +57,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #defineKBD_DRIVER_NAME "gpiokeys" #defineGPIOKEYS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -99,6 +105,9 @@ struct gpiokey struct resource *irq_res; void*intr_hl; struct mtx mtx; +#ifdef EVDEV_SUPPORT + uint32_tevcode; +#endif uint32_tkeycode; int autorepeat; struct callout debounce_callout; @@ -115,6 +124,9 @@ struct gpiokeys_softc struct gpiokey *sc_keys; int sc_total_keys; +#ifdef EVDEV_SUPPORT + struct evdev_dev*sc_evdev; +#endif keyboard_t sc_kbd; keymap_tsc_keymap; accentmap_t sc_accmap; @@ -171,26 +183,34 @@ gpiokeys_put_key(struct gpiokeys_softc *sc, uint32_t k } static void -gpiokeys_key_event(struct gpiokeys_softc *sc, uint16_t keycode, int pressed) +gpiokeys_key_event(struct gpiokeys_softc *sc, struct gpiokey *key, int pressed) { - uint32_t key; + uint32_t code; - - key = keycode & SCAN_KEYCODE_MASK; - - if (!pressed) - key |= KEY_RELEASE; - GPIOKEYS_LOCK(sc); - if (keycode & SCAN_PREFIX_E0) - gpiokeys_put_key(sc, 0xe0); - else if (keycode & SCAN_PREFIX_E1) - gpiokeys_put_key(sc, 0xe1); +#ifdef EVDEV_SUPPORT + if (key->evcode != GPIOKEY_NONE && + (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD) != 0) { + evdev_push_key(sc->sc_evdev, key->evcode, pressed); + evdev_sync(sc->sc_evdev); + } +#endif + if (key->keycode != GPIOKEY_NONE) { + code = key->keycode & SCAN_KEYCODE_MASK; + if (!pressed) + code |= KEY_RELEASE; - gpiokeys_put_key(sc, key); + if (key->keycode & SCAN_PREFIX_E0) + gpiokeys_put_key(sc, 0xe0); + else if (key->keycode & SCAN_PREFIX_E1) + gpiokeys_put_key(sc, 0xe1); + + gpiokeys_put_key(sc, code); + } GPIOKEYS_UNLOCK(sc); - gpiokeys_event_keyinput(sc); + if (key->keycode != GPIOKEY_NONE) + gpiokeys_event_keyinput(sc); } static void @@ -200,11 +220,8 @@ gpiokey_autorepeat(void *arg) key = arg; - if (key->keycode == GPIOKEY_NONE) - return; + gpiokeys_key_event(key->parent_sc, key, 1); - gpiokeys_key_event(key->parent_sc, key->keycode, 1); - callout_reset(>repeat_callout, key->repeat, gpiokey_autorepeat, key); } @@ -217,12 +234,9 @@ gpiokey_debounced_intr(void *arg) key = arg; - if (key->keycode == GPIOKEY_NONE) - return; - gpio_pin_is_active(key->pin, ); if (active) { - gpiokeys_key_event(key->parent_sc, key->keycode, 1); + gpiokeys_key_event(key->parent_sc, key, 1); if (key->autorepeat) { callout_reset(>repeat_callout, key->repeat_delay, gpiokey_autorepeat, key); @@ -232,7 +246,7 @@ gpiokey_debounced_intr(void *arg) if (key->autorepeat && callout_pending(>repeat_callout)) callout_stop(>repeat_callout); - gpiokeys_key_event(key->parent_sc, key->keycode, 0); + gpiokeys_key_event(key->parent_sc, key, 0); } } @@ -301,6 +315,10 @@ gpiokeys_attach_key(struct gpiokeys_softc *sc, phandle if (key->keycode == GPIOKEY_NONE) device_printf(sc->sc_dev, "<%s> failed to map linux,code value 0x%x\n", key_name, code); +#ifdef EVDEV_SUPPORT + key->evcode = code; + evdev_support_key(sc->sc_evdev, code); +#endif } else device_printf(sc->sc_dev, "<%s> no linux,code or freebsd,code property\n", @@ -365,7 +383,6 @@
svn commit: r364144 - head/share/man/man4
Author: avg Date: Wed Aug 12 09:42:05 2020 New Revision: 364144 URL: https://svnweb.freebsd.org/changeset/base/364144 Log: add a manual page for cp2112 MFC after:1 week Added: head/share/man/man4/cp2112.4 (contents, props changed) Added: head/share/man/man4/cp2112.4 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/cp2112.4Wed Aug 12 09:42:05 2020 (r364144) @@ -0,0 +1,87 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2020 Andriy Gapon +.\" +.\" 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$ +.\" +.Dd August 12, 2020 +.Dt CP2112 4 +.Os +.Sh NAME +.Nm cp2112 +.Nd driver for a USB GPIO and I2C peripheral device +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device cp2112" +.Cd "device usb" +.Cd "device gpio" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +cp2112_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for Silicon Labs CP2112 device. +The device has 8 general purpose I/O pins and an I2C controller that supports +a subset of the I2C protocol. +.Pp +All pins support both input and output modes. +An output pin can be configured either for open-drain or push-pull operation. +Pins 0, 1 and 7 support special functions: I2C transmit indication, +I2C receive indication and clock output respectively. +At the moment the +.Nm +driver does not provide a way to enable and configure the special functions. +.Pp +The I2C controller supports read transactions with up to 512 bytes of data, +write transactions with up to 61 bytes of data and a write followed by +the repeated start followed by a read transactions where the write can be +up to 16 bytes and the read can be up to 512 bytes. +Zero length transfers are not supported. +The +.Nm +driver creates a +.Xr gpio 4 +and +.Xr iicbus 4 +child buses to expose the respective functions. +.Sh SEE ALSO +.Xr gpio 4 , +.Xr iicbus 4 , +.Xr usb 4 +.Sh HISTORY +The +.Nm +driver and this manual page was written by +.An Andriy Gapon Aq Mt a...@freebsd.org . ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364143 - head/sys/dev/usb/misc
Author: avg Date: Wed Aug 12 09:07:07 2020 New Revision: 364143 URL: https://svnweb.freebsd.org/changeset/base/364143 Log: cp2112: a number of cleanups and improvements - hoist all request / response structures from function level to top level - replace magic numeric literals with constants - regroup types, data and functions - remove setting of the id field in responses as they are completely overwritten with data from the device - centralize setting of the id field as it is always set to the value of request type - fix setting and querying of open-drain vs push-pull configuration of an output pin -- it's always in one of those configurations - detect special pin configurations: a pin in a special configuration is neither general purpose input or output - there is still no support for setting special configurations MFC after:2 weeks Modified: head/sys/dev/usb/misc/cp2112.c Modified: head/sys/dev/usb/misc/cp2112.c == --- head/sys/dev/usb/misc/cp2112.c Wed Aug 12 07:00:06 2020 (r364142) +++ head/sys/dev/usb/misc/cp2112.c Wed Aug 12 09:07:07 2020 (r364143) @@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$"); #defineUSB_DEBUG_VAR usb_debug #include +#defineSIZEOF_FIELD(_s, _f)sizeof(((struct _s *)NULL)->_f) + #defineCP2112GPIO_LOCK(sc) sx_xlock(>gpio_lock) #defineCP2112GPIO_UNLOCK(sc) sx_xunlock(>gpio_lock) #defineCP2112GPIO_LOCKED(sc) sx_assert(>gpio_lock, SX_XLOCKED) @@ -93,8 +95,13 @@ __FBSDID("$FreeBSD$"); #defineCP2112_REQ_LOCK 0x20 #defineCP2112_REQ_USB_CFG 0x21 +#defineCP2112_IIC_MAX_READ_LEN 512 #defineCP2112_IIC_REPSTART_VER 2 /* Erratum CP2112_E10. */ +#defineCP2112_GPIO_SPEC_CLK7 1 /* Pin 7 is clock output. */ +#defineCP2112_GPIO_SPEC_TX02 /* Pin 0 pulses on USB TX. */ +#defineCP2112_GPIO_SPEC_RX14 /* Pin 1 pulses on USB RX. */ + #defineCP2112_IIC_STATUS0_IDLE 0 #defineCP2112_IIC_STATUS0_BUSY 1 #defineCP2112_IIC_STATUS0_CMP 2 @@ -104,7 +111,112 @@ __FBSDID("$FreeBSD$"); #defineCP2112_IIC_STATUS1_TIMEOUT_BUS 1 #defineCP2112_IIC_STATUS1_ARB_LOST 2 +/* CP2112_REQ_VERSION */ +struct version_request { + uint8_t id; + uint8_t part_num; + uint8_t version; +} __packed; +/* CP2112_REQ_GPIO_GET */ +struct gpio_get_req { + uint8_t id; + uint8_t state; +} __packed; + +/* CP2112_REQ_GPIO_SET */ +struct gpio_set_req { + uint8_t id; + uint8_t state; + uint8_t mask; +} __packed; + +/* CP2112_REQ_GPIO_CFG */ +struct gpio_config_req { + uint8_t id; + uint8_t output; + uint8_t pushpull; + uint8_t special; + uint8_t divider; +} __packed; + +/* CP2112_REQ_SMB_XFER_STATUS_REQ */ +struct i2c_xfer_status_req { + uint8_t id; + uint8_t request; +} __packed; + +/* CP2112_REQ_SMB_XFER_STATUS_RESP */ +struct i2c_xfer_status_resp { + uint8_t id; + uint8_t status0; + uint8_t status1; + uint16_t status2; + uint16_t status3; +} __packed; + +/* CP2112_REQ_SMB_READ_FORCE_SEND */ +struct i2c_data_read_force_send_req { + uint8_t id; + uint16_t len; +} __packed; + +/* CP2112_REQ_SMB_READ_RESPONSE */ +struct i2c_data_read_resp { + uint8_t id; + uint8_t status; + uint8_t len; + uint8_t data[61]; +} __packed; + +/* CP2112_REQ_SMB_READ */ +struct i2c_write_read_req { + uint8_t id; + uint8_t slave; + uint16_t rlen; + uint8_t wlen; + uint8_t wdata[16]; +} __packed; + +/* CP2112_REQ_SMB_WRITE */ +struct i2c_read_req { + uint8_t id; + uint8_t slave; + uint16_t len; +} __packed; + +/* CP2112_REQ_SMB_WRITE_READ */ +struct i2c_write_req { + uint8_t id; + uint8_t slave; + uint8_t len; + uint8_t data[61]; +} __packed; + +/* CP2112_REQ_SMB_CFG */ +struct i2c_cfg_req { + uint8_t id; + uint32_tspeed; /* Hz */ + uint8_t slave_addr; /* ACK only */ + uint8_t auto_send_read; /* boolean */ + uint16_twrite_timeout; /* 0-1000 ms, 0 ~ no timeout */ + uint16_tread_timeout; /* 0-1000 ms, 0 ~ no timeout */ + uint8_t scl_low_timeout;/* boolean */ + uint16_tretry_count;/* 1-1000, 0 ~ forever */ +} __packed; + +enum cp2112_out_mode { + OUT_OD, + OUT_PP, + OUT_KEEP +}; + +enum { + CP2112_INTR_OUT = 0, + CP2112_INTR_IN, + CP2112_N_TRANSFER, +}; + struct cp2112_softc { device_tsc_gpio_dev; device_tsc_iic_dev; @@ -120,10 +232,38 @@ struct cp2112gpio_softc { struct gpio_pin
svn commit: r363951 - in head/sys: conf dev/usb/misc modules/usb modules/usb/cp2112
Author: avg Date: Thu Aug 6 13:41:42 2020 New Revision: 363951 URL: https://svnweb.freebsd.org/changeset/base/363951 Log: cp2112: driver for the namesake GPIO and I2C master gadget Documentation: - CP2112 Datasheet https://www.silabs.com/documents/public/data-sheets/cp2112-datasheet.pdf - AN495: CP2112 Interface Specification https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf - CP2112 Errata https://www.silabs.com/documents/public/errata/cp2112-errata.pdf The logic is implemented as three sub-drivers. The parent driver claims the USB device and creates two child devices. One acts as a GPIO controller and the other is an I2C controller. Tested with CP2112 revision F02. Both features seem to work. HTU21 sensor was used as an I2C slave. Reviewed by: adrian, hselasky MFC after:2 weeks Relnotes: maybe Differential Revision: https://reviews.freebsd.org/D25359 Added: head/sys/dev/usb/misc/cp2112.c (contents, props changed) head/sys/modules/usb/cp2112/ head/sys/modules/usb/cp2112/Makefile (contents, props changed) Modified: head/sys/conf/files head/sys/modules/usb/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Thu Aug 6 13:25:04 2020(r363950) +++ head/sys/conf/files Thu Aug 6 13:41:42 2020(r363951) @@ -3331,6 +3331,7 @@ dev/usb/serial/usb_serial.c optional ucom | u3g | uar # # USB misc drivers # +dev/usb/misc/cp2112.c optional cp2112 dev/usb/misc/ufm.c optional ufm dev/usb/misc/udbp.coptional udbp dev/usb/misc/ugold.c optional ugold Added: head/sys/dev/usb/misc/cp2112.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb/misc/cp2112.c Thu Aug 6 13:41:42 2020 (r363951) @@ -0,0 +1,1381 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) Andriy Gapon + * + * 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. + * + */ + +/* + * Hardware information links: + * - CP2112 Datasheet + * https://www.silabs.com/documents/public/data-sheets/cp2112-datasheet.pdf + * - AN495: CP2112 Interface Specification + * https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf + * - CP2112 Errata + * https://www.silabs.com/documents/public/errata/cp2112-errata.pdf + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include "iicbus_if.h" + +#include +#include +#include +#include +#include "usbdevs.h" + +#defineUSB_DEBUG_VAR usb_debug +#include + +#defineCP2112GPIO_LOCK(sc) sx_xlock(>gpio_lock) +#defineCP2112GPIO_UNLOCK(sc) sx_xunlock(>gpio_lock) +#defineCP2112GPIO_LOCKED(sc) sx_assert(>gpio_lock, SX_XLOCKED) + +#defineCP2112_PART_NUM 0x0c +#defineCP2112_GPIO_COUNT 8 +#defineCP2112_REPORT_SIZE 64 + +#defineCP2112_REQ_RESET0x1 +#defineCP2112_REQ_GPIO_CFG 0x2 +#defineCP2112_REQ_GPIO_GET 0x3 +#defineCP2112_REQ_GPIO_SET 0x4 +#defineCP2112_REQ_VERSION 0x5 +#defineCP2112_REQ_SMB_CFG 0x6 + +#defineCP2112_REQ_SMB_READ 0x10 +#defineCP2112_REQ_SMB_WRITE_READ 0x11 +#define
svn commit: r363948 - head/sys/arm/allwinner/clkng
Author: avg Date: Thu Aug 6 11:18:06 2020 New Revision: 363948 URL: https://svnweb.freebsd.org/changeset/base/363948 Log: ccu_sun8i_r: minor comment update MFC after:1 week Modified: head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Modified: head/sys/arm/allwinner/clkng/ccu_sun8i_r.c == --- head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Thu Aug 6 10:12:39 2020 (r363947) +++ head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Thu Aug 6 11:18:06 2020 (r363948) @@ -119,7 +119,7 @@ NM_CLK(r_ccu_ir_clk, "ir", r_ccu_ir_parents,/* names, parents */ 0x54, /* offset */ 0, 4, 0, 0,/* N factor */ -16, 2, 0, 0, /* M flags */ +16, 2, 0, 0, /* M factor */ 24, 2, /* mux */ 31,/* gate */ AW_CLK_HAS_MUX | AW_CLK_REPARENT | AW_CLK_HAS_GATE);/* flags */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r363944 - stable/12/sys/dev/iicbus
Author: avg Date: Thu Aug 6 08:06:07 2020 New Revision: 363944 URL: https://svnweb.freebsd.org/changeset/base/363944 Log: MFC r362042: iicbb: rebuild the bit-banging algorithms using different primitives I2C_SET was quite inflexible, it used too long delays as well as some unnecessary delays. The new building blocks are iicbb_clockin and iicbb_clockout. The former sets SDA and starts the high period of SCL, the latter executes the low period of SCL. What happens during the high phase depends on the operation. For writes we just hold both lines, for reads we poll SDA. S, Sr and P change SDA in the middle of the high period. Also, the calculation of udelay has been updated, so that the resulting period more closely corresponds the requested bus frequency. There is a new knob, io_delay, that allows to further adjust udelay based on the estimated latency of pin toggling operations. Finally, I slightly changed debug tracing and added error indicators to it. The debug prints are compiled in but disabled by default. This can be of use if there is any fallout from this change. Modified: stable/12/sys/dev/iicbus/iicbb.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/iicbb.c == --- stable/12/sys/dev/iicbus/iicbb.cThu Aug 6 07:26:31 2020 (r363943) +++ stable/12/sys/dev/iicbus/iicbb.cThu Aug 6 08:06:07 2020 (r363944) @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); struct iicbb_softc { device_t iicbus; u_int udelay; /* signal toggle delay in usec */ + u_int io_latency; /* approximate pin toggling latency */ u_int scl_low_timeout; }; @@ -86,6 +87,7 @@ static int iicbb_probe(device_t); static int iicbb_callback(device_t, int, caddr_t); static int iicbb_start(device_t, u_char, int); +static int iicbb_repstart(device_t, u_char, int); static int iicbb_stop(device_t); static int iicbb_write(device_t, const char *, int, int *, int); static int iicbb_read(device_t, char *, int, int *, int, int); @@ -109,7 +111,7 @@ static device_method_t iicbb_methods[] = { /* iicbus interface */ DEVMETHOD(iicbus_callback, iicbb_callback), DEVMETHOD(iicbus_start, iicbb_start), - DEVMETHOD(iicbus_repeated_start, iicbb_start), + DEVMETHOD(iicbus_repeated_start, iicbb_repstart), DEVMETHOD(iicbus_stop, iicbb_stop), DEVMETHOD(iicbus_write, iicbb_write), DEVMETHOD(iicbus_read, iicbb_read), @@ -160,6 +162,11 @@ iicbb_attach(device_t dev) SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "scl_low_timeout", CTLFLAG_RWTUN, >scl_low_timeout, 0, "SCL low timeout, microseconds"); + SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, + "io_latency", CTLFLAG_RWTUN, >io_latency, + 0, "Estimate of pin toggling latency, microseconds"); + bus_generic_attach(dev); return (0); } @@ -217,80 +224,105 @@ iicbb_print_child(device_t bus, device_t dev) return (retval); } +#define IICBB_DEBUG +#ifdef IICBB_DEBUG +static int i2c_debug = 0; + +static SYSCTL_NODE(_hw, OID_AUTO, i2c, CTLFLAG_RW, 0, "i2c debug"); +SYSCTL_INT(_hw_i2c, OID_AUTO, iicbb_debug, CTLFLAG_RWTUN, +_debug, 0, "Enable i2c bit-banging driver debug"); + +#define I2C_DEBUG(x) do {\ + if (i2c_debug) (x); \ + } while (0) +#else +#define I2C_DEBUG(x) +#endif + #defineI2C_GETSDA(dev) (IICBB_GETSDA(device_get_parent(dev))) #defineI2C_SETSDA(dev, x) (IICBB_SETSDA(device_get_parent(dev), x)) #defineI2C_GETSCL(dev) (IICBB_GETSCL(device_get_parent(dev))) #defineI2C_SETSCL(dev, x) (IICBB_SETSCL(device_get_parent(dev), x)) -#define I2C_SET(sc, dev, ctrl, val) do { \ - iicbb_setscl(dev, ctrl);\ - I2C_SETSDA(dev, val); \ - DELAY(sc->udelay); \ - } while (0) - -static int i2c_debug = 0; -#define I2C_DEBUG(x) do {\ - if (i2c_debug) (x); \ - } while (0) - -#define I2C_LOG(format,args...)do {\ - printf(format, args); \ - } while (0) - -static void -iicbb_setscl(device_t dev, int val) +static int +iicbb_waitforscl(device_t dev) { struct iicbb_softc *sc = device_get_softc(dev); - sbintime_t now, end; - int fast_timeout; + sbintime_t fast_timeout; + sbintime_t now, timeout; - I2C_SETSCL(dev, val); - DELAY(sc->udelay); - - /* Pulling low cannot fail. */ -