sync with OpenBSD -current

This commit is contained in:
purplerain 2024-03-04 15:49:10 +00:00
parent 3c7ee3c11c
commit dd4d2242a5
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
44 changed files with 850 additions and 587 deletions

View File

@ -1955,7 +1955,6 @@
./usr/share/man/man3/EVP_SealInit.3
./usr/share/man/man3/EVP_SignInit.3
./usr/share/man/man3/EVP_VerifyInit.3
./usr/share/man/man3/EVP_add_cipher.3
./usr/share/man/man3/EVP_aes_128_cbc.3
./usr/share/man/man3/EVP_camellia_128_cbc.3
./usr/share/man/man3/EVP_chacha20.3

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: CRYPTO_lock.3,v 1.1 2019/03/10 15:00:34 schwarze Exp $
.\" $OpenBSD: CRYPTO_lock.3,v 1.2 2024/03/04 09:30:43 tb Exp $
.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000
.\"
.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
@ -15,14 +15,10 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 10 2019 $
.Dd $Mdocdate: March 4 2024 $
.Dt CRYPTO_LOCK 3
.Os
.Sh NAME
.Nm CRYPTO_THREADID_current ,
.Nm CRYPTO_THREADID_cmp ,
.Nm CRYPTO_THREADID_cpy ,
.Nm CRYPTO_THREADID_hash ,
.Nm CRYPTO_lock ,
.Nm CRYPTO_w_lock ,
.Nm CRYPTO_w_unlock ,
@ -33,24 +29,6 @@
.Sh SYNOPSIS
.In openssl/crypto.h
.Ft void
.Fo CRYPTO_THREADID_current
.Fa "CRYPTO_THREADID *id"
.Fc
.Ft int
.Fo CRYPTO_THREADID_cmp
.Fa "const CRYPTO_THREADID *a"
.Fa "const CRYPTO_THREADID *b"
.Fc
.Ft void
.Fo CRYPTO_THREADID_cpy
.Fa "CRYPTO_THREADID *dest"
.Fa "const CRYPTO_THREADID *src"
.Fc
.Ft unsigned long
.Fo CRYPTO_THREADID_hash
.Fa "const CRYPTO_THREADID *id"
.Fc
.Ft void
.Fo CRYPTO_lock
.Fa "int mode"
.Fa "int type"
@ -75,18 +53,6 @@
.Ed
.Sh DESCRIPTION
These functions are obsolete.
.Pp
.Fn CRYPTO_THREADID_current
stores a unique identifier of the currently executing thread
into the opaque object
.Fa id .
.Pp
.Fn CRYPTO_THREADID_cpy
copies the contents of
.Fa src
to
.Fa dest .
.Pp
.Fn CRYPTO_lock
locks or unlocks a mutex lock.
.Pp
@ -135,20 +101,6 @@ and unlocks the lock number
.Fa type
again.
.Sh RETURN VALUES
.Fn CRYPTO_THREADID_cmp
returns 0 if
.Fa a
and
.Fa b
refer to the same thread or a non-zero value otherwise.
.Pp
.Fn CRYPTO_THREADID_hash
returns a numeric value usable as a hash-table key.
In the LibreSSL implementation, it is the value returned from
.Xr pthread_self 3
for the thread
.Fa id .
.Pp
.Fn CRYPTO_add
returns the new value of
.Pf * Fa p .
@ -166,11 +118,3 @@ first appeared in SSLeay 0.6.0.
first appeared in SSLeay 0.6.2.
These functions have been available since
.Ox 2.4 .
.Pp
.Fn CRYPTO_THREADID_current ,
.Fn CRYPTO_THREADID_cmp ,
.Fn CRYPTO_THREADID_cpy ,
and
.Fn CRYPTO_THREADID_hash
first appeared in OpenSSL 1.0.0 and have been available since
.Ox 4.9 .

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.5 2023/09/10 05:22:46 jsg Exp $
.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.6 2024/03/04 09:49:07 tb Exp $
.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000
.\"
.\" This file is a derived work.
@ -66,7 +66,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: September 10 2023 $
.Dd $Mdocdate: March 4 2024 $
.Dt EVP_CIPHER_METH_NEW 3
.Os
.Sh NAME
@ -233,18 +233,6 @@ function with a command
of
.Dv EVP_CTRL_INIT
early during the setup.
.It Dv EVP_CIPH_CUSTOM_KEY_LENGTH
Instruct
.Xr EVP_CIPHER_CTX_set_key_length 3
to not check and set the key length itself,
but to leave that to the implementation by instead calling its
.Fa ctrl
function with a command
.Fa type
of
.Dv EVP_CTRL_SET_KEY_LENGTH
and the key length in
.Fa arg .
.It Dv EVP_CIPH_NO_PADDING
Instruct
.Xr EVP_CipherFinal_ex 3

View File

