From owner-svn-src-stable-12@freebsd.org Sun Oct 25 07:48:08 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95AE64461FF; Sun, 25 Oct 2020 07:48:08 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CJqp03Cj8z3T4Q; Sun, 25 Oct 2020 07:48:08 +0000 (UTC) (envelope-from vmaffione@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4D21E2649C; Sun, 25 Oct 2020 07:48:08 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09P7m8CY068258; Sun, 25 Oct 2020 07:48:08 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09P7m8jt068257; Sun, 25 Oct 2020 07:48:08 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <202010250748.09P7m8jt068257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sun, 25 Oct 2020 07:48:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367036 - stable/12/sys/dev/netmap X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/sys/dev/netmap X-SVN-Commit-Revision: 367036 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2020 07:48:08 -0000 Author: vmaffione Date: Sun Oct 25 07:48:07 2020 New Revision: 367036 URL: https://svnweb.freebsd.org/changeset/base/367036 Log: MFC r366952 netmap: fix mutex double unlock bug https://github.com/luigirizzo/netmap/pull/733 Submitted by: brian90013 Modified: stable/12/sys/dev/netmap/netmap_mem2.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/netmap/netmap_mem2.c ============================================================================== --- stable/12/sys/dev/netmap/netmap_mem2.c Sun Oct 25 01:36:33 2020 (r367035) +++ stable/12/sys/dev/netmap/netmap_mem2.c Sun Oct 25 07:48:07 2020 (r367036) @@ -2007,7 +2007,6 @@ netmap_mem2_if_new(struct netmap_adapter *na, struct n len = sizeof(struct netmap_if) + (ntot * sizeof(ssize_t)); nifp = netmap_if_malloc(na->nm_mem, len); if (nifp == NULL) { - NMA_UNLOCK(na->nm_mem); return NULL; } From owner-svn-src-stable-12@freebsd.org Sun Oct 25 23:25:53 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D8C6845B8C9; Sun, 25 Oct 2020 23:25:53 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKDc15Pjsz4fPl; Sun, 25 Oct 2020 23:25:53 +0000 (UTC) (envelope-from rpokala@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9CBE41134B; Sun, 25 Oct 2020 23:25:53 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09PNPrcX047322; Sun, 25 Oct 2020 23:25:53 GMT (envelope-from rpokala@FreeBSD.org) Received: (from rpokala@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09PNPrBd047321; Sun, 25 Oct 2020 23:25:53 GMT (envelope-from rpokala@FreeBSD.org) Message-Id: <202010252325.09PNPrBd047321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rpokala set sender to rpokala@FreeBSD.org using -f From: Ravi Pokala Date: Sun, 25 Oct 2020 23:25:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367046 - stable/12/sys/ofed/drivers/infiniband/ulp/ipoib X-SVN-Group: stable-12 X-SVN-Commit-Author: rpokala X-SVN-Commit-Paths: stable/12/sys/ofed/drivers/infiniband/ulp/ipoib X-SVN-Commit-Revision: 367046 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2020 23:25:53 -0000 Author: rpokala Date: Sun Oct 25 23:25:53 2020 New Revision: 367046 URL: https://svnweb.freebsd.org/changeset/base/367046 Log: MFC r366686: Allow IP over IB to work with multiple FIBs. Call M_SETFIB() to make sure the IPoIB packet is directed to the correct interface-specific FIB. This was sufficient to allow general-purpose routing using the default FIB, and a separate FIB for routing between IPoIB on ib0 and IPoEthernet on mce0. Reviewed by: hselasky Obtained from: Anmol Kumar Sponsored by: Panasas Differential Revision: https://reviews.freebsd.org/D26733 Modified: stable/12/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c ============================================================================== --- stable/12/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Sun Oct 25 21:04:07 2020 (r367045) +++ stable/12/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Sun Oct 25 23:25:53 2020 (r367046) @@ -1603,6 +1603,8 @@ ipoib_demux(struct ifnet *ifp, struct mbuf *m, u_short m_freem(m); return; } + /* Direct packet to correct FIB based on interface config */ + M_SETFIB(m, ifp->if_fib); /* * Dispatch frame to upper layer. */ From owner-svn-src-stable-12@freebsd.org Mon Oct 26 01:18:16 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8AC545DEA9; Mon, 26 Oct 2020 01:18:16 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKH5h4RGrz4mVh; Mon, 26 Oct 2020 01:18:16 +0000 (UTC) (envelope-from cy@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 78836124F3; Mon, 26 Oct 2020 01:18:16 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09Q1IGah016377; Mon, 26 Oct 2020 01:18:16 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09Q1IGo7016376; Mon, 26 Oct 2020 01:18:16 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202010260118.09Q1IGo7016376@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Mon, 26 Oct 2020 01:18:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367049 - stable/12/libexec/rc/rc.d X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/12/libexec/rc/rc.d X-SVN-Commit-Revision: 367049 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 01:18:16 -0000 Author: cy Date: Mon Oct 26 01:18:15 2020 New Revision: 367049 URL: https://svnweb.freebsd.org/changeset/base/367049 Log: MFC r366857: Destroy cloned interfaces at netif stop, netif restart and shutdown. This is especially important during shutdown because a child interface of lagg with WOL enabled will not enable WOL at interface shutdown and thus no WOL to wake up the device (and machine). PR: 158734, 109980 Reported by: Antonio Huete Jimenez Marat N.Afanasyev reviewed by: kp Modified: stable/12/libexec/rc/rc.d/netif Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.d/netif ============================================================================== --- stable/12/libexec/rc/rc.d/netif Mon Oct 26 00:37:31 2020 (r367048) +++ stable/12/libexec/rc/rc.d/netif Mon Oct 26 01:18:15 2020 (r367049) @@ -28,7 +28,7 @@ # PROVIDE: netif # REQUIRE: FILESYSTEMS iovctl serial sppp sysctl # REQUIRE: hostid ipfs -# KEYWORD: nojailvnet +# KEYWORD: nojailvnet shutdown . /etc/rc.subr . /etc/network.subr From owner-svn-src-stable-12@freebsd.org Mon Oct 26 12:34:51 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6BD65444627; Mon, 26 Oct 2020 12:34:51 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKZ6M29H8z4CkR; Mon, 26 Oct 2020 12:34:51 +0000 (UTC) (envelope-from freqlabs@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29B061A8B1; Mon, 26 Oct 2020 12:34:51 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09QCYpA3036517; Mon, 26 Oct 2020 12:34:51 GMT (envelope-from freqlabs@FreeBSD.org) Received: (from freqlabs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09QCYp2f036516; Mon, 26 Oct 2020 12:34:51 GMT (envelope-from freqlabs@FreeBSD.org) Message-Id: <202010261234.09QCYp2f036516@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: freqlabs set sender to freqlabs@FreeBSD.org using -f From: Ryan Moeller Date: Mon, 26 Oct 2020 12:34:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367055 - stable/12/usr.sbin/efibootmgr X-SVN-Group: stable-12 X-SVN-Commit-Author: freqlabs X-SVN-Commit-Paths: stable/12/usr.sbin/efibootmgr X-SVN-Commit-Revision: 367055 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 12:34:51 -0000 Author: freqlabs Date: Mon Oct 26 12:34:50 2020 New Revision: 367055 URL: https://svnweb.freebsd.org/changeset/base/367055 Log: MFC r366830: efibootmgr: Use returned error code for error message, not errno efivar_unix_path_to_device_path returns the error code, it does not set errno. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D26852 Modified: stable/12/usr.sbin/efibootmgr/efibootmgr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/efibootmgr/efibootmgr.c ============================================================================== --- stable/12/usr.sbin/efibootmgr/efibootmgr.c Mon Oct 26 08:17:41 2020 (r367054) +++ stable/12/usr.sbin/efibootmgr/efibootmgr.c Mon Oct 26 12:34:50 2020 (r367055) @@ -641,11 +641,16 @@ make_boot_var(const char *label, const char *loader, c err(1, "bootvar creation"); if (loader == NULL) errx(1, "Must specify boot loader"); - if (efivar_unix_path_to_device_path(loader, &loaderdp) != 0) - err(1, "Cannot translate unix loader path '%s' to UEFI", loader); + ret = efivar_unix_path_to_device_path(loader, &loaderdp); + if (ret != 0) + errc(1, ret, "Cannot translate unix loader path '%s' to UEFI", + loader); if (kernel != NULL) { - if (efivar_unix_path_to_device_path(kernel, &kerneldp) != 0) - err(1, "Cannot translate unix kernel path '%s' to UEFI", kernel); + ret = efivar_unix_path_to_device_path(kernel, &kerneldp); + if (ret != 0) + errc(1, ret, + "Cannot translate unix kernel path '%s' to UEFI", + kernel); } else { kerneldp = NULL; } From owner-svn-src-stable-12@freebsd.org Mon Oct 26 13:22:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16EC6444FED; Mon, 26 Oct 2020 13:22:56 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKb9q6sW1z4FnJ; Mon, 26 Oct 2020 13:22:55 +0000 (UTC) (envelope-from kp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEDF91B0E1; Mon, 26 Oct 2020 13:22:55 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09QDMtgf066967; Mon, 26 Oct 2020 13:22:55 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09QDMtjg066966; Mon, 26 Oct 2020 13:22:55 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202010261322.09QDMtjg066966@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Mon, 26 Oct 2020 13:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367056 - stable/12/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/netpfil/pf X-SVN-Commit-Revision: 367056 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 13:22:56 -0000 Author: kp Date: Mon Oct 26 13:22:55 2020 New Revision: 367056 URL: https://svnweb.freebsd.org/changeset/base/367056 Log: MFC r366647: pf: create a kif for flags If userspace tries to set flags (e.g. 'set skip on ') and doesn't exist we should create a kif so that we apply the flags when the does turn up. Otherwise we'd end up in surprising situations where the rules say the interface should be skipped, but it's not until the rules get re-applied. Modified: stable/12/sys/netpfil/pf/pf_if.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_if.c ============================================================================== --- stable/12/sys/netpfil/pf/pf_if.c Mon Oct 26 12:34:50 2020 (r367055) +++ stable/12/sys/netpfil/pf/pf_if.c Mon Oct 26 13:22:55 2020 (r367056) @@ -787,8 +787,14 @@ pfi_skip_if(const char *filter, struct pfi_kif *p) int pfi_set_flags(const char *name, int flags) { - struct pfi_kif *p; + struct pfi_kif *p, *kif; + kif = malloc(sizeof(*kif), PFI_MTYPE, M_NOWAIT); + if (kif == NULL) + return (ENOMEM); + + kif = pfi_kif_attach(kif, name); + RB_FOREACH(p, pfi_ifhead, &V_pfi_ifs) { if (pfi_skip_if(name, p)) continue; @@ -800,12 +806,19 @@ pfi_set_flags(const char *name, int flags) int pfi_clear_flags(const char *name, int flags) { - struct pfi_kif *p; + struct pfi_kif *p, *tmp; - RB_FOREACH(p, pfi_ifhead, &V_pfi_ifs) { + RB_FOREACH_SAFE(p, pfi_ifhead, &V_pfi_ifs, tmp) { if (pfi_skip_if(name, p)) continue; p->pfik_flags &= ~flags; + + if (p->pfik_ifp == NULL && p->pfik_group == NULL && + p->pfik_flags == 0) { + /* Delete this kif. */ + RB_REMOVE(pfi_ifhead, &V_pfi_ifs, p); + free(p, PFI_MTYPE); + } } return (0); } From owner-svn-src-stable-12@freebsd.org Mon Oct 26 13:23:41 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A70AB44555C; Mon, 26 Oct 2020 13:23:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKbBj3Vqyz4GBS; Mon, 26 Oct 2020 13:23:41 +0000 (UTC) (envelope-from kp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C8301B339; Mon, 26 Oct 2020 13:23:41 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09QDNfTk067044; Mon, 26 Oct 2020 13:23:41 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09QDNfkl067043; Mon, 26 Oct 2020 13:23:41 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202010261323.09QDNfkl067043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Mon, 26 Oct 2020 13:23:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367057 - stable/12/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/netpfil/pf X-SVN-Commit-Revision: 367057 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 13:23:41 -0000 Author: kp Date: Mon Oct 26 13:23:40 2020 New Revision: 367057 URL: https://svnweb.freebsd.org/changeset/base/367057 Log: MFC r366667: pf: do not remove kifs that are referenced by rules Even if a kif doesn't have an ifp or if_group pointer we still can't delete it if it's referenced by a rule. In other words: we must check rulerefs as well. While we're here also teach pfi_kif_unref() not to remove kifs with flags. Reported-by: syzbot+b31d1d7e12c5d4d42f28@syzkaller.appspotmail.com Modified: stable/12/sys/netpfil/pf/pf_if.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_if.c ============================================================================== --- stable/12/sys/netpfil/pf/pf_if.c Mon Oct 26 13:22:55 2020 (r367056) +++ stable/12/sys/netpfil/pf/pf_if.c Mon Oct 26 13:23:40 2020 (r367057) @@ -258,8 +258,10 @@ pfi_kif_unref(struct pfi_kif *kif) if (kif->pfik_rulerefs > 0) return; - /* kif referencing an existing ifnet or group should exist. */ - if (kif->pfik_ifp != NULL || kif->pfik_group != NULL || kif == V_pfi_all) + /* kif referencing an existing ifnet or group or holding flags should + * exist. */ + if (kif->pfik_ifp != NULL || kif->pfik_group != NULL || + kif == V_pfi_all || kif->pfik_flags != 0) return; RB_REMOVE(pfi_ifhead, &V_pfi_ifs, kif); @@ -814,7 +816,7 @@ pfi_clear_flags(const char *name, int flags) p->pfik_flags &= ~flags; if (p->pfik_ifp == NULL && p->pfik_group == NULL && - p->pfik_flags == 0) { + p->pfik_flags == 0 && p->pfik_rulerefs == 0) { /* Delete this kif. */ RB_REMOVE(pfi_ifhead, &V_pfi_ifs, p); free(p, PFI_MTYPE); From owner-svn-src-stable-12@freebsd.org Mon Oct 26 13:24:20 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EF020445816; Mon, 26 Oct 2020 13:24:20 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKbCS60wNz4G2k; Mon, 26 Oct 2020 13:24:20 +0000 (UTC) (envelope-from kp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B176A1B0E2; Mon, 26 Oct 2020 13:24:20 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09QDOKNF067120; Mon, 26 Oct 2020 13:24:20 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09QDOKxj067119; Mon, 26 Oct 2020 13:24:20 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202010261324.09QDOKxj067119@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Mon, 26 Oct 2020 13:24:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367058 - stable/12/tests/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/tests/sys/netpfil/pf X-SVN-Commit-Revision: 367058 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 13:24:21 -0000 Author: kp Date: Mon Oct 26 13:24:20 2020 New Revision: 367058 URL: https://svnweb.freebsd.org/changeset/base/367058 Log: MFC r366648: pf tests: Test that 'set skip on ' works on new group members There's a know issue where new group members don't get the 'set skip on' applied until the rules are re-loaded. Do this by setting rules that block all traffic, but skip members of the 'epair' group. If we can communicate over the epair interface we know the set skip rule took effect, even if the rule was set before the interface was created. Modified: stable/12/tests/sys/netpfil/pf/set_skip.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/netpfil/pf/set_skip.sh ============================================================================== --- stable/12/tests/sys/netpfil/pf/set_skip.sh Mon Oct 26 13:23:40 2020 (r367057) +++ stable/12/tests/sys/netpfil/pf/set_skip.sh Mon Oct 26 13:24:20 2020 (r367058) @@ -60,8 +60,41 @@ set_skip_group_lo_cleanup() pft_cleanup } +atf_test_case "set_skip_dynamic" "cleanup" +set_skip_dynamic_head() +{ + atf_set descr "Cope with group changes" + atf_set require.user root +} + +set_skip_dynamic_body() +{ + pft_init + + set -x + + vnet_mkjail alcatraz + jexec alcatraz pfctl -e + pft_set_rules alcatraz "set skip on epair" \ + "block" + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.2/24 up + ifconfig ${epair}b vnet alcatraz + + jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up + + atf_check -s exit:0 -o ignore jexec alcatraz ping -c 1 192.0.2.2 +} + +set_skip_dynamic_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "set_skip_group" atf_add_test_case "set_skip_group_lo" + atf_add_test_case "set_skip_dynamic" } From owner-svn-src-stable-12@freebsd.org Mon Oct 26 17:47:42 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E26F944A65F; Mon, 26 Oct 2020 17:47:42 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CKj3L5j8rz4WSq; Mon, 26 Oct 2020 17:47:42 +0000 (UTC) (envelope-from brooks@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A702E1E30E; Mon, 26 Oct 2020 17:47:42 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09QHlggC025339; Mon, 26 Oct 2020 17:47:42 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09QHlgS6025338; Mon, 26 Oct 2020 17:47:42 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202010261747.09QHlgS6025338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Mon, 26 Oct 2020 17:47:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367061 - stable/12/lib/libc/tests/ssp X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/lib/libc/tests/ssp X-SVN-Commit-Revision: 367061 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 17:47:43 -0000 Author: brooks Date: Mon Oct 26 17:47:42 2020 New Revision: 367061 URL: https://svnweb.freebsd.org/changeset/base/367061 Log: MFC r366981: Only use ASAN when using the in-tree compiler When building FreeBSD 11 on a FreeBSD 12 system with CROSS_TOOLCHAIN=llvm10 we end up trying to link against the packaged version of the sanitizer library. This resulted in a requirement for getentropy(3) which is not present in FreeBSD 11. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D26903 Modified: stable/12/lib/libc/tests/ssp/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/tests/ssp/Makefile ============================================================================== --- stable/12/lib/libc/tests/ssp/Makefile Mon Oct 26 17:30:17 2020 (r367060) +++ stable/12/lib/libc/tests/ssp/Makefile Mon Oct 26 17:47:42 2020 (r367061) @@ -6,7 +6,9 @@ NO_WERROR= WARNS?= 2 CFLAGS.h_raw+= -fstack-protector-all -Wstack-protector -.if ${COMPILER_TYPE} == "clang" +.if ${COMPILER_TYPE} == "clang" && ${CC} == "cc" +# Only use -fsanitize=bounds when using the in-tree compiler. Otherwise +# we may link to a sanitizer library targeted at a newer kernel/libc. CFLAGS.h_raw+= -fsanitize=bounds .elif ${COMPILER_TYPE} == "gcc" CFLAGS.h_raw+= --param ssp-buffer-size=1 From owner-svn-src-stable-12@freebsd.org Tue Oct 27 13:13:06 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 912C644CFFF; Tue, 27 Oct 2020 13:13:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLBw23JPjz4pD2; Tue, 27 Oct 2020 13:13:06 +0000 (UTC) (envelope-from kevans@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 55951C1C0; Tue, 27 Oct 2020 13:13:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09RDD6L2048614; Tue, 27 Oct 2020 13:13:06 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09RDD48l048608; Tue, 27 Oct 2020 13:13:04 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202010271313.09RDD48l048608@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 27 Oct 2020 13:13:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367080 - in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/freebsd32 i386/linux kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/sys: amd64/linux amd64/linux32 arm64/linux compat/freebsd32 i386/linux kern X-SVN-Commit-Revision: 367080 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 13:13:06 -0000 Author: kevans Date: Tue Oct 27 13:13:04 2020 New Revision: 367080 URL: https://svnweb.freebsd.org/changeset/base/367080 Log: MFC r367002, r367060 r367002: audit: correct reporting of *execve(2) success r326145 corrected do_execve() to return EJUSTRETURN upon success so that important registers are not clobbered. This had the side effect of tapping out 'failures' for all *execve(2) audit records, which is less than useful for auditing purposes. Audit exec returns earlier, where we can know for sure that EJUSTRETURN translates to success. Note that this unsets TDP_AUDITREC as we commit the audit record, so the usual audit in the syscall return path will do nothing. r367060: audit: also correctly audit linux_execve() Linux execve() gets audited as AUE_EXECVE as well, we should also interpret the return from this correctly for the same reasoning as in r367002. PR: 249179, 242938 Modified: stable/12/sys/amd64/linux/linux_machdep.c stable/12/sys/amd64/linux32/linux32_machdep.c stable/12/sys/arm64/linux/linux_machdep.c stable/12/sys/compat/freebsd32/freebsd32_misc.c stable/12/sys/i386/linux/linux_machdep.c stable/12/sys/kern/kern_exec.c stable/12/sys/kern/subr_syscall.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/linux/linux_machdep.c ============================================================================== --- stable/12/sys/amd64/linux/linux_machdep.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/amd64/linux/linux_machdep.c Tue Oct 27 13:13:04 2020 (r367080) @@ -81,6 +81,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -107,6 +109,7 @@ linux_execve(struct thread *td, struct linux_execve_ar free(path, M_TEMP); if (error == 0) error = linux_common_execve(td, &eargs); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } Modified: stable/12/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_machdep.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/amd64/linux32/linux32_machdep.c Tue Oct 27 13:13:04 2020 (r367080) @@ -69,6 +69,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -138,6 +140,7 @@ linux_execve(struct thread *td, struct linux_execve_ar free(path, M_TEMP); if (error == 0) error = linux_common_execve(td, &eargs); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } Modified: stable/12/sys/arm64/linux/linux_machdep.c ============================================================================== --- stable/12/sys/arm64/linux/linux_machdep.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/arm64/linux/linux_machdep.c Tue Oct 27 13:13:04 2020 (r367080) @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -74,6 +76,7 @@ linux_execve(struct thread *td, struct linux_execve_ar free(path, M_TEMP); if (error == 0) error = linux_common_execve(td, &eargs); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_misc.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/compat/freebsd32/freebsd32_misc.c Tue Oct 27 13:13:04 2020 (r367080) @@ -440,6 +440,7 @@ freebsd32_execve(struct thread *td, struct freebsd32_e if (error == 0) error = kern_execve(td, &eargs, NULL, oldvmspace); post_execve(td, error, oldvmspace); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } @@ -460,6 +461,7 @@ freebsd32_fexecve(struct thread *td, struct freebsd32_ error = kern_execve(td, &eargs, NULL, oldvmspace); } post_execve(td, error, oldvmspace); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } Modified: stable/12/sys/i386/linux/linux_machdep.c ============================================================================== --- stable/12/sys/i386/linux/linux_machdep.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/i386/linux/linux_machdep.c Tue Oct 27 13:13:04 2020 (r367080) @@ -61,6 +61,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -111,6 +113,7 @@ linux_execve(struct thread *td, struct linux_execve_ar free(newpath, M_TEMP); if (error == 0) error = linux_common_execve(td, &eargs); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } Modified: stable/12/sys/kern/kern_exec.c ============================================================================== --- stable/12/sys/kern/kern_exec.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/kern/kern_exec.c Tue Oct 27 13:13:04 2020 (r367080) @@ -224,6 +224,7 @@ sys_execve(struct thread *td, struct execve_args *uap) if (error == 0) error = kern_execve(td, &args, NULL, oldvmspace); post_execve(td, error, oldvmspace); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } @@ -251,6 +252,7 @@ sys_fexecve(struct thread *td, struct fexecve_args *ua error = kern_execve(td, &args, NULL, oldvmspace); } post_execve(td, error, oldvmspace); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); } @@ -279,6 +281,7 @@ sys___mac_execve(struct thread *td, struct __mac_execv if (error == 0) error = kern_execve(td, &args, uap->mac_p, oldvmspace); post_execve(td, error, oldvmspace); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); return (error); #else return (ENOSYS); Modified: stable/12/sys/kern/subr_syscall.c ============================================================================== --- stable/12/sys/kern/subr_syscall.c Tue Oct 27 12:49:40 2020 (r367079) +++ stable/12/sys/kern/subr_syscall.c Tue Oct 27 13:13:04 2020 (r367080) @@ -142,6 +142,16 @@ syscallenter(struct thread *td) AUDIT_SYSCALL_ENTER(sa->code, td); error = (sa->callp->sy_call)(td, sa->args); + + /* + * Note that some syscall implementations (e.g., sys_execve) + * will commit the audit record just before their final return. + * These were done under the assumption that nothing of interest + * would happen between their return and here, where we would + * normally commit the audit record. These assumptions will + * need to be revisited should any substantial logic be added + * above. + */ AUDIT_SYSCALL_EXIT(error, td); /* Save the latest error return value. */ From owner-svn-src-stable-12@freebsd.org Wed Oct 28 11:40:11 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80F0A44373C; Wed, 28 Oct 2020 11:40:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLmpM2vXRz40Wr; Wed, 28 Oct 2020 11:40: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 431A51BADE; Wed, 28 Oct 2020 11:40: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 09SBeBAo085240; Wed, 28 Oct 2020 11:40:11 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09SBeBWw085239; Wed, 28 Oct 2020 11:40:11 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202010281140.09SBeBWw085239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 28 Oct 2020 11:40:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367098 - stable/12/sys/arm/allwinner X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/arm/allwinner X-SVN-Commit-Revision: 367098 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 11:40:11 -0000 Author: avg Date: Wed Oct 28 11:40:10 2020 New Revision: 367098 URL: https://svnweb.freebsd.org/changeset/base/367098 Log: MFC r365943: aw_usbphy: add support for device mode operation OTG mode is not supported still. It's easy to do it as a one-off detection, but the proper support requires continuous monitoring and communicating the current state to the USB layer. Also, fix phy0_route setting for H3. Remove duplicate register definitions. Modified: stable/12/sys/arm/allwinner/aw_usbphy.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/aw_usbphy.c ============================================================================== --- stable/12/sys/arm/allwinner/aw_usbphy.c Wed Oct 28 08:29:31 2020 (r367097) +++ stable/12/sys/arm/allwinner/aw_usbphy.c Wed Oct 28 11:40:10 2020 (r367098) @@ -102,7 +102,7 @@ static const struct aw_usbphy_conf h3_usbphy_conf = { .num_phys = 4, .phy_type = AWUSBPHY_TYPE_H3, .pmu_unk1 = true, - .phy0_route = false, + .phy0_route = true, }; static const struct aw_usbphy_conf a64_usbphy_conf = { @@ -167,8 +167,10 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define FORCE_ID (0x3 << 14) #define FORCE_ID_SHIFT 14 #define FORCE_ID_LOW 2 +#define FORCE_ID_HIGH 3 #define FORCE_VBUS_VALID (0x3 << 12) #define FORCE_VBUS_VALID_SHIFT 12 +#define FORCE_VBUS_VALID_LOW 2 #define FORCE_VBUS_VALID_HIGH 3 #define VBUS_CHANGE_DET (1 << 6) #define ID_CHANGE_DET (1 << 5) @@ -182,18 +184,6 @@ DEFINE_CLASS_1(awusbphy_phynode, awusbphy_phynode_clas #define PMU_ULPI_BYPASS (1 << 0) #define PMU_UNK_H3 0x10 #define PMU_UNK_H3_CLR 0x2 -#define PHY_CSR 0x00 -#define ID_PULLUP_EN (1 << 17) -#define DPDM_PULLUP_EN (1 << 16) -#define FORCE_ID (0x3 << 14) -#define FORCE_ID_SHIFT 14 -#define FORCE_ID_LOW 2 -#define FORCE_VBUS_VALID (0x3 << 12) -#define FORCE_VBUS_VALID_SHIFT 12 -#define FORCE_VBUS_VALID_HIGH 3 -#define VBUS_CHANGE_DET (1 << 6) -#define ID_CHANGE_DET (1 << 5) -#define DPDM_CHANGE_DET (1 << 4) static void awusbphy_configure(device_t dev, int phyno) @@ -327,7 +317,12 @@ awusbphy_vbus_detect(device_t dev, int *val) return (0); } - *val = 0; + /* TODO check vbus_power-supply. */ + + /* + * If there is no way to detect, assume present. + */ + *val = 1; return (0); } @@ -361,10 +356,11 @@ awusbphy_phy_enable(struct phynode *phynode, bool enab if (error) goto out; - if (vbus_det == 1) { + /* TODO check vbus_power-supply as well. */ + if (sc->vbus_det_valid && vbus_det == 1) { if (bootverbose) - device_printf(dev, "External VBUS detected, not enabling the regulator\n"); - + device_printf(dev, "External VBUS detected, " + "not enabling the regulator\n"); return (0); } } @@ -418,37 +414,40 @@ awusbphy_set_mode(struct phynode *phynode, int mode) return (0); } + if (sc->mode == mode) + return (0); + if (mode == PHY_USB_MODE_OTG) /* TODO */ + return (EOPNOTSUPP); + + error = awusbphy_vbus_detect(dev, &vbus_det); + if (error != 0) + return (error); + + val = bus_read_4(sc->phy_ctrl, PHY_CSR); + val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); + val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); + val &= ~FORCE_VBUS_VALID; + val |= (vbus_det ? FORCE_VBUS_VALID_HIGH : FORCE_VBUS_VALID_LOW) << + FORCE_VBUS_VALID_SHIFT; + val &= ~FORCE_ID; + switch (mode) { case PHY_USB_MODE_HOST: - val = bus_read_4(sc->phy_ctrl, PHY_CSR); - val &= ~(VBUS_CHANGE_DET | ID_CHANGE_DET | DPDM_CHANGE_DET); - val |= (ID_PULLUP_EN | DPDM_PULLUP_EN); - val &= ~FORCE_ID; val |= (FORCE_ID_LOW << FORCE_ID_SHIFT); - val &= ~FORCE_VBUS_VALID; - val |= (FORCE_VBUS_VALID_HIGH << FORCE_VBUS_VALID_SHIFT); - bus_write_4(sc->phy_ctrl, PHY_CSR, val); - if (sc->phy_conf->phy0_route == true) { - error = awusbphy_vbus_detect(dev, &vbus_det); - if (error) - goto out; - if (vbus_det == 0) - CLR4(sc->phy_ctrl, OTG_PHY_CFG, - OTG_PHY_ROUTE_OTG); - else - SET4(sc->phy_ctrl, OTG_PHY_CFG, - OTG_PHY_ROUTE_OTG); - } + if (sc->phy_conf->phy0_route) + CLR4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); break; - case PHY_USB_MODE_OTG: - /* TODO */ + case PHY_USB_MODE_DEVICE: + val |= (FORCE_ID_HIGH << FORCE_ID_SHIFT); + if (sc->phy_conf->phy0_route) + SET4(sc->phy_ctrl, OTG_PHY_CFG, OTG_PHY_ROUTE_OTG); break; + default: + return (EINVAL); } + bus_write_4(sc->phy_ctrl, PHY_CSR, val); sc->mode = mode; - - -out: return (0); } From owner-svn-src-stable-12@freebsd.org Wed Oct 28 17:03:04 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7604944BA89; Wed, 28 Oct 2020 17:03:04 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLvyw2Fmcz4MDC; Wed, 28 Oct 2020 17:03:04 +0000 (UTC) (envelope-from 0mp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30AB11FA86; Wed, 28 Oct 2020 17:03:04 +0000 (UTC) (envelope-from 0mp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09SH348v087942; Wed, 28 Oct 2020 17:03:04 GMT (envelope-from 0mp@FreeBSD.org) Received: (from 0mp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09SH346n087941; Wed, 28 Oct 2020 17:03:04 GMT (envelope-from 0mp@FreeBSD.org) Message-Id: <202010281703.09SH346n087941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: 0mp set sender to 0mp@FreeBSD.org using -f From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Wed, 28 Oct 2020 17:03:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367111 - stable/12/lib/geom/eli X-SVN-Group: stable-12 X-SVN-Commit-Author: 0mp X-SVN-Commit-Paths: stable/12/lib/geom/eli X-SVN-Commit-Revision: 367111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 17:03:04 -0000 Author: 0mp (doc,ports committer) Date: Wed Oct 28 17:03:03 2020 New Revision: 367111 URL: https://svnweb.freebsd.org/changeset/base/367111 Log: MFC r366725: Fix formatting of SYNOPSIS There was an unnecessary newline being added before Nm. Modified: stable/12/lib/geom/eli/geli.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/geom/eli/geli.8 ============================================================================== --- stable/12/lib/geom/eli/geli.8 Wed Oct 28 16:54:37 2020 (r367110) +++ stable/12/lib/geom/eli/geli.8 Wed Oct 28 17:03:03 2020 (r367111) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 22, 2020 +.Dd October 15, 2020 .Dt GELI 8 .Os .Sh NAME @@ -45,8 +45,7 @@ to your geom_eli_load="YES" .Ed .Pp -Usage of the -.Nm +.No Usage of the Nm utility: .Pp .Nm From owner-svn-src-stable-12@freebsd.org Wed Oct 28 21:01:01 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AE8E4504BE; Wed, 28 Oct 2020 21:01:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CM1FT1LGbz4ZGr; Wed, 28 Oct 2020 21:01:01 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12907221D8; Wed, 28 Oct 2020 21:01:01 +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 09SL10Nq033226; Wed, 28 Oct 2020 21:01:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09SL107L033224; Wed, 28 Oct 2020 21:01:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202010282101.09SL107L033224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 28 Oct 2020 21:01:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367115 - in stable/12/sys: amd64/ia32 i386/i386 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: amd64/ia32 i386/i386 X-SVN-Commit-Revision: 367115 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 21:01:01 -0000 Author: kib Date: Wed Oct 28 21:01:00 2020 New Revision: 367115 URL: https://svnweb.freebsd.org/changeset/base/367115 Log: MFC r366904: Improve FPU Tag Word reconstruction on i386 to indicate register states. PR: 250454 Modified: stable/12/sys/amd64/ia32/ia32_reg.c stable/12/sys/i386/i386/npx.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/ia32/ia32_reg.c ============================================================================== --- stable/12/sys/amd64/ia32/ia32_reg.c Wed Oct 28 20:22:20 2020 (r367114) +++ stable/12/sys/amd64/ia32/ia32_reg.c Wed Oct 28 21:01:00 2020 (r367115) @@ -146,7 +146,11 @@ fill_fpregs32(struct thread *td, struct fpreg32 *regs) struct save87 *sv_87; struct env87 *penv_87; struct envxmm *penv_xmm; - int i; + struct fpacc87 *fx_reg; + int i, st; + uint64_t mantissa; + uint16_t tw, exp; + uint8_t ab_tw; bzero(regs, sizeof(*regs)); sv_87 = (struct save87 *)regs; @@ -172,13 +176,39 @@ fill_fpregs32(struct thread *td, struct fpreg32 *regs) /* Entry into the kernel always sets TF_HASSEGS */ penv_87->en_fos = td->td_frame->tf_ds; - /* FPU registers and tags */ - penv_87->en_tw = 0xffff; - for (i = 0; i < 8; ++i) { - sv_87->sv_ac[i] = sv_fpu->sv_fp[i].fp_acc; - if ((penv_xmm->en_tw & (1 << i)) != 0) - penv_87->en_tw &= ~(3 << i * 2); + /* + * FPU registers and tags. + * For ST(i), i = fpu_reg - top; we start with fpu_reg=7. + */ + st = 7 - ((penv_xmm->en_sw >> 11) & 7); + ab_tw = penv_xmm->en_tw; + tw = 0; + for (i = 0x80; i != 0; i >>= 1) { + sv_87->sv_ac[st] = sv_fpu->sv_fp[st].fp_acc; + tw <<= 2; + if ((ab_tw & i) != 0) { + /* Non-empty - we need to check ST(i) */ + fx_reg = &sv_fpu->sv_fp[st].fp_acc; + /* The first 64 bits contain the mantissa. */ + mantissa = *((uint64_t *)fx_reg->fp_bytes); + /* + * The final 16 bits contain the sign bit and the exponent. + * Mask the sign bit since it is of no consequence to these + * tests. + */ + exp = *((uint16_t *)&fx_reg->fp_bytes[8]) & 0x7fff; + if (exp == 0) { + if (mantissa == 0) + tw |= 1; /* Zero */ + else + tw |= 2; /* Denormal */ + } else if (exp == 0x7fff) + tw |= 2; /* Infinity or NaN */ + } else + tw |= 3; /* Empty */ + st = (st - 1) & 7; } + penv_87->en_tw = tw; return (0); } Modified: stable/12/sys/i386/i386/npx.c ============================================================================== --- stable/12/sys/i386/i386/npx.c Wed Oct 28 20:22:20 2020 (r367114) +++ stable/12/sys/i386/i386/npx.c Wed Oct 28 21:01:00 2020 (r367115) @@ -1149,7 +1149,11 @@ npx_fill_fpregs_xmm1(struct savexmm *sv_xmm, struct sa { struct env87 *penv_87; struct envxmm *penv_xmm; - int i; + struct fpacc87 *fx_reg; + int i, st; + uint64_t mantissa; + uint16_t tw, exp; + uint8_t ab_tw; penv_87 = &sv_87->sv_env; penv_xmm = &sv_xmm->sv_env; @@ -1163,14 +1167,39 @@ npx_fill_fpregs_xmm1(struct savexmm *sv_xmm, struct sa penv_87->en_foo = penv_xmm->en_foo; penv_87->en_fos = penv_xmm->en_fos; - /* FPU registers and tags */ - penv_87->en_tw = 0xffff; - for (i = 0; i < 8; ++i) { - sv_87->sv_ac[i] = sv_xmm->sv_fp[i].fp_acc; - if ((penv_xmm->en_tw & (1 << i)) != 0) - /* zero and special are set as valid */ - penv_87->en_tw &= ~(3 << i * 2); + /* + * FPU registers and tags. + * For ST(i), i = fpu_reg - top; we start with fpu_reg=7. + */ + st = 7 - ((penv_xmm->en_sw >> 11) & 7); + ab_tw = penv_xmm->en_tw; + tw = 0; + for (i = 0x80; i != 0; i >>= 1) { + sv_87->sv_ac[st] = sv_xmm->sv_fp[st].fp_acc; + tw <<= 2; + if (ab_tw & i) { + /* Non-empty - we need to check ST(i) */ + fx_reg = &sv_xmm->sv_fp[st].fp_acc; + /* The first 64 bits contain the mantissa. */ + mantissa = *((uint64_t *)fx_reg->fp_bytes); + /* + * The final 16 bits contain the sign bit and the exponent. + * Mask the sign bit since it is of no consequence to these + * tests. + */ + exp = *((uint16_t *)&fx_reg->fp_bytes[8]) & 0x7fff; + if (exp == 0) { + if (mantissa == 0) + tw |= 1; /* Zero */ + else + tw |= 2; /* Denormal */ + } else if (exp == 0x7fff) + tw |= 2; /* Infinity or NaN */ + } else + tw |= 3; /* Empty */ + st = (st - 1) & 7; } + penv_87->en_tw = tw; } void From owner-svn-src-stable-12@freebsd.org Wed Oct 28 21:02:44 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CDFB4504D1; Wed, 28 Oct 2020 21:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CM1HS1Npdz4ZfK; Wed, 28 Oct 2020 21:02:44 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 13975221F4; Wed, 28 Oct 2020 21:02:44 +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 09SL2h3K036556; Wed, 28 Oct 2020 21:02:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09SL2hNJ036555; Wed, 28 Oct 2020 21:02:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202010282102.09SL2hNJ036555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 28 Oct 2020 21:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367116 - stable/12/lib/libc/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/lib/libc/sys X-SVN-Commit-Revision: 367116 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 21:02:44 -0000 Author: kib Date: Wed Oct 28 21:02:43 2020 New Revision: 367116 URL: https://svnweb.freebsd.org/changeset/base/367116 Log: MFC r366918: mmap(2): Document guard size for MAP_STACK and related EINVAL. Modified: stable/12/lib/libc/sys/mmap.2 Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/sys/mmap.2 ============================================================================== --- stable/12/lib/libc/sys/mmap.2 Wed Oct 28 21:01:00 2020 (r367115) +++ stable/12/lib/libc/sys/mmap.2 Wed Oct 28 21:02:43 2020 (r367116) @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd June 22, 2017 +.Dd October 21, 2020 .Dt MMAP 2 .Os .Sh NAME @@ -335,6 +335,8 @@ Stacks created with automatically grow. Guards prevent inadvertent use of the regions into which those stacks can grow without requiring mapping the whole stack in advance. +The size of the guard, in pages, is specified by sysctl +.Dv security.bsd.stack_guard_page . .El .Pp The @@ -435,6 +437,11 @@ or .Dv MAP_STACK was specified. At least one of these flags must be included. +.It Bq Er EINVAL +.Dv MAP_STACK +was specified and +.Va len +is less than or equal to the guard size. .It Bq Er EINVAL .Dv MAP_FIXED was specified and the From owner-svn-src-stable-12@freebsd.org Thu Oct 29 00:30:38 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E7DFB453A5D; Thu, 29 Oct 2020 00:30:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CM5vL5trNz3XZD; Thu, 29 Oct 2020 00:30:38 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A77A6249B9; Thu, 29 Oct 2020 00:30:38 +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 09T0Uctt060769; Thu, 29 Oct 2020 00:30:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09T0Uc2E060768; Thu, 29 Oct 2020 00:30:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202010290030.09T0Uc2E060768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 29 Oct 2020 00:30:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367124 - stable/12/sys/dev/sound/pci/hda X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/sound/pci/hda X-SVN-Commit-Revision: 367124 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 00:30:39 -0000 Author: mav Date: Thu Oct 29 00:30:38 2020 New Revision: 367124 URL: https://svnweb.freebsd.org/changeset/base/367124 Log: MFC r366733: Drop unsolicited responses to the still attaching CODECs. It is reported to fix kernel panics when early unsolicited responses delivered to the CODEC device not having driver attached yet. PR: 250248 Modified: stable/12/sys/dev/sound/pci/hda/hdac.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/12/sys/dev/sound/pci/hda/hdac.c Thu Oct 29 00:23:16 2020 (r367123) +++ stable/12/sys/dev/sound/pci/hda/hdac.c Thu Oct 29 00:30:38 2020 (r367124) @@ -1001,7 +1001,8 @@ hdac_unsolq_flush(struct hdac_softc *sc) sc->unsolq_rp %= HDAC_UNSOLQ_MAX; cad = sc->unsolq[sc->unsolq_rp++]; sc->unsolq_rp %= HDAC_UNSOLQ_MAX; - if ((child = sc->codecs[cad].dev) != NULL) + if ((child = sc->codecs[cad].dev) != NULL && + device_is_attached(child)) HDAC_UNSOL_INTR(child, resp); ret++; } From owner-svn-src-stable-12@freebsd.org Thu Oct 29 11:09:48 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D38DA44BAEE; Thu, 29 Oct 2020 11:09:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMN4r5HhGz4Yhj; Thu, 29 Oct 2020 11:09:48 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98EB02C9DF; Thu, 29 Oct 2020 11:09:48 +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 09TB9mFA055200; Thu, 29 Oct 2020 11:09:48 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09TB9m9a055199; Thu, 29 Oct 2020 11:09:48 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202010291109.09TB9m9a055199@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 29 Oct 2020 11:09:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367128 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 367128 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 11:09:48 -0000 Author: kib Date: Thu Oct 29 11:09:48 2020 New Revision: 367128 URL: https://svnweb.freebsd.org/changeset/base/367128 Log: MFC r366932: sysv_sem: semusz depends on semume. PR: 250361 Modified: stable/12/sys/kern/sysv_sem.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/sysv_sem.c ============================================================================== --- stable/12/sys/kern/sysv_sem.c Thu Oct 29 08:31:47 2020 (r367127) +++ stable/12/sys/kern/sysv_sem.c Thu Oct 29 11:09:48 2020 (r367128) @@ -187,13 +187,13 @@ struct sem_undo { #define SEM_ALIGN(bytes) roundup2(bytes, sizeof(long)) /* actual size of an undo structure */ -#define SEMUSZ SEM_ALIGN(offsetof(struct sem_undo, un_ent[SEMUME])) +#define SEMUSZ(x) SEM_ALIGN(offsetof(struct sem_undo, un_ent[(x)])) /* * Macro to find a particular sem_undo vector */ #define SEMU(ix) \ - ((struct sem_undo *)(((intptr_t)semu)+ix * seminfo.semusz)) + ((struct sem_undo *)(((intptr_t)semu) + (ix) * seminfo.semusz)) /* * semaphore info struct @@ -205,7 +205,7 @@ struct seminfo seminfo = { .semmsl = SEMMSL, /* max # of semaphores per id */ .semopm = SEMOPM, /* max # of operations per semop call */ .semume = SEMUME, /* max # of undo entries per process */ - .semusz = SEMUSZ, /* size in bytes of undo structure */ + .semusz = SEMUSZ(SEMUME), /* size in bytes of undo structure */ .semvmx = SEMVMX, /* semaphore maximum value */ .semaem = SEMAEM, /* adjust on exit max value */ }; @@ -222,7 +222,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, "Max operations per semop call"); SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0, "Max undo entries per process"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RD, &seminfo.semusz, 0, "Size in bytes of undo structure"); SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RWTUN, &seminfo.semvmx, 0, "Semaphore maximum value"); @@ -284,6 +284,7 @@ seminit(void) M_WAITOK | M_ZERO); sema_mtx = malloc(sizeof(struct mtx) * seminfo.semmni, M_SEM, M_WAITOK | M_ZERO); + seminfo.semusz = SEMUSZ(seminfo.semume); semu = malloc(seminfo.semmnu * seminfo.semusz, M_SEM, M_WAITOK); for (i = 0; i < seminfo.semmni; i++) { From owner-svn-src-stable-12@freebsd.org Thu Oct 29 16:18:16 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ECB3A457212; Thu, 29 Oct 2020 16:18:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMVwl68Jmz40sf; Thu, 29 Oct 2020 16:18:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 09TGHpoI003874 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 29 Oct 2020 18:17:54 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 09TGHpoI003874 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 09TGHpqu003873; Thu, 29 Oct 2020 18:17:51 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 29 Oct 2020 18:17:51 +0200 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r367049 - stable/12/libexec/rc/rc.d Message-ID: <20201029161751.GA2654@kib.kiev.ua> References: <202010260118.09Q1IGo7016376@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202010260118.09Q1IGo7016376@repo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4CMVwl68Jmz40sf X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-0.08 / 15.00]; ARC_NA(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-0.11)[-0.106]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_SPAM_MEDIUM(0.40)[0.402]; NEURAL_HAM_SHORT(-0.38)[-0.376]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-stable,svn-src-stable-12]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 16:18:17 -0000 On Mon, Oct 26, 2020 at 01:18:16AM +0000, Cy Schubert wrote: > Author: cy > Date: Mon Oct 26 01:18:15 2020 > New Revision: 367049 > URL: https://svnweb.freebsd.org/changeset/base/367049 > > Log: > MFC r366857: > Destroy cloned interfaces at netif stop, netif restart and shutdown. > This is especially important during shutdown because a child interface > of lagg with WOL enabled will not enable WOL at interface shutdown and > thus no WOL to wake up the device (and machine). > > PR: 158734, 109980 > Reported by: Antonio Huete Jimenez > Marat N.Afanasyev > reviewed by: kp > > Modified: > stable/12/libexec/rc/rc.d/netif > Directory Properties: > stable/12/ (props changed) > > Modified: stable/12/libexec/rc/rc.d/netif > ============================================================================== > --- stable/12/libexec/rc/rc.d/netif Mon Oct 26 00:37:31 2020 (r367048) > +++ stable/12/libexec/rc/rc.d/netif Mon Oct 26 01:18:15 2020 (r367049) > @@ -28,7 +28,7 @@ > # PROVIDE: netif > # REQUIRE: FILESYSTEMS iovctl serial sppp sysctl > # REQUIRE: hostid ipfs > -# KEYWORD: nojailvnet > +# KEYWORD: nojailvnet shutdown > > . /etc/rc.subr > . /etc/network.subr After this change, shutdown of my stable/12 router looks like this: Stopping devd. Waiting for PIDS: 1120. Oct 29 18:09:52 tom minissdpd[1619]: setsockopt(udp, IP_DROP_MEMBERSHIP)(vlan1): Can't assign requested address /etc/rc.shutdown: WARNING: vlan1 does not exist. Skipped. /etc/rc.shutdown: WARNING: vlan2 does not exist. Skipped. /etc/rc.shutdown: WARNING: vlan3 does not exist. Skipped. /etc/rc.shutdown: WARNING: vlan4 does not exist. Skipped. /etc/rc.shutdown: WARNING: vlan5 does not exist. Skipped. Stopping Network: lo0 re0 re1 pflog0 gif0. lo0: flags=8048 metric 0 mtu 16384 options=680003 groups: lo nd6 options=21 re0: flags=8802 metric 0 mtu 1500 options=201b ether e0:d5:5e:50:93:04 media: Ethernet autoselect (1000baseT ) status: active nd6 options=29 re1: flags=8802 metric 0 mtu 1500 options=201b ether e0:d5:5e:50:93:05 media: Ethernet autoselect (100baseTX ) status: active nd6 options=29 pflog0: flags=100 metric 0 mtu 33160 groups: pflog gif0: flags=8010 metric 0 mtu 1280 options=80000 tunnel inet 176.36.249.139 --> 216.66.84.46 groups: gif nd6 options=21 Destroyed clone interfaces: gif0. Writing entropy file: . . Terminated Oct 29 18:09:53 tom syslogd: exiting on signal 15 pflog0: promiscuous mode disabled Waiting (max 60 seconds) for system process `vnlru' to stop... done Waiting (max 60 seconds) for system process `syncer' to stop... Syncing disks, vnodes remaining... 14 2 2 1 1 1 0 0 0 0 done From owner-svn-src-stable-12@freebsd.org Thu Oct 29 18:18:52 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6AEA4459C9D; Thu, 29 Oct 2020 18:18:52 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMYbv0GCjz46Xb; Thu, 29 Oct 2020 18:18:50 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.229.168]) by shaw.ca with ESMTPA id YCVakUr75RAWfYCVbkY77n; Thu, 29 Oct 2020 12:18:48 -0600 X-Authority-Analysis: v=2.4 cv=P9aEOgMu c=1 sm=1 tr=0 ts=5f9b0789 a=7AlCcx2GqMg+lh9P3BclKA==:117 a=7AlCcx2GqMg+lh9P3BclKA==:17 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=afefHYAZSVUA:10 a=6I5d2MoRAAAA:8 a=zfY9hoTtAAAA:8 a=FtSH8AnkAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=K21vTHoHs0vVa7GZ0N4A:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=5hhNq975vnbPBhNyUpu_:22 a=Bk7rEp8Xs0BjyB-fwPJV:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [IPv6:fc00:1:1:1::5b]) by spqr.komquats.com (Postfix) with ESMTPS id 780712FE7; Thu, 29 Oct 2020 11:18:45 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.16.1/8.16.1) with ESMTP id 09TIIjlV049416; Thu, 29 Oct 2020 11:18:45 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <202010291818.09TIIjlV049416@slippy.cwsent.com> X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r367049 - stable/12/libexec/rc/rc.d In-reply-to: <20201029161751.GA2654@kib.kiev.ua> References: <202010260118.09Q1IGo7016376@repo.freebsd.org> <20201029161751.GA2654@kib.kiev.ua> Comments: In-reply-to Konstantin Belousov message dated "Thu, 29 Oct 2020 18:17:51 +0200." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 29 Oct 2020 11:18:45 -0700 X-CMAE-Envelope: MS4xfHId3XnIWLEYXXKKqnW9TzgiWAz+V++/2q2CSu54X+uRa9/ZxQRuJjwH+Xgb4bEbXse7/D6ARt5z78B/krJ2jXK0MQyZwHcaY+QTjVzXMd++VrSRT2i7 bAUP7+XNk61J5SwAiVK9dh0YtEHZeT90jiHxuwC0MotUBoS93q8fxzTVQ19XdZIuzSnbKEE+yJ6rTOADLrb63HDYnIiGvV+ugQyf609a39SSpT7XKfU20FBw NZiJ2uU4b1daIj+t2JGy4Z84pcnGyS/oTpDNkpRLH7mFZkzgaJQUqxknbR6s3WDoygV/HGco24Kc0Zp9x/crD1KnRUnPX+nZgmY/9adaDwLbup+Yk83HLxqy 4a1KxTnoT61LRiWDcpJEbP/4hoPbBw== X-Rspamd-Queue-Id: 4CMYbv0GCjz46Xb X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 64.59.136.139) smtp.mailfrom=cy.schubert@cschubert.com X-Spamd-Result: default: False [-0.89 / 15.00]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[4]; NEURAL_HAM_SHORT(-0.64)[-0.640]; FREEMAIL_TO(0.00)[gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[70.67.229.168:received]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:6327, ipnet:64.59.128.0/20, country:CA]; MIME_TRACE(0.00)[0:+]; RCVD_IN_DNSWL_LOW(-0.10)[64.59.136.139:from]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.84)[-0.841]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-0.70)[-0.704]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[cschubert.com: no valid DMARC record]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_VERYGOOD(0.00)[64.59.136.139:from]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-stable-12,svn-src-stable] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 18:18:52 -0000 In message <20201029161751.GA2654@kib.kiev.ua>, Konstantin Belousov writes: > On Mon, Oct 26, 2020 at 01:18:16AM +0000, Cy Schubert wrote: > > Author: cy > > Date: Mon Oct 26 01:18:15 2020 > > New Revision: 367049 > > URL: https://svnweb.freebsd.org/changeset/base/367049 > > > > Log: > > MFC r366857: > > Destroy cloned interfaces at netif stop, netif restart and shutdown. > > This is especially important during shutdown because a child interface > > of lagg with WOL enabled will not enable WOL at interface shutdown and > > thus no WOL to wake up the device (and machine). > > > > PR: 158734, 109980 > > Reported by: Antonio Huete Jimenez > > Marat N.Afanasyev > > reviewed by: kp > > > > Modified: > > stable/12/libexec/rc/rc.d/netif > > Directory Properties: > > stable/12/ (props changed) > > > > Modified: stable/12/libexec/rc/rc.d/netif > > =========================================================================== > === > > --- stable/12/libexec/rc/rc.d/netif Mon Oct 26 00:37:31 2020 (r36704 > 8) > > +++ stable/12/libexec/rc/rc.d/netif Mon Oct 26 01:18:15 2020 (r36704 > 9) > > @@ -28,7 +28,7 @@ > > # PROVIDE: netif > > # REQUIRE: FILESYSTEMS iovctl serial sppp sysctl > > # REQUIRE: hostid ipfs > > -# KEYWORD: nojailvnet > > +# KEYWORD: nojailvnet shutdown > > > > . /etc/rc.subr > > . /etc/network.subr > After this change, shutdown of my stable/12 router looks like this: > > Stopping devd. > Waiting for PIDS: 1120. > Oct 29 18:09:52 tom minissdpd[1619]: setsockopt(udp, IP_DROP_MEMBERSHIP)(vlan > 1): Can't assign requested address > /etc/rc.shutdown: WARNING: vlan1 does not exist. Skipped. > /etc/rc.shutdown: WARNING: vlan2 does not exist. Skipped. > /etc/rc.shutdown: WARNING: vlan3 does not exist. Skipped. > /etc/rc.shutdown: WARNING: vlan4 does not exist. Skipped. > /etc/rc.shutdown: WARNING: vlan5 does not exist. Skipped. > Stopping Network: lo0 re0 re1 pflog0 gif0. > lo0: flags=8048 metric 0 mtu 16384 > options=680003 > groups: lo > nd6 options=21 > re0: flags=8802 metric 0 mtu 1500 > options=201b > ether e0:d5:5e:50:93:04 > media: Ethernet autoselect (1000baseT ) > status: active > nd6 options=29 > re1: flags=8802 metric 0 mtu 1500 > options=201b > ether e0:d5:5e:50:93:05 > media: Ethernet autoselect (100baseTX ) > status: active > nd6 options=29 > pflog0: flags=100 metric 0 mtu 33160 > groups: pflog > gif0: flags=8010 metric 0 mtu 1280 > options=80000 > tunnel inet 176.36.249.139 --> 216.66.84.46 > groups: gif > nd6 options=21 > Destroyed clone interfaces: gif0. > Writing entropy file: . > . > Terminated > Oct 29 18:09:53 tom syslogd: exiting on signal 15 > pflog0: promiscuous mode disabled > Waiting (max 60 seconds) for system process `vnlru' to stop... done > Waiting (max 60 seconds) for system process `syncer' to stop... > Syncing disks, vnodes remaining... 14 2 2 1 1 1 0 0 0 0 done > The messages are innocuous. We could disable printing of the messages during shutdown though. The patch resolves an issue where one or both interfaces with WOL enabled are members of a lagg(4) and since the lagg(4) is not torn down during shutdown WOL isn't enabled in the NIC prior to power off. This results in no WOL when interfaces are members of a lagg(4). Without the patch my machines with lagg(4) fail to wake on lan after being powered off. Another alternative would be to tear down cloned interfaces in the kernel prior to calling device_shutdown or device_suspend for each physical interface, both of which enable WOL in drivers that support this feature. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. From owner-svn-src-stable-12@freebsd.org Thu Oct 29 18:29:24 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 63AF545A581; Thu, 29 Oct 2020 18:29:24 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMYr42201z47L8; Thu, 29 Oct 2020 18:29:24 +0000 (UTC) (envelope-from brooks@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28805A0F1; Thu, 29 Oct 2020 18:29:24 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09TITOVS034869; Thu, 29 Oct 2020 18:29:24 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09TITNAX034863; Thu, 29 Oct 2020 18:29:23 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202010291829.09TITNAX034863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 29 Oct 2020 18:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367140 - in stable/12/sys: cam dev/nvme kern sys ufs/ffs X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in stable/12/sys: cam dev/nvme kern sys ufs/ffs X-SVN-Commit-Revision: 367140 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 18:29:24 -0000 Author: brooks Date: Thu Oct 29 18:29:22 2020 New Revision: 367140 URL: https://svnweb.freebsd.org/changeset/base/367140 Log: MFC r366911: vmapbuf: don't smuggle address or length in buf Instead, add arguments to vmapbuf. Since this argument is always a pointer use a type of void * and cast to vm_offset_t in vmapbuf. (In CheriBSD we've altered vm_fault_quick_hold_pages to take a pointer and check its bounds.) In no other situtation does b_data contain a user pointer and vmapbuf replaces b_data with the actual mapping. Suggested by: jhb Reviewed by: imp, jhb Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26784 Modified: stable/12/sys/cam/cam_periph.c stable/12/sys/dev/nvme/nvme_ctrlr.c stable/12/sys/kern/vfs_bio.c stable/12/sys/sys/buf.h stable/12/sys/ufs/ffs/ffs_rawread.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/cam_periph.c ============================================================================== --- stable/12/sys/cam/cam_periph.c Thu Oct 29 15:44:44 2020 (r367139) +++ stable/12/sys/cam/cam_periph.c Thu Oct 29 18:29:22 2020 (r367140) @@ -959,12 +959,6 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma */ mapinfo->bp[i] = getpbuf(NULL); - /* put our pointer in the data slot */ - mapinfo->bp[i]->b_data = *data_ptrs[i]; - - /* set the transfer length, we know it's < MAXPHYS */ - mapinfo->bp[i]->b_bufsize = lengths[i]; - /* set the direction */ mapinfo->bp[i]->b_iocmd = (dirs[i] == CAM_DIR_OUT) ? BIO_WRITE : BIO_READ; @@ -977,7 +971,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * into a larger area of VM, or if userland races against * vmapbuf() after the useracc() check. */ - if (vmapbuf(mapinfo->bp[i], 1) < 0) { + if (vmapbuf(mapinfo->bp[i], *data_ptrs[i], lengths[i], 1) < 0) { relpbuf(mapinfo->bp[i], NULL); goto fail; } Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Oct 29 15:44:44 2020 (r367139) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Oct 29 18:29:22 2020 (r367140) @@ -1232,10 +1232,8 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr */ PHOLD(curproc); buf = getpbuf(NULL); - buf->b_data = pt->buf; - buf->b_bufsize = pt->len; buf->b_iocmd = pt->is_read ? BIO_READ : BIO_WRITE; - if (vmapbuf(buf, 1) < 0) { + if (vmapbuf(buf, pt->buf, pt->len, 1) < 0) { ret = EFAULT; goto err; } Modified: stable/12/sys/kern/vfs_bio.c ============================================================================== --- stable/12/sys/kern/vfs_bio.c Thu Oct 29 15:44:44 2020 (r367139) +++ stable/12/sys/kern/vfs_bio.c Thu Oct 29 18:29:22 2020 (r367140) @@ -4912,22 +4912,21 @@ vm_hold_free_pages(struct buf *bp, int newbsize) * This function only works with pager buffers. */ int -vmapbuf(struct buf *bp, int mapbuf) +vmapbuf(struct buf *bp, void *uaddr, size_t len, int mapbuf) { vm_prot_t prot; int pidx; - if (bp->b_bufsize < 0) - return (-1); prot = VM_PROT_READ; if (bp->b_iocmd == BIO_READ) prot |= VM_PROT_WRITE; /* Less backwards than it looks */ if ((pidx = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, - (vm_offset_t)bp->b_data, bp->b_bufsize, prot, bp->b_pages, + (vm_offset_t)uaddr, len, prot, bp->b_pages, btoc(MAXPHYS))) < 0) return (-1); + bp->b_bufsize = len; bp->b_npages = pidx; - bp->b_offset = ((vm_offset_t)bp->b_data) & PAGE_MASK; + bp->b_offset = ((vm_offset_t)uaddr) & PAGE_MASK; if (mapbuf || !unmapped_buf_allowed) { pmap_qenter((vm_offset_t)bp->b_kvabase, bp->b_pages, pidx); bp->b_data = bp->b_kvabase + bp->b_offset; Modified: stable/12/sys/sys/buf.h ============================================================================== --- stable/12/sys/sys/buf.h Thu Oct 29 15:44:44 2020 (r367139) +++ stable/12/sys/sys/buf.h Thu Oct 29 18:29:22 2020 (r367140) @@ -560,7 +560,7 @@ void vfs_bio_set_flags(struct buf *bp, int ioflags); void vfs_bio_set_valid(struct buf *, int base, int size); void vfs_busy_pages(struct buf *, int clear_modify); void vfs_unbusy_pages(struct buf *); -int vmapbuf(struct buf *, int); +int vmapbuf(struct buf *, void *, size_t, int); void vunmapbuf(struct buf *); void relpbuf(struct buf *, int *); void brelvp(struct buf *); Modified: stable/12/sys/ufs/ffs/ffs_rawread.c ============================================================================== --- stable/12/sys/ufs/ffs/ffs_rawread.c Thu Oct 29 15:44:44 2020 (r367139) +++ stable/12/sys/ufs/ffs/ffs_rawread.c Thu Oct 29 18:29:22 2020 (r367140) @@ -218,7 +218,6 @@ ffs_rawread_readahead(struct vnode *vp, bp->b_flags = 0; /* XXX necessary ? */ bp->b_iocmd = BIO_READ; bp->b_iodone = bdone; - bp->b_data = udata; blockno = offset / bsize; blockoff = (offset % bsize) / DEV_BSIZE; if ((daddr_t) blockno != blockno) { @@ -236,9 +235,8 @@ ffs_rawread_readahead(struct vnode *vp, if (bp->b_bcount + blockoff * DEV_BSIZE > bsize) bp->b_bcount = bsize - blockoff * DEV_BSIZE; - bp->b_bufsize = bp->b_bcount; - if (vmapbuf(bp, 1) < 0) + if (vmapbuf(bp, udata, bp->b_bcount, 1) < 0) return EFAULT; maybe_yield(); @@ -255,9 +253,8 @@ ffs_rawread_readahead(struct vnode *vp, if (bp->b_bcount + blockoff * DEV_BSIZE > bsize * (1 + bforwards)) bp->b_bcount = bsize * (1 + bforwards) - blockoff * DEV_BSIZE; - bp->b_bufsize = bp->b_bcount; - if (vmapbuf(bp, 1) < 0) + if (vmapbuf(bp, udata, bp->b_bcount, 1) < 0) return EFAULT; BO_STRATEGY(&dp->v_bufobj, bp); From owner-svn-src-stable-12@freebsd.org Fri Oct 30 00:32:15 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E6C7442BAD; Fri, 30 Oct 2020 00:32:15 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMjtl2pwJz4YRX; Fri, 30 Oct 2020 00:32:15 +0000 (UTC) (envelope-from cy@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4346AE1FB; Fri, 30 Oct 2020 00:32:15 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09U0WFHX063432; Fri, 30 Oct 2020 00:32:15 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09U0WFXD063431; Fri, 30 Oct 2020 00:32:15 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202010300032.09U0WFXD063431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Fri, 30 Oct 2020 00:32:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367154 - in stable: 11/contrib/ipfilter/lib 12/contrib/ipfilter/lib X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/ipfilter/lib 12/contrib/ipfilter/lib X-SVN-Commit-Revision: 367154 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 00:32:15 -0000 Author: cy Date: Fri Oct 30 00:32:14 2020 New Revision: 367154 URL: https://svnweb.freebsd.org/changeset/base/367154 Log: MFC r367069: Continued ipfilter #ifdef cleanup. The r343701 log entry contains a complete description. Modified: stable/12/contrib/ipfilter/lib/kmem.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/ipfilter/lib/kmem.h Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/ipfilter/lib/kmem.h ============================================================================== --- stable/12/contrib/ipfilter/lib/kmem.h Fri Oct 30 00:06:36 2020 (r367153) +++ stable/12/contrib/ipfilter/lib/kmem.h Fri Oct 30 00:32:14 2020 (r367154) @@ -21,7 +21,7 @@ extern int openkmem __P((char *, char *)); extern int kmemcpy __P((char *, long, int)); extern int kstrncpy __P((char *, long, int)); -#if defined(__NetBSD__) || defined(__OpenBSD) +#if defined(__NetBSD__) # include #endif From owner-svn-src-stable-12@freebsd.org Fri Oct 30 00:34:41 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3BB4B442FE3; Fri, 30 Oct 2020 00:34:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMjxY0s7yz4YFM; Fri, 30 Oct 2020 00:34:41 +0000 (UTC) (envelope-from cy@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 00E17E703; Fri, 30 Oct 2020 00:34:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09U0Yegr063636; Fri, 30 Oct 2020 00:34:40 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09U0YeS1063635; Fri, 30 Oct 2020 00:34:40 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202010300034.09U0YeS1063635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Fri, 30 Oct 2020 00:34:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367155 - in stable: 10/contrib/ipfilter/man 11/contrib/ipfilter/man 12/contrib/ipfilter/man X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/contrib/ipfilter/man 11/contrib/ipfilter/man 12/contrib/ipfilter/man X-SVN-Commit-Revision: 367155 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 00:34:41 -0000 Author: cy Date: Fri Oct 30 00:34:40 2020 New Revision: 367155 URL: https://svnweb.freebsd.org/changeset/base/367155 Log: MFC r367070: Remove a random equal sign from the example. It should not be there. It's a syntax error. PR: 210303 Reported by: leventelist at gmail.com Modified: stable/12/contrib/ipfilter/man/ipf.5 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/10/contrib/ipfilter/man/ipf.5 stable/11/contrib/ipfilter/man/ipf.5 Directory Properties: stable/10/ (props changed) stable/11/ (props changed) Modified: stable/12/contrib/ipfilter/man/ipf.5 ============================================================================== --- stable/12/contrib/ipfilter/man/ipf.5 Fri Oct 30 00:32:14 2020 (r367154) +++ stable/12/contrib/ipfilter/man/ipf.5 Fri Oct 30 00:34:40 2020 (r367155) @@ -355,7 +355,7 @@ block in proto tcp from any port >= 1024 to any port < pass in proto tcp from 10.1.0.0/24 to any port = 22 block out proto udp from any to 10.1.1.1 port = 135 pass in proto udp from 1.1.1.1 port = 123 to 10.1.1.1 port = 123 -pass in proto tcp from 127.0.0.0/8 to any port = 6000:6009 +pass in proto tcp from 127.0.0.0/8 to any port 6000:6009 .fi .PP If there is no desire to mention any specific source or destintion From owner-svn-src-stable-12@freebsd.org Fri Oct 30 08:05:48 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E18B44B166; Fri, 30 Oct 2020 08:05:48 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CMvy43kFCz4tqN; Fri, 30 Oct 2020 08:05:48 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5EDD21383E; Fri, 30 Oct 2020 08:05:48 +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 09U85mjf038893; Fri, 30 Oct 2020 08:05:48 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09U85mCo038892; Fri, 30 Oct 2020 08:05:48 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202010300805.09U85mCo038892@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 30 Oct 2020 08:05:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367157 - stable/12/sys/fs/cuse X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/fs/cuse X-SVN-Commit-Revision: 367157 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 08:05:48 -0000 Author: hselasky Date: Fri Oct 30 08:05:47 2020 New Revision: 367157 URL: https://svnweb.freebsd.org/changeset/base/367157 Log: MFC r366961: Fix for loading cuse.ko via rc.d . Make sure we declare the cuse(3) module by name and not only by the version information, so that "kldstat -q -m cuse" works. Found by: Goran Mekic Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: stable/12/sys/fs/cuse/cuse.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/cuse/cuse.c ============================================================================== --- stable/12/sys/fs/cuse/cuse.c Fri Oct 30 06:30:46 2020 (r367156) +++ stable/12/sys/fs/cuse/cuse.c Fri Oct 30 08:05:47 2020 (r367157) @@ -64,6 +64,24 @@ #include #include +static int +cuse_modevent(module_t mod, int type, void *data) +{ + switch (type) { + case MOD_LOAD: + case MOD_UNLOAD: + return (0); + default: + return (EOPNOTSUPP); + } +} + +static moduledata_t cuse_mod = { + .name = "cuse", + .evhand = &cuse_modevent, +}; + +DECLARE_MODULE(cuse, cuse_mod, SI_SUB_DEVFS, SI_ORDER_FIRST); MODULE_VERSION(cuse, 1); /* From owner-svn-src-stable-12@freebsd.org Fri Oct 30 14:37:52 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9924845380B; Fri, 30 Oct 2020 14:37:52 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CN4fS3WWlz43Bw; Fri, 30 Oct 2020 14:37:52 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 57322181D3; Fri, 30 Oct 2020 14:37:52 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09UEbqQI079246; Fri, 30 Oct 2020 14:37:52 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09UEbq4S079245; Fri, 30 Oct 2020 14:37:52 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202010301437.09UEbq4S079245@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 30 Oct 2020 14:37:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367168 - stable/12/usr.sbin/rtsold X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/usr.sbin/rtsold X-SVN-Commit-Revision: 367168 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 14:37:52 -0000 Author: markj Date: Fri Oct 30 14:37:51 2020 New Revision: 367168 URL: https://svnweb.freebsd.org/changeset/base/367168 Log: MFC r366972: rtsold: Remove an incorrect __unused annotation Modified: stable/12/usr.sbin/rtsold/cap_script.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/rtsold/cap_script.c ============================================================================== --- stable/12/usr.sbin/rtsold/cap_script.c Fri Oct 30 14:34:51 2020 (r367167) +++ stable/12/usr.sbin/rtsold/cap_script.c Fri Oct 30 14:37:51 2020 (r367168) @@ -207,7 +207,7 @@ script_command(const char *cmd, const nvlist_t *limits } static int -script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits __unused) +script_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits) { const char *name; void *cookie; From owner-svn-src-stable-12@freebsd.org Fri Oct 30 14:38:18 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 190944530F2; Fri, 30 Oct 2020 14:38:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CN4fx6ytvz43NT; Fri, 30 Oct 2020 14:38:17 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2A7C17D50; Fri, 30 Oct 2020 14:38:17 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09UEcH72079316; Fri, 30 Oct 2020 14:38:17 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09UEcHdI079315; Fri, 30 Oct 2020 14:38:17 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202010301438.09UEcHdI079315@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 30 Oct 2020 14:38:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367169 - stable/12/sys/dev/ntb X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/ntb X-SVN-Commit-Revision: 367169 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 14:38:18 -0000 Author: markj Date: Fri Oct 30 14:38:17 2020 New Revision: 367169 URL: https://svnweb.freebsd.org/changeset/base/367169 Log: MFC r366968: ntb: Fix an assertion to permit >= 32 doorbells Modified: stable/12/sys/dev/ntb/ntb_transport.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/12/sys/dev/ntb/ntb_transport.c Fri Oct 30 14:37:51 2020 (r367168) +++ stable/12/sys/dev/ntb/ntb_transport.c Fri Oct 30 14:38:17 2020 (r367169) @@ -355,7 +355,7 @@ ntb_transport_attach(device_t dev) spad_count = ntb_spad_count(dev); db_bitmap = ntb_db_valid_mask(dev); db_count = flsll(db_bitmap); - KASSERT(db_bitmap == (1 << db_count) - 1, + KASSERT(db_bitmap == ((uint64_t)1 << db_count) - 1, ("Doorbells are not sequential (%jx).\n", db_bitmap)); if (nt->mw_count == 0) { From owner-svn-src-stable-12@freebsd.org Fri Oct 30 14:40:49 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2164F45384A; Fri, 30 Oct 2020 14:40:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CN4js06lpz43pf; Fri, 30 Oct 2020 14:40:49 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC18517B6B; Fri, 30 Oct 2020 14:40:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09UEemwO079512; Fri, 30 Oct 2020 14:40:48 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09UEem3Y079511; Fri, 30 Oct 2020 14:40:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202010301440.09UEem3Y079511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 30 Oct 2020 14:40:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367170 - stable/12/share/man/man9 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/share/man/man9 X-SVN-Commit-Revision: 367170 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 14:40:49 -0000 Author: markj Date: Fri Oct 30 14:40:48 2020 New Revision: 367170 URL: https://svnweb.freebsd.org/changeset/base/367170 Log: MFC r366970: Add some missing nv(9) MLINKS Modified: stable/12/share/man/man9/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man9/Makefile ============================================================================== --- stable/12/share/man/man9/Makefile Fri Oct 30 14:38:17 2020 (r367169) +++ stable/12/share/man/man9/Makefile Fri Oct 30 14:40:48 2020 (r367170) @@ -1483,6 +1483,11 @@ MLINKS+=nv.9 libnv.9 \ nv.9 nvlist_add_stringf.9 \ nv.9 nvlist_add_stringv.9 \ nv.9 nvlist_add_string_array.9 \ + nv.9 nvlist_append_bool_array.9 \ + nv.9 nvlist_append_descriptor_array.9 \ + nv.9 nvlist_append_nvlist_array.9 \ + nv.9 nvlist_append_number_array.9 \ + nv.9 nvlist_append_string_array.9 \ nv.9 nvlist_clone.9 \ nv.9 nvlist_create.9 \ nv.9 nvlist_destroy.9 \ From owner-svn-src-stable-12@freebsd.org Fri Oct 30 14:41:22 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 00C564536EA; Fri, 30 Oct 2020 14:41:22 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CN4kT6D63z43qb; Fri, 30 Oct 2020 14:41:21 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9EE717D5C; Fri, 30 Oct 2020 14:41:21 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09UEfL7o080339; Fri, 30 Oct 2020 14:41:21 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09UEfKCB080331; Fri, 30 Oct 2020 14:41:20 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202010301441.09UEfKCB080331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 30 Oct 2020 14:41:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367171 - in stable/12/usr.bin/col: . tests X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/usr.bin/col: . tests X-SVN-Commit-Revision: 367171 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 14:41:22 -0000 Author: markj Date: Fri Oct 30 14:41:19 2020 New Revision: 367171 URL: https://svnweb.freebsd.org/changeset/base/367171 Log: MFC r366577: col(1): Fix a couple of bugs PR: 249308 Added: stable/12/usr.bin/col/tests/hlf.in - copied unchanged from r366577, head/usr.bin/col/tests/hlf.in stable/12/usr.bin/col/tests/hlf2.in - copied unchanged from r366577, head/usr.bin/col/tests/hlf2.in stable/12/usr.bin/col/tests/nl.in - copied unchanged from r366577, head/usr.bin/col/tests/nl.in stable/12/usr.bin/col/tests/nl2.in - copied unchanged from r366577, head/usr.bin/col/tests/nl2.in stable/12/usr.bin/col/tests/nl3.in - copied unchanged from r366577, head/usr.bin/col/tests/nl3.in stable/12/usr.bin/col/tests/rlf3.in - copied unchanged from r366577, head/usr.bin/col/tests/rlf3.in Modified: stable/12/usr.bin/col/col.c stable/12/usr.bin/col/tests/Makefile stable/12/usr.bin/col/tests/col_test.sh (contents, props changed) Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/col/col.c ============================================================================== --- stable/12/usr.bin/col/col.c Fri Oct 30 14:40:48 2020 (r367170) +++ stable/12/usr.bin/col/col.c Fri Oct 30 14:41:19 2020 (r367171) @@ -100,7 +100,7 @@ struct line_str { }; static void addto_lineno(int *, int); -static LINE *alloc_line(void); +static LINE *alloc_line(void); static void dowarn(int); static void flush_line(LINE *); static void flush_lines(int); @@ -109,7 +109,7 @@ static void free_line(LINE *); static void usage(void); static CSET last_set; /* char_set of last char printed */ -static LINE *lines; +static LINE *lines; static int compress_spaces; /* if doing space -> tab conversion */ static int fine; /* if `fine' resolution (half lines) */ static int max_bufd_lines; /* max # of half lines to keep in memory */ @@ -340,8 +340,16 @@ main(int argc, char **argv) } if (ferror(stdin)) err(1, NULL); - if (extra_lines) + if (extra_lines) { + /* + * Extra lines only exist if no lines have been flushed + * yet. This means that 'lines' must point to line zero + * after we flush the extra lines. + */ flush_lines(extra_lines); + l = lines; + this_line = 0; + } /* goto the last line that had a character on it */ for (; l->l_next; l = l->l_next) @@ -353,14 +361,22 @@ main(int argc, char **argv) PUTC(SI); /* flush out the last few blank lines */ - if (max_line > this_line) - nblank_lines = max_line - this_line; - if (max_line & 1) - nblank_lines++; + if (max_line >= this_line) + nblank_lines = max_line - this_line + (max_line & 1); + if (nblank_lines == 0) + /* end with a newline even if the source doesn't */ + nblank_lines = 2; flush_blanks(); exit(0); } +/* + * Prints the first 'nflush' lines. Printed lines are freed. + * After this function returns, 'lines' points to the first + * of the remaining lines, and 'nblank_lines' will have the + * number of half line feeds between the final flushed line + * and the first remaining line. + */ static void flush_lines(int nflush) { @@ -372,11 +388,10 @@ flush_lines(int nflush) if (l->l_line) { flush_blanks(); flush_line(l); + free(l->l_line); } - if (l->l_line || l->l_next) + if (l->l_next) nblank_lines++; - if (l->l_line) - (void)free(l->l_line); free_line(l); } if (lines) @@ -384,9 +399,8 @@ flush_lines(int nflush) } /* - * Print a number of newline/half newlines. If fine flag is set, nblank_lines - * is the number of half line feeds, otherwise it is the number of whole line - * feeds. + * Print a number of newline/half newlines. + * nblank_lines is the number of half line feeds. */ static void flush_blanks(void) Modified: stable/12/usr.bin/col/tests/Makefile ============================================================================== --- stable/12/usr.bin/col/tests/Makefile Fri Oct 30 14:40:48 2020 (r367170) +++ stable/12/usr.bin/col/tests/Makefile Fri Oct 30 14:41:19 2020 (r367171) @@ -4,8 +4,14 @@ PACKAGE= tests ATF_TESTS_SH= col_test -${PACKAGE}FILES+= \ +${PACKAGE}FILES+= \ + hlf.in \ + hlf2.in \ + nl.in \ + nl2.in \ + nl3.in \ rlf.in \ - rlf2.in + rlf2.in \ + rlf3.in .include Modified: stable/12/usr.bin/col/tests/col_test.sh ============================================================================== --- stable/12/usr.bin/col/tests/col_test.sh Fri Oct 30 14:40:48 2020 (r367170) +++ stable/12/usr.bin/col/tests/col_test.sh Fri Oct 30 14:41:19 2020 (r367171) @@ -1,5 +1,44 @@ # $FreeBSD$ +atf_test_case nl + +nl_head() +{ + atf_set "descr" "testing just newlines" +} +nl_body() +{ + atf_check \ + -o inline:"a\nb\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/nl.in + + atf_check \ + -o inline:"a\nb\n" \ + -e empty \ + -s exit:0 \ + col -f < $(atf_get_srcdir)/nl.in + + atf_check \ + -o inline:"a\nb\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/nl2.in + + atf_check \ + -o inline:"a\nb\n" \ + -e empty \ + -s exit:0 \ + col -f < $(atf_get_srcdir)/nl2.in + + atf_check \ + -o inline:"a\n\nb\n\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/nl3.in +} + atf_test_case rlf rlf_head() @@ -25,9 +64,53 @@ rlf_body() -e empty \ -s exit:0 \ col -x < $(atf_get_srcdir)/rlf2.in + + atf_check \ + -o inline:" b\na\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/rlf3.in } +atf_test_case hlf + +hlf_head() +{ + atf_set "descr" "testing half line feed" +} +hlf_body() +{ + atf_check \ + -o inline:"a f\naf\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/hlf.in + + atf_check \ + -o inline:"a f9 + f9 +a\n" \ + -e empty \ + -s exit:0 \ + col -f < $(atf_get_srcdir)/hlf.in + + atf_check \ + -o inline:"a\n f\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/hlf2.in + + atf_check \ + -o inline:"a9 + f\n9" \ + -e empty \ + -s exit:0 \ + col -f < $(atf_get_srcdir)/hlf2.in +} + atf_init_test_cases() { + atf_add_test_case nl atf_add_test_case rlf + atf_add_test_case hlf } Copied: stable/12/usr.bin/col/tests/hlf.in (from r366577, head/usr.bin/col/tests/hlf.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/hlf.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/hlf.in) @@ -0,0 +1,2 @@ +a +a8f8f Copied: stable/12/usr.bin/col/tests/hlf2.in (from r366577, head/usr.bin/col/tests/hlf2.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/hlf2.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/hlf2.in) @@ -0,0 +1 @@ +a9f Copied: stable/12/usr.bin/col/tests/nl.in (from r366577, head/usr.bin/col/tests/nl.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/nl.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/nl.in) @@ -0,0 +1,2 @@ +a +b Copied: stable/12/usr.bin/col/tests/nl2.in (from r366577, head/usr.bin/col/tests/nl2.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/nl2.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/nl2.in) @@ -0,0 +1,2 @@ +a +b \ No newline at end of file Copied: stable/12/usr.bin/col/tests/nl3.in (from r366577, head/usr.bin/col/tests/nl3.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/nl3.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/nl3.in) @@ -0,0 +1,4 @@ +a + +b + Copied: stable/12/usr.bin/col/tests/rlf3.in (from r366577, head/usr.bin/col/tests/rlf3.in) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/col/tests/rlf3.in Fri Oct 30 14:41:19 2020 (r367171, copy of r366577, head/usr.bin/col/tests/rlf3.in) @@ -0,0 +1 @@ +a b From owner-svn-src-stable-12@freebsd.org Sat Oct 31 11:56:14 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6586444990A; Sat, 31 Oct 2020 11:56:14 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNd1T601fz4N2m; Sat, 31 Oct 2020 11:56:13 +0000 (UTC) (envelope-from gbe@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 874AF27414; Sat, 31 Oct 2020 11:56:13 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VBuDA3069697; Sat, 31 Oct 2020 11:56:13 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VBuDIH069696; Sat, 31 Oct 2020 11:56:13 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202010311156.09VBuDIH069696@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Sat, 31 Oct 2020 11:56:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367197 - stable/12/share/man/man5 X-SVN-Group: stable-12 X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: stable/12/share/man/man5 X-SVN-Commit-Revision: 367197 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 11:56:14 -0000 Author: gbe (doc committer) Date: Sat Oct 31 11:56:13 2020 New Revision: 367197 URL: https://svnweb.freebsd.org/changeset/base/367197 Log: MFC r358891, r358894, r359454, r359513, r359550 and r359556 elf(5) Updates: - start documenting ELF note sections - Remove extra Sy from table header - table markup fixes - add definitions of FreeBSD notes - minor update to FreeBSD ELF note descriptions - correct and expand NT_FREEBSD_NOINIT_TAG description - expand on NT_FREEBSD_FEATURE_CTL bit definitions Reviewed by: emaste Approved by: emaste Modified: stable/12/share/man/man5/elf.5 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man5/elf.5 ============================================================================== --- stable/12/share/man/man5/elf.5 Sat Oct 31 11:44:10 2020 (r367196) +++ stable/12/share/man/man5/elf.5 Sat Oct 31 11:56:13 2020 (r367197) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 18, 2005 +.Dd March 11, 2020 .Dt ELF 5 .Os .Sh NAME @@ -1275,6 +1275,55 @@ member. .It Dv r_addend This member specifies a constant addend used to compute the value to be stored into the relocatable field. +.El +.Ss Note Section +ELF note sections consist of entries with the following format: +.Bl -column -offset indent "namesz" "32 bits" "Null-terminated originator name" +.Sy Field Ta Sy Size Ta Sy Description +.It Va namesz Ta 32 bits Ta Size of "name" +.It Va descsz Ta 32 bits Ta Size of "desc" +.It Va type Ta 32 bits Ta OS-dependent note type +.It Va name Ta Va namesz Ta Null-terminated originator name +.It Va desc Ta Va descsz Ta OS-dependent note data +.El +.Pp +The +.Va name +and +.Va desc +fields are padded to ensure 4-byte alignemnt. +.Va namesz +and +.Va descsz +specify the unpadded length. +.Pp +.Fx +defines the following ELF note types +.Po with corresponding interpretation of +.Va desc Pc : +.Bl -tag -width 4n +.It Dv NT_FREEBSD_ABI_TAG Pq Value: 1 +Indicates the OS ABI version in a form of a 32-bit integer containing expected +ABI version +.Po i.e., +.Dv __FreeBSD_version Pc . +.It Dv NT_FREEBSD_NOINIT_TAG Pq Value: 2 +Indicates that the C startup does not call initialization routines, and thus +.Xr rtld 1 +must do so. +.Va desc +is ignored. +.It Dv NT_FREEBSD_ARCH_TAG Pq Value: 3 +Contains the MACHINE_ARCH that the executable was built for. +.It Dv NT_FREEBSD_FEATURE_CTL Pq Value: 4 +Contains a bitmask of mitigations and features to enable: +.Bl -column "NT_FREEBSD_FCTL_PROTMAX_DISABLE" "0x00" "Disable implicit PROT_MAX" +.Sy Name Ta Sy Value Ta Sy Description +.It NT_FREEBSD_FCTL_ASLR_DISABLE Ta 0x01 Ta Disable ASLR +.It NT_FREEBSD_FCTL_PROTMAX_DISABLE Ta 0x02 Ta Disable implicit PROT_MAX +.It NT_FREEBSD_FCTL_STKGAP_DISABLE Ta 0x04 Ta Disable stack gap +.It NT_FREEBSD_FCTL_WXNEEDED Ta 0x08 Ta Binary makes W+X mappings +.El .El .Sh SEE ALSO .Xr as 1 , From owner-svn-src-stable-12@freebsd.org Sat Oct 31 12:05:01 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3622344A90D; Sat, 31 Oct 2020 12:05:01 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNdCd0kwqz4PDy; Sat, 31 Oct 2020 12:05:01 +0000 (UTC) (envelope-from gbe@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ECD4526F79; Sat, 31 Oct 2020 12:05:00 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VC50YN075824; Sat, 31 Oct 2020 12:05:00 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VC50n1075823; Sat, 31 Oct 2020 12:05:00 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202010311205.09VC50n1075823@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Sat, 31 Oct 2020 12:05:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367198 - stable/12/share/man/man5 X-SVN-Group: stable-12 X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: stable/12/share/man/man5 X-SVN-Commit-Revision: 367198 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 12:05:01 -0000 Author: gbe (doc committer) Date: Sat Oct 31 12:05:00 2020 New Revision: 367198 URL: https://svnweb.freebsd.org/changeset/base/367198 Log: MFC r359608, r359611 elf(5) Updates - expand on NT_FREEBSD_FEATURE_CTL bit definitions - remove commented out leftovers Modified: stable/12/share/man/man5/elf.5 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man5/elf.5 ============================================================================== --- stable/12/share/man/man5/elf.5 Sat Oct 31 11:56:13 2020 (r367197) +++ stable/12/share/man/man5/elf.5 Sat Oct 31 12:05:00 2020 (r367198) @@ -1317,12 +1317,22 @@ is ignored. Contains the MACHINE_ARCH that the executable was built for. .It Dv NT_FREEBSD_FEATURE_CTL Pq Value: 4 Contains a bitmask of mitigations and features to enable: -.Bl -column "NT_FREEBSD_FCTL_PROTMAX_DISABLE" "0x00" "Disable implicit PROT_MAX" -.Sy Name Ta Sy Value Ta Sy Description -.It NT_FREEBSD_FCTL_ASLR_DISABLE Ta 0x01 Ta Disable ASLR -.It NT_FREEBSD_FCTL_PROTMAX_DISABLE Ta 0x02 Ta Disable implicit PROT_MAX -.It NT_FREEBSD_FCTL_STKGAP_DISABLE Ta 0x04 Ta Disable stack gap -.It NT_FREEBSD_FCTL_WXNEEDED Ta 0x08 Ta Binary makes W+X mappings +.Bl -tag -width 4n +.It NT_FREEBSD_FCTL_ASLR_DISABLE Pq Value: 0x01 +Request that address randomization (ASLR) not be performed. +See +.Xr security 7 . +.It NT_FREEBSD_FCTL_PROTMAX_DISABLE Pq Value: 0x02 +Request that +.Xr mmap 2 +calls not set PROT_MAX to the initial value of the +.Fa prot +argument. +.It NT_FREEBSD_FCTL_STKGAP_DISABLE Pq Value: 0x04 +Disable stack gap. +.It NT_FREEBSD_FCTL_WXNEEDED Pq Value: 0x08 +Indicate that the binary requires mappings that are simultaneously +writeable and executable. .El .El .Sh SEE ALSO From owner-svn-src-stable-12@freebsd.org Sat Oct 31 12:36:09 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67DB244B532; Sat, 31 Oct 2020 12:36:09 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNdvY1vqkz4Qr0; Sat, 31 Oct 2020 12:36:09 +0000 (UTC) (envelope-from gbe@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2126527C85; Sat, 31 Oct 2020 12:36:09 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VCa8G3094373; Sat, 31 Oct 2020 12:36:08 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VCa8mW094371; Sat, 31 Oct 2020 12:36:08 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202010311236.09VCa8mW094371@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Sat, 31 Oct 2020 12:36:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367200 - stable/12/share/man/man5 X-SVN-Group: stable-12 X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: stable/12/share/man/man5 X-SVN-Commit-Revision: 367200 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 12:36:09 -0000 Author: gbe (doc committer) Date: Sat Oct 31 12:36:08 2020 New Revision: 367200 URL: https://svnweb.freebsd.org/changeset/base/367200 Log: MFC r359731: Add a basic manpage for smbfs(5) Added: stable/12/share/man/man5/smbfs.5 - copied unchanged from r359731, head/share/man/man5/smbfs.5 Modified: stable/12/share/man/man5/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man5/Makefile ============================================================================== --- stable/12/share/man/man5/Makefile Sat Oct 31 12:10:43 2020 (r367199) +++ stable/12/share/man/man5/Makefile Sat Oct 31 12:36:08 2020 (r367200) @@ -65,6 +65,7 @@ MAN= acct.5 \ resolver.5 \ services.5 \ shells.5 \ + smbfs.5 \ src.conf.5 \ stab.5 \ style.Makefile.5 \ Copied: stable/12/share/man/man5/smbfs.5 (from r359731, head/share/man/man5/smbfs.5) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man5/smbfs.5 Sat Oct 31 12:36:08 2020 (r367200, copy of r359731, head/share/man/man5/smbfs.5) @@ -0,0 +1,79 @@ +.\" Copyright (c) 2020 Gordon Bergling +.\" +.\" 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 April 8, 2020 +.Dt SMBFS 5 +.Os +.Sh NAME +.Nm smbfs +.Nd "SMB FS" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "option NETSMB" +.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 +smbfs_load="YES" +.Ed +.Sh DESCRIPTION +The SMB driver is an implementation of the CIFS (Common Internet Filesystem) +network protocol. +.Sh SEE ALSO +.Xr smbutil 1 , +.Xr mount_smbfs 8 +.Sh STANDARDS +.Rs +.%U https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/ +.%T Common Internet File System (CIFS) Protocol +.%R MS-CIFS +.%D December 2018 +.Re +.Pp +.Rs +.%U https://tools.ietf.org/html/draft-heizer-cifs-v1-spec-00 +.%T Common Internet File System Protocol (CIFS/1.0) +.%D June 13, 1996 +.%A I. Heizer +.%A P. Leach +.%A D. Perry +.Re +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 4.4 . +.Sh AUTHORS +The +.Nm +device driver was written by +.An Boris Popov Aq Mt bp@FreeBSD.org . +The manual page was contributed by +.An Gordon Bergling Aq Mt gbergling@gmail.com . From owner-svn-src-stable-12@freebsd.org Sat Oct 31 12:37:27 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78B8844B456; Sat, 31 Oct 2020 12:37:27 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNdx32b0mz4RCp; Sat, 31 Oct 2020 12:37:27 +0000 (UTC) (envelope-from gbe@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BA57279A2; Sat, 31 Oct 2020 12:37:27 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VCbRQx094481; Sat, 31 Oct 2020 12:37:27 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VCbQxH094477; Sat, 31 Oct 2020 12:37:26 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202010311237.09VCbQxH094477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Sat, 31 Oct 2020 12:37:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367201 - in stable/12/share/man: man4 man5 X-SVN-Group: stable-12 X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: in stable/12/share/man: man4 man5 X-SVN-Commit-Revision: 367201 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 12:37:27 -0000 Author: gbe (doc committer) Date: Sat Oct 31 12:37:26 2020 New Revision: 367201 URL: https://svnweb.freebsd.org/changeset/base/367201 Log: MFC r367091: Use my FreeBSD.org mail address in man pages I have written Modified: stable/12/share/man/man4/smbios.4 stable/12/share/man/man5/smbfs.5 stable/12/share/man/man5/unionfs.5 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/smbios.4 ============================================================================== --- stable/12/share/man/man4/smbios.4 Sat Oct 31 12:36:08 2020 (r367200) +++ stable/12/share/man/man4/smbios.4 Sat Oct 31 12:37:26 2020 (r367201) @@ -62,4 +62,4 @@ The device driver was written by .An Matthew N. Dodd Aq Mt winter@jurai.net . This manual page was written by -.An Gordon Bergling Aq Mt gbergling@gmail.com . +.An Gordon Bergling Aq Mt gbe@FreeBSD.org . Modified: stable/12/share/man/man5/smbfs.5 ============================================================================== --- stable/12/share/man/man5/smbfs.5 Sat Oct 31 12:36:08 2020 (r367200) +++ stable/12/share/man/man5/smbfs.5 Sat Oct 31 12:37:26 2020 (r367201) @@ -76,4 +76,4 @@ The device driver was written by .An Boris Popov Aq Mt bp@FreeBSD.org . The manual page was contributed by -.An Gordon Bergling Aq Mt gbergling@gmail.com . +.An Gordon Bergling Aq Mt gbe@FreeBSD.org . Modified: stable/12/share/man/man5/unionfs.5 ============================================================================== --- stable/12/share/man/man5/unionfs.5 Sat Oct 31 12:36:08 2020 (r367200) +++ stable/12/share/man/man5/unionfs.5 Sat Oct 31 12:37:26 2020 (r367201) @@ -78,7 +78,7 @@ and reimplemented the handling of the locking for .Fx 7.0 . The manual page was written by -.An Gordon Bergling Aq Mt gbergling@gmail.com . +.An Gordon Bergling Aq Mt gbe@FreeBSD.org . .Sh BUGS Please see the .Xr mount_unionfs 8 From owner-svn-src-stable-12@freebsd.org Sat Oct 31 12:39:23 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3FF9944B635; Sat, 31 Oct 2020 12:39:23 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNdzH0xthz4R5b; Sat, 31 Oct 2020 12:39:23 +0000 (UTC) (envelope-from gbe@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F3C212782B; Sat, 31 Oct 2020 12:39:22 +0000 (UTC) (envelope-from gbe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VCdMAP094613; Sat, 31 Oct 2020 12:39:22 GMT (envelope-from gbe@FreeBSD.org) Received: (from gbe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VCdMit094612; Sat, 31 Oct 2020 12:39:22 GMT (envelope-from gbe@FreeBSD.org) Message-Id: <202010311239.09VCdMit094612@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gbe set sender to gbe@FreeBSD.org using -f From: Gordon Bergling Date: Sat, 31 Oct 2020 12:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367202 - stable/12/share/man/man9 X-SVN-Group: stable-12 X-SVN-Commit-Author: gbe X-SVN-Commit-Paths: stable/12/share/man/man9 X-SVN-Commit-Revision: 367202 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 12:39:23 -0000 Author: gbe (doc committer) Date: Sat Oct 31 12:39:22 2020 New Revision: 367202 URL: https://svnweb.freebsd.org/changeset/base/367202 Log: MFC r366946: socket(9): Remove duplicate word 'is is' Modified: stable/12/share/man/man9/socket.9 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man9/socket.9 ============================================================================== --- stable/12/share/man/man9/socket.9 Sat Oct 31 12:37:26 2020 (r367201) +++ stable/12/share/man/man9/socket.9 Sat Oct 31 12:39:22 2020 (r367202) @@ -378,7 +378,7 @@ or A kernel system can use the .Fn sodtor_set function to set a destructor for a socket. -The destructor is called when the socket is is about to be freed. +The destructor is called when the socket is about to be freed. The destructor is called before the protocol detach routine. The destructor can serve as a callback to initiate additional cleanup actions. .Ss Socket I/O From owner-svn-src-stable-12@freebsd.org Sat Oct 31 14:56:17 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E123A44DF0D; Sat, 31 Oct 2020 14:56:17 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNj1F5rLLz4X8m; Sat, 31 Oct 2020 14:56:17 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABAB79601; Sat, 31 Oct 2020 14:56:17 +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 09VEuHKD079792; Sat, 31 Oct 2020 14:56:17 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VEuG3U079785; Sat, 31 Oct 2020 14:56:16 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311456.09VEuG3U079785@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 14:56:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367205 - in stable/12/sys: arm/mv arm64/conf conf X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: in stable/12/sys: arm/mv arm64/conf conf X-SVN-Commit-Revision: 367205 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 14:56:17 -0000 Author: mmel Date: Sat Oct 31 14:56:16 2020 New Revision: 367205 URL: https://svnweb.freebsd.org/changeset/base/367205 Log: MFC r353773: Update Armada 8k drivers to cover newly imported DT and latest changes in simple multifunction driver. - follow interrupt changes in DT. Split old ICU driver to function oriented parts and add drivers for newly defined parts (system error interrupts). - Many drivers are children of simple multifunction driver. But after r349596 simple MF driver doesn't longer exports memory resources, and all children must use syscon interface to access their registers. Adapt affected drivers to this fact. Added: stable/12/sys/arm/mv/mv_ap806_sei.c - copied unchanged from r353773, head/sys/arm/mv/mv_ap806_sei.c stable/12/sys/arm/mv/mv_cp110_icu_bus.c - copied unchanged from r353773, head/sys/arm/mv/mv_cp110_icu_bus.c Modified: stable/12/sys/arm/mv/mv_ap806_clock.c stable/12/sys/arm/mv/mv_ap806_gicp.c stable/12/sys/arm/mv/mv_cp110_clock.c stable/12/sys/arm/mv/mv_cp110_icu.c stable/12/sys/arm/mv/mv_thermal.c stable/12/sys/arm/mv/mvebu_pinctrl.c stable/12/sys/arm64/conf/GENERIC stable/12/sys/conf/files.arm64 Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/mv/mv_ap806_clock.c ============================================================================== --- stable/12/sys/arm/mv/mv_ap806_clock.c Sat Oct 31 13:55:10 2020 (r367204) +++ stable/12/sys/arm/mv/mv_ap806_clock.c Sat Oct 31 14:56:16 2020 (r367205) @@ -44,13 +44,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include +#include #include #include -#include +#include "syscon_if.h" + static struct clk_fixed_def ap806_clk_cluster_0 = { .clkdef.id = 0, .clkdef.name = "ap806-cpu-cluster-0", @@ -92,23 +94,19 @@ static struct clk_fixed_def ap806_clk_sdio = { }; struct mv_ap806_clock_softc { - struct simplebus_softc simplebus_sc; device_t dev; - struct resource *res; + struct syscon *syscon; }; -static struct resource_spec mv_ap806_clock_res_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE | RF_SHAREABLE }, - { -1, 0 } -}; + static struct ofw_compat_data compat_data[] = { - {"marvell,ap806-clock", 1}, - {NULL, 0} + {"marvell,ap806-clock", 1}, + {NULL, 0} }; -#define RD4(sc, reg) bus_read_4((sc)->res, (reg)) -#define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) +#define RD4(sc, reg) SYSCON_READ_4((sc)->syscon, (reg)) +#define WR4(sc, reg, val) SYSCON_WRITE_4((sc)->syscon, (reg), (val)) static int mv_ap806_clock_probe(device_t dev) @@ -135,8 +133,9 @@ mv_ap806_clock_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - if (bus_alloc_resources(dev, mv_ap806_clock_res_spec, &sc->res) != 0) { - device_printf(dev, "cannot allocate resources for device\n"); + if (SYSCON_GET_HANDLE(sc->dev, &sc->syscon) != 0 || + sc->syscon == NULL) { + device_printf(dev, "cannot get syscon for device\n"); return (ENXIO); } @@ -160,7 +159,8 @@ mv_ap806_clock_attach(device_t dev) clock_freq = 1333000000; break; default: - device_printf(dev, "Cannot guess clock freq with reg %x\n", reg & 0x1f); + device_printf(dev, "Cannot guess clock freq with reg %x\n", + reg & 0x1f); return (ENXIO); break; }; Modified: stable/12/sys/arm/mv/mv_ap806_gicp.c ============================================================================== --- stable/12/sys/arm/mv/mv_ap806_gicp.c Sat Oct 31 13:55:10 2020 (r367204) +++ stable/12/sys/arm/mv/mv_ap806_gicp.c Sat Oct 31 14:56:16 2020 (r367205) @@ -60,6 +60,7 @@ struct mv_ap806_gicp_softc { ssize_t spi_ranges_cnt; uint32_t *spi_ranges; + struct intr_map_data_fdt *parent_map_data; }; static struct ofw_compat_data compat_data[] = { @@ -96,11 +97,13 @@ mv_ap806_gicp_attach(device_t dev) /* Look for our parent */ if ((intr_parent = ofw_bus_find_iparent(node)) == 0) { - device_printf(dev, "Cannot find our parent interrupt controller\n"); + device_printf(dev, + "Cannot find our parent interrupt controller\n"); return (ENXIO); } if ((sc->parent = OF_device_from_xref(intr_parent)) == NULL) { - device_printf(dev, "cannot find parent interrupt controller device\n"); + device_printf(dev, + "cannot find parent interrupt controller device\n"); return (ENXIO); } @@ -112,7 +115,10 @@ mv_ap806_gicp_attach(device_t dev) device_printf(dev, "Cannot register GICP\n"); return (ENXIO); } - + /* Allocate GIC compatible mapping entry (3 cells) */ + sc->parent_map_data = (struct intr_map_data_fdt *)intr_alloc_map_data( + INTR_MAP_DATA_FDT, sizeof(struct intr_map_data_fdt) + + + 3 * sizeof(phandle_t), M_WAITOK | M_ZERO); OF_device_register_xref(xref, dev); return (0); @@ -125,6 +131,45 @@ mv_ap806_gicp_detach(device_t dev) return (EBUSY); } +static struct intr_map_data * +mv_ap806_gicp_convert_map_data(struct mv_ap806_gicp_softc *sc, + struct intr_map_data *data) +{ + struct intr_map_data_fdt *daf; + uint32_t i, irq_num, irq_type; + + daf = (struct intr_map_data_fdt *)data; + if (daf->ncells != 2) + return (NULL); + + irq_num = daf->cells[0]; + irq_type = daf->cells[1]; + if (irq_num >= MV_AP806_GICP_MAX_NIRQS) + return (NULL); + + /* Construct GIC compatible mapping. */ + sc->parent_map_data->ncells = 3; + sc->parent_map_data->cells[0] = 0; /* SPI */ + sc->parent_map_data->cells[2] = irq_type; + + /* Map the interrupt number to SPI number */ + for (i = 0; i < sc->spi_ranges_cnt / 2; i += 2) { + if (irq_num < sc->spi_ranges[i + 1]) { + irq_num += sc->spi_ranges[i]; + break; + } + + irq_num -= sc->spi_ranges[i]; + } + + sc->parent_map_data->cells[1] = irq_num - 32; + + return ((struct intr_map_data *)sc->parent_map_data); +} + + + + static int mv_ap806_gicp_activate_intr(device_t dev, struct intr_irqsrc *isrc, struct resource *res, struct intr_map_data *data) @@ -132,6 +177,9 @@ mv_ap806_gicp_activate_intr(device_t dev, struct intr_ struct mv_ap806_gicp_softc *sc; sc = device_get_softc(dev); + data = mv_ap806_gicp_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_ACTIVATE_INTR(sc->parent, isrc, res, data)); } @@ -161,36 +209,20 @@ mv_ap806_gicp_map_intr(device_t dev, struct intr_map_d struct intr_irqsrc **isrcp) { struct mv_ap806_gicp_softc *sc; - struct intr_map_data_fdt *daf; - uint32_t group, irq_num, irq_type; - int i; + int ret; sc = device_get_softc(dev); if (data->type != INTR_MAP_DATA_FDT) return (ENOTSUP); - daf = (struct intr_map_data_fdt *)data; - if (daf->ncells != 3 || daf->cells[0] >= MV_AP806_GICP_MAX_NIRQS) + data = mv_ap806_gicp_convert_map_data(sc, data); + if (data == NULL) return (EINVAL); - group = daf->cells[0]; - irq_num = daf->cells[1]; - irq_type = daf->cells[2]; - - /* Map the interrupt number to spi number */ - for (i = 0; i < sc->spi_ranges_cnt / 2; i += 2) { - if (irq_num < sc->spi_ranges[i + 1]) { - irq_num += sc->spi_ranges[i]; - break; - } - - irq_num -= sc->spi_ranges[i]; - } - - daf->cells[1] = irq_num - 32; - - return (PIC_MAP_INTR(sc->parent, data, isrcp)); + ret = PIC_MAP_INTR(sc->parent, data, isrcp); + (*isrcp)->isrc_dev = sc->dev; + return(ret); } static int @@ -201,6 +233,10 @@ mv_ap806_gicp_deactivate_intr(device_t dev, struct int sc = device_get_softc(dev); + data = mv_ap806_gicp_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); + return (PIC_DEACTIVATE_INTR(sc->parent, isrc, res, data)); } @@ -211,6 +247,9 @@ mv_ap806_gicp_setup_intr(device_t dev, struct intr_irq struct mv_ap806_gicp_softc *sc; sc = device_get_softc(dev); + data = mv_ap806_gicp_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_SETUP_INTR(sc->parent, isrc, res, data)); } @@ -222,6 +261,9 @@ mv_ap806_gicp_teardown_intr(device_t dev, struct intr_ struct mv_ap806_gicp_softc *sc; sc = device_get_softc(dev); + data = mv_ap806_gicp_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_TEARDOWN_INTR(sc->parent, isrc, res, data)); } Copied: stable/12/sys/arm/mv/mv_ap806_sei.c (from r353773, head/sys/arm/mv/mv_ap806_sei.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm/mv/mv_ap806_sei.c Sat Oct 31 14:56:16 2020 (r367205, copy of r353773, head/sys/arm/mv/mv_ap806_sei.c) @@ -0,0 +1,419 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include "pic_if.h" + +#define MV_AP806_SEI_LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define MV_AP806_SEI_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define MV_AP806_SEI_LOCK_INIT(_sc) mtx_init(&_sc->mtx, \ + device_get_nameunit(_sc->dev), "mv_ap806_sei", MTX_DEF) +#define MV_AP806_SEI_LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx); +#define MV_AP806_SEI_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED); +#define MV_AP806_SEI_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->mtx, MA_NOTOWNED); + +#define MV_AP806_SEI_MAX_NIRQS 64 +#define GICP_SECR0 0x00 +#define GICP_SECR1 0x04 +#define GICP_SECR(i) (0x00 + (((i)/32) * 0x4)) +#define GICP_SECR_BIT(i) ((i) % 32) +#define GICP_SEMR0 0x20 +#define GICP_SEMR1 0x24 +#define GICP_SEMR(i) (0x20 + (((i)/32) * 0x4)) +#define GICP_SEMR_BIT(i) ((i) % 32) + + + +struct mv_ap806_sei_irqsrc { + struct intr_irqsrc isrc; + u_int irq; +}; + +struct mv_ap806_sei_softc { + device_t dev; + struct resource *mem_res; + struct resource *irq_res; + void *irq_ih; + struct mtx mtx; + + struct mv_ap806_sei_irqsrc *isrcs; +}; + +static struct ofw_compat_data compat_data[] = { + {"marvell,ap806-sei", 1}, + {NULL, 0} +}; + +#define RD4(sc, reg) bus_read_4((sc)->mem_res, (reg)) +#define WR4(sc, reg, val) bus_write_4((sc)->mem_res, (reg), (val)) + +static inline void +mv_ap806_sei_isrc_mask(struct mv_ap806_sei_softc *sc, + struct mv_ap806_sei_irqsrc *sisrc, uint32_t val) +{ + uint32_t tmp; + int bit; + + bit = GICP_SEMR_BIT(sisrc->irq); + MV_AP806_SEI_LOCK(sc); + tmp = RD4(sc, GICP_SEMR(sisrc->irq)); + if (val != 0) + tmp |= 1 << bit; + else + tmp &= ~(1 << bit); + WR4(sc, GICP_SEMR(sisrc->irq), tmp); + MV_AP806_SEI_UNLOCK(sc); +} + +static inline void +mv_ap806_sei_isrc_eoi(struct mv_ap806_sei_softc *sc, + struct mv_ap806_sei_irqsrc *sisrc) +{ + + WR4(sc, GICP_SECR(sisrc->irq), GICP_SECR_BIT(sisrc->irq)); +} + +static void +mv_ap806_sei_enable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + mv_ap806_sei_isrc_mask(sc, sisrc, 0); +} + +static void +mv_ap806_sei_disable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + mv_ap806_sei_isrc_mask(sc, sisrc, 1); +} + +static int +mv_ap806_sei_map(device_t dev, struct intr_map_data *data, u_int *irqp) +{ + struct mv_ap806_sei_softc *sc; + struct intr_map_data_fdt *daf; + u_int irq; + + sc = device_get_softc(dev); + + if (data->type != INTR_MAP_DATA_FDT) + return (ENOTSUP); + + daf = (struct intr_map_data_fdt *)data; + if (daf->ncells != 1 || daf->cells[0] >= MV_AP806_SEI_MAX_NIRQS) + return (EINVAL); + irq = daf->cells[0]; + if (irqp != NULL) + *irqp = irq; + + return(0); +} + +static int +mv_ap806_sei_map_intr(device_t dev, struct intr_map_data *data, + struct intr_irqsrc **isrcp) +{ + struct mv_ap806_sei_softc *sc; + u_int irq; + int rv; + + sc = device_get_softc(dev); + rv = mv_ap806_sei_map(dev, data, &irq); + if (rv == 0) + *isrcp = &sc->isrcs[irq].isrc; + + return (rv); +} + + + +static int +mv_ap806_sei_setup_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + u_int irq; + int rv; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + if (data == NULL) + return (ENOTSUP); + rv = mv_ap806_sei_map(dev, data, &irq); + if (rv != 0) + return (rv); + if (irq != sisrc->irq) + return (EINVAL); + mv_ap806_sei_isrc_mask(sc, sisrc, 0); + return (0); +} + +static int +mv_ap806_sei_teardown_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + + mv_ap806_sei_isrc_mask(sc, sisrc, 1); + return (0); +} + +static void +mv_ap806_sei_pre_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + + mv_ap806_sei_isrc_mask(sc, sisrc, 1); + mv_ap806_sei_isrc_eoi(sc, sisrc); +} + +static void +mv_ap806_sei_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + + mv_ap806_sei_isrc_mask(sc, sisrc, 1); +} + +static void +mv_ap806_sei_post_filter(device_t dev, struct intr_irqsrc *isrc) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sisrc; + + sc = device_get_softc(dev); + sisrc = (struct mv_ap806_sei_irqsrc *)isrc; + + mv_ap806_sei_isrc_mask(sc, sisrc, 1); + mv_ap806_sei_isrc_eoi(sc, sisrc); +} + +/* ---------------------------------------------------------------------------- + * + * B u s i n t e r f a c e + */ +static int +mv_ap806_sei_intr(void *arg) +{ + struct mv_ap806_sei_softc *sc; + struct mv_ap806_sei_irqsrc *sirq; + struct trapframe *tf; + uint64_t cause; + u_int irq; + + sc = (struct mv_ap806_sei_softc *)arg; + tf = curthread->td_intr_frame; + while (1) { + cause = RD4(sc, GICP_SECR1); + cause <<= 32; + cause |= RD4(sc, GICP_SECR0); + + irq = ffsll(cause); + if (irq == 0) break; + irq--; + sirq = &sc->isrcs[irq]; + if (intr_isrc_dispatch(&sirq->isrc, tf) != 0) { + mv_ap806_sei_isrc_mask(sc, sirq, 0); + mv_ap806_sei_isrc_eoi(sc, sirq); + device_printf(sc->dev, + "Stray irq %u disabled\n", irq); + } + } + + return (FILTER_HANDLED); +} + + +static int +mv_ap806_sei_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, "Marvell SEI"); + return (BUS_PROBE_DEFAULT); +} + +static int +mv_ap806_sei_attach(device_t dev) +{ + struct mv_ap806_sei_softc *sc; + phandle_t xref, node; + uint32_t irq; + const char *name; + int rv, rid; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + MV_AP806_SEI_LOCK_INIT(sc); + + /* Allocate resources. */ + 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 allocate memory resources\n"); + rv = ENXIO; + goto fail; + } + + 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 IRQ resources\n"); + rv = ENXIO; + goto fail; + } + + /* Mask all interrupts) */ + WR4(sc, GICP_SEMR0, 0xFFFFFFFF); + WR4(sc, GICP_SEMR1, 0xFFFFFFFF); + + /* Create all interrupt sources */ + sc->isrcs = malloc(sizeof(*sc->isrcs) * MV_AP806_SEI_MAX_NIRQS, + M_DEVBUF, M_WAITOK | M_ZERO); + name = device_get_nameunit(sc->dev); + for (irq = 0; irq < MV_AP806_SEI_MAX_NIRQS; irq++) { + sc->isrcs[irq].irq = irq; + rv = intr_isrc_register(&sc->isrcs[irq].isrc, + sc->dev, 0, "%s,%u", name, irq); + if (rv != 0) + goto fail; /* XXX deregister ISRCs */ + } + xref = OF_xref_from_node(node);; + if (intr_pic_register(dev, xref) == NULL) { + device_printf(dev, "Cannot register SEI\n"); + rv = ENXIO; + goto fail; + } + if (bus_setup_intr(dev, sc->irq_res,INTR_TYPE_MISC | INTR_MPSAFE, + mv_ap806_sei_intr, NULL, sc, &sc->irq_ih)) { + device_printf(dev, + "Unable to register interrupt handler\n"); + rv = ENXIO; + goto fail; + } + + OF_device_register_xref(xref, dev); + return (0); + +fail: + if (sc->irq_ih != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_ih); + 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); + MV_AP806_SEI_LOCK_DESTROY(sc); + return (ENXIO); +} + +static int +mv_ap806_sei_detach(device_t dev) +{ + + return (EBUSY); +} + + +static device_method_t mv_ap806_sei_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, mv_ap806_sei_probe), + DEVMETHOD(device_attach, mv_ap806_sei_attach), + DEVMETHOD(device_detach, mv_ap806_sei_detach), + + /* Interrupt controller interface */ + DEVMETHOD(pic_disable_intr, mv_ap806_sei_disable_intr), + DEVMETHOD(pic_enable_intr, mv_ap806_sei_enable_intr), + DEVMETHOD(pic_map_intr, mv_ap806_sei_map_intr), + DEVMETHOD(pic_setup_intr, mv_ap806_sei_setup_intr), + DEVMETHOD(pic_teardown_intr, mv_ap806_sei_teardown_intr), + DEVMETHOD(pic_post_filter, mv_ap806_sei_post_filter), + DEVMETHOD(pic_post_ithread, mv_ap806_sei_post_ithread), + DEVMETHOD(pic_pre_ithread, mv_ap806_sei_pre_ithread), + + DEVMETHOD_END +}; + +static devclass_t mv_ap806_sei_devclass; + +static driver_t mv_ap806_sei_driver = { + "mv_ap806_sei", + mv_ap806_sei_methods, + sizeof(struct mv_ap806_sei_softc), +}; + +EARLY_DRIVER_MODULE(mv_ap806_sei, simplebus, mv_ap806_sei_driver, + mv_ap806_sei_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); Modified: stable/12/sys/arm/mv/mv_cp110_clock.c ============================================================================== --- stable/12/sys/arm/mv/mv_cp110_clock.c Sat Oct 31 13:55:10 2020 (r367204) +++ stable/12/sys/arm/mv/mv_cp110_clock.c Sat Oct 31 14:56:16 2020 (r367205) @@ -44,17 +44,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include +#include +#include #include #include -#include -#include - #include #include "clkdev_if.h" +#include "syscon_if.h" /* Clocks */ static struct clk_fixed_def cp110_clk_pll_0 = { @@ -126,24 +126,19 @@ static struct cp110_gate cp110_gates[] = { }; struct mv_cp110_clock_softc { - struct simplebus_softc simplebus_sc; device_t dev; - struct resource *res; + struct syscon *syscon; struct mtx mtx; }; -static struct resource_spec mv_cp110_clock_res_spec[] = { - { SYS_RES_MEMORY, 0, RF_ACTIVE | RF_SHAREABLE }, - { -1, 0 } -}; static struct ofw_compat_data compat_data[] = { {"marvell,cp110-clock", 1}, {NULL, 0} }; -#define RD4(sc, reg) bus_read_4((sc)->res, (reg)) -#define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) +#define RD4(sc, reg) SYSCON_READ_4((sc)->syscon, (reg)) +#define WR4(sc, reg, val) SYSCON_WRITE_4((sc)->syscon, (reg), (val)) static char * mv_cp110_clock_name(device_t dev, const char *name) @@ -201,8 +196,9 @@ mv_cp110_clock_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - if (bus_alloc_resources(dev, mv_cp110_clock_res_spec, &sc->res) != 0) { - device_printf(dev, "cannot allocate resources for device\n"); + if (SYSCON_GET_HANDLE(sc->dev, &sc->syscon) != 0 || + sc->syscon == NULL) { + device_printf(dev, "cannot get syscon for device\n"); return (ENXIO); } Modified: stable/12/sys/arm/mv/mv_cp110_icu.c ============================================================================== --- stable/12/sys/arm/mv/mv_cp110_icu.c Sat Oct 31 13:55:10 2020 (r367204) +++ stable/12/sys/arm/mv/mv_cp110_icu.c Sat Oct 31 14:56:16 2020 (r367205) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "pic_if.h" #define ICU_GRP_NSR 0x0 @@ -72,6 +73,7 @@ struct mv_cp110_icu_softc { device_t dev; device_t parent; struct resource *res; + struct intr_map_data_fdt *parent_map_data; }; static struct resource_spec mv_cp110_icu_res_spec[] = { @@ -80,8 +82,9 @@ static struct resource_spec mv_cp110_icu_res_spec[] = }; static struct ofw_compat_data compat_data[] = { - {"marvell,cp110-icu", 1}, - {NULL, 0} + {"marvell,cp110-icu-nsr", 1}, + {"marvell,cp110-icu-sei", 2}, + {NULL, 0} }; #define RD4(sc, reg) bus_read_4((sc)->res, (reg)) @@ -130,6 +133,11 @@ mv_cp110_icu_attach(device_t dev) device_printf(dev, "Cannot register ICU\n"); goto fail; } + + /* Allocate GICP compatible mapping entry (2 cells) */ + sc->parent_map_data = (struct intr_map_data_fdt *)intr_alloc_map_data( + INTR_MAP_DATA_FDT, sizeof(struct intr_map_data_fdt) + + + 3 * sizeof(phandle_t), M_WAITOK | M_ZERO); return (0); fail: @@ -137,6 +145,35 @@ fail: return (ENXIO); } +static struct intr_map_data * +mv_cp110_icu_convert_map_data(struct mv_cp110_icu_softc *sc, struct intr_map_data *data) +{ + struct intr_map_data_fdt *daf; + uint32_t reg, irq_no, irq_type; + + daf = (struct intr_map_data_fdt *)data; + if (daf->ncells != 2) + return (NULL); + irq_no = daf->cells[0]; + irq_type = daf->cells[1]; + if (irq_no >= MV_CP110_ICU_MAX_NIRQS) + return (NULL); + if (irq_type != IRQ_TYPE_LEVEL_HIGH && + irq_type != IRQ_TYPE_EDGE_RISING) + return (NULL); + + /* We rely on fact that ICU->GIC mapping is preset by bootstrap. */ + reg = RD4(sc, ICU_INT_CFG(irq_no)); + + /* Construct GICP compatible mapping. */ + sc->parent_map_data->ncells = 2; + sc->parent_map_data->cells[0] = reg & ICU_INT_MASK; + sc->parent_map_data->cells[1] = irq_type; + + return ((struct intr_map_data *)sc->parent_map_data); +} + + static int mv_cp110_icu_detach(device_t dev) { @@ -151,7 +188,9 @@ mv_cp110_icu_activate_intr(device_t dev, struct intr_i struct mv_cp110_icu_softc *sc; sc = device_get_softc(dev); - + data = mv_cp110_icu_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_ACTIVATE_INTR(sc->parent, isrc, res, data)); } @@ -159,7 +198,6 @@ static void mv_cp110_icu_enable_intr(device_t dev, struct intr_irqsrc *isrc) { struct mv_cp110_icu_softc *sc; - sc = device_get_softc(dev); PIC_ENABLE_INTR(sc->parent, isrc); @@ -175,32 +213,43 @@ mv_cp110_icu_disable_intr(device_t dev, struct intr_ir PIC_DISABLE_INTR(sc->parent, isrc); } + + static int mv_cp110_icu_map_intr(device_t dev, struct intr_map_data *data, struct intr_irqsrc **isrcp) { struct mv_cp110_icu_softc *sc; struct intr_map_data_fdt *daf; - uint32_t reg; + uint32_t reg, irq_no, irq_type; + int ret; sc = device_get_softc(dev); if (data->type != INTR_MAP_DATA_FDT) return (ENOTSUP); + /* Parse original */ daf = (struct intr_map_data_fdt *)data; - if (daf->ncells != 3 || daf->cells[0] >= MV_CP110_ICU_MAX_NIRQS) + if (daf->ncells != 2) return (EINVAL); + irq_no = daf->cells[0]; + irq_type = daf->cells[1]; + data = mv_cp110_icu_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); - reg = RD4(sc, ICU_INT_CFG(daf->cells[1])); + reg = RD4(sc, ICU_INT_CFG(irq_no)); + reg |= ICU_INT_ENABLE; + if (irq_type == IRQ_TYPE_LEVEL_HIGH) + reg &= ~ICU_INT_EDGE; + else + reg |= ICU_INT_EDGE; + WR4(sc, ICU_INT_CFG(irq_no), reg); - if ((reg & ICU_INT_ENABLE) == 0) { - reg |= ICU_INT_ENABLE; - WR4(sc, ICU_INT_CFG(daf->cells[1]), reg); - } - - daf->cells[1] = reg & ICU_INT_MASK; - return (PIC_MAP_INTR(sc->parent, data, isrcp)); + ret = PIC_MAP_INTR(sc->parent, data, isrcp); + (*isrcp)->isrc_dev = sc->dev; + return (ret); } static int @@ -210,6 +259,9 @@ mv_cp110_icu_deactivate_intr(device_t dev, struct intr struct mv_cp110_icu_softc *sc; sc = device_get_softc(dev); + data = mv_cp110_icu_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_DEACTIVATE_INTR(sc->parent, isrc, res, data)); } @@ -221,6 +273,9 @@ mv_cp110_icu_setup_intr(device_t dev, struct intr_irqs struct mv_cp110_icu_softc *sc; sc = device_get_softc(dev); + data = mv_cp110_icu_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_SETUP_INTR(sc->parent, isrc, res, data)); } @@ -232,6 +287,9 @@ mv_cp110_icu_teardown_intr(device_t dev, struct intr_i struct mv_cp110_icu_softc *sc; sc = device_get_softc(dev); + data = mv_cp110_icu_convert_map_data(sc, data); + if (data == NULL) + return (EINVAL); return (PIC_TEARDOWN_INTR(sc->parent, isrc, res, data)); } @@ -295,5 +353,5 @@ static driver_t mv_cp110_icu_driver = { sizeof(struct mv_cp110_icu_softc), }; -EARLY_DRIVER_MODULE(mv_cp110_icu, simplebus, mv_cp110_icu_driver, +EARLY_DRIVER_MODULE(mv_cp110_icu, mv_cp110_icu_bus, mv_cp110_icu_driver, mv_cp110_icu_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); Copied: stable/12/sys/arm/mv/mv_cp110_icu_bus.c (from r353773, head/sys/arm/mv/mv_cp110_icu_bus.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm/mv/mv_cp110_icu_bus.c Sat Oct 31 14:56:16 2020 (r367205, copy of r353773, head/sys/arm/mv/mv_cp110_icu_bus.c) @@ -0,0 +1,78 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 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$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +static struct ofw_compat_data compat_data[] = { + {"marvell,cp110-icu", 1}, + {NULL, 0} +}; + +static int +mv_cp110_icu_bus_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, "Marvell Interrupt Consolidation Unit Bus"); + return (BUS_PROBE_DEFAULT); +} + +static device_method_t mv_cp110_icu_bus_methods[] = { + DEVMETHOD(device_probe, mv_cp110_icu_bus_probe), + + DEVMETHOD_END +}; + +DEFINE_CLASS_1(mv_cp110_icu_bus, mv_cp110_icu_bus_driver, + mv_cp110_icu_bus_methods, sizeof(struct simple_mfd_softc), + simple_mfd_driver); + +static devclass_t mv_cp110_icu_bus_devclass; +EARLY_DRIVER_MODULE(mv_cp110_icu_bus, simplebus, mv_cp110_icu_bus_driver, + mv_cp110_icu_bus_devclass, 0, 0, BUS_PASS_INTERRUPT); +MODULE_VERSION(mv_cp110_icu_bus, 1); Modified: stable/12/sys/arm/mv/mv_thermal.c ============================================================================== --- stable/12/sys/arm/mv/mv_thermal.c Sat Oct 31 13:55:10 2020 (r367204) +++ stable/12/sys/arm/mv/mv_thermal.c Sat Oct 31 14:56:16 2020 (r367205) @@ -44,13 +44,14 @@ __FBSDID("$FreeBSD$"); #include #include *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sat Oct 31 14:59:41 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 451A344DCD0; Sat, 31 Oct 2020 14:59:41 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNj591Mzdz4XCJ; Sat, 31 Oct 2020 14:59:41 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 122CB9596; Sat, 31 Oct 2020 14:59:41 +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 09VExe7Z079995; Sat, 31 Oct 2020 14:59:40 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VExehJ079989; Sat, 31 Oct 2020 14:59:40 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311459.09VExehJ079989@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 14:59:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367206 - in stable/12/sys: conf dev/pci X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: in stable/12/sys: conf dev/pci X-SVN-Commit-Revision: 367206 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 14:59:41 -0000 Author: mmel Date: Sat Oct 31 14:59:39 2020 New Revision: 367206 URL: https://svnweb.freebsd.org/changeset/base/367206 Log: MFC r353774: Add driver for DesignWare PCIE core, and its Armada 8K specific attachement. Added: stable/12/sys/dev/pci/pci_dw.c - copied unchanged from r353774, head/sys/dev/pci/pci_dw.c stable/12/sys/dev/pci/pci_dw.h - copied unchanged from r353774, head/sys/dev/pci/pci_dw.h stable/12/sys/dev/pci/pci_dw_if.m - copied unchanged from r353774, head/sys/dev/pci/pci_dw_if.m stable/12/sys/dev/pci/pci_dw_mv.c - copied unchanged from r353774, head/sys/dev/pci/pci_dw_mv.c Modified: stable/12/sys/conf/files.arm64 Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/files.arm64 ============================================================================== --- stable/12/sys/conf/files.arm64 Sat Oct 31 14:56:16 2020 (r367205) +++ stable/12/sys/conf/files.arm64 Sat Oct 31 14:59:39 2020 (r367206) @@ -288,6 +288,9 @@ dev/ofw/ofwpci.c optional fdt pci dev/pci/pci_host_generic.c optional pci dev/pci/pci_host_generic_acpi.c optional pci acpi dev/pci/pci_host_generic_fdt.c optional pci fdt +dev/pci/pci_dw_mv.c optional pci fdt +dev/pci/pci_dw.c optional pci fdt +dev/pci/pci_dw_if.m optional pci fdt dev/psci/psci.c standard dev/psci/psci_arm64.S standard dev/psci/smccc.c standard Copied: stable/12/sys/dev/pci/pci_dw.c (from r353774, head/sys/dev/pci/pci_dw.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/pci/pci_dw.c Sat Oct 31 14:59:39 2020 (r367206, copy of r353774, head/sys/dev/pci/pci_dw.c) @@ -0,0 +1,697 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * 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. + * + */ + +/* Base class for all Synopsys DesignWare PCI/PCIe drivers */ + +#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 "pcib_if.h" +#include "pci_dw_if.h" + +#define DEBUG +#ifdef DEBUG +#define debugf(fmt, args...) do { printf(fmt,##args); } while (0) +#else +#define debugf(fmt, args...) +#endif + +#define DBI_WR1(sc, reg, val) pci_dw_dbi_wr1((sc)->dev, reg, val) +#define DBI_WR2(sc, reg, val) pci_dw_dbi_wr2((sc)->dev, reg, val) +#define DBI_WR4(sc, reg, val) pci_dw_dbi_wr4((sc)->dev, reg, val) +#define DBI_RD1(sc, reg) pci_dw_dbi_rd1((sc)->dev, reg) +#define DBI_RD2(sc, reg) pci_dw_dbi_rd2((sc)->dev, reg) +#define DBI_RD4(sc, reg) pci_dw_dbi_rd4((sc)->dev, reg) + +#define PCI_BUS_SHIFT 20 +#define PCI_SLOT_SHIFT 15 +#define PCI_FUNC_SHIFT 12 +#define PCI_BUS_MASK 0xFF +#define PCI_SLOT_MASK 0x1F +#define PCI_FUNC_MASK 0x07 +#define PCI_REG_MASK 0xFFF + + +#define IATU_CFG_BUS(bus) ((uint64_t)((bus) & 0xff) << 24) +#define IATU_CFG_SLOT(slot) ((uint64_t)((slot) & 0x1f) << 19) +#define IATU_CFG_FUNC(func) ((uint64_t)((func) & 0x07) << 16) + + + +static uint32_t +pci_dw_dbi_read(device_t dev, u_int reg, int width) +{ + struct pci_dw_softc *sc; + + sc = device_get_softc(dev); + MPASS(sc->dbi_res != NULL); + + switch (width) { + case 4: + return (bus_read_4(sc->dbi_res, reg)); + case 2: + return (bus_read_2(sc->dbi_res, reg)); + case 1: + return (bus_read_1(sc->dbi_res, reg)); + default: + device_printf(sc->dev, "Unsupported width: %d\n", width); + return (0xFFFFFFFF); + } +} + +static void +pci_dw_dbi_write(device_t dev, u_int reg, uint32_t val, int width) +{ + struct pci_dw_softc *sc; + + sc = device_get_softc(dev); + MPASS(sc->dbi_res != NULL); + + switch (width) { + case 4: + bus_write_4(sc->dbi_res, reg, val); + break; + case 2: + bus_write_2(sc->dbi_res, reg, val); + break; + case 1: + bus_write_1(sc->dbi_res, reg, val); + break; + default: + device_printf(sc->dev, "Unsupported width: %d\n", width); + break; + } +} + + +static void +pci_dw_dbi_protect(struct pci_dw_softc *sc, bool protect) +{ + uint32_t reg; + + reg = DBI_RD4(sc, DW_MISC_CONTROL_1); + if (protect) + reg &= ~DBI_RO_WR_EN; + else + reg |= DBI_RO_WR_EN; + DBI_WR4(sc, DW_MISC_CONTROL_1, reg); +} + +static bool +pci_dw_check_dev(struct pci_dw_softc *sc, u_int bus, u_int slot, u_int func, + u_int reg) +{ + bool status; + int rv; + + if (bus < sc->bus_start || bus > sc->bus_end || slot > PCI_SLOTMAX || + func > PCI_FUNCMAX || reg > PCI_REGMAX) + return (false); + + /* link is needed for access to all non-root busses */ + if (bus != sc->root_bus) { + rv = PCI_DW_GET_LINK(sc->dev, &status); + if (rv != 0 || !status) + return (false); + return (true); + } + + /* we have only 1 device with 1 function root port */ + if (slot > 0 || func > 0) + return (false); + return (true); +} + +/* Map one uoutbound ATU region */ +static int +pci_dw_map_out_atu(struct pci_dw_softc *sc, int idx, int type, + uint64_t pa, uint64_t pci_addr, uint32_t size) +{ + uint32_t reg; + int i; + + if (size == 0) + return (0); + + DBI_WR4(sc, DW_IATU_VIEWPORT, IATU_REGION_INDEX(idx)); + DBI_WR4(sc, DW_IATU_LWR_BASE_ADDR, pa & 0xFFFFFFFF); + DBI_WR4(sc, DW_IATU_UPPER_BASE_ADDR, (pa >> 32) & 0xFFFFFFFF); + DBI_WR4(sc, DW_IATU_LIMIT_ADDR, (pa + size - 1) & 0xFFFFFFFF); + DBI_WR4(sc, DW_IATU_LWR_TARGET_ADDR, pci_addr & 0xFFFFFFFF); + DBI_WR4(sc, DW_IATU_UPPER_TARGET_ADDR, (pci_addr >> 32) & 0xFFFFFFFF); + DBI_WR4(sc, DW_IATU_CTRL1, IATU_CTRL1_TYPE(type)); + DBI_WR4(sc, DW_IATU_CTRL2, IATU_CTRL2_REGION_EN); + + /* Wait until setup becomes valid */ + for (i = 10; i > 0; i--) { + reg = DBI_RD4(sc, DW_IATU_CTRL2); + if (reg & IATU_CTRL2_REGION_EN) + return (0); + DELAY(5); + } + device_printf(sc->dev, + "Cannot map outbound region(%d) in iATU\n", idx); + return (ETIMEDOUT); +} + +static int +pci_dw_setup_hw(struct pci_dw_softc *sc) +{ + uint32_t reg; + int rv; + + pci_dw_dbi_protect(sc, false); + + /* Setup config registers */ + DBI_WR1(sc, PCIR_CLASS, PCIC_BRIDGE); + DBI_WR1(sc, PCIR_SUBCLASS, PCIS_BRIDGE_PCI); + DBI_WR4(sc, PCIR_BAR(0), 4); + DBI_WR4(sc, PCIR_BAR(1), 0); + DBI_WR1(sc, PCIR_INTPIN, 1); + DBI_WR1(sc, PCIR_PRIBUS_1, sc->root_bus); + DBI_WR1(sc, PCIR_SECBUS_1, sc->sub_bus); + DBI_WR1(sc, PCIR_SUBBUS_1, sc->bus_end); + DBI_WR2(sc, PCIR_COMMAND, + PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | + PCIM_CMD_BUSMASTEREN | PCIM_CMD_SERRESPEN); + pci_dw_dbi_protect(sc, true); + + /* Setup outbound memory window */ + rv = pci_dw_map_out_atu(sc, 0, IATU_CTRL1_TYPE_MEM, + sc->mem_range.host, sc->mem_range.pci, sc->mem_range.size); + if (rv != 0) + return (rv); + + /* If we have enouht viewports ..*/ + if (sc->num_viewport >= 3) { + /* Setup outbound I/O window */ + rv = pci_dw_map_out_atu(sc, 0, IATU_CTRL1_TYPE_MEM, + sc->io_range.host, sc->io_range.pci, sc->io_range.size); + if (rv != 0) + return (rv); + } + /* XXX Should we handle also prefetch memory? */ + + + /* Adjust number of lanes */ + reg = DBI_RD4(sc, DW_PORT_LINK_CTRL); + reg &= ~PORT_LINK_CAPABLE(~0); + switch (sc->num_lanes) { + case 1: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_1); + break; + case 2: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_2); + break; + case 4: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_4); + break; + case 8: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_8); + break; + case 16: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_16); + break; + case 32: + reg |= PORT_LINK_CAPABLE(PORT_LINK_CAPABLE_32); + break; + default: + device_printf(sc->dev, + "'num-lanes' property have invalid value: %d\n", + sc->num_lanes); + return (EINVAL); + } + DBI_WR4(sc, DW_PORT_LINK_CTRL, reg); + + + /* And link width */ + reg = DBI_RD4(sc, DW_GEN2_CTRL); + reg &= ~GEN2_CTRL_NUM_OF_LANES(~0); + switch (sc->num_lanes) { + case 1: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_1); + break; + case 2: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_2); + break; + case 4: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_4); + break; + case 8: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_8); + break; + case 16: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_16); + break; + case 32: + reg |= GEN2_CTRL_NUM_OF_LANES(GEN2_CTRL_NUM_OF_LANES_32); + break; + } + DBI_WR4(sc, DW_GEN2_CTRL, reg); + + reg = DBI_RD4(sc, DW_GEN2_CTRL); + reg |= DIRECT_SPEED_CHANGE; + DBI_WR4(sc, DW_GEN2_CTRL, reg); + + + return (0); +} + +static int +pci_dw_decode_ranges(struct pci_dw_softc *sc, struct ofw_pci_range *ranges, + int nranges) +{ + int i; + + for (i = 0; i < nranges; i++) { + if ((ranges[i].pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) == + OFW_PCI_PHYS_HI_SPACE_IO) { + if (sc->io_range.size != 0) { + device_printf(sc->dev, + "Duplicated IO range found in DT\n"); + return (ENXIO); + } + sc->io_range = ranges[i]; + } + if (((ranges[i].pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) == + OFW_PCI_PHYS_HI_SPACE_MEM32)) { + if (ranges[i].pci_hi & OFW_PCI_PHYS_HI_PREFETCHABLE) { + if (sc->pref_mem_range.size != 0) { + device_printf(sc->dev, + "Duplicated memory range found " + "in DT\n"); + return (ENXIO); + } + sc->pref_mem_range = ranges[i]; + } else { + if (sc->mem_range.size != 0) { + device_printf(sc->dev, + "Duplicated memory range found " + "in DT\n"); + return (ENXIO); + } + sc->mem_range = ranges[i]; + } + } + } + if ((sc->io_range.size == 0) || (sc->mem_range.size == 0)) { + device_printf(sc->dev, + " Not all required ranges are found in DT\n"); + return (ENXIO); + } + return (0); +} + + + +/*----------------------------------------------------------------------------- + * + * P C I B I N T E R F A C E + */ + +static uint32_t +pci_dw_read_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, int bytes) +{ + struct pci_dw_softc *sc; + struct resource *res; + uint32_t data; + uint64_t addr; + int type, rv; + + sc = device_get_softc(dev); + + if (!pci_dw_check_dev(sc, bus, slot, func, reg)) + return (0xFFFFFFFFU); + + if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || + (reg > PCI_REGMAX)) + return (0xFFFFFFFFU); + + if (bus == sc->root_bus) { + res = (sc->dbi_res); + } else { + addr = IATU_CFG_BUS(bus) | IATU_CFG_SLOT(slot) | + IATU_CFG_FUNC(func); + if (bus == sc->sub_bus) + type = IATU_CTRL1_TYPE_CFG0; + else + type = IATU_CTRL1_TYPE_CFG1; + rv = pci_dw_map_out_atu(sc, 1, type, + sc->cfg_pa, addr, sc->cfg_size); + if (rv != 0) + return (0xFFFFFFFFU); + res = sc->cfg_res; + } + + switch (bytes) { + case 1: + data = bus_read_1(res, reg); + break; + case 2: + data = bus_read_2(res, reg); + break; + case 4: + data = bus_read_4(res, reg); + break; + default: + data = 0xFFFFFFFFU; + } + + return (data); + +} + +static void +pci_dw_write_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, uint32_t val, int bytes) +{ + struct pci_dw_softc *sc; + struct resource *res; + uint64_t addr; + int type, rv; + + sc = device_get_softc(dev); + if (!pci_dw_check_dev(sc, bus, slot, func, reg)) + return; + + if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || + (reg > PCI_REGMAX)) + return; + + if (bus == sc->root_bus) { + res = (sc->dbi_res); + } else { + addr = IATU_CFG_BUS(bus) | IATU_CFG_SLOT(slot) | + IATU_CFG_FUNC(func); + if (bus == sc->sub_bus) + type = IATU_CTRL1_TYPE_CFG0; + else + type = IATU_CTRL1_TYPE_CFG1; + rv = pci_dw_map_out_atu(sc, 1, type, + sc->cfg_pa, addr, sc->cfg_size); + if (rv != 0) + return ; + res = sc->cfg_res; + } + + + switch (bytes) { + case 1: + bus_write_1(res, reg, val); + break; + case 2: + bus_write_2(res, reg, val); + break; + case 4: + bus_write_4(res, reg, val); + break; + default: + break; + } +} + +static int +pci_dw_alloc_msi(device_t pci, device_t child, int count, + int maxcount, int *irqs) +{ + phandle_t msi_parent; + int rv; + + rv = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), + &msi_parent, NULL); + if (rv != 0) + return (rv); + + return (intr_alloc_msi(pci, child, msi_parent, count, maxcount, + irqs)); +} + +static int +pci_dw_release_msi(device_t pci, device_t child, int count, int *irqs) +{ + phandle_t msi_parent; + int rv; + + rv = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), + &msi_parent, NULL); + if (rv != 0) + return (rv); + return (intr_release_msi(pci, child, msi_parent, count, irqs)); +} + +static int +pci_dw_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, + uint32_t *data) +{ + phandle_t msi_parent; + int rv; + + rv = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), + &msi_parent, NULL); + if (rv != 0) + return (rv); + + return (intr_map_msi(pci, child, msi_parent, irq, addr, data)); +} + +static int +pci_dw_alloc_msix(device_t pci, device_t child, int *irq) +{ + phandle_t msi_parent; + int rv; + + rv = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), + &msi_parent, NULL); + if (rv != 0) + return (rv); + return (intr_alloc_msix(pci, child, msi_parent, irq)); +} + +static int +pci_dw_release_msix(device_t pci, device_t child, int irq) +{ + phandle_t msi_parent; + int rv; + + rv = ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), + &msi_parent, NULL); + if (rv != 0) + return (rv); + return (intr_release_msix(pci, child, msi_parent, irq)); +} + +static int +pci_dw_get_id(device_t pci, device_t child, enum pci_id_type type, + uintptr_t *id) +{ + phandle_t node; + int rv; + uint32_t rid; + uint16_t pci_rid; + + if (type != PCI_ID_MSI) + return (pcib_get_id(pci, child, type, id)); + + node = ofw_bus_get_node(pci); + pci_rid = pci_get_rid(child); + + rv = ofw_bus_msimap(node, pci_rid, NULL, &rid); + if (rv != 0) + return (rv); + *id = rid; + + return (0); +} + +/*----------------------------------------------------------------------------- + * + * B U S / D E V I C E I N T E R F A C E + */ +static bus_dma_tag_t +pci_dw_get_dma_tag(device_t dev, device_t child) +{ + struct pci_dw_softc *sc; + + sc = device_get_softc(dev); + return (sc->dmat); +} + +int +pci_dw_init(device_t dev) +{ + struct pci_dw_softc *sc; + int rv, rid; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->node = ofw_bus_get_node(dev); + + mtx_init(&sc->mtx, "pci_dw_mtx", NULL, MTX_DEF); + + /* XXXn Should not be this configurable ? */ + sc->bus_start = 0; + sc->bus_end = 255; + sc->root_bus = 0; + sc->sub_bus = 1; + + /* Read FDT properties */ + if (!sc->coherent) + sc->coherent = OF_hasprop(sc->node, "dma-coherent"); + + rv = OF_getencprop(sc->node, "num-viewport", &sc->num_viewport, + sizeof(sc->num_viewport)); + if (rv != sizeof(sc->num_viewport)) + sc->num_viewport = 2; + + rv = OF_getencprop(sc->node, "num-lanes", &sc->num_lanes, + sizeof(sc->num_viewport)); + if (rv != sizeof(sc->num_lanes)) + sc->num_lanes = 1; + if (sc->num_lanes != 1 && sc->num_lanes != 2 && + sc->num_lanes != 4 && sc->num_lanes != 8) { + device_printf(dev, + "invalid number of lanes: %d\n",sc->num_lanes); + sc->num_lanes = 0; + rv = ENXIO; + goto out; + } + + rid = 0; + rv = ofw_bus_find_string_index(sc->node, "reg-names", "config", &rid); + if (rv != 0) { + device_printf(dev, "Cannot get config space memory\n"); + rv = ENXIO; + goto out; + } + sc->cfg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->cfg_res == NULL) { + device_printf(dev, "Cannot allocate config space(rid: %d)\n", + rid); + rv = ENXIO; + goto out; + } + + /* Fill up config region related variables */ + sc->cfg_size = rman_get_size(sc->cfg_res); + sc->cfg_pa = rman_get_start(sc->cfg_res) ; + + if (bootverbose) + device_printf(dev, "Bus is%s cache-coherent\n", + sc->coherent ? "" : " not"); + rv = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ + 1, 0, /* alignment, bounds */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + BUS_SPACE_MAXSIZE, /* maxsize */ + BUS_SPACE_UNRESTRICTED, /* nsegments */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ + sc->coherent ? BUS_DMA_COHERENT : 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc->dmat); + if (rv != 0) + goto out; + + rv = ofw_pci_init(dev); + if (rv != 0) + goto out; + rv = pci_dw_decode_ranges(sc, sc->ofw_pci.sc_range, + sc->ofw_pci.sc_nrange); + if (rv != 0) + goto out; + + rv = pci_dw_setup_hw(sc); + if (rv != 0) + goto out; + + device_add_child(dev, "pci", -1); + + return (bus_generic_attach(dev)); +out: + /* XXX Cleanup */ + return (rv); +} + +static device_method_t pci_dw_methods[] = { + + /* Bus interface */ + DEVMETHOD(bus_get_dma_tag, pci_dw_get_dma_tag), + + /* pcib interface */ + DEVMETHOD(pcib_read_config, pci_dw_read_config), + DEVMETHOD(pcib_write_config, pci_dw_write_config), + DEVMETHOD(pcib_alloc_msi, pci_dw_alloc_msi), + DEVMETHOD(pcib_release_msi, pci_dw_release_msi), + DEVMETHOD(pcib_alloc_msix, pci_dw_alloc_msix), + DEVMETHOD(pcib_release_msix, pci_dw_release_msix), + DEVMETHOD(pcib_map_msi, pci_dw_map_msi), + DEVMETHOD(pcib_get_id, pci_dw_get_id), + + /* OFW bus interface */ + DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), + DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), + DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), + DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), + DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), + + /* PCI DW interface */ + DEVMETHOD(pci_dw_dbi_read, pci_dw_dbi_read), + DEVMETHOD(pci_dw_dbi_write, pci_dw_dbi_write), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(pcib, pci_dw_driver, pci_dw_methods, + sizeof(struct pci_dw_softc), ofw_pci_driver); Copied: stable/12/sys/dev/pci/pci_dw.h (from r353774, head/sys/dev/pci/pci_dw.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/pci/pci_dw.h Sat Oct 31 14:59:39 2020 (r367206, copy of r353774, head/sys/dev/pci/pci_dw.h) @@ -0,0 +1,158 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * 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$ + * + */ + +#ifndef _PCI_DW_H_ +#define _PCI_DW_H_ + +#include "pci_dw_if.h" + + +/* DesignWare CIe configuration registers */ +#define DW_PORT_LINK_CTRL 0x710 +#define PORT_LINK_CAPABLE(n) (((n) & 0x3F) << 16) +#define PORT_LINK_CAPABLE_1 0x01 +#define PORT_LINK_CAPABLE_2 0x03 +#define PORT_LINK_CAPABLE_4 0x07 +#define PORT_LINK_CAPABLE_8 0x0F +#define PORT_LINK_CAPABLE_16 0x1F +#define PORT_LINK_CAPABLE_32 0x3F + + +#define DW_GEN2_CTRL 0x80C +#define DIRECT_SPEED_CHANGE (1 << 17) +#define GEN2_CTRL_NUM_OF_LANES(n) (((n) & 0x3F) << 8) +#define GEN2_CTRL_NUM_OF_LANES_1 0x01 +#define GEN2_CTRL_NUM_OF_LANES_2 0x03 +#define GEN2_CTRL_NUM_OF_LANES_4 0x07 +#define GEN2_CTRL_NUM_OF_LANES_8 0x0F +#define GEN2_CTRL_NUM_OF_LANES_16 0x1F +#define GEN2_CTRL_NUM_OF_LANES_32 0x3F + +#define DW_MSI_ADDR_LO 0x820 +#define DW_MSI_ADDR_HI 0x824 +#define DW_MSI_INTR0_ENABLE 0x828 +#define DW_MSI_INTR0_MASK 0x82C +#define DW_MSI_INTR0_STATUS 0x830 + + +#define DW_MISC_CONTROL_1 0x8BC +#define DBI_RO_WR_EN (1 << 0) + +#define DW_IATU_VIEWPORT 0x900 +#define IATU_REGION_INBOUND (1U << 31) +#define IATU_REGION_INDEX(x) ((x) & 0x7) +#define DW_IATU_CTRL1 0x904 +#define IATU_CTRL1_TYPE(x) ((x) & 0x1F) +#define IATU_CTRL1_TYPE_MEM 0x0 +#define IATU_CTRL1_TYPE_IO 0x2 +#define IATU_CTRL1_TYPE_CFG0 0x4 +#define IATU_CTRL1_TYPE_CFG1 0x5 +#define DW_IATU_CTRL2 0x908 +#define IATU_CTRL2_REGION_EN (1U << 31) +#define DW_IATU_LWR_BASE_ADDR 0x90C +#define DW_IATU_UPPER_BASE_ADDR 0x910 +#define DW_IATU_LIMIT_ADDR 0x914 +#define DW_IATU_LWR_TARGET_ADDR 0x918 +#define DW_IATU_UPPER_TARGET_ADDR 0x91C + + +struct pci_dw_softc { + struct ofw_pci_softc ofw_pci; /* Must be first */ + + /* Filled by attachement stub */ + struct resource *dbi_res; + + /* pci_dw variables */ + device_t dev; + phandle_t node; + struct mtx mtx; + struct resource *cfg_res; + + struct ofw_pci_range mem_range; + struct ofw_pci_range pref_mem_range; + struct ofw_pci_range io_range; + + bool coherent; + bus_dma_tag_t dmat; + + int num_lanes; + int num_viewport; + bus_addr_t cfg_pa; /* PA of config memoty */ + bus_size_t cfg_size; /* size of config region */ + + u_int bus_start; + u_int bus_end; + u_int root_bus; + u_int sub_bus; +}; + +DECLARE_CLASS(pci_dw_driver); + + +static inline void +pci_dw_dbi_wr4(device_t dev, u_int reg, uint32_t val) +{ + PCI_DW_DBI_WRITE(dev, reg, val, 4); +} + +static inline void +pci_dw_dbi_wr2(device_t dev, u_int reg, uint16_t val) +{ + PCI_DW_DBI_WRITE(dev, reg, val, 2); +} + +static inline void +pci_dw_dbi_wr1(device_t dev, u_int reg, uint8_t val) +{ + PCI_DW_DBI_WRITE(dev, reg, val, 1); +} + +static inline uint32_t +pci_dw_dbi_rd4(device_t dev, u_int reg) +{ + return (PCI_DW_DBI_READ(dev, reg, 4)); +} + +static inline uint16_t +pci_dw_dbi_rd2(device_t dev, u_int reg) +{ + return ((uint16_t)PCI_DW_DBI_READ(dev, reg, 2)); +} + +static inline uint8_t +pci_dw_dbi_rd1(device_t dev, u_int reg) +{ + return ((uint8_t)PCI_DW_DBI_READ(dev, reg, 1)); +} + +int pci_dw_init(device_t); + +#endif /* __PCI_HOST_GENERIC_H_ */ Copied: stable/12/sys/dev/pci/pci_dw_if.m (from r353774, head/sys/dev/pci/pci_dw_if.m) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/pci/pci_dw_if.m Sat Oct 31 14:59:39 2020 (r367206, copy of r353774, head/sys/dev/pci/pci_dw_if.m) @@ -0,0 +1,73 @@ +#- +# Copyright (c) 2019 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. +# +# $FreeBSD$ +# + +#include + +INTERFACE pci_dw; + + +/** + * Read from dbi space. + * The reg argument is a byte offset into dbi space. + * The width argument (which should be 1, 2 or 4) specifies how + * many bytes to read from that offset. + */ +METHOD uint32_t dbi_read{ + device_t dev; + u_int reg; + int width; +}; + +/** + * Write to dbi space. + * The reg argument is a byte offset into dbi space. + * The width argument (which should be 1, 2 or 4) specifies how + * many bytes to write to that offset. + */ +METHOD void dbi_write{ + device_t dev; + u_int reg; + uint32_t value; + int width; +}; + +/** + * Start or stop link + */ +METHOD int set_link{ + device_t dev; + bool start; +}; + +/** + * Query link status (up/down) + */ +METHOD int get_link{ + device_t dev; + bool *status; +}; Copied: stable/12/sys/dev/pci/pci_dw_mv.c (from r353774, head/sys/dev/pci/pci_dw_mv.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/pci/pci_dw_mv.c Sat Oct 31 14:59:39 2020 (r367206, copy of r353774, head/sys/dev/pci/pci_dw_mv.c) @@ -0,0 +1,328 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * 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. + * + */ + +/* Armada 8k DesignWare PCIe driver */ + +#include +__FBSDID("$FreeBSD$"); + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:25:42 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F12EE44EB8D; Sat, 31 Oct 2020 15:25:42 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNjgB68Tcz4Ypv; Sat, 31 Oct 2020 15:25:42 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C5FB97FB; Sat, 31 Oct 2020 15:25:42 +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 09VFPg1t098249; Sat, 31 Oct 2020 15:25:42 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFPgF9098246; Sat, 31 Oct 2020 15:25:42 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311525.09VFPgF9098246@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:25:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367208 - in stable/12/sys: arm64/rockchip conf X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: in stable/12/sys: arm64/rockchip conf X-SVN-Commit-Revision: 367208 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:25:43 -0000 Author: mmel Date: Sat Oct 31 15:25:41 2020 New Revision: 367208 URL: https://svnweb.freebsd.org/changeset/base/367208 Log: MFC r355755,r358807: r355755: Add driver for Rockchip PCIe root complex found in RK3399 SOC. Unfortunately, there are some limitations: - memory aperture of his controller is only 16MiB, so it is nearly unusable for graphic cards - every attempt to generate type 1 config cycle always causes trap. These config cycles are disabled now and we don't support cards with PCIe switch. - in some cases, attempt to do config cycle to (probably) not-yet ready card also causes trap. This cannot be detected at runtime, but it seems like very rare issue. r358807: Add the missing brackets to the logical expression. Added: stable/12/sys/arm64/rockchip/rk_pcie.c - copied, changed from r355755, head/sys/arm64/rockchip/rk_pcie.c stable/12/sys/arm64/rockchip/rk_pcie_phy.c - copied unchanged from r355755, head/sys/arm64/rockchip/rk_pcie_phy.c Modified: stable/12/sys/conf/files.arm64 Directory Properties: stable/12/ (props changed) Copied and modified: stable/12/sys/arm64/rockchip/rk_pcie.c (from r355755, head/sys/arm64/rockchip/rk_pcie.c) ============================================================================== --- head/sys/arm64/rockchip/rk_pcie.c Sat Dec 14 14:56:34 2019 (r355755, copy source) +++ stable/12/sys/arm64/rockchip/rk_pcie.c Sat Oct 31 15:25:41 2020 (r367208) @@ -895,7 +895,7 @@ rk_pcie_enable_resources(struct rk_pcie_softc *sc) /* Set basic PCIe core mode (RC, lanes, gen1 or 2) */ val = STRAP_CONF_GEN_2 << 16 | - sc->link_is_gen2 ? STRAP_CONF_GEN_2: 0; + (sc->link_is_gen2 ? STRAP_CONF_GEN_2: 0); val |= STRAP_CONF_MODE_RC << 16 | STRAP_CONF_MODE_RC; val |= STRAP_CONF_LANES(~0) << 16 | STRAP_CONF_LANES(sc->num_lanes); val |= STRAP_CONF_ARI_EN << 16 | STRAP_CONF_ARI_EN; @@ -1408,4 +1408,4 @@ DEFINE_CLASS_1(pcib, rk_pcie_driver, rk_pcie_methods, sizeof(struct rk_pcie_softc), ofw_pci_driver); static devclass_t rk_pcie_devclass; DRIVER_MODULE( rk_pcie, simplebus, rk_pcie_driver, rk_pcie_devclass, - NULL, NULL); \ No newline at end of file + NULL, NULL); Copied: stable/12/sys/arm64/rockchip/rk_pcie_phy.c (from r355755, head/sys/arm64/rockchip/rk_pcie_phy.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm64/rockchip/rk_pcie_phy.c Sat Oct 31 15:25:41 2020 (r367208, copy of r355755, head/sys/arm64/rockchip/rk_pcie_phy.c) @@ -0,0 +1,369 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Michal Meloun + * + * 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. + */ + +/* + * Rockchip PHY TYPEC + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "syscon_if.h" + +#define GRF_HIWORD_SHIFT 16 +#define GRF_SOC_CON_5_PCIE 0xE214 +#define CON_5_PCIE_IDLE_OFF(x) (1 <<(((x) & 0x3) + 3)) +#define GRF_SOC_CON8 0xE220 +#define GRF_SOC_STATUS1 0xE2A4 + +/* PHY config registers - write */ +#define PHY_CFG_CLK_TEST 0x10 +#define CLK_TEST_SEPE_RATE (1 << 3) +#define PHY_CFG_CLK_SCC 0x12 +#define CLK_SCC_PLL_100M (1 << 3) + +/* PHY config registers - read */ +#define PHY_CFG_PLL_LOCK 0x10 +#define CLK_PLL_LOCKED (1 << 1) +#define PHY_CFG_SCC_LOCK 0x12 +#define CLK_SCC_100M_GATE (1 << 2) + + +#define STATUS1_PLL_LOCKED (1 << 9) + +static struct ofw_compat_data compat_data[] = { + {"rockchip,rk3399-pcie-phy", 1}, + {NULL, 0} +}; + + +struct rk_pcie_phy_softc { + device_t dev; + struct syscon *syscon; + struct mtx mtx; + clk_t clk_ref; + hwreset_t hwreset_phy; + int enable_count; +}; + +#define PHY_LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define PHY_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define PHY_LOCK_INIT(_sc) mtx_init(&(_sc)->mtx, \ + device_get_nameunit(_sc->dev), "rk_pcie_phyc", MTX_DEF) +#define PHY_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx); +#define PHY_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED); +#define PHY_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED); + + +#define RD4(sc, reg) SYSCON_READ_4((sc)->syscon, (reg)) +#define WR4(sc, reg, mask, val) \ + SYSCON_WRITE_4((sc)->syscon, (reg), ((mask) << GRF_HIWORD_SHIFT) | (val)) + +#define MAX_LANE 4 + + +static void +cfg_write(struct rk_pcie_phy_softc *sc, uint32_t reg, uint32_t data) +{ + /* setup register address and data first */ + WR4(sc, GRF_SOC_CON8, 0x7FF, + (reg & 0x3F) << 1 | (data & 0x0F) << 7); + /* dummy readback for sync */ + RD4(sc, GRF_SOC_CON8); + + /* Do write pulse */ + WR4(sc, GRF_SOC_CON8, 1, 1); + RD4(sc, GRF_SOC_CON8); + DELAY(10); + WR4(sc, GRF_SOC_CON8, 1, 0); + RD4(sc, GRF_SOC_CON8); + DELAY(10); +} + +static uint32_t +cfg_read(struct rk_pcie_phy_softc *sc, uint32_t reg) +{ + uint32_t val; + + WR4(sc, GRF_SOC_CON8, 0x3FF, reg << 1); + RD4(sc, GRF_SOC_CON8); + DELAY(10); + val = RD4(sc, GRF_SOC_STATUS1); + return ((val >> 8) & 0x0f); +} + +static int +rk_pcie_phy_up(struct rk_pcie_phy_softc *sc, int id) +{ + uint32_t val; + int i, rv; + + PHY_LOCK(sc); + + sc->enable_count++; + if (sc->enable_count != 1) { + PHY_UNLOCK(sc); + return (0); + } + + rv = hwreset_deassert(sc->hwreset_phy); + if (rv != 0) { + device_printf(sc->dev, "Cannot deassert 'phy' reset\n"); + PHY_UNLOCK(sc); + return (rv); + } + /* Un-idle all lanes */ + for (i = 0; i < MAX_LANE; i++) + WR4(sc, GRF_SOC_CON_5_PCIE, CON_5_PCIE_IDLE_OFF(i), 0); + + /* Wait for PLL lock */ + for (i = 100; i > 0; i--) { + val = cfg_read(sc, PHY_CFG_PLL_LOCK); + if (val & CLK_PLL_LOCKED) + break; + DELAY(1000); + } + if (i <= 0) { + device_printf(sc->dev, "PLL lock timeouted, 0x%02X\n", val); + PHY_UNLOCK(sc); + return (ETIMEDOUT); + } + /* Switch PLL to stable 5GHz, rate adjustment is done by divider */ + cfg_write(sc, PHY_CFG_CLK_TEST, CLK_TEST_SEPE_RATE); + /* Enable 100MHz output for PCIe ref clock */ + cfg_write(sc, PHY_CFG_CLK_SCC, CLK_SCC_PLL_100M); + + /* Wait for ungating of ref clock */ + for (i = 100; i > 0; i--) { + val = cfg_read(sc, PHY_CFG_SCC_LOCK); + if ((val & CLK_SCC_100M_GATE) == 0) + break; + DELAY(1000); + } + if (i <= 0) { + device_printf(sc->dev, "PLL output enable timeouted\n"); + PHY_UNLOCK(sc); + return (ETIMEDOUT); + } + + /* Wait for PLL relock (to 5GHz) */ + for (i = 100; i > 0; i--) { + val = cfg_read(sc, PHY_CFG_PLL_LOCK); + if (val & CLK_PLL_LOCKED) + break; + DELAY(1000); + } + if (i <= 0) { + device_printf(sc->dev, "PLL relock timeouted\n"); + PHY_UNLOCK(sc); + return (ETIMEDOUT); + } + + PHY_UNLOCK(sc); + return (rv); +} + +static int +rk_pcie_phy_down(struct rk_pcie_phy_softc *sc, int id) +{ + int rv; + + PHY_LOCK(sc); + + rv = 0; + if (sc->enable_count <= 0) + panic("unpaired enable/disable"); + + sc->enable_count--; + + /* Idle given lane */ + WR4(sc, GRF_SOC_CON_5_PCIE, + CON_5_PCIE_IDLE_OFF(id), + CON_5_PCIE_IDLE_OFF(id)); + + if (sc->enable_count == 0) { + rv = hwreset_assert(sc->hwreset_phy); + if (rv != 0) + device_printf(sc->dev, "Cannot assert 'phy' reset\n"); + } + PHY_UNLOCK(sc); + return (rv); +} + +static int +rk_pcie_phy_enable(struct phynode *phynode, bool enable) +{ + struct rk_pcie_phy_softc *sc; + device_t dev; + intptr_t phy; + int rv; + + dev = phynode_get_device(phynode); + phy = phynode_get_id(phynode); + sc = device_get_softc(dev); + + if (enable) + rv = rk_pcie_phy_up(sc, (int)phy); + else + rv = rk_pcie_phy_down(sc, (int) phy); + + return (rv); +} + + +/* Phy class and methods. */ +static int rk_pcie_phy_enable(struct phynode *phynode, bool enable); +static phynode_method_t rk_pcie_phy_phynode_methods[] = { + PHYNODEMETHOD(phynode_enable, rk_pcie_phy_enable), + + PHYNODEMETHOD_END +}; + +DEFINE_CLASS_1( rk_pcie_phy_phynode, rk_pcie_phy_phynode_class, + rk_pcie_phy_phynode_methods, 0, phynode_class); + +static int + rk_pcie_phy_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, "Rockchip RK3399 PCIe PHY"); + return (BUS_PROBE_DEFAULT); +} + +static int + rk_pcie_phy_attach(device_t dev) +{ + struct rk_pcie_phy_softc *sc; + struct phynode_init_def phy_init; + struct phynode *phynode; + phandle_t node; + int i, rv; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + PHY_LOCK_INIT(sc); + + if (SYSCON_GET_HANDLE(sc->dev, &sc->syscon) != 0 || + sc->syscon == NULL) { + device_printf(dev, "cannot get syscon for device\n"); + rv = ENXIO; + goto fail; + } + + rv = clk_get_by_ofw_name(sc->dev, 0, "refclk", &sc->clk_ref); + if (rv != 0) { + device_printf(sc->dev, "Cannot get 'refclk' clock\n"); + rv = ENXIO; + goto fail; + } + rv = hwreset_get_by_ofw_name(sc->dev, 0, "phy", &sc->hwreset_phy); + if (rv != 0) { + device_printf(sc->dev, "Cannot get 'phy' reset\n"); + rv = ENXIO; + goto fail; + } + + rv = hwreset_assert(sc->hwreset_phy); + if (rv != 0) { + device_printf(sc->dev, "Cannot assert 'phy' reset\n"); + rv = ENXIO; + goto fail; + } + + rv = clk_enable(sc->clk_ref); + if (rv != 0) { + device_printf(sc->dev, "Cannot enable 'ref' clock\n"); + rv = ENXIO; + goto fail; + } + + for (i = 0; i < MAX_LANE; i++) { + phy_init.id = i; + phy_init.ofw_node = node; + phynode = phynode_create(dev, &rk_pcie_phy_phynode_class, + &phy_init); + if (phynode == NULL) { + device_printf(dev, "Cannot create phy[%d]\n", i); + rv = ENXIO; + goto fail; + } + if (phynode_register(phynode) == NULL) { + device_printf(dev, "Cannot register phy[%d]\n", i); + rv = ENXIO; + goto fail; + } + } + + return (0); + +fail: + return (rv); +} + +static device_method_t rk_pcie_phy_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, rk_pcie_phy_probe), + DEVMETHOD(device_attach, rk_pcie_phy_attach), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(rk_pcie_phy, rk_pcie_phy_driver, rk_pcie_phy_methods, + sizeof(struct rk_pcie_phy_softc)); + +static devclass_t rk_pcie_phy_devclass; +EARLY_DRIVER_MODULE(rk_pcie_phy, simplebus, rk_pcie_phy_driver, + rk_pcie_phy_devclass, NULL, NULL, + BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); Modified: stable/12/sys/conf/files.arm64 ============================================================================== --- stable/12/sys/conf/files.arm64 Sat Oct 31 15:11:24 2020 (r367207) +++ stable/12/sys/conf/files.arm64 Sat Oct 31 15:25:41 2020 (r367208) @@ -353,6 +353,8 @@ arm64/rockchip/rk_typec_phy.c optional fdt rk_typec_p arm64/rockchip/if_dwc_rk.c optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 arm64/rockchip/rk_tsadc_if.m optional fdt soc_rockchip_rk3399 arm64/rockchip/rk_tsadc.c optional fdt soc_rockchip_rk3399 +arm64/rockchip/rk_pcie.c optional fdt pci soc_rockchip_rk3399 +arm64/rockchip/rk_pcie_phy.c optional fdt pci soc_rockchip_rk3399 arm64/rockchip/rk_pwm.c optional fdt rk_pwm dev/dwc/if_dwc.c optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 dev/dwc/if_dwc_if.m optional fdt dwc_rk soc_rockchip_rk3328 | fdt dwc_rk soc_rockchip_rk3399 From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:28:22 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1478D44ED1D; Sat, 31 Oct 2020 15:28:22 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNjkF6kNJz4Z6m; Sat, 31 Oct 2020 15:28: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CAD4F99C8; Sat, 31 Oct 2020 15:28:21 +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 09VFSLjX098475; Sat, 31 Oct 2020 15:28:21 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFSLEW098473; Sat, 31 Oct 2020 15:28:21 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311528.09VFSLEW098473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:28:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367210 - stable/12/sys/arm64/rockchip X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm64/rockchip X-SVN-Commit-Revision: 367210 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:28:22 -0000 Author: mmel Date: Sat Oct 31 15:28:21 2020 New Revision: 367210 URL: https://svnweb.freebsd.org/changeset/base/367210 Log: MFC r360293,r360461: r360293: Reorder initialization steps for given pin. If pin is switched from fixed function to GPIO, it should have prepared direction, pull-up/down and default value before function gets switched. Otherwise we may produce unwanted glitch on output pin. Right order of drive strength settings is questionable, but I think that is slightly safer to do it also before function switch. r360461: Multiple fixes for rockchip iodomain driver: - always initialize selector of voltage signaling standard. Various versions of U-boot leaves voltage signaling standard settings for PMUIO2 domain in different state. Always initialize it into expected state. - start the driver as early as possible, the IO domains should be initialized before other drivers are attached. - rename RK3399 register to its name founds in TRM. Modified: stable/12/sys/arm64/rockchip/rk_iodomain.c stable/12/sys/arm64/rockchip/rk_pinctrl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/rockchip/rk_iodomain.c ============================================================================== --- stable/12/sys/arm64/rockchip/rk_iodomain.c Sat Oct 31 15:27:45 2020 (r367209) +++ stable/12/sys/arm64/rockchip/rk_iodomain.c Sat Oct 31 15:28:21 2020 (r367210) @@ -45,17 +45,20 @@ __FBSDID("$FreeBSD$"); #define RK3288_GRF_IO_VSEL 0x380 #define RK3399_GRF_IO_VSEL 0xe640 -#define RK3399_PMUGRF_IO_VSEL 0x180 +#define RK3399_PMUGRF_SOC_CON0 0x180 struct rk_iodomain_supply { char *name; uint32_t bit; }; +struct rk_iodomain_softc; + struct rk_iodomain_conf { struct rk_iodomain_supply *supply; int nsupply; uint32_t grf_reg; + void (*init)(struct rk_iodomain_softc *sc); }; struct rk_iodomain_softc { @@ -101,10 +104,12 @@ static struct rk_iodomain_supply rk3399_pmu_supply[] = {"pmu1830-supply", 9}, }; +static void rk3399_pmu_init(struct rk_iodomain_softc *sc); static struct rk_iodomain_conf rk3399_pmu_conf = { .supply = rk3399_pmu_supply, .nsupply = nitems(rk3399_pmu_supply), - .grf_reg = RK3399_PMUGRF_IO_VSEL, + .grf_reg = RK3399_PMUGRF_SOC_CON0, + .init = rk3399_pmu_init, }; static struct ofw_compat_data compat_data[] = { @@ -115,6 +120,14 @@ static struct ofw_compat_data compat_data[] = { }; static void +rk3399_pmu_init(struct rk_iodomain_softc *sc) +{ + + SYSCON_WRITE_4(sc->grf, RK3399_PMUGRF_SOC_CON0, + (1 << 8) | (1 << (8 + 16))); /* set pmu1830_volsel */ +} + +static void rk_iodomain_set(struct rk_iodomain_softc *sc) { regulator_t supply; @@ -141,6 +154,8 @@ rk_iodomain_set(struct rk_iodomain_softc *sc) } SYSCON_WRITE_4(sc->grf, sc->conf->grf_reg, reg | mask); + if (sc->conf->init != NULL) + sc->conf->init(sc); } static int @@ -204,4 +219,4 @@ static driver_t rk_iodomain_driver = { static devclass_t rk_iodomain_devclass; EARLY_DRIVER_MODULE(rk_iodomain, simplebus, rk_iodomain_driver, - rk_iodomain_devclass, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); + rk_iodomain_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); Modified: stable/12/sys/arm64/rockchip/rk_pinctrl.c ============================================================================== --- stable/12/sys/arm64/rockchip/rk_pinctrl.c Sat Oct 31 15:27:45 2020 (r367209) +++ stable/12/sys/arm64/rockchip/rk_pinctrl.c Sat Oct 31 15:28:21 2020 (r367210) @@ -933,7 +933,28 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, /* Find syscon */ syscon = sc->conf->get_syscon(sc, bank); - /* Parse pin function */ + /* Setup GPIO properties first */ + rv = rk_pinctrl_handle_io(sc, pin_conf, bank, pin); + + /* Then pin pull-up/down */ + bias = sc->conf->parse_bias(pin_conf, bank); + if (bias >= 0) { + reg = sc->conf->get_pd_offset(sc, bank); + reg += bank * 0x10 + ((pin / 8) * 0x4); + bit = (pin % 8) * 2; + mask = (0x3 << bit); + SYSCON_MODIFY_4(syscon, reg, mask, bias << bit | (mask << 16)); + } + + /* Then drive strength */ + rv = rk_pinctrl_parse_drive(sc, pin_conf, bank, subbank, &drive, ®); + if (rv == 0) { + bit = (pin % 8) * 2; + mask = (0x3 << bit); + SYSCON_MODIFY_4(syscon, reg, mask, drive << bit | (mask << 16)); + } + + /* Finally set the pin function */ reg = sc->conf->iomux_conf[i].offset; switch (sc->conf->iomux_conf[i].nbits) { case 4: @@ -967,28 +988,6 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, * without hi-word write mask. */ SYSCON_MODIFY_4(syscon, reg, mask, function << bit | (mask << 16)); - - /* Pull-Up/Down */ - bias = sc->conf->parse_bias(pin_conf, bank); - if (bias >= 0) { - reg = sc->conf->get_pd_offset(sc, bank); - - reg += bank * 0x10 + ((pin / 8) * 0x4); - bit = (pin % 8) * 2; - mask = (0x3 << bit); - SYSCON_MODIFY_4(syscon, reg, mask, bias << bit | (mask << 16)); - } - - /* Drive Strength */ - rv = rk_pinctrl_parse_drive(sc, pin_conf, bank, subbank, &drive, ®); - if (rv == 0) { - bit = (pin % 8) * 2; - mask = (0x3 << bit); - SYSCON_MODIFY_4(syscon, reg, mask, drive << bit | (mask << 16)); - } - - /* Input/Outpot + default level */ - rv = rk_pinctrl_handle_io(sc, pin_conf, bank, pin); } static int From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:30:28 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1186944ECAF; Sat, 31 Oct 2020 15:30:28 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNjmg6lVYz4ZJT; Sat, 31 Oct 2020 15:30:27 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C688E9B81; Sat, 31 Oct 2020 15:30:27 +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 09VFURmr098652; Sat, 31 Oct 2020 15:30:27 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFURB3098651; Sat, 31 Oct 2020 15:30:27 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311530.09VFURB3098651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:30:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367211 - stable/12/sys/arm64/rockchip X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm64/rockchip X-SVN-Commit-Revision: 367211 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:30:28 -0000 Author: mmel Date: Sat Oct 31 15:30:27 2020 New Revision: 367211 URL: https://svnweb.freebsd.org/changeset/base/367211 Log: MFC r360462: Don't try to re-initialize already preseted regulator. Modified: stable/12/sys/arm64/rockchip/rk805.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/rockchip/rk805.c ============================================================================== --- stable/12/sys/arm64/rockchip/rk805.c Sat Oct 31 15:28:21 2020 (r367210) +++ stable/12/sys/arm64/rockchip/rk805.c Sat Oct 31 15:30:27 2020 (r367211) @@ -106,6 +106,7 @@ struct rk805_softc { static int rk805_regnode_status(struct regnode *regnode, int *status); static int rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt, int max_uvolt, int *udelay); +static int rk805_regnode_get_voltage(struct regnode *regnode, int *uvolt); static struct rk805_regdef rk805_regdefs[] = { { @@ -367,13 +368,21 @@ rk805_regnode_init(struct regnode *regnode) { struct rk805_reg_sc *sc; struct regnode_std_param *param; - int rv, udelay, status; + int rv, udelay, uvolt, status; sc = regnode_get_softc(regnode); + dprintf(sc, "Regulator %s init called\n", sc->def->name); param = regnode_get_stdparam(regnode); if (param->min_uvolt == 0) return (0); + /* Check that the regulator is preset to the correct voltage */ + rv = rk805_regnode_get_voltage(regnode, &uvolt); + if (rv != 0) + return(rv); + + if (uvolt >= param->min_uvolt && uvolt <= param->max_uvolt) + return(0); /* * Set the regulator at the correct voltage if it is not enabled. * Do not enable it, this is will be done either by a From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:36:42 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 366E644F03E; Sat, 31 Oct 2020 15:36:42 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNjvt0kqFz4ZhR; Sat, 31 Oct 2020 15:36:42 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFA159B49; Sat, 31 Oct 2020 15:36:41 +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 09VFaf1i004679; Sat, 31 Oct 2020 15:36:41 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFaf0k004678; Sat, 31 Oct 2020 15:36:41 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311536.09VFaf0k004678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:36:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367212 - stable/12/libexec/rtld-elf/arm X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/libexec/rtld-elf/arm X-SVN-Commit-Revision: 367212 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:36:42 -0000 Author: mmel Date: Sat Oct 31 15:36:41 2020 New Revision: 367212 URL: https://svnweb.freebsd.org/changeset/base/367212 Log: MFC r360463,r360469: r360463: Don't allow to use FPU inside of rtld library. Clang10 may use FPU instructions for optimizing operations with memory blocks. But we don't want to do lengthy save/restore of all FPU registers across each rtld_start() call. r360469: Move ARM specific flags to arm/Makefile.inc Modified: stable/12/libexec/rtld-elf/arm/Makefile.inc Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rtld-elf/arm/Makefile.inc ============================================================================== --- stable/12/libexec/rtld-elf/arm/Makefile.inc Sat Oct 31 15:30:27 2020 (r367211) +++ stable/12/libexec/rtld-elf/arm/Makefile.inc Sat Oct 31 15:36:41 2020 (r367212) @@ -1 +1,2 @@ # $FreeBSD$ +CFLAGS+= -mfpu=none From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:38:42 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A1EC044F060; Sat, 31 Oct 2020 15:38:42 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNjyB3qydz4Zpc; Sat, 31 Oct 2020 15:38:42 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 66EF59C8E; Sat, 31 Oct 2020 15:38:42 +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 09VFcgw0004831; Sat, 31 Oct 2020 15:38:42 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFcgJo004830; Sat, 31 Oct 2020 15:38:42 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311538.09VFcgJo004830@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367213 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 367213 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:38:42 -0000 Author: mmel Date: Sat Oct 31 15:38:41 2020 New Revision: 367213 URL: https://svnweb.freebsd.org/changeset/base/367213 Log: MFC r360464: Don't try to set frequendcy for enumerated but never started CPUs. Modified: stable/12/sys/kern/kern_cpu.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_cpu.c ============================================================================== --- stable/12/sys/kern/kern_cpu.c Sat Oct 31 15:36:41 2020 (r367212) +++ stable/12/sys/kern/kern_cpu.c Sat Oct 31 15:38:41 2020 (r367213) @@ -333,6 +333,12 @@ cf_set_method(device_t dev, const struct cf_level *lev /* Bind to the target CPU before switching. */ pc = cpu_get_pcpu(set->dev); + + /* Skip settings if CPU is not started. */ + if (pc == NULL) { + error = 0; + goto out; + } thread_lock(curthread); pri = curthread->td_priority; sched_prio(curthread, PRI_MIN); From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:40:53 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7757444F21F; Sat, 31 Oct 2020 15:40:53 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNk0j2bxHz4bGj; Sat, 31 Oct 2020 15:40:53 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C9AA9B4F; Sat, 31 Oct 2020 15:40:53 +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 09VFerYX006504; Sat, 31 Oct 2020 15:40:53 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFeqLX006502; Sat, 31 Oct 2020 15:40:52 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311540.09VFeqLX006502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:40:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367214 - stable/12/sys/arm64/arm64 X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm64/arm64 X-SVN-Commit-Revision: 367214 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:40:53 -0000 Author: mmel Date: Sat Oct 31 15:40:52 2020 New Revision: 367214 URL: https://svnweb.freebsd.org/changeset/base/367214 Log: MFC r360466: Export tracing facility of GIC500 ITS block. Possibility of tracing of processing message based interrupts is very useful for debugging of PCIe driver, mainly for its MSI part. Modified: stable/12/sys/arm64/arm64/gic_v3_reg.h stable/12/sys/arm64/arm64/gicv3_its.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/arm64/gic_v3_reg.h ============================================================================== --- stable/12/sys/arm64/arm64/gic_v3_reg.h Sat Oct 31 15:38:41 2020 (r367213) +++ stable/12/sys/arm64/arm64/gic_v3_reg.h Sat Oct 31 15:40:52 2020 (r367214) @@ -220,6 +220,8 @@ (rev) << GITS_IIDR_REVISION_SHIFT | \ (impl) << GITS_IIDR_IMPLEMENTOR_SHIFT) +#define GITS_IIDR_IMPL_ARM (0x43B) +#define GITS_IIDR_PROD_GIC500 (0x0) #define GITS_IIDR_IMPL_CAVIUM (0x34c) #define GITS_IIDR_PROD_THUNDER (0xa1) #define GITS_IIDR_VAR_THUNDER_1 (0x0) @@ -359,6 +361,18 @@ #define LPI_CONF_PRIO_MASK (0xFC) #define LPI_CONF_GROUP1 (1 << 1) #define LPI_CONF_ENABLE (1 << 0) + +/* + * GIC 500 ITS tracking facility + */ +#define GITS_TRKCTLR 0xC000 +#define GITS_TRKR 0xC004 +#define GITS_TRKDIDR 0xC008 +#define GITS_TRKPIDR 0xC00C +#define GITS_TRKVIDR 0xC010 +#define GITS_TRKTGTR 0xC014 +#define GITS_TRKICR 0xC018 +#define GITS_TRKLCR 0xC018 /* * CPU interface Modified: stable/12/sys/arm64/arm64/gicv3_its.c ============================================================================== --- stable/12/sys/arm64/arm64/gicv3_its.c Sat Oct 31 15:38:41 2020 (r367213) +++ stable/12/sys/arm64/arm64/gicv3_its.c Sat Oct 31 15:40:52 2020 (r367214) @@ -47,7 +47,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include @@ -226,6 +228,7 @@ struct gicv3_its_irqsrc { }; struct gicv3_its_softc { + device_t dev; struct intr_pic *sc_pic; struct resource *sc_its_res; @@ -259,6 +262,7 @@ struct gicv3_its_softc { #define ITS_FLAGS_LPI_CONF_FLUSH 0x00000002 #define ITS_FLAGS_ERRATA_CAVIUM_22375 0x00000004 u_int sc_its_flags; + bool trace_enable; }; typedef void (its_quirk_func_t)(device_t); @@ -696,6 +700,86 @@ its_init_cpu(device_t dev, struct gicv3_its_softc *sc) } static int +gicv3_its_sysctl_trace_enable(SYSCTL_HANDLER_ARGS) +{ + struct gicv3_its_softc *sc; + int rv; + + sc = arg1; + + rv = sysctl_handle_bool(oidp, &sc->trace_enable, 0, req); + if (rv != 0 || req->newptr == NULL) + return (rv); + if (sc->trace_enable) + gic_its_write_8(sc, GITS_TRKCTLR, 3); + else + gic_its_write_8(sc, GITS_TRKCTLR, 0); + + return (0); +} + +static int +gicv3_its_sysctl_trace_regs(SYSCTL_HANDLER_ARGS) +{ + struct gicv3_its_softc *sc; + struct sbuf *sb; + int err; + + sc = arg1; + sb = sbuf_new_for_sysctl(NULL, NULL, 128, req); + if (sb == NULL) { + device_printf(sc->dev, "Could not allocate sbuf for output.\n"); + return (ENOMEM); + } + sbuf_cat(sb, "\n"); + sbuf_printf(sb, "GITS_TRKCTLR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKCTLR)); + sbuf_printf(sb, "GITS_TRKR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKR)); + sbuf_printf(sb, "GITS_TRKDIDR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKDIDR)); + sbuf_printf(sb, "GITS_TRKPIDR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKPIDR)); + sbuf_printf(sb, "GITS_TRKVIDR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKVIDR)); + sbuf_printf(sb, "GITS_TRKTGTR: 0x%08X\n", + gic_its_read_4(sc, GITS_TRKTGTR)); + + err = sbuf_finish(sb); + if (err) + device_printf(sc->dev, "Error finishing sbuf: %d\n", err); + sbuf_delete(sb); + return(err); +} + +static int +gicv3_its_init_sysctl(struct gicv3_its_softc *sc) +{ + struct sysctl_oid *oid, *child; + struct sysctl_ctx_list *ctx_list; + + ctx_list = device_get_sysctl_ctx(sc->dev); + child = device_get_sysctl_tree(sc->dev); + oid = SYSCTL_ADD_NODE(ctx_list, + SYSCTL_CHILDREN(child), OID_AUTO, "tracing", + CTLFLAG_RD| CTLFLAG_MPSAFE, NULL, "Messages tracing"); + if (oid == NULL) + return (ENXIO); + + /* Add registers */ + SYSCTL_ADD_PROC(ctx_list, + SYSCTL_CHILDREN(oid), OID_AUTO, "enable", + CTLTYPE_U8 | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + gicv3_its_sysctl_trace_enable, "CU", "Enable tracing"); + SYSCTL_ADD_PROC(ctx_list, + SYSCTL_CHILDREN(oid), OID_AUTO, "capture", + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + gicv3_its_sysctl_trace_regs, "", "Captured tracing registers."); + + return (0); +} + +static int gicv3_its_attach(device_t dev) { struct gicv3_its_softc *sc; @@ -793,6 +877,11 @@ gicv3_its_attach(device_t dev) "%s,%u", name, i); } + /* For GIC-500 install tracking sysctls. */ + if ((iidr & (GITS_IIDR_PRODUCT_MASK | GITS_IIDR_IMPLEMENTOR_MASK)) == + GITS_IIDR_RAW(GITS_IIDR_IMPL_ARM, GITS_IIDR_PROD_GIC500, 0, 0)) + gicv3_its_init_sysctl(sc); + return (0); } @@ -1681,6 +1770,7 @@ gicv3_its_fdt_attach(device_t dev) int err; sc = device_get_softc(dev); + sc->dev = dev; err = gicv3_its_attach(dev); if (err != 0) return (err); @@ -1742,6 +1832,7 @@ gicv3_its_acpi_attach(device_t dev) int err; sc = device_get_softc(dev); + sc->dev = dev; err = gicv3_its_attach(dev); if (err != 0) return (err); From owner-svn-src-stable-12@freebsd.org Sat Oct 31 15:58:06 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B145144F6F9; Sat, 31 Oct 2020 15:58:06 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkNZ47h0z4c0H; Sat, 31 Oct 2020 15:58:06 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7139F9FFB; Sat, 31 Oct 2020 15:58:06 +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 09VFw6j4017192; Sat, 31 Oct 2020 15:58:06 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VFw6Eq017191; Sat, 31 Oct 2020 15:58:06 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311558.09VFw6Eq017191@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 15:58:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367215 - stable/12/sys/arm/nvidia X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm/nvidia X-SVN-Commit-Revision: 367215 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 15:58:06 -0000 Author: mmel Date: Sat Oct 31 15:58:05 2020 New Revision: 367215 URL: https://svnweb.freebsd.org/changeset/base/367215 Log: MFC r362053: Fix grabbing of tegra uart. An attempt to write to FCR register may corrupt transmit FIFO, so we should wait for the FIFO to be empty before we can modify it. Modified: stable/12/sys/arm/nvidia/tegra_uart.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/nvidia/tegra_uart.c ============================================================================== --- stable/12/sys/arm/nvidia/tegra_uart.c Sat Oct 31 15:40:52 2020 (r367214) +++ stable/12/sys/arm/nvidia/tegra_uart.c Sat Oct 31 15:58:05 2020 (r367215) @@ -102,6 +102,10 @@ tegra_uart_grab(struct uart_softc *sc) uart_lock(sc->sc_hwmtx); ier = uart_getreg(bas, REG_IER); uart_setreg(bas, REG_IER, ier & ns8250->ier_mask); + + while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0) + ; + uart_setreg(bas, REG_FCR, 0); uart_barrier(bas); uart_unlock(sc->sc_hwmtx); From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:03:36 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F2A6644FC39; Sat, 31 Oct 2020 16:03:36 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkVw5BSsz4cdk; Sat, 31 Oct 2020 16:03:36 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9512DA384; Sat, 31 Oct 2020 16:03:36 +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 09VG3aQO023627; Sat, 31 Oct 2020 16:03:36 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VG3as1023623; Sat, 31 Oct 2020 16:03:36 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311603.09VG3as1023623@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:03:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367216 - in stable/12/sys: arm/mv arm/mv/armada38x conf dev/pci modules/dtb/mv X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: in stable/12/sys: arm/mv arm/mv/armada38x conf dev/pci modules/dtb/mv X-SVN-Commit-Revision: 367216 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:03:37 -0000 Author: mmel Date: Sat Oct 31 16:03:35 2020 New Revision: 367216 URL: https://svnweb.freebsd.org/changeset/base/367216 Log: MFC r362384,r362385,r362386,r362392: r362384: Add DTB files for ARMADA 8040 based boards. r362385: Add specialized gpio driver for ARMADA 8k SoC. Older marvell gpio blocks are to different for reusing/enhancing existing frivers. r362386: Add specific stub for ARMADA 8k SoC to Marvell RTC driver. The AXI bridge is different between ARMADA 38x and 8K, and both platforms needs specific setup to mitigate HW issues with accessing RTC registers. r362392: Adapt ARMADA8k PCIe driver to newly imported 5.7 DT. - temporarily disable handling with phy, we don't have driver for it yet - always clear cause for administartive interrupt. While I'm in, fix style(9) (mainly whitespace). Added: stable/12/sys/arm/mv/mvebu_gpio.c - copied unchanged from r362385, head/sys/arm/mv/mvebu_gpio.c Modified: stable/12/sys/arm/mv/armada38x/armada38x_rtc.c stable/12/sys/arm/mv/gpio.c stable/12/sys/conf/files.arm64 stable/12/sys/dev/pci/pci_dw_mv.c stable/12/sys/modules/dtb/mv/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/mv/armada38x/armada38x_rtc.c ============================================================================== --- stable/12/sys/arm/mv/armada38x/armada38x_rtc.c Sat Oct 31 15:58:05 2020 (r367215) +++ stable/12/sys/arm/mv/armada38x/armada38x_rtc.c Sat Oct 31 16:03:35 2020 (r367216) @@ -72,14 +72,27 @@ __FBSDID("$FreeBSD$"); #define MV_RTC_LOCK(sc) mtx_lock_spin(&(sc)->mutex) #define MV_RTC_UNLOCK(sc) mtx_unlock_spin(&(sc)->mutex) -#define RTC_BRIDGE_TIMING_CTRL 0x0 -#define RTC_WRCLK_PERIOD_SHIFT 0 -#define RTC_WRCLK_PERIOD_MASK 0x00000003FF -#define RTC_WRCLK_PERIOD_MAX 0x3FF -#define RTC_READ_OUTPUT_DELAY_SHIFT 26 -#define RTC_READ_OUTPUT_DELAY_MASK 0x007C000000 -#define RTC_READ_OUTPUT_DELAY_MAX 0x1F +#define A38X_RTC_BRIDGE_TIMING_CTRL 0x0 +#define A38X_RTC_WRCLK_PERIOD_SHIFT 0 +#define A38X_RTC_WRCLK_PERIOD_MASK 0x00000003FF +#define A38X_RTC_WRCLK_PERIOD_MAX 0x3FF +#define A38X_RTC_READ_OUTPUT_DELAY_SHIFT 26 +#define A38X_RTC_READ_OUTPUT_DELAY_MASK 0x007C000000 +#define A38X_RTC_READ_OUTPUT_DELAY_MAX 0x1F +#define A8K_RTC_BRIDGE_TIMING_CTRL0 0x0 +#define A8K_RTC_WRCLK_PERIOD_SHIFT 0 +#define A8K_RTC_WRCLK_PERIOD_MASK 0x000000FFFF +#define A8K_RTC_WRCLK_PERIOD_VAL 0x3FF +#define A8K_RTC_WRCLK_SETUP_SHIFT 16 +#define A8K_RTC_WRCLK_SETUP_MASK 0x00FFFF0000 +#define A8K_RTC_WRCLK_SETUP_VAL 29 +#define A8K_RTC_BRIDGE_TIMING_CTRL1 0x4 +#define A8K_RTC_READ_OUTPUT_DELAY_SHIFT 0 +#define A8K_RTC_READ_OUTPUT_DELAY_MASK 0x000000FFFF +#define A8K_RTC_READ_OUTPUT_DELAY_VAL 0x3F + + #define RTC_RES 0 #define RTC_SOC_RES 1 @@ -94,6 +107,7 @@ struct mv_rtc_softc { device_t dev; struct resource *res[2]; struct mtx mutex; + int rtc_type; }; static int mv_rtc_probe(device_t dev); @@ -107,7 +121,8 @@ static inline uint32_t mv_rtc_reg_read(struct mv_rtc_s bus_size_t off); static inline int mv_rtc_reg_write(struct mv_rtc_softc *sc, bus_size_t off, uint32_t val); -static inline void mv_rtc_configure_bus(struct mv_rtc_softc *sc); +static inline void mv_rtc_configure_bus_a38x(struct mv_rtc_softc *sc); +static inline void mv_rtc_configure_bus_a8k(struct mv_rtc_softc *sc); static device_method_t mv_rtc_methods[] = { DEVMETHOD(device_probe, mv_rtc_probe), @@ -126,10 +141,13 @@ static driver_t mv_rtc_driver = { sizeof(struct mv_rtc_softc), }; +#define RTC_A38X 1 +#define RTC_A8K 2 + static struct ofw_compat_data mv_rtc_compat[] = { - {"marvell,armada-380-rtc", true}, - {"marvell,armada-8k-rtc", true}, - {NULL, false}, + {"marvell,armada-380-rtc", RTC_A38X}, + {"marvell,armada-8k-rtc", RTC_A8K}, + {NULL, 0}, }; static devclass_t mv_rtc_devclass; @@ -198,20 +216,29 @@ mv_rtc_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; + sc->rtc_type = ofw_bus_search_compatible(dev, mv_rtc_compat)->ocd_data; - clock_register(dev, RTC_RES_US); - mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); ret = bus_alloc_resources(dev, res_spec, sc->res); - if (ret != 0) { device_printf(dev, "could not allocate resources\n"); mtx_destroy(&sc->mutex); return (ENXIO); } - mv_rtc_configure_bus(sc); + switch (sc->rtc_type) { + case RTC_A38X: + mv_rtc_configure_bus_a38x(sc); + break; + case RTC_A8K: + mv_rtc_configure_bus_a8k(sc); + break; + default: + panic("Unknown RTC type: %d", sc->rtc_type); + } + clock_register(dev, RTC_RES_US); + return (0); } @@ -239,13 +266,15 @@ mv_rtc_gettime(device_t dev, struct timespec *ts) MV_RTC_LOCK(sc); /* - * According to HW Errata if more than one second between - * two time reads is detected, then read once again + * According to HW Errata, if more than one second is detected + * between two time reads, then at least one of the reads gave + * an invalid value. */ - val = mv_rtc_reg_read(sc, RTC_TIME); - val_check = mv_rtc_reg_read(sc, RTC_TIME); - if (val_check - val > 1) + do { + val = mv_rtc_reg_read(sc, RTC_TIME); + DELAY(100); val_check = mv_rtc_reg_read(sc, RTC_TIME); + } while ((val_check - val) > 1); MV_RTC_UNLOCK(sc); @@ -284,7 +313,6 @@ mv_rtc_settime(device_t dev, struct timespec *ts) mv_rtc_reg_write(sc, RTC_STATUS, 0x0); mv_rtc_reg_write(sc, RTC_STATUS, 0x0); mv_rtc_reg_write(sc, RTC_TIME, ts->tv_sec); - MV_RTC_UNLOCK(sc); return (0); @@ -313,13 +341,30 @@ mv_rtc_reg_write(struct mv_rtc_softc *sc, bus_size_t o } static inline void -mv_rtc_configure_bus(struct mv_rtc_softc *sc) +mv_rtc_configure_bus_a38x(struct mv_rtc_softc *sc) { int val; - val = bus_read_4(sc->res[RTC_SOC_RES], RTC_BRIDGE_TIMING_CTRL); - val &= ~(RTC_WRCLK_PERIOD_MASK | RTC_READ_OUTPUT_DELAY_MASK); - val |= RTC_WRCLK_PERIOD_MAX << RTC_WRCLK_PERIOD_SHIFT; - val |= RTC_READ_OUTPUT_DELAY_MAX << RTC_READ_OUTPUT_DELAY_SHIFT; - bus_write_4(sc->res[RTC_SOC_RES], RTC_BRIDGE_TIMING_CTRL, val); + val = bus_read_4(sc->res[RTC_SOC_RES], A38X_RTC_BRIDGE_TIMING_CTRL); + val &= ~(A38X_RTC_WRCLK_PERIOD_MASK | A38X_RTC_READ_OUTPUT_DELAY_MASK); + val |= A38X_RTC_WRCLK_PERIOD_MAX << A38X_RTC_WRCLK_PERIOD_SHIFT; + val |= A38X_RTC_READ_OUTPUT_DELAY_MAX << A38X_RTC_READ_OUTPUT_DELAY_SHIFT; + bus_write_4(sc->res[RTC_SOC_RES], A38X_RTC_BRIDGE_TIMING_CTRL, val); +} + +static inline void +mv_rtc_configure_bus_a8k(struct mv_rtc_softc *sc) +{ + int val; + + val = bus_read_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL0); + val &= ~(A8K_RTC_WRCLK_PERIOD_MASK | A8K_RTC_WRCLK_SETUP_MASK); + val |= A8K_RTC_WRCLK_PERIOD_VAL << A8K_RTC_WRCLK_PERIOD_SHIFT; + val |= A8K_RTC_WRCLK_SETUP_VAL << A8K_RTC_WRCLK_SETUP_SHIFT; + bus_write_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL1, val); + + val = bus_read_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL0); + val &= ~A8K_RTC_READ_OUTPUT_DELAY_MASK; + val |= A8K_RTC_READ_OUTPUT_DELAY_VAL << A8K_RTC_READ_OUTPUT_DELAY_SHIFT; + bus_write_4(sc->res[RTC_SOC_RES], A8K_RTC_BRIDGE_TIMING_CTRL1, val); } Modified: stable/12/sys/arm/mv/gpio.c ============================================================================== --- stable/12/sys/arm/mv/gpio.c Sat Oct 31 15:58:05 2020 (r367215) +++ stable/12/sys/arm/mv/gpio.c Sat Oct 31 16:03:35 2020 (r367216) @@ -60,9 +60,6 @@ __FBSDID("$FreeBSD$"); #include "gpio_if.h" -#ifdef __aarch64__ -#include "opt_soc.h" -#endif #define GPIO_MAX_INTR_COUNT 8 #define GPIO_PINS_PER_REG 32 @@ -199,9 +196,6 @@ EARLY_DRIVER_MODULE(mv_gpio, simplebus, mv_gpio_driver struct ofw_compat_data compat_data[] = { { "mrvl,gpio", 1 }, { "marvell,orion-gpio", 1 }, -#ifdef SOC_MARVELL_8K - { "marvell,armada-8k-gpio", 1 }, -#endif { NULL, 0 } }; Copied: stable/12/sys/arm/mv/mvebu_gpio.c (from r362385, head/sys/arm/mv/mvebu_gpio.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm/mv/mvebu_gpio.c Sat Oct 31 16:03:35 2020 (r367216, copy of r362385, head/sys/arm/mv/mvebu_gpio.c) @@ -0,0 +1,869 @@ +/*- + * Copyright (c) 2020 Michal Meloun + * + * 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$"); + +/* + * ARMADA 8040 GPIO driver. + */ +#include "opt_platform.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "pic_if.h" +#include "syscon_if.h" + +#define GPIO_LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define GPIO_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define GPIO_LOCK_INIT(_sc) mtx_init(&_sc->mtx, \ + device_get_nameunit(_sc->dev), "mvebu_gpio", MTX_DEF) +#define GPIO_LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx); +#define GPIO_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED); +#define GPIO_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->mtx, MA_NOTOWNED); + +#define GPIO_DATA_OUT 0x00 +#define GPIO_CONTROL 0x04 +#define GPIO_BLINK_ENA 0x08 +#define GPIO_DATA_IN_POL 0x0C +#define GPIO_DATA_IN 0x10 +#define GPIO_INT_CAUSE 0x14 +#define GPIO_INT_MASK 0x18 +#define GPIO_INT_LEVEL_MASK 0x1C +#define GPIO_CONTROL_SET 0x28 +#define GPIO_CONTROL_CLR 0x2C +#define GPIO_DATA_SET 0x30 +#define GPIO_DATA_CLR 0x34 + +#define GPIO_BIT(_p) ((_p) % 32) +#define GPIO_REGNUM(_p) ((_p) / 32) + +#define MV_GPIO_MAX_NIRQS 4 +#define MV_GPIO_MAX_NPINS 32 + +#define RD4(sc, reg) SYSCON_READ_4((sc)->syscon, (reg)) +#define WR4(sc, reg, val) SYSCON_WRITE_4((sc)->syscon, (reg), (val)) + +struct mvebu_gpio_irqsrc { + struct intr_irqsrc isrc; + u_int irq; + bool is_level; + bool is_inverted; +}; + +struct mvebu_gpio_softc; +struct mvebu_gpio_irq_cookie { + struct mvebu_gpio_softc *sc; + int bank_num; +}; + +struct mvebu_gpio_softc { + device_t dev; + device_t busdev; + struct mtx mtx; + struct syscon *syscon; + uint32_t offset; + struct resource *irq_res[MV_GPIO_MAX_NIRQS]; + void *irq_ih[MV_GPIO_MAX_NIRQS]; + struct mvebu_gpio_irq_cookie irq_cookies[MV_GPIO_MAX_NIRQS]; + int gpio_npins; + struct gpio_pin gpio_pins[MV_GPIO_MAX_NPINS]; + struct mvebu_gpio_irqsrc *isrcs; +}; + +static struct ofw_compat_data compat_data[] = { + {"marvell,armada-8k-gpio", 1}, + {NULL, 0} +}; + +/* -------------------------------------------------------------------------- + * + * GPIO + * + */ +static inline void +gpio_write(struct mvebu_gpio_softc *sc, bus_size_t reg, + struct gpio_pin *pin, uint32_t val) +{ + uint32_t tmp; + int bit; + + bit = GPIO_BIT(pin->gp_pin); + tmp = 0x100 << bit; /* mask */ + tmp |= (val & 1) << bit; /* value */ + SYSCON_WRITE_4(sc->syscon, sc->offset + GPIO_REGNUM(pin->gp_pin) + reg, + tmp); +} + +static inline uint32_t +gpio_read(struct mvebu_gpio_softc *sc, bus_size_t reg, struct gpio_pin *pin) +{ + int bit; + uint32_t val; + + bit = GPIO_BIT(pin->gp_pin); + val = SYSCON_READ_4(sc->syscon, + sc->offset + GPIO_REGNUM(pin->gp_pin) + reg); + return (val >> bit) & 1; +} + +static void +mvebu_gpio_pin_configure(struct mvebu_gpio_softc *sc, struct gpio_pin *pin, + unsigned int flags) +{ + + if ((flags & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == 0) + return; + + /* Manage input/output */ + pin->gp_flags &= ~(GPIO_PIN_INPUT | GPIO_PIN_OUTPUT); + if (flags & GPIO_PIN_OUTPUT) { + pin->gp_flags |= GPIO_PIN_OUTPUT; + gpio_write(sc, GPIO_CONTROL_SET, pin, 1); + } else { + pin->gp_flags |= GPIO_PIN_INPUT; + gpio_write(sc, GPIO_CONTROL_CLR, pin, 1); + } +} + +static device_t +mvebu_gpio_get_bus(device_t dev) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + return (sc->busdev); +} + +static int +mvebu_gpio_pin_max(device_t dev, int *maxpin) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + *maxpin = sc->gpio_npins - 1; + return (0); +} + +static int +mvebu_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + *caps = sc->gpio_pins[pin].gp_caps; + + return (0); +} + +static int +mvebu_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + *flags = sc->gpio_pins[pin].gp_flags; + + return (0); +} + +static int +mvebu_gpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + memcpy(name, sc->gpio_pins[pin].gp_name, GPIOMAXNAME); + + return (0); +} + +static int +mvebu_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + + mvebu_gpio_pin_configure(sc, &sc->gpio_pins[pin], flags); + + return (0); +} + +static int +mvebu_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + if (value != 0) + gpio_write(sc, GPIO_DATA_SET, &sc->gpio_pins[pin], 1); + else + gpio_write(sc, GPIO_DATA_CLR, &sc->gpio_pins[pin], 1); + + return (0); +} + +static int +mvebu_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val) +{ + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + GPIO_LOCK(sc); + *val = gpio_read(sc, GPIO_DATA_IN, &sc->gpio_pins[pin]); + *val ^= gpio_read(sc, GPIO_DATA_IN_POL, &sc->gpio_pins[pin]); + GPIO_UNLOCK(sc); + + return (0); +} + +static int +mvebu_gpio_pin_toggle(device_t dev, uint32_t pin) +{ + struct mvebu_gpio_softc *sc; + uint32_t val; + + sc = device_get_softc(dev); + if (pin >= sc->gpio_npins) + return (EINVAL); + + GPIO_LOCK(sc); + mvebu_gpio_pin_get(sc->dev, pin, &val); + if (val != 0) + gpio_write(sc, GPIO_DATA_CLR, &sc->gpio_pins[pin], 1); + else + gpio_write(sc, GPIO_DATA_SET, &sc->gpio_pins[pin], 1); + GPIO_UNLOCK(sc); + + return (0); +} + + +/* -------------------------------------------------------------------------- + * + * Interrupts + * + */ +static inline void +intr_modify(struct mvebu_gpio_softc *sc, bus_addr_t reg, + struct mvebu_gpio_irqsrc *mgi, uint32_t val, uint32_t mask) +{ + int bit; + + bit = GPIO_BIT(mgi->irq); + GPIO_LOCK(sc); + val = SYSCON_MODIFY_4(sc->syscon, + sc->offset + GPIO_REGNUM(mgi->irq) + reg, val, mask); + GPIO_UNLOCK(sc); +} + +static inline void +mvebu_gpio_isrc_mask(struct mvebu_gpio_softc *sc, + struct mvebu_gpio_irqsrc *mgi, uint32_t val) +{ + + if (mgi->is_level) + intr_modify(sc, GPIO_INT_LEVEL_MASK, mgi, val, 1); + else + intr_modify(sc, GPIO_INT_MASK, mgi, val, 1); +} + +static inline void +mvebu_gpio_isrc_eoi(struct mvebu_gpio_softc *sc, + struct mvebu_gpio_irqsrc *mgi) +{ + + if (!mgi->is_level) + intr_modify(sc, GPIO_INT_CAUSE, mgi, 1, 1); +} + + +static int +mvebu_gpio_pic_attach(struct mvebu_gpio_softc *sc) +{ + int rv; + uint32_t irq; + const char *name; + + sc->isrcs = malloc(sizeof(*sc->isrcs) * sc->gpio_npins, M_DEVBUF, + M_WAITOK | M_ZERO); + + name = device_get_nameunit(sc->dev); + for (irq = 0; irq < sc->gpio_npins; irq++) { + sc->isrcs[irq].irq = irq; + sc->isrcs[irq].is_level = false; + sc->isrcs[irq].is_inverted = false; + rv = intr_isrc_register(&sc->isrcs[irq].isrc, + sc->dev, 0, "%s,%u", name, irq); + if (rv != 0) + return (rv); /* XXX deregister ISRCs */ + } + if (intr_pic_register(sc->dev, + OF_xref_from_node(ofw_bus_get_node(sc->dev))) == NULL) + return (ENXIO); + + return (0); +} + +static int +mvebu_gpio_pic_detach(struct mvebu_gpio_softc *sc) +{ + + /* + * There has not been established any procedure yet + * how to detach PIC from living system correctly. + */ + device_printf(sc->dev, "%s: not implemented yet\n", __func__); + return (EBUSY); +} + + +static void +mvebu_gpio_pic_disable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + mvebu_gpio_isrc_mask(sc, mgi, 0); +} + +static void +mvebu_gpio_pic_enable_intr(device_t dev, struct intr_irqsrc *isrc) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + mvebu_gpio_isrc_mask(sc, mgi, 1); +} + +static int +mvebu_gpio_pic_map_fdt(struct mvebu_gpio_softc *sc, u_int ncells, + pcell_t *cells, u_int *irqp, bool *invertedp, bool *levelp) +{ + bool inverted, level; + + /* + * The first cell is the interrupt number. + * The second cell is used to specify flags: + * bits[3:0] trigger type and level flags: + * 1 = low-to-high edge triggered. + * 2 = high-to-low edge triggered. + * 4 = active high level-sensitive. + * 8 = active low level-sensitive. + */ + if (ncells != 2 || cells[0] >= sc->gpio_npins) + return (EINVAL); + + + switch (cells[1]) { + case 1: + inverted = false; + level = false; + break; + case 2: + inverted = true; + level = false; + break; + case 4: + inverted = false; + level = true; + break; + case 8: + inverted = true; + level = true; + break; + default: + return (EINVAL); + } + *irqp = cells[0]; + if (invertedp != NULL) + *invertedp = inverted; + if (levelp != NULL) + *levelp = level; + return (0); +} + + +static int +mvebu_gpio_pic_map_gpio(struct mvebu_gpio_softc *sc, u_int gpio_pin_num, + u_int gpio_pin_flags, u_int intr_mode, u_int *irqp, bool *invertedp, + bool *levelp) +{ + bool inverted, level; + + if (gpio_pin_num >= sc->gpio_npins) + return (EINVAL); + + switch (intr_mode) { + case GPIO_INTR_LEVEL_LOW: + inverted = true; + level = true; + break; + case GPIO_INTR_LEVEL_HIGH: + inverted = false; + level = true; + break; + case GPIO_INTR_CONFORM: + case GPIO_INTR_EDGE_RISING: + inverted = false; + level = false; + break; + case GPIO_INTR_EDGE_FALLING: + inverted = true; + level = false; + break; + default: + return (EINVAL); + } + *irqp = gpio_pin_num; + if (invertedp != NULL) + *invertedp = inverted; + if (levelp != NULL) + *levelp = level; + return (0); +} + +static int +mvebu_gpio_pic_map_intr(device_t dev, struct intr_map_data *data, + struct intr_irqsrc **isrcp) +{ + int rv; + u_int irq; + struct mvebu_gpio_softc *sc; + + sc = device_get_softc(dev); + + if (data->type == INTR_MAP_DATA_FDT) { + struct intr_map_data_fdt *daf; + + daf = (struct intr_map_data_fdt *)data; + rv = mvebu_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq, + NULL, NULL); + } else if (data->type == INTR_MAP_DATA_GPIO) { + struct intr_map_data_gpio *dag; + + dag = (struct intr_map_data_gpio *)data; + rv = mvebu_gpio_pic_map_gpio(sc, dag->gpio_pin_num, + dag->gpio_pin_flags, dag->gpio_intr_mode, &irq, NULL, NULL); + } else + return (ENOTSUP); + + if (rv == 0) + *isrcp = &sc->isrcs[irq].isrc; + return (rv); +} + +static void +mvebu_gpio_pic_post_filter(device_t dev, struct intr_irqsrc *isrc) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + if (mgi->is_level) + mvebu_gpio_isrc_eoi(sc, mgi); +} + +static void +mvebu_gpio_pic_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + mvebu_gpio_isrc_mask(sc, mgi, 1); +} + +static void +mvebu_gpio_pic_pre_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + + mvebu_gpio_isrc_mask(sc, mgi, 0); + if (mgi->is_level) + mvebu_gpio_isrc_eoi(sc, mgi); +} + +static int +mvebu_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + u_int irq; + bool inverted, level; + int rv; + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + + if (data == NULL) + return (ENOTSUP); + + /* Get and check config for an interrupt. */ + if (data->type == INTR_MAP_DATA_FDT) { + struct intr_map_data_fdt *daf; + + daf = (struct intr_map_data_fdt *)data; + rv = mvebu_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq, + &inverted, &level); + } else if (data->type == INTR_MAP_DATA_GPIO) { + struct intr_map_data_gpio *dag; + + dag = (struct intr_map_data_gpio *)data; + rv = mvebu_gpio_pic_map_gpio(sc, dag->gpio_pin_num, + dag->gpio_pin_flags, dag->gpio_intr_mode, &irq, + &inverted, &level); + } else + return (ENOTSUP); + + if (rv != 0) + return (EINVAL); + + /* + * If this is a setup for another handler, + * only check that its configuration match. + */ + if (isrc->isrc_handlers != 0) + return ( + mgi->is_level == level && mgi->is_inverted == inverted ? + 0 : EINVAL); + + mgi->is_level = level; + mgi->is_inverted = inverted; + intr_modify(sc, GPIO_DATA_IN_POL, mgi, inverted ? 1 : 0, 1); + mvebu_gpio_pic_enable_intr(dev, isrc); + + return (0); +} + +static int +mvebu_gpio_pic_teardown_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ + struct mvebu_gpio_softc *sc; + struct mvebu_gpio_irqsrc *mgi; + + sc = device_get_softc(dev); + mgi = (struct mvebu_gpio_irqsrc *)isrc; + + if (isrc->isrc_handlers == 0) + mvebu_gpio_isrc_mask(sc, mgi, 0); + return (0); +} + +/* -------------------------------------------------------------------------- + * + * Bus + * + */ + +static int +mvebu_gpio_intr(void *arg) +{ + u_int i, lvl, edge; + struct mvebu_gpio_softc *sc; + struct trapframe *tf; + struct mvebu_gpio_irqsrc *mgi; + struct mvebu_gpio_irq_cookie *cookie; + + + cookie = (struct mvebu_gpio_irq_cookie *)arg; + sc = cookie->sc; + tf = curthread->td_intr_frame; + + for (i = 0; i < sc->gpio_npins; i++) { + lvl = gpio_read(sc, GPIO_DATA_IN, &sc->gpio_pins[i]); + lvl &= gpio_read(sc, GPIO_INT_LEVEL_MASK, &sc->gpio_pins[i]); + edge = gpio_read(sc, GPIO_DATA_IN, &sc->gpio_pins[i]); + edge &= gpio_read(sc, GPIO_INT_LEVEL_MASK, &sc->gpio_pins[i]); + if (edge == 0 || lvl == 0) + continue; + + mgi = &sc->isrcs[i]; + if (!mgi->is_level) + mvebu_gpio_isrc_eoi(sc, mgi); + if (intr_isrc_dispatch(&mgi->isrc, tf) != 0) { + mvebu_gpio_isrc_mask(sc, mgi, 0); + if (mgi->is_level) + mvebu_gpio_isrc_eoi(sc, mgi); + device_printf(sc->dev, + "Stray irq %u disabled\n", mgi->irq); + } + } + return (FILTER_HANDLED); +} + +static int +mvebu_gpio_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, "Marvell Integrated GPIO Controller"); + return (0); +} + +static int +mvebu_gpio_detach(device_t dev) +{ + struct mvebu_gpio_softc *sc; + int i; + + sc = device_get_softc(dev); + + KASSERT(mtx_initialized(&sc->mtx), ("gpio mutex not initialized")); + + for (i = 0; i < MV_GPIO_MAX_NIRQS; i++) { + if (sc->irq_ih[i] != NULL) + bus_teardown_intr(dev, sc->irq_res[i], sc->irq_ih[i]); + } + + if (sc->isrcs != NULL) + mvebu_gpio_pic_detach(sc); + + gpiobus_detach_bus(dev); + + for (i = 0; i < MV_GPIO_MAX_NIRQS; i++) { + if (sc->irq_res[i] != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, + sc->irq_res[i]); + } + GPIO_LOCK_DESTROY(sc); + + return(0); +} + +static int +mvebu_gpio_attach(device_t dev) +{ + struct mvebu_gpio_softc *sc; + phandle_t node; + struct gpio_pin *pin; + pcell_t pincnt; + int i, rv, rid; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + + GPIO_LOCK_INIT(sc); + + pincnt = 0; + rv = OF_getencprop(node, "ngpios", &pincnt, sizeof(pcell_t)); + if (rv < 0) { + device_printf(dev, + "ERROR: no pin-count or ngpios entry found!\n"); + return (ENXIO); + } + + sc->gpio_npins = MIN(pincnt, MV_GPIO_MAX_NPINS); + if (bootverbose) + device_printf(dev, + "%d pins available\n", sc->gpio_npins); + + rv = OF_getencprop(node, "offset", &sc->offset, sizeof(sc->offset)); + if (rv == -1) { + device_printf(dev, "ERROR: no 'offset' property found!\n"); + return (ENXIO); + } + + if (SYSCON_GET_HANDLE(sc->dev, &sc->syscon) != 0 || + sc->syscon == NULL) { + device_printf(dev, "ERROR: cannot get syscon handle!\n"); + return (ENXIO); + } + + /* Allocate interrupts. */ + for (i = 0; i < MV_GPIO_MAX_NIRQS; i++) { + sc->irq_cookies[i].sc = sc; + sc->irq_cookies[i].bank_num = i; + rid = i; + sc->irq_res[i] = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &rid, RF_ACTIVE); + if (sc->irq_res[i] == NULL) + break; + if ((bus_setup_intr(dev, sc->irq_res[i], + INTR_TYPE_MISC | INTR_MPSAFE, mvebu_gpio_intr, NULL, + &sc->irq_cookies[i], &sc->irq_ih[i]))) { + device_printf(dev, + "WARNING: unable to register interrupt handler\n"); + mvebu_gpio_detach(dev); + return (ENXIO); + } + } + + /* Init GPIO pins */ + for (i = 0; i < sc->gpio_npins; i++) { + pin = sc->gpio_pins + i; + pin->gp_pin = i; + if (sc->irq_res[0] != NULL) + pin->gp_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | + GPIO_INTR_LEVEL_LOW | GPIO_INTR_LEVEL_HIGH | + GPIO_INTR_EDGE_RISING | GPIO_INTR_EDGE_FALLING; + else + pin->gp_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT; + pin->gp_flags = + gpio_read(sc, GPIO_CONTROL, &sc->gpio_pins[i]) != 0 ? + GPIO_PIN_OUTPUT : GPIO_PIN_INPUT; + snprintf(pin->gp_name, GPIOMAXNAME, "gpio%d", i); + + /* Init HW */ + gpio_write(sc, GPIO_INT_MASK, pin, 0); + gpio_write(sc, GPIO_INT_LEVEL_MASK, pin, 0); + gpio_write(sc, GPIO_INT_CAUSE, pin, 1); + gpio_write(sc, GPIO_DATA_IN_POL, pin, 1); + gpio_write(sc, GPIO_BLINK_ENA, pin, 0); + } + + if (sc->irq_res[0] != NULL) { + rv = mvebu_gpio_pic_attach(sc); + if (rv != 0) { + device_printf(dev, "WARNING: unable to attach PIC\n"); + mvebu_gpio_detach(dev); + return (rv); + } + } + + sc->busdev = gpiobus_attach_bus(dev); + if (sc->busdev == NULL) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:05:25 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 993D444FAFB; Sat, 31 Oct 2020 16:05:25 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkY13XBCz4cZL; Sat, 31 Oct 2020 16:05:25 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5416F9EF7; Sat, 31 Oct 2020 16:05:25 +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 09VG5PWh023828; Sat, 31 Oct 2020 16:05:25 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VG5P6n023827; Sat, 31 Oct 2020 16:05:25 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311605.09VG5P6n023827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:05:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367217 - stable/12/sys/arm64/arm64 X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm64/arm64 X-SVN-Commit-Revision: 367217 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:05:25 -0000 Author: mmel Date: Sat Oct 31 16:05:24 2020 New Revision: 367217 URL: https://svnweb.freebsd.org/changeset/base/367217 Log: MFC r362388: Use native-sized accesses when accessing memory from kdb. Not all MMIO mapped devices supports byte access. Modified: stable/12/sys/arm64/arm64/db_interface.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/arm64/db_interface.c ============================================================================== --- stable/12/sys/arm64/arm64/db_interface.c Sat Oct 31 16:03:35 2020 (r367216) +++ stable/12/sys/arm64/arm64/db_interface.c Sat Oct 31 16:05:24 2020 (r367217) @@ -118,12 +118,25 @@ db_read_bytes(vm_offset_t addr, size_t size, char *dat void *prev_jb; const char *src; int ret; + uint64_t tmp64; + uint32_t tmp32; + uint16_t tmp16; prev_jb = kdb_jmpbuf(jb); ret = setjmp(jb); if (ret == 0) { src = (const char *)addr; + if (size == 8 && (addr & 7) == 0) { + tmp64 = *((const int *)src); + src = (const char *)&tmp64; + } else if (size == 4 && (addr & 3) == 0) { + tmp32 = *((const int *)src); + src = (const char *)&tmp32; + } else if (size == 2 && (addr & 1) == 0) { + tmp16 = *((const short *)src); + src = (const char *)&tmp16; + } while (size-- > 0) *data++ = *src++; } @@ -142,14 +155,33 @@ db_write_bytes(vm_offset_t addr, size_t size, char *da void *prev_jb; char *dst; int ret; + uint64_t tmp64; + uint32_t tmp32; + uint16_t tmp16; prev_jb = kdb_jmpbuf(jb); ret = setjmp(jb); if (ret == 0) { - dst = (char *)addr; - while (size-- > 0) - *dst++ = *data++; - + if (size == 8 && (addr & 7) == 0) { + dst = (char *)&tmp64; + while (size-- > 0) + *dst++ = *data++; + *((uint64_t *)addr) = tmp64; + } else if (size == 4 && (addr & 3) == 0) { + dst = (char *)&tmp32; + while (size-- > 0) + *dst++ = *data++; + *((uint32_t *)addr) = tmp32; + } else if (size == 2 && (addr & 1) == 0) { + dst = (char *)&tmp16; + while (size-- > 0) + *dst++ = *data++; + *((uint32_t *)addr) = tmp16; + } else { + dst = (char *)addr; + while (size-- > 0) + *dst++ = *data++; + } dsb(ish); /* Clean D-cache and invalidate I-cache */ From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:15:20 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 169AF450213; Sat, 31 Oct 2020 16:15:20 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkmR6rXkz4dLr; Sat, 31 Oct 2020 16:15:19 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF5BE9C67; Sat, 31 Oct 2020 16:15:19 +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 09VGFJRv030437; Sat, 31 Oct 2020 16:15:19 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VGFJ5R030436; Sat, 31 Oct 2020 16:15:19 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311615.09VGFJ5R030436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:15:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367218 - stable/12/sys/arm/mv X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm/mv X-SVN-Commit-Revision: 367218 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:15:20 -0000 Author: mmel Date: Sat Oct 31 16:15:19 2020 New Revision: 367218 URL: https://svnweb.freebsd.org/changeset/base/367218 Log: MFC r363121: Fix the module name for some arm drivers. Module name (unlike of the of driver name) must be system wide unique. Modified: stable/12/sys/arm/mv/mvebu_gpio.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/mv/mvebu_gpio.c ============================================================================== --- stable/12/sys/arm/mv/mvebu_gpio.c Sat Oct 31 16:05:24 2020 (r367217) +++ stable/12/sys/arm/mv/mvebu_gpio.c Sat Oct 31 16:15:19 2020 (r367218) @@ -864,6 +864,6 @@ static device_method_t mvebu_gpio_methods[] = { static devclass_t mvebu_gpio_devclass; static DEFINE_CLASS_0(gpio, mvebu_gpio_driver, mvebu_gpio_methods, sizeof(struct mvebu_gpio_softc)); -EARLY_DRIVER_MODULE(gpio, simplebus, mvebu_gpio_driver, +EARLY_DRIVER_MODULE(mvebu_gpio, simplebus, mvebu_gpio_driver, mvebu_gpio_devclass, NULL, NULL, BUS_PASS_TIMER + BUS_PASS_ORDER_LAST); From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:18:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D0A04503B2; Sat, 31 Oct 2020 16:18:56 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkrc0Nspz4dWH; Sat, 31 Oct 2020 16:18:56 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E556AA598; Sat, 31 Oct 2020 16:18:55 +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 09VGItlf030636; Sat, 31 Oct 2020 16:18:55 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VGItr5030635; Sat, 31 Oct 2020 16:18:55 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311618.09VGItr5030635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:18:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367219 - stable/12/sys/dev/pci X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/pci X-SVN-Commit-Revision: 367219 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:18:56 -0000 Author: mmel Date: Sat Oct 31 16:18:55 2020 New Revision: 367219 URL: https://svnweb.freebsd.org/changeset/base/367219 Log: MFC r362387: Improve DesignWare PCIe driver: - only normal memory window is mandatory, prefetchable memory and I/O windows should be optional - full PCIe configuration space is supported - remove duplicated check from function for accessing configuration space. It is already contained in pci_dw_check_dev() Modified: stable/12/sys/dev/pci/pci_dw.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/pci/pci_dw.c ============================================================================== --- stable/12/sys/dev/pci/pci_dw.c Sat Oct 31 16:15:19 2020 (r367218) +++ stable/12/sys/dev/pci/pci_dw.c Sat Oct 31 16:18:55 2020 (r367219) @@ -156,7 +156,7 @@ pci_dw_check_dev(struct pci_dw_softc *sc, u_int bus, u int rv; if (bus < sc->bus_start || bus > sc->bus_end || slot > PCI_SLOTMAX || - func > PCI_FUNCMAX || reg > PCI_REGMAX) + func > PCI_FUNCMAX || reg > PCIE_REGMAX) return (false); /* link is needed for access to all non-root busses */ @@ -234,7 +234,7 @@ pci_dw_setup_hw(struct pci_dw_softc *sc) return (rv); /* If we have enouht viewports ..*/ - if (sc->num_viewport >= 3) { + if (sc->num_viewport >= 3 && sc->io_range.size != 0) { /* Setup outbound I/O window */ rv = pci_dw_map_out_atu(sc, 0, IATU_CTRL1_TYPE_MEM, sc->io_range.host, sc->io_range.pci, sc->io_range.size); @@ -345,7 +345,7 @@ pci_dw_decode_ranges(struct pci_dw_softc *sc, struct o } } } - if ((sc->io_range.size == 0) || (sc->mem_range.size == 0)) { + if (sc->mem_range.size == 0) { device_printf(sc->dev, " Not all required ranges are found in DT\n"); return (ENXIO); @@ -375,10 +375,6 @@ pci_dw_read_config(device_t dev, u_int bus, u_int slot if (!pci_dw_check_dev(sc, bus, slot, func, reg)) return (0xFFFFFFFFU); - if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || - (reg > PCI_REGMAX)) - return (0xFFFFFFFFU); - if (bus == sc->root_bus) { res = (sc->dbi_res); } else { @@ -424,10 +420,6 @@ pci_dw_write_config(device_t dev, u_int bus, u_int slo sc = device_get_softc(dev); if (!pci_dw_check_dev(sc, bus, slot, func, reg)) - return; - - if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || - (reg > PCI_REGMAX)) return; if (bus == sc->root_bus) { From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:24:12 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D7C1450471; Sat, 31 Oct 2020 16:24:12 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkyh0GhXz4dr5; Sat, 31 Oct 2020 16:24: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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E0A5EA4E4; Sat, 31 Oct 2020 16:24:11 +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 09VGOBMX036359; Sat, 31 Oct 2020 16:24:11 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VGOB1Y036358; Sat, 31 Oct 2020 16:24:11 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311624.09VGOB1Y036358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:24:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367220 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 367220 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:24:12 -0000 Author: mmel Date: Sat Oct 31 16:24:11 2020 New Revision: 367220 URL: https://svnweb.freebsd.org/changeset/base/367220 Log: MFC r363123,r363510: r363123: Reverse the processing order of assigned clocks property. Linux processes these clocks in reverse order and some DT relies on this fact. For example, the frequency setting for a given PLL is the last in the list, preceded by the frequency setting of its following divider or so... r363510: Revert r363123. As Emanuel poited me the Linux processes these clock assignments in forward order, not in reversed. I misread the original code. Tha problem with wrong order for assigned clocks found in tegra (and some imx) DT should be reanalyzed and solved by different way. Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:51:19 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CB658451461; Sat, 31 Oct 2020 16:51:19 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNlYz4BBzz3Sk2; Sat, 31 Oct 2020 16:51:19 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7397CAB8C; Sat, 31 Oct 2020 16:51:19 +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 09VGpJmn051413; Sat, 31 Oct 2020 16:51:19 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VGpJJi051412; Sat, 31 Oct 2020 16:51:19 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311651.09VGpJJi051412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:51:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367222 - stable/12/sys/arm64/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm64/conf X-SVN-Commit-Revision: 367222 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:51:19 -0000 Author: mmel Date: Sat Oct 31 16:51:19 2020 New Revision: 367222 URL: https://svnweb.freebsd.org/changeset/base/367222 Log: MFC r365929: Adjust DMA alignment for USB stack. It should be at least as large as the maximum value of caheline size for currently known CPUs. Modified: stable/12/sys/arm64/conf/GENERIC Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/conf/GENERIC ============================================================================== --- stable/12/sys/arm64/conf/GENERIC Sat Oct 31 16:39:27 2020 (r367221) +++ stable/12/sys/arm64/conf/GENERIC Sat Oct 31 16:51:19 2020 (r367222) @@ -182,6 +182,7 @@ device uart_snps device pl011 # USB support +options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. device aw_usbphy # Allwinner USB PHY device rk_usb2phy # Rockchip USB2PHY device rk_typec_phy # Rockchip TypeC PHY From owner-svn-src-stable-12@freebsd.org Sat Oct 31 17:07:44 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 558FE451B3B; Sat, 31 Oct 2020 17:07:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNlww1G4jz3TG3; Sat, 31 Oct 2020 17:07:44 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09FB7AB2D; Sat, 31 Oct 2020 17:07:44 +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 09VH7h4B062072; Sat, 31 Oct 2020 17:07:43 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VH7hqt062071; Sat, 31 Oct 2020 17:07:43 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311707.09VH7hqt062071@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:07:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367223 - stable/12/sys/dev/fdt X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/fdt X-SVN-Commit-Revision: 367223 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:07:44 -0000 Author: mmel Date: Sat Oct 31 17:07:43 2020 New Revision: 367223 URL: https://svnweb.freebsd.org/changeset/base/367223 Log: MFC r342008,r363799,r366146: r342008: fdt: Add support for simple-mfd bus r363799: Allow child classes of simplebus to call attach directly r366146: Make simplebus friendlier for subclassing. Modified: stable/12/sys/dev/fdt/simplebus.c stable/12/sys/dev/fdt/simplebus.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/fdt/simplebus.c ============================================================================== --- stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 16:51:19 2020 (r367222) +++ stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 17:07:43 2020 (r367223) @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); * Bus interface. */ static int simplebus_probe(device_t dev); -static int simplebus_attach(device_t dev); static struct resource *simplebus_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); static void simplebus_probe_nomatch(device_t bus, device_t child); @@ -68,7 +67,7 @@ static device_method_t simplebus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, simplebus_probe), DEVMETHOD(device_attach, simplebus_attach), - DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_detach, simplebus_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume, bus_generic_resume), @@ -134,15 +133,16 @@ simplebus_probe(device_t dev) return (BUS_PROBE_GENERIC); } -static int -simplebus_attach(device_t dev) +int +simplebus_attach_impl(device_t dev) { struct simplebus_softc *sc; phandle_t node; sc = device_get_softc(dev); simplebus_init(dev, 0); - if (simplebus_fill_ranges(sc->node, sc) < 0) { + if ((sc->flags & SB_FLAG_NO_RANGES) == 0 && + simplebus_fill_ranges(sc->node, sc) < 0) { device_printf(dev, "could not get ranges\n"); return (ENXIO); } @@ -154,7 +154,32 @@ simplebus_attach(device_t dev) for (node = OF_child(sc->node); node > 0; node = OF_peer(node)) simplebus_add_device(dev, node, 0, NULL, -1, NULL); + + return (0); +} + +int +simplebus_attach(device_t dev) +{ + int rv; + + rv = simplebus_attach_impl(dev); + if (rv != 0) + return (rv); + return (bus_generic_attach(dev)); +} + +int +simplebus_detach(device_t dev) +{ + struct simplebus_softc *sc; + + sc = device_get_softc(dev); + if (sc->ranges != NULL) + free(sc->ranges, M_DEVBUF); + + return (bus_generic_detach(dev)); } void Modified: stable/12/sys/dev/fdt/simplebus.h ============================================================================== --- stable/12/sys/dev/fdt/simplebus.h Sat Oct 31 16:51:19 2020 (r367222) +++ stable/12/sys/dev/fdt/simplebus.h Sat Oct 31 17:07:43 2020 (r367223) @@ -47,6 +47,8 @@ struct simplebus_softc { struct simplebus_range *ranges; int nranges; +#define SB_FLAG_NO_RANGES (1 << 0) /* Bus doesn't have ranges property */ + int flags; pcell_t acells, scells; }; @@ -63,4 +65,9 @@ struct simplebus_devinfo *simplebus_setup_dinfo(device struct simplebus_devinfo *di); int simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc); + +int simplebus_attach(device_t dev); +int simplebus_attach_impl(device_t dev); +int simplebus_detach(device_t dev); + #endif /* _FDT_SIMPLEBUS_H */ From owner-svn-src-stable-12@freebsd.org Sat Oct 31 17:09:26 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 415FB451BD8; Sat, 31 Oct 2020 17:09:26 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNlyt14m6z3TRc; Sat, 31 Oct 2020 17:09:26 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0839FAF1D; Sat, 31 Oct 2020 17:09:26 +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 09VH9PbN062203; Sat, 31 Oct 2020 17:09:25 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VH9PBa062201; Sat, 31 Oct 2020 17:09:25 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311709.09VH9PBa062201@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:09:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367224 - in stable/12/sys/dev: extres/syscon fdt X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: in stable/12/sys/dev: extres/syscon fdt X-SVN-Commit-Revision: 367224 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:09:26 -0000 Author: mmel Date: Sat Oct 31 17:09:25 2020 New Revision: 367224 URL: https://svnweb.freebsd.org/changeset/base/367224 Log: MFC r366156: Correctly handle nodes compatible with "syscon", "simple-bus". Syscon can also have child nodes that share a registration file with it. To do this correctly, follow these steps: - subclass syscon from simplebus and expose it if the node is also "simple-bus" compatible. - block simplebus probe for this compatible string, so it's priority (bus pass) doesn't colide with syscon driver. Modified: stable/12/sys/dev/extres/syscon/syscon_generic.c stable/12/sys/dev/extres/syscon/syscon_generic.h stable/12/sys/dev/fdt/simplebus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/extres/syscon/syscon_generic.c ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:07:43 2020 (r367223) +++ stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:09:25 2020 (r367224) @@ -59,7 +59,7 @@ static int syscon_generic_write_4(struct syscon *sysco uint32_t val); static int syscon_generic_modify_4(struct syscon *syscon, bus_size_t offset, uint32_t clear_bits, uint32_t set_bits); - +static int syscon_generic_detach(device_t dev); /* * Generic syscon driver (FDT) */ @@ -148,7 +148,7 @@ static int syscon_generic_attach(device_t dev) { struct syscon_generic_softc *sc; - int rid; + int rid, rv; sc = device_get_softc(dev); sc->dev = dev; @@ -166,9 +166,20 @@ syscon_generic_attach(device_t dev) ofw_bus_get_node(dev)); if (sc->syscon == NULL) { device_printf(dev, "Failed to create/register syscon\n"); + syscon_generic_detach(dev); return (ENXIO); } - return (0); + if (ofw_bus_is_compatible(dev, "simple-bus")) { + rv = simplebus_attach_impl(sc->dev); + if (rv != 0) { + device_printf(dev, "Failed to create simplebus\n"); + syscon_generic_detach(dev); + return (ENXIO); + } + sc->simplebus_attached = true; + } + + return (bus_generic_attach(dev)); } static int @@ -181,7 +192,8 @@ syscon_generic_detach(device_t dev) syscon_unregister(sc->syscon); free(sc->syscon, M_SYSCON); } - + if (sc->simplebus_attached) + simplebus_detach(dev); SYSCON_LOCK_DESTROY(sc); if (sc->mem_res != NULL) @@ -198,8 +210,8 @@ static device_method_t syscon_generic_dmethods[] = { DEVMETHOD_END }; -DEFINE_CLASS_0(syscon_generic, syscon_generic_driver, syscon_generic_dmethods, - sizeof(struct syscon_generic_softc)); +DEFINE_CLASS_1(syscon_generic_dev, syscon_generic_driver, syscon_generic_dmethods, + sizeof(struct syscon_generic_softc), simplebus_driver); static devclass_t syscon_generic_devclass; EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver, Modified: stable/12/sys/dev/extres/syscon/syscon_generic.h ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon_generic.h Sat Oct 31 17:07:43 2020 (r367223) +++ stable/12/sys/dev/extres/syscon/syscon_generic.h Sat Oct 31 17:09:25 2020 (r367224) @@ -29,11 +29,15 @@ #ifndef DEV_SYSCON_GENERIC_H #define DEV_SYSCON_GENERIC_H +#include + struct syscon_generic_softc { + struct simplebus_softc simplebus; device_t dev; struct syscon *syscon; struct resource *mem_res; struct mtx mtx; + bool simplebus_attached; }; DECLARE_CLASS(syscon_generic_driver); Modified: stable/12/sys/dev/fdt/simplebus.c ============================================================================== --- stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 17:07:43 2020 (r367223) +++ stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 17:09:25 2020 (r367224) @@ -116,6 +116,16 @@ simplebus_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); + /* + * XXX We should attach only to pure' compatible = "simple-bus"', + * without any other compatible string. + * For now, filter only know cases: + * "syscon", "simple-bus"; is handled by fdt/syscon driver + * "simple-mfd", "simple-bus"; is handled by fdt/simple-mfd driver + */ + if (ofw_bus_is_compatible(dev, "syscon") || + ofw_bus_is_compatible(dev, "simple-mfd")) + return (ENXIO); /* * FDT data puts a "simple-bus" compatible string on many things that From owner-svn-src-stable-12@freebsd.org Sat Oct 31 17:10:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFF65451D8C; Sat, 31 Oct 2020 17:10:56 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNm0c4DY3z3TSn; Sat, 31 Oct 2020 17:10:56 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 757AEADA1; Sat, 31 Oct 2020 17:10:56 +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 09VHAuas064673; Sat, 31 Oct 2020 17:10:56 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VHAtTd064671; Sat, 31 Oct 2020 17:10:55 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311710.09VHAtTd064671@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:10:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367225 - stable/12/sys/dev/extres/syscon X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/extres/syscon X-SVN-Commit-Revision: 367225 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:10:56 -0000 Author: mmel Date: Sat Oct 31 17:10:55 2020 New Revision: 367225 URL: https://svnweb.freebsd.org/changeset/base/367225 Log: MFC r366161: Refine locking inside of syscon driver. In some cases, the syscon driver may be used by consumer requiring better control about locking (ie. it may be used as registe file provider for clock driver which needs locked access to multiple registers). Add fine locking protocol methods together with bunch of helper functions in syscon driver and implement this functionality in syscon_generic driver. Modified: stable/12/sys/dev/extres/syscon/syscon.c stable/12/sys/dev/extres/syscon/syscon_generic.c stable/12/sys/dev/extres/syscon/syscon_if.m Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/extres/syscon/syscon.c ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon.c Sat Oct 31 17:09:25 2020 (r367224) +++ stable/12/sys/dev/extres/syscon/syscon.c Sat Oct 31 17:10:55 2020 (r367225) @@ -67,7 +67,13 @@ typedef TAILQ_HEAD(syscon_list, syscon) syscon_list_t; */ static int syscon_method_init(struct syscon *syscon); static int syscon_method_uninit(struct syscon *syscon); +static uint32_t syscon_method_read_4(struct syscon *syscon, bus_size_t offset); +static int syscon_method_write_4(struct syscon *syscon, bus_size_t offset, + uint32_t val); +static int syscon_method_modify_4(struct syscon *syscon, bus_size_t offset, + uint32_t clear_bits, uint32_t set_bits); + MALLOC_DEFINE(M_SYSCON, "syscon", "Syscon driver"); static syscon_list_t syscon_list = TAILQ_HEAD_INITIALIZER(syscon_list); @@ -80,6 +86,9 @@ SX_SYSINIT(syscon_topology, &syscon_topo_lock, "Syscon static syscon_method_t syscon_methods[] = { SYSCONMETHOD(syscon_init, syscon_method_init), SYSCONMETHOD(syscon_uninit, syscon_method_uninit), + SYSCONMETHOD(syscon_read_4, syscon_method_read_4), + SYSCONMETHOD(syscon_write_4, syscon_method_write_4), + SYSCONMETHOD(syscon_modify_4, syscon_method_modify_4), SYSCONMETHOD_END }; @@ -115,6 +124,39 @@ syscon_get_softc(struct syscon *syscon) return (syscon->softc); }; +static uint32_t +syscon_method_read_4(struct syscon *syscon, bus_size_t offset) +{ + uint32_t val; + + SYSCON_DEVICE_LOCK(syscon->pdev); + val = SYSCON_UNLOCKED_READ_4(syscon, offset); + SYSCON_DEVICE_UNLOCK(syscon->pdev); + return(val); +} + +static int +syscon_method_write_4(struct syscon *syscon, bus_size_t offset, uint32_t val) +{ + int rv; + + SYSCON_DEVICE_LOCK(syscon->pdev); + rv = SYSCON_UNLOCKED_WRITE_4(syscon, offset, val); + SYSCON_DEVICE_UNLOCK(syscon->pdev); + return(rv); +} + +static int +syscon_method_modify_4(struct syscon *syscon, bus_size_t offset, + uint32_t clear_bits, uint32_t set_bits) +{ + int rv; + + SYSCON_DEVICE_LOCK(syscon->pdev); + rv = SYSCON_UNLOCKED_MODIFY_4(syscon, offset, clear_bits, set_bits); + SYSCON_DEVICE_UNLOCK(syscon->pdev); + return(rv); +} /* * Create and initialize syscon object, but do not register it. */ @@ -254,14 +296,3 @@ syscon_get_by_ofw_property(device_t cdev, phandle_t cn return (0); } #endif - -int -syscon_get_handle_default(device_t dev, struct syscon **syscon) -{ - device_t parent; - - parent = device_get_parent(dev); - if (parent == NULL) - return (ENODEV); - return (SYSCON_GET_HANDLE(parent, syscon)); -} Modified: stable/12/sys/dev/extres/syscon/syscon_generic.c ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:09:25 2020 (r367224) +++ stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:10:55 2020 (r367225) @@ -54,11 +54,12 @@ __FBSDID("$FreeBSD$"); MALLOC_DECLARE(M_SYSCON); -static uint32_t syscon_generic_read_4(struct syscon *syscon, bus_size_t offset); -static int syscon_generic_write_4(struct syscon *syscon, bus_size_t offset, - uint32_t val); -static int syscon_generic_modify_4(struct syscon *syscon, bus_size_t offset, - uint32_t clear_bits, uint32_t set_bits); +static uint32_t syscon_generic_unlocked_read_4(struct syscon *syscon, + bus_size_t offset); +static int syscon_generic_unlocked_write_4(struct syscon *syscon, + bus_size_t offset, uint32_t val); +static int syscon_generic_unlocked_modify_4(struct syscon *syscon, + bus_size_t offset, uint32_t clear_bits, uint32_t set_bits); static int syscon_generic_detach(device_t dev); /* * Generic syscon driver (FDT) @@ -77,9 +78,9 @@ static struct ofw_compat_data compat_data[] = { #define SYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED); static syscon_method_t syscon_generic_methods[] = { - SYSCONMETHOD(syscon_read_4, syscon_generic_read_4), - SYSCONMETHOD(syscon_write_4, syscon_generic_write_4), - SYSCONMETHOD(syscon_modify_4, syscon_generic_modify_4), + SYSCONMETHOD(syscon_unlocked_read_4, syscon_generic_unlocked_read_4), + SYSCONMETHOD(syscon_unlocked_write_4, syscon_generic_unlocked_write_4), + SYSCONMETHOD(syscon_unlocked_modify_4, syscon_generic_unlocked_modify_4), SYSCONMETHOD_END }; @@ -87,50 +88,62 @@ DEFINE_CLASS_1(syscon_generic, syscon_generic_class, s 0, syscon_class); static uint32_t -syscon_generic_read_4(struct syscon *syscon, bus_size_t offset) +syscon_generic_unlocked_read_4(struct syscon *syscon, bus_size_t offset) { struct syscon_generic_softc *sc; uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_UNLOCKED(sc); val = bus_read_4(sc->mem_res, offset); - SYSCON_UNLOCK(sc); return (val); } static int -syscon_generic_write_4(struct syscon *syscon, bus_size_t offset, uint32_t val) +syscon_generic_unlocked_write_4(struct syscon *syscon, bus_size_t offset, uint32_t val) { struct syscon_generic_softc *sc; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_UNLOCKED(sc); bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } static int -syscon_generic_modify_4(struct syscon *syscon, bus_size_t offset, +syscon_generic_unlocked_modify_4(struct syscon *syscon, bus_size_t offset, uint32_t clear_bits, uint32_t set_bits) { struct syscon_generic_softc *sc; uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_UNLOCKED(sc); val = bus_read_4(sc->mem_res, offset); val &= ~clear_bits; val |= set_bits; bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } +static void +syscon_generic_lock(device_t dev) +{ + struct syscon_generic_softc *sc; + + sc = device_get_softc(dev); + SYSCON_LOCK(sc); +} + +static void +syscon_generic_unlock(device_t dev) +{ + struct syscon_generic_softc *sc; + + sc = device_get_softc(dev); + SYSCON_UNLOCK(sc); +} + static int syscon_generic_probe(device_t dev) { @@ -206,6 +219,9 @@ static device_method_t syscon_generic_dmethods[] = { DEVMETHOD(device_probe, syscon_generic_probe), DEVMETHOD(device_attach, syscon_generic_attach), DEVMETHOD(device_detach, syscon_generic_detach), + + DEVMETHOD(syscon_device_lock, syscon_generic_lock), + DEVMETHOD(syscon_device_unlock, syscon_generic_unlock), DEVMETHOD_END }; Modified: stable/12/sys/dev/extres/syscon/syscon_if.m ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon_if.m Sat Oct 31 17:09:25 2020 (r367224) +++ stable/12/sys/dev/extres/syscon/syscon_if.m Sat Oct 31 17:10:55 2020 (r367225) @@ -35,6 +35,36 @@ HEADER { int syscon_get_handle_default(device_t dev, struct syscon **syscon); } +CODE { + #include + #include + + int + syscon_get_handle_default(device_t dev, struct syscon **syscon) + { + device_t parent; + + parent = device_get_parent(dev); + if (parent == NULL) + return (ENODEV); + return (SYSCON_GET_HANDLE(parent, syscon)); + } + + static void + syscon_device_lock_default(device_t dev) + { + + panic("syscon_device_lock is not implemented"); + }; + + static void + syscon_device_unlock_default(device_t dev) + { + + panic("syscon_device_unlock is not implemented"); + }; +} + METHOD int init { struct syscon *syscon; }; @@ -63,6 +93,38 @@ METHOD int modify_4 { uint32_t clear_bits; uint32_t set_bits; }; + +/** + * Unlocked verion of access function + */ +METHOD uint32_t unlocked_read_4 { + struct syscon *syscon; + bus_size_t offset; +}; + +METHOD int unlocked_write_4 { + struct syscon *syscon; + bus_size_t offset; + uint32_t val; +}; + +METHOD int unlocked_modify_4 { + struct syscon *syscon; + bus_size_t offset; + uint32_t clear_bits; + uint32_t set_bits; +}; + +/** +* Locking for exclusive access to underlying device +*/ +METHOD void device_lock { + device_t dev; +} DEFAULT syscon_device_lock_default; + +METHOD void device_unlock { + device_t dev; +} DEFAULT syscon_device_unlock_default; /** * Get syscon handle from parent driver From owner-svn-src-stable-12@freebsd.org Sat Oct 31 17:18:19 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FE57451D24; Sat, 31 Oct 2020 17:18:19 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNm970T7Bz3Tyj; Sat, 31 Oct 2020 17:18:19 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E45D5AF39; Sat, 31 Oct 2020 17:18:18 +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 09VHIITd068318; Sat, 31 Oct 2020 17:18:18 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VHIIvp068317; Sat, 31 Oct 2020 17:18:18 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311718.09VHIIvp068317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:18:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367226 - stable/12/sys/dev/extres/syscon X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/extres/syscon X-SVN-Commit-Revision: 367226 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:18:19 -0000 Author: mmel Date: Sat Oct 31 17:18:18 2020 New Revision: 367226 URL: https://svnweb.freebsd.org/changeset/base/367226 Log: MFC r366312: Fix the inverted condition in mtx_asserts. Mutex should be owned in affected functions. Modified: stable/12/sys/dev/extres/syscon/syscon_generic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/extres/syscon/syscon_generic.c ============================================================================== --- stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:10:55 2020 (r367225) +++ stable/12/sys/dev/extres/syscon/syscon_generic.c Sat Oct 31 17:18:18 2020 (r367226) @@ -94,7 +94,7 @@ syscon_generic_unlocked_read_4(struct syscon *syscon, uint32_t val; sc = device_get_softc(syscon->pdev); - SYSCON_ASSERT_UNLOCKED(sc); + SYSCON_ASSERT_LOCKED(sc); val = bus_read_4(sc->mem_res, offset); return (val); } @@ -105,7 +105,7 @@ syscon_generic_unlocked_write_4(struct syscon *syscon, struct syscon_generic_softc *sc; sc = device_get_softc(syscon->pdev); - SYSCON_ASSERT_UNLOCKED(sc); + SYSCON_ASSERT_LOCKED(sc); bus_write_4(sc->mem_res, offset, val); return (0); } @@ -118,7 +118,7 @@ syscon_generic_unlocked_modify_4(struct syscon *syscon uint32_t val; sc = device_get_softc(syscon->pdev); - SYSCON_ASSERT_UNLOCKED(sc); + SYSCON_ASSERT_LOCKED(sc); val = bus_read_4(sc->mem_res, offset); val &= ~clear_bits; val |= set_bits; From owner-svn-src-stable-12@freebsd.org Sat Oct 31 17:26:57 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8E6E5451E4F; Sat, 31 Oct 2020 17:26:57 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNmM52vGrz3VNS; Sat, 31 Oct 2020 17:26:57 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 422CDAE4A; Sat, 31 Oct 2020 17:26:57 +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 09VHQvlK074526; Sat, 31 Oct 2020 17:26:57 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VHQvNx074525; Sat, 31 Oct 2020 17:26:57 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311726.09VHQvNx074525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:26:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367227 - stable/12/sys/arm/arm X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm/arm X-SVN-Commit-Revision: 367227 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:26:57 -0000 Author: mmel Date: Sat Oct 31 17:26:56 2020 New Revision: 367227 URL: https://svnweb.freebsd.org/changeset/base/367227 Log: MFC r366197: Don't send a signal with uninitialized 'sig' and 'code' fields. We have a few shortcuts in the arm trap code to speed up obvious "must fail" cases. In these situations, make sure that we fill in the "sig" and "code" fields of the generated signal. Modified: stable/12/sys/arm/arm/trap-v6.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/arm/trap-v6.c ============================================================================== --- stable/12/sys/arm/arm/trap-v6.c Sat Oct 31 17:18:18 2020 (r367226) +++ stable/12/sys/arm/arm/trap-v6.c Sat Oct 31 17:26:56 2020 (r367227) @@ -462,8 +462,11 @@ abort_handler(struct trapframe *tf, int prefetch) /* * Don't allow user-mode faults in kernel address space. */ - if (usermode) + if (usermode) { + ksig.sig = SIGSEGV; + ksig.code = SEGV_ACCERR; goto nogo; + } map = kernel_map; } else { @@ -472,8 +475,11 @@ abort_handler(struct trapframe *tf, int prefetch) * is NULL or curproc->p_vmspace is NULL the fault is fatal. */ vm = (p != NULL) ? p->p_vmspace : NULL; - if (vm == NULL) + if (vm == NULL) { + ksig.sig = SIGSEGV; + ksig.code = 0; goto nogo; + } map = &vm->vm_map; if (!usermode && (td->td_intr_nesting_level != 0 || From owner-svn-src-stable-12@freebsd.org Sat Oct 31 18:42:04 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7F8E453171; Sat, 31 Oct 2020 18:42:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNp1m3zcnz3YQr; Sat, 31 Oct 2020 18:42:04 +0000 (UTC) (envelope-from dim@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6BEFFBE28; Sat, 31 Oct 2020 18:42:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VIg4lq023137; Sat, 31 Oct 2020 18:42:04 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VIg41m023136; Sat, 31 Oct 2020 18:42:04 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202010311842.09VIg41m023136@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 31 Oct 2020 18:42:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367228 - in stable: 11/contrib/llvm-project/lldb/source/Target 12/contrib/llvm-project/lldb/source/Target X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/llvm-project/lldb/source/Target 12/contrib/llvm-project/lldb/source/Target X-SVN-Commit-Revision: 367228 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 18:42:04 -0000 Author: dim Date: Sat Oct 31 18:42:03 2020 New Revision: 367228 URL: https://svnweb.freebsd.org/changeset/base/367228 Log: MFC r364480: Merge commit 1ce07cd614be from llvm git (by me): Instantiate Error in Target::GetEntryPointAddress() only when necessary When Target::GetEntryPointAddress() calls exe_module->GetObjectFile()->GetEntryPointAddress(), and the returned entry_addr is valid, it can immediately be returned. However, just before that, an llvm::Error value has been setup, but in this case it is not consumed before returning, like is done further below in the function. In https://bugs.freebsd.org/248745 we got a bug report for this, where a very simple test case aborts and dumps core: * thread #1, name = 'testcase', stop reason = breakpoint 1.1 frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5 1 int main(int argc, char *argv[]) 2 { -> 3 return 0; 4 } (lldb) p argc Program aborted due to an unhandled Error: Error value was Success. (Note: Success values must still be checked prior to being destroyed). Thread 1 received signal SIGABRT, Aborted. thr_kill () at thr_kill.S:3 3 thr_kill.S: No such file or directory. (gdb) bt #0 thr_kill () at thr_kill.S:3 #1 0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52 #2 0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 #3 0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112 #4 0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267 #5 0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67 #6 0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114 #7 0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97 #8 0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604 #9 0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347 #10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383 #11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301 #12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331 #13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190 #14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372 #15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414 #16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646 #17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003 #18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762 #19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760 #20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548 #21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903 #22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946 #23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169 #24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675 #25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890 Fix the incorrect error catch by only instantiating an Error object if it is necessary. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D86355 This should fix lldb aborting as described in the scenario above. Reported by: dmgk PR: 248745 Modified: stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/llvm-project/lldb/source/Target/Target.cpp Directory Properties: stable/11/ (props changed) stable/11/contrib/llvm-project/lldb/ (props changed) Modified: stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp ============================================================================== --- stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp Sat Oct 31 17:26:56 2020 (r367227) +++ stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp Sat Oct 31 18:42:03 2020 (r367228) @@ -2412,21 +2412,13 @@ lldb::addr_t Target::GetPersistentSymbol(ConstString n llvm::Expected Target::GetEntryPointAddress() { Module *exe_module = GetExecutableModulePointer(); - llvm::Error error = llvm::Error::success(); - assert(!error); // Check the success value when assertions are enabled. - if (!exe_module || !exe_module->GetObjectFile()) { - error = llvm::make_error("No primary executable found", - llvm::inconvertibleErrorCode()); - } else { + // Try to find the entry point address in the primary executable. + const bool has_primary_executable = exe_module && exe_module->GetObjectFile(); + if (has_primary_executable) { Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress(); if (entry_addr.IsValid()) return entry_addr; - - error = llvm::make_error( - "Could not find entry point address for executable module \"" + - exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", - llvm::inconvertibleErrorCode()); } const ModuleList &modules = GetImages(); @@ -2437,14 +2429,21 @@ llvm::Expected Target::GetEntry continue; Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress(); - if (entry_addr.IsValid()) { - // Discard the error. - llvm::consumeError(std::move(error)); + if (entry_addr.IsValid()) return entry_addr; - } } - return std::move(error); + // We haven't found the entry point address. Return an appropriate error. + if (!has_primary_executable) + return llvm::make_error( + "No primary executable found and could not find entry point address in " + "any executable module", + llvm::inconvertibleErrorCode()); + + return llvm::make_error( + "Could not find entry point address for primary executable module \"" + + exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", + llvm::inconvertibleErrorCode()); } lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr, From owner-svn-src-stable-12@freebsd.org Sat Oct 31 18:59:29 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 82C78453828; Sat, 31 Oct 2020 18:59:29 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (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 4CNpPr6Bw1z3ZCy; Sat, 31 Oct 2020 18:59:28 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 09VIxKgZ006519; Sat, 31 Oct 2020 11:59:21 -0700 (PDT) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 09VIxKjM006518; Sat, 31 Oct 2020 11:59:20 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202010311859.09VIxKjM006518@gndrsh.dnsmgr.net> Subject: Re: svn commit: r367228 - in stable: 11/contrib/llvm-project/lldb/source/Target 12/contrib/llvm-project/lldb/source/Target In-Reply-To: <202010311842.09VIg41m023136@repo.freebsd.org> To: Dimitry Andric Date: Sat, 31 Oct 2020 11:59:20 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4CNpPr6Bw1z3ZCy X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 18:59:29 -0000 > Author: dim > Date: Sat Oct 31 18:42:03 2020 > New Revision: 367228 > URL: https://svnweb.freebsd.org/changeset/base/367228 > > Log: > MFC r364480: > > Merge commit 1ce07cd614be from llvm git (by me): ^^^^^^^ FYI, we have a username me so this is not the best way to express yourself in commit mail: freefall:rgrimes {102} grep ^me: /etc/passwd me:*:589:589:Michael Elbel:/home/me:/usr/local/bin/bash > > Instantiate Error in Target::GetEntryPointAddress() only when > necessary > > When Target::GetEntryPointAddress() calls > exe_module->GetObjectFile()->GetEntryPointAddress(), and the returned > entry_addr is valid, it can immediately be returned. > > However, just before that, an llvm::Error value has been setup, but > in this case it is not consumed before returning, like is done > further below in the function. > > In https://bugs.freebsd.org/248745 we got a bug report for this, > where a very simple test case aborts and dumps core: > > * thread #1, name = 'testcase', stop reason = breakpoint 1.1 > frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5 > 1 int main(int argc, char *argv[]) > 2 { > -> 3 return 0; > 4 } > (lldb) p argc > Program aborted due to an unhandled Error: > Error value was Success. (Note: Success values must still be checked prior to being destroyed). > > Thread 1 received signal SIGABRT, Aborted. > thr_kill () at thr_kill.S:3 > 3 thr_kill.S: No such file or directory. > (gdb) bt > #0 thr_kill () at thr_kill.S:3 > #1 0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52 > #2 0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 > #3 0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112 > #4 0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267 > #5 0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67 > #6 0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114 > #7 0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97 > #8 0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604 > #9 0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347 > #10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383 > #11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301 > #12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331 > #13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190 > #14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372 > #15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414 > #16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646 > #17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003 > #18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762 > #19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760 > #20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548 > #21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903 > #22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946 > #23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169 > #24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675 > #25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890 > > Fix the incorrect error catch by only instantiating an Error object > if it is necessary. > > Reviewed By: JDevlieghere > > Differential Revision: https://reviews.llvm.org/D86355 > > This should fix lldb aborting as described in the scenario above. > > Reported by: dmgk > PR: 248745 > > Modified: > stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp > Directory Properties: > stable/12/ (props changed) > > Changes in other areas also in this revision: > Modified: > stable/11/contrib/llvm-project/lldb/source/Target/Target.cpp > Directory Properties: > stable/11/ (props changed) > stable/11/contrib/llvm-project/lldb/ (props changed) > > Modified: stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp > ============================================================================== > --- stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp Sat Oct 31 17:26:56 2020 (r367227) > +++ stable/12/contrib/llvm-project/lldb/source/Target/Target.cpp Sat Oct 31 18:42:03 2020 (r367228) > @@ -2412,21 +2412,13 @@ lldb::addr_t Target::GetPersistentSymbol(ConstString n > > llvm::Expected Target::GetEntryPointAddress() { > Module *exe_module = GetExecutableModulePointer(); > - llvm::Error error = llvm::Error::success(); > - assert(!error); // Check the success value when assertions are enabled. > > - if (!exe_module || !exe_module->GetObjectFile()) { > - error = llvm::make_error("No primary executable found", > - llvm::inconvertibleErrorCode()); > - } else { > + // Try to find the entry point address in the primary executable. > + const bool has_primary_executable = exe_module && exe_module->GetObjectFile(); > + if (has_primary_executable) { > Address entry_addr = exe_module->GetObjectFile()->GetEntryPointAddress(); > if (entry_addr.IsValid()) > return entry_addr; > - > - error = llvm::make_error( > - "Could not find entry point address for executable module \"" + > - exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", > - llvm::inconvertibleErrorCode()); > } > > const ModuleList &modules = GetImages(); > @@ -2437,14 +2429,21 @@ llvm::Expected Target::GetEntry > continue; > > Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress(); > - if (entry_addr.IsValid()) { > - // Discard the error. > - llvm::consumeError(std::move(error)); > + if (entry_addr.IsValid()) > return entry_addr; > - } > } > > - return std::move(error); > + // We haven't found the entry point address. Return an appropriate error. > + if (!has_primary_executable) > + return llvm::make_error( > + "No primary executable found and could not find entry point address in " > + "any executable module", > + llvm::inconvertibleErrorCode()); > + > + return llvm::make_error( > + "Could not find entry point address for primary executable module \"" + > + exe_module->GetFileSpec().GetFilename().GetStringRef() + "\"", > + llvm::inconvertibleErrorCode()); > } > > lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr, > -- Rod Grimes rgrimes@freebsd.org