From owner-svn-src-head@freebsd.org Sun Oct 30 02:57:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF49BC26484; Sun, 30 Oct 2016 02:57:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B11702A2; Sun, 30 Oct 2016 02:57:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9U2vlWN011914; Sun, 30 Oct 2016 02:57:47 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9U2vlK7011913; Sun, 30 Oct 2016 02:57:47 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610300257.u9U2vlK7011913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 30 Oct 2016 02:57:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308100 - head/lib/libgcc_eh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 02:57:49 -0000 Author: emaste Date: Sun Oct 30 02:57:47 2016 New Revision: 308100 URL: https://svnweb.freebsd.org/changeset/base/308100 Log: compile libunwind c source with -fexceptions When an exception is thrown the unwinder must unwind its own C source (starting with _Unwind_RaiseException in UnwindLevel1.c), so it needs to be built with unwinding data. Modified: head/lib/libgcc_eh/Makefile.inc Modified: head/lib/libgcc_eh/Makefile.inc ============================================================================== --- head/lib/libgcc_eh/Makefile.inc Sat Oct 29 23:25:12 2016 (r308099) +++ head/lib/libgcc_eh/Makefile.inc Sun Oct 30 02:57:47 2016 (r308100) @@ -8,15 +8,20 @@ STATIC_CFLAGS+=${PICFLAG} -fvisibility=h .PATH: ${COMPILERRTDIR}/lib/builtins .PATH: ${UNWINDSRCDIR} -SRCS+= gcc_personality_v0.c -SRCS+= int_util.c -SRCS+= Unwind-EHABI.cpp -SRCS+= Unwind-sjlj.c -SRCS+= UnwindLevel1-gcc-ext.c -SRCS+= UnwindLevel1.c -SRCS+= UnwindRegistersRestore.S -SRCS+= UnwindRegistersSave.S -SRCS+= libunwind.cpp +SRCS_EXC+= gcc_personality_v0.c +SRCS_EXC+= int_util.c +SRCS_EXC+= Unwind-EHABI.cpp +SRCS_EXC+= Unwind-sjlj.c +SRCS_EXC+= UnwindLevel1-gcc-ext.c +SRCS_EXC+= UnwindLevel1.c +SRCS_EXC+= UnwindRegistersRestore.S +SRCS_EXC+= UnwindRegistersSave.S +SRCS_EXC+= libunwind.cpp + +SRCS+= ${SRCS_EXC} +.for file in ${SRCS_EXC:M*.c} +CFLAGS.${file}+= -fexceptions +.endfor CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY .if empty(CXXFLAGS:M-std=*) From owner-svn-src-head@freebsd.org Sun Oct 30 09:38:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49BCBC25666; Sun, 30 Oct 2016 09:38:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BD54BB3; Sun, 30 Oct 2016 09:38:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9U9cATC064811; Sun, 30 Oct 2016 09:38:10 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9U9cAvu064810; Sun, 30 Oct 2016 09:38:10 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610300938.u9U9cAvu064810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 30 Oct 2016 09:38:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308101 - head/sys/dev/hwpmc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 09:38:11 -0000 Author: avg Date: Sun Oct 30 09:38:10 2016 New Revision: 308101 URL: https://svnweb.freebsd.org/changeset/base/308101 Log: hwpmc: fix a race between amd_stop_pmc and amd_intr It is possible that wrmsr in amd_stop_pmc() causes an overflow in a counter that it disables. In that case a non-maskable interrupt is generated. The interrupt handler code was written in such a way that it would re-enable the counter. That would lead to an unexpected interrupt later on. This problem was easy to reproduce with $ pmcstat -T -P instructions -t $pid if the target process is sufficiently busy and there are context switches from time to time. There would be a lot of interrupts to "race" with amd_stop_pmc() called during the context switches. The problem affected only AMD processors. While there, trace whether amd_intr() claimed an interrupt. Reviewed by: jhb MFC after: 2 weeks Modified: head/sys/dev/hwpmc/hwpmc_amd.c Modified: head/sys/dev/hwpmc/hwpmc_amd.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_amd.c Sun Oct 30 02:57:47 2016 (r308100) +++ head/sys/dev/hwpmc/hwpmc_amd.c Sun Oct 30 09:38:10 2016 (r308101) @@ -689,12 +689,13 @@ amd_intr(int cpu, struct trapframe *tf) error = pmc_process_interrupt(cpu, PMC_HR, pm, tf, TRAPF_USERMODE(tf)); if (error == 0) - wrmsr(evsel, config | AMD_PMC_ENABLE); + wrmsr(evsel, config); } atomic_add_int(retval ? &pmc_stats.pm_intr_processed : &pmc_stats.pm_intr_ignored, 1); + PMCDBG1(MDP,INT,2, "retval=%d", retval); return (retval); } From owner-svn-src-head@freebsd.org Sun Oct 30 09:45:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6F15C258E1; Sun, 30 Oct 2016 09:45:33 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com [IPv6:2607:f8b0:400e:c00::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9E0F5C7; Sun, 30 Oct 2016 09:45:33 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: by mail-pf0-x22f.google.com with SMTP id 197so61091936pfu.0; Sun, 30 Oct 2016 02:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:reply-to:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3aATrhi+s1cy+t8zYwsBBuWiTDchdvYlDhJHr5+FEgQ=; b=0rtcfC5IpO0vBVg+/wET87Xscsi2zT1P9btd6Lq6sK/xMCJFKkusReuhIa/YTcb9DR REBRH4CCIIrlLG3kPdZJhDt4mnFVxjZ1BpQ08Ogz6EexFDzadTLRrYN06eMhVW+NcOo0 A+lE2FVRF0Ahb6MuA7TBrtPoUPpeaODiRwXUFmfSt2cS7DgfYSqHWEpm8ZwOKon1Mmj0 f+uN+m3n7N7otpwsB4ysjAnsXnCOhCiuqG/RP6hrygpZsJWZDY5m43qdDzGm+0F7SxSl QSGOjOUTHMzccIOjYrI3Oi1l9mqAcJJ6sj05+DhqlaTvYW4YrsymolWW3UdpcgyJgLhl 3YDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:reply-to:subject:to:references:from:cc :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=3aATrhi+s1cy+t8zYwsBBuWiTDchdvYlDhJHr5+FEgQ=; b=NXjnxgN5nd+vz8tSzCnyrLfhwP3oXy/vBxQh3XefTZivx+J+A5lNRy9SzMsrtK7ftE L6I5KCZ/nOiCyDykHTsv0xa//spE1SjO0ge9WXzaEdsqFEw4Qdk2tvl8+jVckppy9Rwl DZ1uGJY5Oo8HEwyHjW4kDPzRXpXHaKP8T+d4ZqUseJ2ktV4VcHT2U0JJSN8IJ2b10vn0 vPhytP9DiWGd6BNPzwAaLFn5BoOxdJA9qEzCJves6GjeCIRyU9CHdS/8GsdNONQDQ6la qwTBjr/s9XUaA450ze64h56JpYWPzKfld72g+D3nBAR1vyjnblqndOt1bcxLDTZKZIY4 tPOQ== X-Gm-Message-State: ABUngvfetHtfSIsrJYL4+Y8csoMI1kiOthxZzyB3S0r6Vnu6NGQuY8UySH03uTfiiwBUZQ== X-Received: by 10.98.18.220 with SMTP id 89mr40193122pfs.71.1477820733008; Sun, 30 Oct 2016 02:45:33 -0700 (PDT) Received: from ?IPv6:2001:44b8:31ae:7b01:bcc5:61de:d926:8238? (2001-44b8-31ae-7b01-bcc5-61de-d926-8238.static.ipv6.internode.on.net. [2001:44b8:31ae:7b01:bcc5:61de:d926:8238]) by smtp.gmail.com with ESMTPSA id l187sm29397176pfc.0.2016.10.30.02.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Oct 2016 02:45:32 -0700 (PDT) Sender: Kubilay Kocak Reply-To: koobs@FreeBSD.org Subject: Re: svn commit: r306577 - head/sys/netinet To: Eric van Gyzen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610020142.u921gjsJ016528@repo.freebsd.org> From: Kubilay Kocak Cc: Steven Hartland , Gleb Smirnoff Message-ID: <46cdc5d8-75ee-16f6-ee9d-d9c14cb5098e@FreeBSD.org> Date: Sun, 30 Oct 2016 20:44:13 +1100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Thunderbird/51.0a2 MIME-Version: 1.0 In-Reply-To: <201610020142.u921gjsJ016528@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-AU Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 09:45:33 -0000 On 2/10/2016 12:42 PM, Eric van Gyzen wrote: > Author: vangyzen Date: Sun Oct 2 01:42:45 2016 New Revision: 306577 > URL: https://svnweb.freebsd.org/changeset/base/306577 > > Log: Add GARP retransmit capability > > A single gratuitous ARP (GARP) is always transmitted when an IPv4 > address is added to an interface, and that is usually sufficient. > However, in some circumstances, such as when a shared address is > passed between cluster nodes, this single GARP may occasionally be > dropped or lost. This can lead to neighbors on the network link > working with a stale ARP cache and sending packets destined for that > address to the node that previously owned the address, which may not > respond. > > To avoid this situation, GARP retransmissions can be enabled by > setting the net.link.ether.inet.garp_rexmit_count sysctl to a value > greater than zero. The setting represents the maximum number of > retransmissions. The interval between retransmissions is calculated > using an exponential backoff algorithm, doubling each time, so the > retransmission intervals are: {1, 2, 4, 8, 16, ...} (seconds). > > Due to the exponential backoff algorithm used for the interval > between GARP retransmissions, the maximum number of retransmissions > is limited to 16 for sanity. This limit corresponds to a maximum > interval between retransmissions of 2^16 seconds ~= 18 hours. > Increasing this limit is possible, but sending out GARPs spaced days > apart would be of little use. > Thanks for this David & Eric I presume this is (or would be) quite complementary to D4111 [1] (Gratuitous ARP's for lagg(4) failover) when it lands? I'm thinking particularly given the various states upstream switch ports can have during topology changes. [1] https://reviews.freebsd.org/D4111 ./koobs From owner-svn-src-head@freebsd.org Sun Oct 30 12:15:35 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EA49C1B819; Sun, 30 Oct 2016 12:15:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 050B712B9; Sun, 30 Oct 2016 12:15:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UCFYdi024852; Sun, 30 Oct 2016 12:15:34 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UCFXJe024840; Sun, 30 Oct 2016 12:15:33 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610301215.u9UCFXJe024840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 30 Oct 2016 12:15:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308104 - in head: . share/man/man4 sys/conf sys/dev/chromebook_platform sys/dev/cyapa sys/dev/ichiic sys/dev/iicbus sys/dev/isl sys/modules sys/modules/chromebook_platform sys/modules/... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 12:15:35 -0000 Author: avg Date: Sun Oct 30 12:15:33 2016 New Revision: 308104 URL: https://svnweb.freebsd.org/changeset/base/308104 Log: add iic interface to ig4 driver, move isl and cyapa to iicbus Summary: The hardware does not expose a classic SMBus interface. Instead it has a lower level interface that can express a far richer I2C protocol than what smbus offers. However, the interface does not provide a way to explicitly generate the I2C stop and start conditions. It's only possible to request that the stop condition is generated after transferring the next byte in either direction. So, at least one data byte must always be transferred. Thus, some I2C sequences are impossible to generate, e.g., an equivalent of smbus quick command (---). At the same time isl(4) and cyapa(4) are moved to iicbus and now they use iicbus_transfer for communication. Previously they used smbus_trans() interface that is not defined by the SMBus protocol and was implemented only by ig4(4). In fact, that interface was impossible to implement for the typical SMBus controllers like intpm(4) or ichsmb(4) where a type of the SMBus command must be programmed. The plan is to remove smbus_trans() and all its uses. As an aside, the smbus_trans() method deviates from the standard, but perhaps backwards, FreeBSD convention of using 8-bit slave addresses (shifted by 1 bit to the left). The method expects 7-bit addresses. There is a user facing consequence of this change. A user must now provide device hints for isl and cyapa that specify an iicbus to use and a slave address on it. On Chromebook hardware where isl and cyapa devices are commonly found it is also possible to use a new chromebook_platform(4) driver that automatically configures isl and cyapa devices. There is no need to provide the device hints in that case, Right now smbus(4) driver tries to discover all slaves on the bus. That is very dangerous. Fortunately, the probing code uses smbus_trans() to do its job, so it is really enabled for ig4 only. The plan is to remove that auto-probing code and smbus_trans(). Tested by: grembo, Matthias Apitz (w/o chromebook_platform) Discussed with: grembo, imp Reviewed by: wblock (docs) MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D8172 Added: head/share/man/man4/chromebook_platform.4 (contents, props changed) head/sys/dev/chromebook_platform/ head/sys/dev/chromebook_platform/chromebook_platform.c (contents, props changed) head/sys/modules/chromebook_platform/ head/sys/modules/chromebook_platform/Makefile (contents, props changed) Modified: head/UPDATING head/share/man/man4/cyapa.4 head/share/man/man4/ig4.4 head/share/man/man4/isl.4 head/sys/conf/files head/sys/dev/cyapa/cyapa.c head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_var.h head/sys/dev/iicbus/iicbus.c head/sys/dev/isl/isl.c head/sys/modules/Makefile head/sys/modules/i2c/controllers/ichiic/Makefile head/sys/modules/i2c/cyapa/Makefile head/sys/modules/i2c/isl/Makefile Modified: head/UPDATING ============================================================================== --- head/UPDATING Sun Oct 30 11:45:01 2016 (r308103) +++ head/UPDATING Sun Oct 30 12:15:33 2016 (r308104) @@ -51,6 +51,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 ****************************** SPECIAL WARNING: ****************************** +20161030: + isl(4) and cyapa(4) drivers now require a new driver, + chromebook_platform(4), to work properly on Chromebook-class hardware. + On other types of hardware the drivers may need to be configured using + device hints. Please see the corresponding manual pages for details. + 20161017: The urtwn(4) driver was merged into rtwn(4) and now consists of rtwn(4) main module + rtwn_usb(4) and rtwn_pci(4) bus-specific Added: head/share/man/man4/chromebook_platform.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/chromebook_platform.4 Sun Oct 30 12:15:33 2016 (r308104) @@ -0,0 +1,68 @@ +.\" Copyright (c) 2016 Andriy Gapon +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd October 13, 2016 +.Dt CHROMEBOOK_PLATFORM 4 +.Os +.Sh NAME +.Nm chromebook_platform +.Nd support driver for hardware on various Chromebook models +.Sh SYNOPSIS +To compile this driver into the kernel, place the following lines into +the kernel configuration file: +.Bd -ragged -offset indent +.Cd "device chromebook_platform" +.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 +chromebook_platform_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides automatic configuration for devices that cannot be enumerated +or safely probed. +In particular, I2C peripherals are different from model to model. +.Nm +has a model-specific information about the I2C peripherals, their drivers, +their bus attachments and slave addresses. +.Pp +Note that +.Nm +does not load driver modules for the peripherals. +Those have to be compiled into the kernel or loaded separately. +.Sh SEE ALSO +.Xr cyapa 4 , +.Xr iicbus 4 , +.Xr isl 4 , +.Sh AUTHORS +.An -nosplit +The +.Nm +driver and this manual page were written by +.An Andriy Gapon Aq Mt avg@FreeBSD.org . Modified: head/share/man/man4/cyapa.4 ============================================================================== --- head/share/man/man4/cyapa.4 Sun Oct 30 11:45:01 2016 (r308103) +++ head/share/man/man4/cyapa.4 Sun Oct 30 12:15:33 2016 (r308104) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 25, 2015 +.Dd October 03, 2016 .Dt CYAPA 4 .Os .Sh NAME @@ -36,7 +36,7 @@ the kernel configuration file: .Bd -ragged -offset indent .Cd "device cyapa" .Cd "device ig4" -.Cd "device smbus" +.Cd "device iicbus" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in @@ -45,6 +45,13 @@ Alternatively, to load the driver as a m cyapa_load="YES" ig4_load="YES" .Ed +.Pp +In +.Pa /boot/device.hints : +.Cd hint.cyapa.0.at="iicbus0" +.Cd hint.cyapa.0.addr="0xCE" +.Cd hint.cyapa.1.at="iicbus1" +.Cd hint.cyapa.1.addr="0xCE" .Sh DESCRIPTION The .Nm @@ -86,6 +93,20 @@ The upper right corner issues a MIDDLE b The lower right corner issues a RIGHT button. Optionally, tap to click can be enabled (see below). .El +.Pp +On a system using +.Xr device.hints 5 , +these values are configurable for +.Nm : +.Bl -tag -width "hint.cyapa.%d.addr" +.It Va hint.cyapa.%d.at +target +.Xr iicbus 4 . +.It Va hint.cyapa.%d.addr +.Nm +i2c address on the +.Xr iicbus 4 . +.El .Sh SYSCTL VARIABLES These .Xr sysctl 8 @@ -175,7 +196,7 @@ file: .Dl debug.cyapa_enable_tapclick=2 .Sh SEE ALSO .Xr ig4 4 , -.Xr smbus 4 , +.Xr iicbus 4 , .Xr sysmouse 4 , .Xr moused 8 .Sh AUTHORS @@ -195,6 +216,6 @@ This manual page was written by .Sh BUGS The .Nm -driver detects the device based on its I2C address (0x67). +driver detects the device from the I2C address. This might have unforeseen consequences if the initialization sequence is sent to an unknown device at that address. Modified: head/share/man/man4/ig4.4 ============================================================================== --- head/share/man/man4/ig4.4 Sun Oct 30 11:45:01 2016 (r308103) +++ head/share/man/man4/ig4.4 Sun Oct 30 12:15:33 2016 (r308104) @@ -24,18 +24,18 @@ .\" .\" $FreeBSD$ .\" -.Dd May 30, 2015 +.Dd October 03, 2016 .Dt IG4 4 .Os .Sh NAME .Nm ig4 -.Nd Intel(R) fourth generation mobile CPU integrated I2C SMBus driver +.Nd Intel(R) fourth generation mobile CPU integrated I2C driver .Sh SYNOPSIS To compile this driver into the kernel, place the following lines into the kernel configuration file: .Bd -ragged -offset indent .Cd "device ig4" -.Cd "device smbus" +.Cd "device iicbus" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in @@ -46,9 +46,10 @@ ig4_load="YES" .Sh DESCRIPTION The .Nm -driver provides access to peripherals attached to an I2C SMB controller. +driver provides access to peripherals attached to an I2C controller. +.Sh HARDWARE .Nm -supports the SMBus controller found in fourth generation Intel(R) Core(TM) +supports the I2C controllers found in fourth generation Intel(R) Core(TM) processors based on the mobile U-processor line for intelligent systems. This includes the i7-4650U, i5-4300U, i3-4010U, and 2980U. .Sh SYSCTL VARIABLES @@ -57,13 +58,15 @@ These variables are available: .Bl -tag -width "debug.ig4_dump" .It Va debug.ig4_dump -Setting this to a non-zero value dumps controller registers to console and -syslog once. -The sysctl resets to zero immediately. +This sysctl is a zero-based bit mask. +When any of the bits are set, a register dump is printed for +every I2C transfer on an +.Nm +device with the same unit number. .El .Sh SEE ALSO -.Xr smb 4 , -.Xr smbus 4 +.Xr iic 4 , +.Xr iicbus 4 .Sh AUTHORS .An -nosplit The Modified: head/share/man/man4/isl.4 ============================================================================== --- head/share/man/man4/isl.4 Sun Oct 30 11:45:01 2016 (r308103) +++ head/share/man/man4/isl.4 Sun Oct 30 12:15:33 2016 (r308104) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 25, 2015 +.Dd October 03, 2016 .Dt ISL 4 .Os .Sh NAME @@ -36,7 +36,7 @@ the kernel configuration file: .Bd -ragged -offset indent .Cd "device isl" .Cd "device ig4" -.Cd "device smbus" +.Cd "device iicbus" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in @@ -45,6 +45,13 @@ Alternatively, to load the driver as a m isl_load="YES" ig4_load="YES" .Ed +.Pp +In +.Pa /boot/device.hints : +.Cd hint.isl.0.at="iicbus0" +.Cd hint.isl.0.addr="0x88" +.Cd hint.isl.1.at="iicbus1" +.Cd hint.isl.1.addr="0x88" .Sh DESCRIPTION The .Nm @@ -54,6 +61,20 @@ Function. Functionality is basic and provided through the .Xr sysctl 8 interface. +.Pp +On a system using +.Xr device.hints 5 , +these values are configurable for +.Nm : +.Bl -tag -width "hint.isl.%d.addr" +.It Va hint.isl.%d.at +target +.Xr iicbus 4 . +.It Va hint.isl.%d.addr +.Nm +i2c address on the +.Xr iicbus 4 . +.El .Sh SYSCTL VARIABLES The following .Xr sysctl 8 @@ -86,7 +107,7 @@ $ sh /usr/local/share/examples/intel-bac .Ed .Sh SEE ALSO .Xr ig4 4 , -.Xr smbus 4 +.Xr iicbus 4 .Sh AUTHORS .An -nosplit The @@ -99,6 +120,6 @@ This manual page was written by .Sh BUGS The .Nm -driver detects the device based on its I2C address (0x44). +driver detects the device based from the I2C address. This might have unforeseen consequences if the initialization sequence is sent to an unknown device at that address. Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Oct 30 11:45:01 2016 (r308103) +++ head/sys/conf/files Sun Oct 30 12:15:33 2016 (r308104) @@ -1273,6 +1273,7 @@ dev/cfi/cfi_bus_nexus.c optional cfi dev/cfi/cfi_core.c optional cfi dev/cfi/cfi_dev.c optional cfi dev/cfi/cfi_disk.c optional cfid +dev/chromebook_platform/chromebook_platform.c optional chromebook_platform dev/ciss/ciss.c optional ciss dev/cm/smc90cx6.c optional cm dev/cmx/cmx.c optional cmx @@ -1389,7 +1390,7 @@ t5fw.fw optional cxgbe \ dev/cy/cy.c optional cy dev/cy/cy_isa.c optional cy isa dev/cy/cy_pci.c optional cy pci -dev/cyapa/cyapa.c optional cyapa smbus +dev/cyapa/cyapa.c optional cyapa iicbus dev/dc/if_dc.c optional dc pci dev/dc/dcphy.c optional dc pci dev/dc/pnphy.c optional dc pci @@ -1631,8 +1632,8 @@ dev/hptiop/hptiop.c optional hptiop scb dev/hwpmc/hwpmc_logging.c optional hwpmc dev/hwpmc/hwpmc_mod.c optional hwpmc dev/hwpmc/hwpmc_soft.c optional hwpmc -dev/ichiic/ig4_iic.c optional ig4 smbus -dev/ichiic/ig4_pci.c optional ig4 pci smbus +dev/ichiic/ig4_iic.c optional ig4 iicbus +dev/ichiic/ig4_pci.c optional ig4 pci iicbus dev/ichsmb/ichsmb.c optional ichsmb dev/ichsmb/ichsmb_pci.c optional ichsmb pci dev/ida/ida.c optional ida @@ -1726,7 +1727,7 @@ dev/iscsi_initiator/isc_soc.c optional i dev/iscsi_initiator/isc_sm.c optional iscsi_initiator scbus dev/iscsi_initiator/isc_subr.c optional iscsi_initiator scbus dev/ismt/ismt.c optional ismt -dev/isl/isl.c optional isl smbus +dev/isl/isl.c optional isl iicbus dev/isp/isp.c optional isp dev/isp/isp_freebsd.c optional isp dev/isp/isp_library.c optional isp Added: head/sys/dev/chromebook_platform/chromebook_platform.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/chromebook_platform/chromebook_platform.c Sun Oct 30 12:15:33 2016 (r308104) @@ -0,0 +1,102 @@ +/*- + * Copyright (c) 2016 The FreeBSD Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* + * Driver that attaches I2C devices. + */ +static struct { + uint32_t pci_id; + const char *name; + uint8_t addr; +} slaves[] = { + { 0x9c628086, "isl", 0x88 }, + { 0x9c618086, "cyapa", 0xce }, +}; + +static void +chromebook_i2c_identify(driver_t *driver, device_t bus) +{ + device_t controller; + device_t child; + int i; + + /* + * A stopgap approach to preserve the status quo. + * A more intelligent approach is required to correctly + * identify a machine model and hardware available on it. + * For instance, DMI could be used. + * See http://lxr.free-electrons.com/source/drivers/platform/chrome/chromeos_laptop.c + */ + controller = device_get_parent(bus); + if (strcmp(device_get_name(controller), "ig4iic") != 0) + return; + + for (i = 0; i < nitems(slaves); i++) { + if (device_find_child(bus, slaves[i].name, -1) != NULL) + continue; + if (slaves[i].pci_id != pci_get_devid(controller)) + continue; + child = BUS_ADD_CHILD(bus, 0, slaves[i].name, -1); + if (child != NULL) + iicbus_set_addr(child, slaves[i].addr); + } +} + +static device_method_t chromebook_i2c_methods[] = { + DEVMETHOD(device_identify, chromebook_i2c_identify), + { 0, 0 } +}; + +static driver_t chromebook_i2c_driver = { + "chromebook_i2c", + chromebook_i2c_methods, + 0 /* no softc */ +}; + +static devclass_t chromebook_i2c_devclass; + +DRIVER_MODULE(chromebook_i2c, iicbus, chromebook_i2c_driver, + chromebook_i2c_devclass, 0, 0); +MODULE_VERSION(chromebook_i2c, 1); + Modified: head/sys/dev/cyapa/cyapa.c ============================================================================== --- head/sys/dev/cyapa/cyapa.c Sun Oct 30 11:45:01 2016 (r308103) +++ head/sys/dev/cyapa/cyapa.c Sun Oct 30 12:15:33 2016 (r308104) @@ -122,11 +122,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #include -#include "smbus_if.h" +#include "iicbus_if.h" #include "bus_if.h" #include "device_if.h" @@ -149,7 +149,6 @@ struct cyapa_fifo { struct cyapa_softc { device_t dev; int count; /* >0 if device opened */ - int addr; struct cdev *devnode; struct selinfo selinfo; struct mtx mutex; @@ -273,6 +272,30 @@ static int cyapa_reset = 0; SYSCTL_INT(_debug, OID_AUTO, cyapa_reset, CTLFLAG_RW, &cyapa_reset, 0, "Reset track pad"); +static int +cyapa_read_bytes(device_t dev, uint8_t reg, uint8_t *val, int cnt) +{ + uint16_t addr = iicbus_get_addr(dev); + struct iic_msg msgs[] = { + { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, + { addr, IIC_M_RD, cnt, val }, + }; + + return (iicbus_transfer(dev, msgs, nitems(msgs))); +} + +static int +cyapa_write_bytes(device_t dev, uint8_t reg, const uint8_t *val, int cnt) +{ + uint16_t addr = iicbus_get_addr(dev); + struct iic_msg msgs[] = { + { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, + { addr, IIC_M_WR | IIC_M_NOSTART, cnt, __DECONST(uint8_t *, val) }, + }; + + return (iicbus_transfer(dev, msgs, nitems(msgs))); +} + static void cyapa_lock(struct cyapa_softc *sc) { @@ -318,7 +341,7 @@ cyapa_notify(struct cyapa_softc *sc) * Initialize the device */ static int -init_device(device_t dev, struct cyapa_cap *cap, int addr, int probe) +init_device(device_t dev, struct cyapa_cap *cap, int probe) { static char bl_exit[] = { 0x00, 0xff, 0xa5, 0x00, 0x01, @@ -326,17 +349,13 @@ init_device(device_t dev, struct cyapa_c static char bl_deactivate[] = { 0x00, 0xff, 0x3b, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; - device_t bus; struct cyapa_boot_regs boot; int error; int retries; - bus = device_get_parent(dev); /* smbus */ - /* Get status */ - error = smbus_trans(bus, addr, CMD_BOOT_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, (void *)&boot, sizeof(boot), NULL); + error = cyapa_read_bytes(dev, CMD_BOOT_STATUS, + (void *)&boot, sizeof(boot)); if (error) goto done; @@ -350,25 +369,21 @@ init_device(device_t dev, struct cyapa_c /* Busy, wait loop. */ } else if (boot.error & CYAPA_ERROR_BOOTLOADER) { /* Magic */ - error = smbus_trans(bus, addr, CMD_BOOT_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - bl_deactivate, sizeof(bl_deactivate), - NULL, 0, NULL); + error = cyapa_write_bytes(dev, CMD_BOOT_STATUS, + bl_deactivate, sizeof(bl_deactivate)); if (error) goto done; } else { /* Magic */ - error = smbus_trans(bus, addr, CMD_BOOT_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - bl_exit, sizeof(bl_exit), NULL, 0, NULL); + error = cyapa_write_bytes(dev, CMD_BOOT_STATUS, + bl_exit, sizeof(bl_exit)); if (error) goto done; } pause("cyapab1", (hz * 2) / 10); --retries; - error = smbus_trans(bus, addr, CMD_BOOT_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, (void *)&boot, sizeof(boot), NULL); + error = cyapa_read_bytes(dev, CMD_BOOT_STATUS, + (void *)&boot, sizeof(boot)); if (error) goto done; } @@ -381,9 +396,8 @@ init_device(device_t dev, struct cyapa_c /* Check identity */ if (cap) { - error = smbus_trans(bus, addr, CMD_QUERY_CAPABILITIES, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, (void *)cap, sizeof(*cap), NULL); + error = cyapa_read_bytes(dev, CMD_QUERY_CAPABILITIES, + (void *)cap, sizeof(*cap)); if (strncmp(cap->prod_ida, "CYTRA", 5) != 0) { device_printf(dev, "Product ID \"%5.5s\" mismatch\n", @@ -391,9 +405,8 @@ init_device(device_t dev, struct cyapa_c error = ENXIO; } } - error = smbus_trans(bus, addr, CMD_BOOT_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, (void *)&boot, sizeof(boot), NULL); + error = cyapa_read_bytes(dev, CMD_BOOT_STATUS, + (void *)&boot, sizeof(boot)); if (probe == 0) /* official init */ device_printf(dev, "cyapa init status %02x\n", boot.stat); @@ -452,16 +465,16 @@ cyapa_probe(device_t dev) int addr; int error; - addr = smbus_get_addr(dev); + addr = iicbus_get_addr(dev); /* * 0x67 - cypress trackpad on the acer c720 * (other devices might use other ids). */ - if (addr != 0x67) + if (addr != 0xce) return (ENXIO); - error = init_device(dev, &cap, addr, 1); + error = init_device(dev, &cap, 1); if (error != 0) return (ENXIO); @@ -482,15 +495,14 @@ cyapa_attach(device_t dev) sc->reporting_mode = 1; unit = device_get_unit(dev); - addr = smbus_get_addr(dev); + addr = iicbus_get_addr(dev); - if (init_device(dev, &cap, addr, 0)) + if (init_device(dev, &cap, 0)) return (ENXIO); mtx_init(&sc->mutex, "cyapa", NULL, MTX_DEF); sc->dev = dev; - sc->addr = addr; knlist_init_mtx(&sc->selinfo.si_note, &sc->mutex); @@ -1159,7 +1171,7 @@ cyapa_poll_thread(void *arg) { struct cyapa_softc *sc; struct cyapa_regs regs; - device_t bus; /* smbus */ + device_t bus; /* iicbus */ int error; int freq; int isidle; @@ -1180,12 +1192,10 @@ cyapa_poll_thread(void *arg) while (!sc->detaching) { cyapa_unlock(sc); - error = smbus_request_bus(bus, sc->dev, SMB_WAIT); + error = iicbus_request_bus(bus, sc->dev, IIC_WAIT); if (error == 0) { - error = smbus_trans(bus, sc->addr, CMD_DEV_STATUS, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, - (void *)®s, sizeof(regs), NULL); + error = cyapa_read_bytes(sc->dev, CMD_DEV_STATUS, + (void *)®s, sizeof(regs)); if (error == 0) { isidle = cyapa_raw_input(sc, ®s, freq); } @@ -1200,9 +1210,9 @@ cyapa_poll_thread(void *arg) (unsigned)(ticks - last_reset) > TIME_TO_RESET)) { cyapa_reset = 0; last_reset = ticks; - init_device(sc->dev, NULL, sc->addr, 2); + init_device(sc->dev, NULL, 2); } - smbus_release_bus(bus, sc->dev); + iicbus_release_bus(bus, sc->dev); } pause("cyapw", hz / freq); ++sc->poll_ticks; @@ -1531,18 +1541,16 @@ cyapa_set_power_mode(struct cyapa_softc int error; bus = device_get_parent(sc->dev); - error = smbus_request_bus(bus, sc->dev, SMB_WAIT); + error = iicbus_request_bus(bus, sc->dev, IIC_WAIT); if (error == 0) { - error = smbus_trans(bus, sc->addr, CMD_POWER_MODE, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - NULL, 0, (void *)&data, 1, NULL); + error = cyapa_read_bytes(sc->dev, CMD_POWER_MODE, + &data, 1); data = (data & ~0xFC) | mode; if (error == 0) { - error = smbus_trans(bus, sc->addr, CMD_POWER_MODE, - SMB_TRANS_NOCNT | SMB_TRANS_7BIT, - (void *)&data, 1, NULL, 0, NULL); + error = cyapa_write_bytes(sc->dev, CMD_POWER_MODE, + &data, 1); } - smbus_release_bus(bus, sc->dev); + iicbus_release_bus(bus, sc->dev); } } @@ -1697,6 +1705,6 @@ cyapa_fuzz(int delta, int *fuzzp) return (delta); } -DRIVER_MODULE(cyapa, smbus, cyapa_driver, cyapa_devclass, NULL, NULL); -MODULE_DEPEND(cyapa, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); +DRIVER_MODULE(cyapa, iicbus, cyapa_driver, cyapa_devclass, NULL, NULL); +MODULE_DEPEND(cyapa, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); MODULE_VERSION(cyapa, 1); Modified: head/sys/dev/ichiic/ig4_iic.c ============================================================================== --- head/sys/dev/ichiic/ig4_iic.c Sun Oct 30 11:45:01 2016 (r308103) +++ head/sys/dev/ichiic/ig4_iic.c Sun Oct 30 12:15:33 2016 (r308104) @@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -120,7 +122,7 @@ set_controller(ig4iic_softc_t *sc, uint3 reg_write(sc, IG4_REG_INTR_MASK, 0); reg_write(sc, IG4_REG_I2C_EN, ctl); - error = SMB_ETIMEOUT; + error = IIC_ETIMEOUT; for (retry = 100; retry > 0; --retry) { v = reg_read(sc, IG4_REG_ENABLE_STATUS); @@ -148,7 +150,7 @@ wait_status(ig4iic_softc_t *sc, uint32_t u_int count_us = 0; u_int limit_us = 25000; /* 25ms */ - error = SMB_ETIMEOUT; + error = IIC_ETIMEOUT; for (;;) { /* @@ -484,6 +486,236 @@ done: } /* + * IICBUS API FUNCTIONS + */ +static int +ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave) +{ + /* XXX 10-bit address support? */ + set_slave_addr(sc, slave >> 1, 0); + return (0); +} + +static int +ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t len, + bool repeated_start, bool stop) +{ + uint32_t cmd; + uint16_t i; + int error; + + if (len == 0) + return (0); + + cmd = IG4_DATA_COMMAND_RD; + cmd |= repeated_start ? IG4_DATA_RESTART : 0; + cmd |= stop && len == 1 ? IG4_DATA_STOP : 0; + + /* Issue request for the first byte (could be last as well). */ + reg_write(sc, IG4_REG_DATA_CMD, cmd); + + for (i = 0; i < len; i++) { + /* + * Maintain a pipeline by queueing the allowance for the next + * read before waiting for the current read. + */ + cmd = IG4_DATA_COMMAND_RD; + if (i < len - 1) { + cmd = IG4_DATA_COMMAND_RD; + cmd |= stop && i == len - 2 ? IG4_DATA_STOP : 0; + reg_write(sc, IG4_REG_DATA_CMD, cmd); + } + error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); + if (error) + break; + buf[i] = data_read(sc); + } + + (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + return (error); +} + +static int +ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_t len, + bool repeated_start, bool stop) +{ + uint32_t cmd; + uint16_t i; + int error; + + if (len == 0) + return (0); + + cmd = repeated_start ? IG4_DATA_RESTART : 0; + for (i = 0; i < len; i++) { + error = wait_status(sc, IG4_STATUS_TX_NOTFULL); + if (error) + break; + cmd |= buf[i]; + cmd |= stop && i == len - 1 ? IG4_DATA_STOP : 0; + reg_write(sc, IG4_REG_DATA_CMD, cmd); + cmd = 0; + } + + (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + return (error); +} + +int +ig4iic_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + const char *reason = NULL; + uint32_t i; + int error; + int unit; + bool rpstart; + bool stop; + + /* + * The hardware interface imposes limits on allowed I2C messages. + * It is not possible to explicitly send a start or stop. + * They are automatically sent (or not sent, depending on the + * configuration) when a data byte is transferred. + * For this reason it's impossible to send a message with no data + * at all (like an SMBus quick message). + * The start condition is automatically generated after the stop + * condition, so it's impossible to not have a start after a stop. + * The repeated start condition is automatically sent if a change + * of the transfer direction happens, so it's impossible to have + * a change of direction without a (repeated) start. + * The repeated start can be forced even without the change of + * direction. + * Changing the target slave address requires resetting the hardware + * state, so it's impossible to do that without the stop followed + * by the start. + */ + for (i = 0; i < nmsgs; i++) { +#if 0 + if (i == 0 && (msgs[i].flags & IIC_M_NOSTART) != 0) { + reason = "first message without start"; + break; + } + if (i == nmsgs - 1 && (msgs[i].flags & IIC_M_NOSTOP) != 0) { + reason = "last message without stop"; + break; + } +#endif + if (msgs[i].len == 0) { + reason = "message with no data"; + break; + } + if (i > 0) { + if ((msgs[i].flags & IIC_M_NOSTART) != 0 && + (msgs[i - 1].flags & IIC_M_NOSTOP) == 0) { + reason = "stop not followed by start"; + break; + } + if ((msgs[i - 1].flags & IIC_M_NOSTOP) != 0 && + msgs[i].slave != msgs[i - 1].slave) { + reason = "change of slave without stop"; + break; + } + if ((msgs[i].flags & IIC_M_NOSTART) != 0 && + (msgs[i].flags & IIC_M_RD) != + (msgs[i - 1].flags & IIC_M_RD)) { + reason = "change of direction without repeated" + " start"; + break; + } + } + } + if (reason != NULL) { + if (bootverbose) + device_printf(dev, "%s\n", reason); + return (IIC_ENOTSUPP); + } + + sx_xlock(&sc->call_lock); + mtx_lock(&sc->io_lock); + + /* Debugging - dump registers. */ + if (ig4_dump) { + unit = device_get_unit(dev); + if (ig4_dump & (1 << unit)) { + ig4_dump &= ~(1 << unit); + ig4iic_dump(sc); + } + } + + /* + * Clear any previous abort condition that may have been holding + * the txfifo in reset. + */ + reg_read(sc, IG4_REG_CLR_TX_ABORT); + + /* + * Clean out any previously received data. + */ + if (sc->rpos != sc->rnext && bootverbose) { + device_printf(sc->dev, "discarding %d bytes of spurious data\n", + sc->rnext - sc->rpos); + } + sc->rpos = 0; + sc->rnext = 0; + + rpstart = false; + error = 0; + for (i = 0; i < nmsgs; i++) { + if ((msgs[i].flags & IIC_M_NOSTART) == 0) { + error = ig4iic_xfer_start(sc, msgs[i].slave); + } else { + if (!sc->slave_valid || + (msgs[i].slave >> 1) != sc->last_slave) { + device_printf(dev, "start condition suppressed" + "but slave address is not set up"); + error = EINVAL; + break; + } + rpstart = false; + } + if (error != 0) + break; + + stop = (msgs[i].flags & IIC_M_NOSTOP) == 0; + if (msgs[i].flags & IIC_M_RD) + error = ig4iic_read(sc, msgs[i].buf, msgs[i].len, + rpstart, stop); + else + error = ig4iic_write(sc, msgs[i].buf, msgs[i].len, + rpstart, stop); + if (error != 0) + break; + + rpstart = !stop; + } + + mtx_unlock(&sc->io_lock); + sx_unlock(&sc->call_lock); + return (error); +} + +int +ig4iic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + + sx_xlock(&sc->call_lock); + mtx_lock(&sc->io_lock); + + /* TODO handle speed configuration? */ + if (oldaddr != NULL) + *oldaddr = sc->last_slave << 1; + set_slave_addr(sc, addr >> 1, 0); + if (addr == IIC_UNKNOWN) + sc->slave_valid = false; + + mtx_unlock(&sc->io_lock); + sx_unlock(&sc->call_lock); + return (0); +} + +/* * SMBUS API FUNCTIONS * * Called from ig4iic_pci_attach/detach() @@ -549,9 +781,9 @@ ig4iic_attach(ig4iic_softc_t *sc) IG4_CTL_RESTARTEN | IG4_CTL_SPEED_STD); - sc->smb = device_add_child(sc->dev, "smbus", -1); - if (sc->smb == NULL) { - device_printf(sc->dev, "smbus driver not found\n"); + sc->iicbus = device_add_child(sc->dev, "iicbus", -1); + if (sc->iicbus == NULL) { + device_printf(sc->dev, "iicbus driver not found\n"); error = ENXIO; goto done; } @@ -624,15 +856,15 @@ ig4iic_detach(ig4iic_softc_t *sc) if (error) return (error); } - if (sc->smb) - device_delete_child(sc->dev, sc->smb); + if (sc->iicbus) + device_delete_child(sc->dev, sc->iicbus); if (sc->intr_handle) bus_teardown_intr(sc->dev, sc->intr_res, sc->intr_handle); sx_xlock(&sc->call_lock); mtx_lock(&sc->io_lock); - sc->smb = NULL; + sc->iicbus = NULL; sc->intr_handle = NULL; reg_write(sc, IG4_REG_INTR_MASK, 0); set_controller(sc, 0); @@ -976,4 +1208,4 @@ ig4iic_dump(ig4iic_softc_t *sc) } #undef REGDUMP -DRIVER_MODULE(smbus, ig4iic, smbus_driver, smbus_devclass, NULL, NULL); +DRIVER_MODULE(iicbus, ig4iic, iicbus_driver, iicbus_devclass, NULL, NULL); Modified: head/sys/dev/ichiic/ig4_pci.c ============================================================================== --- head/sys/dev/ichiic/ig4_pci.c Sun Oct 30 11:45:01 2016 (r308103) +++ head/sys/dev/ichiic/ig4_pci.c Sun Oct 30 12:15:33 2016 (r308104) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "smbus_if.h" @@ -180,6 +181,10 @@ static device_method_t ig4iic_pci_method DEVMETHOD(smbus_bread, ig4iic_smb_bread), DEVMETHOD(smbus_trans, ig4iic_smb_trans), *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Sun Oct 30 14:39:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 96CFDC25534; Sun, 30 Oct 2016 14:39:34 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66E70145A; Sun, 30 Oct 2016 14:39:34 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UEdXeU077870; Sun, 30 Oct 2016 14:39:33 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UEdXRX077869; Sun, 30 Oct 2016 14:39:33 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201610301439.u9UEdXRX077869@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Sun, 30 Oct 2016 14:39:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308105 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 14:39:34 -0000 Author: jmcneill Date: Sun Oct 30 14:39:33 2016 New Revision: 308105 URL: https://svnweb.freebsd.org/changeset/base/308105 Log: Fix H3 temperature reporting. The formula in for V1.0 of the H3 datasheet seems to be incorrect, so use the same method of conversion as the H3 BSP instead. Modified: head/sys/arm/allwinner/aw_thermal.c Modified: head/sys/arm/allwinner/aw_thermal.c ============================================================================== --- head/sys/arm/allwinner/aw_thermal.c Sun Oct 30 12:15:33 2016 (r308104) +++ head/sys/arm/allwinner/aw_thermal.c Sun Oct 30 14:39:33 2016 (r308105) @@ -109,9 +109,9 @@ __FBSDID("$FreeBSD$"); #define H3_ADC_ACQUIRE_TIME 0x3f #define H3_FILTER 0x6 #define H3_INTC 0x191000 -#define H3_TEMP_BASE 2794000 +#define H3_TEMP_BASE 1794000 #define H3_TEMP_MUL 1000 -#define H3_TEMP_DIV -14882 +#define H3_TEMP_DIV -8253 #define H3_CLK_RATE 4000000 #define TEMP_C_TO_K 273 From owner-svn-src-head@freebsd.org Sun Oct 30 15:46:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4DF52C26501; Sun, 30 Oct 2016 15:46:25 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1AC861E5C; Sun, 30 Oct 2016 15:46:25 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UFkOGm005427; Sun, 30 Oct 2016 15:46:24 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UFkOZr005426; Sun, 30 Oct 2016 15:46:24 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201610301546.u9UFkOZr005426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Sun, 30 Oct 2016 15:46:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308106 - head/release/tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 15:46:25 -0000 Author: lwhsu (ports committer) Date: Sun Oct 30 15:46:24 2016 New Revision: 308106 URL: https://svnweb.freebsd.org/changeset/base/308106 Log: - Use virtualbox-ose-additions-nox11 for vagrant image to reduce size Reviewed by: brd, gjb, swills Approved by: gjb Modified: head/release/tools/vagrant-virtualbox.conf Modified: head/release/tools/vagrant-virtualbox.conf ============================================================================== --- head/release/tools/vagrant-virtualbox.conf Sun Oct 30 14:39:33 2016 (r308105) +++ head/release/tools/vagrant-virtualbox.conf Sun Oct 30 15:46:24 2016 (r308106) @@ -5,11 +5,11 @@ . ${WORLDDIR}/release/tools/vagrant.conf -export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} virtualbox-ose-additions" +export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} virtualbox-ose-additions-nox11" vm_extra_pre_umount () { # VirtualBox first boot pkgs - echo 'firstboot_pkgs_list="sudo rsync virtualbox-ose-additions"' >> ${DESTDIR}/etc/rc.conf + echo 'firstboot_pkgs_list="sudo rsync virtualbox-ose-additions-nox11"' >> ${DESTDIR}/etc/rc.conf echo 'vboxguest_enable="YES"' >> ${DESTDIR}/etc/rc.conf echo 'vboxservice_enable="YES"' >> ${DESTDIR}/etc/rc.conf From owner-svn-src-head@freebsd.org Sun Oct 30 15:56:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F9E9C26945; Sun, 30 Oct 2016 15:56:45 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C614F1359; Sun, 30 Oct 2016 15:56:44 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UFuips009417; Sun, 30 Oct 2016 15:56:44 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UFuhAi009407; Sun, 30 Oct 2016 15:56:43 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201610301556.u9UFuhAi009407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Sun, 30 Oct 2016 15:56:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308107 - in head/sys/modules/bhnd: . bcma bcma_bhndb bhndb bhndb_pci cores/bhnd_pci cores/bhnd_pci_hostb cores/bhnd_pcib siba siba_bhndb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 15:56:45 -0000 Author: lwhsu (ports committer) Date: Sun Oct 30 15:56:42 2016 New Revision: 308107 URL: https://svnweb.freebsd.org/changeset/base/308107 Log: - Fix `make` in sys/modules/bhnd Approved by: landonf Differential Revision: https://reviews.freebsd.org/D7774 Modified: head/sys/modules/bhnd/Makefile head/sys/modules/bhnd/bcma/Makefile head/sys/modules/bhnd/bcma_bhndb/Makefile head/sys/modules/bhnd/bhndb/Makefile head/sys/modules/bhnd/bhndb_pci/Makefile head/sys/modules/bhnd/cores/bhnd_pci/Makefile head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile head/sys/modules/bhnd/cores/bhnd_pcib/Makefile head/sys/modules/bhnd/siba/Makefile head/sys/modules/bhnd/siba_bhndb/Makefile Modified: head/sys/modules/bhnd/Makefile ============================================================================== --- head/sys/modules/bhnd/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -37,6 +37,8 @@ SRCS+= bhnd_nvram_if.c bhnd_nvram_if.h SRCS+= device_if.h bus_if.h +SRCS+= opt_global.h + SUBDIR= bcma \ bcma_bhndb \ bhndb \ Modified: head/sys/modules/bhnd/bcma/Makefile ============================================================================== --- head/sys/modules/bhnd/bcma/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/bcma/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -6,6 +6,6 @@ KMOD= bcma SRCS= bcma.c bcma_subr.c bcma_erom.c SRCS+= device_if.h bus_if.h -SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h +SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h opt_global.h .include Modified: head/sys/modules/bhnd/bcma_bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/bcma_bhndb/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/bcma_bhndb/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -7,6 +7,6 @@ SRCS= bcma_bhndb.c SRCS+= bhnd_bus_if.h bhnd_erom_if.h SRCS+= bhndb_bus_if.h bhndb_if.h -SRCS+= device_if.h bus_if.h +SRCS+= device_if.h bus_if.h opt_global.h .include Modified: head/sys/modules/bhnd/bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/bhndb/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/bhndb/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -12,6 +12,6 @@ SRCS+= bhnd_bus_if.h \ bhnd_erom_if.h \ bhnd_nvram_if.h -SRCS+= device_if.h bus_if.h pci_if.h +SRCS+= device_if.h bus_if.h pci_if.h opt_global.h .include Modified: head/sys/modules/bhnd/bhndb_pci/Makefile ============================================================================== --- head/sys/modules/bhnd/bhndb_pci/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/bhndb_pci/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -8,6 +8,6 @@ SRCS= bhndb_pci.c bhndb_pci_hwdata.c \ SRCS+= bhnd_bus_if.h bhndb_bus_if.h bhndb_if.h SRCS+= bhnd_nvram_if.h -SRCS+= device_if.h bus_if.h pci_if.h +SRCS+= device_if.h bus_if.h pci_if.h opt_global.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pci/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pci/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/cores/bhnd_pci/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -5,6 +5,6 @@ KMOD= bhnd_pci SRCS= bhnd_pci.c bhnd_pcie2.c -SRCS+= device_if.h bus_if.h bhnd_bus_if.h +SRCS+= device_if.h bus_if.h bhnd_bus_if.h opt_global.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -6,6 +6,6 @@ KMOD= bhnd_pci_hostb SRCS= bhnd_pci_hostb.c bhnd_pcie2_hostb.c SRCS+= device_if.h bus_if.h pci_if.h \ - bhnd_bus_if.h bhnd_chipc_if.h + bhnd_bus_if.h bhnd_chipc_if.h opt_global.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pcib/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pcib/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/cores/bhnd_pcib/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -6,6 +6,6 @@ KMOD= bhnd_pcib SRCS= bhnd_pcib.c bhnd_pcie2b.c SRCS+= device_if.h bus_if.h pci_if.h \ - bhnd_bus_if.h + bhnd_bus_if.h opt_global.h .include Modified: head/sys/modules/bhnd/siba/Makefile ============================================================================== --- head/sys/modules/bhnd/siba/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/siba/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -7,6 +7,6 @@ SRCS= siba.c siba_subr.c \ siba_erom.c SRCS+= device_if.h bus_if.h -SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h +SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h opt_global.h .include Modified: head/sys/modules/bhnd/siba_bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/siba_bhndb/Makefile Sun Oct 30 15:46:24 2016 (r308106) +++ head/sys/modules/bhnd/siba_bhndb/Makefile Sun Oct 30 15:56:42 2016 (r308107) @@ -7,6 +7,6 @@ SRCS= siba_bhndb.c SRCS+= bhnd_bus_if.h bhnd_erom_if.h SRCS+= bhndb_bus_if.h bhndb_if.h -SRCS+= device_if.h bus_if.h +SRCS+= device_if.h bus_if.h opt_global.h .include From owner-svn-src-head@freebsd.org Sun Oct 30 18:04:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 997CCC275AB; Sun, 30 Oct 2016 18:04:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 68E6914E1; Sun, 30 Oct 2016 18:04:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UI4BHK058938; Sun, 30 Oct 2016 18:04:11 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UI4BnP058937; Sun, 30 Oct 2016 18:04:11 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610301804.u9UI4BnP058937@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 30 Oct 2016 18:04:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308108 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 18:04:12 -0000 Author: kib Date: Sun Oct 30 18:04:11 2016 New Revision: 308108 URL: https://svnweb.freebsd.org/changeset/base/308108 Log: Split long line instead of unindenting it. Add KASSERT() verifying that a device object with the same handle has the same ops vector. Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/vm/device_pager.c Modified: head/sys/vm/device_pager.c ============================================================================== --- head/sys/vm/device_pager.c Sun Oct 30 15:56:42 2016 (r308107) +++ head/sys/vm/device_pager.c Sun Oct 30 18:04:11 2016 (r308108) @@ -169,7 +169,10 @@ cdev_pager_allocate(void *handle, enum o if (pindex > object->size) object->size = pindex; KASSERT(object->type == tp, - ("Inconsistent device pager type %p %d", object, tp)); + ("Inconsistent device pager type %p %d", + object, tp)); + KASSERT(object->un_pager.devp.ops == ops, + ("Inconsistent devops %p %p", object, ops)); } else { object = object1; object1 = NULL; From owner-svn-src-head@freebsd.org Sun Oct 30 18:05:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DAD5C27608; Sun, 30 Oct 2016 18:05:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3F20167A; Sun, 30 Oct 2016 18:05:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UI5ISi059042; Sun, 30 Oct 2016 18:05:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UI5Ibg059041; Sun, 30 Oct 2016 18:05:18 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610301805.u9UI5Ibg059041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 30 Oct 2016 18:05:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308109 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 18:05:19 -0000 Author: kib Date: Sun Oct 30 18:05:18 2016 New Revision: 308109 URL: https://svnweb.freebsd.org/changeset/base/308109 Log: Remove vnode_locked label and goto, by collapsing vp calculation into the conditional. Suggested and reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Oct 30 18:04:11 2016 (r308108) +++ head/sys/vm/vm_fault.c Sun Oct 30 18:05:18 2016 (r308109) @@ -641,10 +641,8 @@ readrest: */ unlock_map(&fs); - if (fs.object->type == OBJT_VNODE) { - vp = fs.object->handle; - if (vp == fs.vp) - goto vnode_locked; + if (fs.object->type == OBJT_VNODE && + (vp = fs.object->handle) != fs.vp) { unlock_vp(&fs); locked = VOP_ISLOCKED(vp); @@ -667,7 +665,6 @@ readrest: } fs.vp = vp; } -vnode_locked: KASSERT(fs.vp == NULL || !fs.map->system_map, ("vm_fault: vnode-backed object mapped by system map")); From owner-svn-src-head@freebsd.org Sun Oct 30 19:16:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9EAAC27F2F; Sun, 30 Oct 2016 19:16:00 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AC08C1AA8; Sun, 30 Oct 2016 19:16:00 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UJFxEP086505; Sun, 30 Oct 2016 19:15:59 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UJFxmE086504; Sun, 30 Oct 2016 19:15:59 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201610301915.u9UJFxmE086504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sun, 30 Oct 2016 19:15:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308112 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 19:16:00 -0000 Author: alc Date: Sun Oct 30 19:15:59 2016 New Revision: 308112 URL: https://svnweb.freebsd.org/changeset/base/308112 Log: Merge and sort vm_fault_hold()'s "int" variable definitions. Reviewed by: kib MFC after: 7 days Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Oct 30 18:33:57 2016 (r308111) +++ head/sys/vm/vm_fault.c Sun Oct 30 19:15:59 2016 (r308112) @@ -291,14 +291,13 @@ vm_fault_hold(vm_map_t map, vm_offset_t int fault_flags, vm_page_t *m_hold) { vm_prot_t prot; - int alloc_req, era, faultcount, nera, result; - int map_generation; vm_object_t next_object; struct faultstate fs; struct vnode *vp; vm_offset_t e_end, e_start; vm_page_t m; - int ahead, behind, cluster_offset, error, locked, rv; + int ahead, alloc_req, behind, cluster_offset, error, era, faultcount; + int locked, map_generation, nera, result, rv; u_char behavior; boolean_t wired; /* Passed by reference. */ bool dead, growstack, hardfault, is_first_object_locked; From owner-svn-src-head@freebsd.org Sun Oct 30 19:46:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD8F4C27470; Sun, 30 Oct 2016 19:46:01 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [IPv6:2607:fc50:1000:7400:216:3eff:fe72:314f]) by mx1.freebsd.org (Postfix) with ESMTP id 961BB136B; Sun, 30 Oct 2016 19:46:01 +0000 (UTC) (envelope-from eric@vangyzen.net) Received: from imac.home.vangyzen.net (unknown [76.164.15.242]) by smtp.vangyzen.net (Postfix) with ESMTPSA id 914405648E; Sun, 30 Oct 2016 14:46:00 -0500 (CDT) Subject: Re: svn commit: r306577 - head/sys/netinet To: koobs@FreeBSD.org, Eric van Gyzen , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610020142.u921gjsJ016528@repo.freebsd.org> <46cdc5d8-75ee-16f6-ee9d-d9c14cb5098e@FreeBSD.org> Cc: Steven Hartland , Gleb Smirnoff , David Bright From: Eric van Gyzen Message-ID: <89972ae0-2125-1966-4845-38c6a4d20b1e@vangyzen.net> Date: Sun, 30 Oct 2016 14:45:56 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <46cdc5d8-75ee-16f6-ee9d-d9c14cb5098e@FreeBSD.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 19:46:01 -0000 On 10/30/16 4:44 AM, Kubilay Kocak wrote: > On 2/10/2016 12:42 PM, Eric van Gyzen wrote: >> Author: vangyzen Date: Sun Oct 2 01:42:45 2016 New Revision: 306577 >> URL: https://svnweb.freebsd.org/changeset/base/306577 >> >> Log: Add GARP retransmit capability > > Thanks for this David & Eric > > I presume this is (or would be) quite complementary to D4111 [1] > (Gratuitous ARP's for lagg(4) failover) when it lands? I'm thinking > particularly given the various states upstream switch ports can have > during topology changes. > > [1] https://reviews.freebsd.org/D4111 Yes, I expect it would be nicely complementary. The disruption of a topology change increases the chance of a dropped packet, so it would be wise to retransmit the GARP sent by lagg(4). Eric From owner-svn-src-head@freebsd.org Sun Oct 30 20:38:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D944C27AAF; Sun, 30 Oct 2016 20:38:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1AB9616A1; Sun, 30 Oct 2016 20:38:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UKcv4j017713; Sun, 30 Oct 2016 20:38:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UKcv4o017712; Sun, 30 Oct 2016 20:38:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610302038.u9UKcv4o017712@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 30 Oct 2016 20:38:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308113 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 20:38:58 -0000 Author: kib Date: Sun Oct 30 20:38:57 2016 New Revision: 308113 URL: https://svnweb.freebsd.org/changeset/base/308113 Log: Remove vm_pager_has_page() declaration. It is not too useful since static inline definition appears later in the file. Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/vm/vm_pager.h Modified: head/sys/vm/vm_pager.h ============================================================================== --- head/sys/vm/vm_pager.h Sun Oct 30 19:15:59 2016 (r308112) +++ head/sys/vm/vm_pager.h Sun Oct 30 20:38:57 2016 (r308113) @@ -109,7 +109,6 @@ void vm_pager_deallocate(vm_object_t); int vm_pager_get_pages(vm_object_t, vm_page_t *, int, int *, int *); int vm_pager_get_pages_async(vm_object_t, vm_page_t *, int, int *, int *, pgo_getpages_iodone_t, void *); -static __inline boolean_t vm_pager_has_page(vm_object_t, vm_pindex_t, int *, int *); void vm_pager_init(void); vm_object_t vm_pager_object_lookup(struct pagerlst *, void *); From owner-svn-src-head@freebsd.org Sun Oct 30 20:39:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0543C27B1C; Sun, 30 Oct 2016 20:39:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9299D1876; Sun, 30 Oct 2016 20:39:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UKdcwh017794; Sun, 30 Oct 2016 20:39:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UKdcWq017793; Sun, 30 Oct 2016 20:39:38 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610302039.u9UKdcWq017793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 30 Oct 2016 20:39:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308114 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 20:39:39 -0000 Author: kib Date: Sun Oct 30 20:39:38 2016 New Revision: 308114 URL: https://svnweb.freebsd.org/changeset/base/308114 Log: Change remained internal uses of boolean_t to bool in vm/vm_fault.c. Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Oct 30 20:38:57 2016 (r308113) +++ head/sys/vm/vm_fault.c Sun Oct 30 20:39:38 2016 (r308114) @@ -184,9 +184,9 @@ unlock_and_deallocate(struct faultstate static void vm_fault_dirty(vm_map_entry_t entry, vm_page_t m, vm_prot_t prot, - vm_prot_t fault_type, int fault_flags, boolean_t set_wd) + vm_prot_t fault_type, int fault_flags, bool set_wd) { - boolean_t need_dirty; + bool need_dirty; if (((prot & VM_PROT_WRITE) == 0 && (fault_flags & VM_FAULT_DIRTY) == 0) || @@ -397,7 +397,7 @@ RetryFault:; vm_page_unlock(m); } vm_fault_dirty(fs.entry, m, prot, fault_type, fault_flags, - FALSE); + false); VM_OBJECT_RUNLOCK(fs.first_object); if (!wired) vm_fault_prefault(&fs, vaddr, PFBAK, PFFOR); @@ -987,7 +987,7 @@ readrest: if (hardfault) fs.entry->next_read = vaddr + ptoa(ahead) + PAGE_SIZE; - vm_fault_dirty(fs.entry, fs.m, prot, fault_type, fault_flags, TRUE); + vm_fault_dirty(fs.entry, fs.m, prot, fault_type, fault_flags, true); vm_page_assert_xbusied(fs.m); /* From owner-svn-src-head@freebsd.org Sun Oct 30 22:07:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A14EEC2754F; Sun, 30 Oct 2016 22:07:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80B3C1111; Sun, 30 Oct 2016 22:07:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id AD36710AF92; Sun, 30 Oct 2016 18:07:38 -0400 (EDT) From: John Baldwin To: Li-Wen Hsu Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308107 - in head/sys/modules/bhnd: . bcma bcma_bhndb bhndb bhndb_pci cores/bhnd_pci cores/bhnd_pci_hostb cores/bhnd_pcib siba siba_bhndb Date: Sun, 30 Oct 2016 15:05:49 -0700 Message-ID: <4862480.RxOcpDe54A@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201610301556.u9UFuhAi009407@repo.freebsd.org> References: <201610301556.u9UFuhAi009407@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Sun, 30 Oct 2016 18:07:38 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 22:07:47 -0000 On Sunday, October 30, 2016 03:56:43 PM Li-Wen Hsu wrote: > Author: lwhsu (ports committer) > Date: Sun Oct 30 15:56:42 2016 > New Revision: 308107 > URL: https://svnweb.freebsd.org/changeset/base/308107 > > Log: > - Fix `make` in sys/modules/bhnd > > Approved by: landonf > Differential Revision: https://reviews.freebsd.org/D7774 This is wrong. bhnd_debug.h should not have '#include opt_global.h'. It is included implicitly during kernel builds via '-include' in CFLAGS. It is always incorrect to include it explicitly in source. This should be reverted and bhnd_debug.h should be fixed instead. -- John Baldwin From owner-svn-src-head@freebsd.org Sun Oct 30 22:18:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3DDCDC27709; Sun, 30 Oct 2016 22:18:24 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F165E158B; Sun, 30 Oct 2016 22:18:23 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9UMINLZ056058; Sun, 30 Oct 2016 22:18:23 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9UMIMts056048; Sun, 30 Oct 2016 22:18:22 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201610302218.u9UMIMts056048@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Sun, 30 Oct 2016 22:18:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308115 - in head/sys/modules/bhnd: . bcma bcma_bhndb bhndb bhndb_pci cores/bhnd_pci cores/bhnd_pci_hostb cores/bhnd_pcib siba siba_bhndb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 22:18:24 -0000 Author: lwhsu (ports committer) Date: Sun Oct 30 22:18:22 2016 New Revision: 308115 URL: https://svnweb.freebsd.org/changeset/base/308115 Log: Revert r308107 Requested by: jhb Modified: head/sys/modules/bhnd/Makefile head/sys/modules/bhnd/bcma/Makefile head/sys/modules/bhnd/bcma_bhndb/Makefile head/sys/modules/bhnd/bhndb/Makefile head/sys/modules/bhnd/bhndb_pci/Makefile head/sys/modules/bhnd/cores/bhnd_pci/Makefile head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile head/sys/modules/bhnd/cores/bhnd_pcib/Makefile head/sys/modules/bhnd/siba/Makefile head/sys/modules/bhnd/siba_bhndb/Makefile Modified: head/sys/modules/bhnd/Makefile ============================================================================== --- head/sys/modules/bhnd/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -37,8 +37,6 @@ SRCS+= bhnd_nvram_if.c bhnd_nvram_if.h SRCS+= device_if.h bus_if.h -SRCS+= opt_global.h - SUBDIR= bcma \ bcma_bhndb \ bhndb \ Modified: head/sys/modules/bhnd/bcma/Makefile ============================================================================== --- head/sys/modules/bhnd/bcma/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/bcma/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -6,6 +6,6 @@ KMOD= bcma SRCS= bcma.c bcma_subr.c bcma_erom.c SRCS+= device_if.h bus_if.h -SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h opt_global.h +SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h .include Modified: head/sys/modules/bhnd/bcma_bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/bcma_bhndb/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/bcma_bhndb/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -7,6 +7,6 @@ SRCS= bcma_bhndb.c SRCS+= bhnd_bus_if.h bhnd_erom_if.h SRCS+= bhndb_bus_if.h bhndb_if.h -SRCS+= device_if.h bus_if.h opt_global.h +SRCS+= device_if.h bus_if.h .include Modified: head/sys/modules/bhnd/bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/bhndb/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/bhndb/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -12,6 +12,6 @@ SRCS+= bhnd_bus_if.h \ bhnd_erom_if.h \ bhnd_nvram_if.h -SRCS+= device_if.h bus_if.h pci_if.h opt_global.h +SRCS+= device_if.h bus_if.h pci_if.h .include Modified: head/sys/modules/bhnd/bhndb_pci/Makefile ============================================================================== --- head/sys/modules/bhnd/bhndb_pci/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/bhndb_pci/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -8,6 +8,6 @@ SRCS= bhndb_pci.c bhndb_pci_hwdata.c \ SRCS+= bhnd_bus_if.h bhndb_bus_if.h bhndb_if.h SRCS+= bhnd_nvram_if.h -SRCS+= device_if.h bus_if.h pci_if.h opt_global.h +SRCS+= device_if.h bus_if.h pci_if.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pci/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pci/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/cores/bhnd_pci/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -5,6 +5,6 @@ KMOD= bhnd_pci SRCS= bhnd_pci.c bhnd_pcie2.c -SRCS+= device_if.h bus_if.h bhnd_bus_if.h opt_global.h +SRCS+= device_if.h bus_if.h bhnd_bus_if.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/cores/bhnd_pci_hostb/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -6,6 +6,6 @@ KMOD= bhnd_pci_hostb SRCS= bhnd_pci_hostb.c bhnd_pcie2_hostb.c SRCS+= device_if.h bus_if.h pci_if.h \ - bhnd_bus_if.h bhnd_chipc_if.h opt_global.h + bhnd_bus_if.h bhnd_chipc_if.h .include Modified: head/sys/modules/bhnd/cores/bhnd_pcib/Makefile ============================================================================== --- head/sys/modules/bhnd/cores/bhnd_pcib/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/cores/bhnd_pcib/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -6,6 +6,6 @@ KMOD= bhnd_pcib SRCS= bhnd_pcib.c bhnd_pcie2b.c SRCS+= device_if.h bus_if.h pci_if.h \ - bhnd_bus_if.h opt_global.h + bhnd_bus_if.h .include Modified: head/sys/modules/bhnd/siba/Makefile ============================================================================== --- head/sys/modules/bhnd/siba/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/siba/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -7,6 +7,6 @@ SRCS= siba.c siba_subr.c \ siba_erom.c SRCS+= device_if.h bus_if.h -SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h opt_global.h +SRCS+= bhnd_bus_if.h bhnd_erom_if.h bhnd_pmu_if.h .include Modified: head/sys/modules/bhnd/siba_bhndb/Makefile ============================================================================== --- head/sys/modules/bhnd/siba_bhndb/Makefile Sun Oct 30 20:39:38 2016 (r308114) +++ head/sys/modules/bhnd/siba_bhndb/Makefile Sun Oct 30 22:18:22 2016 (r308115) @@ -7,6 +7,6 @@ SRCS= siba_bhndb.c SRCS+= bhnd_bus_if.h bhnd_erom_if.h SRCS+= bhndb_bus_if.h bhndb_if.h -SRCS+= device_if.h bus_if.h opt_global.h +SRCS+= device_if.h bus_if.h .include From owner-svn-src-head@freebsd.org Sun Oct 30 22:19:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CE9CC2777D; Sun, 30 Oct 2016 22:19:53 +0000 (UTC) (envelope-from lwhsu@FreeBSD.cs.nctu.edu.tw) Received: from FreeBSD.cs.nctu.edu.tw (freebsd2.cs.nctu.edu.tw [140.113.17.206]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1DDAD170C; Sun, 30 Oct 2016 22:19:52 +0000 (UTC) (envelope-from lwhsu@FreeBSD.cs.nctu.edu.tw) Received: by FreeBSD.cs.nctu.edu.tw (Postfix, from userid 1058) id 3CC632919; Mon, 31 Oct 2016 06:19:51 +0800 (CST) Date: Mon, 31 Oct 2016 06:19:51 +0800 From: Li-Wen Hsu To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308107 - in head/sys/modules/bhnd: . bcma bcma_bhndb bhndb bhndb_pci cores/bhnd_pci cores/bhnd_pci_hostb cores/bhnd_pcib siba siba_bhndb Message-ID: <20161030221951.GA86782@FreeBSD.cs.nctu.edu.tw> References: <201610301556.u9UFuhAi009407@repo.freebsd.org> <4862480.RxOcpDe54A@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="liOOAslEiF7prFVr" Content-Disposition: inline In-Reply-To: <4862480.RxOcpDe54A@ralph.baldwin.cx> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Oct 2016 22:19:53 -0000 --liOOAslEiF7prFVr Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 30, 2016 at 15:05:49 -0700, John Baldwin wrote: > On Sunday, October 30, 2016 03:56:43 PM Li-Wen Hsu wrote: > > Author: lwhsu (ports committer) > > Date: Sun Oct 30 15:56:42 2016 > > New Revision: 308107 > > URL: https://svnweb.freebsd.org/changeset/base/308107 > >=20 > > Log: > > - Fix `make` in sys/modules/bhnd > > =20 > > Approved by: landonf > > Differential Revision: https://reviews.freebsd.org/D7774 >=20 > This is wrong. bhnd_debug.h should not have '#include opt_global.h'. It= is > included implicitly during kernel builds via '-include' in CFLAGS. It is > always incorrect to include it explicitly in source. This should be > reverted and bhnd_debug.h should be fixed instead. Got it, reverted in r308115. --=20 Li-Wen Hsu https://lwhsu.org --liOOAslEiF7prFVr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJ8BAEBCgBmBQJYFnIGXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMDdENTNGNjUyMTUzMzVCNzA5NDNGODQ2 NzI3RTc3Qzg4NjJCNjU2AAoJEGcn53yIYrZWvRIP/3HbcDartsocVKvlsoaG5E1W BG7yyDvo2NsmxgE0zq7ismBqmFYQDIMfKaD5Fuxsma3yVuSrUUlIxjp0t8igaISw Q2k0AS4fkazLhAQERHIo3EpjmBgIapI9q6Bm34gXL4zDARuWN+F9lifs5Cf+Q3lf UcdGshhnl+xsRpYjQ00mz+VBeNYWwBIoLdy34aAGVu/SUuXZkKIskhHWIeEQi7Cw /w+BRefEM3eyR0SybkbXBeDJQir9C584cFOPVb17bmUnD+U6HiVrdQMYvhzbkJbT YVbE2CgzqGcVsv7LqV1skxV6iO8mzQ9K9i4z76xgHGaXwMRrizD4pCruzu/UJ10V b/fKpmzMia7Pshs+HGw7wpF2CUFudVpibLZGCExflXffmDB4nnC/tU6K/t4Dl3GC 4F1GwEwekjBdtOsxNfeU0/K0UAfcBU7K/VMiQ19Ajmpn79hYUAgm0AIH23Ye9BHu aEEzKC3KNSu4Jgu9zjSN0UpxPzFDNGVwrEMM8JtYucBW0qvfRxEHlnWCRGR6axHp gxWizyCF1Gn3bP94sPGz261kNgOmWkS3vrEIAvNHImXOXwVil1J3n38OCRF448Ft ta92OXakOY9Yna6vSwr/8+G/LAn0IvLZ+t567RQjb5DcmezuFC7sJV7qwPge8JPB i1jvUH53y6SumMey2G8g =+gYj -----END PGP SIGNATURE----- --liOOAslEiF7prFVr-- From owner-svn-src-head@freebsd.org Mon Oct 31 01:36:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93267C27A23; Mon, 31 Oct 2016 01:36:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 347EE1EFA; Mon, 31 Oct 2016 01:36:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V1aSpg031841; Mon, 31 Oct 2016 01:36:28 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V1aS0V031838; Mon, 31 Oct 2016 01:36:28 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610310136.u9V1aS0V031838@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Oct 2016 01:36:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308116 - in head/sys: conf dev/hyperv/netvsc modules/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 01:36:29 -0000 Author: sephe Date: Mon Oct 31 01:36:28 2016 New Revision: 308116 URL: https://svnweb.freebsd.org/changeset/base/308116 Log: hyperv/hn: Rename cleaned up RNDIS source file. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8361 Added: head/sys/dev/hyperv/netvsc/hn_rndis.c - copied unchanged from r308115, head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Deleted: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/modules/hyperv/netvsc/Makefile Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Sun Oct 30 22:18:22 2016 (r308115) +++ head/sys/conf/files.amd64 Mon Oct 31 01:36:28 2016 (r308116) @@ -292,8 +292,8 @@ dev/hwpmc/hwpmc_piv.c optional hwpmc dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hn_nvs.c optional hyperv +dev/hyperv/netvsc/hn_rndis.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv -dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Sun Oct 30 22:18:22 2016 (r308115) +++ head/sys/conf/files.i386 Mon Oct 31 01:36:28 2016 (r308116) @@ -249,8 +249,8 @@ dev/hwpmc/hwpmc_ppro.c optional hwpmc dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hn_nvs.c optional hyperv +dev/hyperv/netvsc/hn_rndis.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv -dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Copied: head/sys/dev/hyperv/netvsc/hn_rndis.c (from r308115, head/sys/dev/hyperv/netvsc/hv_rndis_filter.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/netvsc/hn_rndis.c Mon Oct 31 01:36:28 2016 (r308116, copy of r308115, head/sys/dev/hyperv/netvsc/hv_rndis_filter.c) @@ -0,0 +1,991 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2010-2012 Citrix Inc. + * Copyright (c) 2012 NetApp Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet6.h" +#include "opt_inet.h" + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define HN_RNDIS_RID_COMPAT_MASK 0xffff +#define HN_RNDIS_RID_COMPAT_MAX HN_RNDIS_RID_COMPAT_MASK + +#define HN_RNDIS_XFER_SIZE 2048 + +#define HN_NDIS_TXCSUM_CAP_IP4 \ + (NDIS_TXCSUM_CAP_IP4 | NDIS_TXCSUM_CAP_IP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP4 \ + (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP6 \ + (NDIS_TXCSUM_CAP_TCP6 | NDIS_TXCSUM_CAP_TCP6OPT | \ + NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_TXCSUM_CAP_UDP6 \ + (NDIS_TXCSUM_CAP_UDP6 | NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_LSOV2_CAP_IP6 \ + (NDIS_LSOV2_CAP_IP6EXT | NDIS_LSOV2_CAP_TCP6OPT) + +static const void *hn_rndis_xact_exec1(struct hn_softc *, + struct vmbus_xact *, size_t, + struct hn_nvs_sendctx *, size_t *); +static const void *hn_rndis_xact_execute(struct hn_softc *, + struct vmbus_xact *, uint32_t, size_t, size_t *, + uint32_t); +static int hn_rndis_query(struct hn_softc *, uint32_t, + const void *, size_t, void *, size_t *); +static int hn_rndis_query2(struct hn_softc *, uint32_t, + const void *, size_t, void *, size_t *, size_t); +static int hn_rndis_set(struct hn_softc *, uint32_t, + const void *, size_t); +static int hn_rndis_init(struct hn_softc *); +static int hn_rndis_halt(struct hn_softc *); +static int hn_rndis_conf_offload(struct hn_softc *, int); +static int hn_rndis_query_hwcaps(struct hn_softc *, + struct ndis_offload *); + +static __inline uint32_t +hn_rndis_rid(struct hn_softc *sc) +{ + uint32_t rid; + +again: + rid = atomic_fetchadd_int(&sc->hn_rndis_rid, 1); + if (rid == 0) + goto again; + + /* Use upper 16 bits for non-compat RNDIS messages. */ + return ((rid & 0xffff) << 16); +} + +void +hn_rndis_rx_ctrl(struct hn_softc *sc, const void *data, int dlen) +{ + const struct rndis_comp_hdr *comp; + const struct rndis_msghdr *hdr; + + KASSERT(dlen >= sizeof(*hdr), ("invalid RNDIS msg\n")); + hdr = data; + + switch (hdr->rm_type) { + case REMOTE_NDIS_INITIALIZE_CMPLT: + case REMOTE_NDIS_QUERY_CMPLT: + case REMOTE_NDIS_SET_CMPLT: + case REMOTE_NDIS_KEEPALIVE_CMPLT: /* unused */ + if (dlen < sizeof(*comp)) { + if_printf(sc->hn_ifp, "invalid RNDIS cmplt\n"); + return; + } + comp = data; + + KASSERT(comp->rm_rid > HN_RNDIS_RID_COMPAT_MAX, + ("invalid RNDIS rid 0x%08x\n", comp->rm_rid)); + vmbus_xact_ctx_wakeup(sc->hn_xact, comp, dlen); + break; + + case REMOTE_NDIS_RESET_CMPLT: + /* + * Reset completed, no rid. + * + * NOTE: + * RESET is not issued by hn(4), so this message should + * _not_ be observed. + */ + if_printf(sc->hn_ifp, "RESET cmplt received\n"); + break; + + default: + if_printf(sc->hn_ifp, "unknown RNDIS msg 0x%x\n", + hdr->rm_type); + break; + } +} + +int +hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr) +{ + size_t eaddr_len; + int error; + + eaddr_len = ETHER_ADDR_LEN; + error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, + eaddr, &eaddr_len); + if (error) + return (error); + if (eaddr_len != ETHER_ADDR_LEN) { + if_printf(sc->hn_ifp, "invalid eaddr len %zu\n", eaddr_len); + return (EINVAL); + } + return (0); +} + +int +hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status) +{ + size_t size; + int error; + + size = sizeof(*link_status); + error = hn_rndis_query(sc, OID_GEN_MEDIA_CONNECT_STATUS, NULL, 0, + link_status, &size); + if (error) + return (error); + if (size != sizeof(uint32_t)) { + if_printf(sc->hn_ifp, "invalid link status len %zu\n", size); + return (EINVAL); + } + return (0); +} + +static const void * +hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, + struct hn_nvs_sendctx *sndc, size_t *comp_len) +{ + struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; + int gpa_cnt, error; + bus_addr_t paddr; + + KASSERT(reqlen <= HN_XACT_REQ_SIZE && reqlen > 0, + ("invalid request length %zu", reqlen)); + + /* + * Setup the SG list. + */ + paddr = vmbus_xact_req_paddr(xact); + KASSERT((paddr & PAGE_MASK) == 0, + ("vmbus xact request is not page aligned 0x%jx", (uintmax_t)paddr)); + for (gpa_cnt = 0; gpa_cnt < HN_XACT_REQ_PGCNT; ++gpa_cnt) { + int len = PAGE_SIZE; + + if (reqlen == 0) + break; + if (reqlen < len) + len = reqlen; + + gpa[gpa_cnt].gpa_page = atop(paddr) + gpa_cnt; + gpa[gpa_cnt].gpa_len = len; + gpa[gpa_cnt].gpa_ofs = 0; + + reqlen -= len; + } + KASSERT(reqlen == 0, ("still have %zu request data left", reqlen)); + + /* + * Send this RNDIS control message and wait for its completion + * message. + */ + vmbus_xact_activate(xact); + error = hn_nvs_send_rndis_ctrl(sc->hn_prichan, sndc, gpa, gpa_cnt); + if (error) { + vmbus_xact_deactivate(xact); + if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); + return (NULL); + } + return (vmbus_xact_wait(xact, comp_len)); +} + +static const void * +hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, + size_t reqlen, size_t *comp_len0, uint32_t comp_type) +{ + const struct rndis_comp_hdr *comp; + size_t comp_len, min_complen = *comp_len0; + + KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); + KASSERT(min_complen >= sizeof(*comp), + ("invalid minimum complete len %zu", min_complen)); + + /* + * Execute the xact setup by the caller. + */ + comp = hn_rndis_xact_exec1(sc, xact, reqlen, &hn_nvs_sendctx_none, + &comp_len); + if (comp == NULL) + return (NULL); + + /* + * Check this RNDIS complete message. + */ + if (comp_len < min_complen) { + if (comp_len >= sizeof(*comp)) { + /* rm_status field is valid */ + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu, " + "status 0x%08x\n", comp_len, comp->rm_status); + } else { + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", + comp_len); + } + return (NULL); + } + if (comp->rm_len < min_complen) { + if_printf(sc->hn_ifp, "invalid RNDIS comp msglen %u\n", + comp->rm_len); + return (NULL); + } + if (comp->rm_type != comp_type) { + if_printf(sc->hn_ifp, "unexpected RNDIS comp 0x%08x, " + "expect 0x%08x\n", comp->rm_type, comp_type); + return (NULL); + } + if (comp->rm_rid != rid) { + if_printf(sc->hn_ifp, "RNDIS comp rid mismatch %u, " + "expect %u\n", comp->rm_rid, rid); + return (NULL); + } + /* All pass! */ + *comp_len0 = comp_len; + return (comp); +} + +static int +hn_rndis_query(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0) +{ + + return (hn_rndis_query2(sc, oid, idata, idlen, odata, odlen0, *odlen0)); +} + +static int +hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen) +{ + struct rndis_query_req *req; + const struct rndis_query_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, odlen = *odlen0, comp_len; + int error, ofs; + uint32_t rid; + + reqlen = sizeof(*req) + idlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS query 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_QUERY_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + /* + * XXX + * This is _not_ RNDIS Spec conforming: + * "This MUST be set to 0 when there is no input data + * associated with the OID." + * + * If this field was set to 0 according to the RNDIS Spec, + * Hyper-V would set non-SUCCESS status in the query + * completion. + */ + req->rm_infobufoffset = RNDIS_QUERY_REQ_INFOBUFOFFSET; + + if (idlen > 0) { + req->rm_infobuflen = idlen; + /* Input data immediately follows RNDIS query. */ + memcpy(req + 1, idata, idlen); + } + + comp_len = sizeof(*comp) + min_odlen; + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_QUERY_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS query 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS query 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + if (comp->rm_infobuflen == 0 || comp->rm_infobufoffset == 0) { + /* No output data! */ + if_printf(sc->hn_ifp, "RNDIS query 0x%08x, no data\n", oid); + *odlen0 = 0; + error = 0; + goto done; + } + + /* + * Check output data length and offset. + */ + /* ofs is the offset from the beginning of comp. */ + ofs = RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(comp->rm_infobufoffset); + if (ofs < sizeof(*comp) || ofs + comp->rm_infobuflen > comp_len) { + if_printf(sc->hn_ifp, "RNDIS query invalid comp ib off/len, " + "%u/%u\n", comp->rm_infobufoffset, comp->rm_infobuflen); + error = EINVAL; + goto done; + } + + /* + * Save output data. + */ + if (comp->rm_infobuflen < odlen) + odlen = comp->rm_infobuflen; + memcpy(odata, ((const uint8_t *)comp) + ofs, odlen); + *odlen0 = odlen; + + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +int +hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_cnt0) +{ + struct ndis_rss_caps in, caps; + size_t caps_len; + int error, indsz, rxr_cnt, hash_fnidx; + uint32_t hash_func = 0, hash_types = 0; + + *rxr_cnt0 = 0; + + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_20) + return (EOPNOTSUPP); + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + + caps_len = NDIS_RSS_CAPS_SIZE; + error = hn_rndis_query2(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len, NDIS_RSS_CAPS_SIZE_6_0); + if (error) + return (error); + + /* + * Preliminary verification. + */ + if (caps.ndis_hdr.ndis_type != NDIS_OBJTYPE_RSS_CAPS) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps.ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_rev < NDIS_RSS_CAPS_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps.ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps.ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps.ndis_hdr.ndis_size < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps.ndis_hdr.ndis_size); + return (EINVAL); + } + + /* + * Save information for later RSS configuration. + */ + if (caps.ndis_nrxr == 0) { + if_printf(sc->hn_ifp, "0 RX rings!?\n"); + return (EINVAL); + } + if (bootverbose) + if_printf(sc->hn_ifp, "%u RX rings\n", caps.ndis_nrxr); + rxr_cnt = caps.ndis_nrxr; + + if (caps.ndis_hdr.ndis_size == NDIS_RSS_CAPS_SIZE && + caps.ndis_hdr.ndis_rev >= NDIS_RSS_CAPS_REV_2) { + if (caps.ndis_nind > NDIS_HASH_INDCNT) { + if_printf(sc->hn_ifp, + "too many RSS indirect table entries %u\n", + caps.ndis_nind); + return (EOPNOTSUPP); + } + if (!powerof2(caps.ndis_nind)) { + if_printf(sc->hn_ifp, "RSS indirect table size is not " + "power-of-2 %u\n", caps.ndis_nind); + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "RSS indirect table size %u\n", + caps.ndis_nind); + } + indsz = caps.ndis_nind; + } else { + indsz = NDIS_HASH_INDCNT; + } + if (indsz < rxr_cnt) { + if_printf(sc->hn_ifp, "# of RX rings (%d) > " + "RSS indirect table size %d\n", rxr_cnt, indsz); + rxr_cnt = indsz; + } + + /* + * NOTE: + * Toeplitz is at the lowest bit, and it is prefered; so ffs(), + * instead of fls(), is used here. + */ + hash_fnidx = ffs(caps.ndis_caps & NDIS_RSS_CAP_HASHFUNC_MASK); + if (hash_fnidx == 0) { + if_printf(sc->hn_ifp, "no hash functions, caps 0x%08x\n", + caps.ndis_caps); + return (EOPNOTSUPP); + } + hash_func = 1 << (hash_fnidx - 1); /* ffs is 1-based */ + + if (caps.ndis_caps & NDIS_RSS_CAP_IPV4) + hash_types |= NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4; + if (caps.ndis_caps & NDIS_RSS_CAP_IPV6) + hash_types |= NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6; + if (caps.ndis_caps & NDIS_RSS_CAP_IPV6_EX) + hash_types |= NDIS_HASH_IPV6_EX | NDIS_HASH_TCP_IPV6_EX; + if (hash_types == 0) { + if_printf(sc->hn_ifp, "no hash types, caps 0x%08x\n", + caps.ndis_caps); + return (EOPNOTSUPP); + } + + /* Commit! */ + sc->hn_rss_ind_size = indsz; + sc->hn_rss_hash = hash_func | hash_types; + *rxr_cnt0 = rxr_cnt; + return (0); +} + +static int +hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen) +{ + struct rndis_set_req *req; + const struct rndis_set_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, comp_len; + uint32_t rid; + int error; + + KASSERT(dlen > 0, ("invalid dlen %zu", dlen)); + + reqlen = sizeof(*req) + dlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS set 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_SET_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + req->rm_infobuflen = dlen; + req->rm_infobufoffset = RNDIS_SET_REQ_INFOBUFOFFSET; + /* Data immediately follows RNDIS set. */ + memcpy(req + 1, data, dlen); + + comp_len = sizeof(*comp); + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_SET_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS set 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS set 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_conf_offload(struct hn_softc *sc, int mtu) +{ + struct ndis_offload hwcaps; + struct ndis_offload_params params; + uint32_t caps = 0; + size_t paramsz; + int error, tso_maxsz, tso_minsg; + + error = hn_rndis_query_hwcaps(sc, &hwcaps); + if (error) { + if_printf(sc->hn_ifp, "hwcaps query failed: %d\n", error); + return (error); + } + + /* NOTE: 0 means "no change" */ + memset(¶ms, 0, sizeof(params)); + + params.ndis_hdr.ndis_type = NDIS_OBJTYPE_DEFAULT; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_2; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE_6_1; + } else { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_3; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE; + } + params.ndis_hdr.ndis_size = paramsz; + + /* + * TSO4/TSO6 setup. + */ + tso_maxsz = IP_MAXPACKET; + tso_minsg = 2; + if (hwcaps.ndis_lsov2.ndis_ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { + caps |= HN_CAP_TSO4; + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip4_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip4_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip4_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip4_minsg; + } + if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && + (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == + HN_NDIS_LSOV2_CAP_IP6) { +#ifdef notyet + caps |= HN_CAP_TSO6; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip6_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; +#endif + } + sc->hn_ndis_tso_szmax = 0; + sc->hn_ndis_tso_sgmin = 0; + if (caps & (HN_CAP_TSO4 | HN_CAP_TSO6)) { + KASSERT(tso_maxsz <= IP_MAXPACKET, + ("invalid NDIS TSO maxsz %d", tso_maxsz)); + KASSERT(tso_minsg >= 2, + ("invalid NDIS TSO minsg %d", tso_minsg)); + if (tso_maxsz < tso_minsg * mtu) { + if_printf(sc->hn_ifp, "invalid NDIS TSO config: " + "maxsz %d, minsg %d, mtu %d; " + "disable TSO4 and TSO6\n", + tso_maxsz, tso_minsg, mtu); + caps &= ~(HN_CAP_TSO4 | HN_CAP_TSO6); + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_OFF; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_OFF; + } else { + sc->hn_ndis_tso_szmax = tso_maxsz; + sc->hn_ndis_tso_sgmin = tso_minsg; + if (bootverbose) { + if_printf(sc->hn_ifp, "NDIS TSO " + "szmax %d sgmin %d\n", + sc->hn_ndis_tso_szmax, + sc->hn_ndis_tso_sgmin); + } + } + } + + /* IPv4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_IP4) == + HN_NDIS_TXCSUM_CAP_IP4) { + caps |= HN_CAP_IPCS; + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_IP4) { + if (params.ndis_ip4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_TCP4) == + HN_NDIS_TXCSUM_CAP_TCP4) { + caps |= HN_CAP_TCP4CS; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_TCP4) { + if (params.ndis_tcp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP4 checksum */ + if (hwcaps.ndis_csum.ndis_ip4_txcsum & NDIS_TXCSUM_CAP_UDP4) { + caps |= HN_CAP_UDP4CS; + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_UDP4) { + if (params.ndis_udp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_TCP6) == + HN_NDIS_TXCSUM_CAP_TCP6) { + caps |= HN_CAP_TCP6CS; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_TCP6) { + if (params.ndis_tcp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_UDP6) == + HN_NDIS_TXCSUM_CAP_UDP6) { + caps |= HN_CAP_UDP6CS; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_UDP6) { + if (params.ndis_udp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "offload csum: " + "ip4 %u, tcp4 %u, udp4 %u, tcp6 %u, udp6 %u\n", + params.ndis_ip4csum, + params.ndis_tcp4csum, + params.ndis_udp4csum, + params.ndis_tcp6csum, + params.ndis_udp6csum); + if_printf(sc->hn_ifp, "offload lsov2: ip4 %u, ip6 %u\n", + params.ndis_lsov2_ip4, + params.ndis_lsov2_ip6); + } + + error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); + if (error) { + if_printf(sc->hn_ifp, "offload config failed: %d\n", error); + return (error); + } + + if (bootverbose) + if_printf(sc->hn_ifp, "offload config done\n"); + sc->hn_caps |= caps; + return (0); +} + +int +hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + struct ndis_rss_params *prm = &rss->rss_params; + int error, rss_size; + + /* + * Only NDIS 6.20+ is supported: + * We only support 4bytes element in indirect table, which has been + * adopted since NDIS 6.20. + */ + KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_20, + ("NDIS 6.20+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); + + /* XXX only one can be specified through, popcnt? */ + KASSERT((sc->hn_rss_hash & NDIS_HASH_FUNCTION_MASK), ("no hash func")); + KASSERT((sc->hn_rss_hash & NDIS_HASH_TYPE_MASK), ("no hash types")); + KASSERT(sc->hn_rss_ind_size > 0, ("no indirect table size")); + + if (bootverbose) { + if_printf(sc->hn_ifp, "RSS indirect table size %d, " + "hash 0x%08x\n", sc->hn_rss_ind_size, sc->hn_rss_hash); + } + + /* + * NOTE: + * DO NOT whack rss_key and rss_ind, which are setup by the caller. + */ + memset(prm, 0, sizeof(*prm)); + rss_size = NDIS_RSSPRM_TOEPLITZ_SIZE(sc->hn_rss_ind_size); + + prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; + prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; + prm->ndis_hdr.ndis_size = rss_size; + prm->ndis_flags = flags; + prm->ndis_hash = sc->hn_rss_hash; + prm->ndis_indsize = sizeof(rss->rss_ind[0]) * sc->hn_rss_ind_size; + prm->ndis_indoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_ind[0]); + prm->ndis_keysize = sizeof(rss->rss_key); + prm->ndis_keyoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_key[0]); + + error = hn_rndis_set(sc, OID_GEN_RECEIVE_SCALE_PARAMETERS, + rss, rss_size); + if (error) { + if_printf(sc->hn_ifp, "RSS config failed: %d\n", error); + } else { + if (bootverbose) + if_printf(sc->hn_ifp, "RSS config done\n"); + } + return (error); +} + +int +hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter) +{ + int error; + + error = hn_rndis_set(sc, OID_GEN_CURRENT_PACKET_FILTER, + &filter, sizeof(filter)); + if (error) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x failed: %d\n", + filter, error); + } else { + if (bootverbose) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x done\n", + filter); + } + } + return (error); +} + +static int +hn_rndis_init(struct hn_softc *sc) +{ + struct rndis_init_req *req; + const struct rndis_init_comp *comp; + struct vmbus_xact *xact; + size_t comp_len; + uint32_t rid; + int error; + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS init\n"); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_INITIALIZE_MSG; + req->rm_len = sizeof(*req); + req->rm_rid = rid; + req->rm_ver_major = RNDIS_VERSION_MAJOR; + req->rm_ver_minor = RNDIS_VERSION_MINOR; + req->rm_max_xfersz = HN_RNDIS_XFER_SIZE; + + comp_len = RNDIS_INIT_COMP_SIZE_MIN; + comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), &comp_len, + REMOTE_NDIS_INITIALIZE_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS init failed\n"); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS init failed: status 0x%08x\n", + comp->rm_status); + error = EIO; + goto done; + } + if (bootverbose) { + if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u, " + "align %u\n", comp->rm_ver_major, comp->rm_ver_minor, + comp->rm_pktmaxsz, comp->rm_pktmaxcnt, + 1U << comp->rm_align); + } + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_halt(struct hn_softc *sc) +{ + struct vmbus_xact *xact; + struct rndis_halt_req *halt; + struct hn_nvs_sendctx sndc; + size_t comp_len; + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*halt)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS halt\n"); + return (ENXIO); + } + halt = vmbus_xact_req_data(xact); + halt->rm_type = REMOTE_NDIS_HALT_MSG; + halt->rm_len = sizeof(*halt); + halt->rm_rid = hn_rndis_rid(sc); + + /* No RNDIS completion; rely on NVS message send completion */ + hn_nvs_sendctx_init(&sndc, hn_nvs_sent_xact, xact); + hn_rndis_xact_exec1(sc, xact, sizeof(*halt), &sndc, &comp_len); + + vmbus_xact_put(xact); + if (bootverbose) + if_printf(sc->hn_ifp, "RNDIS halt done\n"); + return (0); +} + +static int +hn_rndis_query_hwcaps(struct hn_softc *sc, struct ndis_offload *caps) +{ + struct ndis_offload in; + size_t caps_len, size; + int error; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_OFFLOAD; + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_3; + size = NDIS_OFFLOAD_SIZE; + } else if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_1) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_2; + size = NDIS_OFFLOAD_SIZE_6_1; + } else { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_1; + size = NDIS_OFFLOAD_SIZE_6_0; + } + in.ndis_hdr.ndis_size = size; + + caps_len = NDIS_OFFLOAD_SIZE; + error = hn_rndis_query2(sc, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, + &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_6_0); + if (error) + return (error); + + /* + * Preliminary verification. + */ + if (caps->ndis_hdr.ndis_type != NDIS_OBJTYPE_OFFLOAD) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps->ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_rev < NDIS_OFFLOAD_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps->ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps->ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps->ndis_hdr.ndis_size); + return (EINVAL); + } + + if (bootverbose) { + /* + * NOTE: + * caps->ndis_hdr.ndis_size MUST be checked before accessing + * NDIS 6.1+ specific fields. + */ + if_printf(sc->hn_ifp, "hwcaps rev %u\n", + caps->ndis_hdr.ndis_rev); + + if_printf(sc->hn_ifp, "hwcaps csum: " + "ip4 tx 0x%x/0x%x rx 0x%x/0x%x, " + "ip6 tx 0x%x/0x%x rx 0x%x/0x%x\n", + caps->ndis_csum.ndis_ip4_txcsum, + caps->ndis_csum.ndis_ip4_txenc, + caps->ndis_csum.ndis_ip4_rxcsum, + caps->ndis_csum.ndis_ip4_rxenc, + caps->ndis_csum.ndis_ip6_txcsum, + caps->ndis_csum.ndis_ip6_txenc, + caps->ndis_csum.ndis_ip6_rxcsum, + caps->ndis_csum.ndis_ip6_rxenc); + if_printf(sc->hn_ifp, "hwcaps lsov2: " + "ip4 maxsz %u minsg %u encap 0x%x, " + "ip6 maxsz %u minsg %u encap 0x%x opts 0x%x\n", + caps->ndis_lsov2.ndis_ip4_maxsz, + caps->ndis_lsov2.ndis_ip4_minsg, + caps->ndis_lsov2.ndis_ip4_encap, + caps->ndis_lsov2.ndis_ip6_maxsz, + caps->ndis_lsov2.ndis_ip6_minsg, + caps->ndis_lsov2.ndis_ip6_encap, + caps->ndis_lsov2.ndis_ip6_opts); + } + return (0); +} + +int +hn_rndis_attach(struct hn_softc *sc, int mtu) +{ + int error; + + /* + * Initialize RNDIS. + */ + error = hn_rndis_init(sc); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Oct 31 04:46:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8203BC27447; Mon, 31 Oct 2016 04:46:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4399C144C; Mon, 31 Oct 2016 04:46:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V4k23m004212; Mon, 31 Oct 2016 04:46:02 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V4k29f004210; Mon, 31 Oct 2016 04:46:02 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610310446.u9V4k29f004210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Oct 2016 04:46:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308117 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 04:46:03 -0000 Author: sephe Date: Mon Oct 31 04:46:02 2016 New Revision: 308117 URL: https://svnweb.freebsd.org/changeset/base/308117 Log: hyperv/hn: Rework temporary channel packet buffer expanding. And use large default temporary channel packer buffer; we really don't want it to be expanded at run time. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8367 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 01:36:28 2016 (r308116) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 04:46:02 2016 (r308117) @@ -176,6 +176,8 @@ __FBSDID("$FreeBSD$"); HN_RXINFO_HASHINF | \ HN_RXINFO_HASHVAL) +#define HN_PKTBUF_LEN_DEF (16 * 1024) + struct hn_txdesc { #ifndef HN_USE_TXDESC_BUFRING SLIST_ENTRY(hn_txdesc) link; @@ -2720,7 +2722,8 @@ hn_create_rx_data(struct hn_softc *sc, i rxr->hn_ifp = sc->hn_ifp; if (i < sc->hn_tx_ring_cnt) rxr->hn_txr = &sc->hn_tx_ring[i]; - rxr->hn_pktbuf = malloc(HN_PKTBUF_LEN, M_DEVBUF, M_WAITOK); + rxr->hn_pktbuf_len = HN_PKTBUF_LEN_DEF; + rxr->hn_pktbuf = malloc(rxr->hn_pktbuf_len, M_DEVBUF, M_WAITOK); rxr->hn_rx_idx = i; rxr->hn_rxbuf = sc->hn_rxbuf; @@ -2763,6 +2766,11 @@ hn_create_rx_data(struct hn_softc *sc, i OID_AUTO, "rss_pkts", CTLFLAG_RW, &rxr->hn_rss_pkts, "# of packets w/ RSS info received"); + SYSCTL_ADD_INT(ctx, + SYSCTL_CHILDREN(rxr->hn_rx_sysctl_tree), + OID_AUTO, "pktbuf_len", CTLFLAG_RD, + &rxr->hn_pktbuf_len, 0, + "Temporary channel packet buffer length"); } } } @@ -4536,60 +4544,62 @@ hn_chan_callback(struct vmbus_channel *c { struct hn_rx_ring *rxr = xrxr; struct hn_softc *sc = rxr->hn_ifp->if_softc; - void *buffer; - int bufferlen = HN_PKTBUF_LEN; - buffer = rxr->hn_pktbuf; - do { - struct vmbus_chanpkt_hdr *pkt = buffer; - uint32_t bytes_rxed; - int ret; - - bytes_rxed = bufferlen; - ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); - if (ret == 0) { - switch (pkt->cph_type) { - case VMBUS_CHANPKT_TYPE_COMP: - hn_nvs_handle_comp(sc, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_RXBUF: - hn_nvs_handle_rxbuf(rxr, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_INBAND: - hn_nvs_handle_notify(sc, pkt); - break; - default: - if_printf(rxr->hn_ifp, - "unknown chan pkt %u\n", - pkt->cph_type); - break; - } - } else if (ret == ENOBUFS) { - /* Handle large packet */ - if (bufferlen > HN_PKTBUF_LEN) { - free(buffer, M_DEVBUF); - buffer = NULL; - } + for (;;) { + struct vmbus_chanpkt_hdr *pkt = rxr->hn_pktbuf; + int error, pktlen; + + pktlen = rxr->hn_pktbuf_len; + error = vmbus_chan_recv_pkt(chan, pkt, &pktlen); + if (__predict_false(error == ENOBUFS)) { + void *nbuf; + int nlen; - /* alloc new buffer */ - buffer = malloc(bytes_rxed, M_DEVBUF, M_NOWAIT); - if (buffer == NULL) { - if_printf(rxr->hn_ifp, - "hv_cb malloc buffer failed, len=%u\n", - bytes_rxed); - bufferlen = 0; - break; - } - bufferlen = bytes_rxed; - } else { - /* No more packets */ + /* + * Expand channel packet buffer. + * + * XXX + * Use M_WAITOK here, since allocation failure + * is fatal. + */ + nlen = rxr->hn_pktbuf_len * 2; + while (nlen < pktlen) + nlen *= 2; + nbuf = malloc(nlen, M_DEVBUF, M_WAITOK); + + if_printf(rxr->hn_ifp, "expand pktbuf %d -> %d\n", + rxr->hn_pktbuf_len, nlen); + + free(rxr->hn_pktbuf, M_DEVBUF); + rxr->hn_pktbuf = nbuf; + rxr->hn_pktbuf_len = nlen; + /* Retry! */ + continue; + } else if (__predict_false(error == EAGAIN)) { + /* No more channel packets; done! */ break; } - } while (1); + KASSERT(!error, ("vmbus_chan_recv_pkt failed: %d", error)); + + switch (pkt->cph_type) { + case VMBUS_CHANPKT_TYPE_COMP: + hn_nvs_handle_comp(sc, chan, pkt); + break; - if (bufferlen > HN_PKTBUF_LEN) - free(buffer, M_DEVBUF); + case VMBUS_CHANPKT_TYPE_RXBUF: + hn_nvs_handle_rxbuf(rxr, chan, pkt); + break; + case VMBUS_CHANPKT_TYPE_INBAND: + hn_nvs_handle_notify(sc, pkt); + break; + + default: + if_printf(rxr->hn_ifp, "unknown chan pkt %u\n", + pkt->cph_type); + break; + } + } hn_chan_rollup(rxr, rxr->hn_txr); } Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 31 01:36:28 2016 (r308116) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 31 04:46:02 2016 (r308117) @@ -39,8 +39,6 @@ /* Claimed to be 12232B */ #define HN_MTU_MAX (9 * 1024) -#define HN_PKTBUF_LEN 4096 - #define HN_TXBR_SIZE (128 * PAGE_SIZE) #define HN_RXBR_SIZE (128 * PAGE_SIZE) @@ -63,6 +61,7 @@ struct hn_rx_ring { struct ifnet *hn_ifp; struct hn_tx_ring *hn_txr; void *hn_pktbuf; + int hn_pktbuf_len; uint8_t *hn_rxbuf; /* shadow sc->hn_rxbuf */ int hn_rx_idx; From owner-svn-src-head@freebsd.org Mon Oct 31 04:54:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D418C276C0; Mon, 31 Oct 2016 04:54:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BC2318D8; Mon, 31 Oct 2016 04:54:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V4sFm1007809; Mon, 31 Oct 2016 04:54:15 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V4sFKo007807; Mon, 31 Oct 2016 04:54:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610310454.u9V4sFKo007807@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Oct 2016 04:54:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308118 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 04:54:16 -0000 Author: sephe Date: Mon Oct 31 04:54:15 2016 New Revision: 308118 URL: https://svnweb.freebsd.org/changeset/base/308118 Log: hyperv/hn: Cleanup RXBUF ack processing. - Increase the # of retries. - Add comment. - Log error, if RXBUF ack fails. - Add stat for RXBUF ack failures. RXBUF ack really should _not_ fail... MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8368 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 04:46:02 2016 (r308117) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 04:54:15 2016 (r308118) @@ -414,7 +414,8 @@ static void hn_nvs_handle_comp(struct hn static void hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr); -static void hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid); +static void hn_nvs_ack_rxbuf(struct hn_rx_ring *, struct vmbus_channel *, + uint64_t); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -2843,6 +2844,10 @@ hn_create_rx_data(struct hn_softc *sc, i CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, __offsetof(struct hn_rx_ring, hn_small_pkts), hn_rx_stat_ulong_sysctl, "LU", "# of small packets received"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rx_ack_failed", + CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, + __offsetof(struct hn_rx_ring, hn_ack_failed), + hn_rx_stat_ulong_sysctl, "LU", "# of RXBUF ack failures"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_cnt", CTLFLAG_RD, &sc->hn_rx_ring_cnt, 0, "# created RX rings"); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rx_ring_inuse", @@ -4499,43 +4504,43 @@ hn_nvs_handle_rxbuf(struct hn_rx_ring *r } /* - * Moved completion call back here so that all received - * messages (not just data messages) will trigger a response - * message back to the host. + * Ack the consumed RXBUF associated w/ this channel packet, + * so that this RXBUF can be recycled by the hypervisor. */ - hn_nvs_ack_rxbuf(chan, pkt->cp_hdr.cph_xactid); + hn_nvs_ack_rxbuf(rxr, chan, pkt->cp_hdr.cph_xactid); } -/* - * Net VSC on receive completion - * - * Send a receive completion packet to RNDIS device (ie NetVsp) - */ static void -hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid) +hn_nvs_ack_rxbuf(struct hn_rx_ring *rxr, struct vmbus_channel *chan, + uint64_t tid) { struct hn_nvs_rndis_ack ack; - int retries = 0; - int ret = 0; + int retries, error; ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; ack.nvs_status = HN_NVS_STATUS_OK; -retry_send_cmplt: - /* Send the completion */ - ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, + retries = 0; +again: + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); - if (ret == 0) { - /* success */ - /* no-op */ - } else if (ret == EAGAIN) { - /* no more room... wait a bit and attempt to retry 3 times */ + if (__predict_false(error == EAGAIN)) { + /* + * NOTE: + * This should _not_ happen in real world, since the + * consumption of the TX bufring from the TX path is + * controlled. + */ + if (rxr->hn_ack_failed == 0) + if_printf(rxr->hn_ifp, "RXBUF ack retry\n"); + rxr->hn_ack_failed++; retries++; - - if (retries < 4) { + if (retries < 10) { DELAY(100); - goto retry_send_cmplt; + goto again; } + /* RXBUF leaks! */ + if_printf(rxr->hn_ifp, "RXBUF ack failed\n"); } } Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 31 04:46:02 2016 (r308117) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 31 04:54:15 2016 (r308118) @@ -77,6 +77,7 @@ struct hn_rx_ring { u_long hn_small_pkts; u_long hn_pkts; u_long hn_rss_pkts; + u_long hn_ack_failed; /* Rarely used stuffs */ struct sysctl_oid *hn_rx_sysctl_tree; From owner-svn-src-head@freebsd.org Mon Oct 31 05:05:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49554C278E0; Mon, 31 Oct 2016 05:05:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EF8DF1D28; Mon, 31 Oct 2016 05:05:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V55D1e011554; Mon, 31 Oct 2016 05:05:13 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V55D4O011553; Mon, 31 Oct 2016 05:05:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610310505.u9V55D4O011553@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Oct 2016 05:05:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308119 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 05:05:14 -0000 Author: sephe Date: Mon Oct 31 05:05:12 2016 New Revision: 308119 URL: https://svnweb.freebsd.org/changeset/base/308119 Log: hyperv/hn: Reset do_lro, if the hash types are not TCP related. Mainly because the host side only set TCPCS and IPCS even for UDP datagrams. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8369 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 04:54:15 2016 (r308118) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 05:05:12 2016 (r308119) @@ -1754,6 +1754,13 @@ hn_rxpkt(struct hn_rx_ring *rxr, const v rxr->hn_csum_udp++; } + /* + * XXX + * As of this write (Oct 28th, 2016), host side will turn + * on only TCPCS_OK and IPCS_OK even for UDP datagrams, so + * the do_lro setting here is actually _not_ accurate. We + * depend on the RSS hash type check to reset do_lro. + */ if ((info->csum_info & (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) == (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) @@ -1828,9 +1835,16 @@ skip: NDIS_HASH_FUNCTION_TOEPLITZ) { uint32_t type = (info->hash_info & NDIS_HASH_TYPE_MASK); + /* + * NOTE: + * do_lro is resetted, if the hash types are not TCP + * related. See the comment in the above csum_flags + * setup section. + */ switch (type) { case NDIS_HASH_IPV4: hash_type = M_HASHTYPE_RSS_IPV4; + do_lro = 0; break; case NDIS_HASH_TCP_IPV4: @@ -1839,10 +1853,12 @@ skip: case NDIS_HASH_IPV6: hash_type = M_HASHTYPE_RSS_IPV6; + do_lro = 0; break; case NDIS_HASH_IPV6_EX: hash_type = M_HASHTYPE_RSS_IPV6_EX; + do_lro = 0; break; case NDIS_HASH_TCP_IPV6: From owner-svn-src-head@freebsd.org Mon Oct 31 05:22:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 423B9C27B92; Mon, 31 Oct 2016 05:22:02 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EA681410; Mon, 31 Oct 2016 05:22:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V5M1la016367; Mon, 31 Oct 2016 05:22:01 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V5M1TS016366; Mon, 31 Oct 2016 05:22:01 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610310522.u9V5M1TS016366@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 31 Oct 2016 05:22:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308120 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 05:22:02 -0000 Author: sephe Date: Mon Oct 31 05:22:00 2016 New Revision: 308120 URL: https://svnweb.freebsd.org/changeset/base/308120 Log: hyperv/hn: Don't start shared TX taskq, if the hypervisor is not Hyper-V. - Move the SYSINIT to DRIVER/SECOND, i.e. after the vm_guest becomes determistic. - Minor style changes. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8370 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 05:05:12 2016 (r308119) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 31 05:22:00 2016 (r308120) @@ -4627,6 +4627,10 @@ hn_chan_callback(struct vmbus_channel *c static void hn_tx_taskq_create(void *arg __unused) { + + if (vm_guest != VM_GUEST_HV) + return; + if (!hn_share_tx_taskq) return; @@ -4645,16 +4649,17 @@ hn_tx_taskq_create(void *arg __unused) taskqueue_start_threads(&hn_tx_taskq, 1, PI_NET, "hn tx"); } } -SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_FIRST, +SYSINIT(hn_txtq_create, SI_SUB_DRIVERS, SI_ORDER_SECOND, hn_tx_taskq_create, NULL); static void hn_tx_taskq_destroy(void *arg __unused) { + if (hn_tx_taskq != NULL) taskqueue_free(hn_tx_taskq); } -SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_FIRST, +SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_SECOND, hn_tx_taskq_destroy, NULL); static device_method_t netvsc_methods[] = { From owner-svn-src-head@freebsd.org Mon Oct 31 05:58:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F1D4C27596; Mon, 31 Oct 2016 05:58:13 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D536116E; Mon, 31 Oct 2016 05:58:13 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V5wCYs030571; Mon, 31 Oct 2016 05:58:12 GMT (envelope-from kevlo@FreeBSD.org) Received: (from kevlo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9V5wBRN030563; Mon, 31 Oct 2016 05:58:11 GMT (envelope-from kevlo@FreeBSD.org) Message-Id: <201610310558.u9V5wBRN030563@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevlo set sender to kevlo@FreeBSD.org using -f From: Kevin Lo Date: Mon, 31 Oct 2016 05:58:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308121 - in head: etc/devd share/man/man4 sys/conf sys/dev/mii sys/dev/usb/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 05:58:13 -0000 Author: kevlo Date: Mon Oct 31 05:58:11 2016 New Revision: 308121 URL: https://svnweb.freebsd.org/changeset/base/308121 Log: Add preliminary support for the RTL8153. Reviewed by: hselasky Modified: head/etc/devd/usb.conf head/share/man/man4/ure.4 head/sys/conf/NOTES head/sys/dev/mii/miidevs head/sys/dev/mii/rgephy.c head/sys/dev/mii/rgephyreg.h head/sys/dev/usb/net/if_ure.c head/sys/dev/usb/net/if_urereg.h Modified: head/etc/devd/usb.conf ============================================================================== --- head/etc/devd/usb.conf Mon Oct 31 05:22:00 2016 (r308120) +++ head/etc/devd/usb.conf Mon Oct 31 05:58:11 2016 (r308121) @@ -2713,7 +2713,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0bda"; - match "product" "0x8152"; + match "product" "(0x8152|0x8153)"; action "kldload -n if_ure"; }; Modified: head/share/man/man4/ure.4 ============================================================================== --- head/share/man/man4/ure.4 Mon Oct 31 05:22:00 2016 (r308120) +++ head/share/man/man4/ure.4 Mon Oct 31 05:58:11 2016 (r308121) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2015 Kevin Lo +.\" Copyright (c) 2015-2016 Kevin Lo .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,12 +25,12 @@ .\" .\" $FreeBSD$ .\" -.Dd December 1, 2015 +.Dd October 31, 2016 .Dt URE 4 .Os .Sh NAME .Nm ure -.Nd "RealTek RTL8152 USB to Fast Ethernet controller driver" +.Nd "RealTek RTL8152/RTL8153 USB to Ethernet controller driver" .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -54,10 +54,10 @@ if_ure_load="YES" The .Nm driver provides support for USB Ethernet adapters based on the RealTek -RTL8152 USB to Fast Ethernet controller chip. +RealTek RTL8152 and RTL8153 USB Ethernet controllers. .Pp -The RTL8152 contains an integrated Fast Ethernet MAC, which supports -both 10 and 100Mbps speeds in either full or half duplex. +NICs based on the RTL8152 are capable of 10 and 100Mbps speeds. +NICs based on the RTL8153 are capable of 10, 100 and 1000Mbps operation. .Pp The .Nm @@ -87,12 +87,17 @@ option can also be used to select either or .Cm half-duplex modes. +.It Cm 1000baseTX +Set 1000baseTX operation over twisted pair. +The RealTek gigE chips support 1000Mbps in +.Cm full-duplex +mode only. .El .Pp The .Nm driver supports the following media options: -.Bl -tag -width ".Cm 10baseT/UTP" +.Bl -tag -width ".Cm full-duplex" .It Cm full-duplex Force full duplex operation. .It Cm half-duplex Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/conf/NOTES Mon Oct 31 05:58:11 2016 (r308121) @@ -2788,7 +2788,7 @@ device rue # Davicom DM9601E USB to fast ethernet. Supports the Corega FEther USB-TXC. device udav # -# RealTek RTL8152 USB to fast ethernet. +# RealTek RTL8152/RTL8153 USB Ethernet driver device ure # # Moschip MCS7730/MCS7840 USB to fast ethernet. Supports the Sitecom LN030. Modified: head/sys/dev/mii/miidevs ============================================================================== --- head/sys/dev/mii/miidevs Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/dev/mii/miidevs Mon Oct 31 05:58:11 2016 (r308121) @@ -316,7 +316,7 @@ model yyREALTEK RTL8201L 0x0020 RTL8201L model xxREALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface model REALTEK RTL8305SC 0x0005 RTL8305SC 10/100 802.1q switch model REALTEK RTL8201E 0x0008 RTL8201E 10/100 media interface -model REALTEK RTL8251 0x0000 RTL8251 1000BASE-T media interface +model REALTEK RTL8251 0x0000 RTL8251/8153 1000BASE-T media interface model REALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface /* Seeq Seeq PHYs */ Modified: head/sys/dev/mii/rgephy.c ============================================================================== --- head/sys/dev/mii/rgephy.c Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/dev/mii/rgephy.c Mon Oct 31 05:58:11 2016 (r308121) @@ -121,6 +121,8 @@ rgephy_attach(device_t dev) flags = 0; if (mii_dev_mac_match(dev, "re")) flags |= MIIF_PHYPRIV0; + else if (mii_dev_mac_match(dev, "ure")) + flags |= MIIF_PHYPRIV1; mii_phy_dev_attach(dev, flags, &rgephy_funcs, 0); /* RTL8169S do not report auto-sense; add manually. */ @@ -293,7 +295,10 @@ rgephy_linkup(struct mii_softc *sc) linkup++; } } else { - reg = PHY_READ(sc, RL_GMEDIASTAT); + if (sc->mii_flags & MIIF_PHYPRIV1) + reg = PHY_READ(sc, URE_GMEDIASTAT); + else + reg = PHY_READ(sc, RL_GMEDIASTAT); if (reg & RL_GMEDIASTAT_LINK) linkup++; } @@ -378,7 +383,10 @@ rgephy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_HDX; } } else { - bmsr = PHY_READ(sc, RL_GMEDIASTAT); + if (sc->mii_flags & MIIF_PHYPRIV1) + bmsr = PHY_READ(sc, URE_GMEDIASTAT); + else + bmsr = PHY_READ(sc, RL_GMEDIASTAT); if (bmsr & RL_GMEDIASTAT_1000MBPS) mii->mii_media_active |= IFM_1000_T; else if (bmsr & RL_GMEDIASTAT_100MBPS) Modified: head/sys/dev/mii/rgephyreg.h ============================================================================== --- head/sys/dev/mii/rgephyreg.h Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/dev/mii/rgephyreg.h Mon Oct 31 05:58:11 2016 (r308121) @@ -199,4 +199,7 @@ #define EEELPAR_1000T 0x0004 /* link partner 1000baseT EEE capable */ #define EEELPAR_100TX 0x0002 /* link partner 100baseTX EEE capable */ +/* RTL8153 */ +#define URE_GMEDIASTAT 0xe908 /* media status register */ + #endif /* _DEV_RGEPHY_MIIREG_H_ */ Modified: head/sys/dev/usb/net/if_ure.c ============================================================================== --- head/sys/dev/usb/net/if_ure.c Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/dev/usb/net/if_ure.c Mon Oct 31 05:58:11 2016 (r308121) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Kevin Lo + * Copyright (c) 2015-2016 Kevin Lo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,8 +66,9 @@ SYSCTL_INT(_hw_usb_ure, OID_AUTO, debug, * Various supported device vendors/products. */ static const STRUCT_USB_HOST_ID ure_devs[] = { -#define URE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } - URE_DEV(REALTEK, RTL8152), +#define URE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } + URE_DEV(REALTEK, RTL8152, URE_FLAG_8152), + URE_DEV(REALTEK, RTL8153, 0), #undef URE_DEV }; @@ -87,8 +88,7 @@ static uether_fn_t ure_init; static uether_fn_t ure_stop; static uether_fn_t ure_start; static uether_fn_t ure_tick; -static uether_fn_t ure_setmulti; -static uether_fn_t ure_setpromisc; +static uether_fn_t ure_rxfilter; static int ure_ctl(struct ure_softc *, uint8_t, uint16_t, uint16_t, void *, int); @@ -112,6 +112,7 @@ static int ure_ifmedia_upd(struct ifnet static void ure_ifmedia_sts(struct ifnet *, struct ifmediareq *); static int ure_ioctl(struct ifnet *, u_long, caddr_t); static void ure_rtl8152_init(struct ure_softc *); +static void ure_rtl8153_init(struct ure_softc *); static void ure_disable_teredo(struct ure_softc *); static void ure_init_fifo(struct ure_softc *); @@ -129,7 +130,7 @@ static const struct usb_config ure_confi .type = UE_BULK, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, - .bufsize = MCLBYTES, + .bufsize = 16384, .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, .callback = ure_bulk_read_callback, .timeout = 0, /* no timeout */ @@ -173,8 +174,8 @@ static const struct usb_ether_methods ur .ue_init = ure_init, .ue_stop = ure_stop, .ue_tick = ure_tick, - .ue_setmulti = ure_setmulti, - .ue_setpromisc = ure_setpromisc, + .ue_setmulti = ure_rxfilter, + .ue_setpromisc = ure_rxfilter, .ue_mii_upd = ure_ifmedia_upd, .ue_mii_sts = ure_ifmedia_sts, }; @@ -343,6 +344,13 @@ ure_miibus_readreg(device_t dev, int phy if (!locked) URE_LOCK(sc); + /* Let the rgephy driver read the URE_GMEDIASTAT register. */ + if (reg == URE_GMEDIASTAT) { + if (!locked) + URE_UNLOCK(sc); + return (ure_read_1(sc, URE_GMEDIASTAT, URE_MCU_TYPE_PLA)); + } + val = ure_ocp_reg_read(sc, URE_OCP_BASE_MII + reg * 2); if (!locked) @@ -398,6 +406,11 @@ ure_miibus_statchg(device_t dev) case IFM_100_TX: sc->sc_flags |= URE_FLAG_LINK; break; + case IFM_1000_T: + if ((sc->sc_flags & URE_FLAG_8152) != 0) + break; + sc->sc_flags |= URE_FLAG_LINK; + break; default: break; } @@ -412,7 +425,7 @@ done: } /* - * Probe for a RTL8152 chip. + * Probe for a RTL8152/RTL8153 chip. */ static int ure_probe(device_t dev) @@ -443,6 +456,7 @@ ure_attach(device_t dev) uint8_t iface_index; int error; + sc->sc_flags = USB_GET_DRIVER_INFO(uaa); device_set_usb_desc(dev); mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); @@ -617,6 +631,18 @@ ure_read_chipver(struct ure_softc *sc) case 0x4c10: sc->sc_chip |= URE_CHIP_VER_4C10; break; + case 0x5c00: + sc->sc_chip |= URE_CHIP_VER_5C00; + break; + case 0x5c10: + sc->sc_chip |= URE_CHIP_VER_5C10; + break; + case 0x5c20: + sc->sc_chip |= URE_CHIP_VER_5C20; + break; + case 0x5c30: + sc->sc_chip |= URE_CHIP_VER_5C30; + break; default: device_printf(sc->sc_ue.ue_dev, "unknown version 0x%04x\n", ver); @@ -635,7 +661,10 @@ ure_attach_post(struct usb_ether *ue) ure_read_chipver(sc); /* Initialize controller and get station address. */ - ure_rtl8152_init(sc); + if (sc->sc_flags & URE_FLAG_8152) + ure_rtl8152_init(sc); + else + ure_rtl8153_init(sc); if (sc->sc_chip & URE_CHIP_VER_4C00) ure_read_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA, @@ -676,7 +705,6 @@ ure_init(struct usb_ether *ue) { struct ure_softc *sc = uether_getsc(ue); struct ifnet *ifp = uether_getifp(ue); - uint32_t rxmode; URE_LOCK_ASSERT(sc, MA_OWNED); @@ -709,20 +737,8 @@ ure_init(struct usb_ether *ue) ure_read_2(sc, URE_PLA_MISC_1, URE_MCU_TYPE_PLA) & ~URE_RXDY_GATED_EN); - /* Set Rx mode. */ - rxmode = URE_RCR_APM; - - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) - rxmode |= URE_RCR_AAP; - - if (ifp->if_flags & IFF_BROADCAST) - rxmode |= URE_RCR_AB; - - ure_write_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA, rxmode); - - /* Load the multicast filter. */ - ure_setmulti(ue); + /* Configure RX filters. */ + ure_rxfilter(ue); usbd_xfer_set_stall(sc->sc_xfer[URE_BULK_DT_WR]); @@ -750,30 +766,11 @@ ure_tick(struct usb_ether *ue) } } -static void -ure_setpromisc(struct usb_ether *ue) -{ - struct ure_softc *sc = uether_getsc(ue); - struct ifnet *ifp = uether_getifp(ue); - uint32_t rxmode; - - rxmode = ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA); - - if (ifp->if_flags & IFF_PROMISC) - rxmode |= URE_RCR_AAP; - else - rxmode &= ~URE_RCR_AAP; - - ure_write_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA, rxmode); - - ure_setmulti(ue); -} - /* * Program the 64-bit multicast hash filter. */ static void -ure_setmulti(struct usb_ether *ue) +ure_rxfilter(struct usb_ether *ue) { struct ure_softc *sc = uether_getsc(ue); struct ifnet *ifp = uether_getifp(ue); @@ -783,7 +780,9 @@ ure_setmulti(struct usb_ether *ue) URE_LOCK_ASSERT(sc, MA_OWNED); - rxmode = ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA); + rxmode = URE_RCR_APM; + if (ifp->if_flags & IFF_BROADCAST) + rxmode |= URE_RCR_AB; if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) { if (ifp->if_flags & IFF_PROMISC) rxmode |= URE_RCR_AAP; @@ -792,6 +791,7 @@ ure_setmulti(struct usb_ether *ue) goto done; } + rxmode |= URE_RCR_AM; if_maddr_rlock(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) @@ -965,6 +965,156 @@ ure_rtl8152_init(struct ure_softc *sc) } static void +ure_rtl8153_init(struct ure_softc *sc) +{ + uint16_t val; + uint8_t u1u2[8]; + int i; + + /* Disable ALDPS. */ + ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, + ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) & ~URE_EN_ALDPS); + uether_pause(&sc->sc_ue, hz / 50); + + memset(u1u2, 0x00, sizeof(u1u2)); + ure_write_mem(sc, URE_USB_TOLERANCE, + URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); + + for (i = 0; i < URE_TIMEOUT; i++) { + if (ure_read_2(sc, URE_PLA_BOOT_CTRL, URE_MCU_TYPE_PLA) & + URE_AUTOLOAD_DONE) + break; + uether_pause(&sc->sc_ue, hz / 100); + } + if (i == URE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, + "timeout waiting for chip autoload\n"); + + for (i = 0; i < URE_TIMEOUT; i++) { + val = ure_ocp_reg_read(sc, URE_OCP_PHY_STATUS) & + URE_PHY_STAT_MASK; + if (val == URE_PHY_STAT_LAN_ON || val == URE_PHY_STAT_PWRDN) + break; + uether_pause(&sc->sc_ue, hz / 100); + } + if (i == URE_TIMEOUT) + device_printf(sc->sc_ue.ue_dev, + "timeout waiting for phy to stabilize\n"); + + ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, + ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB) & + ~URE_U2P3_ENABLE); + + if (sc->sc_chip & URE_CHIP_VER_5C10) { + val = ure_read_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB); + val &= ~URE_PWD_DN_SCALE_MASK; + val |= URE_PWD_DN_SCALE(96); + ure_write_2(sc, URE_USB_SSPHYLINK2, URE_MCU_TYPE_USB, val); + + ure_write_1(sc, URE_USB_USB2PHY, URE_MCU_TYPE_USB, + ure_read_1(sc, URE_USB_USB2PHY, URE_MCU_TYPE_USB) | + URE_USB2PHY_L1 | URE_USB2PHY_SUSPEND); + } else if (sc->sc_chip & URE_CHIP_VER_5C20) { + ure_write_1(sc, URE_PLA_DMY_REG0, URE_MCU_TYPE_PLA, + ure_read_1(sc, URE_PLA_DMY_REG0, URE_MCU_TYPE_PLA) & + ~URE_ECM_ALDPS); + } + if (sc->sc_chip & (URE_CHIP_VER_5C20 | URE_CHIP_VER_5C30)) { + val = ure_read_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB); + if (ure_read_2(sc, URE_USB_BURST_SIZE, URE_MCU_TYPE_USB) == + 0) + val &= ~URE_DYNAMIC_BURST; + else + val |= URE_DYNAMIC_BURST; + ure_write_1(sc, URE_USB_CSR_DUMMY1, URE_MCU_TYPE_USB, val); + } + + ure_write_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB, + ure_read_1(sc, URE_USB_CSR_DUMMY2, URE_MCU_TYPE_USB) | + URE_EP4_FULL_FC); + + ure_write_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB, + ure_read_2(sc, URE_USB_WDT11_CTRL, URE_MCU_TYPE_USB) & + ~URE_TIMER11_EN); + + ure_write_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA, + ure_read_2(sc, URE_PLA_LED_FEATURE, URE_MCU_TYPE_PLA) & + ~URE_LED_MODE_MASK); + + if ((sc->sc_chip & URE_CHIP_VER_5C10) && + usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_SUPER) + val = URE_LPM_TIMER_500MS; + else + val = URE_LPM_TIMER_500US; + ure_write_1(sc, URE_USB_LPM_CTRL, URE_MCU_TYPE_USB, + val | URE_FIFO_EMPTY_1FB | URE_ROK_EXIT_LPM); + + val = ure_read_2(sc, URE_USB_AFE_CTRL2, URE_MCU_TYPE_USB); + val &= ~URE_SEN_VAL_MASK; + val |= URE_SEN_VAL_NORMAL | URE_SEL_RXIDLE; + ure_write_2(sc, URE_USB_AFE_CTRL2, URE_MCU_TYPE_USB, val); + + ure_write_2(sc, URE_USB_CONNECT_TIMER, URE_MCU_TYPE_USB, 0x0001); + + ure_write_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB, + ure_read_2(sc, URE_USB_POWER_CUT, URE_MCU_TYPE_USB) & + ~(URE_PWR_EN | URE_PHASE2_EN)); + ure_write_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB, + ure_read_2(sc, URE_USB_MISC_0, URE_MCU_TYPE_USB) & + ~URE_PCUT_STATUS); + + memset(u1u2, 0xff, sizeof(u1u2)); + ure_write_mem(sc, URE_USB_TOLERANCE, + URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); + + ure_write_2(sc, URE_PLA_MAC_PWR_CTRL, URE_MCU_TYPE_PLA, + URE_ALDPS_SPDWN_RATIO); + ure_write_2(sc, URE_PLA_MAC_PWR_CTRL2, URE_MCU_TYPE_PLA, + URE_EEE_SPDWN_RATIO); + ure_write_2(sc, URE_PLA_MAC_PWR_CTRL3, URE_MCU_TYPE_PLA, + URE_PKT_AVAIL_SPDWN_EN | URE_SUSPEND_SPDWN_EN | + URE_U1U2_SPDWN_EN | URE_L1_SPDWN_EN); + ure_write_2(sc, URE_PLA_MAC_PWR_CTRL4, URE_MCU_TYPE_PLA, + URE_PWRSAVE_SPDWN_EN | URE_RXDV_SPDWN_EN | URE_TX10MIDLE_EN | + URE_TP100_SPDWN_EN | URE_TP500_SPDWN_EN | URE_TP1000_SPDWN_EN | + URE_EEE_SPDWN_EN); + + val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB); + if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) + val |= URE_U2P3_ENABLE; + else + val &= ~URE_U2P3_ENABLE; + ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, val); + + memset(u1u2, 0x00, sizeof(u1u2)); + ure_write_mem(sc, URE_USB_TOLERANCE, + URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); + + /* Disable ALDPS. */ + ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, + ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) & ~URE_EN_ALDPS); + uether_pause(&sc->sc_ue, hz / 50); + + ure_init_fifo(sc); + + /* Disable Rx aggregation. */ + ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB, + ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) | + URE_RX_AGG_DISABLE); + + val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB); + if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) + val |= URE_U2P3_ENABLE; + else + val &= ~URE_U2P3_ENABLE; + ure_write_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB, val); + + memset(u1u2, 0xff, sizeof(u1u2)); + ure_write_mem(sc, URE_USB_TOLERANCE, + URE_MCU_TYPE_USB | URE_BYTE_EN_SIX_BYTES, u1u2, sizeof(u1u2)); +} + +static void ure_stop(struct usb_ether *ue) { struct ure_softc *sc = uether_getsc(ue); @@ -1011,6 +1161,43 @@ ure_init_fifo(struct ure_softc *sc) ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA) & ~URE_RCR_ACPT_ALL); + if (!(sc->sc_flags & URE_FLAG_8152)) { + if (sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10 | + URE_CHIP_VER_5C20)) { + ure_ocp_reg_write(sc, URE_OCP_ADC_CFG, + URE_CKADSEL_L | URE_ADC_EN | URE_EN_EMI_L); + } + if (sc->sc_chip & URE_CHIP_VER_5C00) { + ure_ocp_reg_write(sc, URE_OCP_EEE_CFG, + ure_ocp_reg_read(sc, URE_OCP_EEE_CFG) & + ~URE_CTAP_SHORT_EN); + } + ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, + ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | + URE_EEE_CLKDIV_EN); + ure_ocp_reg_write(sc, URE_OCP_DOWN_SPEED, + ure_ocp_reg_read(sc, URE_OCP_DOWN_SPEED) | + URE_EN_10M_BGOFF); + ure_ocp_reg_write(sc, URE_OCP_POWER_CFG, + ure_ocp_reg_read(sc, URE_OCP_POWER_CFG) | + URE_EN_10M_PLLOFF); + ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_IMPEDANCE); + ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x0b13); + ure_write_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA, + ure_read_2(sc, URE_PLA_PHY_PWR, URE_MCU_TYPE_PLA) | + URE_PFM_PWM_SWITCH); + + /* Enable LPF corner auto tune. */ + ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_LPF_CFG); + ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0xf70f); + + /* Adjust 10M amplitude. */ + ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_10M_AMP1); + ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x00af); + ure_ocp_reg_write(sc, URE_OCP_SRAM_ADDR, URE_SRAM_10M_AMP2); + ure_ocp_reg_write(sc, URE_OCP_SRAM_DATA, 0x0208); + } + ure_reset(sc); ure_write_1(sc, URE_PLA_CR, URE_MCU_TYPE_PLA, 0); Modified: head/sys/dev/usb/net/if_urereg.h ============================================================================== --- head/sys/dev/usb/net/if_urereg.h Mon Oct 31 05:22:00 2016 (r308120) +++ head/sys/dev/usb/net/if_urereg.h Mon Oct 31 05:58:11 2016 (r308121) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Kevin Lo + * Copyright (c) 2015-2016 Kevin Lo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,7 @@ #define URE_PLA_OCP_GPHY_BASE 0xe86c #define URE_PLA_TELLYCNT 0xe890 #define URE_PLA_SFF_STS_7 0xe8de -#define URE_PLA_PHYSTATUS 0xe908 +#define URE_GMEDIASTAT 0xe908 #define URE_USB_USB2PHY 0xb41e #define URE_USB_SSPHYLINK2 0xb428 @@ -424,10 +424,15 @@ struct ure_softc { u_int sc_flags; #define URE_FLAG_LINK 0x0001 +#define URE_FLAG_8152 0x1000 /* RTL8152 */ u_int sc_chip; #define URE_CHIP_VER_4C00 0x01 #define URE_CHIP_VER_4C10 0x02 +#define URE_CHIP_VER_5C00 0x04 +#define URE_CHIP_VER_5C10 0x08 +#define URE_CHIP_VER_5C20 0x10 +#define URE_CHIP_VER_5C30 0x20 }; #define URE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) From owner-svn-src-head@freebsd.org Mon Oct 31 11:13:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC0A1C27EB4; Mon, 31 Oct 2016 11:13:37 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B87411431; Mon, 31 Oct 2016 11:13:37 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VBDaMP053994; Mon, 31 Oct 2016 11:13:36 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VBDaxi053993; Mon, 31 Oct 2016 11:13:36 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610311113.u9VBDaxi053993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 31 Oct 2016 11:13:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308124 - head/sys/boot/efi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 11:13:38 -0000 Author: andrew Date: Mon Oct 31 11:13:36 2016 New Revision: 308124 URL: https://svnweb.freebsd.org/changeset/base/308124 Log: On arm64 build the efi loader with -fPIC. Without this clang 3.9 will generate relocation in the self relocation code. MFC after: 1 week Sponsored by: ABT Systems Ltd Modified: head/sys/boot/efi/Makefile.inc Modified: head/sys/boot/efi/Makefile.inc ============================================================================== --- head/sys/boot/efi/Makefile.inc Mon Oct 31 07:21:37 2016 (r308123) +++ head/sys/boot/efi/Makefile.inc Mon Oct 31 11:13:36 2016 (r308124) @@ -20,6 +20,7 @@ CFLAGS+= -mno-aes .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -fshort-wchar +CFLAGS+= -fPIC .endif .include "../Makefile.inc" From owner-svn-src-head@freebsd.org Mon Oct 31 11:30:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E0A8C28354; Mon, 31 Oct 2016 11:30:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FE961BE4; Mon, 31 Oct 2016 11:30:02 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VBU1OH058208; Mon, 31 Oct 2016 11:30:01 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VBU18w058207; Mon, 31 Oct 2016 11:30:01 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201610311130.u9VBU18w058207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 31 Oct 2016 11:30:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308125 - head/sys/boot/efi/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 11:30:02 -0000 Author: manu Date: Mon Oct 31 11:30:01 2016 New Revision: 308125 URL: https://svnweb.freebsd.org/changeset/base/308125 Log: In loader.efi, instead of exiting directly, try to fallback on the first EFI device if we can't find the one from which the image was loaded. Reviewed by: allanjude,imp,jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6780 Modified: head/sys/boot/efi/loader/main.c Modified: head/sys/boot/efi/loader/main.c ============================================================================== --- head/sys/boot/efi/loader/main.c Mon Oct 31 11:13:36 2016 (r308124) +++ head/sys/boot/efi/loader/main.c Mon Oct 31 11:30:01 2016 (r308125) @@ -237,6 +237,11 @@ find_currdev(EFI_LOADED_IMAGE *img, stru } } + /* Try to fallback on first device */ + if (devsw[0] != NULL) { + *dev = devsw[0]; + return (0); + } return (ENOENT); } From owner-svn-src-head@freebsd.org Mon Oct 31 11:31:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E405BC2845F; Mon, 31 Oct 2016 11:31:12 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5E0E1DEF; Mon, 31 Oct 2016 11:31:12 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VBVBS9060987; Mon, 31 Oct 2016 11:31:11 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VBVBh6060986; Mon, 31 Oct 2016 11:31:11 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201610311131.u9VBVBh6060986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Mon, 31 Oct 2016 11:31:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308126 - head/sys/dev/xen/netfront X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 11:31:13 -0000 Author: royger Date: Mon Oct 31 11:31:11 2016 New Revision: 308126 URL: https://svnweb.freebsd.org/changeset/base/308126 Log: xen/netfront: fix statistics Fix the statistics used by netfront. Reported by: Trond.Endrestol@ximalas.info Submitted by: ae Reviewed by: royger, Wei Liu MFC after: 4 weeks PR: 213439 Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Mon Oct 31 11:30:01 2016 (r308125) +++ head/sys/dev/xen/netfront/netfront.c Mon Oct 31 11:31:11 2016 (r308126) @@ -156,21 +156,6 @@ static int xn_get_responses(struct netfr #define virt_to_mfn(x) (vtophys(x) >> PAGE_SHIFT) #define INVALID_P2M_ENTRY (~0UL) - -struct xn_rx_stats -{ - u_long rx_packets; /* total packets received */ - u_long rx_bytes; /* total bytes received */ - u_long rx_errors; /* bad packets received */ -}; - -struct xn_tx_stats -{ - u_long tx_packets; /* total packets transmitted */ - u_long tx_bytes; /* total bytes transmitted */ - u_long tx_errors; /* packet transmit problems */ -}; - #define XN_QUEUE_NAME_LEN 8 /* xn{t,r}x_%u, allow for two digits */ struct netfront_rxq { struct netfront_info *info; @@ -190,8 +175,6 @@ struct netfront_rxq { struct lro_ctrl lro; struct callout rx_refill; - - struct xn_rx_stats stats; }; struct netfront_txq { @@ -215,8 +198,6 @@ struct netfront_txq { struct task defrtask; bool full; - - struct xn_tx_stats stats; }; struct netfront_info { @@ -1191,7 +1172,7 @@ xn_rxeof(struct netfront_rxq *rxq) if (__predict_false(err)) { if (m) (void )mbufq_enqueue(&mbufq_errq, m); - rxq->stats.rx_errors++; + if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); continue; } @@ -1216,9 +1197,6 @@ xn_rxeof(struct netfront_rxq *rxq) m->m_pkthdr.csum_flags |= CSUM_TSO; } - rxq->stats.rx_packets++; - rxq->stats.rx_bytes += m->m_pkthdr.len; - (void )mbufq_enqueue(&mbufq_rxq, m); rxq->ring.rsp_cons = i; } @@ -1304,12 +1282,6 @@ xn_txeof(struct netfront_txq *txq) "trying to free it again!")); M_ASSERTVALID(m); - /* - * Increment packet count if this is the last - * mbuf of the chain. - */ - if (!m->m_next) - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); if (__predict_false(gnttab_query_foreign_access( txq->grant_ref[id]) != 0)) { panic("%s: grant id %u still in use by the " @@ -1701,10 +1673,12 @@ xn_assemble_tx_request(struct netfront_t } BPF_MTAP(ifp, m_head); - xn_txeof(txq); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); + if_inc_counter(ifp, IFCOUNTER_OBYTES, m_head->m_pkthdr.len); + if (m_head->m_flags & M_MCAST) + if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); - txq->stats.tx_bytes += m_head->m_pkthdr.len; - txq->stats.tx_packets++; + xn_txeof(txq); return (0); } From owner-svn-src-head@freebsd.org Mon Oct 31 13:00:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8CA96C284B5; Mon, 31 Oct 2016 13:00:54 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6458C1594; Mon, 31 Oct 2016 13:00:54 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VD0rpH092159; Mon, 31 Oct 2016 13:00:53 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VD0rRO092157; Mon, 31 Oct 2016 13:00:53 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201610311300.u9VD0rRO092157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Mon, 31 Oct 2016 13:00:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308127 - in head/sys: x86/xen xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 13:00:54 -0000 Author: royger Date: Mon Oct 31 13:00:53 2016 New Revision: 308127 URL: https://svnweb.freebsd.org/changeset/base/308127 Log: xen/intr: add reference counts to event channels Add a reference count to xenisrc. This is required for implementation of unmap-notifications in the grant table userspace device (gntdev). We need to hold a reference to the event channel port, in case the user deallocates the port before we send the notification. Submitted by: jaggi Reviewed by: royger Differential review: https://reviews.freebsd.org/D7429 Modified: head/sys/x86/xen/xen_intr.c head/sys/xen/xen_intr.h Modified: head/sys/x86/xen/xen_intr.c ============================================================================== --- head/sys/x86/xen/xen_intr.c Mon Oct 31 11:31:11 2016 (r308126) +++ head/sys/x86/xen/xen_intr.c Mon Oct 31 13:00:53 2016 (r308127) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -128,6 +129,7 @@ struct xenisrc { u_int xi_activehi:1; u_int xi_edgetrigger:1; u_int xi_masked:1; + volatile u_int xi_refcount; }; static void xen_intr_suspend(struct pic *); @@ -343,10 +345,8 @@ xen_intr_release_isrc(struct xenisrc *is { mtx_lock(&xen_intr_isrc_lock); - if (isrc->xi_intsrc.is_handlers != 0) { - mtx_unlock(&xen_intr_isrc_lock); - return (EBUSY); - } + KASSERT(isrc->xi_intsrc.is_handlers == 0, + ("Release called, but xenisrc still in use")); evtchn_mask_port(isrc->xi_port); evtchn_clear_port(isrc->xi_port); @@ -417,6 +417,7 @@ xen_intr_bind_isrc(struct xenisrc **isrc } isrc->xi_port = local_port; xen_intr_port_to_isrc[local_port] = isrc; + refcount_init(&isrc->xi_refcount, 1); mtx_unlock(&xen_intr_isrc_lock); /* Assign the opaque handler (the event channel port) */ @@ -1508,6 +1509,13 @@ xen_intr_unbind(xen_intr_handle_t *port_ if (isrc == NULL) return; + mtx_lock(&xen_intr_isrc_lock); + if (refcount_release(&isrc->xi_refcount) == 0) { + mtx_unlock(&xen_intr_isrc_lock); + return; + } + mtx_unlock(&xen_intr_isrc_lock); + if (isrc->xi_cookie != NULL) intr_remove_handler(isrc->xi_cookie); xen_intr_release_isrc(isrc); @@ -1563,6 +1571,31 @@ xen_intr_add_handler(device_t dev, drive return (error); } +int +xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep) +{ + + if (!is_valid_evtchn(port) || port >= NR_EVENT_CHANNELS) + return (EINVAL); + + if (handlep == NULL) { + return (EINVAL); + } + + mtx_lock(&xen_intr_isrc_lock); + if (xen_intr_port_to_isrc[port] == NULL) { + mtx_unlock(&xen_intr_isrc_lock); + return (EINVAL); + } + refcount_acquire(&xen_intr_port_to_isrc[port]->xi_refcount); + mtx_unlock(&xen_intr_isrc_lock); + + /* Assign the opaque handler (the event channel port) */ + *handlep = &xen_intr_port_to_isrc[port]->xi_vector; + + return (0); +} + #ifdef DDB static const char * xen_intr_print_type(enum evtchn_type type) Modified: head/sys/xen/xen_intr.h ============================================================================== --- head/sys/xen/xen_intr.h Mon Oct 31 11:31:11 2016 (r308126) +++ head/sys/xen/xen_intr.h Mon Oct 31 13:00:53 2016 (r308127) @@ -263,4 +263,16 @@ int xen_intr_add_handler(device_t dev, d driver_intr_t handler, void *arg, enum intr_type flags, xen_intr_handle_t handle); +/** + * Get a reference to an event channel port + * + * \param port Event channel port to which we get a reference. + * \param handlep Pointer to an opaque handle used to manage this + * registration. + * + * \returns 0 on success, otherwise an errno. + */ +int xen_intr_get_evtchn_from_port(evtchn_port_t port, + xen_intr_handle_t *handlep); + #endif /* _XEN_INTR_H_ */ From owner-svn-src-head@freebsd.org Mon Oct 31 13:12:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3852C2887D; Mon, 31 Oct 2016 13:12:59 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6811B1CA6; Mon, 31 Oct 2016 13:12:59 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VDCwL3099253; Mon, 31 Oct 2016 13:12:58 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VDCwrT099250; Mon, 31 Oct 2016 13:12:58 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201610311312.u9VDCwrT099250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Mon, 31 Oct 2016 13:12:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308128 - in head/sys: conf dev/xen/gntdev xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 13:12:59 -0000 Author: royger Date: Mon Oct 31 13:12:58 2016 New Revision: 308128 URL: https://svnweb.freebsd.org/changeset/base/308128 Log: xen: add a grant-table user-space device A grant-table user-space device will allow user-space applications to map and share grants (Xen way to share memory) among Xen domains. This grant table user-space device has been tested with the QEMU Qdisk Xen backed. Submitted by: jaggi Reviewed by: royger Differential review: https://reviews.freebsd.org/D7293 Added: head/sys/dev/xen/gntdev/ head/sys/dev/xen/gntdev/gntdev.c (contents, props changed) head/sys/xen/gntdev.h (contents, props changed) Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Oct 31 13:00:53 2016 (r308127) +++ head/sys/conf/files Mon Oct 31 13:12:58 2016 (r308128) @@ -3183,6 +3183,7 @@ dev/xen/xenstore/xenstore_dev.c optional dev/xen/xenstore/xenstored_dev.c optional xenhvm dev/xen/evtchn/evtchn_dev.c optional xenhvm dev/xen/privcmd/privcmd.c optional xenhvm +dev/xen/gntdev/gntdev.c optional xenhvm dev/xen/debug/debug.c optional xenhvm dev/xl/if_xl.c optional xl pci dev/xl/xlphy.c optional xl pci Added: head/sys/dev/xen/gntdev/gntdev.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/xen/gntdev/gntdev.c Mon Oct 31 13:12:58 2016 (r308128) @@ -0,0 +1,1275 @@ +/*- + * Copyright (c) 2016 Akshay Jaggi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * gntdev.c + * + * Interface to /dev/xen/gntdev. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +MALLOC_DEFINE(M_GNTDEV, "gntdev", "Xen grant-table user-space device"); + +#define MAX_OFFSET_COUNT ((0xffffffffffffffffull >> PAGE_SHIFT) + 1) + +static d_open_t gntdev_open; +static d_ioctl_t gntdev_ioctl; +static d_mmap_single_t gntdev_mmap_single; + +static struct cdevsw gntdev_devsw = { + .d_version = D_VERSION, + .d_open = gntdev_open, + .d_ioctl = gntdev_ioctl, + .d_mmap_single = gntdev_mmap_single, + .d_name = "gntdev", +}; + +static device_t gntdev_dev = NULL; + +struct gntdev_gref; +struct gntdev_gmap; +STAILQ_HEAD(gref_list_head, gntdev_gref); +STAILQ_HEAD(gmap_list_head, gntdev_gmap); +RB_HEAD(gref_tree_head, gntdev_gref); +RB_HEAD(gmap_tree_head, gntdev_gmap); + +struct file_offset_struct { + RB_ENTRY(file_offset_struct) next; + uint64_t file_offset; + uint64_t count; +}; + +static int +offset_cmp(struct file_offset_struct *f1, struct file_offset_struct *f2) +{ + return (f1->file_offset - f2->file_offset); +} + +RB_HEAD(file_offset_head, file_offset_struct); +RB_GENERATE_STATIC(file_offset_head, file_offset_struct, next, offset_cmp); + +struct per_user_data { + struct mtx user_data_lock; + struct gref_tree_head gref_tree; + struct gmap_tree_head gmap_tree; + struct file_offset_head file_offset; +}; + +/* + * Get offset into the file which will be used while mmapping the + * appropriate pages by the userspace program. + */ +static int +get_file_offset(struct per_user_data *priv_user, uint32_t count, + uint64_t *file_offset) +{ + struct file_offset_struct *offset, *offset_tmp; + + if (count == 0) + return (EINVAL); + mtx_lock(&priv_user->user_data_lock); + RB_FOREACH_SAFE(offset, file_offset_head, &priv_user->file_offset, + offset_tmp) { + if (offset->count >= count) { + offset->count -= count; + *file_offset = offset->file_offset + offset->count * + PAGE_SIZE; + if (offset->count == 0) { + RB_REMOVE(file_offset_head, + &priv_user->file_offset, offset); + free(offset, M_GNTDEV); + } + mtx_unlock(&priv_user->user_data_lock); + return (0); + } + } + mtx_unlock(&priv_user->user_data_lock); + + return (ENOSPC); +} + +static void +put_file_offset(struct per_user_data *priv_user, uint32_t count, + uint64_t file_offset) +{ + struct file_offset_struct *offset, *offset_nxt, *offset_prv; + + offset = malloc(sizeof(*offset), M_GNTDEV, M_WAITOK | M_ZERO); + offset->file_offset = file_offset; + offset->count = count; + + mtx_lock(&priv_user->user_data_lock); + RB_INSERT(file_offset_head, &priv_user->file_offset, offset); + offset_nxt = RB_NEXT(file_offset_head, &priv_user->file_offset, offset); + offset_prv = RB_PREV(file_offset_head, &priv_user->file_offset, offset); + if (offset_nxt != NULL && + offset_nxt->file_offset == offset->file_offset + offset->count * + PAGE_SIZE) { + offset->count += offset_nxt->count; + RB_REMOVE(file_offset_head, &priv_user->file_offset, + offset_nxt); + free(offset_nxt, M_GNTDEV); + } + if (offset_prv != NULL && + offset->file_offset == offset_prv->file_offset + offset_prv->count * + PAGE_SIZE) { + offset_prv->count += offset->count; + RB_REMOVE(file_offset_head, &priv_user->file_offset, offset); + free(offset, M_GNTDEV); + } + mtx_unlock(&priv_user->user_data_lock); +} + +static int gntdev_gmap_pg_ctor(void *handle, vm_ooffset_t size, + vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred, u_short *color); +static void gntdev_gmap_pg_dtor(void *handle); +static int gntdev_gmap_pg_fault(vm_object_t object, vm_ooffset_t offset, + int prot, vm_page_t *mres); + +static struct cdev_pager_ops gntdev_gmap_pg_ops = { + .cdev_pg_fault = gntdev_gmap_pg_fault, + .cdev_pg_ctor = gntdev_gmap_pg_ctor, + .cdev_pg_dtor = gntdev_gmap_pg_dtor, +}; + +struct cleanup_data_struct { + struct mtx to_kill_grefs_mtx; + struct mtx to_kill_gmaps_mtx; + struct gref_list_head to_kill_grefs; + struct gmap_list_head to_kill_gmaps; +}; + +static struct cleanup_data_struct cleanup_data = { + .to_kill_grefs = STAILQ_HEAD_INITIALIZER(cleanup_data.to_kill_grefs), + .to_kill_gmaps = STAILQ_HEAD_INITIALIZER(cleanup_data.to_kill_gmaps), +}; +MTX_SYSINIT(to_kill_grefs_mtx, &cleanup_data.to_kill_grefs_mtx, + "gntdev to_kill_grefs mutex", MTX_DEF); +MTX_SYSINIT(to_kill_gmaps_mtx, &cleanup_data.to_kill_gmaps_mtx, + "gntdev to_kill_gmaps mutex", MTX_DEF); + +static void cleanup_function(void *arg, __unused int pending); +static struct task cleanup_task = TASK_INITIALIZER(0, cleanup_function, + &cleanup_data); + +struct notify_data { + uint64_t index; + uint32_t action; + uint32_t event_channel_port; + xen_intr_handle_t notify_evtchn_handle; +}; + +static void notify(struct notify_data *notify, vm_page_t page); + +/*-------------------- Grant Allocation Methods -----------------------------*/ + +struct gntdev_gref { + union gref_next_union { + STAILQ_ENTRY(gntdev_gref) list; + RB_ENTRY(gntdev_gref) tree; + } gref_next; + uint64_t file_index; + grant_ref_t gref_id; + vm_page_t page; + struct notify_data *notify; +}; + +static int +gref_cmp(struct gntdev_gref *g1, struct gntdev_gref *g2) +{ + return (g1->file_index - g2->file_index); +} + +RB_GENERATE_STATIC(gref_tree_head, gntdev_gref, gref_next.tree, gref_cmp); + +/* + * Traverse over the device-list of to-be-deleted grants allocated, and + * if all accesses, both local mmaps and foreign maps, to them have ended, + * destroy them. + */ +static void +gref_list_dtor(struct cleanup_data_struct *cleanup_data) +{ + struct gref_list_head tmp_grefs; + struct gntdev_gref *gref, *gref_tmp, *gref_previous; + + STAILQ_INIT(&tmp_grefs); + mtx_lock(&cleanup_data->to_kill_grefs_mtx); + STAILQ_SWAP(&cleanup_data->to_kill_grefs, &tmp_grefs, gntdev_gref); + mtx_unlock(&cleanup_data->to_kill_grefs_mtx); + + gref_previous = NULL; + STAILQ_FOREACH_SAFE(gref, &tmp_grefs, gref_next.list, gref_tmp) { + if (gref->page && gref->page->object == NULL) { + if (gref->notify) { + notify(gref->notify, gref->page); + } + if (gref->gref_id != GRANT_REF_INVALID) { + if (gnttab_query_foreign_access(gref->gref_id)) + continue; + if (gnttab_end_foreign_access_ref(gref->gref_id) + == 0) + continue; + gnttab_free_grant_reference(gref->gref_id); + } + vm_page_unwire(gref->page, PQ_NONE); + vm_page_free(gref->page); + gref->page = NULL; + } + if (gref->page == NULL) { + if (gref_previous == NULL) + STAILQ_REMOVE_HEAD(&tmp_grefs, gref_next.list); + else + STAILQ_REMOVE_AFTER(&tmp_grefs, gref_previous, + gref_next.list); + if (gref->notify) + free(gref->notify, M_GNTDEV); + free(gref, M_GNTDEV); + } + else + gref_previous = gref; + } + + if (!STAILQ_EMPTY(&tmp_grefs)) { + mtx_lock(&cleanup_data->to_kill_grefs_mtx); + STAILQ_CONCAT(&cleanup_data->to_kill_grefs, &tmp_grefs); + mtx_unlock(&cleanup_data->to_kill_grefs_mtx); + } +} + +/* + * Find count number of contiguous allocated grants for a given userspace + * program by file-offset (index). + */ +static struct gntdev_gref* +gntdev_find_grefs(struct per_user_data *priv_user, + uint64_t index, uint32_t count) +{ + struct gntdev_gref find_gref, *gref, *gref_start = NULL; + + find_gref.file_index = index; + + mtx_lock(&priv_user->user_data_lock); + gref_start = RB_FIND(gref_tree_head, &priv_user->gref_tree, &find_gref); + for (gref = gref_start; gref != NULL && count > 0; gref = + RB_NEXT(gref_tree_head, &priv_user->gref_tree, gref)) { + if (index != gref->file_index) + break; + index += PAGE_SIZE; + count--; + } + mtx_unlock(&priv_user->user_data_lock); + + if (count) + return (NULL); + return (gref_start); +} + +/* + * IOCTL_GNTDEV_ALLOC_GREF + * Allocate required number of wired pages for the request, grant foreign + * access to the physical frames for these pages, and add details about + * this allocation to the per user private data, so that these pages can + * be mmapped by the userspace program. + */ +static int +gntdev_alloc_gref(struct ioctl_gntdev_alloc_gref *arg) +{ + uint32_t i; + int error, readonly; + uint64_t file_offset; + struct gntdev_gref *grefs; + struct per_user_data *priv_user; + + readonly = !(arg->flags & GNTDEV_ALLOC_FLAG_WRITABLE); + + error = devfs_get_cdevpriv((void**) &priv_user); + if (error != 0) + return (EINVAL); + + /* Cleanup grefs and free pages. */ + taskqueue_enqueue(taskqueue_thread, &cleanup_task); + + /* Get file offset for this request. */ + error = get_file_offset(priv_user, arg->count, &file_offset); + if (error != 0) + return (error); + + /* Allocate grefs. */ + grefs = malloc(sizeof(*grefs) * arg->count, M_GNTDEV, M_WAITOK); + + for (i = 0; i < arg->count; i++) { + grefs[i].file_index = file_offset + i * PAGE_SIZE; + grefs[i].gref_id = GRANT_REF_INVALID; + grefs[i].notify = NULL; + grefs[i].page = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL + | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO); + if (grefs[i].page == NULL) { + log(LOG_ERR, "Page allocation failed."); + error = ENOMEM; + break; + } + if ((grefs[i].page->flags & PG_ZERO) == 0) { + /* + * Zero the allocated page, as we don't want to + * leak our memory to other domains. + */ + pmap_zero_page(grefs[i].page); + } + grefs[i].page->valid = VM_PAGE_BITS_ALL; + + error = gnttab_grant_foreign_access(arg->domid, + (VM_PAGE_TO_PHYS(grefs[i].page) >> PAGE_SHIFT), + readonly, &grefs[i].gref_id); + if (error != 0) { + log(LOG_ERR, "Grant Table Hypercall failed."); + break; + } + } + + if (error != 0) { + /* + * If target domain maps the gref (by guessing the gref-id), + * then we can't clean it up yet and we have to leave the + * page in place so as to not leak our memory to that domain. + * Add it to a global list to be cleaned up later. + */ + mtx_lock(&cleanup_data.to_kill_grefs_mtx); + for (i = 0; i < arg->count; i++) + STAILQ_INSERT_TAIL(&cleanup_data.to_kill_grefs, + &grefs[i], gref_next.list); + mtx_unlock(&cleanup_data.to_kill_grefs_mtx); + + taskqueue_enqueue(taskqueue_thread, &cleanup_task); + + return (error); + } + + /* Copy the output values. */ + arg->index = file_offset; + for (i = 0; i < arg->count; i++) + arg->gref_ids[i] = grefs[i].gref_id; + + /* Modify the per user private data. */ + mtx_lock(&priv_user->user_data_lock); + for (i = 0; i < arg->count; i++) + RB_INSERT(gref_tree_head, &priv_user->gref_tree, &grefs[i]); + mtx_unlock(&priv_user->user_data_lock); + + return (error); +} + +/* + * IOCTL_GNTDEV_DEALLOC_GREF + * Remove grant allocation information from the per user private data, so + * that it can't be mmapped anymore by the userspace program, and add it + * to the to-be-deleted grants global device-list. + */ +static int +gntdev_dealloc_gref(struct ioctl_gntdev_dealloc_gref *arg) +{ + int error; + uint32_t count; + struct gntdev_gref *gref, *gref_tmp; + struct per_user_data *priv_user; + + error = devfs_get_cdevpriv((void**) &priv_user); + if (error != 0) + return (EINVAL); + + gref = gntdev_find_grefs(priv_user, arg->index, arg->count); + if (gref == NULL) { + log(LOG_ERR, "Can't find requested grant-refs."); + return (EINVAL); + } + + /* Remove the grefs from user private data. */ + count = arg->count; + mtx_lock(&priv_user->user_data_lock); + mtx_lock(&cleanup_data.to_kill_grefs_mtx); + for (; gref != NULL && count > 0; gref = gref_tmp) { + gref_tmp = RB_NEXT(gref_tree_head, &priv_user->gref_tree, gref); + RB_REMOVE(gref_tree_head, &priv_user->gref_tree, gref); + STAILQ_INSERT_TAIL(&cleanup_data.to_kill_grefs, gref, + gref_next.list); + count--; + } + mtx_unlock(&cleanup_data.to_kill_grefs_mtx); + mtx_unlock(&priv_user->user_data_lock); + + taskqueue_enqueue(taskqueue_thread, &cleanup_task); + put_file_offset(priv_user, arg->count, arg->index); + + return (0); +} + +/*-------------------- Grant Mapping Methods --------------------------------*/ + +struct gntdev_gmap_map { + vm_object_t mem; + struct resource *pseudo_phys_res; + int pseudo_phys_res_id; + vm_paddr_t phys_base_addr; +}; + +struct gntdev_gmap { + union gmap_next_union { + STAILQ_ENTRY(gntdev_gmap) list; + RB_ENTRY(gntdev_gmap) tree; + } gmap_next; + uint64_t file_index; + uint32_t count; + struct gnttab_map_grant_ref *grant_map_ops; + struct gntdev_gmap_map *map; + struct notify_data *notify; +}; + +static int +gmap_cmp(struct gntdev_gmap *g1, struct gntdev_gmap *g2) +{ + return (g1->file_index - g2->file_index); +} + +RB_GENERATE_STATIC(gmap_tree_head, gntdev_gmap, gmap_next.tree, gmap_cmp); + +/* + * Traverse over the device-list of to-be-deleted grant mappings, and if + * the region is no longer mmapped by anyone, free the memory used to + * store information about the mapping. + */ +static void +gmap_list_dtor(struct cleanup_data_struct *cleanup_data) +{ + struct gmap_list_head tmp_gmaps; + struct gntdev_gmap *gmap, *gmap_tmp, *gmap_previous; + + STAILQ_INIT(&tmp_gmaps); + mtx_lock(&cleanup_data->to_kill_gmaps_mtx); + STAILQ_SWAP(&cleanup_data->to_kill_gmaps, &tmp_gmaps, gntdev_gmap); + mtx_unlock(&cleanup_data->to_kill_gmaps_mtx); + + gmap_previous = NULL; + STAILQ_FOREACH_SAFE(gmap, &tmp_gmaps, gmap_next.list, gmap_tmp) { + if (gmap->map == NULL) { + if (gmap_previous == NULL) + STAILQ_REMOVE_HEAD(&tmp_gmaps, gmap_next.list); + else + STAILQ_REMOVE_AFTER(&tmp_gmaps, gmap_previous, + gmap_next.list); + + if (gmap->notify) + free(gmap->notify, M_GNTDEV); + free(gmap->grant_map_ops, M_GNTDEV); + free(gmap, M_GNTDEV); + } + else + gmap_previous = gmap; + } + + if (!STAILQ_EMPTY(&tmp_gmaps)) { + mtx_lock(&cleanup_data->to_kill_gmaps_mtx); + STAILQ_CONCAT(&cleanup_data->to_kill_gmaps, &tmp_gmaps); + mtx_unlock(&cleanup_data->to_kill_gmaps_mtx); + } +} + +/* + * Find mapped grants for a given userspace program, by file-offset (index) + * and count, as supplied during the map-ioctl. + */ +static struct gntdev_gmap* +gntdev_find_gmap(struct per_user_data *priv_user, + uint64_t index, uint32_t count) +{ + struct gntdev_gmap find_gmap, *gmap; + + find_gmap.file_index = index; + + mtx_lock(&priv_user->user_data_lock); + gmap = RB_FIND(gmap_tree_head, &priv_user->gmap_tree, &find_gmap); + mtx_unlock(&priv_user->user_data_lock); + + if (gmap != NULL && gmap->count == count) + return (gmap); + return (NULL); +} + +/* + * Remove the pages from the mgtdevice pager, call the unmap hypercall, + * free the xenmem resource. This function is called during the + * destruction of the mgtdevice pager, which happens when all mmaps to + * it have been removed, and the unmap-ioctl has been performed. + */ +static int +notify_unmap_cleanup(struct gntdev_gmap *gmap) +{ + uint32_t i; + int error, count; + vm_page_t m; + struct gnttab_unmap_grant_ref *unmap_ops; + + unmap_ops = malloc(sizeof(struct gnttab_unmap_grant_ref) * gmap->count, + M_GNTDEV, M_WAITOK); + + /* Enumerate freeable maps. */ + count = 0; + for (i = 0; i < gmap->count; i++) { + if (gmap->grant_map_ops[i].handle != -1) { + unmap_ops[count].handle = gmap->grant_map_ops[i].handle; + unmap_ops[count].host_addr = + gmap->grant_map_ops[i].host_addr; + unmap_ops[count].dev_bus_addr = 0; + count++; + } + } + + /* Perform notification. */ + if (count > 0 && gmap->notify) { + vm_page_t page; + uint64_t page_offset; + + page_offset = gmap->notify->index - gmap->file_index; + page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + page_offset); + notify(gmap->notify, page); + } + + /* Free the pages. */ + VM_OBJECT_WLOCK(gmap->map->mem); +retry: + for (i = 0; i < gmap->count; i++) { + m = vm_page_lookup(gmap->map->mem, i); + if (m == NULL) + continue; + if (vm_page_sleep_if_busy(m, "pcmdum")) + goto retry; + cdev_pager_free_page(gmap->map->mem, m); + } + VM_OBJECT_WUNLOCK(gmap->map->mem); + + /* Perform unmap hypercall. */ + error = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, + unmap_ops, count); + + for (i = 0; i < gmap->count; i++) { + gmap->grant_map_ops[i].handle = -1; + gmap->grant_map_ops[i].host_addr = 0; + } + + if (gmap->map) { + error = xenmem_free(gntdev_dev, gmap->map->pseudo_phys_res_id, + gmap->map->pseudo_phys_res); + KASSERT(error == 0, + ("Unable to release memory resource: %d", error)); + + free(gmap->map, M_GNTDEV); + gmap->map = NULL; + } + + free(unmap_ops, M_GNTDEV); + + return (error); +} + +/* + * IOCTL_GNTDEV_MAP_GRANT_REF + * Populate structures for mapping the grant reference in the per user + * private data. Actual resource allocation and map hypercall is performed + * during the mmap. + */ +static int +gntdev_map_grant_ref(struct ioctl_gntdev_map_grant_ref *arg) +{ + uint32_t i; + int error; + struct gntdev_gmap *gmap; + struct per_user_data *priv_user; + + error = devfs_get_cdevpriv((void**) &priv_user); + if (error != 0) + return (EINVAL); + + gmap = malloc(sizeof(*gmap), M_GNTDEV, M_WAITOK | M_ZERO); + gmap->count = arg->count; + gmap->grant_map_ops = + malloc(sizeof(struct gnttab_map_grant_ref) * arg->count, + M_GNTDEV, M_WAITOK | M_ZERO); + + error = get_file_offset(priv_user, arg->count, &gmap->file_index); + if (error != 0) + return (error); + + for (i = 0; i < arg->count; i++) { + gmap->grant_map_ops[i].dom = arg->refs[i].domid; + gmap->grant_map_ops[i].ref = arg->refs[i].ref; + gmap->grant_map_ops[i].handle = -1; + gmap->grant_map_ops[i].flags = GNTMAP_host_map; + } + + mtx_lock(&priv_user->user_data_lock); + RB_INSERT(gmap_tree_head, &priv_user->gmap_tree, gmap); + mtx_unlock(&priv_user->user_data_lock); + + arg->index = gmap->file_index; + + return (error); +} + +/* + * IOCTL_GNTDEV_UNMAP_GRANT_REF + * Remove the map information from the per user private data and add it + * to the global device-list of mappings to be deleted. A reference to + * the mgtdevice pager is also decreased, the reason for which is + * explained in mmap_gmap(). + */ +static int +gntdev_unmap_grant_ref(struct ioctl_gntdev_unmap_grant_ref *arg) +{ + int error; + struct gntdev_gmap *gmap; + struct per_user_data *priv_user; + + error = devfs_get_cdevpriv((void**) &priv_user); + if (error != 0) + return (EINVAL); + + gmap = gntdev_find_gmap(priv_user, arg->index, arg->count); + if (gmap == NULL) { + log(LOG_ERR, "Can't find requested grant-map."); + return (EINVAL); + } + + mtx_lock(&priv_user->user_data_lock); + mtx_lock(&cleanup_data.to_kill_gmaps_mtx); + RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); + STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, gmap_next.list); + mtx_unlock(&cleanup_data.to_kill_gmaps_mtx); + mtx_unlock(&priv_user->user_data_lock); + + if (gmap->map) + vm_object_deallocate(gmap->map->mem); + + taskqueue_enqueue(taskqueue_thread, &cleanup_task); + put_file_offset(priv_user, arg->count, arg->index); + + return (0); +} + +/* + * IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR + * Get file-offset and count for a given mapping, from the virtual address + * where the mapping is mmapped. + * Please note, this only works for grants mapped by this domain, and not + * grants allocated. Count doesn't make much sense in reference to grants + * allocated. Also, because this function is present in the linux gntdev + * device, but not in the linux gntalloc one, most userspace code only use + * it for mapped grants. + */ +static int +gntdev_get_offset_for_vaddr(struct ioctl_gntdev_get_offset_for_vaddr *arg, + struct thread *td) +{ + int error; + vm_map_t map; + vm_map_entry_t entry; + vm_object_t mem; + vm_pindex_t pindex; + vm_prot_t prot; + boolean_t wired; + struct gntdev_gmap *gmap; + + map = &td->td_proc->p_vmspace->vm_map; + error = vm_map_lookup(&map, arg->vaddr, VM_PROT_NONE, &entry, + &mem, &pindex, &prot, &wired); + if (error != KERN_SUCCESS) + return (EINVAL); + vm_map_lookup_done(map, entry); + + if ((mem->type != OBJT_MGTDEVICE) || + (mem->un_pager.devp.ops != &gntdev_gmap_pg_ops)) + return (EINVAL); + + gmap = mem->handle; + if (gmap == NULL || + (entry->end - entry->start) != (gmap->count * PAGE_SIZE)) + return (EINVAL); + + arg->count = gmap->count; + arg->offset = gmap->file_index; + return (0); +} + +/*-------------------- Grant Mapping Pager ----------------------------------*/ + +static int +gntdev_gmap_pg_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot, + vm_ooffset_t foff, struct ucred *cred, u_short *color) +{ + + return (0); +} + +static void +gntdev_gmap_pg_dtor(void *handle) +{ + + notify_unmap_cleanup((struct gntdev_gmap *)handle); +} + +static int +gntdev_gmap_pg_fault(vm_object_t object, vm_ooffset_t offset, int prot, + vm_page_t *mres) +{ + struct gntdev_gmap *gmap = object->handle; + vm_pindex_t pidx, ridx; + vm_page_t page, oldm; + vm_ooffset_t relative_offset; + + if (gmap->map == NULL) + return (VM_PAGER_FAIL); + + relative_offset = offset - gmap->file_index; + + pidx = OFF_TO_IDX(offset); + ridx = OFF_TO_IDX(relative_offset); + if (ridx >= gmap->count || + gmap->grant_map_ops[ridx].status != GNTST_okay) + return (VM_PAGER_FAIL); + + page = PHYS_TO_VM_PAGE(gmap->map->phys_base_addr + relative_offset); + if (page == NULL) + return (VM_PAGER_FAIL); + + KASSERT((page->flags & PG_FICTITIOUS) != 0, + ("not fictitious %p", page)); + KASSERT(page->wire_count == 1, ("wire_count not 1 %p", page)); + KASSERT(vm_page_busied(page) == 0, ("page %p is busy", page)); + + if (*mres != NULL) { + oldm = *mres; + vm_page_lock(oldm); + vm_page_free(oldm); + vm_page_unlock(oldm); + *mres = NULL; + } + + vm_page_insert(page, object, pidx); + page->valid = VM_PAGE_BITS_ALL; + vm_page_xbusy(page); + *mres = page; + return (VM_PAGER_OK); +} + +/*------------------ Grant Table Methods ------------------------------------*/ + +static void +notify(struct notify_data *notify, vm_page_t page) +{ + if (notify->action & UNMAP_NOTIFY_CLEAR_BYTE) { + uint8_t *mem; + uint64_t offset; + + offset = notify->index & PAGE_MASK; + mem = (uint8_t *)pmap_quick_enter_page(page); + mem[offset] = 0; + pmap_quick_remove_page((vm_offset_t)mem); + } + if (notify->action & UNMAP_NOTIFY_SEND_EVENT) { + xen_intr_signal(notify->notify_evtchn_handle); + xen_intr_unbind(¬ify->notify_evtchn_handle); + } + notify->action = 0; +} + +/* + * Helper to copy new arguments from the notify ioctl into + * the existing notify data. + */ +static int +copy_notify_helper(struct notify_data *destination, + struct ioctl_gntdev_unmap_notify *source) +{ + xen_intr_handle_t handlep = NULL; + + /* + * "Get" before "Put"ting previous reference, as we might be + * holding the last reference to the event channel port. + */ + if (source->action & UNMAP_NOTIFY_SEND_EVENT) + if (xen_intr_get_evtchn_from_port(source->event_channel_port, + &handlep) != 0) + return (EINVAL); + + if (destination->action & UNMAP_NOTIFY_SEND_EVENT) + xen_intr_unbind(&destination->notify_evtchn_handle); + + destination->action = source->action; + destination->event_channel_port = source->event_channel_port; + destination->index = source->index; + destination->notify_evtchn_handle = handlep; + + return (0); +} + +/* + * IOCTL_GNTDEV_SET_UNMAP_NOTIFY + * Set unmap notification inside the appropriate grant. It sends a + * notification when the grant is completely munmapped by this domain + * and ready for destruction. + */ +static int +gntdev_set_unmap_notify(struct ioctl_gntdev_unmap_notify *arg) +{ + int error; + uint64_t index; + struct per_user_data *priv_user; + struct gntdev_gref *gref = NULL; + struct gntdev_gmap *gmap; + + error = devfs_get_cdevpriv((void**) &priv_user); + if (error != 0) + return (EINVAL); + + if (arg->action & ~(UNMAP_NOTIFY_CLEAR_BYTE|UNMAP_NOTIFY_SEND_EVENT)) + return (EINVAL); + + index = arg->index & ~PAGE_MASK; + gref = gntdev_find_grefs(priv_user, index, 1); + if (gref) { + if (gref->notify == NULL) + gref->notify = malloc(sizeof(*arg), M_GNTDEV, + M_WAITOK | M_ZERO); + return (copy_notify_helper(gref->notify, arg)); + } + + error = EINVAL; + mtx_lock(&priv_user->user_data_lock); + RB_FOREACH(gmap, gmap_tree_head, &priv_user->gmap_tree) { + if (arg->index >= gmap->file_index && + arg->index < gmap->file_index + gmap->count * PAGE_SIZE) { + if (gmap->notify == NULL) + gmap->notify = malloc(sizeof(*arg), M_GNTDEV, + M_WAITOK | M_ZERO); + error = copy_notify_helper(gmap->notify, arg); + break; + } + } + mtx_unlock(&priv_user->user_data_lock); + + return (error); +} + +/*------------------ Gntdev Char Device Methods -----------------------------*/ + +static void +cleanup_function(void *arg, __unused int pending) +{ + + gref_list_dtor((struct cleanup_data_struct *) arg); + gmap_list_dtor((struct cleanup_data_struct *) arg); +} + +static void +per_user_data_dtor(void *arg) +{ + struct gntdev_gref *gref, *gref_tmp; + struct gntdev_gmap *gmap, *gmap_tmp; + struct file_offset_struct *offset, *offset_tmp; + struct per_user_data *priv_user; + + priv_user = (struct per_user_data *) arg; + + mtx_lock(&priv_user->user_data_lock); + + mtx_lock(&cleanup_data.to_kill_grefs_mtx); + RB_FOREACH_SAFE(gref, gref_tree_head, &priv_user->gref_tree, gref_tmp) { + RB_REMOVE(gref_tree_head, &priv_user->gref_tree, gref); + STAILQ_INSERT_TAIL(&cleanup_data.to_kill_grefs, gref, + gref_next.list); + } + mtx_unlock(&cleanup_data.to_kill_grefs_mtx); + + mtx_lock(&cleanup_data.to_kill_gmaps_mtx); + RB_FOREACH_SAFE(gmap, gmap_tree_head, &priv_user->gmap_tree, gmap_tmp) { + RB_REMOVE(gmap_tree_head, &priv_user->gmap_tree, gmap); + STAILQ_INSERT_TAIL(&cleanup_data.to_kill_gmaps, gmap, + gmap_next.list); + if (gmap->map) + vm_object_deallocate(gmap->map->mem); + } + mtx_unlock(&cleanup_data.to_kill_gmaps_mtx); + + RB_FOREACH_SAFE(offset, file_offset_head, &priv_user->file_offset, + offset_tmp) { + RB_REMOVE(file_offset_head, &priv_user->file_offset, offset); + free(offset, M_GNTDEV); + } + + mtx_unlock(&priv_user->user_data_lock); + + taskqueue_enqueue(taskqueue_thread, &cleanup_task); + + mtx_destroy(&priv_user->user_data_lock); + free(priv_user, M_GNTDEV); +} + +static int +gntdev_open(struct cdev *dev, int flag, int otyp, struct thread *td) +{ + int error; + struct per_user_data *priv_user; + struct file_offset_struct *offset; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Mon Oct 31 15:11:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 313ADC285F5; Mon, 31 Oct 2016 15:11:57 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ECA1B115E; Mon, 31 Oct 2016 15:11:56 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VFBun2044742; Mon, 31 Oct 2016 15:11:56 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VFBu0C044741; Mon, 31 Oct 2016 15:11:56 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610311511.u9VFBu0C044741@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 31 Oct 2016 15:11:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308129 - head/lib/libstand X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 15:11:57 -0000 Author: bapt Date: Mon Oct 31 15:11:55 2016 New Revision: 308129 URL: https://svnweb.freebsd.org/changeset/base/308129 Log: When issuing a PXE dhcp request, always issue a param request (DHCP option 55) with all dhcp parameters we might be interested in. Some DHCP server like the new kea (by ISC) expect it. This makes pxeboot functional with ISC kea. Submitted by: Vincent Legout MFC after: 1 month Sponsored by: Gandi.net Modified: head/lib/libstand/bootp.c Modified: head/lib/libstand/bootp.c ============================================================================== --- head/lib/libstand/bootp.c Mon Oct 31 13:12:58 2016 (r308128) +++ head/lib/libstand/bootp.c Mon Oct 31 15:11:55 2016 (r308129) @@ -148,7 +148,17 @@ bootp(sock, flag) bp->bp_vend[7] = TAG_CLASSID; bp->bp_vend[8] = 9; bcopy("PXEClient", &bp->bp_vend[9], 9); - bp->bp_vend[18] = TAG_END; + bp->bp_vend[18] = TAG_PARAM_REQ; + bp->bp_vend[19] = 8; + bp->bp_vend[20] = TAG_ROOTPATH; + bp->bp_vend[21] = TAG_TFTP_SERVER; + bp->bp_vend[22] = TAG_HOSTNAME; + bp->bp_vend[23] = TAG_SWAPSERVER; + bp->bp_vend[24] = TAG_GATEWAY; + bp->bp_vend[25] = TAG_SUBNET_MASK; + bp->bp_vend[26] = TAG_INTF_MTU; + bp->bp_vend[27] = TAG_SERVERID; + bp->bp_vend[28] = TAG_END; } else bp->bp_vend[7] = TAG_END; #else From owner-svn-src-head@freebsd.org Mon Oct 31 15:34:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B40ACC28B02; Mon, 31 Oct 2016 15:34:02 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5596E1DB1; Mon, 31 Oct 2016 15:34:02 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VFY181053196; Mon, 31 Oct 2016 15:34:01 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VFXw2x053156; Mon, 31 Oct 2016 15:33:58 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610311533.u9VFXw2x053156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 31 Oct 2016 15:33:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308130 - in head: . gnu/lib/libgcc gnu/usr.bin/binutils gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/libbfd gnu/usr.bin/cc gnu/usr.bin/gdb gnu/usr.bin/gdb/libgdb lib/libc lib/libc/mips... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 15:34:02 -0000 Author: br Date: Mon Oct 31 15:33:58 2016 New Revision: 308130 URL: https://svnweb.freebsd.org/changeset/base/308130 Log: Add full softfloat and hardfloat support for MIPS. This adds new target architectures for hardfloat: mipselhf mipshf mips64elhf mips64hf. Tested in QEMU only. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8376 Modified: head/Makefile head/Makefile.inc1 head/gnu/lib/libgcc/Makefile head/gnu/usr.bin/binutils/Makefile.inc0 head/gnu/usr.bin/binutils/ld/Makefile.mips head/gnu/usr.bin/binutils/libbfd/Makefile.mips head/gnu/usr.bin/cc/Makefile.inc head/gnu/usr.bin/cc/Makefile.tgt head/gnu/usr.bin/gdb/Makefile.inc head/gnu/usr.bin/gdb/libgdb/Makefile head/lib/libc/Makefile head/lib/libc/mips/Makefile.inc head/lib/libc/mips/Symbol.map head/lib/libc/mips/gen/Makefile.inc head/lib/libc/mips/gen/flt_rounds.c head/lib/msun/mips/Makefile.inc head/lib/msun/mips/Symbol.map head/lib/msun/mips/fenv.c head/lib/msun/mips/fenv.h head/share/man/man7/arch.7 head/share/mk/bsd.cpu.mk head/share/mk/bsd.endian.mk head/share/mk/sys.mk head/sys/boot/Makefile.ficl head/sys/boot/common/Makefile.inc head/sys/boot/mips/uboot/Makefile head/sys/conf/kern.mk head/sys/mips/include/float.h head/sys/mips/mips/exception.S head/sys/mips/mips/locore.S head/sys/mips/mips/swtch.S head/sys/mips/mips/trap.c Modified: head/Makefile ============================================================================== --- head/Makefile Mon Oct 31 15:11:55 2016 (r308129) +++ head/Makefile Mon Oct 31 15:33:58 2016 (r308130) @@ -239,7 +239,7 @@ _MAKE+= MK_META_MODE=no _TARGET_ARCH= ${TARGET:S/pc98/i386/:S/arm64/aarch64/} .elif !defined(TARGET) && defined(TARGET_ARCH) && \ ${TARGET_ARCH} != ${MACHINE_ARCH} -_TARGET= ${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/powerpcspe/powerpc/:C/riscv64/riscv/} +_TARGET= ${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/powerpcspe/powerpc/:C/riscv64/riscv/} .endif .if defined(TARGET) && !defined(_TARGET) _TARGET=${TARGET} @@ -421,7 +421,7 @@ TARGETS?=amd64 arm arm64 i386 mips pc98 _UNIVERSE_TARGETS= ${TARGETS} TARGET_ARCHES_arm?= arm armeb armv6 TARGET_ARCHES_arm64?= aarch64 -TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 +TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe TARGET_ARCHES_pc98?= i386 .for target in ${TARGETS} Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Mon Oct 31 15:11:55 2016 (r308129) +++ head/Makefile.inc1 Mon Oct 31 15:33:58 2016 (r308130) @@ -356,6 +356,10 @@ KNOWN_ARCHES?= aarch64/arm64 \ mipsn32el/mips \ mips64/mips \ mipsn32/mips \ + mipshf/mips \ + mipselhf/mips \ + mips64elhf/mips \ + mips64hf/mips \ powerpc \ powerpc64/powerpc \ powerpcspe/powerpc \ Modified: head/gnu/lib/libgcc/Makefile ============================================================================== --- head/gnu/lib/libgcc/Makefile Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/lib/libgcc/Makefile Mon Oct 31 15:33:58 2016 (r308130) @@ -165,7 +165,7 @@ LIBADD+= compiler_rt .if ${TARGET_CPUARCH} == mips LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c # ABIs other than o32 need this -.if ${TARGET_ARCH} != "mips" && ${TARGET_ARCH} != "mipsel" +.if ${TARGET_ARCH:Mmips64*} != "" || ${TARGET_ARCH:Mmipsn32*} != "" LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c Modified: head/gnu/usr.bin/binutils/Makefile.inc0 ============================================================================== --- head/gnu/usr.bin/binutils/Makefile.inc0 Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/binutils/Makefile.inc0 Mon Oct 31 15:33:58 2016 (r308130) @@ -7,7 +7,7 @@ VERSION= "2.17.50 [FreeBSD] 2007-07-03" .if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} +TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} .else TARGET_CPUARCH=${MACHINE_CPUARCH} .endif @@ -17,7 +17,7 @@ TARGET_OS?= freebsd BINUTILS_ARCH=${TARGET_ARCH:C/amd64/x86_64/} TARGET_TUPLE?= ${BINUTILS_ARCH}-${TARGET_VENDOR}-${TARGET_OS} .if ${TARGET_ARCH} == "armeb" || ${TARGET_ARCH} == "armv6eb" || \ - (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el} == "") + (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") TARGET_BIG_ENDIAN=t .endif Modified: head/gnu/usr.bin/binutils/ld/Makefile.mips ============================================================================== --- head/gnu/usr.bin/binutils/ld/Makefile.mips Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/binutils/ld/Makefile.mips Mon Oct 31 15:33:58 2016 (r308130) @@ -1,6 +1,6 @@ # $FreeBSD$ -.if ${TARGET_ARCH:Mmips*el} != "" +.if ${TARGET_ARCH:Mmips*el*} != "" _EMULATION_ENDIAN=l .else _EMULATION_ENDIAN=b Modified: head/gnu/usr.bin/binutils/libbfd/Makefile.mips ============================================================================== --- head/gnu/usr.bin/binutils/libbfd/Makefile.mips Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/binutils/libbfd/Makefile.mips Mon Oct 31 15:33:58 2016 (r308130) @@ -1,6 +1,6 @@ # $FreeBSD$ -.if ${TARGET_ARCH:Mmips*el} != "" +.if ${TARGET_ARCH:Mmips*el*} != "" _EMULATION_ENDIAN=little .else _EMULATION_ENDIAN=big Modified: head/gnu/usr.bin/cc/Makefile.inc ============================================================================== --- head/gnu/usr.bin/cc/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/cc/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -39,7 +39,7 @@ CFLAGS += -DFREEBSD_ARCH_armv6 .endif .if ${TARGET_CPUARCH} == "mips" -.if ${TARGET_ARCH:Mmips*el} != "" +.if ${TARGET_ARCH:Mmips*el*} != "" CFLAGS += -DTARGET_ENDIAN_DEFAULT=0 .endif Modified: head/gnu/usr.bin/cc/Makefile.tgt ============================================================================== --- head/gnu/usr.bin/cc/Makefile.tgt Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/cc/Makefile.tgt Mon Oct 31 15:33:58 2016 (r308130) @@ -4,7 +4,7 @@ # MACHINE_CPUARCH, but there's no easy way to export make functions... .if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} +TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} .else TARGET_CPUARCH=${MACHINE_CPUARCH} .endif @@ -15,7 +15,7 @@ GCC_CPU=${TARGET_CPUARCH:C/amd64/i386/:C TARGET_CPU_DEFAULT= TARGET_CPU_ultrasparc .endif .if ${TARGET_ARCH} == "armeb" || ${TARGET_ARCH} == "armv6eb" || \ - (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el} == "") + (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") TARGET_BIG_ENDIAN=t .endif .if ${TARGET_ARCH} == "powerpc64" Modified: head/gnu/usr.bin/gdb/Makefile.inc ============================================================================== --- head/gnu/usr.bin/gdb/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/gdb/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -23,7 +23,7 @@ OBJ_RL= ${OBJ_ROOT}/../lib/libreadline/r # MACHINE_CPUARCH, but there's no easy way to export make functions... .if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} +TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} .else TARGET_CPUARCH=${MACHINE_CPUARCH} .endif Modified: head/gnu/usr.bin/gdb/libgdb/Makefile ============================================================================== --- head/gnu/usr.bin/gdb/libgdb/Makefile Mon Oct 31 15:11:55 2016 (r308129) +++ head/gnu/usr.bin/gdb/libgdb/Makefile Mon Oct 31 15:33:58 2016 (r308130) @@ -4,7 +4,7 @@ # MACHINE_CPUARCH, but there's no easy way to export make functions... .if defined(TARGET_ARCH) -TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} +TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} .else TARGET_CPUARCH=${MACHINE_CPUARCH} .endif Modified: head/lib/libc/Makefile ============================================================================== --- head/lib/libc/Makefile Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/libc/Makefile Mon Oct 31 15:33:58 2016 (r308130) @@ -111,7 +111,7 @@ NOASM= .include "${LIBC_SRCTOP}/xdr/Makefile.inc" .if (${LIBC_ARCH} == "arm" && \ (${MACHINE_ARCH:Marmv6*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \ - ${LIBC_ARCH} == "mips" + (${LIBC_ARCH} == "mips" && ${MACHINE_ARCH:Mmips*hf} == "") .include "${LIBC_SRCTOP}/softfloat/Makefile.inc" .endif .if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64" Modified: head/lib/libc/mips/Makefile.inc ============================================================================== --- head/lib/libc/mips/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/libc/mips/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -1,7 +1,9 @@ # $NetBSD: Makefile.inc,v 1.7 2005/09/17 11:49:39 tsutsui Exp $ # $FreeBSD$ +.if ${MACHINE_ARCH:Mmips*hf} == "" CFLAGS+=-DSOFTFLOAT +.endif MDSRCS+= machdep_ldisd.c SYM_MAPS+= ${LIBC_SRCTOP}/mips/Symbol.map Modified: head/lib/libc/mips/Symbol.map ============================================================================== --- head/lib/libc/mips/Symbol.map Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/libc/mips/Symbol.map Mon Oct 31 15:33:58 2016 (r308130) @@ -31,6 +31,10 @@ FBSD_1.0 { sbrk; }; +FBSD_1.3 { + __flt_rounds; +}; + FBSDprivate_1.0 { /* PSEUDO syscalls */ __sys_getlogin; Modified: head/lib/libc/mips/gen/Makefile.inc ============================================================================== --- head/lib/libc/mips/gen/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/libc/mips/gen/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -1,7 +1,7 @@ # $NetBSD: Makefile.inc,v 1.27 2005/10/07 17:16:40 tsutsui Exp $ # $FreeBSD$ -SRCS+= infinity.c fabs.c ldexp.c +SRCS+= infinity.c fabs.c ldexp.c flt_rounds.c # SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ # fpsetround.c fpsetsticky.c Modified: head/lib/libc/mips/gen/flt_rounds.c ============================================================================== --- head/lib/libc/mips/gen/flt_rounds.c Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/libc/mips/gen/flt_rounds.c Mon Oct 31 15:33:58 2016 (r308130) @@ -11,7 +11,14 @@ __FBSDID("$FreeBSD$"); __RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $"); #endif /* LIBC_SCCS and not lint */ -#include +#include +#include + +#ifdef SOFTFLOAT +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" +#endif static const int map[] = { 1, /* round to nearest */ @@ -23,8 +30,13 @@ static const int map[] = { int __flt_rounds() { - int x; + int mode; + +#ifdef SOFTFLOAT + mode = __softfloat_float_rounding_mode; +#else + __asm __volatile("cfc1 %0,$31" : "=r" (mode)); +#endif - __asm("cfc1 %0,$31" : "=r" (x)); - return map[x & 0x03]; + return map[mode & 0x03]; } Modified: head/lib/msun/mips/Makefile.inc ============================================================================== --- head/lib/msun/mips/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/msun/mips/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -1,4 +1,8 @@ # $FreeBSD$ +.if ${MACHINE_ARCH:Mmips*hf} == "" +CFLAGS+=-DSOFTFLOAT +.endif + LDBL_PREC = 53 SYM_MAPS += ${.CURDIR}/mips/Symbol.map Modified: head/lib/msun/mips/Symbol.map ============================================================================== --- head/lib/msun/mips/Symbol.map Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/msun/mips/Symbol.map Mon Oct 31 15:33:58 2016 (r308130) @@ -5,9 +5,17 @@ FBSD_1.0 { }; FBSD_1.3 { + feclearexcept; + fegetexceptflag; fesetexceptflag; feraiseexcept; + fetestexcept; + fegetround; + fesetround; fegetenv; feholdexcept; feupdateenv; + feenableexcept; + fedisableexcept; + fegetexcept; }; Modified: head/lib/msun/mips/fenv.c ============================================================================== --- head/lib/msun/mips/fenv.c Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/msun/mips/fenv.c Mon Oct 31 15:33:58 2016 (r308130) @@ -39,6 +39,17 @@ */ const fenv_t __fe_dfl_env = 0; +#ifdef SOFTFLOAT +#define __set_env(env, flags, mask, rnd) env = ((flags) \ + | (mask)<<_FPUSW_SHIFT \ + | (rnd) << 24) +#define __env_flags(env) ((env) & FE_ALL_EXCEPT) +#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \ + & FE_ALL_EXCEPT) +#define __env_round(env) (((env) >> 24) & _ROUND_MASK) +#include "fenv-softfloat.h" +#endif + extern inline int feclearexcept(int __excepts); extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts); extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts); @@ -50,3 +61,6 @@ extern inline int fegetenv(fenv_t *__env extern inline int feholdexcept(fenv_t *__envp); extern inline int fesetenv(const fenv_t *__envp); extern inline int feupdateenv(const fenv_t *__envp); +extern inline int feenableexcept(int __mask); +extern inline int fedisableexcept(int __mask); +extern inline int fegetexcept(void); Modified: head/lib/msun/mips/fenv.h ============================================================================== --- head/lib/msun/mips/fenv.h Mon Oct 31 15:11:55 2016 (r308129) +++ head/lib/msun/mips/fenv.h Mon Oct 31 15:33:58 2016 (r308130) @@ -39,11 +39,21 @@ typedef __uint32_t fenv_t; typedef __uint32_t fexcept_t; /* Exception flags */ +#ifdef SOFTFLOAT +#define _FPUSW_SHIFT 16 #define FE_INVALID 0x0001 #define FE_DIVBYZERO 0x0002 #define FE_OVERFLOW 0x0004 #define FE_UNDERFLOW 0x0008 #define FE_INEXACT 0x0010 +#else +#define _FCSR_CAUSE_SHIFT 10 +#define FE_INVALID 0x0040 +#define FE_DIVBYZERO 0x0020 +#define FE_OVERFLOW 0x0010 +#define FE_UNDERFLOW 0x0008 +#define FE_INEXACT 0x0004 +#endif #define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) @@ -61,104 +71,135 @@ extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) /* We need to be able to map status flag positions to mask flag positions */ -#define _FPUSW_SHIFT 16 -#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) +#define _ENABLE_SHIFT 5 +#define _ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT) -#ifdef ARM_HARD_FLOAT -#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr))) -#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr)) -#else -#define __rfs(__fpsr) -#define __wfs(__fpsr) +#ifndef SOFTFLOAT +#define __cfc1(__fcsr) __asm __volatile("cfc1 %0, $31" : "=r" (__fcsr)) +#define __ctc1(__fcsr) __asm __volatile("ctc1 %0, $31" :: "r" (__fcsr)) #endif +#ifdef SOFTFLOAT +int feclearexcept(int __excepts); +int fegetexceptflag(fexcept_t *__flagp, int __excepts); +int fesetexceptflag(const fexcept_t *__flagp, int __excepts); +int feraiseexcept(int __excepts); +int fetestexcept(int __excepts); +int fegetround(void); +int fesetround(int __round); +int fegetenv(fenv_t *__envp); +int feholdexcept(fenv_t *__envp); +int fesetenv(const fenv_t *__envp); +int feupdateenv(const fenv_t *__envp); +#else __fenv_static inline int feclearexcept(int __excepts) { - fexcept_t __fpsr; + fexcept_t fcsr; + + __excepts &= FE_ALL_EXCEPT; + __cfc1(fcsr); + fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT)); + __ctc1(fcsr); - __rfs(&__fpsr); - __fpsr &= ~__excepts; - __wfs(__fpsr); return (0); } __fenv_static inline int fegetexceptflag(fexcept_t *__flagp, int __excepts) { - fexcept_t __fpsr; + fexcept_t fcsr; + + __excepts &= FE_ALL_EXCEPT; + __cfc1(fcsr); + *__flagp = fcsr & __excepts; - __rfs(&__fpsr); - *__flagp = __fpsr & __excepts; return (0); } __fenv_static inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts) { - fexcept_t __fpsr; + fexcept_t fcsr; + + __excepts &= FE_ALL_EXCEPT; + __cfc1(fcsr); + fcsr &= ~__excepts; + fcsr |= *__flagp & __excepts; + __ctc1(fcsr); - __rfs(&__fpsr); - __fpsr &= ~__excepts; - __fpsr |= *__flagp & __excepts; - __wfs(__fpsr); return (0); } __fenv_static inline int feraiseexcept(int __excepts) { - fexcept_t __ex = __excepts; + fexcept_t fcsr; + + __excepts &= FE_ALL_EXCEPT; + __cfc1(fcsr); + fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT); + __ctc1(fcsr); - fesetexceptflag(&__ex, __excepts); /* XXX */ return (0); } __fenv_static inline int fetestexcept(int __excepts) { - fexcept_t __fpsr; + fexcept_t fcsr; - __rfs(&__fpsr); - return (__fpsr & __excepts); + __excepts &= FE_ALL_EXCEPT; + __cfc1(fcsr); + + return (fcsr & __excepts); } __fenv_static inline int fegetround(void) { + fexcept_t fcsr; + + __cfc1(fcsr); - /* - * Apparently, the rounding mode is specified as part of the - * instruction format on ARM, so the dynamic rounding mode is - * indeterminate. Some FPUs may differ. - */ - return (-1); + return (fcsr & _ROUND_MASK); } __fenv_static inline int fesetround(int __round) { + fexcept_t fcsr; + + if (__round & ~_ROUND_MASK) + return (-1); - return (-1); + __cfc1(fcsr); + fcsr &= ~_ROUND_MASK; + fcsr |= __round; + __ctc1(fcsr); + + return (0); } __fenv_static inline int fegetenv(fenv_t *__envp) { - __rfs(__envp); + __cfc1(*__envp); + return (0); } __fenv_static inline int feholdexcept(fenv_t *__envp) { - fenv_t __env; + fexcept_t fcsr; + + __cfc1(fcsr); + *__envp = fcsr; + fcsr &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); + __ctc1(fcsr); - __rfs(&__env); - *__envp = __env; - __env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); - __wfs(__env); return (0); } @@ -166,56 +207,69 @@ __fenv_static inline int fesetenv(const fenv_t *__envp) { - __wfs(*__envp); + __ctc1(*__envp); + return (0); } __fenv_static inline int feupdateenv(const fenv_t *__envp) { - fexcept_t __fpsr; + fexcept_t fcsr; + + __cfc1(fcsr); + fesetenv(__envp); + feraiseexcept(fcsr); - __rfs(&__fpsr); - __wfs(*__envp); - feraiseexcept(__fpsr & FE_ALL_EXCEPT); return (0); } +#endif /* !SOFTFLOAT */ #if __BSD_VISIBLE /* We currently provide no external definitions of the functions below. */ +#ifdef SOFTFLOAT +int feenableexcept(int __mask); +int fedisableexcept(int __mask); +int fegetexcept(void); +#else static inline int feenableexcept(int __mask) { - fenv_t __old_fpsr, __new_fpsr; + fenv_t __old_fcsr, __new_fcsr; + + __cfc1(__old_fcsr); + __new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT; + __ctc1(__new_fcsr); - __rfs(&__old_fpsr); - __new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT; - __wfs(__new_fpsr); - return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT); + return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT); } static inline int fedisableexcept(int __mask) { - fenv_t __old_fpsr, __new_fpsr; + fenv_t __old_fcsr, __new_fcsr; + + __cfc1(__old_fcsr); + __new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT); + __ctc1(__new_fcsr); - __rfs(&__old_fpsr); - __new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT); - __wfs(__new_fpsr); - return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT); + return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT); } static inline int fegetexcept(void) { - fenv_t __fpsr; + fexcept_t fcsr; - __rfs(&__fpsr); - return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT); + __cfc1(fcsr); + + return ((fcsr & _ENABLE_MASK) >> _ENABLE_SHIFT); } +#endif /* !SOFTFLOAT */ + #endif /* __BSD_VISIBLE */ __END_DECLS Modified: head/share/man/man7/arch.7 ============================================================================== --- head/share/man/man7/arch.7 Mon Oct 31 15:11:55 2016 (r308129) +++ head/share/man/man7/arch.7 Mon Oct 31 15:33:58 2016 (r308130) @@ -57,9 +57,13 @@ On all supported architectures, .It i386 Ta 4 Ta 12 .It mips Ta 4 Ta 8 .It mipsel Ta 4 Ta 8 +.It mipselhf Ta 4 Ta 8 +.It mipshf Ta 4 Ta 8 .It mipsn32 Ta 4 Ta 8 .It mips64 Ta 8 Ta 8 .It mips64el Ta 8 Ta 8 +.It mips64elhf Ta 8 Ta 8 +.It mips64hf Ta 8 Ta 8 .It powerpc Ta 4 Ta 8 .It powerpc64 Ta 8 Ta 8 .It riscv Ta 8 Ta @@ -76,9 +80,13 @@ On all supported architectures, .It i386 Ta little Ta signed .It mips Ta big Ta signed .It mipsel Ta little Ta signed +.It mipselhf Ta little Ta signed +.It mipshf Ta big Ta signed .It mipsn32 Ta big Ta signed .It mips64 Ta big Ta signed .It mips64el Ta little Ta signed +.It mips64elhf Ta little Ta signed +.It mips64hf Ta big Ta signed .It powerpc Ta big Ta unsigned .It powerpc64 Ta big Ta unsigned .It riscv Ta little Ta signed @@ -95,9 +103,13 @@ On all supported architectures, .It i386 Ta 4K, 2M (PAE), 4M .It mips Ta 4K .It mipsel Ta 4K +.It mipselhf Ta 4K +.It mipshf Ta 4K .It mipsn32 Ta 4K .It mips64 Ta 4K .It mips64el Ta 4K +.It mips64elhf Ta 4K +.It mips64hf Ta 4K .It powerpc Ta 4K .It powerpc64 Ta 4K .It riscv Ta 4K @@ -114,9 +126,13 @@ On all supported architectures, .It i386 Ta hard Ta hard, 80 bit .It mips Ta soft Ta identical to double .It mipsel Ta soft Ta identical to double -.It mipsn32 Ta soft Ta identical to double +.It mipselhf Ta hard Ta identical to double +.It mipshf Ta hard Ta identical to double +.It mipsn32 Ta soft Ta identical to double .It mips64 Ta soft Ta identical to double .It mips64el Ta soft Ta identical to double +.It mips64elhf Ta hard Ta identical to double +.It mips64hf Ta hard Ta identical to double .It powerpc Ta hard Ta hard, double precision .It powerpc64 Ta hard Ta hard, double precision .It riscv Ta @@ -155,9 +171,13 @@ Architecture-specific macros: .It i386 Ta Dv __i386__ .It mips Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_o32 .It mipsel Ta Dv __mips__, Dv __mips_o32 +.It mipselhf Ta Dv __mips__, Dv __mips_o32 +.It mipshf Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_o32 .It mipsn32 Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n32 .It mips64 Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n64 .It mips64el Ta Dv __mips__, Dv __mips_n64 +.It mips64elhf Ta Dv __mips__, Dv __mips_n64 +.It mips64hf Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n64 .It powerpc Ta Dv __powerpc__ .It powerpc64 Ta Dv __powerpc__, Dv __powerpc64__ .It riscv Ta Dv __riscv__, Dv __riscv64 Modified: head/share/mk/bsd.cpu.mk ============================================================================== --- head/share/mk/bsd.cpu.mk Mon Oct 31 15:11:55 2016 (r308129) +++ head/share/mk/bsd.cpu.mk Mon Oct 31 15:33:58 2016 (r308130) @@ -303,6 +303,9 @@ MACHINE_CPU = v9 ultrasparc ultrasparc3 .if ${MACHINE_CPUARCH} == "mips" CFLAGS += -G0 +.if ${TARGET_ARCH:Mmips*hf} +CFLAGS += -mhard-float +.endif .endif ########## arm Modified: head/share/mk/bsd.endian.mk ============================================================================== --- head/share/mk/bsd.endian.mk Mon Oct 31 15:11:55 2016 (r308129) +++ head/share/mk/bsd.endian.mk Mon Oct 31 15:33:58 2016 (r308130) @@ -5,7 +5,7 @@ ${MACHINE_ARCH} == "i386" || \ (${MACHINE} == "arm" && ${MACHINE_ARCH:Marm*eb*} == "") || \ ${MACHINE_CPUARCH} == "riscv" || \ - ${MACHINE_ARCH:Mmips*el} != "" + ${MACHINE_ARCH:Mmips*el*} != "" TARGET_ENDIANNESS= 1234 .elif ${MACHINE_ARCH} == "powerpc" || \ ${MACHINE_ARCH} == "powerpc64" || \ Modified: head/share/mk/sys.mk ============================================================================== --- head/share/mk/sys.mk Mon Oct 31 15:11:55 2016 (r308129) +++ head/share/mk/sys.mk Mon Oct 31 15:33:58 2016 (r308130) @@ -13,7 +13,7 @@ unix ?= We run FreeBSD, not UNIX. # and/or endian. This is called MACHINE_CPU in NetBSD, but that's used # for something different in FreeBSD. # -MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64/riscv/} +MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64/riscv/} .endif Modified: head/sys/boot/Makefile.ficl ============================================================================== --- head/sys/boot/Makefile.ficl Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/boot/Makefile.ficl Mon Oct 31 15:33:58 2016 (r308130) @@ -6,7 +6,7 @@ FICLDIR?= ${SRCTOP}/sys/boot/ficl .if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) FICL_CPUARCH= i386 -.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" +.elif ${MACHINE_ARCH:Mmips64*} != "" FICL_CPUARCH= mips64 .else FICL_CPUARCH= ${MACHINE_CPUARCH} Modified: head/sys/boot/common/Makefile.inc ============================================================================== --- head/sys/boot/common/Makefile.inc Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/boot/common/Makefile.inc Mon Oct 31 15:33:58 2016 (r308130) @@ -18,7 +18,7 @@ SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf64.c reloc_elf64.c .elif ${MACHINE_CPUARCH} == "sparc64" SRCS+= load_elf64.c reloc_elf64.c -.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" +.elif ${MACHINE_ARCH:Mmips64*} != "" SRCS+= load_elf64.c reloc_elf64.c .elif ${MACHINE} == "mips" SRCS+= load_elf32.c reloc_elf32.c Modified: head/sys/boot/mips/uboot/Makefile ============================================================================== --- head/sys/boot/mips/uboot/Makefile Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/boot/mips/uboot/Makefile Mon Oct 31 15:33:58 2016 (r308130) @@ -85,7 +85,7 @@ LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a # Enable BootForth BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" +.if ${MACHINE_ARCH:Mmips64*} != "" CFLAGS+= -I${.CURDIR}/../../ficl/mips64 .else CFLAGS+= -I${.CURDIR}/../../ficl/mips Modified: head/sys/conf/kern.mk ============================================================================== --- head/sys/conf/kern.mk Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/conf/kern.mk Mon Oct 31 15:33:58 2016 (r308130) @@ -184,6 +184,9 @@ CFLAGS.gcc+= -mcall-aixdesc .if ${MACHINE_CPUARCH} == "mips" CFLAGS+= -msoft-float INLINE_LIMIT?= 8000 +.if ${TARGET_ARCH:Mmips*hf} != "" +CFLAGS+= -DCPU_HAVEFPU +.endif .endif # Modified: head/sys/mips/include/float.h ============================================================================== --- head/sys/mips/include/float.h Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/mips/include/float.h Mon Oct 31 15:33:58 2016 (r308130) @@ -42,11 +42,7 @@ extern int __flt_rounds(void); __END_DECLS #define FLT_RADIX 2 /* b */ -#ifdef CPU_HAVEFPU #define FLT_ROUNDS __flt_rounds() /* FP addition rounds to nearest */ -#else -#define FLT_ROUNDS (-1) -#endif #if __ISO_C_VISIBLE >= 1999 #define FLT_EVAL_METHOD 0 Modified: head/sys/mips/mips/exception.S ============================================================================== --- head/sys/mips/mips/exception.S Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/mips/mips/exception.S Mon Oct 31 15:33:58 2016 (r308130) @@ -1098,11 +1098,17 @@ END(MipsTLBMissException) NESTED(MipsFPTrap, CALLFRAME_SIZ, ra) PTR_SUBU sp, sp, CALLFRAME_SIZ mfc0 t0, MIPS_COP_0_STATUS + HAZARD_DELAY REG_S ra, CALLFRAME_RA(sp) .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) +#if defined(__mips_n64) + or t1, t0, MIPS_SR_COP_1_BIT | MIPS_SR_FR +#else or t1, t0, MIPS_SR_COP_1_BIT +#endif mtc0 t1, MIPS_COP_0_STATUS + HAZARD_DELAY ITLBNOPFIX cfc1 t1, MIPS_FPU_CSR # stall til FP done cfc1 t1, MIPS_FPU_CSR # now get status Modified: head/sys/mips/mips/locore.S ============================================================================== --- head/sys/mips/mips/locore.S Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/mips/mips/locore.S Mon Oct 31 15:33:58 2016 (r308130) @@ -118,7 +118,7 @@ VECTOR(_locore, unknown) */ li t1, MIPS_SR_COP_1_BIT #ifdef __mips_n64 - or t1, MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX + or t1, MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX | MIPS_SR_FR #endif #endif /* Modified: head/sys/mips/mips/swtch.S ============================================================================== --- head/sys/mips/mips/swtch.S Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/mips/mips/swtch.S Mon Oct 31 15:33:58 2016 (r308130) @@ -415,8 +415,14 @@ LEAF(MipsSwitchFPState) .set push .set hardfloat mfc0 t1, MIPS_COP_0_STATUS # Save old SR - li t0, MIPS_SR_COP_1_BIT # enable the coprocessor + HAZARD_DELAY +#if defined(__mips_n64) + or t0, t1, MIPS_SR_COP_1_BIT | MIPS_SR_FR # enable the coprocessor +#else + or t0, t1, MIPS_SR_COP_1_BIT # enable the coprocessor +#endif mtc0 t0, MIPS_COP_0_STATUS + HAZARD_DELAY ITLBNOPFIX beq a0, zero, 1f # skip save if NULL pointer @@ -540,8 +546,14 @@ LEAF(MipsSaveCurFPState) .set hardfloat PTR_L a0, TD_PCB(a0) # get pointer to pcb for thread mfc0 t1, MIPS_COP_0_STATUS # Disable interrupts and - li t0, MIPS_SR_COP_1_BIT # enable the coprocessor + HAZARD_DELAY +#if defined(__mips_n64) + or t0, t1, MIPS_SR_COP_1_BIT | MIPS_SR_FR # enable the coprocessor +#else + or t0, t1, MIPS_SR_COP_1_BIT # enable the coprocessor +#endif mtc0 t0, MIPS_COP_0_STATUS + HAZARD_DELAY ITLBNOPFIX GET_CPU_PCPU(a1) PTR_S zero, PC_FPCURTHREAD(a1) # indicate state has been saved Modified: head/sys/mips/mips/trap.c ============================================================================== --- head/sys/mips/mips/trap.c Mon Oct 31 15:11:55 2016 (r308129) +++ head/sys/mips/mips/trap.c Mon Oct 31 15:33:58 2016 (r308130) @@ -590,7 +590,8 @@ trap(struct trapframe *trapframe) break; } if ((last_badvaddr == this_badvaddr) && - ((type & ~T_USER) != T_SYSCALL)) { + ((type & ~T_USER) != T_SYSCALL) && + ((type & ~T_USER) != T_COP_UNUSABLE)) { if (++count == 3) { trap_frame_dump(trapframe); panic("too many faults at %p\n", (void *)last_badvaddr); @@ -980,7 +981,11 @@ dofault: addr = trapframe->pc; MipsSwitchFPState(PCPU_GET(fpcurthread), td->td_frame); PCPU_SET(fpcurthread, td); +#if defined(__mips_n64) + td->td_frame->sr |= MIPS_SR_COP_1_BIT | MIPS_SR_FR; +#else td->td_frame->sr |= MIPS_SR_COP_1_BIT; +#endif td->td_md.md_flags |= MDTD_FPUSED; goto out; #endif From owner-svn-src-head@freebsd.org Mon Oct 31 15:49:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C05F3C28F73; Mon, 31 Oct 2016 15:49:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8CAA9161C; Mon, 31 Oct 2016 15:49:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VFnfl9057108; Mon, 31 Oct 2016 15:49:41 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VFnfKX057107; Mon, 31 Oct 2016 15:49:41 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610311549.u9VFnfKX057107@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 31 Oct 2016 15:49:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308132 - head/sys/mips/mips X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 15:49:42 -0000 Author: br Date: Mon Oct 31 15:49:41 2016 New Revision: 308132 URL: https://svnweb.freebsd.org/changeset/base/308132 Log: Use correct signal number for floating point exceptions. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/sys/mips/mips/trap.c Modified: head/sys/mips/mips/trap.c ============================================================================== --- head/sys/mips/mips/trap.c Mon Oct 31 15:46:06 2016 (r308131) +++ head/sys/mips/mips/trap.c Mon Oct 31 15:49:41 2016 (r308132) @@ -1033,7 +1033,7 @@ dofault: case T_FPE + T_USER: if (!emulate_fp) { - i = SIGILL; + i = SIGFPE; addr = trapframe->pc; break; } From owner-svn-src-head@freebsd.org Mon Oct 31 16:01:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A4DFC28273; Mon, 31 Oct 2016 16:01:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED4081DF4; Mon, 31 Oct 2016 16:01:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VG1Nou061591; Mon, 31 Oct 2016 16:01:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VG1NFJ061590; Mon, 31 Oct 2016 16:01:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610311601.u9VG1NFJ061590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 31 Oct 2016 16:01:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308133 - head/usr.sbin/ctld X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 16:01:24 -0000 Author: mav Date: Mon Oct 31 16:01:22 2016 New Revision: 308133 URL: https://svnweb.freebsd.org/changeset/base/308133 Log: Fix wrong copy/paste in error message. Submitted by: Dmitry Luhtionov MFC after: 2 weeks Modified: head/usr.sbin/ctld/ctld.c Modified: head/usr.sbin/ctld/ctld.c ============================================================================== --- head/usr.sbin/ctld/ctld.c Mon Oct 31 15:49:41 2016 (r308132) +++ head/usr.sbin/ctld/ctld.c Mon Oct 31 16:01:22 2016 (r308133) @@ -198,7 +198,7 @@ auth_check_secret_length(struct auth *au auth->a_auth_group->ag_name); else log_warnx("secret for user \"%s\", target \"%s\", " - "is too short; it should be at least 16 characters " + "is too short; it should be at least 12 characters " "long", auth->a_user, auth->a_auth_group->ag_target->t_name); } From owner-svn-src-head@freebsd.org Mon Oct 31 16:06:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90AAAC28463; Mon, 31 Oct 2016 16:06:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62AF311B2; Mon, 31 Oct 2016 16:06:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VG6vwB064591; Mon, 31 Oct 2016 16:06:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VG6vC9064590; Mon, 31 Oct 2016 16:06:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610311606.u9VG6vC9064590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 31 Oct 2016 16:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308134 - head/usr.sbin/ctld X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 16:06:58 -0000 Author: mav Date: Mon Oct 31 16:06:57 2016 New Revision: 308134 URL: https://svnweb.freebsd.org/changeset/base/308134 Log: There appeared to be even more copy/pastes. :) Submitted by: Dmitry Luhtionov MFC after: 2 weeks Modified: head/usr.sbin/ctld/ctld.c Modified: head/usr.sbin/ctld/ctld.c ============================================================================== --- head/usr.sbin/ctld/ctld.c Mon Oct 31 16:01:22 2016 (r308133) +++ head/usr.sbin/ctld/ctld.c Mon Oct 31 16:06:57 2016 (r308134) @@ -227,7 +227,7 @@ auth_check_secret_length(struct auth *au else log_warnx("mutual secret for user \"%s\", " "target \"%s\", is too short; it should be " - "at least 16 characters long", + "at least 12 characters long", auth->a_user, auth->a_auth_group->ag_target->t_name); } From owner-svn-src-head@freebsd.org Mon Oct 31 16:55:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C42FDC281D7; Mon, 31 Oct 2016 16:55:15 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BA96115D; Mon, 31 Oct 2016 16:55:15 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VGtEbG083859; Mon, 31 Oct 2016 16:55:14 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VGtE0q083855; Mon, 31 Oct 2016 16:55:14 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610311655.u9VGtE0q083855@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 31 Oct 2016 16:55:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308137 - in head: sbin/geom/class/eli sys/geom/eli sys/modules/geom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 16:55:15 -0000 Author: br Date: Mon Oct 31 16:55:14 2016 New Revision: 308137 URL: https://svnweb.freebsd.org/changeset/base/308137 Log: Fix alignment issues on MIPS: align the pointers properly. All the 5520 GEOM_ELI tests passed successfully on MIPS64EB. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D7905 Modified: head/sbin/geom/class/eli/geom_eli.c head/sys/geom/eli/g_eli.h head/sys/geom/eli/g_eli_integrity.c head/sys/modules/geom/Makefile Modified: head/sbin/geom/class/eli/geom_eli.c ============================================================================== --- head/sbin/geom/class/eli/geom_eli.c Mon Oct 31 16:48:16 2016 (r308136) +++ head/sbin/geom/class/eli/geom_eli.c Mon Oct 31 16:55:14 2016 (r308137) @@ -666,7 +666,7 @@ static void eli_init(struct gctl_req *req) { struct g_eli_metadata md; - unsigned char sector[sizeof(struct g_eli_metadata)]; + unsigned char sector[sizeof(struct g_eli_metadata)] __aligned(4); unsigned char key[G_ELI_USERKEYLEN]; char backfile[MAXPATHLEN]; const char *str, *prov; Modified: head/sys/geom/eli/g_eli.h ============================================================================== --- head/sys/geom/eli/g_eli.h Mon Oct 31 16:48:16 2016 (r308136) +++ head/sys/geom/eli/g_eli.h Mon Oct 31 16:55:14 2016 (r308137) @@ -289,6 +289,7 @@ eli_metadata_encode_v1v2v3v4v5v6v7(struc static __inline void eli_metadata_encode(struct g_eli_metadata *md, u_char *data) { + uint32_t hash[4]; MD5_CTX ctx; u_char *p; @@ -320,12 +321,14 @@ eli_metadata_encode(struct g_eli_metadat } MD5Init(&ctx); MD5Update(&ctx, data, p - data); - MD5Final(md->md_hash, &ctx); + MD5Final((void *)hash, &ctx); + bcopy(hash, md->md_hash, sizeof(md->md_hash)); bcopy(md->md_hash, p, sizeof(md->md_hash)); } static __inline int eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md) { + uint32_t hash[4]; MD5_CTX ctx; const u_char *p; @@ -341,7 +344,8 @@ eli_metadata_decode_v0(const u_char *dat bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); MD5Init(&ctx); MD5Update(&ctx, data, p - data); - MD5Final(md->md_hash, &ctx); + MD5Final((void *)hash, &ctx); + bcopy(hash, md->md_hash, sizeof(md->md_hash)); if (bcmp(md->md_hash, p, 16) != 0) return (EINVAL); return (0); @@ -350,6 +354,7 @@ eli_metadata_decode_v0(const u_char *dat static __inline int eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md) { + uint32_t hash[4]; MD5_CTX ctx; const u_char *p; @@ -366,7 +371,8 @@ eli_metadata_decode_v1v2v3v4v5v6v7(const bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); MD5Init(&ctx); MD5Update(&ctx, data, p - data); - MD5Final(md->md_hash, &ctx); + MD5Final((void *)hash, &ctx); + bcopy(hash, md->md_hash, sizeof(md->md_hash)); if (bcmp(md->md_hash, p, 16) != 0) return (EINVAL); return (0); Modified: head/sys/geom/eli/g_eli_integrity.c ============================================================================== --- head/sys/geom/eli/g_eli_integrity.c Mon Oct 31 16:48:16 2016 (r308136) +++ head/sys/geom/eli/g_eli_integrity.c Mon Oct 31 16:55:14 2016 (r308137) @@ -444,6 +444,7 @@ g_eli_auth_run(struct g_eli_worker *wr, size += sizeof(*crde) * nsec; size += sizeof(*crda) * nsec; size += G_ELI_AUTH_SECKEYLEN * nsec; + size += sizeof(uintptr_t); /* Space for alignment. */ data = malloc(size, M_ELI, M_WAITOK); bp->bio_driver2 = data; p = data + encr_secsize * nsec; @@ -451,6 +452,10 @@ g_eli_auth_run(struct g_eli_worker *wr, bp->bio_inbed = 0; bp->bio_children = nsec; +#if defined(__mips_n64) || defined(__mips_o64) + p = (char *)roundup((uintptr_t)p, sizeof(uintptr_t)); +#endif + for (i = 1; i <= nsec; i++, dstoff += encr_secsize) { crp = (struct cryptop *)p; p += sizeof(*crp); crde = (struct cryptodesc *)p; p += sizeof(*crde); Modified: head/sys/modules/geom/Makefile ============================================================================== --- head/sys/modules/geom/Makefile Mon Oct 31 16:48:16 2016 (r308136) +++ head/sys/modules/geom/Makefile Mon Oct 31 16:55:14 2016 (r308137) @@ -6,6 +6,7 @@ SYSDIR?=${.CURDIR}/../.. SUBDIR= geom_bde \ geom_cache \ geom_concat \ + geom_eli \ geom_gate \ geom_journal \ geom_label \ @@ -29,9 +30,4 @@ SUBDIR= geom_bde \ SUBDIR+= geom_ccd .endif -# Alignment issues in g_eli_auth_run() on MIPS64 causes kernel panic -.if ${MACHINE_ARCH} != "mips64" && ${MACHINE_ARCH} != "mips64el" -SUBDIR+= geom_eli -.endif - .include From owner-svn-src-head@freebsd.org Mon Oct 31 18:20:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0954FC16EEA; Mon, 31 Oct 2016 18:20:14 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D743D1334; Mon, 31 Oct 2016 18:20:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VIKDuA015680; Mon, 31 Oct 2016 18:20:13 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VIKCHj015674; Mon, 31 Oct 2016 18:20:12 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610311820.u9VIKCHj015674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 31 Oct 2016 18:20:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308139 - in head: etc/mtree usr.sbin/cron/cron usr.sbin/cron/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 18:20:14 -0000 Author: bapt Date: Mon Oct 31 18:20:12 2016 New Revision: 308139 URL: https://svnweb.freebsd.org/changeset/base/308139 Log: cron(8): add support for /etc/cron.d and /usr/local/etc/cron.d For automation tools it is way easier to maintain files in directories rather than modifying /etc/crontab. The files in those directories are in the same format as /etc/crontab Reviewed by: adrian MFC after: 2 weeks Relnotes: yes Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D8400 Modified: head/etc/mtree/BSD.root.dist head/usr.sbin/cron/cron/cron.8 head/usr.sbin/cron/cron/cron.h head/usr.sbin/cron/cron/database.c head/usr.sbin/cron/cron/pathnames.h head/usr.sbin/cron/lib/misc.c Modified: head/etc/mtree/BSD.root.dist ============================================================================== --- head/etc/mtree/BSD.root.dist Mon Oct 31 18:12:07 2016 (r308138) +++ head/etc/mtree/BSD.root.dist Mon Oct 31 18:20:12 2016 (r308139) @@ -32,6 +32,8 @@ .. casper .. + cron.d + .. defaults .. devd Modified: head/usr.sbin/cron/cron/cron.8 ============================================================================== --- head/usr.sbin/cron/cron/cron.8 Mon Oct 31 18:12:07 2016 (r308138) +++ head/usr.sbin/cron/cron/cron.8 Mon Oct 31 18:20:12 2016 (r308139) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 21, 2016 +.Dd Octobre 31, 2016 .Dt CRON 8 .Os .Sh NAME @@ -53,7 +53,11 @@ The .Nm utility also searches for .Pa /etc/crontab -which is in a different format (see +and files in +.Pa /etc/cron.d +and +.Pa /usr/local/etc/cron.d +which are in a different format (see .Xr crontab 5 ) . .Pp The Modified: head/usr.sbin/cron/cron/cron.h ============================================================================== --- head/usr.sbin/cron/cron/cron.h Mon Oct 31 18:12:07 2016 (r308138) +++ head/usr.sbin/cron/cron/cron.h Mon Oct 31 18:20:12 2016 (r308139) @@ -218,7 +218,7 @@ void set_cron_uid(void), unget_char(int, FILE *), free_entry(entry *), skip_comments(FILE *), - log_it(char *, int, char *, char *), + log_it(char *, int, char *, const char *), log_close(void); int job_runqueue(void), Modified: head/usr.sbin/cron/cron/database.c ============================================================================== --- head/usr.sbin/cron/cron/database.c Mon Oct 31 18:12:07 2016 (r308138) +++ head/usr.sbin/cron/cron/database.c Mon Oct 31 18:20:12 2016 (r308139) @@ -45,9 +45,18 @@ load_database(old_db) DIR *dir; struct stat statbuf; struct stat syscron_stat; + time_t maxmtime; DIR_T *dp; cron_db new_db; user *u, *nu; + struct { + const char *name; + struct stat st; + } syscrontabs [] = { + { SYSCRONTABS }, + { LOCALSYSCRONTABS } + }; + int i; Debug(DLOAD, ("[%d] load_database()\n", getpid())) @@ -65,6 +74,16 @@ load_database(old_db) if (stat(SYSCRONTAB, &syscron_stat) < OK) syscron_stat.st_mtime = 0; + maxmtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime); + + for (i = 0; i < nitems(syscrontabs); i++) { + if (stat(syscrontabs[i].name, &syscrontabs[i].st) != -1) { + maxmtime = TMAX(syscrontabs[i].st.st_mtime, maxmtime); + } else { + syscrontabs[i].st.st_mtime = 0; + } + } + /* if spooldir's mtime has not changed, we don't need to fiddle with * the database. * @@ -72,7 +91,7 @@ load_database(old_db) * so is guaranteed to be different than the stat() mtime the first * time this function is called. */ - if (old_db->mtime == TMAX(statbuf.st_mtime, syscron_stat.st_mtime)) { + if (old_db->mtime == maxmtime) { Debug(DLOAD, ("[%d] spool dir mtime unch, no load needed.\n", getpid())) return; @@ -83,7 +102,7 @@ load_database(old_db) * actually changed. Whatever is left in the old database when * we're done is chaff -- crontabs that disappeared. */ - new_db.mtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime); + new_db.mtime = maxmtime; new_db.head = new_db.tail = NULL; if (syscron_stat.st_mtime) { @@ -92,6 +111,29 @@ load_database(old_db) &new_db, old_db); } + for (i = 0; i < nitems(syscrontabs); i++) { + char tabname[MAXPATHLEN]; + if (syscrontabs[i].st.st_mtime == 0) + continue; + if (!(dir = opendir(syscrontabs[i].name))) { + log_it("CRON", getpid(), "OPENDIR FAILED", + syscrontabs[i].name); + (void) exit(ERROR_EXIT); + } + + while (NULL != (dp = readdir(dir))) { + if (dp->d_name[0] == '.') + continue; + if (dp->d_type != DT_REG) + continue; + snprintf(tabname, sizeof(tabname), "%s/%s", + syscrontabs[i].name, dp->d_name); + process_crontab("root", SYS_NAME, tabname, + &syscrontabs[i].st, &new_db, old_db); + } + closedir(dir); + } + /* we used to keep this dir open all the time, for the sake of * efficiency. however, we need to close it in every fork, and * we fork a lot more often than the mtime of the dir changes. Modified: head/usr.sbin/cron/cron/pathnames.h ============================================================================== --- head/usr.sbin/cron/cron/pathnames.h Mon Oct 31 18:12:07 2016 (r308138) +++ head/usr.sbin/cron/cron/pathnames.h Mon Oct 31 18:20:12 2016 (r308139) @@ -62,6 +62,8 @@ /* 4.3BSD-style crontab */ #define SYSCRONTAB "/etc/crontab" +#define SYSCRONTABS "/etc/cron.d" +#define LOCALSYSCRONTABS "/usr/local/etc/cron.d" /* what editor to use if no EDITOR or VISUAL * environment variable specified. Modified: head/usr.sbin/cron/lib/misc.c ============================================================================== --- head/usr.sbin/cron/lib/misc.c Mon Oct 31 18:12:07 2016 (r308138) +++ head/usr.sbin/cron/lib/misc.c Mon Oct 31 18:20:12 2016 (r308139) @@ -385,11 +385,7 @@ out: if (allow) void -log_it(username, xpid, event, detail) - char *username; - int xpid; - char *event; - char *detail; +log_it(char *username, int xpid, char *event, const char *detail) { #if defined(LOG_FILE) || DEBUGGING PID_T pid = xpid; From owner-svn-src-head@freebsd.org Mon Oct 31 18:37:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77557C27344; Mon, 31 Oct 2016 18:37:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3845B1EB8; Mon, 31 Oct 2016 18:37:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VIb5uD023470; Mon, 31 Oct 2016 18:37:05 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VIb5n4023468; Mon, 31 Oct 2016 18:37:05 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201610311837.u9VIb5n4023468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 31 Oct 2016 18:37:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308142 - head/sys/amd64/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 18:37:06 -0000 Author: jhb Date: Mon Oct 31 18:37:05 2016 New Revision: 308142 URL: https://svnweb.freebsd.org/changeset/base/308142 Log: Move declarations of invpcid_works and pmap_pcid_enabled to pmap.h. Previously these were only declared under #ifdef SMP in . However, these variables are defind in pmap.c unconditionally, and efirt.c references them unconditionally. This fixes non-SMP kernel builds. Discussed with: kib MFC after: 1 week Modified: head/sys/amd64/include/pmap.h head/sys/amd64/include/smp.h Modified: head/sys/amd64/include/pmap.h ============================================================================== --- head/sys/amd64/include/pmap.h Mon Oct 31 18:29:16 2016 (r308141) +++ head/sys/amd64/include/pmap.h Mon Oct 31 18:37:05 2016 (r308142) @@ -382,6 +382,8 @@ extern vm_paddr_t dump_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; extern vm_paddr_t dmaplimit; +extern int pmap_pcid_enabled; +extern int invpcid_works; #define pmap_page_get_memattr(m) ((vm_memattr_t)(m)->md.pat_mode) #define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0) Modified: head/sys/amd64/include/smp.h ============================================================================== --- head/sys/amd64/include/smp.h Mon Oct 31 18:29:16 2016 (r308141) +++ head/sys/amd64/include/smp.h Mon Oct 31 18:37:05 2016 (r308142) @@ -21,9 +21,6 @@ #include -extern int pmap_pcid_enabled; -extern int invpcid_works; - /* global symbols in mpboot.S */ extern char mptramp_start[]; extern char mptramp_end[]; From owner-svn-src-head@freebsd.org Mon Oct 31 18:38:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4ADACC27462; Mon, 31 Oct 2016 18:38:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1A0EE11AD; Mon, 31 Oct 2016 18:38:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VIcogZ023628; Mon, 31 Oct 2016 18:38:50 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VIcoG6023627; Mon, 31 Oct 2016 18:38:50 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610311838.u9VIcoG6023627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 31 Oct 2016 18:38:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308144 - head/sys/dev/usb/input X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 18:38:51 -0000 Author: hselasky Date: Mon Oct 31 18:38:50 2016 New Revision: 308144 URL: https://svnweb.freebsd.org/changeset/base/308144 Log: Make sure the virtual T-axis buttons gets cleared for USB mice which has less than 6 buttons. PR: 213919 MFC after: 3 days Modified: head/sys/dev/usb/input/ums.c Modified: head/sys/dev/usb/input/ums.c ============================================================================== --- head/sys/dev/usb/input/ums.c Mon Oct 31 18:37:44 2016 (r308143) +++ head/sys/dev/usb/input/ums.c Mon Oct 31 18:38:50 2016 (r308144) @@ -295,8 +295,11 @@ ums_intr_callback(struct usb_xfer *xfer, } if ((info->sc_flags & UMS_FLAG_T_AXIS) && - (id == info->sc_iid_t)) + (id == info->sc_iid_t)) { dt -= hid_get_data(buf, len, &info->sc_loc_t); + /* T-axis is translated into button presses */ + buttons_found |= (1UL << 5) | (1UL << 6); + } for (i = 0; i < info->sc_buttons; i++) { uint32_t mask; From owner-svn-src-head@freebsd.org Mon Oct 31 18:38:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCE26C27490; Mon, 31 Oct 2016 18:38:59 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 917251304; Mon, 31 Oct 2016 18:38:59 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VIcw86023693; Mon, 31 Oct 2016 18:38:58 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VIcwii023690; Mon, 31 Oct 2016 18:38:58 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610311838.u9VIcwii023690@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 31 Oct 2016 18:38:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308145 - in head: contrib/netbsd-tests/lib/libc/stdio include lib/libc/stdio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 18:38:59 -0000 Author: br Date: Mon Oct 31 18:38:58 2016 New Revision: 308145 URL: https://svnweb.freebsd.org/changeset/base/308145 Log: Detect integer overflow and limit the number of positional arguments in the string format. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8286 Modified: head/contrib/netbsd-tests/lib/libc/stdio/t_printf.c head/include/limits.h head/lib/libc/stdio/printf-pos.c Modified: head/contrib/netbsd-tests/lib/libc/stdio/t_printf.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/stdio/t_printf.c Mon Oct 31 18:38:50 2016 (r308144) +++ head/contrib/netbsd-tests/lib/libc/stdio/t_printf.c Mon Oct 31 18:38:58 2016 (r308145) @@ -120,12 +120,6 @@ ATF_TC_BODY(snprintf_posarg_error, tc) { char s[16], fmt[32]; -#ifndef __NetBSD__ - atf_tc_expect_signal(SIGSEGV, - "some non-NetBSD platforms including FreeBSD don't validate " - "negative size; testcase blows up with SIGSEGV"); -#endif - snprintf(fmt, sizeof(fmt), "%%%zu$d", SIZE_MAX / sizeof(size_t)); ATF_CHECK(snprintf(s, sizeof(s), fmt, -23) == -1); Modified: head/include/limits.h ============================================================================== --- head/include/limits.h Mon Oct 31 18:38:50 2016 (r308144) +++ head/include/limits.h Mon Oct 31 18:38:58 2016 (r308145) @@ -120,7 +120,7 @@ #endif #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809 -#define NL_ARGMAX 99 /* max # of position args for printf */ +#define NL_ARGMAX 65536 /* max # of position args for printf */ #define NL_MSGMAX 32767 #define NL_SETMAX 255 #define NL_TEXTMAX 2048 Modified: head/lib/libc/stdio/printf-pos.c ============================================================================== --- head/lib/libc/stdio/printf-pos.c Mon Oct 31 18:38:50 2016 (r308144) +++ head/lib/libc/stdio/printf-pos.c Mon Oct 31 18:38:58 2016 (r308145) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include +#include #include #include #include @@ -55,6 +56,12 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "printflocal.h" +#ifdef NL_ARGMAX +#define MAX_POSARG NL_ARGMAX +#else +#define MAX_POSARG 65536 +#endif + /* * Type ids for argument type table. */ @@ -70,9 +77,9 @@ enum typeid { struct typetable { enum typeid *table; /* table of types */ enum typeid stattable[STATIC_ARG_TBL_SIZE]; - int tablesize; /* current size of type table */ - int tablemax; /* largest used index in table */ - int nextarg; /* 1-based argument index */ + u_int tablesize; /* current size of type table */ + u_int tablemax; /* largest used index in table */ + u_int nextarg; /* 1-based argument index */ }; static int __grow_type_table(struct typetable *); @@ -84,7 +91,7 @@ static void build_arg_table (struct type static inline void inittypes(struct typetable *types) { - int n; + u_int n; types->table = types->stattable; types->tablesize = STATIC_ARG_TBL_SIZE; @@ -185,7 +192,7 @@ static inline int addaster(struct typetable *types, char **fmtp) { char *cp; - int n2; + u_int n2; n2 = 0; cp = *fmtp; @@ -194,7 +201,7 @@ addaster(struct typetable *types, char * cp++; } if (*cp == '$') { - int hold = types->nextarg; + u_int hold = types->nextarg; types->nextarg = n2; if (addtype(types, T_INT)) return (-1); @@ -211,7 +218,7 @@ static inline int addwaster(struct typetable *types, wchar_t **fmtp) { wchar_t *cp; - int n2; + u_int n2; n2 = 0; cp = *fmtp; @@ -220,7 +227,7 @@ addwaster(struct typetable *types, wchar cp++; } if (*cp == '$') { - int hold = types->nextarg; + u_int hold = types->nextarg; types->nextarg = n2; if (addtype(types, T_INT)) return (-1); @@ -245,7 +252,7 @@ __find_arguments (const char *fmt0, va_l { char *fmt; /* format string */ int ch; /* character from fmt */ - int n; /* handy integer (short term usage) */ + u_int n; /* handy integer (short term usage) */ int error; int flags; /* flags as above */ struct typetable types; /* table of types */ @@ -296,6 +303,11 @@ reswitch: switch (ch) { n = 0; do { n = 10 * n + to_digit(ch); + /* Detect overflow */ + if (n > MAX_POSARG) { + error = -1; + goto error; + } ch = *fmt++; } while (is_digit(ch)); if (ch == '$') { @@ -433,7 +445,7 @@ __find_warguments (const wchar_t *fmt0, { wchar_t *fmt; /* format string */ wchar_t ch; /* character from fmt */ - int n; /* handy integer (short term usage) */ + u_int n; /* handy integer (short term usage) */ int error; int flags; /* flags as above */ struct typetable types; /* table of types */ @@ -484,6 +496,11 @@ reswitch: switch (ch) { n = 0; do { n = 10 * n + to_digit(ch); + /* Detect overflow */ + if (n > MAX_POSARG) { + error = -1; + goto error; + } ch = *fmt++; } while (is_digit(ch)); if (ch == '$') { @@ -624,7 +641,11 @@ __grow_type_table(struct typetable *type enum typeid *const oldtable = types->table; const int oldsize = types->tablesize; enum typeid *newtable; - int n, newsize = oldsize * 2; + u_int n, newsize = oldsize * 2; + + /* Detect overflow */ + if (types->nextarg > NL_ARGMAX) + return (-1); if (newsize < types->nextarg + 1) newsize = types->nextarg + 1; @@ -653,7 +674,7 @@ __grow_type_table(struct typetable *type static void build_arg_table(struct typetable *types, va_list ap, union arg **argtable) { - int n; + u_int n; if (types->tablemax >= STATIC_ARG_TBL_SIZE) { *argtable = (union arg *) From owner-svn-src-head@freebsd.org Mon Oct 31 20:31:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84D9EC280C9; Mon, 31 Oct 2016 20:31:57 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5470018C9; Mon, 31 Oct 2016 20:31:57 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VKVuQQ066290; Mon, 31 Oct 2016 20:31:56 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VKVuK8066278; Mon, 31 Oct 2016 20:31:56 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610312031.u9VKVuK8066278@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 31 Oct 2016 20:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308148 - head/usr.bin/calendar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 20:31:57 -0000 Author: gjb Date: Mon Oct 31 20:31:56 2016 New Revision: 308148 URL: https://svnweb.freebsd.org/changeset/base/308148 Log: Fix packaging calendar(1) files. Sponsored by: The FreeBSD Foundation Modified: head/usr.bin/calendar/Makefile Modified: head/usr.bin/calendar/Makefile ============================================================================== --- head/usr.bin/calendar/Makefile Mon Oct 31 19:02:42 2016 (r308147) +++ head/usr.bin/calendar/Makefile Mon Oct 31 20:31:56 2016 (r308148) @@ -15,20 +15,22 @@ FR_LINKS= fr_FR.ISO8859-15 TEXTMODE?= 444 beforeinstall: - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ + ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar .for lang in ${INTER} - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ + ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ ${.CURDIR}/calendars/${lang}/calendar.* \ ${DESTDIR}${SHAREDIR}/calendar/${lang} .endfor .for link in ${DE_LINKS} rm -rf ${DESTDIR}${SHAREDIR}/calendar/${link} - ln -s de_DE.ISO8859-1 ${DESTDIR}${SHAREDIR}/calendar/${link} + ${INSTALL} ${TAG_ARGS} -l s de_DE.ISO8859-1 \ + ${DESTDIR}${SHAREDIR}/calendar/${link} .endfor .for link in ${FR_LINKS} rm -rf ${DESTDIR}${SHAREDIR}/calendar/${link} - ln -s fr_FR.ISO8859-1 ${DESTDIR}${SHAREDIR}/calendar/${link} + ${INSTALL} ${TAG_ARGS} -l s fr_FR.ISO8859-1 \ + ${DESTDIR}${SHAREDIR}/calendar/${link} .endfor .if ${MK_TESTS} != "no" From owner-svn-src-head@freebsd.org Mon Oct 31 20:43:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61FB9C2846A; Mon, 31 Oct 2016 20:43:44 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3F04411E4; Mon, 31 Oct 2016 20:43:44 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VKhhhf073451; Mon, 31 Oct 2016 20:43:43 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VKhhMM073450; Mon, 31 Oct 2016 20:43:43 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610312043.u9VKhhMM073450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 31 Oct 2016 20:43:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308149 - head/sys/ufs/ffs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 20:43:44 -0000 Author: emaste Date: Mon Oct 31 20:43:43 2016 New Revision: 308149 URL: https://svnweb.freebsd.org/changeset/base/308149 Log: ANSIfy ffs_subr.c Also renumber license clause to avoid skipping #3 Modified: head/sys/ufs/ffs/ffs_subr.c Modified: head/sys/ufs/ffs/ffs_subr.c ============================================================================== --- head/sys/ufs/ffs/ffs_subr.c Mon Oct 31 20:31:56 2016 (r308148) +++ head/sys/ufs/ffs/ffs_subr.c Mon Oct 31 20:43:43 2016 (r308149) @@ -10,7 +10,7 @@ * 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. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -61,11 +61,7 @@ __FBSDID("$FreeBSD$"); * remaining space in the directory. */ int -ffs_blkatoff(vp, offset, res, bpp) - struct vnode *vp; - off_t offset; - char **res; - struct buf **bpp; +ffs_blkatoff(struct vnode *vp, off_t offset, char **res, struct buf **bpp) { struct inode *ip; struct fs *fs; @@ -95,11 +91,7 @@ ffs_blkatoff(vp, offset, res, bpp) * to the incore copy. */ void -ffs_load_inode(bp, ip, fs, ino) - struct buf *bp; - struct inode *ip; - struct fs *fs; - ino_t ino; +ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino) { if (I_IS_UFS1(ip)) { @@ -131,11 +123,7 @@ ffs_load_inode(bp, ip, fs, ino) * of some frags. */ void -ffs_fragacct(fs, fragmap, fraglist, cnt) - struct fs *fs; - int fragmap; - int32_t fraglist[]; - int cnt; +ffs_fragacct(struct fs *fs, int fragmap, int32_t fraglist[], int cnt) { int inblk; int field, subfield; @@ -167,10 +155,7 @@ ffs_fragacct(fs, fragmap, fraglist, cnt) * check if a block is available */ int -ffs_isblock(fs, cp, h) - struct fs *fs; - unsigned char *cp; - ufs1_daddr_t h; +ffs_isblock(struct fs *fs, unsigned char *cp, ufs1_daddr_t h) { unsigned char mask; @@ -199,10 +184,7 @@ ffs_isblock(fs, cp, h) * check if a block is free */ int -ffs_isfreeblock(fs, cp, h) - struct fs *fs; - u_char *cp; - ufs1_daddr_t h; +ffs_isfreeblock(struct fs *fs, u_char *cp, ufs1_daddr_t h) { switch ((int)fs->fs_frag) { @@ -227,10 +209,7 @@ ffs_isfreeblock(fs, cp, h) * take a block out of the map */ void -ffs_clrblock(fs, cp, h) - struct fs *fs; - u_char *cp; - ufs1_daddr_t h; +ffs_clrblock(struct fs *fs, u_char *cp, ufs1_daddr_t h) { switch ((int)fs->fs_frag) { @@ -258,10 +237,7 @@ ffs_clrblock(fs, cp, h) * put a block into the map */ void -ffs_setblock(fs, cp, h) - struct fs *fs; - unsigned char *cp; - ufs1_daddr_t h; +ffs_setblock(struct fs *fs, unsigned char *cp, ufs1_daddr_t h) { switch ((int)fs->fs_frag) { @@ -292,11 +268,7 @@ ffs_setblock(fs, cp, h) * Cnt == 1 means free; cnt == -1 means allocating. */ void -ffs_clusteracct(fs, cgp, blkno, cnt) - struct fs *fs; - struct cg *cgp; - ufs1_daddr_t blkno; - int cnt; +ffs_clusteracct(struct fs *fs, struct cg *cgp, ufs1_daddr_t blkno, int cnt) { int32_t *sump; int32_t *lp; From owner-svn-src-head@freebsd.org Mon Oct 31 21:11:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA232C28CB7; Mon, 31 Oct 2016 21:11:47 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ABFA415F5; Mon, 31 Oct 2016 21:11:47 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VLBkge084461; Mon, 31 Oct 2016 21:11:46 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VLBk6m084459; Mon, 31 Oct 2016 21:11:46 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610312111.u9VLBk6m084459@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 31 Oct 2016 21:11:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308150 - in head: etc share/examples X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 21:11:47 -0000 Author: gjb Date: Mon Oct 31 21:11:46 2016 New Revision: 308150 URL: https://svnweb.freebsd.org/changeset/base/308150 Log: Fix packaging /usr/share/examples/etc. Reported by: woodsb02 MFC after: 3 days X-MFC-With: r308148 Sponsored by: The FreeBSD Foundation Modified: head/etc/Makefile head/share/examples/Makefile Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Mon Oct 31 20:43:43 2016 (r308149) +++ head/etc/Makefile Mon Oct 31 21:11:46 2016 (r308150) @@ -459,7 +459,7 @@ distrib-dirs: ${MTREES:N/*} distrib-clea .endif etc-examples-install: ${META_DEPS} - cd ${.CURDIR}; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \ + cd ${.CURDIR}; ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 \ ${BIN1} ${BIN2} nsmb.conf opieaccess \ ${DESTDIR}${SHAREDIR}/examples/etc Modified: head/share/examples/Makefile ============================================================================== --- head/share/examples/Makefile Mon Oct 31 20:43:43 2016 (r308149) +++ head/share/examples/Makefile Mon Oct 31 21:11:46 2016 (r308150) @@ -250,7 +250,7 @@ copies: symlinks: .for i in ${LDIRS} rm -rf ${DESTDIR}${BINDIR}/$i - ln -s ${.CURDIR}/$i ${DESTDIR}${BINDIR}/$i + ${INSTALL} ${TAG_ARGS} -l s ${.CURDIR}/$i ${DESTDIR}${BINDIR}/$i .endfor etc-examples: From owner-svn-src-head@freebsd.org Mon Oct 31 23:09:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23C20C289B6; Mon, 31 Oct 2016 23:09:55 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3EF11663; Mon, 31 Oct 2016 23:09:54 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VN9sQV027975; Mon, 31 Oct 2016 23:09:54 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VN9qGk027956; Mon, 31 Oct 2016 23:09:52 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201610312309.u9VN9qGk027956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Mon, 31 Oct 2016 23:09:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308155 - in head/sys: amd64/conf cam cam/scsi conf dev/mps geom geom/part kern sys vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 23:09:55 -0000 Author: cem Date: Mon Oct 31 23:09:52 2016 New Revision: 308155 URL: https://svnweb.freebsd.org/changeset/base/308155 Log: Add BUF_TRACKING and FULL_BUF_TRACKING buffer debugging Upstream the BUF_TRACKING and FULL_BUF_TRACKING buffer debugging code. This can be handy in tracking down what code touched hung bios and bufs last. The full history is especially useful, but adds enough bloat that it shouldn't be enabled in release builds. Function names (or arbitrary string constants) are tracked in a fixed-size ring in bufs. Bios gain a pointer to the upper buf for tracking. SCSI CCBs gain a pointer to the upper bio for tracking. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8366 Modified: head/sys/amd64/conf/GENERIC head/sys/amd64/conf/GENERIC-NODEBUG head/sys/cam/cam_ccb.h head/sys/cam/cam_periph.c head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_da.c head/sys/conf/options head/sys/dev/mps/mps_sas.c head/sys/geom/geom_dev.c head/sys/geom/geom_disk.c head/sys/geom/geom_io.c head/sys/geom/geom_subr.c head/sys/geom/geom_vfs.c head/sys/geom/part/g_part.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_cluster.c head/sys/sys/bio.h head/sys/sys/buf.h head/sys/vm/vm_pager.c Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/amd64/conf/GENERIC Mon Oct 31 23:09:52 2016 (r308155) @@ -83,7 +83,9 @@ options RCTL # Resource limits options KDB # Enable kernel debugger support. options KDB_TRACE # Print a stack trace for a panic. # For full debugger support use (turn off in stable branch): +options BUF_TRACKING # Track buffer history options DDB # Support DDB. +options FULL_BUF_TRACKING # Track more buffer history options GDB # Support remote GDB. options DEADLKRES # Enable the deadlock resolver options INVARIANTS # Enable calls of extra sanity checking Modified: head/sys/amd64/conf/GENERIC-NODEBUG ============================================================================== --- head/sys/amd64/conf/GENERIC-NODEBUG Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/amd64/conf/GENERIC-NODEBUG Mon Oct 31 23:09:52 2016 (r308155) @@ -34,5 +34,7 @@ nooptions INVARIANTS nooptions INVARIANT_SUPPORT nooptions WITNESS nooptions WITNESS_SKIPSPIN +nooptions BUF_TRACKING nooptions DEADLKRES +nooptions FULL_BUF_TRACKING Modified: head/sys/cam/cam_ccb.h ============================================================================== --- head/sys/cam/cam_ccb.h Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/cam/cam_ccb.h Mon Oct 31 23:09:52 2016 (r308155) @@ -744,6 +744,9 @@ struct ccb_scsiio { #define CAM_TAG_ACTION_NONE 0x00 u_int tag_id; /* tag id from initator (target mode) */ u_int init_id; /* initiator id of who selected */ +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + struct bio *bio; /* Associated bio */ +#endif }; static __inline uint8_t * @@ -1335,6 +1338,9 @@ cam_fill_csio(struct ccb_scsiio *csio, u csio->sense_len = sense_len; csio->cdb_len = cdb_len; csio->tag_action = tag_action; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + csio->bio = NULL; +#endif } static __inline void Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/cam/cam_periph.c Mon Oct 31 23:09:52 2016 (r308155) @@ -1427,6 +1427,11 @@ camperiphscsisenseerror(union ccb *ccb, union ccb *orig_ccb = ccb; int error, recoveryccb; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->ccb_h.func_code == XPT_SCSI_IO && ccb->csio.bio != NULL) + biotrack(ccb->csio.bio, __func__); +#endif + periph = xpt_path_periph(ccb->ccb_h.path); recoveryccb = (ccb->ccb_h.cbfcnp == camperiphdone); if ((periph->flags & CAM_PERIPH_RECOVERY_INPROG) && !recoveryccb) { Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/cam/cam_xpt.c Mon Oct 31 23:09:52 2016 (r308155) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -4471,6 +4472,12 @@ xpt_done(union ccb *done_ccb) struct cam_doneq *queue; int run, hash; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (done_ccb->ccb_h.func_code == XPT_SCSI_IO && + done_ccb->csio.bio != NULL) + biotrack(done_ccb->csio.bio, __func__); +#endif + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done: func= %#x %s status %#x\n", done_ccb->ccb_h.func_code, @@ -5189,6 +5196,16 @@ xpt_done_process(struct ccb_hdr *ccb_h) struct cam_devq *devq; struct mtx *mtx = NULL; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + struct ccb_scsiio *csio; + + if (ccb_h->func_code == XPT_SCSI_IO) { + csio = &((union ccb *)ccb_h)->csio; + if (csio->bio != NULL) + biotrack(csio->bio, __func__); + } +#endif + if (ccb_h->flags & CAM_HIGH_POWER) { struct highpowerlist *hphead; struct cam_ed *device; Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/cam/scsi/scsi_da.c Mon Oct 31 23:09:52 2016 (r308155) @@ -2949,6 +2949,8 @@ more: void *data_ptr; int rw_op; + biotrack(bp, __func__); + if (bp->bio_cmd == BIO_WRITE) { softc->flags |= DA_FLAG_DIRTY; rw_op = SCSI_RW_WRITE; @@ -2976,6 +2978,9 @@ more: /*dxfer_len*/ bp->bio_bcount, /*sense_len*/SSD_FULL_SIZE, da_default_timeout * 1000); +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + start_ccb->csio.bio = bp; +#endif break; } case BIO_FLUSH: @@ -4008,6 +4013,10 @@ dadone(struct cam_periph *periph, union CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone\n")); csio = &done_ccb->csio; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (csio->bio != NULL) + biotrack(csio->bio, __func__); +#endif state = csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK; switch (state) { case DA_CCB_BUFFER_IO: @@ -4106,6 +4115,7 @@ dadone(struct cam_periph *periph, union } } + biotrack(bp, __func__); LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); if (LIST_EMPTY(&softc->pending_ccbs)) softc->flags |= DA_FLAG_WAS_OTAG; @@ -5219,6 +5229,11 @@ daerror(union ccb *ccb, u_int32_t cam_fl struct cam_periph *periph; int error, error_code, sense_key, asc, ascq; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->csio.bio != NULL) + biotrack(ccb->csio.bio, __func__); +#endif + periph = xpt_path_periph(ccb->ccb_h.path); softc = (struct da_softc *)periph->softc; Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/conf/options Mon Oct 31 23:09:52 2016 (r308155) @@ -50,12 +50,14 @@ TWA_FLASH_FIRMWARE opt_twa.h # Debugging options. ALT_BREAK_TO_DEBUGGER opt_kdb.h BREAK_TO_DEBUGGER opt_kdb.h +BUF_TRACKING opt_global.h DDB DDB_BUFR_SIZE opt_ddb.h DDB_CAPTURE_DEFAULTBUFSIZE opt_ddb.h DDB_CAPTURE_MAXBUFSIZE opt_ddb.h DDB_CTF opt_ddb.h DDB_NUMSYM opt_ddb.h +FULL_BUF_TRACKING opt_global.h GDB KDB opt_global.h KDB_TRACE opt_kdb.h Modified: head/sys/dev/mps/mps_sas.c ============================================================================== --- head/sys/dev/mps/mps_sas.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/dev/mps/mps_sas.c Mon Oct 31 23:09:52 2016 (r308155) @@ -1872,6 +1872,10 @@ mpssas_action_scsiio(struct mpssas_softc } } +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (csio->bio != NULL) + biotrack(csio->bio, __func__); +#endif callout_reset_sbt(&cm->cm_callout, SBT_1MS * ccb->ccb_h.timeout, 0, mpssas_scsiio_timeout, cm, 0); @@ -2125,6 +2129,11 @@ mpssas_scsiio_complete(struct mps_softc TAILQ_REMOVE(&cm->cm_targ->commands, cm, cm_link); ccb->ccb_h.status &= ~(CAM_STATUS_MASK | CAM_SIM_QUEUED); +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->csio.bio != NULL) + biotrack(ccb->csio.bio, __func__); +#endif + if (cm->cm_state == MPS_CM_STATE_TIMEDOUT) { TAILQ_REMOVE(&cm->cm_targ->timedout_commands, cm, cm_recovery); if (cm->cm_reply != NULL) Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/geom_dev.c Mon Oct 31 23:09:52 2016 (r308155) @@ -668,6 +668,7 @@ g_dev_strategy(struct bio *bp) sc = cp->private; KASSERT(cp->acr || cp->acw, ("Consumer with zero access count in g_dev_strategy")); + biotrack(bp, __func__); #ifdef INVARIANTS if ((bp->bio_offset % cp->provider->sectorsize) != 0 || (bp->bio_bcount % cp->provider->sectorsize) != 0) { Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/geom_disk.c Mon Oct 31 23:09:52 2016 (r308155) @@ -421,6 +421,8 @@ g_disk_start(struct bio *bp) int error; off_t off; + biotrack(bp, __func__); + sc = bp->bio_to->private; if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) { g_io_deliver(bp, ENXIO); Modified: head/sys/geom/geom_io.c ============================================================================== --- head/sys/geom/geom_io.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/geom_io.c Mon Oct 31 23:09:52 2016 (r308155) @@ -223,6 +223,9 @@ g_clone_bio(struct bio *bp) /* Inherit classification info from the parent */ bp2->bio_classifier1 = bp->bio_classifier1; bp2->bio_classifier2 = bp->bio_classifier2; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + bp2->bio_track_bp = bp->bio_track_bp; +#endif bp->bio_children++; } #ifdef KTR @@ -362,6 +365,8 @@ g_io_check(struct bio *bp) off_t excess; int error; + biotrack(bp, __func__); + cp = bp->bio_from; pp = bp->bio_to; @@ -503,6 +508,8 @@ g_run_classifiers(struct bio *bp) struct g_classifier_hook *hook; int classified = 0; + biotrack(bp, __func__); + TAILQ_FOREACH(hook, &g_classifier_tailq, link) classified |= hook->func(hook->arg, bp); @@ -518,6 +525,8 @@ g_io_request(struct bio *bp, struct g_co int direct, error, first; uint8_t cmd; + biotrack(bp, __func__); + KASSERT(cp != NULL, ("NULL cp in g_io_request")); KASSERT(bp != NULL, ("NULL bp in g_io_request")); pp = cp->provider; @@ -644,6 +653,8 @@ g_io_deliver(struct bio *bp, int error) struct mtx *mtxp; int direct, first; + biotrack(bp, __func__); + KASSERT(bp != NULL, ("NULL bp in g_io_deliver")); pp = bp->bio_to; KASSERT(pp != NULL, ("NULL bio_to in g_io_deliver")); @@ -835,6 +846,7 @@ g_io_schedule_down(struct thread *tp __u } CTR0(KTR_GEOM, "g_down has work to do"); g_bioq_unlock(&g_bio_run_down); + biotrack(bp, __func__); if (pace != 0) { /* * There has been at least one memory allocation Modified: head/sys/geom/geom_subr.c ============================================================================== --- head/sys/geom/geom_subr.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/geom_subr.c Mon Oct 31 23:09:52 2016 (r308155) @@ -1531,6 +1531,10 @@ DB_SHOW_COMMAND(bio, db_show_bio) db_printf(" caller2: %p\n", bp->bio_caller2); db_printf(" bio_from: %p\n", bp->bio_from); db_printf(" bio_to: %p\n", bp->bio_to); + +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + db_printf(" bio_track_bp: %p\n", bp->bio_track_bp); +#endif } } Modified: head/sys/geom/geom_vfs.c ============================================================================== --- head/sys/geom/geom_vfs.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/geom_vfs.c Mon Oct 31 23:09:52 2016 (r308155) @@ -192,6 +192,10 @@ g_vfs_strategy(struct bufobj *bo, struct } bip->bio_done = g_vfs_done; bip->bio_caller2 = bp; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + buf_track(bp, __func__); + bip->bio_track_bp = bp; +#endif g_io_request(bip, cp); } Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/geom/part/g_part.c Mon Oct 31 23:09:52 2016 (r308155) @@ -2154,6 +2154,8 @@ g_part_start(struct bio *bp) struct g_provider *pp; char buf[64]; + biotrack(bp, __func__); + pp = bp->bio_to; gp = pp->geom; table = gp->softc; Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/kern/vfs_bio.c Mon Oct 31 23:09:52 2016 (r308155) @@ -1952,6 +1952,7 @@ bufwrite(struct buf *bp) if (oldflags & B_ASYNC) BUF_KERNPROC(bp); bp->b_iooffset = dbtob(bp->b_blkno); + buf_track(bp, __func__); bstrategy(bp); if ((oldflags & B_ASYNC) == 0) { @@ -2078,6 +2079,8 @@ bdwrite(struct buf *bp) VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL); } + buf_track(bp, __func__); + /* * Set the *dirty* buffer range based upon the VM system dirty * pages. @@ -2386,6 +2389,8 @@ brelse(struct buf *bp) brelvp(bp); } + buf_track(bp, __func__); + /* buffers with no memory */ if (bp->b_bufsize == 0) { buf_free(bp); @@ -2470,6 +2475,7 @@ bqrelse(struct buf *bp) binsfree(bp, qindex); out: + buf_track(bp, __func__); /* unlock */ BUF_UNLOCK(bp); if (qindex == QUEUE_CLEAN) @@ -3716,6 +3722,7 @@ loop: CTR4(KTR_BUF, "getblk(%p, %ld, %d) = %p", vp, (long)blkno, size, bp); BUF_ASSERT_HELD(bp); end: + buf_track(bp, __func__); KASSERT(bp->b_bufobj == bo, ("bp %p wrong b_bufobj %p should be %p", bp, bp->b_bufobj, bo)); return (bp); @@ -3892,6 +3899,7 @@ biodone(struct bio *bp) void (*done)(struct bio *); vm_offset_t start, end; + biotrack(bp, __func__); if ((bp->bio_flags & BIO_TRANSIENT_MAPPING) != 0) { bp->bio_flags &= ~BIO_TRANSIENT_MAPPING; bp->bio_flags |= BIO_UNMAPPED; @@ -3948,6 +3956,15 @@ biofinish(struct bio *bp, struct devstat biodone(bp); } +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) +void +biotrack_buf(struct bio *bp, const char *location) +{ + + buf_track(bp->bio_track_bp, location); +} +#endif + /* * bufwait: * @@ -3998,6 +4015,7 @@ bufdone(struct buf *bp) struct bufobj *dropobj; void (*biodone)(struct buf *); + buf_track(bp, __func__); CTR3(KTR_BUF, "bufdone(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); dropobj = NULL; @@ -4801,6 +4819,9 @@ DB_SHOW_COMMAND(buffer, db_show_buffer) { /* get args */ struct buf *bp = (struct buf *)addr; +#ifdef FULL_BUF_TRACKING + uint32_t i, j; +#endif if (!have_addr) { db_printf("usage: show buffer \n"); @@ -4837,6 +4858,16 @@ DB_SHOW_COMMAND(buffer, db_show_buffer) } db_printf("\n"); } +#if defined(FULL_BUF_TRACKING) + db_printf("b_io_tracking: b_io_tcnt = %u\n", bp->b_io_tcnt); + + i = bp->b_io_tcnt % BUF_TRACKING_SIZE; + for (j = 1; j <= BUF_TRACKING_SIZE; j++) + db_printf(" %2u: %s\n", j, + bp->b_io_tracking[BUF_TRACKING_ENTRY(i - j)]); +#elif defined(BUF_TRACKING) + db_printf("b_io_tracking: %s\n", bp->b_io_tracking); +#endif db_printf(" "); BUF_LOCKPRINTINFO(bp); } Modified: head/sys/kern/vfs_cluster.c ============================================================================== --- head/sys/kern/vfs_cluster.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/kern/vfs_cluster.c Mon Oct 31 23:09:52 2016 (r308155) @@ -1008,6 +1008,7 @@ cluster_wbuild(struct vnode *vp, long si reassignbuf(tbp); /* put on clean list */ bufobj_wref(tbp->b_bufobj); BUF_KERNPROC(tbp); + buf_track(tbp, __func__); TAILQ_INSERT_TAIL(&bp->b_cluster.cluster_head, tbp, b_cluster.cluster_entry); } Modified: head/sys/sys/bio.h ============================================================================== --- head/sys/sys/bio.h Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/sys/bio.h Mon Oct 31 23:09:52 2016 (r308155) @@ -121,6 +121,9 @@ struct bio { void *_bio_caller2; uint8_t _bio_cflags; #endif +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + struct buf *bio_track_bp; /* Parent buf for tracking */ +#endif /* XXX: these go away when bio chaining is introduced */ daddr_t bio_pblkno; /* physical block number */ @@ -142,6 +145,23 @@ void biodone(struct bio *bp); void biofinish(struct bio *bp, struct devstat *stat, int error); int biowait(struct bio *bp, const char *wchan); +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) +void biotrack_buf(struct bio *bp, const char *location); + +static __inline void +biotrack(struct bio *bp, const char *location) +{ + + if (bp->bio_track_bp != NULL) + biotrack_buf(bp, location); +} +#else +static __inline void +biotrack(struct bio *bp __unused, const char *location __unused) +{ +} +#endif + void bioq_disksort(struct bio_queue_head *ap, struct bio *bp); struct bio *bioq_first(struct bio_queue_head *head); struct bio *bioq_takefirst(struct bio_queue_head *head); Modified: head/sys/sys/buf.h ============================================================================== --- head/sys/sys/buf.h Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/sys/buf.h Mon Oct 31 23:09:52 2016 (r308155) @@ -140,6 +140,15 @@ struct buf { void *b_fsprivate1; void *b_fsprivate2; void *b_fsprivate3; + +#if defined(FULL_BUF_TRACKING) +#define BUF_TRACKING_SIZE 32 +#define BUF_TRACKING_ENTRY(x) ((x) & (BUF_TRACKING_SIZE - 1)) + const char *b_io_tracking[BUF_TRACKING_SIZE]; + uint32_t b_io_tcnt; +#elif defined(BUF_TRACKING) + const char *b_io_tracking; +#endif }; #define b_object b_bufobj->bo_object @@ -429,6 +438,17 @@ buf_countdeps(struct buf *bp, int i) return (0); } +static __inline void +buf_track(struct buf *bp, const char *location) +{ + +#if defined(FULL_BUF_TRACKING) + bp->b_io_tracking[BUF_TRACKING_ENTRY(bp->b_io_tcnt++)] = location; +#elif defined(BUF_TRACKING) + bp->b_io_tracking = location; +#endif +} + #endif /* _KERNEL */ /* Modified: head/sys/vm/vm_pager.c ============================================================================== --- head/sys/vm/vm_pager.c Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/vm/vm_pager.c Mon Oct 31 23:09:52 2016 (r308155) @@ -376,6 +376,7 @@ initpbuf(struct buf *bp) bp->b_iodone = NULL; bp->b_error = 0; BUF_LOCK(bp, LK_EXCLUSIVE, NULL); + buf_track(bp, __func__); } /* @@ -473,6 +474,7 @@ relpbuf(struct buf *bp, int *pfreecnt) KASSERT(bp->b_vp == NULL, ("relpbuf with vp")); KASSERT(bp->b_bufobj == NULL, ("relpbuf with bufobj")); + buf_track(bp, __func__); BUF_UNLOCK(bp); mtx_lock(&pbuf_mtx); From owner-svn-src-head@freebsd.org Mon Oct 31 23:13:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B373CC28C00; Mon, 31 Oct 2016 23:13:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 858A11AD5; Mon, 31 Oct 2016 23:13:10 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VND9cW031471; Mon, 31 Oct 2016 23:13:09 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VND9EW031470; Mon, 31 Oct 2016 23:13:09 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610312313.u9VND9EW031470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 31 Oct 2016 23:13:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308156 - head/gnu/lib/libgcc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 23:13:10 -0000 Author: gjb Date: Mon Oct 31 23:13:09 2016 New Revision: 308156 URL: https://svnweb.freebsd.org/changeset/base/308156 Log: Fix packaging /usr/lib{,32}/libgcc_eh{,_p}.a. Reported by: woodsb02 MFC after: 3 days Sponsored by: The FreeBSD Foundation Modified: head/gnu/lib/libgcc/Makefile Modified: head/gnu/lib/libgcc/Makefile ============================================================================== --- head/gnu/lib/libgcc/Makefile Mon Oct 31 23:09:52 2016 (r308155) +++ head/gnu/lib/libgcc/Makefile Mon Oct 31 23:13:09 2016 (r308156) @@ -397,11 +397,11 @@ _libinstall: _lib-eh-install _lib-eh-install: .if ${MK_INSTALLLIB} != "no" - ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${TAG_ARGS} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR} .endif .if ${MK_PROFILE} != "no" - ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALL} ${TAG_ARGS} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR} .endif From owner-svn-src-head@freebsd.org Mon Oct 31 23:32:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA294C28367; Mon, 31 Oct 2016 23:32:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 893B615AC; Mon, 31 Oct 2016 23:32:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VNWcbh039133; Mon, 31 Oct 2016 23:32:38 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VNWcsG039132; Mon, 31 Oct 2016 23:32:38 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610312332.u9VNWcsG039132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 31 Oct 2016 23:32:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308157 - head/usr.sbin/cron/cron X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 23:32:39 -0000 Author: bapt Date: Mon Oct 31 23:32:38 2016 New Revision: 308157 URL: https://svnweb.freebsd.org/changeset/base/308157 Log: Fix typo in cron(8) date Reported by: jilles Modified: head/usr.sbin/cron/cron/cron.8 Modified: head/usr.sbin/cron/cron/cron.8 ============================================================================== --- head/usr.sbin/cron/cron/cron.8 Mon Oct 31 23:13:09 2016 (r308156) +++ head/usr.sbin/cron/cron/cron.8 Mon Oct 31 23:32:38 2016 (r308157) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Octobre 31, 2016 +.Dd October 31, 2016 .Dt CRON 8 .Os .Sh NAME From owner-svn-src-head@freebsd.org Mon Oct 31 23:40:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2EC8C2842F; Mon, 31 Oct 2016 23:40:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7794E1774; Mon, 31 Oct 2016 23:40:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VNe4LZ039447; Mon, 31 Oct 2016 23:40:04 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VNe4r3039446; Mon, 31 Oct 2016 23:40:04 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610312340.u9VNe4r3039446@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 31 Oct 2016 23:40:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308158 - head/usr.sbin/cron/cron X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 23:40:05 -0000 Author: bapt Date: Mon Oct 31 23:40:04 2016 New Revision: 308158 URL: https://svnweb.freebsd.org/changeset/base/308158 Log: Allow symlinks to be followed in cron.d directories and fix detection of regular files on NFS Reported by: jilles Modified: head/usr.sbin/cron/cron/database.c Modified: head/usr.sbin/cron/cron/database.c ============================================================================== --- head/usr.sbin/cron/cron/database.c Mon Oct 31 23:32:38 2016 (r308157) +++ head/usr.sbin/cron/cron/database.c Mon Oct 31 23:40:04 2016 (r308158) @@ -44,7 +44,7 @@ load_database(old_db) { DIR *dir; struct stat statbuf; - struct stat syscron_stat; + struct stat syscron_stat, st; time_t maxmtime; DIR_T *dp; cron_db new_db; @@ -124,7 +124,8 @@ load_database(old_db) while (NULL != (dp = readdir(dir))) { if (dp->d_name[0] == '.') continue; - if (dp->d_type != DT_REG) + if (fstatat(dirfd(dir), dp->d_name, &st, 0) == 0 && + !S_ISREG(st.st_mode)) continue; snprintf(tabname, sizeof(tabname), "%s/%s", syscrontabs[i].name, dp->d_name); From owner-svn-src-head@freebsd.org Tue Nov 1 00:02:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 49FD7C28AF7; Tue, 1 Nov 2016 00:02:54 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 282A71214; Tue, 1 Nov 2016 00:02:53 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id uA102kQE021220 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 31 Oct 2016 17:02:46 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id uA102kfl021219; Mon, 31 Oct 2016 17:02:46 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 31 Oct 2016 17:02:46 -0700 From: Gleb Smirnoff To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308026 - in head/sys: kern sys ufs/ffs Message-ID: <20161101000246.GQ27748@FreeBSD.org> References: <201610281143.u9SBhxrN008547@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201610281143.u9SBhxrN008547@repo.freebsd.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 00:02:54 -0000 Hi, On Fri, Oct 28, 2016 at 11:43:59AM +0000, Konstantin Belousov wrote: K> Author: kib K> Date: Fri Oct 28 11:43:59 2016 K> New Revision: 308026 K> URL: https://svnweb.freebsd.org/changeset/base/308026 K> K> Log: K> Generalize UFS buffer pager to allow it serving other filesystems K> which also use buffer cache. K> K> Most important addition to the code is the handling of filesystems K> where the block size is less than the machine page size, which might K> require reading several buffers to validate single page. K> K> Tested by: pho K> Sponsored by: The FreeBSD Foundation K> MFC after: 2 weeks K> K> Modified: K> head/sys/kern/vfs_bio.c K> head/sys/sys/buf.h K> head/sys/ufs/ffs/ffs_vnops.c K> K> Modified: head/sys/kern/vfs_bio.c K> ============================================================================== K> --- head/sys/kern/vfs_bio.c Fri Oct 28 11:35:06 2016 (r308025) K> +++ head/sys/kern/vfs_bio.c Fri Oct 28 11:43:59 2016 (r308026) K> @@ -75,9 +75,10 @@ __FBSDID("$FreeBSD$"); K> #include K> #include K> #include K> -#include K> -#include K> #include K> +#include K> +#include K> +#include K> #include K> #include K> #include K> @@ -4636,6 +4637,161 @@ bdata2bio(struct buf *bp, struct bio *bi K> } K> } K> K> +static int buf_pager_relbuf; K> +SYSCTL_INT(_vfs, OID_AUTO, buf_pager_relbuf, CTLFLAG_RWTUN, K> + &buf_pager_relbuf, 0, K> + "Make buffer pager release buffers after reading"); K> + K> +/* K> + * The buffer pager. It uses buffer reads to validate pages. K> + * K> + * In contrast to the generic local pager from vm/vnode_pager.c, this K> + * pager correctly and easily handles volumes where the underlying K> + * device block size is greater than the machine page size. The K> + * buffer cache transparently extends the requested page run to be K> + * aligned at the block boundary, and does the necessary bogus page K> + * replacements in the addends to avoid obliterating already valid K> + * pages. K> + * K> + * The only non-trivial issue is that the exclusive busy state for K> + * pages, which is assumed by the vm_pager_getpages() interface, is K> + * incompatible with the VMIO buffer cache's desire to share-busy the K> + * pages. This function performs a trivial downgrade of the pages' K> + * state before reading buffers, and a less trivial upgrade from the K> + * shared-busy to excl-busy state after the read. IMHO, should be noted that the pager ignores requested rbehind and rahead values, and does the rbehind and rahead sizes that he prefers. -- Totus tuus, Glebius. From owner-svn-src-head@freebsd.org Tue Nov 1 01:41:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00E0EC280B0; Tue, 1 Nov 2016 01:41:26 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C864E1C70; Tue, 1 Nov 2016 01:41:25 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA11fOLE086077; Tue, 1 Nov 2016 01:41:24 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA11fOPS086073; Tue, 1 Nov 2016 01:41:24 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201611010141.uA11fOPS086073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 1 Nov 2016 01:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308160 - in head: etc etc/mtree usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 01:41:26 -0000 Author: bapt Date: Tue Nov 1 01:41:24 2016 New Revision: 308160 URL: https://svnweb.freebsd.org/changeset/base/308160 Log: syslogd(8): add an 'include' keyword All the '.conf' files not beginning with a '.' contained int he directory following the keyword will be included. This keyword can only be used in the first level configuration files. Modify the default syslogd.conf to 'include' /etc/syslog.d and /usr/local/etc/syslog.d It simplify a lot handling of syslog from automation tools. Reviewed by: markj, kib (via irc) Approved by: markj MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D8402 Modified: head/etc/mtree/BSD.root.dist head/etc/syslog.conf head/usr.sbin/syslogd/syslog.conf.5 head/usr.sbin/syslogd/syslogd.c Modified: head/etc/mtree/BSD.root.dist ============================================================================== --- head/etc/mtree/BSD.root.dist Tue Nov 1 01:19:48 2016 (r308159) +++ head/etc/mtree/BSD.root.dist Tue Nov 1 01:41:24 2016 (r308160) @@ -78,6 +78,8 @@ .. ssl .. + syslog.d + .. zfs .. .. Modified: head/etc/syslog.conf ============================================================================== --- head/etc/syslog.conf Tue Nov 1 01:19:48 2016 (r308159) +++ head/etc/syslog.conf Tue Nov 1 01:41:24 2016 (r308160) @@ -34,3 +34,5 @@ cron.* /var/log/cron !ppp *.* /var/log/ppp.log !* +include /etc/syslog.d +include /usr/local/etc/syslog.d Modified: head/usr.sbin/syslogd/syslog.conf.5 ============================================================================== --- head/usr.sbin/syslogd/syslog.conf.5 Tue Nov 1 01:19:48 2016 (r308159) +++ head/usr.sbin/syslogd/syslog.conf.5 Tue Nov 1 01:41:24 2016 (r308160) @@ -28,7 +28,7 @@ .\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd September 12, 2012 +.Dd November 1, 2016 .Dt SYSLOG.CONF 5 .Os .Sh NAME @@ -62,6 +62,12 @@ field is separated from the .Em action field by one or more tab characters or spaces. .Pp +A special +.Em include +keyword can be used to include all files with names ending in '.conf' and not +beginning with a '.' contained in the directory following the keyword. +This keyword can only be used in the first level configuration file. +.Pp Note that if you use spaces as separators, your .Nm might be incompatible with other Unices or Unix-like systems. Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Tue Nov 1 01:19:48 2016 (r308159) +++ head/usr.sbin/syslogd/syslogd.c Tue Nov 1 01:41:24 2016 (r308160) @@ -95,6 +95,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -118,6 +119,8 @@ __FBSDID("$FreeBSD$"); const char *ConfFile = _PATH_LOGCONF; const char *PidFile = _PATH_LOGPID; const char ctty[] = _PATH_CONSOLE; +static const char include_str[] = "include"; +static const char include_ext[] = ".conf"; #define dprintf if (Debug) printf @@ -1601,6 +1604,157 @@ die(int signo) exit(1); } +static int +configfiles(const struct dirent *dp) +{ + const char *p; + size_t ext_len; + + if (dp->d_name[0] == '.') + return (0); + + ext_len = sizeof(include_ext) -1; + + if (dp->d_namlen <= ext_len) + return (0); + + p = &dp->d_name[dp->d_namlen - ext_len]; + if (strcmp(p, include_ext) != 0) + return (0); + + return (1); +} + +static void +readconfigfile(FILE *cf, struct filed **nextp, int allow_includes) +{ + FILE *cf2; + struct filed *f; + struct dirent **ent; + char cline[LINE_MAX]; + char host[MAXHOSTNAMELEN]; + char prog[LINE_MAX]; + char file[MAXPATHLEN]; + char *p, *tmp; + int i, nents; + size_t include_len; + + /* + * Foreach line in the conf table, open that file. + */ + f = NULL; + include_len = sizeof(include_str) -1; + (void)strlcpy(host, "*", sizeof(host)); + (void)strlcpy(prog, "*", sizeof(prog)); + while (fgets(cline, sizeof(cline), cf) != NULL) { + /* + * check for end-of-section, comments, strip off trailing + * spaces and newline character. #!prog is treated specially: + * following lines apply only to that program. + */ + for (p = cline; isspace(*p); ++p) + continue; + if (*p == 0) + continue; + if (allow_includes && + strncmp(p, include_str, include_len) == 0 && + isspace(p[include_len])) { + p += include_len; + while (isspace(*p)) + p++; + tmp = p; + while (*tmp != '\0' && !isspace(*tmp)) + tmp++; + *tmp = '\0'; + dprintf("Trying to include files in '%s'\n", p); + nents = scandir(p, &ent, configfiles, alphasort); + if (nents == -1) { + dprintf("Unable to open '%s': %s\n", p, + strerror(errno)); + continue; + } + for (i = 0; i < nents; i++) { + if (snprintf(file, sizeof(file), "%s/%s", p, + ent[i]->d_name) >= (int)sizeof(file)) { + dprintf("ignoring path too long: " + "'%s/%s'\n", p, ent[i]->d_name); + free(ent[i]); + continue; + } + free(ent[i]); + cf2 = fopen(file, "r"); + if (cf2 == NULL) + continue; + dprintf("reading %s\n", file); + readconfigfile(cf2, nextp, 0); + fclose(cf2); + } + free(ent); + continue; + } + if (*p == '#') { + p++; + if (*p != '!' && *p != '+' && *p != '-') + continue; + } + if (*p == '+' || *p == '-') { + host[0] = *p++; + while (isspace(*p)) + p++; + if ((!*p) || (*p == '*')) { + (void)strlcpy(host, "*", sizeof(host)); + continue; + } + if (*p == '@') + p = LocalHostName; + for (i = 1; i < MAXHOSTNAMELEN - 1; i++) { + if (!isalnum(*p) && *p != '.' && *p != '-' + && *p != ',' && *p != ':' && *p != '%') + break; + host[i] = *p++; + } + host[i] = '\0'; + continue; + } + if (*p == '!') { + p++; + while (isspace(*p)) p++; + if ((!*p) || (*p == '*')) { + (void)strlcpy(prog, "*", sizeof(prog)); + continue; + } + for (i = 0; i < LINE_MAX - 1; i++) { + if (!isprint(p[i]) || isspace(p[i])) + break; + prog[i] = p[i]; + } + prog[i] = 0; + continue; + } + for (p = cline + 1; *p != '\0'; p++) { + if (*p != '#') + continue; + if (*(p - 1) == '\\') { + strcpy(p - 1, p); + p--; + continue; + } + *p = '\0'; + break; + } + for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) + cline[i] = '\0'; + f = (struct filed *)calloc(1, sizeof(*f)); + if (f == NULL) { + logerror("calloc"); + exit(1); + } + *nextp = f; + nextp = &f->f_next; + cfline(cline, f, prog, host); + } +} + /* * INIT -- Initialize syslogd from configuration table */ @@ -1611,9 +1765,6 @@ init(int signo) FILE *cf; struct filed *f, *next, **nextp; char *p; - char cline[LINE_MAX]; - char prog[LINE_MAX]; - char host[MAXHOSTNAMELEN]; char oldLocalHostName[MAXHOSTNAMELEN]; char hostMsg[2*MAXHOSTNAMELEN+40]; char bootfileMsg[LINE_MAX]; @@ -1684,7 +1835,6 @@ init(int signo) free((char *)f); } Files = NULL; - nextp = &Files; /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { @@ -1705,83 +1855,7 @@ init(int signo) return; } - /* - * Foreach line in the conf table, open that file. - */ - f = NULL; - (void)strlcpy(host, "*", sizeof(host)); - (void)strlcpy(prog, "*", sizeof(prog)); - while (fgets(cline, sizeof(cline), cf) != NULL) { - /* - * check for end-of-section, comments, strip off trailing - * spaces and newline character. #!prog is treated specially: - * following lines apply only to that program. - */ - for (p = cline; isspace(*p); ++p) - continue; - if (*p == 0) - continue; - if (*p == '#') { - p++; - if (*p != '!' && *p != '+' && *p != '-') - continue; - } - if (*p == '+' || *p == '-') { - host[0] = *p++; - while (isspace(*p)) - p++; - if ((!*p) || (*p == '*')) { - (void)strlcpy(host, "*", sizeof(host)); - continue; - } - if (*p == '@') - p = LocalHostName; - for (i = 1; i < MAXHOSTNAMELEN - 1; i++) { - if (!isalnum(*p) && *p != '.' && *p != '-' - && *p != ',' && *p != ':' && *p != '%') - break; - host[i] = *p++; - } - host[i] = '\0'; - continue; - } - if (*p == '!') { - p++; - while (isspace(*p)) p++; - if ((!*p) || (*p == '*')) { - (void)strlcpy(prog, "*", sizeof(prog)); - continue; - } - for (i = 0; i < LINE_MAX - 1; i++) { - if (!isprint(p[i]) || isspace(p[i])) - break; - prog[i] = p[i]; - } - prog[i] = 0; - continue; - } - for (p = cline + 1; *p != '\0'; p++) { - if (*p != '#') - continue; - if (*(p - 1) == '\\') { - strcpy(p - 1, p); - p--; - continue; - } - *p = '\0'; - break; - } - for (i = strlen(cline) - 1; i >= 0 && isspace(cline[i]); i--) - cline[i] = '\0'; - f = (struct filed *)calloc(1, sizeof(*f)); - if (f == NULL) { - logerror("calloc"); - exit(1); - } - *nextp = f; - nextp = &f->f_next; - cfline(cline, f, prog, host); - } + readconfigfile(cf, &Files, 1); /* close the configuration file */ (void)fclose(cf); From owner-svn-src-head@freebsd.org Tue Nov 1 03:49:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9CA9C27925; Tue, 1 Nov 2016 03:49:32 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA8A51F28; Tue, 1 Nov 2016 03:49:32 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA13nVjc035871; Tue, 1 Nov 2016 03:49:31 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA13nVUO035870; Tue, 1 Nov 2016 03:49:31 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201611010349.uA13nVUO035870@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Tue, 1 Nov 2016 03:49:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308161 - head/sys/dev/bhnd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 03:49:33 -0000 Author: lwhsu (ports committer) Date: Tue Nov 1 03:49:31 2016 New Revision: 308161 URL: https://svnweb.freebsd.org/changeset/base/308161 Log: - Fix `make` in sys/modules/bhnd Reviewed by: landonf, imp Differential Revision: https://reviews.freebsd.org/D8385 Modified: head/sys/dev/bhnd/bhnd_debug.h Modified: head/sys/dev/bhnd/bhnd_debug.h ============================================================================== --- head/sys/dev/bhnd/bhnd_debug.h Tue Nov 1 01:41:24 2016 (r308160) +++ head/sys/dev/bhnd/bhnd_debug.h Tue Nov 1 03:49:31 2016 (r308161) @@ -70,8 +70,6 @@ #include -#include "opt_global.h" - #define BHND_ERROR_LEVEL 0x00 #define BHND_ERROR_MSG "ERROR" #define BHND_WARN_LEVEL 0x10 From owner-svn-src-head@freebsd.org Tue Nov 1 04:44:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46C2AC29ABF; Tue, 1 Nov 2016 04:44:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A13F12AE; Tue, 1 Nov 2016 04:44:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA14iBFB058657; Tue, 1 Nov 2016 04:44:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA14iBrR058656; Tue, 1 Nov 2016 04:44:11 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010444.uA14iBrR058656@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 04:44:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308162 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 04:44:12 -0000 Author: sephe Date: Tue Nov 1 04:44:11 2016 New Revision: 308162 URL: https://svnweb.freebsd.org/changeset/base/308162 Log: hyperv/hn: Cosmetic cleanup; no functional changes. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8389 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Nov 1 03:49:31 2016 (r308161) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Nov 1 04:44:11 2016 (r308162) @@ -59,62 +59,41 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include -#include -#include +#include +#include #include -#include #include +#include #include -#include -#include #include #include -#include #include +#include +#include +#include #include -#include +#include #include +#include -#include -#include +#include +#include + +#include #include -#include +#include #include -#include -#include - -#include #include -#include +#include +#include #include #include #include -#include +#include #include #include #include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include #include #include @@ -129,24 +108,11 @@ __FBSDID("$FreeBSD$"); #include "vmbus_if.h" -/* Short for Hyper-V network interface */ -#define NETVSC_DEVNAME "hn" - -/* - * It looks like offset 0 of buf is reserved to hold the softc pointer. - * The sc pointer evidently not needed, and is not presently populated. - * The packet offset is where the netvsc_packet starts in the buffer. - */ -#define HV_NV_SC_PTR_OFFSET_IN_BUF 0 -#define HV_NV_PACKET_OFFSET_IN_BUF 16 +#define HN_RING_CNT_DEF_MAX 8 /* YYY should get it from the underlying channel */ #define HN_TX_DESC_CNT 512 -#define HN_LROENT_CNT_DEF 128 - -#define HN_RING_CNT_DEF_MAX 8 - #define HN_RNDIS_PKT_LEN \ (sizeof(struct rndis_packet_msg) + \ HN_RNDIS_PKTINFO_SIZE(HN_NDIS_HASH_VALUE_SIZE) + \ @@ -166,50 +132,9 @@ __FBSDID("$FreeBSD$"); #define HN_EARLY_TXEOF_THRESH 8 -#define HN_RXINFO_VLAN 0x0001 -#define HN_RXINFO_CSUM 0x0002 -#define HN_RXINFO_HASHINF 0x0004 -#define HN_RXINFO_HASHVAL 0x0008 -#define HN_RXINFO_ALL \ - (HN_RXINFO_VLAN | \ - HN_RXINFO_CSUM | \ - HN_RXINFO_HASHINF | \ - HN_RXINFO_HASHVAL) - #define HN_PKTBUF_LEN_DEF (16 * 1024) -struct hn_txdesc { -#ifndef HN_USE_TXDESC_BUFRING - SLIST_ENTRY(hn_txdesc) link; -#endif - struct mbuf *m; - struct hn_tx_ring *txr; - int refs; - uint32_t flags; /* HN_TXD_FLAG_ */ - struct hn_nvs_sendctx send_ctx; - uint32_t chim_index; - int chim_size; - - bus_dmamap_t data_dmap; - - bus_addr_t rndis_pkt_paddr; - struct rndis_packet_msg *rndis_pkt; - bus_dmamap_t rndis_pkt_dmap; -}; - -#define HN_TXD_FLAG_ONLIST 0x1 -#define HN_TXD_FLAG_DMAMAP 0x2 - -#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff -#define HN_NDIS_RXCSUM_INFO_INVALID 0 -#define HN_NDIS_HASH_INFO_INVALID 0 - -struct hn_rxinfo { - uint32_t vlan_info; - uint32_t csum_info; - uint32_t hash_info; - uint32_t hash_value; -}; +#define HN_LROENT_CNT_DEF 128 #define HN_LRO_LENLIM_MULTIRX_DEF (12 * ETHERMTU) #define HN_LRO_LENLIM_DEF (25 * ETHERMTU) @@ -220,8 +145,8 @@ struct hn_rxinfo { #define HN_LOCK_INIT(sc) \ sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) -#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) #define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) +#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) #define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) #define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) @@ -232,199 +157,276 @@ struct hn_rxinfo { #define HN_CSUM_IP6_HWASSIST(sc) \ ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) -/* - * Globals - */ +struct hn_txdesc { +#ifndef HN_USE_TXDESC_BUFRING + SLIST_ENTRY(hn_txdesc) link; +#endif + struct mbuf *m; + struct hn_tx_ring *txr; + int refs; + uint32_t flags; /* HN_TXD_FLAG_ */ + struct hn_nvs_sendctx send_ctx; + uint32_t chim_index; + int chim_size; + + bus_dmamap_t data_dmap; + + bus_addr_t rndis_pkt_paddr; + struct rndis_packet_msg *rndis_pkt; + bus_dmamap_t rndis_pkt_dmap; +}; + +#define HN_TXD_FLAG_ONLIST 0x0001 +#define HN_TXD_FLAG_DMAMAP 0x0002 + +struct hn_rxinfo { + uint32_t vlan_info; + uint32_t csum_info; + uint32_t hash_info; + uint32_t hash_value; +}; + +#define HN_RXINFO_VLAN 0x0001 +#define HN_RXINFO_CSUM 0x0002 +#define HN_RXINFO_HASHINF 0x0004 +#define HN_RXINFO_HASHVAL 0x0008 +#define HN_RXINFO_ALL \ + (HN_RXINFO_VLAN | \ + HN_RXINFO_CSUM | \ + HN_RXINFO_HASHINF | \ + HN_RXINFO_HASHVAL) + +#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff +#define HN_NDIS_RXCSUM_INFO_INVALID 0 +#define HN_NDIS_HASH_INFO_INVALID 0 + +static int hn_probe(device_t); +static int hn_attach(device_t); +static int hn_detach(device_t); +static int hn_shutdown(device_t); +static void hn_chan_callback(struct vmbus_channel *, + void *); + +static void hn_init(void *); +static int hn_ioctl(struct ifnet *, u_long, caddr_t); +static void hn_start(struct ifnet *); +static int hn_transmit(struct ifnet *, struct mbuf *); +static void hn_xmit_qflush(struct ifnet *); +static int hn_ifmedia_upd(struct ifnet *); +static void hn_ifmedia_sts(struct ifnet *, + struct ifmediareq *); + +static int hn_rndis_rxinfo(const void *, int, + struct hn_rxinfo *); +static void hn_rndis_rx_data(struct hn_rx_ring *, + const void *, int); +static void hn_rndis_rx_status(struct hn_softc *, + const void *, int); + +static void hn_nvs_handle_notify(struct hn_softc *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_handle_comp(struct hn_softc *, + struct vmbus_channel *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_handle_rxbuf(struct hn_rx_ring *, + struct vmbus_channel *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_ack_rxbuf(struct hn_rx_ring *, + struct vmbus_channel *, uint64_t); + +#if __FreeBSD_version >= 1100099 +static int hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); +#if __FreeBSD_version < 1100095 +static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); +#else +static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS); + +static void hn_stop(struct hn_softc *); +static void hn_init_locked(struct hn_softc *); +static int hn_chan_attach(struct hn_softc *, + struct vmbus_channel *); +static void hn_chan_detach(struct hn_softc *, + struct vmbus_channel *); +static int hn_attach_subchans(struct hn_softc *); +static void hn_detach_allchans(struct hn_softc *); +static void hn_chan_rollup(struct hn_rx_ring *, + struct hn_tx_ring *); +static void hn_set_ring_inuse(struct hn_softc *, int); +static int hn_synth_attach(struct hn_softc *, int); +static void hn_synth_detach(struct hn_softc *); +static int hn_synth_alloc_subchans(struct hn_softc *, + int *); +static void hn_suspend(struct hn_softc *); +static void hn_suspend_data(struct hn_softc *); +static void hn_suspend_mgmt(struct hn_softc *); +static void hn_resume(struct hn_softc *); +static void hn_resume_data(struct hn_softc *); +static void hn_resume_mgmt(struct hn_softc *); +static void hn_suspend_mgmt_taskfunc(void *, int); +static void hn_chan_drain(struct vmbus_channel *); + +static void hn_update_link_status(struct hn_softc *); +static void hn_change_network(struct hn_softc *); +static void hn_link_taskfunc(void *, int); +static void hn_netchg_init_taskfunc(void *, int); +static void hn_netchg_status_taskfunc(void *, int); +static void hn_link_status(struct hn_softc *); + +static int hn_create_rx_data(struct hn_softc *, int); +static void hn_destroy_rx_data(struct hn_softc *); +static int hn_check_iplen(const struct mbuf *, int); +static int hn_set_rxfilter(struct hn_softc *); +static int hn_rss_reconfig(struct hn_softc *); +static void hn_rss_ind_fixup(struct hn_softc *, int); +static int hn_rxpkt(struct hn_rx_ring *, const void *, + int, const struct hn_rxinfo *); + +static int hn_tx_ring_create(struct hn_softc *, int); +static void hn_tx_ring_destroy(struct hn_tx_ring *); +static int hn_create_tx_data(struct hn_softc *, int); +static void hn_fixup_tx_data(struct hn_softc *); +static void hn_destroy_tx_data(struct hn_softc *); +static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); +static int hn_encap(struct hn_tx_ring *, + struct hn_txdesc *, struct mbuf **); +static int hn_txpkt(struct ifnet *, struct hn_tx_ring *, + struct hn_txdesc *); +static void hn_set_chim_size(struct hn_softc *, int); +static void hn_set_tso_maxsize(struct hn_softc *, int, int); +static bool hn_tx_ring_pending(struct hn_tx_ring *); +static void hn_tx_ring_qflush(struct hn_tx_ring *); +static void hn_resume_tx(struct hn_softc *, int); +static int hn_get_txswq_depth(const struct hn_tx_ring *); +static void hn_txpkt_done(struct hn_nvs_sendctx *, + struct hn_softc *, struct vmbus_channel *, + const void *, int); +static int hn_txpkt_sglist(struct hn_tx_ring *, + struct hn_txdesc *); +static int hn_txpkt_chim(struct hn_tx_ring *, + struct hn_txdesc *); +static int hn_xmit(struct hn_tx_ring *, int); +static void hn_xmit_taskfunc(void *, int); +static void hn_xmit_txeof(struct hn_tx_ring *); +static void hn_xmit_txeof_taskfunc(void *, int); +static int hn_start_locked(struct hn_tx_ring *, int); +static void hn_start_taskfunc(void *, int); +static void hn_start_txeof(struct hn_tx_ring *); +static void hn_start_txeof_taskfunc(void *, int); SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Hyper-V network interface"); /* Trust tcp segements verification on host side. */ -static int hn_trust_hosttcp = 1; +static int hn_trust_hosttcp = 1; SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosttcp, CTLFLAG_RDTUN, &hn_trust_hosttcp, 0, "Trust tcp segement verification on host side, " "when csum info is missing (global setting)"); /* Trust udp datagrams verification on host side. */ -static int hn_trust_hostudp = 1; +static int hn_trust_hostudp = 1; SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostudp, CTLFLAG_RDTUN, &hn_trust_hostudp, 0, "Trust udp datagram verification on host side, " "when csum info is missing (global setting)"); /* Trust ip packets verification on host side. */ -static int hn_trust_hostip = 1; +static int hn_trust_hostip = 1; SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostip, CTLFLAG_RDTUN, &hn_trust_hostip, 0, "Trust ip packet verification on host side, " "when csum info is missing (global setting)"); /* Limit TSO burst size */ -static int hn_tso_maxlen = IP_MAXPACKET; +static int hn_tso_maxlen = IP_MAXPACKET; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); /* Limit chimney send size */ -static int hn_tx_chimney_size = 0; +static int hn_tx_chimney_size = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_chimney_size, CTLFLAG_RDTUN, &hn_tx_chimney_size, 0, "Chimney send packet size limit"); /* Limit the size of packet for direct transmission */ -static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; +static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; SYSCTL_INT(_hw_hn, OID_AUTO, direct_tx_size, CTLFLAG_RDTUN, &hn_direct_tx_size, 0, "Size of the packet for direct transmission"); +/* # of LRO entries per RX ring */ #if defined(INET) || defined(INET6) #if __FreeBSD_version >= 1100095 -static int hn_lro_entry_count = HN_LROENT_CNT_DEF; +static int hn_lro_entry_count = HN_LROENT_CNT_DEF; SYSCTL_INT(_hw_hn, OID_AUTO, lro_entry_count, CTLFLAG_RDTUN, &hn_lro_entry_count, 0, "LRO entry count"); #endif #endif -static int hn_share_tx_taskq = 0; +/* Use shared TX taskqueue */ +static int hn_share_tx_taskq = 0; SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_taskq, CTLFLAG_RDTUN, &hn_share_tx_taskq, 0, "Enable shared TX taskqueue"); -static struct taskqueue *hn_tx_taskq; - #ifndef HN_USE_TXDESC_BUFRING -static int hn_use_txdesc_bufring = 0; +static int hn_use_txdesc_bufring = 0; #else -static int hn_use_txdesc_bufring = 1; +static int hn_use_txdesc_bufring = 1; #endif SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD, &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors"); -static int hn_bind_tx_taskq = -1; +/* Bind TX taskqueue to the target CPU */ +static int hn_bind_tx_taskq = -1; SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); -static int hn_use_if_start = 0; +/* Use ifnet.if_start instead of ifnet.if_transmit */ +static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); -static int hn_chan_cnt = 0; +/* # of channels to use */ +static int hn_chan_cnt = 0; SYSCTL_INT(_hw_hn, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, &hn_chan_cnt, 0, "# of channels to use; each channel has one RX ring and one TX ring"); -static int hn_tx_ring_cnt = 0; +/* # of transmit rings to use */ +static int hn_tx_ring_cnt = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_ring_cnt, CTLFLAG_RDTUN, &hn_tx_ring_cnt, 0, "# of TX rings to use"); -static int hn_tx_swq_depth = 0; +/* Software TX ring deptch */ +static int hn_tx_swq_depth = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_swq_depth, CTLFLAG_RDTUN, &hn_tx_swq_depth, 0, "Depth of IFQ or BUFRING"); +/* Enable sorted LRO, and the depth of the per-channel mbuf queue */ #if __FreeBSD_version >= 1100095 -static u_int hn_lro_mbufq_depth = 0; +static u_int hn_lro_mbufq_depth = 0; SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); #endif -static u_int hn_cpu_index; - -/* - * Forward declarations - */ -static void hn_stop(struct hn_softc *sc); -static void hn_init_locked(struct hn_softc *sc); -static void hn_init(void *xsc); -static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static int hn_start_locked(struct hn_tx_ring *txr, int len); -static void hn_start(struct ifnet *ifp); -static void hn_start_txeof(struct hn_tx_ring *); -static int hn_ifmedia_upd(struct ifnet *ifp); -static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); -#if __FreeBSD_version >= 1100099 -static int hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); -#endif -static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); -#if __FreeBSD_version < 1100095 -static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); -#else -static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); -#endif -static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_check_iplen(const struct mbuf *, int); -static int hn_create_tx_ring(struct hn_softc *, int); -static void hn_destroy_tx_ring(struct hn_tx_ring *); -static int hn_create_tx_data(struct hn_softc *, int); -static void hn_fixup_tx_data(struct hn_softc *); -static void hn_destroy_tx_data(struct hn_softc *); -static void hn_start_taskfunc(void *, int); -static void hn_start_txeof_taskfunc(void *, int); -static void hn_link_taskfunc(void *, int); -static void hn_netchg_init_taskfunc(void *, int); -static void hn_netchg_status_taskfunc(void *, int); -static void hn_suspend_mgmt_taskfunc(void *, int); -static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); -static int hn_create_rx_data(struct hn_softc *sc, int); -static void hn_destroy_rx_data(struct hn_softc *sc); -static void hn_set_chim_size(struct hn_softc *, int); -static void hn_set_tso_maxsize(struct hn_softc *, int, int); -static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); -static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); -static int hn_attach_subchans(struct hn_softc *); -static void hn_detach_allchans(struct hn_softc *); -static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); -static void hn_chan_rollup(struct hn_rx_ring *, struct hn_tx_ring *); -static void hn_set_ring_inuse(struct hn_softc *, int); -static int hn_synth_attach(struct hn_softc *, int); -static void hn_synth_detach(struct hn_softc *); -static bool hn_tx_ring_pending(struct hn_tx_ring *); -static void hn_suspend(struct hn_softc *); -static void hn_suspend_data(struct hn_softc *); -static void hn_suspend_mgmt(struct hn_softc *); -static void hn_resume(struct hn_softc *); -static void hn_resume_data(struct hn_softc *); -static void hn_resume_mgmt(struct hn_softc *); -static void hn_rx_drain(struct vmbus_channel *); -static void hn_tx_resume(struct hn_softc *, int); -static void hn_tx_ring_qflush(struct hn_tx_ring *); -static int netvsc_detach(device_t dev); -static void hn_link_status(struct hn_softc *); -static int hn_sendpkt_rndis_sglist(struct hn_tx_ring *, struct hn_txdesc *); -static int hn_sendpkt_rndis_chim(struct hn_tx_ring *, struct hn_txdesc *); -static int hn_set_rxfilter(struct hn_softc *); -static void hn_link_status_update(struct hn_softc *); -static void hn_network_change(struct hn_softc *); - -static int hn_rndis_rxinfo(const void *, int, struct hn_rxinfo *); -static void hn_rndis_rx_data(struct hn_rx_ring *, const void *, int); -static void hn_rndis_rx_status(struct hn_softc *, const void *, int); - -static void hn_nvs_handle_notify(struct hn_softc *sc, - const struct vmbus_chanpkt_hdr *pkt); -static void hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkt); -static void hn_nvs_handle_rxbuf(struct hn_rx_ring *rxr, - struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkthdr); -static void hn_nvs_ack_rxbuf(struct hn_rx_ring *, struct vmbus_channel *, - uint64_t); - -static int hn_transmit(struct ifnet *, struct mbuf *); -static void hn_xmit_qflush(struct ifnet *); -static int hn_xmit(struct hn_tx_ring *, int); -static void hn_xmit_txeof(struct hn_tx_ring *); -static void hn_xmit_taskfunc(void *, int); -static void hn_xmit_txeof_taskfunc(void *, int); +static u_int hn_cpu_index; /* next CPU for channel */ +static struct taskqueue *hn_tx_taskq; /* shared TX taskqueue */ -static const uint8_t hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { +static const uint8_t +hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, @@ -432,6 +434,27 @@ static const uint8_t hn_rss_key_default[ 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa }; +static device_method_t hn_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, hn_probe), + DEVMETHOD(device_attach, hn_attach), + DEVMETHOD(device_detach, hn_detach), + DEVMETHOD(device_shutdown, hn_shutdown), + DEVMETHOD_END +}; + +static driver_t hn_driver = { + "hn", + hn_methods, + sizeof(struct hn_softc) +}; + +static devclass_t hn_devclass; + +DRIVER_MODULE(hn, vmbus, hn_driver, hn_devclass, 0, 0); +MODULE_VERSION(hn, 1); +MODULE_DEPEND(hn, vmbus, 1, 1, 1); + #if __FreeBSD_version >= 1100099 static void hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) @@ -444,7 +467,7 @@ hn_set_lro_lenlim(struct hn_softc *sc, i #endif static int -hn_sendpkt_rndis_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd) +hn_txpkt_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd) { KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID && @@ -454,7 +477,7 @@ hn_sendpkt_rndis_sglist(struct hn_tx_rin } static int -hn_sendpkt_rndis_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd) +hn_txpkt_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd) { struct hn_nvs_rndis rndis; @@ -653,13 +676,10 @@ static const struct hyperv_guid g_net_vs 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} }; -/* - * Standard probe entry point. - * - */ static int -netvsc_probe(device_t dev) +hn_probe(device_t dev) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &g_net_vsc_device_type) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); @@ -668,14 +688,8 @@ netvsc_probe(device_t dev) return ENXIO; } -/* - * Standard attach entry point. - * - * Called when the driver is loaded. It allocates needed resources, - * and initializes the "hardware" and software. - */ static int -netvsc_attach(device_t dev) +hn_attach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); struct sysctl_oid_list *child; @@ -917,18 +931,18 @@ netvsc_attach(device_t dev) * Kick off link status check. */ sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; - hn_link_status_update(sc); + hn_update_link_status(sc); return (0); failed: if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) hn_synth_detach(sc); - netvsc_detach(dev); + hn_detach(dev); return (error); } static int -netvsc_detach(device_t dev) +hn_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->hn_ifp; @@ -967,12 +981,10 @@ netvsc_detach(device_t dev) return (0); } -/* - * Standard shutdown entry point - */ static int -netvsc_shutdown(device_t dev) +hn_shutdown(device_t dev) { + return (0); } @@ -1037,7 +1049,7 @@ hn_netchg_status_taskfunc(void *xsc, int } static void -hn_link_status_update(struct hn_softc *sc) +hn_update_link_status(struct hn_softc *sc) { if (sc->hn_mgmt_taskq != NULL) @@ -1045,7 +1057,7 @@ hn_link_status_update(struct hn_softc *s } static void -hn_network_change(struct hn_softc *sc) +hn_change_network(struct hn_softc *sc) { if (sc->hn_mgmt_taskq != NULL) @@ -1197,7 +1209,7 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct hn_nvs_sendctx *sndc, struct hn_softc *sc, +hn_txpkt_done(struct hn_nvs_sendctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data __unused, int dlen __unused) { struct hn_txdesc *txd = sndc->hn_cbarg; @@ -1420,7 +1432,7 @@ hn_encap(struct hn_tx_ring *txr, struct txd->chim_size = pkt->rm_len; txr->hn_gpa_cnt = 0; txr->hn_tx_chimney++; - txr->hn_sendpkt = hn_sendpkt_rndis_chim; + txr->hn_sendpkt = hn_txpkt_chim; goto done; } } @@ -1467,12 +1479,12 @@ hn_encap(struct hn_tx_ring *txr, struct txd->chim_index = HN_NVS_CHIM_IDX_INVALID; txd->chim_size = 0; - txr->hn_sendpkt = hn_sendpkt_rndis_sglist; + txr->hn_sendpkt = hn_txpkt_sglist; done: txd->m = m_head; /* Set the completion routine */ - hn_nvs_sendctx_init(&txd->send_ctx, hn_tx_done, txd); + hn_nvs_sendctx_init(&txd->send_ctx, hn_txpkt_done, txd); return 0; } @@ -1483,7 +1495,7 @@ done: * associated w/ the txd will _not_ be freed. */ static int -hn_send_pkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) +hn_txpkt(struct ifnet *ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) { int error, send_failed = 0; @@ -1599,7 +1611,7 @@ hn_start_locked(struct hn_tx_ring *txr, continue; } - error = hn_send_pkt(ifp, txr, txd); + error = hn_txpkt(ifp, txr, txd); if (__predict_false(error)) { /* txd is freed, but m_head is not */ IFQ_DRV_PREPEND(&ifp->if_snd, m_head); @@ -2114,9 +2126,6 @@ hn_stop(struct hn_softc *sc) sc->hn_tx_ring[i].hn_oactive = 0; } -/* - * FreeBSD transmit entry point - */ static void hn_start(struct ifnet *ifp) { @@ -2195,7 +2204,7 @@ hn_init_locked(struct hn_softc *sc) sc->hn_tx_ring[i].hn_oactive = 0; /* Clear TX 'suspended' bit. */ - hn_tx_resume(sc, sc->hn_tx_ring_inuse); + hn_resume_tx(sc, sc->hn_tx_ring_inuse); /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); @@ -2211,20 +2220,6 @@ hn_init(void *xsc) HN_UNLOCK(sc); } -#ifdef LATER -/* - * - */ -static void -hn_watchdog(struct ifnet *ifp) -{ - - if_printf(ifp, "watchdog timeout -- resetting\n"); - hn_init(ifp->if_softc); /* XXX */ - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); -} -#endif - #if __FreeBSD_version >= 1100099 static int @@ -2906,7 +2901,7 @@ hn_destroy_rx_data(struct hn_softc *sc) } static int -hn_create_tx_ring(struct hn_softc *sc, int id) +hn_tx_ring_create(struct hn_softc *sc, int id) { struct hn_tx_ring *txr = &sc->hn_tx_ring[id]; device_t dev = sc->hn_dev; @@ -3103,7 +3098,7 @@ hn_txdesc_dmamap_destroy(struct hn_txdes } static void -hn_destroy_tx_ring(struct hn_tx_ring *txr) +hn_tx_ring_destroy(struct hn_tx_ring *txr) { struct hn_txdesc *txd; @@ -3179,7 +3174,7 @@ hn_create_tx_data(struct hn_softc *sc, i for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { int error; - error = hn_create_tx_ring(sc, i); + error = hn_tx_ring_create(sc, i); if (error) return error; } @@ -3325,7 +3320,7 @@ hn_destroy_tx_data(struct hn_softc *sc) return; for (i = 0; i < sc->hn_tx_ring_cnt; ++i) - hn_destroy_tx_ring(&sc->hn_tx_ring[i]); + hn_tx_ring_destroy(&sc->hn_tx_ring[i]); free(sc->hn_tx_ring, M_DEVBUF); sc->hn_tx_ring = NULL; @@ -3401,7 +3396,7 @@ hn_xmit(struct hn_tx_ring *txr, int len) continue; } - error = hn_send_pkt(ifp, txr, txd); + error = hn_txpkt(ifp, txr, txd); if (__predict_false(error)) { /* txd is freed, but m_head is not */ drbr_putback(ifp, txr->hn_mbuf_br, m_head); @@ -3924,7 +3919,7 @@ hn_set_ring_inuse(struct hn_softc *sc, i } static void -hn_rx_drain(struct vmbus_channel *chan) +hn_chan_drain(struct vmbus_channel *chan) { while (!vmbus_chan_rx_empty(chan) || !vmbus_chan_tx_empty(chan)) @@ -3979,9 +3974,9 @@ hn_suspend_data(struct hn_softc *sc) if (subch != NULL) { for (i = 0; i < nsubch; ++i) - hn_rx_drain(subch[i]); + hn_chan_drain(subch[i]); } - hn_rx_drain(sc->hn_prichan); + hn_chan_drain(sc->hn_prichan); if (subch != NULL) vmbus_subchan_rel(subch, nsubch); @@ -4026,7 +4021,7 @@ hn_suspend(struct hn_softc *sc) } static void -hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) +hn_resume_tx(struct hn_softc *sc, int tx_ring_cnt) { int i; @@ -4059,7 +4054,7 @@ hn_resume_data(struct hn_softc *sc) * since hn_tx_ring_inuse can be changed after * hn_suspend_data(). */ - hn_tx_resume(sc, sc->hn_tx_ring_cnt); + hn_resume_tx(sc, sc->hn_tx_ring_cnt); if (!hn_use_if_start) { /* @@ -4097,9 +4092,9 @@ hn_resume_mgmt(struct hn_softc *sc) * detection. */ if (sc->hn_link_flags & HN_LINK_FLAG_NETCHG) - hn_network_change(sc); + hn_change_network(sc); else - hn_link_status_update(sc); + hn_update_link_status(sc); } static void @@ -4126,7 +4121,7 @@ hn_rndis_rx_status(struct hn_softc *sc, switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: case RNDIS_STATUS_MEDIA_DISCONNECT: - hn_link_status_update(sc); + hn_update_link_status(sc); break; case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: @@ -4146,7 +4141,7 @@ hn_rndis_rx_status(struct hn_softc *sc, if_printf(sc->hn_ifp, "network changed, change %u\n", change); } - hn_network_change(sc); + hn_change_network(sc); break; default: @@ -4661,25 +4656,3 @@ hn_tx_taskq_destroy(void *arg __unused) } SYSUNINIT(hn_txtq_destroy, SI_SUB_DRIVERS, SI_ORDER_SECOND, hn_tx_taskq_destroy, NULL); - -static device_method_t netvsc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, netvsc_probe), - DEVMETHOD(device_attach, netvsc_attach), - DEVMETHOD(device_detach, netvsc_detach), - DEVMETHOD(device_shutdown, netvsc_shutdown), - - { 0, 0 } -}; - -static driver_t netvsc_driver = { - NETVSC_DEVNAME, - netvsc_methods, - sizeof(struct hn_softc) -}; - -static devclass_t netvsc_devclass; - -DRIVER_MODULE(hn, vmbus, netvsc_driver, netvsc_devclass, 0, 0); -MODULE_VERSION(hn, 1); -MODULE_DEPEND(hn, vmbus, 1, 1, 1); From owner-svn-src-head@freebsd.org Tue Nov 1 07:10:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15784C2A57C; Tue, 1 Nov 2016 07:10:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E310F1D6A; Tue, 1 Nov 2016 07:10:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA17AiDW011122; Tue, 1 Nov 2016 07:10:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA17Aid0011121; Tue, 1 Nov 2016 07:10:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010710.uA17Aid0011121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 07:10:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308164 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 07:10:45 -0000 Author: sephe Date: Tue Nov 1 07:10:43 2016 New Revision: 308164 URL: https://svnweb.freebsd.org/changeset/base/308164 Log: hyperv/hn: Regroup if_start related functions. And put them under HN_IFSTART_SUPPORT, which is by default on until we whack the if_start related bits from base system. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8392 Modified: head/sys/dev/hyperv/netvsc/if_hn.c Modified: head/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 06:54:25 2016 (r308163) +++ head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 07:10:43 2016 (r308164) @@ -108,6 +108,8 @@ __FBSDID("$FreeBSD$"); #include "vmbus_if.h" +#define HN_IFSTART_SUPPORT + #define HN_RING_CNT_DEF_MAX 8 /* YYY should get it from the underlying channel */ @@ -209,7 +211,9 @@ static void hn_chan_callback(struct vm static void hn_init(void *); static int hn_ioctl(struct ifnet *, u_long, caddr_t); +#ifdef HN_IFSTART_SUPPORT static void hn_start(struct ifnet *); +#endif static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); static int hn_ifmedia_upd(struct ifnet *); @@ -323,10 +327,12 @@ static int hn_xmit(struct hn_tx_ring * static void hn_xmit_taskfunc(void *, int); static void hn_xmit_txeof(struct hn_tx_ring *); static void hn_xmit_txeof_taskfunc(void *, int); +#ifdef HN_IFSTART_SUPPORT static int hn_start_locked(struct hn_tx_ring *, int); static void hn_start_taskfunc(void *, int); static void hn_start_txeof(struct hn_tx_ring *); static void hn_start_txeof_taskfunc(void *, int); +#endif SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Hyper-V network interface"); @@ -394,10 +400,12 @@ static int hn_bind_tx_taskq = -1; SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); +#ifdef HN_IFSTART_SUPPORT /* Use ifnet.if_start instead of ifnet.if_transmit */ static int hn_use_if_start = 0; SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, &hn_use_if_start, 0, "Use if_start TX method"); +#endif /* # of channels to use */ static int hn_chan_cnt = 0; @@ -773,10 +781,12 @@ hn_attach(device_t dev) tx_ring_cnt = hn_tx_ring_cnt; if (tx_ring_cnt <= 0 || tx_ring_cnt > ring_cnt) tx_ring_cnt = ring_cnt; +#ifdef HN_IFSTART_SUPPORT if (hn_use_if_start) { /* ifnet.if_start only needs one TX ring. */ tx_ring_cnt = 1; } +#endif /* * Set the leader CPU for channels. @@ -872,6 +882,7 @@ hn_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; ifp->if_init = hn_init; +#ifdef HN_IFSTART_SUPPORT if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -879,7 +890,9 @@ hn_attach(device_t dev) IFQ_SET_MAXLEN(&ifp->if_snd, qdepth); ifp->if_snd.ifq_drv_maxlen = qdepth - 1; IFQ_SET_READY(&ifp->if_snd); - } else { + } else +#endif + { ifp->if_transmit = hn_transmit; ifp->if_qflush = hn_xmit_qflush; } @@ -1508,7 +1521,10 @@ again: if (!error) { ETHER_BPF_MTAP(ifp, txd->m); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); - if (!hn_use_if_start) { +#ifdef HN_IFSTART_SUPPORT + if (!hn_use_if_start) +#endif + { if_inc_counter(ifp, IFCOUNTER_OBYTES, txd->m->m_pkthdr.len); if (txd->m->m_flags & M_MCAST) @@ -1558,71 +1574,6 @@ again: } /* - * Start a transmit of one or more packets - */ -static int -hn_start_locked(struct hn_tx_ring *txr, int len) -{ - struct hn_softc *sc = txr->hn_sc; - struct ifnet *ifp = sc->hn_ifp; - - KASSERT(hn_use_if_start, - ("hn_start_locked is called, when if_start is disabled")); - KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); - mtx_assert(&txr->hn_tx_lock, MA_OWNED); - - if (__predict_false(txr->hn_suspended)) - return 0; - - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING) - return 0; - - while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { - struct hn_txdesc *txd; - struct mbuf *m_head; - int error; - - IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); - if (m_head == NULL) - break; - - if (len > 0 && m_head->m_pkthdr.len > len) { - /* - * This sending could be time consuming; let callers - * dispatch this packet sending (and sending of any - * following up packets) to tx taskqueue. - */ - IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - return 1; - } - - txd = hn_txdesc_get(txr); - if (txd == NULL) { - txr->hn_no_txdescs++; - IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - break; - } - - error = hn_encap(txr, txd, &m_head); - if (error) { - /* Both txd and m_head are freed */ - continue; - } - - error = hn_txpkt(ifp, txr, txd); - if (__predict_false(error)) { - /* txd is freed, but m_head is not */ - IFQ_DRV_PREPEND(&ifp->if_snd, m_head); - atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - break; - } - } - return 0; -} - -/* * Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in * existing space. @@ -2127,61 +2078,6 @@ hn_stop(struct hn_softc *sc) } static void -hn_start(struct ifnet *ifp) -{ - struct hn_softc *sc = ifp->if_softc; - struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; - - if (txr->hn_sched_tx) - goto do_sched; - - if (mtx_trylock(&txr->hn_tx_lock)) { - int sched; - - sched = hn_start_locked(txr, txr->hn_direct_tx_size); - mtx_unlock(&txr->hn_tx_lock); - if (!sched) - return; - } -do_sched: - taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_tx_task); -} - -static void -hn_start_txeof(struct hn_tx_ring *txr) -{ - struct hn_softc *sc = txr->hn_sc; - struct ifnet *ifp = sc->hn_ifp; - - KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); - - if (txr->hn_sched_tx) - goto do_sched; - - if (mtx_trylock(&txr->hn_tx_lock)) { - int sched; - - atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - sched = hn_start_locked(txr, txr->hn_direct_tx_size); - mtx_unlock(&txr->hn_tx_lock); - if (sched) { - taskqueue_enqueue(txr->hn_tx_taskq, - &txr->hn_tx_task); - } - } else { -do_sched: - /* - * Release the OACTIVE earlier, with the hope, that - * others could catch up. The task will clear the - * flag again with the hn_tx_lock to avoid possible - * races. - */ - atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); - taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); - } -} - -static void hn_init_locked(struct hn_softc *sc) { struct ifnet *ifp = sc->hn_ifp; @@ -2928,11 +2824,14 @@ hn_tx_ring_create(struct hn_softc *sc, i txr->hn_tx_taskq = sc->hn_tx_taskq; +#ifdef HN_IFSTART_SUPPORT if (hn_use_if_start) { txr->hn_txeof = hn_start_txeof; TASK_INIT(&txr->hn_tx_task, 0, hn_start_taskfunc, txr); TASK_INIT(&txr->hn_txeof_task, 0, hn_start_txeof_taskfunc, txr); - } else { + } else +#endif + { int br_depth; txr->hn_txeof = hn_xmit_txeof; @@ -3069,7 +2968,10 @@ hn_tx_ring_create(struct hn_softc *sc, i SYSCTL_ADD_INT(ctx, child, OID_AUTO, "txdesc_avail", CTLFLAG_RD, &txr->hn_txdesc_avail, 0, "# of available TX descs"); - if (!hn_use_if_start) { +#ifdef HN_IFSTART_SUPPORT + if (!hn_use_if_start) +#endif + { SYSCTL_ADD_INT(ctx, child, OID_AUTO, "oactive", CTLFLAG_RD, &txr->hn_oactive, 0, "over active"); @@ -3329,6 +3231,8 @@ hn_destroy_tx_data(struct hn_softc *sc) sc->hn_tx_ring_inuse = 0; } +#ifdef HN_IFSTART_SUPPORT + static void hn_start_taskfunc(void *xtxr, int pending __unused) { @@ -3339,6 +3243,89 @@ hn_start_taskfunc(void *xtxr, int pendin mtx_unlock(&txr->hn_tx_lock); } +static int +hn_start_locked(struct hn_tx_ring *txr, int len) +{ + struct hn_softc *sc = txr->hn_sc; + struct ifnet *ifp = sc->hn_ifp; + + KASSERT(hn_use_if_start, + ("hn_start_locked is called, when if_start is disabled")); + KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); + mtx_assert(&txr->hn_tx_lock, MA_OWNED); + + if (__predict_false(txr->hn_suspended)) + return 0; + + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) + return 0; + + while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { + struct hn_txdesc *txd; + struct mbuf *m_head; + int error; + + IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); + if (m_head == NULL) + break; + + if (len > 0 && m_head->m_pkthdr.len > len) { + /* + * This sending could be time consuming; let callers + * dispatch this packet sending (and sending of any + * following up packets) to tx taskqueue. + */ + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); + return 1; + } + + txd = hn_txdesc_get(txr); + if (txd == NULL) { + txr->hn_no_txdescs++; + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + break; + } + + error = hn_encap(txr, txd, &m_head); + if (error) { + /* Both txd and m_head are freed */ + continue; + } + + error = hn_txpkt(ifp, txr, txd); + if (__predict_false(error)) { + /* txd is freed, but m_head is not */ + IFQ_DRV_PREPEND(&ifp->if_snd, m_head); + atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + break; + } + } + return 0; +} + +static void +hn_start(struct ifnet *ifp) +{ + struct hn_softc *sc = ifp->if_softc; + struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; + + if (txr->hn_sched_tx) + goto do_sched; + + if (mtx_trylock(&txr->hn_tx_lock)) { + int sched; + + sched = hn_start_locked(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); + if (!sched) + return; + } +do_sched: + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_tx_task); +} + static void hn_start_txeof_taskfunc(void *xtxr, int pending __unused) { @@ -3350,6 +3337,42 @@ hn_start_txeof_taskfunc(void *xtxr, int mtx_unlock(&txr->hn_tx_lock); } +static void +hn_start_txeof(struct hn_tx_ring *txr) +{ + struct hn_softc *sc = txr->hn_sc; + struct ifnet *ifp = sc->hn_ifp; + + KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); + + if (txr->hn_sched_tx) + goto do_sched; + + if (mtx_trylock(&txr->hn_tx_lock)) { + int sched; + + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + sched = hn_start_locked(txr, txr->hn_direct_tx_size); + mtx_unlock(&txr->hn_tx_lock); + if (sched) { + taskqueue_enqueue(txr->hn_tx_taskq, + &txr->hn_tx_task); + } + } else { +do_sched: + /* + * Release the OACTIVE earlier, with the hope, that + * others could catch up. The task will clear the + * flag again with the hn_tx_lock to avoid possible + * races. + */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); + } +} + +#endif /* HN_IFSTART_SUPPORT */ + static int hn_xmit(struct hn_tx_ring *txr, int len) { @@ -3358,8 +3381,10 @@ hn_xmit(struct hn_tx_ring *txr, int len) struct mbuf *m_head; mtx_assert(&txr->hn_tx_lock, MA_OWNED); +#ifdef HN_IFSTART_SUPPORT KASSERT(hn_use_if_start == 0, ("hn_xmit is called, when if_start is enabled")); +#endif if (__predict_false(txr->hn_suspended)) return 0; @@ -4056,7 +4081,10 @@ hn_resume_data(struct hn_softc *sc) */ hn_resume_tx(sc, sc->hn_tx_ring_cnt); - if (!hn_use_if_start) { +#ifdef HN_IFSTART_SUPPORT + if (!hn_use_if_start) +#endif + { /* * Flush unused drbrs, since hn_tx_ring_inuse may be * reduced. From owner-svn-src-head@freebsd.org Tue Nov 1 06:54:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3DD58C2A733; Tue, 1 Nov 2016 06:54:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00BB61FFC; Tue, 1 Nov 2016 06:54:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA16sQ6c007198; Tue, 1 Nov 2016 06:54:26 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA16sPod007194; Tue, 1 Nov 2016 06:54:25 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010654.uA16sPod007194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 06:54:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308163 - in head/sys: conf dev/hyperv/netvsc modules/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 06:54:27 -0000 Author: sephe Date: Tue Nov 1 06:54:25 2016 New Revision: 308163 URL: https://svnweb.freebsd.org/changeset/base/308163 Log: hyperv/hn: Rename cleaned up file. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8390 Added: head/sys/dev/hyperv/netvsc/if_hn.c - copied unchanged from r308162, head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Deleted: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/modules/hyperv/netvsc/Makefile Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Tue Nov 1 04:44:11 2016 (r308162) +++ head/sys/conf/files.amd64 Tue Nov 1 06:54:25 2016 (r308163) @@ -293,7 +293,7 @@ dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hn_nvs.c optional hyperv dev/hyperv/netvsc/hn_rndis.c optional hyperv -dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv +dev/hyperv/netvsc/if_hn.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Tue Nov 1 04:44:11 2016 (r308162) +++ head/sys/conf/files.i386 Tue Nov 1 06:54:25 2016 (r308163) @@ -250,7 +250,7 @@ dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hn_nvs.c optional hyperv dev/hyperv/netvsc/hn_rndis.c optional hyperv -dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv +dev/hyperv/netvsc/if_hn.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Copied: head/sys/dev/hyperv/netvsc/if_hn.c (from r308162, head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 06:54:25 2016 (r308163, copy of r308162, head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c) @@ -0,0 +1,4658 @@ +/*- + * Copyright (c) 2010-2012 Citrix Inc. + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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. + */ + +/*- + * Copyright (c) 2004-2006 Kip Macy + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_inet6.h" +#include "opt_inet.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "vmbus_if.h" + +#define HN_RING_CNT_DEF_MAX 8 + +/* YYY should get it from the underlying channel */ +#define HN_TX_DESC_CNT 512 + +#define HN_RNDIS_PKT_LEN \ + (sizeof(struct rndis_packet_msg) + \ + HN_RNDIS_PKTINFO_SIZE(HN_NDIS_HASH_VALUE_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_VLAN_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_LSO2_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_TXCSUM_INFO_SIZE)) +#define HN_RNDIS_PKT_BOUNDARY PAGE_SIZE +#define HN_RNDIS_PKT_ALIGN CACHE_LINE_SIZE + +#define HN_TX_DATA_BOUNDARY PAGE_SIZE +#define HN_TX_DATA_MAXSIZE IP_MAXPACKET +#define HN_TX_DATA_SEGSIZE PAGE_SIZE +/* -1 for RNDIS packet message */ +#define HN_TX_DATA_SEGCNT_MAX (HN_GPACNT_MAX - 1) + +#define HN_DIRECT_TX_SIZE_DEF 128 + +#define HN_EARLY_TXEOF_THRESH 8 + +#define HN_PKTBUF_LEN_DEF (16 * 1024) + +#define HN_LROENT_CNT_DEF 128 + +#define HN_LRO_LENLIM_MULTIRX_DEF (12 * ETHERMTU) +#define HN_LRO_LENLIM_DEF (25 * ETHERMTU) +/* YYY 2*MTU is a bit rough, but should be good enough. */ +#define HN_LRO_LENLIM_MIN(ifp) (2 * (ifp)->if_mtu) + +#define HN_LRO_ACKCNT_DEF 1 + +#define HN_LOCK_INIT(sc) \ + sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) +#define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) +#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) +#define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) +#define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) + +#define HN_CSUM_IP_MASK (CSUM_IP | CSUM_IP_TCP | CSUM_IP_UDP) +#define HN_CSUM_IP6_MASK (CSUM_IP6_TCP | CSUM_IP6_UDP) +#define HN_CSUM_IP_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP_MASK) +#define HN_CSUM_IP6_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) + +struct hn_txdesc { +#ifndef HN_USE_TXDESC_BUFRING + SLIST_ENTRY(hn_txdesc) link; +#endif + struct mbuf *m; + struct hn_tx_ring *txr; + int refs; + uint32_t flags; /* HN_TXD_FLAG_ */ + struct hn_nvs_sendctx send_ctx; + uint32_t chim_index; + int chim_size; + + bus_dmamap_t data_dmap; + + bus_addr_t rndis_pkt_paddr; + struct rndis_packet_msg *rndis_pkt; + bus_dmamap_t rndis_pkt_dmap; +}; + +#define HN_TXD_FLAG_ONLIST 0x0001 +#define HN_TXD_FLAG_DMAMAP 0x0002 + +struct hn_rxinfo { + uint32_t vlan_info; + uint32_t csum_info; + uint32_t hash_info; + uint32_t hash_value; +}; + +#define HN_RXINFO_VLAN 0x0001 +#define HN_RXINFO_CSUM 0x0002 +#define HN_RXINFO_HASHINF 0x0004 +#define HN_RXINFO_HASHVAL 0x0008 +#define HN_RXINFO_ALL \ + (HN_RXINFO_VLAN | \ + HN_RXINFO_CSUM | \ + HN_RXINFO_HASHINF | \ + HN_RXINFO_HASHVAL) + +#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff +#define HN_NDIS_RXCSUM_INFO_INVALID 0 +#define HN_NDIS_HASH_INFO_INVALID 0 + +static int hn_probe(device_t); +static int hn_attach(device_t); +static int hn_detach(device_t); +static int hn_shutdown(device_t); +static void hn_chan_callback(struct vmbus_channel *, + void *); + +static void hn_init(void *); +static int hn_ioctl(struct ifnet *, u_long, caddr_t); +static void hn_start(struct ifnet *); +static int hn_transmit(struct ifnet *, struct mbuf *); +static void hn_xmit_qflush(struct ifnet *); +static int hn_ifmedia_upd(struct ifnet *); +static void hn_ifmedia_sts(struct ifnet *, + struct ifmediareq *); + +static int hn_rndis_rxinfo(const void *, int, + struct hn_rxinfo *); +static void hn_rndis_rx_data(struct hn_rx_ring *, + const void *, int); +static void hn_rndis_rx_status(struct hn_softc *, + const void *, int); + +static void hn_nvs_handle_notify(struct hn_softc *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_handle_comp(struct hn_softc *, + struct vmbus_channel *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_handle_rxbuf(struct hn_rx_ring *, + struct vmbus_channel *, + const struct vmbus_chanpkt_hdr *); +static void hn_nvs_ack_rxbuf(struct hn_rx_ring *, + struct vmbus_channel *, uint64_t); + +#if __FreeBSD_version >= 1100099 +static int hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); +#if __FreeBSD_version < 1100095 +static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); +#else +static int hn_rx_stat_u64_sysctl(SYSCTL_HANDLER_ARGS); +#endif +static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rxfilter_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS); + +static void hn_stop(struct hn_softc *); +static void hn_init_locked(struct hn_softc *); +static int hn_chan_attach(struct hn_softc *, + struct vmbus_channel *); +static void hn_chan_detach(struct hn_softc *, + struct vmbus_channel *); +static int hn_attach_subchans(struct hn_softc *); +static void hn_detach_allchans(struct hn_softc *); +static void hn_chan_rollup(struct hn_rx_ring *, + struct hn_tx_ring *); +static void hn_set_ring_inuse(struct hn_softc *, int); +static int hn_synth_attach(struct hn_softc *, int); +static void hn_synth_detach(struct hn_softc *); +static int hn_synth_alloc_subchans(struct hn_softc *, + int *); +static void hn_suspend(struct hn_softc *); +static void hn_suspend_data(struct hn_softc *); +static void hn_suspend_mgmt(struct hn_softc *); +static void hn_resume(struct hn_softc *); +static void hn_resume_data(struct hn_softc *); +static void hn_resume_mgmt(struct hn_softc *); +static void hn_suspend_mgmt_taskfunc(void *, int); +static void hn_chan_drain(struct vmbus_channel *); + +static void hn_update_link_status(struct hn_softc *); +static void hn_change_network(struct hn_softc *); +static void hn_link_taskfunc(void *, int); +static void hn_netchg_init_taskfunc(void *, int); +static void hn_netchg_status_taskfunc(void *, int); +static void hn_link_status(struct hn_softc *); + +static int hn_create_rx_data(struct hn_softc *, int); +static void hn_destroy_rx_data(struct hn_softc *); +static int hn_check_iplen(const struct mbuf *, int); +static int hn_set_rxfilter(struct hn_softc *); +static int hn_rss_reconfig(struct hn_softc *); +static void hn_rss_ind_fixup(struct hn_softc *, int); +static int hn_rxpkt(struct hn_rx_ring *, const void *, + int, const struct hn_rxinfo *); + +static int hn_tx_ring_create(struct hn_softc *, int); +static void hn_tx_ring_destroy(struct hn_tx_ring *); +static int hn_create_tx_data(struct hn_softc *, int); +static void hn_fixup_tx_data(struct hn_softc *); +static void hn_destroy_tx_data(struct hn_softc *); +static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); +static int hn_encap(struct hn_tx_ring *, + struct hn_txdesc *, struct mbuf **); +static int hn_txpkt(struct ifnet *, struct hn_tx_ring *, + struct hn_txdesc *); +static void hn_set_chim_size(struct hn_softc *, int); +static void hn_set_tso_maxsize(struct hn_softc *, int, int); +static bool hn_tx_ring_pending(struct hn_tx_ring *); +static void hn_tx_ring_qflush(struct hn_tx_ring *); +static void hn_resume_tx(struct hn_softc *, int); +static int hn_get_txswq_depth(const struct hn_tx_ring *); +static void hn_txpkt_done(struct hn_nvs_sendctx *, + struct hn_softc *, struct vmbus_channel *, + const void *, int); +static int hn_txpkt_sglist(struct hn_tx_ring *, + struct hn_txdesc *); +static int hn_txpkt_chim(struct hn_tx_ring *, + struct hn_txdesc *); +static int hn_xmit(struct hn_tx_ring *, int); +static void hn_xmit_taskfunc(void *, int); +static void hn_xmit_txeof(struct hn_tx_ring *); +static void hn_xmit_txeof_taskfunc(void *, int); +static int hn_start_locked(struct hn_tx_ring *, int); +static void hn_start_taskfunc(void *, int); +static void hn_start_txeof(struct hn_tx_ring *); +static void hn_start_txeof_taskfunc(void *, int); + +SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Hyper-V network interface"); + +/* Trust tcp segements verification on host side. */ +static int hn_trust_hosttcp = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosttcp, CTLFLAG_RDTUN, + &hn_trust_hosttcp, 0, + "Trust tcp segement verification on host side, " + "when csum info is missing (global setting)"); + +/* Trust udp datagrams verification on host side. */ +static int hn_trust_hostudp = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostudp, CTLFLAG_RDTUN, + &hn_trust_hostudp, 0, + "Trust udp datagram verification on host side, " + "when csum info is missing (global setting)"); + +/* Trust ip packets verification on host side. */ +static int hn_trust_hostip = 1; +SYSCTL_INT(_hw_hn, OID_AUTO, trust_hostip, CTLFLAG_RDTUN, + &hn_trust_hostip, 0, + "Trust ip packet verification on host side, " + "when csum info is missing (global setting)"); + +/* Limit TSO burst size */ +static int hn_tso_maxlen = IP_MAXPACKET; +SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, + &hn_tso_maxlen, 0, "TSO burst limit"); + +/* Limit chimney send size */ +static int hn_tx_chimney_size = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_chimney_size, CTLFLAG_RDTUN, + &hn_tx_chimney_size, 0, "Chimney send packet size limit"); + +/* Limit the size of packet for direct transmission */ +static int hn_direct_tx_size = HN_DIRECT_TX_SIZE_DEF; +SYSCTL_INT(_hw_hn, OID_AUTO, direct_tx_size, CTLFLAG_RDTUN, + &hn_direct_tx_size, 0, "Size of the packet for direct transmission"); + +/* # of LRO entries per RX ring */ +#if defined(INET) || defined(INET6) +#if __FreeBSD_version >= 1100095 +static int hn_lro_entry_count = HN_LROENT_CNT_DEF; +SYSCTL_INT(_hw_hn, OID_AUTO, lro_entry_count, CTLFLAG_RDTUN, + &hn_lro_entry_count, 0, "LRO entry count"); +#endif +#endif + +/* Use shared TX taskqueue */ +static int hn_share_tx_taskq = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, share_tx_taskq, CTLFLAG_RDTUN, + &hn_share_tx_taskq, 0, "Enable shared TX taskqueue"); + +#ifndef HN_USE_TXDESC_BUFRING +static int hn_use_txdesc_bufring = 0; +#else +static int hn_use_txdesc_bufring = 1; +#endif +SYSCTL_INT(_hw_hn, OID_AUTO, use_txdesc_bufring, CTLFLAG_RD, + &hn_use_txdesc_bufring, 0, "Use buf_ring for TX descriptors"); + +/* Bind TX taskqueue to the target CPU */ +static int hn_bind_tx_taskq = -1; +SYSCTL_INT(_hw_hn, OID_AUTO, bind_tx_taskq, CTLFLAG_RDTUN, + &hn_bind_tx_taskq, 0, "Bind TX taskqueue to the specified cpu"); + +/* Use ifnet.if_start instead of ifnet.if_transmit */ +static int hn_use_if_start = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, use_if_start, CTLFLAG_RDTUN, + &hn_use_if_start, 0, "Use if_start TX method"); + +/* # of channels to use */ +static int hn_chan_cnt = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, + &hn_chan_cnt, 0, + "# of channels to use; each channel has one RX ring and one TX ring"); + +/* # of transmit rings to use */ +static int hn_tx_ring_cnt = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_ring_cnt, CTLFLAG_RDTUN, + &hn_tx_ring_cnt, 0, "# of TX rings to use"); + +/* Software TX ring deptch */ +static int hn_tx_swq_depth = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, tx_swq_depth, CTLFLAG_RDTUN, + &hn_tx_swq_depth, 0, "Depth of IFQ or BUFRING"); + +/* Enable sorted LRO, and the depth of the per-channel mbuf queue */ +#if __FreeBSD_version >= 1100095 +static u_int hn_lro_mbufq_depth = 0; +SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, + &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); +#endif + +static u_int hn_cpu_index; /* next CPU for channel */ +static struct taskqueue *hn_tx_taskq; /* shared TX taskqueue */ + +static const uint8_t +hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +}; + +static device_method_t hn_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, hn_probe), + DEVMETHOD(device_attach, hn_attach), + DEVMETHOD(device_detach, hn_detach), + DEVMETHOD(device_shutdown, hn_shutdown), + DEVMETHOD_END +}; + +static driver_t hn_driver = { + "hn", + hn_methods, + sizeof(struct hn_softc) +}; + +static devclass_t hn_devclass; + +DRIVER_MODULE(hn, vmbus, hn_driver, hn_devclass, 0, 0); +MODULE_VERSION(hn, 1); +MODULE_DEPEND(hn, vmbus, 1, 1, 1); + +#if __FreeBSD_version >= 1100099 +static void +hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) +{ + int i; + + for (i = 0; i < sc->hn_rx_ring_inuse; ++i) + sc->hn_rx_ring[i].hn_lro.lro_length_lim = lenlim; +} +#endif + +static int +hn_txpkt_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd) +{ + + KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID && + txd->chim_size == 0, ("invalid rndis sglist txd")); + return (hn_nvs_send_rndis_sglist(txr->hn_chan, HN_NVS_RNDIS_MTYPE_DATA, + &txd->send_ctx, txr->hn_gpa, txr->hn_gpa_cnt)); +} + +static int +hn_txpkt_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd) +{ + struct hn_nvs_rndis rndis; + + KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID && + txd->chim_size > 0, ("invalid rndis chim txd")); + + rndis.nvs_type = HN_NVS_TYPE_RNDIS; + rndis.nvs_rndis_mtype = HN_NVS_RNDIS_MTYPE_DATA; + rndis.nvs_chim_idx = txd->chim_index; + rndis.nvs_chim_sz = txd->chim_size; + + return (hn_nvs_send(txr->hn_chan, VMBUS_CHANPKT_FLAG_RC, + &rndis, sizeof(rndis), &txd->send_ctx)); +} + +static __inline uint32_t +hn_chim_alloc(struct hn_softc *sc) +{ + int i, bmap_cnt = sc->hn_chim_bmap_cnt; + u_long *bmap = sc->hn_chim_bmap; + uint32_t ret = HN_NVS_CHIM_IDX_INVALID; + + for (i = 0; i < bmap_cnt; ++i) { + int idx; + + idx = ffsl(~bmap[i]); + if (idx == 0) + continue; + + --idx; /* ffsl is 1-based */ + KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt, + ("invalid i %d and idx %d", i, idx)); + + if (atomic_testandset_long(&bmap[i], idx)) + continue; + + ret = i * LONG_BIT + idx; + break; + } + return (ret); +} + +static __inline void +hn_chim_free(struct hn_softc *sc, uint32_t chim_idx) +{ + u_long mask; + uint32_t idx; + + idx = chim_idx / LONG_BIT; + KASSERT(idx < sc->hn_chim_bmap_cnt, + ("invalid chimney index 0x%x", chim_idx)); + + mask = 1UL << (chim_idx % LONG_BIT); + KASSERT(sc->hn_chim_bmap[idx] & mask, + ("index bitmap 0x%lx, chimney index %u, " + "bitmap idx %d, bitmask 0x%lx", + sc->hn_chim_bmap[idx], chim_idx, idx, mask)); + + atomic_clear_long(&sc->hn_chim_bmap[idx], mask); +} + +static int +hn_set_rxfilter(struct hn_softc *sc) +{ + struct ifnet *ifp = sc->hn_ifp; + uint32_t filter; + int error = 0; + + HN_LOCK_ASSERT(sc); + + if (ifp->if_flags & IFF_PROMISC) { + filter = NDIS_PACKET_TYPE_PROMISCUOUS; + } else { + filter = NDIS_PACKET_TYPE_DIRECTED; + if (ifp->if_flags & IFF_BROADCAST) + filter |= NDIS_PACKET_TYPE_BROADCAST; +#ifdef notyet + /* + * See the comment in SIOCADDMULTI/SIOCDELMULTI. + */ + /* TODO: support multicast list */ + if ((ifp->if_flags & IFF_ALLMULTI) || + !TAILQ_EMPTY(&ifp->if_multiaddrs)) + filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; +#else + /* Always enable ALLMULTI */ + filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; +#endif + } + + if (sc->hn_rx_filter != filter) { + error = hn_rndis_set_rxfilter(sc, filter); + if (!error) + sc->hn_rx_filter = filter; + } + return (error); +} + +static int +hn_get_txswq_depth(const struct hn_tx_ring *txr) +{ + + KASSERT(txr->hn_txdesc_cnt > 0, ("tx ring is not setup yet")); + if (hn_tx_swq_depth < txr->hn_txdesc_cnt) + return txr->hn_txdesc_cnt; + return hn_tx_swq_depth; +} + +static int +hn_rss_reconfig(struct hn_softc *sc) +{ + int error; + + HN_LOCK_ASSERT(sc); + + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + return (ENXIO); + + /* + * Disable RSS first. + * + * NOTE: + * Direct reconfiguration by setting the UNCHG flags does + * _not_ work properly. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "disable RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_DISABLE); + if (error) { + if_printf(sc->hn_ifp, "RSS disable failed\n"); + return (error); + } + + /* + * Reenable the RSS w/ the updated RSS key or indirect + * table. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "reconfig RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); + if (error) { + if_printf(sc->hn_ifp, "RSS reconfig failed\n"); + return (error); + } + return (0); +} + +static void +hn_rss_ind_fixup(struct hn_softc *sc, int nchan) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + int i; + + KASSERT(nchan > 1, ("invalid # of channels %d", nchan)); + + /* + * Check indirect table to make sure that all channels in it + * can be used. + */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) { + if (rss->rss_ind[i] >= nchan) { + if_printf(sc->hn_ifp, + "RSS indirect table %d fixup: %u -> %d\n", + i, rss->rss_ind[i], nchan - 1); + rss->rss_ind[i] = nchan - 1; + } + } +} + +static int +hn_ifmedia_upd(struct ifnet *ifp __unused) +{ + + return EOPNOTSUPP; +} + +static void +hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) +{ + struct hn_softc *sc = ifp->if_softc; + + ifmr->ifm_status = IFM_AVALID; + ifmr->ifm_active = IFM_ETHER; + + if ((sc->hn_link_flags & HN_LINK_FLAG_LINKUP) == 0) { + ifmr->ifm_active |= IFM_NONE; + return; + } + ifmr->ifm_status |= IFM_ACTIVE; + ifmr->ifm_active |= IFM_10G_T | IFM_FDX; +} + +/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ +static const struct hyperv_guid g_net_vsc_device_type = { + .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, + 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} +}; + +static int +hn_probe(device_t dev) +{ + + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, + &g_net_vsc_device_type) == 0) { + device_set_desc(dev, "Hyper-V Network Interface"); + return BUS_PROBE_DEFAULT; + } + return ENXIO; +} + +static int +hn_attach(device_t dev) +{ + struct hn_softc *sc = device_get_softc(dev); + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; + uint8_t eaddr[ETHER_ADDR_LEN]; + struct ifnet *ifp = NULL; + int error, ring_cnt, tx_ring_cnt; + + sc->hn_dev = dev; + sc->hn_prichan = vmbus_get_channel(dev); + HN_LOCK_INIT(sc); + + /* + * Setup taskqueue for transmission. + */ + if (hn_tx_taskq == NULL) { + sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_tx_taskq); + if (hn_bind_tx_taskq >= 0) { + int cpu = hn_bind_tx_taskq; + cpuset_t cpu_set; + + if (cpu > mp_ncpus - 1) + cpu = mp_ncpus - 1; + CPU_SETOF(cpu, &cpu_set); + taskqueue_start_threads_cpuset(&sc->hn_tx_taskq, 1, + PI_NET, &cpu_set, "%s tx", + device_get_nameunit(dev)); + } else { + taskqueue_start_threads(&sc->hn_tx_taskq, 1, PI_NET, + "%s tx", device_get_nameunit(dev)); + } + } else { + sc->hn_tx_taskq = hn_tx_taskq; + } + + /* + * Setup taskqueue for mangement tasks, e.g. link status. + */ + sc->hn_mgmt_taskq0 = taskqueue_create("hn_mgmt", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_mgmt_taskq0); + taskqueue_start_threads(&sc->hn_mgmt_taskq0, 1, PI_NET, "%s mgmt", + device_get_nameunit(dev)); + TASK_INIT(&sc->hn_link_task, 0, hn_link_taskfunc, sc); + TASK_INIT(&sc->hn_netchg_init, 0, hn_netchg_init_taskfunc, sc); + TIMEOUT_TASK_INIT(sc->hn_mgmt_taskq0, &sc->hn_netchg_status, 0, + hn_netchg_status_taskfunc, sc); + + /* + * Allocate ifnet and setup its name earlier, so that if_printf + * can be used by functions, which will be called after + * ether_ifattach(). + */ + ifp = sc->hn_ifp = if_alloc(IFT_ETHER); + ifp->if_softc = sc; + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); + + /* + * Initialize ifmedia earlier so that it can be unconditionally + * destroyed, if error happened later on. + */ + ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); + + /* + * Figure out the # of RX rings (ring_cnt) and the # of TX rings + * to use (tx_ring_cnt). + * + * NOTE: + * The # of RX rings to use is same as the # of channels to use. + */ + ring_cnt = hn_chan_cnt; + if (ring_cnt <= 0) { + /* Default */ + ring_cnt = mp_ncpus; + if (ring_cnt > HN_RING_CNT_DEF_MAX) + ring_cnt = HN_RING_CNT_DEF_MAX; + } else if (ring_cnt > mp_ncpus) { + ring_cnt = mp_ncpus; + } + + tx_ring_cnt = hn_tx_ring_cnt; + if (tx_ring_cnt <= 0 || tx_ring_cnt > ring_cnt) + tx_ring_cnt = ring_cnt; + if (hn_use_if_start) { + /* ifnet.if_start only needs one TX ring. */ + tx_ring_cnt = 1; + } + + /* + * Set the leader CPU for channels. + */ + sc->hn_cpu = atomic_fetchadd_int(&hn_cpu_index, ring_cnt) % mp_ncpus; + + /* + * Create enough TX/RX rings, even if only limited number of + * channels can be allocated. + */ + error = hn_create_tx_data(sc, tx_ring_cnt); + if (error) + goto failed; + error = hn_create_rx_data(sc, ring_cnt); + if (error) + goto failed; + + /* + * Create transaction context for NVS and RNDIS transactions. + */ + sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); + if (sc->hn_xact == NULL) + goto failed; + + /* + * Attach the synthetic parts, i.e. NVS and RNDIS. + */ + error = hn_synth_attach(sc, ETHERMTU); + if (error) + goto failed; + + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring_inuse > 1) { + /* + * Reduce TCP segment aggregation limit for multiple + * RX rings to increase ACK timeliness. + */ + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); + } +#endif + + /* + * Fixup TX stuffs after synthetic parts are attached. + */ + hn_fixup_tx_data(sc); + + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "caps", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_caps_sysctl, "A", "capabilities"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "hwassist", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_hwassist_sysctl, "A", "hwassist"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxfilter", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rxfilter_sysctl, "A", "rxfilter"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_hash", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rss_hash_sysctl, "A", "RSS hash"); + SYSCTL_ADD_INT(ctx, child, OID_AUTO, "rss_ind_size", + CTLFLAG_RD, &sc->hn_rss_ind_size, 0, "RSS indirect entry count"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_key_sysctl, "IU", "RSS key"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_ind", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_ind_sysctl, "IU", "RSS indirect table"); + + /* + * Setup the ifmedia, which has been initialized earlier. + */ + ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); + /* XXX ifmedia_set really should do this for us */ + sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; + + /* + * Setup the ifnet for this interface. + */ + + ifp->if_baudrate = IF_Gbps(10); + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_ioctl = hn_ioctl; + ifp->if_init = hn_init; + if (hn_use_if_start) { + int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); + + ifp->if_start = hn_start; + IFQ_SET_MAXLEN(&ifp->if_snd, qdepth); + ifp->if_snd.ifq_drv_maxlen = qdepth - 1; + IFQ_SET_READY(&ifp->if_snd); + } else { + ifp->if_transmit = hn_transmit; + ifp->if_qflush = hn_xmit_qflush; + } + + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO; +#ifdef foo + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + ifp->if_capabilities |= IFCAP_RXCSUM_IPV6; +#endif + if (sc->hn_caps & HN_CAP_VLAN) { + /* XXX not sure about VLAN_MTU. */ + ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; + } + + ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist; + if (ifp->if_hwassist & HN_CSUM_IP_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM; + if (ifp->if_hwassist & HN_CSUM_IP6_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM_IPV6; + if (sc->hn_caps & HN_CAP_TSO4) { + ifp->if_capabilities |= IFCAP_TSO4; + ifp->if_hwassist |= CSUM_IP_TSO; + } + if (sc->hn_caps & HN_CAP_TSO6) { + ifp->if_capabilities |= IFCAP_TSO6; + ifp->if_hwassist |= CSUM_IP6_TSO; + } + + /* Enable all available capabilities by default. */ + ifp->if_capenable = ifp->if_capabilities; + + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; + ifp->if_hw_tsomaxsegsize = PAGE_SIZE; + } + + ether_ifattach(ifp, eaddr); + + if ((ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) && bootverbose) { + if_printf(ifp, "TSO segcnt %u segsz %u\n", + ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); + } + + /* Inform the upper layer about the long frame support. */ + ifp->if_hdrlen = sizeof(struct ether_vlan_header); + + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_update_link_status(sc); + + return (0); +failed: + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) + hn_synth_detach(sc); + hn_detach(dev); + return (error); +} + +static int +hn_detach(device_t dev) +{ + struct hn_softc *sc = device_get_softc(dev); + struct ifnet *ifp = sc->hn_ifp; + + if (device_is_attached(dev)) { + HN_LOCK(sc); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_stop(sc); + /* + * NOTE: + * hn_stop() only suspends data, so managment + * stuffs have to be suspended manually here. + */ + hn_suspend_mgmt(sc); + hn_synth_detach(sc); + } + HN_UNLOCK(sc); + ether_ifdetach(ifp); + } + + ifmedia_removeall(&sc->hn_media); + hn_destroy_rx_data(sc); + hn_destroy_tx_data(sc); + + if (sc->hn_tx_taskq != hn_tx_taskq) + taskqueue_free(sc->hn_tx_taskq); + taskqueue_free(sc->hn_mgmt_taskq0); + + if (sc->hn_xact != NULL) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Nov 1 07:15:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10773C2AD88; Tue, 1 Nov 2016 07:15:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CFD7412C0; Tue, 1 Nov 2016 07:15:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA17FdSL014946; Tue, 1 Nov 2016 07:15:39 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA17FdH2014945; Tue, 1 Nov 2016 07:15:39 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201611010715.uA17FdH2014945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 1 Nov 2016 07:15:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308165 - head/sys/dev/usb/input X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 07:15:41 -0000 Author: hselasky Date: Tue Nov 1 07:15:39 2016 New Revision: 308165 URL: https://svnweb.freebsd.org/changeset/base/308165 Log: Make sure the virtual T-axis buttons generate button release event(s) for continuous tilting. PR: 213957 MFC after: 3 days Modified: head/sys/dev/usb/input/ums.c Modified: head/sys/dev/usb/input/ums.c ============================================================================== --- head/sys/dev/usb/input/ums.c Tue Nov 1 07:10:43 2016 (r308164) +++ head/sys/dev/usb/input/ums.c Tue Nov 1 07:15:39 2016 (r308165) @@ -330,10 +330,13 @@ ums_intr_callback(struct usb_xfer *xfer, dx, dy, dz, dt, dw, buttons); /* translate T-axis into button presses until further */ - if (dt > 0) + if (dt > 0) { + ums_put_queue(sc, 0, 0, 0, 0, buttons); buttons |= 1UL << 5; - else if (dt < 0) + } else if (dt < 0) { + ums_put_queue(sc, 0, 0, 0, 0, buttons); buttons |= 1UL << 6; + } sc->sc_status.button = buttons; sc->sc_status.dx += dx; From owner-svn-src-head@freebsd.org Tue Nov 1 07:41:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FC5AC28AB9; Tue, 1 Nov 2016 07:41:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FFE816D3; Tue, 1 Nov 2016 07:41:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA17fQQn023295; Tue, 1 Nov 2016 07:41:26 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA17fQtS023294; Tue, 1 Nov 2016 07:41:26 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010741.uA17fQtS023294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 07:41:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308166 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 07:41:27 -0000 Author: sephe Date: Tue Nov 1 07:41:26 2016 New Revision: 308166 URL: https://svnweb.freebsd.org/changeset/base/308166 Log: hyperv/hn: Move TSO packet fixup to an earlier place for if_transmit. While TSO packet header may be still cache-hot. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8393 Modified: head/sys/dev/hyperv/netvsc/if_hn.c Modified: head/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 07:15:39 2016 (r308165) +++ head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 07:41:26 2016 (r308166) @@ -547,6 +547,80 @@ hn_chim_free(struct hn_softc *sc, uint32 atomic_clear_long(&sc->hn_chim_bmap[idx], mask); } +#if defined(INET6) || defined(INET) +/* + * NOTE: If this function failed, the m_head would be freed. + */ +static __inline struct mbuf * +hn_tso_fixup(struct mbuf *m_head) +{ + struct ether_vlan_header *evl; + struct tcphdr *th; + int ehlen; + + KASSERT(M_WRITABLE(m_head), ("TSO mbuf not writable")); + +#define PULLUP_HDR(m, len) \ +do { \ + if (__predict_false((m)->m_len < (len))) { \ + (m) = m_pullup((m), (len)); \ + if ((m) == NULL) \ + return (NULL); \ + } \ +} while (0) + + PULLUP_HDR(m_head, sizeof(*evl)); + evl = mtod(m_head, struct ether_vlan_header *); + if (evl->evl_encap_proto == ntohs(ETHERTYPE_VLAN)) + ehlen = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; + else + ehlen = ETHER_HDR_LEN; + +#ifdef INET + if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { + struct ip *ip; + int iphlen; + + PULLUP_HDR(m_head, ehlen + sizeof(*ip)); + ip = mtodo(m_head, ehlen); + iphlen = ip->ip_hl << 2; + + PULLUP_HDR(m_head, ehlen + iphlen + sizeof(*th)); + th = mtodo(m_head, ehlen + iphlen); + + ip->ip_len = 0; + ip->ip_sum = 0; + th->th_sum = in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + } +#endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET6 + { + struct ip6_hdr *ip6; + + PULLUP_HDR(m_head, ehlen + sizeof(*ip6)); + ip6 = mtodo(m_head, ehlen); + if (ip6->ip6_nxt != IPPROTO_TCP) { + m_freem(m_head); + return (NULL); + } + + PULLUP_HDR(m_head, ehlen + sizeof(*ip6) + sizeof(*th)); + th = mtodo(m_head, ehlen + sizeof(*ip6)); + + ip6->ip6_plen = 0; + th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + } +#endif + return (m_head); + +#undef PULLUP_HDR +} +#endif /* INET6 || INET */ + static int hn_set_rxfilter(struct hn_softc *sc) { @@ -1358,32 +1432,10 @@ hn_encap(struct hn_tx_ring *txr, struct if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { #if defined(INET6) || defined(INET) - struct ether_vlan_header *eh; - int ether_len; - - /* - * XXX need m_pullup and use mtodo - */ - eh = mtod(m_head, struct ether_vlan_header*); - if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) - ether_len = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; - else - ether_len = ETHER_HDR_LEN; - pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, NDIS_LSO2_INFO_SIZE, NDIS_PKTINFO_TYPE_LSO); #ifdef INET if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { - struct ip *ip = - (struct ip *)(m_head->m_data + ether_len); - unsigned long iph_len = ip->ip_hl << 2; - struct tcphdr *th = - (struct tcphdr *)((caddr_t)ip + iph_len); - - ip->ip_len = 0; - ip->ip_sum = 0; - th->th_sum = in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htons(IPPROTO_TCP)); *pi_data = NDIS_LSO2_INFO_MAKEIPV4(0, m_head->m_pkthdr.tso_segsz); } @@ -1393,12 +1445,6 @@ hn_encap(struct hn_tx_ring *txr, struct #endif #ifdef INET6 { - struct ip6_hdr *ip6 = (struct ip6_hdr *) - (m_head->m_data + ether_len); - struct tcphdr *th = (struct tcphdr *)(ip6 + 1); - - ip6->ip6_plen = 0; - th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); *pi_data = NDIS_LSO2_INFO_MAKEIPV6(0, m_head->m_pkthdr.tso_segsz); } @@ -3280,6 +3326,16 @@ hn_start_locked(struct hn_tx_ring *txr, return 1; } +#if defined(INET6) || defined(INET) + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + m_head = hn_tso_fixup(m_head); + if (__predict_false(m_head == NULL)) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + continue; + } + } +#endif + txd = hn_txdesc_get(txr); if (txd == NULL) { txr->hn_no_txdescs++; @@ -3442,6 +3498,20 @@ hn_transmit(struct ifnet *ifp, struct mb struct hn_tx_ring *txr; int error, idx = 0; +#if defined(INET6) || defined(INET) + /* + * Perform TSO packet header fixup now, since the TSO + * packet header should be cache-hot. + */ + if (m->m_pkthdr.csum_flags & CSUM_TSO) { + m = hn_tso_fixup(m); + if (__predict_false(m == NULL)) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + return EIO; + } + } +#endif + /* * Select the TX ring based on flowid */ From owner-svn-src-head@freebsd.org Tue Nov 1 08:20:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58B51C29C16; Tue, 1 Nov 2016 08:20:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 14C8D1A11; Tue, 1 Nov 2016 08:20:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA18KX2S040376; Tue, 1 Nov 2016 08:20:33 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA18KXwg040375; Tue, 1 Nov 2016 08:20:33 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010820.uA18KXwg040375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 08:20:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308167 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 08:20:34 -0000 Author: sephe Date: Tue Nov 1 08:20:33 2016 New Revision: 308167 URL: https://svnweb.freebsd.org/changeset/base/308167 Log: hyperv/hn: Directly fill chimney sending buffer for small packets. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8394 Modified: head/sys/dev/hyperv/netvsc/if_hn.c Modified: head/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 07:41:26 2016 (r308166) +++ head/sys/dev/hyperv/netvsc/if_hn.c Tue Nov 1 08:20:33 2016 (r308167) @@ -1394,15 +1394,28 @@ hn_encap(struct hn_tx_ring *txr, struct struct mbuf *m_head = *m_head0; struct rndis_packet_msg *pkt; uint32_t *pi_data; + void *chim = NULL; int pktlen; - /* - * extension points to the area reserved for the - * rndis_filter_packet, which is placed just after - * the netvsc_packet (and rppi struct, if present; - * length is updated later). - */ pkt = txd->rndis_pkt; + if (m_head->m_pkthdr.len + HN_RNDIS_PKT_LEN < txr->hn_chim_size) { + /* + * This packet is small enough to fit into a chimney sending + * buffer. Try allocating one chimney sending buffer now. + */ + txr->hn_tx_chimney_tried++; + txd->chim_index = hn_chim_alloc(txr->hn_sc); + if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { + chim = txr->hn_sc->hn_chim + + (txd->chim_index * txr->hn_sc->hn_chim_szmax); + /* + * Directly fill the chimney sending buffer w/ the + * RNDIS packet message. + */ + pkt = chim; + } + } + pkt->rm_type = REMOTE_NDIS_PACKET_MSG; pkt->rm_len = sizeof(*pkt) + m_head->m_pkthdr.len; pkt->rm_dataoffset = sizeof(*pkt); @@ -1475,26 +1488,25 @@ hn_encap(struct hn_tx_ring *txr, struct pkt->rm_pktinfooffset = hn_rndis_pktmsg_offset(pkt->rm_pktinfooffset); /* - * Chimney send, if the packet could fit into one chimney buffer. + * Fast path: Chimney sending. */ - if (pkt->rm_len < txr->hn_chim_size) { - txr->hn_tx_chimney_tried++; - txd->chim_index = hn_chim_alloc(txr->hn_sc); - if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { - uint8_t *dest = txr->hn_sc->hn_chim + - (txd->chim_index * txr->hn_sc->hn_chim_szmax); - - memcpy(dest, pkt, pktlen); - dest += pktlen; - m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); - - txd->chim_size = pkt->rm_len; - txr->hn_gpa_cnt = 0; - txr->hn_tx_chimney++; - txr->hn_sendpkt = hn_txpkt_chim; - goto done; - } - } + if (chim != NULL) { + KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID, + ("chimney buffer is not used")); + KASSERT(pkt == chim, ("RNDIS pkt not in chimney buffer")); + + m_copydata(m_head, 0, m_head->m_pkthdr.len, + ((uint8_t *)chim) + pktlen); + + txd->chim_size = pkt->rm_len; + txr->hn_gpa_cnt = 0; + txr->hn_tx_chimney++; + txr->hn_sendpkt = hn_txpkt_chim; + goto done; + } + KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, + ("chimney buffer is used")); + KASSERT(pkt == txd->rndis_pkt, ("RNDIS pkt not in txdesc")); error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs); if (error) { From owner-svn-src-head@freebsd.org Tue Nov 1 08:30:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 295C6C29F8F; Tue, 1 Nov 2016 08:30:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D20DA134A; Tue, 1 Nov 2016 08:30:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA18U7lu042013; Tue, 1 Nov 2016 08:30:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA18U7K6042012; Tue, 1 Nov 2016 08:30:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611010830.uA18U7K6042012@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 1 Nov 2016 08:30:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308168 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 08:30:08 -0000 Author: sephe Date: Tue Nov 1 08:30:06 2016 New Revision: 308168 URL: https://svnweb.freebsd.org/changeset/base/308168 Log: hyperv/vmbus: Avoid extra header copy. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8395 Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_chan.c Tue Nov 1 08:20:33 2016 (r308167) +++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Tue Nov 1 08:30:06 2016 (r308168) @@ -926,28 +926,28 @@ vmbus_chan_recv(struct vmbus_channel *ch int vmbus_chan_recv_pkt(struct vmbus_channel *chan, - struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) + struct vmbus_chanpkt_hdr *pkt, int *pktlen0) { - struct vmbus_chanpkt_hdr pkt; - int error, pktlen; + int error, pktlen, pkt_hlen; - error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + pkt_hlen = sizeof(*pkt); + error = vmbus_rxbr_peek(&chan->ch_rxbr, pkt, pkt_hlen); if (error) return (error); - if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { - vmbus_chan_printf(chan, "invalid hlen %u\n", pkt.cph_hlen); + if (__predict_false(pkt->cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + vmbus_chan_printf(chan, "invalid hlen %u\n", pkt->cph_hlen); /* XXX this channel is dead actually. */ return (EIO); } - if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + if (__predict_false(pkt->cph_hlen > pkt->cph_tlen)) { vmbus_chan_printf(chan, "invalid hlen %u and tlen %u\n", - pkt.cph_hlen, pkt.cph_tlen); + pkt->cph_hlen, pkt->cph_tlen); /* XXX this channel is dead actually. */ return (EIO); } - pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + pktlen = VMBUS_CHANPKT_GETLEN(pkt->cph_tlen); if (*pktlen0 < pktlen) { /* Return the size of this packet. */ *pktlen0 = pktlen; @@ -955,8 +955,12 @@ vmbus_chan_recv_pkt(struct vmbus_channel } *pktlen0 = pktlen; - /* Include packet header */ - error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); + /* + * Skip the fixed-size packet header, which has been filled + * by the above vmbus_rxbr_peek(). + */ + error = vmbus_rxbr_read(&chan->ch_rxbr, pkt + 1, + pktlen - pkt_hlen, pkt_hlen); KASSERT(!error, ("vmbus_rxbr_read failed")); return (0); From owner-svn-src-head@freebsd.org Tue Nov 1 12:47:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7243C23BA4; Tue, 1 Nov 2016 12:47:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9A5501854; Tue, 1 Nov 2016 12:47:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1ClJAU040976; Tue, 1 Nov 2016 12:47:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1ClJ5B040975; Tue, 1 Nov 2016 12:47:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201611011247.uA1ClJ5B040975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 1 Nov 2016 12:47:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308169 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 12:47:21 -0000 Author: mav Date: Tue Nov 1 12:47:19 2016 New Revision: 308169 URL: https://svnweb.freebsd.org/changeset/base/308169 Log: Pass to zvol_log_truncate() same sync values as to zvol_log_write(). Surplus marking of TX_TRUNCATE records as sync could result in putting them into ZIL before previous writes if ones were async. MFC after: 2 weeks Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Tue Nov 1 08:30:06 2016 (r308168) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Tue Nov 1 12:47:19 2016 (r308169) @@ -1674,7 +1674,7 @@ zvol_strategy(struct bio *bp) if (error != 0) { dmu_tx_abort(tx); } else { - zvol_log_truncate(zv, tx, off, resid, B_TRUE); + zvol_log_truncate(zv, tx, off, resid, sync); dmu_tx_commit(tx); error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ, off, resid); @@ -3118,9 +3118,9 @@ zvol_d_ioctl(struct cdev *dev, u_long cm { zvol_state_t *zv; rl_t *rl; - off_t offset, length, chunk; + off_t offset, length; int i, error; - u_int u; + boolean_t sync; zv = dev->si_drv2; @@ -3158,15 +3158,17 @@ zvol_d_ioctl(struct cdev *dev, u_long cm dmu_tx_t *tx = dmu_tx_create(zv->zv_objset); error = dmu_tx_assign(tx, TXG_WAIT); if (error != 0) { + sync = FALSE; dmu_tx_abort(tx); } else { - zvol_log_truncate(zv, tx, offset, length, B_TRUE); + sync = (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS); + zvol_log_truncate(zv, tx, offset, length, sync); dmu_tx_commit(tx); error = dmu_free_long_range(zv->zv_objset, ZVOL_OBJ, offset, length); } zfs_range_unlock(rl); - if (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS) + if (sync) zil_commit(zv->zv_zilog, ZVOL_OBJ); break; case DIOCGSTRIPESIZE: From owner-svn-src-head@freebsd.org Tue Nov 1 12:53:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2402C23DC4; Tue, 1 Nov 2016 12:53:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 67D4715D6; Tue, 1 Nov 2016 12:53:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id uA1CrBQ6066380 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 1 Nov 2016 14:53:11 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua uA1CrBQ6066380 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id uA1CrAkl066379; Tue, 1 Nov 2016 14:53:10 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 1 Nov 2016 14:53:10 +0200 From: Konstantin Belousov To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308026 - in head/sys: kern sys ufs/ffs Message-ID: <20161101125310.GD54029@kib.kiev.ua> References: <201610281143.u9SBhxrN008547@repo.freebsd.org> <20161101000246.GQ27748@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161101000246.GQ27748@FreeBSD.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 12:53:17 -0000 On Mon, Oct 31, 2016 at 05:02:46PM -0700, Gleb Smirnoff wrote: > Hi, > > On Fri, Oct 28, 2016 at 11:43:59AM +0000, Konstantin Belousov wrote: > K> Author: kib > K> Date: Fri Oct 28 11:43:59 2016 > K> New Revision: 308026 > K> URL: https://svnweb.freebsd.org/changeset/base/308026 > K> > K> Log: > K> Generalize UFS buffer pager to allow it serving other filesystems > K> which also use buffer cache. > K> > K> Most important addition to the code is the handling of filesystems > K> where the block size is less than the machine page size, which might > K> require reading several buffers to validate single page. > K> > K> Tested by: pho > K> Sponsored by: The FreeBSD Foundation > K> MFC after: 2 weeks > K> > K> Modified: > K> head/sys/kern/vfs_bio.c > K> head/sys/sys/buf.h > K> head/sys/ufs/ffs/ffs_vnops.c > K> > K> Modified: head/sys/kern/vfs_bio.c > K> ============================================================================== > K> --- head/sys/kern/vfs_bio.c Fri Oct 28 11:35:06 2016 (r308025) > K> +++ head/sys/kern/vfs_bio.c Fri Oct 28 11:43:59 2016 (r308026) > K> @@ -75,9 +75,10 @@ __FBSDID("$FreeBSD$"); > K> #include > K> #include > K> #include > K> -#include > K> -#include > K> #include > K> +#include > K> +#include > K> +#include > K> #include > K> #include > K> #include > K> @@ -4636,6 +4637,161 @@ bdata2bio(struct buf *bp, struct bio *bi > K> } > K> } > K> > K> +static int buf_pager_relbuf; > K> +SYSCTL_INT(_vfs, OID_AUTO, buf_pager_relbuf, CTLFLAG_RWTUN, > K> + &buf_pager_relbuf, 0, > K> + "Make buffer pager release buffers after reading"); > K> + > K> +/* > K> + * The buffer pager. It uses buffer reads to validate pages. > K> + * > K> + * In contrast to the generic local pager from vm/vnode_pager.c, this > K> + * pager correctly and easily handles volumes where the underlying > K> + * device block size is greater than the machine page size. The > K> + * buffer cache transparently extends the requested page run to be > K> + * aligned at the block boundary, and does the necessary bogus page > K> + * replacements in the addends to avoid obliterating already valid > K> + * pages. > K> + * > K> + * The only non-trivial issue is that the exclusive busy state for > K> + * pages, which is assumed by the vm_pager_getpages() interface, is > K> + * incompatible with the VMIO buffer cache's desire to share-busy the > K> + * pages. This function performs a trivial downgrade of the pages' > K> + * state before reading buffers, and a less trivial upgrade from the > K> + * shared-busy to excl-busy state after the read. > > IMHO, should be noted that the pager ignores requested rbehind and rahead > values, and does the rbehind and rahead sizes that he prefers. Pager interface considers the ahead/behind pages' page-in as unsignificant, in particular because the pages can be recycled or invalidated during the pager operation, when pager drops the object lock. More important, this pager de-facto uses the optimal filesystem-depended aligned io size due to its structure, comparing with the bmap pager. For this reason, I consider additional attempts to follow optional upper-level hints not very useful. Measurements show no difference in the real workload times, and marginal improvements for microbenchmarks (5% scale). I might do something more aggressive when upper-level specified rahead is (significantly) above the natural block size limit, like using breadn() instead of bread(). Practice suggests that this would not help or even be a pessimisation due to higher buf cache trashing. From owner-svn-src-head@freebsd.org Tue Nov 1 13:54:45 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94D53C27FC4; Tue, 1 Nov 2016 13:54:45 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 601041ECC; Tue, 1 Nov 2016 13:54:45 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1DsiO9067511; Tue, 1 Nov 2016 13:54:44 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1Dsio7067508; Tue, 1 Nov 2016 13:54:44 GMT (envelope-from br@FreeBSD.org) Message-Id: <201611011354.uA1Dsio7067508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 1 Nov 2016 13:54:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308170 - head/lib/libc/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 13:54:45 -0000 Author: br Date: Tue Nov 1 13:54:44 2016 New Revision: 308170 URL: https://svnweb.freebsd.org/changeset/base/308170 Log: Locale fix for endian big (EB) machines. We have locale files generated on EL machines (e.g. during cross-build on amd64 host), but then we are using them on EB machines (e.g. MIPS64EB), so proceed byte-swap if necessary. All the libc tests passed successfully, including Russian collation. Tested by: br@, Hongyan Xia Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8281 Added: head/lib/libc/locale/endian.h (contents, props changed) Modified: head/lib/libc/locale/collate.c head/lib/libc/locale/rune.c Modified: head/lib/libc/locale/collate.c ============================================================================== --- head/lib/libc/locale/collate.c Tue Nov 1 12:47:19 2016 (r308169) +++ head/lib/libc/locale/collate.c Tue Nov 1 13:54:44 2016 (r308170) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include "un-namespace.h" +#include "endian.h" #include "collate.h" #include "setlocale.h" #include "ldpart.h" @@ -160,7 +161,7 @@ __collate_load_tables_l(const char *enco if ((info->directive_count < 1) || (info->directive_count >= COLL_WEIGHTS_MAX) || - ((chains = info->chain_count) < 0)) { + ((chains = BSWAP(info->chain_count)) < 0)) { (void) munmap(map, sbuf.st_size); errno = EINVAL; return (_LDP_ERROR); @@ -168,9 +169,9 @@ __collate_load_tables_l(const char *enco i = (sizeof (collate_char_t) * (UCHAR_MAX + 1)) + (sizeof (collate_chain_t) * chains) + - (sizeof (collate_large_t) * info->large_count); + (sizeof (collate_large_t) * BSWAP(info->large_count)); for (z = 0; z < info->directive_count; z++) { - i += sizeof (collate_subst_t) * info->subst_count[z]; + i += sizeof (collate_subst_t) * BSWAP(info->subst_count[z]); } if (i != (sbuf.st_size - (TMP - map))) { (void) munmap(map, sbuf.st_size); @@ -183,9 +184,9 @@ __collate_load_tables_l(const char *enco TMP += sizeof (collate_char_t) * (UCHAR_MAX + 1); for (z = 0; z < info->directive_count; z++) { - if (info->subst_count[z] > 0) { + if (BSWAP(info->subst_count[z]) > 0) { table->subst_table[z] = (void *)TMP; - TMP += info->subst_count[z] * sizeof (collate_subst_t); + TMP += BSWAP(info->subst_count[z]) * sizeof (collate_subst_t); } else { table->subst_table[z] = NULL; } @@ -196,7 +197,7 @@ __collate_load_tables_l(const char *enco TMP += chains * sizeof (collate_chain_t); } else table->chain_pri_table = NULL; - if (info->large_count > 0) + if (BSWAP(info->large_count) > 0) table->large_pri_table = (void *)TMP; else table->large_pri_table = NULL; @@ -209,7 +210,7 @@ static const int32_t * substsearch(struct xlocale_collate *table, const wchar_t key, int pass) { const collate_subst_t *p; - int n = table->info->subst_count[pass]; + int n = BSWAP(table->info->subst_count[pass]); if (n == 0) return (NULL); @@ -221,7 +222,8 @@ substsearch(struct xlocale_collate *tabl return (NULL); p = table->subst_table[pass] + (key & ~COLLATE_SUBST_PRIORITY); - assert(p->key == key); + assert(BSWAP(p->key) == key); + return (p->pri); } @@ -229,7 +231,7 @@ static collate_chain_t * chainsearch(struct xlocale_collate *table, const wchar_t *key, int *len) { int low = 0; - int high = table->info->chain_count - 1;; + int high = BSWAP(table->info->chain_count) - 1; int next, compar, l; collate_chain_t *p; collate_chain_t *tab = table->chain_pri_table; @@ -240,7 +242,7 @@ chainsearch(struct xlocale_collate *tabl while (low <= high) { next = (low + high) / 2; p = tab + next; - compar = *key - *p->str; + compar = *key - le16toh(*p->str); if (compar == 0) { l = wcsnlen(p->str, COLLATE_STR_LEN); compar = wcsncmp(key, p->str, l); @@ -261,7 +263,7 @@ static collate_large_t * largesearch(struct xlocale_collate *table, const wchar_t key) { int low = 0; - int high = table->info->large_count - 1; + int high = BSWAP(table->info->large_count) - 1; int next, compar; collate_large_t *p; collate_large_t *tab = table->large_pri_table; @@ -272,7 +274,7 @@ largesearch(struct xlocale_collate *tabl while (low <= high) { next = (low + high) / 2; p = tab + next; - compar = key - p->val; + compar = key - BSWAP(p->val); if (compar == 0) return (p); if (compar > 0) @@ -337,15 +339,15 @@ _collate_lookup(struct xlocale_collate * * Character is a small (8-bit) character. * We just look these up directly for speed. */ - *pri = table->char_pri_table[*t].pri[which]; + *pri = BSWAP(table->char_pri_table[*t].pri[which]); - } else if ((table->info->large_count > 0) && + } else if ((BSWAP(table->info->large_count) > 0) && ((match = largesearch(table, *t)) != NULL)) { /* * Character was found in the extended table. */ - *pri = match->pri.pri[which]; + *pri = BSWAP(match->pri.pri[which]); } else { /* @@ -355,7 +357,7 @@ _collate_lookup(struct xlocale_collate * /* Mask off sign bit to prevent ordering confusion. */ *pri = (*t & COLLATE_MAX_PRIORITY); } else { - *pri = table->info->undef_pri[which]; + *pri = BSWAP(table->info->undef_pri[which]); } /* No substitutions for undefined characters! */ return; @@ -374,9 +376,9 @@ _collate_lookup(struct xlocale_collate * * code ensures this for us. */ if ((sptr = substsearch(table, *pri, which)) != NULL) { - if ((*pri = *sptr) > 0) { + if ((*pri = BSWAP(*sptr)) > 0) { sptr++; - *state = *sptr ? sptr : NULL; + *state = BSWAP(*sptr) ? sptr : NULL; } } @@ -518,7 +520,7 @@ static int xfrm(struct xlocale_collate *table, unsigned char *p, int pri, int pass) { /* we use unsigned to ensure zero fill on right shift */ - uint32_t val = (uint32_t)table->info->pri_count[pass]; + uint32_t val = BSWAP((uint32_t)table->info->pri_count[pass]); int nc = 0; while (val) { @@ -678,7 +680,7 @@ __collate_equiv_value(locale_t locale, c e = -1; if (*str <= UCHAR_MAX) e = table->char_pri_table[*str].pri[0]; - else if (table->info->large_count > 0) { + else if (BSWAP(table->info->large_count) > 0) { collate_large_t *match_large; match_large = largesearch(table, *str); if (match_large) @@ -688,7 +690,7 @@ __collate_equiv_value(locale_t locale, c return (1); return (e > 0 ? e : 0); } - if (table->info->chain_count > 0) { + if (BSWAP(table->info->chain_count) > 0) { wchar_t name[COLLATE_STR_LEN]; collate_chain_t *match_chain; int clen; Added: head/lib/libc/locale/endian.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/locale/endian.h Tue Nov 1 13:54:44 2016 (r308170) @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2016 Ruslan Bukin + * All rights reserved. + * + * Portions of this software were 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. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +/* + * We assume locale files were generated on EL machine + * (e.g. during cross build on amd64 host), but used on EB + * machine (e.g. MIPS64EB), so convert it to host endianness. + * + * TODO: detect host endianness on the build machine and use + * correct macros here. + */ + +#if BYTE_ORDER == BIG_ENDIAN && defined(__mips__) +#define BSWAP(x) le32toh(x) +#else +#define BSWAP(x) x +#endif Modified: head/lib/libc/locale/rune.c ============================================================================== --- head/lib/libc/locale/rune.c Tue Nov 1 12:47:19 2016 (r308169) +++ head/lib/libc/locale/rune.c Tue Nov 1 13:54:44 2016 (r308170) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include "un-namespace.h" +#include "endian.h" #include "runefile.h" _RuneLocale * @@ -107,29 +108,29 @@ _Read_RuneMagi(const char *fname) } runetype_ext_ranges = (_FileRuneEntry *)variable; - variable = runetype_ext_ranges + frl->runetype_ext_nranges; + variable = runetype_ext_ranges + BSWAP(frl->runetype_ext_nranges); if (variable > lastp) { goto invalid; } maplower_ext_ranges = (_FileRuneEntry *)variable; - variable = maplower_ext_ranges + frl->maplower_ext_nranges; + variable = maplower_ext_ranges + BSWAP(frl->maplower_ext_nranges); if (variable > lastp) { goto invalid; } mapupper_ext_ranges = (_FileRuneEntry *)variable; - variable = mapupper_ext_ranges + frl->mapupper_ext_nranges; + variable = mapupper_ext_ranges + BSWAP(frl->mapupper_ext_nranges); if (variable > lastp) { goto invalid; } frr = runetype_ext_ranges; - for (x = 0; x < frl->runetype_ext_nranges; ++x) { + for (x = 0; x < BSWAP(frl->runetype_ext_nranges); ++x) { uint32_t *types; - if (frr[x].map == 0) { - int len = frr[x].max - frr[x].min + 1; + if (BSWAP(frr[x].map) == 0) { + int len = BSWAP(frr[x].max) - BSWAP(frr[x].min) + 1; types = variable; variable = types + len; runetype_ext_len += len; @@ -139,7 +140,7 @@ _Read_RuneMagi(const char *fname) } } - if ((char *)variable + frl->variable_len > (char *)lastp) { + if ((char *)variable + BSWAP(frl->variable_len) > (char *)lastp) { goto invalid; } @@ -147,10 +148,10 @@ _Read_RuneMagi(const char *fname) * Convert from disk format to host format. */ data = malloc(sizeof(_RuneLocale) + - (frl->runetype_ext_nranges + frl->maplower_ext_nranges + - frl->mapupper_ext_nranges) * sizeof(_RuneEntry) + + (BSWAP(frl->runetype_ext_nranges) + BSWAP(frl->maplower_ext_nranges) + + BSWAP(frl->mapupper_ext_nranges)) * sizeof(_RuneEntry) + runetype_ext_len * sizeof(*rr->__types) + - frl->variable_len); + BSWAP(frl->variable_len)); if (data == NULL) { saverr = errno; munmap(fdata, sb.st_size); @@ -164,15 +165,15 @@ _Read_RuneMagi(const char *fname) memcpy(rl->__magic, _RUNE_MAGIC_1, sizeof(rl->__magic)); memcpy(rl->__encoding, frl->encoding, sizeof(rl->__encoding)); - rl->__variable_len = frl->variable_len; - rl->__runetype_ext.__nranges = frl->runetype_ext_nranges; - rl->__maplower_ext.__nranges = frl->maplower_ext_nranges; - rl->__mapupper_ext.__nranges = frl->mapupper_ext_nranges; + rl->__variable_len = BSWAP(frl->variable_len); + rl->__runetype_ext.__nranges = BSWAP(frl->runetype_ext_nranges); + rl->__maplower_ext.__nranges = BSWAP(frl->maplower_ext_nranges); + rl->__mapupper_ext.__nranges = BSWAP(frl->mapupper_ext_nranges); for (x = 0; x < _CACHED_RUNES; ++x) { - rl->__runetype[x] = frl->runetype[x]; - rl->__maplower[x] = frl->maplower[x]; - rl->__mapupper[x] = frl->mapupper[x]; + rl->__runetype[x] = BSWAP(frl->runetype[x]); + rl->__maplower[x] = BSWAP(frl->maplower[x]); + rl->__mapupper[x] = BSWAP(frl->mapupper[x]); } rl->__runetype_ext.__ranges = (_RuneEntry *)rl->__variable; @@ -187,15 +188,15 @@ _Read_RuneMagi(const char *fname) rl->__variable = rl->__mapupper_ext.__ranges + rl->__mapupper_ext.__nranges; - variable = mapupper_ext_ranges + frl->mapupper_ext_nranges; + variable = mapupper_ext_ranges + BSWAP(frl->mapupper_ext_nranges); frr = runetype_ext_ranges; rr = rl->__runetype_ext.__ranges; for (x = 0; x < rl->__runetype_ext.__nranges; ++x) { uint32_t *types; - rr[x].__min = frr[x].min; - rr[x].__max = frr[x].max; - rr[x].__map = frr[x].map; + rr[x].__min = BSWAP(frr[x].min); + rr[x].__max = BSWAP(frr[x].max); + rr[x].__map = BSWAP(frr[x].map); if (rr[x].__map == 0) { int len = rr[x].__max - rr[x].__min + 1; types = variable; @@ -211,17 +212,17 @@ _Read_RuneMagi(const char *fname) frr = maplower_ext_ranges; rr = rl->__maplower_ext.__ranges; for (x = 0; x < rl->__maplower_ext.__nranges; ++x) { - rr[x].__min = frr[x].min; - rr[x].__max = frr[x].max; - rr[x].__map = frr[x].map; + rr[x].__min = BSWAP(frr[x].min); + rr[x].__max = BSWAP(frr[x].max); + rr[x].__map = BSWAP(frr[x].map); } frr = mapupper_ext_ranges; rr = rl->__mapupper_ext.__ranges; for (x = 0; x < rl->__mapupper_ext.__nranges; ++x) { - rr[x].__min = frr[x].min; - rr[x].__max = frr[x].max; - rr[x].__map = frr[x].map; + rr[x].__min = BSWAP(frr[x].min); + rr[x].__max = BSWAP(frr[x].max); + rr[x].__map = BSWAP(frr[x].map); } memcpy(rl->__variable, variable, rl->__variable_len); From owner-svn-src-head@freebsd.org Tue Nov 1 14:50:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E93CBC280CD; Tue, 1 Nov 2016 14:50:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD39C1B88; Tue, 1 Nov 2016 14:50:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1EoWSw086882; Tue, 1 Nov 2016 14:50:32 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1EoWFU086881; Tue, 1 Nov 2016 14:50:32 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611011450.uA1EoWFU086881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 1 Nov 2016 14:50:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308171 - head/release/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 14:50:34 -0000 Author: emaste Date: Tue Nov 1 14:50:32 2016 New Revision: 308171 URL: https://svnweb.freebsd.org/changeset/base/308171 Log: arm64 make-memstick.sh: use 'set -e' to abort if any step fails Also remove the now-redundant error handling that was only for makefs. This script was run on an older FreeBSD host that lacked efi-on-mbr support in makefs. A warning was emitted on the console (from makefs) but the script continued running and exited with 0. Reviewed by: gjb Sponsored by: The FreeBSD Foundation Modified: head/release/arm64/make-memstick.sh Modified: head/release/arm64/make-memstick.sh ============================================================================== --- head/release/arm64/make-memstick.sh Tue Nov 1 13:54:44 2016 (r308170) +++ head/release/arm64/make-memstick.sh Tue Nov 1 14:50:32 2016 (r308171) @@ -10,6 +10,8 @@ # $FreeBSD$ # +set -e + PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH @@ -31,10 +33,6 @@ fi echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab echo 'root_rw_mount="NO"' > ${1}/etc/rc.conf.local makefs -B little -o label=FreeBSD_Install ${2}.part ${1} -if [ $? -ne 0 ]; then - echo "makefs failed" - exit 1 -fi rm ${1}/etc/fstab rm ${1}/etc/rc.conf.local From owner-svn-src-head@freebsd.org Tue Nov 1 15:11:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1E8BC28A8A; Tue, 1 Nov 2016 15:11:11 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5753D121A; Tue, 1 Nov 2016 15:11:11 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1FBA6q095148; Tue, 1 Nov 2016 15:11:10 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1FBA0Z095146; Tue, 1 Nov 2016 15:11:10 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611011511.uA1FBA0Z095146@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 1 Nov 2016 15:11:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308172 - head/lib/msun/ld80 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 15:11:11 -0000 Author: emaste Date: Tue Nov 1 15:11:10 2016 New Revision: 308172 URL: https://svnweb.freebsd.org/changeset/base/308172 Log: libm: add braces around initialization of subobjects This cleans up a warning when building libm at higher WARNS levels and makes the intent more clear. By the C standard the values are assigned to subobject members in order so this change introduces no functional change. (6.7.9 20) Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8333 Modified: head/lib/msun/ld80/k_expl.h head/lib/msun/ld80/s_logl.c Modified: head/lib/msun/ld80/k_expl.h ============================================================================== --- head/lib/msun/ld80/k_expl.h Tue Nov 1 14:50:32 2016 (r308171) +++ head/lib/msun/ld80/k_expl.h Tue Nov 1 15:11:10 2016 (r308172) @@ -75,140 +75,140 @@ static const struct { double hi; double lo; } tbl[INTERVALS] = { - 0x1p+0, 0x0p+0, + { 0x1p+0, 0x0p+0 }, /* * XXX hi is rounded down, and the formatting is not quite normal. * But I rather like both. The 0x1.*p format is good for 4N+1 * mantissa bits. Rounding down makes the lo terms positive, * so that the columnar formatting can be simpler. */ - 0x1.0163da9fb3335p+0, 0x1.b61299ab8cdb7p-54, - 0x1.02c9a3e778060p+0, 0x1.dcdef95949ef4p-53, - 0x1.04315e86e7f84p+0, 0x1.7ae71f3441b49p-53, - 0x1.059b0d3158574p+0, 0x1.d73e2a475b465p-55, - 0x1.0706b29ddf6ddp+0, 0x1.8db880753b0f6p-53, - 0x1.0874518759bc8p+0, 0x1.186be4bb284ffp-57, - 0x1.09e3ecac6f383p+0, 0x1.1487818316136p-54, - 0x1.0b5586cf9890fp+0, 0x1.8a62e4adc610bp-54, - 0x1.0cc922b7247f7p+0, 0x1.01edc16e24f71p-54, - 0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c57b53p-59, - 0x1.0fb66affed31ap+0, 0x1.e464123bb1428p-53, - 0x1.11301d0125b50p+0, 0x1.49d77e35db263p-53, - 0x1.12abdc06c31cbp+0, 0x1.f72575a649ad2p-53, - 0x1.1429aaea92ddfp+0, 0x1.66820328764b1p-53, - 0x1.15a98c8a58e51p+0, 0x1.2406ab9eeab0ap-55, - 0x1.172b83c7d517ap+0, 0x1.b9bef918a1d63p-53, - 0x1.18af9388c8de9p+0, 0x1.777ee1734784ap-53, - 0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4968e4p-55, - 0x1.1bbe084045cd3p+0, 0x1.3563ce56884fcp-53, - 0x1.1d4873168b9aap+0, 0x1.e016e00a2643cp-54, - 0x1.1ed5022fcd91cp+0, 0x1.71033fec2243ap-53, - 0x1.2063b88628cd6p+0, 0x1.dc775814a8495p-55, - 0x1.21f49917ddc96p+0, 0x1.2a97e9494a5eep-55, - 0x1.2387a6e756238p+0, 0x1.9b07eb6c70573p-54, - 0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f4a4p-55, - 0x1.26b4565e27cddp+0, 0x1.2bd339940e9d9p-55, - 0x1.284dfe1f56380p+0, 0x1.2d9e2b9e07941p-53, - 0x1.29e9df51fdee1p+0, 0x1.612e8afad1255p-55, - 0x1.2b87fd0dad98fp+0, 0x1.fbbd48ca71f95p-53, - 0x1.2d285a6e4030bp+0, 0x1.0024754db41d5p-54, - 0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d52383p-56, - 0x1.306fe0a31b715p+0, 0x1.6f46ad23182e4p-55, - 0x1.32170fc4cd831p+0, 0x1.a9ce78e18047cp-55, - 0x1.33c08b26416ffp+0, 0x1.32721843659a6p-54, - 0x1.356c55f929ff0p+0, 0x1.928c468ec6e76p-53, - 0x1.371a7373aa9cap+0, 0x1.4e28aa05e8a8fp-53, - 0x1.38cae6d05d865p+0, 0x1.0b53961b37da2p-53, - 0x1.3a7db34e59ff6p+0, 0x1.d43792533c144p-53, - 0x1.3c32dc313a8e4p+0, 0x1.08003e4516b1ep-53, - 0x1.3dea64c123422p+0, 0x1.ada0911f09ebcp-55, - 0x1.3fa4504ac801bp+0, 0x1.417ee03548306p-53, - 0x1.4160a21f72e29p+0, 0x1.f0864b71e7b6cp-53, - 0x1.431f5d950a896p+0, 0x1.b8e088728219ap-53, - 0x1.44e086061892dp+0, 0x1.89b7a04ef80d0p-59, - 0x1.46a41ed1d0057p+0, 0x1.c944bd1648a76p-54, - 0x1.486a2b5c13cd0p+0, 0x1.3c1a3b69062f0p-56, - 0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be56p-54, - 0x1.4bfdad5362a27p+0, 0x1.d4397afec42e2p-56, - 0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a7833p-54, - 0x1.4f9b2769d2ca6p+0, 0x1.5a67b16d3540ep-53, - 0x1.516daa2cf6641p+0, 0x1.8225ea5909b04p-53, - 0x1.5342b569d4f81p+0, 0x1.be1507893b0d5p-53, - 0x1.551a4ca5d920ep+0, 0x1.8a5d8c4048699p-53, - 0x1.56f4736b527dap+0, 0x1.9bb2c011d93adp-54, - 0x1.58d12d497c7fdp+0, 0x1.295e15b9a1de8p-55, - 0x1.5ab07dd485429p+0, 0x1.6324c054647adp-54, - 0x1.5c9268a5946b7p+0, 0x1.c4b1b816986a2p-60, - 0x1.5e76f15ad2148p+0, 0x1.ba6f93080e65ep-54, - 0x1.605e1b976dc08p+0, 0x1.60edeb25490dcp-53, - 0x1.6247eb03a5584p+0, 0x1.63e1f40dfa5b5p-53, - 0x1.6434634ccc31fp+0, 0x1.8edf0e2989db3p-53, - 0x1.6623882552224p+0, 0x1.224fb3c5371e6p-53, - 0x1.68155d44ca973p+0, 0x1.038ae44f73e65p-57, - 0x1.6a09e667f3bccp+0, 0x1.21165f626cdd5p-53, - 0x1.6c012750bdabep+0, 0x1.daed533001e9ep-53, - 0x1.6dfb23c651a2ep+0, 0x1.e441c597c3775p-53, - 0x1.6ff7df9519483p+0, 0x1.9f0fc369e7c42p-53, - 0x1.71f75e8ec5f73p+0, 0x1.ba46e1e5de15ap-53, - 0x1.73f9a48a58173p+0, 0x1.7ab9349cd1562p-53, - 0x1.75feb564267c8p+0, 0x1.7edd354674916p-53, - 0x1.780694fde5d3fp+0, 0x1.866b80a02162dp-54, - 0x1.7a11473eb0186p+0, 0x1.afaa2047ed9b4p-53, - 0x1.7c1ed0130c132p+0, 0x1.f124cd1164dd6p-54, - 0x1.7e2f336cf4e62p+0, 0x1.05d02ba15797ep-56, - 0x1.80427543e1a11p+0, 0x1.6c1bccec9346bp-53, - 0x1.82589994cce12p+0, 0x1.159f115f56694p-53, - 0x1.8471a4623c7acp+0, 0x1.9ca5ed72f8c81p-53, - 0x1.868d99b4492ecp+0, 0x1.01c83b21584a3p-53, - 0x1.88ac7d98a6699p+0, 0x1.994c2f37cb53ap-54, - 0x1.8ace5422aa0dbp+0, 0x1.6e9f156864b27p-54, - 0x1.8cf3216b5448bp+0, 0x1.de55439a2c38bp-53, - 0x1.8f1ae99157736p+0, 0x1.5cc13a2e3976cp-55, - 0x1.9145b0b91ffc5p+0, 0x1.114c368d3ed6ep-53, - 0x1.93737b0cdc5e4p+0, 0x1.e8a0387e4a814p-53, - 0x1.95a44cbc8520ep+0, 0x1.d36906d2b41f9p-53, - 0x1.97d829fde4e4fp+0, 0x1.173d241f23d18p-53, - 0x1.9a0f170ca07b9p+0, 0x1.7462137188ce7p-53, - 0x1.9c49182a3f090p+0, 0x1.c7c46b071f2bep-56, - 0x1.9e86319e32323p+0, 0x1.824ca78e64c6ep-56, - 0x1.a0c667b5de564p+0, 0x1.6535b51719567p-53, - 0x1.a309bec4a2d33p+0, 0x1.6305c7ddc36abp-54, - 0x1.a5503b23e255cp+0, 0x1.1684892395f0fp-53, - 0x1.a799e1330b358p+0, 0x1.bcb7ecac563c7p-54, - 0x1.a9e6b5579fdbfp+0, 0x1.0fac90ef7fd31p-54, - 0x1.ac36bbfd3f379p+0, 0x1.81b72cd4624ccp-53, - 0x1.ae89f995ad3adp+0, 0x1.7a1cd345dcc81p-54, - 0x1.b0e07298db665p+0, 0x1.2108559bf8deep-53, - 0x1.b33a2b84f15fap+0, 0x1.ed7fa1cf7b290p-53, - 0x1.b59728de55939p+0, 0x1.1c7102222c90ep-53, - 0x1.b7f76f2fb5e46p+0, 0x1.d54f610356a79p-53, - 0x1.ba5b030a10649p+0, 0x1.0819678d5eb69p-53, - 0x1.bcc1e904bc1d2p+0, 0x1.23dd07a2d9e84p-55, - 0x1.bf2c25bd71e08p+0, 0x1.0811ae04a31c7p-53, - 0x1.c199bdd85529cp+0, 0x1.11065895048ddp-55, - 0x1.c40ab5fffd07ap+0, 0x1.b4537e083c60ap-54, - 0x1.c67f12e57d14bp+0, 0x1.2884dff483cadp-54, - 0x1.c8f6d9406e7b5p+0, 0x1.1acbc48805c44p-56, - 0x1.cb720dcef9069p+0, 0x1.503cbd1e949dbp-56, - 0x1.cdf0b555dc3f9p+0, 0x1.889f12b1f58a3p-53, - 0x1.d072d4a07897bp+0, 0x1.1a1e45e4342b2p-53, - 0x1.d2f87080d89f1p+0, 0x1.15bc247313d44p-53, - 0x1.d5818dcfba487p+0, 0x1.2ed02d75b3707p-55, - 0x1.d80e316c98397p+0, 0x1.7709f3a09100cp-53, - 0x1.da9e603db3285p+0, 0x1.c2300696db532p-54, - 0x1.dd321f301b460p+0, 0x1.2da5778f018c3p-54, - 0x1.dfc97337b9b5ep+0, 0x1.72d195873da52p-53, - 0x1.e264614f5a128p+0, 0x1.424ec3f42f5b5p-53, - 0x1.e502ee78b3ff6p+0, 0x1.39e8980a9cc8fp-55, - 0x1.e7a51fbc74c83p+0, 0x1.2d522ca0c8de2p-54, - 0x1.ea4afa2a490d9p+0, 0x1.0b1ee7431ebb6p-53, - 0x1.ecf482d8e67f0p+0, 0x1.1b60625f7293ap-53, - 0x1.efa1bee615a27p+0, 0x1.dc7f486a4b6b0p-54, - 0x1.f252b376bba97p+0, 0x1.3a1a5bf0d8e43p-54, - 0x1.f50765b6e4540p+0, 0x1.9d3e12dd8a18bp-54, - 0x1.f7bfdad9cbe13p+0, 0x1.1227697fce57bp-53, - 0x1.fa7c1819e90d8p+0, 0x1.74853f3a5931ep-55, - 0x1.fd3c22b8f71f1p+0, 0x1.2eb74966579e7p-57 + { 0x1.0163da9fb3335p+0, 0x1.b61299ab8cdb7p-54 }, + { 0x1.02c9a3e778060p+0, 0x1.dcdef95949ef4p-53 }, + { 0x1.04315e86e7f84p+0, 0x1.7ae71f3441b49p-53 }, + { 0x1.059b0d3158574p+0, 0x1.d73e2a475b465p-55 }, + { 0x1.0706b29ddf6ddp+0, 0x1.8db880753b0f6p-53 }, + { 0x1.0874518759bc8p+0, 0x1.186be4bb284ffp-57 }, + { 0x1.09e3ecac6f383p+0, 0x1.1487818316136p-54 }, + { 0x1.0b5586cf9890fp+0, 0x1.8a62e4adc610bp-54 }, + { 0x1.0cc922b7247f7p+0, 0x1.01edc16e24f71p-54 }, + { 0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c57b53p-59 }, + { 0x1.0fb66affed31ap+0, 0x1.e464123bb1428p-53 }, + { 0x1.11301d0125b50p+0, 0x1.49d77e35db263p-53 }, + { 0x1.12abdc06c31cbp+0, 0x1.f72575a649ad2p-53 }, + { 0x1.1429aaea92ddfp+0, 0x1.66820328764b1p-53 }, + { 0x1.15a98c8a58e51p+0, 0x1.2406ab9eeab0ap-55 }, + { 0x1.172b83c7d517ap+0, 0x1.b9bef918a1d63p-53 }, + { 0x1.18af9388c8de9p+0, 0x1.777ee1734784ap-53 }, + { 0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4968e4p-55 }, + { 0x1.1bbe084045cd3p+0, 0x1.3563ce56884fcp-53 }, + { 0x1.1d4873168b9aap+0, 0x1.e016e00a2643cp-54 }, + { 0x1.1ed5022fcd91cp+0, 0x1.71033fec2243ap-53 }, + { 0x1.2063b88628cd6p+0, 0x1.dc775814a8495p-55 }, + { 0x1.21f49917ddc96p+0, 0x1.2a97e9494a5eep-55 }, + { 0x1.2387a6e756238p+0, 0x1.9b07eb6c70573p-54 }, + { 0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f4a4p-55 }, + { 0x1.26b4565e27cddp+0, 0x1.2bd339940e9d9p-55 }, + { 0x1.284dfe1f56380p+0, 0x1.2d9e2b9e07941p-53 }, + { 0x1.29e9df51fdee1p+0, 0x1.612e8afad1255p-55 }, + { 0x1.2b87fd0dad98fp+0, 0x1.fbbd48ca71f95p-53 }, + { 0x1.2d285a6e4030bp+0, 0x1.0024754db41d5p-54 }, + { 0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d52383p-56 }, + { 0x1.306fe0a31b715p+0, 0x1.6f46ad23182e4p-55 }, + { 0x1.32170fc4cd831p+0, 0x1.a9ce78e18047cp-55 }, + { 0x1.33c08b26416ffp+0, 0x1.32721843659a6p-54 }, + { 0x1.356c55f929ff0p+0, 0x1.928c468ec6e76p-53 }, + { 0x1.371a7373aa9cap+0, 0x1.4e28aa05e8a8fp-53 }, + { 0x1.38cae6d05d865p+0, 0x1.0b53961b37da2p-53 }, + { 0x1.3a7db34e59ff6p+0, 0x1.d43792533c144p-53 }, + { 0x1.3c32dc313a8e4p+0, 0x1.08003e4516b1ep-53 }, + { 0x1.3dea64c123422p+0, 0x1.ada0911f09ebcp-55 }, + { 0x1.3fa4504ac801bp+0, 0x1.417ee03548306p-53 }, + { 0x1.4160a21f72e29p+0, 0x1.f0864b71e7b6cp-53 }, + { 0x1.431f5d950a896p+0, 0x1.b8e088728219ap-53 }, + { 0x1.44e086061892dp+0, 0x1.89b7a04ef80d0p-59 }, + { 0x1.46a41ed1d0057p+0, 0x1.c944bd1648a76p-54 }, + { 0x1.486a2b5c13cd0p+0, 0x1.3c1a3b69062f0p-56 }, + { 0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be56p-54 }, + { 0x1.4bfdad5362a27p+0, 0x1.d4397afec42e2p-56 }, + { 0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a7833p-54 }, + { 0x1.4f9b2769d2ca6p+0, 0x1.5a67b16d3540ep-53 }, + { 0x1.516daa2cf6641p+0, 0x1.8225ea5909b04p-53 }, + { 0x1.5342b569d4f81p+0, 0x1.be1507893b0d5p-53 }, + { 0x1.551a4ca5d920ep+0, 0x1.8a5d8c4048699p-53 }, + { 0x1.56f4736b527dap+0, 0x1.9bb2c011d93adp-54 }, + { 0x1.58d12d497c7fdp+0, 0x1.295e15b9a1de8p-55 }, + { 0x1.5ab07dd485429p+0, 0x1.6324c054647adp-54 }, + { 0x1.5c9268a5946b7p+0, 0x1.c4b1b816986a2p-60 }, + { 0x1.5e76f15ad2148p+0, 0x1.ba6f93080e65ep-54 }, + { 0x1.605e1b976dc08p+0, 0x1.60edeb25490dcp-53 }, + { 0x1.6247eb03a5584p+0, 0x1.63e1f40dfa5b5p-53 }, + { 0x1.6434634ccc31fp+0, 0x1.8edf0e2989db3p-53 }, + { 0x1.6623882552224p+0, 0x1.224fb3c5371e6p-53 }, + { 0x1.68155d44ca973p+0, 0x1.038ae44f73e65p-57 }, + { 0x1.6a09e667f3bccp+0, 0x1.21165f626cdd5p-53 }, + { 0x1.6c012750bdabep+0, 0x1.daed533001e9ep-53 }, + { 0x1.6dfb23c651a2ep+0, 0x1.e441c597c3775p-53 }, + { 0x1.6ff7df9519483p+0, 0x1.9f0fc369e7c42p-53 }, + { 0x1.71f75e8ec5f73p+0, 0x1.ba46e1e5de15ap-53 }, + { 0x1.73f9a48a58173p+0, 0x1.7ab9349cd1562p-53 }, + { 0x1.75feb564267c8p+0, 0x1.7edd354674916p-53 }, + { 0x1.780694fde5d3fp+0, 0x1.866b80a02162dp-54 }, + { 0x1.7a11473eb0186p+0, 0x1.afaa2047ed9b4p-53 }, + { 0x1.7c1ed0130c132p+0, 0x1.f124cd1164dd6p-54 }, + { 0x1.7e2f336cf4e62p+0, 0x1.05d02ba15797ep-56 }, + { 0x1.80427543e1a11p+0, 0x1.6c1bccec9346bp-53 }, + { 0x1.82589994cce12p+0, 0x1.159f115f56694p-53 }, + { 0x1.8471a4623c7acp+0, 0x1.9ca5ed72f8c81p-53 }, + { 0x1.868d99b4492ecp+0, 0x1.01c83b21584a3p-53 }, + { 0x1.88ac7d98a6699p+0, 0x1.994c2f37cb53ap-54 }, + { 0x1.8ace5422aa0dbp+0, 0x1.6e9f156864b27p-54 }, + { 0x1.8cf3216b5448bp+0, 0x1.de55439a2c38bp-53 }, + { 0x1.8f1ae99157736p+0, 0x1.5cc13a2e3976cp-55 }, + { 0x1.9145b0b91ffc5p+0, 0x1.114c368d3ed6ep-53 }, + { 0x1.93737b0cdc5e4p+0, 0x1.e8a0387e4a814p-53 }, + { 0x1.95a44cbc8520ep+0, 0x1.d36906d2b41f9p-53 }, + { 0x1.97d829fde4e4fp+0, 0x1.173d241f23d18p-53 }, + { 0x1.9a0f170ca07b9p+0, 0x1.7462137188ce7p-53 }, + { 0x1.9c49182a3f090p+0, 0x1.c7c46b071f2bep-56 }, + { 0x1.9e86319e32323p+0, 0x1.824ca78e64c6ep-56 }, + { 0x1.a0c667b5de564p+0, 0x1.6535b51719567p-53 }, + { 0x1.a309bec4a2d33p+0, 0x1.6305c7ddc36abp-54 }, + { 0x1.a5503b23e255cp+0, 0x1.1684892395f0fp-53 }, + { 0x1.a799e1330b358p+0, 0x1.bcb7ecac563c7p-54 }, + { 0x1.a9e6b5579fdbfp+0, 0x1.0fac90ef7fd31p-54 }, + { 0x1.ac36bbfd3f379p+0, 0x1.81b72cd4624ccp-53 }, + { 0x1.ae89f995ad3adp+0, 0x1.7a1cd345dcc81p-54 }, + { 0x1.b0e07298db665p+0, 0x1.2108559bf8deep-53 }, + { 0x1.b33a2b84f15fap+0, 0x1.ed7fa1cf7b290p-53 }, + { 0x1.b59728de55939p+0, 0x1.1c7102222c90ep-53 }, + { 0x1.b7f76f2fb5e46p+0, 0x1.d54f610356a79p-53 }, + { 0x1.ba5b030a10649p+0, 0x1.0819678d5eb69p-53 }, + { 0x1.bcc1e904bc1d2p+0, 0x1.23dd07a2d9e84p-55 }, + { 0x1.bf2c25bd71e08p+0, 0x1.0811ae04a31c7p-53 }, + { 0x1.c199bdd85529cp+0, 0x1.11065895048ddp-55 }, + { 0x1.c40ab5fffd07ap+0, 0x1.b4537e083c60ap-54 }, + { 0x1.c67f12e57d14bp+0, 0x1.2884dff483cadp-54 }, + { 0x1.c8f6d9406e7b5p+0, 0x1.1acbc48805c44p-56 }, + { 0x1.cb720dcef9069p+0, 0x1.503cbd1e949dbp-56 }, + { 0x1.cdf0b555dc3f9p+0, 0x1.889f12b1f58a3p-53 }, + { 0x1.d072d4a07897bp+0, 0x1.1a1e45e4342b2p-53 }, + { 0x1.d2f87080d89f1p+0, 0x1.15bc247313d44p-53 }, + { 0x1.d5818dcfba487p+0, 0x1.2ed02d75b3707p-55 }, + { 0x1.d80e316c98397p+0, 0x1.7709f3a09100cp-53 }, + { 0x1.da9e603db3285p+0, 0x1.c2300696db532p-54 }, + { 0x1.dd321f301b460p+0, 0x1.2da5778f018c3p-54 }, + { 0x1.dfc97337b9b5ep+0, 0x1.72d195873da52p-53 }, + { 0x1.e264614f5a128p+0, 0x1.424ec3f42f5b5p-53 }, + { 0x1.e502ee78b3ff6p+0, 0x1.39e8980a9cc8fp-55 }, + { 0x1.e7a51fbc74c83p+0, 0x1.2d522ca0c8de2p-54 }, + { 0x1.ea4afa2a490d9p+0, 0x1.0b1ee7431ebb6p-53 }, + { 0x1.ecf482d8e67f0p+0, 0x1.1b60625f7293ap-53 }, + { 0x1.efa1bee615a27p+0, 0x1.dc7f486a4b6b0p-54 }, + { 0x1.f252b376bba97p+0, 0x1.3a1a5bf0d8e43p-54 }, + { 0x1.f50765b6e4540p+0, 0x1.9d3e12dd8a18bp-54 }, + { 0x1.f7bfdad9cbe13p+0, 0x1.1227697fce57bp-53 }, + { 0x1.fa7c1819e90d8p+0, 0x1.74853f3a5931ep-55 }, + { 0x1.fd3c22b8f71f1p+0, 0x1.2eb74966579e7p-57 } }; /* Modified: head/lib/msun/ld80/s_logl.c ============================================================================== --- head/lib/msun/ld80/s_logl.c Tue Nov 1 14:50:32 2016 (r308171) +++ head/lib/msun/ld80/s_logl.c Tue Nov 1 15:11:10 2016 (r308172) @@ -152,135 +152,135 @@ static const struct { * mainly to minimize the size of the table. Using all 24 bits * in a float for it automatically satisfies the above constraints. */ - 0x800000.0p-23, 0, 0, - 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6675.0p-84, - 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83718.0p-84, - 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173698.0p-83, - 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e79.0p-82, - 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7c.0p-82, - 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a1076.0p-83, - 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb9589.0p-82, - 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c5.0p-91, - 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560e.0p-81, - 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d503.0p-82, - 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a.0p-83, - 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da9a.0p-81, - 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150b.0p-83, - 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251af0.0p-85, - 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d5.0p-84, - 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e676.0p-81, - 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f42.0p-82, - 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6b00.0p-80, - 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1e.0p-83, - 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b4.0p-82, - 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9.0p-80, - 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c47.0p-82, - 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e569.0p-81, - 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba936770.0p-84, - 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d32.0p-80, - 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b7.0p-81, - 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06.0p-80, - 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3b0.0p-82, - 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d6866.0p-81, - 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae55.0p-80, - 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc45954.0p-81, - 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d.0p-81, - 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df842.0p-85, - 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe.0p-87, - 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa69.0p-81, - 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb3283.0p-80, - 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e.0p-79, - 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f46.0p-79, - 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a.0p-81, - 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de9.0p-79, - 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5148.0p-81, - 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba4.0p-79, - 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b731.0p-80, - 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed73.0p-81, - 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7.0p-79, - 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c566.0p-79, - 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb24.0p-81, - 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698.0p-81, - 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123616.0p-82, - 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b2.0p-80, - 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a424234.0p-79, - 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a4.0p-83, - 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770634.0p-79, - 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b152.0p-82, - 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f09.0p-80, - 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad89.0p-79, - 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf.0p-79, - 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab90486409.0p-80, - 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333.0p-79, - 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fc0.0p-80, - 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c9.0p-80, - 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8.0p-79, - 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a87.0p-81, - 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3cb.0p-79, - 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d.0p-81, - 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac.0p-81, - 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549e.0p-79, - 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b61.0p-80, - 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a3.0p-80, - 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f1.0p-82, - 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b68.0p-80, - 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f57.0p-80, - 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d9.0p-80, - 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d4.0p-80, - 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd.0p-79, - 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f730190.0p-79, - 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cd.0p-80, - 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d.0p-81, - 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af2.0p-79, - 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e0.0p-84, - 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade0.0p-79, - 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1.0p-79, - 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c53.0p-79, - 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f.0p-78, - 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e5.0p-81, - 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b.0p-79, - 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb8287.0p-78, - 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9c.0p-78, - 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f0.0p-79, - 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd6.0p-80, - 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de.0p-78, - 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f452.0p-78, - 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af72.0p-79, - 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfe.0p-79, - 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f77.0p-78, - 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a26.0p-80, - 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d7.0p-79, - 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3237.0p-79, - 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d.0p-79, - 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c337.0p-79, - 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf3.0p-78, - 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf1.0p-79, - 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507c.0p-78, - 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e98.0p-79, - 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea7.0p-78, - 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f952.0p-78, - 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe.0p-78, - 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576b.0p-78, - 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a2.0p-79, - 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c3.0p-79, - 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f.0p-81, - 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3.0p-79, - 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d20.0p-78, - 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c01.0p-79, - 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541ad.0p-79, - 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4572.0p-78, - 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c.0p-80, - 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d74936.0p-80, - 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce53266.0p-79, - 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d2.0p-79, - 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b36.0p-80, - 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3.0p-79, - 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900346.0p-80, - 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f8.0p-80, - 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a83.0p-81, - 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b.0p-78, - 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a198.0p-78, - 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c39.0p-81, + { 0x800000.0p-23, 0, 0 }, + { 0xfe0000.0p-24, 0x8080ac.0p-30, -0x14ee431dae6675.0p-84 }, + { 0xfc0000.0p-24, 0x8102b3.0p-29, -0x1db29ee2d83718.0p-84 }, + { 0xfa0000.0p-24, 0xc24929.0p-29, 0x1191957d173698.0p-83 }, + { 0xf80000.0p-24, 0x820aec.0p-28, 0x13ce8888e02e79.0p-82 }, + { 0xf60000.0p-24, 0xa33577.0p-28, -0x17a4382ce6eb7c.0p-82 }, + { 0xf48000.0p-24, 0xbc42cb.0p-28, -0x172a21161a1076.0p-83 }, + { 0xf30000.0p-24, 0xd57797.0p-28, -0x1e09de07cb9589.0p-82 }, + { 0xf10000.0p-24, 0xf7518e.0p-28, 0x1ae1eec1b036c5.0p-91 }, + { 0xef0000.0p-24, 0x8cb9df.0p-27, -0x1d7355325d560e.0p-81 }, + { 0xed8000.0p-24, 0x999ec0.0p-27, -0x1f9f02d256d503.0p-82 }, + { 0xec0000.0p-24, 0xa6988b.0p-27, -0x16fc0a9d12c17a.0p-83 }, + { 0xea0000.0p-24, 0xb80698.0p-27, 0x15d581c1e8da9a.0p-81 }, + { 0xe80000.0p-24, 0xc99af3.0p-27, -0x1535b3ba8f150b.0p-83 }, + { 0xe70000.0p-24, 0xd273b2.0p-27, 0x163786f5251af0.0p-85 }, + { 0xe50000.0p-24, 0xe442c0.0p-27, 0x1bc4b2368e32d5.0p-84 }, + { 0xe38000.0p-24, 0xf1b83f.0p-27, 0x1c6090f684e676.0p-81 }, + { 0xe20000.0p-24, 0xff448a.0p-27, -0x1890aa69ac9f42.0p-82 }, + { 0xe08000.0p-24, 0x8673f6.0p-26, 0x1b9985194b6b00.0p-80 }, + { 0xdf0000.0p-24, 0x8d515c.0p-26, -0x1dc08d61c6ef1e.0p-83 }, + { 0xdd8000.0p-24, 0x943a9e.0p-26, -0x1f72a2dac729b4.0p-82 }, + { 0xdc0000.0p-24, 0x9b2fe6.0p-26, -0x1fd4dfd3a0afb9.0p-80 }, + { 0xda8000.0p-24, 0xa2315d.0p-26, -0x11b26121629c47.0p-82 }, + { 0xd90000.0p-24, 0xa93f2f.0p-26, 0x1286d633e8e569.0p-81 }, + { 0xd78000.0p-24, 0xb05988.0p-26, 0x16128eba936770.0p-84 }, + { 0xd60000.0p-24, 0xb78094.0p-26, 0x16ead577390d32.0p-80 }, + { 0xd50000.0p-24, 0xbc4c6c.0p-26, 0x151131ccf7c7b7.0p-81 }, + { 0xd38000.0p-24, 0xc3890a.0p-26, -0x115e2cd714bd06.0p-80 }, + { 0xd20000.0p-24, 0xcad2d7.0p-26, -0x1847f406ebd3b0.0p-82 }, + { 0xd10000.0p-24, 0xcfb620.0p-26, 0x1c2259904d6866.0p-81 }, + { 0xcf8000.0p-24, 0xd71653.0p-26, 0x1ece57a8d5ae55.0p-80 }, + { 0xce0000.0p-24, 0xde843a.0p-26, -0x1f109d4bc45954.0p-81 }, + { 0xcd0000.0p-24, 0xe37fde.0p-26, 0x1bc03dc271a74d.0p-81 }, + { 0xcb8000.0p-24, 0xeb050c.0p-26, -0x1bf2badc0df842.0p-85 }, + { 0xca0000.0p-24, 0xf29878.0p-26, -0x18efededd89fbe.0p-87 }, + { 0xc90000.0p-24, 0xf7ad6f.0p-26, 0x1373ff977baa69.0p-81 }, + { 0xc80000.0p-24, 0xfcc8e3.0p-26, 0x196766f2fb3283.0p-80 }, + { 0xc68000.0p-24, 0x823f30.0p-25, 0x19bd076f7c434e.0p-79 }, + { 0xc58000.0p-24, 0x84d52c.0p-25, -0x1a327257af0f46.0p-79 }, + { 0xc40000.0p-24, 0x88bc74.0p-25, 0x113f23def19c5a.0p-81 }, + { 0xc30000.0p-24, 0x8b5ae6.0p-25, 0x1759f6e6b37de9.0p-79 }, + { 0xc20000.0p-24, 0x8dfccb.0p-25, 0x1ad35ca6ed5148.0p-81 }, + { 0xc10000.0p-24, 0x90a22b.0p-25, 0x1a1d71a87deba4.0p-79 }, + { 0xbf8000.0p-24, 0x94a0d8.0p-25, -0x139e5210c2b731.0p-80 }, + { 0xbe8000.0p-24, 0x974f16.0p-25, -0x18f6ebcff3ed73.0p-81 }, + { 0xbd8000.0p-24, 0x9a00f1.0p-25, -0x1aa268be39aab7.0p-79 }, + { 0xbc8000.0p-24, 0x9cb672.0p-25, -0x14c8815839c566.0p-79 }, + { 0xbb0000.0p-24, 0xa0cda1.0p-25, 0x1eaf46390dbb24.0p-81 }, + { 0xba0000.0p-24, 0xa38c6e.0p-25, 0x138e20d831f698.0p-81 }, + { 0xb90000.0p-24, 0xa64f05.0p-25, -0x1e8d3c41123616.0p-82 }, + { 0xb80000.0p-24, 0xa91570.0p-25, 0x1ce28f5f3840b2.0p-80 }, + { 0xb70000.0p-24, 0xabdfbb.0p-25, -0x186e5c0a424234.0p-79 }, + { 0xb60000.0p-24, 0xaeadef.0p-25, -0x14d41a0b2a08a4.0p-83 }, + { 0xb50000.0p-24, 0xb18018.0p-25, 0x16755892770634.0p-79 }, + { 0xb40000.0p-24, 0xb45642.0p-25, -0x16395ebe59b152.0p-82 }, + { 0xb30000.0p-24, 0xb73077.0p-25, 0x1abc65c8595f09.0p-80 }, + { 0xb20000.0p-24, 0xba0ec4.0p-25, -0x1273089d3dad89.0p-79 }, + { 0xb10000.0p-24, 0xbcf133.0p-25, 0x10f9f67b1f4bbf.0p-79 }, + { 0xb00000.0p-24, 0xbfd7d2.0p-25, -0x109fab90486409.0p-80 }, + { 0xaf0000.0p-24, 0xc2c2ac.0p-25, -0x1124680aa43333.0p-79 }, + { 0xae8000.0p-24, 0xc439b3.0p-25, -0x1f360cc4710fc0.0p-80 }, + { 0xad8000.0p-24, 0xc72afd.0p-25, -0x132d91f21d89c9.0p-80 }, + { 0xac8000.0p-24, 0xca20a2.0p-25, -0x16bf9b4d1f8da8.0p-79 }, + { 0xab8000.0p-24, 0xcd1aae.0p-25, 0x19deb5ce6a6a87.0p-81 }, + { 0xaa8000.0p-24, 0xd0192f.0p-25, 0x1a29fb48f7d3cb.0p-79 }, + { 0xaa0000.0p-24, 0xd19a20.0p-25, 0x1127d3c6457f9d.0p-81 }, + { 0xa90000.0p-24, 0xd49f6a.0p-25, -0x1ba930e486a0ac.0p-81 }, + { 0xa80000.0p-24, 0xd7a94b.0p-25, -0x1b6e645f31549e.0p-79 }, + { 0xa70000.0p-24, 0xdab7d0.0p-25, 0x1118a425494b61.0p-80 }, + { 0xa68000.0p-24, 0xdc40d5.0p-25, 0x1966f24d29d3a3.0p-80 }, + { 0xa58000.0p-24, 0xdf566d.0p-25, -0x1d8e52eb2248f1.0p-82 }, + { 0xa48000.0p-24, 0xe270ce.0p-25, -0x1ee370f96e6b68.0p-80 }, + { 0xa40000.0p-24, 0xe3ffce.0p-25, 0x1d155324911f57.0p-80 }, + { 0xa30000.0p-24, 0xe72179.0p-25, -0x1fe6e2f2f867d9.0p-80 }, + { 0xa20000.0p-24, 0xea4812.0p-25, 0x1b7be9add7f4d4.0p-80 }, + { 0xa18000.0p-24, 0xebdd3d.0p-25, 0x1b3cfb3f7511dd.0p-79 }, + { 0xa08000.0p-24, 0xef0b5b.0p-25, -0x1220de1f730190.0p-79 }, + { 0xa00000.0p-24, 0xf0a451.0p-25, -0x176364c9ac81cd.0p-80 }, + { 0x9f0000.0p-24, 0xf3da16.0p-25, 0x1eed6b9aafac8d.0p-81 }, + { 0x9e8000.0p-24, 0xf576e9.0p-25, 0x1d593218675af2.0p-79 }, + { 0x9d8000.0p-24, 0xf8b47c.0p-25, -0x13e8eb7da053e0.0p-84 }, + { 0x9d0000.0p-24, 0xfa553f.0p-25, 0x1c063259bcade0.0p-79 }, + { 0x9c0000.0p-24, 0xfd9ac5.0p-25, 0x1ef491085fa3c1.0p-79 }, + { 0x9b8000.0p-24, 0xff3f8c.0p-25, 0x1d607a7c2b8c53.0p-79 }, + { 0x9a8000.0p-24, 0x814697.0p-24, -0x12ad3817004f3f.0p-78 }, + { 0x9a0000.0p-24, 0x821b06.0p-24, -0x189fc53117f9e5.0p-81 }, + { 0x990000.0p-24, 0x83c5f8.0p-24, 0x14cf15a048907b.0p-79 }, + { 0x988000.0p-24, 0x849c7d.0p-24, 0x1cbb1d35fb8287.0p-78 }, + { 0x978000.0p-24, 0x864ba6.0p-24, 0x1128639b814f9c.0p-78 }, + { 0x970000.0p-24, 0x87244c.0p-24, 0x184733853300f0.0p-79 }, + { 0x968000.0p-24, 0x87fdaa.0p-24, 0x109d23aef77dd6.0p-80 }, + { 0x958000.0p-24, 0x89b293.0p-24, -0x1a81ef367a59de.0p-78 }, + { 0x950000.0p-24, 0x8a8e20.0p-24, -0x121ad3dbb2f452.0p-78 }, + { 0x948000.0p-24, 0x8b6a6a.0p-24, -0x1cfb981628af72.0p-79 }, + { 0x938000.0p-24, 0x8d253a.0p-24, -0x1d21730ea76cfe.0p-79 }, + { 0x930000.0p-24, 0x8e03c2.0p-24, 0x135cc00e566f77.0p-78 }, + { 0x928000.0p-24, 0x8ee30d.0p-24, -0x10fcb5df257a26.0p-80 }, + { 0x918000.0p-24, 0x90a3ee.0p-24, -0x16e171b15433d7.0p-79 }, + { 0x910000.0p-24, 0x918587.0p-24, -0x1d050da07f3237.0p-79 }, + { 0x908000.0p-24, 0x9267e7.0p-24, 0x1be03669a5268d.0p-79 }, + { 0x8f8000.0p-24, 0x942f04.0p-24, 0x10b28e0e26c337.0p-79 }, + { 0x8f0000.0p-24, 0x9513c3.0p-24, 0x1a1d820da57cf3.0p-78 }, + { 0x8e8000.0p-24, 0x95f950.0p-24, -0x19ef8f13ae3cf1.0p-79 }, + { 0x8e0000.0p-24, 0x96dfab.0p-24, -0x109e417a6e507c.0p-78 }, + { 0x8d0000.0p-24, 0x98aed2.0p-24, 0x10d01a2c5b0e98.0p-79 }, + { 0x8c8000.0p-24, 0x9997a2.0p-24, -0x1d6a50d4b61ea7.0p-78 }, + { 0x8c0000.0p-24, 0x9a8145.0p-24, 0x1b3b190b83f952.0p-78 }, + { 0x8b8000.0p-24, 0x9b6bbf.0p-24, 0x13a69fad7e7abe.0p-78 }, + { 0x8b0000.0p-24, 0x9c5711.0p-24, -0x11cd12316f576b.0p-78 }, + { 0x8a8000.0p-24, 0x9d433b.0p-24, 0x1c95c444b807a2.0p-79 }, + { 0x898000.0p-24, 0x9f1e22.0p-24, -0x1b9c224ea698c3.0p-79 }, + { 0x890000.0p-24, 0xa00ce1.0p-24, 0x125ca93186cf0f.0p-81 }, + { 0x888000.0p-24, 0xa0fc80.0p-24, -0x1ee38a7bc228b3.0p-79 }, + { 0x880000.0p-24, 0xa1ed00.0p-24, -0x1a0db876613d20.0p-78 }, + { 0x878000.0p-24, 0xa2de62.0p-24, 0x193224e8516c01.0p-79 }, + { 0x870000.0p-24, 0xa3d0a9.0p-24, 0x1fa28b4d2541ad.0p-79 }, + { 0x868000.0p-24, 0xa4c3d6.0p-24, 0x1c1b5760fb4572.0p-78 }, + { 0x858000.0p-24, 0xa6acea.0p-24, 0x1fed5d0f65949c.0p-80 }, + { 0x850000.0p-24, 0xa7a2d4.0p-24, 0x1ad270c9d74936.0p-80 }, + { 0x848000.0p-24, 0xa899ab.0p-24, 0x199ff15ce53266.0p-79 }, + { 0x840000.0p-24, 0xa99171.0p-24, 0x1a19e15ccc45d2.0p-79 }, + { 0x838000.0p-24, 0xaa8a28.0p-24, -0x121a14ec532b36.0p-80 }, + { 0x830000.0p-24, 0xab83d1.0p-24, 0x1aee319980bff3.0p-79 }, + { 0x828000.0p-24, 0xac7e6f.0p-24, -0x18ffd9e3900346.0p-80 }, + { 0x820000.0p-24, 0xad7a03.0p-24, -0x1e4db102ce29f8.0p-80 }, + { 0x818000.0p-24, 0xae768f.0p-24, 0x17c35c55a04a83.0p-81 }, + { 0x810000.0p-24, 0xaf7415.0p-24, 0x1448324047019b.0p-78 }, + { 0x808000.0p-24, 0xb07298.0p-24, -0x1750ee3915a198.0p-78 }, + { 0x800000.0p-24, 0xb17218.0p-24, -0x105c610ca86c39.0p-81 }, }; #ifdef USE_UTAB @@ -288,135 +288,135 @@ static const struct { float H; /* 1 + i/INTERVALS (exact) */ float E; /* H(i) * G(i) - 1 (exact) */ } U[TSIZE] = { - 0x800000.0p-23, 0, - 0x810000.0p-23, -0x800000.0p-37, - 0x820000.0p-23, -0x800000.0p-35, - 0x830000.0p-23, -0x900000.0p-34, - 0x840000.0p-23, -0x800000.0p-33, - 0x850000.0p-23, -0xc80000.0p-33, - 0x860000.0p-23, -0xa00000.0p-36, - 0x870000.0p-23, 0x940000.0p-33, - 0x880000.0p-23, 0x800000.0p-35, - 0x890000.0p-23, -0xc80000.0p-34, - 0x8a0000.0p-23, 0xe00000.0p-36, - 0x8b0000.0p-23, 0x900000.0p-33, - 0x8c0000.0p-23, -0x800000.0p-35, - 0x8d0000.0p-23, -0xe00000.0p-33, - 0x8e0000.0p-23, 0x880000.0p-33, - 0x8f0000.0p-23, -0xa80000.0p-34, - 0x900000.0p-23, -0x800000.0p-35, - 0x910000.0p-23, 0x800000.0p-37, - 0x920000.0p-23, 0x900000.0p-35, - 0x930000.0p-23, 0xd00000.0p-35, - 0x940000.0p-23, 0xe00000.0p-35, - 0x950000.0p-23, 0xc00000.0p-35, - 0x960000.0p-23, 0xe00000.0p-36, - 0x970000.0p-23, -0x800000.0p-38, - 0x980000.0p-23, -0xc00000.0p-35, - 0x990000.0p-23, -0xd00000.0p-34, - 0x9a0000.0p-23, 0x880000.0p-33, - 0x9b0000.0p-23, 0xe80000.0p-35, - 0x9c0000.0p-23, -0x800000.0p-35, - 0x9d0000.0p-23, 0xb40000.0p-33, - 0x9e0000.0p-23, 0x880000.0p-34, - 0x9f0000.0p-23, -0xe00000.0p-35, - 0xa00000.0p-23, 0x800000.0p-33, - 0xa10000.0p-23, -0x900000.0p-36, - 0xa20000.0p-23, -0xb00000.0p-33, - 0xa30000.0p-23, -0xa00000.0p-36, - 0xa40000.0p-23, 0x800000.0p-33, - 0xa50000.0p-23, -0xf80000.0p-35, - 0xa60000.0p-23, 0x880000.0p-34, - 0xa70000.0p-23, -0x900000.0p-33, - 0xa80000.0p-23, -0x800000.0p-35, - 0xa90000.0p-23, 0x900000.0p-34, - 0xaa0000.0p-23, 0xa80000.0p-33, - 0xab0000.0p-23, -0xac0000.0p-34, - 0xac0000.0p-23, -0x800000.0p-37, - 0xad0000.0p-23, 0xf80000.0p-35, - 0xae0000.0p-23, 0xf80000.0p-34, - 0xaf0000.0p-23, -0xac0000.0p-33, - 0xb00000.0p-23, -0x800000.0p-33, - 0xb10000.0p-23, -0xb80000.0p-34, - 0xb20000.0p-23, -0x800000.0p-34, - 0xb30000.0p-23, -0xb00000.0p-35, - 0xb40000.0p-23, -0x800000.0p-35, - 0xb50000.0p-23, -0xe00000.0p-36, - 0xb60000.0p-23, -0x800000.0p-35, - 0xb70000.0p-23, -0xb00000.0p-35, - 0xb80000.0p-23, -0x800000.0p-34, - 0xb90000.0p-23, -0xb80000.0p-34, - 0xba0000.0p-23, -0x800000.0p-33, - 0xbb0000.0p-23, -0xac0000.0p-33, - 0xbc0000.0p-23, 0x980000.0p-33, - 0xbd0000.0p-23, 0xbc0000.0p-34, - 0xbe0000.0p-23, 0xe00000.0p-36, - 0xbf0000.0p-23, -0xb80000.0p-35, - 0xc00000.0p-23, -0x800000.0p-33, - 0xc10000.0p-23, 0xa80000.0p-33, - 0xc20000.0p-23, 0x900000.0p-34, - 0xc30000.0p-23, -0x800000.0p-35, - 0xc40000.0p-23, -0x900000.0p-33, - 0xc50000.0p-23, 0x820000.0p-33, - 0xc60000.0p-23, 0x800000.0p-38, - 0xc70000.0p-23, -0x820000.0p-33, - 0xc80000.0p-23, 0x800000.0p-33, - 0xc90000.0p-23, -0xa00000.0p-36, - 0xca0000.0p-23, -0xb00000.0p-33, - 0xcb0000.0p-23, 0x840000.0p-34, - 0xcc0000.0p-23, -0xd00000.0p-34, - 0xcd0000.0p-23, 0x800000.0p-33, - 0xce0000.0p-23, -0xe00000.0p-35, - 0xcf0000.0p-23, 0xa60000.0p-33, - 0xd00000.0p-23, -0x800000.0p-35, - 0xd10000.0p-23, 0xb40000.0p-33, - 0xd20000.0p-23, -0x800000.0p-35, - 0xd30000.0p-23, 0xaa0000.0p-33, - 0xd40000.0p-23, -0xe00000.0p-35, - 0xd50000.0p-23, 0x880000.0p-33, - 0xd60000.0p-23, -0xd00000.0p-34, - 0xd70000.0p-23, 0x9c0000.0p-34, - 0xd80000.0p-23, -0xb00000.0p-33, - 0xd90000.0p-23, -0x800000.0p-38, - 0xda0000.0p-23, 0xa40000.0p-33, - 0xdb0000.0p-23, -0xdc0000.0p-34, - 0xdc0000.0p-23, 0xc00000.0p-35, - 0xdd0000.0p-23, 0xca0000.0p-33, - 0xde0000.0p-23, -0xb80000.0p-34, - 0xdf0000.0p-23, 0xd00000.0p-35, - 0xe00000.0p-23, 0xc00000.0p-33, - 0xe10000.0p-23, -0xf40000.0p-34, - 0xe20000.0p-23, 0x800000.0p-37, - 0xe30000.0p-23, 0x860000.0p-33, - 0xe40000.0p-23, -0xc80000.0p-33, - 0xe50000.0p-23, -0xa80000.0p-34, - 0xe60000.0p-23, 0xe00000.0p-36, - 0xe70000.0p-23, 0x880000.0p-33, - 0xe80000.0p-23, -0xe00000.0p-33, - 0xe90000.0p-23, -0xfc0000.0p-34, - 0xea0000.0p-23, -0x800000.0p-35, - 0xeb0000.0p-23, 0xe80000.0p-35, - 0xec0000.0p-23, 0x900000.0p-33, - 0xed0000.0p-23, 0xe20000.0p-33, - 0xee0000.0p-23, -0xac0000.0p-33, - 0xef0000.0p-23, -0xc80000.0p-34, - 0xf00000.0p-23, -0x800000.0p-35, - 0xf10000.0p-23, 0x800000.0p-35, - 0xf20000.0p-23, 0xb80000.0p-34, - 0xf30000.0p-23, 0x940000.0p-33, - 0xf40000.0p-23, 0xc80000.0p-33, - 0xf50000.0p-23, -0xf20000.0p-33, - 0xf60000.0p-23, -0xc80000.0p-33, - 0xf70000.0p-23, -0xa20000.0p-33, - 0xf80000.0p-23, -0x800000.0p-33, - 0xf90000.0p-23, -0xc40000.0p-34, - 0xfa0000.0p-23, -0x900000.0p-34, - 0xfb0000.0p-23, -0xc80000.0p-35, - 0xfc0000.0p-23, -0x800000.0p-35, - 0xfd0000.0p-23, -0x900000.0p-36, - 0xfe0000.0p-23, -0x800000.0p-37, - 0xff0000.0p-23, -0x800000.0p-39, - 0x800000.0p-22, 0, + { 0x800000.0p-23, 0 }, + { 0x810000.0p-23, -0x800000.0p-37 }, + { 0x820000.0p-23, -0x800000.0p-35 }, + { 0x830000.0p-23, -0x900000.0p-34 }, + { 0x840000.0p-23, -0x800000.0p-33 }, + { 0x850000.0p-23, -0xc80000.0p-33 }, + { 0x860000.0p-23, -0xa00000.0p-36 }, + { 0x870000.0p-23, 0x940000.0p-33 }, + { 0x880000.0p-23, 0x800000.0p-35 }, + { 0x890000.0p-23, -0xc80000.0p-34 }, + { 0x8a0000.0p-23, 0xe00000.0p-36 }, + { 0x8b0000.0p-23, 0x900000.0p-33 }, + { 0x8c0000.0p-23, -0x800000.0p-35 }, + { 0x8d0000.0p-23, -0xe00000.0p-33 }, + { 0x8e0000.0p-23, 0x880000.0p-33 }, + { 0x8f0000.0p-23, -0xa80000.0p-34 }, + { 0x900000.0p-23, -0x800000.0p-35 }, + { 0x910000.0p-23, 0x800000.0p-37 }, + { 0x920000.0p-23, 0x900000.0p-35 }, + { 0x930000.0p-23, 0xd00000.0p-35 }, + { 0x940000.0p-23, 0xe00000.0p-35 }, + { 0x950000.0p-23, 0xc00000.0p-35 }, + { 0x960000.0p-23, 0xe00000.0p-36 }, + { 0x970000.0p-23, -0x800000.0p-38 }, + { 0x980000.0p-23, -0xc00000.0p-35 }, + { 0x990000.0p-23, -0xd00000.0p-34 }, + { 0x9a0000.0p-23, 0x880000.0p-33 }, + { 0x9b0000.0p-23, 0xe80000.0p-35 }, + { 0x9c0000.0p-23, -0x800000.0p-35 }, + { 0x9d0000.0p-23, 0xb40000.0p-33 }, + { 0x9e0000.0p-23, 0x880000.0p-34 }, + { 0x9f0000.0p-23, -0xe00000.0p-35 }, + { 0xa00000.0p-23, 0x800000.0p-33 }, + { 0xa10000.0p-23, -0x900000.0p-36 }, + { 0xa20000.0p-23, -0xb00000.0p-33 }, + { 0xa30000.0p-23, -0xa00000.0p-36 }, + { 0xa40000.0p-23, 0x800000.0p-33 }, + { 0xa50000.0p-23, -0xf80000.0p-35 }, + { 0xa60000.0p-23, 0x880000.0p-34 }, + { 0xa70000.0p-23, -0x900000.0p-33 }, + { 0xa80000.0p-23, -0x800000.0p-35 }, + { 0xa90000.0p-23, 0x900000.0p-34 }, + { 0xaa0000.0p-23, 0xa80000.0p-33 }, + { 0xab0000.0p-23, -0xac0000.0p-34 }, + { 0xac0000.0p-23, -0x800000.0p-37 }, + { 0xad0000.0p-23, 0xf80000.0p-35 }, + { 0xae0000.0p-23, 0xf80000.0p-34 }, + { 0xaf0000.0p-23, -0xac0000.0p-33 }, + { 0xb00000.0p-23, -0x800000.0p-33 }, + { 0xb10000.0p-23, -0xb80000.0p-34 }, + { 0xb20000.0p-23, -0x800000.0p-34 }, + { 0xb30000.0p-23, -0xb00000.0p-35 }, + { 0xb40000.0p-23, -0x800000.0p-35 }, + { 0xb50000.0p-23, -0xe00000.0p-36 }, + { 0xb60000.0p-23, -0x800000.0p-35 }, + { 0xb70000.0p-23, -0xb00000.0p-35 }, + { 0xb80000.0p-23, -0x800000.0p-34 }, + { 0xb90000.0p-23, -0xb80000.0p-34 }, + { 0xba0000.0p-23, -0x800000.0p-33 }, + { 0xbb0000.0p-23, -0xac0000.0p-33 }, + { 0xbc0000.0p-23, 0x980000.0p-33 }, + { 0xbd0000.0p-23, 0xbc0000.0p-34 }, + { 0xbe0000.0p-23, 0xe00000.0p-36 }, + { 0xbf0000.0p-23, -0xb80000.0p-35 }, + { 0xc00000.0p-23, -0x800000.0p-33 }, + { 0xc10000.0p-23, 0xa80000.0p-33 }, + { 0xc20000.0p-23, 0x900000.0p-34 }, + { 0xc30000.0p-23, -0x800000.0p-35 }, + { 0xc40000.0p-23, -0x900000.0p-33 }, + { 0xc50000.0p-23, 0x820000.0p-33 }, + { 0xc60000.0p-23, 0x800000.0p-38 }, + { 0xc70000.0p-23, -0x820000.0p-33 }, + { 0xc80000.0p-23, 0x800000.0p-33 }, + { 0xc90000.0p-23, -0xa00000.0p-36 }, + { 0xca0000.0p-23, -0xb00000.0p-33 }, + { 0xcb0000.0p-23, 0x840000.0p-34 }, + { 0xcc0000.0p-23, -0xd00000.0p-34 }, + { 0xcd0000.0p-23, 0x800000.0p-33 }, + { 0xce0000.0p-23, -0xe00000.0p-35 }, + { 0xcf0000.0p-23, 0xa60000.0p-33 }, + { 0xd00000.0p-23, -0x800000.0p-35 }, + { 0xd10000.0p-23, 0xb40000.0p-33 }, + { 0xd20000.0p-23, -0x800000.0p-35 }, + { 0xd30000.0p-23, 0xaa0000.0p-33 }, + { 0xd40000.0p-23, -0xe00000.0p-35 }, + { 0xd50000.0p-23, 0x880000.0p-33 }, + { 0xd60000.0p-23, -0xd00000.0p-34 }, + { 0xd70000.0p-23, 0x9c0000.0p-34 }, + { 0xd80000.0p-23, -0xb00000.0p-33 }, + { 0xd90000.0p-23, -0x800000.0p-38 }, + { 0xda0000.0p-23, 0xa40000.0p-33 }, + { 0xdb0000.0p-23, -0xdc0000.0p-34 }, + { 0xdc0000.0p-23, 0xc00000.0p-35 }, + { 0xdd0000.0p-23, 0xca0000.0p-33 }, + { 0xde0000.0p-23, -0xb80000.0p-34 }, + { 0xdf0000.0p-23, 0xd00000.0p-35 }, + { 0xe00000.0p-23, 0xc00000.0p-33 }, + { 0xe10000.0p-23, -0xf40000.0p-34 }, + { 0xe20000.0p-23, 0x800000.0p-37 }, + { 0xe30000.0p-23, 0x860000.0p-33 }, + { 0xe40000.0p-23, -0xc80000.0p-33 }, + { 0xe50000.0p-23, -0xa80000.0p-34 }, + { 0xe60000.0p-23, 0xe00000.0p-36 }, + { 0xe70000.0p-23, 0x880000.0p-33 }, + { 0xe80000.0p-23, -0xe00000.0p-33 }, + { 0xe90000.0p-23, -0xfc0000.0p-34 }, + { 0xea0000.0p-23, -0x800000.0p-35 }, + { 0xeb0000.0p-23, 0xe80000.0p-35 }, + { 0xec0000.0p-23, 0x900000.0p-33 }, + { 0xed0000.0p-23, 0xe20000.0p-33 }, + { 0xee0000.0p-23, -0xac0000.0p-33 }, + { 0xef0000.0p-23, -0xc80000.0p-34 }, + { 0xf00000.0p-23, -0x800000.0p-35 }, + { 0xf10000.0p-23, 0x800000.0p-35 }, + { 0xf20000.0p-23, 0xb80000.0p-34 }, + { 0xf30000.0p-23, 0x940000.0p-33 }, + { 0xf40000.0p-23, 0xc80000.0p-33 }, + { 0xf50000.0p-23, -0xf20000.0p-33 }, + { 0xf60000.0p-23, -0xc80000.0p-33 }, + { 0xf70000.0p-23, -0xa20000.0p-33 }, + { 0xf80000.0p-23, -0x800000.0p-33 }, + { 0xf90000.0p-23, -0xc40000.0p-34 }, + { 0xfa0000.0p-23, -0x900000.0p-34 }, + { 0xfb0000.0p-23, -0xc80000.0p-35 }, + { 0xfc0000.0p-23, -0x800000.0p-35 }, + { 0xfd0000.0p-23, -0x900000.0p-36 }, + { 0xfe0000.0p-23, -0x800000.0p-37 }, + { 0xff0000.0p-23, -0x800000.0p-39 }, + { 0x800000.0p-22, 0 }, }; #endif /* USE_UTAB */ From owner-svn-src-head@freebsd.org Tue Nov 1 16:03:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33FE3C29EDB; Tue, 1 Nov 2016 16:03:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0D66117E0; Tue, 1 Nov 2016 16:03:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1G3WSt017373; Tue, 1 Nov 2016 16:03:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1G3VqQ017370; Tue, 1 Nov 2016 16:03:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201611011603.uA1G3VqQ017370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 1 Nov 2016 16:03:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308173 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 16:03:33 -0000 Author: mav Date: Tue Nov 1 16:03:31 2016 New Revision: 308173 URL: https://svnweb.freebsd.org/changeset/base/308173 Log: Fix ZIL records ordering when ZVOL opened both with and without FSYNC. Before this an earlier writes to a ZVOL opened without FSYNC could get to ZIL after later writes to the same ZVOL opened with FSYNC. Fix this by replicating functionality of ZPL (zv_sync_cnt equivalent to z_sync_cnt), marking all log records sync if anybody opened the ZVOL with FSYNC. MFC after: 2 weeks Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h Tue Nov 1 15:11:10 2016 (r308172) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h Tue Nov 1 16:03:31 2016 (r308173) @@ -405,6 +405,7 @@ extern itx_t *zil_itx_create(uint64_t tx extern void zil_itx_destroy(itx_t *itx); extern void zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx); +extern void zil_async_to_sync(zilog_t *zilog, uint64_t oid); extern void zil_commit(zilog_t *zilog, uint64_t oid); extern int zil_vdev_offline(const char *osname, void *txarg); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Tue Nov 1 15:11:10 2016 (r308172) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Tue Nov 1 16:03:31 2016 (r308173) @@ -90,8 +90,6 @@ SYSCTL_INT(_vfs_zfs_trim, OID_AUTO, enab static kmem_cache_t *zil_lwb_cache; -static void zil_async_to_sync(zilog_t *zilog, uint64_t foid); - #define LWB_EMPTY(lwb) ((BP_GET_LSIZE(&lwb->lwb_blk) - \ sizeof (zil_chain_t)) == (lwb->lwb_sz - lwb->lwb_nused)) @@ -1421,7 +1419,7 @@ zil_get_commit_list(zilog_t *zilog) /* * Move the async itxs for a specified object to commit into sync lists. */ -static void +void zil_async_to_sync(zilog_t *zilog, uint64_t foid) { uint64_t otxg, txg; Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Tue Nov 1 15:11:10 2016 (r308172) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Tue Nov 1 16:03:31 2016 (r308173) @@ -169,6 +169,7 @@ typedef struct zvol_state { uint32_t zv_open_count[OTYPCNT]; /* open counts */ #endif uint32_t zv_total_opens; /* total open count */ + uint32_t zv_sync_cnt; /* synchronous open count */ zilog_t *zv_zilog; /* ZIL handle */ list_t zv_extents; /* List of extents for dump */ znode_t zv_znode; /* for range locking */ @@ -1441,7 +1442,9 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_ BP_ZERO(&lr->lr_blkptr); itx->itx_private = zv; - itx->itx_sync = sync; + + if (!sync && (zv->zv_sync_cnt == 0)) + itx->itx_sync = B_FALSE; zil_itx_assign(zilog, itx, tx); @@ -2083,7 +2086,7 @@ zvol_log_truncate(zvol_state_t *zv, dmu_ lr->lr_offset = off; lr->lr_length = len; - itx->itx_sync = sync; + itx->itx_sync = (sync || zv->zv_sync_cnt != 0); zil_itx_assign(zilog, itx, tx); } @@ -3075,6 +3078,11 @@ zvol_d_open(struct cdev *dev, int flags, #endif zv->zv_total_opens++; + if (flags & (FSYNC | FDSYNC)) { + zv->zv_sync_cnt++; + if (zv->zv_sync_cnt == 1) + zil_async_to_sync(zv->zv_zilog, ZVOL_OBJ); + } mutex_exit(&zfsdev_state_lock); return (err); out: @@ -3105,6 +3113,8 @@ zvol_d_close(struct cdev *dev, int flags * You may get multiple opens, but only one close. */ zv->zv_total_opens--; + if (flags & (FSYNC | FDSYNC)) + zv->zv_sync_cnt--; if (zv->zv_total_opens == 0) zvol_last_close(zv); From owner-svn-src-head@freebsd.org Tue Nov 1 17:11:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD6D7C2919F; Tue, 1 Nov 2016 17:11:11 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8C3C8175F; Tue, 1 Nov 2016 17:11:11 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1HBAWH043696; Tue, 1 Nov 2016 17:11:10 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1HBAKR043695; Tue, 1 Nov 2016 17:11:10 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201611011711.uA1HBAKR043695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Tue, 1 Nov 2016 17:11:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308174 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 17:11:12 -0000 Author: alc Date: Tue Nov 1 17:11:10 2016 New Revision: 308174 URL: https://svnweb.freebsd.org/changeset/base/308174 Log: Move and revise a comment about the relation between the object's paging- in-progress count and the vnode. Prior to r188331, we always acquired the vnode lock before incrementing the object's paging-in-progress count. Now, we increment it before attempting to acquire the vnode lock with LK_NOWAIT, but we never sleep acquiring the vnode lock while we have the count incremented. Reviewed by: kib MFC after: 3 days Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Tue Nov 1 16:03:31 2016 (r308173) +++ head/sys/vm/vm_fault.c Tue Nov 1 17:11:10 2016 (r308174) @@ -420,8 +420,7 @@ fast_failed: * they will stay around as well. * * Bump the paging-in-progress count to prevent size changes (e.g. - * truncation operations) during I/O. This must be done after - * obtaining the vnode lock in order to avoid possible deadlocks. + * truncation operations) during I/O. */ vm_object_reference_locked(fs.first_object); vm_object_pip_add(fs.first_object, 1); @@ -647,7 +646,13 @@ readrest: if (locked != LK_EXCLUSIVE) locked = LK_SHARED; - /* Do not sleep for vnode lock while fs.m is busy */ + + /* + * We must not sleep acquiring the vnode lock + * while we have the page exclusive busied or + * the object's paging-in-progress count + * incremented. Otherwise, we could deadlock. + */ error = vget(vp, locked | LK_CANRECURSE | LK_NOWAIT, curthread); if (error != 0) { From owner-svn-src-head@freebsd.org Tue Nov 1 18:18:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52D73C2575B; Tue, 1 Nov 2016 18:18:11 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D8BEC161A; Tue, 1 Nov 2016 18:18:10 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1II9eJ069266; Tue, 1 Nov 2016 18:18:09 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1II9oe069262; Tue, 1 Nov 2016 18:18:09 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201611011818.uA1II9oe069262@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Tue, 1 Nov 2016 18:18:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308175 - head/libexec/ftpd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 18:18:11 -0000 Author: lidl Date: Tue Nov 1 18:18:09 2016 New Revision: 308175 URL: https://svnweb.freebsd.org/changeset/base/308175 Log: Revisit blacklistd support in ftpd Enhance blacklistd support to not log anything by default, unless blacklistd support is enabled on the command line. Document new flag in man page, cleanup patches to be less intrusive in code. Reported by: Rick Adams Reviewed by: cem, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8374 Modified: head/libexec/ftpd/blacklist.c head/libexec/ftpd/blacklist_client.h head/libexec/ftpd/ftpd.8 head/libexec/ftpd/ftpd.c Modified: head/libexec/ftpd/blacklist.c ============================================================================== --- head/libexec/ftpd/blacklist.c Tue Nov 1 17:11:10 2016 (r308174) +++ head/libexec/ftpd/blacklist.c Tue Nov 1 18:18:09 2016 (r308175) @@ -37,16 +37,20 @@ #include static struct blacklist *blstate; +extern int use_blacklist; void blacklist_init(void) { - blstate = blacklist_open(); + + if (use_blacklist) + blstate = blacklist_open(); } void blacklist_notify(int action, int fd, char *msg) { + if (blstate == NULL) return; (void)blacklist_r(blstate, action, fd, msg); Modified: head/libexec/ftpd/blacklist_client.h ============================================================================== --- head/libexec/ftpd/blacklist_client.h Tue Nov 1 17:11:10 2016 (r308174) +++ head/libexec/ftpd/blacklist_client.h Tue Nov 1 18:18:09 2016 (r308175) @@ -28,5 +28,26 @@ /* $FreeBSD$ */ -void blacklist_notify(int, int, char *); +#ifndef BLACKLIST_CLIENT_H +#define BLACKLIST_CLIENT_H + +enum { + BLACKLIST_AUTH_OK = 0, + BLACKLIST_AUTH_FAIL +}; + +#ifdef USE_BLACKLIST void blacklist_init(void); +void blacklist_notify(int, int, char *); + +#define BLACKLIST_INIT() blacklist_init() +#define BLACKLIST_NOTIFY(x, y, z) blacklist_notify(x, y, z) + +#else + +#define BLACKLIST_INIT() +#define BLACKLIST_NOTIFY(x, y, z) + +#endif + +#endif /* BLACKLIST_CLIENT_H */ Modified: head/libexec/ftpd/ftpd.8 ============================================================================== --- head/libexec/ftpd/ftpd.8 Tue Nov 1 17:11:10 2016 (r308174) +++ head/libexec/ftpd/ftpd.8 Tue Nov 1 18:18:09 2016 (r308175) @@ -36,7 +36,7 @@ .Nd Internet File Transfer Protocol server .Sh SYNOPSIS .Nm -.Op Fl 468ADdEhMmOoRrSUvW +.Op Fl 468ABDdEhMmOoRrSUvW .Op Fl l Op Fl l .Op Fl a Ar address .Op Fl P Ar port @@ -95,6 +95,14 @@ When .Fl D is specified, accept connections only on the specified .Ar address . +.It Fl B +With this option set, +.Nm +sends authentication success and failure messages to the +.Xr blacklistd 8 +daemon. If this option is not specified, no communcation with the +.Xr blacklistd 8 +daemon is attempted. .It Fl D With this option set, .Nm Modified: head/libexec/ftpd/ftpd.c ============================================================================== --- head/libexec/ftpd/ftpd.c Tue Nov 1 17:11:10 2016 (r308174) +++ head/libexec/ftpd/ftpd.c Tue Nov 1 18:18:09 2016 (r308175) @@ -144,6 +144,7 @@ int noretr = 0; /* RETR command is disa int noguestretr = 0; /* RETR command is disabled for anon users. */ int noguestmkd = 0; /* MKD command is disabled for anon users. */ int noguestmod = 1; /* anon users may not modify existing files. */ +int use_blacklist = 0; off_t file_size; off_t byte_count; @@ -305,7 +306,7 @@ main(int argc, char *argv[], char **envp openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); while ((ch = getopt(argc, argv, - "468a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { + "468a:ABdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { switch (ch) { case '4': family = (family == AF_INET6) ? AF_UNSPEC : AF_INET; @@ -327,6 +328,14 @@ main(int argc, char *argv[], char **envp anon_only = 1; break; + case 'B': +#ifdef USE_BLACKLIST + use_blacklist = 1; +#else + syslog(LOG_WARNING, "not compiled with USE_BLACKLIST support"); +#endif + break; + case 'd': ftpdebug++; break; @@ -644,9 +653,7 @@ gotchild: reply(220, "%s FTP server (%s) ready.", hostname, version); else reply(220, "FTP server ready."); -#ifdef USE_BLACKLIST - blacklist_init(); -#endif + BLACKLIST_INIT(); for (;;) (void) yyparse(); /* NOTREACHED */ @@ -1422,9 +1429,7 @@ skip: */ if (rval) { reply(530, "Login incorrect."); -#ifdef USE_BLACKLIST - blacklist_notify(1, STDIN_FILENO, "Login incorrect"); -#endif + BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, STDIN_FILENO, "Login incorrect"); if (logging) { syslog(LOG_NOTICE, "FTP LOGIN FAILED FROM %s", @@ -1441,12 +1446,9 @@ skip: exit(0); } return; + } else { + BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK, STDIN_FILENO, "Login successful"); } -#ifdef USE_BLACKLIST - else { - blacklist_notify(0, STDIN_FILENO, "Login successful"); - } -#endif } login_attempts = 0; /* this time successful */ if (setegid(pw->pw_gid) < 0) { From owner-svn-src-head@freebsd.org Tue Nov 1 18:42:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 279D4C25FD7; Tue, 1 Nov 2016 18:42:46 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2A1811CC; Tue, 1 Nov 2016 18:42:45 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1Igi7W080671; Tue, 1 Nov 2016 18:42:44 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1Igix8080670; Tue, 1 Nov 2016 18:42:44 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201611011842.uA1Igix8080670@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Tue, 1 Nov 2016 18:42:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308176 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 18:42:46 -0000 Author: loos Date: Tue Nov 1 18:42:44 2016 New Revision: 308176 URL: https://svnweb.freebsd.org/changeset/base/308176 Log: Stop abusing from struct ifnet presence to determine the packet direction for dummynet, use the correct argument for that, remove the false coment about the presence of struct ifnet. Fixes the input match of dummynet l2 rules. Obtained from: pfSense MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_pfil.c Tue Nov 1 18:18:09 2016 (r308175) +++ head/sys/netpfil/ipfw/ip_fw_pfil.c Tue Nov 1 18:42:44 2016 (r308176) @@ -303,11 +303,9 @@ again: /* * ipfw processing for ethernet packets (in and out). - * Inteface is NULL from ether_demux, and ifp from - * ether_output_frame. */ int -ipfw_check_frame(void *arg, struct mbuf **m0, struct ifnet *dst, int dir, +ipfw_check_frame(void *arg, struct mbuf **m0, struct ifnet *ifp, int dir, struct inpcb *inp) { struct ether_header *eh; @@ -348,7 +346,7 @@ ipfw_check_frame(void *arg, struct mbuf m_adj(m, ETHER_HDR_LEN); /* strip ethernet header */ args.m = m; /* the packet we are looking at */ - args.oif = dir == PFIL_OUT ? dst: NULL; /* destination, if any */ + args.oif = dir == PFIL_OUT ? ifp: NULL; /* destination, if any */ args.next_hop = NULL; /* we do not support forward yet */ args.next_hop6 = NULL; /* we do not support forward yet */ args.eh = &save_eh; /* MAC header for bridged/MAC packets */ @@ -383,14 +381,13 @@ ipfw_check_frame(void *arg, struct mbuf case IP_FW_DUMMYNET: ret = EACCES; - int dir; if (ip_dn_io_ptr == NULL) break; /* i.e. drop */ *m0 = NULL; - dir = PROTO_LAYER2 | (dst ? DIR_OUT : DIR_IN); - ip_dn_io_ptr(&m, dir, &args); + dir = (dir == PFIL_IN) ? DIR_IN : DIR_OUT; + ip_dn_io_ptr(&m, dir | PROTO_LAYER2, &args); return 0; default: From owner-svn-src-head@freebsd.org Tue Nov 1 19:18:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4B74C28962; Tue, 1 Nov 2016 19:18:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60F971BAE; Tue, 1 Nov 2016 19:18:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1JIGWm092162; Tue, 1 Nov 2016 19:18:16 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1JIGDV092159; Tue, 1 Nov 2016 19:18:16 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201611011918.uA1JIGDV092159@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 1 Nov 2016 19:18:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308177 - head/tests/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 19:18:18 -0000 Author: cem Date: Tue Nov 1 19:18:16 2016 New Revision: 308177 URL: https://svnweb.freebsd.org/changeset/base/308177 Log: Add test case for >65535 segment coredumps A long-belated follow-up to r303099. With feedback from: jmmv, ngie Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D7264 Added: head/tests/sys/kern/coredump_phnum_helper.c (contents, props changed) head/tests/sys/kern/coredump_phnum_test.sh (contents, props changed) Modified: head/tests/sys/kern/Makefile Modified: head/tests/sys/kern/Makefile ============================================================================== --- head/tests/sys/kern/Makefile Tue Nov 1 18:42:44 2016 (r308176) +++ head/tests/sys/kern/Makefile Tue Nov 1 19:18:16 2016 (r308177) @@ -14,6 +14,11 @@ ATF_TESTS_C+= unix_passfd_test TEST_METADATA.unix_seqpacket_test+= timeout="15" ATF_TESTS_C+= waitpid_nohang +ATF_TESTS_SH+= coredump_phnum_test + +BINDIR= ${TESTSDIR} +PROGS+= coredump_phnum_helper + LIBADD.ptrace_test+= pthread LIBADD.unix_seqpacket_test+= pthread Added: head/tests/sys/kern/coredump_phnum_helper.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/kern/coredump_phnum_helper.c Tue Nov 1 19:18:16 2016 (r308177) @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, Conrad Meyer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include +#include +#include + +/* + * This program is intended to create a bunch of segment mappings, then dump + * core. + */ +int +main(int argc __unused, char **argv __unused) +{ + void *v; + unsigned i; + + for (i = 0; i < UINT16_MAX + 1000; i++) { + /* + * Alternate protections; otherwise the kernel will just extend + * the adjacent same-protection previous mapping. + */ + v = mmap(NULL, PAGE_SIZE, + (((i % 2) == 0) ? PROT_READ : 0) | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + if (v == MAP_FAILED) + err(1, "mmap"); + } + + /* Dump core. */ + abort(); +} Added: head/tests/sys/kern/coredump_phnum_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/kern/coredump_phnum_test.sh Tue Nov 1 19:18:16 2016 (r308177) @@ -0,0 +1,90 @@ +# +# Copyright (c) 2016 Dell EMC Isilon +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. +# +# $FreeBSD$ + +atf_test_case coredump_phnum cleanup +coredump_phnum_head() +{ + atf_set "allow_sysctl_side_effects" "1" + atf_set "descr" "More than 65534 segments" + atf_set "require.progs" "readelf procstat" + atf_set "require.user" "root" +} +coredump_phnum_body() +{ + # Set up core dumping + cat > coredump_phnum_restore_state.sh <<-EOF + #!/bin/sh + ulimit -c '$(ulimit -c)' + sysctl kern.coredump=$(sysctl -n kern.coredump) + sysctl kern.corefile='$(sysctl -n kern.corefile)' +EOF + chmod +x coredump_phnum_restore_state.sh + + ulimit -c unlimited + sysctl kern.coredump=1 + sysctl kern.corefile="$(pwd)/coredump_phnum_helper.core" + + atf_check -s signal:sigabrt "$(atf_get_srcdir)/coredump_phnum_helper" + + # Check that core looks good + if [ ! -f coredump_phnum_helper.core ]; then + atf_fail "Helper program did not dump core" + fi + + # These magic numbers don't have any real significance. They are just + # the result of running the helper program and dumping core. The only + # important bit is that they're larger than 65535 (UINT16_MAX). + readelf -h coredump_phnum_helper.core | \ + atf_check -o "match:65535 \(66169\)" \ + grep "Number of program headers:" + readelf -l coredump_phnum_helper.core | \ + atf_check -o "match:There are 66169 program headers" \ + grep -1 "program headers" + readelf -S coredump_phnum_helper.core | \ + atf_check -o "match: 0000000000000001 .* 66169 " \ + grep -A1 "^ \[ 0\] " + + procstat -v coredump_phnum_helper.core | \ + atf_check -o "match:66545" wc -l +} +coredump_phnum_cleanup() +{ + rm -f coredump_phnum_helper.core + if [ -x coredump_phnum_restore_state.sh ]; then + ./coredump_phnum_restore_state.sh + fi + rm -f coredump_phnum_restore_state.sh +} + +atf_init_test_cases() +{ + atf_add_test_case coredump_phnum +} From owner-svn-src-head@freebsd.org Tue Nov 1 19:18:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7CA2C28A3B; Tue, 1 Nov 2016 19:18:53 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E03D1F23; Tue, 1 Nov 2016 19:18:53 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1JIq1W092227; Tue, 1 Nov 2016 19:18:52 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1JIqQK092225; Tue, 1 Nov 2016 19:18:52 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201611011918.uA1JIqQK092225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 1 Nov 2016 19:18:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308178 - head/sys/dev/ioat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 19:18:53 -0000 Author: cem Date: Tue Nov 1 19:18:52 2016 New Revision: 308178 URL: https://svnweb.freebsd.org/changeset/base/308178 Log: ioat(4): Simplify by removing dynamic scaling This paves the way for a contiguous descriptor array. A contiguous descriptor array has the benefit that we can make strong assertions about whether an address is a valid descriptor or not. The other benefit is that future generations of I/OAT hardware will require a contiguous descriptor array anyway. The downside is that after system boot, big chunks of contiguous memory is much harder to find. So dynamic scaling after boot is basically impossible. Reviewed by: markj Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Tue Nov 1 19:18:16 2016 (r308177) +++ head/sys/dev/ioat/ioat.c Tue Nov 1 19:18:52 2016 (r308178) @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #define BUS_SPACE_MAXADDR_40BIT 0xFFFFFFFFFFULL #endif #define IOAT_REFLK (&ioat->submit_lock) -#define IOAT_SHRINK_PERIOD (10 * hz) static int ioat_probe(device_t device); static int ioat_attach(device_t device); @@ -90,15 +89,8 @@ static struct ioat_descriptor *ioat_allo static int ioat_reserve_space(struct ioat_softc *, uint32_t, int mflags); static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *ioat, uint32_t index); -static struct ioat_descriptor **ioat_prealloc_ring(struct ioat_softc *, - uint32_t size, boolean_t need_dscr, int mflags); -static int ring_grow(struct ioat_softc *, uint32_t oldorder, - struct ioat_descriptor **); -static int ring_shrink(struct ioat_softc *, uint32_t oldorder, - struct ioat_descriptor **); static void ioat_halted_debug(struct ioat_softc *, uint32_t); static void ioat_poll_timer_callback(void *arg); -static void ioat_shrink_timer_callback(void *arg); static void dump_descriptor(void *hw_desc); static void ioat_submit_single(struct ioat_softc *ioat); static void ioat_comp_update_map(void *arg, bus_dma_segment_t *seg, int nseg, @@ -135,6 +127,10 @@ int g_ioat_debug_level = 0; SYSCTL_INT(_hw_ioat, OID_AUTO, debug_level, CTLFLAG_RWTUN, &g_ioat_debug_level, 0, "Set log level (0-3) for ioat(4). Higher is more verbose."); +unsigned g_ioat_ring_order = 13; +SYSCTL_UINT(_hw_ioat, OID_AUTO, ring_order, CTLFLAG_RDTUN, &g_ioat_ring_order, + 0, "Set IOAT ring order. (1 << this) == ring size."); + /* * OS <-> Driver interface structures */ @@ -336,7 +332,6 @@ ioat_detach(device_t device) ioat_teardown_intr(ioat); callout_drain(&ioat->poll_timer); - callout_drain(&ioat->shrink_timer); pci_disable_busmaster(device); @@ -453,7 +448,6 @@ ioat3_attach(device_t device) mtx_init(&ioat->submit_lock, "ioat_submit", NULL, MTX_DEF); mtx_init(&ioat->cleanup_lock, "ioat_cleanup", NULL, MTX_DEF); callout_init(&ioat->poll_timer, 1); - callout_init(&ioat->shrink_timer, 1); TASK_INIT(&ioat->reset_task, 0, ioat_reset_hw_task, ioat); /* Establish lock order for Witness */ @@ -462,7 +456,6 @@ ioat3_attach(device_t device) mtx_unlock(&ioat->cleanup_lock); mtx_unlock(&ioat->submit_lock); - ioat->is_resize_pending = FALSE; ioat->is_submitter_processing = FALSE; ioat->is_completion_pending = FALSE; ioat->is_reset_pending = FALSE; @@ -484,7 +477,7 @@ ioat3_attach(device_t device) if (error != 0) return (error); - ioat->ring_size_order = IOAT_MIN_ORDER; + ioat->ring_size_order = g_ioat_ring_order; num_descriptors = 1 << ioat->ring_size_order; @@ -725,8 +718,6 @@ out: pending = (ioat_get_active(ioat) != 0); if (!pending && ioat->is_completion_pending) { ioat->is_completion_pending = FALSE; - callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, - ioat_shrink_timer_callback, ioat); callout_stop(&ioat->poll_timer); } mtx_unlock(&ioat->submit_lock); @@ -781,8 +772,6 @@ out: if (ioat->is_completion_pending) { ioat->is_completion_pending = FALSE; - callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, - ioat_shrink_timer_callback, ioat); callout_stop(&ioat->poll_timer); } @@ -964,7 +953,6 @@ ioat_release(bus_dmaengine_t dmaengine) ioat->is_completion_pending = TRUE; callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, ioat); - callout_stop(&ioat->shrink_timer); } mtx_unlock(&ioat->submit_lock); } @@ -1402,8 +1390,6 @@ ioat_free_ring_entry(struct ioat_softc * static int ioat_reserve_space(struct ioat_softc *ioat, uint32_t num_descs, int mflags) { - struct ioat_descriptor **new_ring; - uint32_t order; boolean_t dug; int error; @@ -1411,7 +1397,7 @@ ioat_reserve_space(struct ioat_softc *io error = 0; dug = FALSE; - if (num_descs < 1 || num_descs >= (1 << IOAT_MAX_ORDER)) { + if (num_descs < 1 || num_descs >= (1 << ioat->ring_size_order)) { error = EINVAL; goto out; } @@ -1428,8 +1414,7 @@ ioat_reserve_space(struct ioat_softc *io CTR3(KTR_IOAT, "%s channel=%u starved (%u)", __func__, ioat->chan_idx, num_descs); - if (!dug && !ioat->is_submitter_processing && - (1 << ioat->ring_size_order) > num_descs) { + if (!dug && !ioat->is_submitter_processing) { ioat->is_submitter_processing = TRUE; mtx_unlock(&ioat->submit_lock); @@ -1446,46 +1431,15 @@ ioat_reserve_space(struct ioat_softc *io continue; } - order = ioat->ring_size_order; - if (ioat->is_resize_pending || order == IOAT_MAX_ORDER) { - if ((mflags & M_WAITOK) != 0) { - CTR2(KTR_IOAT, "%s channel=%u blocking on completions", - __func__, ioat->chan_idx); - msleep(&ioat->tail, &ioat->submit_lock, 0, - "ioat_rsz", 0); - continue; - } - + if ((mflags & M_WAITOK) == 0) { error = EAGAIN; break; } - - ioat->is_resize_pending = TRUE; - for (;;) { - mtx_unlock(&ioat->submit_lock); - - new_ring = ioat_prealloc_ring(ioat, 1 << (order + 1), - TRUE, mflags); - - mtx_lock(&ioat->submit_lock); - KASSERT(ioat->ring_size_order == order, - ("is_resize_pending should protect order")); - - if (new_ring == NULL) { - KASSERT((mflags & M_WAITOK) == 0, - ("allocation failed")); - error = EAGAIN; - break; - } - - error = ring_grow(ioat, order, new_ring); - if (error == 0) - break; - } - ioat->is_resize_pending = FALSE; - wakeup(&ioat->tail); - if (error) - break; + CTR2(KTR_IOAT, "%s channel=%u blocking on completions", + __func__, ioat->chan_idx); + msleep(&ioat->tail, &ioat->submit_lock, 0, + "ioat_full", 0); + continue; } out: @@ -1495,39 +1449,6 @@ out: return (error); } -static struct ioat_descriptor ** -ioat_prealloc_ring(struct ioat_softc *ioat, uint32_t size, boolean_t need_dscr, - int mflags) -{ - struct ioat_descriptor **ring; - uint32_t i; - int error; - - KASSERT(size > 0 && powerof2(size), ("bogus size")); - - ring = malloc(size * sizeof(*ring), M_IOAT, M_ZERO | mflags); - if (ring == NULL) - return (NULL); - - if (need_dscr) { - error = ENOMEM; - for (i = size / 2; i < size; i++) { - ring[i] = ioat_alloc_ring_entry(ioat, mflags); - if (ring[i] == NULL) - goto out; - ring[i]->id = i; - } - } - error = 0; - -out: - if (error != 0 && ring != NULL) { - ioat_free_ring(ioat, size, ring); - ring = NULL; - } - return (ring); -} - static void ioat_free_ring(struct ioat_softc *ioat, uint32_t size, struct ioat_descriptor **ring) @@ -1548,181 +1469,6 @@ ioat_get_ring_entry(struct ioat_softc *i return (ioat->ring[index % (1 << ioat->ring_size_order)]); } -static int -ring_grow(struct ioat_softc *ioat, uint32_t oldorder, - struct ioat_descriptor **newring) -{ - struct ioat_descriptor *tmp, *next; - struct ioat_dma_hw_descriptor *hw; - uint32_t oldsize, newsize, head, tail, i, end; - int error; - - CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - - mtx_assert(&ioat->submit_lock, MA_OWNED); - - if (oldorder != ioat->ring_size_order || oldorder >= IOAT_MAX_ORDER) { - error = EINVAL; - goto out; - } - - oldsize = (1 << oldorder); - newsize = (1 << (oldorder + 1)); - - mtx_lock(&ioat->cleanup_lock); - - head = ioat->head & (oldsize - 1); - tail = ioat->tail & (oldsize - 1); - - /* Copy old descriptors to new ring */ - for (i = 0; i < oldsize; i++) - newring[i] = ioat->ring[i]; - - /* - * If head has wrapped but tail hasn't, we must swap some descriptors - * around so that tail can increment directly to head. - */ - if (head < tail) { - for (i = 0; i <= head; i++) { - tmp = newring[oldsize + i]; - - newring[oldsize + i] = newring[i]; - newring[oldsize + i]->id = oldsize + i; - - newring[i] = tmp; - newring[i]->id = i; - } - head += oldsize; - } - - KASSERT(head >= tail, ("invariants")); - - /* Head didn't wrap; we only need to link in oldsize..newsize */ - if (head < oldsize) { - i = oldsize - 1; - end = newsize; - } else { - /* Head did wrap; link newhead..newsize and 0..oldhead */ - i = head; - end = newsize + (head - oldsize) + 1; - } - - /* - * Fix up hardware ring, being careful not to trample the active - * section (tail -> head). - */ - for (; i < end; i++) { - KASSERT((i & (newsize - 1)) < tail || - (i & (newsize - 1)) >= head, ("trampling snake")); - - next = newring[(i + 1) & (newsize - 1)]; - hw = newring[i & (newsize - 1)]->u.dma; - hw->next = next->hw_desc_bus_addr; - } - -#ifdef INVARIANTS - for (i = 0; i < newsize; i++) { - next = newring[(i + 1) & (newsize - 1)]; - hw = newring[i & (newsize - 1)]->u.dma; - - KASSERT(hw->next == next->hw_desc_bus_addr, - ("mismatch at i:%u (oldsize:%u); next=%p nextaddr=0x%lx" - " (tail:%u)", i, oldsize, next, next->hw_desc_bus_addr, - tail)); - } -#endif - - free(ioat->ring, M_IOAT); - ioat->ring = newring; - ioat->ring_size_order = oldorder + 1; - ioat->tail = tail; - ioat->head = head; - error = 0; - - mtx_unlock(&ioat->cleanup_lock); -out: - if (error) - ioat_free_ring(ioat, (1 << (oldorder + 1)), newring); - return (error); -} - -static int -ring_shrink(struct ioat_softc *ioat, uint32_t oldorder, - struct ioat_descriptor **newring) -{ - struct ioat_dma_hw_descriptor *hw; - struct ioat_descriptor *ent, *next; - uint32_t oldsize, newsize, current_idx, new_idx, i; - int error; - - CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - - mtx_assert(&ioat->submit_lock, MA_OWNED); - - if (oldorder != ioat->ring_size_order || oldorder <= IOAT_MIN_ORDER) { - error = EINVAL; - goto out_unlocked; - } - - oldsize = (1 << oldorder); - newsize = (1 << (oldorder - 1)); - - mtx_lock(&ioat->cleanup_lock); - - /* Can't shrink below current active set! */ - if (ioat_get_active(ioat) >= newsize) { - error = ENOMEM; - goto out; - } - - /* - * Copy current descriptors to the new ring, dropping the removed - * descriptors. - */ - for (i = 0; i < newsize; i++) { - current_idx = (ioat->tail + i) & (oldsize - 1); - new_idx = (ioat->tail + i) & (newsize - 1); - - newring[new_idx] = ioat->ring[current_idx]; - newring[new_idx]->id = new_idx; - } - - /* Free deleted descriptors */ - for (i = newsize; i < oldsize; i++) { - ent = ioat_get_ring_entry(ioat, ioat->tail + i); - ioat_free_ring_entry(ioat, ent); - } - - /* Fix up hardware ring. */ - hw = newring[(ioat->tail + newsize - 1) & (newsize - 1)]->u.dma; - next = newring[(ioat->tail + newsize) & (newsize - 1)]; - hw->next = next->hw_desc_bus_addr; - -#ifdef INVARIANTS - for (i = 0; i < newsize; i++) { - next = newring[(i + 1) & (newsize - 1)]; - hw = newring[i & (newsize - 1)]->u.dma; - - KASSERT(hw->next == next->hw_desc_bus_addr, - ("mismatch at i:%u (newsize:%u); next=%p nextaddr=0x%lx " - "(tail:%u)", i, newsize, next, next->hw_desc_bus_addr, - ioat->tail)); - } -#endif - - free(ioat->ring, M_IOAT); - ioat->ring = newring; - ioat->ring_size_order = oldorder - 1; - error = 0; - -out: - mtx_unlock(&ioat->cleanup_lock); -out_unlocked: - if (error) - ioat_free_ring(ioat, (1 << (oldorder - 1)), newring); - return (error); -} - static void ioat_halted_debug(struct ioat_softc *ioat, uint32_t chanerr) { @@ -1753,55 +1499,6 @@ ioat_poll_timer_callback(void *arg) ioat_process_events(ioat); } -static void -ioat_shrink_timer_callback(void *arg) -{ - struct ioat_descriptor **newring; - struct ioat_softc *ioat; - uint32_t order; - - ioat = arg; - ioat_log_message(1, "%s\n", __func__); - - /* Slowly scale the ring down if idle. */ - mtx_lock(&ioat->submit_lock); - - /* Don't run while the hardware is being reset. */ - if (ioat->resetting) { - mtx_unlock(&ioat->submit_lock); - return; - } - - order = ioat->ring_size_order; - if (ioat->is_completion_pending || ioat->is_resize_pending || - order == IOAT_MIN_ORDER) { - mtx_unlock(&ioat->submit_lock); - goto out; - } - ioat->is_resize_pending = TRUE; - mtx_unlock(&ioat->submit_lock); - - newring = ioat_prealloc_ring(ioat, 1 << (order - 1), FALSE, - M_NOWAIT); - - mtx_lock(&ioat->submit_lock); - KASSERT(ioat->ring_size_order == order, - ("resize_pending protects order")); - - if (newring != NULL && !ioat->is_completion_pending) - ring_shrink(ioat, order, newring); - else if (newring != NULL) - ioat_free_ring(ioat, (1 << (order - 1)), newring); - - ioat->is_resize_pending = FALSE; - mtx_unlock(&ioat->submit_lock); - -out: - if (ioat->ring_size_order > IOAT_MIN_ORDER) - callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, - ioat_shrink_timer_callback, ioat); -} - /* * Support Functions */ @@ -2128,8 +1825,6 @@ ioat_setup_sysctl(device_t device) SYSCTL_ADD_UQUAD(ctx, state, OID_AUTO, "last_completion", CTLFLAG_RD, ioat->comp_update, "HW addr of last completion"); - SYSCTL_ADD_INT(ctx, state, OID_AUTO, "is_resize_pending", CTLFLAG_RD, - &ioat->is_resize_pending, 0, "resize pending"); SYSCTL_ADD_INT(ctx, state, OID_AUTO, "is_submitter_processing", CTLFLAG_RD, &ioat->is_submitter_processing, 0, "submitter processing"); @@ -2307,16 +2002,8 @@ DB_SHOW_COMMAND(ioat, db_show_ioat) db_printf(" c_lock: %p\n", sc->poll_timer.c_lock); db_printf(" c_flags: 0x%x\n", (unsigned)sc->poll_timer.c_flags); - db_printf(" shrink_timer:\n"); - db_printf(" c_time: %ju\n", (uintmax_t)sc->shrink_timer.c_time); - db_printf(" c_arg: %p\n", sc->shrink_timer.c_arg); - db_printf(" c_func: %p\n", sc->shrink_timer.c_func); - db_printf(" c_lock: %p\n", sc->shrink_timer.c_lock); - db_printf(" c_flags: 0x%x\n", (unsigned)sc->shrink_timer.c_flags); - db_printf(" quiescing: %d\n", (int)sc->quiescing); db_printf(" destroying: %d\n", (int)sc->destroying); - db_printf(" is_resize_pending: %d\n", (int)sc->is_resize_pending); db_printf(" is_submitter_processing: %d\n", (int)sc->is_submitter_processing); db_printf(" is_completion_pending: %d\n", (int)sc->is_completion_pending); Modified: head/sys/dev/ioat/ioat_internal.h ============================================================================== --- head/sys/dev/ioat/ioat_internal.h Tue Nov 1 19:18:16 2016 (r308177) +++ head/sys/dev/ioat/ioat_internal.h Tue Nov 1 19:18:52 2016 (r308178) @@ -487,7 +487,6 @@ struct ioat_softc { boolean_t quiescing; boolean_t destroying; boolean_t is_submitter_processing; - boolean_t is_resize_pending; boolean_t is_completion_pending; /* submit_lock */ boolean_t is_reset_pending; boolean_t is_channel_running; From owner-svn-src-head@freebsd.org Tue Nov 1 19:18:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E73E4C28A48; Tue, 1 Nov 2016 19:18:55 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 979F01F3E; Tue, 1 Nov 2016 19:18:55 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1JIstt092272; Tue, 1 Nov 2016 19:18:54 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1JIs3O092270; Tue, 1 Nov 2016 19:18:54 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201611011918.uA1JIs3O092270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 1 Nov 2016 19:18:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308179 - head/sys/dev/ioat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 19:18:56 -0000 Author: cem Date: Tue Nov 1 19:18:54 2016 New Revision: 308179 URL: https://svnweb.freebsd.org/changeset/base/308179 Log: ioat(4): Allocate contiguous descriptors This allows us to make strong assertions about descriptor address validity. Additionally, future generations of the ioat(4) hardware will require contiguous descriptors. Reviewed by: markj Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Tue Nov 1 19:18:52 2016 (r308178) +++ head/sys/dev/ioat/ioat.c Tue Nov 1 19:18:54 2016 (r308179) @@ -81,13 +81,11 @@ static void ioat_process_events(struct i static inline uint32_t ioat_get_active(struct ioat_softc *ioat); static inline uint32_t ioat_get_ring_space(struct ioat_softc *ioat); static void ioat_free_ring(struct ioat_softc *, uint32_t size, - struct ioat_descriptor **); -static void ioat_free_ring_entry(struct ioat_softc *ioat, - struct ioat_descriptor *desc); -static struct ioat_descriptor *ioat_alloc_ring_entry(struct ioat_softc *, - int mflags); + struct ioat_descriptor *); static int ioat_reserve_space(struct ioat_softc *, uint32_t, int mflags); -static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *ioat, +static union ioat_hw_descriptor *ioat_get_descriptor(struct ioat_softc *, + uint32_t index); +static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *, uint32_t index); static void ioat_halted_debug(struct ioat_softc *, uint32_t); static void ioat_poll_timer_callback(void *arg); @@ -349,7 +347,12 @@ ioat_detach(device_t device) bus_dma_tag_destroy(ioat->comp_update_tag); } - bus_dma_tag_destroy(ioat->hw_desc_tag); + if (ioat->hw_desc_ring != NULL) { + bus_dmamap_unload(ioat->hw_desc_tag, ioat->hw_desc_map); + bus_dmamem_free(ioat->hw_desc_tag, ioat->hw_desc_ring, + ioat->hw_desc_map); + bus_dma_tag_destroy(ioat->hw_desc_tag); + } return (0); } @@ -383,8 +386,8 @@ ioat_start_channel(struct ioat_softc *io /* Submit 'NULL' operation manually to avoid quiescing flag */ desc = ioat_get_ring_entry(ioat, ioat->head); + hw_desc = &ioat_get_descriptor(ioat, ioat->head)->dma; dmadesc = &desc->bus_dmadesc; - hw_desc = desc->u.dma; dmadesc->callback_fn = NULL; dmadesc->callback_arg = NULL; @@ -421,9 +424,10 @@ static int ioat3_attach(device_t device) { struct ioat_softc *ioat; - struct ioat_descriptor **ring; - struct ioat_descriptor *next; + struct ioat_descriptor *ring; struct ioat_dma_hw_descriptor *dma_hw_desc; + void *hw_desc; + size_t ringsz; int i, num_descriptors; int error; uint8_t xfercap; @@ -478,36 +482,41 @@ ioat3_attach(device_t device) return (error); ioat->ring_size_order = g_ioat_ring_order; - num_descriptors = 1 << ioat->ring_size_order; + ringsz = sizeof(struct ioat_dma_hw_descriptor) * num_descriptors; - bus_dma_tag_create(bus_get_dma_tag(ioat->device), 0x40, 0x0, - BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct ioat_dma_hw_descriptor), 1, - sizeof(struct ioat_dma_hw_descriptor), 0, NULL, NULL, - &ioat->hw_desc_tag); + error = bus_dma_tag_create(bus_get_dma_tag(ioat->device), + 2 * 1024 * 1024, 0x0, BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, + NULL, NULL, ringsz, 1, ringsz, 0, NULL, NULL, &ioat->hw_desc_tag); + if (error != 0) + return (error); + + error = bus_dmamem_alloc(ioat->hw_desc_tag, &hw_desc, + BUS_DMA_ZERO | BUS_DMA_WAITOK, &ioat->hw_desc_map); + if (error != 0) + return (error); + + error = bus_dmamap_load(ioat->hw_desc_tag, ioat->hw_desc_map, hw_desc, + ringsz, ioat_dmamap_cb, &ioat->hw_desc_bus_addr, BUS_DMA_WAITOK); + if (error) + return (error); + + ioat->hw_desc_ring = hw_desc; ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT, M_ZERO | M_WAITOK); ring = ioat->ring; for (i = 0; i < num_descriptors; i++) { - ring[i] = ioat_alloc_ring_entry(ioat, M_WAITOK); - if (ring[i] == NULL) - return (ENOMEM); - - ring[i]->id = i; + memset(&ring[i].bus_dmadesc, 0, sizeof(ring[i].bus_dmadesc)); + ring[i].id = i; } - for (i = 0; i < num_descriptors - 1; i++) { - next = ring[i + 1]; - dma_hw_desc = ring[i]->u.dma; - - dma_hw_desc->next = next->hw_desc_bus_addr; + for (i = 0; i < num_descriptors; i++) { + dma_hw_desc = &ioat->hw_desc_ring[i].dma; + dma_hw_desc->next = RING_PHYS_ADDR(ioat, i + 1); } - ring[i]->u.dma->next = ring[0]->hw_desc_bus_addr; - ioat->head = ioat->hw_head = 0; ioat->tail = 0; ioat->last_seen = 0; @@ -673,6 +682,12 @@ ioat_process_events(struct ioat_softc *i comp_update = *ioat->comp_update; status = comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK; + if (status < ioat->hw_desc_bus_addr || + status >= ioat->hw_desc_bus_addr + (1 << ioat->ring_size_order) * + sizeof(struct ioat_generic_hw_descriptor)) + panic("Bogus completion address %jx (channel %u)", + (uintmax_t)status, ioat->chan_idx); + if (status == ioat->last_seen) { /* * If we landed in process_events and nothing has been @@ -683,8 +698,7 @@ ioat_process_events(struct ioat_softc *i CTR4(KTR_IOAT, "%s channel=%u hw_status=0x%lx last_seen=0x%lx", __func__, ioat->chan_idx, comp_update, ioat->last_seen); - desc = ioat_get_ring_entry(ioat, ioat->tail - 1); - while (desc->hw_desc_bus_addr != status) { + while (RING_PHYS_ADDR(ioat, ioat->tail - 1) != status) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; CTR5(KTR_IOAT, "channel=%u completing desc idx %u (%p) ok cb %p(%p)", @@ -701,7 +715,7 @@ ioat_process_events(struct ioat_softc *i ioat->chan_idx, ioat->head, ioat->tail, ioat_get_active(ioat)); if (completed != 0) { - ioat->last_seen = desc->hw_desc_bus_addr; + ioat->last_seen = RING_PHYS_ADDR(ioat, ioat->tail - 1); ioat->stats.descriptors_processed += completed; } @@ -986,7 +1000,7 @@ ioat_op_generic(struct ioat_softc *ioat, return (NULL); desc = ioat_get_ring_entry(ioat, ioat->head); - hw_desc = desc->u.generic; + hw_desc = &ioat_get_descriptor(ioat, ioat->head)->generic; hw_desc->u.control_raw = 0; hw_desc->u.control_generic.op = op; @@ -1022,7 +1036,7 @@ ioat_null(bus_dmaengine_t dmaengine, bus if (desc == NULL) return (NULL); - hw_desc = desc->u.dma; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->dma; hw_desc->u.control.null = 1; ioat_submit_single(ioat); return (&desc->bus_dmadesc); @@ -1050,7 +1064,7 @@ ioat_copy(bus_dmaengine_t dmaengine, bus if (desc == NULL) return (NULL); - hw_desc = desc->u.dma; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->dma; if (g_ioat_debug_level >= 3) dump_descriptor(hw_desc); @@ -1088,7 +1102,7 @@ ioat_copy_8k_aligned(bus_dmaengine_t dma if (desc == NULL) return (NULL); - hw_desc = desc->u.dma; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->dma; if (src2 != src1 + PAGE_SIZE) { hw_desc->u.control.src_page_break = 1; hw_desc->next_src_addr = src2; @@ -1165,7 +1179,7 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, if (desc == NULL) return (NULL); - hw_desc = desc->u.crc32; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->crc32; if ((flags & DMA_CRC_INLINE) == 0) hw_desc->crc_address = crcptr; @@ -1244,7 +1258,7 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_ if (desc == NULL) return (NULL); - hw_desc = desc->u.crc32; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->crc32; if ((flags & DMA_CRC_INLINE) == 0) hw_desc->crc_address = crcptr; @@ -1292,7 +1306,7 @@ ioat_blockfill(bus_dmaengine_t dmaengine if (desc == NULL) return (NULL); - hw_desc = desc->u.fill; + hw_desc = &ioat_get_descriptor(ioat, desc->id)->fill; if (g_ioat_debug_level >= 3) dump_descriptor(hw_desc); @@ -1317,60 +1331,6 @@ ioat_get_ring_space(struct ioat_softc *i return ((1 << ioat->ring_size_order) - ioat_get_active(ioat) - 1); } -static struct ioat_descriptor * -ioat_alloc_ring_entry(struct ioat_softc *ioat, int mflags) -{ - struct ioat_generic_hw_descriptor *hw_desc; - struct ioat_descriptor *desc; - int error, busdmaflag; - - error = ENOMEM; - hw_desc = NULL; - - if ((mflags & M_WAITOK) != 0) - busdmaflag = BUS_DMA_WAITOK; - else - busdmaflag = BUS_DMA_NOWAIT; - - desc = malloc(sizeof(*desc), M_IOAT, mflags); - if (desc == NULL) - goto out; - - bus_dmamem_alloc(ioat->hw_desc_tag, (void **)&hw_desc, - BUS_DMA_ZERO | busdmaflag, &ioat->hw_desc_map); - if (hw_desc == NULL) - goto out; - - memset(&desc->bus_dmadesc, 0, sizeof(desc->bus_dmadesc)); - desc->u.generic = hw_desc; - - error = bus_dmamap_load(ioat->hw_desc_tag, ioat->hw_desc_map, hw_desc, - sizeof(*hw_desc), ioat_dmamap_cb, &desc->hw_desc_bus_addr, - busdmaflag); - if (error) - goto out; - -out: - if (error) { - ioat_free_ring_entry(ioat, desc); - return (NULL); - } - return (desc); -} - -static void -ioat_free_ring_entry(struct ioat_softc *ioat, struct ioat_descriptor *desc) -{ - - if (desc == NULL) - return; - - if (desc->u.generic) - bus_dmamem_free(ioat->hw_desc_tag, desc->u.generic, - ioat->hw_desc_map); - free(desc, M_IOAT); -} - /* * Reserves space in this IOAT descriptor ring by ensuring enough slots remain * for 'num_descs'. @@ -1451,14 +1411,9 @@ out: static void ioat_free_ring(struct ioat_softc *ioat, uint32_t size, - struct ioat_descriptor **ring) + struct ioat_descriptor *ring) { - uint32_t i; - for (i = 0; i < size; i++) { - if (ring[i] != NULL) - ioat_free_ring_entry(ioat, ring[i]); - } free(ring, M_IOAT); } @@ -1466,13 +1421,20 @@ static struct ioat_descriptor * ioat_get_ring_entry(struct ioat_softc *ioat, uint32_t index) { - return (ioat->ring[index % (1 << ioat->ring_size_order)]); + return (&ioat->ring[index % (1 << ioat->ring_size_order)]); +} + +static union ioat_hw_descriptor * +ioat_get_descriptor(struct ioat_softc *ioat, uint32_t index) +{ + + return (&ioat->hw_desc_ring[index % (1 << ioat->ring_size_order)]); } static void ioat_halted_debug(struct ioat_softc *ioat, uint32_t chanerr) { - struct ioat_descriptor *desc; + union ioat_hw_descriptor *desc; ioat_log_message(0, "Channel halted (%b)\n", (int)chanerr, IOAT_CHANERR_STR); @@ -1481,11 +1443,11 @@ ioat_halted_debug(struct ioat_softc *ioa mtx_assert(&ioat->cleanup_lock, MA_OWNED); - desc = ioat_get_ring_entry(ioat, ioat->tail + 0); - dump_descriptor(desc->u.raw); + desc = ioat_get_descriptor(ioat, ioat->tail + 0); + dump_descriptor(desc); - desc = ioat_get_ring_entry(ioat, ioat->tail + 1); - dump_descriptor(desc->u.raw); + desc = ioat_get_descriptor(ioat, ioat->tail + 1); + dump_descriptor(desc); } static void @@ -1643,7 +1605,7 @@ ioat_reset_hw(struct ioat_softc *ioat) ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN); ioat_write_chancmp(ioat, ioat->comp_update_bus_addr); - ioat_write_chainaddr(ioat, ioat->ring[0]->hw_desc_bus_addr); + ioat_write_chainaddr(ioat, RING_PHYS_ADDR(ioat, 0)); error = 0; CTR2(KTR_IOAT, "%s channel=%u configured channel", __func__, ioat->chan_idx); @@ -2018,34 +1980,37 @@ DB_SHOW_COMMAND(ioat, db_show_ioat) db_printf(" ring_size_order: %u\n", sc->ring_size_order); db_printf(" last_seen: 0x%lx\n", sc->last_seen); db_printf(" ring: %p\n", sc->ring); + db_printf(" descriptors: %p\n", sc->hw_desc_ring); + db_printf(" descriptors (phys): 0x%jx\n", + (uintmax_t)sc->hw_desc_bus_addr); db_printf(" ring[%u] (tail):\n", sc->tail % (1 << sc->ring_size_order)); db_printf(" id: %u\n", ioat_get_ring_entry(sc, sc->tail)->id); db_printf(" addr: 0x%lx\n", - ioat_get_ring_entry(sc, sc->tail)->hw_desc_bus_addr); + RING_PHYS_ADDR(sc, sc->tail)); db_printf(" next: 0x%lx\n", - ioat_get_ring_entry(sc, sc->tail)->u.generic->next); + ioat_get_descriptor(sc, sc->tail)->generic.next); db_printf(" ring[%u] (head - 1):\n", (sc->head - 1) % (1 << sc->ring_size_order)); db_printf(" id: %u\n", ioat_get_ring_entry(sc, sc->head - 1)->id); db_printf(" addr: 0x%lx\n", - ioat_get_ring_entry(sc, sc->head - 1)->hw_desc_bus_addr); + RING_PHYS_ADDR(sc, sc->head - 1)); db_printf(" next: 0x%lx\n", - ioat_get_ring_entry(sc, sc->head - 1)->u.generic->next); + ioat_get_descriptor(sc, sc->head - 1)->generic.next); db_printf(" ring[%u] (head):\n", (sc->head) % (1 << sc->ring_size_order)); db_printf(" id: %u\n", ioat_get_ring_entry(sc, sc->head)->id); db_printf(" addr: 0x%lx\n", - ioat_get_ring_entry(sc, sc->head)->hw_desc_bus_addr); + RING_PHYS_ADDR(sc, sc->head)); db_printf(" next: 0x%lx\n", - ioat_get_ring_entry(sc, sc->head)->u.generic->next); + ioat_get_descriptor(sc, sc->head)->generic.next); for (idx = 0; idx < (1 << sc->ring_size_order); idx++) if ((*sc->comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK) - == ioat_get_ring_entry(sc, idx)->hw_desc_bus_addr) + == RING_PHYS_ADDR(sc, idx)) db_printf(" ring[%u] == hardware tail\n", idx); db_printf(" cleanup_lock: "); Modified: head/sys/dev/ioat/ioat_internal.h ============================================================================== --- head/sys/dev/ioat/ioat_internal.h Tue Nov 1 19:18:52 2016 (r308178) +++ head/sys/dev/ioat/ioat_internal.h Tue Nov 1 19:18:54 2016 (r308179) @@ -413,19 +413,7 @@ struct bus_dmadesc { struct ioat_descriptor { struct bus_dmadesc bus_dmadesc; - union { - struct ioat_generic_hw_descriptor *generic; - struct ioat_dma_hw_descriptor *dma; - struct ioat_fill_hw_descriptor *fill; - struct ioat_crc32_hw_descriptor *crc32; - struct ioat_xor_hw_descriptor *xor; - struct ioat_xor_ext_hw_descriptor *xor_ext; - struct ioat_pq_hw_descriptor *pq; - struct ioat_pq_ext_hw_descriptor *pq_ext; - struct ioat_raw_hw_descriptor *raw; - } u; uint32_t id; - bus_addr_t hw_desc_bus_addr; }; /* Unused by this driver at this time. */ @@ -500,7 +488,22 @@ struct ioat_softc { uint32_t ring_size_order; bus_addr_t last_seen; - struct ioat_descriptor **ring; + struct ioat_descriptor *ring; + + union ioat_hw_descriptor { + struct ioat_generic_hw_descriptor generic; + struct ioat_dma_hw_descriptor dma; + struct ioat_fill_hw_descriptor fill; + struct ioat_crc32_hw_descriptor crc32; + struct ioat_xor_hw_descriptor xor; + struct ioat_xor_ext_hw_descriptor xor_ext; + struct ioat_pq_hw_descriptor pq; + struct ioat_pq_ext_hw_descriptor pq_ext; + struct ioat_raw_hw_descriptor raw; + } *hw_desc_ring; + bus_addr_t hw_desc_bus_addr; +#define RING_PHYS_ADDR(sc, i) (sc)->hw_desc_bus_addr + \ + (((i) % (1 << (sc)->ring_size_order)) * sizeof(struct ioat_dma_hw_descriptor)) struct mtx cleanup_lock; volatile uint32_t refcnt; From owner-svn-src-head@freebsd.org Tue Nov 1 21:04:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2B18C2A1AE; Tue, 1 Nov 2016 21:04:19 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D30D1CD7; Tue, 1 Nov 2016 21:04:19 +0000 (UTC) (envelope-from garga.bsd@gmail.com) Received: by mail-qk0-x22c.google.com with SMTP id q130so95347430qke.1; Tue, 01 Nov 2016 14:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=tKGCPng89vy1y0P7okySLAjKj/4+R6VQkveUVP4MmUo=; b=JyfNqoxAwkBM7pDayi9lPKZ7bFgvte04x/y3NfQq1iBZh8asv1WzCmQgxyMquZYlQU WYmiwX64iG6dN25WquvRBRanIOurS07PWviNbVjnWkOyf2/trcB5zIX+d94ZmrZ8lwgd 1C56wVg33Ypp8xwIiZD9+ek2sfH68oh6sZvwmbHwpLk5vMPoDV/dV3988zA1jrr/qh3X MHfhSw16emD2P5TbYv6b3qvaq1NgWdvaYSN2FbDdSswdT4nFYSsmb9mVMhDKqpMtBvaN KNWqfvb9op2xD9BcWqSABL5ZUThp7BtMAYmsUew3xMg+Im5cbsu1SCKxJEJAD8PYe5SY Rneg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=tKGCPng89vy1y0P7okySLAjKj/4+R6VQkveUVP4MmUo=; b=KTPcIhI0ewgf/p9oBvPv7SJDJ8sLUI+wTZN931IiOhNxbJwoxcctFvv0f7hp0on1Ln uBmAKNwzxA4eOY9ew827ZmVSV6T5eG9xxd343JSXdiQ0DRZfl1uriz4yGeZ5NM4X/j+V DXaK8t/HrLvN/yKcdJPPMC27zAkPO6iry+kMtnHvTCroC8JsoRjASWLC/dHAuNhPN+fQ Lu89FLkPhMaUaaWmY36km5e/9mtJhrNyEssdTPmvKIQMjjupTIXbWWGtKWMNGmVRqWLG 5ZvqTqYoL1+6H8Ofdm8VHWIqwaO+D6dzERPLyr8oY6CknpbJHare3GoWlgEabM9j0JtH fPpQ== X-Gm-Message-State: ABUngvcsplOuMXOtAuhiHa+lUPjtzGSAoi+HMXSQYX1yINv3qCyxqyJKogYmLHXw3njEkQ== X-Received: by 10.233.221.135 with SMTP id r129mr22644qkf.204.1478034258099; Tue, 01 Nov 2016 14:04:18 -0700 (PDT) Received: from mbp-eth.home ([200.236.239.51]) by smtp.gmail.com with ESMTPSA id m30sm3963269qta.7.2016.11.01.14.04.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Nov 2016 14:04:17 -0700 (PDT) Sender: Renato Botelho From: Renato Botelho Message-Id: <645D2DFA-81A2-495B-B8B8-13FAF80A5B62@FreeBSD.org> Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: svn commit: r308139 - in head: etc/mtree usr.sbin/cron/cron usr.sbin/cron/lib Date: Tue, 1 Nov 2016 19:04:13 -0200 In-Reply-To: <201610311820.u9VIKCHj015674@repo.freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org To: Baptiste Daroussin References: <201610311820.u9VIKCHj015674@repo.freebsd.org> X-Mailer: Apple Mail (2.3251) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 21:04:20 -0000 > On 31 Oct 2016, at 16:20, Baptiste Daroussin wrote: >=20 > Author: bapt > Date: Mon Oct 31 18:20:12 2016 > New Revision: 308139 > URL: https://svnweb.freebsd.org/changeset/base/308139 >=20 > Log: > cron(8): add support for /etc/cron.d and /usr/local/etc/cron.d >=20 > For automation tools it is way easier to maintain files in = directories rather > than modifying /etc/crontab. >=20 > The files in those directories are in the same format as /etc/crontab Thank you! -- Renato Botelho From owner-svn-src-head@freebsd.org Tue Nov 1 21:08:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ECC97C2A40F; Tue, 1 Nov 2016 21:08:39 +0000 (UTC) (envelope-from hiren@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88C0C1021; Tue, 1 Nov 2016 21:08:39 +0000 (UTC) (envelope-from hiren@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1L8cef038343; Tue, 1 Nov 2016 21:08:38 GMT (envelope-from hiren@FreeBSD.org) Received: (from hiren@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1L8b1I038337; Tue, 1 Nov 2016 21:08:37 GMT (envelope-from hiren@FreeBSD.org) Message-Id: <201611012108.uA1L8b1I038337@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hiren set sender to hiren@FreeBSD.org using -f From: Hiren Panchasara Date: Tue, 1 Nov 2016 21:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308180 - in head/sys/netinet: . cc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 21:08:40 -0000 Author: hiren Date: Tue Nov 1 21:08:37 2016 New Revision: 308180 URL: https://svnweb.freebsd.org/changeset/base/308180 Log: Set slow start threshold more accurately on loss to be flightsize/2 instead of cwnd/2 as recommended by RFC5681. (spotted by mmacy at nextbsd dot org) Restore pre-r307901 behavior of aligning ssthresh/cwnd on mss boundary. (spotted by slawa at zxy dot spb dot ru) Tested by: dim, Slawa MFC after: 1 month X-MFC with: r307901 Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D8349 Modified: head/sys/netinet/cc/cc_cdg.c head/sys/netinet/cc/cc_chd.c head/sys/netinet/cc/cc_dctcp.c head/sys/netinet/cc/cc_htcp.c head/sys/netinet/cc/cc_newreno.c head/sys/netinet/tcp_input.c Modified: head/sys/netinet/cc/cc_cdg.c ============================================================================== --- head/sys/netinet/cc/cc_cdg.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/cc/cc_cdg.c Tue Nov 1 21:08:37 2016 (r308180) @@ -474,7 +474,9 @@ cdg_cong_signal(struct cc_var *ccv, uint ENTER_RECOVERY(CCV(ccv, t_flags)); break; case CC_RTO: - CCV(ccv, snd_ssthresh) = max(2*mss, cwin/2); + CCV(ccv, snd_ssthresh) = + max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2) + * mss; CCV(ccv, snd_cwnd) = mss; break; default: Modified: head/sys/netinet/cc/cc_chd.c ============================================================================== --- head/sys/netinet/cc/cc_chd.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/cc/cc_chd.c Tue Nov 1 21:08:37 2016 (r308180) @@ -330,13 +330,11 @@ chd_cong_signal(struct cc_var *ccv, uint struct ertt *e_t; struct chd *chd_data; int qdly; - uint32_t cwin; u_int mss; e_t = khelp_get_osd(CCV(ccv, osd), ertt_id); chd_data = ccv->cc_data; qdly = imax(e_t->rtt, chd_data->maxrtt_in_rtt) - e_t->minrtt; - cwin = CCV(ccv, snd_cwnd); mss = CCV(ccv, t_maxseg); switch(signal_type) { @@ -378,7 +376,9 @@ chd_cong_signal(struct cc_var *ccv, uint ENTER_FASTRECOVERY(CCV(ccv, t_flags)); break; case CC_RTO: - CCV(ccv, snd_ssthresh) = max(2*mss, cwin/2); + CCV(ccv, snd_ssthresh) = + max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2) + * mss; CCV(ccv, snd_cwnd) = mss; break; Modified: head/sys/netinet/cc/cc_dctcp.c ============================================================================== --- head/sys/netinet/cc/cc_dctcp.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/cc/cc_dctcp.c Tue Nov 1 21:08:37 2016 (r308180) @@ -230,19 +230,21 @@ static void dctcp_cong_signal(struct cc_var *ccv, uint32_t type) { struct dctcp *dctcp_data; - uint32_t cwin; + uint32_t cwin, ssthresh_on_loss; u_int mss; dctcp_data = ccv->cc_data; cwin = CCV(ccv, snd_cwnd); mss = CCV(ccv, t_maxseg); + ssthresh_on_loss = + max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2) + * mss; switch (type) { case CC_NDUPACK: if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { - CCV(ccv, snd_ssthresh) = mss * - max(cwin / 2 / mss, 2); + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; dctcp_data->num_cong_events++; } else { /* cwnd has already updated as congestion @@ -250,8 +252,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui * snd_cwnd_prev and recalculate snd_ssthresh */ cwin = CCV(ccv, snd_cwnd_prev); - CCV(ccv, snd_ssthresh) = - max(cwin / 2 / mss, 2) * mss; + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; } ENTER_RECOVERY(CCV(ccv, t_flags)); } @@ -265,8 +266,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { if (V_dctcp_slowstart && dctcp_data->num_cong_events++ == 0) { - CCV(ccv, snd_ssthresh) = - mss * max(cwin / 2 / mss, 2); + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; dctcp_data->alpha = MAX_ALPHA_VALUE; dctcp_data->bytes_ecn = 0; dctcp_data->bytes_total = 0; @@ -285,7 +285,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui dctcp_update_alpha(ccv); dctcp_data->save_sndnxt += CCV(ccv, t_maxseg); dctcp_data->num_cong_events++; - CCV(ccv, snd_ssthresh) = max(2 * mss, cwin / 2); + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; CCV(ccv, snd_cwnd) = mss; } break; Modified: head/sys/netinet/cc/cc_htcp.c ============================================================================== --- head/sys/netinet/cc/cc_htcp.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/cc/cc_htcp.c Tue Nov 1 21:08:37 2016 (r308180) @@ -325,7 +325,9 @@ htcp_cong_signal(struct cc_var *ccv, uin */ if (CCV(ccv, t_rxtshift) >= 2) htcp_data->t_last_cong = ticks; - CCV(ccv, snd_ssthresh) = max(2 * mss, cwin / 2); + CCV(ccv, snd_ssthresh) = + max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2) + * mss; CCV(ccv, snd_cwnd) = mss; break; } @@ -518,6 +520,10 @@ htcp_ssthresh_update(struct cc_var *ccv) CCV(ccv, snd_ssthresh) = ((u_long)CCV(ccv, snd_cwnd) * htcp_data->beta) >> HTCP_SHIFT; } + + /* Align ssthresh to MSS boundary */ + CCV(ccv, snd_ssthresh) = (CCV(ccv, snd_ssthresh) / CCV(ccv, t_maxseg)) + * CCV(ccv, t_maxseg); } Modified: head/sys/netinet/cc/cc_newreno.c ============================================================================== --- head/sys/netinet/cc/cc_newreno.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/cc/cc_newreno.c Tue Nov 1 21:08:37 2016 (r308180) @@ -182,23 +182,26 @@ newreno_after_idle(struct cc_var *ccv) static void newreno_cong_signal(struct cc_var *ccv, uint32_t type) { - uint32_t cwin; + uint32_t cwin, ssthresh_on_loss; u_int mss; cwin = CCV(ccv, snd_cwnd); mss = CCV(ccv, t_maxseg); + ssthresh_on_loss = + max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2) + * mss; /* Catch algos which mistakenly leak private signal types. */ KASSERT((type & CC_SIGPRIVMASK) == 0, ("%s: congestion signal type 0x%08x is private\n", __func__, type)); - cwin = max(2*mss, cwin/2); + cwin = max(cwin / 2 / mss, 2) * mss; switch (type) { case CC_NDUPACK: if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { - CCV(ccv, snd_ssthresh) = cwin; + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; CCV(ccv, snd_cwnd) = cwin; } ENTER_RECOVERY(CCV(ccv, t_flags)); @@ -206,13 +209,13 @@ newreno_cong_signal(struct cc_var *ccv, break; case CC_ECN: if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { - CCV(ccv, snd_ssthresh) = cwin; + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; CCV(ccv, snd_cwnd) = cwin; ENTER_CONGRECOVERY(CCV(ccv, t_flags)); } break; case CC_RTO: - CCV(ccv, snd_ssthresh) = cwin; + CCV(ccv, snd_ssthresh) = ssthresh_on_loss; CCV(ccv, snd_cwnd) = mss; break; } Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Tue Nov 1 19:18:54 2016 (r308179) +++ head/sys/netinet/tcp_input.c Tue Nov 1 21:08:37 2016 (r308180) @@ -444,7 +444,8 @@ cc_cong_signal(struct tcpcb *tp, struct * ssthresh = max (FlightSize / 2, 2*SMSS) eq (4) */ tp->snd_ssthresh = - max((tp->snd_max - tp->snd_una) / 2, 2 * maxseg); + max((tp->snd_max - tp->snd_una) / 2 / maxseg, 2) + * maxseg; tp->snd_cwnd = maxseg; } break; From owner-svn-src-head@freebsd.org Tue Nov 1 21:27:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F3E9C2AA40; Tue, 1 Nov 2016 21:27:44 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD4C314A6; Tue, 1 Nov 2016 21:27:43 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1LRgPa045904; Tue, 1 Nov 2016 21:27:42 GMT (envelope-from jonathan@FreeBSD.org) Received: (from jonathan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1LRg0B045900; Tue, 1 Nov 2016 21:27:42 GMT (envelope-from jonathan@FreeBSD.org) Message-Id: <201611012127.uA1LRg0B045900@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jonathan set sender to jonathan@FreeBSD.org using -f From: Jonathan Anderson Date: Tue, 1 Nov 2016 21:27:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308181 - in head: . share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 21:27:44 -0000 Author: jonathan Date: Tue Nov 1 21:27:42 2016 New Revision: 308181 URL: https://svnweb.freebsd.org/changeset/base/308181 Log: Add rules to build LLVM IR binaries and libraries. Running `make libfoo.ll` or `make libfoo.bc` within a library directory will now give us an LLVM IR version of the library, and `make foo.full.ll` or `make foo.full.bc` will give us an IR version of a binary. As part of this change, we add an LLVM_LINK variable to sys.mk that can be specified/overridden using an external toolchain. Reviewed by: bdrewery, brooks Approved by: rwatson (mentor) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8388 Modified: head/Makefile.inc1 head/share/mk/bsd.lib.mk head/share/mk/bsd.prog.mk head/share/mk/sys.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Tue Nov 1 21:08:37 2016 (r308180) +++ head/Makefile.inc1 Tue Nov 1 21:27:42 2016 (r308181) @@ -543,8 +543,8 @@ HMAKE+= PATH=${TMPPATH} METALOG=${METAL CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \ CPP="${XCPP} ${XCFLAGS}" \ - AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \ - OBJCOPY="${XOBJCOPY}" \ + AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \ + NM=${XNM} OBJCOPY="${XOBJCOPY}" \ RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \ SIZE="${XSIZE}" Modified: head/share/mk/bsd.lib.mk ============================================================================== --- head/share/mk/bsd.lib.mk Tue Nov 1 21:08:37 2016 (r308180) +++ head/share/mk/bsd.lib.mk Tue Nov 1 21:27:42 2016 (r308181) @@ -78,7 +78,7 @@ CTFFLAGS+= -g # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries # .pico used for PIC object files -.SUFFIXES: .out .o .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln +.SUFFIXES: .out .o .bc .ll .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln .if !defined(PICFLAG) .if ${MACHINE_CPUARCH} == "sparc64" @@ -199,6 +199,18 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} ${RANLIB} ${RANLIBFLAGS} ${.TARGET} .endif +.if defined(LLVM_LINK) +BCOBJS= ${OBJS:.o=.bco} ${STATICOBJS:.o=.bco} +LLOBJS= ${OBJS:.o=.llo} ${STATICOBJS:.o=.llo} +CLEANFILES+= ${BCOBJS} ${LLOBJS} + +lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS} + ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} + +lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS} + ${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS} +.endif + .if defined(SHLIB_NAME) || \ defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) SOBJS+= ${OBJS:.o=.pico} Modified: head/share/mk/bsd.prog.mk ============================================================================== --- head/share/mk/bsd.prog.mk Tue Nov 1 21:08:37 2016 (r308180) +++ head/share/mk/bsd.prog.mk Tue Nov 1 21:27:42 2016 (r308181) @@ -4,7 +4,7 @@ .include .include -.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm +.SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S .asm # XXX The use of COPTS in modern makefiles is discouraged. .if defined(COPTS) @@ -147,6 +147,19 @@ ${PROGNAME}.debug: ${PROG_FULL} ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} .endif +.if defined(LLVM_LINK) +# LLVM bitcode / textual IR representations of the program +BCOBJS= ${OBJS:.o=.bco} +LLOBJS= ${OBJS:.o=.llo} + +${PROG_FULL}.bc: ${BCOBJS} + ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} + +${PROG_FULL}.ll: ${LLOBJS} + ${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS} + +.endif # defined(LLVM_LINK) + .if ${MK_MAN} != "no" && !defined(MAN) && \ !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ @@ -166,14 +179,14 @@ all: all-man .endif .if defined(PROG) -CLEANFILES+= ${PROG} +CLEANFILES+= ${PROG} ${PROG}.bc ${PROG}.ll .if ${MK_DEBUG_FILES} != "no" -CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug +CLEANFILES+= ${PROG_FULL} ${PROG_FULL}.bc ${PROGNAME}.debug ${PROG_FULL}.ll .endif .endif .if defined(OBJS) -CLEANFILES+= ${OBJS} +CLEANFILES+= ${OBJS} ${BCOBJS} ${LLOBJS} .endif .include Modified: head/share/mk/sys.mk ============================================================================== --- head/share/mk/sys.mk Tue Nov 1 21:08:37 2016 (r308180) +++ head/share/mk/sys.mk Tue Nov 1 21:27:42 2016 (r308181) @@ -231,6 +231,8 @@ LINTLIBFLAGS ?= -cghapbxu -C ${LIB} MAKE ?= make .if !defined(%POSIX) +LLVM_LINK ?= llvm-link + LORDER ?= lorder NM ?= nm From owner-svn-src-head@freebsd.org Tue Nov 1 22:03:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1BF57C2A54A; Tue, 1 Nov 2016 22:03:38 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF5EE1497; Tue, 1 Nov 2016 22:03:37 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1M3aIV061339; Tue, 1 Nov 2016 22:03:36 GMT (envelope-from gavin@FreeBSD.org) Received: (from gavin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1M3aep061338; Tue, 1 Nov 2016 22:03:36 GMT (envelope-from gavin@FreeBSD.org) Message-Id: <201611012203.uA1M3aep061338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gavin set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson Date: Tue, 1 Nov 2016 22:03:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308182 - head/sbin/ifconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 22:03:38 -0000 Author: gavin Date: Tue Nov 1 22:03:36 2016 New Revision: 308182 URL: https://svnweb.freebsd.org/changeset/base/308182 Log: Remove MATCHOUI macro, unused since r197980. Modified: head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue Nov 1 21:27:42 2016 (r308181) +++ head/sbin/ifconfig/ifieee80211.c Tue Nov 1 22:03:36 2016 (r308182) @@ -2716,11 +2716,6 @@ printathie(const char *tag, const u_int8 static void printmeshconf(const char *tag, const uint8_t *ie, size_t ielen, int maxlen) { -#define MATCHOUI(field, oui, string) \ -do { \ - if (memcmp(field, oui, 4) == 0) \ - printf("%s", string); \ -} while (0) printf("%s", tag); if (verbose) { @@ -2754,7 +2749,6 @@ do { \ printf(" FORM:0x%x CAPS:0x%x>", mconf->conf_form, mconf->conf_cap); } -#undef MATCHOUI } static void From owner-svn-src-head@freebsd.org Tue Nov 1 22:38:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73A84C2AB06; Tue, 1 Nov 2016 22:38:27 +0000 (UTC) (envelope-from ivadasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2B3441A63; Tue, 1 Nov 2016 22:38:27 +0000 (UTC) (envelope-from ivadasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1McQrG073388; Tue, 1 Nov 2016 22:38:26 GMT (envelope-from ivadasz@FreeBSD.org) Received: (from ivadasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1McQ87073387; Tue, 1 Nov 2016 22:38:26 GMT (envelope-from ivadasz@FreeBSD.org) Message-Id: <201611012238.uA1McQ87073387@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ivadasz set sender to ivadasz@FreeBSD.org using -f From: =?UTF-8?Q?Imre_Vad=c3=a1sz?= Date: Tue, 1 Nov 2016 22:38:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308183 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 22:38:27 -0000 Author: ivadasz Date: Tue Nov 1 22:38:26 2016 New Revision: 308183 URL: https://svnweb.freebsd.org/changeset/base/308183 Log: [iwm] Get rid of SYNC_RESP_STRUCT and SYNC_RESP_PTR macros. * SYNC_RESP_STRUCT and SYNC_RESP_PTR originate from the OpenBSD version of iwm, and they weren't serving any real purpose in the FreeBSD port. * We just do a single bus_dmamap_sync for syncing the complete received frame, instead of explicitly bus_dmamap_sync-ing subranges of the frame like in the OpenBSD iwm code. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D7939 Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Tue Nov 1 22:03:36 2016 (r308182) +++ head/sys/dev/iwm/if_iwm.c Tue Nov 1 22:38:26 2016 (r308183) @@ -5071,18 +5071,6 @@ iwm_nic_error(struct iwm_softc *sc) } #endif -#define SYNC_RESP_STRUCT(_var_, _pkt_) \ -do { \ - bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);\ - _var_ = (void *)((_pkt_)+1); \ -} while (/*CONSTCOND*/0) - -#define SYNC_RESP_PTR(_ptr_, _len_, _pkt_) \ -do { \ - bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);\ - _ptr_ = (void *)((_pkt_)+1); \ -} while (/*CONSTCOND*/0) - #define ADVANCE_RXQ(sc) (sc->rxq.cur = (sc->rxq.cur + 1) % IWM_RX_RING_COUNT); /* @@ -5105,12 +5093,12 @@ iwm_notif_intr(struct iwm_softc *sc) */ while (sc->rxq.cur != hw) { struct iwm_rx_ring *ring = &sc->rxq; - struct iwm_rx_data *data = &sc->rxq.data[sc->rxq.cur]; + struct iwm_rx_data *data = &ring->data[ring->cur]; struct iwm_rx_packet *pkt; struct iwm_cmd_response *cresp; int qid, idx, code; - bus_dmamap_sync(sc->rxq.data_dmat, data->map, + bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); pkt = mtod(data->m, struct iwm_rx_packet *); @@ -5120,7 +5108,7 @@ iwm_notif_intr(struct iwm_softc *sc) code = IWM_WIDE_ID(pkt->hdr.flags, pkt->hdr.code); IWM_DPRINTF(sc, IWM_DEBUG_INTR, "rx packet qid=%d idx=%d type=%x %d %d\n", - pkt->hdr.qid & ~0x80, pkt->hdr.idx, code, sc->rxq.cur, hw); + pkt->hdr.qid & ~0x80, pkt->hdr.idx, code, ring->cur, hw); /* * randomly get these from the firmware, no idea why. @@ -5152,7 +5140,7 @@ iwm_notif_intr(struct iwm_softc *sc) /* XXX look at mac_id to determine interface ID */ struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); - SYNC_RESP_STRUCT(resp, pkt); + resp = (void *)pkt->data; missed = le32toh(resp->consec_missed_beacons); IWM_DPRINTF(sc, IWM_DEBUG_BEACON | IWM_DEBUG_STATE, @@ -5192,7 +5180,7 @@ iwm_notif_intr(struct iwm_softc *sc) struct iwm_mvm_alive_resp_v3 *resp3; if (iwm_rx_packet_payload_len(pkt) == sizeof(*resp1)) { - SYNC_RESP_STRUCT(resp1, pkt); + resp1 = (void *)pkt->data; sc->sc_uc.uc_error_event_table = le32toh(resp1->error_event_table_ptr); sc->sc_uc.uc_log_event_table @@ -5205,7 +5193,7 @@ iwm_notif_intr(struct iwm_softc *sc) } if (iwm_rx_packet_payload_len(pkt) == sizeof(*resp2)) { - SYNC_RESP_STRUCT(resp2, pkt); + resp2 = (void *)pkt->data; sc->sc_uc.uc_error_event_table = le32toh(resp2->error_event_table_ptr); sc->sc_uc.uc_log_event_table @@ -5220,7 +5208,7 @@ iwm_notif_intr(struct iwm_softc *sc) } if (iwm_rx_packet_payload_len(pkt) == sizeof(*resp3)) { - SYNC_RESP_STRUCT(resp3, pkt); + resp3 = (void *)pkt->data; sc->sc_uc.uc_error_event_table = le32toh(resp3->error_event_table_ptr); sc->sc_uc.uc_log_event_table @@ -5240,7 +5228,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_CALIB_RES_NOTIF_PHY_DB: { struct iwm_calib_res_notif_phy_db *phy_db_notif; - SYNC_RESP_STRUCT(phy_db_notif, pkt); + phy_db_notif = (void *)pkt->data; iwm_phy_db_set_section(sc, phy_db_notif); @@ -5248,7 +5236,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_STATISTICS_NOTIFICATION: { struct iwm_notif_statistics *stats; - SYNC_RESP_STRUCT(stats, pkt); + stats = (void *)pkt->data; memcpy(&sc->sc_stats, stats, sizeof(sc->sc_stats)); sc->sc_noise = iwm_get_noise(sc, &stats->rx.general); break; } @@ -5256,8 +5244,6 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_NVM_ACCESS_CMD: case IWM_MCC_UPDATE_CMD: if (sc->sc_wantresp == ((qid << 16) | idx)) { - bus_dmamap_sync(sc->rxq.data_dmat, data->map, - BUS_DMASYNC_POSTREAD); memcpy(sc->sc_cmd_resp, pkt, sizeof(sc->sc_cmd_resp)); } @@ -5265,7 +5251,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_MCC_CHUB_UPDATE_CMD: { struct iwm_mcc_chub_notif *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; sc->sc_fw_mcc[0] = (notif->mcc & 0xff00) >> 8; sc->sc_fw_mcc[1] = notif->mcc & 0xff; @@ -5298,7 +5284,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_LQ_CMD: case IWM_BT_CONFIG: case IWM_REPLY_THERMAL_MNG_BACKOFF: - SYNC_RESP_STRUCT(cresp, pkt); + cresp = (void *)pkt->data; if (sc->sc_wantresp == ((qid << 16) | idx)) { memcpy(sc->sc_cmd_resp, pkt, sizeof(*pkt)+sizeof(*cresp)); @@ -5316,20 +5302,20 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_SCAN_OFFLOAD_COMPLETE: { struct iwm_periodic_scan_complete *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; break; } case IWM_SCAN_ITERATION_COMPLETE: { struct iwm_lmac_scan_complete_notif *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; ieee80211_runtask(&sc->sc_ic, &sc->sc_es_task); break; } case IWM_SCAN_COMPLETE_UMAC: { struct iwm_umac_scan_complete *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; IWM_DPRINTF(sc, IWM_DEBUG_SCAN, "UMAC scan complete, status=0x%x\n", @@ -5342,7 +5328,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_SCAN_ITERATION_COMPLETE_UMAC: { struct iwm_umac_scan_iter_complete_notif *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; IWM_DPRINTF(sc, IWM_DEBUG_SCAN, "UMAC scan iteration " "complete, status=0x%x, %d channels scanned\n", @@ -5353,7 +5339,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_REPLY_ERROR: { struct iwm_error_resp *resp; - SYNC_RESP_STRUCT(resp, pkt); + resp = (void *)pkt->data; device_printf(sc->sc_dev, "firmware error 0x%x, cmd 0x%x\n", @@ -5364,7 +5350,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_TIME_EVENT_NOTIFICATION: { struct iwm_time_event_notif *notif; - SYNC_RESP_STRUCT(notif, pkt); + notif = (void *)pkt->data; IWM_DPRINTF(sc, IWM_DEBUG_INTR, "TE notif status = 0x%x action = 0x%x\n", @@ -5377,7 +5363,7 @@ iwm_notif_intr(struct iwm_softc *sc) case IWM_SCD_QUEUE_CFG: { struct iwm_scd_txq_cfg_rsp *rsp; - SYNC_RESP_STRUCT(rsp, pkt); + rsp = (void *)pkt->data; IWM_DPRINTF(sc, IWM_DEBUG_CMD, "queue cfg token=0x%x sta_id=%d " From owner-svn-src-head@freebsd.org Tue Nov 1 22:47:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3A36C2AE86; Tue, 1 Nov 2016 22:47:59 +0000 (UTC) (envelope-from ivadasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A879B157C; Tue, 1 Nov 2016 22:47:59 +0000 (UTC) (envelope-from ivadasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA1Mlw1F077352; Tue, 1 Nov 2016 22:47:58 GMT (envelope-from ivadasz@FreeBSD.org) Received: (from ivadasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA1MlwSu077351; Tue, 1 Nov 2016 22:47:58 GMT (envelope-from ivadasz@FreeBSD.org) Message-Id: <201611012247.uA1MlwSu077351@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ivadasz set sender to ivadasz@FreeBSD.org using -f From: =?UTF-8?Q?Imre_Vad=c3=a1sz?= Date: Tue, 1 Nov 2016 22:47:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308185 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 22:48:00 -0000 Author: ivadasz Date: Tue Nov 1 22:47:58 2016 New Revision: 308185 URL: https://svnweb.freebsd.org/changeset/base/308185 Log: [iwm] Set full-offload scan flag. Fixes fw panic when already associated. * Starting a scan from wpa_supplicant or via ifconfig while associated, should no longer cause firmware panics or abort early. Tested: * AC7260, STA mode Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8412 Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Tue Nov 1 22:40:25 2016 (r308184) +++ head/sys/dev/iwm/if_iwm.c Tue Nov 1 22:47:58 2016 (r308185) @@ -5879,6 +5879,8 @@ iwm_attach(device_t dev) IEEE80211_C_SHPREAMBLE /* short preamble supported */ // IEEE80211_C_BGSCAN /* capable of bg scanning */ ; + /* Advertise full-offload scanning */ + ic->ic_flags_ext = IEEE80211_FEXT_SCAN_OFFLOAD; for (i = 0; i < nitems(sc->sc_phyctxt); i++) { sc->sc_phyctxt[i].id = i; sc->sc_phyctxt[i].color = 0; From owner-svn-src-head@freebsd.org Tue Nov 1 23:41:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 185E4C2A9A8; Tue, 1 Nov 2016 23:41:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A27AD100C; Tue, 1 Nov 2016 23:41:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:7b8:3a7::b1de:3edc:3315:7091] (unknown [IPv6:2001:7b8:3a7:0:b1de:3edc:3315:7091]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id C2C5012C1F; Wed, 2 Nov 2016 00:41:02 +0100 (CET) Content-Type: multipart/signed; boundary="Apple-Mail=_83304E14-9301-494C-94FD-7F49B67553D6"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r308181 - in head: . share/mk From: Dimitry Andric In-Reply-To: <201611012127.uA1LRg0B045900@repo.freebsd.org> Date: Wed, 2 Nov 2016 00:40:57 +0100 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Ed Maste Message-Id: <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> References: <201611012127.uA1LRg0B045900@repo.freebsd.org> To: Jonathan Anderson X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2016 23:41:06 -0000 --Apple-Mail=_83304E14-9301-494C-94FD-7F49B67553D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 01 Nov 2016, at 22:27, Jonathan Anderson = wrote: >=20 > Author: jonathan > Date: Tue Nov 1 21:27:42 2016 > New Revision: 308181 > URL: https://svnweb.freebsd.org/changeset/base/308181 >=20 > Log: > Add rules to build LLVM IR binaries and libraries. >=20 > Running `make libfoo.ll` or `make libfoo.bc` within a library = directory > will now give us an LLVM IR version of the library, and `make = foo.full.ll` > or `make foo.full.bc` will give us an IR version of a binary. Please note, I reverted r307823 (which changed the suffixes from .bco and .llo to .bc and .ll) in r308003, since it caused a number of ports failures. These ports were already using .ll as a suffix for C++ lex scripts. > Modified: head/share/mk/bsd.lib.mk > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/share/mk/bsd.lib.mk Tue Nov 1 21:08:37 2016 = (r308180) > +++ head/share/mk/bsd.lib.mk Tue Nov 1 21:27:42 2016 = (r308181) > @@ -78,7 +78,7 @@ CTFFLAGS+=3D -g >=20 > # prefer .s to a .c, add .po, remove stuff not used in the BSD = libraries > # .pico used for PIC object files > -.SUFFIXES: .out .o .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l = .ln > +.SUFFIXES: .out .o .bc .ll .po .pico .S .asm .s .c .cc .cpp .cxx .C = .f .y .l .ln So here, please use .bco and .llo. > @@ -199,6 +199,18 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} > ${RANLIB} ${RANLIBFLAGS} ${.TARGET} > .endif >=20 > +.if defined(LLVM_LINK) > +BCOBJS=3D ${OBJS:.o=3D.bco} ${STATICOBJS:.o=3D.bco} > +LLOBJS=3D ${OBJS:.o=3D.llo} ${STATICOBJS:.o=3D.llo} But apparently you already used those suffixes here. > Modified: head/share/mk/bsd.prog.mk > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/share/mk/bsd.prog.mk Tue Nov 1 21:08:37 2016 = (r308180) > +++ head/share/mk/bsd.prog.mk Tue Nov 1 21:27:42 2016 = (r308181) > @@ -4,7 +4,7 @@ > .include > .include >=20 > -.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm > +.SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S = .asm But not here, these should also be changed. Sorry for any confusion. -Dimitry --Apple-Mail=_83304E14-9301-494C-94FD-7F49B67553D6 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlgZKA0ACgkQsF6jCi4glqMxRQCfUXfsIVRkLTiDyAJW2H+A1AYG 4LgAoLTkkTVUAbQViBo0LBz+hjF2HXew =N6JI -----END PGP SIGNATURE----- --Apple-Mail=_83304E14-9301-494C-94FD-7F49B67553D6-- From owner-svn-src-head@freebsd.org Wed Nov 2 00:51:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11D05C29998; Wed, 2 Nov 2016 00:51:11 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 893211B94; Wed, 2 Nov 2016 00:51:10 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA20p9fK023005; Wed, 2 Nov 2016 00:51:09 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA20p96l023002; Wed, 2 Nov 2016 00:51:09 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611020051.uA20p96l023002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 00:51:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308186 - in head/sys: arm/freescale/imx dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 00:51:11 -0000 Author: jhibbits Date: Wed Nov 2 00:51:09 2016 New Revision: 308186 URL: https://svnweb.freebsd.org/changeset/base/308186 Log: Move imx_sdhci driver over to a dev/sdhci in preparation for QorIQ support. Freescale uses eSDHC in both i.MX (ARM) and QorIQ (PowerPC), with slight differences. This is part one in unifying the drivers. Reviewed by: imp Added: head/sys/dev/sdhci/fsl_sdhci.c - copied, changed from r308185, head/sys/arm/freescale/imx/imx_sdhci.c Deleted: head/sys/arm/freescale/imx/imx_sdhci.c Modified: head/sys/arm/freescale/imx/files.imx5 head/sys/arm/freescale/imx/files.imx6 Modified: head/sys/arm/freescale/imx/files.imx5 ============================================================================== --- head/sys/arm/freescale/imx/files.imx5 Tue Nov 1 22:47:58 2016 (r308185) +++ head/sys/arm/freescale/imx/files.imx5 Wed Nov 2 00:51:09 2016 (r308186) @@ -32,7 +32,7 @@ arm/freescale/imx/imx51_ccm.c standard dev/ata/chipsets/ata-fsl.c optional imxata # SDHCI/MMC -arm/freescale/imx/imx_sdhci.c optional sdhci +dev/sdhci/fsl_sdhci.c optional sdhci # USB OH3 controller (1 OTG, 3 EHCI) arm/freescale/imx/imx_nop_usbphy.c optional ehci Modified: head/sys/arm/freescale/imx/files.imx6 ============================================================================== --- head/sys/arm/freescale/imx/files.imx6 Tue Nov 1 22:47:58 2016 (r308185) +++ head/sys/arm/freescale/imx/files.imx6 Wed Nov 2 00:51:09 2016 (r308186) @@ -32,7 +32,7 @@ arm/freescale/imx/imx6_ipu.c optional v # # Optional devices. # -arm/freescale/imx/imx_sdhci.c optional sdhci +dev/sdhci/fsl_sdhci.c optional sdhci arm/freescale/imx/imx_wdog.c optional imxwdt Copied and modified: head/sys/dev/sdhci/fsl_sdhci.c (from r308185, head/sys/arm/freescale/imx/imx_sdhci.c) ============================================================================== --- head/sys/arm/freescale/imx/imx_sdhci.c Tue Nov 1 22:47:58 2016 (r308185, copy source) +++ head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 00:51:09 2016 (r308186) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include "sdhci_if.h" -struct imx_sdhci_softc { +struct fsl_sdhci_softc { device_t dev; struct resource * mem_res; struct resource * irq_res; @@ -88,8 +88,8 @@ struct imx_sdhci_softc { #define R1BFIX_AC12 2 /* Wait for busy after auto command 12. */ #define HWTYPE_NONE 0 /* Hardware not recognized/supported. */ -#define HWTYPE_ESDHC 1 /* imx5x and earlier. */ -#define HWTYPE_USDHC 2 /* imx6. */ +#define HWTYPE_ESDHC 1 /* fsl5x and earlier. */ +#define HWTYPE_USDHC 2 /* fsl6. */ /* * Freescale-specific registers, or in some cases the layout of bits within the @@ -172,28 +172,28 @@ static struct ofw_compat_data compat_dat {NULL, HWTYPE_NONE}, }; -static uint16_t imx_sdhc_get_clock(struct imx_sdhci_softc *sc); -static void imx_sdhc_set_clock(struct imx_sdhci_softc *sc, uint16_t val); -static void imx_sdhci_r1bfix_func(void *arg); +static uint16_t fsl_sdhc_get_clock(struct fsl_sdhci_softc *sc); +static void fsl_sdhc_set_clock(struct fsl_sdhci_softc *sc, uint16_t val); +static void fsl_sdhci_r1bfix_func(void *arg); static inline uint32_t -RD4(struct imx_sdhci_softc *sc, bus_size_t off) +RD4(struct fsl_sdhci_softc *sc, bus_size_t off) { return (bus_read_4(sc->mem_res, off)); } static inline void -WR4(struct imx_sdhci_softc *sc, bus_size_t off, uint32_t val) +WR4(struct fsl_sdhci_softc *sc, bus_size_t off, uint32_t val) { bus_write_4(sc->mem_res, off, val); } static uint8_t -imx_sdhci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32, wrk32; /* @@ -246,9 +246,9 @@ imx_sdhci_read_1(device_t dev, struct sd } static uint16_t -imx_sdhci_read_2(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_2(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; if (sc->hwtype == HWTYPE_USDHC) { @@ -297,16 +297,16 @@ imx_sdhci_read_2(device_t dev, struct sd * hardware type, complex enough to have their own function. */ if (off == SDHCI_CLOCK_CONTROL) { - return (imx_sdhc_get_clock(sc)); + return (fsl_sdhc_get_clock(sc)); } return ((RD4(sc, off & ~3) >> (off & 3) * 8) & 0xffff); } static uint32_t -imx_sdhci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32, wrk32; val32 = RD4(sc, off); @@ -348,7 +348,7 @@ imx_sdhci_read_4(device_t dev, struct sd } /* - * imx_sdhci_intr() can synthesize a DATA_END interrupt following a + * fsl_sdhci_intr() can synthesize a DATA_END interrupt following a * command with an R1B response, mix it into the hardware status. */ if (off == SDHCI_INT_STATUS) { @@ -359,18 +359,18 @@ imx_sdhci_read_4(device_t dev, struct sd } static void -imx_sdhci_read_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, +fsl_sdhci_read_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t *data, bus_size_t count) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); bus_read_multi_4(sc->mem_res, off, data, count); } static void -imx_sdhci_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint8_t val) +fsl_sdhci_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint8_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; /* @@ -406,9 +406,9 @@ imx_sdhci_write_1(device_t dev, struct s } static void -imx_sdhci_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint16_t val) +fsl_sdhci_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint16_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; /* @@ -416,7 +416,7 @@ imx_sdhci_write_2(device_t dev, struct s * that can handle the ESDHC versus USDHC differences. */ if (off == SDHCI_CLOCK_CONTROL) { - imx_sdhc_set_clock(sc, val); + fsl_sdhc_set_clock(sc, val); return; } @@ -432,7 +432,7 @@ imx_sdhci_write_2(device_t dev, struct s * there's a control bit for it (bit 3) in the vendor register. * When we're starting a command that needs a manual DAT0 line check at * interrupt time, we leave ourselves a note in r1bfix_type so that we - * can do the extra work in imx_sdhci_intr(). + * can do the extra work in fsl_sdhci_intr(). */ if (off == SDHCI_COMMAND_FLAGS) { if (val & SDHCI_CMD_DATA) { @@ -485,9 +485,9 @@ imx_sdhci_write_2(device_t dev, struct s } static void -imx_sdhci_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t val) +fsl_sdhci_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); /* Clear synthesized interrupts, then pass the value to the hardware. */ if (off == SDHCI_INT_STATUS) { @@ -498,16 +498,16 @@ imx_sdhci_write_4(device_t dev, struct s } static void -imx_sdhci_write_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, +fsl_sdhci_write_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t *data, bus_size_t count) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); bus_write_multi_4(sc->mem_res, off, data, count); } static uint16_t -imx_sdhc_get_clock(struct imx_sdhci_softc *sc) +fsl_sdhc_get_clock(struct fsl_sdhci_softc *sc) { uint16_t val; @@ -551,7 +551,7 @@ imx_sdhc_get_clock(struct imx_sdhci_soft } static void -imx_sdhc_set_clock(struct imx_sdhci_softc *sc, uint16_t val) +fsl_sdhc_set_clock(struct fsl_sdhci_softc *sc, uint16_t val) { uint32_t divisor, freq, prescale, val32; @@ -629,7 +629,7 @@ imx_sdhc_set_clock(struct imx_sdhci_soft } static boolean_t -imx_sdhci_r1bfix_is_wait_done(struct imx_sdhci_softc *sc) +fsl_sdhci_r1bfix_is_wait_done(struct fsl_sdhci_softc *sc) { uint32_t inhibit; @@ -646,7 +646,7 @@ imx_sdhci_r1bfix_is_wait_done(struct imx if (inhibit && getsbinuptime() < sc->r1bfix_timeout_at) { callout_reset_sbt(&sc->r1bfix_callout, SBT_1MS, 0, - imx_sdhci_r1bfix_func, sc, 0); + fsl_sdhci_r1bfix_func, sc, 0); return (false); } @@ -670,22 +670,22 @@ imx_sdhci_r1bfix_is_wait_done(struct imx } static void -imx_sdhci_r1bfix_func(void * arg) +fsl_sdhci_r1bfix_func(void * arg) { - struct imx_sdhci_softc *sc = arg; + struct fsl_sdhci_softc *sc = arg; boolean_t r1bwait_done; mtx_lock(&sc->slot.mtx); - r1bwait_done = imx_sdhci_r1bfix_is_wait_done(sc); + r1bwait_done = fsl_sdhci_r1bfix_is_wait_done(sc); mtx_unlock(&sc->slot.mtx); if (r1bwait_done) sdhci_generic_intr(&sc->slot); } static void -imx_sdhci_intr(void *arg) +fsl_sdhci_intr(void *arg) { - struct imx_sdhci_softc *sc = arg; + struct fsl_sdhci_softc *sc = arg; uint32_t intmask; mtx_lock(&sc->slot.mtx); @@ -721,7 +721,7 @@ imx_sdhci_intr(void *arg) } if (intmask) { sc->r1bfix_timeout_at = getsbinuptime() + 250 * SBT_1MS; - if (!imx_sdhci_r1bfix_is_wait_done(sc)) { + if (!fsl_sdhci_r1bfix_is_wait_done(sc)) { WR4(sc, SDHC_INT_STATUS, intmask); bus_barrier(sc->mem_res, SDHC_INT_STATUS, 4, BUS_SPACE_BARRIER_WRITE); @@ -733,23 +733,23 @@ imx_sdhci_intr(void *arg) } static int -imx_sdhci_get_ro(device_t bus, device_t child) +fsl_sdhci_get_ro(device_t bus, device_t child) { return (false); } static int -imx_sdhci_detach(device_t dev) +fsl_sdhci_detach(device_t dev) { return (EBUSY); } static int -imx_sdhci_attach(device_t dev) +fsl_sdhci_attach(device_t dev) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); int rid, err; phandle_t node; @@ -757,7 +757,7 @@ imx_sdhci_attach(device_t dev) sc->hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; if (sc->hwtype == HWTYPE_NONE) - panic("Impossible: not compatible in imx_sdhci_attach()"); + panic("Impossible: not compatible in fsl_sdhci_attach()"); rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, @@ -778,7 +778,7 @@ imx_sdhci_attach(device_t dev) } if (bus_setup_intr(dev, sc->irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, imx_sdhci_intr, sc, &sc->intr_cookie)) { + NULL, fsl_sdhci_intr, sc, &sc->intr_cookie)) { device_printf(dev, "cannot setup interrupt handler\n"); err = ENXIO; goto fail; @@ -853,7 +853,7 @@ fail: } static int -imx_sdhci_probe(device_t dev) +fsl_sdhci_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) @@ -872,11 +872,11 @@ imx_sdhci_probe(device_t dev) return (ENXIO); } -static device_method_t imx_sdhci_methods[] = { +static device_method_t fsl_sdhci_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, imx_sdhci_probe), - DEVMETHOD(device_attach, imx_sdhci_attach), - DEVMETHOD(device_detach, imx_sdhci_detach), + DEVMETHOD(device_probe, fsl_sdhci_probe), + DEVMETHOD(device_attach, fsl_sdhci_attach), + DEVMETHOD(device_detach, fsl_sdhci_detach), /* Bus interface */ DEVMETHOD(bus_read_ivar, sdhci_generic_read_ivar), @@ -886,32 +886,32 @@ static device_method_t imx_sdhci_methods /* MMC bridge interface */ DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), DEVMETHOD(mmcbr_request, sdhci_generic_request), - DEVMETHOD(mmcbr_get_ro, imx_sdhci_get_ro), + DEVMETHOD(mmcbr_get_ro, fsl_sdhci_get_ro), DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), /* SDHCI registers accessors */ - DEVMETHOD(sdhci_read_1, imx_sdhci_read_1), - DEVMETHOD(sdhci_read_2, imx_sdhci_read_2), - DEVMETHOD(sdhci_read_4, imx_sdhci_read_4), - DEVMETHOD(sdhci_read_multi_4, imx_sdhci_read_multi_4), - DEVMETHOD(sdhci_write_1, imx_sdhci_write_1), - DEVMETHOD(sdhci_write_2, imx_sdhci_write_2), - DEVMETHOD(sdhci_write_4, imx_sdhci_write_4), - DEVMETHOD(sdhci_write_multi_4, imx_sdhci_write_multi_4), + DEVMETHOD(sdhci_read_1, fsl_sdhci_read_1), + DEVMETHOD(sdhci_read_2, fsl_sdhci_read_2), + DEVMETHOD(sdhci_read_4, fsl_sdhci_read_4), + DEVMETHOD(sdhci_read_multi_4, fsl_sdhci_read_multi_4), + DEVMETHOD(sdhci_write_1, fsl_sdhci_write_1), + DEVMETHOD(sdhci_write_2, fsl_sdhci_write_2), + DEVMETHOD(sdhci_write_4, fsl_sdhci_write_4), + DEVMETHOD(sdhci_write_multi_4, fsl_sdhci_write_multi_4), { 0, 0 } }; -static devclass_t imx_sdhci_devclass; +static devclass_t fsl_sdhci_devclass; -static driver_t imx_sdhci_driver = { - "sdhci_imx", - imx_sdhci_methods, - sizeof(struct imx_sdhci_softc), +static driver_t fsl_sdhci_driver = { + "sdhci_fsl", + fsl_sdhci_methods, + sizeof(struct fsl_sdhci_softc), }; -DRIVER_MODULE(sdhci_imx, simplebus, imx_sdhci_driver, imx_sdhci_devclass, 0, 0); -MODULE_DEPEND(sdhci_imx, sdhci, 1, 1, 1); -DRIVER_MODULE(mmc, sdhci_imx, mmc_driver, mmc_devclass, NULL, NULL); -MODULE_DEPEND(sdhci_imx, mmc, 1, 1, 1); +DRIVER_MODULE(sdhci_fsl, simplebus, fsl_sdhci_driver, fsl_sdhci_devclass, 0, 0); +MODULE_DEPEND(sdhci_fsl, sdhci, 1, 1, 1); +DRIVER_MODULE(mmc, sdhci_fsl, mmc_driver, mmc_devclass, NULL, NULL); +MODULE_DEPEND(sdhci_fsl, mmc, 1, 1, 1); From owner-svn-src-head@freebsd.org Wed Nov 2 00:54:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3EC3AC29B62; Wed, 2 Nov 2016 00:54:41 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5D8A1CC4; Wed, 2 Nov 2016 00:54:40 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA20sdAZ025976; Wed, 2 Nov 2016 00:54:39 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA20sdnK025975; Wed, 2 Nov 2016 00:54:39 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611020054.uA20sdnK025975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 00:54:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308187 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 00:54:41 -0000 Author: jhibbits Date: Wed Nov 2 00:54:39 2016 New Revision: 308187 URL: https://svnweb.freebsd.org/changeset/base/308187 Log: Toggle card insert/remove interrupt enable bits on events Some controllers (namely Freescale's eSDHC, tested) will continue to assert the card removed or card insert interrupts even after being handled. To work around this, disable watching the interrupt that just occurred until the opposite interrupt is triggered. Linux has a similar change in its driver to address the same problem. Modified: head/sys/dev/sdhci/sdhci.c Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Wed Nov 2 00:51:09 2016 (r308186) +++ head/sys/dev/sdhci/sdhci.c Wed Nov 2 00:54:39 2016 (r308187) @@ -1309,7 +1309,7 @@ sdhci_acmd_irq(struct sdhci_slot *slot) void sdhci_generic_intr(struct sdhci_slot *slot) { - uint32_t intmask; + uint32_t intmask, present; SDHCI_LOCK(slot); /* Read slot interrupt status. */ @@ -1323,6 +1323,13 @@ sdhci_generic_intr(struct sdhci_slot *sl /* Handle card presence interrupts. */ if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) { + present = RD4(slot, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT; + slot->intmask &= + ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); + slot->intmask |= present ? SDHCI_INT_CARD_REMOVE : + SDHCI_INT_CARD_INSERT; + WR4(slot, SDHCI_INT_ENABLE, slot->intmask); + WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); WR4(slot, SDHCI_INT_STATUS, intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)); From owner-svn-src-head@freebsd.org Wed Nov 2 00:57:06 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 564C4C29C00; Wed, 2 Nov 2016 00:57:06 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8CBD17E9; Wed, 2 Nov 2016 00:57:05 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA20v4is026120; Wed, 2 Nov 2016 00:57:04 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA20v4hY026118; Wed, 2 Nov 2016 00:57:04 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611020057.uA20v4hY026118@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 00:57:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308188 - in head/sys: conf dev/sdhci powerpc/mpc85xx X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 00:57:06 -0000 Author: jhibbits Date: Wed Nov 2 00:57:04 2016 New Revision: 308188 URL: https://svnweb.freebsd.org/changeset/base/308188 Log: Merge i.MX and PowerPC SDHCI drivers Summary: i.MX5 and PowerPC use a very similar eSDHC controller, which is also similar to the uSDHC controller used by i.MX6. The imx_sdhci driver works almost completely with PowerPC, with some minor tweaks. There is one caveat with this: reset currently does not work on PowerPC, so has been #ifdef'd out until this can be tracked down and fixed. If resets are done the controller will timeout all data transactions. Without a reset, it appears to work just fine. This is part 3, following up r308186 and r308187. Test Plan: This has been tested on a PowerPC QorIQ P1022 board. It has not been tested on i.MX, but no regressions are expected. Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D8407 Deleted: head/sys/powerpc/mpc85xx/fsl_sdhc.c head/sys/powerpc/mpc85xx/fsl_sdhc.h Modified: head/sys/conf/files.powerpc head/sys/dev/sdhci/fsl_sdhci.c Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Wed Nov 2 00:54:39 2016 (r308187) +++ head/sys/conf/files.powerpc Wed Nov 2 00:57:04 2016 (r308188) @@ -63,6 +63,7 @@ dev/ofw/ofw_subr.c optional aim powerpc dev/powermac_nvram/powermac_nvram.c optional powermac_nvram powermac dev/quicc/quicc_bfe_fdt.c optional quicc mpc85xx dev/scc/scc_bfe_macio.c optional scc powermac +dev/sdhci/fsl_sdhci.c optional mpc85xx sdhci dev/sec/sec.c optional sec mpc85xx dev/sound/macio/aoa.c optional snd_davbus | snd_ai2s powermac dev/sound/macio/davbus.c optional snd_davbus powermac @@ -137,7 +138,6 @@ powerpc/mpc85xx/atpic.c optional mpc85x powerpc/mpc85xx/ds1553_bus_fdt.c optional ds1553 fdt powerpc/mpc85xx/ds1553_core.c optional ds1553 powerpc/mpc85xx/fsl_diu.c optional mpc85xx diu -powerpc/mpc85xx/fsl_sdhc.c optional mpc85xx sdhc powerpc/mpc85xx/i2c.c optional iicbus fdt powerpc/mpc85xx/isa.c optional mpc85xx isa powerpc/mpc85xx/lbc.c optional mpc85xx Modified: head/sys/dev/sdhci/fsl_sdhci.c ============================================================================== --- head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 00:54:39 2016 (r308187) +++ head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 00:57:04 2016 (r308188) @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); /* - * SDHCI driver glue for Freescale i.MX SoC family. + * SDHCI driver glue for Freescale i.MX SoC and QorIQ families. * * This supports both eSDHC (earlier SoCs) and uSDHC (more recent SoCs). */ @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -52,9 +53,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __arm__ #include #include +#endif #include #include @@ -146,7 +149,6 @@ struct fsl_sdhci_softc { #define SDHC_PROT_CDSS (1 << 7) #define SDHC_SYS_CTRL 0x2c -#define SDHC_INT_STATUS 0x30 /* * The clock enable bits exist in different registers for ESDHC vs USDHC, but @@ -169,6 +171,7 @@ static struct ofw_compat_data compat_dat {"fsl,imx6sl-usdhc", HWTYPE_USDHC}, {"fsl,imx53-esdhc", HWTYPE_ESDHC}, {"fsl,imx51-esdhc", HWTYPE_ESDHC}, + {"fsl,esdhc", HWTYPE_ESDHC}, {NULL, HWTYPE_NONE}, }; @@ -397,6 +400,11 @@ fsl_sdhci_write_1(device_t dev, struct s if (off == SDHCI_POWER_CONTROL) { return; } +#ifdef __powerpc__ + /* XXX Reset doesn't seem to work as expected. Do nothing for now. */ + if (off == SDHCI_SOFTWARE_RESET) + return; +#endif val32 = RD4(sc, off & ~3); val32 &= ~(0xff << (off & 3) * 8); @@ -531,17 +539,20 @@ fsl_sdhc_get_clock(struct fsl_sdhci_soft val |= SDHCI_CLOCK_INT_STABLE; /* - * On ESDHC hardware the card bus clock enable is in the usual sdhci - * register but it's a different bit, so transcribe it (note the + * On i.MX ESDHC hardware the card bus clock enable is in the usual + * sdhci register but it's a different bit, so transcribe it (note the * difference between standard SDHCI_ and Freescale SDHC_ prefixes - * here). On USDHC hardware there is a force-on bit, but no force-off - * for the card bus clock (the hardware runs the clock when transfers - * are active no matter what), so we always say the clock is on. + * here). On USDHC and QorIQ ESDHC hardware there is a force-on bit, but + * no force-off for the card bus clock (the hardware runs the clock when + * transfers are active no matter what), so we always say the clock is + * on. * XXX Maybe we should say it's in whatever state the sdhci driver last * set it to. */ if (sc->hwtype == HWTYPE_ESDHC) { +#ifdef __arm__ if (RD4(sc, SDHC_SYS_CTRL) & SDHC_CLK_SDCLKEN) +#endif val |= SDHCI_CLOCK_CARD_EN; } else { val |= SDHCI_CLOCK_CARD_EN; @@ -565,15 +576,18 @@ fsl_sdhc_set_clock(struct fsl_sdhci_soft sc->sdclockreg_freq_bits = val & SDHCI_DIVIDERS_MASK; if (sc->hwtype == HWTYPE_ESDHC) { /* - * The ESDHC hardware requires the driver to manually start and - * stop the sd bus clock. If the enable bit is not set, turn - * off the clock in hardware and we're done, otherwise decode - * the requested frequency. ESDHC hardware is sdhci 2.0; the - * sdhci driver will use the original 8-bit divisor field and - * the "base / 2^N" divisor scheme. + * The i.MX5 ESDHC hardware requires the driver to manually + * start and stop the sd bus clock. If the enable bit is not + * set, turn off the clock in hardware and we're done, otherwise + * decode the requested frequency. ESDHC hardware is sdhci 2.0; + * the sdhci driver will use the original 8-bit divisor field + * and the "base / 2^N" divisor scheme. */ if ((val & SDHCI_CLOCK_CARD_EN) == 0) { +#ifdef __arm__ + /* On QorIQ, this is a reserved bit. */ WR4(sc, SDHCI_CLOCK_CONTROL, val32 & ~SDHC_CLK_SDCLKEN); +#endif return; } @@ -625,6 +639,7 @@ fsl_sdhc_set_clock(struct fsl_sdhci_soft val32 &= ~(SDHC_CLK_DIVISOR_MASK | SDHC_CLK_PRESCALE_MASK); val32 |= divisor << SDHC_CLK_DIVISOR_SHIFT; val32 |= prescale << SDHC_CLK_PRESCALE_SHIFT; + val32 |= SDHC_CLK_IPGEN; WR4(sc, SDHCI_CLOCK_CONTROL, val32); } @@ -710,10 +725,10 @@ fsl_sdhci_intr(void *arg) */ switch (sc->r1bfix_type) { case R1BFIX_NODATA: - intmask = RD4(sc, SDHC_INT_STATUS) & SDHCI_INT_RESPONSE; + intmask = RD4(sc, SDHCI_INT_STATUS) & SDHCI_INT_RESPONSE; break; case R1BFIX_AC12: - intmask = RD4(sc, SDHC_INT_STATUS) & SDHCI_INT_DATA_END; + intmask = RD4(sc, SDHCI_INT_STATUS) & SDHCI_INT_DATA_END; break; default: intmask = 0; @@ -722,8 +737,8 @@ fsl_sdhci_intr(void *arg) if (intmask) { sc->r1bfix_timeout_at = getsbinuptime() + 250 * SBT_1MS; if (!fsl_sdhci_r1bfix_is_wait_done(sc)) { - WR4(sc, SDHC_INT_STATUS, intmask); - bus_barrier(sc->mem_res, SDHC_INT_STATUS, 4, + WR4(sc, SDHCI_INT_STATUS, intmask); + bus_barrier(sc->mem_res, SDHCI_INT_STATUS, 4, BUS_SPACE_BARRIER_WRITE); } } @@ -735,9 +750,53 @@ fsl_sdhci_intr(void *arg) static int fsl_sdhci_get_ro(device_t bus, device_t child) { + struct fsl_sdhci_softc *sc = device_get_softc(bus); + + if (RD4(sc, SDHCI_PRESENT_STATE) & SDHC_PRES_WPSPL) + return (false); + return (true); +} + +#ifdef __powerpc__ +static uint32_t +fsl_sdhci_get_platform_clock(device_t dev) +{ + device_t parent; + phandle_t node; + uint32_t clock; + + node = ofw_bus_get_node(dev); - return (false); + /* Get sdhci node properties */ + if((OF_getprop(node, "clock-frequency", (void *)&clock, + sizeof(clock)) <= 0) || (clock == 0)) { + + /* + * Trying to get clock from parent device (soc) if correct + * clock cannot be acquired from sdhci node. + */ + parent = device_get_parent(dev); + node = ofw_bus_get_node(parent); + + /* Get soc properties */ + if ((OF_getprop(node, "bus-frequency", (void *)&clock, + sizeof(clock)) <= 0) || (clock == 0)) { + device_printf(dev,"Cannot acquire correct sdhci " + "frequency from DTS.\n"); + + return (0); + } + /* eSDHC clock is 1/2 platform clock. */ + clock /= 2; + } + + if (bootverbose) + device_printf(dev, "Acquired clock: %d from DTS\n", clock); + + return (clock); } +#endif + static int fsl_sdhci_detach(device_t dev) @@ -752,6 +811,7 @@ fsl_sdhci_attach(device_t dev) struct fsl_sdhci_softc *sc = device_get_softc(dev); int rid, err; phandle_t node; + uint32_t protctl; sc->dev = dev; @@ -807,9 +867,23 @@ fsl_sdhci_attach(device_t dev) * * XXX need named constants for this stuff. */ - WR4(sc, SDHC_WTMK_LVL, 0x08800880); +#ifdef __powerpc__ + /* P1022 has the '*_BRST_LEN' fields as reserved, always reading 0x10 */ + if ((SVR_VER(mfspr(SPR_SVR)) & 0xfff6) == SVR_P1022 ) + WR4(sc, SDHC_WTMK_LVL, 0x10801080); + else +#endif + WR4(sc, SDHC_WTMK_LVL, 0x08800880); + /* + * We read in native byte order in the main driver, but the register + * defaults to little endian. + */ +#ifdef __powerpc__ + sc->baseclk_hz = fsl_sdhci_get_platform_clock(dev); +#else sc->baseclk_hz = imx_ccm_sdhci_hz(); +#endif sc->slot.max_clk = sc->baseclk_hz; /* @@ -830,6 +904,16 @@ fsl_sdhci_attach(device_t dev) /* XXX put real gpio hookup here. */ sc->force_card_present = true; } +#ifdef __powerpc__ + /* Default to big-endian on powerpc */ + protctl = RD4(sc, SDHC_PROT_CTRL); + protctl &= ~SDHC_PROT_EMODE_MASK; + if (OF_hasprop(node, "little-endian")) + protctl |= SDHC_PROT_EMODE_LITTLE; + else + protctl |= SDHC_PROT_EMODE_BIG; + WR4(sc, SDHC_PROT_CTRL, protctl); +#endif callout_init(&sc->r1bfix_callout, 1); sdhci_init_slot(dev, &sc->slot, 0); From owner-svn-src-head@freebsd.org Wed Nov 2 01:27:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B04C2C2A226; Wed, 2 Nov 2016 01:27:21 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F2261B96; Wed, 2 Nov 2016 01:27:21 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA21RK53037373; Wed, 2 Nov 2016 01:27:20 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA21RKHe037372; Wed, 2 Nov 2016 01:27:20 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201611020127.uA21RKHe037372@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 2 Nov 2016 01:27:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308189 - head/sys/dev/atkbdc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 01:27:22 -0000 Author: gonzo Date: Wed Nov 2 01:27:20 2016 New Revision: 308189 URL: https://svnweb.freebsd.org/changeset/base/308189 Log: [psm] Fix choosing wrong mode for synaptic device + trackpoint With guest trackpoint present trackpoint probing switched synaptics device to absolute mode with different protocol instead of keeping it in relative mode. PR: 213757 Submitted by: Vladimir Kondratyev MFC after: 1 week Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c ============================================================================== --- head/sys/dev/atkbdc/psm.c Wed Nov 2 00:57:04 2016 (r308188) +++ head/sys/dev/atkbdc/psm.c Wed Nov 2 01:27:20 2016 (r308189) @@ -1062,27 +1062,15 @@ doopen(struct psm_softc *sc, int command */ if (sc->hw.model == MOUSE_MODEL_GENERIC) { if (tap_enabled > 0) { - /* - * Enable tap & drag gestures. We use a Mode Byte - * and clear the DisGest bit (see §2.5 of Synaptics - * TouchPad Interfacing Guide). - */ VLOG(2, (LOG_DEBUG, "psm%d: enable tap and drag gestures\n", sc->unit)); - mouse_ext_command(sc->kbdc, 0x00); - set_mouse_sampling_rate(sc->kbdc, 20); + synaptics_set_mode(sc, synaptics_preferred_mode(sc)); } else if (tap_enabled == 0) { - /* - * Disable tap & drag gestures. We use a Mode Byte - * and set the DisGest bit (see §2.5 of Synaptics - * TouchPad Interfacing Guide). - */ VLOG(2, (LOG_DEBUG, "psm%d: disable tap and drag gestures\n", sc->unit)); - mouse_ext_command(sc->kbdc, 0x04); - set_mouse_sampling_rate(sc->kbdc, 20); + synaptics_set_mode(sc, synaptics_preferred_mode(sc)); } } @@ -5364,6 +5352,24 @@ static int synaptics_preferred_mode(struct psm_softc *sc) { int mode_byte; + /* Check if we are in relative mode */ + if (sc->hw.model != MOUSE_MODEL_SYNAPTICS) { + if (tap_enabled == 0) + /* + * Disable tap & drag gestures. We use a Mode Byte + * and set the DisGest bit (see §2.5 of Synaptics + * TouchPad Interfacing Guide). + */ + return (0x04); + else + /* + * Enable tap & drag gestures. We use a Mode Byte + * and clear the DisGest bit (see §2.5 of Synaptics + * TouchPad Interfacing Guide). + */ + return (0x00); + } + mode_byte = 0xc4; /* request wmode where available */ @@ -5382,10 +5388,10 @@ synaptics_set_mode(struct psm_softc *sc, /* * Enable advanced gestures mode if supported and we are not entering - * passthrough mode. + * passthrough or relative mode. */ if ((sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) && - !(mode_byte & (1 << 5))) { + sc->hw.model == MOUSE_MODEL_SYNAPTICS && !(mode_byte & (1 << 5))) { mouse_ext_command(sc->kbdc, 3); set_mouse_sampling_rate(sc->kbdc, 0xc8); } @@ -5698,6 +5704,9 @@ enable_synaptics(struct psm_softc *sc, e if (!synaptics_support) return (FALSE); + /* Set mouse type just now for synaptics_set_mode() */ + sc->hw.model = MOUSE_MODEL_SYNAPTICS; + synaptics_set_mode(sc, synaptics_preferred_mode(sc)); if (trackpoint_support && synhw.capPassthrough) { From owner-svn-src-head@freebsd.org Wed Nov 2 03:07:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4FACC29DE6; Wed, 2 Nov 2016 03:07:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 662081601; Wed, 2 Nov 2016 03:07:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2371Z9076827; Wed, 2 Nov 2016 03:07:01 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2371rN076826; Wed, 2 Nov 2016 03:07:01 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611020307.uA2371rN076826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 03:07:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308190 - head/sys/powerpc/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 03:07:03 -0000 Author: jhibbits Date: Wed Nov 2 03:07:01 2016 New Revision: 308190 URL: https://svnweb.freebsd.org/changeset/base/308190 Log: Add P1022 and compatible SVR IDs The eSDHC driver requires these IDs. Missed in r308188. Modified: head/sys/powerpc/include/spr.h Modified: head/sys/powerpc/include/spr.h ============================================================================== --- head/sys/powerpc/include/spr.h Wed Nov 2 01:27:20 2016 (r308189) +++ head/sys/powerpc/include/spr.h Wed Nov 2 03:07:01 2016 (r308190) @@ -698,8 +698,12 @@ #define SVR_MPC8572E 0x80e8 #define SVR_P1011 0x80e5 #define SVR_P1011E 0x80ed +#define SVR_P1013 0x80e7 +#define SVR_P1013E 0x80ef #define SVR_P1020 0x80e4 #define SVR_P1020E 0x80ec +#define SVR_P1022 0x80e6 +#define SVR_P1022E 0x80ee #define SVR_P2010 0x80e3 #define SVR_P2010E 0x80eb #define SVR_P2020 0x80e2 From owner-svn-src-head@freebsd.org Wed Nov 2 05:41:24 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7F3DC2A26B; Wed, 2 Nov 2016 05:41:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B54EF1C64; Wed, 2 Nov 2016 05:41:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA25fN8U035170; Wed, 2 Nov 2016 05:41:23 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA25fNg6035167; Wed, 2 Nov 2016 05:41:23 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611020541.uA25fNg6035167@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 2 Nov 2016 05:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308194 - in head/sys/dev/hyperv: include vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 05:41:25 -0000 Author: sephe Date: Wed Nov 2 05:41:23 2016 New Revision: 308194 URL: https://svnweb.freebsd.org/changeset/base/308194 Log: hyperv: GC unused functions. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8406 Modified: head/sys/dev/hyperv/include/hyperv.h head/sys/dev/hyperv/include/vmbus.h head/sys/dev/hyperv/vmbus/vmbus_chan.c Modified: head/sys/dev/hyperv/include/hyperv.h ============================================================================== --- head/sys/dev/hyperv/include/hyperv.h Wed Nov 2 05:13:27 2016 (r308193) +++ head/sys/dev/hyperv/include/hyperv.h Wed Nov 2 05:41:23 2016 (r308194) @@ -44,15 +44,4 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); -/** - * @brief Get physical address from virtual - */ -static inline unsigned long -hv_get_phys_addr(void *virt) -{ - unsigned long ret; - ret = (vtophys(virt) | ((vm_offset_t) virt & PAGE_MASK)); - return (ret); -} - #endif /* _HYPERV_H_ */ Modified: head/sys/dev/hyperv/include/vmbus.h ============================================================================== --- head/sys/dev/hyperv/include/vmbus.h Wed Nov 2 05:13:27 2016 (r308193) +++ head/sys/dev/hyperv/include/vmbus.h Wed Nov 2 05:41:23 2016 (r308194) @@ -146,8 +146,6 @@ int vmbus_chan_gpadl_disconnect(struct void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); void vmbus_chan_cpu_rr(struct vmbus_channel *chan); -struct vmbus_channel * - vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); struct vmbus_channel ** Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Nov 2 05:13:27 2016 (r308193) +++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Nov 2 05:41:23 2016 (r308194) @@ -1534,65 +1534,6 @@ vmbus_chan_destroy_all(struct vmbus_soft } } -/* - * The channel whose vcpu binding is closest to the currect vcpu will - * be selected. - * If no multi-channel, always select primary channel. - */ -struct vmbus_channel * -vmbus_chan_cpu2chan(struct vmbus_channel *prichan, int cpu) -{ - struct vmbus_channel *sel, *chan; - uint32_t vcpu, sel_dist; - - KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpuid %d", cpu)); - if (TAILQ_EMPTY(&prichan->ch_subchans)) - return prichan; - - vcpu = VMBUS_PCPU_GET(prichan->ch_vmbus, vcpuid, cpu); - -#define CHAN_VCPU_DIST(ch, vcpu) \ - (((ch)->ch_vcpuid > (vcpu)) ? \ - ((ch)->ch_vcpuid - (vcpu)) : ((vcpu) - (ch)->ch_vcpuid)) - -#define CHAN_SELECT(ch) \ -do { \ - sel = ch; \ - sel_dist = CHAN_VCPU_DIST(ch, vcpu); \ -} while (0) - - CHAN_SELECT(prichan); - - mtx_lock(&prichan->ch_subchan_lock); - TAILQ_FOREACH(chan, &prichan->ch_subchans, ch_sublink) { - uint32_t dist; - - KASSERT(chan->ch_stflags & VMBUS_CHAN_ST_OPENED, - ("chan%u is not opened", chan->ch_id)); - - if (chan->ch_vcpuid == vcpu) { - /* Exact match; done */ - CHAN_SELECT(chan); - break; - } - - dist = CHAN_VCPU_DIST(chan, vcpu); - if (sel_dist <= dist) { - /* Far or same distance; skip */ - continue; - } - - /* Select the closer channel. */ - CHAN_SELECT(chan); - } - mtx_unlock(&prichan->ch_subchan_lock); - -#undef CHAN_SELECT -#undef CHAN_VCPU_DIST - - return sel; -} - struct vmbus_channel ** vmbus_subchan_get(struct vmbus_channel *pri_chan, int subchan_cnt) { From owner-svn-src-head@freebsd.org Wed Nov 2 06:37:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AC2CC2B37A; Wed, 2 Nov 2016 06:37:37 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC6E916E0; Wed, 2 Nov 2016 06:37:36 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA26bZ7w058587; Wed, 2 Nov 2016 06:37:35 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA26bZRu058586; Wed, 2 Nov 2016 06:37:35 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201611020637.uA26bZRu058586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Wed, 2 Nov 2016 06:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308195 - head/sys/boot/efi/libefi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 06:37:37 -0000 Author: tsoome Date: Wed Nov 2 06:37:35 2016 New Revision: 308195 URL: https://svnweb.freebsd.org/changeset/base/308195 Log: efinet_dev_print should honor verbose option. lsdev should display detailed information about net devices only with -v switch. This will make EFI and BIOS version of the loader to have the same behavior. Reviewed by: bapt, imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D8415 Modified: head/sys/boot/efi/libefi/efinet.c Modified: head/sys/boot/efi/libefi/efinet.c ============================================================================== --- head/sys/boot/efi/libefi/efinet.c Wed Nov 2 05:41:23 2016 (r308194) +++ head/sys/boot/efi/libefi/efinet.c Wed Nov 2 06:37:35 2016 (r308195) @@ -357,10 +357,12 @@ efinet_dev_print(int verbose) for (unit = 0, h = efi_find_handle(&efinet_dev, 0); h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) { printf(" %s%d:", efinet_dev.dv_name, unit); - text = efi_devpath_name(efi_lookup_devpath(h)); - if (text != NULL) { - printf(" %S", text); - efi_free_devpath_name(text); + if (verbose) { + text = efi_devpath_name(efi_lookup_devpath(h)); + if (text != NULL) { + printf(" %S", text); + efi_free_devpath_name(text); + } } if (pager_output("\n")) break; From owner-svn-src-head@freebsd.org Wed Nov 2 06:49:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3514FC2B7D3; Wed, 2 Nov 2016 06:49:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C47CD1B09; Wed, 2 Nov 2016 06:49:26 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA26nPmL063042; Wed, 2 Nov 2016 06:49:25 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA26nP8G063041; Wed, 2 Nov 2016 06:49:25 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201611020649.uA26nP8G063041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Wed, 2 Nov 2016 06:49:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308197 - head/crypto/openssh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 06:49:27 -0000 Author: delphij Date: Wed Nov 2 06:49:25 2016 New Revision: 308197 URL: https://svnweb.freebsd.org/changeset/base/308197 Log: MFV r308196: Fix OpenSSH remote Denial of Service vulnerability. Security: CVE-2016-8858 Modified: head/crypto/openssh/kex.c Directory Properties: head/crypto/openssh/ (props changed) Modified: head/crypto/openssh/kex.c ============================================================================== --- head/crypto/openssh/kex.c Wed Nov 2 06:43:20 2016 (r308196) +++ head/crypto/openssh/kex.c Wed Nov 2 06:49:25 2016 (r308197) @@ -468,6 +468,7 @@ kex_input_kexinit(int type, u_int32_t se if (kex == NULL) return SSH_ERR_INVALID_ARGUMENT; + ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, NULL); ptr = sshpkt_ptr(ssh, &dlen); if ((r = sshbuf_put(kex->peer, ptr, dlen)) != 0) return r; From owner-svn-src-head@freebsd.org Wed Nov 2 07:18:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BE8AC2BE15; Wed, 2 Nov 2016 07:18:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCF221099; Wed, 2 Nov 2016 07:18:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA27ISqB074598; Wed, 2 Nov 2016 07:18:28 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA27IRVQ074593; Wed, 2 Nov 2016 07:18:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611020718.uA27IRVQ074593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 2 Nov 2016 07:18:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308201 - in head: contrib/hyperv/tools sys/dev/hyperv/utilities X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 07:18:29 -0000 Author: sephe Date: Wed Nov 2 07:18:27 2016 New Revision: 308201 URL: https://svnweb.freebsd.org/changeset/base/308201 Log: hyperv/kvp: Don't mix message status codes and function return values. While I'm here, move message status codes to hv_utilreg.h, since they will be used by the upcoming VSS stuffs. Submitted by: Hongjiang Zhang MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8391 Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c head/sys/dev/hyperv/utilities/hv_kvp.c head/sys/dev/hyperv/utilities/hv_kvp.h head/sys/dev/hyperv/utilities/hv_utilreg.h Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c ============================================================================== --- head/contrib/hyperv/tools/hv_kvp_daemon.c Wed Nov 2 07:09:31 2016 (r308200) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Wed Nov 2 07:18:27 2016 (r308201) @@ -52,9 +52,10 @@ #include #include #include +#include #include "hv_kvp.h" - +#include "hv_utilreg.h" typedef uint8_t __u8; typedef uint16_t __u16; typedef uint32_t __u32; @@ -684,18 +685,16 @@ kvp_get_ipconfig_info(char *if_name, str */ kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, (MAX_GATEWAY_SIZE * 2), INET_ADDRSTRLEN, 0); - /* * Retrieve the IPV6 address of default gateway. */ - snprintf(cmd, sizeof(cmd), "netstat -rn inet6 | grep %s | awk '/default/ {print $2 }", if_name); + snprintf(cmd, sizeof(cmd), "netstat -rn inet6 | grep %s | awk '/default/ {print $2 }'", if_name); /* * Execute the command to gather gateway IPV6 info. */ kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, (MAX_GATEWAY_SIZE * 2), INET6_ADDRSTRLEN, 1); - /* * we just invoke an external script to get the DNS info. * @@ -782,11 +781,11 @@ kvp_process_ip_address(void *addrp, } if ((length - *offset) < addr_length + 1) { - return (HV_KVP_E_FAIL); + return (EINVAL); } if (str == NULL) { strlcpy(buffer, "inet_ntop failed\n", length); - return (HV_KVP_E_FAIL); + return (errno); } if (*offset == 0) { strlcpy(buffer, tmp, length); @@ -832,7 +831,7 @@ kvp_get_ip_info(int family, char *if_nam if (getifaddrs(&ifap)) { strlcpy(buffer, "getifaddrs failed\n", buffer_length); - return (HV_KVP_E_FAIL); + return (errno); } curp = ifap; @@ -924,7 +923,6 @@ kvp_get_ip_info(int family, char *if_nam /* * Collect other ip configuration info. */ - kvp_get_ipconfig_info(if_name, ip_buffer); } @@ -954,7 +952,7 @@ kvp_write_file(FILE *f, const char *s1, ret = fprintf(f, "%s%s%s%s\n", s1, s2, "=", s3); if (ret < 0) { - return (HV_KVP_E_FAIL); + return (EIO); } return (0); @@ -979,7 +977,7 @@ kvp_set_ip_info(char *if_name, struct hv if (file == NULL) { KVP_LOG(LOG_ERR, "FreeBSD Failed to open config file\n"); - return (HV_KVP_E_FAIL); + return (errno); } /* @@ -988,7 +986,7 @@ kvp_set_ip_info(char *if_name, struct hv mac_addr = kvp_if_name_to_mac(if_name); if (mac_addr == NULL) { - error = HV_KVP_E_FAIL; + error = EINVAL; goto kvp_set_ip_info_error; } /* MAC Address */ @@ -1091,28 +1089,30 @@ kvp_op_getipinfo(struct hv_kvp_msg *op_m { struct hv_kvp_ipaddr_value *ip_val; char *if_name; + int error = 0; assert(op_msg != NULL); KVP_LOG(LOG_DEBUG, "In kvp_op_getipinfo.\n"); ip_val = &op_msg->body.kvp_ip_val; - op_msg->hdr.error = HV_KVP_S_OK; + op_msg->hdr.error = HV_S_OK; if_name = kvp_mac_to_if_name((char *)ip_val->adapter_id); if (if_name == NULL) { /* No interface found with the mac address. */ - op_msg->hdr.error = HV_KVP_E_FAIL; + op_msg->hdr.error = HV_E_FAIL; goto kvp_op_getipinfo_done; } - op_msg->hdr.error = kvp_get_ip_info(0, if_name, + error = kvp_get_ip_info(0, if_name, HV_KVP_OP_GET_IP_INFO, ip_val, (MAX_IP_ADDR_SIZE * 2)); - + if (error) + op_msg->hdr.error = HV_E_FAIL; free(if_name); kvp_op_getipinfo_done: - return(op_msg->hdr.error); + return (error); } @@ -1121,25 +1121,27 @@ kvp_op_setipinfo(struct hv_kvp_msg *op_m { struct hv_kvp_ipaddr_value *ip_val; char *if_name; + int error = 0; assert(op_msg != NULL); KVP_LOG(LOG_DEBUG, "In kvp_op_setipinfo.\n"); ip_val = &op_msg->body.kvp_ip_val; - op_msg->hdr.error = HV_KVP_S_OK; + op_msg->hdr.error = HV_S_OK; if_name = (char *)ip_val->adapter_id; if (if_name == NULL) { /* No adapter provided. */ - op_msg->hdr.error = HV_KVP_GUID_NOTFOUND; + op_msg->hdr.error = HV_GUID_NOTFOUND; goto kvp_op_setipinfo_done; } - op_msg->hdr.error = kvp_set_ip_info(if_name, ip_val); - + error = kvp_set_ip_info(if_name, ip_val); + if (error) + op_msg->hdr.error = HV_E_FAIL; kvp_op_setipinfo_done: - return(op_msg->hdr.error); + return (error); } @@ -1154,7 +1156,7 @@ kvp_op_setgetdel(struct hv_kvp_msg *op_m assert(op_hdlr != NULL); op_pool = op_msg->hdr.kvp_hdr.pool; - op_msg->hdr.error = HV_KVP_S_OK; + op_msg->hdr.error = HV_S_OK; switch(op_hdlr->kvp_op_key) { case HV_KVP_OP_SET: @@ -1198,8 +1200,7 @@ kvp_op_setgetdel(struct hv_kvp_msg *op_m } if (error != 0) - op_msg->hdr.error = HV_KVP_S_CONT; - + op_msg->hdr.error = HV_S_CONT; return(error); } @@ -1216,7 +1217,7 @@ kvp_op_enumerate(struct hv_kvp_msg *op_m op = op_msg->hdr.kvp_hdr.operation; op_pool = op_msg->hdr.kvp_hdr.pool; - op_msg->hdr.error = HV_KVP_S_OK; + op_msg->hdr.error = HV_S_OK; /* * If the pool is not HV_KVP_POOL_AUTO, read from the appropriate @@ -1229,7 +1230,7 @@ kvp_op_enumerate(struct hv_kvp_msg *op_m HV_KVP_EXCHANGE_MAX_KEY_SIZE, op_msg->body.kvp_enum_data.data.msg_value.value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) { - op_msg->hdr.error = HV_KVP_S_CONT; + op_msg->hdr.error = HV_S_CONT; error = -1; } goto kvp_op_enumerate_done; @@ -1298,12 +1299,14 @@ kvp_op_enumerate(struct hv_kvp_msg *op_m KVP_LOG(LOG_ERR, "Auto pool Index %d not found.\n", op_msg->body.kvp_enum_data.index); #endif - op_msg->hdr.error = HV_KVP_S_CONT; + op_msg->hdr.error = HV_S_CONT; error = -1; break; } kvp_op_enumerate_done: + if (error != 0) + op_msg->hdr.error = HV_S_CONT; return(error); } @@ -1496,10 +1499,13 @@ main(int argc, char *argv[]) */ error = kvp_op_hdlrs[op].kvp_op_exec(hv_msg, (void *)&kvp_op_hdlrs[op]); - if (error != 0 && hv_msg->hdr.error != HV_KVP_S_CONT) - KVP_LOG(LOG_WARNING, - "Operation failed OP = %d, error = 0x%x\n", - op, error); + if (error != 0) { + assert(hv_msg->hdr.error != HV_S_OK); + if (hv_msg->hdr.error != HV_S_CONT) + KVP_LOG(LOG_WARNING, + "Operation failed OP = %d, error = 0x%x\n", + op, error); + } } /* Modified: head/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.c Wed Nov 2 07:09:31 2016 (r308200) +++ head/sys/dev/hyperv/utilities/hv_kvp.c Wed Nov 2 07:18:27 2016 (r308201) @@ -72,8 +72,6 @@ __FBSDID("$FreeBSD$"); /* hv_kvp defines */ #define BUFFERSIZE sizeof(struct hv_kvp_msg) -#define KVP_SUCCESS 0 -#define KVP_ERROR 1 #define kvp_hdr hdr.kvp_hdr #define KVP_FWVER_MAJOR 3 @@ -480,7 +478,7 @@ hv_kvp_convert_usermsg_to_hostmsg(struct case HV_KVP_OP_SET_IP_INFO: case HV_KVP_OP_SET: case HV_KVP_OP_DELETE: - return (KVP_SUCCESS); + return (0); case HV_KVP_OP_ENUMERATE: host_exchg_data = &hmsg->body.kvp_enum_data.data; @@ -501,9 +499,9 @@ hv_kvp_convert_usermsg_to_hostmsg(struct host_exchg_data->value_type = HV_REG_SZ; if ((hkey_len < 0) || (hvalue_len < 0)) - return (HV_KVP_E_FAIL); + return (EINVAL); - return (KVP_SUCCESS); + return (0); case HV_KVP_OP_GET: host_exchg_data = &hmsg->body.kvp_get.data; @@ -519,12 +517,12 @@ hv_kvp_convert_usermsg_to_hostmsg(struct host_exchg_data->value_type = HV_REG_SZ; if ((hkey_len < 0) || (hvalue_len < 0)) - return (HV_KVP_E_FAIL); + return (EINVAL); - return (KVP_SUCCESS); + return (0); default: - return (HV_KVP_E_FAIL); + return (EINVAL); } } @@ -533,16 +531,13 @@ hv_kvp_convert_usermsg_to_hostmsg(struct * Send the response back to the host. */ static void -hv_kvp_respond_host(hv_kvp_sc *sc, int error) +hv_kvp_respond_host(hv_kvp_sc *sc, uint32_t error) { struct hv_vmbus_icmsg_hdr *hv_icmsg_hdrp; hv_icmsg_hdrp = (struct hv_vmbus_icmsg_hdr *) &sc->rcv_buf[sizeof(struct hv_vmbus_pipe_hdr)]; - if (error) - error = HV_KVP_E_FAIL; - hv_icmsg_hdrp->status = error; hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; @@ -612,8 +607,10 @@ hv_kvp_process_request(void *context, in error = vmbus_ic_negomsg(&sc->util_sc, kvp_buf, &recvlen, KVP_FWVER, KVP_MSGVER); /* XXX handle vmbus_ic_negomsg failure. */ - hv_kvp_respond_host(sc, error); - + if (!error) + hv_kvp_respond_host(sc, HV_S_OK); + else + hv_kvp_respond_host(sc, HV_E_FAIL); /* * It is ok to not acquire the mutex before setting * req_in_progress here because negotiation is the @@ -657,7 +654,7 @@ hv_kvp_process_request(void *context, in */ if (hv_kvp_req_in_progress(sc)) { hv_kvp_log_info("%s: request was still active after wait so failing\n", __func__); - hv_kvp_respond_host(sc, HV_KVP_E_FAIL); + hv_kvp_respond_host(sc, HV_E_FAIL); sc->req_in_progress = false; } @@ -737,9 +734,9 @@ hv_kvp_dev_daemon_read(struct cdev *dev, struct hv_kvp_msg *hv_kvp_dev_buf; hv_kvp_sc *sc = (hv_kvp_sc*)dev->si_drv1; - /* Check hv_kvp daemon registration status*/ + /* Read is not allowed util registering is done. */ if (!sc->register_done) - return (KVP_ERROR); + return (EPERM); sema_wait(&sc->dev_sema); @@ -789,7 +786,7 @@ hv_kvp_dev_daemon_write(struct cdev *dev } else { hv_kvp_log_info("%s, KVP Registration Failed\n", __func__); - return (KVP_ERROR); + return (EINVAL); } } else { @@ -799,10 +796,15 @@ hv_kvp_dev_daemon_write(struct cdev *dev struct hv_kvp_msg *hmsg = sc->host_kvp_msg; struct hv_kvp_msg *umsg = &sc->daemon_kvp_msg; - hv_kvp_convert_usermsg_to_hostmsg(umsg, hmsg); - hv_kvp_respond_host(sc, KVP_SUCCESS); + error = hv_kvp_convert_usermsg_to_hostmsg(umsg, hmsg); + hv_kvp_respond_host(sc, umsg->hdr.error); wakeup(sc); sc->req_in_progress = false; + if (umsg->hdr.error != HV_S_OK) + hv_kvp_log_info("%s, Error 0x%x from daemon\n", + __func__, umsg->hdr.error); + if (error) + hv_kvp_log_info("%s, Error from convert\n", __func__); } sc->daemon_busy = false; @@ -865,7 +867,7 @@ hv_kvp_attach(device_t dev) child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); SYSCTL_ADD_INT(ctx, child, OID_AUTO, "hv_kvp_log", - CTLFLAG_RW, &hv_kvp_log, 0, "Hyperv KVP service log level"); + CTLFLAG_RWTUN, &hv_kvp_log, 0, "Hyperv KVP service log level"); TASK_INIT(&sc->task, 0, hv_kvp_process_request, sc); Modified: head/sys/dev/hyperv/utilities/hv_kvp.h ============================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.h Wed Nov 2 07:09:31 2016 (r308200) +++ head/sys/dev/hyperv/utilities/hv_kvp.h Wed Nov 2 07:18:27 2016 (r308201) @@ -144,19 +144,6 @@ enum hv_kvp_exchg_pool { HV_KVP_POOL_COUNT /* Number of pools, must be last. */ }; - -/* - * Some Hyper-V status codes. - */ -#define HV_KVP_S_OK 0x00000000 -#define HV_KVP_E_FAIL 0x80004005 -#define HV_KVP_S_CONT 0x80070103 -#define HV_ERROR_NOT_SUPPORTED 0x80070032 -#define HV_ERROR_MACHINE_LOCKED 0x800704F7 -#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F -#define HV_INVALIDARG 0x80070057 -#define HV_KVP_GUID_NOTFOUND 0x80041002 - #define ADDR_FAMILY_NONE 0x00 #define ADDR_FAMILY_IPV4 0x01 #define ADDR_FAMILY_IPV6 0x02 Modified: head/sys/dev/hyperv/utilities/hv_utilreg.h ============================================================================== --- head/sys/dev/hyperv/utilities/hv_utilreg.h Wed Nov 2 07:09:31 2016 (r308200) +++ head/sys/dev/hyperv/utilities/hv_utilreg.h Wed Nov 2 07:18:27 2016 (r308201) @@ -29,10 +29,17 @@ #ifndef _HV_UTILREG_H_ #define _HV_UTILREG_H_ -#define HV_S_OK 0x00000000 -#define HV_E_FAIL 0x80004005 -#define HV_ERROR_NOT_SUPPORTED 0x80070032 -#define HV_ERROR_MACHINE_LOCKED 0x800704F7 +/* + * Some Hyper-V status codes. + */ +#define HV_S_OK 0x00000000 +#define HV_E_FAIL 0x80004005 +#define HV_S_CONT 0x80070103 +#define HV_ERROR_NOT_SUPPORTED 0x80070032 +#define HV_ERROR_MACHINE_LOCKED 0x800704F7 +#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F +#define HV_INVALIDARG 0x80070057 +#define HV_GUID_NOTFOUND 0x80041002 /* * Common defines for Hyper-V ICs From owner-svn-src-head@freebsd.org Wed Nov 2 07:24:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E69ADC2A063; Wed, 2 Nov 2016 07:24:15 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id A58CE1F14; Wed, 2 Nov 2016 07:24:15 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from [10.10.1.110] (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id C9FA7151E; Wed, 2 Nov 2016 07:24:12 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) From: "Jonathan Anderson" To: "Dimitry Andric" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Ed Maste" Subject: Re: svn commit: r308181 - in head: . share/mk Date: Wed, 02 Nov 2016 04:55:22 -0230 Message-ID: <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> In-Reply-To: <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> References: <201611012127.uA1LRg0B045900@repo.freebsd.org> <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=_MailMate_C088D1FA-BC25-4B93-9B58-A7469C1D18E8_="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Mailer: MailMate (1.9.5r5263) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 07:24:16 -0000 This is an OpenPGP/MIME signed message (RFC 3156 and 4880). --=_MailMate_C088D1FA-BC25-4B93-9B58-A7469C1D18E8_= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, On 1 Nov 2016, at 21:10, Dimitry Andric wrote: > Please note, I reverted r307823 (which changed the suffixes from .bco > and .llo to .bc and .ll) in r308003, since it caused a number of ports > failures. These ports were already using .ll as a suffix for C++ lex > scripts. The changes to bsd.suffixes-posix.mk (included by sys.mk) would have affe= cted anything compiled with bmake, and indeed, I'd imagine that adding a = =2Ec->.ll rule alongside .c->.o could cause problems with C++ lex rules. = In fact, part of brooks' original motivation for introducing .llo suffixe= s was to avoid name conflicts (although conflicts with program IR like we= 're introducing in this commit). The changes in this commit should only b= e picked up by things that explicit include bsd.{lib,prog}.mk, however, a= nd they also have slightly more esoteric names (e.g., progname.full.ll) t= hat are less likely to cause a conflict. Perhaps I ought to have done an = exp-run, but I suspect that this commit will cause much less / no fallout= =2E I don't suppose you have a list of the ports that failed after your r= 307823 change so that I could do spot checks? >> # prefer .s to a .c, add .po, remove stuff not used in the BSD librari= es >> # .pico used for PIC object files >> -.SUFFIXES: .out .o .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l = =2Eln >> +.SUFFIXES: .out .o .bc .ll .po .pico .S .asm .s .c .cc .cpp .cxx .C .= f .y .l .ln > > So here, please use .bco and .llo. The "o" in the suffix indicates that the file is analogous to an object f= ile, which is not really the case with the rules added here in r308181. I= 'd be happy to consider a different suffix if we get ports fallout, but I= 'd like to wait for evidence of such fallout before renaming these suffix= es away from upstream's usage. I think that we should stick with the upst= ream suffixes unless there's a good reason not to (such as collisions wit= h lex things as affected r307823). >> @@ -199,6 +199,18 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} >> ${RANLIB} ${RANLIBFLAGS} ${.TARGET} >> .endif >> >> +.if defined(LLVM_LINK) >> +BCOBJS=3D ${OBJS:.o=3D.bco} ${STATICOBJS:.o=3D.bco} >> +LLOBJS=3D ${OBJS:.o=3D.llo} ${STATICOBJS:.o=3D.llo} > > But apparently you already used those suffixes here. Yup, because of the "object file" analogy. >> -.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm >> +.SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S .as= m > > But not here, these should also be changed. Sorry for any confusion. The .bco and .llo suffixes should already be included because of bsd.suff= ixes-posix.mk (included from sys.mk). This SUFFIXES change, on the other = hand, is to add the .ll and .bc suffixes for the final build products (IR= "binaries" and "libraries"). I hope this clears up any confusion, Jon -- Jonathan Anderson jonathan@FreeBSD.org --=_MailMate_C088D1FA-BC25-4B93-9B58-A7469C1D18E8_= Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJYGZToAAoJEDusuBaTfFXcdPoQAJEB0SMMoIrbRvwYxrXg8yUn HO2NfSDOR7mJVz4uPlpUScwfDbBgpqDo1MFxoewY8gP/lBpWBAfjVq5ngcLm2Z/j 4NednX3D2hXzk/E5VIxEFNK4uRC73ZCvzxs3tFLRCPNa1n9frQHtmCy4Af7tqQFU D39jFZ3AHeqRkFI3u4mOAXRStWgQTr8NtbhoW3DsDkrKQvI4AL7vgNIKAXoyH2sG RFvY9zL0ympT+O/vYjgB0RIBLWDP4WsmEPuAVrs8GnjEFQYJVpusDjfrjQefXtuf m82O5n/2Q17cW6HnTuQdgOr6ZO5tp409+kgLsx/+P+0R1KcdgXgLp7zKnFKCZsXu 9Z9ROtrrCyTyQH9VWEPLDCpauvUitfWIaGRG03xepDzgXMrgfz/XsH22gZaH7oFH Ah0CeYyaN/cWlXznnB8CbsSEpNJmOSnoZwnjLApeIPZZ8h/5wJnnjRF6A2JO9/Xw 7+ddeMruDnku+SOdPs6W4I0RYwwEomr63oS5wAE14VR+WLGffoDjm3U22Pit8r2W t1WiK2aqCCLYVLpmb/hv1DEN7aPVR1SAePJM6pANAeR/mASdNqpWBHtSwlK9PHOt 7GWfghSBpO/OzQPxMGxKxNQApOw2sc6pJA+a+2rvx17MdArfdtBkbiwKaBTs1V+W 3VianVDHgT+uBB3Bbz6G =GQM9 -----END PGP SIGNATURE----- --=_MailMate_C088D1FA-BC25-4B93-9B58-A7469C1D18E8_=-- From owner-svn-src-head@freebsd.org Wed Nov 2 07:53:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9EE8C2AAB5; Wed, 2 Nov 2016 07:53:12 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8829B1F4E; Wed, 2 Nov 2016 07:53:12 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:7b8:3a7::d184:fcf6:484f:1394] (unknown [IPv6:2001:7b8:3a7:0:d184:fcf6:484f:1394]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id D766A12C5C; Wed, 2 Nov 2016 08:53:08 +0100 (CET) Content-Type: multipart/signed; boundary="Apple-Mail=_5010B624-4795-4995-8532-CD3F6C39A9D9"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r308181 - in head: . share/mk From: Dimitry Andric In-Reply-To: <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> Date: Wed, 2 Nov 2016 08:53:05 +0100 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Ed Maste , Jonathan Anderson Message-Id: <459BD98A-4788-497E-B2D5-5EC20C5B9EE8@FreeBSD.org> References: <201611012127.uA1LRg0B045900@repo.freebsd.org> <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> To: Antoine Brodin X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 07:53:13 -0000 --Apple-Mail=_5010B624-4795-4995-8532-CD3F6C39A9D9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 02 Nov 2016, at 08:25, Jonathan Anderson = wrote: >=20 > On 1 Nov 2016, at 21:10, Dimitry Andric wrote: >=20 >> Please note, I reverted r307823 (which changed the suffixes from .bco >> and .llo to .bc and .ll) in r308003, since it caused a number of = ports >> failures. These ports were already using .ll as a suffix for C++ lex >> scripts. >=20 > The changes to bsd.suffixes-posix.mk (included by sys.mk) would have = affected anything compiled with bmake, and indeed, I'd imagine that = adding a .c->.ll rule alongside .c->.o could cause problems with C++ lex = rules. In fact, part of brooks' original motivation for introducing .llo = suffixes was to avoid name conflicts (although conflicts with program IR = like we're introducing in this commit). The changes in this commit = should only be picked up by things that explicit include = bsd.{lib,prog}.mk, however, and they also have slightly more esoteric = names (e.g., progname.full.ll) that are less likely to cause a conflict. = Perhaps I ought to have done an exp-run, but I suspect that this commit = will cause much less / no fallout. I don't suppose you have a list of = the ports that failed after your r307823 change so that I could do spot = checks? Hi Antoine, you pointed me at some of these port failures due to the .ll change, do you still have a list of them? -Dimitry --Apple-Mail=_5010B624-4795-4995-8532-CD3F6C39A9D9 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlgZm2UACgkQsF6jCi4glqPF/wCghI2Bzv/tDpoLiWG6MUOss4/t qFQAn0tj6GxNxmdXvMVwezZJQBZdfKTO =drqb -----END PGP SIGNATURE----- --Apple-Mail=_5010B624-4795-4995-8532-CD3F6C39A9D9-- From owner-svn-src-head@freebsd.org Wed Nov 2 08:12:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31354C2A620; Wed, 2 Nov 2016 08:12:39 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E861E13CB; Wed, 2 Nov 2016 08:12:38 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA28CbkI097675; Wed, 2 Nov 2016 08:12:37 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA28Cbpj097674; Wed, 2 Nov 2016 08:12:37 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201611020812.uA28Cbpj097674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Wed, 2 Nov 2016 08:12:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308206 - head/usr.sbin/autofs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 08:12:39 -0000 Author: trasz Date: Wed Nov 2 08:12:37 2016 New Revision: 308206 URL: https://svnweb.freebsd.org/changeset/base/308206 Log: Make autounmountd(8) not die when traced with "truss -p". MFC after: 1 month Modified: head/usr.sbin/autofs/autounmountd.c Modified: head/usr.sbin/autofs/autounmountd.c ============================================================================== --- head/usr.sbin/autofs/autounmountd.c Wed Nov 2 07:24:34 2016 (r308205) +++ head/usr.sbin/autofs/autounmountd.c Wed Nov 2 08:12:37 2016 (r308206) @@ -244,8 +244,11 @@ do_wait(int kq, double sleep_time) log_debugx("waiting for filesystem event"); nevents = kevent(kq, NULL, 0, &unused, 1, NULL); } - if (nevents < 0) + if (nevents < 0) { + if (errno == EINTR) + return; log_err(1, "kevent"); + } if (nevents == 0) { log_debugx("timeout reached"); From owner-svn-src-head@freebsd.org Wed Nov 2 09:11:58 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76B7BC2B745; Wed, 2 Nov 2016 09:11:58 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-vk0-x231.google.com (mail-vk0-x231.google.com [IPv6:2607:f8b0:400c:c05::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E607A1A3E; Wed, 2 Nov 2016 09:11:57 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: by mail-vk0-x231.google.com with SMTP id x186so7552806vkd.1; Wed, 02 Nov 2016 02:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=9ZpUA+2x1qb+E+OeYZzlhVyL1ev5m/uv3reKsbLvzW8=; b=nNDEV2TOFFxQsSY1wsSa1wg2/crAbpKZW3mvQNyvt4jlGr3PK+pTY8JeD33/cZOjnY 1RQLyC4WAYjr1zfzRmBcRcY5ydLYT7IBSAPFj3LnTmtDIlwS1D/vPWLSnEOvr007IiBY gb1XNJOJA9nACKXn/uPGaAZKOpXDyjakdQaDNNG6Vk2De8qG8sl/9jr4kj6EO+g89c6P exXVYpp8NqUIYmz/W3FShz4rA56WYjy7dKQjOAZr0HkwrjoFfUXDbvJT8rUwJP4MN0DX plQzYCmigY5amrYr8PGhgixMFGCHVOpq3reY7GNj9YtEkcDmM1Nmatx2ZV4pbJ5gAdoq aYmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=9ZpUA+2x1qb+E+OeYZzlhVyL1ev5m/uv3reKsbLvzW8=; b=NHSjYzNdsnMLbbAwqcykoqoPbQWjTXQX7rThGcs3hsIAOKqOMwDn4NEx+d4QHEsueh kf6iPyj2niWeWe3fhNKvDSIQYF0CDmEsZdPf8FYsOX4S9NKbp3KY436V9EiZuDcEFVtk KgyOtifIzxGCtz3AEq90yVPpkWCPOSVO2dPsOotwwtCSMRQD+2Vt6ZuCgegWsm7jqfVG Ymwsjaqdz6E9U+mR/lhszI3E278HZDfpd1t8LBfqAL1xxtgXXOA5rrtTEBk+Yh9QWHug rkTso6RTcRWYX5GmRvT12RYLG33w38YnqfBOFuaKoXtsHo7rOW/h5xdsyjF0r+g9IZoF jacQ== X-Gm-Message-State: ABUngvfoIpSKnYc3EXKJRlzCayd6qG7hGkWj44FADEkwB5rp6J8cikWHolkvVIRbywKcQLr2fOD5YY0/pkGRIA== X-Received: by 10.31.161.65 with SMTP id k62mr1758352vke.12.1478077916768; Wed, 02 Nov 2016 02:11:56 -0700 (PDT) MIME-Version: 1.0 Sender: antoine.brodin.freebsd@gmail.com Received: by 10.159.40.103 with HTTP; Wed, 2 Nov 2016 02:11:56 -0700 (PDT) In-Reply-To: <459BD98A-4788-497E-B2D5-5EC20C5B9EE8@FreeBSD.org> References: <201611012127.uA1LRg0B045900@repo.freebsd.org> <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> <459BD98A-4788-497E-B2D5-5EC20C5B9EE8@FreeBSD.org> From: Antoine Brodin Date: Wed, 2 Nov 2016 09:11:56 +0000 X-Google-Sender-Auth: xobuI8B6zdgKumx3jtcaI6IlHOo Message-ID: Subject: Re: svn commit: r308181 - in head: . share/mk To: Dimitry Andric Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Ed Maste , Jonathan Anderson Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 09:11:58 -0000 On Wed, Nov 2, 2016 at 7:53 AM, Dimitry Andric wrote: > On 02 Nov 2016, at 08:25, Jonathan Anderson wrote: >> >> On 1 Nov 2016, at 21:10, Dimitry Andric wrote: >> >>> Please note, I reverted r307823 (which changed the suffixes from .bco >>> and .llo to .bc and .ll) in r308003, since it caused a number of ports >>> failures. These ports were already using .ll as a suffix for C++ lex >>> scripts. >> >> The changes to bsd.suffixes-posix.mk (included by sys.mk) would have aff= ected anything compiled with bmake, and indeed, I'd imagine that adding a .= c->.ll rule alongside .c->.o could cause problems with C++ lex rules. In fa= ct, part of brooks' original motivation for introducing .llo suffixes was t= o avoid name conflicts (although conflicts with program IR like we're intro= ducing in this commit). The changes in this commit should only be picked up= by things that explicit include bsd.{lib,prog}.mk, however, and they also = have slightly more esoteric names (e.g., progname.full.ll) that are less li= kely to cause a conflict. Perhaps I ought to have done an exp-run, but I su= spect that this commit will cause much less / no fallout. I don't suppose y= ou have a list of the ports that failed after your r307823 change so that I= could do spot checks? > > Hi Antoine, you pointed me at some of these port failures due to the .ll > change, do you still have a list of them? The failures were: http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/super-smack-1.3_2.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/dprog-0.3.1_2.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/ebnf2yacc-0.1.1.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/gnuchess-6.2.3.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/bugle-0.0.20100508_2.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/hfst-3.8.2.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/grap-1.45.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/g-cows-1.12.log http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_s307= 951/logs/worker-3.8.4.log Antoine From owner-svn-src-head@freebsd.org Wed Nov 2 09:43:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AAD4C2A005; Wed, 2 Nov 2016 09:43:21 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE7161CF8; Wed, 2 Nov 2016 09:43:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA29hJdf033035; Wed, 2 Nov 2016 09:43:19 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA29hJda033034; Wed, 2 Nov 2016 09:43:19 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201611020943.uA29hJda033034@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Wed, 2 Nov 2016 09:43:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308209 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 09:43:21 -0000 Author: trasz Date: Wed Nov 2 09:43:19 2016 New Revision: 308209 URL: https://svnweb.freebsd.org/changeset/base/308209 Log: Fix getfsstat(2) with MNT_WAIT to not skip filesystems that are in the process of being unmounted. Previously it would skip them, even if the unmount eventually failed eg due to the filesystem being busy. This behaviour broke autounmountd(8) - if you tried to manually unmount a mounted filesystem, using 'automount -u', and the autounmountd attempted to refresh the filesystem list in that very moment, it would conclude that the filesystem got unmounted and not try to unmount it afterwards. Reviewed by: kib@ Tested by: pho@ MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8030 Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Wed Nov 2 08:46:04 2016 (r308208) +++ head/sys/kern/vfs_syscalls.c Wed Nov 2 09:43:19 2016 (r308209) @@ -446,16 +446,19 @@ kern_getfsstat(struct thread *td, struct size_t *countp, enum uio_seg bufseg, int flags) { struct mount *mp, *nmp; - struct statfs *sfsp, *sp, sb; + struct statfs *sfsp, *sp, sb, *tofree; size_t count, maxcount; int error; +restart: maxcount = bufsize / sizeof(struct statfs); - if (bufsize == 0) + if (bufsize == 0) { sfsp = NULL; - else if (bufseg == UIO_USERSPACE) + tofree = NULL; + } else if (bufseg == UIO_USERSPACE) { sfsp = *buf; - else /* if (bufseg == UIO_SYSSPACE) */ { + tofree = NULL; + } else /* if (bufseg == UIO_SYSSPACE) */ { count = 0; mtx_lock(&mountlist_mtx); TAILQ_FOREACH(mp, &mountlist, mnt_list) { @@ -464,8 +467,8 @@ kern_getfsstat(struct thread *td, struct mtx_unlock(&mountlist_mtx); if (maxcount > count) maxcount = count; - sfsp = *buf = malloc(maxcount * sizeof(struct statfs), M_TEMP, - M_WAITOK); + tofree = sfsp = *buf = malloc(maxcount * sizeof(struct statfs), + M_TEMP, M_WAITOK); } count = 0; mtx_lock(&mountlist_mtx); @@ -480,9 +483,24 @@ kern_getfsstat(struct thread *td, struct continue; } #endif - if (vfs_busy(mp, MBF_NOWAIT | MBF_MNTLSTLOCK)) { - nmp = TAILQ_NEXT(mp, mnt_list); - continue; + if (flags == MNT_WAIT) { + if (vfs_busy(mp, MBF_MNTLSTLOCK) != 0) { + /* + * If vfs_busy() failed, and MBF_NOWAIT + * wasn't passed, then the mp is gone. + * Furthermore, because of MBF_MNTLSTLOCK, + * the mountlist_mtx was dropped. We have + * no other choice than to start over. + */ + mtx_unlock(&mountlist_mtx); + free(tofree, M_TEMP); + goto restart; + } + } else { + if (vfs_busy(mp, MBF_NOWAIT | MBF_MNTLSTLOCK) != 0) { + nmp = TAILQ_NEXT(mp, mnt_list); + continue; + } } if (sfsp && count < maxcount) { sp = &mp->mnt_stat; From owner-svn-src-head@freebsd.org Wed Nov 2 12:02:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E1E5C2BD5C; Wed, 2 Nov 2016 12:02:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8077111B; Wed, 2 Nov 2016 12:02:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2C2WR6087453; Wed, 2 Nov 2016 12:02:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2C2WHu087452; Wed, 2 Nov 2016 12:02:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611021202.uA2C2WHu087452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 2 Nov 2016 12:02:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308210 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 12:02:33 -0000 Author: kib Date: Wed Nov 2 12:02:31 2016 New Revision: 308210 URL: https://svnweb.freebsd.org/changeset/base/308210 Log: Style fixes. Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/vfs_lookup.c Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Wed Nov 2 09:43:19 2016 (r308209) +++ head/sys/kern/vfs_lookup.c Wed Nov 2 12:02:31 2016 (r308210) @@ -73,13 +73,10 @@ SDT_PROBE_DEFINE3(vfs, namei, lookup, en "unsigned long"); SDT_PROBE_DEFINE2(vfs, namei, lookup, return, "int", "struct vnode *"); -/* - * Allocation zone for namei - */ +/* Allocation zone for namei. */ uma_zone_t namei_zone; -/* - * Placeholder vnode for mp traversal - */ + +/* Placeholder vnode for mp traversal. */ static struct vnode *vp_crossmp; static void @@ -97,11 +94,12 @@ SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND static int lookup_shared = 1; SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, - "Enables/Disables shared locks for path name translation"); + "enables shared locks for path name translation"); static void namei_cleanup_cnp(struct componentname *cnp) { + uma_zfree(namei_zone, cnp->cn_pnbuf); #ifdef DIAGNOSTIC cnp->cn_pnbuf = NULL; @@ -158,12 +156,16 @@ namei(struct nameidata *ndp) char *cp; /* pointer into pathname argument */ struct vnode *dp; /* the directory we are searching */ struct iovec aiov; /* uio for reading symbolic links */ + struct componentname *cnp; + struct thread *td; + struct proc *p; + cap_rights_t rights; struct uio auio; int error, linklen, startdir_used; - struct componentname *cnp = &ndp->ni_cnd; - struct thread *td = cnp->cn_thread; - struct proc *p = td->td_proc; + cnp = &ndp->ni_cnd; + td = cnp->cn_thread; + p = td->td_proc; ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_ucred; KASSERT(cnp->cn_cred && p, ("namei: bad cred/proc")); KASSERT((cnp->cn_nameiop & (~OPMASK)) == 0, @@ -258,8 +260,6 @@ namei(struct nameidata *ndp) dp = fdp->fd_cdir; VREF(dp); } else { - cap_rights_t rights; - rights = ndp->ni_rightsneeded; cap_rights_set(&rights, CAP_LOOKUP); From owner-svn-src-head@freebsd.org Wed Nov 2 12:10:41 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 289D3C29114; Wed, 2 Nov 2016 12:10:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C44B11376; Wed, 2 Nov 2016 12:10:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2CAdGS087883; Wed, 2 Nov 2016 12:10:39 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2CAd82087882; Wed, 2 Nov 2016 12:10:39 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611021210.uA2CAd82087882@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 2 Nov 2016 12:10:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308211 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 12:10:41 -0000 Author: kib Date: Wed Nov 2 12:10:39 2016 New Revision: 308211 URL: https://svnweb.freebsd.org/changeset/base/308211 Log: Remove tautological casts. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/vfs_lookup.c Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Wed Nov 2 12:02:31 2016 (r308210) +++ head/sys/kern/vfs_lookup.c Wed Nov 2 12:10:39 2016 (r308211) @@ -188,11 +188,11 @@ namei(struct nameidata *ndp) if ((cnp->cn_flags & HASBUF) == 0) cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); if (ndp->ni_segflg == UIO_SYSSPACE) - error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, - MAXPATHLEN, (size_t *)&ndp->ni_pathlen); + error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, + &ndp->ni_pathlen); else - error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, - MAXPATHLEN, (size_t *)&ndp->ni_pathlen); + error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, + &ndp->ni_pathlen); /* * Don't allow empty pathnames. From owner-svn-src-head@freebsd.org Wed Nov 2 12:43:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9803C29FBC; Wed, 2 Nov 2016 12:43:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6056F1508; Wed, 2 Nov 2016 12:43:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2ChG9V003299; Wed, 2 Nov 2016 12:43:16 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2ChGIg003295; Wed, 2 Nov 2016 12:43:16 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611021243.uA2ChGIg003295@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 2 Nov 2016 12:43:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308212 - in head/sys: fs/nfsserver kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 12:43:18 -0000 Author: kib Date: Wed Nov 2 12:43:15 2016 New Revision: 308212 URL: https://svnweb.freebsd.org/changeset/base/308212 Log: Allow some dotdot lookups in capability mode. If dotdot lookup does not escape from the file descriptor passed as the lookup root, we can allow the component traversal. Track the directories traversed, and check the result of dotdot lookup against the recorded list of the directory vnodes. Dotdot lookups are enabled by sysctl vfs.lookup_cap_dotdot, currently disabled by default until more verification of the approach is done. Disallow non-local filesystems for dotdot, since remote server might conspire with the local process to allow it to escape the namespace. This might be too cautious, provide the knob vfs.lookup_cap_dotdot_nonlocal to override as well. Idea by: rwatson Discussed with: emaste, jonathan, rwatson Reviewed by: mjg (previous version) Tested by: pho (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 week Differential revision: https://reviews.freebsd.org/D8110 Modified: head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/kern/vfs_lookup.c head/sys/kern/vfs_syscalls.c head/sys/sys/namei.h Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Wed Nov 2 12:10:39 2016 (r308211) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Wed Nov 2 12:43:15 2016 (r308212) @@ -350,7 +350,7 @@ nfsvno_namei(struct nfsrv_descript *nd, *retdirp = NULL; cnp->cn_nameptr = cnp->cn_pnbuf; - ndp->ni_strictrelative = 0; + ndp->ni_lcf = 0; /* * Extract and set starting directory. */ Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Wed Nov 2 12:10:39 2016 (r308211) +++ head/sys/kern/vfs_lookup.c Wed Nov 2 12:43:15 2016 (r308212) @@ -79,12 +79,22 @@ uma_zone_t namei_zone; /* Placeholder vnode for mp traversal. */ static struct vnode *vp_crossmp; +struct nameicap_tracker { + struct vnode *dp; + TAILQ_ENTRY(nameicap_tracker) nm_link; +}; + +/* Zone for cap mode tracker elements used for dotdot capability checks. */ +static uma_zone_t nt_zone; + static void nameiinit(void *dummy __unused) { namei_zone = uma_zcreate("NAMEI", MAXPATHLEN, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); + nt_zone = uma_zcreate("rentr", sizeof(struct nameicap_tracker), + NULL, NULL, NULL, NULL, sizeof(void *), 0); getnewvnode("crossmp", NULL, &dead_vnodeops, &vp_crossmp); vn_lock(vp_crossmp, LK_EXCLUSIVE); VN_LOCK_ASHARE(vp_crossmp); @@ -96,6 +106,76 @@ static int lookup_shared = 1; SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, "enables shared locks for path name translation"); +/* + * Intent is that lookup_cap_dotdot becomes unconditionally enabled, + * but it defaults to the disabled state until verification efforts + * are complete. + */ +static int lookup_cap_dotdot = 0; +SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot, CTLFLAG_RWTUN, + &lookup_cap_dotdot, 0, + "enables \"..\" components in path lookup in capability mode"); +static int lookup_cap_dotdot_nonlocal = 0; +SYSCTL_INT(_vfs, OID_AUTO, lookup_cap_dotdot_nonlocal, CTLFLAG_RWTUN, + &lookup_cap_dotdot_nonlocal, 0, + "enables \"..\" components in path lookup in capability mode " + "on non-local mount"); + +static void +nameicap_tracker_add(struct nameidata *ndp, struct vnode *dp) +{ + struct nameicap_tracker *nt; + + if ((ndp->ni_lcf & NI_LCF_CAP_DOTDOT) == 0 || dp->v_type != VDIR) + return; + nt = uma_zalloc(nt_zone, M_WAITOK); + vhold(dp); + nt->dp = dp; + TAILQ_INSERT_TAIL(&ndp->ni_cap_tracker, nt, nm_link); +} + +static void +nameicap_cleanup(struct nameidata *ndp) +{ + struct nameicap_tracker *nt, *nt1; + + KASSERT(TAILQ_EMPTY(&ndp->ni_cap_tracker) || + (ndp->ni_lcf & NI_LCF_CAP_DOTDOT) != 0, ("not strictrelative")); + TAILQ_FOREACH_SAFE(nt, &ndp->ni_cap_tracker, nm_link, nt1) { + TAILQ_REMOVE(&ndp->ni_cap_tracker, nt, nm_link); + vdrop(nt->dp); + uma_zfree(nt_zone, nt); + } +} + +/* + * For dotdot lookups in capability mode, only allow the component + * lookup to succeed if the resulting directory was already traversed + * during the operation. Also fail dotdot lookups for non-local + * filesystems, where external agents might assist local lookups to + * escape the compartment. + */ +static int +nameicap_check_dotdot(struct nameidata *ndp, struct vnode *dp) +{ + struct nameicap_tracker *nt; + struct mount *mp; + + if ((ndp->ni_lcf & NI_LCF_CAP_DOTDOT) == 0 || dp == NULL || + dp->v_type != VDIR) + return (0); + mp = dp->v_mount; + if (lookup_cap_dotdot_nonlocal == 0 && mp != NULL && + (mp->mnt_flag & MNT_LOCAL) == 0) + return (ENOTCAPABLE); + TAILQ_FOREACH_REVERSE(nt, &ndp->ni_cap_tracker, nameicap_tracker_head, + nm_link) { + if (dp == nt->dp) + return (0); + } + return (ENOTCAPABLE); +} + static void namei_cleanup_cnp(struct componentname *cnp) { @@ -113,7 +193,7 @@ namei_handle_root(struct nameidata *ndp, struct componentname *cnp; cnp = &ndp->ni_cnd; - if (ndp->ni_strictrelative != 0) { + if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0) { #ifdef KTRACE if (KTRPOINT(curthread, KTR_CAPFAIL)) ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); @@ -177,6 +257,8 @@ namei(struct nameidata *ndp) if (!lookup_shared) cnp->cn_flags &= ~LOCKSHARED; fdp = p->p_fd; + TAILQ_INIT(&ndp->ni_cap_tracker); + ndp->ni_lcf = 0; /* We will set this ourselves if we need it. */ cnp->cn_flags &= ~TRAILINGSLASH; @@ -202,13 +284,21 @@ namei(struct nameidata *ndp) #ifdef CAPABILITY_MODE /* - * In capability mode, lookups must be "strictly relative" (i.e. - * not an absolute path, and not containing '..' components) to - * a real file descriptor, not the pseudo-descriptor AT_FDCWD. + * In capability mode, lookups must be restricted to happen in + * the subtree with the root specified by the file descriptor: + * - The root must be real file descriptor, not the pseudo-descriptor + * AT_FDCWD. + * - The passed path must be relative and not absolute. + * - If lookup_cap_dotdot is disabled, path must not contain the + * '..' components. + * - If lookup_cap_dotdot is enabled, we verify that all '..' + * components lookups result in the directories which were + * previously walked by us, which prevents an escape from + * the relative root. */ if (error == 0 && IN_CAPABILITY_MODE(td) && (cnp->cn_flags & NOCAPCHECK) == 0) { - ndp->ni_strictrelative = 1; + ndp->ni_lcf |= NI_LCF_STRICTRELATIVE; if (ndp->ni_dirfd == AT_FDCWD) { #ifdef KTRACE if (KTRPOINT(td, KTR_CAPFAIL)) @@ -282,7 +372,7 @@ namei(struct nameidata *ndp) &rights) || ndp->ni_filecaps.fc_fcntls != CAP_FCNTL_ALL || ndp->ni_filecaps.fc_nioctls != -1) { - ndp->ni_strictrelative = 1; + ndp->ni_lcf |= NI_LCF_STRICTRELATIVE; } #endif } @@ -297,6 +387,9 @@ namei(struct nameidata *ndp) vrele(dp); goto out; } + if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 && + lookup_cap_dotdot != 0) + ndp->ni_lcf |= NI_LCF_CAP_DOTDOT; SDT_PROBE3(vfs, namei, lookup, entry, dp, cnp->cn_pnbuf, cnp->cn_flags); for (;;) { @@ -313,7 +406,7 @@ namei(struct nameidata *ndp) namei_cleanup_cnp(cnp); } else cnp->cn_flags |= HASBUF; - + nameicap_cleanup(ndp); SDT_PROBE2(vfs, namei, lookup, return, 0, ndp->ni_vp); return (0); } @@ -387,6 +480,7 @@ namei(struct nameidata *ndp) out: vrele(ndp->ni_rootdir); namei_cleanup_cnp(cnp); + nameicap_cleanup(ndp); SDT_PROBE2(vfs, namei, lookup, return, error, NULL); return (error); } @@ -583,6 +677,8 @@ dirloop: goto bad; } + nameicap_tracker_add(ndp, dp); + /* * Check for degenerate name (e.g. / or "") * which is a way of talking about a directory, @@ -618,9 +714,8 @@ dirloop: /* * Handle "..": five special cases. - * 0. If doing a capability lookup, return ENOTCAPABLE (this is a - * fairly conservative design choice, but it's the only one that we - * are satisfied guarantees the property we're looking for). + * 0. If doing a capability lookup and lookup_cap_dotdot is + * disabled, return ENOTCAPABLE. * 1. Return an error if this is the last component of * the name and the operation is DELETE or RENAME. * 2. If at root directory (e.g. after chroot) @@ -632,9 +727,15 @@ dirloop: * .. in the other filesystem. * 4. If the vnode is the top directory of * the jail or chroot, don't let them out. + * 5. If doing a capability lookup and lookup_cap_dotdot is + * enabled, return ENOTCAPABLE if the lookup would escape + * from the initial file descriptor directory. Checks are + * done by ensuring that namei() already traversed the + * result of dotdot lookup. */ if (cnp->cn_flags & ISDOTDOT) { - if (ndp->ni_strictrelative != 0) { + if ((ndp->ni_lcf & (NI_LCF_STRICTRELATIVE | NI_LCF_CAP_DOTDOT)) + == NI_LCF_STRICTRELATIVE) { #ifdef KTRACE if (KTRPOINT(curthread, KTR_CAPFAIL)) ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); @@ -676,6 +777,14 @@ dirloop: vn_lock(dp, compute_cn_lkflags(dp->v_mount, cnp->cn_lkflags | LK_RETRY, ISDOTDOT)); + error = nameicap_check_dotdot(ndp, dp); + if (error != 0) { +#ifdef KTRACE + if (KTRPOINT(curthread, KTR_CAPFAIL)) + ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); +#endif + goto bad; + } } } @@ -735,6 +844,7 @@ unionlookup: vn_lock(dp, compute_cn_lkflags(dp->v_mount, cnp->cn_lkflags | LK_RETRY, cnp->cn_flags)); + nameicap_tracker_add(ndp, dp); goto unionlookup; } @@ -855,6 +965,16 @@ nextname: vrele(ndp->ni_dvp); goto dirloop; } + if (cnp->cn_flags & ISDOTDOT) { + error = nameicap_check_dotdot(ndp, ndp->ni_vp); + if (error != 0) { +#ifdef KTRACE + if (KTRPOINT(curthread, KTR_CAPFAIL)) + ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); +#endif + goto bad2; + } + } if (*ndp->ni_next == '/') { cnp->cn_nameptr = ndp->ni_next; while (*cnp->cn_nameptr == '/') { @@ -1081,7 +1201,6 @@ NDINIT_ALL(struct nameidata *ndp, u_long ndp->ni_dirp = namep; ndp->ni_dirfd = dirfd; ndp->ni_startdir = startdir; - ndp->ni_strictrelative = 0; if (rightsp != NULL) ndp->ni_rightsneeded = *rightsp; else Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Wed Nov 2 12:10:39 2016 (r308211) +++ head/sys/kern/vfs_syscalls.c Wed Nov 2 12:43:15 2016 (r308212) @@ -1030,7 +1030,7 @@ kern_openat(struct thread *td, int fd, c * understand exactly what would happen, and we don't think * that it ever should. */ - if (nd.ni_strictrelative == 0 && + if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) == 0 && (error == ENODEV || error == ENXIO) && td->td_dupfd >= 0) { error = dupfdopen(td, fdp, td->td_dupfd, flags, error, @@ -1076,7 +1076,7 @@ success: struct filecaps *fcaps; #ifdef CAPABILITIES - if (nd.ni_strictrelative == 1) + if ((nd.ni_lcf & NI_LCF_STRICTRELATIVE) != 0) fcaps = &nd.ni_filecaps; else #endif Modified: head/sys/sys/namei.h ============================================================================== --- head/sys/sys/namei.h Wed Nov 2 12:10:39 2016 (r308211) +++ head/sys/sys/namei.h Wed Nov 2 12:43:15 2016 (r308212) @@ -55,6 +55,9 @@ struct componentname { long cn_namelen; /* length of looked up component */ }; +struct nameicap_tracker; +TAILQ_HEAD(nameicap_tracker_head, nameicap_tracker); + /* * Encapsulation of namei parameters. */ @@ -72,7 +75,7 @@ struct nameidata { struct vnode *ni_rootdir; /* logical root directory */ struct vnode *ni_topdir; /* logical top directory */ int ni_dirfd; /* starting directory for *at functions */ - int ni_strictrelative; /* relative lookup only; no '..' */ + int ni_lcf; /* local call flags */ /* * Results: returned from namei */ @@ -94,6 +97,7 @@ struct nameidata { * through the VOP interface. */ struct componentname ni_cnd; + struct nameicap_tracker_head ni_cap_tracker; }; #ifdef _KERNEL @@ -152,6 +156,12 @@ struct nameidata { #define PARAMASK 0x3ffffe00 /* mask of parameter descriptors */ /* + * Flags in ni_lcf, valid for the duration of the namei call. + */ +#define NI_LCF_STRICTRELATIVE 0x0001 /* relative lookup only */ +#define NI_LCF_CAP_DOTDOT 0x0002 /* ".." in strictrelative case */ + +/* * Initialization of a nameidata structure. */ #define NDINIT(ndp, op, flags, segflg, namep, td) \ From owner-svn-src-head@freebsd.org Wed Nov 2 13:10:10 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B56C7C2A78D; Wed, 2 Nov 2016 13:10:10 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B8851F24; Wed, 2 Nov 2016 13:10:10 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2DA9km011779; Wed, 2 Nov 2016 13:10:09 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2DA9au011776; Wed, 2 Nov 2016 13:10:09 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201611021310.uA2DA9au011776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 2 Nov 2016 13:10:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308213 - in head/sys/arm: arm include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 13:10:10 -0000 Author: andrew Date: Wed Nov 2 13:10:08 2016 New Revision: 308213 URL: https://svnweb.freebsd.org/changeset/base/308213 Log: Allow an SMP kernel to boot on Cortex-A8: * Rename ARM_HAVE_MP_EXTENSIONS to ARM_USE_MP_EXTENSIONS and extend it to handle more cases, including when SMP is not enabled. * Check ARM_USE_MP_EXTENSIONS when building for ARMv7+, even if no SMP. * Use ARM_USE_MP_EXTENSIONS in pmap-v6.c to detect when to set PRRR_NS1. With this we should be able to boot on all ARMv7+ Cortex-A cores with 32-bit support. Reviewed by: mmel, imp (earlier version) Relnotes: yes Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D8335 Modified: head/sys/arm/arm/pmap-v6.c head/sys/arm/include/cpu-v6.h head/sys/arm/include/sysreg.h Modified: head/sys/arm/arm/pmap-v6.c ============================================================================== --- head/sys/arm/arm/pmap-v6.c Wed Nov 2 12:43:15 2016 (r308212) +++ head/sys/arm/arm/pmap-v6.c Wed Nov 2 13:10:08 2016 (r308213) @@ -500,7 +500,8 @@ pmap_set_tex(void) /* Add shareable bits for normal memory in SMP case. */ #ifdef SMP - prrr |= PRRR_NS1; + if (ARM_USE_MP_EXTENSIONS) + prrr |= PRRR_NS1; #endif cp15_prrr_set(prrr); cp15_nmrr_set(nmrr); Modified: head/sys/arm/include/cpu-v6.h ============================================================================== --- head/sys/arm/include/cpu-v6.h Wed Nov 2 12:43:15 2016 (r308212) +++ head/sys/arm/include/cpu-v6.h Wed Nov 2 13:10:08 2016 (r308213) @@ -45,6 +45,21 @@ #define CPU_ASID_KERNEL 0 +#if __ARM_ARCH >= 7 +#if !defined(SMP) +/* No SMP so no need to use the MP extensions */ +#define ARM_USE_MP_EXTENSIONS 0 +#elif defined(CPU_CORTEXA8) && \ + (defined(CPU_CORTEXA_MP) || defined(CPU_KRAIT) || defined(CPU_MV_PJ4B)) +#define ARM_USE_MP_EXTENSIONS (cpuinfo.mp_ext != 0) +#elif defined(CPU_CORTEXA8) +#define ARM_USE_MP_EXTENSIONS 0 +#else +#define ARM_USE_MP_EXTENSIONS 1 +#endif +#endif /* __ARM_ARCH >= 7 */ + + void dcache_wbinv_poc_all(void); /* !!! NOT SMP coherent function !!! */ vm_offset_t dcache_wb_pou_checked(vm_offset_t, vm_size_t); vm_offset_t icache_inv_pou_checked(vm_offset_t, vm_size_t); @@ -111,15 +126,15 @@ fname(uint64_t reg) \ /* TLB */ _WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */ -#if __ARM_ARCH >= 7 && defined SMP +#if __ARM_ARCH >= 7 _WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */ #endif _WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */ -#if __ARM_ARCH >= 7 && defined SMP +#if __ARM_ARCH >= 7 _WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */ #endif _WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */ -#if __ARM_ARCH >= 7 && defined SMP +#if __ARM_ARCH >= 7 _WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */ #endif _WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */ @@ -129,7 +144,7 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0)) /* Cache and Branch predictor */ _WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */ -#if __ARM_ARCH >= 7 && defined SMP +#if __ARM_ARCH >= 7 _WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */ #endif _WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */ @@ -143,7 +158,7 @@ _WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Da _WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */ _WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */ _WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */ -#if __ARM_ARCH >= 7 && defined SMP +#if __ARM_ARCH >= 7 _WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */ #endif _WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */ @@ -345,20 +360,14 @@ tlb_flush_range_local(vm_offset_t va, vm } /* Broadcasting operations. */ -#if __ARM_ARCH >= 7 && defined SMP - -#if defined(CPU_CORTEXA8) -#define ARM_HAVE_MP_EXTENSIONS (cpuinfo.mp_ext != 0) -#else -#define ARM_HAVE_MP_EXTENSIONS 1 -#endif +#if __ARM_ARCH >= 7 static __inline void tlb_flush_all(void) { dsb(); - if (ARM_HAVE_MP_EXTENSIONS) + if (ARM_USE_MP_EXTENSIONS) _CP15_TLBIALLIS(); else _CP15_TLBIALL(); @@ -370,7 +379,7 @@ tlb_flush_all_ng(void) { dsb(); - if (ARM_HAVE_MP_EXTENSIONS) + if (ARM_USE_MP_EXTENSIONS) _CP15_TLBIASIDIS(CPU_ASID_KERNEL); else _CP15_TLBIASID(CPU_ASID_KERNEL); @@ -384,7 +393,7 @@ tlb_flush(vm_offset_t va) KASSERT((va & PAGE_MASK) == 0, ("%s: va %#x not aligned", __func__, va)); dsb(); - if (ARM_HAVE_MP_EXTENSIONS) + if (ARM_USE_MP_EXTENSIONS) _CP15_TLBIMVAAIS(va); else _CP15_TLBIMVA(va | CPU_ASID_KERNEL); @@ -401,7 +410,7 @@ tlb_flush_range(vm_offset_t va, vm_size size)); dsb(); - if (ARM_HAVE_MP_EXTENSIONS) { + if (ARM_USE_MP_EXTENSIONS) { for (; va < eva; va += PAGE_SIZE) _CP15_TLBIMVAAIS(va); } else { @@ -410,14 +419,14 @@ tlb_flush_range(vm_offset_t va, vm_size } dsb(); } -#else /* SMP */ +#else /* __ARM_ARCH < 7 */ #define tlb_flush_all() tlb_flush_all_local() #define tlb_flush_all_ng() tlb_flush_all_ng_local() #define tlb_flush(va) tlb_flush_local(va) #define tlb_flush_range(va, size) tlb_flush_range_local(va, size) -#endif /* SMP */ +#endif /* __ARM_ARCH < 7 */ /* * Cache maintenance operations. @@ -431,8 +440,8 @@ icache_sync(vm_offset_t va, vm_size_t si dsb(); va &= ~cpuinfo.dcache_line_mask; -#if __ARM_ARCH >= 7 && defined SMP - if (ARM_HAVE_MP_EXTENSIONS) { +#if __ARM_ARCH >= 7 + if (ARM_USE_MP_EXTENSIONS) { for ( ; va < eva; va += cpuinfo.dcache_line_size) _CP15_DCCMVAU(va); } else @@ -442,8 +451,8 @@ icache_sync(vm_offset_t va, vm_size_t si _CP15_DCCMVAC(va); } dsb(); -#if __ARM_ARCH >= 7 && defined SMP - if (ARM_HAVE_MP_EXTENSIONS) +#if __ARM_ARCH >= 7 + if (ARM_USE_MP_EXTENSIONS) _CP15_ICIALLUIS(); else #endif @@ -456,8 +465,8 @@ icache_sync(vm_offset_t va, vm_size_t si static __inline void icache_inv_all(void) { -#if __ARM_ARCH >= 7 && defined SMP - if (ARM_HAVE_MP_EXTENSIONS) +#if __ARM_ARCH >= 7 + if (ARM_USE_MP_EXTENSIONS) _CP15_ICIALLUIS(); else #endif @@ -470,8 +479,8 @@ icache_inv_all(void) static __inline void bpb_inv_all(void) { -#if __ARM_ARCH >= 7 && defined SMP - if (ARM_HAVE_MP_EXTENSIONS) +#if __ARM_ARCH >= 7 + if (ARM_USE_MP_EXTENSIONS) _CP15_BPIALLIS(); else #endif @@ -488,8 +497,8 @@ dcache_wb_pou(vm_offset_t va, vm_size_t dsb(); va &= ~cpuinfo.dcache_line_mask; -#if __ARM_ARCH >= 7 && defined SMP - if (ARM_HAVE_MP_EXTENSIONS) { +#if __ARM_ARCH >= 7 + if (ARM_USE_MP_EXTENSIONS) { for ( ; va < eva; va += cpuinfo.dcache_line_size) _CP15_DCCMVAU(va); } else Modified: head/sys/arm/include/sysreg.h ============================================================================== --- head/sys/arm/include/sysreg.h Wed Nov 2 12:43:15 2016 (r308212) +++ head/sys/arm/include/sysreg.h Wed Nov 2 13:10:08 2016 (r308213) @@ -140,7 +140,7 @@ /* * CP15 C7 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */ #define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */ @@ -205,7 +205,7 @@ /* * CP15 C8 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */ #define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */ From owner-svn-src-head@freebsd.org Wed Nov 2 13:11:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40B55C2A7F1; Wed, 2 Nov 2016 13:11:21 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D59821686; Wed, 2 Nov 2016 13:11:20 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2DBJBX014607; Wed, 2 Nov 2016 13:11:19 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2DBJe5014606; Wed, 2 Nov 2016 13:11:19 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201611021311.uA2DBJe5014606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 2 Nov 2016 13:11:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308214 - head/sys/arm/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 13:11:21 -0000 Author: andrew Date: Wed Nov 2 13:11:19 2016 New Revision: 308214 URL: https://svnweb.freebsd.org/changeset/base/308214 Log: Add BeagleBone Black support to GENERIC on armv6. Reviewed by: mmel, imp Relnotes: yes Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D8335 Modified: head/sys/arm/conf/GENERIC Modified: head/sys/arm/conf/GENERIC ============================================================================== --- head/sys/arm/conf/GENERIC Wed Nov 2 13:10:08 2016 (r308213) +++ head/sys/arm/conf/GENERIC Wed Nov 2 13:11:19 2016 (r308214) @@ -21,6 +21,7 @@ ident GENERIC cpu CPU_CORTEXA_MP +cpu CPU_CORTEXA8 machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" @@ -37,6 +38,8 @@ files "../broadcom/bcm2835/files.bcm283 files "../broadcom/bcm2835/files.bcm283x" files "../nvidia/tegra124/files.tegra124" files "../qemu/files.qemu" +files "../ti/files.ti" +files "../ti/am335x/files.am335x" options SOC_ALLWINNER_A20 options SOC_ALLWINNER_A31 @@ -44,6 +47,7 @@ options SOC_ALLWINNER_A31S options SOC_ALLWINNER_A83T options SOC_ALLWINNER_H3 options SOC_BCM2836 +options SOC_TI_AM335X options SCHED_ULE # ULE scheduler options SMP # Enable multiple cores @@ -66,6 +70,9 @@ device cpufreq options INTRNG device gic +# PMU support (for CCNT). +device pmu + # ARM Generic Timer device generic_timer @@ -113,9 +120,14 @@ device axp81x # AXP813/818 Power Mana device bcm2835_bsc device icee device sy8106a # SY8106A Buck Regulator +device ti_i2c +device am335x_pmic # AM335x Power Management IC (TPC65217) +device am335x_rtc # RTC support (power management only) +#define am335x_dmtpps # Pulse Per Second capture driver # GPIO device gpio +device gpiobacklight device gpioled device gpioregulator @@ -128,6 +140,16 @@ device aw_cir # SPI device spibus device bcm2835_spi +device ti_spi + +# ADC support +device ti_adc + +# Watchdog support +# If we don't enable the watchdog driver, the BealeBone could potentially +# reboot automatically because the boot loader might have enabled the +# watchdog. +device ti_wdt device scbus # SCSI bus (required for ATA/SCSI) device da # Direct Access (disks) @@ -141,11 +163,16 @@ device usb device ohci device ehci device dwcotg # DWC OTG controller +device musb device umass # Disks/Mass storage - Requires scbus and da device uhid # "Human Interface Devices" device ukbd # Allow keyboard like HIDs to control console +# Device mode support and USFS template +device usb_template # Control of the gadget +device usfs + # Ethernet device loop device ether @@ -176,6 +203,12 @@ device vchiq # Pinmux device fdt_pinctrl +# TI Programmable Realtime Unit support +device ti_pruss + +# Mailbox support +device ti_mbox + # Extensible Firmware Interface options EFI From owner-svn-src-head@freebsd.org Wed Nov 2 14:23:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B112C2A40A; Wed, 2 Nov 2016 14:23:43 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 0050017C7; Wed, 2 Nov 2016 14:23:42 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from [10.10.30.201] (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id 0D5671EE4; Wed, 2 Nov 2016 14:23:41 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) From: "Jonathan Anderson" To: "Antoine Brodin" Cc: "Dimitry Andric" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Ed Maste" Subject: Re: svn commit: r308181 - in head: . share/mk Date: Wed, 02 Nov 2016 11:24:57 -0300 Message-ID: <16C8B4E6-EF20-4BC8-B6E8-5FC60CD0E1F8@FreeBSD.org> In-Reply-To: References: <201611012127.uA1LRg0B045900@repo.freebsd.org> <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> <459BD98A-4788-497E-B2D5-5EC20C5B9EE8@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Content-Transfer-Encoding: quoted-printable X-Mailer: MailMate (1.9.5r5263) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 14:23:43 -0000 On 2 Nov 2016, at 6:11, Antoine Brodin wrote: > On Wed, Nov 2, 2016 at 7:53 AM, Dimitry Andric = > wrote: >> >> Hi Antoine, you pointed me at some of these port failures due to the = >> .ll >> change, do you still have a list of them? > > The failures were: > > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/super-smack-1.3_2.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/dprog-0.3.1_2.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/ebnf2yacc-0.1.1.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/gnuchess-6.2.3.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/bugle-0.0.20100508_2.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/hfst-3.8.2.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/grap-1.45.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/g-cows-1.12.log > http://gohan2.ysv.freebsd.org/data/head-amd64-default-baseline/p424659_= s307951/logs/worker-3.8.4.log Thanks very much for that list. I've checked all of these ports with the = new IR binary and library changes, and they all build successfully. So, = I propose that we keep the new use of .bc and .ll within = bsd.{lib,prog}.mk, as those changes only affect consumers that = explicitly include these makefiles (vs the sys.mk changes that affect = everybody). Jon -- Jonathan Anderson jonathan@FreeBSD.org From owner-svn-src-head@freebsd.org Wed Nov 2 14:25:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 705D6C2A531; Wed, 2 Nov 2016 14:25:31 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24BB610D3; Wed, 2 Nov 2016 14:25:31 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2EPUiU043355; Wed, 2 Nov 2016 14:25:30 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2EPUxA043354; Wed, 2 Nov 2016 14:25:30 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201611021425.uA2EPUxA043354@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 2 Nov 2016 14:25:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308215 - head/sys/dev/e1000 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 14:25:31 -0000 Author: sbruno Date: Wed Nov 2 14:25:30 2016 New Revision: 308215 URL: https://svnweb.freebsd.org/changeset/base/308215 Log: Removed unused M_TSO_LEN. MFC after: 2 weeks Modified: head/sys/dev/e1000/if_em.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Wed Nov 2 13:11:19 2016 (r308214) +++ head/sys/dev/e1000/if_em.c Wed Nov 2 14:25:30 2016 (r308215) @@ -365,7 +365,6 @@ MODULE_DEPEND(em, netmap, 1, 1, 1); #define EM_TICKS_TO_USECS(ticks) ((1024 * (ticks) + 500) / 1000) #define EM_USECS_TO_TICKS(usecs) ((1000 * (usecs) + 512) / 1024) -#define M_TSO_LEN 66 #define MAX_INTS_PER_SEC 8000 #define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) From owner-svn-src-head@freebsd.org Wed Nov 2 15:11:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 163E1C2BB5C; Wed, 2 Nov 2016 15:11:25 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC9A1172A; Wed, 2 Nov 2016 15:11:24 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2FBNTd062341; Wed, 2 Nov 2016 15:11:23 GMT (envelope-from fabient@FreeBSD.org) Received: (from fabient@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2FBNok062340; Wed, 2 Nov 2016 15:11:23 GMT (envelope-from fabient@FreeBSD.org) Message-Id: <201611021511.uA2FBNok062340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fabient set sender to fabient@FreeBSD.org using -f From: Fabien Thomas Date: Wed, 2 Nov 2016 15:11:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308216 - head/usr.sbin/rtadvd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 15:11:25 -0000 Author: fabient Date: Wed Nov 2 15:11:23 2016 New Revision: 308216 URL: https://svnweb.freebsd.org/changeset/base/308216 Log: In rtadvd, interface lookup calls if_indextoname() many times in a loop, (it takes a long time on systems with many interfaces) without reason and without checking its return value. Reviewed by: cem Obtained from: Maryse Levavasseur MFC after: 1 month Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D6979 Modified: head/usr.sbin/rtadvd/if.c Modified: head/usr.sbin/rtadvd/if.c ============================================================================== --- head/usr.sbin/rtadvd/if.c Wed Nov 2 14:25:30 2016 (r308215) +++ head/usr.sbin/rtadvd/if.c Wed Nov 2 15:11:23 2016 (r308216) @@ -470,11 +470,18 @@ update_ifinfo(struct ifilist_head_t *ifi ifindex != ifm->ifm_index) continue; + /* ifname */ + if (if_indextoname(ifm->ifm_index, ifname) == NULL) { + syslog(LOG_WARNING, + "<%s> ifname not found (idx=%d)", + __func__, ifm->ifm_index); + continue; + } + /* lookup an entry with the same ifindex */ TAILQ_FOREACH(ifi, ifi_head, ifi_next) { if (ifm->ifm_index == ifi->ifi_ifindex) break; - if_indextoname(ifm->ifm_index, ifname); if (strncmp(ifname, ifi->ifi_ifname, sizeof(ifname)) == 0) break; @@ -493,15 +500,7 @@ update_ifinfo(struct ifilist_head_t *ifi ifi->ifi_ifindex = ifm->ifm_index; /* ifname */ - if_indextoname(ifm->ifm_index, ifi->ifi_ifname); - if (ifi->ifi_ifname == NULL) { - syslog(LOG_WARNING, - "<%s> ifname not found (idx=%d)", - __func__, ifm->ifm_index); - if (ifi_new) - free(ifi); - continue; - } + strlcpy(ifi->ifi_ifname, ifname, IFNAMSIZ); if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, From owner-svn-src-head@freebsd.org Wed Nov 2 15:13:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29971C2BC30; Wed, 2 Nov 2016 15:13:27 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAD771FD8; Wed, 2 Nov 2016 15:13:26 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2FDP4K062470; Wed, 2 Nov 2016 15:13:25 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2FDPk6062463; Wed, 2 Nov 2016 15:13:25 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201611021513.uA2FDPk6062463@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Wed, 2 Nov 2016 15:13:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308217 - in head/sys/dev: mpr mps X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 15:13:27 -0000 Author: scottl Date: Wed Nov 2 15:13:25 2016 New Revision: 308217 URL: https://svnweb.freebsd.org/changeset/base/308217 Log: Add a fallback to the device mapper logic. We've seen systems in the field that are apparently misconfigured by the manufacturer and cause the mapping logic to fail. The fallback allows drive numbers to be assigned based on the PHY number that they're attached to. Add sysctls and tunables to overrid this new behavior, but they should be considered only necessary for debugging. Reviewed by: imp, smh Obtained from: Netflix MFC after: 3 days Sponsored by: D8403 Modified: head/sys/dev/mpr/mpr.c head/sys/dev/mpr/mpr_sas_lsi.c head/sys/dev/mpr/mprvar.h head/sys/dev/mps/mps.c head/sys/dev/mps/mps_sas_lsi.c head/sys/dev/mps/mpsvar.h Modified: head/sys/dev/mpr/mpr.c ============================================================================== --- head/sys/dev/mpr/mpr.c Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mpr/mpr.c Wed Nov 2 15:13:25 2016 (r308217) @@ -1376,6 +1376,7 @@ mpr_get_tunables(struct mpr_softc *sc) sc->max_io_pages = MPR_MAXIO_PAGES; sc->enable_ssu = MPR_SSU_ENABLE_SSD_DISABLE_HDD; sc->spinup_wait_time = DEFAULT_SPINUP_WAIT; + sc->use_phynum = 1; /* * Grab the global variables. @@ -1387,6 +1388,7 @@ mpr_get_tunables(struct mpr_softc *sc) TUNABLE_INT_FETCH("hw.mpr.max_io_pages", &sc->max_io_pages); TUNABLE_INT_FETCH("hw.mpr.enable_ssu", &sc->enable_ssu); TUNABLE_INT_FETCH("hw.mpr.spinup_wait_time", &sc->spinup_wait_time); + TUNABLE_INT_FETCH("hw.mpr.use_phy_num", &sc->use_phynum); /* Grab the unit-instance variables */ snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.debug_level", @@ -1421,6 +1423,10 @@ mpr_get_tunables(struct mpr_softc *sc) snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.spinup_wait_time", device_get_unit(sc->mpr_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->spinup_wait_time); + + snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.use_phy_num", + device_get_unit(sc->mpr_dev)); + TUNABLE_INT_FETCH(tmpstr, &sc->use_phynum); } static void @@ -1510,6 +1516,10 @@ mpr_setup_sysctl(struct mpr_softc *sc) OID_AUTO, "spinup_wait_time", CTLFLAG_RD, &sc->spinup_wait_time, DEFAULT_SPINUP_WAIT, "seconds to wait for " "spinup after SATA ID error"); + + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "use_phy_num", CTLFLAG_RD, &sc->use_phynum, 0, + "Use the phy number for enumeration"); } int Modified: head/sys/dev/mpr/mpr_sas_lsi.c ============================================================================== --- head/sys/dev/mpr/mpr_sas_lsi.c Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mpr/mpr_sas_lsi.c Wed Nov 2 15:13:25 2016 (r308217) @@ -757,13 +757,24 @@ mprsas_add_device(struct mpr_softc *sc, } } - id = mpr_mapping_get_sas_id(sc, sas_address, handle); + /* + * use_phynum: + * 1 - use the PhyNum field as a fallback to the mapping logic + * 0 - never use the PhyNum field + * -1 - only use the PhyNum field + */ + id = MPR_MAP_BAD_ID; + if (sc->use_phynum != -1) + id = mpr_mapping_get_sas_id(sc, sas_address, handle); if (id == MPR_MAP_BAD_ID) { - printf("failure at %s:%d/%s()! Could not get ID for device " - "with handle 0x%04x\n", __FILE__, __LINE__, __func__, - handle); - error = ENXIO; - goto out; + if ((sc->use_phynum == 0) + || ((id = config_page.PhyNum) > sassc->maxtargets)) { + mpr_dprint(sc, MPR_INFO, "failure at %s:%d/%s()! " + "Could not get ID for device with handle 0x%04x\n", + __FILE__, __LINE__, __func__, handle); + error = ENXIO; + goto out; + } } if (mprsas_check_id(sassc, id) != 0) { @@ -772,9 +783,16 @@ mprsas_add_device(struct mpr_softc *sc, goto out; } + targ = &sassc->targets[id]; + if (targ->handle != 0x0) { + mpr_dprint(sc, MPR_MAPPING, "Attempting to reuse target id " + "%d handle 0x%04x\n", id, targ->handle); + error = ENXIO; + goto out; + } + mpr_dprint(sc, MPR_MAPPING, "SAS Address from SAS device page0 = %jx\n", sas_address); - targ = &sassc->targets[id]; targ->devinfo = device_info; targ->devname = le32toh(config_page.DeviceName.High); targ->devname = (targ->devname << 32) | Modified: head/sys/dev/mpr/mprvar.h ============================================================================== --- head/sys/dev/mpr/mprvar.h Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mpr/mprvar.h Wed Nov 2 15:13:25 2016 (r308217) @@ -271,6 +271,7 @@ struct mpr_softc { uint16_t chain_seg_size; u_int enable_ssu; int spinup_wait_time; + int use_phynum; uint64_t chain_alloc_fail; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mps/mps.c Wed Nov 2 15:13:25 2016 (r308217) @@ -1353,6 +1353,7 @@ mps_get_tunables(struct mps_softc *sc) sc->max_io_pages = MPS_MAXIO_PAGES; sc->enable_ssu = MPS_SSU_ENABLE_SSD_DISABLE_HDD; sc->spinup_wait_time = DEFAULT_SPINUP_WAIT; + sc->use_phynum = 1; /* * Grab the global variables. @@ -1364,6 +1365,7 @@ mps_get_tunables(struct mps_softc *sc) TUNABLE_INT_FETCH("hw.mps.max_io_pages", &sc->max_io_pages); TUNABLE_INT_FETCH("hw.mps.enable_ssu", &sc->enable_ssu); TUNABLE_INT_FETCH("hw.mps.spinup_wait_time", &sc->spinup_wait_time); + TUNABLE_INT_FETCH("hw.mps.use_phy_num", &sc->use_phynum); /* Grab the unit-instance variables */ snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.debug_level", @@ -1398,6 +1400,10 @@ mps_get_tunables(struct mps_softc *sc) snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.spinup_wait_time", device_get_unit(sc->mps_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->spinup_wait_time); + + snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.use_phy_num", + device_get_unit(sc->mps_dev)); + TUNABLE_INT_FETCH(tmpstr, &sc->use_phynum); } static void @@ -1495,6 +1501,10 @@ mps_setup_sysctl(struct mps_softc *sc) SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "encl_table_dump", CTLTYPE_STRING | CTLFLAG_RD, sc, 0, mps_mapping_encl_dump, "A", "Enclosure Table Dump"); + + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "use_phy_num", CTLFLAG_RD, &sc->use_phynum, 0, + "Use the phy number for enumeration"); } int Modified: head/sys/dev/mps/mps_sas_lsi.c ============================================================================== --- head/sys/dev/mps/mps_sas_lsi.c Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mps/mps_sas_lsi.c Wed Nov 2 15:13:25 2016 (r308217) @@ -669,13 +669,24 @@ mpssas_add_device(struct mps_softc *sc, } } - id = mps_mapping_get_sas_id(sc, sas_address, handle); + /* + * use_phynum: + * 1 - use the PhyNum field as a fallback to the mapping logic + * 0 - never use the PhyNum field + * -1 - only use the PhyNum field + */ + id = MPS_MAP_BAD_ID; + if (sc->use_phynum != -1) + id = mps_mapping_get_sas_id(sc, sas_address, handle); if (id == MPS_MAP_BAD_ID) { - printf("failure at %s:%d/%s()! Could not get ID for device " - "with handle 0x%04x\n", __FILE__, __LINE__, __func__, - handle); - error = ENXIO; - goto out; + if ((sc->use_phynum == 0) + || ((id = config_page.PhyNum) > sassc->maxtargets)) { + mps_dprint(sc, MPS_INFO, "failure at %s:%d/%s()! " + "Could not get ID for device with handle 0x%04x\n", + __FILE__, __LINE__, __func__, handle); + error = ENXIO; + goto out; + } } if (mpssas_check_id(sassc, id) != 0) { @@ -684,9 +695,16 @@ mpssas_add_device(struct mps_softc *sc, goto out; } + targ = &sassc->targets[id]; + if (targ->handle != 0x0) { + mps_dprint(sc, MPS_MAPPING, "Attempting to reuse target id " + "%d handle 0x%04x\n", id, targ->handle); + error = ENXIO; + goto out; + } + mps_dprint(sc, MPS_MAPPING, "SAS Address from SAS device page0 = %jx\n", sas_address); - targ = &sassc->targets[id]; targ->devinfo = device_info; targ->devname = le32toh(config_page.DeviceName.High); targ->devname = (targ->devname << 32) | Modified: head/sys/dev/mps/mpsvar.h ============================================================================== --- head/sys/dev/mps/mpsvar.h Wed Nov 2 15:11:23 2016 (r308216) +++ head/sys/dev/mps/mpsvar.h Wed Nov 2 15:13:25 2016 (r308217) @@ -285,6 +285,7 @@ struct mps_softc { int chain_free_lowwater; u_int enable_ssu; int spinup_wait_time; + int use_phynum; uint64_t chain_alloc_fail; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; From owner-svn-src-head@freebsd.org Wed Nov 2 16:15:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E02BAC2B0BD; Wed, 2 Nov 2016 16:15:51 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7576910DF; Wed, 2 Nov 2016 16:15:51 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2GFoUS085737; Wed, 2 Nov 2016 16:15:50 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2GFove085732; Wed, 2 Nov 2016 16:15:50 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611021615.uA2GFove085732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 2 Nov 2016 16:15:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308218 - in head: sys/dev/cpuctl usr.sbin/cpucontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 16:15:52 -0000 Author: avg Date: Wed Nov 2 16:15:49 2016 New Revision: 308218 URL: https://svnweb.freebsd.org/changeset/base/308218 Log: Add support for microcode update on newer AMD CPUs (10h+) This includes new code for parsing microcode files as well as the kernel-side change to apply the update on all processors at the same time. Developed with help from Borislav Petkov, formerly bp@amd64.org. Tested using Athlon II X2 processor on a system where BIOS does not have the latest microcode version: /boot/firmware/microcode_amd.bin: updating cpu /dev/cpuctl0 to revision 0x10000c7... done. The microcode file is taken from here: https://web.archive.org/web/20160528230514/http://www.amd64.org/microcode.html (note that the original site seems to be down at the moment) It can also be found here: https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/amd-ucode Reviewed by: kib, stas MFC after: 2 weeks Relnotes: maybe Differential Revision: https://reviews.freebsd.org/D8384 Added: head/usr.sbin/cpucontrol/amd10h.c (contents, props changed) Modified: head/sys/dev/cpuctl/cpuctl.c head/usr.sbin/cpucontrol/Makefile head/usr.sbin/cpucontrol/amd.h head/usr.sbin/cpucontrol/cpucontrol.c Modified: head/sys/dev/cpuctl/cpuctl.c ============================================================================== --- head/sys/dev/cpuctl/cpuctl.c Wed Nov 2 15:13:25 2016 (r308217) +++ head/sys/dev/cpuctl/cpuctl.c Wed Nov 2 16:15:49 2016 (r308218) @@ -377,13 +377,24 @@ fail: return (ret); } +/* + * NB: MSR 0xc0010020, MSR_K8_UCODE_UPDATE, is not documented by AMD. + * Coreboot, illumos and Linux source code was used to understand + * its workings. + */ +static void +amd_ucode_wrmsr(void *ucode_ptr) +{ + uint32_t tmp[4]; + + wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)ucode_ptr); + do_cpuid(0, tmp); +} + static int update_amd(int cpu, cpuctl_update_args_t *args, struct thread *td) { - void *ptr = NULL; - uint32_t tmp[4]; - int is_bound = 0; - int oldcpu; + void *ptr; int ret; if (args->size == 0 || args->data == NULL) { @@ -394,41 +405,23 @@ update_amd(int cpu, cpuctl_update_args_t DPRINTF("[cpuctl,%d]: firmware image too large", __LINE__); return (EINVAL); } + /* - * XXX Might not require contignous address space - needs check + * 16 byte alignment required. Rely on the fact that + * malloc(9) always returns the pointer aligned at least on + * the size of the allocation. */ - ptr = contigmalloc(args->size, M_CPUCTL, 0, 0, 0xffffffff, 16, 0); - if (ptr == NULL) { - DPRINTF("[cpuctl,%d]: cannot allocate %zd bytes of memory", - __LINE__, args->size); - return (ENOMEM); - } + ptr = malloc(args->size + 16, M_CPUCTL, M_ZERO | M_WAITOK); if (copyin(args->data, ptr, args->size) != 0) { DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed", __LINE__, args->data, ptr, args->size); ret = EFAULT; goto fail; } - oldcpu = td->td_oncpu; - is_bound = cpu_sched_is_bound(td); - set_cpu(cpu, td); - critical_enter(); - - /* - * Perform update. - */ - wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)ptr); - - /* - * Serialize instruction flow. - */ - do_cpuid(0, tmp); - critical_exit(); - restore_cpu(oldcpu, is_bound, td); + smp_rendezvous(NULL, amd_ucode_wrmsr, NULL, ptr); ret = 0; fail: - if (ptr != NULL) - contigfree(ptr, args->size, M_CPUCTL); + free(ptr, M_CPUCTL); return (ret); } Modified: head/usr.sbin/cpucontrol/Makefile ============================================================================== --- head/usr.sbin/cpucontrol/Makefile Wed Nov 2 15:13:25 2016 (r308217) +++ head/usr.sbin/cpucontrol/Makefile Wed Nov 2 16:15:49 2016 (r308218) @@ -2,7 +2,7 @@ PROG= cpucontrol MAN= cpucontrol.8 -SRCS= cpucontrol.c intel.c amd.c via.c +SRCS= cpucontrol.c intel.c amd.c amd10h.c via.c NO_WCAST_ALIGN= Modified: head/usr.sbin/cpucontrol/amd.h ============================================================================== --- head/usr.sbin/cpucontrol/amd.h Wed Nov 2 15:13:25 2016 (r308217) +++ head/usr.sbin/cpucontrol/amd.h Wed Nov 2 16:15:49 2016 (r308218) @@ -33,6 +33,8 @@ */ ucode_probe_t amd_probe; ucode_update_t amd_update; +ucode_probe_t amd10h_probe; +ucode_update_t amd10h_update; typedef struct amd_fw_header { uint32_t date; /* Update creation date. */ @@ -46,4 +48,45 @@ typedef struct amd_fw_header { #define AMD_MAGIC 0xaaaaaa +/* + * AMD family 10h and later. + */ +typedef struct amd_10h_fw_header { + uint32_t data_code; + uint32_t patch_id; + uint16_t mc_patch_data_id; + uint8_t mc_patch_data_len; + uint8_t init_flag; + uint32_t mc_patch_data_checksum; + uint32_t nb_dev_id; + uint32_t sb_dev_id; + uint16_t processor_rev_id; + uint8_t nb_rev_id; + uint8_t sb_rev_id; + uint8_t bios_api_rev; + uint8_t reserved1[3]; + uint32_t match_reg[8]; +} amd_10h_fw_header_t; + +typedef struct equiv_cpu_entry { + uint32_t installed_cpu; + uint32_t fixed_errata_mask; + uint32_t fixed_errata_compare; + uint16_t equiv_cpu; + uint16_t res; +} equiv_cpu_entry_t; + +typedef struct section_header { + uint32_t type; + uint32_t size; +} section_header_t; + +typedef struct container_header { + uint32_t magic; +} container_header_t; + +#define AMD_10H_MAGIC 0x414d44 +#define AMD_10H_EQUIV_TABLE_TYPE 0 +#define AMD_10H_uCODE_TYPE 1 + #endif /* !AMD_H */ Added: head/usr.sbin/cpucontrol/amd10h.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/cpucontrol/amd10h.c Wed Nov 2 16:15:49 2016 (r308218) @@ -0,0 +1,307 @@ +/*- + * Copyright (c) 2012 Andriy Gapon . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cpucontrol.h" +#include "amd.h" + +int +amd10h_probe(int fd) +{ + char vendor[13]; + cpuctl_cpuid_args_t idargs; + uint32_t family; + uint32_t signature; + int error; + + idargs.level = 0; + error = ioctl(fd, CPUCTL_CPUID, &idargs); + if (error < 0) { + WARN(0, "ioctl()"); + return (1); + } + ((uint32_t *)vendor)[0] = idargs.data[1]; + ((uint32_t *)vendor)[1] = idargs.data[3]; + ((uint32_t *)vendor)[2] = idargs.data[2]; + vendor[12] = '\0'; + if (strncmp(vendor, AMD_VENDOR_ID, sizeof(AMD_VENDOR_ID)) != 0) + return (1); + + idargs.level = 1; + error = ioctl(fd, CPUCTL_CPUID, &idargs); + if (error < 0) { + WARN(0, "ioctl()"); + return (1); + } + signature = idargs.data[0]; + family = ((signature >> 8) & 0x0f) + ((signature >> 20) & 0xff); + if (family < 0x10) + return (1); + return (0); +} + +/* + * NB: the format of microcode update files is not documented by AMD. + * It has been reverse engineered from studying Coreboot, illumos and Linux + * source code. + */ +void +amd10h_update(const char *dev, const char *path) +{ + struct stat st; + cpuctl_cpuid_args_t idargs; + cpuctl_msr_args_t msrargs; + cpuctl_update_args_t args; + const amd_10h_fw_header_t *fw_header; + const amd_10h_fw_header_t *selected_fw; + const equiv_cpu_entry_t *equiv_cpu_table; + const section_header_t *section_header; + const container_header_t *container_header; + const uint8_t *fw_data; + uint8_t *fw_image; + size_t fw_size; + size_t selected_size; + uint32_t revision; + uint32_t new_rev; + uint32_t signature; + uint16_t equiv_id; + int fd, devfd; + unsigned int i; + int error; + + assert(path); + assert(dev); + + fd = -1; + fw_image = MAP_FAILED; + devfd = open(dev, O_RDWR); + if (devfd < 0) { + WARN(0, "could not open %s for writing", dev); + return; + } + idargs.level = 1; + error = ioctl(devfd, CPUCTL_CPUID, &idargs); + if (error < 0) { + WARN(0, "ioctl()"); + goto done; + } + signature = idargs.data[0]; + + msrargs.msr = 0x0000008b; + error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); + if (error < 0) { + WARN(0, "ioctl(%s)", dev); + goto done; + } + revision = (uint32_t)msrargs.data; + + WARNX(1, "found cpu family %#x model %#x " + "stepping %#x extfamily %#x extmodel %#x.", + (signature >> 8) & 0x0f, (signature >> 4) & 0x0f, + (signature >> 0) & 0x0f, (signature >> 20) & 0xff, + (signature >> 16) & 0x0f); + WARNX(1, "microcode revision %#x", revision); + + /* + * Open the firmware file. + */ + fd = open(path, O_RDONLY, 0); + if (fd < 0) { + WARN(0, "open(%s)", path); + goto done; + } + error = fstat(fd, &st); + if (error != 0) { + WARN(0, "fstat(%s)", path); + goto done; + } + if (st.st_size < 0 || (size_t)st.st_size < + (sizeof(*container_header) + sizeof(*section_header))) { + WARNX(2, "file too short: %s", path); + goto done; + } + fw_size = st.st_size; + + /* + * mmap the whole image. + */ + fw_image = (uint8_t *)mmap(NULL, st.st_size, PROT_READ, + MAP_PRIVATE, fd, 0); + if (fw_image == MAP_FAILED) { + WARN(0, "mmap(%s)", path); + goto done; + } + + fw_data = fw_image; + container_header = (const container_header_t *)fw_data; + if (container_header->magic != AMD_10H_MAGIC) { + WARNX(2, "%s is not a valid amd firmware: bad magic", path); + goto done; + } + fw_data += sizeof(*container_header); + fw_size -= sizeof(*container_header); + + section_header = (const section_header_t *)fw_data; + if (section_header->type != AMD_10H_EQUIV_TABLE_TYPE) { + WARNX(2, "%s is not a valid amd firmware: " + "first section is not CPU equivalence table", path); + goto done; + } + if (section_header->size == 0) { + WARNX(2, "%s is not a valid amd firmware: " + "first section is empty", path); + goto done; + } + fw_data += sizeof(*section_header); + fw_size -= sizeof(*section_header); + + if (section_header->size > fw_size) { + WARNX(2, "%s is not a valid amd firmware: " + "file is truncated", path); + goto done; + } + if (section_header->size < sizeof(*equiv_cpu_table)) { + WARNX(2, "%s is not a valid amd firmware: " + "first section is too short", path); + goto done; + } + equiv_cpu_table = (const equiv_cpu_entry_t *)fw_data; + fw_data += section_header->size; + fw_size -= section_header->size; + + equiv_id = 0; + for (i = 0; equiv_cpu_table[i].installed_cpu != 0; i++) { + if (signature == equiv_cpu_table[i].installed_cpu) { + equiv_id = equiv_cpu_table[i].equiv_cpu; + WARNX(3, "equiv_id: %x", equiv_id); + break; + } + } + if (equiv_id == 0) { + WARNX(2, "CPU is not found in the equivalence table"); + goto done; + } + + selected_fw = NULL; + selected_size = 0; + while (fw_size >= sizeof(*section_header)) { + section_header = (const section_header_t *)fw_data; + fw_data += sizeof(*section_header); + fw_size -= sizeof(*section_header); + if (section_header->type != AMD_10H_uCODE_TYPE) { + WARNX(2, "%s is not a valid amd firmware: " + "section has incorret type", path); + goto done; + } + if (section_header->size > fw_size) { + WARNX(2, "%s is not a valid amd firmware: " + "file is truncated", path); + goto done; + } + if (section_header->size < sizeof(*fw_header)) { + WARNX(2, "%s is not a valid amd firmware: " + "section is too short", path); + goto done; + } + fw_header = (const amd_10h_fw_header_t *)fw_data; + fw_data += section_header->size; + fw_size -= section_header->size; + + if (fw_header->processor_rev_id != equiv_id) + continue; /* different cpu */ + if (fw_header->patch_id <= revision) + continue; /* not newer revision */ + if (fw_header->nb_dev_id != 0 || fw_header->sb_dev_id != 0) { + WARNX(2, "Chipset-specific microcode is not supported"); + } + + WARNX(3, "selecting revision: %x", fw_header->patch_id); + revision = fw_header->patch_id; + selected_fw = fw_header; + selected_size = section_header->size; + } + + if (fw_size != 0) { + WARNX(2, "%s is not a valid amd firmware: " + "file is truncated", path); + goto done; + } + + if (selected_fw != NULL) { + WARNX(1, "selected ucode size is %zu", selected_size); + fprintf(stderr, "%s: updating cpu %s to revision %#x... ", + path, dev, revision); + + args.data = __DECONST(void *, selected_fw); + args.size = selected_size; + error = ioctl(devfd, CPUCTL_UPDATE, &args); + if (error < 0) { + fprintf(stderr, "failed.\n"); + warn("ioctl()"); + goto done; + } + fprintf(stderr, "done.\n"); + } + + msrargs.msr = 0x0000008b; + error = ioctl(devfd, CPUCTL_RDMSR, &msrargs); + if (error < 0) { + WARN(0, "ioctl(%s)", dev); + goto done; + } + new_rev = (uint32_t)msrargs.data; + if (new_rev != revision) + WARNX(0, "revision after update %#x", new_rev); + +done: + if (fd >= 0) + close(fd); + if (devfd >= 0) + close(devfd); + if (fw_image != MAP_FAILED) + if (munmap(fw_image, st.st_size) != 0) + warn("munmap(%s)", path); + return; +} Modified: head/usr.sbin/cpucontrol/cpucontrol.c ============================================================================== --- head/usr.sbin/cpucontrol/cpucontrol.c Wed Nov 2 15:13:25 2016 (r308217) +++ head/usr.sbin/cpucontrol/cpucontrol.c Wed Nov 2 16:15:49 2016 (r308218) @@ -91,6 +91,7 @@ static struct ucode_handler { ucode_update_t *update; } handlers[] = { { intel_probe, intel_update }, + { amd10h_probe, amd10h_update }, { amd_probe, amd_update }, { via_probe, via_update }, }; From owner-svn-src-head@freebsd.org Wed Nov 2 16:51:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C8B7C2C0DA; Wed, 2 Nov 2016 16:51:46 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EF9D21671; Wed, 2 Nov 2016 16:51:45 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id DB7D05A9F14; Wed, 2 Nov 2016 16:45:38 +0000 (UTC) Date: Wed, 2 Nov 2016 16:45:38 +0000 From: Brooks Davis To: Jonathan Anderson Cc: Dimitry Andric , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Ed Maste Subject: Re: svn commit: r308181 - in head: . share/mk Message-ID: <20161102164538.GA83465@spindle.one-eyed-alien.net> References: <201611012127.uA1LRg0B045900@repo.freebsd.org> <46715A69-03C5-404F-B133-C8FE89D59A9B@FreeBSD.org> <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/9DWx/yDrRhgMJTb" Content-Disposition: inline In-Reply-To: <69A64340-FE51-4AF0-9905-B46220D041E9@FreeBSD.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 16:51:46 -0000 --/9DWx/yDrRhgMJTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 02, 2016 at 04:55:22AM -0230, Jonathan Anderson wrote: > Hi, >=20 > On 1 Nov 2016, at 21:10, Dimitry Andric wrote: >=20 > > Please note, I reverted r307823 (which changed the suffixes from .bco > > and .llo to .bc and .ll) in r308003, since it caused a number of ports > > failures. These ports were already using .ll as a suffix for C++ lex > > scripts. >=20 > The changes to bsd.suffixes-posix.mk (included by sys.mk) would have affe= cted anything compiled with bmake, and indeed, I'd imagine that adding a .c= ->.ll rule alongside .c->.o could cause problems with C++ lex rules. In fac= t, part of brooks' original motivation for introducing .llo suffixes was to= avoid name conflicts (although conflicts with program IR like we're introd= ucing in this commit). The changes in this commit should only be picked up = by things that explicit include bsd.{lib,prog}.mk, however, and they also h= ave slightly more esoteric names (e.g., progname.full.ll) that are less lik= ely to cause a conflict. Perhaps I ought to have done an exp-run, but I sus= pect that this commit will cause much less / no fallout. I don't suppose yo= u have a list of the ports that failed after your r307823 change so that I = could do spot checks? As a bit of background, the original motivation for the .bco and .llo files what that I wanted to differentiate between IR files produced from single translation units (.c files) and IR files produced by llvm-link so I didn't have to worry about things like name space collisions in the case of transitions like: clang llvm-link opt ld (prog.c, utils.c) =3D> (prog.llo, util.llo) =3D> prog.ll =3D> prog.o =3D> p= rog Part of the fun is that you might instead want: clang opt ld (prog.c, utils.c) =3D> (prog.llo, util.llo) =3D> (prog.o, util.o) =3D> prog and for extra fun you might insert instrumentation at any IR stage so yet more suffixes may be required if your tools don't fit neatly into clang, opt, etc plugins. Make is lousy at this stuff so a certain about of ugliness is likely to remain required. -- Brooks --/9DWx/yDrRhgMJTb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYGhgyAAoJEKzQXbSebgfAHToH/A0zptfJES+9bRZRLrUEJjpR tEsoFE4v/xJPb1iz7LGKB327NX1nM7sFSalHcnFOy++5o9gAUzEmhQMHWx6dWyo2 HzOhIGySxhUqvieG1o8Yj01E9ObyhpBBPXGAeA1G4kWRlO2wi5Ze7ZwdmJPP0Cel aNsBo0p2O0coT+qhbphs0GbQH112zsErvFdfSgjgz5HnACaXl5mr85rDxCYXxKye nbWka0+HsFMMUxmeQWBoj5/jgrPI0H8sV86Wf7TZklijPvROa+r5HCI9kFzu+Xe6 gNc94FJDYOH8K1qwKATzCDFYvSJnvN7J2umBRxygNtECIA9DWrx1bSXcK8VPY9M= =VM2J -----END PGP SIGNATURE----- --/9DWx/yDrRhgMJTb-- From owner-svn-src-head@freebsd.org Wed Nov 2 17:04:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AAE5C2C2C0; Wed, 2 Nov 2016 17:04:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 341D01DBC; Wed, 2 Nov 2016 17:04:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2H41gq004984; Wed, 2 Nov 2016 17:04:01 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2H41bk004980; Wed, 2 Nov 2016 17:04:01 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611021704.uA2H41bk004980@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 2 Nov 2016 17:04:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308219 - head/sys/dev/ichiic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 17:04:02 -0000 Author: avg Date: Wed Nov 2 17:04:00 2016 New Revision: 308219 URL: https://svnweb.freebsd.org/changeset/base/308219 Log: ichiic/ig4: completely disengage from smbus MFC after: 5 weeks Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_reg.h head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c ============================================================================== --- head/sys/dev/ichiic/ig4_iic.c Wed Nov 2 16:15:49 2016 (r308218) +++ head/sys/dev/ichiic/ig4_iic.c Wed Nov 2 17:04:00 2016 (r308219) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); /* - * Intel fourth generation mobile cpus integrated I2C device, smbus driver. + * Intel fourth generation mobile cpus integrated I2C deviceer. * * See ig4_reg.h for datasheet reference and notes. * See ig4_var.h for locking semantics. @@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -236,18 +235,13 @@ data_read(ig4iic_softc_t *sc) * the target address for when the controller later issues a START. */ static void -set_slave_addr(ig4iic_softc_t *sc, uint8_t slave, int trans_op) +set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) { uint32_t tar; uint32_t ctl; int use_10bit; - use_10bit = sc->use_10bit; - if (trans_op & SMB_TRANS_7BIT) - use_10bit = 0; - if (trans_op & SMB_TRANS_10BIT) - use_10bit = 1; - + use_10bit = 0; if (sc->slave_valid && sc->last_slave == slave && sc->use_10bit == use_10bit) { return; @@ -291,208 +285,12 @@ set_slave_addr(ig4iic_softc_t *sc, uint8 } /* - * Issue START with byte command, possible count, and a variable length - * read or write buffer, then possible turn-around read. The read also - * has a possible count received. - * - * For SMBUS - - * - * Quick: START+ADDR+RD/WR STOP - * - * Normal: START+ADDR+WR CMD DATA..DATA STOP - * - * START+ADDR+RD CMD - * RESTART+ADDR RDATA..RDATA STOP - * (can also be used for I2C transactions) - * - * Process Call: START+ADDR+WR CMD DATAL DATAH - * RESTART+ADDR+RD RDATAL RDATAH STOP - * - * Block: START+ADDR+RD CMD - * RESTART+ADDR+RD RCOUNT DATA... STOP - * - * START+ADDR+WR CMD - * RESTART+ADDR+WR WCOUNT DATA... STOP - * - * For I2C - basically, no *COUNT fields, possibly no *CMD field. If the - * sender needs to issue a 2-byte command it will incorporate it - * into the write buffer and also set NOCMD. - * - * Generally speaking, the START+ADDR / RESTART+ADDR is handled automatically - * by the controller at the beginning of a command sequence or on a data - * direction turn-around, and we only need to tell it when to issue the STOP. - */ -static int -smb_transaction(ig4iic_softc_t *sc, char cmd, int op, - char *wbuf, int wcount, char *rbuf, int rcount, int *actualp) -{ - int error; - int unit; - uint32_t last; - - /* - * Debugging - dump registers - */ - if (ig4_dump) { - unit = device_get_unit(sc->dev); - if (ig4_dump & (1 << unit)) { - ig4_dump &= ~(1 << unit); - ig4iic_dump(sc); - } - } - - /* - * Issue START or RESTART with next data byte, clear any previous - * abort condition that may have been holding the txfifo in reset. - */ - last = IG4_DATA_RESTART; - reg_read(sc, IG4_REG_CLR_TX_ABORT); - if (actualp) - *actualp = 0; - - /* - * Issue command if not told otherwise (smbus). - */ - if ((op & SMB_TRANS_NOCMD) == 0) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (error) - goto done; - last |= (u_char)cmd; - if (wcount == 0 && rcount == 0 && (op & SMB_TRANS_NOSTOP) == 0) - last |= IG4_DATA_STOP; - reg_write(sc, IG4_REG_DATA_CMD, last); - last = 0; - } - - /* - * Clean out any previously received data. - */ - if (sc->rpos != sc->rnext && - (op & SMB_TRANS_NOREPORT) == 0) { - device_printf(sc->dev, - "discarding %d bytes of spurious data\n", - sc->rnext - sc->rpos); - } - sc->rpos = 0; - sc->rnext = 0; - - /* - * If writing and not told otherwise, issue the write count (smbus). - */ - if (wcount && (op & SMB_TRANS_NOCNT) == 0) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (error) - goto done; - last |= (u_char)cmd; - reg_write(sc, IG4_REG_DATA_CMD, last); - last = 0; - } - - /* - * Bulk write (i2c) - */ - while (wcount) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (error) - goto done; - last |= (u_char)*wbuf; - if (wcount == 1 && rcount == 0 && (op & SMB_TRANS_NOSTOP) == 0) - last |= IG4_DATA_STOP; - reg_write(sc, IG4_REG_DATA_CMD, last); - --wcount; - ++wbuf; - last = 0; - } - - /* - * Issue reads to xmit FIFO (strange, I know) to tell the controller - * to clock in data. At the moment just issue one read ahead to - * pipeline the incoming data. - * - * NOTE: In the case of NOCMD and wcount == 0 we still issue a - * RESTART here, even if the data direction has not changed - * from the previous CHAINing call. This we force the RESTART. - * (A new START is issued automatically by the controller in - * the other nominal cases such as a data direction change or - * a previous STOP was issued). - * - * If this will be the last byte read we must also issue the STOP - * at the end of the read. - */ - if (rcount) { - last = IG4_DATA_RESTART | IG4_DATA_COMMAND_RD; - if (rcount == 1 && - (op & (SMB_TRANS_NOSTOP | SMB_TRANS_NOCNT)) == - SMB_TRANS_NOCNT) { - last |= IG4_DATA_STOP; - } - reg_write(sc, IG4_REG_DATA_CMD, last); - last = IG4_DATA_COMMAND_RD; - } - - /* - * Bulk read (i2c) and count field handling (smbus) - */ - while (rcount) { - /* - * Maintain a pipeline by queueing the allowance for the next - * read before waiting for the current read. - */ - if (rcount > 1) { - if (op & SMB_TRANS_NOCNT) - last = (rcount == 2) ? IG4_DATA_STOP : 0; - else - last = 0; - reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_COMMAND_RD | - last); - } - error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); - if (error) { - if ((op & SMB_TRANS_NOREPORT) == 0) { - device_printf(sc->dev, - "rx timeout addr 0x%02x\n", - sc->last_slave); - } - goto done; - } - last = data_read(sc); - - if (op & SMB_TRANS_NOCNT) { - *rbuf = (u_char)last; - ++rbuf; - --rcount; - if (actualp) - ++*actualp; - } else { - /* - * Handle count field (smbus), which is not part of - * the rcount'ed buffer. The first read data in a - * bulk transfer is the count. - * - * XXX if rcount is loaded as 0 how do I generate a - * STOP now without issuing another RD or WR? - */ - if (rcount > (u_char)last) - rcount = (u_char)last; - op |= SMB_TRANS_NOCNT; - } - } - error = 0; -done: - /* XXX wait for xmit buffer to become empty */ - last = reg_read(sc, IG4_REG_TX_ABRT_SOURCE); - - return (error); -} - -/* * IICBUS API FUNCTIONS */ static int ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave) { - /* XXX 10-bit address support? */ - set_slave_addr(sc, slave >> 1, 0); + set_slave_addr(sc, slave >> 1); return (0); } @@ -706,7 +504,7 @@ ig4iic_reset(device_t dev, u_char speed, /* TODO handle speed configuration? */ if (oldaddr != NULL) *oldaddr = sc->last_slave << 1; - set_slave_addr(sc, addr >> 1, 0); + set_slave_addr(sc, addr >> 1); if (addr == IIC_UNKNOWN) sc->slave_valid = false; @@ -716,8 +514,6 @@ ig4iic_reset(device_t dev, u_char speed, } /* - * SMBUS API FUNCTIONS - * * Called from ig4iic_pci_attach/detach() */ int @@ -836,7 +632,6 @@ ig4iic_start(void *xdev) config_intrhook_disestablish(&sc->enum_hook); - /* Attach us to the smbus */ error = bus_generic_attach(sc->dev); if (error) { device_printf(sc->dev, @@ -844,8 +639,6 @@ ig4iic_start(void *xdev) } } - - int ig4iic_detach(ig4iic_softc_t *sc) { @@ -874,276 +667,6 @@ ig4iic_detach(ig4iic_softc_t *sc) return (0); } -int -ig4iic_smb_callback(device_t dev, int index, void *data) -{ - int error; - - switch (index) { - case SMB_REQUEST_BUS: - error = 0; - break; - case SMB_RELEASE_BUS: - error = 0; - break; - default: - error = SMB_EABORT; - break; - } - - return (error); -} - -/* - * Quick command. i.e. START + cmd + R/W + STOP and no data. It is - * unclear to me how I could implement this with the intel i2c controller - * because the controller sends STARTs and STOPs automatically with data. - */ -int -ig4iic_smb_quick(device_t dev, u_char slave, int how) -{ - - return (SMB_ENOTSUPP); -} - -/* - * Incremental send byte without stop (?). It is unclear why the slave - * address is specified if this presumably is used in combination with - * ig4iic_smb_quick(). - * - * (Also, how would this work anyway? Issue the last byte with writeb()?) - */ -int -ig4iic_smb_sendb(device_t dev, u_char slave, char byte) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - uint32_t cmd; - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - cmd = byte; - if (wait_status(sc, IG4_STATUS_TX_NOTFULL) == 0) { - reg_write(sc, IG4_REG_DATA_CMD, cmd); - error = 0; - } else { - error = SMB_ETIMEOUT; - } - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * Incremental receive byte without stop (?). It is unclear why the slave - * address is specified if this presumably is used in combination with - * ig4iic_smb_quick(). - */ -int -ig4iic_smb_recvb(device_t dev, u_char slave, char *byte) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_COMMAND_RD); - if (wait_status(sc, IG4_STATUS_RX_NOTEMPTY) == 0) { - *byte = data_read(sc); - error = 0; - } else { - *byte = 0; - error = SMB_ETIMEOUT; - } - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * Write command and single byte in transaction. - */ -int -ig4iic_smb_writeb(device_t dev, u_char slave, char cmd, char byte) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT, - &byte, 1, NULL, 0, NULL); - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * Write command and single word in transaction. - */ -int -ig4iic_smb_writew(device_t dev, u_char slave, char cmd, short word) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - char buf[2]; - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - buf[0] = word & 0xFF; - buf[1] = word >> 8; - error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT, - buf, 2, NULL, 0, NULL); - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * write command and read single byte in transaction. - */ -int -ig4iic_smb_readb(device_t dev, u_char slave, char cmd, char *byte) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT, - NULL, 0, byte, 1, NULL); - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * write command and read word in transaction. - */ -int -ig4iic_smb_readw(device_t dev, u_char slave, char cmd, short *word) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - char buf[2]; - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - if ((error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT, - NULL, 0, buf, 2, NULL)) == 0) { - *word = (u_char)buf[0] | ((u_char)buf[1] << 8); - } - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -/* - * write command and word and read word in transaction - */ -int -ig4iic_smb_pcall(device_t dev, u_char slave, char cmd, - short sdata, short *rdata) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - char rbuf[2]; - char wbuf[2]; - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - wbuf[0] = sdata & 0xFF; - wbuf[1] = sdata >> 8; - if ((error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT, - wbuf, 2, rbuf, 2, NULL)) == 0) { - *rdata = (u_char)rbuf[0] | ((u_char)rbuf[1] << 8); - } - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -int -ig4iic_smb_bwrite(device_t dev, u_char slave, char cmd, - u_char wcount, char *buf) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - error = smb_transaction(sc, cmd, 0, - buf, wcount, NULL, 0, NULL); - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -int -ig4iic_smb_bread(device_t dev, u_char slave, char cmd, - u_char *countp_char, char *buf) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int rcount = *countp_char; - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, 0); - error = smb_transaction(sc, cmd, 0, - NULL, 0, buf, rcount, &rcount); - *countp_char = rcount; - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - -int -ig4iic_smb_trans(device_t dev, int slave, char cmd, int op, - char *wbuf, int wcount, char *rbuf, int rcount, - int *actualp) -{ - ig4iic_softc_t *sc = device_get_softc(dev); - int error; - - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); - - set_slave_addr(sc, slave, op); - error = smb_transaction(sc, cmd, op, - wbuf, wcount, rbuf, rcount, actualp); - - mtx_unlock(&sc->io_lock); - sx_xunlock(&sc->call_lock); - return (error); -} - /* * Interrupt Operation, see ig4_var.h for locking semantics. */ Modified: head/sys/dev/ichiic/ig4_pci.c ============================================================================== --- head/sys/dev/ichiic/ig4_pci.c Wed Nov 2 16:15:49 2016 (r308218) +++ head/sys/dev/ichiic/ig4_pci.c Wed Nov 2 17:04:00 2016 (r308219) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); /* - * Intel fourth generation mobile cpus integrated I2C device, smbus driver. + * Intel fourth generation mobile cpus integrated I2C device. * * See ig4_reg.h for datasheet reference and notes. */ @@ -59,11 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include -#include "smbus_if.h" - #include #include @@ -167,20 +164,6 @@ static device_method_t ig4iic_pci_method DEVMETHOD(device_attach, ig4iic_pci_attach), DEVMETHOD(device_detach, ig4iic_pci_detach), - /* SMBus methods from ig4_smb.c */ - DEVMETHOD(smbus_callback, ig4iic_smb_callback), - DEVMETHOD(smbus_quick, ig4iic_smb_quick), - DEVMETHOD(smbus_sendb, ig4iic_smb_sendb), - DEVMETHOD(smbus_recvb, ig4iic_smb_recvb), - DEVMETHOD(smbus_writeb, ig4iic_smb_writeb), - DEVMETHOD(smbus_writew, ig4iic_smb_writew), - DEVMETHOD(smbus_readb, ig4iic_smb_readb), - DEVMETHOD(smbus_readw, ig4iic_smb_readw), - DEVMETHOD(smbus_pcall, ig4iic_smb_pcall), - DEVMETHOD(smbus_bwrite, ig4iic_smb_bwrite), - DEVMETHOD(smbus_bread, ig4iic_smb_bread), - DEVMETHOD(smbus_trans, ig4iic_smb_trans), - DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), DEVMETHOD(iicbus_callback, iicbus_null_callback), @@ -199,6 +182,5 @@ static devclass_t ig4iic_pci_devclass; DRIVER_MODULE_ORDERED(ig4iic, pci, ig4iic_pci_driver, ig4iic_pci_devclass, 0, 0, SI_ORDER_ANY); MODULE_DEPEND(ig4iic, pci, 1, 1, 1); -MODULE_DEPEND(ig4iic, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); MODULE_DEPEND(ig4iic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); MODULE_VERSION(ig4iic, 1); Modified: head/sys/dev/ichiic/ig4_reg.h ============================================================================== --- head/sys/dev/ichiic/ig4_reg.h Wed Nov 2 16:15:49 2016 (r308218) +++ head/sys/dev/ichiic/ig4_reg.h Wed Nov 2 17:04:00 2016 (r308219) @@ -47,14 +47,14 @@ * I am also using the linux driver code as a reference to help resolve any * issues that come. These will be specifically documented in the code. * - * Please see protocol notes in section 5.21. This controller is an I2C - * master only and cannot act as a slave. The IO voltage should be set by - * the BIOS. Standard (100Kb/s) and Fast (400Kb/s) and fast mode plus - * (1MB/s) is supported. High speed mode (3.4 MB/s) is NOT supported. + * This controller is an I2C master only and cannot act as a slave. The IO + * voltage should be set by the BIOS. Standard (100Kb/s) and Fast (400Kb/s) + * and fast mode plus (1MB/s) is supported. High speed mode (3.4 MB/s) is NOT + * supported. */ -#ifndef _BUS_SMBUS_INTELGEN4_IG4_REG_H_ -#define _BUS_SMBUS_INTELGEN4_IG4_REG_H_ +#ifndef _ICHIIC_IG4_REG_H_ +#define _ICHIIC_IG4_REG_H_ /* * 22.2 MMIO registers can be accessed through BAR0 in PCI mode or through @@ -619,4 +619,4 @@ #define IG4_SWLTR_SNOOP_VALUE_DECODE(v) ((v) & 0x3F) #define IG4_SWLTR_SNOOP_VALUE_ENCODE(v) ((v) & 0x3F) -#endif +#endif /* _ICHIIC_IG4_REG_H_ */ Modified: head/sys/dev/ichiic/ig4_var.h ============================================================================== --- head/sys/dev/ichiic/ig4_var.h Wed Nov 2 16:15:49 2016 (r308218) +++ head/sys/dev/ichiic/ig4_var.h Wed Nov 2 17:04:00 2016 (r308219) @@ -35,13 +35,12 @@ * $FreeBSD$ */ -#ifndef _BUS_SMBUS_INTELGEN4_IG4_VAR_H_ -#define _BUS_SMBUS_INTELGEN4_IG4_VAR_H_ +#ifndef _ICHIIC_IG4_VAR_H_ +#define _ICHIIC_IG4_VAR_H_ #include "bus_if.h" #include "device_if.h" #include "pci_if.h" -#include "smbus_if.h" #include "iicbus_if.h" #define IG4_RBUFSIZE 128 @@ -75,12 +74,12 @@ struct ig4iic_softc { /* * Locking semantics: * - * Functions implementing the smbus interface that interact + * Functions implementing the icbus interface that interact * with the controller acquire an exclusive lock on call_lock * to prevent interleaving of calls to the interface and a lock on * io_lock right afterwards, to synchronize controller I/O activity. - * - * The interrupt handler can only read data while no ig4iic_smb_* call + * + * The interrupt handler can only read data while no iicbus call * is in progress or while io_lock is dropped during mtx_sleep in * wait_status and set_controller. It is safe to drop io_lock in those * places, because the interrupt handler only accesses those registers: @@ -91,7 +90,7 @@ struct ig4iic_softc { * * Locking outside of those places is required to make the content * of rpos/rnext predictable (e.g. whenever data_read is called and in - * smb_transaction). + * ig4iic_transfer). */ struct sx call_lock; struct mtx io_lock; @@ -103,20 +102,8 @@ typedef struct ig4iic_softc ig4iic_softc int ig4iic_attach(ig4iic_softc_t *sc); int ig4iic_detach(ig4iic_softc_t *sc); -/* SMBus methods */ -extern smbus_callback_t ig4iic_smb_callback; -extern smbus_quick_t ig4iic_smb_quick; -extern smbus_sendb_t ig4iic_smb_sendb; -extern smbus_recvb_t ig4iic_smb_recvb; -extern smbus_writeb_t ig4iic_smb_writeb; -extern smbus_writew_t ig4iic_smb_writew; -extern smbus_readb_t ig4iic_smb_readb; -extern smbus_readw_t ig4iic_smb_readw; -extern smbus_pcall_t ig4iic_smb_pcall; -extern smbus_bwrite_t ig4iic_smb_bwrite; -extern smbus_bread_t ig4iic_smb_bread; -extern smbus_trans_t ig4iic_smb_trans; +/* iicbus methods */ extern iicbus_transfer_t ig4iic_transfer; extern iicbus_reset_t ig4iic_reset; -#endif +#endif /* _ICHIIC_IG4_VAR_H_ */ From owner-svn-src-head@freebsd.org Wed Nov 2 17:07:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DCABC2C5F4; Wed, 2 Nov 2016 17:07:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D59E51CAC; Wed, 2 Nov 2016 17:07:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2H7I6G005150; Wed, 2 Nov 2016 17:07:18 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2H7I3w005149; Wed, 2 Nov 2016 17:07:18 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611021707.uA2H7I3w005149@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 2 Nov 2016 17:07:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308220 - head/sys/dev/smbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 17:07:20 -0000 Author: avg Date: Wed Nov 2 17:07:18 2016 New Revision: 308220 URL: https://svnweb.freebsd.org/changeset/base/308220 Log: smbus: remove the potentially very dangerous slave probing code MFC after: 5 weeks Modified: head/sys/dev/smbus/smbus.c Modified: head/sys/dev/smbus/smbus.c ============================================================================== --- head/sys/dev/smbus/smbus.c Wed Nov 2 17:04:00 2016 (r308219) +++ head/sys/dev/smbus/smbus.c Wed Nov 2 17:07:18 2016 (r308220) @@ -50,7 +50,6 @@ struct smbus_ivar /* * Autoconfiguration and support routines for System Management bus */ -static void smbus_probe_device(device_t dev, u_char addr); static int smbus_probe(device_t dev) @@ -65,13 +64,9 @@ static int smbus_attach(device_t dev) { struct smbus_softc *sc = device_get_softc(dev); - unsigned char addr; mtx_init(&sc->lock, device_get_nameunit(dev), "smbus", MTX_DEF); bus_generic_probe(dev); - for (addr = SMBUS_ADDR_MIN; addr < SMBUS_ADDR_MAX; ++addr) { - smbus_probe_device(dev, addr); - } bus_enumerate_hinted_children(dev); bus_generic_attach(dev); @@ -98,30 +93,6 @@ smbus_generic_intr(device_t dev, u_char { } -static void -smbus_probe_device(device_t dev, u_char addr) -{ - device_t child; - int error; - u_char cmd; - u_char buf[2]; - struct smbus_ivar *devi; - - cmd = 0x01; - error = smbus_trans(dev, addr, cmd, - SMB_TRANS_NOCNT | SMB_TRANS_NOREPORT, - NULL, 0, buf, 1, NULL); - if (error == 0) { - if (bootverbose) - device_printf(dev, "Probed address 0x%02x\n", addr); - child = BUS_ADD_CHILD(dev, SMBUS_ORDER_PNP, NULL, -1); - if (child == NULL) - return; - devi = device_get_ivars(child); - devi->addr = addr; - } -} - static device_t smbus_add_child(device_t dev, u_int order, const char *name, int unit) { From owner-svn-src-head@freebsd.org Wed Nov 2 17:12:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0A4BC2C804; Wed, 2 Nov 2016 17:12:17 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0889D1223; Wed, 2 Nov 2016 17:12:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2HCG6N008931; Wed, 2 Nov 2016 17:12:16 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2HCG3T008930; Wed, 2 Nov 2016 17:12:16 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611021712.uA2HCG3T008930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 2 Nov 2016 17:12:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308221 - head/sys/dev/ichiic X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 17:12:18 -0000 Author: avg Date: Wed Nov 2 17:12:15 2016 New Revision: 308221 URL: https://svnweb.freebsd.org/changeset/base/308221 Log: fix typo in a comment MFC after: 5 weeks X-MFC with: r308219 Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c ============================================================================== --- head/sys/dev/ichiic/ig4_iic.c Wed Nov 2 17:07:18 2016 (r308220) +++ head/sys/dev/ichiic/ig4_iic.c Wed Nov 2 17:12:15 2016 (r308221) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); /* - * Intel fourth generation mobile cpus integrated I2C deviceer. + * Intel fourth generation mobile cpus integrated I2C device. * * See ig4_reg.h for datasheet reference and notes. * See ig4_var.h for locking semantics. From owner-svn-src-head@freebsd.org Wed Nov 2 17:47:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B045FC2CE47; Wed, 2 Nov 2016 17:47:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6DEB11678; Wed, 2 Nov 2016 17:47:20 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2HlJTG020779; Wed, 2 Nov 2016 17:47:19 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2HlJOp020778; Wed, 2 Nov 2016 17:47:19 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611021747.uA2HlJOp020778@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 2 Nov 2016 17:47:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308225 - head/sys/dev/cpuctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 17:47:20 -0000 Author: avg Date: Wed Nov 2 17:47:19 2016 New Revision: 308225 URL: https://svnweb.freebsd.org/changeset/base/308225 Log: dev/cpuctl: put debug output under CPUCTL_DEBUG rather than DEBUG DEBUG is a well-known flag. It doesn't imply that there is a particular interest in cpuctl. MFC after: 1 week Modified: head/sys/dev/cpuctl/cpuctl.c Modified: head/sys/dev/cpuctl/cpuctl.c ============================================================================== --- head/sys/dev/cpuctl/cpuctl.c Wed Nov 2 17:34:33 2016 (r308224) +++ head/sys/dev/cpuctl/cpuctl.c Wed Nov 2 17:47:19 2016 (r308225) @@ -57,7 +57,7 @@ static d_ioctl_t cpuctl_ioctl; #define CPUCTL_VERSION 1 -#ifdef DEBUG +#ifdef CPUCTL_DEBUG # define DPRINTF(format,...) printf(format, __VA_ARGS__); #else # define DPRINTF(...) From owner-svn-src-head@freebsd.org Wed Nov 2 20:57:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9DB34C2BF91; Wed, 2 Nov 2016 20:57:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 591BB15EA; Wed, 2 Nov 2016 20:57:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2KvK5B093228; Wed, 2 Nov 2016 20:57:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2KvKIb093227; Wed, 2 Nov 2016 20:57:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611022057.uA2KvKIb093227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 2 Nov 2016 20:57:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308228 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 20:57:21 -0000 Author: kib Date: Wed Nov 2 20:57:20 2016 New Revision: 308228 URL: https://svnweb.freebsd.org/changeset/base/308228 Log: Remove remnants of the recursive sleep support. Instead assert that we never try to sleep while the thread is on a sleepqueue. Reviewed by: jhb Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8422 Modified: head/sys/kern/kern_synch.c Modified: head/sys/kern/kern_synch.c ============================================================================== --- head/sys/kern/kern_synch.c Wed Nov 2 19:18:24 2016 (r308227) +++ head/sys/kern/kern_synch.c Wed Nov 2 20:57:20 2016 (r308228) @@ -170,13 +170,7 @@ _sleep(void *ident, struct lock_object * catch = priority & PCATCH; pri = priority & PRIMASK; - /* - * If we are already on a sleep queue, then remove us from that - * sleep queue first. We have to do this to handle recursive - * sleeps. - */ - if (TD_ON_SLEEPQ(td)) - sleepq_remove(td, td->td_wchan); + KASSERT(!TD_ON_SLEEPQ(td), ("recursive sleep")); if ((uint8_t *)ident >= &pause_wchan[0] && (uint8_t *)ident <= &pause_wchan[MAXCPU - 1]) From owner-svn-src-head@freebsd.org Wed Nov 2 22:33:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1FD7DC2C2CA; Wed, 2 Nov 2016 22:33:39 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A77D91FFE; Wed, 2 Nov 2016 22:33:38 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2MXbKw031304; Wed, 2 Nov 2016 22:33:37 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2MXbFO031302; Wed, 2 Nov 2016 22:33:37 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201611022233.uA2MXbFO031302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Wed, 2 Nov 2016 22:33:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308229 - head/bin/sh/tests/execution X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 22:33:39 -0000 Author: jilles Date: Wed Nov 2 22:33:37 2016 New Revision: 308229 URL: https://svnweb.freebsd.org/changeset/base/308229 Log: sh: Add simple test for 'set -C' (noclobber). To ensure fast test runs, race conditions are not tested. Added: head/bin/sh/tests/execution/set-C1.0 (contents, props changed) Modified: head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/tests/execution/Makefile ============================================================================== --- head/bin/sh/tests/execution/Makefile Wed Nov 2 20:57:20 2016 (r308228) +++ head/bin/sh/tests/execution/Makefile Wed Nov 2 22:33:37 2016 (r308229) @@ -37,6 +37,7 @@ ${PACKAGE}FILES+= redir4.0 ${PACKAGE}FILES+= redir5.0 ${PACKAGE}FILES+= redir6.0 ${PACKAGE}FILES+= redir7.0 +${PACKAGE}FILES+= set-C1.0 ${PACKAGE}FILES+= set-n1.0 ${PACKAGE}FILES+= set-n2.0 ${PACKAGE}FILES+= set-n3.0 Added: head/bin/sh/tests/execution/set-C1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/sh/tests/execution/set-C1.0 Wed Nov 2 22:33:37 2016 (r308229) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit +trap 'rm -rf "$T"' 0 + +set -C +echo . >"$T/a" && +[ -s "$T/a" ] && +{ ! true >"$T/a"; } 2>/dev/null && +[ -s "$T/a" ] && +ln -s /dev/null "$T/b" && +true >"$T/b" From owner-svn-src-head@freebsd.org Wed Nov 2 23:18:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ECE3C2CD87; Wed, 2 Nov 2016 23:18:18 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BE341207; Wed, 2 Nov 2016 23:18:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NIGWI049357; Wed, 2 Nov 2016 23:18:16 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2NIGla049356; Wed, 2 Nov 2016 23:18:16 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201611022318.uA2NIGla049356@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Wed, 2 Nov 2016 23:18:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308230 - head/sys/dev/ioat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:18:18 -0000 Author: cem Date: Wed Nov 2 23:18:16 2016 New Revision: 308230 URL: https://svnweb.freebsd.org/changeset/base/308230 Log: ioat(4): Read CHANSTS register for suspended/halted checks The device doesn't accurately update the CHANCMP address with the device state when the device is suspended or halted. So, read the CHANSTS register to check for those states. We still need to read the CHANCMP address for the last completed descriptor. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Wed Nov 2 22:33:37 2016 (r308229) +++ head/sys/dev/ioat/ioat.c Wed Nov 2 23:18:16 2016 (r308230) @@ -747,6 +747,12 @@ out: wakeup(&ioat->tail); } + /* + * The device doesn't seem to reliably push suspend/halt statuses to + * the channel completion memory address, so poll the device register + * here. + */ + comp_update = ioat_get_chansts(ioat) & IOAT_CHANSTS_STATUS; if (!is_ioat_halted(comp_update) && !is_ioat_suspended(comp_update)) return; From owner-svn-src-head@freebsd.org Wed Nov 2 23:43:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB71FC2C2E5; Wed, 2 Nov 2016 23:43:19 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CC761E13; Wed, 2 Nov 2016 23:43:19 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NhIwr060656; Wed, 2 Nov 2016 23:43:18 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2NhI5E060655; Wed, 2 Nov 2016 23:43:18 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611022343.uA2NhI5E060655@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 23:43:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308231 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:43:20 -0000 Author: jhibbits Date: Wed Nov 2 23:43:18 2016 New Revision: 308231 URL: https://svnweb.freebsd.org/changeset/base/308231 Log: Fix the build. protctl is only used on powerpc. While here, remove the need to check the SVR SPR, as others may be compatible with the p1022-esdhc type. Replaced: head/sys/dev/sdhci/fsl_sdhci.c - copied, changed from r308095, head/sys/arm/freescale/imx/imx_sdhci.c Copied and modified: head/sys/dev/sdhci/fsl_sdhci.c (from r308095, head/sys/arm/freescale/imx/imx_sdhci.c) ============================================================================== --- head/sys/arm/freescale/imx/imx_sdhci.c Sat Oct 29 18:47:28 2016 (r308095, copy source) +++ head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 23:43:18 2016 (r308231) @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); /* - * SDHCI driver glue for Freescale i.MX SoC family. + * SDHCI driver glue for Freescale i.MX SoC and QorIQ families. * * This supports both eSDHC (earlier SoCs) and uSDHC (more recent SoCs). */ @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -52,9 +53,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __arm__ #include #include +#endif #include #include @@ -66,7 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include "sdhci_if.h" -struct imx_sdhci_softc { +struct fsl_sdhci_softc { device_t dev; struct resource * mem_res; struct resource * irq_res; @@ -88,8 +91,8 @@ struct imx_sdhci_softc { #define R1BFIX_AC12 2 /* Wait for busy after auto command 12. */ #define HWTYPE_NONE 0 /* Hardware not recognized/supported. */ -#define HWTYPE_ESDHC 1 /* imx5x and earlier. */ -#define HWTYPE_USDHC 2 /* imx6. */ +#define HWTYPE_ESDHC 1 /* fsl5x and earlier. */ +#define HWTYPE_USDHC 2 /* fsl6. */ /* * Freescale-specific registers, or in some cases the layout of bits within the @@ -146,7 +149,6 @@ struct imx_sdhci_softc { #define SDHC_PROT_CDSS (1 << 7) #define SDHC_SYS_CTRL 0x2c -#define SDHC_INT_STATUS 0x30 /* * The clock enable bits exist in different registers for ESDHC vs USDHC, but @@ -169,31 +171,32 @@ static struct ofw_compat_data compat_dat {"fsl,imx6sl-usdhc", HWTYPE_USDHC}, {"fsl,imx53-esdhc", HWTYPE_ESDHC}, {"fsl,imx51-esdhc", HWTYPE_ESDHC}, + {"fsl,esdhc", HWTYPE_ESDHC}, {NULL, HWTYPE_NONE}, }; -static uint16_t imx_sdhc_get_clock(struct imx_sdhci_softc *sc); -static void imx_sdhc_set_clock(struct imx_sdhci_softc *sc, uint16_t val); -static void imx_sdhci_r1bfix_func(void *arg); +static uint16_t fsl_sdhc_get_clock(struct fsl_sdhci_softc *sc); +static void fsl_sdhc_set_clock(struct fsl_sdhci_softc *sc, uint16_t val); +static void fsl_sdhci_r1bfix_func(void *arg); static inline uint32_t -RD4(struct imx_sdhci_softc *sc, bus_size_t off) +RD4(struct fsl_sdhci_softc *sc, bus_size_t off) { return (bus_read_4(sc->mem_res, off)); } static inline void -WR4(struct imx_sdhci_softc *sc, bus_size_t off, uint32_t val) +WR4(struct fsl_sdhci_softc *sc, bus_size_t off, uint32_t val) { bus_write_4(sc->mem_res, off, val); } static uint8_t -imx_sdhci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32, wrk32; /* @@ -246,9 +249,9 @@ imx_sdhci_read_1(device_t dev, struct sd } static uint16_t -imx_sdhci_read_2(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_2(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; if (sc->hwtype == HWTYPE_USDHC) { @@ -297,16 +300,16 @@ imx_sdhci_read_2(device_t dev, struct sd * hardware type, complex enough to have their own function. */ if (off == SDHCI_CLOCK_CONTROL) { - return (imx_sdhc_get_clock(sc)); + return (fsl_sdhc_get_clock(sc)); } return ((RD4(sc, off & ~3) >> (off & 3) * 8) & 0xffff); } static uint32_t -imx_sdhci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) +fsl_sdhci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32, wrk32; val32 = RD4(sc, off); @@ -348,7 +351,7 @@ imx_sdhci_read_4(device_t dev, struct sd } /* - * imx_sdhci_intr() can synthesize a DATA_END interrupt following a + * fsl_sdhci_intr() can synthesize a DATA_END interrupt following a * command with an R1B response, mix it into the hardware status. */ if (off == SDHCI_INT_STATUS) { @@ -359,18 +362,18 @@ imx_sdhci_read_4(device_t dev, struct sd } static void -imx_sdhci_read_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, +fsl_sdhci_read_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t *data, bus_size_t count) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); bus_read_multi_4(sc->mem_res, off, data, count); } static void -imx_sdhci_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint8_t val) +fsl_sdhci_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint8_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; /* @@ -397,6 +400,11 @@ imx_sdhci_write_1(device_t dev, struct s if (off == SDHCI_POWER_CONTROL) { return; } +#ifdef __powerpc__ + /* XXX Reset doesn't seem to work as expected. Do nothing for now. */ + if (off == SDHCI_SOFTWARE_RESET) + return; +#endif val32 = RD4(sc, off & ~3); val32 &= ~(0xff << (off & 3) * 8); @@ -406,9 +414,9 @@ imx_sdhci_write_1(device_t dev, struct s } static void -imx_sdhci_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint16_t val) +fsl_sdhci_write_2(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint16_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); uint32_t val32; /* @@ -416,7 +424,7 @@ imx_sdhci_write_2(device_t dev, struct s * that can handle the ESDHC versus USDHC differences. */ if (off == SDHCI_CLOCK_CONTROL) { - imx_sdhc_set_clock(sc, val); + fsl_sdhc_set_clock(sc, val); return; } @@ -432,7 +440,7 @@ imx_sdhci_write_2(device_t dev, struct s * there's a control bit for it (bit 3) in the vendor register. * When we're starting a command that needs a manual DAT0 line check at * interrupt time, we leave ourselves a note in r1bfix_type so that we - * can do the extra work in imx_sdhci_intr(). + * can do the extra work in fsl_sdhci_intr(). */ if (off == SDHCI_COMMAND_FLAGS) { if (val & SDHCI_CMD_DATA) { @@ -485,9 +493,9 @@ imx_sdhci_write_2(device_t dev, struct s } static void -imx_sdhci_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t val) +fsl_sdhci_write_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t val) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); /* Clear synthesized interrupts, then pass the value to the hardware. */ if (off == SDHCI_INT_STATUS) { @@ -498,16 +506,16 @@ imx_sdhci_write_4(device_t dev, struct s } static void -imx_sdhci_write_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, +fsl_sdhci_write_multi_4(device_t dev, struct sdhci_slot *slot, bus_size_t off, uint32_t *data, bus_size_t count) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); bus_write_multi_4(sc->mem_res, off, data, count); } static uint16_t -imx_sdhc_get_clock(struct imx_sdhci_softc *sc) +fsl_sdhc_get_clock(struct fsl_sdhci_softc *sc) { uint16_t val; @@ -531,17 +539,20 @@ imx_sdhc_get_clock(struct imx_sdhci_soft val |= SDHCI_CLOCK_INT_STABLE; /* - * On ESDHC hardware the card bus clock enable is in the usual sdhci - * register but it's a different bit, so transcribe it (note the + * On i.MX ESDHC hardware the card bus clock enable is in the usual + * sdhci register but it's a different bit, so transcribe it (note the * difference between standard SDHCI_ and Freescale SDHC_ prefixes - * here). On USDHC hardware there is a force-on bit, but no force-off - * for the card bus clock (the hardware runs the clock when transfers - * are active no matter what), so we always say the clock is on. + * here). On USDHC and QorIQ ESDHC hardware there is a force-on bit, but + * no force-off for the card bus clock (the hardware runs the clock when + * transfers are active no matter what), so we always say the clock is + * on. * XXX Maybe we should say it's in whatever state the sdhci driver last * set it to. */ if (sc->hwtype == HWTYPE_ESDHC) { +#ifdef __arm__ if (RD4(sc, SDHC_SYS_CTRL) & SDHC_CLK_SDCLKEN) +#endif val |= SDHCI_CLOCK_CARD_EN; } else { val |= SDHCI_CLOCK_CARD_EN; @@ -551,7 +562,7 @@ imx_sdhc_get_clock(struct imx_sdhci_soft } static void -imx_sdhc_set_clock(struct imx_sdhci_softc *sc, uint16_t val) +fsl_sdhc_set_clock(struct fsl_sdhci_softc *sc, uint16_t val) { uint32_t divisor, freq, prescale, val32; @@ -565,15 +576,18 @@ imx_sdhc_set_clock(struct imx_sdhci_soft sc->sdclockreg_freq_bits = val & SDHCI_DIVIDERS_MASK; if (sc->hwtype == HWTYPE_ESDHC) { /* - * The ESDHC hardware requires the driver to manually start and - * stop the sd bus clock. If the enable bit is not set, turn - * off the clock in hardware and we're done, otherwise decode - * the requested frequency. ESDHC hardware is sdhci 2.0; the - * sdhci driver will use the original 8-bit divisor field and - * the "base / 2^N" divisor scheme. + * The i.MX5 ESDHC hardware requires the driver to manually + * start and stop the sd bus clock. If the enable bit is not + * set, turn off the clock in hardware and we're done, otherwise + * decode the requested frequency. ESDHC hardware is sdhci 2.0; + * the sdhci driver will use the original 8-bit divisor field + * and the "base / 2^N" divisor scheme. */ if ((val & SDHCI_CLOCK_CARD_EN) == 0) { +#ifdef __arm__ + /* On QorIQ, this is a reserved bit. */ WR4(sc, SDHCI_CLOCK_CONTROL, val32 & ~SDHC_CLK_SDCLKEN); +#endif return; } @@ -625,11 +639,12 @@ imx_sdhc_set_clock(struct imx_sdhci_soft val32 &= ~(SDHC_CLK_DIVISOR_MASK | SDHC_CLK_PRESCALE_MASK); val32 |= divisor << SDHC_CLK_DIVISOR_SHIFT; val32 |= prescale << SDHC_CLK_PRESCALE_SHIFT; + val32 |= SDHC_CLK_IPGEN; WR4(sc, SDHCI_CLOCK_CONTROL, val32); } static boolean_t -imx_sdhci_r1bfix_is_wait_done(struct imx_sdhci_softc *sc) +fsl_sdhci_r1bfix_is_wait_done(struct fsl_sdhci_softc *sc) { uint32_t inhibit; @@ -646,7 +661,7 @@ imx_sdhci_r1bfix_is_wait_done(struct imx if (inhibit && getsbinuptime() < sc->r1bfix_timeout_at) { callout_reset_sbt(&sc->r1bfix_callout, SBT_1MS, 0, - imx_sdhci_r1bfix_func, sc, 0); + fsl_sdhci_r1bfix_func, sc, 0); return (false); } @@ -670,22 +685,22 @@ imx_sdhci_r1bfix_is_wait_done(struct imx } static void -imx_sdhci_r1bfix_func(void * arg) +fsl_sdhci_r1bfix_func(void * arg) { - struct imx_sdhci_softc *sc = arg; + struct fsl_sdhci_softc *sc = arg; boolean_t r1bwait_done; mtx_lock(&sc->slot.mtx); - r1bwait_done = imx_sdhci_r1bfix_is_wait_done(sc); + r1bwait_done = fsl_sdhci_r1bfix_is_wait_done(sc); mtx_unlock(&sc->slot.mtx); if (r1bwait_done) sdhci_generic_intr(&sc->slot); } static void -imx_sdhci_intr(void *arg) +fsl_sdhci_intr(void *arg) { - struct imx_sdhci_softc *sc = arg; + struct fsl_sdhci_softc *sc = arg; uint32_t intmask; mtx_lock(&sc->slot.mtx); @@ -710,10 +725,10 @@ imx_sdhci_intr(void *arg) */ switch (sc->r1bfix_type) { case R1BFIX_NODATA: - intmask = RD4(sc, SDHC_INT_STATUS) & SDHCI_INT_RESPONSE; + intmask = RD4(sc, SDHCI_INT_STATUS) & SDHCI_INT_RESPONSE; break; case R1BFIX_AC12: - intmask = RD4(sc, SDHC_INT_STATUS) & SDHCI_INT_DATA_END; + intmask = RD4(sc, SDHCI_INT_STATUS) & SDHCI_INT_DATA_END; break; default: intmask = 0; @@ -721,9 +736,9 @@ imx_sdhci_intr(void *arg) } if (intmask) { sc->r1bfix_timeout_at = getsbinuptime() + 250 * SBT_1MS; - if (!imx_sdhci_r1bfix_is_wait_done(sc)) { - WR4(sc, SDHC_INT_STATUS, intmask); - bus_barrier(sc->mem_res, SDHC_INT_STATUS, 4, + if (!fsl_sdhci_r1bfix_is_wait_done(sc)) { + WR4(sc, SDHCI_INT_STATUS, intmask); + bus_barrier(sc->mem_res, SDHCI_INT_STATUS, 4, BUS_SPACE_BARRIER_WRITE); } } @@ -733,31 +748,78 @@ imx_sdhci_intr(void *arg) } static int -imx_sdhci_get_ro(device_t bus, device_t child) +fsl_sdhci_get_ro(device_t bus, device_t child) { + struct fsl_sdhci_softc *sc = device_get_softc(bus); + + if (RD4(sc, SDHCI_PRESENT_STATE) & SDHC_PRES_WPSPL) + return (false); + return (true); +} + +#ifdef __powerpc__ +static uint32_t +fsl_sdhci_get_platform_clock(device_t dev) +{ + device_t parent; + phandle_t node; + uint32_t clock; + + node = ofw_bus_get_node(dev); - return (false); + /* Get sdhci node properties */ + if((OF_getprop(node, "clock-frequency", (void *)&clock, + sizeof(clock)) <= 0) || (clock == 0)) { + + /* + * Trying to get clock from parent device (soc) if correct + * clock cannot be acquired from sdhci node. + */ + parent = device_get_parent(dev); + node = ofw_bus_get_node(parent); + + /* Get soc properties */ + if ((OF_getprop(node, "bus-frequency", (void *)&clock, + sizeof(clock)) <= 0) || (clock == 0)) { + device_printf(dev,"Cannot acquire correct sdhci " + "frequency from DTS.\n"); + + return (0); + } + /* eSDHC clock is 1/2 platform clock. */ + clock /= 2; + } + + if (bootverbose) + device_printf(dev, "Acquired clock: %d from DTS\n", clock); + + return (clock); } +#endif + static int -imx_sdhci_detach(device_t dev) +fsl_sdhci_detach(device_t dev) { return (EBUSY); } static int -imx_sdhci_attach(device_t dev) +fsl_sdhci_attach(device_t dev) { - struct imx_sdhci_softc *sc = device_get_softc(dev); + struct fsl_sdhci_softc *sc = device_get_softc(dev); int rid, err; phandle_t node; +#ifdef __powerpc__ + uint32_t protctl; +#endif sc->dev = dev; sc->hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; if (sc->hwtype == HWTYPE_NONE) - panic("Impossible: not compatible in imx_sdhci_attach()"); + panic("Impossible: not compatible in fsl_sdhci_attach()"); rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, @@ -778,7 +840,7 @@ imx_sdhci_attach(device_t dev) } if (bus_setup_intr(dev, sc->irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, imx_sdhci_intr, sc, &sc->intr_cookie)) { + NULL, fsl_sdhci_intr, sc, &sc->intr_cookie)) { device_printf(dev, "cannot setup interrupt handler\n"); err = ENXIO; goto fail; @@ -807,9 +869,23 @@ imx_sdhci_attach(device_t dev) * * XXX need named constants for this stuff. */ - WR4(sc, SDHC_WTMK_LVL, 0x08800880); +#ifdef __powerpc__ + /* P1022 has the '*_BRST_LEN' fields as reserved, always reading 0x10 */ + if (ofw_bus_is_compatible(dev, "fsl,p1022-esdhc")) + WR4(sc, SDHC_WTMK_LVL, 0x10801080); + else +#endif + WR4(sc, SDHC_WTMK_LVL, 0x08800880); + /* + * We read in native byte order in the main driver, but the register + * defaults to little endian. + */ +#ifdef __powerpc__ + sc->baseclk_hz = fsl_sdhci_get_platform_clock(dev); +#else sc->baseclk_hz = imx_ccm_sdhci_hz(); +#endif sc->slot.max_clk = sc->baseclk_hz; /* @@ -830,6 +906,16 @@ imx_sdhci_attach(device_t dev) /* XXX put real gpio hookup here. */ sc->force_card_present = true; } +#ifdef __powerpc__ + /* Default to big-endian on powerpc */ + protctl = RD4(sc, SDHC_PROT_CTRL); + protctl &= ~SDHC_PROT_EMODE_MASK; + if (OF_hasprop(node, "little-endian")) + protctl |= SDHC_PROT_EMODE_LITTLE; + else + protctl |= SDHC_PROT_EMODE_BIG; + WR4(sc, SDHC_PROT_CTRL, protctl); +#endif callout_init(&sc->r1bfix_callout, 1); sdhci_init_slot(dev, &sc->slot, 0); @@ -853,7 +939,7 @@ fail: } static int -imx_sdhci_probe(device_t dev) +fsl_sdhci_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) @@ -872,11 +958,11 @@ imx_sdhci_probe(device_t dev) return (ENXIO); } -static device_method_t imx_sdhci_methods[] = { +static device_method_t fsl_sdhci_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, imx_sdhci_probe), - DEVMETHOD(device_attach, imx_sdhci_attach), - DEVMETHOD(device_detach, imx_sdhci_detach), + DEVMETHOD(device_probe, fsl_sdhci_probe), + DEVMETHOD(device_attach, fsl_sdhci_attach), + DEVMETHOD(device_detach, fsl_sdhci_detach), /* Bus interface */ DEVMETHOD(bus_read_ivar, sdhci_generic_read_ivar), @@ -886,32 +972,32 @@ static device_method_t imx_sdhci_methods /* MMC bridge interface */ DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), DEVMETHOD(mmcbr_request, sdhci_generic_request), - DEVMETHOD(mmcbr_get_ro, imx_sdhci_get_ro), + DEVMETHOD(mmcbr_get_ro, fsl_sdhci_get_ro), DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), /* SDHCI registers accessors */ - DEVMETHOD(sdhci_read_1, imx_sdhci_read_1), - DEVMETHOD(sdhci_read_2, imx_sdhci_read_2), - DEVMETHOD(sdhci_read_4, imx_sdhci_read_4), - DEVMETHOD(sdhci_read_multi_4, imx_sdhci_read_multi_4), - DEVMETHOD(sdhci_write_1, imx_sdhci_write_1), - DEVMETHOD(sdhci_write_2, imx_sdhci_write_2), - DEVMETHOD(sdhci_write_4, imx_sdhci_write_4), - DEVMETHOD(sdhci_write_multi_4, imx_sdhci_write_multi_4), + DEVMETHOD(sdhci_read_1, fsl_sdhci_read_1), + DEVMETHOD(sdhci_read_2, fsl_sdhci_read_2), + DEVMETHOD(sdhci_read_4, fsl_sdhci_read_4), + DEVMETHOD(sdhci_read_multi_4, fsl_sdhci_read_multi_4), + DEVMETHOD(sdhci_write_1, fsl_sdhci_write_1), + DEVMETHOD(sdhci_write_2, fsl_sdhci_write_2), + DEVMETHOD(sdhci_write_4, fsl_sdhci_write_4), + DEVMETHOD(sdhci_write_multi_4, fsl_sdhci_write_multi_4), { 0, 0 } }; -static devclass_t imx_sdhci_devclass; +static devclass_t fsl_sdhci_devclass; -static driver_t imx_sdhci_driver = { - "sdhci_imx", - imx_sdhci_methods, - sizeof(struct imx_sdhci_softc), +static driver_t fsl_sdhci_driver = { + "sdhci_fsl", + fsl_sdhci_methods, + sizeof(struct fsl_sdhci_softc), }; -DRIVER_MODULE(sdhci_imx, simplebus, imx_sdhci_driver, imx_sdhci_devclass, 0, 0); -MODULE_DEPEND(sdhci_imx, sdhci, 1, 1, 1); -DRIVER_MODULE(mmc, sdhci_imx, mmc_driver, mmc_devclass, NULL, NULL); -MODULE_DEPEND(sdhci_imx, mmc, 1, 1, 1); +DRIVER_MODULE(sdhci_fsl, simplebus, fsl_sdhci_driver, fsl_sdhci_devclass, 0, 0); +MODULE_DEPEND(sdhci_fsl, sdhci, 1, 1, 1); +DRIVER_MODULE(mmc, sdhci_fsl, mmc_driver, mmc_devclass, NULL, NULL); +MODULE_DEPEND(sdhci_fsl, mmc, 1, 1, 1); From owner-svn-src-head@freebsd.org Wed Nov 2 23:44:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F35B0C2C345; Wed, 2 Nov 2016 23:44:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D1ED13BC; Wed, 2 Nov 2016 23:44:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NiUVx060762; Wed, 2 Nov 2016 23:44:30 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2NiUk3060761; Wed, 2 Nov 2016 23:44:30 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201611022344.uA2NiUk3060761@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 2 Nov 2016 23:44:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308232 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:44:32 -0000 Author: jhibbits Date: Wed Nov 2 23:44:30 2016 New Revision: 308232 URL: https://svnweb.freebsd.org/changeset/base/308232 Log: Since it's no longer accessing a powerpc-specific register, drop the #ifdef. Modified: head/sys/dev/sdhci/fsl_sdhci.c Modified: head/sys/dev/sdhci/fsl_sdhci.c ============================================================================== --- head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 23:43:18 2016 (r308231) +++ head/sys/dev/sdhci/fsl_sdhci.c Wed Nov 2 23:44:30 2016 (r308232) @@ -869,12 +869,10 @@ fsl_sdhci_attach(device_t dev) * * XXX need named constants for this stuff. */ -#ifdef __powerpc__ /* P1022 has the '*_BRST_LEN' fields as reserved, always reading 0x10 */ if (ofw_bus_is_compatible(dev, "fsl,p1022-esdhc")) WR4(sc, SDHC_WTMK_LVL, 0x10801080); else -#endif WR4(sc, SDHC_WTMK_LVL, 0x08800880); /* From owner-svn-src-head@freebsd.org Wed Nov 2 23:46:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41772C2C3E3; Wed, 2 Nov 2016 23:46:25 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FAE21C96; Wed, 2 Nov 2016 23:46:23 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NkN1m060869; Wed, 2 Nov 2016 23:46:23 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2NkNg7060868; Wed, 2 Nov 2016 23:46:23 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201611022346.uA2NkNg7060868@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Wed, 2 Nov 2016 23:46:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308233 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:46:25 -0000 Author: jmcneill Date: Wed Nov 2 23:46:23 2016 New Revision: 308233 URL: https://svnweb.freebsd.org/changeset/base/308233 Log: The DTS may report fewer than 4 parents for a module clock. Avoid setting the module clock parent to an out-of-range index in these cases. Modified: head/sys/arm/allwinner/clk/aw_modclk.c Modified: head/sys/arm/allwinner/clk/aw_modclk.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_modclk.c Wed Nov 2 23:44:30 2016 (r308232) +++ head/sys/arm/allwinner/clk/aw_modclk.c Wed Nov 2 23:46:23 2016 (r308233) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #define SCLK_GATING (1 << 31) #define CLK_SRC_SEL (0x3 << 24) #define CLK_SRC_SEL_SHIFT 24 -#define CLK_SRC_SEL_MAX 0x3 #define CLK_RATIO_N (0x3 << 16) #define CLK_RATIO_N_SHIFT 16 #define CLK_RATIO_N_MAX 0x3 @@ -69,6 +68,7 @@ static struct ofw_compat_data compat_dat struct aw_modclk_sc { device_t clkdev; bus_addr_t reg; + u_int parent_cnt; }; #define MODCLK_READ(sc, val) CLKDEV_READ_4((sc)->clkdev, (sc)->reg, (val)) @@ -102,7 +102,7 @@ aw_modclk_set_mux(struct clknode *clk, i sc = clknode_get_softc(clk); - if (index < 0 || index > CLK_SRC_SEL_MAX) + if (index < 0 || index >= sc->parent_cnt) return (ERANGE); DEVICE_LOCK(sc); @@ -170,7 +170,7 @@ aw_modclk_set_freq(struct clknode *clk, best_diff = (int64_t)*fout; best_src = 0; - for (src = 0; src < CLK_SRC_SEL_MAX; src++) { + for (src = 0; src < sc->parent_cnt; src++) { error = clknode_set_parent_by_idx(clk, src); if (error != 0) continue; @@ -299,6 +299,7 @@ aw_modclk_attach(device_t dev) sc = clknode_get_softc(clk); sc->reg = paddr; sc->clkdev = device_get_parent(dev); + sc->parent_cnt = def.parent_cnt; clknode_register(clkdom, clk); From owner-svn-src-head@freebsd.org Wed Nov 2 23:49:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F631C2C4AC; Wed, 2 Nov 2016 23:49:59 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F15931CAF; Wed, 2 Nov 2016 23:49:58 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NnwN2061186; Wed, 2 Nov 2016 23:49:58 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2Nnweg061185; Wed, 2 Nov 2016 23:49:58 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201611022349.uA2Nnweg061185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Wed, 2 Nov 2016 23:49:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308234 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:49:59 -0000 Author: jmcneill Date: Wed Nov 2 23:49:57 2016 New Revision: 308234 URL: https://svnweb.freebsd.org/changeset/base/308234 Log: Add support for H3 PLL2 (PLL_Audio). Modified: head/sys/arm/allwinner/clk/aw_pll.c Modified: head/sys/arm/allwinner/clk/aw_pll.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_pll.c Wed Nov 2 23:46:23 2016 (r308233) +++ head/sys/arm/allwinner/clk/aw_pll.c Wed Nov 2 23:49:57 2016 (r308234) @@ -171,6 +171,15 @@ __FBSDID("$FreeBSD$"); #define A83T_PLLCPUX_POSTDIV_M (0x3 << 0) #define A83T_PLLCPUX_POSTDIV_M_SHIFT 0 +#define H3_PLL2_LOCK (1 << 28) +#define H3_PLL2_SDM_EN (1 << 24) +#define H3_PLL2_POST_DIV (0xf << 16) +#define H3_PLL2_POST_DIV_SHIFT 16 +#define H3_PLL2_FACTOR_N (0x7f << 8) +#define H3_PLL2_FACTOR_N_SHIFT 8 +#define H3_PLL2_PRE_DIV (0x1f << 0) +#define H3_PLL2_PRE_DIV_SHIFT 0 + #define CLKID_A10_PLL3_1X 0 #define CLKID_A10_PLL3_2X 1 @@ -278,6 +287,11 @@ static struct aw_pll_factor aw_a23_pll1_ PLLFACTOR(25, 2, 0, 0, 1872000000), }; +static struct aw_pll_factor aw_h3_pll2_factors[] = { + PLLFACTOR(13, 0, 0, 13, 24576000), + PLLFACTOR(6, 0, 0, 7, 22579200), +}; + enum aw_pll_type { AWPLL_A10_PLL1 = 1, AWPLL_A10_PLL2, @@ -292,6 +306,7 @@ enum aw_pll_type { AWPLL_A80_PLL4, AWPLL_A83T_PLLCPUX, AWPLL_H3_PLL1, + AWPLL_H3_PLL2, }; struct aw_pll_sc { @@ -698,6 +713,85 @@ a13_pll2_set_freq(struct aw_pll_sc *sc, } static int +h3_pll2_recalc(struct aw_pll_sc *sc, uint64_t *freq) +{ + uint32_t val, p, n, m; + + DEVICE_LOCK(sc); + PLL_READ(sc, &val); + DEVICE_UNLOCK(sc); + + p = ((val & H3_PLL2_POST_DIV) >> H3_PLL2_POST_DIV_SHIFT) + 1; + n = ((val & H3_PLL2_FACTOR_N) >> H3_PLL2_FACTOR_N_SHIFT) + 1; + m = ((val & H3_PLL2_PRE_DIV) >> H3_PLL2_PRE_DIV_SHIFT) + 1; + + switch (sc->id) { + case SUN4I_A10_PLL2_1X: + *freq = (*freq * n) / (m * p); + break; + case SUN4I_A10_PLL2_2X: + *freq = (*freq * 2 * n) / m / 4; + break; + case SUN4I_A10_PLL2_4X: + *freq = (*freq * 2 * n) / m / 2; + break; + case SUN4I_A10_PLL2_8X: + *freq = (*freq * 2 * n) / m; + break; + default: + return (EINVAL); + } + + return (0); +} + +static int +h3_pll2_set_freq(struct aw_pll_sc *sc, uint64_t fin, uint64_t *fout, + int flags) +{ + struct aw_pll_factor *f; + uint32_t val; + int n, error, retry; + + if (sc->id != SUN4I_A10_PLL2_1X) + return (ENXIO); + + f = NULL; + for (n = 0; n < nitems(aw_h3_pll2_factors); n++) { + if (aw_h3_pll2_factors[n].freq == *fout) { + f = &aw_h3_pll2_factors[n]; + break; + } + } + if (f == NULL) + return (EINVAL); + + DEVICE_LOCK(sc); + PLL_READ(sc, &val); + val &= ~(H3_PLL2_POST_DIV|H3_PLL2_FACTOR_N|H3_PLL2_PRE_DIV); + val |= (f->p << H3_PLL2_POST_DIV_SHIFT); + val |= (f->n << H3_PLL2_FACTOR_N_SHIFT); + val |= (f->m << H3_PLL2_PRE_DIV_SHIFT); + val |= AW_PLL_ENABLE; + PLL_WRITE(sc, val); + + /* Wait for lock */ + error = 0; + for (retry = 0; retry < 1000; retry++) { + PLL_READ(sc, &val); + if ((val & H3_PLL2_LOCK) != 0) + break; + DELAY(100); + } + if (retry == 0) + error = ETIMEDOUT; + + DEVICE_UNLOCK(sc); + + return (error); +} + +static int a23_pll1_set_freq(struct aw_pll_sc *sc, uint64_t fin, uint64_t *fout, int flags) { @@ -1006,6 +1100,7 @@ static struct aw_pll_funcs aw_pll_func[] PLL(AWPLL_A83T_PLLCPUX, a83t_pllcpux_recalc, a83t_pllcpux_set_freq, NULL), PLL(AWPLL_A64_PLLHSIC, a64_pllhsic_recalc, NULL, a64_pllhsic_init), PLL(AWPLL_H3_PLL1, a23_pll1_recalc, h3_pll1_set_freq, NULL), + PLL(AWPLL_H3_PLL2, h3_pll2_recalc, h3_pll2_set_freq, NULL), }; static struct ofw_compat_data compat_data[] = { @@ -1020,6 +1115,7 @@ static struct ofw_compat_data compat_dat { "allwinner,sun8i-a23-pll1-clk", AWPLL_A23_PLL1 }, { "allwinner,sun8i-a83t-pllcpux-clk", AWPLL_A83T_PLLCPUX }, { "allwinner,sun8i-h3-pll1-clk", AWPLL_H3_PLL1 }, + { "allwinner,sun8i-h3-pll2-clk", AWPLL_H3_PLL2 }, { "allwinner,sun9i-a80-pll4-clk", AWPLL_A80_PLL4 }, { "allwinner,sun50i-a64-pllhsic-clk", AWPLL_A64_PLLHSIC }, { NULL, 0 } From owner-svn-src-head@freebsd.org Wed Nov 2 23:53:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA754C2C5F5; Wed, 2 Nov 2016 23:53:48 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8AD141F52; Wed, 2 Nov 2016 23:53:48 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2Nrlsw064701; Wed, 2 Nov 2016 23:53:47 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2Nrl1Q064700; Wed, 2 Nov 2016 23:53:47 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201611022353.uA2Nrl1Q064700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Wed, 2 Nov 2016 23:53:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308235 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:53:49 -0000 Author: jmcneill Date: Wed Nov 2 23:53:47 2016 New Revision: 308235 URL: https://svnweb.freebsd.org/changeset/base/308235 Log: Register the device's xref handle at attach time. Modified: head/sys/arm/allwinner/a10_dmac.c Modified: head/sys/arm/allwinner/a10_dmac.c ============================================================================== --- head/sys/arm/allwinner/a10_dmac.c Wed Nov 2 23:49:57 2016 (r308234) +++ head/sys/arm/allwinner/a10_dmac.c Wed Nov 2 23:53:47 2016 (r308235) @@ -168,6 +168,7 @@ a10dmac_attach(device_t dev) return (ENXIO); } + OF_device_register_xref(OF_xref_from_node(ofw_bus_get_node(dev)), dev); return (0); } From owner-svn-src-head@freebsd.org Wed Nov 2 23:58:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CD28C2C870; Wed, 2 Nov 2016 23:58:12 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C52A611F6; Wed, 2 Nov 2016 23:58:11 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA2NwBAS064908; Wed, 2 Nov 2016 23:58:11 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA2NwANG064906; Wed, 2 Nov 2016 23:58:10 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201611022358.uA2NwANG064906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Wed, 2 Nov 2016 23:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308236 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Nov 2016 23:58:12 -0000 Author: jmcneill Date: Wed Nov 2 23:58:10 2016 New Revision: 308236 URL: https://svnweb.freebsd.org/changeset/base/308236 Log: Add support for the integrated DMA controller found in the Allwinner A31, A64, A83T, and H3 SoCs. Relnotes: yes Added: head/sys/arm/allwinner/a31_dmac.c (contents, props changed) Modified: head/sys/arm/allwinner/files.allwinner Added: head/sys/arm/allwinner/a31_dmac.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/allwinner/a31_dmac.c Wed Nov 2 23:58:10 2016 (r308236) @@ -0,0 +1,557 @@ +/*- + * Copyright (c) 2016 Jared D. McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* + * Allwinner DMA controller + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include "sunxi_dma_if.h" + +#define DMA_IRQ_EN_REG0 0x00 +#define DMA_IRQ_EN_REG1 0x04 +#define DMA_IRQ_EN_REG(ch) (DMA_IRQ_EN_REG0 + ((ch) / 8) * 4) +#define DMA_PKG_IRQ_EN(ch) (1 << (((ch) % 8) * 4 + 1)) +#define DMA_PKG_IRQ_MASK 0x2222222222222222ULL +#define DMA_IRQ_PEND_REG0 0x10 +#define DMA_IRQ_PEND_REG1 0x14 +#define DMA_IRQ_PEND_REG(ch) (DMA_IRQ_PEND_REG0 + ((ch) / 8) * 4) +#define DMA_STA_REG 0x30 +#define DMA_EN_REG(n) (0x100 + (n) * 0x40 + 0x00) +#define DMA_EN (1 << 0) +#define DMA_PAU_REG(n) (0x100 + (n) * 0x40 + 0x04) +#define DMA_STAR_ADDR_REG(n) (0x100 + (n) * 0x40 + 0x08) +#define DMA_CFG_REG(n) (0x100 + (n) * 0x40 + 0x0c) +#define DMA_DEST_DATA_WIDTH (0x3 << 25) +#define DMA_DEST_DATA_WIDTH_SHIFT 25 +#define DMA_DEST_BST_LEN (0x3 << 22) +#define DMA_DEST_BST_LEN_SHIFT 22 +#define DMA_DEST_ADDR_MODE (0x1 << 21) +#define DMA_DEST_ADDR_MODE_SHIFT 21 +#define DMA_DEST_DRQ_TYPE (0x1f << 16) +#define DMA_DEST_DRQ_TYPE_SHIFT 16 +#define DMA_SRC_DATA_WIDTH (0x3 << 9) +#define DMA_SRC_DATA_WIDTH_SHIFT 9 +#define DMA_SRC_BST_LEN (0x3 << 6) +#define DMA_SRC_BST_LEN_SHIFT 6 +#define DMA_SRC_ADDR_MODE (0x1 << 5) +#define DMA_SRC_ADDR_MODE_SHIFT 5 +#define DMA_SRC_DRQ_TYPE (0x1f << 0) +#define DMA_SRC_DRQ_TYPE_SHIFT 0 +#define DMA_DATA_WIDTH_8BIT 0 +#define DMA_DATA_WIDTH_16BIT 1 +#define DMA_DATA_WIDTH_32BIT 2 +#define DMA_DATA_WIDTH_64BIT 3 +#define DMA_ADDR_MODE_LINEAR 0 +#define DMA_ADDR_MODE_IO 1 +#define DMA_BST_LEN_1 0 +#define DMA_BST_LEN_4 1 +#define DMA_BST_LEN_8 2 +#define DMA_BST_LEN_16 3 +#define DMA_CUR_SRC_REG(n) (0x100 + (n) * 0x40 + 0x10) +#define DMA_CUR_DEST_REG(n) (0x100 + (n) * 0x40 + 0x14) +#define DMA_BCNT_LEFT_REG(n) (0x100 + (n) * 0x40 + 0x18) +#define DMA_PARA_REG(n) (0x100 + (n) * 0x40 + 0x1c) +#define WAIT_CYC (0xff << 0) +#define WAIT_CYC_SHIFT 0 + +struct a31dmac_desc { + uint32_t config; + uint32_t srcaddr; + uint32_t dstaddr; + uint32_t bcnt; + uint32_t para; + uint32_t next; +#define DMA_NULL 0xfffff800 +}; +#define DESC_ALIGN 4 +#define DESC_SIZE sizeof(struct a31dmac_desc) + +struct a31dmac_config { + u_int nchans; +}; + +static const struct a31dmac_config a31_config = { .nchans = 16 }; +static const struct a31dmac_config h3_config = { .nchans = 12 }; +static const struct a31dmac_config a83t_config = { .nchans = 8 }; +static const struct a31dmac_config a64_config = { .nchans = 8 }; + +static struct ofw_compat_data compat_data[] = { + { "allwinner,sun6i-a31-dma", (uintptr_t)&a31_config }, + { "allwinner,sun8i-a83t-dma", (uintptr_t)&a83t_config }, + { "allwinner,sun8i-h3-dma", (uintptr_t)&h3_config }, + { "allwinner,sun50i-a64-dma", (uintptr_t)&a64_config }, + { NULL, (uintptr_t)NULL } +}; + +struct a31dmac_softc; + +struct a31dmac_channel { + struct a31dmac_softc * sc; + uint8_t index; + void (*callback)(void *); + void * callbackarg; + + bus_dmamap_t dmamap; + struct a31dmac_desc *desc; + bus_addr_t physaddr; +}; + +struct a31dmac_softc { + struct resource * res[2]; + struct mtx mtx; + void * ih; + + bus_dma_tag_t dmat; + + u_int nchans; + struct a31dmac_channel * chans; +}; + +static struct resource_spec a31dmac_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +#define DMA_READ(sc, reg) bus_read_4((sc)->res[0], (reg)) +#define DMA_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val)) + +static void a31dmac_intr(void *); +static void a31dmac_dmamap_cb(void *, bus_dma_segment_t *, int, int); + +static int +a31dmac_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) + return (ENXIO); + + device_set_desc(dev, "Allwinner DMA controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +a31dmac_attach(device_t dev) +{ + struct a31dmac_softc *sc; + struct a31dmac_config *conf; + u_int index; + hwreset_t rst; + clk_t clk; + int error; + + sc = device_get_softc(dev); + conf = (void *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + clk = NULL; + rst = NULL; + + if (bus_alloc_resources(dev, a31dmac_spec, sc->res)) { + device_printf(dev, "cannot allocate resources for device\n"); + return (ENXIO); + } + + mtx_init(&sc->mtx, "a31 dmac", NULL, MTX_SPIN); + + /* Clock and reset setup */ + if (clk_get_by_ofw_index(dev, 0, 0, &clk) != 0) { + device_printf(dev, "cannot get clock\n"); + goto fail; + } + if (clk_enable(clk) != 0) { + device_printf(dev, "cannot enable clock\n"); + goto fail; + } + if (hwreset_get_by_ofw_idx(dev, 0, 0, &rst) != 0) { + device_printf(dev, "cannot get hwreset\n"); + goto fail; + } + if (hwreset_deassert(rst) != 0) { + device_printf(dev, "cannot de-assert reset\n"); + goto fail; + } + + /* Descriptor DMA */ + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* Parent tag */ + DESC_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + DESC_SIZE, 1, /* maxsize, nsegs */ + DESC_SIZE, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->dmat); + if (error != 0) { + device_printf(dev, "cannot create dma tag\n"); + goto fail; + } + + /* Disable all interrupts and clear pending status */ + DMA_WRITE(sc, DMA_IRQ_EN_REG0, 0); + DMA_WRITE(sc, DMA_IRQ_EN_REG1, 0); + DMA_WRITE(sc, DMA_IRQ_PEND_REG0, ~0); + DMA_WRITE(sc, DMA_IRQ_PEND_REG1, ~0); + + /* Initialize channels */ + sc->nchans = conf->nchans; + sc->chans = malloc(sizeof(*sc->chans) * sc->nchans, M_DEVBUF, + M_WAITOK | M_ZERO); + + for (index = 0; index < sc->nchans; index++) { + sc->chans[index].sc = sc; + sc->chans[index].index = index; + sc->chans[index].callback = NULL; + sc->chans[index].callbackarg = NULL; + + error = bus_dmamem_alloc(sc->dmat, + (void **)&sc->chans[index].desc, + BUS_DMA_WAITOK | BUS_DMA_COHERENT, + &sc->chans[index].dmamap); + if (error != 0) { + device_printf(dev, "cannot allocate dma mem\n"); + goto fail; + } + error = bus_dmamap_load(sc->dmat, sc->chans[index].dmamap, + sc->chans[index].desc, sizeof(*sc->chans[index].desc), + a31dmac_dmamap_cb, &sc->chans[index], BUS_DMA_WAITOK); + if (error != 0) { + device_printf(dev, "cannot load dma map\n"); + goto fail; + } + + DMA_WRITE(sc, DMA_EN_REG(index), 0); + } + + error = bus_setup_intr(dev, sc->res[1], INTR_MPSAFE | INTR_TYPE_MISC, + NULL, a31dmac_intr, sc, &sc->ih); + if (error != 0) { + device_printf(dev, "could not setup interrupt handler\n"); + bus_release_resources(dev, a31dmac_spec, sc->res); + mtx_destroy(&sc->mtx); + return (ENXIO); + } + + OF_device_register_xref(OF_xref_from_node(ofw_bus_get_node(dev)), dev); + return (0); + +fail: + for (index = 0; index < sc->nchans; index++) + if (sc->chans[index].desc != NULL) { + bus_dmamap_unload(sc->dmat, sc->chans[index].dmamap); + bus_dmamem_free(sc->dmat, sc->chans[index].desc, + sc->chans[index].dmamap); + } + if (sc->chans != NULL) + free(sc->chans, M_DEVBUF); + if (sc->ih != NULL) + bus_teardown_intr(dev, sc->res[1], sc->ih); + if (rst != NULL) + hwreset_release(rst); + if (clk != NULL) + clk_release(clk); + bus_release_resources(dev, a31dmac_spec, sc->res); + + return (ENXIO); +} + +static void +a31dmac_dmamap_cb(void *priv, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct a31dmac_channel *ch; + + if (error != 0) + return; + + ch = priv; + ch->physaddr = segs[0].ds_addr; +} + +static void +a31dmac_intr(void *priv) +{ + struct a31dmac_softc *sc; + uint32_t pend0, pend1, bit; + uint64_t pend, mask; + u_int index; + + sc = priv; + pend0 = DMA_READ(sc, DMA_IRQ_PEND_REG0); + pend1 = sc->nchans > 8 ? DMA_READ(sc, DMA_IRQ_PEND_REG1) : 0; + if (pend0 == 0 && pend1 == 0) + return; + + if (pend0 != 0) + DMA_WRITE(sc, DMA_IRQ_PEND_REG0, pend0); + if (pend1 != 0) + DMA_WRITE(sc, DMA_IRQ_PEND_REG1, pend1); + + pend = pend0 | ((uint64_t)pend1 << 32); + + while ((bit = ffsll(pend & DMA_PKG_IRQ_MASK)) != 0) { + mask = (1U << (bit - 1)); + pend &= ~mask; + index = (bit - 1) / 4; + + if (index >= sc->nchans) + continue; + if (sc->chans[index].callback == NULL) + continue; + sc->chans[index].callback(sc->chans[index].callbackarg); + } +} + +static int +a31dmac_set_config(device_t dev, void *priv, const struct sunxi_dma_config *cfg) +{ + struct a31dmac_channel *ch; + uint32_t config, para; + unsigned int dst_dw, dst_bl, dst_wc, dst_am; + unsigned int src_dw, src_bl, src_wc, src_am; + + ch = priv; + + switch (cfg->dst_width) { + case 8: + dst_dw = DMA_DATA_WIDTH_8BIT; + break; + case 16: + dst_dw = DMA_DATA_WIDTH_16BIT; + break; + case 32: + dst_dw = DMA_DATA_WIDTH_32BIT; + break; + case 64: + dst_dw = DMA_DATA_WIDTH_64BIT; + break; + default: + return (EINVAL); + } + switch (cfg->dst_burst_len) { + case 1: + dst_bl = DMA_BST_LEN_1; + break; + case 4: + dst_bl = DMA_BST_LEN_4; + break; + case 8: + dst_bl = DMA_BST_LEN_8; + break; + case 16: + dst_bl = DMA_BST_LEN_16; + break; + default: + return (EINVAL); + } + switch (cfg->src_width) { + case 8: + src_dw = DMA_DATA_WIDTH_8BIT; + break; + case 16: + src_dw = DMA_DATA_WIDTH_16BIT; + break; + case 32: + src_dw = DMA_DATA_WIDTH_32BIT; + break; + case 64: + src_dw = DMA_DATA_WIDTH_64BIT; + default: + return (EINVAL); + } + switch (cfg->src_burst_len) { + case 1: + src_bl = DMA_BST_LEN_1; + break; + case 4: + src_bl = DMA_BST_LEN_4; + break; + case 8: + src_bl = DMA_BST_LEN_8; + break; + case 16: + src_bl = DMA_BST_LEN_16; + break; + default: + return (EINVAL); + } + dst_am = cfg->dst_noincr ? DMA_ADDR_MODE_IO : DMA_ADDR_MODE_LINEAR; + src_am = cfg->src_noincr ? DMA_ADDR_MODE_IO : DMA_ADDR_MODE_LINEAR; + dst_wc = cfg->dst_wait_cyc; + src_wc = cfg->src_wait_cyc; + if (dst_wc != src_wc) + return (EINVAL); + + config = (dst_dw << DMA_DEST_DATA_WIDTH_SHIFT) | + (dst_bl << DMA_DEST_BST_LEN_SHIFT) | + (dst_am << DMA_DEST_ADDR_MODE_SHIFT) | + (cfg->dst_drqtype << DMA_DEST_DRQ_TYPE_SHIFT) | + (src_dw << DMA_SRC_DATA_WIDTH_SHIFT) | + (src_bl << DMA_SRC_BST_LEN_SHIFT) | + (src_am << DMA_SRC_ADDR_MODE_SHIFT) | + (cfg->src_drqtype << DMA_SRC_DRQ_TYPE_SHIFT); + para = (dst_wc << WAIT_CYC_SHIFT); + + ch->desc->config = htole32(config); + ch->desc->para = htole32(para); + + return (0); +} + +static void * +a31dmac_alloc(device_t dev, bool dedicated, void (*cb)(void *), void *cbarg) +{ + struct a31dmac_softc *sc; + struct a31dmac_channel *ch; + uint32_t irqen; + u_int index; + + sc = device_get_softc(dev); + ch = NULL; + + mtx_lock_spin(&sc->mtx); + for (index = 0; index < sc->nchans; index++) { + if (sc->chans[index].callback == NULL) { + ch = &sc->chans[index]; + ch->callback = cb; + ch->callbackarg = cbarg; + + irqen = DMA_READ(sc, DMA_IRQ_EN_REG(index)); + irqen |= DMA_PKG_IRQ_EN(index); + DMA_WRITE(sc, DMA_IRQ_EN_REG(index), irqen); + break; + } + } + mtx_unlock_spin(&sc->mtx); + + return (ch); +} + +static void +a31dmac_free(device_t dev, void *priv) +{ + struct a31dmac_channel *ch; + struct a31dmac_softc *sc; + uint32_t irqen; + u_int index; + + ch = priv; + sc = ch->sc; + index = ch->index; + + mtx_lock_spin(&sc->mtx); + + irqen = DMA_READ(sc, DMA_IRQ_EN_REG(index)); + irqen &= ~DMA_PKG_IRQ_EN(index); + DMA_WRITE(sc, DMA_IRQ_EN_REG(index), irqen); + DMA_WRITE(sc, DMA_IRQ_PEND_REG(index), DMA_PKG_IRQ_EN(index)); + + ch->callback = NULL; + ch->callbackarg = NULL; + + mtx_unlock_spin(&sc->mtx); +} + +static int +a31dmac_transfer(device_t dev, void *priv, bus_addr_t src, bus_addr_t dst, + size_t nbytes) +{ + struct a31dmac_channel *ch; + struct a31dmac_softc *sc; + + ch = priv; + sc = ch->sc; + + ch->desc->srcaddr = htole32((uint32_t)src); + ch->desc->dstaddr = htole32((uint32_t)dst); + ch->desc->bcnt = htole32(nbytes); + ch->desc->next = htole32(DMA_NULL); + + DMA_WRITE(sc, DMA_STAR_ADDR_REG(ch->index), (uint32_t)ch->physaddr); + DMA_WRITE(sc, DMA_EN_REG(ch->index), DMA_EN); + + return (0); +} + +static void +a31dmac_halt(device_t dev, void *priv) +{ + struct a31dmac_channel *ch; + struct a31dmac_softc *sc; + + ch = priv; + sc = ch->sc; + + DMA_WRITE(sc, DMA_EN_REG(ch->index), 0); +} + +static device_method_t a31dmac_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, a31dmac_probe), + DEVMETHOD(device_attach, a31dmac_attach), + + /* sunxi DMA interface */ + DEVMETHOD(sunxi_dma_alloc, a31dmac_alloc), + DEVMETHOD(sunxi_dma_free, a31dmac_free), + DEVMETHOD(sunxi_dma_set_config, a31dmac_set_config), + DEVMETHOD(sunxi_dma_transfer, a31dmac_transfer), + DEVMETHOD(sunxi_dma_halt, a31dmac_halt), + + DEVMETHOD_END +}; + +static driver_t a31dmac_driver = { + "a31dmac", + a31dmac_methods, + sizeof(struct a31dmac_softc) +}; + +static devclass_t a31dmac_devclass; + +DRIVER_MODULE(a31dmac, simplebus, a31dmac_driver, a31dmac_devclass, 0, 0); Modified: head/sys/arm/allwinner/files.allwinner ============================================================================== --- head/sys/arm/allwinner/files.allwinner Wed Nov 2 23:53:47 2016 (r308235) +++ head/sys/arm/allwinner/files.allwinner Wed Nov 2 23:58:10 2016 (r308236) @@ -5,6 +5,7 @@ arm/allwinner/a10_ahci.c optional ahci arm/allwinner/a10_codec.c optional sound arm/allwinner/a10_common.c standard arm/allwinner/a10_dmac.c standard +arm/allwinner/a31_dmac.c standard arm/allwinner/a10_ehci.c optional ehci arm/allwinner/aw_usbphy.c optional ehci arm/allwinner/a10_gpio.c optional gpio From owner-svn-src-head@freebsd.org Thu Nov 3 00:27:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57CE6C2B0CC; Thu, 3 Nov 2016 00:27:00 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0061C1CDC; Thu, 3 Nov 2016 00:26:59 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA30Qx0F076992; Thu, 3 Nov 2016 00:26:59 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA30QxOd076991; Thu, 3 Nov 2016 00:26:59 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201611030026.uA30QxOd076991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Thu, 3 Nov 2016 00:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308237 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 00:27:00 -0000 Author: loos Date: Thu Nov 3 00:26:58 2016 New Revision: 308237 URL: https://svnweb.freebsd.org/changeset/base/308237 Log: Remove the mbuf tag after use (for reinjected packets). Fixes the packet processing in dummynet l2 rules. Obtained from: pfSense MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c Modified: head/sys/netpfil/ipfw/ip_fw_pfil.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_pfil.c Wed Nov 2 23:58:10 2016 (r308236) +++ head/sys/netpfil/ipfw/ip_fw_pfil.c Thu Nov 3 00:26:58 2016 (r308237) @@ -315,20 +315,15 @@ ipfw_check_frame(void *arg, struct mbuf struct ip_fw_args args; struct m_tag *mtag; - /* fetch start point from rule, if any */ + /* fetch start point from rule, if any. remove the tag if present. */ mtag = m_tag_locate(*m0, MTAG_IPFW_RULE, 0, NULL); if (mtag == NULL) { args.rule.slot = 0; } else { - /* dummynet packet, already partially processed */ - struct ipfw_rule_ref *r; - - /* XXX can we free it after use ? */ - mtag->m_tag_id = PACKET_TAG_NONE; - r = (struct ipfw_rule_ref *)(mtag + 1); - if (r->info & IPFW_ONEPASS) + args.rule = *((struct ipfw_rule_ref *)(mtag+1)); + m_tag_delete(*m0, mtag); + if (args.rule.info & IPFW_ONEPASS) return (0); - args.rule = *r; } /* I need some amt of data to be contiguous */ From owner-svn-src-head@freebsd.org Thu Nov 3 00:57:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23DEBC2B994; Thu, 3 Nov 2016 00:57:01 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAEE9143A; Thu, 3 Nov 2016 00:57:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA30uxxu088892; Thu, 3 Nov 2016 00:56:59 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA30uxYI088890; Thu, 3 Nov 2016 00:56:59 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201611030056.uA30uxYI088890@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Thu, 3 Nov 2016 00:56:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308240 - head/sys/dev/atkbdc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 00:57:01 -0000 Author: gonzo Date: Thu Nov 3 00:56:59 2016 New Revision: 308240 URL: https://svnweb.freebsd.org/changeset/base/308240 Log: [evdev] Add evdev support to atkbd(4) driver To enable event sourcing from atkbd kern.evdev.rcpt_mask value should have bit 3 set. Submitted by: Vladimir Kondratiev MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8381 Modified: head/sys/dev/atkbdc/atkbd.c head/sys/dev/atkbdc/atkbd_atkbdc.c Modified: head/sys/dev/atkbdc/atkbd.c ============================================================================== --- head/sys/dev/atkbdc/atkbd.c Thu Nov 3 00:50:20 2016 (r308239) +++ head/sys/dev/atkbdc/atkbd.c Thu Nov 3 00:56:59 2016 (r308240) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" #include "opt_kbd.h" #include "opt_atkbd.h" +#include "opt_evdev.h" #include #include @@ -49,6 +50,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + typedef struct atkbd_state { KBDC kbdc; /* keyboard controller */ int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ @@ -60,6 +66,10 @@ typedef struct atkbd_state { u_int ks_composed_char; /* composed char code (> 0) */ u_char ks_prefix; /* AT scan code prefix */ struct callout ks_timer; +#ifdef EVDEV_SUPPORT + struct evdev_dev *ks_evdev; + int ks_evdev_state; +#endif } atkbd_state_t; static void atkbd_timeout(void *arg); @@ -72,6 +82,11 @@ static int atkbd_reset(KBDC kbdc, int f #define DEFAULT_DELAY 0x1 /* 500ms */ #define DEFAULT_RATE 0x10 /* 14Hz */ +#ifdef EVDEV_SUPPORT +#define PS2_KEYBOARD_VENDOR 1 +#define PS2_KEYBOARD_PRODUCT 1 +#endif + int atkbd_probe_unit(device_t dev, int irq, int flags) { @@ -250,6 +265,12 @@ static int typematic(int delay, int rat static int typematic_delay(int delay); static int typematic_rate(int rate); +#ifdef EVDEV_SUPPORT +static const struct evdev_methods atkbd_evdev_methods = { + .ev_event = evdev_ev_kbd_event, +}; +#endif + /* local variables */ /* the initial key map, accent map and fkey strings */ @@ -352,6 +373,10 @@ atkbd_init(int unit, keyboard_t **kbdp, int delay[2]; int *data = (int *)arg; /* data[0]: controller, data[1]: irq */ int error, needfree; +#ifdef EVDEV_SUPPORT + struct evdev_dev *evdev; + char phys_loc[8]; +#endif /* XXX */ if (unit == ATKBD_DEFAULT) { @@ -436,6 +461,34 @@ atkbd_init(int unit, keyboard_t **kbdp, delay[0] = kbd->kb_delay1; delay[1] = kbd->kb_delay2; atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay); + +#ifdef EVDEV_SUPPORT + /* register as evdev provider on first init */ + if (state->ks_evdev == NULL) { + snprintf(phys_loc, sizeof(phys_loc), "atkbd%d", unit); + evdev = evdev_alloc(); + evdev_set_name(evdev, "AT keyboard"); + evdev_set_phys(evdev, phys_loc); + evdev_set_id(evdev, BUS_I8042, PS2_KEYBOARD_VENDOR, + PS2_KEYBOARD_PRODUCT, 0); + evdev_set_methods(evdev, kbd, &atkbd_evdev_methods); + evdev_support_event(evdev, EV_SYN); + evdev_support_event(evdev, EV_KEY); + evdev_support_event(evdev, EV_LED); + evdev_support_event(evdev, EV_REP); + evdev_support_all_known_keys(evdev); + evdev_support_led(evdev, LED_NUML); + evdev_support_led(evdev, LED_CAPSL); + evdev_support_led(evdev, LED_SCROLLL); + + if (evdev_register(evdev)) + evdev_free(evdev); + else + state->ks_evdev = evdev; + state->ks_evdev_state = 0; + } +#endif + KBD_INIT_DONE(kbd); } if (!KBD_IS_CONFIGURED(kbd)) { @@ -620,6 +673,20 @@ next_code: printf("atkbd_read_char(): scancode:0x%x\n", scancode); #endif +#ifdef EVDEV_SUPPORT + /* push evdev event */ + if (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD && state->ks_evdev != NULL) { + keycode = evdev_scancode2key(&state->ks_evdev_state, + scancode); + + if (keycode != KEY_RESERVED) { + evdev_push_event(state->ks_evdev, EV_KEY, + (uint16_t)keycode, scancode & 0x80 ? 0 : 1); + evdev_sync(state->ks_evdev); + } + } +#endif + /* return the byte as is for the K_RAW mode */ if (state->ks_mode == K_RAW) return scancode; @@ -930,6 +997,12 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, return error; } } +#ifdef EVDEV_SUPPORT + /* push LED states to evdev */ + if (state->ks_evdev != NULL && + evdev_rcpt_mask & EVDEV_RCPT_HW_KBD) + evdev_push_leds(state->ks_evdev, *(int *)arg); +#endif KBD_LED_VAL(kbd) = *(int *)arg; break; @@ -963,6 +1036,11 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, if (error == 0) { kbd->kb_delay1 = typematic_delay(i); kbd->kb_delay2 = typematic_rate(i); +#ifdef EVDEV_SUPPORT + if (state->ks_evdev != NULL && + evdev_rcpt_mask & EVDEV_RCPT_HW_KBD) + evdev_push_repeats(state->ks_evdev, kbd); +#endif } return error; @@ -981,6 +1059,11 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, if (error == 0) { kbd->kb_delay1 = typematic_delay(*(int *)arg); kbd->kb_delay2 = typematic_rate(*(int *)arg); +#ifdef EVDEV_SUPPORT + if (state->ks_evdev != NULL && + evdev_rcpt_mask & EVDEV_RCPT_HW_KBD) + evdev_push_repeats(state->ks_evdev, kbd); +#endif } return error; Modified: head/sys/dev/atkbdc/atkbd_atkbdc.c ============================================================================== --- head/sys/dev/atkbdc/atkbd_atkbdc.c Thu Nov 3 00:50:20 2016 (r308239) +++ head/sys/dev/atkbdc/atkbd_atkbdc.c Thu Nov 3 00:56:59 2016 (r308240) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include "opt_kbd.h" +#include "opt_evdev.h" #include #include @@ -169,3 +170,6 @@ atkbdintr(void *arg) } DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(atkbd, evdev, 1, 1, 1); +#endif From owner-svn-src-head@freebsd.org Thu Nov 3 07:40:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3D4BFC2D057; Thu, 3 Nov 2016 07:40:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D94841D00; Thu, 3 Nov 2016 07:40:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA37erTA046403; Thu, 3 Nov 2016 07:40:53 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA37eqGq046397; Thu, 3 Nov 2016 07:40:52 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611030740.uA37eqGq046397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 3 Nov 2016 07:40:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308242 - in head: share/man/man4 sys/dev/smbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 07:40:54 -0000 Author: avg Date: Thu Nov 3 07:40:52 2016 New Revision: 308242 URL: https://svnweb.freebsd.org/changeset/base/308242 Log: smbus: remove smbus_trans / SMB_TRANS This change reverts most of r281985. The method did not map to anything defined by SMBus protocol and could not be implemented for SMBus controllers. This change is obviously not backwards compatible, but I have good reasons to believe that there have never been any users of SMB_TRANS. Discussed with: grembo, jhb MFC after: 6 weeks Modified: head/share/man/man4/smb.4 head/sys/dev/smbus/smb.c head/sys/dev/smbus/smb.h head/sys/dev/smbus/smbconf.h head/sys/dev/smbus/smbus_if.m Modified: head/share/man/man4/smb.4 ============================================================================== --- head/share/man/man4/smb.4 Thu Nov 3 00:58:50 2016 (r308241) +++ head/share/man/man4/smb.4 Thu Nov 3 07:40:52 2016 (r308242) @@ -162,33 +162,6 @@ to the device, then reads bytes of data that from the device. This data is returned in the buffer pointed to by .Fa rbuf . -.It Dv SMB_TRANS Ta -.Em Trans -sends an SMB roll-up transaction with flags that also allow it to -be used for (mostly) I2C pass-through and with 10-bit addresses. -This function can be utilized to roll up all of the above functions. -It first sends the byte from -.Fa cmd -to the device, followed by -.Fa wcount -bytes of data that are taken from the buffer pointed to by -.Fa wbuf , -then reads -.Fa rcount -bytes of data that from the device. -This data is returned in the buffer pointed to by -.Fa rbuf . -.Pp -The following flags are allowed in -.Fa op : -.Pp -.Bd -literal -compact -SMB_TRANS_NOSTOP Do not send STOP at end -SMB_TRANS_NOCMD Ignore cmd field (do not tx) -SMB_TRANS_NOCNT Do not tx or rx count field -SMB_TRANS_7BIT Change address mode to 7-bit -SMB_TRANS_10BIT Change address mode to 10-bit -.Ed .El .Pp The Modified: head/sys/dev/smbus/smb.c ============================================================================== --- head/sys/dev/smbus/smb.c Thu Nov 3 00:58:50 2016 (r308241) +++ head/sys/dev/smbus/smb.c Thu Nov 3 07:40:52 2016 (r308242) @@ -293,24 +293,6 @@ smbioctl(struct cdev *dev, u_long cmd, c error = copyout(buf, s->rbuf, s->rcount); break; - case SMB_TRANS: - if (s->rcount < 0 || s->wcount < 0) { - error = EINVAL; - break; - } - if (s->rcount > SMB_MAXBLOCKSIZE) - s->rcount = SMB_MAXBLOCKSIZE; - if (s->wcount > SMB_MAXBLOCKSIZE) - s->wcount = SMB_MAXBLOCKSIZE; - if (s->wcount) - error = copyin(s->wbuf, buf, s->wcount); - if (error) - break; - error = smbus_error(smbus_trans(parent, s->slave, s->cmd, - s->op, buf, s->wcount, buf, s->rcount, &s->rcount)); - if (error == 0) - error = copyout(buf, s->rbuf, s->rcount); - break; default: error = ENOTTY; } Modified: head/sys/dev/smbus/smb.h ============================================================================== --- head/sys/dev/smbus/smb.h Thu Nov 3 00:58:50 2016 (r308241) +++ head/sys/dev/smbus/smb.h Thu Nov 3 07:40:52 2016 (r308242) @@ -54,11 +54,8 @@ struct smbcmd { /* * SMBus spec 2.0 says block transfers may be at most 32 bytes. - * We use SMBus for i2c as well, make the size limit something more - * reasonable. Keep in mind that a char buf array is declared on the - * kernel stack. */ -#define SMB_MAXBLOCKSIZE 1024 +#define SMB_MAXBLOCKSIZE 32 #define SMB_QUICK_WRITE _IOW('i', 1, struct smbcmd) #define SMB_QUICK_READ _IOW('i', 2, struct smbcmd) @@ -72,6 +69,6 @@ struct smbcmd { #define SMB_BWRITE _IOW('i', 10, struct smbcmd) #define SMB_OLD_BREAD _IOW('i', 11, struct smbcmd) #define SMB_BREAD _IOWR('i', 11, struct smbcmd) -#define SMB_TRANS _IOWR('i', 12, struct smbcmd) +#define SMB_OLD_TRANS _IOWR('i', 12, struct smbcmd) #endif Modified: head/sys/dev/smbus/smbconf.h ============================================================================== --- head/sys/dev/smbus/smbconf.h Thu Nov 3 00:58:50 2016 (r308241) +++ head/sys/dev/smbus/smbconf.h Thu Nov 3 07:40:52 2016 (r308242) @@ -72,25 +72,6 @@ #define SMB_QREAD 0x1 /* - * smbus transction op with pass-thru capabilities - * - * This smbus function is capable of doing a smbus command transaction - * (read or write), and can be flagged to not issue the 'cmd' and/or - * issue or expect a count field as well as flagged for chaining (no STOP), - * which gives it an i2c pass-through capability. - * - * NOSTOP- Caller chaining transactions, do not issue STOP - * NOCMD- Do not transmit the command field - * NOCNT- Do not transmit (wr) or expect (rd) the count field - */ -#define SMB_TRANS_NOSTOP 0x0001 /* do not send STOP at end */ -#define SMB_TRANS_NOCMD 0x0002 /* ignore cmd field (do not tx) */ -#define SMB_TRANS_NOCNT 0x0004 /* do not tx or rx count field */ -#define SMB_TRANS_7BIT 0x0008 /* change address mode to 7-bit */ -#define SMB_TRANS_10BIT 0x0010 /* change address mode to 10-bit */ -#define SMB_TRANS_NOREPORT 0x0020 /* do not report errors */ - -/* * ivars codes */ enum smbus_ivars { Modified: head/sys/dev/smbus/smbus_if.m ============================================================================== --- head/sys/dev/smbus/smbus_if.m Thu Nov 3 00:58:50 2016 (r308241) +++ head/sys/dev/smbus/smbus_if.m Thu Nov 3 07:40:52 2016 (r308242) @@ -149,20 +149,3 @@ METHOD int bread { u_char *count; char *buf; }; - -# -# SMB roll-up transaction with flags that also allow it to be -# used for (mostly) i2c pass-through and with 10-bit addresses. -# This function can be used to roll-up all of the above functions. -# -METHOD int trans { - device_t dev; - int slave; - char cmd; - int op; - char *wbuf; - int wcount; - char *rbuf; - int rcount; - int *actualp; -}; From owner-svn-src-head@freebsd.org Thu Nov 3 09:24:29 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B757C2B495; Thu, 3 Nov 2016 09:24:29 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 090B61A52; Thu, 3 Nov 2016 09:24:28 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA39OSc0088667; Thu, 3 Nov 2016 09:24:28 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA39OSx7088665; Thu, 3 Nov 2016 09:24:28 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611030924.uA39OSx7088665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 3 Nov 2016 09:24:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308247 - head/cddl/contrib/opensolaris/lib/libzfs_core/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 09:24:29 -0000 Author: avg Date: Thu Nov 3 09:24:27 2016 New Revision: 308247 URL: https://svnweb.freebsd.org/changeset/base/308247 Log: MFV r308222: 6051 lzc_receive: allow the caller to read the begin record illumos/illumos-gate@620f322510b2d6433f7f6af60fa52380c07756ad https://github.com/illumos/illumos-gate/commit/620f322510b2d6433f7f6af60fa52380c07756ad https://www.illumos.org/issues/6051 Currently lzc_receive() requires that its snapname argument is a snapshot name (contains '@'). zfs receive allows to specify just a dataset name and would try to deduce the snapshot name from the stream. I propose to allow lzc_receive() to do the same. That seems to be quite easy to implement, it requires only a small amount of logic, it does not require any additional system calls or any additional data from the stream. The benefit is that the new behavior would allow to keep the snapshot names the same between the sender and receiver at zero cost, without a need to pass the names out of band. Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Robert Mustacchi Author: Andriy Gapon MFC after: 2 weeks Modified: head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h Directory Properties: head/cddl/contrib/opensolaris/ (props changed) Modified: head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Thu Nov 3 08:54:35 2016 (r308246) +++ head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Thu Nov 3 09:24:27 2016 (r308247) @@ -596,8 +596,9 @@ recv_read(int fd, void *buf, int ilen) } static int -lzc_receive_impl(const char *snapname, nvlist_t *props, const char *origin, - boolean_t force, boolean_t resumable, int fd) +recv_impl(const char *snapname, nvlist_t *props, const char *origin, + boolean_t force, boolean_t resumable, int fd, + const dmu_replay_record_t *begin_record) { /* * The receive ioctl is still legacy, so we need to construct our own @@ -642,9 +643,14 @@ lzc_receive_impl(const char *snapname, n (void) strlcpy(zc.zc_string, origin, sizeof (zc.zc_string)); /* zc_begin_record is non-byteswapped BEGIN record */ - error = recv_read(fd, &zc.zc_begin_record, sizeof (zc.zc_begin_record)); - if (error != 0) - goto out; + if (begin_record == NULL) { + error = recv_read(fd, &zc.zc_begin_record, + sizeof (zc.zc_begin_record)); + if (error != 0) + goto out; + } else { + zc.zc_begin_record = *begin_record; + } /* zc_cookie is fd to read from */ zc.zc_cookie = fd; @@ -685,7 +691,7 @@ int lzc_receive(const char *snapname, nvlist_t *props, const char *origin, boolean_t force, int fd) { - return (lzc_receive_impl(snapname, props, origin, force, B_FALSE, fd)); + return (recv_impl(snapname, props, origin, force, B_FALSE, fd, NULL)); } /* @@ -698,7 +704,29 @@ int lzc_receive_resumable(const char *snapname, nvlist_t *props, const char *origin, boolean_t force, int fd) { - return (lzc_receive_impl(snapname, props, origin, force, B_TRUE, fd)); + return (recv_impl(snapname, props, origin, force, B_TRUE, fd, NULL)); +} + +/* + * Like lzc_receive, but allows the caller to read the begin record and then to + * pass it in. That could be useful if the caller wants to derive, for example, + * the snapname or the origin parameters based on the information contained in + * the begin record. + * The begin record must be in its original form as read from the stream, + * in other words, it should not be byteswapped. + * + * The 'resumable' parameter allows to obtain the same behavior as with + * lzc_receive_resumable. + */ +int +lzc_receive_with_header(const char *snapname, nvlist_t *props, + const char *origin, boolean_t force, boolean_t resumable, int fd, + const dmu_replay_record_t *begin_record) +{ + if (begin_record == NULL) + return (EINVAL); + return (recv_impl(snapname, props, origin, force, resumable, fd, + begin_record)); } /* Modified: head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h Thu Nov 3 08:54:35 2016 (r308246) +++ head/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h Thu Nov 3 09:24:27 2016 (r308247) @@ -68,10 +68,15 @@ enum lzc_send_flags { int lzc_send(const char *, const char *, int, enum lzc_send_flags); int lzc_send_resume(const char *, const char *, int, enum lzc_send_flags, uint64_t, uint64_t); +int lzc_send_space(const char *, const char *, uint64_t *); + +struct dmu_replay_record; + int lzc_receive(const char *, nvlist_t *, const char *, boolean_t, int); int lzc_receive_resumable(const char *, nvlist_t *, const char *, boolean_t, int); -int lzc_send_space(const char *, const char *, uint64_t *); +int lzc_receive_with_header(const char *, nvlist_t *, const char *, boolean_t, + boolean_t, int, const struct dmu_replay_record *); boolean_t lzc_exists(const char *); From owner-svn-src-head@freebsd.org Thu Nov 3 10:12:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCCD0C2CBBA; Thu, 3 Nov 2016 10:12:00 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 868F21E58; Thu, 3 Nov 2016 10:12:00 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3ABx1i007740; Thu, 3 Nov 2016 10:11:59 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3ABxPN007738; Thu, 3 Nov 2016 10:11:59 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201611031011.uA3ABxPN007738@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Thu, 3 Nov 2016 10:11:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308250 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 10:12:01 -0000 Author: trasz Date: Thu Nov 3 10:11:59 2016 New Revision: 308250 URL: https://svnweb.freebsd.org/changeset/base/308250 Log: Check for lengths being <= 0. Note that this interface can only be accessed by root. It uses unsigned ints instead of size_t to preserve the ABI. PR: 207627 Submitted by: ryan@ryanday.net (with slight tweaks) MFC after: 1 month Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_ioctl.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Nov 3 09:51:25 2016 (r308249) +++ head/sys/cam/ctl/ctl.c Thu Nov 3 10:11:59 2016 (r308250) @@ -2370,7 +2370,7 @@ ctl_ioctl_fill_ooa(struct ctl_lun *lun, } static void * -ctl_copyin_alloc(void *user_addr, int len, char *error_str, +ctl_copyin_alloc(void *user_addr, unsigned int len, char *error_str, size_t error_str_len) { void *kptr; @@ -2425,6 +2425,12 @@ ctl_copyin_args(int num_args, struct ctl for (i = 0; i < num_args; i++) { uint8_t *tmpptr; + if (args[i].namelen == 0) { + snprintf(error_str, error_str_len, "Argument %d " + "name length is zero", i); + goto bailout; + } + args[i].kname = ctl_copyin_alloc(args[i].name, args[i].namelen, error_str, error_str_len); if (args[i].kname == NULL) @@ -2437,10 +2443,17 @@ ctl_copyin_args(int num_args, struct ctl } if (args[i].flags & CTL_BEARG_RD) { + if (args[i].vallen == 0) { + snprintf(error_str, error_str_len, "Argument %d " + "value length is zero", i); + goto bailout; + } + tmpptr = ctl_copyin_alloc(args[i].value, args[i].vallen, error_str, error_str_len); if (tmpptr == NULL) goto bailout; + if ((args[i].flags & CTL_BEARG_ASCII) && (tmpptr[args[i].vallen - 1] != '\0')) { snprintf(error_str, error_str_len, "Argument " Modified: head/sys/cam/ctl/ctl_ioctl.h ============================================================================== --- head/sys/cam/ctl/ctl_ioctl.h Thu Nov 3 09:51:25 2016 (r308249) +++ head/sys/cam/ctl/ctl_ioctl.h Thu Nov 3 10:11:59 2016 (r308250) @@ -317,20 +317,20 @@ typedef enum { * * flags: Flags for the parameter, see above for values. * - * vallen: Length of the value in bytes. + * vallen: Length of the value in bytes, including the terminating NUL. * - * value: Value to be set/fetched. + * value: Value to be set/fetched. This must be NUL-terminated. * * kname: For kernel use only. * * kvalue: For kernel use only. */ struct ctl_be_arg { - int namelen; - char *name; - int flags; - int vallen; - void *value; + unsigned int namelen; + char *name; + int flags; + unsigned int vallen; + void *value; char *kname; void *kvalue; From owner-svn-src-head@freebsd.org Thu Nov 3 13:06:19 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6213C2D4BB; Thu, 3 Nov 2016 13:06:19 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8F249157F; Thu, 3 Nov 2016 13:06:19 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3D6IR6072744; Thu, 3 Nov 2016 13:06:18 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3D6HbK072736; Thu, 3 Nov 2016 13:06:17 GMT (envelope-from br@FreeBSD.org) Message-Id: <201611031306.uA3D6HbK072736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Thu, 3 Nov 2016 13:06:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308251 - in head: lib/libcompiler_rt lib/msun/riscv share/man/man7 share/mk sys/modules/dtrace/dtrace sys/riscv/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 13:06:20 -0000 Author: br Date: Thu Nov 3 13:06:17 2016 New Revision: 308251 URL: https://svnweb.freebsd.org/changeset/base/308251 Log: o Add support for long double. o Add support for latest RISC-V GNU toolchain. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/lib/libcompiler_rt/Makefile.inc head/lib/msun/riscv/Makefile.inc head/share/man/man7/arch.7 head/share/mk/bsd.cpu.mk head/share/mk/bsd.stand.mk head/sys/modules/dtrace/dtrace/Makefile head/sys/riscv/include/asm.h head/sys/riscv/include/float.h Modified: head/lib/libcompiler_rt/Makefile.inc ============================================================================== --- head/lib/libcompiler_rt/Makefile.inc Thu Nov 3 10:11:59 2016 (r308250) +++ head/lib/libcompiler_rt/Makefile.inc Thu Nov 3 13:06:17 2016 (r308251) @@ -123,8 +123,11 @@ SRCF+= udivti3 SRCF+= umoddi3 SRCF+= umodti3 -# 128-bit quad precision long double support, only used on arm64 -.if ${MACHINE_CPUARCH} == "aarch64" +# +# 128-bit quad precision long double support, +# only used on arm64 and riscv. +# +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" SRCF+= addtf3 SRCF+= comparetf2 SRCF+= divtf3 Modified: head/lib/msun/riscv/Makefile.inc ============================================================================== --- head/lib/msun/riscv/Makefile.inc Thu Nov 3 10:11:59 2016 (r308250) +++ head/lib/msun/riscv/Makefile.inc Thu Nov 3 13:06:17 2016 (r308251) @@ -1,6 +1,3 @@ # $FreeBSD$ -# RISCVTODO: should be 113 -# compilation problems: gcc generates bltuz instruction, which is not exists - -LDBL_PREC = 53 +LDBL_PREC = 113 Modified: head/share/man/man7/arch.7 ============================================================================== --- head/share/man/man7/arch.7 Thu Nov 3 10:11:59 2016 (r308250) +++ head/share/man/man7/arch.7 Thu Nov 3 13:06:17 2016 (r308251) @@ -66,7 +66,7 @@ On all supported architectures, .It mips64hf Ta 8 Ta 8 .It powerpc Ta 4 Ta 8 .It powerpc64 Ta 8 Ta 8 -.It riscv Ta 8 Ta +.It riscv Ta 8 Ta 16 .It sparc64 Ta 8 Ta 16 .El .Ss Endianness and Char Signedness Modified: head/share/mk/bsd.cpu.mk ============================================================================== --- head/share/mk/bsd.cpu.mk Thu Nov 3 10:11:59 2016 (r308250) +++ head/share/mk/bsd.cpu.mk Thu Nov 3 13:06:17 2016 (r308251) @@ -156,7 +156,7 @@ _CPUCFLAGS = -march=${CPUTYPE} _CPUCFLAGS = -march=${CPUTYPE:S/^mips//} . endif . elif ${MACHINE_CPUARCH} == "riscv" -_CPUCFLAGS = -msoft-float # -march="RV64I" # RISCVTODO +_CPUCFLAGS = -mno-float -march="IMAFD" . elif ${MACHINE_ARCH} == "sparc64" . if ${CPUTYPE} == "v9" _CPUCFLAGS = -mcpu=v9 @@ -337,8 +337,8 @@ CFLAGS += -mcpu=8540 -Wa,-me500 -mspe=ye .endif .if ${MACHINE_CPUARCH} == "riscv" -CFLAGS += -msoft-float -ACFLAGS += -msoft-float +CFLAGS += -mno-float +ACFLAGS += -mno-float .endif # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk Modified: head/share/mk/bsd.stand.mk ============================================================================== --- head/share/mk/bsd.stand.mk Thu Nov 3 10:11:59 2016 (r308250) +++ head/share/mk/bsd.stand.mk Thu Nov 3 13:06:17 2016 (r308251) @@ -5,7 +5,12 @@ # CFLAGS+= -ffreestanding -Wformat -CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float -D_STANDALONE +CFLAGS+= ${CFLAGS_NO_SIMD} -D_STANDALONE +.if ${MACHINE_CPUARCH} == "riscv" +CFLAGS+= -mno-float +.else +CFLAGS+= -msoft-float +.endif .if ${MACHINE_CPUARCH} == "i386" CFLAGS.gcc+= -mpreferred-stack-boundary=2 Modified: head/sys/modules/dtrace/dtrace/Makefile ============================================================================== --- head/sys/modules/dtrace/dtrace/Makefile Thu Nov 3 10:11:59 2016 (r308250) +++ head/sys/modules/dtrace/dtrace/Makefile Thu Nov 3 13:06:17 2016 (r308251) @@ -60,7 +60,7 @@ assym.o: assym.s .if ${MACHINE_CPUARCH} == "riscv" assym.o: assym.s - ${AS} -msoft-float -o assym.o assym.s + ${AS} -mfloat-abi=soft -o assym.o assym.s .endif .include Modified: head/sys/riscv/include/asm.h ============================================================================== --- head/sys/riscv/include/asm.h Thu Nov 3 10:11:59 2016 (r308250) +++ head/sys/riscv/include/asm.h Thu Nov 3 13:06:17 2016 (r308251) @@ -47,7 +47,7 @@ #define _C_LABEL(x) x #define ENTRY(sym) \ - .text; .globl sym; .type sym,@function; .align 2; sym: + .text; .globl sym; .type sym,@function; .align 4; sym: #define END(sym) .size sym, . - sym #define EENTRY(sym) \ Modified: head/sys/riscv/include/float.h ============================================================================== --- head/sys/riscv/include/float.h Thu Nov 3 10:11:59 2016 (r308250) +++ head/sys/riscv/include/float.h Thu Nov 3 13:06:17 2016 (r308251) @@ -76,22 +76,6 @@ __END_DECLS #define DBL_HAS_SUBNORM 1 #endif /* __ISO_C_VISIBLE >= 2011 */ -#define LDBL_MANT_DIG DBL_MANT_DIG -#define LDBL_EPSILON ((long double)DBL_EPSILON) -#define LDBL_DIG DBL_DIG -#define LDBL_MIN_EXP DBL_MIN_EXP -#define LDBL_MIN ((long double)DBL_MIN) -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP -#define LDBL_MAX_EXP DBL_MAX_EXP -#define LDBL_MAX ((long double)DBL_MAX) -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP -#if __ISO_C_VISIBLE >= 2011 -#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN) -#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG -#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#if 0 /* RISCVTODO */ #define LDBL_MANT_DIG 113 #define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L #define LDBL_DIG 33 @@ -106,6 +90,5 @@ __END_DECLS #define LDBL_DECIMAL_DIG 36 #define LDBL_HAS_SUBNORM 1 #endif /* __ISO_C_VISIBLE >= 2011 */ -#endif #endif /* _MACHINE_FLOAT_H_ */ From owner-svn-src-head@freebsd.org Thu Nov 3 16:44:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 588D4C2D80A; Thu, 3 Nov 2016 16:44:57 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CDCF412DF; Thu, 3 Nov 2016 16:44:56 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3GitCd062286; Thu, 3 Nov 2016 16:44:55 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3Git4u062285; Thu, 3 Nov 2016 16:44:55 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201611031644.uA3Git4u062285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Thu, 3 Nov 2016 16:44:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308261 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 16:44:57 -0000 Author: alc Date: Thu Nov 3 16:44:55 2016 New Revision: 308261 URL: https://svnweb.freebsd.org/changeset/base/308261 Log: In vm_fault()'s loop over the shadow chain, move a comment describing our invariants to a better place. Also, add two comments concerning the relationship between the map and vnode locks. Reviewed by: kib MFC after: 3 days Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Thu Nov 3 15:04:16 2016 (r308260) +++ head/sys/vm/vm_fault.c Thu Nov 3 16:44:55 2016 (r308261) @@ -564,6 +564,14 @@ fast_failed: readrest: /* + * At this point, we have either allocated a new page or found + * an existing page that is only partially valid. + * + * We hold a reference on the current object and the page is + * exclusive busied. + */ + + /* * If the pager for the current object might have the page, * then determine the number of additional pages to read and * potentially reprioritize previously read pages for earlier @@ -632,18 +640,23 @@ readrest: */ if (fs.object->type != OBJT_DEFAULT) { /* - * We have either allocated a new page or found an - * existing page that is only partially valid. We - * hold a reference on fs.object and the page is - * exclusive busied. + * Release the map lock before locking the vnode or + * sleeping in the pager. (If the current object has + * a shadow, then an earlier iteration of this loop + * may have already unlocked the map.) */ unlock_map(&fs); if (fs.object->type == OBJT_VNODE && (vp = fs.object->handle) != fs.vp) { + /* + * Perform an unlock in case the desired vnode + * changed while the map was unlocked during a + * retry. + */ unlock_vp(&fs); - locked = VOP_ISLOCKED(vp); + locked = VOP_ISLOCKED(vp); if (locked != LK_EXCLUSIVE) locked = LK_SHARED; From owner-svn-src-head@freebsd.org Thu Nov 3 19:39:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA61EC2DA47; Thu, 3 Nov 2016 19:39:33 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88B9E181B; Thu, 3 Nov 2016 19:39:33 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3JdWJi028452; Thu, 3 Nov 2016 19:39:32 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3JdWdc028451; Thu, 3 Nov 2016 19:39:32 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201611031939.uA3JdWdc028451@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Thu, 3 Nov 2016 19:39:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308262 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 19:39:33 -0000 Author: bdrewery Date: Thu Nov 3 19:39:32 2016 New Revision: 308262 URL: https://svnweb.freebsd.org/changeset/base/308262 Log: Use proper MACHINE_ARCH. This fixes ports on mips after r308130. Modified: head/share/mk/bsd.cpu.mk Modified: head/share/mk/bsd.cpu.mk ============================================================================== --- head/share/mk/bsd.cpu.mk Thu Nov 3 16:44:55 2016 (r308261) +++ head/share/mk/bsd.cpu.mk Thu Nov 3 19:39:32 2016 (r308262) @@ -303,7 +303,7 @@ MACHINE_CPU = v9 ultrasparc ultrasparc3 .if ${MACHINE_CPUARCH} == "mips" CFLAGS += -G0 -.if ${TARGET_ARCH:Mmips*hf} +.if ${MACHINE_ARCH:Mmips*hf} CFLAGS += -mhard-float .endif .endif From owner-svn-src-head@freebsd.org Thu Nov 3 19:41:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21F51C2DB02; Thu, 3 Nov 2016 19:41:01 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 03E6119FF; Thu, 3 Nov 2016 19:41:01 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id EEDC315ED; Thu, 3 Nov 2016 19:41:00 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 7BA782716F; Thu, 3 Nov 2016 19:41:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id 8BTPQyi0E2kA; Thu, 3 Nov 2016 19:39:51 +0000 (UTC) Subject: Re: svn commit: r308130 - in head: . gnu/lib/libgcc gnu/usr.bin/binutils gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/libbfd gnu/usr.bin/cc gnu/usr.bin/gdb gnu/usr.bin/gdb/libgdb lib/libc lib/libc/mips... DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com C99E427168 To: Ruslan Bukin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610311533.u9VFXw2x053156@repo.freebsd.org> From: Bryan Drewery Organization: FreeBSD Message-ID: <128f2edc-eced-dc8b-72b4-267e1d26bd48@FreeBSD.org> Date: Thu, 3 Nov 2016 12:39:48 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610311533.u9VFXw2x053156@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MXIo4xUt3hRp7xshmk08bxCCMW7GIW9wR" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 19:41:01 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MXIo4xUt3hRp7xshmk08bxCCMW7GIW9wR Content-Type: multipart/mixed; boundary="CABlBW8BMv8K80Vs1NcA9RmXaWKfIMlHe"; protected-headers="v1" From: Bryan Drewery To: Ruslan Bukin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <128f2edc-eced-dc8b-72b4-267e1d26bd48@FreeBSD.org> Subject: Re: svn commit: r308130 - in head: . gnu/lib/libgcc gnu/usr.bin/binutils gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/libbfd gnu/usr.bin/cc gnu/usr.bin/gdb gnu/usr.bin/gdb/libgdb lib/libc lib/libc/mips... References: <201610311533.u9VFXw2x053156@repo.freebsd.org> In-Reply-To: <201610311533.u9VFXw2x053156@repo.freebsd.org> --CABlBW8BMv8K80Vs1NcA9RmXaWKfIMlHe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/31/16 8:33 AM, Ruslan Bukin wrote: > Modified: head/share/mk/bsd.cpu.mk > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/share/mk/bsd.cpu.mk Mon Oct 31 15:11:55 2016 (r308129) > +++ head/share/mk/bsd.cpu.mk Mon Oct 31 15:33:58 2016 (r308130) > @@ -303,6 +303,9 @@ MACHINE_CPU =3D v9 ultrasparc ultrasparc3 > =20 > .if ${MACHINE_CPUARCH} =3D=3D "mips" > CFLAGS +=3D -G0 > +.if ${TARGET_ARCH:Mmips*hf} TARGET_ARCH is not valid here. This broke building ports. Fixed in r308262. > +CFLAGS +=3D -mhard-float > +.endif > .endif > =20 --=20 Regards, Bryan Drewery --CABlBW8BMv8K80Vs1NcA9RmXaWKfIMlHe-- --MXIo4xUt3hRp7xshmk08bxCCMW7GIW9wR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQEcBAEBCgAGBQJYG5KFAAoJEDXXcbtuRpfPlRUH/igHLJa6C//45v62CwoBytmB 5+h3ZZee1FSOqaXutxE0IdA10MY+GtCYXeGamHXg/pKJGL9TZrYOdmZslYhtJQS2 5WHpP/YaVyTndsWAG0JbLG26gBjPrujDtHzndrVHrq5B0Do7i9P7zPJoE7ZTCkWR jetnxGbF4M7YKjAygNSuDhO1f3givaAuaFCtkPNcw6N3sGImA/uNAgsW+DpeigIv 5ZZjrW47agezBuCskBtcPAdl0w0AfRe0orom+TIQU+l/rN0uZ0rtaBYrPfvkr2MO i89j8GvQlH6/PKbzQ8VSLD4UKW2Hv+ynkeCxSMkiB8MdhjkR+d0zgDa6ndA+7Jk= =GjiE -----END PGP SIGNATURE----- --MXIo4xUt3hRp7xshmk08bxCCMW7GIW9wR-- From owner-svn-src-head@freebsd.org Thu Nov 3 20:11:38 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7BA6BC13639; Thu, 3 Nov 2016 20:11:38 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) Received: from ppsw-40.csi.cam.ac.uk (ppsw-40.csi.cam.ac.uk [131.111.8.140]) by mx1.freebsd.org (Postfix) with ESMTP id 469101DAD; Thu, 3 Nov 2016 20:11:37 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from sc1.bsdpad.com ([163.172.212.18]:42303) by ppsw-40.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (LOGIN:rb743) (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1c2OMK-0010HX-jL (Exim 4.86_36-e07b163) (return-path ); Thu, 03 Nov 2016 20:11:36 +0000 Date: Thu, 3 Nov 2016 20:10:59 +0000 From: Ruslan Bukin To: Bryan Drewery Cc: Ruslan Bukin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308130 - in head: . gnu/lib/libgcc gnu/usr.bin/binutils gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/libbfd gnu/usr.bin/cc gnu/usr.bin/gdb gnu/usr.bin/gdb/libgdb lib/libc lib/libc/mips... Message-ID: <20161103201059.GA2104@bsdpad.com> References: <201610311533.u9VFXw2x053156@repo.freebsd.org> <128f2edc-eced-dc8b-72b4-267e1d26bd48@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <128f2edc-eced-dc8b-72b4-267e1d26bd48@FreeBSD.org> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: "R. Bukin" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 20:11:38 -0000 On Thu, Nov 03, 2016 at 12:39:48PM -0700, Bryan Drewery wrote: > On 10/31/16 8:33 AM, Ruslan Bukin wrote: > > Modified: head/share/mk/bsd.cpu.mk > > ============================================================================== > > --- head/share/mk/bsd.cpu.mk Mon Oct 31 15:11:55 2016 (r308129) > > +++ head/share/mk/bsd.cpu.mk Mon Oct 31 15:33:58 2016 (r308130) > > @@ -303,6 +303,9 @@ MACHINE_CPU = v9 ultrasparc ultrasparc3 > > > > .if ${MACHINE_CPUARCH} == "mips" > > CFLAGS += -G0 > > +.if ${TARGET_ARCH:Mmips*hf} > > TARGET_ARCH is not valid here. This broke building ports. Fixed in > r308262. > Thank you! Ruslan From owner-svn-src-head@freebsd.org Thu Nov 3 20:21:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59057C13AE4; Thu, 3 Nov 2016 20:21:36 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 305941390; Thu, 3 Nov 2016 20:21:36 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3KLZQC047578; Thu, 3 Nov 2016 20:21:35 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3KLYTW047572; Thu, 3 Nov 2016 20:21:34 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201611032021.uA3KLYTW047572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Thu, 3 Nov 2016 20:21:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308264 - in head: include lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 20:21:36 -0000 Author: ed Date: Thu Nov 3 20:21:34 2016 New Revision: 308264 URL: https://svnweb.freebsd.org/changeset/base/308264 Log: Replace basename(3) by a thread-safe implementation. Now that the changes to the dirname(3) function had some time to settle, let's go ahead and use the same approach for replacing basename(3) by a simple implementation that modifies the input string, thereby making it thread-safe and guaranteed to succeed. Unlike dirname(3), this function already had a thread-safe variant basename_r(3). This function had its own set of problems, like having an upper bound on the pathname length. Keep this function around for compatibility, but remove most references from the man page. Make the man page more similar to that of dirname(3). As the basename_r(3) function is only provided by FreeBSD (and Bionic), depending on its use is even more implementation defined than assuming that basename(3) is thread-safe. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D8382 Added: head/lib/libc/gen/basename_compat.c - copied, changed from r306522, head/lib/libc/gen/basename.c Modified: head/include/libgen.h head/lib/libc/gen/Makefile.inc head/lib/libc/gen/Symbol.map head/lib/libc/gen/basename.3 head/lib/libc/gen/basename.c Modified: head/include/libgen.h ============================================================================== --- head/include/libgen.h Thu Nov 3 19:58:12 2016 (r308263) +++ head/include/libgen.h Thu Nov 3 20:21:34 2016 (r308264) @@ -40,21 +40,24 @@ char *dirname(char *); __END_DECLS /* - * In FreeBSD 12, the prototype of dirname() was modified to comply to - * POSIX. This function may now modify its input. Unfortunately, our - * copy of xinstall(8) shipped with previous versions of FreeBSD is - * built using the host headers and libc during the bootstrapping phase - * and depends on the old behavior. + * In FreeBSD 12, the prototypes of basename() and dirname() were + * modified to comply to POSIX. These functions may now modify their + * input. Unfortunately, our copy of xinstall(8) shipped with previous + * versions of FreeBSD is built using the host headers and libc during + * the bootstrapping phase and depends on the old behavior. * - * Apply a workaround where we explicitly link against dirname@FBSD_1.0 - * in case this function is called on constant strings, instead of - * making the program crash at runtime. + * Apply a workaround where we explicitly link against basename@FBSD_1.0 + * and dirname@FBSD_1.0 in case these functions are called on constant + * strings, instead of making the program crash at runtime. */ #if defined(__generic) && !defined(__cplusplus) __BEGIN_DECLS +char *__old_basename(char *); char *__old_dirname(char *); __END_DECLS +__sym_compat(basename, __old_basename, FBSD_1.0); __sym_compat(dirname, __old_dirname, FBSD_1.0); +#define basename(x) __generic(x, const char *, __old_basename, basename)(x) #define dirname(x) __generic(x, const char *, __old_dirname, dirname)(x) #endif Modified: head/lib/libc/gen/Makefile.inc ============================================================================== --- head/lib/libc/gen/Makefile.inc Thu Nov 3 19:58:12 2016 (r308263) +++ head/lib/libc/gen/Makefile.inc Thu Nov 3 20:21:34 2016 (r308264) @@ -17,6 +17,7 @@ SRCS+= __getosreldate.c \ assert.c \ auxv.c \ basename.c \ + basename_compat.c \ cap_sandboxed.c \ check_utility_compat.c \ clock.c \ Modified: head/lib/libc/gen/Symbol.map ============================================================================== --- head/lib/libc/gen/Symbol.map Thu Nov 3 19:58:12 2016 (r308263) +++ head/lib/libc/gen/Symbol.map Thu Nov 3 20:21:34 2016 (r308264) @@ -68,7 +68,6 @@ FBSD_1.0 { arc4random_addrandom; arc4random_stir; __assert; - basename; check_utility_compat; clock; closedir; @@ -414,6 +413,7 @@ FBSD_1.4 { }; FBSD_1.5 { + basename; dirname; }; Modified: head/lib/libc/gen/basename.3 ============================================================================== --- head/lib/libc/gen/basename.3 Thu Nov 3 19:58:12 2016 (r308263) +++ head/lib/libc/gen/basename.3 Thu Nov 3 20:21:34 2016 (r308264) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 29, 2016 +.Dd October 29, 2016 .Dt BASENAME 3 .Os .Sh NAME @@ -26,8 +26,6 @@ .In libgen.h .Ft char * .Fn basename "char *path" -.Ft char * -.Fn basename_r "const char *path" "char *bname" .Sh DESCRIPTION The .Fn basename @@ -36,6 +34,7 @@ function returns the last component from deleting any trailing .Sq \&/ characters. +.Sh RETURN VALUES If .Fa path consists entirely of @@ -48,48 +47,19 @@ If is a null pointer or the empty string, a pointer to the string .Qq \&. is returned. -.Pp -The -.Fn basename_r -variation accepts a buffer of at least -.Dv MAXPATHLEN -bytes in which to store the resulting component. +Otherwise, +it returns a pointer to the last component of +.Fa path . .Sh IMPLEMENTATION NOTES -The -.Fn basename -function -returns a pointer to internal storage space allocated on the first call -that will be overwritten -by subsequent calls. -.Pp -Other vendor implementations of +This implementation of .Fn basename -may store their result in the input buffer, -making it safe to use in multithreaded applications. -Future versions of -.Fx -will follow this approach as well. -.Fn basename_r -will then become obsolete. -.Sh RETURN VALUES -On successful completion, -.Fn basename -and -.Fn basename_r -return pointers to the last component of -.Fa path . -.Pp -If they fail, a null pointer is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The following error codes may be set in -.Va errno : -.Bl -tag -width Er -.It Bq Er ENAMETOOLONG -The path component to be returned was larger than -.Dv MAXPATHLEN . -.El +uses the buffer provided by the caller to store the resulting pathname +component. +Other vendor implementations may return a pointer to internal storage +space instead. +The advantage of the former approach is that it ensures thread-safety, +while also placing no upper limit on the supported length of the +pathname. .Sh SEE ALSO .Xr basename 1 , .Xr dirname 1 , @@ -106,16 +76,13 @@ function first appeared in .Ox 2.2 and .Fx 4.2 . -.Sh AUTHORS -.An Todd C. Miller -.Sh CAVEATS -.Fn basename -returns a pointer to internal static storage space that will be overwritten -by subsequent calls. .Pp -Other vendor implementations of -.Fn basename -may modify the contents of the string passed to -.Fn basename ; -this should be taken into account when writing code which calls this function -if portability is desired. +In +.Fx 12.0 , +this function was reimplemented to store its result in the provided +input buffer. +There is no longer any need to use the +.Fn basename_r +function. +.Sh AUTHORS +.An Nuxi, the Netherlands Modified: head/lib/libc/gen/basename.c ============================================================================== --- head/lib/libc/gen/basename.c Thu Nov 3 19:58:12 2016 (r308263) +++ head/lib/libc/gen/basename.c Thu Nov 3 20:21:34 2016 (r308264) @@ -1,79 +1,54 @@ -/* $OpenBSD: basename.c,v 1.14 2005/08/08 08:05:33 espie Exp $ */ - -/* - * Copyright (c) 1997, 2004 Todd C. Miller +/*- + * Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. + * 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. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include #include -#include #include -#include - -char * -basename_r(const char *path, char *bname) -{ - const char *endp, *startp; - size_t len; - - /* Empty or NULL string gets treated as "." */ - if (path == NULL || *path == '\0') { - bname[0] = '.'; - bname[1] = '\0'; - return (bname); - } - - /* Strip any trailing slashes */ - endp = path + strlen(path) - 1; - while (endp > path && *endp == '/') - endp--; - - /* All slashes becomes "/" */ - if (endp == path && *endp == '/') { - bname[0] = '/'; - bname[1] = '\0'; - return (bname); - } - - /* Find the start of the base */ - startp = endp; - while (startp > path && *(startp - 1) != '/') - startp--; - - len = endp - startp + 1; - if (len >= MAXPATHLEN) { - errno = ENAMETOOLONG; - return (NULL); - } - memcpy(bname, startp, len); - bname[len] = '\0'; - return (bname); -} char * -basename(char *path) +(basename)(char *path) { - static char *bname = NULL; + char *ptr; - if (bname == NULL) { - bname = (char *)malloc(MAXPATHLEN); - if (bname == NULL) - return (NULL); - } - return (basename_r(path, bname)); + /* + * If path is a null pointer or points to an empty string, + * basename() shall return a pointer to the string ".". + */ + if (path == NULL || *path == '\0') + return (__DECONST(char *, ".")); + + /* Find end of last pathname component and null terminate it. */ + ptr = path + strlen(path); + while (ptr > path + 1 && *(ptr - 1) == '/') + --ptr; + *ptr-- = '\0'; + + /* Find beginning of last pathname component. */ + while (ptr > path && *(ptr - 1) != '/') + --ptr; + return (ptr); } Copied and modified: head/lib/libc/gen/basename_compat.c (from r306522, head/lib/libc/gen/basename.c) ============================================================================== --- head/lib/libc/gen/basename.c Fri Sep 30 19:21:02 2016 (r306522, copy source) +++ head/lib/libc/gen/basename_compat.c Thu Nov 3 20:21:34 2016 (r308264) @@ -66,7 +66,7 @@ basename_r(const char *path, char *bname } char * -basename(char *path) +__freebsd11_basename(char *path) { static char *bname = NULL; @@ -77,3 +77,5 @@ basename(char *path) } return (basename_r(path, bname)); } + +__sym_compat(basename, __freebsd11_basename, FBSD_1.0); From owner-svn-src-head@freebsd.org Thu Nov 3 23:05:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7911EC2E379; Thu, 3 Nov 2016 23:05:40 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E8FC1333; Thu, 3 Nov 2016 23:05:40 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3N5dLC009662; Thu, 3 Nov 2016 23:05:39 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3N5doN009661; Thu, 3 Nov 2016 23:05:39 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201611032305.uA3N5doN009661@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 3 Nov 2016 23:05:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308267 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 23:05:40 -0000 Author: adrian Date: Thu Nov 3 23:05:39 2016 New Revision: 308267 URL: https://svnweb.freebsd.org/changeset/base/308267 Log: [ath] add the MIMO per-chain RSSI and noise floor information. This is a long time coming. The general pieces have been floating around in a local repo since circa 2012 when I dropped the net80211 support into the tree. This allows the per-chain RSSI and NF to show up in 'ifconfig wlanX list sta'. I haven't yet implemented the EVM hookups so that'll show up; that'll come later. Thanks to Susie Hellings who did the original work on this a looong time ago for a company we both worked at. Modified: head/sys/dev/ath/if_ath_rx.c Modified: head/sys/dev/ath/if_ath_rx.c ============================================================================== --- head/sys/dev/ath/if_ath_rx.c Thu Nov 3 22:51:38 2016 (r308266) +++ head/sys/dev/ath/if_ath_rx.c Thu Nov 3 23:05:39 2016 (r308267) @@ -635,7 +635,9 @@ ath_rx_pkt(struct ath_softc *sc, struct struct mbuf *m) { uint64_t rstamp; - int len, type; + /* XXX TODO: make this an mbuf tag? */ + struct ieee80211_rx_stats rxs; + int len, type, i; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni; int is_good = 0; @@ -904,6 +906,33 @@ rx_accept: sc->sc_stats.ast_rx_agg++; #endif /* AH_SUPPORT_AR5416 */ + + /* + * Populate the per-chain RSSI values where appropriate. + */ + bzero(&rxs, sizeof(rxs)); + rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI | + IEEE80211_R_C_CHAIN | + IEEE80211_R_C_NF | + IEEE80211_R_C_RSSI | + IEEE80211_R_TSF64 | + IEEE80211_R_TSF_START; /* XXX TODO: validate */ + rxs.c_rssi = rs->rs_rssi; + rxs.c_nf = nf; + rxs.c_chain = 3; /* XXX TODO: check */ + rxs.c_rx_tsf = rstamp; + + for (i = 0; i < 3; i++) { + rxs.c_rssi_ctl[i] = rs->rs_rssi_ctl[i]; + rxs.c_rssi_ext[i] = rs->rs_rssi_ext[i]; + /* + * XXX note: we currently don't track + * per-chain noisefloor. + */ + rxs.c_nf_ctl[i] = nf; + rxs.c_nf_ext[i] = nf; + } + if (ni != NULL) { /* * Only punt packets for ampdu reorder processing for @@ -916,7 +945,8 @@ rx_accept: /* * Sending station is known, dispatch directly. */ - type = ieee80211_input(ni, m, rs->rs_rssi, nf); + (void) ieee80211_add_rx_params(m, &rxs); + type = ieee80211_input_mimo(ni, m); ieee80211_free_node(ni); m = NULL; /* @@ -929,7 +959,8 @@ rx_accept: rs->rs_keyix != HAL_RXKEYIX_INVALID) is_good = 1; } else { - type = ieee80211_input_all(ic, m, rs->rs_rssi, nf); + (void) ieee80211_add_rx_params(m, &rxs); + type = ieee80211_input_mimo_all(ic, m); m = NULL; } From owner-svn-src-head@freebsd.org Thu Nov 3 23:11:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5301FC2E51A; Thu, 3 Nov 2016 23:11:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E9C8173C; Thu, 3 Nov 2016 23:11:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3NBXAw010618; Thu, 3 Nov 2016 23:11:33 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3NBXJh010617; Thu, 3 Nov 2016 23:11:33 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201611032311.uA3NBXJh010617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 3 Nov 2016 23:11:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308268 - head/sys/x86/x86 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 23:11:34 -0000 Author: adrian Date: Thu Nov 3 23:11:33 2016 New Revision: 308268 URL: https://svnweb.freebsd.org/changeset/base/308268 Log: Add a witness check to enforce that no non-sleeping locks are held when they shouldn't be. I used this during driver bring-up to find that the Linux driver holds a whole lot of locks whilst doing their equivalent of busdma operations. If this works out well, it should be added to the other architecture busdma implementations to aid in similar debugging. Tested: * bounce buffer and dmar busdma, Lenovo X230 laptop, all the internal hardware * ath(4) too Discussed with: jhb Modified: head/sys/x86/x86/busdma_machdep.c Modified: head/sys/x86/x86/busdma_machdep.c ============================================================================== --- head/sys/x86/x86/busdma_machdep.c Thu Nov 3 23:05:39 2016 (r308267) +++ head/sys/x86/x86/busdma_machdep.c Thu Nov 3 23:11:33 2016 (r308268) @@ -197,6 +197,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, struct bus_dma_tag_common *tc; int error; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + if (parent == NULL) { error = bus_dma_bounce_impl.tag_create(parent, alignment, boundary, lowaddr, highaddr, filter, filterarg, maxsize, @@ -228,6 +230,8 @@ bus_dmamap_create(bus_dma_tag_t dmat, in { struct bus_dma_tag_common *tc; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + tc = (struct bus_dma_tag_common *)dmat; return (tc->impl->map_create(dmat, flags, mapp)); } @@ -257,6 +261,8 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, voi { struct bus_dma_tag_common *tc; + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); + tc = (struct bus_dma_tag_common *)dmat; return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp)); } From owner-svn-src-head@freebsd.org Thu Nov 3 23:22:05 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99198C2E8B8; Thu, 3 Nov 2016 23:22:05 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B4021C94; Thu, 3 Nov 2016 23:22:05 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3NM4IF015730; Thu, 3 Nov 2016 23:22:04 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3NM4il015729; Thu, 3 Nov 2016 23:22:04 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201611032322.uA3NM4il015729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Thu, 3 Nov 2016 23:22:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308269 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 23:22:05 -0000 Author: jmcneill Date: Thu Nov 3 23:22:04 2016 New Revision: 308269 URL: https://svnweb.freebsd.org/changeset/base/308269 Log: Add support for Allwinner H3 audio codec. The audio controller in the H3 is more or less the same as A10/A20 except some registers are shuffled around. The mixer interface, however, is completely different between SoCs. Separate a10_mixer_class and h3_mixer_class implementations are now made available. This will also make adding support for other SoCs easier in the future. Reviewed by: andrew, ganbold Relnotes: yes Differential Revision: https://reviews.freebsd.org/D8425 Modified: head/sys/arm/allwinner/a10_codec.c Modified: head/sys/arm/allwinner/a10_codec.c ============================================================================== --- head/sys/arm/allwinner/a10_codec.c Thu Nov 3 23:11:33 2016 (r308268) +++ head/sys/arm/allwinner/a10_codec.c Thu Nov 3 23:22:04 2016 (r308269) @@ -27,7 +27,7 @@ */ /* - * Allwinner A10/A20 Audio Codec + * Allwinner A10/A20 and H3 Audio Codec */ #include @@ -50,19 +50,46 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include +#include #include "sunxi_dma_if.h" #include "mixer_if.h" -#include "gpio_if.h" + +struct a10codec_info; + +struct a10codec_config { + /* mixer class */ + struct kobj_class *mixer_class; + + /* toggle DAC/ADC mute */ + void (*mute)(struct a10codec_info *, int, int); + + /* DRQ types */ + u_int drqtype_codec; + u_int drqtype_sdram; + + /* register map */ + bus_size_t DPC, + DAC_FIFOC, + DAC_FIFOS, + DAC_TXDATA, + ADC_FIFOC, + ADC_FIFOS, + ADC_RXDATA, + DAC_CNT, + ADC_CNT; +}; #define TX_TRIG_LEVEL 0xf #define RX_TRIG_LEVEL 0x7 #define DRQ_CLR_CNT 0x3 -#define AC_DAC_DPC 0x00 +#define AC_DAC_DPC(_sc) ((_sc)->cfg->DPC) #define DAC_DPC_EN_DA 0x80000000 -#define AC_DAC_FIFOC 0x04 +#define AC_DAC_FIFOC(_sc) ((_sc)->cfg->DAC_FIFOC) #define DAC_FIFOC_FS_SHIFT 29 #define DAC_FIFOC_FS_MASK (7U << DAC_FIFOC_FS_SHIFT) #define DAC_FS_48KHZ 0 @@ -86,17 +113,9 @@ __FBSDID("$FreeBSD$"); #define DAC_FIFOC_TX_BITS (1U << 5) #define DAC_FIFOC_DRQ_EN (1U << 4) #define DAC_FIFOC_FIFO_FLUSH (1U << 0) -#define AC_DAC_FIFOS 0x08 -#define AC_DAC_TXDATA 0x0c -#define AC_DAC_ACTL 0x10 -#define DAC_ACTL_DACAREN (1U << 31) -#define DAC_ACTL_DACALEN (1U << 30) -#define DAC_ACTL_MIXEN (1U << 29) -#define DAC_ACTL_DACPAS (1U << 8) -#define DAC_ACTL_PAMUTE (1U << 6) -#define DAC_ACTL_PAVOL_SHIFT 0 -#define DAC_ACTL_PAVOL_MASK (0x3f << DAC_ACTL_PAVOL_SHIFT) -#define AC_ADC_FIFOC 0x1c +#define AC_DAC_FIFOS(_sc) ((_sc)->cfg->DAC_FIFOS) +#define AC_DAC_TXDATA(_sc) ((_sc)->cfg->DAC_TXDATA) +#define AC_ADC_FIFOC(_sc) ((_sc)->cfg->ADC_FIFOC) #define ADC_FIFOC_FS_SHIFT 29 #define ADC_FIFOC_FS_MASK (7U << ADC_FIFOC_FS_SHIFT) #define ADC_FS_48KHZ 0 @@ -108,33 +127,10 @@ __FBSDID("$FreeBSD$"); #define ADC_FIFOC_RX_BITS (1U << 6) #define ADC_FIFOC_DRQ_EN (1U << 4) #define ADC_FIFOC_FIFO_FLUSH (1U << 1) -#define AC_ADC_FIFOS 0x20 -#define AC_ADC_RXDATA 0x24 -#define AC_ADC_ACTL 0x28 -#define ADC_ACTL_ADCREN (1U << 31) -#define ADC_ACTL_ADCLEN (1U << 30) -#define ADC_ACTL_PREG1EN (1U << 29) -#define ADC_ACTL_PREG2EN (1U << 28) -#define ADC_ACTL_VMICEN (1U << 27) -#define ADC_ACTL_ADCG_SHIFT 20 -#define ADC_ACTL_ADCG_MASK (7U << ADC_ACTL_ADCG_SHIFT) -#define ADC_ACTL_ADCIS_SHIFT 17 -#define ADC_ACTL_ADCIS_MASK (7U << ADC_ACTL_ADCIS_SHIFT) -#define ADC_IS_LINEIN 0 -#define ADC_IS_FMIN 1 -#define ADC_IS_MIC1 2 -#define ADC_IS_MIC2 3 -#define ADC_IS_MIC1_L_MIC2_R 4 -#define ADC_IS_MIC1_LR_MIC2_LR 5 -#define ADC_IS_OMIX 6 -#define ADC_IS_LINEIN_L_MIC1_R 7 -#define ADC_ACTL_LNRDF (1U << 16) -#define ADC_ACTL_LNPREG_SHIFT 13 -#define ADC_ACTL_LNPREG_MASK (7U << ADC_ACTL_LNPREG_SHIFT) -#define ADC_ACTL_PA_EN (1U << 4) -#define ADC_ACTL_DDE (1U << 3) -#define AC_DAC_CNT 0x30 -#define AC_ADC_CNT 0x34 +#define AC_ADC_FIFOS(_sc) ((_sc)->cfg->ADC_FIFOS) +#define AC_ADC_RXDATA(_sc) ((_sc)->cfg->ADC_RXDATA) +#define AC_DAC_CNT(_sc) ((_sc)->cfg->DAC_CNT) +#define AC_ADC_CNT(_sc) ((_sc)->cfg->ADC_CNT) static uint32_t a10codec_fmt[] = { SND_FORMAT(AFMT_S16_LE, 1, 0), @@ -168,14 +164,13 @@ struct a10codec_chinfo { struct a10codec_info { device_t dev; - struct resource *res[2]; + struct resource *res[3]; struct mtx *lock; bus_dma_tag_t dmat; unsigned dmasize; void *ih; - unsigned drqtype_codec; - unsigned drqtype_sdram; + struct a10codec_config *cfg; struct a10codec_chinfo play; struct a10codec_chinfo rec; @@ -183,6 +178,7 @@ struct a10codec_info { static struct resource_spec a10codec_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_OPTIONAL }, { SYS_RES_IRQ, 0, RF_ACTIVE }, { -1, 0 } }; @@ -191,127 +187,417 @@ static struct resource_spec a10codec_spe #define CODEC_WRITE(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val)) /* - * Mixer interface + * A10/A20 mixer interface */ +#define A10_DAC_ACTL 0x10 +#define A10_DACAREN (1U << 31) +#define A10_DACALEN (1U << 30) +#define A10_MIXEN (1U << 29) +#define A10_DACPAS (1U << 8) +#define A10_PAMUTE (1U << 6) +#define A10_PAVOL_SHIFT 0 +#define A10_PAVOL_MASK (0x3f << A10_PAVOL_SHIFT) +#define A10_ADC_ACTL 0x28 +#define A10_ADCREN (1U << 31) +#define A10_ADCLEN (1U << 30) +#define A10_PREG1EN (1U << 29) +#define A10_PREG2EN (1U << 28) +#define A10_VMICEN (1U << 27) +#define A10_ADCG_SHIFT 20 +#define A10_ADCG_MASK (7U << A10_ADCG_SHIFT) +#define A10_ADCIS_SHIFT 17 +#define A10_ADCIS_MASK (7U << A10_ADCIS_SHIFT) +#define A10_ADC_IS_LINEIN 0 +#define A10_ADC_IS_FMIN 1 +#define A10_ADC_IS_MIC1 2 +#define A10_ADC_IS_MIC2 3 +#define A10_ADC_IS_MIC1_L_MIC2_R 4 +#define A10_ADC_IS_MIC1_LR_MIC2_LR 5 +#define A10_ADC_IS_OMIX 6 +#define A10_ADC_IS_LINEIN_L_MIC1_R 7 +#define A10_LNRDF (1U << 16) +#define A10_LNPREG_SHIFT 13 +#define A10_LNPREG_MASK (7U << A10_LNPREG_SHIFT) +#define A10_PA_EN (1U << 4) +#define A10_DDE (1U << 3) + static int -a10codec_mixer_init(struct snd_mixer *m) +a10_mixer_init(struct snd_mixer *m) { struct a10codec_info *sc = mix_getdevinfo(m); - pcell_t prop[4]; - phandle_t node; - device_t gpio; uint32_t val; - ssize_t len; - int pin; mix_setdevs(m, SOUND_MASK_VOLUME | SOUND_MASK_LINE | SOUND_MASK_RECLEV); mix_setrecdevs(m, SOUND_MASK_LINE | SOUND_MASK_LINE1 | SOUND_MASK_MIC); /* Unmute input source to PA */ - val = CODEC_READ(sc, AC_DAC_ACTL); - val |= DAC_ACTL_PAMUTE; - CODEC_WRITE(sc, AC_DAC_ACTL, val); + val = CODEC_READ(sc, A10_DAC_ACTL); + val |= A10_PAMUTE; + CODEC_WRITE(sc, A10_DAC_ACTL, val); /* Enable PA */ - val = CODEC_READ(sc, AC_ADC_ACTL); - val |= ADC_ACTL_PA_EN; - CODEC_WRITE(sc, AC_ADC_ACTL, val); - - /* Unmute PA */ - node = ofw_bus_get_node(sc->dev); - len = OF_getencprop(node, "allwinner,pa-gpios", prop, sizeof(prop)); - if (len > 0 && (len / sizeof(prop[0])) == 4) { - gpio = OF_device_from_xref(prop[0]); - if (gpio != NULL) { - pin = prop[1] * 32 + prop[2]; - GPIO_PIN_SETFLAGS(gpio, pin, GPIO_PIN_OUTPUT); - GPIO_PIN_SET(gpio, pin, GPIO_PIN_LOW); - } - } + val = CODEC_READ(sc, A10_ADC_ACTL); + val |= A10_PA_EN; + CODEC_WRITE(sc, A10_ADC_ACTL, val); return (0); } -static const struct a10codec_mixer { +static const struct a10_mixer { unsigned reg; unsigned mask; unsigned shift; -} a10codec_mixers[SOUND_MIXER_NRDEVICES] = { - [SOUND_MIXER_VOLUME] = { AC_DAC_ACTL, DAC_ACTL_PAVOL_MASK, - DAC_ACTL_PAVOL_SHIFT }, - [SOUND_MIXER_LINE] = { AC_ADC_ACTL, ADC_ACTL_LNPREG_MASK, - ADC_ACTL_LNPREG_SHIFT }, - [SOUND_MIXER_RECLEV] = { AC_ADC_ACTL, ADC_ACTL_ADCG_MASK, - ADC_ACTL_ADCG_SHIFT }, +} a10_mixers[SOUND_MIXER_NRDEVICES] = { + [SOUND_MIXER_VOLUME] = { A10_DAC_ACTL, A10_PAVOL_MASK, + A10_PAVOL_SHIFT }, + [SOUND_MIXER_LINE] = { A10_ADC_ACTL, A10_LNPREG_MASK, + A10_LNPREG_SHIFT }, + [SOUND_MIXER_RECLEV] = { A10_ADC_ACTL, A10_ADCG_MASK, + A10_ADCG_SHIFT }, }; static int -a10codec_mixer_set(struct snd_mixer *m, unsigned dev, unsigned left, +a10_mixer_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) { struct a10codec_info *sc = mix_getdevinfo(m); uint32_t val; unsigned nvol, max; - max = a10codec_mixers[dev].mask >> a10codec_mixers[dev].shift; + max = a10_mixers[dev].mask >> a10_mixers[dev].shift; nvol = (left * max) / 100; - val = CODEC_READ(sc, a10codec_mixers[dev].reg); - val &= ~a10codec_mixers[dev].mask; - val |= (nvol << a10codec_mixers[dev].shift); - CODEC_WRITE(sc, a10codec_mixers[dev].reg, val); + val = CODEC_READ(sc, a10_mixers[dev].reg); + val &= ~a10_mixers[dev].mask; + val |= (nvol << a10_mixers[dev].shift); + CODEC_WRITE(sc, a10_mixers[dev].reg, val); left = right = (left * 100) / max; return (left | (right << 8)); } static uint32_t -a10codec_mixer_setrecsrc(struct snd_mixer *m, uint32_t src) +a10_mixer_setrecsrc(struct snd_mixer *m, uint32_t src) { struct a10codec_info *sc = mix_getdevinfo(m); uint32_t val; - val = CODEC_READ(sc, AC_ADC_ACTL); + val = CODEC_READ(sc, A10_ADC_ACTL); switch (src) { case SOUND_MASK_LINE: /* line-in */ - val &= ~ADC_ACTL_ADCIS_MASK; - val |= (ADC_IS_LINEIN << ADC_ACTL_ADCIS_SHIFT); + val &= ~A10_ADCIS_MASK; + val |= (A10_ADC_IS_LINEIN << A10_ADCIS_SHIFT); break; case SOUND_MASK_MIC: /* MIC1 */ - val &= ~ADC_ACTL_ADCIS_MASK; - val |= (ADC_IS_MIC1 << ADC_ACTL_ADCIS_SHIFT); + val &= ~A10_ADCIS_MASK; + val |= (A10_ADC_IS_MIC1 << A10_ADCIS_SHIFT); break; case SOUND_MASK_LINE1: /* MIC2 */ - val &= ~ADC_ACTL_ADCIS_MASK; - val |= (ADC_IS_MIC2 << ADC_ACTL_ADCIS_SHIFT); + val &= ~A10_ADCIS_MASK; + val |= (A10_ADC_IS_MIC2 << A10_ADCIS_SHIFT); break; default: break; } - CODEC_WRITE(sc, AC_ADC_ACTL, val); + CODEC_WRITE(sc, A10_ADC_ACTL, val); - switch ((val & ADC_ACTL_ADCIS_MASK) >> ADC_ACTL_ADCIS_SHIFT) { - case ADC_IS_LINEIN: + switch ((val & A10_ADCIS_MASK) >> A10_ADCIS_SHIFT) { + case A10_ADC_IS_LINEIN: return (SOUND_MASK_LINE); - case ADC_IS_MIC1: + case A10_ADC_IS_MIC1: return (SOUND_MASK_MIC); - case ADC_IS_MIC2: + case A10_ADC_IS_MIC2: return (SOUND_MASK_LINE1); default: return (0); } } -static kobj_method_t a10codec_mixer_methods[] = { - KOBJMETHOD(mixer_init, a10codec_mixer_init), - KOBJMETHOD(mixer_set, a10codec_mixer_set), - KOBJMETHOD(mixer_setrecsrc, a10codec_mixer_setrecsrc), +static void +a10_mute(struct a10codec_info *sc, int mute, int dir) +{ + uint32_t val; + + if (dir == PCMDIR_PLAY) { + val = CODEC_READ(sc, A10_DAC_ACTL); + if (mute) { + /* Disable DAC analog l/r channels and output mixer */ + val &= ~A10_DACAREN; + val &= ~A10_DACALEN; + val &= ~A10_DACPAS; + } else { + /* Enable DAC analog l/r channels and output mixer */ + val |= A10_DACAREN; + val |= A10_DACALEN; + val |= A10_DACPAS; + } + CODEC_WRITE(sc, A10_DAC_ACTL, val); + } else { + val = CODEC_READ(sc, A10_ADC_ACTL); + if (mute) { + /* Disable ADC analog l/r channels, MIC1 preamp, + * and VMIC pin voltage + */ + val &= ~A10_ADCREN; + val &= ~A10_ADCLEN; + val &= ~A10_PREG1EN; + val &= ~A10_VMICEN; + } else { + /* Enable ADC analog l/r channels, MIC1 preamp, + * and VMIC pin voltage + */ + val |= A10_ADCREN; + val |= A10_ADCLEN; + val |= A10_PREG1EN; + val |= A10_VMICEN; + } + CODEC_WRITE(sc, A10_ADC_ACTL, val); + } +} + +static kobj_method_t a10_mixer_methods[] = { + KOBJMETHOD(mixer_init, a10_mixer_init), + KOBJMETHOD(mixer_set, a10_mixer_set), + KOBJMETHOD(mixer_setrecsrc, a10_mixer_setrecsrc), KOBJMETHOD_END }; -MIXER_DECLARE(a10codec_mixer); +MIXER_DECLARE(a10_mixer); + + +/* + * H3 mixer interface + */ + +#define H3_PR_CFG 0x00 +#define H3_AC_PR_RST (1 << 18) +#define H3_AC_PR_RW (1 << 24) +#define H3_AC_PR_ADDR_SHIFT 16 +#define H3_AC_PR_ADDR_MASK (0x1f << H3_AC_PR_ADDR_SHIFT) +#define H3_ACDA_PR_WDAT_SHIFT 8 +#define H3_ACDA_PR_WDAT_MASK (0xff << H3_ACDA_PR_WDAT_SHIFT) +#define H3_ACDA_PR_RDAT_SHIFT 0 +#define H3_ACDA_PR_RDAT_MASK (0xff << H3_ACDA_PR_RDAT_SHIFT) + +#define H3_LOMIXSC 0x01 +#define H3_LOMIXSC_LDAC (1 << 1) +#define H3_ROMIXSC 0x02 +#define H3_ROMIXSC_RDAC (1 << 1) +#define H3_DAC_PA_SRC 0x03 +#define H3_DACAREN (1 << 7) +#define H3_DACALEN (1 << 6) +#define H3_RMIXEN (1 << 5) +#define H3_LMIXEN (1 << 4) +#define H3_LINEIN_GCTR 0x05 +#define H3_LINEING_SHIFT 4 +#define H3_LINEING_MASK (0x7 << H3_LINEING_SHIFT) +#define H3_MIC_GCTR 0x06 +#define H3_MIC1_GAIN_SHIFT 4 +#define H3_MIC1_GAIN_MASK (0x7 << H3_MIC1_GAIN_SHIFT) +#define H3_MIC2_GAIN_SHIFT 0 +#define H3_MIC2_GAIN_MASK (0x7 << H3_MIC2_GAIN_SHIFT) +#define H3_PAEN_CTR 0x07 +#define H3_LINEOUTEN (1 << 7) +#define H3_LINEOUT_VOLC 0x09 +#define H3_LINEOUTVOL_SHIFT 3 +#define H3_LINEOUTVOL_MASK (0x1f << H3_LINEOUTVOL_SHIFT) +#define H3_MIC2G_LINEOUT_CTR 0x0a +#define H3_LINEOUT_LSEL (1 << 3) +#define H3_LINEOUT_RSEL (1 << 2) +#define H3_LADCMIXSC 0x0c +#define H3_RADCMIXSC 0x0d +#define H3_ADCMIXSC_MIC1 (1 << 6) +#define H3_ADCMIXSC_MIC2 (1 << 5) +#define H3_ADCMIXSC_LINEIN (1 << 2) +#define H3_ADCMIXSC_OMIXER (3 << 0) +#define H3_ADC_AP_EN 0x0f +#define H3_ADCREN (1 << 7) +#define H3_ADCLEN (1 << 6) +#define H3_ADCG_SHIFT 0 +#define H3_ADCG_MASK (0x7 << H3_ADCG_SHIFT) + +static u_int +h3_pr_read(struct a10codec_info *sc, u_int addr) +{ + uint32_t val; + + /* Read current value */ + val = bus_read_4(sc->res[1], H3_PR_CFG); + + /* De-assert reset */ + val |= H3_AC_PR_RST; + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Read mode */ + val &= ~H3_AC_PR_RW; + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Set address */ + val &= ~H3_AC_PR_ADDR_MASK; + val |= (addr << H3_AC_PR_ADDR_SHIFT); + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Read data */ + return (bus_read_4(sc->res[1], H3_PR_CFG) & H3_ACDA_PR_RDAT_MASK); +} + +static void +h3_pr_write(struct a10codec_info *sc, u_int addr, u_int data) +{ + uint32_t val; + + /* Read current value */ + val = bus_read_4(sc->res[1], H3_PR_CFG); + + /* De-assert reset */ + val |= H3_AC_PR_RST; + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Set address */ + val &= ~H3_AC_PR_ADDR_MASK; + val |= (addr << H3_AC_PR_ADDR_SHIFT); + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Write data */ + val &= ~H3_ACDA_PR_WDAT_MASK; + val |= (data << H3_ACDA_PR_WDAT_SHIFT); + bus_write_4(sc->res[1], H3_PR_CFG, val); + + /* Write mode */ + val |= H3_AC_PR_RW; + bus_write_4(sc->res[1], H3_PR_CFG, val); +} + +static void +h3_pr_set_clear(struct a10codec_info *sc, u_int addr, u_int set, u_int clr) +{ + u_int old, new; + + old = h3_pr_read(sc, addr); + new = set | (old & ~clr); + h3_pr_write(sc, addr, new); +} + +static int +h3_mixer_init(struct snd_mixer *m) +{ + struct a10codec_info *sc = mix_getdevinfo(m); + + mix_setdevs(m, SOUND_MASK_PCM | SOUND_MASK_VOLUME | SOUND_MASK_RECLEV | + SOUND_MASK_MIC | SOUND_MASK_LINE | SOUND_MASK_LINE1); + mix_setrecdevs(m, SOUND_MASK_MIC | SOUND_MASK_LINE | SOUND_MASK_LINE1 | + SOUND_MASK_IMIX); + + pcm_setflags(sc->dev, pcm_getflags(sc->dev) | SD_F_SOFTPCMVOL); + + /* Right & Left LINEOUT enable */ + h3_pr_set_clear(sc, H3_PAEN_CTR, H3_LINEOUTEN, 0); + h3_pr_set_clear(sc, H3_MIC2G_LINEOUT_CTR, + H3_LINEOUT_LSEL | H3_LINEOUT_RSEL, 0); + + return (0); +} + +static const struct h3_mixer { + unsigned reg; + unsigned mask; + unsigned shift; +} h3_mixers[SOUND_MIXER_NRDEVICES] = { + [SOUND_MIXER_VOLUME] = { H3_LINEOUT_VOLC, H3_LINEOUTVOL_MASK, + H3_LINEOUTVOL_SHIFT }, + [SOUND_MIXER_RECLEV] = { H3_ADC_AP_EN, H3_ADCG_MASK, + H3_ADCG_SHIFT }, + [SOUND_MIXER_LINE] = { H3_LINEIN_GCTR, H3_LINEING_MASK, + H3_LINEING_SHIFT }, + [SOUND_MIXER_MIC] = { H3_MIC_GCTR, H3_MIC1_GAIN_MASK, + H3_MIC1_GAIN_SHIFT }, + [SOUND_MIXER_LINE1] = { H3_MIC_GCTR, H3_MIC2_GAIN_MASK, + H3_MIC2_GAIN_SHIFT }, +}; + +static int +h3_mixer_set(struct snd_mixer *m, unsigned dev, unsigned left, + unsigned right) +{ + struct a10codec_info *sc = mix_getdevinfo(m); + unsigned nvol, max; + + max = h3_mixers[dev].mask >> h3_mixers[dev].shift; + nvol = (left * max) / 100; + + h3_pr_set_clear(sc, h3_mixers[dev].reg, + nvol << h3_mixers[dev].shift, h3_mixers[dev].mask); + + left = right = (left * 100) / max; + return (left | (right << 8)); +} + +static uint32_t +h3_mixer_setrecsrc(struct snd_mixer *m, uint32_t src) +{ + struct a10codec_info *sc = mix_getdevinfo(m); + uint32_t val; + + val = 0; + src &= (SOUND_MASK_LINE | SOUND_MASK_MIC | + SOUND_MASK_LINE1 | SOUND_MASK_IMIX); + + if ((src & SOUND_MASK_LINE) != 0) /* line-in */ + val |= H3_ADCMIXSC_LINEIN; + if ((src & SOUND_MASK_MIC) != 0) /* MIC1 */ + val |= H3_ADCMIXSC_MIC1; + if ((src & SOUND_MASK_LINE1) != 0) /* MIC2 */ + val |= H3_ADCMIXSC_MIC2; + if ((src & SOUND_MASK_IMIX) != 0) /* l/r output mixer */ + val |= H3_ADCMIXSC_OMIXER; + + h3_pr_write(sc, H3_LADCMIXSC, val); + h3_pr_write(sc, H3_RADCMIXSC, val); + + return (src); +} + +static void +h3_mute(struct a10codec_info *sc, int mute, int dir) +{ + if (dir == PCMDIR_PLAY) { + if (mute) { + /* Mute DAC l/r channels to output mixer */ + h3_pr_set_clear(sc, H3_LOMIXSC, 0, H3_LOMIXSC_LDAC); + h3_pr_set_clear(sc, H3_ROMIXSC, 0, H3_ROMIXSC_RDAC); + /* Disable DAC analog l/r channels and output mixer */ + h3_pr_set_clear(sc, H3_DAC_PA_SRC, + 0, H3_DACAREN | H3_DACALEN | H3_RMIXEN | H3_LMIXEN); + } else { + /* Enable DAC analog l/r channels and output mixer */ + h3_pr_set_clear(sc, H3_DAC_PA_SRC, + H3_DACAREN | H3_DACALEN | H3_RMIXEN | H3_LMIXEN, 0); + /* Unmute DAC l/r channels to output mixer */ + h3_pr_set_clear(sc, H3_LOMIXSC, H3_LOMIXSC_LDAC, 0); + h3_pr_set_clear(sc, H3_ROMIXSC, H3_ROMIXSC_RDAC, 0); + } + } else { + if (mute) { + /* Disable ADC analog l/r channels */ + h3_pr_set_clear(sc, H3_ADC_AP_EN, + 0, H3_ADCREN | H3_ADCLEN); + } else { + /* Enable ADC analog l/r channels */ + h3_pr_set_clear(sc, H3_ADC_AP_EN, + H3_ADCREN | H3_ADCLEN, 0); + } + } +} + +static kobj_method_t h3_mixer_methods[] = { + KOBJMETHOD(mixer_init, h3_mixer_init), + KOBJMETHOD(mixer_set, h3_mixer_set), + KOBJMETHOD(mixer_setrecsrc, h3_mixer_setrecsrc), + KOBJMETHOD_END +}; +MIXER_DECLARE(h3_mixer); /* @@ -364,12 +650,12 @@ a10codec_dmaconfig(struct a10codec_chinf if (ch->dir == PCMDIR_PLAY) { conf.dst_noincr = true; - conf.src_drqtype = sc->drqtype_sdram; - conf.dst_drqtype = sc->drqtype_codec; + conf.src_drqtype = sc->cfg->drqtype_sdram; + conf.dst_drqtype = sc->cfg->drqtype_codec; } else { conf.src_noincr = true; - conf.src_drqtype = sc->drqtype_codec; - conf.dst_drqtype = sc->drqtype_sdram; + conf.src_drqtype = sc->cfg->drqtype_codec; + conf.dst_drqtype = sc->cfg->drqtype_sdram; } SUNXI_DMA_SET_CONFIG(ch->dmac, ch->dmachan, &conf); @@ -428,23 +714,20 @@ a10codec_start(struct a10codec_chinfo *c if (ch->dir == PCMDIR_PLAY) { /* Flush DAC FIFO */ - CODEC_WRITE(sc, AC_DAC_FIFOC, DAC_FIFOC_FIFO_FLUSH); + CODEC_WRITE(sc, AC_DAC_FIFOC(sc), DAC_FIFOC_FIFO_FLUSH); /* Clear DAC FIFO status */ - CODEC_WRITE(sc, AC_DAC_FIFOS, CODEC_READ(sc, AC_DAC_FIFOS)); + CODEC_WRITE(sc, AC_DAC_FIFOS(sc), + CODEC_READ(sc, AC_DAC_FIFOS(sc))); - /* Enable DAC analog left/right channels and output mixer */ - val = CODEC_READ(sc, AC_DAC_ACTL); - val |= DAC_ACTL_DACAREN; - val |= DAC_ACTL_DACALEN; - val |= DAC_ACTL_DACPAS; - CODEC_WRITE(sc, AC_DAC_ACTL, val); + /* Unmute output */ + sc->cfg->mute(sc, 0, ch->dir); /* Configure DAC DMA channel */ a10codec_dmaconfig(ch); /* Configure DAC FIFO */ - CODEC_WRITE(sc, AC_DAC_FIFOC, + CODEC_WRITE(sc, AC_DAC_FIFOC(sc), (AFMT_CHANNEL(ch->format) == 1 ? DAC_FIFOC_MONO_EN : 0) | (a10codec_fs(ch) << DAC_FIFOC_FS_SHIFT) | (FIFO_MODE_16_15_0 << DAC_FIFOC_FIFO_MODE_SHIFT) | @@ -452,31 +735,25 @@ a10codec_start(struct a10codec_chinfo *c (TX_TRIG_LEVEL << DAC_FIFOC_TX_TRIG_LEVEL_SHIFT)); /* Enable DAC DRQ */ - val = CODEC_READ(sc, AC_DAC_FIFOC); + val = CODEC_READ(sc, AC_DAC_FIFOC(sc)); val |= DAC_FIFOC_DRQ_EN; - CODEC_WRITE(sc, AC_DAC_FIFOC, val); + CODEC_WRITE(sc, AC_DAC_FIFOC(sc), val); } else { /* Flush ADC FIFO */ - CODEC_WRITE(sc, AC_ADC_FIFOC, ADC_FIFOC_FIFO_FLUSH); + CODEC_WRITE(sc, AC_ADC_FIFOC(sc), ADC_FIFOC_FIFO_FLUSH); /* Clear ADC FIFO status */ - CODEC_WRITE(sc, AC_ADC_FIFOS, CODEC_READ(sc, AC_ADC_FIFOS)); + CODEC_WRITE(sc, AC_ADC_FIFOS(sc), + CODEC_READ(sc, AC_ADC_FIFOS(sc))); - /* Enable ADC analog left/right channels, MIC1 preamp, - * and VMIC pin voltage - */ - val = CODEC_READ(sc, AC_ADC_ACTL); - val |= ADC_ACTL_ADCREN; - val |= ADC_ACTL_ADCLEN; - val |= ADC_ACTL_PREG1EN; - val |= ADC_ACTL_VMICEN; - CODEC_WRITE(sc, AC_ADC_ACTL, val); + /* Unmute input */ + sc->cfg->mute(sc, 0, ch->dir); /* Configure ADC DMA channel */ a10codec_dmaconfig(ch); /* Configure ADC FIFO */ - CODEC_WRITE(sc, AC_ADC_FIFOC, + CODEC_WRITE(sc, AC_ADC_FIFOC(sc), ADC_FIFOC_EN_AD | ADC_FIFOC_RX_FIFO_MODE | (AFMT_CHANNEL(ch->format) == 1 ? ADC_FIFOC_MONO_EN : 0) | @@ -484,9 +761,9 @@ a10codec_start(struct a10codec_chinfo *c (RX_TRIG_LEVEL << ADC_FIFOC_RX_TRIG_LEVEL_SHIFT)); /* Enable ADC DRQ */ - val = CODEC_READ(sc, AC_ADC_FIFOC); + val = CODEC_READ(sc, AC_ADC_FIFOC(sc)); val |= ADC_FIFOC_DRQ_EN; - CODEC_WRITE(sc, AC_ADC_FIFOC, val); + CODEC_WRITE(sc, AC_ADC_FIFOC(sc), val); } /* Start DMA transfer */ @@ -497,34 +774,18 @@ static void a10codec_stop(struct a10codec_chinfo *ch) { struct a10codec_info *sc = ch->parent; - uint32_t val; /* Disable DMA channel */ SUNXI_DMA_HALT(ch->dmac, ch->dmachan); - if (ch->dir == PCMDIR_PLAY) { - /* Disable DAC analog left/right channels and output mixer */ - val = CODEC_READ(sc, AC_DAC_ACTL); - val &= ~DAC_ACTL_DACAREN; - val &= ~DAC_ACTL_DACALEN; - val &= ~DAC_ACTL_DACPAS; - CODEC_WRITE(sc, AC_DAC_ACTL, val); + sc->cfg->mute(sc, 1, ch->dir); + if (ch->dir == PCMDIR_PLAY) { /* Disable DAC DRQ */ - CODEC_WRITE(sc, AC_DAC_FIFOC, 0); + CODEC_WRITE(sc, AC_DAC_FIFOC(sc), 0); } else { - /* Disable ADC analog left/right channels, MIC1 preamp, - * and VMIC pin voltage - */ - val = CODEC_READ(sc, AC_ADC_ACTL); - val &= ~ADC_ACTL_ADCREN; - val &= ~ADC_ACTL_ADCLEN; - val &= ~ADC_ACTL_PREG1EN; - val &= ~ADC_ACTL_VMICEN; - CODEC_WRITE(sc, AC_ADC_ACTL, val); - /* Disable ADC DRQ */ - CODEC_WRITE(sc, AC_ADC_FIFOC, 0); + CODEC_WRITE(sc, AC_ADC_FIFOC(sc), 0); } } @@ -534,18 +795,30 @@ a10codec_chan_init(kobj_t obj, void *dev { struct a10codec_info *sc = devinfo; struct a10codec_chinfo *ch = dir == PCMDIR_PLAY ? &sc->play : &sc->rec; - int error; + phandle_t xref; + pcell_t *cells; + int ncells, error; + + error = ofw_bus_parse_xref_list_alloc(ofw_bus_get_node(sc->dev), + "dmas", "#dma-cells", dir == PCMDIR_PLAY ? 1 : 0, + &xref, &ncells, &cells); + if (error != 0) { + device_printf(sc->dev, "cannot parse 'dmas' property\n"); + return (NULL); + } + OF_prop_free(cells); ch->parent = sc; ch->channel = c; ch->buffer = b; ch->dir = dir; ch->fifo = rman_get_start(sc->res[0]) + - (dir == PCMDIR_REC ? AC_ADC_RXDATA : AC_DAC_TXDATA); + (dir == PCMDIR_REC ? AC_ADC_RXDATA(sc) : AC_DAC_TXDATA(sc)); - ch->dmac = devclass_get_device(devclass_find("a10dmac"), 0); + ch->dmac = OF_device_from_xref(xref); if (ch->dmac == NULL) { device_printf(sc->dev, "cannot find DMA controller\n"); + device_printf(sc->dev, "xref = 0x%x\n", (u_int)xref); return (NULL); } ch->dmachan = SUNXI_DMA_ALLOC(ch->dmac, false, a10codec_dmaintr, ch); @@ -720,10 +993,43 @@ CHANNEL_DECLARE(a10codec_chan); * Device interface */ +static const struct a10codec_config a10_config = { + .mixer_class = &a10_mixer_class, + .mute = a10_mute, + .drqtype_codec = 19, + .drqtype_sdram = 22, + .DPC = 0x00, + .DAC_FIFOC = 0x04, + .DAC_FIFOS = 0x08, + .DAC_TXDATA = 0x0c, + .ADC_FIFOC = 0x1c, + .ADC_FIFOS = 0x20, + .ADC_RXDATA = 0x24, + .DAC_CNT = 0x30, + .ADC_CNT = 0x34, +}; + +static const struct a10codec_config h3_config = { + .mixer_class = &h3_mixer_class, + .mute = h3_mute, + .drqtype_codec = 15, + .drqtype_sdram = 1, + .DPC = 0x00, + .DAC_FIFOC = 0x04, + .DAC_FIFOS = 0x08, + .DAC_TXDATA = 0x20, + .ADC_FIFOC = 0x10, + .ADC_FIFOS = 0x14, + .ADC_RXDATA = 0x18, + .DAC_CNT = 0x40, + .ADC_CNT = 0x44, +}; + static struct ofw_compat_data compat_data[] = { - {"allwinner,sun4i-a10-codec", 1}, - {"allwinner,sun7i-a20-codec", 1}, - {NULL, 0}, + { "allwinner,sun4i-a10-codec", (uintptr_t)&a10_config }, + { "allwinner,sun7i-a20-codec", (uintptr_t)&a10_config }, + { "allwinner,sun8i-h3-codec", (uintptr_t)&h3_config }, + { NULL, 0 } }; static int @@ -744,11 +1050,17 @@ a10codec_attach(device_t dev) { struct a10codec_info *sc; char status[SND_STATUSLEN]; - clk_t clk_apb, clk_codec; + struct gpiobus_pin *pa_pin; + phandle_t node; + clk_t clk_bus, clk_codec; + hwreset_t rst; uint32_t val; int error; + node = ofw_bus_get_node(dev); + sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); + sc->cfg = (void *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; sc->dev = dev; sc->lock = snd_mtxcreate(device_get_nameunit(dev), "a10codec softc"); @@ -758,17 +1070,6 @@ a10codec_attach(device_t dev) goto fail; } - /* XXX DRQ types should come from FDT, but how? */ - if (ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-codec") || - ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-codec")) { - sc->drqtype_codec = 19; - sc->drqtype_sdram = 22; - } else { - device_printf(dev, "DRQ types not known for this SoC\n"); - error = ENXIO; - goto fail; - } - sc->dmasize = 131072; error = bus_dma_tag_create( bus_get_dma_tag(dev), @@ -786,21 +1087,19 @@ a10codec_attach(device_t dev) } /* Get clocks */ - error = clk_get_by_ofw_name(dev, 0, "apb", &clk_apb); - if (error != 0) { - device_printf(dev, "cannot find apb clock\n"); + if (clk_get_by_ofw_name(dev, 0, "apb", &clk_bus) != 0 && + clk_get_by_ofw_name(dev, 0, "ahb", &clk_bus) != 0) { + device_printf(dev, "cannot find bus clock\n"); goto fail; } - error = clk_get_by_ofw_name(dev, 0, "codec", &clk_codec); - if (error != 0) { + if (clk_get_by_ofw_name(dev, 0, "codec", &clk_codec) != 0) { device_printf(dev, "cannot find codec clock\n"); goto fail; } - /* Gating APB clock for codec */ - error = clk_enable(clk_apb); - if (error != 0) { - device_printf(dev, "cannot enable apb clock\n"); + /* Gating bus clock for codec */ + if (clk_enable(clk_bus) != 0) { + device_printf(dev, "cannot enable bus clock\n"); goto fail; } /* Activate audio codec clock. According to the A10 and A20 user @@ -824,10 +1123,20 @@ a10codec_attach(device_t dev) goto fail; } + /* De-assert hwreset */ + if (hwreset_get_by_ofw_name(dev, 0, "apb", &rst) == 0 || + hwreset_get_by_ofw_name(dev, 0, "ahb", &rst) == 0) { + error = hwreset_deassert(rst); + if (error != 0) { + device_printf(dev, "cannot de-assert reset\n"); + goto fail; + } + } + /* Enable DAC */ - val = CODEC_READ(sc, AC_DAC_DPC); + val = CODEC_READ(sc, AC_DAC_DPC(sc)); val |= DAC_DPC_EN_DA; - CODEC_WRITE(sc, AC_DAC_DPC, val); + CODEC_WRITE(sc, AC_DAC_DPC(sc), val); #ifdef notdef error = snd_setup_intr(dev, sc->irq, INTR_MPSAFE, a10codec_intr, sc, @@ -838,11 +1147,19 @@ a10codec_attach(device_t dev) } #endif - if (mixer_init(dev, &a10codec_mixer_class, sc)) { + if (mixer_init(dev, sc->cfg->mixer_class, sc)) { device_printf(dev, "mixer_init failed\n"); goto fail; } + /* Unmute PA */ + if (gpio_pin_get_by_ofw_property(dev, node, "allwinner,pa-gpios", + &pa_pin) == 0) { + error = gpio_pin_set_active(pa_pin, 1); + if (error != 0) + device_printf(dev, "failed to unmute PA\n"); + } + pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE); if (pcm_register(dev, sc, 1, 1)) { @@ -863,7 +1180,7 @@ fail: snd_mtxfree(sc->lock); free(sc, M_DEVBUF); - return (error); + return (ENXIO); } static device_method_t a10codec_pcm_methods[] = { From owner-svn-src-head@freebsd.org Thu Nov 3 23:34:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29B32C2EABA; Thu, 3 Nov 2016 23:34:13 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B99E2134B; Thu, 3 Nov 2016 23:34:12 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA3NYCh0021134; Thu, 3 Nov 2016 23:34:12 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA3NYB2Y021129; Thu, 3 Nov 2016 23:34:11 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201611032334.uA3NYB2Y021129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 3 Nov 2016 23:34:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308270 - head/contrib/tzdata X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2016 23:34:13 -0000 Author: gjb Date: Thu Nov 3 23:34:11 2016 New Revision: 308270 URL: https://svnweb.freebsd.org/changeset/base/308270 Log: MFV r308265: Update tzdata to 2016i. Sponsored by: The FreeBSD Foundation Added: head/contrib/tzdata/CONTRIBUTING - copied unchanged from r308265, vendor/tzdata/dist/CONTRIBUTING head/contrib/tzdata/LICENSE - copied unchanged from r308265, vendor/tzdata/dist/LICENSE head/contrib/tzdata/Makefile - copied unchanged from r308265, vendor/tzdata/dist/Makefile head/contrib/tzdata/NEWS - copied unchanged from r308265, vendor/tzdata/dist/NEWS head/contrib/tzdata/README - copied unchanged from r308265, vendor/tzdata/dist/README head/contrib/tzdata/Theory - copied unchanged from r308265, vendor/tzdata/dist/Theory head/contrib/tzdata/backzone - copied unchanged from r308265, vendor/tzdata/dist/backzone head/contrib/tzdata/checklinks.awk - copied unchanged from r308265, vendor/tzdata/dist/checklinks.awk head/contrib/tzdata/checktab.awk - copied unchanged from r308265, vendor/tzdata/dist/checktab.awk head/contrib/tzdata/leapseconds.awk - copied unchanged from r308265, vendor/tzdata/dist/leapseconds.awk head/contrib/tzdata/version - copied unchanged from r308265, vendor/tzdata/dist/version head/contrib/tzdata/zoneinfo2tdf.pl - copied unchanged from r308265, vendor/tzdata/dist/zoneinfo2tdf.pl Modified: head/contrib/tzdata/antarctica head/contrib/tzdata/asia head/contrib/tzdata/australasia head/contrib/tzdata/europe head/contrib/tzdata/zone.tab head/contrib/tzdata/zone1970.tab Directory Properties: head/contrib/tzdata/ (props changed) Copied: head/contrib/tzdata/CONTRIBUTING (from r308265, vendor/tzdata/dist/CONTRIBUTING) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/tzdata/CONTRIBUTING Thu Nov 3 23:34:11 2016 (r308270, copy of r308265, vendor/tzdata/dist/CONTRIBUTING) @@ -0,0 +1,73 @@ +Contributing to the tz code and data + +The time zone database is by no means authoritative: governments +change timekeeping rules erratically and sometimes with little +warning, the data entries do not cover all of civil time before +1970, and undoubtedly errors remain in the code and data. Feel +free to fill gaps or fix mistakes, and please email improvements +to tz@iana.org for use in the future. + +To email small changes, please run a POSIX shell command like +'diff -u old/europe new/europe >myfix.patch', and attach +myfix.patch to the email. + +For more-elaborate changes, please read the Theory file and browse +the mailing list archives for +examples of patches that tend to work well. Ideally, additions to +data should contain commentary citing reliable sources as +justification. + +Please submit changes against either the latest release in + or the master branch of the experimental +Git repository. If you use Git the following workflow may be helpful: + + * Copy the experimental repository. + + git clone https://github.com/eggert/tz.git + cd tz + + * Get current with the master branch. + + git checkout master + git pull + + * Switch to a new branch for the changes. Choose a different + branch name for each change set. + + git checkout -b mybranch + + * Edit source files. Include commentary that justifies the + changes by citing reliable sources. + + * Debug the changes, e.g.: + + make check + make install + ./zdump -v America/Los_Angeles + + * For each separable change, commit it in the new branch, e.g.: + + git add northamerica + git commit + + See recent 'git log' output for the commit-message style. + + * Create patch files 0001-*, 0002-*, ... + + git format-patch master + + * After reviewing the patch files, send the patches to tz@iana.org + for others to review. + + git send-email master + + * Start anew by getting current with the master branch again + (the second step above). + +Please do not create issues or pull requests on GitHub, as the +proper procedure for proposing and distributing patches is via +email as illustrated above. + +----- + +This file is in the public domain. Copied: head/contrib/tzdata/LICENSE (from r308265, vendor/tzdata/dist/LICENSE) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/tzdata/LICENSE Thu Nov 3 23:34:11 2016 (r308270, copy of r308265, vendor/tzdata/dist/LICENSE) @@ -0,0 +1,4 @@ +With a few exceptions, all files in the tz code and data (including +this one) are in the public domain. The exceptions are date.c, +newstrftime.3, and strftime.c, which contain material derived from BSD +and which use the BSD 3-clause license. Copied: head/contrib/tzdata/Makefile (from r308265, vendor/tzdata/dist/Makefile) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/tzdata/Makefile Thu Nov 3 23:34:11 2016 (r308270, copy of r308265, vendor/tzdata/dist/Makefile) @@ -0,0 +1,793 @@ +# This file is in the public domain, so clarified as of +# 2009-05-17 by Arthur David Olson. + +# Package name for the code distribution. +PACKAGE= tzcode + +# Version number for the distribution, overridden in the 'tarballs' rule below. +VERSION= unknown + +# Email address for bug reports. +BUGEMAIL= tz@iana.org + +# Change the line below for your time zone (after finding the zone you want in +# the time zone files, or adding it to a time zone file). +# Alternately, if you discover you've got the wrong time zone, you can just +# zic -l rightzone +# to correct things. +# Use the command +# make zonenames +# to get a list of the values you can use for LOCALTIME. + +LOCALTIME= GMT + +# If you want something other than Eastern United States time as a template +# for handling POSIX-style time zone environment variables, +# change the line below (after finding the zone you want in the +# time zone files, or adding it to a time zone file). +# (When a POSIX-style environment variable is handled, the rules in the +# template file are used to determine "spring forward" and "fall back" days and +# times; the environment variable itself specifies UT offsets of standard and +# summer time.) +# Alternately, if you discover you've got the wrong time zone, you can just +# zic -p rightzone +# to correct things. +# Use the command +# make zonenames +# to get a list of the values you can use for POSIXRULES. +# If you want POSIX compatibility, use "America/New_York". + +POSIXRULES= America/New_York + +# Also see TZDEFRULESTRING below, which takes effect only +# if the time zone files cannot be accessed. + +# Everything gets put in subdirectories of. . . + +TOPDIR= /usr/local + +# "Compiled" time zone information is placed in the "TZDIR" directory +# (and subdirectories). +# Use an absolute path name for TZDIR unless you're just testing the software. + +TZDIR_BASENAME= zoneinfo +TZDIR= $(TOPDIR)/etc/$(TZDIR_BASENAME) + +# Types to try, as an alternative to time_t. int64_t should be first. +TIME_T_ALTERNATIVES= int64_t int32_t uint32_t uint64_t + +# The "tzselect", "zic", and "zdump" commands get installed in. . . + +ETCDIR= $(TOPDIR)/etc + +# If you "make INSTALL", the "date" command gets installed in. . . + +BINDIR= $(TOPDIR)/bin + +# Manual pages go in subdirectories of. . . + +MANDIR= $(TOPDIR)/man + +# Library functions are put in an archive in LIBDIR. + +LIBDIR= $(TOPDIR)/lib + +# If you always want time values interpreted as "seconds since the epoch +# (not counting leap seconds)", use +# REDO= posix_only +# below. If you always want right time values interpreted as "seconds since +# the epoch" (counting leap seconds)", use +# REDO= right_only +# below. If you want both sets of data available, with leap seconds not +# counted normally, use +# REDO= posix_right +# below. If you want both sets of data available, with leap seconds counted +# normally, use +# REDO= right_posix +# below. POSIX mandates that leap seconds not be counted; for compatibility +# with it, use "posix_only" or "posix_right". + +REDO= posix_right + +# If you want out-of-scope and often-wrong data from the file 'backzone', use +# PACKRATDATA= backzone +# To omit this data, use +# PACKRATDATA= + +PACKRATDATA= + +# Since "." may not be in PATH... + +YEARISTYPE= ./yearistype + +# Non-default libraries needed to link. +LDLIBS= + +# Add the following to the end of the "CFLAGS=" line as needed. +# -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c) +# -DHAVE_DECL_ASCTIME_R=0 if does not declare asctime_r +# -DHAVE_DIRECT_H if mkdir needs (MS-Windows) +# -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS) +# -DHAVE_GETTEXT=1 if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris) +# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares +# ctime_r and asctime_r incompatibly with the POSIX standard +# (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined). +# -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h" +# -DHAVE_LINK=0 if your system lacks a link function +# -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function +# -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz +# This defaults to 1 if a working localtime_rz seems to be available. +# localtime_rz can make zdump significantly faster, but is nonstandard. +# -DHAVE_POSIX_DECLS=0 if your system's include files do not declare +# functions like 'link' or variables like 'tzname' required by POSIX +# -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h" +# -DHAVE_STRFTIME_L=1 if declares locale_t and strftime_l +# This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise. +# -DHAVE_STRDUP=0 if your system lacks the strdup function +# -DHAVE_SYMLINK=0 if your system lacks the symlink function +# -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h" +# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h" +# -DHAVE_TZSET=0 if your system lacks a tzset function +# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?) +# -DEPOCH_LOCAL=1 if the 'time' function returns local time not UT +# -DEPOCH_OFFSET=N if the 'time' function returns a value N greater +# than what POSIX specifies, assuming local time is UT. +# For example, N is 252460800 on AmigaOS. +# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1 +# if you do not want run time warnings about formats that may cause +# year 2000 grief +# -Dssize_t=long on ancient hosts that lack ssize_t +# -DTHREAD_SAFE=1 to make localtime.c thread-safe, as POSIX requires; +# not needed by the main-program tz code, which is single-threaded. +# Append other compiler flags as needed, e.g., -pthread on GNU/Linux. +# -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t +# -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz" +# -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory; +# the default is system-supplied, typically "/usr/lib/locale" +# -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified +# DST transitions if the time zone files cannot be accessed +# -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems +# other than simply getting garbage data +# -DUSE_LTZ=0 to build zdump with the system time zone library +# Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below. +# -DZIC_MAX_ABBR_LEN_WO_WARN=3 +# (or some other number) to set the maximum time zone abbreviation length +# that zic will accept without a warning (the default is 6) +# $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking +GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \ + -Wall -Wextra \ + -Wbad-function-cast -Wcast-align -Wdate-time \ + -Wdeclaration-after-statement \ + -Wdouble-promotion \ + -Wformat=2 -Winit-self -Wjump-misses-init \ + -Wlogical-op -Wmissing-prototypes -Wnested-externs \ + -Wold-style-definition -Woverlength-strings -Wpointer-arith \ + -Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \ + -Wsuggest-attribute=format -Wsuggest-attribute=noreturn \ + -Wsuggest-attribute=pure -Wtrampolines \ + -Wunused -Wwrite-strings \ + -Wno-address -Wno-format-nonliteral -Wno-sign-compare \ + -Wno-type-limits -Wno-unused-parameter +# +# If you want to use System V compatibility code, add +# -DUSG_COMPAT +# to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight" +# variables to be kept up-to-date by the time conversion functions. Neither +# "timezone" nor "daylight" is described in X3J11's work. +# +# If your system has a "GMT offset" field in its "struct tm"s +# (or if you decide to add such a field in your system's "time.h" file), +# add the name to a define such as +# -DTM_GMTOFF=tm_gmtoff +# to the end of the "CFLAGS=" line. If not defined, the code attempts to +# guess TM_GMTOFF from other macros; define NO_TM_GMTOFF to suppress this. +# Similarly, if your system has a "zone abbreviation" field, define +# -DTM_ZONE=tm_zone +# and define NO_TM_ZONE to suppress any guessing. These two fields are not +# required by POSIX, but are widely available on GNU/Linux and BSD systems. +# +# If you want functions that were inspired by early versions of X3J11's work, +# add +# -DSTD_INSPIRED +# to the end of the "CFLAGS=" line. This arranges for the functions +# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff", +# "posix2time", and "time2posix" to be added to the time conversion library. +# "tzsetwall" is like "tzset" except that it arranges for local wall clock +# time (rather than the time specified in the TZ environment variable) +# to be used. +# "offtime" is like "gmtime" except that it accepts a second (long) argument +# that gives an offset to add to the time_t when converting it. +# "timelocal" is equivalent to "mktime". +# "timegm" is like "timelocal" except that it turns a struct tm into +# a time_t using UT (rather than local time as "timelocal" does). +# "timeoff" is like "timegm" except that it accepts a second (long) argument +# that gives an offset to use when converting to a time_t. +# "posix2time" and "time2posix" are described in an included manual page. +# X3J11's work does not describe any of these functions. +# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0. +# These functions may well disappear in future releases of the time +# conversion package. +# +# If you don't want functions that were inspired by NetBSD, add +# -DNETBSD_INSPIRED=0 +# to the end of the "CFLAGS=" line. Otherwise, the functions +# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the +# time library, and if STD_INSPIRED is also defined the functions +# "posix2time_z" and "time2posix_z" are added as well. +# The functions ending in "_z" (or "_rz") are like their unsuffixed +# (or suffixed-by-"_r") counterparts, except with an extra first +# argument of opaque type timezone_t that specifies the time zone. +# "tzalloc" allocates a timezone_t value, and "tzfree" frees it. +# +# If you want to allocate state structures in localtime, add +# -DALL_STATE +# to the end of the "CFLAGS=" line. Storage is obtained by calling malloc. +# +# If you want an "altzone" variable (a la System V Release 3.1), add +# -DALTZONE +# to the end of the "CFLAGS=" line. +# This variable is not described in X3J11's work. +# +# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put +# out by the National Institute of Standards and Technology +# which claims to test C and Posix conformance. If you want to pass PCTS, add +# -DPCTS +# to the end of the "CFLAGS=" line. +# +# If you want strict compliance with XPG4 as of 1994-04-09, add +# -DXPG4_1994_04_09 +# to the end of the "CFLAGS=" line. This causes "strftime" to always return +# 53 as a week number (rather than 52 or 53) for those days in January that +# before the first Monday in January when a "%V" format is used and January 1 +# falls on a Friday, Saturday, or Sunday. + +CFLAGS= + +# Linker flags. Default to $(LFLAGS) for backwards compatibility +# to release 2012h and earlier. + +LDFLAGS= $(LFLAGS) + +# For leap seconds, this Makefile uses LEAPSECONDS='-L leapseconds' in +# submake command lines. The default is no leap seconds. + +LEAPSECONDS= + +# The zic command and its arguments. + +zic= ./zic +ZIC= $(zic) $(ZFLAGS) + +ZFLAGS= + +# How to use zic to install tz binary files. + +ZIC_INSTALL= $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS) + +# The name of a Posix-compliant 'awk' on your system. +AWK= awk + +# The full path name of a Posix-compliant shell, preferably one that supports +# the Korn shell's 'select' statement as an extension. +# These days, Bash is the most popular. +# It should be OK to set this to /bin/sh, on platforms where /bin/sh +# lacks 'select' or doesn't completely conform to Posix, but /bin/bash +# is typically nicer if it works. +KSHELL= /bin/bash + +# The path where SGML DTDs are kept and the catalog file(s) to use when +# validating. The default should work on both Debian and Red Hat. +SGML_TOPDIR= /usr +SGML_DTDDIR= $(SGML_TOPDIR)/share/xml/w3c-sgml-lib/schema/dtd +SGML_SEARCH_PATH= $(SGML_DTDDIR)/REC-html401-19991224 +SGML_CATALOG_FILES= \ + $(SGML_TOPDIR)/share/doc/w3-recs/html/www.w3.org/TR/1999/REC-html401-19991224/HTML4.cat:$(SGML_TOPDIR)/share/sgml/html/4.01/HTML4.cat + +# The name, arguments and environment of a program to validate your web pages. +# See for a validator, and +# for a validation library. +VALIDATE = nsgmls +VALIDATE_FLAGS = -s -B -wall -wno-unused-param +VALIDATE_ENV = \ + SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \ + SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \ + SP_CHARSET_FIXED=YES \ + SP_ENCODING=UTF-8 + +# This expensive test requires USE_LTZ. +# To suppress it, define this macro to be empty. +CHECK_TIME_T_ALTERNATIVES = check_time_t_alternatives + +# SAFE_CHAR is a regular expression that matches a safe character. +# Some parts of this distribution are limited to safe characters; +# others can use any UTF-8 character. +# For now, the safe characters are a safe subset of ASCII. +# The caller must set the shell variable 'sharp' to the character '#', +# since Makefile macros cannot contain '#'. +# TAB_CHAR is a single tab character, in single quotes. +TAB_CHAR= ' ' +SAFE_CHARSET1= $(TAB_CHAR)' !\"'$$sharp'$$%&'\''()*+,./0123456789:;<=>?@' +SAFE_CHARSET2= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\^_`' +SAFE_CHARSET3= 'abcdefghijklmnopqrstuvwxyz{|}~' +SAFE_CHARSET= $(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3) +SAFE_CHAR= '[]'$(SAFE_CHARSET)'-]' + +# OK_CHAR matches any character allowed in the distributed files. +# This is the same as SAFE_CHAR, except that multibyte letters are +# also allowed so that commentary can contain people's names and quote +# non-English sources. For non-letters the sources are limited to +# ASCII renderings for the convenience of maintainers whose text editors +# mishandle UTF-8 by default (e.g., XEmacs 21.4.22). +OK_CHAR= '[][:alpha:]'$(SAFE_CHARSET)'-]' + +# SAFE_LINE matches a line of safe characters. +# SAFE_SHARP_LINE is similar, except any OK character can follow '#'; +# this is so that comments can contain non-ASCII characters. +# OK_LINE matches a line of OK characters. +SAFE_LINE= '^'$(SAFE_CHAR)'*$$' +SAFE_SHARP_LINE='^'$(SAFE_CHAR)'*('$$sharp$(OK_CHAR)'*)?$$' +OK_LINE= '^'$(OK_CHAR)'*$$' + +# Flags to give 'tar' when making a distribution. +# Try to use flags appropriate for GNU tar. +GNUTARFLAGS= --numeric-owner --owner=0 --group=0 --mode=go+u,go-w --sort=name +TARFLAGS= `if tar $(GNUTARFLAGS) --version >/dev/null 2>&1; \ + then echo $(GNUTARFLAGS); \ + else :; \ + fi` + +# Flags to give 'gzip' when making a distribution. +GZIPFLAGS= -9n + +############################################################################### + +#MAKE= make + +cc= cc +CC= $(cc) -DTZDIR=\"$(TZDIR)\" + +AR= ar + +# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib. +RANLIB= : + +TZCOBJS= zic.o +TZDOBJS= zdump.o localtime.o asctime.o +DATEOBJS= date.o localtime.o strftime.o asctime.o +LIBSRCS= localtime.c asctime.c difftime.c +LIBOBJS= localtime.o asctime.o difftime.o +HEADERS= tzfile.h private.h +NONLIBSRCS= zic.c zdump.c +NEWUCBSRCS= date.c strftime.c +SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) \ + tzselect.ksh workman.sh +MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \ + tzfile.5 tzselect.8 zic.8 zdump.8 +MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \ + time2posix.3.txt \ + tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \ + date.1.txt +COMMON= CONTRIBUTING LICENSE Makefile NEWS README Theory version +WEB_PAGES= tz-art.htm tz-how-to.html tz-link.htm +DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES) +PRIMARY_YDATA= africa antarctica asia australasia \ + europe northamerica southamerica +YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward +NDATA= systemv factory +TDATA= $(YDATA) $(NDATA) +ZONETABLES= zone1970.tab zone.tab +TABDATA= iso3166.tab leapseconds $(ZONETABLES) +LEAP_DEPS= leapseconds.awk leap-seconds.list +DATA= $(YDATA) $(NDATA) backzone $(TABDATA) \ + leap-seconds.list yearistype.sh +AWK_SCRIPTS= checklinks.awk checktab.awk leapseconds.awk +MISC= $(AWK_SCRIPTS) zoneinfo2tdf.pl +TZS_YEAR= 2050 +TZS= to$(TZS_YEAR).tzs +TZS_NEW= to$(TZS_YEAR)new.tzs +TZS_DEPS= $(PRIMARY_YDATA) asctime.c localtime.c \ + private.h tzfile.h zdump.c zic.c +ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) + +# Consult these files when deciding whether to rebuild the 'version' file. +# This list is not the same as the output of 'git ls-files', since +# .gitignore is not distributed. +VERSION_DEPS= \ + CONTRIBUTING LICENSE Makefile NEWS README Theory \ + africa antarctica asctime.c asia australasia \ + backward backzone \ + checklinks.awk checktab.awk \ + date.1 date.c difftime.c \ + etcetera europe factory iso3166.tab \ + leap-seconds.list leapseconds.awk localtime.c \ + newctime.3 newstrftime.3 newtzset.3 northamerica \ + pacificnew private.h \ + southamerica strftime.c systemv \ + time2posix.3 tz-art.htm tz-how-to.html tz-link.htm \ + tzfile.5 tzfile.h tzselect.8 tzselect.ksh \ + workman.sh yearistype.sh \ + zdump.8 zdump.c zic.8 zic.c \ + zone.tab zone1970.tab zoneinfo2tdf.pl + +# And for the benefit of csh users on systems that assume the user +# shell should be used to handle commands in Makefiles. . . + +SHELL= /bin/sh + +all: tzselect yearistype zic zdump libtz.a $(TABDATA) + +ALL: all date $(ENCHILADA) + +install: all $(DATA) $(REDO) $(MANS) + mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \ + $(DESTDIR)$(LIBDIR) \ + $(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \ + $(DESTDIR)$(MANDIR)/man8 + $(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) + cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/. + cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/. + cp libtz.a $(DESTDIR)$(LIBDIR)/. + $(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a + cp -f newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/. + cp -f tzfile.5 $(DESTDIR)$(MANDIR)/man5/. + cp -f tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/. + +INSTALL: ALL install date.1 + mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 + cp date $(DESTDIR)$(BINDIR)/. + cp -f date.1 $(DESTDIR)$(MANDIR)/man1/. + +version: $(VERSION_DEPS) + { (type git) >/dev/null 2>&1 && \ + V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \ + --abbrev=7 --dirty` || \ + V=$(VERSION); } && \ + printf '%s\n' "$$V" >$@.out + mv $@.out $@ + +version.h: version + VERSION=`cat version` && printf '%s\n' \ + 'static char const PKGVERSION[]="($(PACKAGE)) ";' \ + "static char const TZVERSION[]=\"$$VERSION\";" \ + 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";' \ + >$@.out + mv $@.out $@ + +zdump: $(TZDOBJS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZDOBJS) $(LDLIBS) + +zic: $(TZCOBJS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(TZCOBJS) $(LDLIBS) + +yearistype: yearistype.sh + cp yearistype.sh yearistype + chmod +x yearistype + +leapseconds: $(LEAP_DEPS) + $(AWK) -f leapseconds.awk leap-seconds.list >$@.out + mv $@.out $@ + +# Arguments to pass to submakes of install_data. +# They can be overridden by later submake arguments. +INSTALLARGS = \ + DESTDIR=$(DESTDIR) \ + LEAPSECONDS='$(LEAPSECONDS)' \ + PACKRATDATA='$(PACKRATDATA)' \ + TZDIR=$(TZDIR) \ + YEARISTYPE=$(YEARISTYPE) \ + ZIC='$(ZIC)' + +# 'make install_data' installs one set of tz binary files. +# It can be tailored by setting LEAPSECONDS, PACKRATDATA, etc. +install_data: zic leapseconds yearistype $(PACKRATDATA) $(TDATA) + $(ZIC_INSTALL) $(TDATA) + $(AWK) '/^Rule/' $(TDATA) | $(ZIC_INSTALL) - $(PACKRATDATA) + +posix_only: + $(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data + +right_only: + $(MAKE) $(INSTALLARGS) LEAPSECONDS='-L leapseconds' \ + install_data + +# In earlier versions of this makefile, the other two directories were +# subdirectories of $(TZDIR). However, this led to configuration errors. +# For example, with posix_right under the earlier scheme, +# TZ='right/Australia/Adelaide' got you localtime with leap seconds, +# but gmtime without leap seconds, which led to problems with applications +# like sendmail that subtract gmtime from localtime. +# Therefore, the other two directories are now siblings of $(TZDIR). +# You must replace all of $(TZDIR) to switch from not using leap seconds +# to using them, or vice versa. +right_posix: right_only + rm -fr $(DESTDIR)$(TZDIR)-leaps + ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \ + $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only + $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only + +posix_right: posix_only + rm -fr $(DESTDIR)$(TZDIR)-posix + ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \ + $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only + $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only + +# This obsolescent rule is present for backwards compatibility with +# tz releases 2014g through 2015g. It should go away eventually. +posix_packrat: + $(MAKE) $(INSTALLARGS) PACKRATDATA=backzone posix_only + +zones: $(REDO) + +$(TZS_NEW): $(TDATA) zdump zic + mkdir -p tzs.dir + $(zic) -d tzs.dir $(TDATA) + $(AWK) '/^Link/{print $$1 "\t" $$2 "\t" $$3}' \ + $(TDATA) | LC_ALL=C sort >$@.out + wd=`pwd` && \ + zones=`$(AWK) -v wd="$$wd" \ + '/^Zone/{print wd "/tzs.dir/" $$2}' $(TDATA) \ + | LC_ALL=C sort` && \ + ./zdump -i -c $(TZS_YEAR) $$zones >>$@.out + sed 's,^TZ=".*tzs\.dir/,TZ=",' $@.out >$@.sed.out + rm -fr tzs.dir $@.out + mv $@.sed.out $@ + +# If $(TZS) does not already exist (e.g., old-format tarballs), create it. +# If it exists but 'make check_tzs' fails, a maintainer should inspect the +# failed output and fix the inconsistency, perhaps by running 'make force_tzs'. +$(TZS): + $(MAKE) force_tzs + +force_tzs: $(TZS_NEW) + cp $(TZS_NEW) $(TZS) + +libtz.a: $(LIBOBJS) + $(AR) ru $@ $(LIBOBJS) + $(RANLIB) $@ + +date: $(DATEOBJS) + $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS) + +tzselect: tzselect.ksh version + VERSION=`cat version` && sed \ + -e 's|#!/bin/bash|#!$(KSHELL)|g' \ + -e 's|AWK=[^}]*|AWK=$(AWK)|g' \ + -e 's|\(PKGVERSION\)=.*|\1='\''($(PACKAGE)) '\''|' \ + -e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \ + -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \ + -e 's|\(TZVERSION\)=.*|\1='"$$VERSION"'|' \ + <$@.ksh >$@.out + chmod +x $@.out + mv $@.out $@ + +check: check_character_set check_white_space check_links check_sorted \ + check_tables check_tzs check_web + +check_character_set: $(ENCHILADA) + LC_ALL=en_US.utf8 && export LC_ALL && \ + sharp='#' && \ + ! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \ + $(MISC) $(SOURCES) $(WEB_PAGES) \ + CONTRIBUTING LICENSE Makefile README version && \ + ! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \ + leapseconds yearistype.sh zone.tab && \ + ! grep -Env $(OK_LINE) $(ENCHILADA) + +check_white_space: $(ENCHILADA) + patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \ + ! grep -En "$$pat" $(ENCHILADA) + ! grep -n '[[:space:]]$$' $(ENCHILADA) + +CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; } + +check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab + $(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu + $(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu + $(AWK) '/^[^#]/ {print $$1}' iso3166.tab | LC_ALL=C sort -cu + $(AWK) '/^[^#]/ {print $$1}' zone.tab | LC_ALL=C sort -c + $(AWK) '/^[^#]/ {print substr($$0, 1, 2)}' zone1970.tab | \ + LC_ALL=C sort -c + $(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \ + LC_ALL=C sort -cu + +check_links: checklinks.awk $(TDATA) + $(AWK) -f checklinks.awk $(TDATA) + +check_tables: checktab.awk $(PRIMARY_YDATA) $(ZONETABLES) + for tab in $(ZONETABLES); do \ + $(AWK) -f checktab.awk -v zone_table=$$tab $(PRIMARY_YDATA) \ + || exit; \ + done + +check_tzs: $(TZS) $(TZS_NEW) + diff -u $(TZS) $(TZS_NEW) + +check_web: $(WEB_PAGES) + $(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES) + +clean_misc: + rm -f core *.o *.out \ + date tzselect version.h zdump zic yearistype libtz.a +clean: clean_misc + rm -fr *.dir tzdb-*/ $(TZS_NEW) + +maintainer-clean: clean + @echo 'This command is intended for maintainers to use; it' + @echo 'deletes files that may need special tools to rebuild.' + rm -f leapseconds version $(MANTXTS) $(TZS) *.asc *.tar.* + +names: + @echo $(ENCHILADA) + +public: check check_public $(CHECK_TIME_T_ALTERNATIVES) \ + tarballs signatures + +date.1.txt: date.1 +newctime.3.txt: newctime.3 +newstrftime.3.txt: newstrftime.3 +newtzset.3.txt: newtzset.3 +time2posix.3.txt: time2posix.3 +tzfile.5.txt: tzfile.5 +tzselect.8.txt: tzselect.8 +zdump.8.txt: zdump.8 +zic.8.txt: zic.8 + +$(MANTXTS): workman.sh + LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@.out + mv $@.out $@ + +# Set the time stamps to those of the git repository, if available, +# and if the files have not changed since then. +# This uses GNU 'touch' syntax 'touch -d@N FILE', +# where N is the number of seconds since 1970. +# If git or GNU 'touch' is absent, don't bother to sync with git timestamps. +# Also, set the timestamp of each prebuilt file like 'leapseconds' +# to be the maximum of the files it depends on. +set-timestamps.out: $(ENCHILADA) + rm -f $@ + if (type git) >/dev/null 2>&1 && \ + files=`git ls-files $(ENCHILADA)` && \ + touch -md @1 test.out; then \ + rm -f test.out && \ + for file in $$files; do \ + if git diff --quiet $$file; then \ + time=`git log -1 --format='tformat:%ct' $$file` && \ + touch -cmd @$$time $$file; \ + else \ + echo >&2 "$$file: warning: does not match repository"; \ + fi || exit; \ + done; \ + fi + touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds + for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \ + touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \ + exit; \ + done + touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS) + touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version + touch $@ + +# The zics below ensure that each data file can stand on its own. +# We also do an all-files run to catch links to links. + +check_public: + $(MAKE) maintainer-clean + $(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL + mkdir -p public.dir + for i in $(TDATA) ; do \ + $(zic) -v -d public.dir $$i 2>&1 || exit; \ + done + $(zic) -v -d public.dir $(TDATA) + rm -fr public.dir + +# Check that the code works under various alternative +# implementations of time_t. +check_time_t_alternatives: + if diff -q Makefile Makefile 2>/dev/null; then \ + quiet_option='-q'; \ + else \ + quiet_option=''; \ + fi && \ + wd=`pwd` && \ + zones=`$(AWK) '/^[^#]/ { print $$3 }' time_t.dir/int64_t.out && \ + time_t.dir/$$type/etc/zdump -V -t $$range $$zones \ + >time_t.dir/$$type.out && \ + diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \ + || exit; \ + done + rm -fr time_t.dir + +tarballs traditional_tarballs signatures traditional_signatures: version + VERSION=`cat version` && \ + $(MAKE) VERSION="$$VERSION" $@_version + +tarballs_version: traditional_tarballs_version tzdb-$(VERSION).tar.lz +traditional_tarballs_version: \ + tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz +signatures_version: traditional_signatures_version tzdb-$(VERSION).tar.lz.asc +traditional_signatures_version: \ + tzcode$(VERSION).tar.gz.asc tzdata$(VERSION).tar.gz.asc \ + +tzcode$(VERSION).tar.gz: set-timestamps.out + LC_ALL=C && export LC_ALL && \ + tar $(TARFLAGS) -cf - \ + $(COMMON) $(DOCS) $(SOURCES) | \ + gzip $(GZIPFLAGS) >$@.out + mv $@.out $@ + +tzdata$(VERSION).tar.gz: set-timestamps.out + LC_ALL=C && export LC_ALL && \ + tar $(TARFLAGS) -cf - $(COMMON) $(DATA) $(MISC) | \ + gzip $(GZIPFLAGS) >$@.out + mv $@.out $@ + +tzdb-$(VERSION).tar.lz: set-timestamps.out + rm -fr tzdb-$(VERSION) + mkdir tzdb-$(VERSION) + ln $(ENCHILADA) tzdb-$(VERSION) + touch -cmr `ls -t tzdb-$(VERSION)/* | sed 1q` tzdb-$(VERSION) + LC_ALL=C && export LC_ALL && \ + tar $(TARFLAGS) -cf - tzdb-$(VERSION) | lzip -9 >$@.out + mv $@.out $@ + +tzcode$(VERSION).tar.gz.asc: tzcode$(VERSION).tar.gz + gpg --armor --detach-sign $? + +tzdata$(VERSION).tar.gz.asc: tzdata$(VERSION).tar.gz + gpg --armor --detach-sign $? + +tzdb-$(VERSION).tar.lz.asc: tzdb-$(VERSION).tar.lz + gpg --armor --detach-sign $? + +typecheck: + $(MAKE) clean + for i in "long long" unsigned; \ + do \ + $(MAKE) CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \ + ./zdump -v Europe/Rome ; \ + $(MAKE) clean ; \ + done + +zonenames: $(TDATA) + @$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA) + +asctime.o: private.h tzfile.h +date.o: private.h +difftime.o: private.h +localtime.o: private.h tzfile.h +strftime.o: private.h tzfile.h +zdump.o: version.h +zic.o: private.h tzfile.h version.h + +.KEEP_STATE: + +.PHONY: ALL INSTALL all +.PHONY: check check_character_set check_links +.PHONY: check_public check_sorted check_tables +.PHONY: check_time_t_alternatives check_tzs check_web check_white_space +.PHONY: clean clean_misc force_tzs +.PHONY: install install_data maintainer-clean names +.PHONY: posix_only posix_packrat posix_right +.PHONY: public right_only right_posix signatures signatures_version +.PHONY: tarballs tarballs_version typecheck +.PHONY: zonenames zones Copied: head/contrib/tzdata/NEWS (from r308265, vendor/tzdata/dist/NEWS) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/tzdata/NEWS Thu Nov 3 23:34:11 2016 (r308270, copy of r308265, vendor/tzdata/dist/NEWS) @@ -0,0 +1,3782 @@ +News for the tz database + +Release 2016i - 2016-11-01 23:19:52 -0700 + + Briefly: Cyprus split into two time zones on 2016-10-30, and Tonga + reintroduces DST on 2016-11-06. + + Changes to future time stamps + + Pacific/Tongatapu begins DST on 2016-11-06 at 02:00, ending on + 2017-01-15 at 03:00. Assume future observances in Tonga will be + from the first Sunday in November through the third Sunday in + January, like Fiji. (Thanks to Pulu Ê»Anau.) Switch to numeric + time zone abbreviations for this zone. + + Changes to past and future time stamps + + Northern Cyprus is now +03 year round, causing a split in Cyprus + time zones starting 2016-10-30 at 04:00. This creates a zone + Asia/Famagusta. (Thanks to Even Scharning and Matt Johnson.) + + Antarctica/Casey switched from +08 to +11 on 2016-10-22. + (Thanks to Steffen Thorsen.) + + Changes to past time stamps + + Several corrections were made for pre-1975 time stamps in Italy. + These affect Europe/Malta, Europe/Rome, Europe/San_Marino, and + Europe/Vatican. + + First, the 1893-11-01 00:00 transition in Italy used the new UT + offset (+01), not the old (+00:49:56). (Thanks to Michael + Deckers.) + + Second, rules for daylight saving in Italy were changed to agree + with Italy's National Institute of Metrological Research (INRiM) + except for 1944, as follows (thanks to Pierpaolo Bernardi, Brian + Inglis, and Michael Deckers): + + The 1916-06-03 transition was at 24:00, not 00:00. + + The 1916-10-01, 1919-10-05, and 1920-09-19 transitions were at + 00:00, not 01:00. + + The 1917-09-30 and 1918-10-06 transitions were at 24:00, not + 01:00. + + The 1944-09-17 transition was at 03:00, not 01:00. This + particular change is taken from Italian law as INRiM's table, + (which says 02:00) appears to have a typo here. Also, keep the + 1944-04-03 transition for Europe/Rome, as Rome was controlled by + Germany then. + + The 1967-1970 and 1972-1974 fallback transitions were at 01:00, + not 00:00. + + Changes to code + + The code should now be buildable on AmigaOS merely by setting the + appropriate Makefile variables. (From a patch by Carsten Larsen.) + + +Release 2016h - 2016-10-19 23:17:57 -0700 + + Changes to future time stamps + + Asia/Gaza and Asia/Hebron end DST on 2016-10-29 at 01:00, not + 2016-10-21 at 00:00. (Thanks to Sharef Mustafa.) Predict that + future fall transitions will be on the last Saturday of October + at 01:00, which is consistent with predicted spring transitions + on the last Saturday of March. (Thanks to Tim Parenti.) + + Changes to past time stamps + + In Turkey, transitions in 1986-1990 were at 01:00 standard time + not at 02:00, and the spring 1994 transition was on March 20, not + March 27. (Thanks to Kıvanç Yazan.) + + Changes to past and future time zone abbreviations + + Asia/Colombo now uses numeric time zone abbreviations like "+0530" + instead of alphabetic ones like "IST" and "LKT". Various + English-language sources use "IST", "LKT" and "SLST", with no + working consensus. (Usage of "SLST" mentioned by Sadika + Sumanapala.) + + Changes to code + + zic no longer mishandles relativizing file names when creating + symbolic links like /etc/localtime, when these symbolic links + are outside the usual directory hierarchy. This fixes a bug + introduced in 2016g. (Problem reported by Andreas Stieger.) + + Changes to build procedure + + New rules 'traditional_tarballs' and 'traditional_signatures' for + building just the traditional-format distribution. (Requested by + Deborah Goldsmith.) + + The file 'version' is now put into the tzdata tarball too. + (Requested by Howard Hinnant.) + + Changes to documentation and commentary + + The 'Theory' file now has a section on interface stability. + (Requested by Paul Koning.) It also mentions features like + tm_zone and localtime_rz that have long been supported by the + reference code. + + tz-link.htm has improved coverage of time zone boundaries suitable + for geolocation. (Thanks to heads-ups from Evan Siroky and Matt + Johnson.) + + The US commentary now mentions Allen and the "day of two noons". + + The Fiji commentary mentions the government's 2016-10-03 press + release. (Thanks to Raymond Kumar.) + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Fri Nov 4 01:14:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D86F4C2E6F7; Fri, 4 Nov 2016 01:14:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7C8D1707; Fri, 4 Nov 2016 01:14:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA41Efqg060122; Fri, 4 Nov 2016 01:14:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA41Ef2R060121; Fri, 4 Nov 2016 01:14:41 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201611040114.uA41Ef2R060121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 4 Nov 2016 01:14:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308278 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 01:14:42 -0000 Author: sephe Date: Fri Nov 4 01:14:41 2016 New Revision: 308278 URL: https://svnweb.freebsd.org/changeset/base/308278 Log: hyperv/vmbus: Reset ch_dev, once the child is deleted. So it will not be mis-used later on, e.g. in vmbus_chan_printf(). Submitted by: dexuan Reported by: dexuan MFC after: 1 week Sponsored by: Microsoft Modified: head/sys/dev/hyperv/vmbus/vmbus.c Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Fri Nov 4 01:12:32 2016 (r308277) +++ head/sys/dev/hyperv/vmbus/vmbus.c Fri Nov 4 01:14:41 2016 (r308278) @@ -954,6 +954,7 @@ vmbus_delete_child(struct vmbus_channel if (chan->ch_dev != NULL) { error = device_delete_child(chan->ch_vmbus->vmbus_dev, chan->ch_dev); + chan->ch_dev = NULL; } mtx_unlock(&Giant); return (error); From owner-svn-src-head@freebsd.org Fri Nov 4 04:47:09 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8AE87C2FFE2; Fri, 4 Nov 2016 04:47:09 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A30C14BB; Fri, 4 Nov 2016 04:47:09 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA44l8Tn040787; Fri, 4 Nov 2016 04:47:08 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA44l8M2040786; Fri, 4 Nov 2016 04:47:08 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611040447.uA44l8M2040786@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 04:47:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308285 - head/sys/arm/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 04:47:09 -0000 Author: manu Date: Fri Nov 4 04:47:08 2016 New Revision: 308285 URL: https://svnweb.freebsd.org/changeset/base/308285 Log: Add Allwinner UP SoC support to GENERIC on armv6 Relnotes: yes Modified: head/sys/arm/conf/GENERIC Modified: head/sys/arm/conf/GENERIC ============================================================================== --- head/sys/arm/conf/GENERIC Fri Nov 4 04:06:55 2016 (r308284) +++ head/sys/arm/conf/GENERIC Fri Nov 4 04:47:08 2016 (r308285) @@ -30,6 +30,9 @@ options KERNVIRTADDR=0xc0000000 include "std.armv6" files "../allwinner/files.allwinner" +files "../allwinner/files.allwinner_up" +files "../allwinner/a10/files.a10" +files "../allwinner/a13/files.a13" files "../allwinner/a20/files.a20" files "../allwinner/a31/files.a31" files "../allwinner/a83t/files.a83t" @@ -41,6 +44,8 @@ files "../qemu/files.qemu" files "../ti/files.ti" files "../ti/am335x/files.am335x" +options SOC_ALLWINNER_A10 +options SOC_ALLWINNER_A13 options SOC_ALLWINNER_A20 options SOC_ALLWINNER_A31 options SOC_ALLWINNER_A31S @@ -180,7 +185,7 @@ device vlan # 802.1Q VLAN support device mii device bpf -#device emac # 10/100 integrated EMAC controller +device emac # 10/100 integrated EMAC controller device dwc # 10/100/1000 integrated GMAC controller device awg # 10/100/1000 integrated EMAC controller From owner-svn-src-head@freebsd.org Fri Nov 4 09:18:04 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 570E2C2B55D; Fri, 4 Nov 2016 09:18:04 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mx0.gentlemail.de (mx0.gentlemail.de [IPv6:2a00:e10:2800::a130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D062B1A6A; Fri, 4 Nov 2016 09:18:03 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mh0.gentlemail.de (mh0.gentlemail.de [78.138.80.135]) by mx0.gentlemail.de (8.14.5/8.14.5) with ESMTP id uA49I2eH011697; Fri, 4 Nov 2016 10:18:02 +0100 (CET) (envelope-from freebsd@omnilan.de) Received: from titan.inop.mo1.omnilan.net (titan.inop.mo1.omnilan.net [IPv6:2001:a60:f0bb:1::3:1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mh0.gentlemail.de (Postfix) with ESMTPSA id C298C6DA; Fri, 4 Nov 2016 10:18:01 +0100 (CET) Message-ID: <581C5249.2060104@omnilan.de> Date: Fri, 04 Nov 2016 10:18:01 +0100 From: Harry Schmalzbauer Organization: OmniLAN User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; de-DE; rv:1.9.2.8) Gecko/20100906 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 To: Scott Long CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308217 - in head/sys/dev: mpr mps References: <201611021513.uA2FDPk6062463@repo.freebsd.org> In-Reply-To: <201611021513.uA2FDPk6062463@repo.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: ACL 119 matched, not delayed by milter-greylist-4.2.7 (mx0.gentlemail.de [78.138.80.130]); Fri, 04 Nov 2016 10:18:02 +0100 (CET) X-Milter: Spamilter (Reciever: mx0.gentlemail.de; Sender-ip: 78.138.80.135; Sender-helo: mh0.gentlemail.de; ) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 09:18:04 -0000 Bezüglich Scott Long's Nachricht vom 02.11.2016 16:13 (localtime): > Author: scottl > Date: Wed Nov 2 15:13:25 2016 > New Revision: 308217 > URL: https://svnweb.freebsd.org/changeset/base/308217 > > Log: > Add a fallback to the device mapper logic. We've seen systems in the field > that are apparently misconfigured by the manufacturer and cause the mapping > logic to fail. The fallback allows drive numbers to be assigned based on the > PHY number that they're attached to. Add sysctls and tunables to overrid > this new behavior, but they should be considered only necessary for debugging. Thanks a lot, this is welcome not only for debugging! I had a hard time finding out how to get rid of static driveserial-targetID assigning. And more surprising, this affects only IT-fw. When using the same controller in IR-mode, mapping is done (correctly) slot-based. In IT-mode, every drive got a consecutive target ID which was static, and even persistent over firmware updates. There's only one possibility with LSIUtil(1.71) to erase /"persitent non-manufacturing config pages/". But I guess this hard drive-targetID assigning is triggered by the driver, namely the mps(4) in FreeBSD. I did quick tests on windows and IT-mode, where I think I saw slot (or Phy?) based assigning. If it's really mps(4) who decides to store driveserial-targetID numbering in the /"persitent non-manufacturing config pages/" of the controller, mpsutil(8) should be able to reset. Otherwise replacing failed drives, or - even mor confusing - rearranging drive/zpool layouts is very unsatisfying. Maybe "-1" should be mentioned with sysctl decription, otherwise this is another very hard to find/influence behaviour. Thanks, -harry From owner-svn-src-head@freebsd.org Fri Nov 4 11:39:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35A9BC2F460; Fri, 4 Nov 2016 11:39:21 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC7DE368; Fri, 4 Nov 2016 11:39:20 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4BdK68002711; Fri, 4 Nov 2016 11:39:20 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4BdK1h002709; Fri, 4 Nov 2016 11:39:20 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201611041139.uA4BdK1h002709@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Fri, 4 Nov 2016 11:39:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308286 - in head/sys/arm/nvidia: . tegra124 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 11:39:21 -0000 Author: mmel Date: Fri Nov 4 11:39:19 2016 New Revision: 308286 URL: https://svnweb.freebsd.org/changeset/base/308286 Log: TEGRA: Add basic driver for memory controller. For now, it only reports memory and SMMU access errors. Added: head/sys/arm/nvidia/tegra_mc.c (contents, props changed) Modified: head/sys/arm/nvidia/tegra124/files.tegra124 Modified: head/sys/arm/nvidia/tegra124/files.tegra124 ============================================================================== --- head/sys/arm/nvidia/tegra124/files.tegra124 Fri Nov 4 04:47:08 2016 (r308285) +++ head/sys/arm/nvidia/tegra124/files.tegra124 Fri Nov 4 11:39:19 2016 (r308286) @@ -33,6 +33,7 @@ arm/nvidia/tegra_efuse.c standard arm/nvidia/tegra_soctherm_if.m standard arm/nvidia/tegra_soctherm.c standard arm/nvidia/tegra_lic.c standard +arm/nvidia/tegra_mc.c standard #arm/nvidia/tegra_hda.c optional snd_hda #arm/nvidia/drm2/hdmi.c optional drm2 #arm/nvidia/drm2/tegra_drm_if.m optional drm2 Added: head/sys/arm/nvidia/tegra_mc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/nvidia/tegra_mc.c Fri Nov 4 11:39:19 2016 (r308286) @@ -0,0 +1,311 @@ +/*- + * Copyright (c) 2016 Michal Meloun + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Memory controller driver for Tegra SoCs. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "clock_if.h" + +#define MC_INTSTATUS 0x000 +#define MC_INTMASK 0x004 +#define MC_INT_DECERR_MTS (1 << 16) +#define MC_INT_SECERR_SEC (1 << 13) +#define MC_INT_DECERR_VPR (1 << 12) +#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11) +#define MC_INT_INVALID_SMMU_PAGE (1 << 10) +#define MC_INT_ARBITRATION_EMEM (1 << 9) +#define MC_INT_SECURITY_VIOLATION (1 << 8) +#define MC_INT_DECERR_EMEM (1 << 6) +#define MC_INT_INT_MASK (MC_INT_DECERR_MTS | \ + MC_INT_SECERR_SEC | \ + MC_INT_DECERR_VPR | \ + MC_INT_INVALID_APB_ASID_UPDATE | \ + MC_INT_INVALID_SMMU_PAGE | \ + MC_INT_ARBITRATION_EMEM | \ + MC_INT_SECURITY_VIOLATION | \ + MC_INT_DECERR_EMEM) + +#define MC_ERR_STATUS 0x008 +#define MC_ERR_TYPE(x) (((x) >> 28) & 0x7) +#define MC_ERR_TYPE_DECERR_EMEM 2 +#define MC_ERR_TYPE_SECURITY_TRUSTZONE 3 +#define MC_ERR_TYPE_SECURITY_CARVEOUT 4 +#define MC_ERR_TYPE_INVALID_SMMU_PAGE 6 +#define MC_ERR_INVALID_SMMU_PAGE_READABLE (1 << 27) +#define MC_ERR_INVALID_SMMU_PAGE_WRITABLE (1 << 26) +#define MC_ERR_INVALID_SMMU_PAGE_NONSECURE (1 << 25) +#define MC_ERR_ADR_HI(x) (((x) >> 20) & 0x3) +#define MC_ERR_SWAP (1 << 18) +#define MC_ERR_SECURITY (1 << 17) +#define MC_ERR_RW (1 << 16) +#define MC_ERR_ADR1(x) (((x) >> 12) & 0x7) +#define MC_ERR_ID(x) (((x) >> 0) & 07F) + +#define MC_ERR_ADDR 0x00C +#define MC_EMEM_CFG 0x050 +#define MC_EMEM_ADR_CFG 0x054 +#define MC_EMEM_NUMDEV(x) (((x) >> 0 ) & 0x1) + +#define MC_EMEM_ADR_CFG_DEV0 0x058 +#define MC_EMEM_ADR_CFG_DEV1 0x05C +#define EMEM_DEV_DEVSIZE(x) (((x) >> 16) & 0xF) +#define EMEM_DEV_BANKWIDTH(x) (((x) >> 8) & 0x3) +#define EMEM_DEV_COLWIDTH(x) (((x) >> 8) & 0x3) + +#define WR4(_sc, _r, _v) bus_write_4((_sc)->mem_res, (_r), (_v)) +#define RD4(_sc, _r) bus_read_4((_sc)->mem_res, (_r)) + +#define LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define SLEEP(_sc, timeout) mtx_sleep(sc, &sc->mtx, 0, "tegra_mc", timeout); +#define LOCK_INIT(_sc) \ + mtx_init(&_sc->mtx, device_get_nameunit(_sc->dev), "tegra_mc", MTX_DEF) +#define LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx) +#define ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED) +#define ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->mtx, MA_NOTOWNED) + +static struct ofw_compat_data compat_data[] = { + {"nvidia,tegra124-mc", 1}, + {NULL, 0} +}; + +struct tegra_mc_softc { + device_t dev; + struct mtx mtx; + + struct resource *mem_res; + struct resource *irq_res; + void *irq_h; + + clk_t clk; +}; + +static char *smmu_err_tbl[16] = { + "reserved", /* 0 */ + "reserved", /* 1 */ + "DRAM decode", /* 2 */ + "Trustzome Security", /* 3 */ + "Security carveout", /* 4 */ + "reserved", /* 5 */ + "Invalid SMMU page", /* 6 */ + "reserved", /* 7 */ +}; + +static void +tegra_mc_intr(void *arg) +{ + struct tegra_mc_softc *sc; + uint32_t stat, err; + uint64_t addr; + + sc = (struct tegra_mc_softc *)arg; + + stat = RD4(sc, MC_INTSTATUS); + if ((stat & MC_INT_INT_MASK) == 0) { + WR4(sc, MC_INTSTATUS, stat); + return; + } + + device_printf(sc->dev, "Memory Controller Interrupt:\n"); + if (stat & MC_INT_DECERR_MTS) + printf(" - MTS carveout violation\n"); + if (stat & MC_INT_SECERR_SEC) + printf(" - SEC carveout violation\n"); + if (stat & MC_INT_DECERR_VPR) + printf(" - VPR requirements violated\n"); + if (stat & MC_INT_INVALID_APB_ASID_UPDATE) + printf(" - ivalid APB ASID update\n"); + if (stat & MC_INT_INVALID_SMMU_PAGE) + printf(" - SMMU address translation error\n"); + if (stat & MC_INT_ARBITRATION_EMEM) + printf(" - arbitration deadlock-prevention threshold hit\n"); + if (stat & MC_INT_SECURITY_VIOLATION) + printf(" - SMMU address translation security error\n"); + if (stat & MC_INT_DECERR_EMEM) + printf(" - SMMU address decode error\n"); + + if ((stat & (MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION | + MC_INT_DECERR_EMEM)) != 0) { + err = RD4(sc, MC_ERR_STATUS); + addr = RD4(sc, MC_ERR_STATUS); + addr |= (uint64_t)(MC_ERR_ADR_HI(err)) << 32; + printf(" at 0x%012llX [%s %s %s] - %s error.\n", + addr, + stat & MC_ERR_SWAP ? "Swap, " : "", + stat & MC_ERR_SECURITY ? "Sec, " : "", + stat & MC_ERR_RW ? "Write" : "Read", + smmu_err_tbl[MC_ERR_TYPE(err)]); + } + WR4(sc, MC_INTSTATUS, stat); +} + +static void +tegra_mc_init_hw(struct tegra_mc_softc *sc) +{ + + /* Disable and acknowledge all interrupts */ + WR4(sc, MC_INTMASK, 0); + WR4(sc, MC_INTSTATUS, MC_INT_INT_MASK); +} + +static int +tegra_mc_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + device_set_desc(dev, "Tegra Memory Controller"); + return (BUS_PROBE_DEFAULT); +} + +static int +tegra_mc_attach(device_t dev) +{ + int rv, rid; + struct tegra_mc_softc *sc; + + sc = device_get_softc(dev); + sc->dev = dev; + + LOCK_INIT(sc); + + /* Get the memory resource for the register mapping. */ + rid = 0; + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->mem_res == NULL) { + device_printf(dev, "Cannot map registers.\n"); + rv = ENXIO; + goto fail; + } + + /* Allocate our IRQ resource. */ + rid = 0; + sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE); + if (sc->irq_res == NULL) { + device_printf(dev, "Cannot allocate interrupt.\n"); + rv = ENXIO; + goto fail; + } + + /* OFW resources. */ + rv = clk_get_by_ofw_name(dev, 0, "mc", &sc->clk); + if (rv != 0) { + device_printf(dev, "Cannot get mc clock: %d\n", rv); + goto fail; + } + rv = clk_enable(sc->clk); + if (rv != 0) { + device_printf(dev, "Cannot enable clock: %d\n", rv); + goto fail; + } + + /* Init hardware. */ + tegra_mc_init_hw(sc); + + /* Setup interrupt */ + rv = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + NULL, tegra_mc_intr, sc, &sc->irq_h); + if (rv) { + device_printf(dev, "Cannot setup interrupt.\n"); + goto fail; + } + + /* Enable Interrupts */ + WR4(sc, MC_INTMASK, MC_INT_INT_MASK); + + return (bus_generic_attach(dev)); + +fail: + if (sc->clk != NULL) + clk_release(sc->clk); + if (sc->irq_h != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_h); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); + LOCK_DESTROY(sc); + + return (rv); +} + +static int +tegra_mc_detach(device_t dev) +{ + struct tegra_mc_softc *sc; + + sc = device_get_softc(dev); + if (sc->irq_h != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_h); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->mem_res != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); + + LOCK_DESTROY(sc); + return (bus_generic_detach(dev)); +} + +static device_method_t tegra_mc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, tegra_mc_probe), + DEVMETHOD(device_attach, tegra_mc_attach), + DEVMETHOD(device_detach, tegra_mc_detach), + + + DEVMETHOD_END +}; + +static devclass_t tegra_mc_devclass; +static DEFINE_CLASS_0(mc, tegra_mc_driver, tegra_mc_methods, + sizeof(struct tegra_mc_softc)); +DRIVER_MODULE(tegra_mc, simplebus, tegra_mc_driver, tegra_mc_devclass, + NULL, NULL); From owner-svn-src-head@freebsd.org Fri Nov 4 11:40:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F6C9C2F529; Fri, 4 Nov 2016 11:40:12 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6796B76D; Fri, 4 Nov 2016 11:40:12 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4BeBND002810; Fri, 4 Nov 2016 11:40:11 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4BeBsL002807; Fri, 4 Nov 2016 11:40:11 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201611041140.uA4BeBsL002807@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Fri, 4 Nov 2016 11:40:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308287 - head/sys/arm/nvidia/tegra124 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 11:40:12 -0000 Author: mmel Date: Fri Nov 4 11:40:11 2016 New Revision: 308287 URL: https://svnweb.freebsd.org/changeset/base/308287 Log: TEGRA: Fix numerous issues in clock code. Define and export clocks related to XUSB driver. Modified: head/sys/arm/nvidia/tegra124/tegra124_car.c head/sys/arm/nvidia/tegra124/tegra124_clk_per.c head/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Modified: head/sys/arm/nvidia/tegra124/tegra124_car.c ============================================================================== --- head/sys/arm/nvidia/tegra124/tegra124_car.c Fri Nov 4 11:39:19 2016 (r308286) +++ head/sys/arm/nvidia/tegra124/tegra124_car.c Fri Nov 4 11:40:11 2016 (r308287) @@ -191,13 +191,13 @@ PLIST(mux_plle_src) = {"pllE_src1", "pll PLIST(mux_plld_out0_plld2_out0) = {"pllD_out0", "pllD2_out0"}; PLIST(mux_pllmcp_clkm) = {"pllM_out0", "pllC_out0", "pllP_out0", "clk_m", "pllM_UD", "pllC2_out0", "pllC3_out0", "pllC_UD"}; -PLIST(mux_xusb_hs) = {"pc_xusb_ss", "pllU_60"}; +PLIST(mux_xusb_hs) = {"xusb_ss_div2", "pllU_60"}; PLIST(mux_xusb_ss) = {"pc_xusb_ss", "osc_div_clk"}; /* Clocks ajusted online. */ static struct clk_fixed_def fixed_clk_m = - FRATE(0, "clk_m", 12000000); + FRATE(TEGRA124_CLK_CLK_M, "clk_m", 12000000); static struct clk_fixed_def fixed_osc_div_clk = FACT(0, "osc_div_clk", "clk_m", 1, 1); @@ -222,6 +222,10 @@ static struct clk_fixed_def tegra124_fix FRATE(0, "audio3", 10000000), FRATE(0, "audio4", 10000000), FRATE(0, "ext_vimclk", 10000000), + + /* XUSB */ + FACT(TEGRA124_CLK_XUSB_SS_DIV2, "xusb_ss_div2", "xusb_ss", 1, 2), + }; @@ -239,7 +243,7 @@ static struct clk_mux_def tegra124_mux_c MUX(0, "emc_mux", mux_pllmcp_clkm, CLK_SOURCE_EMC, 29, 3), /* USB. */ - MUX(0, "xusb_hs", mux_xusb_hs, CLK_SOURCE_XUSB_SS, 25, 1), + MUX(TEGRA124_CLK_XUSB_HS_SRC, "xusb_hs", mux_xusb_hs, CLK_SOURCE_XUSB_SS, 25, 1), MUX(0, "xusb_ss_mux", mux_xusb_ss, CLK_SOURCE_XUSB_SS, 24, 1), }; @@ -249,7 +253,7 @@ static struct clk_gate_def tegra124_gate /* Core clocks. */ GATE_PLL(0, "pllC_out1", "pllC_out1_div", PLLC_OUT, 0), GATE_PLL(0, "pllM_out1", "pllM_out1_div", PLLM_OUT, 0), - GATE_PLL(0, "pllU_480", "pllU_out", PLLU_BASE, 22), + GATE_PLL(TEGRA124_CLK_PLL_U_480M, "pllU_480", "pllU_out", PLLU_BASE, 22), GATE_PLL(0, "pllP_outX0", "pllP_outX0_div", PLLP_RESHIFT, 0), GATE_PLL(0, "pllP_out1", "pllP_out1_div", PLLP_OUTA, 0), GATE_PLL(0, "pllP_out2", "pllP_out2_div", PLLP_OUTA, 16), Modified: head/sys/arm/nvidia/tegra124/tegra124_clk_per.c ============================================================================== --- head/sys/arm/nvidia/tegra124/tegra124_clk_per.c Fri Nov 4 11:39:19 2016 (r308286) +++ head/sys/arm/nvidia/tegra124/tegra124_clk_per.c Fri Nov 4 11:40:11 2016 (r308287) @@ -41,6 +41,15 @@ __FBSDID("$FreeBSD$"); #include #include "tegra124_car.h" +/* The TEGRA124_CLK_XUSB_GATE is missing in current + * DT bindings, define it localy + */ +#ifdef TEGRA124_CLK_XUSB_GATE +#error "TEGRA124_CLK_XUSB_GATE is now defined, revisit XUSB code!" +#else +#define TEGRA124_CLK_XUSB_GATE 143 +#endif + /* Bits in base register. */ #define PERLCK_AMUX_MASK 0x0F #define PERLCK_AMUX_SHIFT 16 @@ -175,7 +184,7 @@ PLIST(mux_sep_audio) = "spdif_in", "i2s0", "i2s1", "i2s2", "i2s4", "pllA_out0", "ext_vimclk"}; -static uint32_t clk_enabale_reg[] = { +static uint32_t clk_enable_reg[] = { CLK_OUT_ENB_L, CLK_OUT_ENB_H, CLK_OUT_ENB_U, @@ -285,7 +294,7 @@ static struct pgate_def pgate_def[] = { GATE(CSUS, "sus_out", "clk_m", U(28)), /* GATE(DEVD2_OUT, "devd2_out", "clk_m", U(29)), */ /* GATE(DEVD1_OUT, "devd1_out", "clk_m", U(30)), */ - GATE(XUSB_DEV_SRC, "xusb_core_dev", "pc_xusb_core_dev", U(31)), + GATE(XUSB_DEV, "xusb_core_dev", "pc_xusb_core_dev", U(31)), /* bank V -> 96-127 */ /* GATE(CPUG, "cpug", "clk_m", V(0)), */ @@ -328,7 +337,7 @@ static struct pgate_def pgate_def[] = { /* GATE(HDMI_IOBIST, "hdmi_iobist", "clk_m", W(11)), */ /* GATE(SATA_IOBIST, "sata_iobist", "clk_m", W(12)), */ /* GATE(MIPI_IOBIST, "mipi_iobist", "clk_m", W(13)), */ - /* GATE(XUSB_IOBIST, "xusb_iobist", "clk_m", W(15)), */ + GATE(XUSB_GATE, "xusb_gate", "clk_m", W(15)), GATE(CILAB, "cilab", "pc_cilab", W(16)), GATE(CILCD, "cilcd", "pc_cilcd", W(17)), GATE(CILE, "cile", "pc_cile", W(18)), @@ -337,10 +346,10 @@ static struct pgate_def pgate_def[] = { GATE(ENTROPY, "entropy", "pc_entropy", W(21)), GATE(AMX, "amx", "pc_amx", W(25)), GATE(ADX, "adx", "pc_adx", W(26)), - GATE(DFLL_REF, "dvfs_ref", "pc_dvfs_ref", X(27)), - GATE(DFLL_SOC, "dvfs_soc", "pc_dvfs_soc", X(27)), - GATE(XUSB_SS_SRC, "xusb_ss", "xusb_ss_mux", X(28)), - /* GATE(EMC_LATENCY, "emc_latency", "pc_emc_latency", X(29)), */ + GATE(DFLL_REF, "dvfs_ref", "pc_dvfs_ref", W(27)), + GATE(DFLL_SOC, "dvfs_soc", "pc_dvfs_soc", W(27)), + GATE(XUSB_SS, "xusb_ss", "xusb_ss_mux", W(28)), + /* GATE(EMC_LATENCY, "emc_latency", "pc_emc_latency", W(29)), */ /* bank X -> 160-191*/ /* GATE(SPARE, "spare", "clk_m", X(0)), */ @@ -391,111 +400,115 @@ static struct pgate_def pgate_def[] = { } /* Mux with fractional 8.1 divider. */ -#define CLK_8_1(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 8, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK_8_1(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 8, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) + /* Mux with fractional 16.1 divider. */ -#define CLK16_1(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 16, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK16_1(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 16, 1, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) /* Mux with integer 16bits divider. */ -#define CLK16_0(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 16, 0, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) +#define CLK16_0(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 16, 0, (f) | DCF_HAVE_MUX | DCF_HAVE_DIV) /* Mux wihout divider. */ -#define CLK_0_0(cn, pl, r, f) \ - PER_CLK(0, cn, pl, r, 0, 0, (f) | DCF_HAVE_MUX) +#define CLK_0_0(id, cn, pl, r, f) \ + PER_CLK(id, cn, pl, r, 0, 0, (f) | DCF_HAVE_MUX) static struct periph_def periph_def[] = { - CLK_8_1("pc_i2s1", mux_a_N_audio1_N_p_N_clkm, CLK_SOURCE_I2S1, DCF_HAVE_ENA), - CLK_8_1("pc_i2s2", mux_a_N_audio2_N_p_N_clkm, CLK_SOURCE_I2S2, DCF_HAVE_ENA), - CLK_8_1("pc_spdif_out", mux_a_N_audio_N_p_N_clkm, CLK_SOURCE_SPDIF_OUT, 0), - CLK_8_1("pc_spdif_in", mux_p_c2_c_c3_m, CLK_SOURCE_SPDIF_IN, 0), - CLK_8_1("pc_pwm", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_PWM, 0), - CLK_8_1("pc_spi2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI2, 0), - CLK_8_1("pc_spi3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI3, 0), - CLK16_0("pc_i2c5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C5, 0), - CLK16_0("pc_i2c1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C1, 0), - CLK_8_1("pc_spi1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI1, 0), - CLK_0_0("pc_disp1", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP1, 0), - CLK_0_0("pc_disp2", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP2, 0), - CLK_8_1("pc_isp", mux_m_c_p_a_c2_c3_clkm_c4, CLK_SOURCE_ISP, 0), - CLK_8_1("pc_vi", mux_m_c2_c_c3_p_N_a_c4, CLK_SOURCE_VI, DCF_IS_VI), - CLK_8_1("pc_sdmmc1", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC1, 0), - CLK_8_1("pc_sdmmc2", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC2, 0), - CLK_8_1("pc_sdmmc4", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC4, 0), - CLK_8_1("pc_vfir", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VFIR, 0), - CLK_8_1("pc_hsi", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HSI, 0), - CLK16_1("pc_uarta", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTA, DCF_IS_UART), - CLK16_1("pc_uartb", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTB, DCF_IS_UART), - CLK_8_1("pc_host1x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HOST1X, DCF_IS_HOST1X), - CLK_8_1("pc_hdmi", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_HDMI, 0), - CLK16_0("pc_i2c2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C2, 0), + CLK_8_1(0, "pc_i2s1", mux_a_N_audio1_N_p_N_clkm, CLK_SOURCE_I2S1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_i2s2", mux_a_N_audio2_N_p_N_clkm, CLK_SOURCE_I2S2, DCF_HAVE_ENA), + CLK_8_1(0, "pc_spdif_out", mux_a_N_audio_N_p_N_clkm, CLK_SOURCE_SPDIF_OUT, 0), + CLK_8_1(0, "pc_spdif_in", mux_p_c2_c_c3_m, CLK_SOURCE_SPDIF_IN, 0), + CLK_8_1(0, "pc_pwm", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_PWM, 0), + CLK_8_1(0, "pc_spi2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI2, 0), + CLK_8_1(0, "pc_spi3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI3, 0), + CLK16_0(0, "pc_i2c5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C5, 0), + CLK16_0(0, "pc_i2c1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C1, 0), + CLK_8_1(0, "pc_spi1", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI1, 0), + CLK_0_0(0, "pc_disp1", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP1, 0), + CLK_0_0(0, "pc_disp2", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_DISP2, 0), + CLK_8_1(0, "pc_isp", mux_m_c_p_a_c2_c3_clkm_c4, CLK_SOURCE_ISP, 0), + CLK_8_1(0, "pc_vi", mux_m_c2_c_c3_p_N_a_c4, CLK_SOURCE_VI, DCF_IS_VI), + CLK_8_1(0, "pc_sdmmc1", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC1, 0), + CLK_8_1(0, "pc_sdmmc2", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC2, 0), + CLK_8_1(0, "pc_sdmmc4", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC4, 0), + CLK_8_1(0, "pc_vfir", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VFIR, 0), + CLK_8_1(0, "pc_hsi", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HSI, 0), + CLK16_1(0, "pc_uarta", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTA, DCF_IS_UART), + CLK16_1(0, "pc_uartb", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTB, DCF_IS_UART), + CLK_8_1(0, "pc_host1x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HOST1X, DCF_IS_HOST1X), + CLK_8_1(0, "pc_hdmi", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_HDMI, 0), + CLK16_0(0, "pc_i2c2", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C2, 0), /* EMC 8 */ - CLK16_1("pc_uartc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTC, DCF_IS_UART), - CLK_8_1("pc_vi_sensor", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR, 0), - CLK_8_1("pc_spi4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI4, 0), - CLK16_0("pc_i2c3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C3, 0), - CLK_8_1("pc_sdmmc3", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC3, 0), - CLK16_1("pc_uartd", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTD, DCF_IS_UART), - CLK_8_1("pc_vde", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VDE, 0), - CLK_8_1("pc_owr", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_OWR, 0), - CLK_8_1("pc_snor", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_NOR, 0), - CLK_8_1("pc_csite", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_CSITE, 0), - CLK_8_1("pc_i2s0", mux_a_N_audio0_N_p_N_clkm, CLK_SOURCE_I2S0, 0), + CLK16_1(0, "pc_uartc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTC, DCF_IS_UART), + CLK_8_1(0, "pc_vi_sensor", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR, 0), + CLK_8_1(0, "pc_spi4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI4, 0), + CLK16_0(0, "pc_i2c3", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C3, 0), + CLK_8_1(0, "pc_sdmmc3", mux_p_c2_c_c3_m_e_clkm, CLK_SOURCE_SDMMC3, 0), + CLK16_1(0, "pc_uartd", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_UARTD, DCF_IS_UART), + CLK_8_1(0, "pc_vde", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_VDE, 0), + CLK_8_1(0, "pc_owr", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_OWR, 0), + CLK_8_1(0, "pc_snor", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_NOR, 0), + CLK_8_1(0, "pc_csite", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_CSITE, 0), + CLK_8_1(0, "pc_i2s0", mux_a_N_audio0_N_p_N_clkm, CLK_SOURCE_I2S0, 0), /* DTV xxx */ - CLK_8_1("pc_msenc", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_MSENC, 0), - CLK_8_1("pc_tsec", mux_p_c2_c_c3_m_a_clkm, CLK_SOURCE_TSEC, 0), + CLK_8_1(0, "pc_msenc", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_MSENC, 0), + CLK_8_1(0, "pc_tsec", mux_p_c2_c_c3_m_a_clkm, CLK_SOURCE_TSEC, 0), /* SPARE2 */ - CLK_8_1("pc_mselect", mux_p_c2_c_c3_m_clks_clkm, CLK_SOURCE_MSELECT, 0), - CLK_8_1("pc_tsensor", mux_p_c2_c_c3_clkm_N_clks, CLK_SOURCE_TSENSOR, 0), - CLK_8_1("pc_i2s3", mux_a_N_audio3_N_p_N_clkm, CLK_SOURCE_I2S3, DCF_HAVE_ENA), - CLK_8_1("pc_i2s4", mux_a_N_audio4_N_p_N_clkm, CLK_SOURCE_I2S4, DCF_HAVE_ENA), - CLK16_0("pc_i2c4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C4, 0), - CLK_8_1("pc_spi5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI5, 0), - CLK_8_1("pc_spi6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI6, 0), - CLK_8_1("pc_audio", mux_sep_audio, CLK_SOURCE_AUDIO, DCF_IS_AUDIO), - CLK_8_1("pc_dam0", mux_sep_audio, CLK_SOURCE_DAM0, DCF_IS_AUDIO), - CLK_8_1("pc_dam1", mux_sep_audio, CLK_SOURCE_DAM1, DCF_IS_AUDIO), - CLK_8_1("pc_dam2", mux_sep_audio, CLK_SOURCE_DAM2, DCF_IS_AUDIO), - CLK_8_1("pc_hda2codec_2x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA2CODEC_2X, 0), - CLK_8_1("pc_actmon", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_ACTMON, 0), - CLK_8_1("pc_extperiph1", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH1, 0), - CLK_8_1("pc_extperiph2", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH2, 0), - CLK_8_1("pc_extperiph3", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH3, 0), - CLK_8_1("pc_i2c_slow", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_I2C_SLOW, 0), + CLK_8_1(0, "pc_mselect", mux_p_c2_c_c3_m_clks_clkm, CLK_SOURCE_MSELECT, 0), + CLK_8_1(0, "pc_tsensor", mux_p_c2_c_c3_clkm_N_clks, CLK_SOURCE_TSENSOR, 0), + CLK_8_1(0, "pc_i2s3", mux_a_N_audio3_N_p_N_clkm, CLK_SOURCE_I2S3, DCF_HAVE_ENA), + CLK_8_1(0, "pc_i2s4", mux_a_N_audio4_N_p_N_clkm, CLK_SOURCE_I2S4, DCF_HAVE_ENA), + CLK16_0(0, "pc_i2c4", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C4, 0), + CLK_8_1(0, "pc_spi5", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI5, 0), + CLK_8_1(0, "pc_spi6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_SPI6, 0), + CLK_8_1(0, "pc_audio", mux_sep_audio, CLK_SOURCE_AUDIO, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam0", mux_sep_audio, CLK_SOURCE_DAM0, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam1", mux_sep_audio, CLK_SOURCE_DAM1, DCF_IS_AUDIO), + CLK_8_1(0, "pc_dam2", mux_sep_audio, CLK_SOURCE_DAM2, DCF_IS_AUDIO), + CLK_8_1(0, "pc_hda2codec_2x", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA2CODEC_2X, 0), + CLK_8_1(0, "pc_actmon", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_ACTMON, 0), + CLK_8_1(0, "pc_extperiph1", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH1, 0), + CLK_8_1(0, "pc_extperiph2", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH2, 0), + CLK_8_1(0, "pc_extperiph3", mux_a_clks_p_clkm_e, CLK_SOURCE_EXTPERIPH3, 0), + CLK_8_1(0, "pc_i2c_slow", mux_p_c2_c_c3_clks_N_clkm, CLK_SOURCE_I2C_SLOW, 0), /* SYS */ - CLK_8_1("pc_sor0", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_SOR0, DCF_IS_SOR0), - CLK_8_1("pc_sata_oob", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA_OOB, 0), - CLK_8_1("pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, FDS_IS_SATA), - CLK_8_1("pc_hda", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA, 0), - - - CLK_8_1("pc_xusb_core_host", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_HOST, 0), - CLK_8_1("pc_xusb_falcon", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_FALCON, 0), - CLK_8_1("pc_xusb_fs", mux_clkm_N_u48_N_p_N_u480, CLK_SOURCE_XUSB_FS, 0), - CLK_8_1("pc_xusb_core_dev", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_DEV, 0), - CLK_8_1("pc_xusb_ss", mux_clkm_refe_clks_u480_c_c2_c3_oscdiv, CLK_SOURCE_XUSB_SS, DCF_IS_XUSB_SS), - CLK_8_1("pc_cilab", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILAB, 0), - CLK_8_1("pc_cilcd", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILCD, 0), - CLK_8_1("pc_cile", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILE, 0), - CLK_8_1("pc_dsia_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIA_LP, 0), - CLK_8_1("pc_dsib_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIB_LP, 0), - CLK_8_1("pc_entropy", mux_p_clkm_clks_E, CLK_SOURCE_ENTROPY, 0), - CLK_8_1("pc_dvfs_ref", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_REF, DCF_HAVE_ENA), - CLK_8_1("pc_dvfs_soc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_SOC, DCF_HAVE_ENA), - CLK_8_1("pc_traceclkin", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_TRACECLKIN, 0), - CLK_8_1("pc_adx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX, DCF_HAVE_ENA), - CLK_8_1("pc_amx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX, DCF_HAVE_ENA), - CLK_8_1("pc_emc_latency", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_LATENCY, 0), - CLK_8_1("pc_soc_therm", mux_m_c_p_a_c2_c3, CLK_SOURCE_SOC_THERM, 0), - CLK_8_1("pc_vi_sensor2", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR2, 0), - CLK16_0("pc_i2c6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C6, 0), - CLK_8_1("pc_emc_dll", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_DLL, DCF_IS_EMC_DLL), - CLK_8_1("pc_hdmi_audio", mux_p_c_c2_clkm, CLK_SOURCE_HDMI_AUDIO, 0), - CLK_8_1("pc_clk72mhz", mux_p_c_c2_clkm, CLK_SOURCE_CLK72MHZ, 0), - CLK_8_1("pc_adx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX1, DCF_HAVE_ENA), - CLK_8_1("pc_amx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX1, DCF_HAVE_ENA), - CLK_8_1("pc_vic", mux_m_c_p_a_c2_c3_clkm, CLK_SOURCE_VIC, DCF_IS_VIC), + CLK_8_1(0, "pc_sor0", mux_p_m_d_a_c_d2_clkm, CLK_SOURCE_SOR0, DCF_IS_SOR0), + CLK_8_1(0, "pc_sata_oob", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA_OOB, 0), + CLK_8_1(0, "pc_sata", mux_p_N_c_N_m_N_clkm, CLK_SOURCE_SATA, FDS_IS_SATA), + CLK_8_1(0, "pc_hda", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_HDA, 0), + CLK_8_1(TEGRA124_CLK_XUSB_HOST_SRC, + "pc_xusb_core_host", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_HOST, 0), + CLK_8_1(TEGRA124_CLK_XUSB_FALCON_SRC, + "pc_xusb_falcon", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_FALCON, 0), + CLK_8_1(TEGRA124_CLK_XUSB_FS_SRC, + "pc_xusb_fs", mux_clkm_N_u48_N_p_N_u480, CLK_SOURCE_XUSB_FS, 0), + CLK_8_1(TEGRA124_CLK_XUSB_DEV_SRC, + "pc_xusb_core_dev", mux_clkm_p_c2_c_c3_refre, CLK_SOURCE_XUSB_CORE_DEV, 0), + CLK_8_1(TEGRA124_CLK_XUSB_SS_SRC, + "pc_xusb_ss", mux_clkm_refe_clks_u480_c_c2_c3_oscdiv, CLK_SOURCE_XUSB_SS, DCF_IS_XUSB_SS), + CLK_8_1(0, "pc_cilab", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILAB, 0), + CLK_8_1(0, "pc_cilcd", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILCD, 0), + CLK_8_1(0, "pc_cile", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_CILE, 0), + CLK_8_1(0, "pc_dsia_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIA_LP, 0), + CLK_8_1(0, "pc_dsib_lp", mux_p_N_c_N_N_N_clkm, CLK_SOURCE_DSIB_LP, 0), + CLK_8_1(0, "pc_entropy", mux_p_clkm_clks_E, CLK_SOURCE_ENTROPY, 0), + CLK_8_1(0, "pc_dvfs_ref", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_REF, DCF_HAVE_ENA), + CLK_8_1(0, "pc_dvfs_soc", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_DVFS_SOC, DCF_HAVE_ENA), + CLK_8_1(0, "pc_traceclkin", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_TRACECLKIN, 0), + CLK_8_1(0, "pc_adx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX, DCF_HAVE_ENA), + CLK_8_1(0, "pc_amx", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX, DCF_HAVE_ENA), + CLK_8_1(0, "pc_emc_latency", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_LATENCY, 0), + CLK_8_1(0, "pc_soc_therm", mux_m_c_p_a_c2_c3, CLK_SOURCE_SOC_THERM, 0), + CLK_8_1(0, "pc_vi_sensor2", mux_m_c2_c_c3_p_N_a, CLK_SOURCE_VI_SENSOR2, 0), + CLK16_0(0, "pc_i2c6", mux_p_c2_c_c3_m_N_clkm, CLK_SOURCE_I2C6, 0), + CLK_8_1(0, "pc_emc_dll", mux_m_c_p_clkm_mud_c2_c3, CLK_SOURCE_EMC_DLL, DCF_IS_EMC_DLL), + CLK_8_1(0, "pc_hdmi_audio", mux_p_c_c2_clkm, CLK_SOURCE_HDMI_AUDIO, 0), + CLK_8_1(0, "pc_clk72mhz", mux_p_c_c2_clkm, CLK_SOURCE_CLK72MHZ, 0), + CLK_8_1(0, "pc_adx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_ADX1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_amx1", mux_a_c2_c_c3_p_N_clkm, CLK_SOURCE_AMX1, DCF_HAVE_ENA), + CLK_8_1(0, "pc_vic", mux_m_c_p_a_c2_c3_clkm, CLK_SOURCE_VIC, DCF_IS_VIC), }; static int periph_init(struct clknode *clk, device_t dev); @@ -528,6 +541,7 @@ static clknode_method_t periph_methods[] }; DEFINE_CLASS_1(tegra124_periph, tegra124_periph_class, periph_methods, sizeof(struct periph_sc), clknode_class); + static int periph_init(struct clknode *clk, device_t dev) { @@ -637,14 +651,13 @@ periph_set_freq(struct clknode *clk, uin divider++; if (divider < (1 << sc->div_f_width)) - divider = 1 << sc->div_f_width; + divider = 1 << (sc->div_f_width - 1); - if ((*stop != 0) && - ((flags & (CLK_SET_ROUND_UP | CLK_SET_ROUND_DOWN)) == 0) && - (*fout != (tmp / divider))) - return (ERANGE); - - if ((flags & CLK_SET_DRYRUN) == 0) { + if (flags & CLK_SET_DRYRUN) { + if (((flags & (CLK_SET_ROUND_UP | CLK_SET_ROUND_DOWN)) == 0) && + (*fout != (tmp / divider))) + return (ERANGE); + } else { DEVICE_LOCK(sc); MD4(sc, sc->base_reg, sc->div_mask, (divider - (1 << sc->div_f_width))); @@ -703,9 +716,9 @@ DEFINE_CLASS_1(tegra124_pgate, tegra124_ static uint32_t get_enable_reg(int idx) { - KASSERT(idx / 32 < nitems(clk_enabale_reg), + KASSERT(idx / 32 < nitems(clk_enable_reg), ("Invalid clock index for enable: %d", idx)); - return (clk_enabale_reg[idx / 32]); + return (clk_enable_reg[idx / 32]); } static uint32_t Modified: head/sys/arm/nvidia/tegra124/tegra124_clk_pll.c ============================================================================== --- head/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Fri Nov 4 11:39:19 2016 (r308286) +++ head/sys/arm/nvidia/tegra124/tegra124_clk_pll.c Fri Nov 4 11:40:11 2016 (r308287) @@ -205,6 +205,16 @@ static struct pdiv_table pllu_map[] = { {0, 0} }; +static struct pdiv_table pllrefe_map[] = { + {1, 0}, + {2, 1}, + {3, 2}, + {4, 3}, + {5, 4}, + {6, 5}, + {0, 0}, +}; + static struct clk_pll_def pll_clks[] = { /* PLLM: 880 MHz Clock source for EMC 2x clock */ { @@ -342,6 +352,7 @@ static struct clk_pll_def pll_clks[] = { .lock_enable = PLLRE_MISC_LOCK_ENABLE, .iddq_reg = PLLRE_MISC, .iddq_mask = 1 << PLLRE_IDDQ_BIT, + .pdiv_table = pllrefe_map, .mnp_bits = {8, 8, 4, 16}, }, /* PLLE: generate the 100 MHz reference clock for USB 3.0 (spread spectrum) */ @@ -433,14 +444,14 @@ pdiv_to_reg(struct pll_sc *sc, uint32_t tbl = sc->pdiv_table; if (tbl == NULL) - return (ffs(p_div)); + return (ffs(p_div) - 1); while (tbl->divider != 0) { if (p_div <= tbl->divider) return (tbl->value); tbl++; } - return ~0; + return (0xFFFFFFFF); } static uint32_t @@ -449,15 +460,15 @@ reg_to_pdiv(struct pll_sc *sc, uint32_t struct pdiv_table *tbl; tbl = sc->pdiv_table; - if (tbl != NULL) { - while (tbl->divider) { - if (reg == tbl->value) - return (tbl->divider); - tbl++; - } - return (0); + if (tbl == NULL) + return (1 << reg); + + while (tbl->divider) { + if (reg == tbl->value) + return (tbl->divider); + tbl++; } - return (1 << reg); + return (0); } static uint32_t @@ -790,6 +801,7 @@ pllrefe_set_freq(struct pll_sc *sc, uint m = 1; p = 1; n = *fout * p * m / fin; + dprintf("%s: m: %d, n: %d, p: %d\n", __func__, m, n, p); return (pll_set_std(sc, fin, fout, flags, m, n, p)); } @@ -902,6 +914,7 @@ tegra124_pll_set_freq(struct clknode *cl rv = ENXIO; break; } + return (rv); } @@ -921,6 +934,11 @@ tegra124_pll_init(struct clknode *clk, d reg |= sc->lock_enable; WR4(sc, sc->misc_reg, reg); } + if (sc->type == PLL_REFE) { + RD4(sc, sc->misc_reg, ®); + reg &= ~(1 << 29); /* Diasble lock override */ + WR4(sc, sc->misc_reg, reg); + } clknode_init_parent_idx(clk, 0); return(0); From owner-svn-src-head@freebsd.org Fri Nov 4 12:58:52 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 308A1C2F771; Fri, 4 Nov 2016 12:58:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F40F21C3; Fri, 4 Nov 2016 12:58:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4CwpPK033620; Fri, 4 Nov 2016 12:58:51 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4CwpRN033619; Fri, 4 Nov 2016 12:58:51 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611041258.uA4CwpRN033619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 4 Nov 2016 12:58:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308288 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 12:58:52 -0000 Author: kib Date: Fri Nov 4 12:58:50 2016 New Revision: 308288 URL: https://svnweb.freebsd.org/changeset/base/308288 Log: Do not sleep in vm_wait() if pagedaemon did not yet started. Panic instead. Requests which cannot be satisfied by allocators at boot time often have unrealizable parameters. Waiting for the pagedaemon' start would hang the boot if done in the thread0 context and just never succeed if executed from another thread. In fact, for very early stages, sleep attempt panics with obscure diagnostic about the scheduler state, and explicit panic in vm_wait() makes the investigation much shorter by cut off the examination of the thread and scheduler. Theoretically, some subsystem might grab a resource to exhaustion, and free it later in the boot process. If this unlikely scenario does appear for real, the way to diagnose the trouble can be revisited. Reported by: emaste Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D8421 Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Fri Nov 4 11:40:11 2016 (r308287) +++ head/sys/vm/vm_page.c Fri Nov 4 12:58:50 2016 (r308288) @@ -2738,6 +2738,8 @@ vm_wait(void) msleep(&vm_pageout_pages_needed, &vm_page_queue_free_mtx, PDROP | PSWP, "VMWait", 0); } else { + if (__predict_false(pageproc == NULL)) + panic("vm_wait in early boot"); if (!vm_pageout_wanted) { vm_pageout_wanted = true; wakeup(&vm_pageout_wanted); From owner-svn-src-head@freebsd.org Fri Nov 4 13:07:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6113C2FAA7; Fri, 4 Nov 2016 13:07:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 757E6A37; Fri, 4 Nov 2016 13:07:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4D7s3e037530; Fri, 4 Nov 2016 13:07:54 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4D7ssp037529; Fri, 4 Nov 2016 13:07:54 GMT (envelope-from br@FreeBSD.org) Message-Id: <201611041307.uA4D7ssp037529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Fri, 4 Nov 2016 13:07:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308289 - head/sys/riscv/riscv X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 13:07:55 -0000 Author: br Date: Fri Nov 4 13:07:54 2016 New Revision: 308289 URL: https://svnweb.freebsd.org/changeset/base/308289 Log: System Binary Interface (SBI) page was moved in latest version of Berkeley Boot Loader (BBL) due to code size increase. We will need to dehardcode this somehow. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/sys/riscv/riscv/locore.S Modified: head/sys/riscv/riscv/locore.S ============================================================================== --- head/sys/riscv/riscv/locore.S Fri Nov 4 12:58:50 2016 (r308288) +++ head/sys/riscv/riscv/locore.S Fri Nov 4 13:07:54 2016 (r308289) @@ -137,7 +137,7 @@ _start: /* Create an L3 page for SBI */ la s1, pagetable_l3_sbi - li s2, 0x80009000 + li s2, 0x8000b000 srli s2, s2, PAGE_SHIFT li a5, 511 li t4, PTE_V | PTE_RX | PTE_W From owner-svn-src-head@freebsd.org Fri Nov 4 15:11:52 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEA4EC2EA74; Fri, 4 Nov 2016 15:11:52 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 806921C8; Fri, 4 Nov 2016 15:11:52 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4FBpmN088326; Fri, 4 Nov 2016 15:11:51 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4FBptL088325; Fri, 4 Nov 2016 15:11:51 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201611041511.uA4FBptL088325@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Fri, 4 Nov 2016 15:11:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308293 - head/usr.bin/fortune/datfiles X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 15:11:52 -0000 Author: vangyzen Date: Fri Nov 4 15:11:51 2016 New Revision: 308293 URL: https://svnweb.freebsd.org/changeset/base/308293 Log: Fix grammar in a fortune. Modified: head/usr.bin/fortune/datfiles/fortunes Modified: head/usr.bin/fortune/datfiles/fortunes ============================================================================== --- head/usr.bin/fortune/datfiles/fortunes Fri Nov 4 14:06:21 2016 (r308292) +++ head/usr.bin/fortune/datfiles/fortunes Fri Nov 4 15:11:51 2016 (r308293) @@ -58947,7 +58947,7 @@ You're not drunk if you can lie on the f % You're not my type. For that matter, you're not even my species!!! % -You're reasoning is excellent -- it's +Your reasoning is excellent -- it's only your basic assumptions that are wrong. % You're ugly and your mother dresses you funny. From owner-svn-src-head@freebsd.org Fri Nov 4 15:44:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52F37C2F35E; Fri, 4 Nov 2016 15:44:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 233598A3; Fri, 4 Nov 2016 15:44:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4Fi0RP000399; Fri, 4 Nov 2016 15:44:00 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4Fi0qW000398; Fri, 4 Nov 2016 15:44:00 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611041544.uA4Fi0qW000398@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 4 Nov 2016 15:44:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308294 - head/lib/libgcc_s X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 15:44:01 -0000 Author: emaste Date: Fri Nov 4 15:44:00 2016 New Revision: 308294 URL: https://svnweb.freebsd.org/changeset/base/308294 Log: libgcc_s: make unspecified shlib symbols local We want only symbols explicitly specified in the Version.map. Sponsored by: The FreeBSD Foundation Modified: head/lib/libgcc_s/Version.map Modified: head/lib/libgcc_s/Version.map ============================================================================== --- head/lib/libgcc_s/Version.map Fri Nov 4 15:11:51 2016 (r308293) +++ head/lib/libgcc_s/Version.map Fri Nov 4 15:44:00 2016 (r308294) @@ -3,6 +3,7 @@ */ GCC_3.0 { +global: __absvdi2; __absvsi2; __addvdi3; @@ -62,6 +63,8 @@ GCC_3.0 { _Unwind_Resume; _Unwind_SetGR; _Unwind_SetIP; +local: + *; }; GCC_3.3 { From owner-svn-src-head@freebsd.org Fri Nov 4 16:24:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FB3AC3047B; Fri, 4 Nov 2016 16:24:40 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F65677E; Fri, 4 Nov 2016 16:24:40 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4GOdgC016464; Fri, 4 Nov 2016 16:24:39 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4GOdc8016458; Fri, 4 Nov 2016 16:24:39 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201611041624.uA4GOdc8016458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 4 Nov 2016 16:24:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308295 - in head/sys: conf dev/gpio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 16:24:40 -0000 Author: gonzo Date: Fri Nov 4 16:24:38 2016 New Revision: 308295 URL: https://svnweb.freebsd.org/changeset/base/308295 Log: [gpio] Add GPIO driver for Intel Bay Trail SoC Bay Trail has three banks of GPIOs exposed to userland as /dev/gpiocN, where N is 1, 2, and 3. Pins in each bank are pre-named to match names on boards schematics: GPIO_S0_SCnn, GPIO_S0_NCnn, and GPIO_S5_nn. Controller supports edge-triggered and level-triggered interrupts but current version of the driver does not have interrupts support Added: head/sys/dev/gpio/bytgpio.c (contents, props changed) Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Fri Nov 4 15:44:00 2016 (r308294) +++ head/sys/conf/files.amd64 Fri Nov 4 16:24:38 2016 (r308295) @@ -270,6 +270,7 @@ dev/fdc/fdc.c optional fdc dev/fdc/fdc_acpi.c optional fdc dev/fdc/fdc_isa.c optional fdc isa dev/fdc/fdc_pccard.c optional fdc pccard +dev/gpio/bytgpio.c optional bytgpio dev/hpt27xx/hpt27xx_os_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_osm_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_config.c optional hpt27xx Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Fri Nov 4 15:44:00 2016 (r308294) +++ head/sys/conf/files.i386 Fri Nov 4 16:24:38 2016 (r308295) @@ -225,6 +225,7 @@ dev/fe/if_fe_isa.c optional fe isa dev/glxiic/glxiic.c optional glxiic dev/glxsb/glxsb.c optional glxsb dev/glxsb/glxsb_hash.c optional glxsb +dev/gpio/bytgpio.c optional bytgpio dev/hpt27xx/hpt27xx_os_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_osm_bsd.c optional hpt27xx dev/hpt27xx/hpt27xx_config.c optional hpt27xx Added: head/sys/dev/gpio/bytgpio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/gpio/bytgpio.c Fri Nov 4 16:24:38 2016 (r308295) @@ -0,0 +1,435 @@ +/*- + * Copyright (c) 2016 Oleksandr Tymoshenko + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_acpi.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include "gpio_if.h" + +/** + * Macros for driver mutex locking + */ +#define BYTGPIO_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx) +#define BYTGPIO_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->sc_mtx) +#define BYTGPIO_LOCK_INIT(_sc) \ + mtx_init(&_sc->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ + "bytgpio", MTX_SPIN) +#define BYTGPIO_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx) +#define BYTGPIO_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) +#define BYTGPIO_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED) + +struct bytgpio_softc { + ACPI_HANDLE sc_handle; + device_t sc_dev; + device_t sc_busdev; + struct mtx sc_mtx; + int sc_mem_rid; + struct resource *sc_mem_res; + int sc_npins; + const char* sc_bank_prefix; + const int *sc_pinpad_map; +}; + +static int bytgpio_probe(device_t dev); +static int bytgpio_attach(device_t dev); + +#define SCORE_UID 1 +#define SCORE_BANK_PREFIX "GPIO_S0_SC" +const int bytgpio_score_pins[] = { + 85, 89, 93, 96, 99, 102, 98, 101, 34, 37, 36, 38, 39, 35, 40, + 84, 62, 61, 64, 59, 54, 56, 60, 55, 63, 57, 51, 50, 53, 47, + 52, 49, 48, 43, 46, 41, 45, 42, 58, 44, 95, 105, 70, 68, 67, + 66, 69, 71, 65, 72, 86, 90, 88, 92, 103, 77, 79, 83, 78, 81, + 80, 82, 13, 12, 15, 14, 17, 18, 19, 16, 2, 1, 0, 4, 6, 7, 9, + 8, 33, 32, 31, 30, 29, 27, 25, 28, 26, 23, 21, 20, 24, 22, 5, + 3, 10, 11, 106, 87, 91, 104, 97, 100 +}; +#define SCORE_PINS nitems(bytgpio_score_pins) + +#define NCORE_UID 2 +#define NCORE_BANK_PREFIX "GPIO_S0_NC" +const int bytgpio_ncore_pins[] = { + 19, 18, 17, 20, 21, 22, 24, 25, 23, 16, 14, 15, 12, 26, 27, + 1, 4, 8, 11, 0, 3, 6, 10, 13, 2, 5, 9, 7 +}; +#define NCORE_PINS nitems(bytgpio_ncore_pins) + +#define SUS_UID 3 +#define SUS_BANK_PREFIX "GPIO_S5_" +const int bytgpio_sus_pins[] = { + 29, 33, 30, 31, 32, 34, 36, 35, 38, 37, 18, 7, 11, 20, 17, 1, + 8, 10, 19, 12, 0, 2, 23, 39, 28, 27, 22, 21, 24, 25, 26, 51, + 56, 54, 49, 55, 48, 57, 50, 58, 52, 53, 59, 40 +}; +#define SUS_PINS nitems(bytgpio_sus_pins) + +#define BYGPIO_PIN_REGISTER(sc, pin, reg) ((sc)->sc_pinpad_map[(pin)] * 16 + (reg)) +#define BYTGPIO_PCONF0 0x0000 +#define BYTGPIO_PAD_VAL 0x0008 +#define BYTGPIO_PAD_VAL_LEVEL (1 << 0) +#define BYTGPIO_PAD_VAL_I_OUTPUT_ENABLED (1 << 1) +#define BYTGPIO_PAD_VAL_I_INPUT_ENABLED (1 << 2) +#define BYTGPIO_PAD_VAL_DIR_MASK (3 << 1) + +static inline uint32_t +bytgpio_read_4(struct bytgpio_softc *sc, bus_size_t off) +{ + return (bus_read_4(sc->sc_mem_res, off)); +} + +static inline void +bytgpio_write_4(struct bytgpio_softc *sc, bus_size_t off, + uint32_t val) +{ + bus_write_4(sc->sc_mem_res, off, val); +} + +static device_t +bytgpio_get_bus(device_t dev) +{ + struct bytgpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->sc_busdev); +} + +static int +bytgpio_pin_max(device_t dev, int *maxpin) +{ + struct bytgpio_softc *sc; + + sc = device_get_softc(dev); + + *maxpin = sc->sc_npins - 1; + + return (0); +} + +static int +bytgpio_valid_pin(struct bytgpio_softc *sc, int pin) +{ + + if (pin >= sc->sc_npins || sc->sc_mem_res == NULL) + return (EINVAL); + + return (0); +} + +static int +bytgpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + struct bytgpio_softc *sc; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + *caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + + return (0); +} + +static int +bytgpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + struct bytgpio_softc *sc; + uint32_t reg, val; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + /* Get the current pin state */ + BYTGPIO_LOCK(sc); + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); + val = bytgpio_read_4(sc, reg); + *flags = 0; + if ((val & BYTGPIO_PAD_VAL_I_OUTPUT_ENABLED) == 0) + *flags |= GPIO_PIN_OUTPUT; + /* + * this bit can be cleared to read current output value + * sou output bit takes precedense + */ + else if ((val & BYTGPIO_PAD_VAL_I_INPUT_ENABLED) == 0) + *flags |= GPIO_PIN_INPUT; + BYTGPIO_UNLOCK(sc); + + return (0); +} + +static int +bytgpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct bytgpio_softc *sc; + uint32_t reg, val; + uint32_t allowed; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + allowed = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + + /* + * Only directtion flag allowed + */ + if (flags & ~allowed) + return (EINVAL); + + /* + * Not both directions simultaneously + */ + if ((flags & allowed) == allowed) + return (EINVAL); + + /* Set the GPIO mode and state */ + BYTGPIO_LOCK(sc); + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); + val = bytgpio_read_4(sc, reg); + val = val | BYTGPIO_PAD_VAL_DIR_MASK; + if (flags & GPIO_PIN_INPUT) + val = val & ~BYTGPIO_PAD_VAL_I_INPUT_ENABLED; + if (flags & GPIO_PIN_OUTPUT) + val = val & ~BYTGPIO_PAD_VAL_I_OUTPUT_ENABLED; + bytgpio_write_4(sc, reg, val); + BYTGPIO_UNLOCK(sc); + + return (0); +} + +static int +bytgpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + struct bytgpio_softc *sc; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + /* Set a very simple name */ + snprintf(name, GPIOMAXNAME, "%s%u", sc->sc_bank_prefix, pin); + name[GPIOMAXNAME - 1] = '\0'; + + return (0); +} + +static int +bytgpio_pin_set(device_t dev, uint32_t pin, unsigned int value) +{ + struct bytgpio_softc *sc; + uint32_t reg, val; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + BYTGPIO_LOCK(sc); + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); + val = bytgpio_read_4(sc, reg); + if (value == GPIO_PIN_LOW) + val = val & ~BYTGPIO_PAD_VAL_LEVEL; + else + val = val | BYTGPIO_PAD_VAL_LEVEL; + bytgpio_write_4(sc, reg, val); + BYTGPIO_UNLOCK(sc); + + return (0); +} + +static int +bytgpio_pin_get(device_t dev, uint32_t pin, unsigned int *value) +{ + struct bytgpio_softc *sc; + uint32_t reg, val; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + BYTGPIO_LOCK(sc); + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); + /* + * Enable input to read current value + */ + val = bytgpio_read_4(sc, reg); + val = val & ~BYTGPIO_PAD_VAL_I_INPUT_ENABLED; + bytgpio_write_4(sc, reg, val); + /* + * And read actual value + */ + val = bytgpio_read_4(sc, reg); + if (val & BYTGPIO_PAD_VAL_LEVEL) + *value = GPIO_PIN_HIGH; + else + *value = GPIO_PIN_LOW; + BYTGPIO_UNLOCK(sc); + + return (0); +} + +static int +bytgpio_pin_toggle(device_t dev, uint32_t pin) +{ + struct bytgpio_softc *sc; + uint32_t reg, val; + + sc = device_get_softc(dev); + if (bytgpio_valid_pin(sc, pin) != 0) + return (EINVAL); + + /* Toggle the pin */ + BYTGPIO_LOCK(sc); + reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PAD_VAL); + val = bytgpio_read_4(sc, reg); + val = val ^ BYTGPIO_PAD_VAL_LEVEL; + bytgpio_write_4(sc, reg, val); + BYTGPIO_UNLOCK(sc); + + return (0); +} + +static int +bytgpio_probe(device_t dev) +{ + static char *gpio_ids[] = { "INT33FC", NULL }; + + if (acpi_disabled("gpio") || + ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) + return (ENXIO); + + device_set_desc(dev, "Intel Baytrail GPIO Controller"); + return (0); +} + +static int +bytgpio_attach(device_t dev) +{ + struct bytgpio_softc *sc; + ACPI_STATUS status; + int uid; + + sc = device_get_softc(dev); + sc->sc_dev = dev; + sc->sc_handle = acpi_get_handle(dev); + status = acpi_GetInteger(sc->sc_handle, "_UID", &uid); + if (ACPI_FAILURE(status)) { + device_printf(dev, "failed to read _UID\n"); + return (ENXIO); + } + + switch (uid) { + case SCORE_UID: + sc->sc_npins = SCORE_PINS; + sc->sc_bank_prefix = SCORE_BANK_PREFIX; + sc->sc_pinpad_map = bytgpio_score_pins; + break; + case NCORE_UID: + sc->sc_npins = NCORE_PINS; + sc->sc_bank_prefix = NCORE_BANK_PREFIX; + sc->sc_pinpad_map = bytgpio_ncore_pins; + break; + case SUS_UID: + sc->sc_npins = SUS_PINS; + sc->sc_bank_prefix = SUS_BANK_PREFIX; + sc->sc_pinpad_map = bytgpio_sus_pins; + break; + default: + device_printf(dev, "invalid _UID value: %d\n", uid); + } + + sc->sc_mem_rid = 0; + sc->sc_mem_res = bus_alloc_resource_any(sc->sc_dev, + SYS_RES_MEMORY, &sc->sc_mem_rid, RF_ACTIVE); + if (sc->sc_mem_res == NULL) { + device_printf(dev, "can't allocate resource\n"); + goto error; + } + + BYTGPIO_LOCK_INIT(sc); + + sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) { + BYTGPIO_LOCK_DESTROY(sc); + bus_release_resource(dev, SYS_RES_MEMORY, + sc->sc_mem_rid, sc->sc_mem_res); + return (ENXIO); + } + + return (0); + +error: + return (ENXIO); +} + +static device_method_t bytgpio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, bytgpio_probe), + DEVMETHOD(device_attach, bytgpio_attach), + + /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, bytgpio_get_bus), + DEVMETHOD(gpio_pin_max, bytgpio_pin_max), + DEVMETHOD(gpio_pin_getname, bytgpio_pin_getname), + DEVMETHOD(gpio_pin_getflags, bytgpio_pin_getflags), + DEVMETHOD(gpio_pin_getcaps, bytgpio_pin_getcaps), + DEVMETHOD(gpio_pin_setflags, bytgpio_pin_setflags), + DEVMETHOD(gpio_pin_get, bytgpio_pin_get), + DEVMETHOD(gpio_pin_set, bytgpio_pin_set), + DEVMETHOD(gpio_pin_toggle, bytgpio_pin_toggle), + + DEVMETHOD_END +}; + +static driver_t bytgpio_driver = { + "gpio", + bytgpio_methods, + sizeof(struct bytgpio_softc), +}; + +static devclass_t bytgpio_devclass; +DRIVER_MODULE(bytgpio, acpi, bytgpio_driver, bytgpio_devclass, 0, 0); +MODULE_DEPEND(bytgpio, acpi, 1, 1, 1); +MODULE_DEPEND(bytgpio, gpio, 1, 1, 1); From owner-svn-src-head@freebsd.org Fri Nov 4 16:38:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC118C307A1; Fri, 4 Nov 2016 16:38:57 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from id.bluezbox.com (id.bluezbox.com [45.55.20.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D23ABF0A; Fri, 4 Nov 2016 16:38:57 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from [136.179.10.143] (helo=[10.140.230.85]) by id.bluezbox.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87 (FreeBSD)) (envelope-from ) id 1c2hVy-000Dgn-HM; Fri, 04 Nov 2016 09:38:50 -0700 From: Oleksandr Tymoshenko Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: svn commit: r308295 - in head/sys: conf dev/gpio Date: Fri, 4 Nov 2016 09:38:19 -0700 References: <201611041624.uA4GOdc8016458@repo.freebsd.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org In-Reply-To: <201611041624.uA4GOdc8016458@repo.freebsd.org> Message-Id: X-Mailer: Apple Mail (2.3251) Sender: gonzo@id.bluezbox.com X-Spam-Level: -- X-Spam-Report: Spam detection software, running on the system "id.bluezbox.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see The administrator of that system for details. Content preview: > On Nov 4, 2016, at 9:24 AM, Oleksandr Tymoshenko wrote: > > Author: gonzo > Date: Fri Nov 4 16:24:38 2016 > New Revision: 308295 > URL: https://svnweb.freebsd.org/changeset/base/308295 > > Log: > [gpio] Add GPIO driver for Intel Bay Trail SoC > > Bay Trail has three banks of GPIOs exposed to userland as /dev/gpiocN, > where N is 1, 2, and 3. Pins in each bank are pre-named to match names [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 16:38:58 -0000 > On Nov 4, 2016, at 9:24 AM, Oleksandr Tymoshenko = wrote: >=20 > Author: gonzo > Date: Fri Nov 4 16:24:38 2016 > New Revision: 308295 > URL: https://svnweb.freebsd.org/changeset/base/308295 >=20 > Log: > [gpio] Add GPIO driver for Intel Bay Trail SoC >=20 > Bay Trail has three banks of GPIOs exposed to userland as = /dev/gpiocN, > where N is 1, 2, and 3. Pins in each bank are pre-named to match = names This should have been =E2=80=9Cwhere N is 0, 1, and 2"= From owner-svn-src-head@freebsd.org Fri Nov 4 16:56:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8182DC30EF1; Fri, 4 Nov 2016 16:56:37 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50DA2FA; Fri, 4 Nov 2016 16:56:37 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4GuaGN028620; Fri, 4 Nov 2016 16:56:36 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4GuaZF028619; Fri, 4 Nov 2016 16:56:36 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201611041656.uA4GuaZF028619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Fri, 4 Nov 2016 16:56:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308296 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 16:56:37 -0000 Author: scottl Date: Fri Nov 4 16:56:36 2016 New Revision: 308296 URL: https://svnweb.freebsd.org/changeset/base/308296 Log: asc/ascq 44/0 is typically a non-transient, permanent error (at least until the components are reset). Therefore retries are pointless. This is very visible in SATL systems, for example an LSI SAS controller and a SATA HDD/SSD. Reviewed by: ken Obtained from: Netflix MFC after: 3 days Modified: head/sys/cam/scsi/scsi_all.c Modified: head/sys/cam/scsi/scsi_all.c ============================================================================== --- head/sys/cam/scsi/scsi_all.c Fri Nov 4 16:24:38 2016 (r308295) +++ head/sys/cam/scsi/scsi_all.c Fri Nov 4 16:56:36 2016 (r308296) @@ -2331,7 +2331,7 @@ static struct asc_table_entry asc_table[ { SST(0x43, 0x00, SS_RDEF, "Message error") }, /* DTLPWROMAEBKVF */ - { SST(0x44, 0x00, SS_RDEF, + { SST(0x44, 0x00, SS_FATAL | EIO, "Internal target failure") }, /* DT P MAEBKVF */ { SST(0x44, 0x01, SS_RDEF, /* XXX TBD */ From owner-svn-src-head@freebsd.org Fri Nov 4 17:02:43 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 471A4C30190; Fri, 4 Nov 2016 17:02:43 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1627B8B0; Fri, 4 Nov 2016 17:02:43 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4H2ge4032230; Fri, 4 Nov 2016 17:02:42 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4H2ghK032229; Fri, 4 Nov 2016 17:02:42 GMT (envelope-from des@FreeBSD.org) Message-Id: <201611041702.uA4H2ghK032229@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 4 Nov 2016 17:02:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308297 - head/bin/freebsd-version X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 17:02:43 -0000 Author: des Date: Fri Nov 4 17:02:42 2016 New Revision: 308297 URL: https://svnweb.freebsd.org/changeset/base/308297 Log: Use what(1) instead of strings(1). It's simpler and always available. PR: 213665 Submitted by: Pawel Worach MFC after: 1 week Modified: head/bin/freebsd-version/freebsd-version.sh.in Modified: head/bin/freebsd-version/freebsd-version.sh.in ============================================================================== --- head/bin/freebsd-version/freebsd-version.sh.in Fri Nov 4 16:56:36 2016 (r308296) +++ head/bin/freebsd-version/freebsd-version.sh.in Fri Nov 4 17:02:42 2016 (r308297) @@ -36,7 +36,7 @@ USERLAND_VERSION="@@REVISION@@-@@BRANCH@ : ${LOADER_CONF_FILES:=$LOADER_DIR/defaults/loader.conf $LOADER_DIR/loader.conf $LOADER_DIR/loader.conf.local} LOADER_RE1='^\([A-Z_a-z][0-9A-Z_a-z]*=[-./0-9A-Z_a-z]\{1,\}\).*$' LOADER_RE2='^\([A-Z_a-z][0-9A-Z_a-z]*="[-./0-9A-Z_a-z]\{1,\}"\).*$' -KERNEL_RE='^@(#)@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$' +KERNEL_RE='^@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$' progname=$(basename $0) @@ -67,7 +67,7 @@ kernel_version() { if [ ! -f "$kernfile" -o ! -r "$kernfile" ] ; then error "unable to locate kernel" fi - strings "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p" + what -qs "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p" } # From owner-svn-src-head@freebsd.org Fri Nov 4 17:04:46 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 601DFC3030C; Fri, 4 Nov 2016 17:04:46 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 236CCB9A; Fri, 4 Nov 2016 17:04:46 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4H4jFk032351; Fri, 4 Nov 2016 17:04:45 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4H4jHo032350; Fri, 4 Nov 2016 17:04:45 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611041704.uA4H4jHo032350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 17:04:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308298 - head/sys/dev/extres/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 17:04:46 -0000 Author: manu Date: Fri Nov 4 17:04:45 2016 New Revision: 308298 URL: https://svnweb.freebsd.org/changeset/base/308298 Log: Add clk_set_assigned assigned-clock-parents are DT properties used to configure some default parent clocks on one node. Reviewed by: mmel MFC after: 2 weeks Modified: head/sys/dev/extres/clk/clk.c head/sys/dev/extres/clk/clk.h Modified: head/sys/dev/extres/clk/clk.c ============================================================================== --- head/sys/dev/extres/clk/clk.c Fri Nov 4 17:02:42 2016 (r308297) +++ head/sys/dev/extres/clk/clk.c Fri Nov 4 17:04:45 2016 (r308298) @@ -1196,7 +1196,47 @@ clk_get_by_id(device_t dev, struct clkdo #ifdef FDT int -clk_get_by_ofw_index(device_t dev, phandle_t cnode, int idx, clk_t *clk) +clk_set_assigned(device_t dev, phandle_t node) +{ + clk_t clk, clk_parent; + int error, nclocks, i; + + error = ofw_bus_parse_xref_list_get_length(node, + "assigned-clock-parents", "#clock-cells", &nclocks); + + if (error != 0) { + device_printf(dev, "cannot parse assigned-clock-parents property\n"); + return (error); + } + + for (i = 0; i < nclocks; i++) { + error = clk_get_by_ofw_index_prop(dev, 0, + "assigned-clock-parents", i, &clk_parent); + if (error != 0) { + device_printf(dev, "cannot get parent %d\n", i); + return (error); + } + + error = clk_get_by_ofw_index_prop(dev, 0, "assigned-clocks", + i, &clk); + if (error != 0) { + device_printf(dev, "cannot get assigned clock %d\n", i); + clk_release(clk_parent); + return (error); + } + + error = clk_set_parent_by_clk(clk, clk_parent); + clk_release(clk_parent); + clk_release(clk); + if (error != 0) + return (error); + } + + return (0); +} + +int +clk_get_by_ofw_index_prop(device_t dev, phandle_t cnode, const char *prop, int idx, clk_t *clk) { phandle_t parent, *cells; device_t clockdev; @@ -1214,7 +1254,7 @@ clk_get_by_ofw_index(device_t dev, phand } - rv = ofw_bus_parse_xref_list_alloc(cnode, "clocks", "#clock-cells", idx, + rv = ofw_bus_parse_xref_list_alloc(cnode, prop, "#clock-cells", idx, &parent, &ncells, &cells); if (rv != 0) { return (rv); @@ -1247,6 +1287,12 @@ done: } int +clk_get_by_ofw_index(device_t dev, phandle_t cnode, int idx, clk_t *clk) +{ + return (clk_get_by_ofw_index_prop(dev, cnode, "clocks", idx, clk)); +} + +int clk_get_by_ofw_name(device_t dev, phandle_t cnode, const char *name, clk_t *clk) { int rv, idx; Modified: head/sys/dev/extres/clk/clk.h ============================================================================== --- head/sys/dev/extres/clk/clk.h Fri Nov 4 17:02:42 2016 (r308297) +++ head/sys/dev/extres/clk/clk.h Fri Nov 4 17:04:45 2016 (r308298) @@ -129,7 +129,9 @@ int clk_set_parent_by_clk(clk_t clk, clk const char *clk_get_name(clk_t clk); #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); +int clk_get_by_ofw_index_prop(device_t dev, phandle_t cnode, const char *prop, int idx, clk_t *clk); int clk_get_by_ofw_name(device_t dev, phandle_t node, const char *name, clk_t *clk); int clk_parse_ofw_out_names(device_t dev, phandle_t node, From owner-svn-src-head@freebsd.org Fri Nov 4 17:08:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB426C304C0; Fri, 4 Nov 2016 17:08:53 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D758EF7; Fri, 4 Nov 2016 17:08:53 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4H8q3m032529; Fri, 4 Nov 2016 17:08:52 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4H8qcc032528; Fri, 4 Nov 2016 17:08:52 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201611041708.uA4H8qcc032528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Fri, 4 Nov 2016 17:08:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308299 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 17:08:53 -0000 Author: scottl Date: Fri Nov 4 17:08:52 2016 New Revision: 308299 URL: https://svnweb.freebsd.org/changeset/base/308299 Log: If the da periph probe state machine gets an asc=0x44 error, the periph is not going to recover until the system is reset. Treat it as a special case and don't allow it to fall through to quasi-success. Reviewed by: ken, imp Obtained from: Netflix MFC after: 3 days Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Fri Nov 4 17:04:45 2016 (r308298) +++ head/sys/cam/scsi/scsi_da.c Fri Nov 4 17:08:52 2016 (r308299) @@ -4310,8 +4310,14 @@ dadone(struct cam_periph *periph, union * direct access or optical disk device, * as long as it doesn't return a "Logical * unit not supported" (0x25) error. + * "Internal Target Failure" (0x44) is also + * special and typically means that the + * device is a SATA drive behind a SATL + * translation that's fallen into a + * terminally fatal state. */ - if ((have_sense) && (asc != 0x25) + if ((have_sense) + && (asc != 0x25) && (asc != 0x44) && (error_code == SSD_CURRENT_ERROR)) { const char *sense_key_desc; const char *asc_desc; From owner-svn-src-head@freebsd.org Fri Nov 4 17:13:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC417C3070E; Fri, 4 Nov 2016 17:13:48 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BAF6780; Fri, 4 Nov 2016 17:13:48 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4HDlmT036335; Fri, 4 Nov 2016 17:13:47 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4HDlJb036334; Fri, 4 Nov 2016 17:13:47 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611041713.uA4HDlJb036334@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 17:13:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308300 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 17:13:48 -0000 Author: manu Date: Fri Nov 4 17:13:47 2016 New Revision: 308300 URL: https://svnweb.freebsd.org/changeset/base/308300 Log: For AHB clock we need to set the assigned parents for cpufreq(4) to work. MFC after: 2 weeks Modified: head/sys/arm/allwinner/clk/aw_ahbclk.c Modified: head/sys/arm/allwinner/clk/aw_ahbclk.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_ahbclk.c Fri Nov 4 17:08:52 2016 (r308299) +++ head/sys/arm/allwinner/clk/aw_ahbclk.c Fri Nov 4 17:13:47 2016 (r308300) @@ -350,6 +350,12 @@ aw_ahbclk_attach(device_t dev) goto fail; } + error = clk_set_assigned(dev, node); + if (error != 0) { + device_printf(dev, "cannot set assigned parents: %d\n", error); + goto fail; + } + if (bootverbose) clkdom_dump(clkdom); From owner-svn-src-head@freebsd.org Fri Nov 4 17:25:49 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 414F1C30B78; Fri, 4 Nov 2016 17:25:49 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 022BFF32; Fri, 4 Nov 2016 17:25:48 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4HPmkp040302; Fri, 4 Nov 2016 17:25:48 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4HPmZX040300; Fri, 4 Nov 2016 17:25:48 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201611041725.uA4HPmZX040300@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Fri, 4 Nov 2016 17:25:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308301 - in head/sys/dev: mpr mps X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 17:25:49 -0000 Author: scottl Date: Fri Nov 4 17:25:47 2016 New Revision: 308301 URL: https://svnweb.freebsd.org/changeset/base/308301 Log: Record the LogInfo field when reporting the IOCStatus. Helps in debugging errors. Submitted by: slm Obtained from: Netflix MFC after: 3 days Modified: head/sys/dev/mpr/mpr_sas.c head/sys/dev/mps/mps_sas.c Modified: head/sys/dev/mpr/mpr_sas.c ============================================================================== --- head/sys/dev/mpr/mpr_sas.c Fri Nov 4 17:13:47 2016 (r308300) +++ head/sys/dev/mpr/mpr_sas.c Fri Nov 4 17:25:47 2016 (r308301) @@ -2496,8 +2496,9 @@ mprsas_scsiio_complete(struct mpr_softc */ mprsas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR); mprsas_log_command(cm, MPR_INFO, - "terminated ioc %x scsi %x state %x xfer %u\n", - le16toh(rep->IOCStatus), rep->SCSIStatus, rep->SCSIState, + "terminated ioc %x loginfo %x scsi %x state %x xfer %u\n", + le16toh(rep->IOCStatus), le32toh(rep->IOCLogInfo), + rep->SCSIStatus, rep->SCSIState, le32toh(rep->TransferCount)); break; case MPI2_IOCSTATUS_INVALID_FUNCTION: @@ -2512,8 +2513,9 @@ mprsas_scsiio_complete(struct mpr_softc case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED: default: mprsas_log_command(cm, MPR_XINFO, - "completed ioc %x scsi %x state %x xfer %u\n", - le16toh(rep->IOCStatus), rep->SCSIStatus, rep->SCSIState, + "completed ioc %x loginfo %x scsi %x state %x xfer %u\n", + le16toh(rep->IOCStatus), le32toh(rep->IOCLogInfo), + rep->SCSIStatus, rep->SCSIState, le32toh(rep->TransferCount)); csio->resid = cm->cm_length; mprsas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR); Modified: head/sys/dev/mps/mps_sas.c ============================================================================== --- head/sys/dev/mps/mps_sas.c Fri Nov 4 17:13:47 2016 (r308300) +++ head/sys/dev/mps/mps_sas.c Fri Nov 4 17:25:47 2016 (r308301) @@ -2446,8 +2446,9 @@ mpssas_scsiio_complete(struct mps_softc */ mpssas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR); mpssas_log_command(cm, MPS_INFO, - "terminated ioc %x scsi %x state %x xfer %u\n", - le16toh(rep->IOCStatus), rep->SCSIStatus, rep->SCSIState, + "terminated ioc %x loginfo %x scsi %x state %x xfer %u\n", + le16toh(rep->IOCStatus), le32toh(rep->IOCLogInfo), + rep->SCSIStatus, rep->SCSIState, le32toh(rep->TransferCount)); break; case MPI2_IOCSTATUS_INVALID_FUNCTION: @@ -2462,8 +2463,9 @@ mpssas_scsiio_complete(struct mps_softc case MPI2_IOCSTATUS_SCSI_TASK_MGMT_FAILED: default: mpssas_log_command(cm, MPS_XINFO, - "completed ioc %x scsi %x state %x xfer %u\n", - le16toh(rep->IOCStatus), rep->SCSIStatus, rep->SCSIState, + "completed ioc %x loginfo %x scsi %x state %x xfer %u\n", + le16toh(rep->IOCStatus), le32toh(rep->IOCLogInfo), + rep->SCSIStatus, rep->SCSIState, le32toh(rep->TransferCount)); csio->resid = cm->cm_length; mpssas_set_ccbstatus(ccb, CAM_REQ_CMP_ERR); From owner-svn-src-head@freebsd.org Fri Nov 4 19:21:13 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CDFFC30D68; Fri, 4 Nov 2016 19:21:13 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D099BDB7; Fri, 4 Nov 2016 19:21:12 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4JLCj1084288; Fri, 4 Nov 2016 19:21:12 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4JLC9B084287; Fri, 4 Nov 2016 19:21:12 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611041921.uA4JLC9B084287@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 19:21:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308306 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 19:21:13 -0000 Author: manu Date: Fri Nov 4 19:21:11 2016 New Revision: 308306 URL: https://svnweb.freebsd.org/changeset/base/308306 Log: Set rst_apb to NULL to avoid panic when release. Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c ============================================================================== --- head/sys/arm/allwinner/aw_cir.c Fri Nov 4 19:07:12 2016 (r308305) +++ head/sys/arm/allwinner/aw_cir.c Fri Nov 4 19:21:11 2016 (r308306) @@ -390,6 +390,7 @@ aw_ir_attach(device_t dev) uint32_t val = 0; clk_ir = clk_gate = NULL; + rst_abp = NULL; sc = device_get_softc(dev); sc->dev = dev; From owner-svn-src-head@freebsd.org Fri Nov 4 19:23:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34AF8C30092; Fri, 4 Nov 2016 19:23:54 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0328A24B; Fri, 4 Nov 2016 19:23:53 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4JNrCT087084; Fri, 4 Nov 2016 19:23:53 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4JNr16087083; Fri, 4 Nov 2016 19:23:53 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611041923.uA4JNr16087083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 19:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308307 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 19:23:54 -0000 Author: manu Date: Fri Nov 4 19:23:52 2016 New Revision: 308307 URL: https://svnweb.freebsd.org/changeset/base/308307 Log: Fix r308306 by spelling variable correctly. Modified: head/sys/arm/allwinner/aw_cir.c Modified: head/sys/arm/allwinner/aw_cir.c ============================================================================== --- head/sys/arm/allwinner/aw_cir.c Fri Nov 4 19:21:11 2016 (r308306) +++ head/sys/arm/allwinner/aw_cir.c Fri Nov 4 19:23:52 2016 (r308307) @@ -390,7 +390,7 @@ aw_ir_attach(device_t dev) uint32_t val = 0; clk_ir = clk_gate = NULL; - rst_abp = NULL; + rst_apb = NULL; sc = device_get_softc(dev); sc->dev = dev; From owner-svn-src-head@freebsd.org Fri Nov 4 19:35:50 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA532C303CD; Fri, 4 Nov 2016 19:35:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AAFD1AE1; Fri, 4 Nov 2016 19:35:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4JZnxL091230; Fri, 4 Nov 2016 19:35:49 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4JZnil091226; Fri, 4 Nov 2016 19:35:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611041935.uA4JZnil091226@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 4 Nov 2016 19:35:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308308 - in head: . gnu/lib gnu/lib/libgcc lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 19:35:51 -0000 Author: emaste Date: Fri Nov 4 19:35:49 2016 New Revision: 308308 URL: https://svnweb.freebsd.org/changeset/base/308308 Log: Connect new LLVM-based libgcc_eh & libgcc_s to the build Compiler-rt and LLVM's libunwind provide a suitable replacement for libgcc.a, libgcc_eh.a, and libgcc_s.so. Remove the now-unused LLVM_LIBUNWIND block from gnu/lib/libgcc. PR: 213480 [exp-run] Reviewed by: brooks, ed Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8189 Modified: head/Makefile.inc1 head/gnu/lib/Makefile head/gnu/lib/libgcc/Makefile head/lib/Makefile Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Nov 4 19:23:52 2016 (r308307) +++ head/Makefile.inc1 Fri Nov 4 19:35:49 2016 (r308308) @@ -2001,7 +2001,7 @@ libraries: .MAKE .PHONY # # static libgcc.a prerequisite for shared libc # -_prereq_libs= gnu/lib/libgcc lib/libcompiler_rt +_prereq_libs= lib/libcompiler_rt .if ${MK_SSP} != "no" _prereq_libs+= gnu/lib/libssp/libssp_nonshared .endif @@ -2013,7 +2013,6 @@ _prereq_libs+= gnu/lib/libssp/libssp_non # _startup_libs= gnu/lib/csu _startup_libs+= lib/csu -_startup_libs+= gnu/lib/libgcc _startup_libs+= lib/libcompiler_rt _startup_libs+= lib/libc _startup_libs+= lib/libc_nonshared @@ -2021,11 +2020,27 @@ _startup_libs+= lib/libc_nonshared _startup_libs+= lib/libcxxrt .endif +.if ${MK_LLVM_LIBUNWIND} != "no" +_prereq_libs+= lib/libgcc_eh lib/libgcc_s +_startup_libs+= lib/libgcc_eh lib/libgcc_s + +lib/libgcc_s__L: lib/libc__L +lib/libgcc_s__L: lib/libc_nonshared__L +.if ${MK_LIBCPLUSPLUS} != "no" +lib/libcxxrt__L: lib/libgcc_s__L +.endif + +.else # MK_LLVM_LIBUNWIND == no + +_prereq_libs+= gnu/lib/libgcc +_startup_libs+= gnu/lib/libgcc + gnu/lib/libgcc__L: lib/libc__L gnu/lib/libgcc__L: lib/libc_nonshared__L .if ${MK_LIBCPLUSPLUS} != "no" lib/libcxxrt__L: gnu/lib/libgcc__L .endif +.endif _prebuild_libs= ${_kerberos5_lib_libasn1} \ ${_kerberos5_lib_libhdb} \ Modified: head/gnu/lib/Makefile ============================================================================== --- head/gnu/lib/Makefile Fri Nov 4 19:23:52 2016 (r308307) +++ head/gnu/lib/Makefile Fri Nov 4 19:35:49 2016 (r308308) @@ -3,8 +3,6 @@ .include SUBDIR= csu -SUBDIR+= libgcc - SUBDIR.${MK_DIALOG}+= libdialog SUBDIR.${MK_GCC}+= libgcov libgomp SUBDIR.${MK_SSP}+= libssp @@ -19,6 +17,10 @@ SUBDIR+= libreadline SUBDIR+= libregex .endif +.if ${MK_LLVM_LIBUNWIND} == "no" +SUBDIR+= libgcc +.endif + # libsupc++ uses libstdc++ headers, although 'make includes' should # have taken care of that already. .if ${MK_GNUCXX} != "no" Modified: head/gnu/lib/libgcc/Makefile ============================================================================== --- head/gnu/lib/libgcc/Makefile Fri Nov 4 19:23:52 2016 (r308307) +++ head/gnu/lib/libgcc/Makefile Fri Nov 4 19:35:49 2016 (r308308) @@ -4,9 +4,6 @@ PACKAGE= clibs GCCDIR= ${.CURDIR}/../../../contrib/gcc GCCLIB= ${.CURDIR}/../../../contrib/gcclibs CCDIR= ${.CURDIR}/../../usr.bin/cc -COMPILERRTDIR= ${.CURDIR}/../../../contrib/compiler-rt -UNWINDINCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/include -UNWINDSRCDIR= ${.CURDIR}/../../../contrib/llvm/projects/libunwind/src SHLIB_NAME= libgcc_s.so.1 SHLIBDIR?= /lib @@ -74,33 +71,6 @@ LIB2FUNCS+= _floatdi${mode} _floatundi${ LIB2ADD = $(LIB2FUNCS_EXTRA) LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) -# Additional sources to handle exceptions; overridden by targets as needed. -.if ${MK_LLVM_LIBUNWIND} != "no" - -.PATH: ${COMPILERRTDIR}/lib/builtins -.PATH: ${UNWINDSRCDIR} -LIB2ADDEH = gcc_personality_v0.c \ - int_util.c \ - Unwind-EHABI.cpp \ - Unwind-sjlj.c \ - UnwindLevel1-gcc-ext.c \ - UnwindLevel1.c \ - UnwindRegistersRestore.S \ - UnwindRegistersSave.S \ - libunwind.cpp - -CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++11 -.endif -CXXFLAGS+= -fno-rtti -STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC -.if ${MK_DIRDEPS_BUILD} == "yes" -# Avoid dependency on lib/libc++ -CFLAGS+= -I${SRCTOP}/contrib/libc++/include -.endif - -.else # MK_LLVM_LIBUNWIND .if ${TARGET_CPUARCH} == "arm" LIB2ADDEH = unwind-arm.c libunwind-arm.S pr-support.c unwind-c.c @@ -109,8 +79,6 @@ LIB2ADDEH = unwind-dw2.c unwind-dw2-fde- unwind-c.c .endif -.endif # MK_LLVM_LIBUNWIND - LIB2ADDEHSTATIC = $(LIB2ADDEH) LIB2ADDEHSHARED = $(LIB2ADDEH) @@ -202,14 +170,7 @@ LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS: .endif COMMONHDRS= tm.h tconfig.h options.h gthr-default.h -.if ${MK_LLVM_LIBUNWIND} != "no" -# unwind.h is a generated file when MK_LLVM_LIBUNWIND == "no", and a stale -# copy may be left behind in OBJDIR when switching, so remove it explicitly. -beforebuild: - @rm -f ${.OBJDIR}/unwind.h -.else COMMONHDRS+= unwind.h -.endif #----------------------------------------------------------------------- # Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Fri Nov 4 19:23:52 2016 (r308307) +++ head/lib/Makefile Fri Nov 4 19:35:49 2016 (r308308) @@ -160,6 +160,8 @@ _libcplusplus= libc++ SUBDIR.${MK_EFI}+= libefivar SUBDIR.${MK_LIBTHR}+= libthr +SUBDIR.${MK_LLVM_LIBUNWIND}+= libgcc_eh +SUBDIR.${MK_LLVM_LIBUNWIND}+= libgcc_s SUBDIR.${MK_NAND}+= libnandfs SUBDIR.${MK_NETGRAPH}+= libnetgraph SUBDIR.${MK_NIS}+= libypclnt From owner-svn-src-head@freebsd.org Fri Nov 4 20:02:53 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85D6CC30B67; Fri, 4 Nov 2016 20:02:53 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 563F9E2B; Fri, 4 Nov 2016 20:02:53 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4K2qib003393; Fri, 4 Nov 2016 20:02:52 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4K2qh0003391; Fri, 4 Nov 2016 20:02:52 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611042002.uA4K2qh0003391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 20:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308309 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 20:02:53 -0000 Author: manu Date: Fri Nov 4 20:02:52 2016 New Revision: 308309 URL: https://svnweb.freebsd.org/changeset/base/308309 Log: Add support for AXP221 Power Management Unit. AXP221 is used on board with A31/A31S and is mostly compatible with AXP209. Regulators, GPIO and Sensors are supported. MFC after: 2 weeks Modified: head/sys/arm/allwinner/axp209.c head/sys/arm/allwinner/axp209reg.h Modified: head/sys/arm/allwinner/axp209.c ============================================================================== --- head/sys/arm/allwinner/axp209.c Fri Nov 4 19:35:49 2016 (r308308) +++ head/sys/arm/allwinner/axp209.c Fri Nov 4 20:02:52 2016 (r308309) @@ -27,9 +27,11 @@ #include __FBSDID("$FreeBSD$"); + /* -* X-Power AXP209 PMU for Allwinner SoCs +* X-Power AXP209/AXP211 PMU for Allwinner SoCs */ + #include #include #include @@ -61,9 +63,9 @@ __FBSDID("$FreeBSD$"); #include "gpio_if.h" #include "regdev_if.h" -MALLOC_DEFINE(M_AXP209_REG, "Axp209 regulator", "Axp209 power regulator"); +MALLOC_DEFINE(M_AXP2XX_REG, "Axp2XX regulator", "Axp2XX power regulator"); -struct axp209_regdef { +struct axp2xx_regdef { intptr_t id; char *name; uint8_t enable_reg; @@ -77,7 +79,7 @@ struct axp209_regdef { int voltage_nstep; }; -static struct axp209_regdef axp209_regdefs[] = { +static struct axp2xx_regdef axp209_regdefs[] = { { .id = AXP209_REG_ID_DCDC2, .name = "dcdc2", @@ -129,36 +131,503 @@ static struct axp209_regdef axp209_regde }, }; -struct axp209_reg_sc { +static struct axp2xx_regdef axp221_regdefs[] = { + { + .id = AXP221_REG_ID_DLDO1, + .name = "dldo1", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_DLDO1, + .voltage_reg = AXP221_REG_DLDO1_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_DLDO2, + .name = "dldo2", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_DLDO2, + .voltage_reg = AXP221_REG_DLDO2_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_DLDO3, + .name = "dldo3", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_DLDO3, + .voltage_reg = AXP221_REG_DLDO3_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_DLDO4, + .name = "dldo4", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_DLDO4, + .voltage_reg = AXP221_REG_DLDO4_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_ELDO1, + .name = "eldo1", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_ELDO1, + .voltage_reg = AXP221_REG_ELDO1_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_ELDO2, + .name = "eldo2", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_ELDO2, + .voltage_reg = AXP221_REG_ELDO2_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_ELDO3, + .name = "eldo3", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_ELDO3, + .voltage_reg = AXP221_REG_ELDO3_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_DC5LDO, + .name = "dc5ldo", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DC5LDO, + .voltage_reg = AXP221_REG_DC5LDO_VOLTAGE, + .voltage_mask = 0x3, + .voltage_min = 700, + .voltage_max = 1400, + .voltage_step = 100, + .voltage_nstep = 7, + }, + { + .id = AXP221_REG_ID_DCDC1, + .name = "dcdc1", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DCDC1, + .voltage_reg = AXP221_REG_DCDC1_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 1600, + .voltage_max = 3400, + .voltage_step = 100, + .voltage_nstep = 18, + }, + { + .id = AXP221_REG_ID_DCDC2, + .name = "dcdc2", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DCDC2, + .voltage_reg = AXP221_REG_DCDC2_VOLTAGE, + .voltage_mask = 0x3f, + .voltage_min = 600, + .voltage_max = 1540, + .voltage_step = 20, + .voltage_nstep = 47, + }, + { + .id = AXP221_REG_ID_DCDC3, + .name = "dcdc3", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DCDC3, + .voltage_reg = AXP221_REG_DCDC3_VOLTAGE, + .voltage_mask = 0x3f, + .voltage_min = 600, + .voltage_max = 1860, + .voltage_step = 20, + .voltage_nstep = 63, + }, + { + .id = AXP221_REG_ID_DCDC4, + .name = "dcdc4", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DCDC4, + .voltage_reg = AXP221_REG_DCDC4_VOLTAGE, + .voltage_mask = 0x3f, + .voltage_min = 600, + .voltage_max = 1540, + .voltage_step = 20, + .voltage_nstep = 47, + }, + { + .id = AXP221_REG_ID_DCDC5, + .name = "dcdc5", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_DCDC5, + .voltage_reg = AXP221_REG_DCDC5_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 1000, + .voltage_max = 2550, + .voltage_step = 50, + .voltage_nstep = 31, + }, + { + .id = AXP221_REG_ID_ALDO1, + .name = "aldo1", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_ALDO1, + .voltage_reg = AXP221_REG_ALDO1_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_ALDO2, + .name = "aldo2", + .enable_reg = AXP221_POWERCTL_1, + .enable_mask = AXP221_POWERCTL1_ALDO2, + .voltage_reg = AXP221_REG_ALDO2_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_ALDO3, + .name = "aldo3", + .enable_reg = AXP221_POWERCTL_3, + .enable_mask = AXP221_POWERCTL3_ALDO3, + .voltage_reg = AXP221_REG_ALDO3_VOLTAGE, + .voltage_mask = 0x1f, + .voltage_min = 700, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 26, + }, + { + .id = AXP221_REG_ID_DC1SW, + .name = "dc1sw", + .enable_reg = AXP221_POWERCTL_2, + .enable_mask = AXP221_POWERCTL2_DC1SW, + }, +}; + +struct axp2xx_reg_sc { struct regnode *regnode; device_t base_dev; - struct axp209_regdef *def; + struct axp2xx_regdef *def; phandle_t xref; struct regnode_std_param *param; }; -struct axp209_softc { +struct axp2xx_pins { + const char *name; + uint8_t ctrl_reg; + uint8_t status_reg; + uint8_t status_mask; + uint8_t status_shift; +}; + +/* GPIO3 is different, don't expose it for now */ +static const struct axp2xx_pins axp209_pins[] = { + { + .name = "GPIO0", + .ctrl_reg = AXP2XX_GPIO0_CTRL, + .status_reg = AXP2XX_GPIO_STATUS, + .status_mask = 0x10, + .status_shift = 4, + }, + { + .name = "GPIO1", + .ctrl_reg = AXP2XX_GPIO1_CTRL, + .status_reg = AXP2XX_GPIO_STATUS, + .status_mask = 0x20, + .status_shift = 5, + }, + { + .name = "GPIO2", + .ctrl_reg = AXP209_GPIO2_CTRL, + .status_reg = AXP2XX_GPIO_STATUS, + .status_mask = 0x40, + .status_shift = 6, + }, +}; + +static const struct axp2xx_pins axp221_pins[] = { + { + .name = "GPIO0", + .ctrl_reg = AXP2XX_GPIO0_CTRL, + .status_reg = AXP2XX_GPIO_STATUS, + .status_mask = 0x1, + .status_shift = 0x0, + }, + { + .name = "GPIO1", + .ctrl_reg = AXP2XX_GPIO0_CTRL, + .status_reg = AXP2XX_GPIO_STATUS, + .status_mask = 0x2, + .status_shift = 0x1, + }, +}; + +struct axp2xx_sensors { + int id; + const char *name; + const char *desc; + const char *format; + uint8_t enable_reg; + uint8_t enable_mask; + uint8_t value_reg; + uint8_t value_size; + uint8_t h_value_mask; + uint8_t h_value_shift; + uint8_t l_value_mask; + uint8_t l_value_shift; + int value_step; + int value_convert; +}; + +static const struct axp2xx_sensors axp209_sensors[] = { + { + .id = AXP209_ACVOLT, + .name = "acvolt", + .desc = "AC Voltage (microvolt)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP209_ADC1_ACVOLT, + .value_reg = AXP209_ACIN_VOLTAGE, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP209_VOLT_STEP, + }, + { + .id = AXP209_ACCURRENT, + .name = "accurrent", + .desc = "AC Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP209_ADC1_ACCURRENT, + .value_reg = AXP209_ACIN_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP209_ACCURRENT_STEP, + }, + { + .id = AXP209_VBUSVOLT, + .name = "vbusvolt", + .desc = "VBUS Voltage (microVolt)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP209_ADC1_VBUSVOLT, + .value_reg = AXP209_VBUS_VOLTAGE, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP209_VOLT_STEP, + }, + { + .id = AXP209_VBUSCURRENT, + .name = "vbuscurrent", + .desc = "VBUS Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP209_ADC1_VBUSCURRENT, + .value_reg = AXP209_VBUS_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP209_VBUSCURRENT_STEP, + }, + { + .id = AXP2XX_BATVOLT, + .name = "batvolt", + .desc = "Battery Voltage (microVolt)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATVOLT, + .value_reg = AXP2XX_BAT_VOLTAGE, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP2XX_BATVOLT_STEP, + }, + { + .id = AXP2XX_BATCHARGECURRENT, + .name = "batchargecurrent", + .desc = "Battery Charging Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATCURRENT, + .value_reg = AXP2XX_BAT_CHARGE_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 5, + .l_value_mask = 0x1f, + .l_value_shift = 0, + .value_step = AXP2XX_BATCURRENT_STEP, + }, + { + .id = AXP2XX_BATDISCHARGECURRENT, + .name = "batdischargecurrent", + .desc = "Battery Discharging Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATCURRENT, + .value_reg = AXP2XX_BAT_DISCHARGE_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 5, + .l_value_mask = 0x1f, + .l_value_shift = 0, + .value_step = AXP2XX_BATCURRENT_STEP, + }, + { + .id = AXP2XX_TEMP, + .name = "temp", + .desc = "Internal Temperature", + .format = "IK", + .enable_reg = AXP209_ADC_ENABLE2, + .enable_mask = AXP209_ADC2_TEMP, + .value_reg = AXP209_TEMPMON, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = 1, + .value_convert = -(AXP209_TEMPMON_MIN - AXP209_0C_TO_K), + }, +}; + +static const struct axp2xx_sensors axp221_sensors[] = { + { + .id = AXP2XX_BATVOLT, + .name = "batvolt", + .desc = "Battery Voltage (microVolt)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATVOLT, + .value_reg = AXP2XX_BAT_VOLTAGE, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = AXP2XX_BATVOLT_STEP, + }, + { + .id = AXP2XX_BATCHARGECURRENT, + .name = "batchargecurrent", + .desc = "Battery Charging Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATCURRENT, + .value_reg = AXP2XX_BAT_CHARGE_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 5, + .l_value_mask = 0x1f, + .l_value_shift = 0, + .value_step = AXP2XX_BATCURRENT_STEP, + }, + { + .id = AXP2XX_BATDISCHARGECURRENT, + .name = "batdischargecurrent", + .desc = "Battery Discharging Current (microAmpere)", + .format = "I", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP2XX_ADC1_BATCURRENT, + .value_reg = AXP2XX_BAT_DISCHARGE_CURRENT, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 5, + .l_value_mask = 0x1f, + .l_value_shift = 0, + .value_step = AXP2XX_BATCURRENT_STEP, + }, + { + .id = AXP2XX_TEMP, + .name = "temp", + .desc = "Internal Temperature", + .format = "IK", + .enable_reg = AXP2XX_ADC_ENABLE1, + .enable_mask = AXP221_ADC1_TEMP, + .value_reg = AXP221_TEMPMON, + .value_size = 2, + .h_value_mask = 0xff, + .h_value_shift = 4, + .l_value_mask = 0xf, + .l_value_shift = 0, + .value_step = 1, + .value_convert = -(AXP221_TEMPMON_MIN - AXP209_0C_TO_K), + }, +}; + +enum AXP2XX_TYPE { + AXP209 = 1, + AXP221, +}; + +struct axp2xx_softc { device_t dev; uint32_t addr; struct resource * res[1]; void * intrcookie; struct intr_config_hook intr_hook; - device_t gpiodev; struct mtx mtx; + uint8_t type; + + /* GPIO */ + device_t gpiodev; + int npins; + const struct axp2xx_pins *pins; + + /* Sensors */ + const struct axp2xx_sensors *sensors; + int nsensors; /* Regulators */ - struct axp209_reg_sc **regs; + struct axp2xx_reg_sc **regs; int nregs; + struct axp2xx_regdef *regdefs; }; -/* GPIO3 is different, don't expose it for now */ -static const struct { - const char *name; - uint8_t ctrl_reg; -} axp209_pins[] = { - { "GPIO0", AXP209_GPIO0_CTRL }, - { "GPIO1", AXP209_GPIO1_CTRL }, - { "GPIO2", AXP209_GPIO2_CTRL }, +static struct ofw_compat_data compat_data[] = { + { "x-powers,axp209", AXP209 }, + { "x-powers,axp221", AXP221 }, + { NULL, 0 } }; static struct resource_spec axp_res_spec[] = { @@ -170,9 +639,9 @@ static struct resource_spec axp_res_spec #define AXP_UNLOCK(sc) mtx_unlock(&(sc)->mtx) static int -axp209_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) +axp2xx_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size) { - struct axp209_softc *sc = device_get_softc(dev); + struct axp2xx_softc *sc = device_get_softc(dev); struct iic_msg msg[2]; msg[0].slave = sc->addr; @@ -189,43 +658,62 @@ axp209_read(device_t dev, uint8_t reg, u } static int -axp209_write(device_t dev, uint8_t reg, uint8_t data) +axp2xx_write(device_t dev, uint8_t reg, uint8_t data) { uint8_t buffer[2]; - struct axp209_softc *sc = device_get_softc(dev); - struct iic_msg msg; + struct axp2xx_softc *sc = device_get_softc(dev); + struct iic_msg msg[2]; + int nmsgs = 0; - buffer[0] = reg; - buffer[1] = data; + if (sc->type == AXP209) { + buffer[0] = reg; + buffer[1] = data; + + msg[0].slave = sc->addr; + msg[0].flags = IIC_M_WR; + msg[0].len = 2; + msg[0].buf = buffer; - msg.slave = sc->addr; - msg.flags = IIC_M_WR; - msg.len = 2; - msg.buf = buffer; + nmsgs = 1; + } + else if (sc->type == AXP221) { + msg[0].slave = sc->addr; + msg[0].flags = IIC_M_WR; + msg[0].len = 1; + msg[0].buf = ® + + msg[1].slave = sc->addr; + msg[1].flags = IIC_M_WR; + msg[1].len = 1; + msg[1].buf = &data; + nmsgs = 2; + } + else + return (EINVAL); - return (iicbus_transfer(dev, &msg, 1)); + return (iicbus_transfer(dev, msg, nmsgs)); } static int -axp209_regnode_init(struct regnode *regnode) +axp2xx_regnode_init(struct regnode *regnode) { return (0); } static int -axp209_regnode_enable(struct regnode *regnode, bool enable, int *udelay) +axp2xx_regnode_enable(struct regnode *regnode, bool enable, int *udelay) { - struct axp209_reg_sc *sc; + struct axp2xx_reg_sc *sc; uint8_t val; sc = regnode_get_softc(regnode); - axp209_read(sc->base_dev, sc->def->enable_reg, &val, 1); + axp2xx_read(sc->base_dev, sc->def->enable_reg, &val, 1); if (enable) val |= sc->def->enable_mask; else val &= ~sc->def->enable_mask; - axp209_write(sc->base_dev, sc->def->enable_reg, val); + axp2xx_write(sc->base_dev, sc->def->enable_reg, val); *udelay = 0; @@ -233,7 +721,7 @@ axp209_regnode_enable(struct regnode *re } static void -axp209_regnode_reg_to_voltage(struct axp209_reg_sc *sc, uint8_t val, int *uv) +axp2xx_regnode_reg_to_voltage(struct axp2xx_reg_sc *sc, uint8_t val, int *uv) { if (val < sc->def->voltage_nstep) *uv = sc->def->voltage_min + val * sc->def->voltage_step; @@ -244,7 +732,7 @@ axp209_regnode_reg_to_voltage(struct axp } static int -axp209_regnode_voltage_to_reg(struct axp209_reg_sc *sc, int min_uvolt, +axp2xx_regnode_voltage_to_reg(struct axp2xx_reg_sc *sc, int min_uvolt, int max_uvolt, uint8_t *val) { uint8_t nval; @@ -266,10 +754,10 @@ axp209_regnode_voltage_to_reg(struct axp } static int -axp209_regnode_set_voltage(struct regnode *regnode, int min_uvolt, +axp2xx_regnode_set_voltage(struct regnode *regnode, int min_uvolt, int max_uvolt, int *udelay) { - struct axp209_reg_sc *sc; + struct axp2xx_reg_sc *sc; uint8_t val; sc = regnode_get_softc(regnode); @@ -277,10 +765,10 @@ axp209_regnode_set_voltage(struct regnod if (!sc->def->voltage_step) return (ENXIO); - if (axp209_regnode_voltage_to_reg(sc, min_uvolt, max_uvolt, &val) != 0) + if (axp2xx_regnode_voltage_to_reg(sc, min_uvolt, max_uvolt, &val) != 0) return (ERANGE); - axp209_write(sc->base_dev, sc->def->voltage_reg, val); + axp2xx_write(sc->base_dev, sc->def->voltage_reg, val); *udelay = 0; @@ -288,9 +776,9 @@ axp209_regnode_set_voltage(struct regnod } static int -axp209_regnode_get_voltage(struct regnode *regnode, int *uvolt) +axp2xx_regnode_get_voltage(struct regnode *regnode, int *uvolt) { - struct axp209_reg_sc *sc; + struct axp2xx_reg_sc *sc; uint8_t val; sc = regnode_get_softc(regnode); @@ -298,106 +786,60 @@ axp209_regnode_get_voltage(struct regnod if (!sc->def->voltage_step) return (ENXIO); - axp209_read(sc->base_dev, sc->def->voltage_reg, &val, 1); - axp209_regnode_reg_to_voltage(sc, val & sc->def->voltage_mask, uvolt); + axp2xx_read(sc->base_dev, sc->def->voltage_reg, &val, 1); + axp2xx_regnode_reg_to_voltage(sc, val & sc->def->voltage_mask, uvolt); return (0); } -static regnode_method_t axp209_regnode_methods[] = { +static regnode_method_t axp2xx_regnode_methods[] = { /* Regulator interface */ - REGNODEMETHOD(regnode_init, axp209_regnode_init), - REGNODEMETHOD(regnode_enable, axp209_regnode_enable), - REGNODEMETHOD(regnode_set_voltage, axp209_regnode_set_voltage), - REGNODEMETHOD(regnode_get_voltage, axp209_regnode_get_voltage), + REGNODEMETHOD(regnode_init, axp2xx_regnode_init), + REGNODEMETHOD(regnode_enable, axp2xx_regnode_enable), + REGNODEMETHOD(regnode_set_voltage, axp2xx_regnode_set_voltage), + REGNODEMETHOD(regnode_get_voltage, axp2xx_regnode_get_voltage), REGNODEMETHOD_END }; -DEFINE_CLASS_1(axp209_regnode, axp209_regnode_class, axp209_regnode_methods, - sizeof(struct axp209_reg_sc), regnode_class); +DEFINE_CLASS_1(axp2xx_regnode, axp2xx_regnode_class, axp2xx_regnode_methods, + sizeof(struct axp2xx_reg_sc), regnode_class); static int -axp209_sysctl(SYSCTL_HANDLER_ARGS) +axp2xx_sysctl(SYSCTL_HANDLER_ARGS) { + struct axp2xx_softc *sc; device_t dev = arg1; - enum axp209_sensor sensor = arg2; + enum axp2xx_sensor sensor = arg2; uint8_t data[2]; - int val, error; - - switch (sensor) { - case AXP209_TEMP: - error = axp209_read(dev, AXP209_TEMPMON, data, 2); - if (error != 0) - return (error); - - /* Temperature is between -144.7C and 264.8C, step +0.1C */ - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) - - AXP209_TEMPMON_MIN + AXP209_0C_TO_K; - break; - case AXP209_ACVOLT: - error = axp209_read(dev, AXP209_ACIN_VOLTAGE, data, 2); - if (error != 0) - return (error); + int val, error, i, found; - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_VOLT_STEP; - break; - case AXP209_ACCURRENT: - error = axp209_read(dev, AXP209_ACIN_CURRENT, data, 2); - if (error != 0) - return (error); - - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_ACCURRENT_STEP; - break; - case AXP209_VBUSVOLT: - error = axp209_read(dev, AXP209_VBUS_VOLTAGE, data, 2); - if (error != 0) - return (error); - - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_VOLT_STEP; - break; - case AXP209_VBUSCURRENT: - error = axp209_read(dev, AXP209_VBUS_CURRENT, data, 2); - if (error != 0) - return (error); - - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_VBUSCURRENT_STEP; - break; - case AXP209_BATVOLT: - error = axp209_read(dev, AXP209_BAT_VOLTAGE, data, 2); - if (error != 0) - return (error); - - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_BATVOLT_STEP; - break; - case AXP209_BATCHARGECURRENT: - error = axp209_read(dev, AXP209_BAT_CHARGE_CURRENT, data, 2); - if (error != 0) - return (error); + sc = device_get_softc(dev); - val = (AXP209_SENSOR_H(data[0]) | AXP209_SENSOR_L(data[1])) * - AXP209_BATCURRENT_STEP; - break; - case AXP209_BATDISCHARGECURRENT: - error = axp209_read(dev, AXP209_BAT_DISCHARGE_CURRENT, data, 2); - if (error != 0) - return (error); + for (found = 0, i = 0; i < sc->nsensors; i++) { + if (sc->sensors[i].id == sensor) { + found = 1; + break; + } + } - val = (AXP209_SENSOR_BAT_H(data[0]) | - AXP209_SENSOR_BAT_L(data[1])) * AXP209_BATCURRENT_STEP; - break; - default: + if (found == 0) return (ENOENT); - } + + error = axp2xx_read(dev, sc->sensors[i].value_reg, data, 2); + if (error != 0) + return (error); + + val = ((data[0] & sc->sensors[i].h_value_mask) << + sc->sensors[i].h_value_shift); + val |= ((data[1] & sc->sensors[i].l_value_mask) << + sc->sensors[i].l_value_shift); + val *= sc->sensors[i].value_step; + val += sc->sensors[i].value_convert; return sysctl_handle_opaque(oidp, &val, sizeof(val), req); } static void -axp209_shutdown(void *devp, int howto) +axp2xx_shutdown(void *devp, int howto) { device_t dev; @@ -406,77 +848,77 @@ axp209_shutdown(void *devp, int howto) dev = (device_t)devp; if (bootverbose) - device_printf(dev, "Shutdown AXP209\n"); + device_printf(dev, "Shutdown AXP2xx\n"); - axp209_write(dev, AXP209_SHUTBAT, AXP209_SHUTBAT_SHUTDOWN); + axp2xx_write(dev, AXP2XX_SHUTBAT, AXP2XX_SHUTBAT_SHUTDOWN); } static void -axp_intr(void *arg) +axp2xx_intr(void *arg) { - struct axp209_softc *sc; + struct axp2xx_softc *sc; uint8_t reg; sc = arg; - axp209_read(sc->dev, AXP209_IRQ1_STATUS, ®, 1); + axp2xx_read(sc->dev, AXP2XX_IRQ1_STATUS, ®, 1); if (reg) { - if (reg & AXP209_IRQ1_AC_OVERVOLT) + if (reg & AXP2XX_IRQ1_AC_OVERVOLT) devctl_notify("PMU", "AC", "overvoltage", NULL); - if (reg & AXP209_IRQ1_VBUS_OVERVOLT) + if (reg & AXP2XX_IRQ1_VBUS_OVERVOLT) devctl_notify("PMU", "USB", "overvoltage", NULL); - if (reg & AXP209_IRQ1_VBUS_LOW) + if (reg & AXP2XX_IRQ1_VBUS_LOW) devctl_notify("PMU", "USB", "undervoltage", NULL); - if (reg & AXP209_IRQ1_AC_CONN) + if (reg & AXP2XX_IRQ1_AC_CONN) devctl_notify("PMU", "AC", "plugged", NULL); - if (reg & AXP209_IRQ1_AC_DISCONN) + if (reg & AXP2XX_IRQ1_AC_DISCONN) devctl_notify("PMU", "AC", "unplugged", NULL); - if (reg & AXP209_IRQ1_VBUS_CONN) + if (reg & AXP2XX_IRQ1_VBUS_CONN) devctl_notify("PMU", "USB", "plugged", NULL); - if (reg & AXP209_IRQ1_VBUS_DISCONN) + if (reg & AXP2XX_IRQ1_VBUS_DISCONN) devctl_notify("PMU", "USB", "unplugged", NULL); - axp209_write(sc->dev, AXP209_IRQ1_STATUS, AXP209_IRQ_ACK); + axp2xx_write(sc->dev, AXP2XX_IRQ1_STATUS, AXP2XX_IRQ_ACK); } - axp209_read(sc->dev, AXP209_IRQ2_STATUS, ®, 1); + axp2xx_read(sc->dev, AXP2XX_IRQ2_STATUS, ®, 1); if (reg) { - if (reg & AXP209_IRQ2_BATT_CHARGED) + if (reg & AXP2XX_IRQ2_BATT_CHARGED) devctl_notify("PMU", "Battery", "charged", NULL); - if (reg & AXP209_IRQ2_BATT_CHARGING) + if (reg & AXP2XX_IRQ2_BATT_CHARGING) devctl_notify("PMU", "Battery", "charging", NULL); - if (reg & AXP209_IRQ2_BATT_CONN) + if (reg & AXP2XX_IRQ2_BATT_CONN) devctl_notify("PMU", "Battery", "connected", NULL); - if (reg & AXP209_IRQ2_BATT_DISCONN) + if (reg & AXP2XX_IRQ2_BATT_DISCONN) devctl_notify("PMU", "Battery", "disconnected", NULL); - if (reg & AXP209_IRQ2_BATT_TEMP_LOW) + if (reg & AXP2XX_IRQ2_BATT_TEMP_LOW) devctl_notify("PMU", "Battery", "low temp", NULL); - if (reg & AXP209_IRQ2_BATT_TEMP_OVER) + if (reg & AXP2XX_IRQ2_BATT_TEMP_OVER) devctl_notify("PMU", "Battery", "high temp", NULL); - axp209_write(sc->dev, AXP209_IRQ2_STATUS, AXP209_IRQ_ACK); + axp2xx_write(sc->dev, AXP2XX_IRQ2_STATUS, AXP2XX_IRQ_ACK); } - axp209_read(sc->dev, AXP209_IRQ3_STATUS, ®, 1); + axp2xx_read(sc->dev, AXP2XX_IRQ3_STATUS, ®, 1); if (reg) { - if (reg & AXP209_IRQ3_PEK_SHORT) + if (reg & AXP2XX_IRQ3_PEK_SHORT) shutdown_nice(RB_POWEROFF); - axp209_write(sc->dev, AXP209_IRQ3_STATUS, AXP209_IRQ_ACK); + axp2xx_write(sc->dev, AXP2XX_IRQ3_STATUS, AXP2XX_IRQ_ACK); } - axp209_read(sc->dev, AXP209_IRQ4_STATUS, ®, 1); + axp2xx_read(sc->dev, AXP2XX_IRQ4_STATUS, ®, 1); if (reg) { - axp209_write(sc->dev, AXP209_IRQ4_STATUS, AXP209_IRQ_ACK); + axp2xx_write(sc->dev, AXP2XX_IRQ4_STATUS, AXP2XX_IRQ_ACK); } - axp209_read(sc->dev, AXP209_IRQ5_STATUS, ®, 1); + axp2xx_read(sc->dev, AXP2XX_IRQ5_STATUS, ®, 1); if (reg) { - axp209_write(sc->dev, AXP209_IRQ5_STATUS, AXP209_IRQ_ACK); + axp2xx_write(sc->dev, AXP2XX_IRQ5_STATUS, AXP2XX_IRQ_ACK); } } static device_t -axp209_gpio_get_bus(device_t dev) +axp2xx_gpio_get_bus(device_t dev) { - struct axp209_softc *sc; + struct axp2xx_softc *sc; sc = device_get_softc(dev); @@ -484,17 +926,25 @@ axp209_gpio_get_bus(device_t dev) } static int -axp209_gpio_pin_max(device_t dev, int *maxpin) +axp2xx_gpio_pin_max(device_t dev, int *maxpin) { - *maxpin = nitems(axp209_pins) - 1; + struct axp2xx_softc *sc; + + sc = device_get_softc(dev); + + *maxpin = sc->npins - 1; return (0); } static int -axp209_gpio_pin_getname(device_t dev, uint32_t pin, char *name) +axp2xx_gpio_pin_getname(device_t dev, uint32_t pin, char *name) { - if (pin >= nitems(axp209_pins)) + struct axp2xx_softc *sc; + + sc = device_get_softc(dev); + + if (pin >= sc->npins) return (EINVAL); snprintf(name, GPIOMAXNAME, "%s", axp209_pins[pin].name); @@ -503,9 +953,13 @@ axp209_gpio_pin_getname(device_t dev, ui } static int -axp209_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +axp2xx_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) { - if (pin >= nitems(axp209_pins)) + struct axp2xx_softc *sc; + + sc = device_get_softc(dev); + + if (pin >= sc->npins) return (EINVAL); *caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; @@ -514,25 +968,25 @@ axp209_gpio_pin_getcaps(device_t dev, ui } static int -axp209_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +axp2xx_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Fri Nov 4 20:06:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0862C30DA6; Fri, 4 Nov 2016 20:06:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C27E5192; Fri, 4 Nov 2016 20:06:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4K6XPM003666; Fri, 4 Nov 2016 20:06:33 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4K6XAe003665; Fri, 4 Nov 2016 20:06:33 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201611042006.uA4K6XAe003665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 4 Nov 2016 20:06:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308310 - head/sys/boot/fdt/dts/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 20:06:34 -0000 Author: manu Date: Fri Nov 4 20:06:32 2016 New Revision: 308310 URL: https://svnweb.freebsd.org/changeset/base/308310 Log: Add AXP221 node in our BananaPi M2 dts. Modified: head/sys/boot/fdt/dts/arm/bananapim2.dts Modified: head/sys/boot/fdt/dts/arm/bananapim2.dts ============================================================================== --- head/sys/boot/fdt/dts/arm/bananapim2.dts Fri Nov 4 20:02:52 2016 (r308309) +++ head/sys/boot/fdt/dts/arm/bananapim2.dts Fri Nov 4 20:06:32 2016 (r308310) @@ -31,3 +31,15 @@ &mmc2 { status = "disabled"; }; + +&p2wi { + status = "okay"; + axp22x: pmic@68 { + compatible = "x-powers,axp221"; + reg = <0x68>; + interrupt-parent = <&nmi_intc>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + }; +}; + +#include "axp22x.dtsi" From owner-svn-src-head@freebsd.org Fri Nov 4 20:32:51 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40C70C308EC; Fri, 4 Nov 2016 20:32:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E78F26C8; Fri, 4 Nov 2016 20:32:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4KWoIi015249; Fri, 4 Nov 2016 20:32:50 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4KWoXi015248; Fri, 4 Nov 2016 20:32:50 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611042032.uA4KWoXi015248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 4 Nov 2016 20:32:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308312 - head/usr.sbin/vidcontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 20:32:51 -0000 Author: emaste Date: Fri Nov 4 20:32:49 2016 New Revision: 308312 URL: https://svnweb.freebsd.org/changeset/base/308312 Log: vidcontrol: improve error handling in vt(4) font loading PR: 209078 Reported by: ecturt@gmail.com Reviewed by: Oliver Pinter Differential Revision: https://reviews.freebsd.org/D8176 Modified: head/usr.sbin/vidcontrol/vidcontrol.c Modified: head/usr.sbin/vidcontrol/vidcontrol.c ============================================================================== --- head/usr.sbin/vidcontrol/vidcontrol.c Fri Nov 4 20:30:15 2016 (r308311) +++ head/usr.sbin/vidcontrol/vidcontrol.c Fri Nov 4 20:32:49 2016 (r308312) @@ -393,11 +393,15 @@ load_vt4mappingtable(unsigned int nmappi if (nmappings == 0) return (NULL); - t = malloc(sizeof *t * nmappings); + if ((t = malloc(sizeof *t * nmappings)) == NULL) { + warn("malloc"); + return (NULL); + } if (fread(t, sizeof *t * nmappings, 1, f) != 1) { - perror("mappings"); - exit(1); + warn("read mappings"); + free(t); + return (NULL); } for (i = 0; i < nmappings; i++) { @@ -422,7 +426,7 @@ load_default_vt4font(void) } } -static int +static void load_vt4font(FILE *f) { struct vt4font_header fh; @@ -431,13 +435,13 @@ load_vt4font(FILE *f) unsigned int i; if (fread(&fh, sizeof fh, 1, f) != 1) { - perror("file_header"); - return (1); + warn("read file_header"); + return; } if (memcmp(fh.magic, "VFNT0002", 8) != 0) { - fprintf(stderr, "Bad magic\n"); - return (1); + warnx("bad magic in font file\n"); + return; } for (i = 0; i < VFNT_MAPS; i++) @@ -447,21 +451,26 @@ load_vt4font(FILE *f) vfnt.height = fh.height; glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count; - vfnt.glyphs = malloc(glyphsize); + if ((vfnt.glyphs = malloc(glyphsize)) == NULL) { + warn("malloc"); + return; + } if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) { - perror("glyphs"); - return (1); + warn("read glyphs"); + free(vfnt.glyphs); + return; } for (i = 0; i < VFNT_MAPS; i++) vfnt.map[i] = load_vt4mappingtable(vfnt.map_count[i], f); - if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) { - perror("PIO_VFONT"); - return (1); - } - return (0); + if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) + warn("PIO_VFONT"); + + for (i = 0; i < VFNT_MAPS; i++) + free(vfnt.map[i]); + free(vfnt.glyphs); } /* @@ -511,8 +520,7 @@ load_font(const char *type, const char * } if (vt4_mode) { - if(load_vt4font(fd)) - warn("failed to load font \"%s\"", filename); + load_vt4font(fd); fclose(fd); return; } From owner-svn-src-head@freebsd.org Fri Nov 4 20:50:00 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 549B2C30D70; Fri, 4 Nov 2016 20:50:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 26C04F6E; Fri, 4 Nov 2016 20:50:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4Knx0x019491; Fri, 4 Nov 2016 20:49:59 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4Knxcx019490; Fri, 4 Nov 2016 20:49:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201611042049.uA4Knxcx019490@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 4 Nov 2016 20:49:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308314 - head/usr.bin/sed X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 20:50:00 -0000 Author: pfg Date: Fri Nov 4 20:49:59 2016 New Revision: 308314 URL: https://svnweb.freebsd.org/changeset/base/308314 Log: sed(1): add LEGACY_BSDSED_COMPAT compile-time flag. In r297602, which included a __FreeBSD_version bump to 1100105, we changed sed 'i' and 'a' from discarding whitespaces to conform with what GNU and sysvish sed do. There are arguments in favor of keeping the old behavior but the new behavior is also useful for migration purposes. It seems important to at least consider the case of developers depending on the previous behavior, so add a CFLAG to enable the old behaviour. PR: 213474 MFC after: 5 days Modified: head/usr.bin/sed/compile.c Modified: head/usr.bin/sed/compile.c ============================================================================== --- head/usr.bin/sed/compile.c Fri Nov 4 20:38:26 2016 (r308313) +++ head/usr.bin/sed/compile.c Fri Nov 4 20:49:59 2016 (r308314) @@ -746,6 +746,9 @@ compile_text(void) while (cu_fgets(lbuf, sizeof(lbuf), NULL) != NULL) { op = s = text + size; p = lbuf; +#ifdef LEGACY_BSDSED_COMPAT + EATSPACE(); +#endif for (esc_nl = 0; *p != '\0'; p++) { if (*p == '\\' && p[1] != '\0' && *++p == '\n') esc_nl = 1; From owner-svn-src-head@freebsd.org Sat Nov 5 06:33:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7EF7C319CD; Sat, 5 Nov 2016 06:33:40 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FAEFE88; Sat, 5 Nov 2016 06:33:40 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA56XdYd046844; Sat, 5 Nov 2016 06:33:39 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA56XdQ1046843; Sat, 5 Nov 2016 06:33:39 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201611050633.uA56XdQ1046843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Sat, 5 Nov 2016 06:33:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308329 - head/usr.bin/ministat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 06:33:40 -0000 Author: cperciva Date: Sat Nov 5 06:33:39 2016 New Revision: 308329 URL: https://svnweb.freebsd.org/changeset/base/308329 Log: Reduce the bogosity of ministat's % difference calculations. The previous calculation used an approximation which was only valid in cases where the means being compared were similar; this resulted in very odd claims being made, e.g. that 0 +/- 0 is a difference of -100% +/- 1% from 100 +/- 1. The new calculation scales sample standard deviations by the means, and yields approximately correct percentage difference bounds providing that the reference population is bounded away from zero. (In the case where the values being compared are not sufficiently bounded away from zero, the distribution of ratios becomes much harder to calculate, and is not likely to be useful anyway.) Note that when ministat is used for its intended purpose of determining whether two samples are statistically different, this change is unlikely to have any noticeable effect; in such cases the means will be similar enough that the correction applied here will be minimal. Modified: head/usr.bin/ministat/ministat.c Modified: head/usr.bin/ministat/ministat.c ============================================================================== --- head/usr.bin/ministat/ministat.c Sat Nov 5 04:40:58 2016 (r308328) +++ head/usr.bin/ministat/ministat.c Sat Nov 5 06:33:39 2016 (r308329) @@ -232,6 +232,7 @@ static void Relative(struct dataset *ds, struct dataset *rs, int confidx) { double spool, s, d, e, t; + double re; int i; i = ds->n + rs->n - 2; @@ -246,11 +247,16 @@ Relative(struct dataset *ds, struct data d = Avg(ds) - Avg(rs); e = t * s; + re = (ds->n - 1) * Var(ds) + (rs->n - 1) * Var(rs) * + (Avg(ds) * Avg(ds)) / (Avg(rs) * Avg(rs)); + re *= (ds->n + rs->n) / (ds->n * rs->n * (ds->n + rs->n - 2.0)); + re = t * sqrt(re); + if (fabs(d) > e) { printf("Difference at %.1f%% confidence\n", studentpct[confidx]); printf(" %g +/- %g\n", d, e); - printf(" %g%% +/- %g%%\n", d * 100 / Avg(rs), e * 100 / Avg(rs)); + printf(" %g%% +/- %g%%\n", d * 100 / Avg(rs), re * 100 / Avg(rs)); printf(" (Student's t, pooled s = %g)\n", spool); } else { printf("No difference proven at %.1f%% confidence\n", From owner-svn-src-head@freebsd.org Sat Nov 5 09:07:39 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB293C2D3FC; Sat, 5 Nov 2016 09:07:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2555083; Sat, 5 Nov 2016 09:07:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id uA597Xl8034258 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 5 Nov 2016 11:07:34 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua uA597Xl8034258 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id uA597XJd034257; Sat, 5 Nov 2016 11:07:33 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 Nov 2016 11:07:33 +0200 From: Konstantin Belousov To: "Pedro F. Giffuni" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308314 - head/usr.bin/sed Message-ID: <20161105090733.GT54029@kib.kiev.ua> References: <201611042049.uA4Knxcx019490@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201611042049.uA4Knxcx019490@repo.freebsd.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 09:07:39 -0000 On Fri, Nov 04, 2016 at 08:49:59PM +0000, Pedro F. Giffuni wrote: > Author: pfg > Date: Fri Nov 4 20:49:59 2016 > New Revision: 308314 > URL: https://svnweb.freebsd.org/changeset/base/308314 > > Log: > sed(1): add LEGACY_BSDSED_COMPAT compile-time flag. > > In r297602, which included a __FreeBSD_version bump to 1100105, we changed > sed 'i' and 'a' from discarding whitespaces to conform with what GNU and > sysvish sed do. > > There are arguments in favor of keeping the old behavior but the new > behavior is also useful for migration purposes. It seems important to at > least consider the case of developers depending on the previous behavior, > so add a CFLAG to enable the old behaviour. If such legacy behavior appears to be useful or even important for real-world scenarios, I think that an environment variable controlling it is more practical and traditional than the recompilation. From owner-svn-src-head@freebsd.org Sat Nov 5 11:19:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34EDCC2E688; Sat, 5 Nov 2016 11:19:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2CCFBE; Sat, 5 Nov 2016 11:19:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5BJubm053781; Sat, 5 Nov 2016 11:19:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5BJuo8053780; Sat, 5 Nov 2016 11:19:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201611051119.uA5BJuo8053780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 5 Nov 2016 11:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308338 - head/usr.sbin/vidcontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 11:19:57 -0000 Author: emaste Date: Sat Nov 5 11:19:55 2016 New Revision: 308338 URL: https://svnweb.freebsd.org/changeset/base/308338 Log: vidcontrol: use calloc where appropriate Reported by: kib Modified: head/usr.sbin/vidcontrol/vidcontrol.c Modified: head/usr.sbin/vidcontrol/vidcontrol.c ============================================================================== --- head/usr.sbin/vidcontrol/vidcontrol.c Sat Nov 5 11:01:56 2016 (r308337) +++ head/usr.sbin/vidcontrol/vidcontrol.c Sat Nov 5 11:19:55 2016 (r308338) @@ -393,8 +393,8 @@ load_vt4mappingtable(unsigned int nmappi if (nmappings == 0) return (NULL); - if ((t = malloc(sizeof *t * nmappings)) == NULL) { - warn("malloc"); + if ((t = calloc(nmappings, sizeof(*t))) == NULL) { + warn("calloc"); return (NULL); } From owner-svn-src-head@freebsd.org Sat Nov 5 12:30:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8091BC30E2E; Sat, 5 Nov 2016 12:30:11 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D4FBA1F; Sat, 5 Nov 2016 12:30:11 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5CUANm080099; Sat, 5 Nov 2016 12:30:10 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5CUAfW080098; Sat, 5 Nov 2016 12:30:10 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201611051230.uA5CUAfW080098@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 5 Nov 2016 12:30:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308339 - head/sys/fs/autofs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 12:30:11 -0000 Author: trasz Date: Sat Nov 5 12:30:10 2016 New Revision: 308339 URL: https://svnweb.freebsd.org/changeset/base/308339 Log: Value returned by taskqueue_enqueue_timeout(9) is not an error; don't treat it as such. MFC after: 1 month Modified: head/sys/fs/autofs/autofs.c Modified: head/sys/fs/autofs/autofs.c ============================================================================== --- head/sys/fs/autofs/autofs.c Sat Nov 5 11:19:55 2016 (r308338) +++ head/sys/fs/autofs/autofs.c Sat Nov 5 12:30:10 2016 (r308339) @@ -442,12 +442,8 @@ autofs_trigger_one(struct autofs_node *a TIMEOUT_TASK_INIT(taskqueue_thread, &ar->ar_task, 0, autofs_task, ar); - error = taskqueue_enqueue_timeout(taskqueue_thread, - &ar->ar_task, autofs_timeout * hz); - if (error != 0) { - AUTOFS_WARN("taskqueue_enqueue_timeout() failed " - "with error %d", error); - } + taskqueue_enqueue_timeout(taskqueue_thread, &ar->ar_task, + autofs_timeout * hz); refcount_init(&ar->ar_refcount, 1); TAILQ_INSERT_TAIL(&autofs_softc->sc_requests, ar, ar_next); } From owner-svn-src-head@freebsd.org Sat Nov 5 14:08:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23520C305CA; Sat, 5 Nov 2016 14:08:16 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7A30FBB; Sat, 5 Nov 2016 14:08:15 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5E8FGJ018996; Sat, 5 Nov 2016 14:08:15 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5E8FAZ018995; Sat, 5 Nov 2016 14:08:15 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201611051408.uA5E8FAZ018995@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Sat, 5 Nov 2016 14:08:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308340 - head/usr.bin/ncal X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 14:08:16 -0000 Author: vangyzen Date: Sat Nov 5 14:08:14 2016 New Revision: 308340 URL: https://svnweb.freebsd.org/changeset/base/308340 Log: ncal: fix a reference to an out-of-scope stack buffer PR: 214237 Submitted by: Jonathan de Boyne Pollard MFC after: 3 days Sponsored by: Dell EMC Modified: head/usr.bin/ncal/ncal.c Modified: head/usr.bin/ncal/ncal.c ============================================================================== --- head/usr.bin/ncal/ncal.c Sat Nov 5 12:30:10 2016 (r308339) +++ head/usr.bin/ncal/ncal.c Sat Nov 5 14:08:14 2016 (r308340) @@ -1110,7 +1110,8 @@ highlight(char *dst, char *src, int len, static const char *term_so, *term_se; if (first) { - char tbuf[1024], cbuf[512], *b; + static char cbuf[512]; + char tbuf[1024], *b; term_se = term_so = NULL; From owner-svn-src-head@freebsd.org Sat Nov 5 14:30:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00BD5C3190A; Sat, 5 Nov 2016 14:30:12 +0000 (UTC) (envelope-from alfred@freebsd.org) Received: from elvis.mu.org (elvis.mu.org [IPv6:2001:470:1f05:b76::196]) by mx1.freebsd.org (Postfix) with ESMTP id E6B317F7; Sat, 5 Nov 2016 14:30:11 +0000 (UTC) (envelope-from alfred@freebsd.org) Received: from Alfreds-MacBook-Pro-2.local (unknown [IPv6:2601:645:8003:a4d6:8de:34f5:a947:3165]) by elvis.mu.org (Postfix) with ESMTPSA id 9564A346DE6A; Sat, 5 Nov 2016 07:30:11 -0700 (PDT) Subject: Re: svn commit: r308314 - head/usr.bin/sed To: Konstantin Belousov , "Pedro F. Giffuni" References: <201611042049.uA4Knxcx019490@repo.freebsd.org> <20161105090733.GT54029@kib.kiev.ua> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Alfred Perlstein Organization: FreeBSD Message-ID: <6d9123fb-2b0a-c4a4-c584-d71874074d47@freebsd.org> Date: Sat, 5 Nov 2016 07:30:10 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161105090733.GT54029@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 14:30:12 -0000 On 11/5/16 2:07 AM, Konstantin Belousov wrote: > On Fri, Nov 04, 2016 at 08:49:59PM +0000, Pedro F. Giffuni wrote: >> Author: pfg >> Date: Fri Nov 4 20:49:59 2016 >> New Revision: 308314 >> URL: https://svnweb.freebsd.org/changeset/base/308314 >> >> Log: >> sed(1): add LEGACY_BSDSED_COMPAT compile-time flag. >> >> In r297602, which included a __FreeBSD_version bump to 1100105, we changed >> sed 'i' and 'a' from discarding whitespaces to conform with what GNU and >> sysvish sed do. >> >> There are arguments in favor of keeping the old behavior but the new >> behavior is also useful for migration purposes. It seems important to at >> least consider the case of developers depending on the previous behavior, >> so add a CFLAG to enable the old behaviour. > If such legacy behavior appears to be useful or even important for > real-world scenarios, I think that an environment variable controlling > it is more practical and traditional than the recompilation. > +1 From owner-svn-src-head@freebsd.org Sat Nov 5 15:01:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 719F4C31195; Sat, 5 Nov 2016 15:01:42 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43423E69; Sat, 5 Nov 2016 15:01:42 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5F1fD4039278; Sat, 5 Nov 2016 15:01:41 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5F1f28039277; Sat, 5 Nov 2016 15:01:41 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201611051501.uA5F1f28039277@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Sat, 5 Nov 2016 15:01:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308342 - head/usr.bin/fortune/datfiles X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 15:01:42 -0000 Author: vangyzen Date: Sat Nov 5 15:01:41 2016 New Revision: 308342 URL: https://svnweb.freebsd.org/changeset/base/308342 Log: Fix sorting after r308293, using the ../tools/do_sort script. Is this a pointy-hat offense? Reported by: jhb Modified: head/usr.bin/fortune/datfiles/fortunes Modified: head/usr.bin/fortune/datfiles/fortunes ============================================================================== --- head/usr.bin/fortune/datfiles/fortunes Sat Nov 5 14:16:32 2016 (r308341) +++ head/usr.bin/fortune/datfiles/fortunes Sat Nov 5 15:01:41 2016 (r308342) @@ -58856,6 +58856,9 @@ Your present plans will be successful. % Your program is sick! Shoot it and put it out of its memory. % +Your reasoning is excellent -- it's +only your basic assumptions that are wrong. +% Your reasoning powers are good, and you are a fairly good planner. % Your responsibility as a parent is not as great as you might imagine. You @@ -58947,9 +58950,6 @@ You're not drunk if you can lie on the f % You're not my type. For that matter, you're not even my species!!! % -Your reasoning is excellent -- it's -only your basic assumptions that are wrong. -% You're ugly and your mother dresses you funny. % You're using a keyboard! How quaint! From owner-svn-src-head@freebsd.org Sat Nov 5 16:17:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC534AF74B9; Sat, 5 Nov 2016 16:17:08 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8681616; Sat, 5 Nov 2016 16:17:08 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5GH7Ix069352; Sat, 5 Nov 2016 16:17:07 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5GH7gr069351; Sat, 5 Nov 2016 16:17:07 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201611051617.uA5GH7gr069351@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sat, 5 Nov 2016 16:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308343 - head/sys/dev/bxe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 16:17:09 -0000 Author: sbruno Date: Sat Nov 5 16:17:07 2016 New Revision: 308343 URL: https://svnweb.freebsd.org/changeset/base/308343 Log: r266979 missed a call to enable capabilities of the hw leading to an inability to enable features of the device. PR: 213845 Submitted by: pherman@frenchfries.net MFC after: 1 week Modified: head/sys/dev/bxe/bxe.c Modified: head/sys/dev/bxe/bxe.c ============================================================================== --- head/sys/dev/bxe/bxe.c Sat Nov 5 15:01:41 2016 (r308342) +++ head/sys/dev/bxe/bxe.c Sat Nov 5 16:17:07 2016 (r308343) @@ -12691,6 +12691,7 @@ bxe_init_ifnet(struct bxe_softc *sc) IFCAP_WOL_MAGIC); #endif if_setcapabilitiesbit(ifp, capabilities, 0); /* XXX */ + if_setcapenable(ifp, if_getcapabilities(ifp)); if_setbaudrate(ifp, IF_Gbps(10)); /* XXX */ if_setsendqlen(ifp, sc->tx_ring_size); From owner-svn-src-head@freebsd.org Sat Nov 5 16:23:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB9A5AF7A7D; Sat, 5 Nov 2016 16:23:34 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9112DCE0; Sat, 5 Nov 2016 16:23:34 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5GNXAW073122; Sat, 5 Nov 2016 16:23:33 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5GNXnT073120; Sat, 5 Nov 2016 16:23:33 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201611051623.uA5GNXnT073120@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Sat, 5 Nov 2016 16:23:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308344 - head/usr.sbin/makefs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 16:23:35 -0000 Author: marcel Date: Sat Nov 5 16:23:33 2016 New Revision: 308344 URL: https://svnweb.freebsd.org/changeset/base/308344 Log: Assign a random number to di_gen (for FFS), instead of extracting it from struct stat. We don't necessarily have permissions to see the generation number and the host OS may not have st_gen in struct stat anyway. Since the kernel assigns random numbers, there's nothing meaningful about the generation that requires us to preserve it when the file system image is created. With this change, all generation numbers come from random() and that makes it easier to add support for reproducible builds at some time in the future (i.e. by adding an argument to makefs that changes the behaviour of random() so that it always returns 0 or some predictable sequence). Differential Revision: https://reviews.freebsd.org/D8418 Modified: head/usr.sbin/makefs/Makefile head/usr.sbin/makefs/ffs.c Modified: head/usr.sbin/makefs/Makefile ============================================================================== --- head/usr.sbin/makefs/Makefile Sat Nov 5 16:17:07 2016 (r308343) +++ head/usr.sbin/makefs/Makefile Sat Nov 5 16:23:33 2016 (r308344) @@ -20,7 +20,6 @@ WARNS?= 2 .include "${SRCDIR}/ffs/Makefile.inc" CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1 -CFLAGS+=-DHAVE_STRUCT_STAT_ST_GEN=1 .PATH: ${SRCTOP}/contrib/mtree CFLAGS+=-I${SRCTOP}/contrib/mtree Modified: head/usr.sbin/makefs/ffs.c ============================================================================== --- head/usr.sbin/makefs/ffs.c Sat Nov 5 16:17:07 2016 (r308343) +++ head/usr.sbin/makefs/ffs.c Sat Nov 5 16:23:33 2016 (r308344) @@ -666,9 +666,7 @@ ffs_build_dinode1(struct ufs1_dinode *di #if HAVE_STRUCT_STAT_ST_FLAGS dinp->di_flags = cur->inode->st.st_flags; #endif -#if HAVE_STRUCT_STAT_ST_GEN - dinp->di_gen = cur->inode->st.st_gen; -#endif + dinp->di_gen = random(); dinp->di_uid = cur->inode->st.st_uid; dinp->di_gid = cur->inode->st.st_gid; @@ -716,9 +714,7 @@ ffs_build_dinode2(struct ufs2_dinode *di #if HAVE_STRUCT_STAT_ST_FLAGS dinp->di_flags = cur->inode->st.st_flags; #endif -#if HAVE_STRUCT_STAT_ST_GEN - dinp->di_gen = cur->inode->st.st_gen; -#endif + dinp->di_gen = random(); dinp->di_uid = cur->inode->st.st_uid; dinp->di_gid = cur->inode->st.st_gid; From owner-svn-src-head@freebsd.org Sat Nov 5 16:30:44 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39E61AF7E05; Sat, 5 Nov 2016 16:30:44 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E725BF6E; Sat, 5 Nov 2016 16:30:43 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5GUh7T073582; Sat, 5 Nov 2016 16:30:43 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5GUhtk073581; Sat, 5 Nov 2016 16:30:43 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201611051630.uA5GUhtk073581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sat, 5 Nov 2016 16:30:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308345 - head/sys/dev/e1000 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 16:30:44 -0000 Author: sbruno Date: Sat Nov 5 16:30:42 2016 New Revision: 308345 URL: https://svnweb.freebsd.org/changeset/base/308345 Log: r295133 attempted to deactivate TSO in the 100Mbit link case with this adapter to work around bugs in TSO handling at this speed. em_init_locked is called during first boot of the adapter and will see that link_speed is unitialized, effectively turning off tso for all cards at all speeds, which I believe was *not* the intent. Move the handling of TSO deactivation to the link handler where we can more effectively make the decision about what to do. In addition, completely purge the TSO capabilities instead of disabling just CSUM_TSO. Thanks to jhb for explanation of the hw capabilites api. Thanks to royger and cognet for testing the 100Mbit failure case to ensure that their adapters do indeed still work. MFC after: 1 week Sponsored by: Limelight Networks Modified: head/sys/dev/e1000/if_em.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Sat Nov 5 16:23:33 2016 (r308344) +++ head/sys/dev/e1000/if_em.c Sat Nov 5 16:30:42 2016 (r308345) @@ -369,11 +369,6 @@ MODULE_DEPEND(em, netmap, 1, 1, 1); #define MAX_INTS_PER_SEC 8000 #define DEFAULT_ITR (1000000000/(MAX_INTS_PER_SEC * 256)) -/* Allow common code without TSO */ -#ifndef CSUM_TSO -#define CSUM_TSO 0 -#endif - #define TSO_WORKAROUND 4 static SYSCTL_NODE(_hw, OID_AUTO, em, CTLFLAG_RD, 0, "EM driver parameters"); @@ -1396,15 +1391,9 @@ em_init_locked(struct adapter *adapter) if_clearhwassist(ifp); if (if_getcapenable(ifp) & IFCAP_TXCSUM) if_sethwassistbits(ifp, CSUM_TCP | CSUM_UDP, 0); - /* - ** There have proven to be problems with TSO when not - ** at full gigabit speed, so disable the assist automatically - ** when at lower speeds. -jfv - */ - if (if_getcapenable(ifp) & IFCAP_TSO4) { - if (adapter->link_speed == SPEED_1000) - if_sethwassistbits(ifp, CSUM_TSO, 0); - } + + if (if_getcapenable(ifp) & IFCAP_TSO4) + if_sethwassistbits(ifp, CSUM_TSO, 0); /* Configure for OS presence */ em_init_manageability(adapter); @@ -2412,6 +2401,18 @@ em_update_link_status(struct adapter *ad if (link_check && (adapter->link_active == 0)) { e1000_get_speed_and_duplex(hw, &adapter->link_speed, &adapter->link_duplex); + /* + ** There have proven to be problems with TSO when not + ** at full gigabit speed, so disable the assist automatically + ** when at lower speeds. -jfv + */ + if (adapter->link_speed != SPEED_1000) { + if_sethwassistbits(ifp, 0, CSUM_TSO); + if_setcapenablebit(ifp, 0, IFCAP_TSO4); + if_setcapabilitiesbit(ifp, 0, IFCAP_TSO4); + + } + /* Check if we must disable SPEED_MODE bit on PCI-E */ if ((adapter->link_speed != SPEED_1000) && ((hw->mac.type == e1000_82571) || From owner-svn-src-head@freebsd.org Sat Nov 5 18:00:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 942D4AF7CF9; Sat, 5 Nov 2016 18:00:37 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DB2B616; Sat, 5 Nov 2016 18:00:37 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5I0aTL010963; Sat, 5 Nov 2016 18:00:36 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5I0akj010962; Sat, 5 Nov 2016 18:00:36 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201611051800.uA5I0akj010962@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sat, 5 Nov 2016 18:00:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308347 - head/usr.sbin/traceroute6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 18:00:37 -0000 Author: hrs Date: Sat Nov 5 18:00:36 2016 New Revision: 308347 URL: https://svnweb.freebsd.org/changeset/base/308347 Log: Fix an infinite loop at an non-responding hop when other echo replies are kept arriving in the waittime time window. Submitted by: Denny Page PR: 210286 MFC after: 3 days Modified: head/usr.sbin/traceroute6/traceroute6.c Modified: head/usr.sbin/traceroute6/traceroute6.c ============================================================================== --- head/usr.sbin/traceroute6/traceroute6.c Sat Nov 5 17:02:38 2016 (r308346) +++ head/usr.sbin/traceroute6/traceroute6.c Sat Nov 5 18:00:36 2016 (r308347) @@ -955,6 +955,9 @@ main(argc, argv) break; } break; + } else if (deltaT(&t1, &t2) > waittime * 1000) { + cc = 0; + break; } } if (cc == 0) From owner-svn-src-head@freebsd.org Sat Nov 5 19:51:15 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1537BBEDA37; Sat, 5 Nov 2016 19:51:15 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB6D32C5; Sat, 5 Nov 2016 19:51:14 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5JpEug059003; Sat, 5 Nov 2016 19:51:14 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5JpEh8059002; Sat, 5 Nov 2016 19:51:14 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201611051951.uA5JpEh8059002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sat, 5 Nov 2016 19:51:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308348 - head/usr.sbin/rtadvd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 19:51:15 -0000 Author: hrs Date: Sat Nov 5 19:51:13 2016 New Revision: 308348 URL: https://svnweb.freebsd.org/changeset/base/308348 Log: Add link-layer address option in RA even for IFT_L2VLAN and IFT_BRIDGE. Reported by: philip MFC after: 3 days Modified: head/usr.sbin/rtadvd/if.c Modified: head/usr.sbin/rtadvd/if.c ============================================================================== --- head/usr.sbin/rtadvd/if.c Sat Nov 5 18:00:36 2016 (r308347) +++ head/usr.sbin/rtadvd/if.c Sat Nov 5 19:51:13 2016 (r308348) @@ -114,6 +114,8 @@ lladdropt_length(struct sockaddr_dl *sdl { switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: + case IFT_BRIDGE: return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: return (0); @@ -129,6 +131,8 @@ lladdropt_fill(struct sockaddr_dl *sdl, switch (sdl->sdl_type) { case IFT_ETHER: + case IFT_L2VLAN: + case IFT_BRIDGE: ndopt->nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) >> 3; addr = (char *)(ndopt + 1); memcpy(addr, LLADDR(sdl), ETHER_ADDR_LEN); From owner-svn-src-head@freebsd.org Sat Nov 5 20:03:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59ADDAF71D3; Sat, 5 Nov 2016 20:03:34 +0000 (UTC) (envelope-from philip@rincewind.trouble.is) Received: from rincewind.trouble.is (rincewind.trouble.is [IPv6:2a01:4f8:a0:10e6::1:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2197AC74; Sat, 5 Nov 2016 20:03:33 +0000 (UTC) (envelope-from philip@rincewind.trouble.is) Received: by rincewind.trouble.is (Postfix, from userid 1001) id 67268D08; Sat, 5 Nov 2016 21:03:31 +0100 (CET) Date: Sat, 5 Nov 2016 13:03:31 -0700 From: Philip Paeps To: Hiroki Sato Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r308348 - head/usr.sbin/rtadvd Message-ID: <20161105200331.GF78961@rincewind.trouble.is> Mail-Followup-To: Hiroki Sato , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201611051951.uA5JpEh8059002@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201611051951.uA5JpEh8059002@repo.freebsd.org> X-PGP-Fingerprint: 2CD1 92C2 6EE7 B7D1 F552 6619 31AE B9B5 FDBB CB0E X-Date: Today is Prickle-Prickle, the 17th day of The Aftermath in the YOLD 3182 X-Phase-of-Moon: The Moon is Waxing Crescent (31% of Full) X-Philip-Conspiracy: There is no conspiracy X-Checked-By-NSA: Probably X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.1 (2016-10-04) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 20:03:34 -0000 On 2016-11-05 19:51:14 (+0000), Hiroki Sato wrote: > Log: > Add link-layer address option in RA even for IFT_L2VLAN and IFT_BRIDGE. > > Reported by: philip > MFC after: 3 days Thank you! Philip -- Philip Paeps Senior Reality Engineer Ministry of Information From owner-svn-src-head@freebsd.org Sat Nov 5 22:41:23 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86CC1AF725C; Sat, 5 Nov 2016 22:41:23 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 603EE2BB; Sat, 5 Nov 2016 22:41:23 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5MfMJk025698; Sat, 5 Nov 2016 22:41:22 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5MfMTa025696; Sat, 5 Nov 2016 22:41:22 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201611052241.uA5MfMTa025696@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 5 Nov 2016 22:41:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308354 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 22:41:23 -0000 Author: adrian Date: Sat Nov 5 22:41:22 2016 New Revision: 308354 URL: https://svnweb.freebsd.org/changeset/base/308354 Log: [net80211] begin fleshing out new hardware crypto offload features. * extend the keycache flag word to be 32 bits, not 16 bits * add new key flags for transmit: + IEEE80211_KEY_NOIV: Don't insert IV in the payload when transmitting data frames; + IEEE80211_KEY_NOIVMGT: Don't insert IV in the payload when transmitting MIC frames; + IEEE80211_KEY_NOMIC: Don't insert MIC in the payload when transmitting data frames; + IEEE80211_KEY_NOMICMGT: don't insert MIC in the payload when transmitting management frames. * teach ieee80211_crypto_demic() about hardware decrypted frames: + if frames are hardware decrypted and the frame has failed MIC, treat it as a michael failure. + if frames are hardware decrypted and the frame has stripped MIC, we can't check the MIC in the payload - we don't have anything to compare it against. This is only part of the work required to successfully transmit/receive hardware crypto frames such as the qualcomm atheros 11ac offload chips. There will be further work in the transmit and receive path before this can be done by default. Reviewed by: avos Differential Revision: https://reviews.freebsd.org/D8364 Modified: head/sys/net80211/ieee80211_crypto.c head/sys/net80211/ieee80211_crypto.h Modified: head/sys/net80211/ieee80211_crypto.c ============================================================================== --- head/sys/net80211/ieee80211_crypto.c Sat Nov 5 22:09:21 2016 (r308353) +++ head/sys/net80211/ieee80211_crypto.c Sat Nov 5 22:41:22 2016 (r308354) @@ -633,6 +633,61 @@ ieee80211_crypto_decap(struct ieee80211_ #undef IEEE80211_WEP_HDRLEN } + +/* + * Check and remove any MIC. + */ +int +ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, + struct mbuf *m, int force) +{ + const struct ieee80211_cipher *cip; + const struct ieee80211_rx_stats *rxs; + struct ieee80211_frame *wh; + + rxs = ieee80211_get_rx_params_ptr(m); + wh = mtod(m, struct ieee80211_frame *); + + /* + * Handle demic / mic errors from hardware-decrypted offload devices. + */ + if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) { + if (rxs->c_pktflags & IEEE80211_RX_F_FAIL_MIC) { + /* + * Hardware has said MIC failed. We don't care about + * whether it was stripped or not. + * + * Eventually - teach the demic methods in crypto + * modules to handle a NULL key and not to dereference + * it. + */ + ieee80211_notify_michael_failure(vap, wh, -1); + return (0); + } + + if (rxs->c_pktflags & IEEE80211_RX_F_MMIC_STRIP) { + /* + * Hardware has decrypted and not indicated a + * MIC failure and has stripped the MIC. + * We may not have a key, so for now just + * return OK. + */ + return (1); + } + } + + /* + * If we don't have a key at this point then we don't + * have to demic anything. + */ + if (k == NULL) + return (1); + + cip = k->wk_cipher; + return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1); +} + + static void load_ucastkey(void *arg, struct ieee80211_node *ni) { Modified: head/sys/net80211/ieee80211_crypto.h ============================================================================== --- head/sys/net80211/ieee80211_crypto.h Sat Nov 5 22:09:21 2016 (r308353) +++ head/sys/net80211/ieee80211_crypto.h Sat Nov 5 22:41:22 2016 (r308354) @@ -73,19 +73,25 @@ typedef uint16_t ieee80211_keyix; /* h/w struct ieee80211_key { uint8_t wk_keylen; /* key length in bytes */ - uint8_t wk_pad; - uint16_t wk_flags; -#define IEEE80211_KEY_XMIT 0x0001 /* key used for xmit */ -#define IEEE80211_KEY_RECV 0x0002 /* key used for recv */ -#define IEEE80211_KEY_GROUP 0x0004 /* key used for WPA group operation */ -#define IEEE80211_KEY_NOREPLAY 0x0008 /* ignore replay failures */ -#define IEEE80211_KEY_SWENCRYPT 0x0010 /* host-based encrypt */ -#define IEEE80211_KEY_SWDECRYPT 0x0020 /* host-based decrypt */ -#define IEEE80211_KEY_SWENMIC 0x0040 /* host-based enmic */ -#define IEEE80211_KEY_SWDEMIC 0x0080 /* host-based demic */ -#define IEEE80211_KEY_DEVKEY 0x0100 /* device key request completed */ -#define IEEE80211_KEY_CIPHER0 0x1000 /* cipher-specific action 0 */ -#define IEEE80211_KEY_CIPHER1 0x2000 /* cipher-specific action 1 */ + uint8_t wk_pad; /* .. some drivers use this. Fix that. */ + uint8_t wk_pad1[2]; + uint32_t wk_flags; +#define IEEE80211_KEY_XMIT 0x00000001 /* key used for xmit */ +#define IEEE80211_KEY_RECV 0x00000002 /* key used for recv */ +#define IEEE80211_KEY_GROUP 0x00000004 /* key used for WPA group operation */ +#define IEEE80211_KEY_NOREPLAY 0x00000008 /* ignore replay failures */ +#define IEEE80211_KEY_SWENCRYPT 0x00000010 /* host-based encrypt */ +#define IEEE80211_KEY_SWDECRYPT 0x00000020 /* host-based decrypt */ +#define IEEE80211_KEY_SWENMIC 0x00000040 /* host-based enmic */ +#define IEEE80211_KEY_SWDEMIC 0x00000080 /* host-based demic */ +#define IEEE80211_KEY_DEVKEY 0x00000100 /* device key request completed */ +#define IEEE80211_KEY_CIPHER0 0x00001000 /* cipher-specific action 0 */ +#define IEEE80211_KEY_CIPHER1 0x00002000 /* cipher-specific action 1 */ +#define IEEE80211_KEY_NOIV 0x00004000 /* don't insert IV/MIC for !mgmt */ +#define IEEE80211_KEY_NOIVMGT 0x00008000 /* don't insert IV/MIC for mgmt */ +#define IEEE80211_KEY_NOMIC 0x00010000 /* don't insert MIC for !mgmt */ +#define IEEE80211_KEY_NOMICMGT 0x00020000 /* don't insert MIC for mgmt */ + ieee80211_keyix wk_keyix; /* h/w key index */ ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */ uint8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; @@ -203,18 +209,8 @@ struct ieee80211_key *ieee80211_crypto_e struct mbuf *); struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *, struct mbuf *, int); - -/* - * Check and remove any MIC. - */ -static __inline int -ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, - struct mbuf *m, int force) -{ - const struct ieee80211_cipher *cip = k->wk_cipher; - return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1); -} - +int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, + struct mbuf *, int); /* * Add any MIC. */ From owner-svn-src-head@freebsd.org Sat Nov 5 22:47:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25C37AF751A; Sat, 5 Nov 2016 22:47:11 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB935908; Sat, 5 Nov 2016 22:47:10 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5MlAcc025936; Sat, 5 Nov 2016 22:47:10 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5MlAiM025935; Sat, 5 Nov 2016 22:47:10 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201611052247.uA5MlAiM025935@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 5 Nov 2016 22:47:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308355 - head/sys/dev/rtwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 22:47:11 -0000 Author: avos Date: Sat Nov 5 22:47:09 2016 New Revision: 308355 URL: https://svnweb.freebsd.org/changeset/base/308355 Log: rtwn: pause beacon queue during scanning. Tested with RTL8821AU, AP + AP mode. Modified: head/sys/dev/rtwn/if_rtwn.c Modified: head/sys/dev/rtwn/if_rtwn.c ============================================================================== --- head/sys/dev/rtwn/if_rtwn.c Sat Nov 5 22:41:22 2016 (r308354) +++ head/sys/dev/rtwn/if_rtwn.c Sat Nov 5 22:47:09 2016 (r308355) @@ -1513,6 +1513,8 @@ rtwn_scan_start(struct ieee80211com *ic) struct rtwn_softc *sc = ic->ic_softc; RTWN_LOCK(sc); + /* Pause beaconing. */ + rtwn_setbits_1(sc, R92C_TXPAUSE, 0, R92C_TX_QUEUE_BCN); /* Receive beacons / probe responses from any BSSID. */ if (sc->bcn_vaps == 0) rtwn_set_rx_bssid_all(sc, 1); @@ -1547,6 +1549,9 @@ rtwn_scan_end(struct ieee80211com *ic) /* Restore basic rates mask. */ rtwn_calc_basicrates(sc); + + /* Resume beaconing. */ + rtwn_setbits_1(sc, R92C_TXPAUSE, R92C_TX_QUEUE_BCN, 0); RTWN_UNLOCK(sc); } From owner-svn-src-head@freebsd.org Sat Nov 5 23:21:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A13FBED931; Sat, 5 Nov 2016 23:21:32 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25EAFB06; Sat, 5 Nov 2016 23:21:32 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA5NLVjB039492; Sat, 5 Nov 2016 23:21:31 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA5NLUr5039487; Sat, 5 Nov 2016 23:21:30 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201611052321.uA5NLUr5039487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 5 Nov 2016 23:21:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308356 - in head/sys/dev/rtwn: . rtl8812a X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2016 23:21:32 -0000 Author: avos Date: Sat Nov 5 23:21:30 2016 New Revision: 308356 URL: https://svnweb.freebsd.org/changeset/base/308356 Log: rtwn: fix Rx filter setup for some multi-vap configuratons. - Correctly refresh Rx filter when AP (IBSS) vap is created after STA vap. - Block any RCR updates during TSF correction (IBSS mode). - Set CBSSID* bits during vap creation, not when it was started / stopped. - Cache current state to prevent unnecessary register reads. Tested with RTL8188CE, STA + AP mode. Modified: head/sys/dev/rtwn/if_rtwn.c head/sys/dev/rtwn/if_rtwn_rx.c head/sys/dev/rtwn/if_rtwn_rx.h head/sys/dev/rtwn/if_rtwnvar.h head/sys/dev/rtwn/rtl8812a/r12a_caps.c Modified: head/sys/dev/rtwn/if_rtwn.c ============================================================================== --- head/sys/dev/rtwn/if_rtwn.c Sat Nov 5 22:47:09 2016 (r308355) +++ head/sys/dev/rtwn/if_rtwn.c Sat Nov 5 23:21:30 2016 (r308356) @@ -917,6 +917,9 @@ rtwn_tsf_sync_adhoc_task(void *arg, int /* Accept beacons with the same BSSID. */ rtwn_set_rx_bssid_all(sc, 0); + /* Deny RCR updates. */ + sc->sc_flags |= RTWN_RCR_LOCKED; + /* Enable synchronization. */ rtwn_setbits_1(sc, R92C_BCN_CTRL(uvp->id), R92C_BCN_CTRL_DIS_TSF_UDT0, 0); @@ -929,6 +932,7 @@ rtwn_tsf_sync_adhoc_task(void *arg, int 0, R92C_BCN_CTRL_DIS_TSF_UDT0); /* Accept all beacons. */ + sc->sc_flags &= ~RTWN_RCR_LOCKED; rtwn_set_rx_bssid_all(sc, 1); /* Schedule next TSF synchronization. */ @@ -1193,7 +1197,6 @@ rtwn_run(struct rtwn_softc *sc, struct i struct ieee80211com *ic = vap->iv_ic; struct rtwn_vap *uvp = RTWN_VAP(vap); struct ieee80211_node *ni; - uint32_t reg; uint8_t mode; int error; @@ -1246,18 +1249,6 @@ rtwn_run(struct rtwn_softc *sc, struct i rtwn_write_1(sc, R92C_TXPAUSE, 0); } - /* Allow Rx from our BSSID only. */ - if (ic->ic_promisc == 0) { - reg = rtwn_read_4(sc, R92C_RCR); - - if (sc->bcn_vaps == 0) - reg |= R92C_RCR_CBSSID_BCN; - if (sc->ap_vaps == 0) - reg |= R92C_RCR_CBSSID_DATA; - - rtwn_write_4(sc, R92C_RCR, reg); - } - #ifndef RTWN_WITHOUT_UCODE /* Upload (QoS) Null Data frame to firmware. */ /* Note: do this for port 0 only. */ Modified: head/sys/dev/rtwn/if_rtwn_rx.c ============================================================================== --- head/sys/dev/rtwn/if_rtwn_rx.c Sat Nov 5 22:47:09 2016 (r308355) +++ head/sys/dev/rtwn/if_rtwn_rx.c Sat Nov 5 23:21:30 2016 (r308356) @@ -362,7 +362,7 @@ rtwn_rxfilter_update_mgt(struct rtwn_sof { uint16_t filter; - filter = 0x7f3f; + filter = 0x7f7f; if (sc->bcn_vaps == 0) { /* STA and/or MONITOR mode vaps */ filter &= ~( R92C_RXFLTMAP_SUBTYPE(IEEE80211_FC0_SUBTYPE_ASSOC_REQ) | @@ -393,7 +393,6 @@ rtwn_rxfilter_update(struct rtwn_softc * void rtwn_rxfilter_init(struct rtwn_softc *sc) { - uint32_t rcr; RTWN_ASSERT_LOCKED(sc); @@ -406,47 +405,60 @@ rtwn_rxfilter_init(struct rtwn_softc *sc /* Reject all data frames. */ rtwn_write_2(sc, R92C_RXFLTMAP2, 0x0000); - rcr = sc->rcr; - rcr |= R92C_RCR_AM | R92C_RCR_AB | R92C_RCR_APM | - R92C_RCR_HTC_LOC_CTRL | R92C_RCR_APP_PHYSTS | - R92C_RCR_APP_ICV | R92C_RCR_APP_MIC; - - /* Set Rx filter. */ - rtwn_write_4(sc, R92C_RCR, rcr); + /* Append generic Rx filter bits. */ + sc->rcr |= R92C_RCR_AM | R92C_RCR_AB | R92C_RCR_APM | + R92C_RCR_HTC_LOC_CTRL | R92C_RCR_APP_PHYSTS | + R92C_RCR_APP_ICV | R92C_RCR_APP_MIC; /* Update dynamic Rx filter parts. */ rtwn_rxfilter_update(sc); } void +rtwn_rxfilter_set(struct rtwn_softc *sc) +{ + if (!(sc->sc_flags & RTWN_RCR_LOCKED)) + rtwn_write_4(sc, R92C_RCR, sc->rcr); +} + +void rtwn_set_rx_bssid_all(struct rtwn_softc *sc, int enable) { + if (enable) - rtwn_setbits_4(sc, R92C_RCR, R92C_RCR_CBSSID_BCN, 0); + sc->rcr &= ~R92C_RCR_CBSSID_BCN; else - rtwn_setbits_4(sc, R92C_RCR, 0, R92C_RCR_CBSSID_BCN); + sc->rcr |= R92C_RCR_CBSSID_BCN; + rtwn_rxfilter_set(sc); } void rtwn_set_promisc(struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; - uint32_t mask1, mask2; + uint32_t mask_all, mask_min; RTWN_ASSERT_LOCKED(sc); - mask1 = R92C_RCR_ACF | R92C_RCR_ADF | R92C_RCR_AMF | R92C_RCR_AAP; - mask2 = R92C_RCR_APM; + mask_all = R92C_RCR_ACF | R92C_RCR_ADF | R92C_RCR_AMF | R92C_RCR_AAP; + mask_min = R92C_RCR_APM; - if (sc->vaps_running != 0) { - if (sc->bcn_vaps == 0) - mask2 |= R92C_RCR_CBSSID_BCN; - if (sc->ap_vaps == 0) - mask2 |= R92C_RCR_CBSSID_DATA; + if (sc->bcn_vaps == 0) + mask_min |= R92C_RCR_CBSSID_BCN; + if (sc->ap_vaps == 0) + mask_min |= R92C_RCR_CBSSID_DATA; + + if (ic->ic_promisc == 0 && sc->mon_vaps == 0) { + if (sc->bcn_vaps != 0) + mask_all |= R92C_RCR_CBSSID_BCN; + if (sc->ap_vaps != 0) /* for Null data frames */ + mask_all |= R92C_RCR_CBSSID_DATA; + + sc->rcr &= ~mask_all; + sc->rcr |= mask_min; + } else { + sc->rcr &= ~mask_min; + sc->rcr |= mask_all; } - - if (ic->ic_promisc == 0 && sc->mon_vaps == 0) - rtwn_setbits_4(sc, R92C_RCR, mask1, mask2); - else - rtwn_setbits_4(sc, R92C_RCR, mask2, mask1); + rtwn_rxfilter_set(sc); } Modified: head/sys/dev/rtwn/if_rtwn_rx.h ============================================================================== --- head/sys/dev/rtwn/if_rtwn_rx.h Sat Nov 5 22:47:09 2016 (r308355) +++ head/sys/dev/rtwn/if_rtwn_rx.h Sat Nov 5 23:21:30 2016 (r308356) @@ -32,6 +32,7 @@ void rtwn_adhoc_recv_mgmt(struct ieee802 void rtwn_set_multi(struct rtwn_softc *); void rtwn_rxfilter_update(struct rtwn_softc *); void rtwn_rxfilter_init(struct rtwn_softc *); +void rtwn_rxfilter_set(struct rtwn_softc *); void rtwn_set_rx_bssid_all(struct rtwn_softc *, int); void rtwn_set_promisc(struct rtwn_softc *); Modified: head/sys/dev/rtwn/if_rtwnvar.h ============================================================================== --- head/sys/dev/rtwn/if_rtwnvar.h Sat Nov 5 22:47:09 2016 (r308355) +++ head/sys/dev/rtwn/if_rtwnvar.h Sat Nov 5 23:21:30 2016 (r308356) @@ -186,6 +186,7 @@ struct rtwn_softc { #define RTWN_RUNNING 0x10 #define RTWN_FW_LOADED 0x20 #define RTWN_TEMP_MEASURED 0x40 +#define RTWN_RCR_LOCKED 0x80 #define RTWN_CHIP_HAS_BCNQ1(_sc) \ ((_sc)->bcn_status_reg[0] != (_sc)->bcn_status_reg[1]) Modified: head/sys/dev/rtwn/rtl8812a/r12a_caps.c ============================================================================== --- head/sys/dev/rtwn/rtl8812a/r12a_caps.c Sat Nov 5 22:47:09 2016 (r308355) +++ head/sys/dev/rtwn/rtl8812a/r12a_caps.c Sat Nov 5 23:21:30 2016 (r308356) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -89,19 +90,13 @@ r12a_ioctl_net(struct ieee80211com *ic, changed = 1; } if (changed) { - if (rxmask == 0) { + if (rxmask == 0) sc->rcr &= ~R12A_RCR_TCP_OFFLD_EN; - if (sc->sc_flags & RTWN_RUNNING) { - rtwn_setbits_4(sc, R92C_RCR, - R12A_RCR_TCP_OFFLD_EN, 0); - } - } else { + else sc->rcr |= R12A_RCR_TCP_OFFLD_EN; - if (sc->sc_flags & RTWN_RUNNING) { - rtwn_setbits_4(sc, R92C_RCR, - 0, R12A_RCR_TCP_OFFLD_EN); - } - } + + if (sc->sc_flags & RTWN_RUNNING) + rtwn_rxfilter_set(sc); } RTWN_UNLOCK(sc);