@ -1,190 +0,0 @@
.\" $OpenBSD: EVP_add_cipher.3,v 1.6 2023/08/25 18:39:04 schwarze Exp $
.\"
.\" Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: August 25 2023 $
.Dt EVP_ADD_CIPHER 3
.Os
.Sh NAME
.Nm EVP_add_cipher ,
.Nm EVP_add_cipher_alias ,
.Nm EVP_delete_cipher_alias ,
.Nm EVP_add_digest ,
.Nm EVP_add_digest_alias ,
.Nm EVP_delete_digest_alias
.Nd maintain lookup tables for cipher and digest names
.Sh SYNOPSIS
.In openssl/evp.h
.Ft int
.Fo EVP_add_cipher
.Fa "const EVP_CIPHER *cipher"
.Fc
.Ft int
.Fo EVP_add_cipher_alias
.Fa "const char *name"
.Fa "const char *alias"
.Fc
.Ft int
.Fo EVP_delete_cipher_alias
.Fa "const char *alias"
.Fc
.Ft int
.Fo EVP_add_digest
.Fa "const EVP_MD *md"
.Fc
.Ft int
.Fo EVP_add_digest_alias
.Fa "const char *name"
.Fa "const char *alias"
.Fc
.Ft int
.Fo EVP_delete_digest_alias
.Fa "const char *alias"
.Fc
.Sh DESCRIPTION
.Fn EVP_add_cipher
adds
.Fa cipher
to a global lookup table so that it can be retrieved with
.Xr EVP_get_cipherbyname 3
using both its long and short names,
as determined by the
.Fa cipher Ns 's
NID via
.Xr OBJ_nid2ln 3
and
.Xr OBJ_nid2sn 3 .
It is the caller's responsibility to ensure that the long
and short names are not
.Dv NULL .
Internally, the lookup table is the global associative array and
.Xr OBJ_NAME_add 3
is used to add two key-value pairs with value pointer
.Fa cipher
and the keys consisting of the names and
the type
.Dv OBJ_NAME_TYPE_CIPHER_METH .
.Pp
.Fn EVP_add_cipher_alias
and
.Fn EVP_delete_cipher_alias
add and remove the
.Fa alias
for the cipher
.Fa name .
They are implemented as macros wrapping
.Xr OBJ_NAME_add 3
and
.Xr OBJ_NAME_remove 3
with
.Fa type
set to the bitwise or of
.Dv OBJ_NAME_TYPE_CIPHER_METH
and
.Dv OBJ_NAME_ALIAS .
.Pp
.Fn EVP_add_digest
adds
.Fa md
to a global lookup table so that it can be retrieved with
.Xr EVP_get_digestbyname 3
using both its long and short names,
as determined by the
.Fa md Ns 's
NID via
.Xr OBJ_nid2ln 3
and
.Xr OBJ_nid2sn 3 .
If the
.Fa md
has an associated public key signing algorithm (see
.Xr EVP_MD_pkey_type 3 )
distinct from the
.Fa md ,
the signing algorithm's short and long names are added as aliases for
the short name of
.Fa md .
It is the caller's responsibility to ensure that all long
and short names are not
.Dv NULL .
Internally, the lookup table is the global associative array and
.Xr OBJ_NAME_add 3
is used to add two key-value pairs with value pointer
.Fa md
and the keys consisting of the names and
the type
.Dv OBJ_NAME_TYPE_MD_METH .
The aliases are added with
.Fn EVP_add_digest_alias .
.Pp
.Fn EVP_add_digest_alias
and
.Fn EVP_delete_digest_alias
add and remove the
.Fa alias
for the digest
.Fa name .
They are implemented as macros wrapping
.Xr OBJ_NAME_add 3
and
.Xr OBJ_NAME_remove 3
with
.Fa type
set to the bitwise or of
.Dv OBJ_NAME_TYPE_MD_METH
and
.Dv OBJ_NAME_ALIAS .
.Sh RETURN VALUES
.Fn EVP_add_cipher ,
.Fn EVP_add_cipher_alias ,
.Fn EVP_add_digest ,
and
.Fn EVP_add_digest_alias
return 1 on success or 0 if memory allocation fails.
.Pp
.Fn EVP_delete_cipher_alias
and
.Fn EVP_delete_digest_alias
return 1 if one alias was removed or 0 otherwise.
.Sh SEE ALSO
.Xr evp 3 ,
.Xr EVP_CIPHER_meth_new 3 ,
.Xr EVP_get_cipherbyname 3 ,
.Xr EVP_get_digestbyname 3 ,
.Xr EVP_MD_meth_new 3 ,
.Xr OBJ_create 3 ,
.Xr OBJ_NAME_add 3 ,
.Xr OpenSSL_add_all_algorithms 3
.Sh HISTORY
.Fn EVP_add_cipher
and
.Fn EVP_add_digest
first appeared in OpenSSL 0.9.0 and have been available since
.Ox 2.4 .
.Pp
.Fn EVP_add_cipher_alias ,
.Fn EVP_delete_cipher_alias ,
.Fn EVP_add_digest_alias ,
and
.Fn EVP_delete_digest_alias
first appeared in OpenSSL 0.9.4 and have been available since
.Ox 2.6 .
.Sh BUGS
Key-value pairs already added before an error occurred
remain in the global associative array,
leaving it in an unknown state.
.Pp
While aliases can be added and removed, there is no dedicated API
to remove added ciphers or digests.

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.282 2024/03/02 11:04:51 tb Exp $
# $OpenBSD: Makefile,v 1.283 2024/03/04 19:04:47 tb Exp $
.include <bsd.own.mk>
@ -200,7 +200,6 @@ MAN= \
EVP_SealInit.3 \
EVP_SignInit.3 \
EVP_VerifyInit.3 \
EVP_add_cipher.3 \
EVP_aes_128_cbc.3 \
EVP_camellia_128_cbc.3 \
EVP_chacha20.3 \

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: OPENSSL_sk_new.3,v 1.12 2021/03/12 05:18:00 jsg Exp $
.\" $OpenBSD: OPENSSL_sk_new.3,v 1.13 2024/03/04 09:47:34 tb Exp $
.\"
.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
.\"
@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 12 2021 $
.Dd $Mdocdate: March 4 2024 $
.Dt OPENSSL_SK_NEW 3
.Os
.Sh NAME
@ -27,7 +27,6 @@
.Nm sk_num ,
.Nm sk_value ,
.Nm sk_find ,
.Nm sk_find_ex ,
.Nm sk_sort ,
.Nm sk_is_sorted ,
.Nm sk_push ,
@ -80,11 +79,6 @@
.Fa "_STACK *stack"
.Fa "void *wanted"
.Fc
.Ft int
.Fo sk_find_ex
.Fa "_STACK *stack"
.Fa "void *wanted"
.Fc
.Ft void
.Fo sk_sort
.Fa "_STACK *stack"
@ -245,16 +239,6 @@ first sorted with
and instead of comparing pointers, two pointers are considered to match
if the comparison function returns 0.
.Pp
.Fn sk_find_ex
is identical to
.Fn sk_find
except that if the
.Fa stack
is not empty but no match is found,
the index of some pointer considered closest to
.Fa wanted
is returned.
.Pp
.Fn sk_sort
sorts the
.Fa stack
@ -285,9 +269,8 @@ or
or changing the comparison function sets the state to unsorted.
If a comparison function is installed, calling
.Fn sk_sort ,
.Fn sk_find ,
or
.Fn sk_find_ex
.Fn sk_find
sets the state to sorted.
.Pp
.Fn sk_push
@ -456,13 +439,6 @@ is a
.Dv NULL
pointer or if no match is found.
.Pp
.Fn sk_find_ex
returns some index or \-1 if
.Fa stack
is a
.Dv NULL
pointer or empty.
.Pp
.Fn sk_is_sorted
returns 1 if the
.Fa stack
@ -562,10 +538,6 @@ Both functions have been available since
.Fn sk_is_sorted
first appeared in OpenSSL 0.9.7e and has been available since
.Ox 3.8 .
.Pp
.Fn sk_find_ex
first appeared in OpenSSL 0.9.8 and has been available since
.Ox 4.5 .
.Sh BUGS
Even if a comparison function is installed, empty stacks and
stacks containing a single pointer are sometimes considered
@ -575,23 +547,7 @@ If a comparison function is installed, the concept of
.Dq first match
in
.Fn sk_find
and
.Fn sk_find_ex
is ill-defined because
.Xr qsort 3
is not a stable sorting function.
It is probably best to only assume that they return an arbitrary match.
.Pp
The concept of
.Dq closest
for
.Fn sk_find_ex
is even less clearly defined.
The match may sometimes be smaller and sometimes larger than
.Fa wanted ,
even if both smaller and larger pointers exist in the
.Fa stack .
Besides, it is again ill-defined
which of several pointers that compare equal is selected.
It is probably best to not assume anything about the selection
for cases where there is no match.

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.15 2023/11/16 20:27:43 schwarze Exp $
.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.16 2024/03/04 19:04:47 tb Exp $
.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
.\"
.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@ -48,7 +48,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: November 16 2023 $
.Dd $Mdocdate: March 4 2024 $
.Dt OPENSSL_ADD_ALL_ALGORITHMS 3
.Os
.Sh NAME
@ -124,7 +124,6 @@ and
are implemented as macros.
.Sh SEE ALSO
.Xr evp 3 ,
.Xr EVP_add_cipher 3 ,
.Xr EVP_DigestInit 3 ,
.Xr EVP_EncryptInit 3 ,
.Xr OBJ_cleanup 3 ,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: X509_STORE_set1_param.3,v 1.20 2023/11/16 20:27:43 schwarze Exp $
.\" $OpenBSD: X509_STORE_set1_param.3,v 1.21 2024/03/04 09:24:07 tb Exp $
.\" content checked up to:
.\" OpenSSL man3/X509_STORE_add_cert b0edda11 Mar 20 13:00:17 2018 +0000
.\" OpenSSL man3/X509_STORE_get0_param e90fc053 Jul 15 09:39:45 2017 -0400
@ -17,7 +17,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: November 16 2023 $
.Dd $Mdocdate: March 4 2024 $
.Dt X509_STORE_SET1_PARAM 3
.Os
.Sh NAME
@ -29,6 +29,7 @@
.Nm X509_STORE_add_cert ,
.Nm X509_STORE_add_crl ,
.Nm X509_STORE_get0_param ,
.Nm X509_STORE_get1_objects ,
.Nm X509_STORE_get0_objects ,
.Nm X509_STORE_get_ex_new_index ,
.Nm X509_STORE_set_ex_data ,
@ -76,6 +77,10 @@
.Fa "X509_STORE *store"
.Fc
.Ft STACK_OF(X509_OBJECT) *
.Fo X509_STORE_get1_objects
.Fa "X509_STORE *store"
.Fc
.Ft STACK_OF(X509_OBJECT) *
.Fo X509_STORE_get0_objects
.Fa "X509_STORE *store"
.Fc
@ -181,10 +186,35 @@ or if memory allocation fails.
.Fn X509_STORE_get0_param
returns an internal pointer to the verification parameter object
contained in the
.Fa store .
The returned pointer must not be freed by the calling application.
.Pp
.Fn X509_STORE_get1_objects
returns a newly allocated stack containing
the certificates, revocation lists, and private keys in
.Fa store ,
as well as cached objects added by
.Xr X509_LOOKUP_hash_dir 3 .
The caller must release the result with
.Xr sk_pop_free 3
and
.Xr X509_OBJECT_free 3
when done.
.Pp
.Fn X509_STORE_get0_objects
to the stack of certificates, revocation lists, and private keys.
The returned pointers must not be freed by the calling application.
is a deprecated function returning an internal pointer to
the stack of certificates, revocation lists, and private keys contained in
.Fa store .
The returned pointer must not be modified or freed by the calling application.
This function is not thread-safe.
If
.Fa store
is shared across multiple threads, callers cannot safely inspect the result of
this function, because another thread may have concurrently added to it.
In particular,
.Xr X509_LOOKUP_hash_dir 3
treats this list as a cache and may add to it in the course of certificate
verification.
.Pp
.Fn X509_STORE_get_ex_new_index
returns a new index or \-1 on failure.
@ -232,3 +262,7 @@ and
.Fn X509_STORE_get_ex_data
first appeared in OpenSSL 1.1.0 and have been available since
.Ox 6.3 .
.Pp
X509_STORE_get1_objects
first appeared in BoringSSL and has been available since
.Ox 7.5 .

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: evp.3,v 1.26 2023/12/01 10:40:21 schwarze Exp $
.\" $OpenBSD: evp.3,v 1.27 2024/03/04 19:04:47 tb Exp $
.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100
.\"
.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@ -51,7 +51,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: December 1 2023 $
.Dd $Mdocdate: March 4 2024 $
.Dt EVP 3
.Os
.Sh NAME
@ -167,7 +167,6 @@ family of functions provides base64 encoding and decoding.
.Xr crypto 3 ,
.Xr d2i_PKCS8PrivateKey_bio 3 ,
.Xr d2i_PrivateKey 3 ,
.Xr EVP_add_cipher 3 ,
.Xr EVP_AEAD_CTX_init 3 ,
.Xr EVP_aes_128_cbc 3 ,
.Xr EVP_BytesToKey 3 ,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: lh_new.3,v 1.11 2024/03/02 11:04:51 tb Exp $
.\" $OpenBSD: lh_new.3,v 1.12 2024/03/04 19:03:31 tb Exp $
.\" full merge up to:
.\" OpenSSL doc/crypto/lhash.pod 1bc74519 May 20 08:11:46 2016 -0400
.\" selective merge up to:
@ -118,7 +118,7 @@
.\" copied and put under another distribution licence
.\" [including the GNU Public Licence.]
.\"
.Dd $Mdocdate: March 2 2024 $
.Dd $Mdocdate: March 4 2024 $
.Dt LH_NEW 3
.Os
.Sh NAME
@ -519,7 +519,7 @@ routine would not normally be passed to
rather it would be used in the function passed to
.Fn lh_<type>_new .
.Sh SEE ALSO
.Xr crypto 3 ,
.Xr crypto 3
.Sh HISTORY
.Fn lh_new ,
.Fn lh_free ,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: s_fabsf.c,v 1.2 2014/04/18 15:09:52 guenther Exp $ */
/* $OpenBSD: s_fabsf.c,v 1.3 2024/03/04 17:09:23 miod Exp $ */
/*
* Written by Martynas Venckus. Public domain
@ -14,4 +14,4 @@ fabsf(float f)
return (f);
}
DEF_STD(fabsf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sxiccmu.c,v 1.35 2024/02/07 22:00:38 uaa Exp $ */
/* $OpenBSD: sxiccmu.c,v 1.37 2024/03/04 04:11:52 deraadt Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2013 Artturi Alm
@ -92,6 +92,8 @@ void sxiccmu_ccu_reset(void *, uint32_t *, int);
uint32_t sxiccmu_a10_get_frequency(struct sxiccmu_softc *, uint32_t);
int sxiccmu_a10_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_a10s_get_frequency(struct sxiccmu_softc *, uint32_t);
int sxiccmu_a10s_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_a23_get_frequency(struct sxiccmu_softc *, uint32_t);
int sxiccmu_a23_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t);
uint32_t sxiccmu_a64_get_frequency(struct sxiccmu_softc *, uint32_t);
@ -139,6 +141,8 @@ sxiccmu_match(struct device *parent, void *match, void *aux)
}
return (OF_is_compatible(node, "allwinner,sun4i-a10-ccu") ||
OF_is_compatible(node, "allwinner,sun5i-a10s-ccu") ||
OF_is_compatible(node, "allwinner,sun5i-a13-ccu") ||
OF_is_compatible(node, "allwinner,sun7i-a20-ccu") ||
OF_is_compatible(node, "allwinner,sun8i-a23-ccu") ||
OF_is_compatible(node, "allwinner,sun8i-a23-prcm") ||
@ -193,6 +197,14 @@ sxiccmu_attach(struct device *parent, struct device *self, void *aux)
sc->sc_nresets = nitems(sun4i_a10_resets);
sc->sc_get_frequency = sxiccmu_a10_get_frequency;
sc->sc_set_frequency = sxiccmu_a10_set_frequency;
} else if (OF_is_compatible(node, "allwinner,sun5i-a10s-ccu")) {
KASSERT(faa->fa_nreg > 0);
sc->sc_gates = sun5i_a10s_gates;
sc->sc_ngates = nitems(sun5i_a10s_gates);
sc->sc_resets = sun5i_a10s_resets;
sc->sc_nresets = nitems(sun5i_a10s_resets);
sc->sc_get_frequency = sxiccmu_a10s_get_frequency;
sc->sc_set_frequency = sxiccmu_a10s_set_frequency;
} else if (OF_is_compatible(node, "allwinner,sun8i-a23-ccu") ||
OF_is_compatible(node, "allwinner,sun8i-a33-ccu")) {
KASSERT(faa->fa_nreg > 0);
@ -907,7 +919,7 @@ sxiccmu_ccu_get_frequency(void *cookie, uint32_t *cells)
return sc->sc_get_frequency(sc, idx);
}
/* Allwinner A10/A20 */
/* Allwinner A10/A10s/A13/A20 */
#define A10_PLL1_CFG_REG 0x0000
#define A10_PLL1_OUT_EXT_DIVP_MASK (0x3 << 16)
#define A10_PLL1_OUT_EXT_DIVP_SHIFT 16
@ -989,6 +1001,62 @@ sxiccmu_a10_get_frequency(struct sxiccmu_softc *sc, uint32_t idx)
return 0;
}
uint32_t
sxiccmu_a10s_get_frequency(struct sxiccmu_softc *sc, uint32_t idx)
{
uint32_t parent;
uint32_t reg, div;
uint32_t k, m, n, p;
switch (idx) {
case A10S_CLK_LOSC:
return clock_get_frequency(sc->sc_node, "losc");
case A10S_CLK_HOSC:
return clock_get_frequency(sc->sc_node, "hosc");
case A10S_CLK_PLL_CORE:
reg = SXIREAD4(sc, A10_PLL1_CFG_REG);
k = A10_PLL1_FACTOR_K(reg) + 1;
m = A10_PLL1_FACTOR_M(reg) + 1;
n = A10_PLL1_FACTOR_N(reg);
p = 1 << A10_PLL1_OUT_EXT_DIVP(reg);
return (24000000 * n * k) / (m * p);
case A10S_CLK_PLL_PERIPH:
return 1200000000;
case A10S_CLK_CPU:
reg = SXIREAD4(sc, A10_CPU_AHB_APB0_CFG_REG);
switch (reg & A10_CPU_CLK_SRC_SEL) {
case A10_CPU_CLK_SRC_SEL_LOSC:
parent = A10S_CLK_LOSC;
break;
case A10_CPU_CLK_SRC_SEL_OSC24M:
parent = A10S_CLK_HOSC;
break;
case A10_CPU_CLK_SRC_SEL_PLL1:
parent = A10S_CLK_PLL_CORE;
break;
case A10_CPU_CLK_SRC_SEL_200MHZ:
return 200000000;
}
return sxiccmu_ccu_get_frequency(sc, &parent);
case A10S_CLK_AXI:
reg = SXIREAD4(sc, A10_CPU_AHB_APB0_CFG_REG);
div = 1 << A10_AXI_CLK_DIV_RATIO(reg);
parent = A10S_CLK_CPU;
return sxiccmu_ccu_get_frequency(sc, &parent) / div;
case A10S_CLK_AHB:
reg = SXIREAD4(sc, A10_CPU_AHB_APB0_CFG_REG);
div = 1 << A10_AHB_CLK_DIV_RATIO(reg);
parent = A10S_CLK_AXI;
return sxiccmu_ccu_get_frequency(sc, &parent) / div;
case A10S_CLK_APB1:
/* XXX Controlled by a MUX. */
return 24000000;
}
printf("%s: 0x%08x\n", __func__, idx);
return 0;
}
/* Allwinner A23/A64/H3/H5/R40 */
#define CCU_AHB1_APB1_CFG_REG 0x0054
#define CCU_AHB1_CLK_SRC_SEL (3 << 12)
@ -1665,6 +1733,66 @@ sxiccmu_a10_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq)
return -1;
}
int
sxiccmu_a10s_set_frequency(struct sxiccmu_softc *sc, uint32_t idx,
uint32_t freq)
{
struct sxiccmu_clock clock;
uint32_t parent, parent_freq;
uint32_t reg;
int k, n;
int error;
switch (idx) {
case A10S_CLK_PLL_CORE:
k = 1; n = 32;
while (k <= 4 && (24000000 * n * k) < freq)
k++;
while (n >= 1 && (24000000 * n * k) > freq)
n--;
reg = SXIREAD4(sc, A10_PLL1_CFG_REG);
reg &= ~A10_PLL1_OUT_EXT_DIVP_MASK;
reg &= ~A10_PLL1_FACTOR_N_MASK;
reg &= ~A10_PLL1_FACTOR_K_MASK;
reg &= ~A10_PLL1_FACTOR_M_MASK;
reg |= (n << A10_PLL1_FACTOR_N_SHIFT);
reg |= ((k - 1) << A10_PLL1_FACTOR_K_SHIFT);
SXIWRITE4(sc, A10_PLL1_CFG_REG, reg);
/* No need to wait PLL to lock? */
return 0;
case A10S_CLK_CPU:
/* Switch to 24 MHz clock. */
reg = SXIREAD4(sc, A10_CPU_AHB_APB0_CFG_REG);
reg &= ~A10_CPU_CLK_SRC_SEL;
reg |= A10_CPU_CLK_SRC_SEL_OSC24M;
SXIWRITE4(sc, A10_CPU_AHB_APB0_CFG_REG, reg);
error = sxiccmu_a10s_set_frequency(sc, A10S_CLK_PLL_CORE, freq);
/* Switch back to PLL. */
reg = SXIREAD4(sc, A10_CPU_AHB_APB0_CFG_REG);
reg &= ~A10_CPU_CLK_SRC_SEL;
reg |= A10_CPU_CLK_SRC_SEL_PLL1;
SXIWRITE4(sc, A10_CPU_AHB_APB0_CFG_REG, reg);
return error;
case A10S_CLK_MMC0:
case A10S_CLK_MMC1:
case A10S_CLK_MMC2:
clock.sc_iot = sc->sc_iot;
bus_space_subregion(sc->sc_iot, sc->sc_ioh,
sc->sc_gates[idx].reg, 4, &clock.sc_ioh);
parent = A10S_CLK_PLL_PERIPH;
parent_freq = sxiccmu_ccu_get_frequency(sc, &parent);
return sxiccmu_mmc_do_set_frequency(&clock, freq, parent_freq);
}
printf("%s: 0x%08x\n", __func__, idx);
return -1;
}
int
sxiccmu_a23_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq)
{

View File

@ -90,6 +90,64 @@ const struct sxiccmu_ccu_bit sun4i_a10_gates[] = {
[A10_CLK_USB_PHY] = { 0x00cc, 8 },
};
/* A10s */
#define A10S_CLK_HOSC 1
#define A10S_CLK_PLL_CORE 2
#define A10S_CLK_PLL_PERIPH 14
#define A10S_CLK_CPU 17
#define A10S_CLK_AXI 18
#define A10S_CLK_AHB 19
#define A10S_CLK_APB1 21
#define A10S_CLK_AHB_EHCI0 24
#define A10S_CLK_AHB_OHCI0 25
#define A10S_CLK_AHB_MMC0 29
#define A10S_CLK_AHB_MMC1 30
#define A10S_CLK_AHB_MMC2 31
#define A10S_CLK_AHB_EMAC 34
#define A10S_CLK_APB0_PIO 53
#define A10S_CLK_APB1_I2C0 56
#define A10S_CLK_APB1_I2C1 57
#define A10S_CLK_APB1_I2C2 58
#define A10S_CLK_APB1_UART0 59
#define A10S_CLK_APB1_UART1 60
#define A10S_CLK_APB1_UART2 61
#define A10S_CLK_APB1_UART3 62
#define A10S_CLK_MMC0 64
#define A10S_CLK_MMC1 65
#define A10S_CLK_MMC2 66
#define A10S_CLK_USB_OHCI0 76
#define A10S_CLK_USB_PHY0 77
#define A10S_CLK_USB_PHY1 78
#define A10S_CLK_LOSC 254
const struct sxiccmu_ccu_bit sun5i_a10s_gates[] = {
[A10S_CLK_AHB_EHCI0] = { 0x0060, 1 },
[A10S_CLK_AHB_OHCI0] = { 0x0060, 2 },
[A10S_CLK_AHB_MMC0] = { 0x0060, 8 },
[A10S_CLK_AHB_MMC1] = { 0x0060, 9 },
[A10S_CLK_AHB_MMC2] = { 0x0060, 10 },
[A10S_CLK_AHB_EMAC] = { 0x0060, 17 },
[A10S_CLK_APB0_PIO] = { 0x0068, 5 },
[A10S_CLK_APB1_I2C0] = { 0x006c, 0, A10S_CLK_APB1 },
[A10S_CLK_APB1_I2C1] = { 0x006c, 1, A10S_CLK_APB1 },
[A10S_CLK_APB1_I2C2] = { 0x006c, 2, A10S_CLK_APB1 },
[A10S_CLK_APB1_UART0] = { 0x006c, 16, A10S_CLK_APB1 },
[A10S_CLK_APB1_UART1] = { 0x006c, 17, A10S_CLK_APB1 },
[A10S_CLK_APB1_UART2] = { 0x006c, 18, A10S_CLK_APB1 },
[A10S_CLK_APB1_UART3] = { 0x006c, 19, A10S_CLK_APB1 },
[A10S_CLK_MMC0] = { 0x0088, 31 },
[A10S_CLK_MMC1] = { 0x008c, 31 },
[A10S_CLK_MMC2] = { 0x0090, 31 },
[A10S_CLK_USB_OHCI0] = { 0x00cc, 6 },
[A10S_CLK_USB_PHY0] = { 0x00cc, 8 },
[A10S_CLK_USB_PHY1] = { 0x00cc, 9 },
};
/* A23/A33 */
#define A23_CLK_PLL_PERIPH 10
@ -773,6 +831,16 @@ const struct sxiccmu_ccu_bit sun4i_a10_resets[] = {
[A10_RST_USB_PHY2] = { 0x00cc, 2 },
};
/* A10s */
#define A10S_RST_USB_PHY0 0
#define A10S_RST_USB_PHY1 1
const struct sxiccmu_ccu_bit sun5i_a10s_resets[] = {
[A10S_RST_USB_PHY0] = { 0x00cc, 0 },
[A10S_RST_USB_PHY1] = { 0x00cc, 1 },
};
/* A23/A33 */
#define A23_RST_USB_PHY0 0

View File

@ -1040,6 +1040,8 @@ struct amdgpu_device {
bool in_s3;
bool in_s4;
bool in_s0ix;
/* indicate amdgpu suspension status */
bool suspend_complete;
enum pp_mp1_state mp1_state;
struct amdgpu_doorbell_index doorbell_index;

View File

@ -2416,6 +2416,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
struct drm_device *drm_dev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(drm_dev);
adev->suspend_complete = false;
if (amdgpu_acpi_is_s0ix_active(adev))
adev->in_s0ix = true;
else if (amdgpu_acpi_is_s3_active(adev))
@ -2430,6 +2431,7 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev)
struct drm_device *drm_dev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(drm_dev);
adev->suspend_complete = true;
if (amdgpu_acpi_should_gpu_reset(adev))
return amdgpu_asic_reset(adev);

View File

@ -362,7 +362,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
}
}
if (copy_to_user((char *)buf, context->mem_context.shared_buf, shared_buf_len))
if (copy_to_user((char *)&buf[copy_pos], context->mem_context.shared_buf, shared_buf_len))
ret = -EFAULT;
err_free_shared_buf:

View File

@ -3033,6 +3033,14 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev)
gfx_v9_0_cp_gfx_enable(adev, true);
/* Now only limit the quirk on the APU gfx9 series and already
* confirmed that the APU gfx10/gfx11 needn't such update.
*/
if (adev->flags & AMD_IS_APU &&
adev->in_s3 && !adev->suspend_complete) {
DRM_INFO(" Will skip the CSB packet resubmit\n");
return 0;
}
r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
if (r) {
DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);

View File

@ -426,6 +426,12 @@ static void nbio_v7_9_init_registers(struct amdgpu_device *adev)
u32 inst_mask;
int i;
if (amdgpu_sriov_vf(adev))
adev->rmmio_remap.reg_offset =
SOC15_REG_OFFSET(
NBIO, 0,
regBIF_BX_DEV0_EPF0_VF0_HDP_MEM_COHERENCY_FLUSH_CNTL)
<< 2;
WREG32_SOC15(NBIO, 0, regXCC_DOORBELL_FENCE,
0xff & ~(adev->gfx.xcc_mask));

View File

@ -1296,10 +1296,32 @@ static int soc15_common_suspend(void *handle)
return soc15_common_hw_fini(adev);
}
static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
{
u32 sol_reg;
sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
/* Will reset for the following suspend abort cases.
* 1) Only reset limit on APU side, dGPU hasn't checked yet.
* 2) S3 suspend abort and TOS already launched.
*/
if (adev->flags & AMD_IS_APU && adev->in_s3 &&
!adev->suspend_complete &&
sol_reg)
return true;
return false;
}
static int soc15_common_resume(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
if (soc15_need_reset_on_resume(adev)) {
dev_info(adev->dev, "S3 suspend abort case, let's reset ASIC.\n");
soc15_asic_reset(adev);
}
return soc15_common_hw_init(adev);
}

View File

@ -1482,10 +1482,15 @@ void kfd_dec_compute_active(struct kfd_node *dev);
/* Cgroup Support */
/* Check with device cgroup if @kfd device is accessible */
static inline int kfd_devcgroup_check_permission(struct kfd_node *kfd)
static inline int kfd_devcgroup_check_permission(struct kfd_node *node)
{
#if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
struct drm_device *ddev = adev_to_drm(kfd->adev);
struct drm_device *ddev;
if (node->xcp)
ddev = node->xcp->ddev;
else
ddev = adev_to_drm(node->adev);
return devcgroup_check_permission(DEVCG_DEV_CHAR, DRM_MAJOR,
ddev->render->index,

View File

@ -1816,21 +1816,12 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
DRM_ERROR("amdgpu: fail to register dmub aux callback");
goto error;
}
if (!register_dmub_notify_callback(adev, DMUB_NOTIFICATION_HPD, dmub_hpd_callback, true)) {
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
goto error;
}
if (!register_dmub_notify_callback(adev, DMUB_NOTIFICATION_HPD_IRQ, dmub_hpd_callback, true)) {
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
goto error;
}
}
/* Enable outbox notification only after IRQ handlers are registered and DMUB is alive.
* It is expected that DMUB will resend any pending notifications at this point, for
* example HPD from DPIA.
*/
if (dc_is_dmub_outbox_supported(adev->dm.dc)) {
/* Enable outbox notification only after IRQ handlers are registered and DMUB is alive.
* It is expected that DMUB will resend any pending notifications at this point. Note
* that hpd and hpd_irq handler registration are deferred to register_hpd_handlers() to
* align legacy interface initialization sequence. Connection status will be proactivly
* detected once in the amdgpu_dm_initialize_drm_device.
*/
dc_enable_dmub_outbox(adev->dm.dc);
/* DPIA trace goes to dmesg logs only if outbox is enabled */
@ -2260,6 +2251,7 @@ static int dm_sw_fini(void *handle)
if (adev->dm.dmub_srv) {
dmub_srv_destroy(adev->dm.dmub_srv);
kfree(adev->dm.dmub_srv);
adev->dm.dmub_srv = NULL;
}
@ -3488,6 +3480,14 @@ static void register_hpd_handlers(struct amdgpu_device *adev)
int_params.requested_polarity = INTERRUPT_POLARITY_DEFAULT;
int_params.current_polarity = INTERRUPT_POLARITY_DEFAULT;
if (dc_is_dmub_outbox_supported(adev->dm.dc)) {
if (!register_dmub_notify_callback(adev, DMUB_NOTIFICATION_HPD, dmub_hpd_callback, true))
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
if (!register_dmub_notify_callback(adev, DMUB_NOTIFICATION_HPD_IRQ, dmub_hpd_callback, true))
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
}
list_for_each_entry(connector,
&dev->mode_config.connector_list, head) {
@ -3513,10 +3513,6 @@ static void register_hpd_handlers(struct amdgpu_device *adev)
handle_hpd_rx_irq,
(void *) aconnector);
}
if (adev->dm.hpd_rx_offload_wq)
adev->dm.hpd_rx_offload_wq[connector->index].aconnector =
aconnector;
}
}
@ -4485,6 +4481,10 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
link = dc_get_link_at_index(dm->dc, i);
if (dm->hpd_rx_offload_wq)
dm->hpd_rx_offload_wq[aconnector->base.index].aconnector =
aconnector;
if (!dc_link_detect_connection_type(link, &new_connection_type))
DRM_ERROR("KMS: Failed to detect connector\n");

View File

@ -1860,19 +1860,21 @@ static enum bp_result get_firmware_info_v3_2(
/* Vega12 */
smu_info_v3_2 = GET_IMAGE(struct atom_smu_info_v3_2,
DATA_TABLES(smu_info));
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_2->gpuclk_ss_percentage);
if (!smu_info_v3_2)
return BP_RESULT_BADBIOSTABLE;
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_2->gpuclk_ss_percentage);
info->default_engine_clk = smu_info_v3_2->bootup_dcefclk_10khz * 10;
} else if (revision.minor == 3) {
/* Vega20 */
smu_info_v3_3 = GET_IMAGE(struct atom_smu_info_v3_3,
DATA_TABLES(smu_info));
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_3->gpuclk_ss_percentage);
if (!smu_info_v3_3)
return BP_RESULT_BADBIOSTABLE;
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", smu_info_v3_3->gpuclk_ss_percentage);
info->default_engine_clk = smu_info_v3_3->bootup_dcefclk_10khz * 10;
}
@ -2435,10 +2437,11 @@ static enum bp_result get_integrated_info_v11(
info_v11 = GET_IMAGE(struct atom_integrated_system_info_v1_11,
DATA_TABLES(integratedsysteminfo));
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v11->gpuclk_ss_percentage);
if (info_v11 == NULL)
return BP_RESULT_BADBIOSTABLE;
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v11->gpuclk_ss_percentage);
info->gpu_cap_info =
le32_to_cpu(info_v11->gpucapinfo);
/*
@ -2650,11 +2653,12 @@ static enum bp_result get_integrated_info_v2_1(
info_v2_1 = GET_IMAGE(struct atom_integrated_system_info_v2_1,
DATA_TABLES(integratedsysteminfo));
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_1->gpuclk_ss_percentage);
if (info_v2_1 == NULL)
return BP_RESULT_BADBIOSTABLE;
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_1->gpuclk_ss_percentage);
info->gpu_cap_info =
le32_to_cpu(info_v2_1->gpucapinfo);
/*
@ -2812,11 +2816,11 @@ static enum bp_result get_integrated_info_v2_2(
info_v2_2 = GET_IMAGE(struct atom_integrated_system_info_v2_2,
DATA_TABLES(integratedsysteminfo));
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_2->gpuclk_ss_percentage);
if (info_v2_2 == NULL)
return BP_RESULT_BADBIOSTABLE;
DC_LOG_BIOS("gpuclk_ss_percentage (unit of 0.001 percent): %d\n", info_v2_2->gpuclk_ss_percentage);
info->gpu_cap_info =
le32_to_cpu(info_v2_2->gpucapinfo);
/*

View File

@ -497,7 +497,7 @@ void dc_link_enable_hpd_filter(struct dc_link *link, bool enable)
link->dc->link_srv->enable_hpd_filter(link, enable);
}
bool dc_link_validate(struct dc *dc, const struct dc_stream_state *streams, const unsigned int count)
bool dc_link_dp_dpia_validate(struct dc *dc, const struct dc_stream_state *streams, const unsigned int count)
{
return dc->link_srv->validate_dpia_bandwidth(streams, count);
}

View File

@ -2116,11 +2116,11 @@ int dc_link_dp_dpia_handle_usb4_bandwidth_allocation_for_link(
*
* @dc: pointer to dc struct
* @stream: pointer to all possible streams
* @num_streams: number of valid DPIA streams
* @count: number of valid DPIA streams
*
* return: TRUE if bw used by DPIAs doesn't exceed available BW else return FALSE
*/
bool dc_link_validate(struct dc *dc, const struct dc_stream_state *streams,
bool dc_link_dp_dpia_validate(struct dc *dc, const struct dc_stream_state *streams,
const unsigned int count);
/* Sink Interfaces - A sink corresponds to a display output device */

View File

@ -1433,6 +1433,12 @@ struct dp_trace {
#ifndef DP_TUNNELING_STATUS
#define DP_TUNNELING_STATUS 0xE0025 /* 1.4a */
#endif
#ifndef DP_TUNNELING_MAX_LINK_RATE
#define DP_TUNNELING_MAX_LINK_RATE 0xE0028 /* 1.4a */
#endif
#ifndef DP_TUNNELING_MAX_LANE_COUNT
#define DP_TUNNELING_MAX_LANE_COUNT 0xE0029 /* 1.4a */
#endif
#ifndef DPTX_BW_ALLOCATION_MODE_CONTROL
#define DPTX_BW_ALLOCATION_MODE_CONTROL 0xE0030 /* 1.4a */
#endif

View File

@ -1110,21 +1110,25 @@ struct dc_panel_config {
} ilr;
};
#define MAX_SINKS_PER_LINK 4
/*
* USB4 DPIA BW ALLOCATION STRUCTS
*/
struct dc_dpia_bw_alloc {
int sink_verified_bw; // The Verified BW that sink can allocated and use that has been verified already
int sink_allocated_bw; // The Actual Allocated BW that sink currently allocated
int sink_max_bw; // The Max BW that sink can require/support
int remote_sink_req_bw[MAX_SINKS_PER_LINK]; // BW requested by remote sinks
int link_verified_bw; // The Verified BW that link can allocated and use that has been verified already
int link_max_bw; // The Max BW that link can require/support
int allocated_bw; // The Actual Allocated BW for this DPIA
int estimated_bw; // The estimated available BW for this DPIA
int bw_granularity; // BW Granularity
int dp_overhead; // DP overhead in dp tunneling
bool bw_alloc_enabled; // The BW Alloc Mode Support is turned ON for all 3: DP-Tx & Dpia & CM
bool response_ready; // Response ready from the CM side
uint8_t nrd_max_lane_count; // Non-reduced max lane count
uint8_t nrd_max_link_rate; // Non-reduced max link rate
};
#define MAX_SINKS_PER_LINK 4
enum dc_hpd_enable_select {
HPD_EN_FOR_ALL_EDP = 0,
HPD_EN_FOR_PRIMARY_EDP_ONLY,

View File

@ -2071,17 +2071,11 @@ static enum dc_status enable_link_dp(struct dc_state *state,
}
}
/*
* If the link is DP-over-USB4 do the following:
* - Train with fallback when enabling DPIA link. Conventional links are
/* Train with fallback when enabling DPIA link. Conventional links are
* trained with fallback during sink detection.
* - Allocate only what the stream needs for bw in Gbps. Inform the CM
* in case stream needs more or less bw from what has been allocated
* earlier at plug time.
*/
if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) {
if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA)
do_fallback = true;
}
/*
* Temporary w/a to get DP2.0 link rates to work with SST.
@ -2263,6 +2257,32 @@ static enum dc_status enable_link(
return status;
}
static bool allocate_usb4_bandwidth_for_stream(struct dc_stream_state *stream, int bw)
{
return true;
}
static bool allocate_usb4_bandwidth(struct dc_stream_state *stream)
{
bool ret;
int bw = dc_bandwidth_in_kbps_from_timing(&stream->timing,
dc_link_get_highest_encoding_format(stream->sink->link));
ret = allocate_usb4_bandwidth_for_stream(stream, bw);
return ret;
}
static bool deallocate_usb4_bandwidth(struct dc_stream_state *stream)
{
bool ret;
ret = allocate_usb4_bandwidth_for_stream(stream, 0);
return ret;
}
void link_set_dpms_off(struct pipe_ctx *pipe_ctx)
{
struct dc *dc = pipe_ctx->stream->ctx->dc;
@ -2299,6 +2319,9 @@ void link_set_dpms_off(struct pipe_ctx *pipe_ctx)
update_psp_stream_config(pipe_ctx, true);
dc->hwss.blank_stream(pipe_ctx);
if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA)
deallocate_usb4_bandwidth(pipe_ctx->stream);
if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
deallocate_mst_payload(pipe_ctx);
else if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT &&
@ -2520,6 +2543,9 @@ void link_set_dpms_on(
}
}
if (pipe_ctx->stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA)
allocate_usb4_bandwidth(pipe_ctx->stream);
if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
allocate_mst_payload(pipe_ctx);
else if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT &&

View File

@ -346,23 +346,61 @@ enum dc_status link_validate_mode_timing(
return DC_OK;
}
/*
* This function calculates the bandwidth required for the stream timing
* and aggregates the stream bandwidth for the respective dpia link
*
* @stream: pointer to the dc_stream_state struct instance
* @num_streams: number of streams to be validated
*
* return: true if validation is succeeded
*/
bool link_validate_dpia_bandwidth(const struct dc_stream_state *stream, const unsigned int num_streams)
{
bool ret = true;
int bw_needed[MAX_DPIA_NUM];
struct dc_link *link[MAX_DPIA_NUM];
int bw_needed[MAX_DPIA_NUM] = {0};
struct dc_link *dpia_link[MAX_DPIA_NUM] = {0};
int num_dpias = 0;
if (!num_streams || num_streams > MAX_DPIA_NUM)
return ret;
for (unsigned int i = 0; i < num_streams; ++i) {
if (stream[i].signal == SIGNAL_TYPE_DISPLAY_PORT) {
/* new dpia sst stream, check whether it exceeds max dpia */
if (num_dpias >= MAX_DPIA_NUM)
return false;
for (uint8_t i = 0; i < num_streams; ++i) {
dpia_link[num_dpias] = stream[i].link;
bw_needed[num_dpias] = dc_bandwidth_in_kbps_from_timing(&stream[i].timing,
dc_link_get_highest_encoding_format(dpia_link[num_dpias]));
num_dpias++;
} else if (stream[i].signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
uint8_t j = 0;
/* check whether its a known dpia link */
for (; j < num_dpias; ++j) {
if (dpia_link[j] == stream[i].link)
break;
}
link[i] = stream[i].link;
bw_needed[i] = dc_bandwidth_in_kbps_from_timing(&stream[i].timing,
dc_link_get_highest_encoding_format(link[i]));
if (j == num_dpias) {
/* new dpia mst stream, check whether it exceeds max dpia */
if (num_dpias >= MAX_DPIA_NUM)
return false;
else {
dpia_link[j] = stream[i].link;
num_dpias++;
}
}
bw_needed[j] += dc_bandwidth_in_kbps_from_timing(&stream[i].timing,
dc_link_get_highest_encoding_format(dpia_link[j]));
}
}
ret = dpia_validate_usb4_bw(link, bw_needed, num_streams);
/* Include dp overheads */
for (uint8_t i = 0; i < num_dpias; ++i) {
int dp_overhead = 0;
return ret;
dp_overhead = link_dp_dpia_get_dp_overhead_in_dp_tunneling(dpia_link[i]);
bw_needed[i] += dp_overhead;
}
return dpia_validate_usb4_bw(dpia_link, bw_needed, num_dpias);
}

View File

@ -54,11 +54,18 @@ static bool get_bw_alloc_proceed_flag(struct dc_link *tmp)
static void reset_bw_alloc_struct(struct dc_link *link)
{
link->dpia_bw_alloc_config.bw_alloc_enabled = false;
link->dpia_bw_alloc_config.sink_verified_bw = 0;
link->dpia_bw_alloc_config.sink_max_bw = 0;
link->dpia_bw_alloc_config.link_verified_bw = 0;
link->dpia_bw_alloc_config.link_max_bw = 0;
link->dpia_bw_alloc_config.allocated_bw = 0;
link->dpia_bw_alloc_config.estimated_bw = 0;
link->dpia_bw_alloc_config.bw_granularity = 0;
link->dpia_bw_alloc_config.dp_overhead = 0;
link->dpia_bw_alloc_config.response_ready = false;
link->dpia_bw_alloc_config.nrd_max_lane_count = 0;
link->dpia_bw_alloc_config.nrd_max_link_rate = 0;
for (int i = 0; i < MAX_SINKS_PER_LINK; i++)
link->dpia_bw_alloc_config.remote_sink_req_bw[i] = 0;
DC_LOG_DEBUG("reset usb4 bw alloc of link(%d)\n", link->link_index);
}
#define BW_GRANULARITY_0 4 // 0.25 Gbps
@ -104,6 +111,32 @@ static int get_estimated_bw(struct dc_link *link)
return bw_estimated_bw * (Kbps_TO_Gbps / link->dpia_bw_alloc_config.bw_granularity);
}
static int get_non_reduced_max_link_rate(struct dc_link *link)
{
uint8_t nrd_max_link_rate = 0;
core_link_read_dpcd(
link,
DP_TUNNELING_MAX_LINK_RATE,
&nrd_max_link_rate,
sizeof(uint8_t));
return nrd_max_link_rate;
}
static int get_non_reduced_max_lane_count(struct dc_link *link)
{
uint8_t nrd_max_lane_count = 0;
core_link_read_dpcd(
link,
DP_TUNNELING_MAX_LANE_COUNT,
&nrd_max_lane_count,
sizeof(uint8_t));
return nrd_max_lane_count;
}
/*
* Read all New BW alloc configuration ex: estimated_bw, allocated_bw,
* granuality, Driver_ID, CM_Group, & populate the BW allocation structs
@ -111,13 +144,20 @@ static int get_estimated_bw(struct dc_link *link)
*/
static void init_usb4_bw_struct(struct dc_link *link)
{
// Init the known values
reset_bw_alloc_struct(link);
/* init the known values */
link->dpia_bw_alloc_config.bw_granularity = get_bw_granularity(link);
link->dpia_bw_alloc_config.estimated_bw = get_estimated_bw(link);
link->dpia_bw_alloc_config.nrd_max_link_rate = get_non_reduced_max_link_rate(link);
link->dpia_bw_alloc_config.nrd_max_lane_count = get_non_reduced_max_lane_count(link);
DC_LOG_DEBUG("%s: bw_granularity(%d), estimated_bw(%d)\n",
__func__, link->dpia_bw_alloc_config.bw_granularity,
link->dpia_bw_alloc_config.estimated_bw);
DC_LOG_DEBUG("%s: nrd_max_link_rate(%d), nrd_max_lane_count(%d)\n",
__func__, link->dpia_bw_alloc_config.nrd_max_link_rate,
link->dpia_bw_alloc_config.nrd_max_lane_count);
}
static uint8_t get_lowest_dpia_index(struct dc_link *link)
@ -142,39 +182,50 @@ static uint8_t get_lowest_dpia_index(struct dc_link *link)
}
/*
* Get the Max Available BW or Max Estimated BW for each Host Router
* Get the maximum dp tunnel banwidth of host router
*
* @link: pointer to the dc_link struct instance
* @type: ESTIMATD BW or MAX AVAILABLE BW
* @dc: pointer to the dc struct instance
* @hr_index: host router index
*
* return: response_ready flag from dc_link struct
* return: host router maximum dp tunnel bandwidth
*/
static int get_host_router_total_bw(struct dc_link *link, uint8_t type)
static int get_host_router_total_dp_tunnel_bw(const struct dc *dc, uint8_t hr_index)
{
const struct dc *dc_struct = link->dc;
uint8_t lowest_dpia_index = get_lowest_dpia_index(link);
uint8_t idx = (link->link_index - lowest_dpia_index) / 2, idx_temp = 0;
struct dc_link *link_temp;
uint8_t lowest_dpia_index = get_lowest_dpia_index(dc->links[0]);
uint8_t hr_index_temp = 0;
struct dc_link *link_dpia_primary, *link_dpia_secondary;
int total_bw = 0;
int i;
for (i = 0; i < MAX_PIPES * 2; ++i) {
for (uint8_t i = 0; i < (MAX_PIPES * 2) - 1; ++i) {
if (!dc_struct->links[i] || dc_struct->links[i]->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
if (!dc->links[i] || dc->links[i]->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
continue;
link_temp = dc_struct->links[i];
if (!link_temp || !link_temp->hpd_status)
continue;
hr_index_temp = (dc->links[i]->link_index - lowest_dpia_index) / 2;
idx_temp = (link_temp->link_index - lowest_dpia_index) / 2;
if (hr_index_temp == hr_index) {
link_dpia_primary = dc->links[i];
link_dpia_secondary = dc->links[i + 1];
if (idx_temp == idx) {
if (type == HOST_ROUTER_BW_ESTIMATED)
total_bw += link_temp->dpia_bw_alloc_config.estimated_bw;
else if (type == HOST_ROUTER_BW_ALLOCATED)
total_bw += link_temp->dpia_bw_alloc_config.sink_allocated_bw;
/**
* If BW allocation enabled on both DPIAs, then
* HR BW = Estimated(dpia_primary) + Allocated(dpia_secondary)
* otherwise HR BW = Estimated(bw alloc enabled dpia)
*/
if ((link_dpia_primary->hpd_status &&
link_dpia_primary->dpia_bw_alloc_config.bw_alloc_enabled) &&
(link_dpia_secondary->hpd_status &&
link_dpia_secondary->dpia_bw_alloc_config.bw_alloc_enabled)) {
total_bw += link_dpia_primary->dpia_bw_alloc_config.estimated_bw +
link_dpia_secondary->dpia_bw_alloc_config.allocated_bw;
} else if (link_dpia_primary->hpd_status &&
link_dpia_primary->dpia_bw_alloc_config.bw_alloc_enabled) {
total_bw = link_dpia_primary->dpia_bw_alloc_config.estimated_bw;
} else if (link_dpia_secondary->hpd_status &&
link_dpia_secondary->dpia_bw_alloc_config.bw_alloc_enabled) {
total_bw += link_dpia_secondary->dpia_bw_alloc_config.estimated_bw;
}
break;
}
}
@ -194,7 +245,6 @@ static void dpia_bw_alloc_unplug(struct dc_link *link)
if (link) {
DC_LOG_DEBUG("%s: resetting bw alloc config for link(%d)\n",
__func__, link->link_index);
link->dpia_bw_alloc_config.sink_allocated_bw = 0;
reset_bw_alloc_struct(link);
}
}
@ -220,7 +270,7 @@ static void set_usb4_req_bw_req(struct dc_link *link, int req_bw)
/* Error check whether requested and allocated are equal */
req_bw = requested_bw * (Kbps_TO_Gbps / link->dpia_bw_alloc_config.bw_granularity);
if (req_bw == link->dpia_bw_alloc_config.sink_allocated_bw) {
if (req_bw == link->dpia_bw_alloc_config.allocated_bw) {
DC_LOG_ERROR("%s: Request bw equals to allocated bw for link(%d)\n",
__func__, link->link_index);
}
@ -343,9 +393,9 @@ void dpia_handle_bw_alloc_response(struct dc_link *link, uint8_t bw, uint8_t res
DC_LOG_DEBUG("%s: BW REQ SUCCESS for DP-TX Request for link(%d)\n",
__func__, link->link_index);
DC_LOG_DEBUG("%s: current allocated_bw(%d), new allocated_bw(%d)\n",
__func__, link->dpia_bw_alloc_config.sink_allocated_bw, bw_needed);
__func__, link->dpia_bw_alloc_config.allocated_bw, bw_needed);
link->dpia_bw_alloc_config.sink_allocated_bw = bw_needed;
link->dpia_bw_alloc_config.allocated_bw = bw_needed;
link->dpia_bw_alloc_config.response_ready = true;
break;
@ -383,8 +433,8 @@ int dpia_handle_usb4_bandwidth_allocation_for_link(struct dc_link *link, int pea
if (link->hpd_status && peak_bw > 0) {
// If DP over USB4 then we need to check BW allocation
link->dpia_bw_alloc_config.sink_max_bw = peak_bw;
set_usb4_req_bw_req(link, link->dpia_bw_alloc_config.sink_max_bw);
link->dpia_bw_alloc_config.link_max_bw = peak_bw;
set_usb4_req_bw_req(link, link->dpia_bw_alloc_config.link_max_bw);
do {
if (timeout > 0)
@ -396,8 +446,8 @@ int dpia_handle_usb4_bandwidth_allocation_for_link(struct dc_link *link, int pea
if (!timeout)
ret = 0;// ERROR TIMEOUT waiting for response for allocating bw
else if (link->dpia_bw_alloc_config.sink_allocated_bw > 0)
ret = get_host_router_total_bw(link, HOST_ROUTER_BW_ALLOCATED);
else if (link->dpia_bw_alloc_config.allocated_bw > 0)
ret = link->dpia_bw_alloc_config.allocated_bw;
}
//2. Cold Unplug
else if (!link->hpd_status)
@ -406,7 +456,6 @@ int dpia_handle_usb4_bandwidth_allocation_for_link(struct dc_link *link, int pea
out:
return ret;
}
bool link_dp_dpia_allocate_usb4_bandwidth_for_stream(struct dc_link *link, int req_bw)
{
bool ret = false;
@ -414,7 +463,7 @@ bool link_dp_dpia_allocate_usb4_bandwidth_for_stream(struct dc_link *link, int r
DC_LOG_DEBUG("%s: ENTER: link(%d), hpd_status(%d), current allocated_bw(%d), req_bw(%d)\n",
__func__, link->link_index, link->hpd_status,
link->dpia_bw_alloc_config.sink_allocated_bw, req_bw);
link->dpia_bw_alloc_config.allocated_bw, req_bw);
if (!get_bw_alloc_proceed_flag(link))
goto out;
@ -439,31 +488,70 @@ out:
bool dpia_validate_usb4_bw(struct dc_link **link, int *bw_needed_per_dpia, const unsigned int num_dpias)
{
bool ret = true;
int bw_needed_per_hr[MAX_HR_NUM] = { 0, 0 };
uint8_t lowest_dpia_index = 0, dpia_index = 0;
uint8_t i;
int bw_needed_per_hr[MAX_HR_NUM] = { 0, 0 }, host_router_total_dp_bw = 0;
uint8_t lowest_dpia_index, i, hr_index;
if (!num_dpias || num_dpias > MAX_DPIA_NUM)
return ret;
//Get total Host Router BW & Validate against each Host Router max BW
lowest_dpia_index = get_lowest_dpia_index(link[0]);
/* get total Host Router BW with granularity for the given modes */
for (i = 0; i < num_dpias; ++i) {
int granularity_Gbps = 0;
int bw_granularity = 0;
if (!link[i]->dpia_bw_alloc_config.bw_alloc_enabled)
continue;
lowest_dpia_index = get_lowest_dpia_index(link[i]);
if (link[i]->link_index < lowest_dpia_index)
continue;
dpia_index = (link[i]->link_index - lowest_dpia_index) / 2;
bw_needed_per_hr[dpia_index] += bw_needed_per_dpia[i];
if (bw_needed_per_hr[dpia_index] > get_host_router_total_bw(link[i], HOST_ROUTER_BW_ALLOCATED)) {
granularity_Gbps = (Kbps_TO_Gbps / link[i]->dpia_bw_alloc_config.bw_granularity);
bw_granularity = (bw_needed_per_dpia[i] / granularity_Gbps) * granularity_Gbps +
((bw_needed_per_dpia[i] % granularity_Gbps) ? granularity_Gbps : 0);
ret = false;
break;
hr_index = (link[i]->link_index - lowest_dpia_index) / 2;
bw_needed_per_hr[hr_index] += bw_granularity;
}
/* validate against each Host Router max BW */
for (hr_index = 0; hr_index < MAX_HR_NUM; ++hr_index) {
if (bw_needed_per_hr[hr_index]) {
host_router_total_dp_bw = get_host_router_total_dp_tunnel_bw(link[0]->dc, hr_index);
if (bw_needed_per_hr[hr_index] > host_router_total_dp_bw) {
ret = false;
break;
}
}
}
return ret;
}
int link_dp_dpia_get_dp_overhead_in_dp_tunneling(struct dc_link *link)
{
int dp_overhead = 0, link_mst_overhead = 0;
if (!get_bw_alloc_proceed_flag((link)))
return dp_overhead;
/* if its mst link, add MTPH overhead */
if ((link->type == dc_connection_mst_branch) &&
!link->dpcd_caps.channel_coding_cap.bits.DP_128b_132b_SUPPORTED) {
/* For 8b/10b encoding: MTP is 64 time slots long, slot 0 is used for MTPH
* MST overhead is 1/64 of link bandwidth (excluding any overhead)
*/
const struct dc_link_settings *link_cap =
dc_link_get_link_cap(link);
uint32_t link_bw_in_kbps = (uint32_t)link_cap->link_rate *
(uint32_t)link_cap->lane_count *
LINK_RATE_REF_FREQ_IN_KHZ * 8;
link_mst_overhead = (link_bw_in_kbps / 64) + ((link_bw_in_kbps % 64) ? 1 : 0);
}
/* add all the overheads */
dp_overhead = link_mst_overhead;
return dp_overhead;
}

View File

@ -99,4 +99,13 @@ void dpia_handle_bw_alloc_response(struct dc_link *link, uint8_t bw, uint8_t res
*/
bool dpia_validate_usb4_bw(struct dc_link **link, int *bw_needed, const unsigned int num_dpias);
/*
* Obtain all the DP overheads in dp tunneling for the dpia link
*
* @link: pointer to the dc_link struct instance
*
* return: DP overheads in DP tunneling
*/
int link_dp_dpia_get_dp_overhead_in_dp_tunneling(struct dc_link *link);
#endif /* DC_INC_LINK_DP_DPIA_BW_H_ */

View File

@ -1096,7 +1096,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
uint64_t *points;
uint32_t signaled_count, i;
if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT)
if (flags & (DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT |
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE))
lockdep_assert_none_held_once();
points = kmalloc_array(count, sizeof(*points), GFP_KERNEL);
@ -1169,7 +1170,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
* fallthough and try a 0 timeout wait!
*/
if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
if (flags & (DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT |
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE)) {
for (i = 0; i < count; ++i)
drm_syncobj_fence_add_wait(syncobjs[i], &entries[i]);
}
@ -1444,10 +1446,21 @@ syncobj_eventfd_entry_func(struct drm_syncobj *syncobj,
/* This happens inside the syncobj lock */
fence = dma_fence_get(rcu_dereference_protected(syncobj->fence, 1));
if (!fence)
return;
ret = dma_fence_chain_find_seqno(&fence, entry->point);
if (ret != 0 || !fence) {
if (ret != 0) {
/* The given seqno has not been submitted yet. */
dma_fence_put(fence);
return;
} else if (!fence) {
/* If dma_fence_chain_find_seqno returns 0 but sets the fence
* to NULL, it implies that the given seqno is signaled and a
* later seqno has already been submitted. Assign a stub fence
* so that the eventfd still gets signaled below.
*/
fence = dma_fence_get_stub();
}
list_del_init(&entry->node);

View File

@ -1212,7 +1212,7 @@ static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo,
struct intel_sdvo_tv_format format;
u32 format_map;
format_map = 1 << conn_state->tv.mode;
format_map = 1 << conn_state->tv.legacy_mode;
memset(&format, 0, sizeof(format));
memcpy(&format, &format_map, min(sizeof(format), sizeof(format_map)));
@ -2295,7 +2295,7 @@ static int intel_sdvo_get_tv_modes(struct drm_connector *connector)
* Read the list of supported input resolutions for the selected TV
* format.
*/
format_map = 1 << conn_state->tv.mode;
format_map = 1 << conn_state->tv.legacy_mode;
memcpy(&tv_res, &format_map,
min(sizeof(format_map), sizeof(struct intel_sdvo_sdtv_resolution_request)));
@ -2360,7 +2360,7 @@ intel_sdvo_connector_atomic_get_property(struct drm_connector *connector,
int i;
for (i = 0; i < intel_sdvo_connector->format_supported_num; i++)
if (state->tv.mode == intel_sdvo_connector->tv_format_supported[i]) {
if (state->tv.legacy_mode == intel_sdvo_connector->tv_format_supported[i]) {
*val = i;
return 0;
@ -2416,7 +2416,7 @@ intel_sdvo_connector_atomic_set_property(struct drm_connector *connector,
struct intel_sdvo_connector_state *sdvo_state = to_intel_sdvo_connector_state(state);
if (property == intel_sdvo_connector->tv_format) {
state->tv.mode = intel_sdvo_connector->tv_format_supported[val];
state->tv.legacy_mode = intel_sdvo_connector->tv_format_supported[val];
if (state->crtc) {
struct drm_crtc_state *crtc_state =
@ -3071,7 +3071,7 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
drm_property_add_enum(intel_sdvo_connector->tv_format, i,
tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
intel_sdvo_connector->base.base.state->tv.mode = intel_sdvo_connector->tv_format_supported[0];
intel_sdvo_connector->base.base.state->tv.legacy_mode = intel_sdvo_connector->tv_format_supported[0];
drm_object_attach_property(&intel_sdvo_connector->base.base.base,
intel_sdvo_connector->tv_format, 0);
return true;

View File

@ -949,7 +949,7 @@ intel_disable_tv(struct intel_atomic_state *state,
static const struct tv_mode *intel_tv_mode_find(const struct drm_connector_state *conn_state)
{
int format = conn_state->tv.mode;
int format = conn_state->tv.legacy_mode;
return &tv_modes[format];
}
@ -1710,7 +1710,7 @@ static void intel_tv_find_better_format(struct drm_connector *connector)
break;
}
connector->state->tv.mode = i;
connector->state->tv.legacy_mode = i;
}
static int
@ -1865,7 +1865,7 @@ static int intel_tv_atomic_check(struct drm_connector *connector,
old_state = drm_atomic_get_old_connector_state(state, connector);
new_crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc);
if (old_state->tv.mode != new_state->tv.mode ||
if (old_state->tv.legacy_mode != new_state->tv.legacy_mode ||
old_state->tv.margins.left != new_state->tv.margins.left ||
old_state->tv.margins.right != new_state->tv.margins.right ||
old_state->tv.margins.top != new_state->tv.margins.top ||
@ -1902,7 +1902,7 @@ static void intel_tv_add_properties(struct drm_connector *connector)
conn_state->tv.margins.right = 46;
conn_state->tv.margins.bottom = 37;
conn_state->tv.mode = 0;
conn_state->tv.legacy_mode = 0;
/* Create TV properties then attach current values */
for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
@ -1916,7 +1916,7 @@ static void intel_tv_add_properties(struct drm_connector *connector)
drm_object_attach_property(&connector->base,
i915->drm.mode_config.legacy_tv_mode_property,
conn_state->tv.mode);
conn_state->tv.legacy_mode);
drm_object_attach_property(&connector->base,
i915->drm.mode_config.tv_left_margin_property,
conn_state->tv.margins.left);

View File

@ -528,7 +528,7 @@ static void ttm_pool_free_range(struct ttm_pool *pool, struct ttm_tt *tt,
enum ttm_caching caching,
pgoff_t start_page, pgoff_t end_page)
{
struct vm_page **pages = tt->pages;
struct vm_page **pages = &tt->pages[start_page];
unsigned int order;
pgoff_t i, nr;

View File

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2065 2024/03/01 08:34:42 jsg Exp $
$OpenBSD: pcidevs,v 1.2066 2024/03/04 05:34:07 jsg Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/*
@ -6032,8 +6032,8 @@ product INTEL DG2_G10_3 0x5692 Arc A550M
product INTEL DG2_G11_1 0x5693 Arc A370M
product INTEL DG2_G11_2 0x5694 Arc A350M
product INTEL DG2_G11_3 0x5695 Graphics
product INTEL DG2_G12_1 0x5696 Graphics
product INTEL DG2_G12_2 0x5697 Graphics
product INTEL DG2_G12_1 0x5696 Arc A570M
product INTEL DG2_G12_2 0x5697 Arc A530M
product INTEL DG2_G10_4 0x56a0 Arc A770
product INTEL DG2_G10_5 0x56a1 Arc A750
product INTEL DG2_G10_6 0x56a2 Arc A580
@ -6043,8 +6043,8 @@ product INTEL DG2_G11_4 0x56a5 Arc A380
product INTEL DG2_G11_5 0x56a6 Arc A310
product INTEL DG2_G11_6 0x56b0 Arc Pro A30M
product INTEL DG2_G11_7 0x56b1 Arc Pro A40/A50
product INTEL DG2_G12_5 0x56b2 Graphics
product INTEL DG2_G12_6 0x56b3 Graphics
product INTEL DG2_G12_5 0x56b2 Arc Pro A60M
product INTEL DG2_G12_6 0x56b3 Arc Pro A60
product INTEL ATS_M150 0x56c0 Flex 170
product INTEL ATS_M75 0x56c1 Flex 140
product INTEL I219_LM24 0x57a0 I219-LM

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2065 2024/03/01 08:34:42 jsg Exp
* OpenBSD: pcidevs,v 1.2066 2024/03/04 05:34:07 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -6037,8 +6037,8 @@
#define PCI_PRODUCT_INTEL_DG2_G11_1 0x5693 /* Arc A370M */
#define PCI_PRODUCT_INTEL_DG2_G11_2 0x5694 /* Arc A350M */
#define PCI_PRODUCT_INTEL_DG2_G11_3 0x5695 /* Graphics */
#define PCI_PRODUCT_INTEL_DG2_G12_1 0x5696 /* Graphics */
#define PCI_PRODUCT_INTEL_DG2_G12_2 0x5697 /* Graphics */
#define PCI_PRODUCT_INTEL_DG2_G12_1 0x5696 /* Arc A570M */
#define PCI_PRODUCT_INTEL_DG2_G12_2 0x5697 /* Arc A530M */
#define PCI_PRODUCT_INTEL_DG2_G10_4 0x56a0 /* Arc A770 */
#define PCI_PRODUCT_INTEL_DG2_G10_5 0x56a1 /* Arc A750 */
#define PCI_PRODUCT_INTEL_DG2_G10_6 0x56a2 /* Arc A580 */
@ -6048,8 +6048,8 @@
#define PCI_PRODUCT_INTEL_DG2_G11_5 0x56a6 /* Arc A310 */
#define PCI_PRODUCT_INTEL_DG2_G11_6 0x56b0 /* Arc Pro A30M */
#define PCI_PRODUCT_INTEL_DG2_G11_7 0x56b1 /* Arc Pro A40/A50 */
#define PCI_PRODUCT_INTEL_DG2_G12_5 0x56b2 /* Graphics */
#define PCI_PRODUCT_INTEL_DG2_G12_6 0x56b3 /* Graphics */
#define PCI_PRODUCT_INTEL_DG2_G12_5 0x56b2 /* Arc Pro A60M */
#define PCI_PRODUCT_INTEL_DG2_G12_6 0x56b3 /* Arc Pro A60 */
#define PCI_PRODUCT_INTEL_ATS_M150 0x56c0 /* Flex 170 */
#define PCI_PRODUCT_INTEL_ATS_M75 0x56c1 /* Flex 140 */
#define PCI_PRODUCT_INTEL_I219_LM24 0x57a0 /* I219-LM */

View File

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2065 2024/03/01 08:34:42 jsg Exp
* OpenBSD: pcidevs,v 1.2066 2024/03/04 05:34:07 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -21489,11 +21489,11 @@ static const struct pci_known_product pci_known_products[] = {
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DG2_G12_1,
"Graphics",
"Arc A570M",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DG2_G12_2,
"Graphics",
"Arc A530M",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DG2_G10_4,
@ -21533,11 +21533,11 @@ static const struct pci_known_product pci_known_products[] = {
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DG2_G12_5,
"Graphics",
"Arc Pro A60M",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DG2_G12_6,
"Graphics",
"Arc Pro A60",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ATS_M150,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_aggr.c,v 1.42 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: if_aggr.c,v 1.43 2024/03/04 04:44:12 dlg Exp $ */
/*
* Copyright (c) 2019 The University of Queensland
@ -1176,8 +1176,8 @@ aggr_add_port(struct aggr_softc *sc, const struct trunk_reqport *rp)
aggr_update_capabilities(sc);
/*
* use (and modification) of ifp->if_input and ac->ac_trunkport
* is protected by NET_LOCK.
* use (and modification) of ifp->if_input and ac->ac_trunkport
* is protected by NET_LOCK.
*/
ac0->ac_trunkport = p;
@ -1406,8 +1406,8 @@ aggr_p_dtor(struct aggr_softc *sc, struct aggr_port *p, const char *op)
timeout_del(&p->p_wait_while_timer);
/*
* use (and modification) of ifp->if_input and ac->ac_trunkport
* is protected by NET_LOCK.
* use (and modification) of ifp->if_input and ac->ac_trunkport
* is protected by NET_LOCK.
*/
ac0->ac_trunkport = NULL;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.189 2023/10/12 03:36:32 djm Exp $ */
/* $OpenBSD: misc.c,v 1.190 2024/03/04 02:16:11 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005-2020 Damien Miller. All rights reserved.
@ -2537,6 +2537,19 @@ opt_array_append(const char *file, const int line, const char *directive,
opt_array_append2(file, line, directive, array, NULL, lp, s, 0);
}
void
opt_array_free2(char **array, int **iarray, u_int l)
{
u_int i;
if (array == NULL || l == 0)
return;
for (i = 0; i < l; i++)
free(array[i]);
free(array);
free(iarray);
}
sshsig_t
ssh_signal(int signum, sshsig_t handler)
{

View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.h,v 1.106 2023/10/11 22:42:26 djm Exp $ */
/* $OpenBSD: misc.h,v 1.107 2024/03/04 02:16:11 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -208,6 +208,7 @@ void opt_array_append(const char *file, const int line,
void opt_array_append2(const char *file, const int line,
const char *directive, char ***array, int **iarray, u_int *lp,
const char *s, int i);
void opt_array_free2(char **array, int **iarray, u_int l);
struct timespec;
void ptimeout_init(struct timespec *pt);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.384 2024/01/11 01:45:36 djm Exp $ */
/* $OpenBSD: readconf.c,v 1.386 2024/03/04 04:13:18 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -867,6 +867,20 @@ parse_token(const char *cp, const char *filename, int linenum,
return oBadOption;
}
static void
free_canon_cnames(struct allowed_cname *cnames, u_int n)
{
u_int i;
if (cnames == NULL || n == 0)
return;
for (i = 0; i < n; i++) {
free(cnames[i].source_list);
free(cnames[i].target_list);
}
free(cnames);
}
/* Multistate option parsing */
struct multistate {
char *key;
@ -1009,21 +1023,24 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
{
char *str, **charptr, *endofnumber, *keyword, *arg, *arg2, *p;
char **cpptr, ***cppptr, fwdarg[256];
u_int i, *uintptr, uvalue, max_entries = 0;
u_int i, *uintptr, max_entries = 0;
int r, oactive, negated, opcode, *intptr, value, value2, cmdline = 0;
int remotefwd, dynamicfwd, ca_only = 0;
int remotefwd, dynamicfwd, ca_only = 0, found = 0;
LogLevel *log_level_ptr;
SyslogFacility *log_facility_ptr;
long long val64;
size_t len;
struct Forward fwd;
const struct multistate *multistate_ptr;
struct allowed_cname *cname;
glob_t gl;
const char *errstr;
char **oav = NULL, **av;
int oac = 0, ac;
int ret = -1;
struct allowed_cname *cnames = NULL;
u_int ncnames = 0;
char **strs = NULL; /* string array arguments; freed implicitly */
u_int nstrs = 0;
if (activep == NULL) { /* We are processing a command line directive */
cmdline = 1;
@ -1639,14 +1656,13 @@ parse_pubkey_algos:
case oPermitRemoteOpen:
uintptr = &options->num_permitted_remote_opens;
cppptr = &options->permitted_remote_opens;
uvalue = *uintptr; /* modified later */
i = 0;
found = *uintptr == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
arg2 = xstrdup(arg);
/* Allow any/none only in first position */
if (strcasecmp(arg, "none") == 0 ||
strcasecmp(arg, "any") == 0) {
if (i > 0 || ac > 0) {
if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"%s\" "
"argument must appear alone.",
filename, linenum, keyword, arg);
@ -1672,17 +1688,20 @@ parse_pubkey_algos:
lookup_opcode_name(opcode));
}
}
if (*activep && uvalue == 0) {
opt_array_append(filename, linenum,
lookup_opcode_name(opcode),
cppptr, uintptr, arg2);
}
opt_array_append(filename, linenum,
lookup_opcode_name(opcode),
&strs, &nstrs, arg2);
free(arg2);
i++;
}
if (i == 0)
if (nstrs == 0)
fatal("%s line %d: missing %s specification",
filename, linenum, lookup_opcode_name(opcode));
if (found && *activep) {
*cppptr = strs;
*uintptr = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
case oClearAllForwardings:
@ -1800,12 +1819,14 @@ parse_pubkey_algos:
goto parse_int;
case oSendEnv:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') != NULL) {
error("%s line %d: Invalid environment name.",
filename, linenum);
goto out;
}
found = 1;
if (!*activep)
continue;
if (*arg == '-') {
@ -1817,27 +1838,38 @@ parse_pubkey_algos:
lookup_opcode_name(opcode),
&options->send_env, &options->num_send_env, arg);
}
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break;
case oSetEnv:
value = options->num_setenv;
found = options->num_setenv == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (strchr(arg, '=') == NULL) {
error("%s line %d: Invalid SetEnv.",
filename, linenum);
goto out;
}
if (!*activep || value != 0)
continue;
if (lookup_setenv_in_list(arg, options->setenv,
options->num_setenv) != NULL) {
if (lookup_setenv_in_list(arg, strs, nstrs) != NULL) {
debug2("%s line %d: ignoring duplicate env "
"name \"%.64s\"", filename, linenum, arg);
continue;
}
opt_array_append(filename, linenum,
lookup_opcode_name(opcode),
&options->setenv, &options->num_setenv, arg);
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->setenv = strs;
options->num_setenv = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
@ -2046,52 +2078,46 @@ parse_pubkey_algos:
goto parse_flag;
case oCanonicalDomains:
value = options->num_canonical_domains != 0;
i = 0;
found = options->num_canonical_domains == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') {
error("%s line %d: keyword %s empty argument",
filename, linenum, keyword);
goto out;
}
/* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) {
if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" "
"argument must appear alone.",
filename, linenum, keyword);
goto out;
}
}
i++;
if (!valid_domain(arg, 1, &errstr)) {
error("%s line %d: %s", filename, linenum,
errstr);
goto out;
}
if (!*activep || value)
continue;
if (options->num_canonical_domains >=
MAX_CANON_DOMAINS) {
error("%s line %d: too many hostname suffixes.",
filename, linenum);
goto out;
}
options->canonical_domains[
options->num_canonical_domains++] = xstrdup(arg);
opt_array_append(filename, linenum, keyword,
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->canonical_domains = strs;
options->num_canonical_domains = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
case oCanonicalizePermittedCNAMEs:
value = options->num_permitted_cnames != 0;
i = 0;
found = options->num_permitted_cnames == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
/*
* Either 'none' (only in first position), '*' for
* everything or 'list:list'
*/
if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) {
if (ncnames > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" "
"argument must appear alone.",
filename, linenum, keyword);
@ -2112,20 +2138,23 @@ parse_pubkey_algos:
*arg2 = '\0';
arg2++;
}
i++;
if (!*activep || value)
continue;
if (options->num_permitted_cnames >=
MAX_CANON_DOMAINS) {
error("%s line %d: too many permitted CNAMEs.",
filename, linenum);
goto out;
}
cname = options->permitted_cnames +
options->num_permitted_cnames++;
cname->source_list = xstrdup(arg);
cname->target_list = xstrdup(arg2);
cnames = xrecallocarray(cnames, ncnames, ncnames + 1,
sizeof(*cnames));
cnames[ncnames].source_list = xstrdup(arg);
cnames[ncnames].target_list = xstrdup(arg2);
ncnames++;
}
if (ncnames == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->permitted_cnames = cnames;
options->num_permitted_cnames = ncnames;
cnames = NULL; /* transferred */
ncnames = 0;
}
/* un-transferred cnames is cleaned up before exit */
break;
case oCanonicalizeHostname:
@ -2306,12 +2335,11 @@ parse_pubkey_algos:
break;
case oChannelTimeout:
uvalue = options->num_channel_timeouts;
i = 0;
found = options->num_channel_timeouts == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
/* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) {
if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" "
"argument must appear alone.",
filename, linenum, keyword);
@ -2322,11 +2350,18 @@ parse_pubkey_algos:
fatal("%s line %d: invalid channel timeout %s",
filename, linenum, arg);
}
if (!*activep || uvalue != 0)
continue;
opt_array_append(filename, linenum, keyword,
&options->channel_timeouts,
&options->num_channel_timeouts, arg);
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->channel_timeouts = strs;
options->num_channel_timeouts = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
@ -2358,6 +2393,8 @@ parse_pubkey_algos:
/* success */
ret = 0;
out:
free_canon_cnames(cnames, ncnames);
opt_array_free2(strs, NULL, nstrs);
argv_free(oav, oac);
return ret;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.h,v 1.155 2024/01/11 01:45:36 djm Exp $ */
/* $OpenBSD: readconf.h,v 1.156 2024/03/04 02:16:11 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -155,12 +155,12 @@ typedef struct {
int proxy_use_fdpass;
int num_canonical_domains;
char *canonical_domains[MAX_CANON_DOMAINS];
char **canonical_domains;
int canonicalize_hostname;
int canonicalize_max_dots;
int canonicalize_fallback_local;
int num_permitted_cnames;
struct allowed_cname permitted_cnames[MAX_CANON_DOMAINS];
struct allowed_cname *permitted_cnames;
char *revoked_host_keys;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: servconf.c,v 1.404 2024/02/20 04:10:03 djm Exp $ */
/* $OpenBSD: servconf.c,v 1.405 2024/03/04 02:16:11 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@ -1247,12 +1247,12 @@ process_server_config_line_depth(ServerOptions *options, char *line,
struct include_list *includes)
{
char *str, ***chararrayptr, **charptr, *arg, *arg2, *p, *keyword;
int cmdline = 0, *intptr, value, value2, n, port, oactive, r, found;
int ca_only = 0;
int cmdline = 0, *intptr, value, value2, n, port, oactive, r;
int ca_only = 0, found = 0;
SyslogFacility *log_facility_ptr;
LogLevel *log_level_ptr;
ServerOpCodes opcode;
u_int i, *uintptr, uvalue, flags = 0;
u_int i, *uintptr, flags = 0;
size_t len;
long long val64;
const struct multistate *multistate_ptr;
@ -1262,6 +1262,8 @@ process_server_config_line_depth(ServerOptions *options, char *line,
char **oav = NULL, **av;
int oac = 0, ac;
int ret = -1;
char **strs = NULL; /* string array arguments; freed implicitly */
u_int nstrs = 0;
/* Strip trailing whitespace. Allow \f (form feed) at EOL only */
if ((len = strlen(line)) == 0)
@ -1718,7 +1720,6 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sLogVerbose:
found = options->num_log_verbose == 0;
i = 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') {
error("%s line %d: keyword %s empty argument",
@ -1727,19 +1728,25 @@ process_server_config_line_depth(ServerOptions *options, char *line,
}
/* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) {
if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" "
"argument must appear alone.",
filename, linenum, keyword);
goto out;
}
}
i++;
if (!found || !*activep)
continue;
opt_array_append(filename, linenum, keyword,
&options->log_verbose, &options->num_log_verbose,
arg);
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->log_verbose = strs;
options->num_log_verbose = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
@ -1765,16 +1772,22 @@ process_server_config_line_depth(ServerOptions *options, char *line,
chararrayptr = &options->allow_users;
uintptr = &options->num_allow_users;
parse_allowdenyusers:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' ||
match_user(NULL, NULL, NULL, arg) == -1)
fatal("%s line %d: invalid %s pattern: \"%s\"",
filename, linenum, keyword, arg);
found = 1;
if (!*activep)
continue;
opt_array_append(filename, linenum, keyword,
chararrayptr, uintptr, arg);
}
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break;
case sDenyUsers:
@ -1785,16 +1798,22 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sAllowGroups:
chararrayptr = &options->allow_groups;
uintptr = &options->num_allow_groups;
/* XXX appends to list; doesn't respect first-match-wins */
parse_allowdenygroups:
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0')
fatal("%s line %d: empty %s pattern",
filename, linenum, keyword);
found = 1;
if (!*activep)
continue;
opt_array_append(filename, linenum, keyword,
chararrayptr, uintptr, arg);
}
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break;
case sDenyGroups:
@ -1978,7 +1997,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
* AuthorizedKeysFile /etc/ssh_keys/%u
*/
case sAuthorizedKeysFile:
uvalue = options->num_authkeys_files;
found = options->num_authkeys_files == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0') {
error("%s line %d: keyword %s empty argument",
@ -1986,13 +2005,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto out;
}
arg2 = tilde_expand_filename(arg, getuid());
if (*activep && uvalue == 0) {
opt_array_append(filename, linenum, keyword,
&options->authorized_keys_files,
&options->num_authkeys_files, arg2);
}
opt_array_append(filename, linenum, keyword,
&strs, &nstrs, arg2);
free(arg2);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->authorized_keys_files = strs;
options->num_authkeys_files = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
case sAuthorizedPrincipalsFile:
@ -2018,34 +2044,47 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto parse_int;
case sAcceptEnv:
/* XXX appends to list; doesn't respect first-match-wins */
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') != NULL)
fatal("%s line %d: Invalid environment name.",
filename, linenum);
found = 1;
if (!*activep)
continue;
opt_array_append(filename, linenum, keyword,
&options->accept_env, &options->num_accept_env,
arg);
}
if (!found) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
break;
case sSetEnv:
uvalue = options->num_setenv;
found = options->num_setenv == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (*arg == '\0' || strchr(arg, '=') == NULL)
fatal("%s line %d: Invalid environment.",
filename, linenum);
if (!*activep || uvalue != 0)
continue;
if (lookup_setenv_in_list(arg, options->setenv,
options->num_setenv) != NULL) {
if (lookup_setenv_in_list(arg, strs, nstrs) != NULL) {
debug2("%s line %d: ignoring duplicate env "
"name \"%.64s\"", filename, linenum, arg);
continue;
}
opt_array_append(filename, linenum, keyword,
&options->setenv, &options->num_setenv, arg);
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->setenv = strs;
options->num_setenv = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
@ -2196,21 +2235,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
uintptr = &options->num_permitted_opens;
chararrayptr = &options->permitted_opens;
}
arg = argv_next(&ac, &av);
if (!arg || *arg == '\0')
fatal("%s line %d: %s missing argument.",
filename, linenum, keyword);
uvalue = *uintptr; /* modified later */
if (strcmp(arg, "any") == 0 || strcmp(arg, "none") == 0) {
if (*activep && uvalue == 0) {
*uintptr = 1;
*chararrayptr = xcalloc(1,
sizeof(**chararrayptr));
(*chararrayptr)[0] = xstrdup(arg);
found = *uintptr == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
if (strcmp(arg, "any") == 0 ||
strcmp(arg, "none") == 0) {
if (nstrs != 0) {
fatal("%s line %d: %s must appear "
"alone on a %s line.",
filename, linenum, arg, keyword);
}
opt_array_append(filename, linenum, keyword,
&strs, &nstrs, arg);
continue;
}
break;
}
for (; arg != NULL && *arg != '\0'; arg = argv_next(&ac, &av)) {
if (opcode == sPermitListen &&
strchr(arg, ':') == NULL) {
/*
@ -2232,12 +2270,20 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: %s bad port number",
filename, linenum, keyword);
}
if (*activep && uvalue == 0) {
opt_array_append(filename, linenum, keyword,
chararrayptr, uintptr, arg2);
}
opt_array_append(filename, linenum, keyword,
&strs, &nstrs, arg2);
free(arg2);
}
if (nstrs == 0) {
fatal("%s line %d: %s missing argument.",
filename, linenum, keyword);
}
if (found && *activep) {
*chararrayptr = strs;
*uintptr = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
case sForceCommand:
@ -2362,10 +2408,9 @@ process_server_config_line_depth(ServerOptions *options, char *line,
case sAuthenticationMethods:
found = options->num_auth_methods == 0;
value = 0; /* seen "any" pseudo-method */
value2 = 0; /* successfully parsed any method */
while ((arg = argv_next(&ac, &av)) != NULL) {
if (strcmp(arg, "any") == 0) {
if (options->num_auth_methods > 0) {
if (nstrs > 0) {
fatal("%s line %d: \"any\" must "
"appear alone in %s",
filename, linenum, keyword);
@ -2378,17 +2423,19 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: invalid %s method list.",
filename, linenum, keyword);
}
value2 = 1;
if (!found || !*activep)
continue;
opt_array_append(filename, linenum, keyword,
&options->auth_methods,
&options->num_auth_methods, arg);
&strs, &nstrs, arg);
}
if (value2 == 0) {
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->auth_methods = strs;
options->num_auth_methods = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
case sStreamLocalBindMask:
@ -2444,12 +2491,11 @@ process_server_config_line_depth(ServerOptions *options, char *line,
goto parse_int;
case sChannelTimeout:
uvalue = options->num_channel_timeouts;
i = 0;
found = options->num_channel_timeouts == 0;
while ((arg = argv_next(&ac, &av)) != NULL) {
/* Allow "none" only in first position */
if (strcasecmp(arg, "none") == 0) {
if (i > 0 || ac > 0) {
if (nstrs > 0 || ac > 0) {
error("%s line %d: keyword %s \"none\" "
"argument must appear alone.",
filename, linenum, keyword);
@ -2460,11 +2506,18 @@ process_server_config_line_depth(ServerOptions *options, char *line,
fatal("%s line %d: invalid channel timeout %s",
filename, linenum, arg);
}
if (!*activep || uvalue != 0)
continue;
opt_array_append(filename, linenum, keyword,
&options->channel_timeouts,
&options->num_channel_timeouts, arg);
&strs, &nstrs, arg);
}
if (nstrs == 0) {
fatal("%s line %d: no %s specified",
filename, linenum, keyword);
}
if (found && *activep) {
options->channel_timeouts = strs;
options->num_channel_timeouts = nstrs;
strs = NULL; /* transferred */
nstrs = 0;
}
break;
@ -2504,6 +2557,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
/* success */
ret = 0;
out:
opt_array_free2(strs, NULL, nstrs);
argv_free(oav, oac);
return ret;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: patterns.c,v 1.11 2024/01/27 15:15:01 phessler Exp $ */
/* $OpenBSD: patterns.c,v 1.12 2024/03/04 17:03:06 deraadt Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
@ -114,6 +114,7 @@ main(void)
printf("%s\n", "otus");
printf("%s\n", "pgt");
printf("%s\n", "qcpas");
printf("%s\n", "qcpas ^ppb0*\"Qualcomm SC8280XP PCIe\"");
printf("%s\n", "qwx");
printf("%s\n", "radeondrm");
print_devices("radeondrm", radeon_devices, nitems(radeon_devices));