Merge branch 'openwrt:master' into master
This commit is contained in:
commit
3e8eb20091
230 changed files with 12215 additions and 3295 deletions
|
@ -1,2 +1,2 @@
|
|||
LINUX_VERSION-5.15 = .141
|
||||
LINUX_KERNEL_HASH-5.15.141 = 936d6ac65c692a986b4bde34b7f3d7ad90f7f86f19e4ef320e008d40f07e2cfa
|
||||
LINUX_VERSION-5.15 = .144
|
||||
LINUX_KERNEL_HASH-5.15.144 = f053afafafce771acbf478afdd16e9aa85b0a0e328205c4f53276062300a5b3b
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
LINUX_VERSION-6.1 = .65
|
||||
LINUX_KERNEL_HASH-6.1.65 = 407229936802a44b1e484c2e9ac3bbe53a65d825cc468ccdbd76281b491ab20a
|
||||
LINUX_VERSION-6.1 = .69
|
||||
LINUX_KERNEL_HASH-6.1.69 = 7e3d2694d18ce502068cc88a430da809abbd17d0773268524ebece442612b541
|
||||
|
|
|
@ -1,100 +1,140 @@
|
|||
#!/usr/bin/awk -f
|
||||
#!/bin/sh
|
||||
|
||||
function bitcount(c) {
|
||||
c=and(rshift(c, 1),0x55555555)+and(c,0x55555555)
|
||||
c=and(rshift(c, 2),0x33333333)+and(c,0x33333333)
|
||||
c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f)
|
||||
c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff)
|
||||
c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff)
|
||||
return c
|
||||
. /lib/functions/ipv4.sh
|
||||
|
||||
PROG="$(basename "$0")"
|
||||
|
||||
# wrapper to convert an integer to an address, unless we're using
|
||||
# decimal output format.
|
||||
# hook for library function
|
||||
_ip2str() {
|
||||
local var="$1" n="$2"
|
||||
assert_uint32 "$n" || exit 1
|
||||
|
||||
if [ "$decimal" -ne 0 ]; then
|
||||
export -- "$var=$n"
|
||||
elif [ "$hexadecimal" -ne 0 ]; then
|
||||
export -- "$var=$(printf "%x" "$n")"
|
||||
else
|
||||
ip2str "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function ip2int(ip) {
|
||||
ret=0
|
||||
n=split(ip,a,"\\.")
|
||||
for (x=1;x<=n;x++)
|
||||
ret=or(lshift(ret,8),a[x])
|
||||
return ret
|
||||
usage() {
|
||||
echo "Usage: $PROG [ -d | -x ] address/prefix [ start limit ]" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function int2ip(ip,ret,x) {
|
||||
ret=and(ip,255)
|
||||
ip=rshift(ip,8)
|
||||
for(;x<3;x++) {
|
||||
ret=and(ip,255)"."ret
|
||||
ip=rshift(ip,8)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
decimal=0
|
||||
hexadecimal=0
|
||||
if [ "$1" = "-d" ]; then
|
||||
decimal=1
|
||||
shift
|
||||
elif [ "$1" = "-x" ]; then
|
||||
hexadecimal=1
|
||||
shift
|
||||
fi
|
||||
|
||||
function compl32(v) {
|
||||
ret=xor(v, 0xffffffff)
|
||||
return ret
|
||||
}
|
||||
if [ $# -eq 0 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
BEGIN {
|
||||
slpos=index(ARGV[1],"/")
|
||||
if (slpos != 0) {
|
||||
# rearrange arguments to not use compound notation
|
||||
ARGV[4]=ARGV[3]
|
||||
ARGV[3]=ARGV[2]
|
||||
ARGV[2]=substr(ARGV[1],slpos+1)
|
||||
ARGV[1]=substr(ARGV[1],0,slpos-1)
|
||||
}
|
||||
ipaddr=ip2int(ARGV[1])
|
||||
dotpos=index(ARGV[2],".")
|
||||
if (dotpos == 0)
|
||||
netmask=compl32(2**(32-int(ARGV[2]))-1)
|
||||
else
|
||||
netmask=ip2int(ARGV[2])
|
||||
case "$1" in
|
||||
*/*.*)
|
||||
# data is n.n.n.n/m.m.m.m format, like on a Cisco router
|
||||
str2ip ipaddr "${1%/*}" || exit 1
|
||||
str2ip netmask "${1#*/}" || exit 1
|
||||
netmask2prefix prefix "$netmask" || exit 1
|
||||
shift
|
||||
;;
|
||||
*/*)
|
||||
# more modern prefix notation of n.n.n.n/p
|
||||
str2ip ipaddr "${1%/*}" || exit 1
|
||||
prefix="${1#*/}"
|
||||
assert_uint32 "$prefix" || exit 1
|
||||
if [ "$prefix" -gt 32 ]; then
|
||||
printf "Prefix out of range (%s)\n" "$prefix" >&2
|
||||
exit 1
|
||||
fi
|
||||
prefix2netmask netmask "$prefix" || exit 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# address and netmask as two separate arguments
|
||||
str2ip ipaddr "$1" || exit 1
|
||||
str2ip netmask "$2" || exit 1
|
||||
netmask2prefix prefix "$netmask" || exit 1
|
||||
shift 2
|
||||
;;
|
||||
esac
|
||||
|
||||
network=and(ipaddr,netmask)
|
||||
prefix=32-bitcount(compl32(netmask))
|
||||
# we either have no arguments left, or we have a range start and length
|
||||
if [ $# -ne 0 ] && [ $# -ne 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
print "IP="int2ip(ipaddr)
|
||||
print "NETMASK="int2ip(netmask)
|
||||
print "NETWORK="int2ip(network)
|
||||
if (prefix<=30) {
|
||||
broadcast=or(network,compl32(netmask))
|
||||
print "BROADCAST="int2ip(broadcast)
|
||||
}
|
||||
print "PREFIX="prefix
|
||||
# complement of the netmask, i.e. the hostmask
|
||||
hostmask=$((netmask ^ 0xffffffff))
|
||||
network=$((ipaddr & netmask))
|
||||
broadcast=$((network | hostmask))
|
||||
count=$((hostmask + 1))
|
||||
|
||||
# range calculations:
|
||||
# ipcalc <ip> <netmask> <range_start> <range_size>
|
||||
_ip2str IP "$ipaddr"
|
||||
_ip2str NETMASK "$netmask"
|
||||
_ip2str NETWORK "$network"
|
||||
|
||||
if (ARGC <= 3)
|
||||
exit(0)
|
||||
echo "IP=$IP"
|
||||
echo "NETMASK=$NETMASK"
|
||||
# don't include this-network or broadcast addresses
|
||||
if [ "$prefix" -le 30 ]; then
|
||||
_ip2str BROADCAST "$broadcast"
|
||||
echo "BROADCAST=$BROADCAST"
|
||||
fi
|
||||
echo "NETWORK=$NETWORK"
|
||||
echo "PREFIX=$prefix"
|
||||
echo "COUNT=$count"
|
||||
|
||||
if (prefix<=30)
|
||||
limit=network+1
|
||||
else
|
||||
limit=network
|
||||
# if there's no range, we're done
|
||||
[ $# -eq 0 ] && exit 0
|
||||
|
||||
start=or(network,and(ip2int(ARGV[3]),compl32(netmask)))
|
||||
if (start<limit) start=limit
|
||||
if (start==ipaddr) start=ipaddr+1
|
||||
if [ "$prefix" -le 30 ]; then
|
||||
lower=$((network + 1))
|
||||
else
|
||||
lower="$network"
|
||||
fi
|
||||
|
||||
if (prefix<=30)
|
||||
limit=or(network,compl32(netmask))-1
|
||||
else
|
||||
limit=or(network,compl32(netmask))
|
||||
start="$1"
|
||||
assert_uint32 "$start" || exit 1
|
||||
start=$((network | (start & hostmask)))
|
||||
[ "$start" -lt "$lower" ] && start="$lower"
|
||||
[ "$start" -eq "$ipaddr" ] && start=$((start + 1))
|
||||
|
||||
end=start+ARGV[4]-1
|
||||
if (end>limit) end=limit
|
||||
if (end==ipaddr) end=ipaddr-1
|
||||
if [ "$prefix" -le 30 ]; then
|
||||
upper=$(((network | hostmask) - 1))
|
||||
else
|
||||
upper="$network"
|
||||
fi
|
||||
|
||||
if (start>end) {
|
||||
print "network ("int2ip(network)"/"prefix") too small" > "/dev/stderr"
|
||||
exit(1)
|
||||
}
|
||||
range="$2"
|
||||
assert_uint32 "$range" || exit 1
|
||||
end=$((start + range - 1))
|
||||
[ "$end" -gt "$upper" ] && end="$upper"
|
||||
[ "$end" -eq "$ipaddr" ] && end=$((end - 1))
|
||||
|
||||
if (ipaddr >= start && ipaddr <= end) {
|
||||
print "warning: ipaddr inside range - this might not be supported in future releases of Openwrt" > "/dev/stderr"
|
||||
# turn this into an error after Openwrt 24 has been released
|
||||
# exit(1)
|
||||
}
|
||||
if [ "$start" -gt "$end" ]; then
|
||||
echo "network ($NETWORK/$prefix) too small" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print "START="int2ip(start)
|
||||
print "END="int2ip(end)
|
||||
}
|
||||
_ip2str START "$start"
|
||||
_ip2str END "$end"
|
||||
|
||||
if [ "$start" -le "$ipaddr" ] && [ "$ipaddr" -le "$end" ]; then
|
||||
echo "error: address $IP inside range $START..$END" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "START=$START"
|
||||
echo "END=$END"
|
||||
|
||||
exit 0
|
||||
|
|
268
package/base-files/files/lib/functions/ipv4.sh
Normal file
268
package/base-files/files/lib/functions/ipv4.sh
Normal file
|
@ -0,0 +1,268 @@
|
|||
uint_max=4294967295
|
||||
|
||||
d_10_0_0_0=167772160
|
||||
d_10_255_255_255=184549375
|
||||
|
||||
d_172_16_0_0=2886729728
|
||||
d_172_31_255_255=2887778303
|
||||
|
||||
d_192_168_0_0=3232235520
|
||||
d_192_168_255_255=3232301055
|
||||
|
||||
d_169_254_0_0=2851995648
|
||||
d_169_254_255_255=2852061183
|
||||
|
||||
d_127_0_0_0=2130706432
|
||||
d_127_255_255_255=2147483647
|
||||
|
||||
d_224_0_0_0=3758096384
|
||||
d_239_255_255_255=4026531839
|
||||
|
||||
# check that $1 is only base 10 digits, and that it doesn't
|
||||
# exceed 2^32-1
|
||||
assert_uint32() {
|
||||
local __n="$1"
|
||||
|
||||
if [ -z "$__n" -o -n "${__n//[0-9]/}" ]; then
|
||||
printf "Not a decimal integer (%s)\n" "$__n ">&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$__n" -gt $uint_max ]; then
|
||||
printf "Out of range (%s)\n" "$__n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$((__n + 0))" != "$__n" ]; then
|
||||
printf "Not normalized notation (%s)\n" "$__n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# return a count of the number of bits set in $1
|
||||
bitcount() {
|
||||
local __var="$1" __c="$2"
|
||||
assert_uint32 "$__c" || return 1
|
||||
|
||||
__c=$((((__c >> 1) & 0x55555555) + (__c & 0x55555555)))
|
||||
__c=$((((__c >> 2) & 0x33333333) + (__c & 0x33333333)))
|
||||
__c=$((((__c >> 4) & 0x0f0f0f0f) + (__c & 0x0f0f0f0f)))
|
||||
__c=$((((__c >> 8) & 0x00ff00ff) + (__c & 0x00ff00ff)))
|
||||
__c=$((((__c >> 16) & 0x0000ffff) + (__c & 0x0000ffff)))
|
||||
|
||||
export -- "$__var=$__c"
|
||||
}
|
||||
|
||||
# tedious but portable with busybox's limited shell
|
||||
# we check each octet to be in the range of 0..255,
|
||||
# and also make sure there's no extaneous characters.
|
||||
str2ip() {
|
||||
local __var="$1" __ip="$2" __n __val=0
|
||||
|
||||
case "$__ip" in
|
||||
[0-9].*)
|
||||
__n="${__ip:0:1}"
|
||||
__ip="${__ip:2}"
|
||||
;;
|
||||
[1-9][0-9].*)
|
||||
__n="${__ip:0:2}"
|
||||
__ip="${__ip:3}"
|
||||
;;
|
||||
1[0-9][0-9].*|2[0-4][0-9].*|25[0-5].*)
|
||||
__n="${__ip:0:3}"
|
||||
__ip="${__ip:4}"
|
||||
;;
|
||||
*)
|
||||
printf "Not a dotted quad (%s)\n" "$2" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__val=$((__n << 24))
|
||||
|
||||
case "$__ip" in
|
||||
[0-9].*)
|
||||
__n="${__ip:0:1}"
|
||||
__ip="${__ip:2}"
|
||||
;;
|
||||
[1-9][0-9].*)
|
||||
__n="${__ip:0:2}"
|
||||
__ip="${__ip:3}"
|
||||
;;
|
||||
1[0-9][0-9].*|2[0-4][0-9].*|25[0-5].*)
|
||||
__n="${__ip:0:3}"
|
||||
__ip="${__ip:4}"
|
||||
;;
|
||||
*)
|
||||
printf "Not a dotted quad (%s)\n" "$2" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__val=$((__val + (__n << 16)))
|
||||
|
||||
case "$__ip" in
|
||||
[0-9].*)
|
||||
__n="${__ip:0:1}"
|
||||
__ip="${__ip:2}"
|
||||
;;
|
||||
[1-9][0-9].*)
|
||||
__n="${__ip:0:2}"
|
||||
__ip="${__ip:3}"
|
||||
;;
|
||||
1[0-9][0-9].*|2[0-4][0-9].*|25[0-5].*)
|
||||
__n="${__ip:0:3}"
|
||||
__ip="${__ip:4}"
|
||||
;;
|
||||
*)
|
||||
printf "Not a dotted quad (%s)\n" "$2" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__val=$((__val + (__n << 8)))
|
||||
|
||||
case "$__ip" in
|
||||
[0-9])
|
||||
__n="${__ip:0:1}"
|
||||
__ip="${__ip:1}"
|
||||
;;
|
||||
[1-9][0-9])
|
||||
__n="${__ip:0:2}"
|
||||
__ip="${__ip:2}"
|
||||
;;
|
||||
1[0-9][0-9]|2[0-4][0-9]|25[0-5])
|
||||
__n="${__ip:0:3}"
|
||||
__ip="${__ip:3}"
|
||||
;;
|
||||
*)
|
||||
printf "Not a dotted quad (%s)\n" "$2" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__val=$((__val + __n))
|
||||
|
||||
if [ -n "$__ip" ]; then
|
||||
printf "Not a dotted quad (%s)\n" "$2" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
export -- "$__var=$__val"
|
||||
return 0
|
||||
}
|
||||
|
||||
# convert back from an integer to dotted-quad.
|
||||
ip2str() {
|
||||
local __var="$1" __n="$2"
|
||||
assert_uint32 "$__n" || return 1
|
||||
|
||||
export -- "$__var=$((__n >> 24)).$(((__n >> 16) & 255)).$(((__n >> 8) & 255)).$((__n & 255))"
|
||||
}
|
||||
|
||||
# convert prefix into an integer bitmask
|
||||
prefix2netmask() {
|
||||
local __var="$1" __n="$2"
|
||||
assert_uint32 "$__n" || return 1
|
||||
|
||||
if [ "$__n" -gt 32 ]; then
|
||||
printf "Prefix out-of-range (%s)" "$__n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
export -- "$__var=$(((~(uint_max >> __n)) & uint_max))"
|
||||
}
|
||||
|
||||
_is_contiguous() {
|
||||
local __x="$1" # no checking done
|
||||
local __y=$((~__x & uint_max))
|
||||
local __z=$(((__y + 1) & uint_max))
|
||||
|
||||
[ $((__z & __y)) -eq 0 ]
|
||||
}
|
||||
|
||||
# check argument as being contiguous upper bits (and yes,
|
||||
# 0 doesn't have any discontiguous bits).
|
||||
is_contiguous() {
|
||||
local __var="$1" __x="$2" __val=0
|
||||
assert_uint32 "$__x" || return 1
|
||||
|
||||
local __y=$((~__x & uint_max))
|
||||
local __z=$(((__y + 1) & uint_max))
|
||||
|
||||
[ $((__z & __y)) -eq 0 ] && __val=1
|
||||
|
||||
export -- "$__var=$__val"
|
||||
}
|
||||
|
||||
# convert mask to prefix, validating that it's a conventional
|
||||
# (contiguous) netmask.
|
||||
netmask2prefix() {
|
||||
local __var="$1" __n="$2" __cont __bits
|
||||
assert_uint32 "$__n" || return 1
|
||||
|
||||
is_contiguous __cont "$__n" || return 1
|
||||
if [ $__cont -eq 0 ]; then
|
||||
printf "Not a contiguous netmask (%08x)\n" "$__n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
bitcount __bits "$__n" # already checked
|
||||
|
||||
export -- "$__var=$__bits"
|
||||
}
|
||||
|
||||
# check the argument as being an rfc-1918 address
|
||||
is_rfc1918() {
|
||||
local __var="$1" __x="$2" __val=0
|
||||
assert_uint32 "$__x" || return 1
|
||||
|
||||
if [ $d_10_0_0_0 -le $__x ] && [ $__x -le $d_10_255_255_255 ]; then
|
||||
__val=1
|
||||
elif [ $d_172_16_0_0 -le $__x ] && [ $__x -le $d_172_31_255_255 ]; then
|
||||
__val=1
|
||||
elif [ $d_192_168_0_0 -le $__x ] && [ $__x -le $d_192_168_255_255 ]; then
|
||||
__val=1
|
||||
fi
|
||||
|
||||
export -- "$__var=$__val"
|
||||
}
|
||||
|
||||
# check the argument as being an rfc-3927 address
|
||||
is_rfc3927() {
|
||||
local __var="$1" __x="$2" __val=0
|
||||
assert_uint32 "$__x" || return 1
|
||||
|
||||
if [ $d_169_254_0_0 -le $__x ] && [ $__x -le $d_169_254_255_255 ]; then
|
||||
__val=1
|
||||
fi
|
||||
|
||||
export -- "$__var=$__val"
|
||||
}
|
||||
|
||||
# check the argument as being an rfc-1122 loopback address
|
||||
is_loopback() {
|
||||
local __var="$1" __x="$2" __val=0
|
||||
assert_uint32 "$__x" || return 1
|
||||
|
||||
if [ $d_127_0_0_0 -le $__x ] && [ $__x -le $d_127_255_255_255 ]; then
|
||||
__val=1
|
||||
fi
|
||||
|
||||
export -- "$__var=$__val"
|
||||
}
|
||||
|
||||
# check the argument as being a multicast address
|
||||
is_multicast() {
|
||||
local __var="$1" __x="$2" __val=0
|
||||
assert_uint32 "$__x" || return 1
|
||||
|
||||
if [ $d_224_0_0_0 -le $__x ] && [ $__x -le $d_239_255_255_255 ]; then
|
||||
__val=1
|
||||
fi
|
||||
|
||||
export -- "$__var=$__val"
|
||||
}
|
||||
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=2.9
|
||||
PKG_VERSION:=2.10
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_HASH:=76a66a1de0c01aeb83dfc7b72b51173fe62c6e51d6fca17cc562393117bed08b
|
||||
PKG_HASH:=88215a62291b9ba87da8e50b077741103cdc08fb6c9e1ebd34dfaace746d3201
|
||||
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
PKG_LICENSE_FILES:=license.md
|
||||
|
|
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||
PKG_NAME:=uboot-envtools
|
||||
PKG_DISTNAME:=u-boot
|
||||
PKG_VERSION:=2023.07.02
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:= \
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Tue, 12 Dec 2023 18:23:45 +0100
|
||||
Subject: [PATCH] fw_env: fix reading NVMEM device's "compatible" value
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Call to fread() was changed to check for return value. The problem is it
|
||||
can't be checked for returning 1 (as it is) to determine success.
|
||||
|
||||
We call fread() with buffer size as "size" argument. Reading any
|
||||
"compatible" value shorter than buffer size will result in returning 0
|
||||
even on success.
|
||||
|
||||
Modify code to use fstat() to determine expected read length.
|
||||
|
||||
This fixes regression that broke using fw_env with NVMEM devices.
|
||||
|
||||
Fixes: c059a22b7776 ("tools: env: fw_env: Fix unused-result warning")
|
||||
Cc: Jaehoon Chung <jh80.chung@samsung.com>
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
---
|
||||
tools/env/fw_env.c | 18 ++++++++++++++----
|
||||
1 file changed, 14 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/tools/env/fw_env.c
|
||||
+++ b/tools/env/fw_env.c
|
||||
@@ -1732,6 +1732,7 @@ static int find_nvmem_device(void)
|
||||
}
|
||||
|
||||
while (!nvmem && (dent = readdir(dir))) {
|
||||
+ struct stat s;
|
||||
FILE *fp;
|
||||
size_t size;
|
||||
|
||||
@@ -1749,14 +1750,22 @@ static int find_nvmem_device(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
- size = fread(buf, sizeof(buf), 1, fp);
|
||||
+ if (fstat(fileno(fp), &s)) {
|
||||
+ fprintf(stderr, "Failed to fstat %s\n", comp);
|
||||
+ goto next;
|
||||
+ }
|
||||
+
|
||||
+ if (s.st_size >= sizeof(buf)) {
|
||||
+ goto next;
|
||||
+ }
|
||||
+
|
||||
+ size = fread(buf, s.st_size, 1, fp);
|
||||
if (size != 1) {
|
||||
fprintf(stderr,
|
||||
"read failed about %s\n", comp);
|
||||
- fclose(fp);
|
||||
- return -EIO;
|
||||
+ goto next;
|
||||
}
|
||||
-
|
||||
+ buf[s.st_size] = '\0';
|
||||
|
||||
if (!strcmp(buf, "u-boot,env")) {
|
||||
bytes = asprintf(&nvmem, "%s/%s/nvmem", path, dent->d_name);
|
||||
@@ -1765,6 +1774,7 @@ static int find_nvmem_device(void)
|
||||
}
|
||||
}
|
||||
|
||||
+next:
|
||||
fclose(fp);
|
||||
}
|
||||
|
74
package/devel/leds/Makefile
Normal file
74
package/devel/leds/Makefile
Normal file
|
@ -0,0 +1,74 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=leds
|
||||
PKG_VERSION:=$(LINUX_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/leds/default
|
||||
SECTION:=devel
|
||||
CATEGORY:=Development
|
||||
VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
|
||||
URL:=http://www.kernel.org
|
||||
endef
|
||||
|
||||
define Package/ledumon
|
||||
$(Package/leds/default)
|
||||
TITLE:=Monitoring userspace LEDs
|
||||
DEPENDS:=+kmod-leds-uleds
|
||||
endef
|
||||
|
||||
define Package/ledumon/description
|
||||
This program creates a new userspace LED class device and monitors it.
|
||||
A timestamp and brightness value is printed each time the brightness
|
||||
changes.
|
||||
endef
|
||||
|
||||
define Package/ledhwbmon
|
||||
$(Package/leds/default)
|
||||
TITLE:=Monitoring hardware controlled LED brightness
|
||||
endef
|
||||
|
||||
define Package/ledhwbmon/description
|
||||
This program monitors LED brightness level changes having its origin
|
||||
in hardware/firmware, i.e. outside of kernel control. A timestamp and
|
||||
brightness value is printed each time the brightness changes.
|
||||
endef
|
||||
|
||||
MAKE_FLAGS = \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
CC="$(TARGET_CC)" \
|
||||
LD="$(TARGET_CROSS)ld" \
|
||||
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS) -static" \
|
||||
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
|
||||
prefix=/usr
|
||||
|
||||
define Build/Compile
|
||||
-$(MAKE) clean \
|
||||
-C $(LINUX_DIR)/tools/leds
|
||||
+$(MAKE_FLAGS) $(MAKE) \
|
||||
-C $(LINUX_DIR)/tools/leds
|
||||
endef
|
||||
|
||||
define Package/ledumon/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(LINUX_DIR)/tools/leds/uledmon \
|
||||
$(1)/usr/bin/ledumon
|
||||
endef
|
||||
|
||||
define Package/ledhwbmon/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(LINUX_DIR)/tools/leds/led_hw_brightness_mon \
|
||||
$(1)/usr/bin/ledhwbmon
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ledumon))
|
||||
$(eval $(call BuildPackage,ledhwbmon))
|
|
@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
|
|||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=strace
|
||||
PKG_VERSION:=6.5
|
||||
PKG_VERSION:=6.6
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION)
|
||||
PKG_HASH:=dfb051702389e1979a151892b5901afc9e93bbc1c70d84c906ade3224ca91980
|
||||
PKG_HASH:=421b4186c06b705163e64dc85f271ebdcf67660af8667283147d5e859fc8a96c
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
PKG_LICENSE:=LGPL-2.1-or-later
|
||||
|
|
|
@ -28,6 +28,7 @@ endef
|
|||
# <https://wireless.wiki.kernel.org/en/users/drivers/ath10k/boardfiles>
|
||||
|
||||
ALLWIFIBOARDS:= \
|
||||
arcadyan_aw1000 \
|
||||
buffalo_wxr-5950ax12 \
|
||||
compex_wpq873 \
|
||||
dynalink_dl-wrx36 \
|
||||
|
@ -45,6 +46,7 @@ ALLWIFIBOARDS:= \
|
|||
xiaomi_ax9000 \
|
||||
yyets_le1 \
|
||||
yuncore_ax880 \
|
||||
zte_mf269 \
|
||||
zte_mf289f \
|
||||
zte_mf287 \
|
||||
zte_mf287plus \
|
||||
|
@ -136,6 +138,7 @@ endef
|
|||
# Board files should follow this name structure:
|
||||
# board-<devicename>.<qca4019|qca9888|qca9889|qca9984|qca99x0|ipq8074>
|
||||
|
||||
$(eval $(call generate-ipq-wifi-package,arcadyan_aw1000,Arcadyan AW1000))
|
||||
$(eval $(call generate-ipq-wifi-package,buffalo_wxr-5950ax12,Buffalo WXR-5950AX12))
|
||||
$(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873))
|
||||
$(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36))
|
||||
|
@ -153,6 +156,7 @@ $(eval $(call generate-ipq-wifi-package,xiaomi_ax3600,Xiaomi AX3600))
|
|||
$(eval $(call generate-ipq-wifi-package,xiaomi_ax9000,Xiaomi AX9000))
|
||||
$(eval $(call generate-ipq-wifi-package,yyets_le1,YYeTs LE1))
|
||||
$(eval $(call generate-ipq-wifi-package,yuncore_ax880,Yuncore AX880))
|
||||
$(eval $(call generate-ipq-wifi-package,zte_mf269,ZTE MF269))
|
||||
$(eval $(call generate-ipq-wifi-package,zte_mf289f,ZTE MF289F))
|
||||
$(eval $(call generate-ipq-wifi-package,zte_mf287,ZTE MF287))
|
||||
$(eval $(call generate-ipq-wifi-package,zte_mf287plus,ZTE MF287Plus))
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=linux-firmware
|
||||
PKG_VERSION:=20230804
|
||||
PKG_VERSION:=20231211
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=@KERNEL/linux/kernel/firmware
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_HASH:=88d46c543847ee3b03404d4941d91c92974690ee1f6fdcbee9cef3e5f97db688
|
||||
PKG_HASH:=96af7e4b5eabd37869cdb3dcbb7ab36911106d39b76e799fa1caab16a9dbe8bb
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
|
|
|
@ -1543,11 +1543,22 @@ endef
|
|||
$(eval $(call KernelPackage,sfp))
|
||||
|
||||
|
||||
define KernelPackage/pcs-xpcs
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Synopsis DesignWare PCS driver
|
||||
DEPENDS:=@(TARGET_x86_64||TARGET_armsr_armv8) +kmod-phylink
|
||||
KCONFIG:=CONFIG_PCS_XPCS
|
||||
FILES:=$(LINUX_DIR)/drivers/net/pcs/pcs_xpcs.ko
|
||||
AUTOLOAD:=$(call AutoLoad,20,pcs_xpcs)
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,pcs-xpcs))
|
||||
|
||||
|
||||
define KernelPackage/stmmac-core
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Synopsis Ethernet Controller core (NXP,STMMicro,others)
|
||||
DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 +kmod-pcs-xpcs +kmod-ptp \
|
||||
+kmod-of-mdio
|
||||
DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 +kmod-pcs-xpcs +kmod-ptp
|
||||
KCONFIG:=CONFIG_STMMAC_ETH \
|
||||
CONFIG_STMMAC_SELFTESTS=n \
|
||||
CONFIG_STMMAC_PLATFORM \
|
||||
|
|
|
@ -236,6 +236,40 @@ endef
|
|||
$(eval $(call KernelPackage,sound-soc-imx))
|
||||
|
||||
|
||||
define KernelPackage/sound-soc-mt7986
|
||||
TITLE:=MediaTek MT7986 Audio support
|
||||
KCONFIG:=CONFIG_SND_SOC_MT7986 CONFIG_SND_SOC_MT7986_WM8960
|
||||
FILES:= \
|
||||
$(LINUX_DIR)/sound/soc/mediatek/common/snd-soc-mtk-common.ko \
|
||||
$(LINUX_DIR)/sound/soc/mediatek/mt7986/snd-soc-mt7986-afe.ko
|
||||
AUTOLOAD:=$(call AutoLoad,56,snd-soc-mtk-common snd-soc-mt7986-afe)
|
||||
DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-core
|
||||
$(call AddDepends/sound)
|
||||
endef
|
||||
|
||||
define KernelPackage/sound-soc-mt7986/description
|
||||
Support for audio on systems using the MediaTek MT7986 SoC.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,sound-soc-mt7986))
|
||||
|
||||
|
||||
define KernelPackage/sound-soc-mt7986-wm8960
|
||||
TITLE:=MediaTek MT7986 Audio support
|
||||
KCONFIG:=CONFIG_SND_SOC_MT7986_WM8960
|
||||
FILES:=$(LINUX_DIR)/sound/soc/mediatek/mt7986/mt7986-wm8960.ko
|
||||
AUTOLOAD:=$(call AutoLoad,57,mt7986-wm8960)
|
||||
DEPENDS:=@TARGET_mediatek_filogic +kmod-sound-soc-wm8960 +kmod-sound-soc-mt7986
|
||||
$(call AddDepends/sound)
|
||||
endef
|
||||
|
||||
define KernelPackage/sound-soc-mt7986-wm8960/description
|
||||
Support for use of the Wolfson Audio WM8960 codec with the MediaTek MT7986 SoC.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,sound-soc-mt7986-wm8960))
|
||||
|
||||
|
||||
define KernelPackage/sound-soc-imx-sgtl5000
|
||||
TITLE:=IMX SoC support for SGTL5000
|
||||
KCONFIG:=CONFIG_SND_SOC_IMX_SGTL5000
|
||||
|
@ -254,6 +288,18 @@ endef
|
|||
$(eval $(call KernelPackage,sound-soc-imx-sgtl5000))
|
||||
|
||||
|
||||
define KernelPackage/sound-soc-wm8960
|
||||
TITLE:=SoC WM8960 codec support
|
||||
KCONFIG:=CONFIG_SND_SOC_WM8960
|
||||
FILES:=$(LINUX_DIR)/sound/soc/codecs/snd-soc-wm8960.ko
|
||||
DEPENDS:=+kmod-sound-soc-core +kmod-i2c-core +kmod-regmap-i2c
|
||||
AUTOLOAD:=$(call AutoProbe,snd-soc-wm8960)
|
||||
$(call AddDepends/sound)
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,sound-soc-wm8960))
|
||||
|
||||
|
||||
define KernelPackage/sound-soc-spdif
|
||||
TITLE:=SoC S/PDIF codec support
|
||||
KCONFIG:=CONFIG_SND_SOC_SPDIF
|
||||
|
|
|
@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
|||
PKG_NAME:=mac80211
|
||||
|
||||
PKG_VERSION:=6.5
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
# PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/
|
||||
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
|
||||
PKG_HASH:=908c22dceba185eab83caa5a1e58ce6b3ebdc58f099c3fd3e11c7352ebfab2d7
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Fri, 15 Dec 2023 10:17:21 +0100
|
||||
Subject: [PATCH] list: don't backport list_count_nodes()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
It's redundant in OpenWrt as it backports it on its own. This fixes:
|
||||
backport-include/linux/list.h:11:22: error: redefinition of 'list_count_nodes'
|
||||
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
---
|
||||
backport-include/linux/list.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/backport-include/linux/list.h
|
||||
+++ b/backport-include/linux/list.h
|
||||
@@ -3,7 +3,7 @@
|
||||
#include_next <linux/list.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
-#if LINUX_VERSION_IS_LESS(6,3,0)
|
||||
+#if 0 /* OpenWrt backports list_count_nodes() on its own */
|
||||
/**
|
||||
* list_count_nodes - count nodes in the list
|
||||
* @head: the head for your list.
|
|
@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
|
|||
|
||||
PKG_SOURCE_URL:=https://github.com/openwrt/mt76
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2023-12-08
|
||||
PKG_SOURCE_VERSION:=f559adf1849c8af91f5a5eb670f4ed2c24988898
|
||||
PKG_MIRROR_HASH:=74dde4478442d5f0edbae918636b40767b0e49181b732d4184feeccd8a8cc328
|
||||
PKG_SOURCE_DATE:=2023-12-18
|
||||
PKG_SOURCE_VERSION:=bebd9cffc2aeb2cecb40aadbb8c6eab3bdf7971b
|
||||
PKG_MIRROR_HASH:=580261755bc3f251b8bc5f7f610274693c067432187570694d2f2ccab0edb62b
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
PKG_USE_NINJA:=0
|
||||
|
|
|
@ -5,9 +5,9 @@ PKG_RELEASE:=1
|
|||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
|
||||
PKG_SOURCE_DATE:=2023-12-05
|
||||
PKG_SOURCE_VERSION:=cc9e928f0a12f04c82356c02dd9a84ac6b383fb9
|
||||
PKG_MIRROR_HASH:=b5bcb3e1c1841559bf202d2dc67dde62dce3c880043166cc8b3a3f97ce004c2a
|
||||
PKG_SOURCE_DATE:=2023-12-19
|
||||
PKG_SOURCE_VERSION:=a2d32f0dcf16880226680d07b07b249f77a3af58
|
||||
PKG_MIRROR_HASH:=765f51335ffa0a143421efbe129d484a90d7c4a0f3e08cb7840cc85408f3e60c
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
|
|
@ -862,7 +862,7 @@ dnsmasq_start()
|
|||
{
|
||||
local cfg="$1"
|
||||
local disabled user_dhcpscript logfacility
|
||||
local resolvfile resolvdir localuse=0
|
||||
local resolvfile resolvdir localuse=1
|
||||
|
||||
config_get_bool disabled "$cfg" disabled 0
|
||||
[ "$disabled" -gt 0 ] && return 0
|
||||
|
@ -1059,7 +1059,7 @@ dnsmasq_start()
|
|||
config_get resolvfile "$cfg" resolvfile /tmp/resolv.conf.d/resolv.conf.auto
|
||||
[ -n "$resolvfile" ] && [ ! -e "$resolvfile" ] && touch "$resolvfile"
|
||||
xappend "--resolv-file=$resolvfile"
|
||||
[ "$resolvfile" = "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=1
|
||||
[ "$resolvfile" != "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=0
|
||||
resolvdir="$(dirname "$resolvfile")"
|
||||
fi
|
||||
config_get_bool localuse "$cfg" localuse "$localuse"
|
||||
|
@ -1230,12 +1230,12 @@ dnsmasq_start()
|
|||
dnsmasq_stop()
|
||||
{
|
||||
local cfg="$1"
|
||||
local noresolv resolvfile localuse=0
|
||||
local noresolv resolvfile localuse=1
|
||||
|
||||
config_get_bool noresolv "$cfg" noresolv 0
|
||||
config_get resolvfile "$cfg" "resolvfile"
|
||||
|
||||
[ "$noresolv" = 0 ] && [ "$resolvfile" = "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=1
|
||||
[ "$noresolv" = 0 ] && [ "$resolvfile" != "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=0
|
||||
config_get_bool localuse "$cfg" localuse "$localuse"
|
||||
[ "$localuse" -gt 0 ] && ln -sf "/tmp/resolv.conf.d/resolv.conf.auto" /tmp/resolv.conf
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ethtool
|
||||
PKG_VERSION:=6.5
|
||||
PKG_VERSION:=6.6
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/software/network/ethtool
|
||||
PKG_HASH:=814171ea4b8026b081c0741dbbf32e6968311483ecf64711232faec2ac70a14c
|
||||
PKG_HASH:=833a8493cb9cd5809ab59743092d9a38742c282290800e9626407511bbcebf9e
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=iproute2
|
||||
PKG_VERSION:=6.5.0
|
||||
PKG_VERSION:=6.6.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
|
||||
PKG_HASH:=a70179085fa1b96d3c33b040c809b75e2b57563adc505a4ad05e2609df373463
|
||||
PKG_HASH:=8738c804afd09f0bf756937f0c3de23117832a98d8cbbf50386cf5005cd613ce
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_BUILD_DEPENDS:=iptables
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/tc/Makefile
|
||||
+++ b/tc/Makefile
|
||||
@@ -127,6 +127,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR
|
||||
@@ -119,6 +119,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR
|
||||
ifneq ($(IPT_LIB_DIR),)
|
||||
CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
|
||||
endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/tc/Makefile
|
||||
+++ b/tc/Makefile
|
||||
@@ -113,7 +113,7 @@ LDLIBS += -L. -lm
|
||||
@@ -106,7 +106,7 @@ LDLIBS += -L. -lm
|
||||
|
||||
ifeq ($(SHARED_LIBS),y)
|
||||
LDLIBS += -ldl
|
||||
|
@ -9,7 +9,7 @@
|
|||
endif
|
||||
|
||||
TCLIB := tc_core.o
|
||||
@@ -143,7 +143,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
@@ -135,7 +135,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
all: tc $(TCSO)
|
||||
|
||||
tc: $(TCOBJ) $(LIBNETLINK) libtc.a
|
||||
|
@ -18,15 +18,15 @@
|
|||
|
||||
libtc.a: $(TCLIB)
|
||||
$(QUIET_AR)$(AR) rcs $@ $^
|
||||
@@ -165,6 +165,7 @@ install: all
|
||||
@@ -157,6 +157,7 @@ install: all
|
||||
clean:
|
||||
rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.tab.h; \
|
||||
rm -f emp_ematch.tab.*
|
||||
+ rm -f dynsyms.list
|
||||
|
||||
q_atm.so: q_atm.c
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
|
||||
@@ -204,4 +205,16 @@ static-syms.h: $(wildcard *.c)
|
||||
m_xt.so: m_xt.c
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs)
|
||||
@@ -193,4 +194,16 @@ static-syms.h: $(wildcard *.c)
|
||||
sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
|
||||
done > $@
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
--- a/tc/Makefile
|
||||
+++ b/tc/Makefile
|
||||
@@ -140,7 +140,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
@@ -132,7 +132,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic $< -o $@
|
||||
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ PKG_RELEASE:=1
|
|||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git
|
||||
PKG_SOURCE_DATE:=2023-11-21
|
||||
PKG_SOURCE_VERSION:=12bf1a99bd6eebae90caa144bb4d8b0cd763ff8f
|
||||
PKG_MIRROR_HASH:=f711bf80123a6f14737da27ab8dfff87a4d429c74057de355b1693e89f223abc
|
||||
PKG_SOURCE_DATE:=2023-11-22
|
||||
PKG_SOURCE_VERSION:=d87b6c4b6423201e595459840f51d0dced04a4eb
|
||||
PKG_MIRROR_HASH:=f34fbf4dc4bd13d18ea94e6e25090b57cde11b3dc7133e46f6ce3bb9164ab8fb
|
||||
|
||||
PKG_BUILD_DEPENDS:=openssl zlib
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=util-linux
|
||||
PKG_VERSION:=2.39.2
|
||||
PKG_VERSION:=2.39.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.39
|
||||
PKG_HASH:=87abdfaa8e490f8be6dde976f7c80b9b5ff9f301e1b67e3899e1f05a59a1531f
|
||||
PKG_HASH:=7b6605e48d1a49f43cc4b4cfc59f313d0dd5402fa40b96810bd572e167dfed0f
|
||||
PKG_CPE_ID:=cpe:/a:kernel:util-linux
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
|
|
@ -47,17 +47,6 @@ endef
|
|||
|
||||
$(eval $(call KernelPackage,fsl-pcs-lynx))
|
||||
|
||||
define KernelPackage/pcs-xpcs
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Synopsis DesignWare PCS driver
|
||||
DEPENDS:=@(TARGET_armsr_armv8) +kmod-phylink
|
||||
KCONFIG:=CONFIG_PCS_XPCS
|
||||
FILES:=$(LINUX_DIR)/drivers/net/pcs/pcs_xpcs.ko
|
||||
AUTOLOAD:=$(call AutoLoad,20,pcs_xpcs)
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,pcs-xpcs))
|
||||
|
||||
define KernelPackage/fsl-fec
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
DEPENDS:=@(TARGET_armsr_armv8) +kmod-libphy +kmod-of-mdio \
|
||||
|
@ -219,7 +208,7 @@ $(eval $(call KernelPackage,imx7-ulp-wdt))
|
|||
define KernelPackage/dwmac-imx
|
||||
SUBMENU=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=NXP i.MX8 Ethernet controller
|
||||
DEPENDS:=+kmod-stmmac-core
|
||||
DEPENDS:=+kmod-stmmac-core +kmod-of-mdio
|
||||
KCONFIG:=CONFIG_DWMAC_IMX8
|
||||
FILES=$(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.ko
|
||||
AUTOLOAD=$(call AutoLoad,45,dwmac-imx)
|
||||
|
@ -230,7 +219,7 @@ $(eval $(call KernelPackage,dwmac-imx))
|
|||
define KernelPackage/dwmac-sun8i
|
||||
SUBMENU=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Allwinner H3/A83T/A64 (sun8i) Ethernet
|
||||
DEPENDS:=+kmod-stmmac-core +kmod-mdio-bus-mux
|
||||
DEPENDS:=+kmod-stmmac-core +kmod-of-mdio +kmod-mdio-bus-mux
|
||||
KCONFIG:=CONFIG_DWMAC_SUN8I
|
||||
FILES=$(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.ko
|
||||
AUTOLOAD=$(call AutoLoad,45,dwmac-sun8i)
|
||||
|
@ -241,7 +230,7 @@ $(eval $(call KernelPackage,dwmac-sun8i))
|
|||
define KernelPackage/dwmac-rockchip
|
||||
SUBMENU=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Rockchip RK3328/RK3399/RK3568 Ethernet
|
||||
DEPENDS:=+kmod-stmmac-core +kmod-mdio-bus-mux
|
||||
DEPENDS:=+kmod-stmmac-core +kmod-of-mdio +kmod-mdio-bus-mux
|
||||
KCONFIG:=CONFIG_DWMAC_ROCKCHIP
|
||||
FILES=$(LINUX_DIR)/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.ko
|
||||
AUTOLOAD=$(call AutoLoad,45,dwmac-rk)
|
||||
|
|
|
@ -22,7 +22,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -3613,7 +3613,7 @@ static int dpaa2_eth_setup_dpni(struct f
|
||||
@@ -3611,7 +3611,7 @@ static int dpaa2_eth_setup_dpni(struct f
|
||||
dev_err(dev, "DPNI version %u.%u not supported, need >= %u.%u\n",
|
||||
priv->dpni_ver_major, priv->dpni_ver_minor,
|
||||
DPNI_VER_MAJOR, DPNI_VER_MINOR);
|
||||
|
|
|
@ -21,7 +21,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -2082,10 +2082,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
@@ -2080,10 +2080,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
goto enable_err;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
return 0;
|
||||
|
||||
@@ -2159,7 +2157,6 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
@@ -2157,7 +2155,6 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
int retries = 10;
|
||||
|
||||
if (dpaa2_eth_is_type_phy(priv)) {
|
||||
|
|
|
@ -49,7 +49,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -4443,9 +4443,8 @@ static int dpaa2_eth_connect_mac(struct
|
||||
@@ -4441,9 +4441,8 @@ static int dpaa2_eth_connect_mac(struct
|
||||
err = dpaa2_mac_open(mac);
|
||||
if (err)
|
||||
goto err_free_mac;
|
||||
|
@ -60,7 +60,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
err = dpaa2_mac_connect(mac);
|
||||
if (err && err != -EPROBE_DEFER)
|
||||
netdev_err(priv->net_dev, "Error connecting to the MAC endpoint: %pe",
|
||||
@@ -4454,11 +4453,12 @@ static int dpaa2_eth_connect_mac(struct
|
||||
@@ -4452,11 +4451,12 @@ static int dpaa2_eth_connect_mac(struct
|
||||
goto err_close_mac;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
err_free_mac:
|
||||
kfree(mac);
|
||||
return err;
|
||||
@@ -4466,15 +4466,18 @@ err_free_mac:
|
||||
@@ -4464,15 +4464,18 @@ err_free_mac:
|
||||
|
||||
static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -4710,6 +4710,10 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
@@ -4708,6 +4708,10 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -44,7 +44,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
err = dpaa2_eth_setup_irqs(dpni_dev);
|
||||
if (err) {
|
||||
netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
|
||||
@@ -4722,10 +4726,6 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
@@ -4720,10 +4724,6 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
priv->do_link_poll = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -2020,8 +2020,11 @@ static int dpaa2_eth_link_state_update(s
|
||||
@@ -2018,8 +2018,11 @@ static int dpaa2_eth_link_state_update(s
|
||||
|
||||
/* When we manage the MAC/PHY using phylink there is no need
|
||||
* to manually update the netif_carrier.
|
||||
|
@ -54,7 +54,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
goto out;
|
||||
|
||||
/* Chech link state; speed / duplex changes are not treated yet */
|
||||
@@ -2060,6 +2063,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
@@ -2058,6 +2061,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
priv->dpbp_dev->obj_desc.id, priv->bpid);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
if (!dpaa2_eth_is_type_phy(priv)) {
|
||||
/* We'll only start the txqs when the link is actually ready;
|
||||
* make sure we don't race against the link up notification,
|
||||
@@ -2078,6 +2083,7 @@ static int dpaa2_eth_open(struct net_dev
|
||||
@@ -2076,6 +2081,7 @@ static int dpaa2_eth_open(struct net_dev
|
||||
|
||||
err = dpni_enable(priv->mc_io, 0, priv->mc_token);
|
||||
if (err < 0) {
|
||||
|
@ -71,7 +71,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
netdev_err(net_dev, "dpni_enable() failed\n");
|
||||
goto enable_err;
|
||||
}
|
||||
@@ -2085,6 +2091,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
@@ -2083,6 +2089,8 @@ static int dpaa2_eth_open(struct net_dev
|
||||
if (dpaa2_eth_is_type_phy(priv))
|
||||
dpaa2_mac_start(priv->mac);
|
||||
|
||||
|
@ -80,7 +80,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
return 0;
|
||||
|
||||
enable_err:
|
||||
@@ -2156,6 +2164,8 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
@@ -2154,6 +2162,8 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
int dpni_enabled = 0;
|
||||
int retries = 10;
|
||||
|
||||
|
@ -89,7 +89,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
if (dpaa2_eth_is_type_phy(priv)) {
|
||||
dpaa2_mac_stop(priv->mac);
|
||||
} else {
|
||||
@@ -2163,6 +2173,8 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
@@ -2161,6 +2171,8 @@ static int dpaa2_eth_stop(struct net_dev
|
||||
netif_carrier_off(net_dev);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
/* On dpni_disable(), the MC firmware will:
|
||||
* - stop MAC Rx and wait for all Rx frames to be enqueued to software
|
||||
* - cut off WRIOP dequeues from egress FQs and wait until transmission
|
||||
@@ -2488,12 +2500,20 @@ static int dpaa2_eth_ts_ioctl(struct net
|
||||
@@ -2486,12 +2498,20 @@ static int dpaa2_eth_ts_ioctl(struct net
|
||||
static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
||||
{
|
||||
struct dpaa2_eth_priv *priv = netdev_priv(dev);
|
||||
|
@ -121,7 +121,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -4453,7 +4473,9 @@ static int dpaa2_eth_connect_mac(struct
|
||||
@@ -4451,7 +4471,9 @@ static int dpaa2_eth_connect_mac(struct
|
||||
goto err_close_mac;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
return 0;
|
||||
|
||||
@@ -4466,9 +4488,12 @@ err_free_mac:
|
||||
@@ -4464,9 +4486,12 @@ err_free_mac:
|
||||
|
||||
static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
if (!mac)
|
||||
return;
|
||||
@@ -4487,6 +4512,7 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
@@ -4485,6 +4510,7 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev);
|
||||
struct net_device *net_dev = dev_get_drvdata(dev);
|
||||
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
|
||||
|
@ -153,7 +153,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
int err;
|
||||
|
||||
err = dpni_get_irq_status(dpni_dev->mc_io, 0, dpni_dev->mc_handle,
|
||||
@@ -4504,7 +4530,12 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
@@ -4502,7 +4528,12 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
dpaa2_eth_update_tx_fqids(priv);
|
||||
|
||||
rtnl_lock();
|
||||
|
@ -167,7 +167,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
dpaa2_eth_disconnect_mac(priv);
|
||||
else
|
||||
dpaa2_eth_connect_mac(priv);
|
||||
@@ -4605,6 +4636,8 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
@@ -4603,6 +4634,8 @@ static int dpaa2_eth_probe(struct fsl_mc
|
||||
priv = netdev_priv(net_dev);
|
||||
priv->net_dev = net_dev;
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
dpaa2_switch_port_disconnect_mac(port_priv);
|
||||
else
|
||||
dpaa2_switch_port_connect_mac(port_priv);
|
||||
@@ -3256,6 +3279,8 @@ static int dpaa2_switch_probe_port(struc
|
||||
@@ -3249,6 +3272,8 @@ static int dpaa2_switch_probe_port(struc
|
||||
port_priv->netdev = port_netdev;
|
||||
port_priv->ethsw_data = ethsw;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
|
||||
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
|
||||
@@ -4529,7 +4529,6 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
@@ -4527,7 +4527,6 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
dpaa2_eth_set_mac_addr(netdev_priv(net_dev));
|
||||
dpaa2_eth_update_tx_fqids(priv);
|
||||
|
||||
|
@ -42,7 +42,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
/* We can avoid locking because the "endpoint changed" IRQ
|
||||
* handler is the only one who changes priv->mac at runtime,
|
||||
* so we are not racing with anyone.
|
||||
@@ -4539,7 +4538,6 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
@@ -4537,7 +4536,6 @@ static irqreturn_t dpni_irq0_handler_thr
|
||||
dpaa2_eth_disconnect_mac(priv);
|
||||
else
|
||||
dpaa2_eth_connect_mac(priv);
|
||||
|
@ -101,7 +101,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|||
}
|
||||
|
||||
out:
|
||||
@@ -2958,9 +2956,7 @@ static void dpaa2_switch_remove_port(str
|
||||
@@ -2951,9 +2949,7 @@ static void dpaa2_switch_remove_port(str
|
||||
{
|
||||
struct ethsw_port_priv *port_priv = ethsw->ports[port_idx];
|
||||
|
||||
|
|
0
target/linux/ath79/nand/base-files/etc/init.d/boot-leds
Normal file → Executable file
0
target/linux/ath79/nand/base-files/etc/init.d/boot-leds
Normal file → Executable file
|
@ -589,15 +589,15 @@ SVN-Revision: 35130
|
|||
* XXX skbs on the gro_list have all been parsed and pulled
|
||||
--- a/include/net/addrconf.h
|
||||
+++ b/include/net/addrconf.h
|
||||
@@ -47,7 +47,7 @@ struct prefix_info {
|
||||
@@ -52,7 +52,7 @@ struct prefix_info {
|
||||
__be32 reserved2;
|
||||
|
||||
struct in6_addr prefix;
|
||||
-};
|
||||
+} __attribute__((packed, aligned(2)));
|
||||
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/netdevice.h>
|
||||
/* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */
|
||||
static_assert(sizeof(struct prefix_info) == 32);
|
||||
--- a/include/net/inet_ecn.h
|
||||
+++ b/include/net/inet_ecn.h
|
||||
@@ -138,9 +138,9 @@ static inline int IP6_ECN_set_ce(struct
|
||||
|
@ -750,7 +750,7 @@ SVN-Revision: 35130
|
|||
EXPORT_SYMBOL(xfrm_parse_spi);
|
||||
--- a/net/ipv4/tcp_input.c
|
||||
+++ b/net/ipv4/tcp_input.c
|
||||
@@ -4171,14 +4171,16 @@ static bool tcp_parse_aligned_timestamp(
|
||||
@@ -4175,14 +4175,16 @@ static bool tcp_parse_aligned_timestamp(
|
||||
{
|
||||
const __be32 *ptr = (const __be32 *)(th + 1);
|
||||
|
||||
|
|
|
@ -589,15 +589,15 @@ SVN-Revision: 35130
|
|||
* XXX skbs on the gro_list have all been parsed and pulled
|
||||
--- a/include/net/addrconf.h
|
||||
+++ b/include/net/addrconf.h
|
||||
@@ -47,7 +47,7 @@ struct prefix_info {
|
||||
@@ -52,7 +52,7 @@ struct prefix_info {
|
||||
__be32 reserved2;
|
||||
|
||||
struct in6_addr prefix;
|
||||
-};
|
||||
+} __attribute__((packed, aligned(2)));
|
||||
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/netdevice.h>
|
||||
/* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */
|
||||
static_assert(sizeof(struct prefix_info) == 32);
|
||||
--- a/include/net/inet_ecn.h
|
||||
+++ b/include/net/inet_ecn.h
|
||||
@@ -138,9 +138,9 @@ static inline int IP6_ECN_set_ce(struct
|
||||
|
@ -750,7 +750,7 @@ SVN-Revision: 35130
|
|||
EXPORT_SYMBOL(xfrm_parse_spi);
|
||||
--- a/net/ipv4/tcp_input.c
|
||||
+++ b/net/ipv4/tcp_input.c
|
||||
@@ -4179,14 +4179,16 @@ static bool tcp_parse_aligned_timestamp(
|
||||
@@ -4183,14 +4183,16 @@ static bool tcp_parse_aligned_timestamp(
|
||||
{
|
||||
const __be32 *ptr = (const __be32 *)(th + 1);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|||
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -1430,6 +1430,7 @@ static bool pl011_tx_char(struct uart_am
|
||||
@@ -1426,6 +1426,7 @@ static bool pl011_tx_char(struct uart_am
|
||||
return false; /* unable to transmit character */
|
||||
|
||||
pl011_write(c, uap, REG_DR);
|
||||
|
|
|
@ -36,7 +36,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|||
- reg
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -2805,6 +2805,11 @@ static int pl011_probe(struct amba_devic
|
||||
@@ -2801,6 +2801,11 @@ static int pl011_probe(struct amba_devic
|
||||
if (IS_ERR(uap->clk))
|
||||
return PTR_ERR(uap->clk);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|||
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -1491,6 +1491,10 @@ static bool pl011_tx_chars(struct uart_a
|
||||
@@ -1487,6 +1487,10 @@ static bool pl011_tx_chars(struct uart_a
|
||||
if (likely(from_irq) && count-- == 0)
|
||||
break;
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
static inline int mmc_blk_part_switch(struct mmc_card *card,
|
||||
unsigned int part_type);
|
||||
static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
|
||||
@@ -2996,6 +3003,8 @@ static int mmc_blk_probe(struct mmc_card
|
||||
@@ -2998,6 +3005,8 @@ static int mmc_blk_probe(struct mmc_card
|
||||
{
|
||||
struct mmc_blk_data *md;
|
||||
int ret = 0;
|
||||
|
@ -275,7 +275,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
|
||||
/*
|
||||
* Check that the card supports the command class(es) we need.
|
||||
@@ -3003,7 +3012,16 @@ static int mmc_blk_probe(struct mmc_card
|
||||
@@ -3005,7 +3014,16 @@ static int mmc_blk_probe(struct mmc_card
|
||||
if (!(card->csd.cmdclass & CCC_BLOCK_READ))
|
||||
return -ENODEV;
|
||||
|
||||
|
@ -293,7 +293,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
|
||||
card->complete_wq = alloc_workqueue("mmc_complete",
|
||||
WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
|
||||
@@ -3018,6 +3036,17 @@ static int mmc_blk_probe(struct mmc_card
|
||||
@@ -3020,6 +3038,17 @@ static int mmc_blk_probe(struct mmc_card
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
goto out;
|
||||
--- a/drivers/mmc/core/core.c
|
||||
+++ b/drivers/mmc/core/core.c
|
||||
@@ -1814,7 +1814,8 @@ EXPORT_SYMBOL(mmc_erase);
|
||||
@@ -1819,7 +1819,8 @@ EXPORT_SYMBOL(mmc_erase);
|
||||
|
||||
int mmc_can_erase(struct mmc_card *card)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,8 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|||
|
||||
--- a/drivers/tty/serial/sc16is7xx.c
|
||||
+++ b/drivers/tty/serial/sc16is7xx.c
|
||||
@@ -770,6 +770,8 @@ static bool sc16is7xx_port_irq(struct sc
|
||||
rxlen = sc16is7xx_port_read(port, SC16IS7XX_RXLVL_REG);
|
||||
@@ -783,6 +783,8 @@ static bool sc16is7xx_port_irq(struct sc
|
||||
|
||||
if (rxlen)
|
||||
sc16is7xx_handle_rx(port, rxlen, iir);
|
||||
+ else
|
||||
|
|
|
@ -33,7 +33,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
|
|||
#define USB_VENDOR_ID_BELKIN 0x050d
|
||||
#define USB_DEVICE_ID_FLIP_KVM 0x3201
|
||||
|
||||
@@ -1369,6 +1372,9 @@
|
||||
@@ -1372,6 +1375,9 @@
|
||||
#define USB_VENDOR_ID_XIAOMI 0x2717
|
||||
#define USB_DEVICE_ID_MI_SILENT_MOUSE 0x5014
|
||||
|
||||
|
@ -45,7 +45,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
|
|||
#define USB_DEVICE_ID_THT_2P_ARCADE 0x75e1
|
||||
--- a/drivers/hid/hid-quirks.c
|
||||
+++ b/drivers/hid/hid-quirks.c
|
||||
@@ -41,6 +41,7 @@ static const struct hid_device_id hid_qu
|
||||
@@ -42,6 +42,7 @@ static const struct hid_device_id hid_qu
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS682), HID_QUIRK_NOGET },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS692), HID_QUIRK_NOGET },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM), HID_QUIRK_NOGET },
|
||||
|
@ -53,7 +53,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
|
|||
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2), HID_QUIRK_ALWAYS_POLL },
|
||||
@@ -199,6 +200,7 @@ static const struct hid_device_id hid_qu
|
||||
@@ -200,6 +201,7 @@ static const struct hid_device_id hid_qu
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD), HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE), HID_QUIRK_MULTI_INPUT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_GROUP_AUDIO), HID_QUIRK_NOGET },
|
||||
|
|
|
@ -32,7 +32,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
|
||||
--- a/drivers/spi/spi.c
|
||||
+++ b/drivers/spi/spi.c
|
||||
@@ -3614,6 +3614,7 @@ static int __spi_validate_bits_per_word(
|
||||
@@ -3633,6 +3633,7 @@ static int __spi_validate_bits_per_word(
|
||||
*/
|
||||
int spi_setup(struct spi_device *spi)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
|||
unsigned bad_bits, ugly_bits;
|
||||
int status = 0;
|
||||
|
||||
@@ -3634,6 +3635,14 @@ int spi_setup(struct spi_device *spi)
|
||||
@@ -3653,6 +3654,14 @@ int spi_setup(struct spi_device *spi)
|
||||
(SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL |
|
||||
SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL)))
|
||||
return -EINVAL;
|
||||
|
|
|
@ -23,7 +23,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
|
|||
|
||||
--- a/drivers/mmc/core/block.c
|
||||
+++ b/drivers/mmc/core/block.c
|
||||
@@ -1926,7 +1926,7 @@ static void mmc_blk_mq_rw_recovery(struc
|
||||
@@ -1928,7 +1928,7 @@ static void mmc_blk_mq_rw_recovery(struc
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
|
|||
|
||||
--- a/arch/arm64/include/asm/pgtable.h
|
||||
+++ b/arch/arm64/include/asm/pgtable.h
|
||||
@@ -999,23 +999,13 @@ static inline void update_mmu_cache(stru
|
||||
@@ -1005,23 +1005,13 @@ static inline void update_mmu_cache(stru
|
||||
* page after fork() + CoW for pfn mappings. We don't always have a
|
||||
* hardware-managed access flag on arm64.
|
||||
*/
|
||||
|
|
|
@ -747,7 +747,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
|
||||
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
|
||||
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
|
||||
@@ -1168,9 +1168,8 @@ static int otx2_set_link_ksettings(struc
|
||||
@@ -1172,9 +1172,8 @@ static int otx2_set_link_ksettings(struc
|
||||
otx2_get_link_ksettings(netdev, &cur_ks);
|
||||
|
||||
/* Check requested modes against supported modes by hardware */
|
||||
|
|
|
@ -27,7 +27,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue);
|
||||
static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue);
|
||||
|
||||
@@ -1712,9 +1715,6 @@ static int __init_dma_rx_desc_rings(stru
|
||||
@@ -1713,9 +1716,6 @@ static int __init_dma_rx_desc_rings(stru
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
/* Setup the chained descriptor addresses */
|
||||
if (priv->mode == STMMAC_CHAIN_MODE) {
|
||||
if (priv->extend_desc)
|
||||
@@ -1820,12 +1820,6 @@ static int __init_dma_tx_desc_rings(stru
|
||||
@@ -1821,12 +1821,6 @@ static int __init_dma_tx_desc_rings(stru
|
||||
tx_q->tx_skbuff[i] = NULL;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
return 0;
|
||||
}
|
||||
|
||||
@@ -2694,10 +2688,7 @@ static void stmmac_tx_err(struct stmmac_
|
||||
@@ -2695,10 +2689,7 @@ static void stmmac_tx_err(struct stmmac_
|
||||
stmmac_stop_tx_dma(priv, chan);
|
||||
dma_free_tx_skbufs(priv, chan);
|
||||
stmmac_clear_tx_descriptors(priv, chan);
|
||||
|
@ -62,7 +62,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
tx_q->dma_tx_phy, chan);
|
||||
stmmac_start_tx_dma(priv, chan);
|
||||
@@ -3781,6 +3772,8 @@ static int stmmac_open(struct net_device
|
||||
@@ -3782,6 +3773,8 @@ static int stmmac_open(struct net_device
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
ret = stmmac_hw_setup(dev, true);
|
||||
if (ret < 0) {
|
||||
netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
|
||||
@@ -6430,6 +6423,7 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
@@ -6429,6 +6422,7 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_clear_rx_descriptors(priv, queue);
|
||||
|
||||
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
@@ -6491,6 +6485,7 @@ void stmmac_enable_tx_queue(struct stmma
|
||||
@@ -6490,6 +6484,7 @@ void stmmac_enable_tx_queue(struct stmma
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_clear_tx_descriptors(priv, queue);
|
||||
|
||||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
@@ -7411,6 +7406,25 @@ int stmmac_suspend(struct device *dev)
|
||||
@@ -7414,6 +7409,25 @@ int stmmac_suspend(struct device *dev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(stmmac_suspend);
|
||||
|
||||
|
@ -113,7 +113,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
/**
|
||||
* stmmac_reset_queues_param - reset queue parameters
|
||||
* @priv: device pointer
|
||||
@@ -7421,22 +7435,11 @@ static void stmmac_reset_queues_param(st
|
||||
@@ -7424,22 +7438,11 @@ static void stmmac_reset_queues_param(st
|
||||
u32 tx_cnt = priv->plat->tx_queues_to_use;
|
||||
u32 queue;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
@@ -3833,8 +3833,6 @@ static int stmmac_release(struct net_dev
|
||||
@@ -3834,8 +3834,6 @@ static int stmmac_release(struct net_dev
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
u32 chan;
|
||||
|
||||
|
@ -26,7 +26,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (device_may_wakeup(priv->device))
|
||||
phylink_speed_down(priv->phylink, false);
|
||||
/* Stop and disconnect the PHY */
|
||||
@@ -3846,6 +3844,8 @@ static int stmmac_release(struct net_dev
|
||||
@@ -3847,6 +3845,8 @@ static int stmmac_release(struct net_dev
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
hrtimer_cancel(&priv->tx_queue[chan].txtimer);
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (tx_q->dirty_tx != tx_q->cur_tx)
|
||||
return -EBUSY; /* still unfinished work */
|
||||
@@ -1309,7 +1309,7 @@ static void stmmac_display_rx_rings(stru
|
||||
@@ -1310,7 +1310,7 @@ static void stmmac_display_rx_rings(stru
|
||||
|
||||
/* Display RX rings */
|
||||
for (queue = 0; queue < rx_cnt; queue++) {
|
||||
|
@ -198,7 +198,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
pr_info("\tRX Queue %u rings\n", queue);
|
||||
|
||||
@@ -1322,7 +1322,7 @@ static void stmmac_display_rx_rings(stru
|
||||
@@ -1323,7 +1323,7 @@ static void stmmac_display_rx_rings(stru
|
||||
}
|
||||
|
||||
/* Display RX ring */
|
||||
|
@ -207,7 +207,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
rx_q->dma_rx_phy, desc_size);
|
||||
}
|
||||
}
|
||||
@@ -1336,7 +1336,7 @@ static void stmmac_display_tx_rings(stru
|
||||
@@ -1337,7 +1337,7 @@ static void stmmac_display_tx_rings(stru
|
||||
|
||||
/* Display TX rings */
|
||||
for (queue = 0; queue < tx_cnt; queue++) {
|
||||
|
@ -216,7 +216,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
pr_info("\tTX Queue %d rings\n", queue);
|
||||
|
||||
@@ -1351,7 +1351,7 @@ static void stmmac_display_tx_rings(stru
|
||||
@@ -1352,7 +1352,7 @@ static void stmmac_display_tx_rings(stru
|
||||
desc_size = sizeof(struct dma_desc);
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
tx_q->dma_tx_phy, desc_size);
|
||||
}
|
||||
}
|
||||
@@ -1392,21 +1392,21 @@ static int stmmac_set_bfsize(int mtu, in
|
||||
@@ -1393,21 +1393,21 @@ static int stmmac_set_bfsize(int mtu, in
|
||||
*/
|
||||
static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -1418,12 +1418,12 @@ static void stmmac_clear_rx_descriptors(
|
||||
@@ -1419,12 +1419,12 @@ static void stmmac_clear_rx_descriptors(
|
||||
*/
|
||||
static void stmmac_clear_tx_descriptors(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -1471,7 +1471,7 @@ static void stmmac_clear_descriptors(str
|
||||
@@ -1472,7 +1472,7 @@ static void stmmac_clear_descriptors(str
|
||||
static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
|
||||
int i, gfp_t flags, u32 queue)
|
||||
{
|
||||
|
@ -278,7 +278,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (!buf->page) {
|
||||
@@ -1496,7 +1496,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
@@ -1497,7 +1497,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset;
|
||||
|
||||
stmmac_set_desc_addr(priv, p, buf->addr);
|
||||
|
@ -287,7 +287,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_init_desc3(priv, p);
|
||||
|
||||
return 0;
|
||||
@@ -1510,7 +1510,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
@@ -1511,7 +1511,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
*/
|
||||
static void stmmac_free_rx_buffer(struct stmmac_priv *priv, u32 queue, int i)
|
||||
{
|
||||
|
@ -296,7 +296,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (buf->page)
|
||||
@@ -1530,7 +1530,7 @@ static void stmmac_free_rx_buffer(struct
|
||||
@@ -1531,7 +1531,7 @@ static void stmmac_free_rx_buffer(struct
|
||||
*/
|
||||
static void stmmac_free_tx_buffer(struct stmmac_priv *priv, u32 queue, int i)
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (tx_q->tx_skbuff_dma[i].buf &&
|
||||
tx_q->tx_skbuff_dma[i].buf_type != STMMAC_TXBUF_T_XDP_TX) {
|
||||
@@ -1575,17 +1575,17 @@ static void dma_free_rx_skbufs(struct st
|
||||
@@ -1576,17 +1576,17 @@ static void dma_free_rx_skbufs(struct st
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -326,7 +326,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
int ret;
|
||||
|
||||
@@ -1612,10 +1612,10 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
@@ -1613,10 +1613,10 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
*/
|
||||
static void dma_free_rx_xskbufs(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (!buf->xdp)
|
||||
@@ -1628,10 +1628,10 @@ static void dma_free_rx_xskbufs(struct s
|
||||
@@ -1629,10 +1629,10 @@ static void dma_free_rx_xskbufs(struct s
|
||||
|
||||
static int stmmac_alloc_rx_buffers_zc(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -352,7 +352,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf;
|
||||
dma_addr_t dma_addr;
|
||||
struct dma_desc *p;
|
||||
@@ -1674,7 +1674,7 @@ static struct xsk_buff_pool *stmmac_get_
|
||||
@@ -1675,7 +1675,7 @@ static struct xsk_buff_pool *stmmac_get_
|
||||
*/
|
||||
static int __init_dma_rx_desc_rings(struct stmmac_priv *priv, u32 queue, gfp_t flags)
|
||||
{
|
||||
|
@ -361,7 +361,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int ret;
|
||||
|
||||
netif_dbg(priv, probe, priv->dev,
|
||||
@@ -1720,11 +1720,11 @@ static int __init_dma_rx_desc_rings(stru
|
||||
@@ -1721,11 +1721,11 @@ static int __init_dma_rx_desc_rings(stru
|
||||
if (priv->extend_desc)
|
||||
stmmac_mode_init(priv, rx_q->dma_erx,
|
||||
rx_q->dma_rx_phy,
|
||||
|
@ -375,7 +375,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
return 0;
|
||||
@@ -1751,7 +1751,7 @@ static int init_dma_rx_desc_rings(struct
|
||||
@@ -1752,7 +1752,7 @@ static int init_dma_rx_desc_rings(struct
|
||||
|
||||
err_init_rx_buffers:
|
||||
while (queue >= 0) {
|
||||
|
@ -384,7 +384,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (rx_q->xsk_pool)
|
||||
dma_free_rx_xskbufs(priv, queue);
|
||||
@@ -1780,7 +1780,7 @@ err_init_rx_buffers:
|
||||
@@ -1781,7 +1781,7 @@ err_init_rx_buffers:
|
||||
*/
|
||||
static int __init_dma_tx_desc_rings(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int i;
|
||||
|
||||
netif_dbg(priv, probe, priv->dev,
|
||||
@@ -1792,16 +1792,16 @@ static int __init_dma_tx_desc_rings(stru
|
||||
@@ -1793,16 +1793,16 @@ static int __init_dma_tx_desc_rings(stru
|
||||
if (priv->extend_desc)
|
||||
stmmac_mode_init(priv, tx_q->dma_etx,
|
||||
tx_q->dma_tx_phy,
|
||||
|
@ -413,7 +413,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -1871,12 +1871,12 @@ static int init_dma_desc_rings(struct ne
|
||||
@@ -1872,12 +1872,12 @@ static int init_dma_desc_rings(struct ne
|
||||
*/
|
||||
static void dma_free_tx_skbufs(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -428,7 +428,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_free_tx_buffer(priv, queue, i);
|
||||
|
||||
if (tx_q->xsk_pool && tx_q->xsk_frames_done) {
|
||||
@@ -1906,7 +1906,7 @@ static void stmmac_free_tx_skbufs(struct
|
||||
@@ -1907,7 +1907,7 @@ static void stmmac_free_tx_skbufs(struct
|
||||
*/
|
||||
static void __free_dma_rx_desc_resources(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Release the DMA RX socket buffers */
|
||||
if (rx_q->xsk_pool)
|
||||
@@ -1919,11 +1919,11 @@ static void __free_dma_rx_desc_resources
|
||||
@@ -1920,11 +1920,11 @@ static void __free_dma_rx_desc_resources
|
||||
|
||||
/* Free DMA regions of consistent memory previously allocated */
|
||||
if (!priv->extend_desc)
|
||||
|
@ -451,7 +451,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_extended_desc),
|
||||
rx_q->dma_erx, rx_q->dma_rx_phy);
|
||||
|
||||
@@ -1952,7 +1952,7 @@ static void free_dma_rx_desc_resources(s
|
||||
@@ -1953,7 +1953,7 @@ static void free_dma_rx_desc_resources(s
|
||||
*/
|
||||
static void __free_dma_tx_desc_resources(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -460,7 +460,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
size_t size;
|
||||
void *addr;
|
||||
|
||||
@@ -1970,7 +1970,7 @@ static void __free_dma_tx_desc_resources
|
||||
@@ -1971,7 +1971,7 @@ static void __free_dma_tx_desc_resources
|
||||
addr = tx_q->dma_tx;
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy);
|
||||
|
||||
@@ -1999,7 +1999,7 @@ static void free_dma_tx_desc_resources(s
|
||||
@@ -2000,7 +2000,7 @@ static void free_dma_tx_desc_resources(s
|
||||
*/
|
||||
static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[queue];
|
||||
bool xdp_prog = stmmac_xdp_is_enabled(priv);
|
||||
struct page_pool_params pp_params = { 0 };
|
||||
@@ -2011,8 +2011,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2012,8 +2012,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
rx_q->priv_data = priv;
|
||||
|
||||
pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
|
||||
|
@ -489,7 +489,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
pp_params.order = ilog2(num_pages);
|
||||
pp_params.nid = dev_to_node(priv->device);
|
||||
pp_params.dev = priv->device;
|
||||
@@ -2027,7 +2027,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2028,7 +2028,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(*rx_q->buf_pool),
|
||||
GFP_KERNEL);
|
||||
if (!rx_q->buf_pool)
|
||||
@@ -2035,7 +2035,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2036,7 +2036,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
|
||||
if (priv->extend_desc) {
|
||||
rx_q->dma_erx = dma_alloc_coherent(priv->device,
|
||||
|
@ -507,7 +507,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_extended_desc),
|
||||
&rx_q->dma_rx_phy,
|
||||
GFP_KERNEL);
|
||||
@@ -2044,7 +2044,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2045,7 +2045,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
|
||||
} else {
|
||||
rx_q->dma_rx = dma_alloc_coherent(priv->device,
|
||||
|
@ -516,7 +516,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_desc),
|
||||
&rx_q->dma_rx_phy,
|
||||
GFP_KERNEL);
|
||||
@@ -2101,20 +2101,20 @@ err_dma:
|
||||
@@ -2102,20 +2102,20 @@ err_dma:
|
||||
*/
|
||||
static int __alloc_dma_tx_desc_resources(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -540,7 +540,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct sk_buff *),
|
||||
GFP_KERNEL);
|
||||
if (!tx_q->tx_skbuff)
|
||||
@@ -2127,7 +2127,7 @@ static int __alloc_dma_tx_desc_resources
|
||||
@@ -2128,7 +2128,7 @@ static int __alloc_dma_tx_desc_resources
|
||||
else
|
||||
size = sizeof(struct dma_desc);
|
||||
|
||||
|
@ -549,7 +549,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
addr = dma_alloc_coherent(priv->device, size,
|
||||
&tx_q->dma_tx_phy, GFP_KERNEL);
|
||||
@@ -2371,7 +2371,7 @@ static void stmmac_dma_operation_mode(st
|
||||
@@ -2372,7 +2372,7 @@ static void stmmac_dma_operation_mode(st
|
||||
|
||||
/* configure all channels */
|
||||
for (chan = 0; chan < rx_channels_count; chan++) {
|
||||
|
@ -558,7 +558,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
u32 buf_size;
|
||||
|
||||
qmode = priv->plat->rx_queues_cfg[chan].mode_to_use;
|
||||
@@ -2386,7 +2386,7 @@ static void stmmac_dma_operation_mode(st
|
||||
@@ -2387,7 +2387,7 @@ static void stmmac_dma_operation_mode(st
|
||||
chan);
|
||||
} else {
|
||||
stmmac_set_dma_bfsize(priv, priv->ioaddr,
|
||||
|
@ -567,7 +567,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
chan);
|
||||
}
|
||||
}
|
||||
@@ -2402,7 +2402,7 @@ static void stmmac_dma_operation_mode(st
|
||||
@@ -2403,7 +2403,7 @@ static void stmmac_dma_operation_mode(st
|
||||
static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
|
||||
{
|
||||
struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
|
||||
|
@ -576,7 +576,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct xsk_buff_pool *pool = tx_q->xsk_pool;
|
||||
unsigned int entry = tx_q->cur_tx;
|
||||
struct dma_desc *tx_desc = NULL;
|
||||
@@ -2477,7 +2477,7 @@ static bool stmmac_xdp_xmit_zc(struct st
|
||||
@@ -2478,7 +2478,7 @@ static bool stmmac_xdp_xmit_zc(struct st
|
||||
|
||||
stmmac_enable_dma_transmission(priv, priv->ioaddr);
|
||||
|
||||
|
@ -585,7 +585,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
entry = tx_q->cur_tx;
|
||||
}
|
||||
|
||||
@@ -2503,7 +2503,7 @@ static bool stmmac_xdp_xmit_zc(struct st
|
||||
@@ -2504,7 +2504,7 @@ static bool stmmac_xdp_xmit_zc(struct st
|
||||
*/
|
||||
static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
|
||||
{
|
||||
|
@ -594,7 +594,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
unsigned int bytes_compl = 0, pkts_compl = 0;
|
||||
unsigned int entry, xmits = 0, count = 0;
|
||||
|
||||
@@ -2516,7 +2516,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
@@ -2517,7 +2517,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
entry = tx_q->dirty_tx;
|
||||
|
||||
/* Try to clean all TX complete frame in 1 shot */
|
||||
|
@ -603,7 +603,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct xdp_frame *xdpf;
|
||||
struct sk_buff *skb;
|
||||
struct dma_desc *p;
|
||||
@@ -2616,7 +2616,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
@@ -2617,7 +2617,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
|
||||
stmmac_release_tx_desc(priv, p, priv->mode);
|
||||
|
||||
|
@ -612,7 +612,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
tx_q->dirty_tx = entry;
|
||||
|
||||
@@ -2681,7 +2681,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
@@ -2682,7 +2682,7 @@ static int stmmac_tx_clean(struct stmmac
|
||||
*/
|
||||
static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan)
|
||||
{
|
||||
|
@ -621,7 +621,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, chan));
|
||||
|
||||
@@ -2748,8 +2748,8 @@ static int stmmac_napi_check(struct stmm
|
||||
@@ -2749,8 +2749,8 @@ static int stmmac_napi_check(struct stmm
|
||||
{
|
||||
int status = stmmac_dma_interrupt_status(priv, priv->ioaddr,
|
||||
&priv->xstats, chan, dir);
|
||||
|
@ -632,7 +632,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[chan];
|
||||
struct napi_struct *rx_napi;
|
||||
struct napi_struct *tx_napi;
|
||||
@@ -2925,7 +2925,7 @@ static int stmmac_init_dma_engine(struct
|
||||
@@ -2926,7 +2926,7 @@ static int stmmac_init_dma_engine(struct
|
||||
|
||||
/* DMA RX Channel Configuration */
|
||||
for (chan = 0; chan < rx_channels_count; chan++) {
|
||||
|
@ -641,7 +641,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
rx_q->dma_rx_phy, chan);
|
||||
@@ -2939,7 +2939,7 @@ static int stmmac_init_dma_engine(struct
|
||||
@@ -2940,7 +2940,7 @@ static int stmmac_init_dma_engine(struct
|
||||
|
||||
/* DMA TX Channel Configuration */
|
||||
for (chan = 0; chan < tx_channels_count; chan++) {
|
||||
|
@ -650,7 +650,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
tx_q->dma_tx_phy, chan);
|
||||
@@ -2954,7 +2954,7 @@ static int stmmac_init_dma_engine(struct
|
||||
@@ -2955,7 +2955,7 @@ static int stmmac_init_dma_engine(struct
|
||||
|
||||
static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -659,7 +659,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
hrtimer_start(&tx_q->txtimer,
|
||||
STMMAC_COAL_TIMER(priv->tx_coal_timer[queue]),
|
||||
@@ -3004,7 +3004,7 @@ static void stmmac_init_coalesce(struct
|
||||
@@ -3005,7 +3005,7 @@ static void stmmac_init_coalesce(struct
|
||||
u32 chan;
|
||||
|
||||
for (chan = 0; chan < tx_channel_count; chan++) {
|
||||
|
@ -668,7 +668,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
priv->tx_coal_frames[chan] = STMMAC_TX_FRAMES;
|
||||
priv->tx_coal_timer[chan] = STMMAC_COAL_TX_TIMER;
|
||||
@@ -3026,12 +3026,12 @@ static void stmmac_set_rings_length(stru
|
||||
@@ -3027,12 +3027,12 @@ static void stmmac_set_rings_length(stru
|
||||
/* set TX ring length */
|
||||
for (chan = 0; chan < tx_channels_count; chan++)
|
||||
stmmac_set_tx_ring_len(priv, priv->ioaddr,
|
||||
|
@ -683,7 +683,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -3366,7 +3366,7 @@ static int stmmac_hw_setup(struct net_de
|
||||
@@ -3367,7 +3367,7 @@ static int stmmac_hw_setup(struct net_de
|
||||
/* Enable TSO */
|
||||
if (priv->tso) {
|
||||
for (chan = 0; chan < tx_cnt; chan++) {
|
||||
|
@ -692,7 +692,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* TSO and TBS cannot co-exist */
|
||||
if (tx_q->tbs & STMMAC_TBS_AVAIL)
|
||||
@@ -3388,7 +3388,7 @@ static int stmmac_hw_setup(struct net_de
|
||||
@@ -3389,7 +3389,7 @@ static int stmmac_hw_setup(struct net_de
|
||||
|
||||
/* TBS */
|
||||
for (chan = 0; chan < tx_cnt; chan++) {
|
||||
|
@ -701,7 +701,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int enable = tx_q->tbs & STMMAC_TBS_AVAIL;
|
||||
|
||||
stmmac_enable_tbs(priv, priv->ioaddr, enable, chan);
|
||||
@@ -3432,7 +3432,7 @@ static void stmmac_free_irq(struct net_d
|
||||
@@ -3433,7 +3433,7 @@ static void stmmac_free_irq(struct net_d
|
||||
for (j = irq_idx - 1; j >= 0; j--) {
|
||||
if (priv->tx_irq[j] > 0) {
|
||||
irq_set_affinity_hint(priv->tx_irq[j], NULL);
|
||||
|
@ -710,7 +710,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
}
|
||||
irq_idx = priv->plat->rx_queues_to_use;
|
||||
@@ -3441,7 +3441,7 @@ static void stmmac_free_irq(struct net_d
|
||||
@@ -3442,7 +3442,7 @@ static void stmmac_free_irq(struct net_d
|
||||
for (j = irq_idx - 1; j >= 0; j--) {
|
||||
if (priv->rx_irq[j] > 0) {
|
||||
irq_set_affinity_hint(priv->rx_irq[j], NULL);
|
||||
|
@ -719,7 +719,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
}
|
||||
|
||||
@@ -3574,7 +3574,7 @@ static int stmmac_request_irq_multi_msi(
|
||||
@@ -3575,7 +3575,7 @@ static int stmmac_request_irq_multi_msi(
|
||||
sprintf(int_name, "%s:%s-%d", dev->name, "rx", i);
|
||||
ret = request_irq(priv->rx_irq[i],
|
||||
stmmac_msi_intr_rx,
|
||||
|
@ -728,7 +728,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (unlikely(ret < 0)) {
|
||||
netdev_err(priv->dev,
|
||||
"%s: alloc rx-%d MSI %d (error: %d)\n",
|
||||
@@ -3597,7 +3597,7 @@ static int stmmac_request_irq_multi_msi(
|
||||
@@ -3598,7 +3598,7 @@ static int stmmac_request_irq_multi_msi(
|
||||
sprintf(int_name, "%s:%s-%d", dev->name, "tx", i);
|
||||
ret = request_irq(priv->tx_irq[i],
|
||||
stmmac_msi_intr_tx,
|
||||
|
@ -737,7 +737,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (unlikely(ret < 0)) {
|
||||
netdev_err(priv->dev,
|
||||
"%s: alloc tx-%d MSI %d (error: %d)\n",
|
||||
@@ -3728,21 +3728,21 @@ static int stmmac_open(struct net_device
|
||||
@@ -3729,21 +3729,21 @@ static int stmmac_open(struct net_device
|
||||
bfsize = 0;
|
||||
|
||||
if (bfsize < BUF_SIZE_16KiB)
|
||||
|
@ -766,7 +766,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int tbs_en = priv->plat->tx_queues_cfg[chan].tbs_en;
|
||||
|
||||
/* Setup per-TXQ tbs flag before TX descriptor alloc */
|
||||
@@ -3800,7 +3800,7 @@ irq_error:
|
||||
@@ -3801,7 +3801,7 @@ irq_error:
|
||||
phylink_stop(priv->phylink);
|
||||
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
|
@ -775,7 +775,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_hw_teardown(dev);
|
||||
init_error:
|
||||
@@ -3842,7 +3842,7 @@ static int stmmac_release(struct net_dev
|
||||
@@ -3843,7 +3843,7 @@ static int stmmac_release(struct net_dev
|
||||
stmmac_disable_all_queues(priv);
|
||||
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
|
@ -784,7 +784,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
netif_tx_disable(dev);
|
||||
|
||||
@@ -3906,7 +3906,7 @@ static bool stmmac_vlan_insert(struct st
|
||||
@@ -3907,7 +3907,7 @@ static bool stmmac_vlan_insert(struct st
|
||||
return false;
|
||||
|
||||
stmmac_set_tx_owner(priv, p);
|
||||
|
@ -793,7 +793,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
return true;
|
||||
}
|
||||
|
||||
@@ -3924,7 +3924,7 @@ static bool stmmac_vlan_insert(struct st
|
||||
@@ -3925,7 +3925,7 @@ static bool stmmac_vlan_insert(struct st
|
||||
static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des,
|
||||
int total_len, bool last_segment, u32 queue)
|
||||
{
|
||||
|
@ -802,7 +802,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *desc;
|
||||
u32 buff_size;
|
||||
int tmp_len;
|
||||
@@ -3935,7 +3935,7 @@ static void stmmac_tso_allocator(struct
|
||||
@@ -3936,7 +3936,7 @@ static void stmmac_tso_allocator(struct
|
||||
dma_addr_t curr_addr;
|
||||
|
||||
tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx,
|
||||
|
@ -811,7 +811,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
|
||||
|
||||
if (tx_q->tbs & STMMAC_TBS_AVAIL)
|
||||
@@ -3963,7 +3963,7 @@ static void stmmac_tso_allocator(struct
|
||||
@@ -3964,7 +3964,7 @@ static void stmmac_tso_allocator(struct
|
||||
|
||||
static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue)
|
||||
{
|
||||
|
@ -820,7 +820,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int desc_size;
|
||||
|
||||
if (likely(priv->extend_desc))
|
||||
@@ -4025,7 +4025,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
@@ -4026,7 +4026,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
dma_addr_t des;
|
||||
int i;
|
||||
|
||||
|
@ -829,7 +829,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
first_tx = tx_q->cur_tx;
|
||||
|
||||
/* Compute header lengths */
|
||||
@@ -4065,7 +4065,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
@@ -4066,7 +4066,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
stmmac_set_mss(priv, mss_desc, mss);
|
||||
tx_q->mss = mss;
|
||||
tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx,
|
||||
|
@ -838,7 +838,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
|
||||
}
|
||||
|
||||
@@ -4177,7 +4177,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
@@ -4178,7 +4178,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
|
||||
* ndo_start_xmit will fill this descriptor the next time it's
|
||||
* called and stmmac_tx_clean may clean up to this descriptor.
|
||||
*/
|
||||
|
@ -847,7 +847,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (unlikely(stmmac_tx_avail(priv, queue) <= (MAX_SKB_FRAGS + 1))) {
|
||||
netif_dbg(priv, hw, priv->dev, "%s: stop transmitted packets\n",
|
||||
@@ -4265,7 +4265,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
@@ -4266,7 +4266,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
int entry, first_tx;
|
||||
dma_addr_t des;
|
||||
|
||||
|
@ -856,7 +856,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
first_tx = tx_q->cur_tx;
|
||||
|
||||
if (priv->tx_path_in_lpi_mode && priv->eee_sw_timer_en)
|
||||
@@ -4328,7 +4328,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
@@ -4329,7 +4329,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
int len = skb_frag_size(frag);
|
||||
bool last_segment = (i == (nfrags - 1));
|
||||
|
||||
|
@ -865,7 +865,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
WARN_ON(tx_q->tx_skbuff[entry]);
|
||||
|
||||
if (likely(priv->extend_desc))
|
||||
@@ -4399,7 +4399,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
@@ -4400,7 +4400,7 @@ static netdev_tx_t stmmac_xmit(struct sk
|
||||
* ndo_start_xmit will fill this descriptor the next time it's
|
||||
* called and stmmac_tx_clean may clean up to this descriptor.
|
||||
*/
|
||||
|
@ -874,7 +874,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
tx_q->cur_tx = entry;
|
||||
|
||||
if (netif_msg_pktdata(priv)) {
|
||||
@@ -4514,7 +4514,7 @@ static void stmmac_rx_vlan(struct net_de
|
||||
@@ -4512,7 +4512,7 @@ static void stmmac_rx_vlan(struct net_de
|
||||
*/
|
||||
static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -883,7 +883,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int dirty = stmmac_rx_dirty(priv, queue);
|
||||
unsigned int entry = rx_q->dirty_rx;
|
||||
|
||||
@@ -4564,7 +4564,7 @@ static inline void stmmac_rx_refill(stru
|
||||
@@ -4562,7 +4562,7 @@ static inline void stmmac_rx_refill(stru
|
||||
dma_wmb();
|
||||
stmmac_set_rx_owner(priv, p, use_rx_wd);
|
||||
|
||||
|
@ -892,7 +892,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
rx_q->dirty_rx = entry;
|
||||
rx_q->rx_tail_addr = rx_q->dma_rx_phy +
|
||||
@@ -4592,12 +4592,12 @@ static unsigned int stmmac_rx_buf1_len(s
|
||||
@@ -4590,12 +4590,12 @@ static unsigned int stmmac_rx_buf1_len(s
|
||||
|
||||
/* First descriptor, not last descriptor and not split header */
|
||||
if (status & rx_not_ls)
|
||||
|
@ -907,7 +907,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv,
|
||||
@@ -4613,7 +4613,7 @@ static unsigned int stmmac_rx_buf2_len(s
|
||||
@@ -4611,7 +4611,7 @@ static unsigned int stmmac_rx_buf2_len(s
|
||||
|
||||
/* Not last descriptor */
|
||||
if (status & rx_not_ls)
|
||||
|
@ -916,7 +916,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
plen = stmmac_get_rx_frame_len(priv, p, coe);
|
||||
|
||||
@@ -4624,7 +4624,7 @@ static unsigned int stmmac_rx_buf2_len(s
|
||||
@@ -4622,7 +4622,7 @@ static unsigned int stmmac_rx_buf2_len(s
|
||||
static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
|
||||
struct xdp_frame *xdpf, bool dma_map)
|
||||
{
|
||||
|
@ -925,7 +925,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
unsigned int entry = tx_q->cur_tx;
|
||||
struct dma_desc *tx_desc;
|
||||
dma_addr_t dma_addr;
|
||||
@@ -4687,7 +4687,7 @@ static int stmmac_xdp_xmit_xdpf(struct s
|
||||
@@ -4685,7 +4685,7 @@ static int stmmac_xdp_xmit_xdpf(struct s
|
||||
|
||||
stmmac_enable_dma_transmission(priv, priv->ioaddr);
|
||||
|
||||
|
@ -934,7 +934,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
tx_q->cur_tx = entry;
|
||||
|
||||
return STMMAC_XDP_TX;
|
||||
@@ -4861,7 +4861,7 @@ static void stmmac_dispatch_skb_zc(struc
|
||||
@@ -4859,7 +4859,7 @@ static void stmmac_dispatch_skb_zc(struc
|
||||
|
||||
static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
|
||||
{
|
||||
|
@ -943,7 +943,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
unsigned int entry = rx_q->dirty_rx;
|
||||
struct dma_desc *rx_desc = NULL;
|
||||
bool ret = true;
|
||||
@@ -4904,7 +4904,7 @@ static bool stmmac_rx_refill_zc(struct s
|
||||
@@ -4902,7 +4902,7 @@ static bool stmmac_rx_refill_zc(struct s
|
||||
dma_wmb();
|
||||
stmmac_set_rx_owner(priv, rx_desc, use_rx_wd);
|
||||
|
||||
|
@ -952,7 +952,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
if (rx_desc) {
|
||||
@@ -4919,7 +4919,7 @@ static bool stmmac_rx_refill_zc(struct s
|
||||
@@ -4917,7 +4917,7 @@ static bool stmmac_rx_refill_zc(struct s
|
||||
|
||||
static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
|
||||
{
|
||||
|
@ -961,7 +961,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
unsigned int count = 0, error = 0, len = 0;
|
||||
int dirty = stmmac_rx_dirty(priv, queue);
|
||||
unsigned int next_entry = rx_q->cur_rx;
|
||||
@@ -4941,7 +4941,7 @@ static int stmmac_rx_zc(struct stmmac_pr
|
||||
@@ -4939,7 +4939,7 @@ static int stmmac_rx_zc(struct stmmac_pr
|
||||
desc_size = sizeof(struct dma_desc);
|
||||
}
|
||||
|
||||
|
@ -970,7 +970,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
rx_q->dma_rx_phy, desc_size);
|
||||
}
|
||||
while (count < limit) {
|
||||
@@ -4988,7 +4988,7 @@ read_again:
|
||||
@@ -4986,7 +4986,7 @@ read_again:
|
||||
|
||||
/* Prefetch the next RX descriptor */
|
||||
rx_q->cur_rx = STMMAC_GET_ENTRY(rx_q->cur_rx,
|
||||
|
@ -979,7 +979,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
next_entry = rx_q->cur_rx;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -5109,7 +5109,7 @@ read_again:
|
||||
@@ -5107,7 +5107,7 @@ read_again:
|
||||
*/
|
||||
static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
|
||||
{
|
||||
|
@ -988,7 +988,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[queue];
|
||||
unsigned int count = 0, error = 0, len = 0;
|
||||
int status = 0, coe = priv->hw->rx_csum;
|
||||
@@ -5122,7 +5122,7 @@ static int stmmac_rx(struct stmmac_priv
|
||||
@@ -5120,7 +5120,7 @@ static int stmmac_rx(struct stmmac_priv
|
||||
int buf_sz;
|
||||
|
||||
dma_dir = page_pool_get_dma_dir(rx_q->page_pool);
|
||||
|
@ -997,7 +997,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (netif_msg_rx_status(priv)) {
|
||||
void *rx_head;
|
||||
@@ -5136,7 +5136,7 @@ static int stmmac_rx(struct stmmac_priv
|
||||
@@ -5134,7 +5134,7 @@ static int stmmac_rx(struct stmmac_priv
|
||||
desc_size = sizeof(struct dma_desc);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
rx_q->dma_rx_phy, desc_size);
|
||||
}
|
||||
while (count < limit) {
|
||||
@@ -5180,7 +5180,7 @@ read_again:
|
||||
@@ -5178,7 +5178,7 @@ read_again:
|
||||
break;
|
||||
|
||||
rx_q->cur_rx = STMMAC_GET_ENTRY(rx_q->cur_rx,
|
||||
|
@ -1015,7 +1015,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
next_entry = rx_q->cur_rx;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -5314,7 +5314,7 @@ read_again:
|
||||
@@ -5312,7 +5312,7 @@ read_again:
|
||||
buf1_len, dma_dir);
|
||||
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
|
||||
buf->page, buf->page_offset, buf1_len,
|
||||
|
@ -1024,7 +1024,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Data payload appended into SKB */
|
||||
page_pool_release_page(rx_q->page_pool, buf->page);
|
||||
@@ -5326,7 +5326,7 @@ read_again:
|
||||
@@ -5324,7 +5324,7 @@ read_again:
|
||||
buf2_len, dma_dir);
|
||||
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
|
||||
buf->sec_page, 0, buf2_len,
|
||||
|
@ -1033,7 +1033,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Data payload appended into SKB */
|
||||
page_pool_release_page(rx_q->page_pool, buf->sec_page);
|
||||
@@ -5768,11 +5768,13 @@ static irqreturn_t stmmac_safety_interru
|
||||
@@ -5767,11 +5767,13 @@ static irqreturn_t stmmac_safety_interru
|
||||
static irqreturn_t stmmac_msi_intr_tx(int irq, void *data)
|
||||
{
|
||||
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)data;
|
||||
|
@ -1048,7 +1048,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (unlikely(!data)) {
|
||||
netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
|
||||
@@ -5812,10 +5814,12 @@ static irqreturn_t stmmac_msi_intr_tx(in
|
||||
@@ -5811,10 +5813,12 @@ static irqreturn_t stmmac_msi_intr_tx(in
|
||||
static irqreturn_t stmmac_msi_intr_rx(int irq, void *data)
|
||||
{
|
||||
struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)data;
|
||||
|
@ -1062,7 +1062,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (unlikely(!data)) {
|
||||
netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
|
||||
@@ -5846,10 +5850,10 @@ static void stmmac_poll_controller(struc
|
||||
@@ -5845,10 +5849,10 @@ static void stmmac_poll_controller(struc
|
||||
|
||||
if (priv->plat->multi_msi_en) {
|
||||
for (i = 0; i < priv->plat->rx_queues_to_use; i++)
|
||||
|
@ -1075,7 +1075,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
} else {
|
||||
disable_irq(dev->irq);
|
||||
stmmac_interrupt(dev->irq, dev);
|
||||
@@ -6030,34 +6034,34 @@ static int stmmac_rings_status_show(stru
|
||||
@@ -6029,34 +6033,34 @@ static int stmmac_rings_status_show(stru
|
||||
return 0;
|
||||
|
||||
for (queue = 0; queue < rx_count; queue++) {
|
||||
|
@ -1116,7 +1116,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
}
|
||||
|
||||
@@ -6404,7 +6408,7 @@ void stmmac_disable_rx_queue(struct stmm
|
||||
@@ -6403,7 +6407,7 @@ void stmmac_disable_rx_queue(struct stmm
|
||||
|
||||
void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -1125,7 +1125,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[queue];
|
||||
unsigned long flags;
|
||||
u32 buf_size;
|
||||
@@ -6441,7 +6445,7 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
@@ -6440,7 +6444,7 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
rx_q->queue_index);
|
||||
} else {
|
||||
stmmac_set_dma_bfsize(priv, priv->ioaddr,
|
||||
|
@ -1134,7 +1134,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
rx_q->queue_index);
|
||||
}
|
||||
|
||||
@@ -6467,7 +6471,7 @@ void stmmac_disable_tx_queue(struct stmm
|
||||
@@ -6466,7 +6470,7 @@ void stmmac_disable_tx_queue(struct stmm
|
||||
|
||||
void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -1143,7 +1143,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[queue];
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
@@ -6517,7 +6521,7 @@ void stmmac_xdp_release(struct net_devic
|
||||
@@ -6516,7 +6520,7 @@ void stmmac_xdp_release(struct net_devic
|
||||
stmmac_disable_all_queues(priv);
|
||||
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
|
@ -1152,7 +1152,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Free the IRQ lines */
|
||||
stmmac_free_irq(dev, REQ_IRQ_ERR_ALL, 0);
|
||||
@@ -6576,7 +6580,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
@@ -6575,7 +6579,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
|
||||
/* DMA RX Channel Configuration */
|
||||
for (chan = 0; chan < rx_cnt; chan++) {
|
||||
|
@ -1161,7 +1161,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
rx_q->dma_rx_phy, chan);
|
||||
@@ -6594,7 +6598,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
@@ -6593,7 +6597,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
rx_q->queue_index);
|
||||
} else {
|
||||
stmmac_set_dma_bfsize(priv, priv->ioaddr,
|
||||
|
@ -1170,7 +1170,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
rx_q->queue_index);
|
||||
}
|
||||
|
||||
@@ -6603,7 +6607,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
@@ -6602,7 +6606,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
|
||||
/* DMA TX Channel Configuration */
|
||||
for (chan = 0; chan < tx_cnt; chan++) {
|
||||
|
@ -1179,7 +1179,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
tx_q->dma_tx_phy, chan);
|
||||
@@ -6636,7 +6640,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
@@ -6635,7 +6639,7 @@ int stmmac_xdp_open(struct net_device *d
|
||||
|
||||
irq_error:
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
|
@ -1188,7 +1188,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_hw_teardown(dev);
|
||||
init_error:
|
||||
@@ -6663,8 +6667,8 @@ int stmmac_xsk_wakeup(struct net_device
|
||||
@@ -6662,8 +6666,8 @@ int stmmac_xsk_wakeup(struct net_device
|
||||
queue >= priv->plat->tx_queues_to_use)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -1199,7 +1199,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
ch = &priv->channel[queue];
|
||||
|
||||
if (!rx_q->xsk_pool && !tx_q->xsk_pool)
|
||||
@@ -6924,8 +6928,8 @@ int stmmac_reinit_ringparam(struct net_d
|
||||
@@ -6923,8 +6927,8 @@ int stmmac_reinit_ringparam(struct net_d
|
||||
if (netif_running(dev))
|
||||
stmmac_release(dev);
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (netif_running(dev))
|
||||
ret = stmmac_open(dev);
|
||||
@@ -7357,7 +7361,7 @@ int stmmac_suspend(struct device *dev)
|
||||
@@ -7359,7 +7363,7 @@ int stmmac_suspend(struct device *dev)
|
||||
stmmac_disable_all_queues(priv);
|
||||
|
||||
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
|
||||
|
@ -1219,7 +1219,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (priv->eee_enabled) {
|
||||
priv->tx_path_in_lpi_mode = false;
|
||||
@@ -7408,7 +7412,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend);
|
||||
@@ -7411,7 +7415,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend);
|
||||
|
||||
static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -1228,7 +1228,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
rx_q->cur_rx = 0;
|
||||
rx_q->dirty_rx = 0;
|
||||
@@ -7416,7 +7420,7 @@ static void stmmac_reset_rx_queue(struct
|
||||
@@ -7419,7 +7423,7 @@ static void stmmac_reset_rx_queue(struct
|
||||
|
||||
static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
{
|
||||
|
@ -1270,7 +1270,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (i >= priv->plat->tx_queues_to_use)
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
|
||||
@@ -970,13 +970,13 @@ static int tc_setup_etf(struct stmmac_pr
|
||||
@@ -971,13 +971,13 @@ static int tc_setup_etf(struct stmmac_pr
|
||||
return -EOPNOTSUPP;
|
||||
if (qopt->queue >= priv->plat->tx_queues_to_use)
|
||||
return -EINVAL;
|
||||
|
|
|
@ -17,7 +17,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
@@ -1300,7 +1300,8 @@ static int stmmac_phy_setup(struct stmma
|
||||
@@ -1301,7 +1301,8 @@ static int stmmac_phy_setup(struct stmma
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
u32 rx_cnt = priv->plat->rx_queues_to_use;
|
||||
unsigned int desc_size;
|
||||
@@ -1309,7 +1310,7 @@ static void stmmac_display_rx_rings(stru
|
||||
@@ -1310,7 +1311,7 @@ static void stmmac_display_rx_rings(stru
|
||||
|
||||
/* Display RX rings */
|
||||
for (queue = 0; queue < rx_cnt; queue++) {
|
||||
|
@ -36,7 +36,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
pr_info("\tRX Queue %u rings\n", queue);
|
||||
|
||||
@@ -1322,12 +1323,13 @@ static void stmmac_display_rx_rings(stru
|
||||
@@ -1323,12 +1324,13 @@ static void stmmac_display_rx_rings(stru
|
||||
}
|
||||
|
||||
/* Display RX ring */
|
||||
|
@ -52,7 +52,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
u32 tx_cnt = priv->plat->tx_queues_to_use;
|
||||
unsigned int desc_size;
|
||||
@@ -1336,7 +1338,7 @@ static void stmmac_display_tx_rings(stru
|
||||
@@ -1337,7 +1339,7 @@ static void stmmac_display_tx_rings(stru
|
||||
|
||||
/* Display TX rings */
|
||||
for (queue = 0; queue < tx_cnt; queue++) {
|
||||
|
@ -61,7 +61,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
pr_info("\tTX Queue %d rings\n", queue);
|
||||
|
||||
@@ -1351,18 +1353,19 @@ static void stmmac_display_tx_rings(stru
|
||||
@@ -1352,18 +1354,19 @@ static void stmmac_display_tx_rings(stru
|
||||
desc_size = sizeof(struct dma_desc);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
static int stmmac_set_bfsize(int mtu, int bufsize)
|
||||
@@ -1386,44 +1389,50 @@ static int stmmac_set_bfsize(int mtu, in
|
||||
@@ -1387,44 +1390,50 @@ static int stmmac_set_bfsize(int mtu, in
|
||||
/**
|
||||
* stmmac_clear_rx_descriptors - clear RX descriptors
|
||||
* @priv: driver private structure
|
||||
|
@ -147,7 +147,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -1440,10 +1449,12 @@ static void stmmac_clear_tx_descriptors(
|
||||
@@ -1441,10 +1450,12 @@ static void stmmac_clear_tx_descriptors(
|
||||
/**
|
||||
* stmmac_clear_descriptors - clear descriptors
|
||||
* @priv: driver private structure
|
||||
|
@ -161,7 +161,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
u32 rx_queue_cnt = priv->plat->rx_queues_to_use;
|
||||
u32 tx_queue_cnt = priv->plat->tx_queues_to_use;
|
||||
@@ -1451,16 +1462,17 @@ static void stmmac_clear_descriptors(str
|
||||
@@ -1452,16 +1463,17 @@ static void stmmac_clear_descriptors(str
|
||||
|
||||
/* Clear the RX descriptors */
|
||||
for (queue = 0; queue < rx_queue_cnt; queue++)
|
||||
|
@ -181,7 +181,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
* @p: descriptor pointer
|
||||
* @i: descriptor index
|
||||
* @flags: gfp flag
|
||||
@@ -1468,10 +1480,12 @@ static void stmmac_clear_descriptors(str
|
||||
@@ -1469,10 +1481,12 @@ static void stmmac_clear_descriptors(str
|
||||
* Description: this function is called to allocate a receive buffer, perform
|
||||
* the DMA mapping and init the descriptor.
|
||||
*/
|
||||
|
@ -196,7 +196,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (!buf->page) {
|
||||
@@ -1496,7 +1510,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
@@ -1497,7 +1511,7 @@ static int stmmac_init_rx_buffers(struct
|
||||
buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset;
|
||||
|
||||
stmmac_set_desc_addr(priv, p, buf->addr);
|
||||
|
@ -205,7 +205,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_init_desc3(priv, p);
|
||||
|
||||
return 0;
|
||||
@@ -1505,12 +1519,13 @@ static int stmmac_init_rx_buffers(struct
|
||||
@@ -1506,12 +1520,13 @@ static int stmmac_init_rx_buffers(struct
|
||||
/**
|
||||
* stmmac_free_rx_buffer - free RX dma buffers
|
||||
* @priv: private structure
|
||||
|
@ -222,7 +222,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (buf->page)
|
||||
@@ -1525,12 +1540,15 @@ static void stmmac_free_rx_buffer(struct
|
||||
@@ -1526,12 +1541,15 @@ static void stmmac_free_rx_buffer(struct
|
||||
/**
|
||||
* stmmac_free_tx_buffer - free RX dma buffers
|
||||
* @priv: private structure
|
||||
|
@ -240,7 +240,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (tx_q->tx_skbuff_dma[i].buf &&
|
||||
tx_q->tx_skbuff_dma[i].buf_type != STMMAC_TXBUF_T_XDP_TX) {
|
||||
@@ -1569,23 +1587,28 @@ static void stmmac_free_tx_buffer(struct
|
||||
@@ -1570,23 +1588,28 @@ static void stmmac_free_tx_buffer(struct
|
||||
/**
|
||||
* dma_free_rx_skbufs - free RX dma buffers
|
||||
* @priv: private structure
|
||||
|
@ -276,7 +276,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
int ret;
|
||||
|
||||
@@ -1594,7 +1617,7 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
@@ -1595,7 +1618,7 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
else
|
||||
p = rx_q->dma_rx + i;
|
||||
|
||||
|
@ -285,7 +285,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
queue);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1608,14 +1631,17 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
@@ -1609,14 +1632,17 @@ static int stmmac_alloc_rx_buffers(struc
|
||||
/**
|
||||
* dma_free_rx_xskbufs - free RX dma buffers from XSK pool
|
||||
* @priv: private structure
|
||||
|
@ -306,7 +306,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i];
|
||||
|
||||
if (!buf->xdp)
|
||||
@@ -1626,12 +1652,14 @@ static void dma_free_rx_xskbufs(struct s
|
||||
@@ -1627,12 +1653,14 @@ static void dma_free_rx_xskbufs(struct s
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_rx_buffer *buf;
|
||||
dma_addr_t dma_addr;
|
||||
struct dma_desc *p;
|
||||
@@ -1666,22 +1694,25 @@ static struct xsk_buff_pool *stmmac_get_
|
||||
@@ -1667,22 +1695,25 @@ static struct xsk_buff_pool *stmmac_get_
|
||||
/**
|
||||
* __init_dma_rx_desc_rings - init the RX descriptor ring (per queue)
|
||||
* @priv: driver private structure
|
||||
|
@ -353,7 +353,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
xdp_rxq_info_unreg_mem_model(&rx_q->xdp_rxq);
|
||||
|
||||
@@ -1708,9 +1739,9 @@ static int __init_dma_rx_desc_rings(stru
|
||||
@@ -1709,9 +1740,9 @@ static int __init_dma_rx_desc_rings(stru
|
||||
/* RX XDP ZC buffer pool may not be populated, e.g.
|
||||
* xdpsock TX-only.
|
||||
*/
|
||||
|
@ -365,7 +365,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (ret < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -1720,17 +1751,19 @@ static int __init_dma_rx_desc_rings(stru
|
||||
@@ -1721,17 +1752,19 @@ static int __init_dma_rx_desc_rings(stru
|
||||
if (priv->extend_desc)
|
||||
stmmac_mode_init(priv, rx_q->dma_erx,
|
||||
rx_q->dma_rx_phy,
|
||||
|
@ -388,7 +388,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
u32 rx_count = priv->plat->rx_queues_to_use;
|
||||
@@ -1742,7 +1775,7 @@ static int init_dma_rx_desc_rings(struct
|
||||
@@ -1743,7 +1776,7 @@ static int init_dma_rx_desc_rings(struct
|
||||
"SKB addresses:\nskb\t\tskb data\tdma data\n");
|
||||
|
||||
for (queue = 0; queue < rx_count; queue++) {
|
||||
|
@ -397,7 +397,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (ret)
|
||||
goto err_init_rx_buffers;
|
||||
}
|
||||
@@ -1751,12 +1784,12 @@ static int init_dma_rx_desc_rings(struct
|
||||
@@ -1752,12 +1785,12 @@ static int init_dma_rx_desc_rings(struct
|
||||
|
||||
err_init_rx_buffers:
|
||||
while (queue >= 0) {
|
||||
|
@ -413,7 +413,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
rx_q->buf_alloc_num = 0;
|
||||
rx_q->xsk_pool = NULL;
|
||||
@@ -1773,14 +1806,17 @@ err_init_rx_buffers:
|
||||
@@ -1774,14 +1807,17 @@ err_init_rx_buffers:
|
||||
/**
|
||||
* __init_dma_tx_desc_rings - init the TX descriptor ring (per queue)
|
||||
* @priv: driver private structure
|
||||
|
@ -434,7 +434,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
int i;
|
||||
|
||||
netif_dbg(priv, probe, priv->dev,
|
||||
@@ -1792,16 +1828,16 @@ static int __init_dma_tx_desc_rings(stru
|
||||
@@ -1793,16 +1829,16 @@ static int __init_dma_tx_desc_rings(stru
|
||||
if (priv->extend_desc)
|
||||
stmmac_mode_init(priv, tx_q->dma_etx,
|
||||
tx_q->dma_tx_phy,
|
||||
|
@ -454,7 +454,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct dma_desc *p;
|
||||
|
||||
if (priv->extend_desc)
|
||||
@@ -1823,7 +1859,8 @@ static int __init_dma_tx_desc_rings(stru
|
||||
@@ -1824,7 +1860,8 @@ static int __init_dma_tx_desc_rings(stru
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -464,7 +464,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
u32 tx_queue_cnt;
|
||||
@@ -1832,7 +1869,7 @@ static int init_dma_tx_desc_rings(struct
|
||||
@@ -1833,7 +1870,7 @@ static int init_dma_tx_desc_rings(struct
|
||||
tx_queue_cnt = priv->plat->tx_queues_to_use;
|
||||
|
||||
for (queue = 0; queue < tx_queue_cnt; queue++)
|
||||
|
@ -473,7 +473,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
return 0;
|
||||
}
|
||||
@@ -1840,26 +1877,29 @@ static int init_dma_tx_desc_rings(struct
|
||||
@@ -1841,26 +1878,29 @@ static int init_dma_tx_desc_rings(struct
|
||||
/**
|
||||
* init_dma_desc_rings - init the RX/TX descriptor rings
|
||||
* @dev: net device structure
|
||||
|
@ -508,7 +508,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
return ret;
|
||||
}
|
||||
@@ -1867,17 +1907,20 @@ static int init_dma_desc_rings(struct ne
|
||||
@@ -1868,17 +1908,20 @@ static int init_dma_desc_rings(struct ne
|
||||
/**
|
||||
* dma_free_tx_skbufs - free TX dma buffers
|
||||
* @priv: private structure
|
||||
|
@ -533,7 +533,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (tx_q->xsk_pool && tx_q->xsk_frames_done) {
|
||||
xsk_tx_completed(tx_q->xsk_pool, tx_q->xsk_frames_done);
|
||||
@@ -1896,34 +1939,37 @@ static void stmmac_free_tx_skbufs(struct
|
||||
@@ -1897,34 +1940,37 @@ static void stmmac_free_tx_skbufs(struct
|
||||
u32 queue;
|
||||
|
||||
for (queue = 0; queue < tx_queue_cnt; queue++)
|
||||
|
@ -578,7 +578,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_extended_desc),
|
||||
rx_q->dma_erx, rx_q->dma_rx_phy);
|
||||
|
||||
@@ -1935,29 +1981,33 @@ static void __free_dma_rx_desc_resources
|
||||
@@ -1936,29 +1982,33 @@ static void __free_dma_rx_desc_resources
|
||||
page_pool_destroy(rx_q->page_pool);
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (priv->extend_desc) {
|
||||
size = sizeof(struct dma_extended_desc);
|
||||
@@ -1970,7 +2020,7 @@ static void __free_dma_tx_desc_resources
|
||||
@@ -1971,7 +2021,7 @@ static void __free_dma_tx_desc_resources
|
||||
addr = tx_q->dma_tx;
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy);
|
||||
|
||||
@@ -1978,28 +2028,32 @@ static void __free_dma_tx_desc_resources
|
||||
@@ -1979,28 +2029,32 @@ static void __free_dma_tx_desc_resources
|
||||
kfree(tx_q->tx_skbuff);
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
struct stmmac_channel *ch = &priv->channel[queue];
|
||||
bool xdp_prog = stmmac_xdp_is_enabled(priv);
|
||||
struct page_pool_params pp_params = { 0 };
|
||||
@@ -2011,8 +2065,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2012,8 +2066,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
rx_q->priv_data = priv;
|
||||
|
||||
pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
|
||||
|
@ -674,7 +674,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
pp_params.order = ilog2(num_pages);
|
||||
pp_params.nid = dev_to_node(priv->device);
|
||||
pp_params.dev = priv->device;
|
||||
@@ -2027,7 +2081,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2028,7 +2082,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(*rx_q->buf_pool),
|
||||
GFP_KERNEL);
|
||||
if (!rx_q->buf_pool)
|
||||
@@ -2035,7 +2089,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2036,7 +2090,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
|
||||
if (priv->extend_desc) {
|
||||
rx_q->dma_erx = dma_alloc_coherent(priv->device,
|
||||
|
@ -692,7 +692,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_extended_desc),
|
||||
&rx_q->dma_rx_phy,
|
||||
GFP_KERNEL);
|
||||
@@ -2044,7 +2098,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2045,7 +2099,7 @@ static int __alloc_dma_rx_desc_resources
|
||||
|
||||
} else {
|
||||
rx_q->dma_rx = dma_alloc_coherent(priv->device,
|
||||
|
@ -701,7 +701,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct dma_desc),
|
||||
&rx_q->dma_rx_phy,
|
||||
GFP_KERNEL);
|
||||
@@ -2069,7 +2123,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
@@ -2070,7 +2124,8 @@ static int __alloc_dma_rx_desc_resources
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
u32 rx_count = priv->plat->rx_queues_to_use;
|
||||
u32 queue;
|
||||
@@ -2077,7 +2132,7 @@ static int alloc_dma_rx_desc_resources(s
|
||||
@@ -2078,7 +2133,7 @@ static int alloc_dma_rx_desc_resources(s
|
||||
|
||||
/* RX queues buffers and DMA */
|
||||
for (queue = 0; queue < rx_count; queue++) {
|
||||
|
@ -720,7 +720,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (ret)
|
||||
goto err_dma;
|
||||
}
|
||||
@@ -2085,7 +2140,7 @@ static int alloc_dma_rx_desc_resources(s
|
||||
@@ -2086,7 +2141,7 @@ static int alloc_dma_rx_desc_resources(s
|
||||
return 0;
|
||||
|
||||
err_dma:
|
||||
|
@ -729,7 +729,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
return ret;
|
||||
}
|
||||
@@ -2093,28 +2148,31 @@ err_dma:
|
||||
@@ -2094,28 +2149,31 @@ err_dma:
|
||||
/**
|
||||
* __alloc_dma_tx_desc_resources - alloc TX resources (per queue).
|
||||
* @priv: private structure
|
||||
|
@ -765,7 +765,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
sizeof(struct sk_buff *),
|
||||
GFP_KERNEL);
|
||||
if (!tx_q->tx_skbuff)
|
||||
@@ -2127,7 +2185,7 @@ static int __alloc_dma_tx_desc_resources
|
||||
@@ -2128,7 +2186,7 @@ static int __alloc_dma_tx_desc_resources
|
||||
else
|
||||
size = sizeof(struct dma_desc);
|
||||
|
||||
|
@ -774,7 +774,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
addr = dma_alloc_coherent(priv->device, size,
|
||||
&tx_q->dma_tx_phy, GFP_KERNEL);
|
||||
@@ -2144,7 +2202,8 @@ static int __alloc_dma_tx_desc_resources
|
||||
@@ -2145,7 +2203,8 @@ static int __alloc_dma_tx_desc_resources
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -784,7 +784,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
{
|
||||
u32 tx_count = priv->plat->tx_queues_to_use;
|
||||
u32 queue;
|
||||
@@ -2152,7 +2211,7 @@ static int alloc_dma_tx_desc_resources(s
|
||||
@@ -2153,7 +2212,7 @@ static int alloc_dma_tx_desc_resources(s
|
||||
|
||||
/* TX queues buffers and DMA */
|
||||
for (queue = 0; queue < tx_count; queue++) {
|
||||
|
@ -793,7 +793,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (ret)
|
||||
goto err_dma;
|
||||
}
|
||||
@@ -2160,27 +2219,29 @@ static int alloc_dma_tx_desc_resources(s
|
||||
@@ -2161,27 +2220,29 @@ static int alloc_dma_tx_desc_resources(s
|
||||
return 0;
|
||||
|
||||
err_dma:
|
||||
|
@ -827,7 +827,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
return ret;
|
||||
}
|
||||
@@ -2188,16 +2249,18 @@ static int alloc_dma_desc_resources(stru
|
||||
@@ -2189,16 +2250,18 @@ static int alloc_dma_desc_resources(stru
|
||||
/**
|
||||
* free_dma_desc_resources - free dma desc resources
|
||||
* @priv: private structure
|
||||
|
@ -849,7 +849,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -2686,8 +2749,8 @@ static void stmmac_tx_err(struct stmmac_
|
||||
@@ -2687,8 +2750,8 @@ static void stmmac_tx_err(struct stmmac_
|
||||
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, chan));
|
||||
|
||||
stmmac_stop_tx_dma(priv, chan);
|
||||
|
@ -860,7 +860,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
stmmac_reset_tx_queue(priv, chan);
|
||||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
tx_q->dma_tx_phy, chan);
|
||||
@@ -3684,19 +3747,93 @@ static int stmmac_request_irq(struct net
|
||||
@@ -3685,19 +3748,93 @@ static int stmmac_request_irq(struct net
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -957,7 +957,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
u32 chan;
|
||||
int ret;
|
||||
|
||||
@@ -3723,45 +3860,10 @@ static int stmmac_open(struct net_device
|
||||
@@ -3724,45 +3861,10 @@ static int stmmac_open(struct net_device
|
||||
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
|
||||
priv->xstats.threshold = tc;
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
if (priv->plat->serdes_powerup) {
|
||||
ret = priv->plat->serdes_powerup(dev, priv->plat->bsp_priv);
|
||||
@@ -3804,14 +3906,28 @@ irq_error:
|
||||
@@ -3805,14 +3907,28 @@ irq_error:
|
||||
|
||||
stmmac_hw_teardown(dev);
|
||||
init_error:
|
||||
|
@ -1036,7 +1036,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
static void stmmac_fpe_stop_wq(struct stmmac_priv *priv)
|
||||
{
|
||||
set_bit(__FPE_REMOVING, &priv->fpe_task_state);
|
||||
@@ -3858,7 +3974,7 @@ static int stmmac_release(struct net_dev
|
||||
@@ -3859,7 +3975,7 @@ static int stmmac_release(struct net_dev
|
||||
stmmac_stop_all_dma(priv);
|
||||
|
||||
/* Release and free the Rx/Tx resources */
|
||||
|
@ -1045,7 +1045,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Disable the MAC Rx/Tx */
|
||||
stmmac_mac_set(priv, priv->ioaddr, false);
|
||||
@@ -6403,7 +6519,7 @@ void stmmac_disable_rx_queue(struct stmm
|
||||
@@ -6402,7 +6518,7 @@ void stmmac_disable_rx_queue(struct stmm
|
||||
spin_unlock_irqrestore(&ch->lock, flags);
|
||||
|
||||
stmmac_stop_rx_dma(priv, queue);
|
||||
|
@ -1054,7 +1054,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
@@ -6414,21 +6530,21 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
@@ -6413,21 +6529,21 @@ void stmmac_enable_rx_queue(struct stmma
|
||||
u32 buf_size;
|
||||
int ret;
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
rx_q->dma_rx_phy, rx_q->queue_index);
|
||||
@@ -6466,7 +6582,7 @@ void stmmac_disable_tx_queue(struct stmm
|
||||
@@ -6465,7 +6581,7 @@ void stmmac_disable_tx_queue(struct stmm
|
||||
spin_unlock_irqrestore(&ch->lock, flags);
|
||||
|
||||
stmmac_stop_tx_dma(priv, queue);
|
||||
|
@ -1089,7 +1089,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
}
|
||||
|
||||
void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue)
|
||||
@@ -6476,21 +6592,21 @@ void stmmac_enable_tx_queue(struct stmma
|
||||
@@ -6475,21 +6591,21 @@ void stmmac_enable_tx_queue(struct stmma
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
|
@ -1115,7 +1115,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
|
||||
tx_q->dma_tx_phy, tx_q->queue_index);
|
||||
@@ -6530,7 +6646,7 @@ void stmmac_xdp_release(struct net_devic
|
||||
@@ -6529,7 +6645,7 @@ void stmmac_xdp_release(struct net_devic
|
||||
stmmac_stop_all_dma(priv);
|
||||
|
||||
/* Release and free the Rx/Tx resources */
|
||||
|
@ -1124,7 +1124,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* Disable the MAC Rx/Tx */
|
||||
stmmac_mac_set(priv, priv->ioaddr, false);
|
||||
@@ -6555,14 +6671,14 @@ int stmmac_xdp_open(struct net_device *d
|
||||
@@ -6554,14 +6670,14 @@ int stmmac_xdp_open(struct net_device *d
|
||||
u32 chan;
|
||||
int ret;
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (ret < 0) {
|
||||
netdev_err(dev, "%s: DMA descriptors initialization failed\n",
|
||||
__func__);
|
||||
@@ -6644,7 +6760,7 @@ irq_error:
|
||||
@@ -6643,7 +6759,7 @@ irq_error:
|
||||
|
||||
stmmac_hw_teardown(dev);
|
||||
init_error:
|
||||
|
@ -1150,7 +1150,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
dma_desc_error:
|
||||
return ret;
|
||||
}
|
||||
@@ -7503,7 +7619,7 @@ int stmmac_resume(struct device *dev)
|
||||
@@ -7506,7 +7622,7 @@ int stmmac_resume(struct device *dev)
|
||||
stmmac_reset_queues_param(priv);
|
||||
|
||||
stmmac_free_tx_skbufs(priv);
|
||||
|
|
|
@ -19,7 +19,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
@@ -5626,18 +5626,15 @@ static int stmmac_change_mtu(struct net_
|
||||
@@ -5624,18 +5624,15 @@ static int stmmac_change_mtu(struct net_
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(dev);
|
||||
int txfifosz = priv->plat->tx_fifo_size;
|
||||
|
@ -40,7 +40,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
|
||||
netdev_dbg(priv->dev, "Jumbo frames not supported for XDP\n");
|
||||
return -EINVAL;
|
||||
@@ -5649,8 +5646,29 @@ static int stmmac_change_mtu(struct net_
|
||||
@@ -5647,8 +5644,29 @@ static int stmmac_change_mtu(struct net_
|
||||
if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
@ -1,229 +0,0 @@
|
|||
From ec51fbd1b8a2bca2948dede99c14ec63dc57ff6b Mon Sep 17 00:00:00 2001
|
||||
From: Bjørn Mork <bjorn@mork.no>
|
||||
Date: Fri, 6 Jan 2023 17:07:38 +0100
|
||||
Subject: [PATCH] r8152: add USB device driver for config selection
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Subclassing the generic USB device driver to override the
|
||||
default configuration selection regardless of matching interface
|
||||
drivers.
|
||||
|
||||
The r815x family devices expose a vendor specific function which
|
||||
the r8152 interface driver wants to handle. This is the preferred
|
||||
device mode. Additionally one or more USB class functions are
|
||||
usually supported for hosts lacking a vendor specific driver. The
|
||||
choice is USB configuration based, with one alternate function per
|
||||
configuration.
|
||||
|
||||
Example device with both NCM and ECM alternate cfgs:
|
||||
|
||||
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0
|
||||
D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 3
|
||||
P: Vendor=0bda ProdID=8156 Rev=31.00
|
||||
S: Manufacturer=Realtek
|
||||
S: Product=USB 10/100/1G/2.5G LAN
|
||||
S: SerialNumber=001000001
|
||||
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=256mA
|
||||
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=00 Driver=r8152
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 2 Ivl=128ms
|
||||
C: #Ifs= 2 Cfg#= 2 Atr=a0 MxPwr=256mA
|
||||
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
|
||||
I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=
|
||||
I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
C: #Ifs= 2 Cfg#= 3 Atr=a0 MxPwr=256mA
|
||||
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
|
||||
I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=
|
||||
I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
|
||||
A problem with this is that Linux will prefer class functions over
|
||||
vendor specific functions. Using the above example, Linux defaults
|
||||
to cfg #2, running the device in a sub-optimal NCM mode.
|
||||
|
||||
Previously we've attempted to work around the problem by
|
||||
blacklisting the devices in the ECM class driver "cdc_ether", and
|
||||
matching on the ECM class function in the vendor specific interface
|
||||
driver. The latter has been used to switch back to the vendor
|
||||
specific configuration when the driver is probed for a class
|
||||
function.
|
||||
|
||||
This workaround has several issues;
|
||||
- class driver blacklists is additional maintanence cruft in an
|
||||
unrelated driver
|
||||
- class driver blacklists prevents users from optionally running
|
||||
the devices in class mode
|
||||
- each device needs double match entries in the vendor driver
|
||||
- the initial probing as a class function slows down device
|
||||
discovery
|
||||
|
||||
Now these issues have become even worse with the introduction of
|
||||
firmware supporting both NCM and ECM, where NCM ends up as the
|
||||
default mode in Linux. To use the same workaround, we now have
|
||||
to blacklist the devices in to two different class drivers and
|
||||
add yet another match entry to the vendor specific driver.
|
||||
|
||||
This patch implements an alternative workaround strategy -
|
||||
independent of the interface drivers. It avoids adding a
|
||||
blacklist to the cdc_ncm driver and will let us remove the
|
||||
existing blacklist from the cdc_ether driver.
|
||||
|
||||
As an additional bonus, removing the blacklists allow users to
|
||||
select one of the other device modes if wanted.
|
||||
|
||||
Signed-off-by: Bjørn Mork <bjorn@mork.no>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 113 ++++++++++++++++++++++++++++------------
|
||||
1 file changed, 81 insertions(+), 32 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9625,6 +9625,9 @@ static int rtl8152_probe(struct usb_inte
|
||||
if (version == RTL_VER_UNKNOWN)
|
||||
return -ENODEV;
|
||||
|
||||
+ if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
if (!rtl_vendor_mode(intf))
|
||||
return -ENODEV;
|
||||
|
||||
@@ -9834,43 +9837,35 @@ static void rtl8152_disconnect(struct us
|
||||
}
|
||||
}
|
||||
|
||||
-#define REALTEK_USB_DEVICE(vend, prod) { \
|
||||
- USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC), \
|
||||
-}, \
|
||||
-{ \
|
||||
- USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_COMM, \
|
||||
- USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), \
|
||||
-}
|
||||
|
||||
/* table of devices that work with this driver */
|
||||
static const struct usb_device_id rtl8152_table[] = {
|
||||
/* Realtek */
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8053),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8155),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8156),
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8050) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8053) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8152) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8153) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8155) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8156) },
|
||||
|
||||
/* Microsoft */
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0c5e),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601),
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab) },
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6) },
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927) },
|
||||
+ { USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x304f) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3054) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3062) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3069) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3082) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7205) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x720c) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7214) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x721e) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0xa387) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
|
||||
+ { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
|
||||
+ { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -9890,7 +9885,61 @@ static struct usb_driver rtl8152_driver
|
||||
.disable_hub_initiated_lpm = 1,
|
||||
};
|
||||
|
||||
-module_usb_driver(rtl8152_driver);
|
||||
+static int rtl8152_cfgselector_probe(struct usb_device *udev)
|
||||
+{
|
||||
+ struct usb_host_config *c;
|
||||
+ int i, num_configs;
|
||||
+
|
||||
+ /* The vendor mode is not always config #1, so to find it out. */
|
||||
+ c = udev->config;
|
||||
+ num_configs = udev->descriptor.bNumConfigurations;
|
||||
+ for (i = 0; i < num_configs; (i++, c++)) {
|
||||
+ struct usb_interface_descriptor *desc = NULL;
|
||||
+
|
||||
+ if (!c->desc.bNumInterfaces)
|
||||
+ continue;
|
||||
+ desc = &c->intf_cache[0]->altsetting->desc;
|
||||
+ if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (i == num_configs)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
|
||||
+ dev_err(&udev->dev, "Failed to set configuration %d\n",
|
||||
+ c->desc.bConfigurationValue);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct usb_device_driver rtl8152_cfgselector_driver = {
|
||||
+ .name = MODULENAME "-cfgselector",
|
||||
+ .probe = rtl8152_cfgselector_probe,
|
||||
+ .id_table = rtl8152_table,
|
||||
+ .generic_subclass = 1,
|
||||
+};
|
||||
+
|
||||
+static int __init rtl8152_driver_init(void)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ return usb_register(&rtl8152_driver);
|
||||
+}
|
||||
+
|
||||
+static void __exit rtl8152_driver_exit(void)
|
||||
+{
|
||||
+ usb_deregister(&rtl8152_driver);
|
||||
+ usb_deregister_device_driver(&rtl8152_cfgselector_driver);
|
||||
+}
|
||||
+
|
||||
+module_init(rtl8152_driver_init);
|
||||
+module_exit(rtl8152_driver_exit);
|
||||
|
||||
MODULE_AUTHOR(DRIVER_AUTHOR);
|
||||
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
@ -1,64 +0,0 @@
|
|||
From 0d4cda805a183bbe523f2407edb5c14ade50b841 Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Tue, 17 Jan 2023 11:03:44 +0800
|
||||
Subject: [PATCH] r8152: avoid to change cfg for all devices
|
||||
|
||||
The rtl8152_cfgselector_probe() should set the USB configuration to the
|
||||
vendor mode only for the devices which the driver (r8152) supports.
|
||||
Otherwise, no driver would be used for such devices.
|
||||
|
||||
Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Reviewed-by: Simon Horman <simon.horman@corigine.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 20 +++++++++++++++++---
|
||||
1 file changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9531,9 +9531,8 @@ static int rtl_fw_init(struct r8152 *tp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-u8 rtl8152_get_version(struct usb_interface *intf)
|
||||
+static u8 __rtl_get_hw_ver(struct usb_device *udev)
|
||||
{
|
||||
- struct usb_device *udev = interface_to_usbdev(intf);
|
||||
u32 ocp_data = 0;
|
||||
__le32 *tmp;
|
||||
u8 version;
|
||||
@@ -9603,10 +9602,19 @@ u8 rtl8152_get_version(struct usb_interf
|
||||
break;
|
||||
default:
|
||||
version = RTL_VER_UNKNOWN;
|
||||
- dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data);
|
||||
+ dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data);
|
||||
break;
|
||||
}
|
||||
|
||||
+ return version;
|
||||
+}
|
||||
+
|
||||
+u8 rtl8152_get_version(struct usb_interface *intf)
|
||||
+{
|
||||
+ u8 version;
|
||||
+
|
||||
+ version = __rtl_get_hw_ver(interface_to_usbdev(intf));
|
||||
+
|
||||
dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
|
||||
|
||||
return version;
|
||||
@@ -9890,6 +9898,12 @@ static int rtl8152_cfgselector_probe(str
|
||||
struct usb_host_config *c;
|
||||
int i, num_configs;
|
||||
|
||||
+ /* Switch the device to vendor mode, if and only if the vendor mode
|
||||
+ * driver supports it.
|
||||
+ */
|
||||
+ if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN)
|
||||
+ return 0;
|
||||
+
|
||||
/* The vendor mode is not always config #1, so to find it out. */
|
||||
c = udev->config;
|
||||
num_configs = udev->descriptor.bNumConfigurations;
|
|
@ -1,71 +0,0 @@
|
|||
From 95a4c1d617b92cdc4522297741b56e8f6cd01a1e Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Thu, 19 Jan 2023 15:40:42 +0800
|
||||
Subject: [PATCH] r8152: remove rtl_vendor_mode function
|
||||
|
||||
After commit ec51fbd1b8a2 ("r8152: add USB device driver for
|
||||
config selection"), the code about changing USB configuration
|
||||
in rtl_vendor_mode() wouldn't be run anymore. Therefore, the
|
||||
function could be removed.
|
||||
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 39 +--------------------------------------
|
||||
1 file changed, 1 insertion(+), 38 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -8267,43 +8267,6 @@ static bool rtl_check_vendor_ok(struct u
|
||||
return true;
|
||||
}
|
||||
|
||||
-static bool rtl_vendor_mode(struct usb_interface *intf)
|
||||
-{
|
||||
- struct usb_host_interface *alt = intf->cur_altsetting;
|
||||
- struct usb_device *udev;
|
||||
- struct usb_host_config *c;
|
||||
- int i, num_configs;
|
||||
-
|
||||
- if (alt->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC)
|
||||
- return rtl_check_vendor_ok(intf);
|
||||
-
|
||||
- /* The vendor mode is not always config #1, so to find it out. */
|
||||
- udev = interface_to_usbdev(intf);
|
||||
- c = udev->config;
|
||||
- num_configs = udev->descriptor.bNumConfigurations;
|
||||
- if (num_configs < 2)
|
||||
- return false;
|
||||
-
|
||||
- for (i = 0; i < num_configs; (i++, c++)) {
|
||||
- struct usb_interface_descriptor *desc = NULL;
|
||||
-
|
||||
- if (c->desc.bNumInterfaces > 0)
|
||||
- desc = &c->intf_cache[0]->altsetting->desc;
|
||||
- else
|
||||
- continue;
|
||||
-
|
||||
- if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
|
||||
- usb_driver_set_configuration(udev, c->desc.bConfigurationValue);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (i == num_configs)
|
||||
- dev_err(&intf->dev, "Unexpected Device\n");
|
||||
-
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
static int rtl8152_pre_reset(struct usb_interface *intf)
|
||||
{
|
||||
struct r8152 *tp = usb_get_intfdata(intf);
|
||||
@@ -9636,7 +9599,7 @@ static int rtl8152_probe(struct usb_inte
|
||||
if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
|
||||
return -ENODEV;
|
||||
|
||||
- if (!rtl_vendor_mode(intf))
|
||||
+ if (!rtl_check_vendor_ok(intf))
|
||||
return -ENODEV;
|
||||
|
||||
usb_reset_device(udev);
|
|
@ -18,7 +18,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9588,20 +9588,21 @@ static int rtl8152_probe(struct usb_inte
|
||||
@@ -9602,20 +9602,21 @@ static int rtl8152_probe(struct usb_inte
|
||||
const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
From 0fbd79c01a9a657348f7032df70c57a406468c86 Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Tue, 2 May 2023 11:36:27 +0800
|
||||
Subject: [PATCH] r8152: fix the autosuspend doesn't work
|
||||
|
||||
Set supports_autosuspend = 1 for the rtl8152_cfgselector_driver.
|
||||
|
||||
Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9898,6 +9898,7 @@ static struct usb_device_driver rtl8152_
|
||||
.probe = rtl8152_cfgselector_probe,
|
||||
.id_table = rtl8152_table,
|
||||
.generic_subclass = 1,
|
||||
+ .supports_autosuspend = 1,
|
||||
};
|
||||
|
||||
static int __init rtl8152_driver_init(void)
|
|
@ -15,7 +15,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -3977,29 +3977,10 @@ static void rtl_reset_bmu(struct r8152 *
|
||||
@@ -3983,29 +3983,10 @@ static void rtl_reset_bmu(struct r8152 *
|
||||
/* Clear the bp to stop the firmware before loading a new one */
|
||||
static void rtl_clear_bp(struct r8152 *tp, u16 type)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
case RTL_VER_08:
|
||||
case RTL_VER_09:
|
||||
case RTL_VER_10:
|
||||
@@ -4007,32 +3988,31 @@ static void rtl_clear_bp(struct r8152 *t
|
||||
@@ -4013,32 +3994,31 @@ static void rtl_clear_bp(struct r8152 *t
|
||||
case RTL_VER_12:
|
||||
case RTL_VER_13:
|
||||
case RTL_VER_15:
|
||||
|
@ -100,7 +100,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* wait 3 ms to make sure the firmware is stopped */
|
||||
usleep_range(3000, 6000);
|
||||
@@ -5009,10 +4989,9 @@ static void rtl8152_fw_phy_nc_apply(stru
|
||||
@@ -5015,10 +4995,9 @@ static void rtl8152_fw_phy_nc_apply(stru
|
||||
|
||||
static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
switch (__le32_to_cpu(mac->blk_hdr.type)) {
|
||||
case RTL_FW_PLA:
|
||||
@@ -5054,12 +5033,8 @@ static void rtl8152_fw_mac_apply(struct
|
||||
@@ -5060,12 +5039,8 @@ static void rtl8152_fw_mac_apply(struct
|
||||
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
|
||||
__le16_to_cpu(mac->bp_ba_value));
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
From 72f93a3136ee18fd59fa6579f84c07e93424681e Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Napolitano <anton@polit.no>
|
||||
Date: Sat, 26 Aug 2023 01:05:50 +0200
|
||||
Subject: [PATCH] r8152: add vendor/device ID pair for D-Link DUB-E250
|
||||
|
||||
The D-Link DUB-E250 is an RTL8156 based 2.5G Ethernet controller.
|
||||
|
||||
Add the vendor and product ID values to the driver. This makes Ethernet
|
||||
work with the adapter.
|
||||
|
||||
Signed-off-by: Antonio Napolitano <anton@polit.no>
|
||||
Link: https://lore.kernel.org/r/CV200KJEEUPC.WPKAHXCQJ05I@mercurius
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 1 +
|
||||
include/linux/usb/r8152.h | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
|
||||
--- a/include/linux/usb/r8152.h
|
||||
+++ b/include/linux/usb/r8152.h
|
||||
@@ -29,6 +29,7 @@
|
||||
#define VENDOR_ID_LINKSYS 0x13b1
|
||||
#define VENDOR_ID_NVIDIA 0x0955
|
||||
#define VENDOR_ID_TPLINK 0x2357
|
||||
+#define VENDOR_ID_DLINK 0x2001
|
||||
|
||||
#if IS_REACHABLE(CONFIG_USB_RTL8152)
|
||||
extern u8 rtl8152_get_version(struct usb_interface *intf);
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9820,6 +9820,7 @@ static const struct usb_device_id rtl815
|
||||
{ USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
|
||||
{ USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
|
||||
{ USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
|
||||
+ { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) },
|
||||
{}
|
||||
};
|
||||
|
|
@ -1,447 +0,0 @@
|
|||
From 715f67f33af45ce2cc3a5b1ef133cc8c8e7787b0 Mon Sep 17 00:00:00 2001
|
||||
From: Douglas Anderson <dianders@chromium.org>
|
||||
Date: Fri, 20 Oct 2023 14:06:58 -0700
|
||||
Subject: [PATCH] r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE
|
||||
|
||||
Whenever the RTL8152_UNPLUG is set that just tells the driver that all
|
||||
accesses will fail and we should just immediately bail. A future patch
|
||||
will use this same concept at a time when the driver hasn't actually
|
||||
been unplugged but is about to be reset. Rename the flag in
|
||||
preparation for the future patch.
|
||||
|
||||
This is a no-op change and just a search and replace.
|
||||
|
||||
Signed-off-by: Douglas Anderson <dianders@chromium.org>
|
||||
Reviewed-by: Grant Grundler <grundler@chromium.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 96 ++++++++++++++++++++---------------------
|
||||
1 file changed, 48 insertions(+), 48 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -763,7 +763,7 @@ enum rtl_register_content {
|
||||
|
||||
/* rtl8152 flags */
|
||||
enum rtl8152_flags {
|
||||
- RTL8152_UNPLUG = 0,
|
||||
+ RTL8152_INACCESSIBLE = 0,
|
||||
RTL8152_SET_RX_MODE,
|
||||
WORK_ENABLE,
|
||||
RTL8152_LINK_CHG,
|
||||
@@ -1241,7 +1241,7 @@ int set_registers(struct r8152 *tp, u16
|
||||
static void rtl_set_unplug(struct r8152 *tp)
|
||||
{
|
||||
if (tp->udev->state == USB_STATE_NOTATTACHED) {
|
||||
- set_bit(RTL8152_UNPLUG, &tp->flags);
|
||||
+ set_bit(RTL8152_INACCESSIBLE, &tp->flags);
|
||||
smp_mb__after_atomic();
|
||||
}
|
||||
}
|
||||
@@ -1252,7 +1252,7 @@ static int generic_ocp_read(struct r8152
|
||||
u16 limit = 64;
|
||||
int ret = 0;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
@@ -1296,7 +1296,7 @@ static int generic_ocp_write(struct r815
|
||||
u16 byteen_start, byteen_end, byen;
|
||||
u16 limit = 512;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
@@ -1533,7 +1533,7 @@ static int read_mii_word(struct net_devi
|
||||
struct r8152 *tp = netdev_priv(netdev);
|
||||
int ret;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
if (phy_id != R8152_PHY_ID)
|
||||
@@ -1549,7 +1549,7 @@ void write_mii_word(struct net_device *n
|
||||
{
|
||||
struct r8152 *tp = netdev_priv(netdev);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (phy_id != R8152_PHY_ID)
|
||||
@@ -1754,7 +1754,7 @@ static void read_bulk_callback(struct ur
|
||||
if (!tp)
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
@@ -1846,7 +1846,7 @@ static void write_bulk_callback(struct u
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!skb_queue_empty(&tp->tx_queue))
|
||||
@@ -1867,7 +1867,7 @@ static void intr_callback(struct urb *ur
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
switch (status) {
|
||||
@@ -2611,7 +2611,7 @@ static void bottom_half(struct tasklet_s
|
||||
{
|
||||
struct r8152 *tp = from_tasklet(tp, t, tx_tl);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
@@ -2654,7 +2654,7 @@ int r8152_submit_rx(struct r8152 *tp, st
|
||||
int ret;
|
||||
|
||||
/* The rx would be stopped, so skip submitting */
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags) ||
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) ||
|
||||
!test_bit(WORK_ENABLE, &tp->flags) || !netif_carrier_ok(tp->netdev))
|
||||
return 0;
|
||||
|
||||
@@ -3050,7 +3050,7 @@ static int rtl_enable(struct r8152 *tp)
|
||||
|
||||
static int rtl8152_enable(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -3137,7 +3137,7 @@ static int rtl8153_enable(struct r8152 *
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -3169,7 +3169,7 @@ static void rtl_disable(struct r8152 *tp
|
||||
u32 ocp_data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -3623,7 +3623,7 @@ static u16 r8153_phy_status(struct r8152
|
||||
}
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3655,7 +3655,7 @@ static void r8153b_ups_en(struct r8152 *
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) &
|
||||
AUTOLOAD_DONE)
|
||||
@@ -3697,7 +3697,7 @@ static void r8153c_ups_en(struct r8152 *
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) &
|
||||
AUTOLOAD_DONE)
|
||||
@@ -4042,8 +4042,8 @@ static int rtl_phy_patch_request(struct
|
||||
for (i = 0; wait && i < 5000; i++) {
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
- break;
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
+ return -ENODEV;
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
ocp_data = ocp_reg_read(tp, OCP_PHY_PATCH_STAT);
|
||||
@@ -6001,7 +6001,7 @@ static int rtl8156_enable(struct r8152 *
|
||||
u32 ocp_data;
|
||||
u16 speed;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
r8156_fc_parameter(tp);
|
||||
@@ -6059,7 +6059,7 @@ static int rtl8156b_enable(struct r8152
|
||||
u32 ocp_data;
|
||||
u16 speed;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -6245,7 +6245,7 @@ out:
|
||||
|
||||
static void rtl8152_up(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8152_aldps_en(tp, false);
|
||||
@@ -6255,7 +6255,7 @@ static void rtl8152_up(struct r8152 *tp)
|
||||
|
||||
static void rtl8152_down(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6270,7 +6270,7 @@ static void rtl8153_up(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_u1u2en(tp, false);
|
||||
@@ -6310,7 +6310,7 @@ static void rtl8153_down(struct r8152 *t
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6331,7 +6331,7 @@ static void rtl8153b_up(struct r8152 *tp
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6355,7 +6355,7 @@ static void rtl8153b_down(struct r8152 *
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6392,7 +6392,7 @@ static void rtl8153c_up(struct r8152 *tp
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6473,7 +6473,7 @@ static void rtl8156_up(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6546,7 +6546,7 @@ static void rtl8156_down(struct r8152 *t
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6684,7 +6684,7 @@ static void rtl_work_func_t(struct work_
|
||||
/* If the device is unplugged or !netif_running(), the workqueue
|
||||
* doesn't need to wake the device, and could return directly.
|
||||
*/
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags) || !netif_running(tp->netdev))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) || !netif_running(tp->netdev))
|
||||
return;
|
||||
|
||||
if (usb_autopm_get_interface(tp->intf) < 0)
|
||||
@@ -6723,7 +6723,7 @@ static void rtl_hw_phy_work_func_t(struc
|
||||
{
|
||||
struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (usb_autopm_get_interface(tp->intf) < 0)
|
||||
@@ -6850,7 +6850,7 @@ static int rtl8152_close(struct net_devi
|
||||
netif_stop_queue(netdev);
|
||||
|
||||
res = usb_autopm_get_interface(tp->intf);
|
||||
- if (res < 0 || test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (res < 0 || test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
rtl_stop_rx(tp);
|
||||
} else {
|
||||
@@ -6883,7 +6883,7 @@ static void r8152b_init(struct r8152 *tp
|
||||
u32 ocp_data;
|
||||
u16 data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
data = r8152_mdio_read(tp, MII_BMCR);
|
||||
@@ -6927,7 +6927,7 @@ static void r8153_init(struct r8152 *tp)
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_u1u2en(tp, false);
|
||||
@@ -6938,7 +6938,7 @@ static void r8153_init(struct r8152 *tp)
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7067,7 +7067,7 @@ static void r8153b_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -7078,7 +7078,7 @@ static void r8153b_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7149,7 +7149,7 @@ static void r8153c_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -7169,7 +7169,7 @@ static void r8153c_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7998,7 +7998,7 @@ static void r8156_init(struct r8152 *tp)
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_ECM_OP);
|
||||
@@ -8019,7 +8019,7 @@ static void r8156_init(struct r8152 *tp)
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8094,7 +8094,7 @@ static void r8156b_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_ECM_OP);
|
||||
@@ -8128,7 +8128,7 @@ static void r8156b_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9153,7 +9153,7 @@ static int rtl8152_ioctl(struct net_devi
|
||||
struct mii_ioctl_data *data = if_mii(rq);
|
||||
int res;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
res = usb_autopm_get_interface(tp->intf);
|
||||
@@ -9255,7 +9255,7 @@ static const struct net_device_ops rtl81
|
||||
|
||||
static void rtl8152_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (tp->version != RTL_VER_01)
|
||||
@@ -9264,7 +9264,7 @@ static void rtl8152_unload(struct r8152
|
||||
|
||||
static void rtl8153_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_power_cut_en(tp, false);
|
||||
@@ -9272,7 +9272,7 @@ static void rtl8153_unload(struct r8152
|
||||
|
||||
static void rtl8153b_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_power_cut_en(tp, false);
|
|
@ -232,7 +232,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
}
|
||||
|
||||
static int generic_ocp_read(struct r8152 *tp, u16 index, u16 size,
|
||||
@@ -8254,7 +8348,7 @@ static int rtl8152_pre_reset(struct usb_
|
||||
@@ -8268,7 +8362,7 @@ static int rtl8152_pre_reset(struct usb_
|
||||
struct r8152 *tp = usb_get_intfdata(intf);
|
||||
struct net_device *netdev;
|
||||
|
||||
|
@ -241,7 +241,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
return 0;
|
||||
|
||||
netdev = tp->netdev;
|
||||
@@ -8269,7 +8363,9 @@ static int rtl8152_pre_reset(struct usb_
|
||||
@@ -8283,7 +8377,9 @@ static int rtl8152_pre_reset(struct usb_
|
||||
napi_disable(&tp->napi);
|
||||
if (netif_carrier_ok(netdev)) {
|
||||
mutex_lock(&tp->control);
|
||||
|
@ -251,7 +251,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
mutex_unlock(&tp->control);
|
||||
}
|
||||
|
||||
@@ -8282,9 +8378,11 @@ static int rtl8152_post_reset(struct usb
|
||||
@@ -8296,9 +8392,11 @@ static int rtl8152_post_reset(struct usb
|
||||
struct net_device *netdev;
|
||||
struct sockaddr sa;
|
||||
|
||||
|
@ -264,7 +264,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
/* reset the MAC address in case of policy change */
|
||||
if (determine_ethernet_addr(tp, &sa) >= 0) {
|
||||
rtnl_lock();
|
||||
@@ -9482,17 +9580,29 @@ static u8 __rtl_get_hw_ver(struct usb_de
|
||||
@@ -9496,17 +9594,29 @@ static u8 __rtl_get_hw_ver(struct usb_de
|
||||
__le32 *tmp;
|
||||
u8 version;
|
||||
int ret;
|
||||
|
@ -300,7 +300,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
|
||||
kfree(tmp);
|
||||
|
||||
@@ -9566,25 +9676,14 @@ u8 rtl8152_get_version(struct usb_interf
|
||||
@@ -9580,25 +9690,14 @@ u8 rtl8152_get_version(struct usb_interf
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rtl8152_get_version);
|
||||
|
||||
|
@ -328,7 +328,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
usb_reset_device(udev);
|
||||
netdev = alloc_etherdev(sizeof(struct r8152));
|
||||
if (!netdev) {
|
||||
@@ -9757,10 +9856,20 @@ static int rtl8152_probe(struct usb_inte
|
||||
@@ -9771,10 +9870,20 @@ static int rtl8152_probe(struct usb_inte
|
||||
else
|
||||
device_set_wakeup_enable(&udev->dev, false);
|
||||
|
||||
|
@ -349,7 +349,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
out1:
|
||||
tasklet_kill(&tp->tx_tl);
|
||||
cancel_delayed_work_sync(&tp->hw_phy_work);
|
||||
@@ -9769,10 +9878,46 @@ out1:
|
||||
@@ -9783,10 +9892,46 @@ out1:
|
||||
rtl8152_release_firmware(tp);
|
||||
usb_set_intfdata(intf, NULL);
|
||||
out:
|
||||
|
|
|
@ -49,7 +49,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
|
||||
--- a/drivers/net/usb/qmi_wwan.c
|
||||
+++ b/drivers/net/usb/qmi_wwan.c
|
||||
@@ -1316,6 +1316,7 @@ static const struct usb_device_id produc
|
||||
@@ -1317,6 +1317,7 @@ static const struct usb_device_id produc
|
||||
{QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
|
||||
{QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */
|
||||
{QMI_FIXED_INTF(0x19d2, 0x1432, 3)}, /* ZTE ME3620 */
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
From b7c1e53751cb3990153084f31c41f25fde3b629c Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 24 Nov 2023 20:38:14 +0100
|
||||
Subject: [PATCH] nvmem: Do not expect fixed layouts to grab a layout driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Two series lived in parallel for some time, which led to this situation:
|
||||
- The nvmem-layout container is used for dynamic layouts
|
||||
- We now expect fixed layouts to also use the nvmem-layout container but
|
||||
this does not require any additional driver, the support is built-in the
|
||||
nvmem core.
|
||||
|
||||
Ensure we don't refuse to probe for wrong reasons.
|
||||
|
||||
Fixes: 27f699e578b1 ("nvmem: core: add support for fixed cells *layout*")
|
||||
Cc: stable@vger.kernel.org
|
||||
Reported-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
|
||||
Link: https://lore.kernel.org/r/20231124193814.360552-1-miquel.raynal@bootlin.com
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -797,6 +797,12 @@ static struct nvmem_layout *nvmem_layout
|
||||
if (!layout_np)
|
||||
return NULL;
|
||||
|
||||
+ /* Fixed layouts don't have a matching driver */
|
||||
+ if (of_device_is_compatible(layout_np, "fixed-layout")) {
|
||||
+ of_node_put(layout_np);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* In case the nvmem device was built-in while the layout was built as a
|
||||
* module, we shall manually request the layout driver loading otherwise
|
|
@ -1,5 +1,6 @@
|
|||
From 1e37bf84afacd5ba17b7a13a18ca2bc78aff05c0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Thu, 14 Sep 2023 07:59:09 +0200
|
||||
Date: Fri, 15 Dec 2023 11:13:58 +0000
|
||||
Subject: [PATCH] nvmem: brcm_nvram: store a copy of NVRAM content
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
@ -21,11 +22,15 @@ allocating so much memory check for actual data length.
|
|||
|
||||
Link: https://lore.kernel.org/linux-mtd/CACna6rwf3_9QVjYcM+847biTX=K0EoWXuXcSMkJO1Vy_5vmVqA@mail.gmail.com/
|
||||
Fixes: 3fef9ed0627a ("nvmem: brcm_nvram: new driver exposing Broadcom's NVRAM")
|
||||
Cc: <Stable@vger.kernel.org>
|
||||
Cc: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Cc: Scott Branden <scott.branden@broadcom.com>
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111358.316727-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/brcm_nvram.c | 134 ++++++++++++++++++++++++++-----------
|
||||
1 file changed, 94 insertions(+), 40 deletions(-)
|
|
@ -0,0 +1,75 @@
|
|||
From 4d70c74659d9746502b23d055dba03d1d28ec388 Mon Sep 17 00:00:00 2001
|
||||
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
Date: Wed, 30 Nov 2022 15:48:35 +0200
|
||||
Subject: [PATCH] i915: Move list_count() to list.h as list_count_nodes() for
|
||||
broader use
|
||||
|
||||
Some of the existing users, and definitely will be new ones, want to
|
||||
count existing nodes in the list. Provide a generic API for that by
|
||||
moving code from i915 to list.h.
|
||||
|
||||
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
|
||||
Acked-by: Jani Nikula <jani.nikula@intel.com>
|
||||
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
Link: https://lore.kernel.org/r/20221130134838.23805-1-andriy.shevchenko@linux.intel.com
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/gpu/drm/i915/gt/intel_engine_cs.c | 15 ++-------------
|
||||
include/linux/list.h | 15 +++++++++++++++
|
||||
2 files changed, 17 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
|
||||
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
|
||||
@@ -1639,17 +1639,6 @@ static void print_request_ring(struct dr
|
||||
}
|
||||
}
|
||||
|
||||
-static unsigned long list_count(struct list_head *list)
|
||||
-{
|
||||
- struct list_head *pos;
|
||||
- unsigned long count = 0;
|
||||
-
|
||||
- list_for_each(pos, list)
|
||||
- count++;
|
||||
-
|
||||
- return count;
|
||||
-}
|
||||
-
|
||||
static unsigned long read_ul(void *p, size_t x)
|
||||
{
|
||||
return *(unsigned long *)(p + x);
|
||||
@@ -1824,8 +1813,8 @@ void intel_engine_dump(struct intel_engi
|
||||
spin_lock_irqsave(&engine->sched_engine->lock, flags);
|
||||
engine_dump_active_requests(engine, m);
|
||||
|
||||
- drm_printf(m, "\tOn hold?: %lu\n",
|
||||
- list_count(&engine->sched_engine->hold));
|
||||
+ drm_printf(m, "\tOn hold?: %zu\n",
|
||||
+ list_count_nodes(&engine->sched_engine->hold));
|
||||
spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
|
||||
|
||||
drm_printf(m, "\tMMIO base: 0x%08x\n", engine->mmio_base);
|
||||
--- a/include/linux/list.h
|
||||
+++ b/include/linux/list.h
|
||||
@@ -628,6 +628,21 @@ static inline void list_splice_tail_init
|
||||
pos = n, n = pos->prev)
|
||||
|
||||
/**
|
||||
+ * list_count_nodes - count nodes in the list
|
||||
+ * @head: the head for your list.
|
||||
+ */
|
||||
+static inline size_t list_count_nodes(struct list_head *head)
|
||||
+{
|
||||
+ struct list_head *pos;
|
||||
+ size_t count = 0;
|
||||
+
|
||||
+ list_for_each(pos, head)
|
||||
+ count++;
|
||||
+
|
||||
+ return count;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* list_entry_is_head - test if the entry points to the head of the list
|
||||
* @pos: the type * to cursor
|
||||
* @head: the head for your list.
|
|
@ -0,0 +1,128 @@
|
|||
From 7f38b70042fcaa49219045bd1a9a2836e27a58ac Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:27 +0000
|
||||
Subject: [PATCH] of: device: Export of_device_make_bus_id()
|
||||
|
||||
This helper is really handy to create unique device names based on their
|
||||
device tree path, we may need it outside of the OF core (in the NVMEM
|
||||
subsystem) so let's export it. As this helper has nothing patform
|
||||
specific, let's move it to of/device.c instead of of/platform.c so we
|
||||
can add its prototype to of_device.h.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Acked-by: Rob Herring <robh@kernel.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-2-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/of/device.c | 41 +++++++++++++++++++++++++++++++++++++++
|
||||
drivers/of/platform.c | 40 --------------------------------------
|
||||
include/linux/of_device.h | 6 ++++++
|
||||
3 files changed, 47 insertions(+), 40 deletions(-)
|
||||
|
||||
--- a/drivers/of/device.c
|
||||
+++ b/drivers/of/device.c
|
||||
@@ -337,3 +337,38 @@ int of_device_uevent_modalias(struct dev
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_device_uevent_modalias);
|
||||
+
|
||||
+/**
|
||||
+ * of_device_make_bus_id - Use the device node data to assign a unique name
|
||||
+ * @dev: pointer to device structure that is linked to a device tree node
|
||||
+ *
|
||||
+ * This routine will first try using the translated bus address to
|
||||
+ * derive a unique name. If it cannot, then it will prepend names from
|
||||
+ * parent nodes until a unique name can be derived.
|
||||
+ */
|
||||
+void of_device_make_bus_id(struct device *dev)
|
||||
+{
|
||||
+ struct device_node *node = dev->of_node;
|
||||
+ const __be32 *reg;
|
||||
+ u64 addr;
|
||||
+
|
||||
+ /* Construct the name, using parent nodes if necessary to ensure uniqueness */
|
||||
+ while (node->parent) {
|
||||
+ /*
|
||||
+ * If the address can be translated, then that is as much
|
||||
+ * uniqueness as we need. Make it the first component and return
|
||||
+ */
|
||||
+ reg = of_get_property(node, "reg", NULL);
|
||||
+ if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) {
|
||||
+ dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn",
|
||||
+ addr, node, dev_name(dev));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* format arguments only used if dev_name() resolves to NULL */
|
||||
+ dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s",
|
||||
+ kbasename(node->full_name), dev_name(dev));
|
||||
+ node = node->parent;
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(of_device_make_bus_id);
|
||||
--- a/drivers/of/platform.c
|
||||
+++ b/drivers/of/platform.c
|
||||
@@ -64,40 +64,6 @@ EXPORT_SYMBOL(of_find_device_by_node);
|
||||
*/
|
||||
|
||||
/**
|
||||
- * of_device_make_bus_id - Use the device node data to assign a unique name
|
||||
- * @dev: pointer to device structure that is linked to a device tree node
|
||||
- *
|
||||
- * This routine will first try using the translated bus address to
|
||||
- * derive a unique name. If it cannot, then it will prepend names from
|
||||
- * parent nodes until a unique name can be derived.
|
||||
- */
|
||||
-static void of_device_make_bus_id(struct device *dev)
|
||||
-{
|
||||
- struct device_node *node = dev->of_node;
|
||||
- const __be32 *reg;
|
||||
- u64 addr;
|
||||
-
|
||||
- /* Construct the name, using parent nodes if necessary to ensure uniqueness */
|
||||
- while (node->parent) {
|
||||
- /*
|
||||
- * If the address can be translated, then that is as much
|
||||
- * uniqueness as we need. Make it the first component and return
|
||||
- */
|
||||
- reg = of_get_property(node, "reg", NULL);
|
||||
- if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) {
|
||||
- dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn",
|
||||
- addr, node, dev_name(dev));
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- /* format arguments only used if dev_name() resolves to NULL */
|
||||
- dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s",
|
||||
- kbasename(node->full_name), dev_name(dev));
|
||||
- node = node->parent;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
* of_device_alloc - Allocate and initialize an of_device
|
||||
* @np: device node to assign to device
|
||||
* @bus_id: Name to assign to the device. May be null to use default name.
|
||||
--- a/include/linux/of_device.h
|
||||
+++ b/include/linux/of_device.h
|
||||
@@ -56,6 +56,9 @@ static inline int of_dma_configure(struc
|
||||
{
|
||||
return of_dma_configure_id(dev, np, force_dma, NULL);
|
||||
}
|
||||
+
|
||||
+void of_device_make_bus_id(struct device *dev);
|
||||
+
|
||||
#else /* CONFIG_OF */
|
||||
|
||||
static inline int of_driver_match_device(struct device *dev,
|
||||
@@ -113,6 +116,9 @@ static inline int of_dma_configure(struc
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+static inline void of_device_make_bus_id(struct device *dev) {}
|
||||
+
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
#endif /* _LINUX_OF_DEVICE_H */
|
|
@ -0,0 +1,95 @@
|
|||
From 4a1a40233b4a9fc159a5c7a27dc34c5c7bc5be55 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:28 +0000
|
||||
Subject: [PATCH] nvmem: Move of_nvmem_layout_get_container() in another header
|
||||
|
||||
nvmem-consumer.h is included by consumer devices, extracting data from
|
||||
NVMEM devices whereas nvmem-provider.h is included by devices providing
|
||||
NVMEM content.
|
||||
|
||||
The only users of of_nvmem_layout_get_container() outside of the core
|
||||
are layout drivers, so better move its prototype to nvmem-provider.h.
|
||||
|
||||
While we do so, we also move the kdoc associated with the function to
|
||||
the header rather than the .c file.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 8 --------
|
||||
include/linux/nvmem-consumer.h | 7 -------
|
||||
include/linux/nvmem-provider.h | 21 +++++++++++++++++++++
|
||||
3 files changed, 21 insertions(+), 15 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -848,14 +848,6 @@ static int nvmem_add_cells_from_layout(s
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_OF)
|
||||
-/**
|
||||
- * of_nvmem_layout_get_container() - Get OF node to layout container.
|
||||
- *
|
||||
- * @nvmem: nvmem device.
|
||||
- *
|
||||
- * Return: a node pointer with refcount incremented or NULL if no
|
||||
- * container exists. Use of_node_put() on it when done.
|
||||
- */
|
||||
struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
{
|
||||
return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
--- a/include/linux/nvmem-consumer.h
|
||||
+++ b/include/linux/nvmem-consumer.h
|
||||
@@ -241,7 +241,6 @@ struct nvmem_cell *of_nvmem_cell_get(str
|
||||
const char *id);
|
||||
struct nvmem_device *of_nvmem_device_get(struct device_node *np,
|
||||
const char *name);
|
||||
-struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
|
||||
#else
|
||||
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
|
||||
const char *id)
|
||||
@@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv
|
||||
{
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
-
|
||||
-static inline struct device_node *
|
||||
-of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- return NULL;
|
||||
-}
|
||||
#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
|
||||
#endif /* ifndef _LINUX_NVMEM_CONSUMER_H */
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -244,6 +244,27 @@ nvmem_layout_get_match_data(struct nvmem
|
||||
|
||||
#endif /* CONFIG_NVMEM */
|
||||
|
||||
+#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
|
||||
+
|
||||
+/**
|
||||
+ * of_nvmem_layout_get_container() - Get OF node of layout container
|
||||
+ *
|
||||
+ * @nvmem: nvmem device
|
||||
+ *
|
||||
+ * Return: a node pointer with refcount incremented or NULL if no
|
||||
+ * container exists. Use of_node_put() on it when done.
|
||||
+ */
|
||||
+struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
|
||||
+
|
||||
+#else /* CONFIG_NVMEM && CONFIG_OF */
|
||||
+
|
||||
+static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
+
|
||||
#define module_nvmem_layout_driver(__layout_driver) \
|
||||
module_driver(__layout_driver, nvmem_layout_register, \
|
||||
nvmem_layout_unregister)
|
|
@ -0,0 +1,91 @@
|
|||
From ec9c08a1cb8dc5e8e003f95f5f62de41dde235bb Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:29 +0000
|
||||
Subject: [PATCH] nvmem: Create a header for internal sharing
|
||||
|
||||
Before adding all the NVMEM layout bus infrastructure to the core, let's
|
||||
move the main nvmem_device structure in an internal header, only
|
||||
available to the core. This way all the additional code can be added in
|
||||
a dedicated file in order to keep the current core file tidy.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-4-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 24 +-----------------------
|
||||
drivers/nvmem/internals.h | 35 +++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 36 insertions(+), 23 deletions(-)
|
||||
create mode 100644 drivers/nvmem/internals.h
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -20,29 +20,7 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
-struct nvmem_device {
|
||||
- struct module *owner;
|
||||
- struct device dev;
|
||||
- int stride;
|
||||
- int word_size;
|
||||
- int id;
|
||||
- struct kref refcnt;
|
||||
- size_t size;
|
||||
- bool read_only;
|
||||
- bool root_only;
|
||||
- int flags;
|
||||
- enum nvmem_type type;
|
||||
- struct bin_attribute eeprom;
|
||||
- struct device *base_dev;
|
||||
- struct list_head cells;
|
||||
- const struct nvmem_keepout *keepout;
|
||||
- unsigned int nkeepout;
|
||||
- nvmem_reg_read_t reg_read;
|
||||
- nvmem_reg_write_t reg_write;
|
||||
- struct gpio_desc *wp_gpio;
|
||||
- struct nvmem_layout *layout;
|
||||
- void *priv;
|
||||
-};
|
||||
+#include "internals.h"
|
||||
|
||||
#define to_nvmem_device(d) container_of(d, struct nvmem_device, dev)
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -0,0 +1,35 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+
|
||||
+#ifndef _LINUX_NVMEM_INTERNALS_H
|
||||
+#define _LINUX_NVMEM_INTERNALS_H
|
||||
+
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/nvmem-consumer.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+
|
||||
+struct nvmem_device {
|
||||
+ struct module *owner;
|
||||
+ struct device dev;
|
||||
+ struct list_head node;
|
||||
+ int stride;
|
||||
+ int word_size;
|
||||
+ int id;
|
||||
+ struct kref refcnt;
|
||||
+ size_t size;
|
||||
+ bool read_only;
|
||||
+ bool root_only;
|
||||
+ int flags;
|
||||
+ enum nvmem_type type;
|
||||
+ struct bin_attribute eeprom;
|
||||
+ struct device *base_dev;
|
||||
+ struct list_head cells;
|
||||
+ const struct nvmem_keepout *keepout;
|
||||
+ unsigned int nkeepout;
|
||||
+ nvmem_reg_read_t reg_read;
|
||||
+ nvmem_reg_write_t reg_write;
|
||||
+ struct gpio_desc *wp_gpio;
|
||||
+ struct nvmem_layout *layout;
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */
|
|
@ -0,0 +1,79 @@
|
|||
From 1b7c298a4ecbc28cc6ee94005734bff55eb83d22 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:30 +0000
|
||||
Subject: [PATCH] nvmem: Simplify the ->add_cells() hook
|
||||
|
||||
The layout entry is not used and will anyway be made useless by the new
|
||||
layout bus infrastructure coming next, so drop it. While at it, clarify
|
||||
the kdoc entry.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-5-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 2 +-
|
||||
drivers/nvmem/layouts/onie-tlv.c | 3 +--
|
||||
drivers/nvmem/layouts/sl28vpd.c | 3 +--
|
||||
include/linux/nvmem-provider.h | 8 +++-----
|
||||
4 files changed, 6 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -817,7 +817,7 @@ static int nvmem_add_cells_from_layout(s
|
||||
int ret;
|
||||
|
||||
if (layout && layout->add_cells) {
|
||||
- ret = layout->add_cells(&nvmem->dev, nvmem, layout);
|
||||
+ ret = layout->add_cells(&nvmem->dev, nvmem);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
--- a/drivers/nvmem/layouts/onie-tlv.c
|
||||
+++ b/drivers/nvmem/layouts/onie-tlv.c
|
||||
@@ -182,8 +182,7 @@ static bool onie_tlv_crc_is_valid(struct
|
||||
return true;
|
||||
}
|
||||
|
||||
-static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout)
|
||||
+static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *nvmem)
|
||||
{
|
||||
struct onie_tlv_hdr hdr;
|
||||
size_t table_len, data_len, hdr_len;
|
||||
--- a/drivers/nvmem/layouts/sl28vpd.c
|
||||
+++ b/drivers/nvmem/layouts/sl28vpd.c
|
||||
@@ -80,8 +80,7 @@ static int sl28vpd_v1_check_crc(struct d
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int sl28vpd_add_cells(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout)
|
||||
+static int sl28vpd_add_cells(struct device *dev, struct nvmem_device *nvmem)
|
||||
{
|
||||
const struct nvmem_cell_info *pinfo;
|
||||
struct nvmem_cell_info info = {0};
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -156,9 +156,8 @@ struct nvmem_cell_table {
|
||||
*
|
||||
* @name: Layout name.
|
||||
* @of_match_table: Open firmware match table.
|
||||
- * @add_cells: Will be called if a nvmem device is found which
|
||||
- * has this layout. The function will add layout
|
||||
- * specific cells with nvmem_add_one_cell().
|
||||
+ * @add_cells: Called to populate the layout using
|
||||
+ * nvmem_add_one_cell().
|
||||
* @fixup_cell_info: Will be called before a cell is added. Can be
|
||||
* used to modify the nvmem_cell_info.
|
||||
* @owner: Pointer to struct module.
|
||||
@@ -172,8 +171,7 @@ struct nvmem_cell_table {
|
||||
struct nvmem_layout {
|
||||
const char *name;
|
||||
const struct of_device_id *of_match_table;
|
||||
- int (*add_cells)(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout);
|
||||
+ int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
void (*fixup_cell_info)(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout,
|
||||
struct nvmem_cell_info *cell);
|
|
@ -0,0 +1,169 @@
|
|||
From 1172460e716784ac7e1049a537bdca8edbf97360 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:31 +0000
|
||||
Subject: [PATCH] nvmem: Move and rename ->fixup_cell_info()
|
||||
|
||||
This hook is meant to be used by any provider and instantiating a layout
|
||||
just for this is useless. Let's instead move this hook to the nvmem
|
||||
device and add it to the config structure to be easily shared by the
|
||||
providers.
|
||||
|
||||
While at moving this hook, rename it ->fixup_dt_cell_info() to clarify
|
||||
its main intended purpose.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-6-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 6 +++---
|
||||
drivers/nvmem/imx-ocotp.c | 11 +++--------
|
||||
drivers/nvmem/internals.h | 2 ++
|
||||
drivers/nvmem/mtk-efuse.c | 11 +++--------
|
||||
include/linux/nvmem-provider.h | 9 ++++-----
|
||||
5 files changed, 15 insertions(+), 24 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -676,7 +676,6 @@ static int nvmem_validate_keepouts(struc
|
||||
|
||||
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
|
||||
{
|
||||
- struct nvmem_layout *layout = nvmem->layout;
|
||||
struct device *dev = &nvmem->dev;
|
||||
struct device_node *child;
|
||||
const __be32 *addr;
|
||||
@@ -706,8 +705,8 @@ static int nvmem_add_cells_from_dt(struc
|
||||
|
||||
info.np = of_node_get(child);
|
||||
|
||||
- if (layout && layout->fixup_cell_info)
|
||||
- layout->fixup_cell_info(nvmem, layout, &info);
|
||||
+ if (nvmem->fixup_dt_cell_info)
|
||||
+ nvmem->fixup_dt_cell_info(nvmem, &info);
|
||||
|
||||
ret = nvmem_add_one_cell(nvmem, &info);
|
||||
kfree(info.name);
|
||||
@@ -896,6 +895,7 @@ struct nvmem_device *nvmem_register(cons
|
||||
|
||||
kref_init(&nvmem->refcnt);
|
||||
INIT_LIST_HEAD(&nvmem->cells);
|
||||
+ nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info;
|
||||
|
||||
nvmem->owner = config->owner;
|
||||
if (!nvmem->owner && config->dev->driver)
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -584,17 +584,12 @@ static const struct of_device_id imx_oco
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
|
||||
|
||||
-static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell)
|
||||
+static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell)
|
||||
{
|
||||
cell->read_post_process = imx_ocotp_cell_pp;
|
||||
}
|
||||
|
||||
-static struct nvmem_layout imx_ocotp_layout = {
|
||||
- .fixup_cell_info = imx_ocotp_fixup_cell_info,
|
||||
-};
|
||||
-
|
||||
static int imx_ocotp_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -620,7 +615,7 @@ static int imx_ocotp_probe(struct platfo
|
||||
imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
|
||||
imx_ocotp_nvmem_config.dev = dev;
|
||||
imx_ocotp_nvmem_config.priv = priv;
|
||||
- imx_ocotp_nvmem_config.layout = &imx_ocotp_layout;
|
||||
+ imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info;
|
||||
|
||||
priv->config = &imx_ocotp_nvmem_config;
|
||||
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -23,6 +23,8 @@ struct nvmem_device {
|
||||
struct bin_attribute eeprom;
|
||||
struct device *base_dev;
|
||||
struct list_head cells;
|
||||
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell);
|
||||
const struct nvmem_keepout *keepout;
|
||||
unsigned int nkeepout;
|
||||
nvmem_reg_read_t reg_read;
|
||||
--- a/drivers/nvmem/mtk-efuse.c
|
||||
+++ b/drivers/nvmem/mtk-efuse.c
|
||||
@@ -45,9 +45,8 @@ static int mtk_efuse_gpu_speedbin_pp(voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell)
|
||||
+static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell)
|
||||
{
|
||||
size_t sz = strlen(cell->name);
|
||||
|
||||
@@ -61,10 +60,6 @@ static void mtk_efuse_fixup_cell_info(st
|
||||
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
|
||||
}
|
||||
|
||||
-static struct nvmem_layout mtk_efuse_layout = {
|
||||
- .fixup_cell_info = mtk_efuse_fixup_cell_info,
|
||||
-};
|
||||
-
|
||||
static int mtk_efuse_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -91,7 +86,7 @@ static int mtk_efuse_probe(struct platfo
|
||||
econfig.priv = priv;
|
||||
econfig.dev = dev;
|
||||
if (pdata->uses_post_processing)
|
||||
- econfig.layout = &mtk_efuse_layout;
|
||||
+ econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
|
||||
nvmem = devm_nvmem_register(dev, &econfig);
|
||||
|
||||
return PTR_ERR_OR_ZERO(nvmem);
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -83,6 +83,8 @@ struct nvmem_cell_info {
|
||||
* @cells: Optional array of pre-defined NVMEM cells.
|
||||
* @ncells: Number of elements in cells.
|
||||
* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
|
||||
+ * @fixup_dt_cell_info: Will be called before a cell is added. Can be
|
||||
+ * used to modify the nvmem_cell_info.
|
||||
* @keepout: Optional array of keepout ranges (sorted ascending by start).
|
||||
* @nkeepout: Number of elements in the keepout array.
|
||||
* @type: Type of the nvmem storage
|
||||
@@ -113,6 +115,8 @@ struct nvmem_config {
|
||||
const struct nvmem_cell_info *cells;
|
||||
int ncells;
|
||||
bool add_legacy_fixed_of_cells;
|
||||
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell);
|
||||
const struct nvmem_keepout *keepout;
|
||||
unsigned int nkeepout;
|
||||
enum nvmem_type type;
|
||||
@@ -158,8 +162,6 @@ struct nvmem_cell_table {
|
||||
* @of_match_table: Open firmware match table.
|
||||
* @add_cells: Called to populate the layout using
|
||||
* nvmem_add_one_cell().
|
||||
- * @fixup_cell_info: Will be called before a cell is added. Can be
|
||||
- * used to modify the nvmem_cell_info.
|
||||
* @owner: Pointer to struct module.
|
||||
* @node: List node.
|
||||
*
|
||||
@@ -172,9 +174,6 @@ struct nvmem_layout {
|
||||
const char *name;
|
||||
const struct of_device_id *of_match_table;
|
||||
int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
- void (*fixup_cell_info)(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell);
|
||||
|
||||
/* private */
|
||||
struct module *owner;
|
|
@ -0,0 +1,763 @@
|
|||
From fc29fd821d9ac2ae3d32a722fac39ce874efb883 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:32 +0000
|
||||
Subject: [PATCH] nvmem: core: Rework layouts to become regular devices
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Current layout support was initially written without modules support in
|
||||
mind. When the requirement for module support rose, the existing base
|
||||
was improved to adopt modularization support, but kind of a design flaw
|
||||
was introduced. With the existing implementation, when a storage device
|
||||
registers into NVMEM, the core tries to hook a layout (if any) and
|
||||
populates its cells immediately. This means, if the hardware description
|
||||
expects a layout to be hooked up, but no driver was provided for that,
|
||||
the storage medium will fail to probe and try later from
|
||||
scratch. Even if we consider that the hardware description shall be
|
||||
correct, we could still probe the storage device (especially if it
|
||||
contains the rootfs).
|
||||
|
||||
One way to overcome this situation is to consider the layouts as
|
||||
devices, and leverage the native notifier mechanism. When a new NVMEM
|
||||
device is registered, we can populate its nvmem-layout child, if any,
|
||||
and wait for the matching to be done in order to get the cells (the
|
||||
waiting can be easily done with the NVMEM notifiers). If the layout
|
||||
driver is compiled as a module, it should automatically be loaded. This
|
||||
way, there is no strong order to enforce, any NVMEM device creation
|
||||
or NVMEM layout driver insertion will be observed as a new event which
|
||||
may lead to the creation of additional cells, without disturbing the
|
||||
probes with costly (and sometimes endless) deferrals.
|
||||
|
||||
In order to achieve that goal we create a new bus for the nvmem-layouts
|
||||
with minimal logic to match nvmem-layout devices with nvmem-layout
|
||||
drivers. All this infrastructure code is created in the layouts.c file.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-7-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/Kconfig | 1 +
|
||||
drivers/nvmem/Makefile | 2 +
|
||||
drivers/nvmem/core.c | 170 ++++++++++----------------
|
||||
drivers/nvmem/internals.h | 21 ++++
|
||||
drivers/nvmem/layouts.c | 201 +++++++++++++++++++++++++++++++
|
||||
drivers/nvmem/layouts/Kconfig | 8 ++
|
||||
drivers/nvmem/layouts/onie-tlv.c | 24 +++-
|
||||
drivers/nvmem/layouts/sl28vpd.c | 24 +++-
|
||||
include/linux/nvmem-provider.h | 38 +++---
|
||||
9 files changed, 354 insertions(+), 135 deletions(-)
|
||||
create mode 100644 drivers/nvmem/layouts.c
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menuconfig NVMEM
|
||||
bool "NVMEM Support"
|
||||
+ imply NVMEM_LAYOUTS
|
||||
help
|
||||
Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES...
|
||||
|
||||
--- a/drivers/nvmem/Makefile
|
||||
+++ b/drivers/nvmem/Makefile
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
obj-$(CONFIG_NVMEM) += nvmem_core.o
|
||||
nvmem_core-y := core.o
|
||||
+obj-$(CONFIG_NVMEM_LAYOUTS) += nvmem_layouts.o
|
||||
+nvmem_layouts-y := layouts.o
|
||||
obj-y += layouts/
|
||||
|
||||
# Devices
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -56,9 +56,6 @@ static LIST_HEAD(nvmem_lookup_list);
|
||||
|
||||
static BLOCKING_NOTIFIER_HEAD(nvmem_notifier);
|
||||
|
||||
-static DEFINE_SPINLOCK(nvmem_layout_lock);
|
||||
-static LIST_HEAD(nvmem_layouts);
|
||||
-
|
||||
static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
|
||||
void *val, size_t bytes)
|
||||
{
|
||||
@@ -741,97 +738,22 @@ static int nvmem_add_cells_from_fixed_la
|
||||
return err;
|
||||
}
|
||||
|
||||
-int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner)
|
||||
+int nvmem_layout_register(struct nvmem_layout *layout)
|
||||
{
|
||||
- layout->owner = owner;
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
- list_add(&layout->node, &nvmem_layouts);
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
-
|
||||
- blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_ADD, layout);
|
||||
+ if (!layout->add_cells)
|
||||
+ return -EINVAL;
|
||||
|
||||
- return 0;
|
||||
+ /* Populate the cells */
|
||||
+ return layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(__nvmem_layout_register);
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_register);
|
||||
|
||||
void nvmem_layout_unregister(struct nvmem_layout *layout)
|
||||
{
|
||||
- blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_REMOVE, layout);
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
- list_del(&layout->node);
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
+ /* Keep the API even with an empty stub in case we need it later */
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_layout_unregister);
|
||||
|
||||
-static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- struct device_node *layout_np;
|
||||
- struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER);
|
||||
-
|
||||
- layout_np = of_nvmem_layout_get_container(nvmem);
|
||||
- if (!layout_np)
|
||||
- return NULL;
|
||||
-
|
||||
- /* Fixed layouts don't have a matching driver */
|
||||
- if (of_device_is_compatible(layout_np, "fixed-layout")) {
|
||||
- of_node_put(layout_np);
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * In case the nvmem device was built-in while the layout was built as a
|
||||
- * module, we shall manually request the layout driver loading otherwise
|
||||
- * we'll never have any match.
|
||||
- */
|
||||
- of_request_module(layout_np);
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
-
|
||||
- list_for_each_entry(l, &nvmem_layouts, node) {
|
||||
- if (of_match_node(l->of_match_table, layout_np)) {
|
||||
- if (try_module_get(l->owner))
|
||||
- layout = l;
|
||||
-
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
- of_node_put(layout_np);
|
||||
-
|
||||
- return layout;
|
||||
-}
|
||||
-
|
||||
-static void nvmem_layout_put(struct nvmem_layout *layout)
|
||||
-{
|
||||
- if (layout)
|
||||
- module_put(layout->owner);
|
||||
-}
|
||||
-
|
||||
-static int nvmem_add_cells_from_layout(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- struct nvmem_layout *layout = nvmem->layout;
|
||||
- int ret;
|
||||
-
|
||||
- if (layout && layout->add_cells) {
|
||||
- ret = layout->add_cells(&nvmem->dev, nvmem);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-#if IS_ENABLED(CONFIG_OF)
|
||||
-struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
|
||||
-#endif
|
||||
-
|
||||
const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout)
|
||||
{
|
||||
@@ -839,7 +761,7 @@ const void *nvmem_layout_get_match_data(
|
||||
const struct of_device_id *match;
|
||||
|
||||
layout_np = of_nvmem_layout_get_container(nvmem);
|
||||
- match = of_match_node(layout->of_match_table, layout_np);
|
||||
+ match = of_match_node(layout->dev.driver->of_match_table, layout_np);
|
||||
|
||||
return match ? match->data : NULL;
|
||||
}
|
||||
@@ -951,19 +873,6 @@ struct nvmem_device *nvmem_register(cons
|
||||
goto err_put_device;
|
||||
}
|
||||
|
||||
- /*
|
||||
- * If the driver supplied a layout by config->layout, the module
|
||||
- * pointer will be NULL and nvmem_layout_put() will be a noop.
|
||||
- */
|
||||
- nvmem->layout = config->layout ?: nvmem_layout_get(nvmem);
|
||||
- if (IS_ERR(nvmem->layout)) {
|
||||
- rval = PTR_ERR(nvmem->layout);
|
||||
- nvmem->layout = NULL;
|
||||
-
|
||||
- if (rval == -EPROBE_DEFER)
|
||||
- goto err_teardown_compat;
|
||||
- }
|
||||
-
|
||||
if (config->cells) {
|
||||
rval = nvmem_add_cells(nvmem, config->cells, config->ncells);
|
||||
if (rval)
|
||||
@@ -984,24 +893,24 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- rval = nvmem_add_cells_from_layout(nvmem);
|
||||
- if (rval)
|
||||
- goto err_remove_cells;
|
||||
-
|
||||
dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
|
||||
|
||||
rval = device_add(&nvmem->dev);
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
+ rval = nvmem_populate_layout(nvmem);
|
||||
+ if (rval)
|
||||
+ goto err_remove_dev;
|
||||
+
|
||||
blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
|
||||
|
||||
return nvmem;
|
||||
|
||||
+err_remove_dev:
|
||||
+ device_del(&nvmem->dev);
|
||||
err_remove_cells:
|
||||
nvmem_device_remove_all_cells(nvmem);
|
||||
- nvmem_layout_put(nvmem->layout);
|
||||
-err_teardown_compat:
|
||||
if (config->compat)
|
||||
nvmem_sysfs_remove_compat(nvmem, config);
|
||||
err_put_device:
|
||||
@@ -1023,7 +932,7 @@ static void nvmem_device_release(struct
|
||||
device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
|
||||
|
||||
nvmem_device_remove_all_cells(nvmem);
|
||||
- nvmem_layout_put(nvmem->layout);
|
||||
+ nvmem_destroy_layout(nvmem);
|
||||
device_unregister(&nvmem->dev);
|
||||
}
|
||||
|
||||
@@ -1325,6 +1234,12 @@ nvmem_cell_get_from_lookup(struct device
|
||||
return cell;
|
||||
}
|
||||
|
||||
+static void nvmem_layout_module_put(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ if (nvmem->layout && nvmem->layout->dev.driver)
|
||||
+ module_put(nvmem->layout->dev.driver->owner);
|
||||
+}
|
||||
+
|
||||
#if IS_ENABLED(CONFIG_OF)
|
||||
static struct nvmem_cell_entry *
|
||||
nvmem_find_cell_entry_by_node(struct nvmem_device *nvmem, struct device_node *np)
|
||||
@@ -1343,6 +1258,18 @@ nvmem_find_cell_entry_by_node(struct nvm
|
||||
return cell;
|
||||
}
|
||||
|
||||
+static int nvmem_layout_module_get_optional(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ if (!nvmem->layout)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (!nvmem->layout->dev.driver ||
|
||||
+ !try_module_get(nvmem->layout->dev.driver->owner))
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
|
||||
*
|
||||
@@ -1405,16 +1332,29 @@ struct nvmem_cell *of_nvmem_cell_get(str
|
||||
return ERR_CAST(nvmem);
|
||||
}
|
||||
|
||||
+ ret = nvmem_layout_module_get_optional(nvmem);
|
||||
+ if (ret) {
|
||||
+ of_node_put(cell_np);
|
||||
+ __nvmem_device_put(nvmem);
|
||||
+ return ERR_PTR(ret);
|
||||
+ }
|
||||
+
|
||||
cell_entry = nvmem_find_cell_entry_by_node(nvmem, cell_np);
|
||||
of_node_put(cell_np);
|
||||
if (!cell_entry) {
|
||||
__nvmem_device_put(nvmem);
|
||||
- return ERR_PTR(-ENOENT);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
+ if (nvmem->layout)
|
||||
+ return ERR_PTR(-EPROBE_DEFER);
|
||||
+ else
|
||||
+ return ERR_PTR(-ENOENT);
|
||||
}
|
||||
|
||||
cell = nvmem_create_cell(cell_entry, id, cell_index);
|
||||
- if (IS_ERR(cell))
|
||||
+ if (IS_ERR(cell)) {
|
||||
__nvmem_device_put(nvmem);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
+ }
|
||||
|
||||
return cell;
|
||||
}
|
||||
@@ -1528,6 +1468,7 @@ void nvmem_cell_put(struct nvmem_cell *c
|
||||
|
||||
kfree(cell);
|
||||
__nvmem_device_put(nvmem);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_cell_put);
|
||||
|
||||
@@ -2105,11 +2046,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_name);
|
||||
|
||||
static int __init nvmem_init(void)
|
||||
{
|
||||
- return bus_register(&nvmem_bus_type);
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = bus_register(&nvmem_bus_type);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = nvmem_layout_bus_register();
|
||||
+ if (ret)
|
||||
+ bus_unregister(&nvmem_bus_type);
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static void __exit nvmem_exit(void)
|
||||
{
|
||||
+ nvmem_layout_bus_unregister();
|
||||
bus_unregister(&nvmem_bus_type);
|
||||
}
|
||||
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -34,4 +34,25 @@ struct nvmem_device {
|
||||
void *priv;
|
||||
};
|
||||
|
||||
+#if IS_ENABLED(CONFIG_OF)
|
||||
+int nvmem_layout_bus_register(void);
|
||||
+void nvmem_layout_bus_unregister(void);
|
||||
+int nvmem_populate_layout(struct nvmem_device *nvmem);
|
||||
+void nvmem_destroy_layout(struct nvmem_device *nvmem);
|
||||
+#else /* CONFIG_OF */
|
||||
+static inline int nvmem_layout_bus_register(void)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void nvmem_layout_bus_unregister(void) {}
|
||||
+
|
||||
+static inline int nvmem_populate_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void nvmem_destroy_layout(struct nvmem_device *nvmem) { }
|
||||
+#endif /* CONFIG_OF */
|
||||
+
|
||||
#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/layouts.c
|
||||
@@ -0,0 +1,201 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * NVMEM layout bus handling
|
||||
+ *
|
||||
+ * Copyright (C) 2023 Bootlin
|
||||
+ * Author: Miquel Raynal <miquel.raynal@bootlin.com
|
||||
+ */
|
||||
+
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/dma-mapping.h>
|
||||
+#include <linux/nvmem-consumer.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/of_irq.h>
|
||||
+
|
||||
+#include "internals.h"
|
||||
+
|
||||
+#define to_nvmem_layout_driver(drv) \
|
||||
+ (container_of((drv), struct nvmem_layout_driver, driver))
|
||||
+#define to_nvmem_layout_device(_dev) \
|
||||
+ container_of((_dev), struct nvmem_layout, dev)
|
||||
+
|
||||
+static int nvmem_layout_bus_match(struct device *dev, struct device_driver *drv)
|
||||
+{
|
||||
+ return of_driver_match_device(dev, drv);
|
||||
+}
|
||||
+
|
||||
+static int nvmem_layout_bus_probe(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ if (!drv->probe || !drv->remove)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ return drv->probe(layout);
|
||||
+}
|
||||
+
|
||||
+static void nvmem_layout_bus_remove(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ return drv->remove(layout);
|
||||
+}
|
||||
+
|
||||
+static struct bus_type nvmem_layout_bus_type = {
|
||||
+ .name = "nvmem-layout",
|
||||
+ .match = nvmem_layout_bus_match,
|
||||
+ .probe = nvmem_layout_bus_probe,
|
||||
+ .remove = nvmem_layout_bus_remove,
|
||||
+};
|
||||
+
|
||||
+int nvmem_layout_driver_register(struct nvmem_layout_driver *drv)
|
||||
+{
|
||||
+ drv->driver.bus = &nvmem_layout_bus_type;
|
||||
+
|
||||
+ return driver_register(&drv->driver);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_driver_register);
|
||||
+
|
||||
+void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv)
|
||||
+{
|
||||
+ driver_unregister(&drv->driver);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_driver_unregister);
|
||||
+
|
||||
+static void nvmem_layout_release_device(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ of_node_put(layout->dev.of_node);
|
||||
+ kfree(layout);
|
||||
+}
|
||||
+
|
||||
+static int nvmem_layout_create_device(struct nvmem_device *nvmem,
|
||||
+ struct device_node *np)
|
||||
+{
|
||||
+ struct nvmem_layout *layout;
|
||||
+ struct device *dev;
|
||||
+ int ret;
|
||||
+
|
||||
+ layout = kzalloc(sizeof(*layout), GFP_KERNEL);
|
||||
+ if (!layout)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Create a bidirectional link */
|
||||
+ layout->nvmem = nvmem;
|
||||
+ nvmem->layout = layout;
|
||||
+
|
||||
+ /* Device model registration */
|
||||
+ dev = &layout->dev;
|
||||
+ device_initialize(dev);
|
||||
+ dev->parent = &nvmem->dev;
|
||||
+ dev->bus = &nvmem_layout_bus_type;
|
||||
+ dev->release = nvmem_layout_release_device;
|
||||
+ dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
||||
+ dev->dma_mask = &dev->coherent_dma_mask;
|
||||
+ device_set_node(dev, of_fwnode_handle(of_node_get(np)));
|
||||
+ of_device_make_bus_id(dev);
|
||||
+ of_msi_configure(dev, dev->of_node);
|
||||
+
|
||||
+ ret = device_add(dev);
|
||||
+ if (ret) {
|
||||
+ put_device(dev);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id of_nvmem_layout_skip_table[] = {
|
||||
+ { .compatible = "fixed-layout", },
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
+static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
|
||||
+ struct device_node *layout_dn)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Make sure it has a compatible property */
|
||||
+ if (!of_get_property(layout_dn, "compatible", NULL)) {
|
||||
+ pr_debug("%s() - skipping %pOF, no compatible prop\n",
|
||||
+ __func__, layout_dn);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Fixed layouts are parsed manually somewhere else for now */
|
||||
+ if (of_match_node(of_nvmem_layout_skip_table, layout_dn)) {
|
||||
+ pr_debug("%s() - skipping %pOF node\n", __func__, layout_dn);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (of_node_check_flag(layout_dn, OF_POPULATED_BUS)) {
|
||||
+ pr_debug("%s() - skipping %pOF, already populated\n",
|
||||
+ __func__, layout_dn);
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* NVMEM layout buses expect only a single device representing the layout */
|
||||
+ ret = nvmem_layout_create_device(nvmem, layout_dn);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ of_node_set_flag(layout_dn, OF_POPULATED_BUS);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
|
||||
+
|
||||
+/*
|
||||
+ * Returns the number of devices populated, 0 if the operation was not relevant
|
||||
+ * for this nvmem device, an error code otherwise.
|
||||
+ */
|
||||
+int nvmem_populate_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct device_node *layout_dn;
|
||||
+ int ret;
|
||||
+
|
||||
+ layout_dn = of_nvmem_layout_get_container(nvmem);
|
||||
+ if (!layout_dn)
|
||||
+ return 0;
|
||||
+
|
||||
+ /* Populate the layout device */
|
||||
+ device_links_supplier_sync_state_pause();
|
||||
+ ret = nvmem_layout_bus_populate(nvmem, layout_dn);
|
||||
+ device_links_supplier_sync_state_resume();
|
||||
+
|
||||
+ of_node_put(layout_dn);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+void nvmem_destroy_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct device *dev;
|
||||
+
|
||||
+ if (!nvmem->layout)
|
||||
+ return;
|
||||
+
|
||||
+ dev = &nvmem->layout->dev;
|
||||
+ of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
|
||||
+ device_unregister(dev);
|
||||
+}
|
||||
+
|
||||
+int nvmem_layout_bus_register(void)
|
||||
+{
|
||||
+ return bus_register(&nvmem_layout_bus_type);
|
||||
+}
|
||||
+
|
||||
+void nvmem_layout_bus_unregister(void)
|
||||
+{
|
||||
+ bus_unregister(&nvmem_layout_bus_type);
|
||||
+}
|
||||
--- a/drivers/nvmem/layouts/Kconfig
|
||||
+++ b/drivers/nvmem/layouts/Kconfig
|
||||
@@ -1,5 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
+config NVMEM_LAYOUTS
|
||||
+ bool
|
||||
+ depends on OF
|
||||
+
|
||||
+if NVMEM_LAYOUTS
|
||||
+
|
||||
menu "Layout Types"
|
||||
|
||||
config NVMEM_LAYOUT_SL28_VPD
|
||||
@@ -21,3 +27,5 @@ config NVMEM_LAYOUT_ONIE_TLV
|
||||
If unsure, say N.
|
||||
|
||||
endmenu
|
||||
+
|
||||
+endif
|
||||
--- a/drivers/nvmem/layouts/onie-tlv.c
|
||||
+++ b/drivers/nvmem/layouts/onie-tlv.c
|
||||
@@ -225,16 +225,32 @@ static int onie_tlv_parse_table(struct d
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int onie_tlv_probe(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ layout->add_cells = onie_tlv_parse_table;
|
||||
+
|
||||
+ return nvmem_layout_register(layout);
|
||||
+}
|
||||
+
|
||||
+static void onie_tlv_remove(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ nvmem_layout_unregister(layout);
|
||||
+}
|
||||
+
|
||||
static const struct of_device_id onie_tlv_of_match_table[] = {
|
||||
{ .compatible = "onie,tlv-layout", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, onie_tlv_of_match_table);
|
||||
|
||||
-static struct nvmem_layout onie_tlv_layout = {
|
||||
- .name = "ONIE tlv layout",
|
||||
- .of_match_table = onie_tlv_of_match_table,
|
||||
- .add_cells = onie_tlv_parse_table,
|
||||
+static struct nvmem_layout_driver onie_tlv_layout = {
|
||||
+ .driver = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .name = "onie-tlv-layout",
|
||||
+ .of_match_table = onie_tlv_of_match_table,
|
||||
+ },
|
||||
+ .probe = onie_tlv_probe,
|
||||
+ .remove = onie_tlv_remove,
|
||||
};
|
||||
module_nvmem_layout_driver(onie_tlv_layout);
|
||||
|
||||
--- a/drivers/nvmem/layouts/sl28vpd.c
|
||||
+++ b/drivers/nvmem/layouts/sl28vpd.c
|
||||
@@ -134,16 +134,32 @@ static int sl28vpd_add_cells(struct devi
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int sl28vpd_probe(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ layout->add_cells = sl28vpd_add_cells;
|
||||
+
|
||||
+ return nvmem_layout_register(layout);
|
||||
+}
|
||||
+
|
||||
+static void sl28vpd_remove(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ nvmem_layout_unregister(layout);
|
||||
+}
|
||||
+
|
||||
static const struct of_device_id sl28vpd_of_match_table[] = {
|
||||
{ .compatible = "kontron,sl28-vpd" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sl28vpd_of_match_table);
|
||||
|
||||
-static struct nvmem_layout sl28vpd_layout = {
|
||||
- .name = "sl28-vpd",
|
||||
- .of_match_table = sl28vpd_of_match_table,
|
||||
- .add_cells = sl28vpd_add_cells,
|
||||
+static struct nvmem_layout_driver sl28vpd_layout = {
|
||||
+ .driver = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .name = "kontron-sl28vpd-layout",
|
||||
+ .of_match_table = sl28vpd_of_match_table,
|
||||
+ },
|
||||
+ .probe = sl28vpd_probe,
|
||||
+ .remove = sl28vpd_remove,
|
||||
};
|
||||
module_nvmem_layout_driver(sl28vpd_layout);
|
||||
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef _LINUX_NVMEM_PROVIDER_H
|
||||
#define _LINUX_NVMEM_PROVIDER_H
|
||||
|
||||
+#include <linux/device.h>
|
||||
#include <linux/device/driver.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/errno.h>
|
||||
@@ -158,12 +159,11 @@ struct nvmem_cell_table {
|
||||
/**
|
||||
* struct nvmem_layout - NVMEM layout definitions
|
||||
*
|
||||
- * @name: Layout name.
|
||||
- * @of_match_table: Open firmware match table.
|
||||
- * @add_cells: Called to populate the layout using
|
||||
- * nvmem_add_one_cell().
|
||||
- * @owner: Pointer to struct module.
|
||||
- * @node: List node.
|
||||
+ * @dev: Device-model layout device.
|
||||
+ * @nvmem: The underlying NVMEM device
|
||||
+ * @add_cells: Will be called if a nvmem device is found which
|
||||
+ * has this layout. The function will add layout
|
||||
+ * specific cells with nvmem_add_one_cell().
|
||||
*
|
||||
* A nvmem device can hold a well defined structure which can just be
|
||||
* evaluated during runtime. For example a TLV list, or a list of "name=val"
|
||||
@@ -171,13 +171,15 @@ struct nvmem_cell_table {
|
||||
* cells.
|
||||
*/
|
||||
struct nvmem_layout {
|
||||
- const char *name;
|
||||
- const struct of_device_id *of_match_table;
|
||||
+ struct device dev;
|
||||
+ struct nvmem_device *nvmem;
|
||||
int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
+};
|
||||
|
||||
- /* private */
|
||||
- struct module *owner;
|
||||
- struct list_head node;
|
||||
+struct nvmem_layout_driver {
|
||||
+ struct device_driver driver;
|
||||
+ int (*probe)(struct nvmem_layout *layout);
|
||||
+ void (*remove)(struct nvmem_layout *layout);
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_NVMEM)
|
||||
@@ -194,11 +196,15 @@ void nvmem_del_cell_table(struct nvmem_c
|
||||
int nvmem_add_one_cell(struct nvmem_device *nvmem,
|
||||
const struct nvmem_cell_info *info);
|
||||
|
||||
-int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner);
|
||||
-#define nvmem_layout_register(layout) \
|
||||
- __nvmem_layout_register(layout, THIS_MODULE)
|
||||
+int nvmem_layout_register(struct nvmem_layout *layout);
|
||||
void nvmem_layout_unregister(struct nvmem_layout *layout);
|
||||
|
||||
+int nvmem_layout_driver_register(struct nvmem_layout_driver *drv);
|
||||
+void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv);
|
||||
+#define module_nvmem_layout_driver(__nvmem_layout_driver) \
|
||||
+ module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \
|
||||
+ nvmem_layout_driver_unregister)
|
||||
+
|
||||
const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout);
|
||||
|
||||
@@ -262,8 +268,4 @@ static inline struct device_node *of_nvm
|
||||
|
||||
#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
|
||||
-#define module_nvmem_layout_driver(__layout_driver) \
|
||||
- module_driver(__layout_driver, nvmem_layout_register, \
|
||||
- nvmem_layout_unregister)
|
||||
-
|
||||
#endif /* ifndef _LINUX_NVMEM_PROVIDER_H */
|
|
@ -0,0 +1,240 @@
|
|||
From 0331c611949fffdf486652450901a4dc52bc5cca Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:34 +0000
|
||||
Subject: [PATCH] nvmem: core: Expose cells through sysfs
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The binary content of nvmem devices is available to the user so in the
|
||||
easiest cases, finding the content of a cell is rather easy as it is
|
||||
just a matter of looking at a known and fixed offset. However, nvmem
|
||||
layouts have been recently introduced to cope with more advanced
|
||||
situations, where the offset and size of the cells is not known in
|
||||
advance or is dynamic. When using layouts, more advanced parsers are
|
||||
used by the kernel in order to give direct access to the content of each
|
||||
cell, regardless of its position/size in the underlying
|
||||
device. Unfortunately, these information are not accessible by users,
|
||||
unless by fully re-implementing the parser logic in userland.
|
||||
|
||||
Let's expose the cells and their content through sysfs to avoid these
|
||||
situations. Of course the relevant NVMEM sysfs Kconfig option must be
|
||||
enabled for this support to be available.
|
||||
|
||||
Not all nvmem devices expose cells. Indeed, the .bin_attrs attribute
|
||||
group member will be filled at runtime only when relevant and will
|
||||
remain empty otherwise. In this case, as the cells attribute group will
|
||||
be empty, it will not lead to any additional folder/file creation.
|
||||
|
||||
Exposed cells are read-only. There is, in practice, everything in the
|
||||
core to support a write path, but as I don't see any need for that, I
|
||||
prefer to keep the interface simple (and probably safer). The interface
|
||||
is documented as being in the "testing" state which means we can later
|
||||
add a write attribute if though relevant.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-9-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 135 +++++++++++++++++++++++++++++++++++++-
|
||||
drivers/nvmem/internals.h | 1 +
|
||||
2 files changed, 135 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -300,6 +300,43 @@ static umode_t nvmem_bin_attr_is_visible
|
||||
return nvmem_bin_attr_get_umode(nvmem);
|
||||
}
|
||||
|
||||
+static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry,
|
||||
+ const char *id, int index);
|
||||
+
|
||||
+static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
|
||||
+ struct bin_attribute *attr, char *buf,
|
||||
+ loff_t pos, size_t count)
|
||||
+{
|
||||
+ struct nvmem_cell_entry *entry;
|
||||
+ struct nvmem_cell *cell = NULL;
|
||||
+ size_t cell_sz, read_len;
|
||||
+ void *content;
|
||||
+
|
||||
+ entry = attr->private;
|
||||
+ cell = nvmem_create_cell(entry, entry->name, 0);
|
||||
+ if (IS_ERR(cell))
|
||||
+ return PTR_ERR(cell);
|
||||
+
|
||||
+ if (!cell)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ content = nvmem_cell_read(cell, &cell_sz);
|
||||
+ if (IS_ERR(content)) {
|
||||
+ read_len = PTR_ERR(content);
|
||||
+ goto destroy_cell;
|
||||
+ }
|
||||
+
|
||||
+ read_len = min_t(unsigned int, cell_sz - pos, count);
|
||||
+ memcpy(buf, content + pos, read_len);
|
||||
+ kfree(content);
|
||||
+
|
||||
+destroy_cell:
|
||||
+ kfree_const(cell->id);
|
||||
+ kfree(cell);
|
||||
+
|
||||
+ return read_len;
|
||||
+}
|
||||
+
|
||||
/* default read/write permissions */
|
||||
static struct bin_attribute bin_attr_rw_nvmem = {
|
||||
.attr = {
|
||||
@@ -321,11 +358,21 @@ static const struct attribute_group nvme
|
||||
.is_bin_visible = nvmem_bin_attr_is_visible,
|
||||
};
|
||||
|
||||
+/* Cell attributes will be dynamically allocated */
|
||||
+static struct attribute_group nvmem_cells_group = {
|
||||
+ .name = "cells",
|
||||
+};
|
||||
+
|
||||
static const struct attribute_group *nvmem_dev_groups[] = {
|
||||
&nvmem_bin_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
+static const struct attribute_group *nvmem_cells_groups[] = {
|
||||
+ &nvmem_cells_group,
|
||||
+ NULL,
|
||||
+};
|
||||
+
|
||||
static struct bin_attribute bin_attr_nvmem_eeprom_compat = {
|
||||
.attr = {
|
||||
.name = "eeprom",
|
||||
@@ -381,6 +428,68 @@ static void nvmem_sysfs_remove_compat(st
|
||||
device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
|
||||
}
|
||||
|
||||
+static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct bin_attribute **cells_attrs, *attrs;
|
||||
+ struct nvmem_cell_entry *entry;
|
||||
+ unsigned int ncells = 0, i = 0;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ mutex_lock(&nvmem_mutex);
|
||||
+
|
||||
+ if (list_empty(&nvmem->cells) || nvmem->sysfs_cells_populated) {
|
||||
+ nvmem_cells_group.bin_attrs = NULL;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ /* Allocate an array of attributes with a sentinel */
|
||||
+ ncells = list_count_nodes(&nvmem->cells);
|
||||
+ cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
|
||||
+ sizeof(struct bin_attribute *), GFP_KERNEL);
|
||||
+ if (!cells_attrs) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ attrs = devm_kcalloc(&nvmem->dev, ncells, sizeof(struct bin_attribute), GFP_KERNEL);
|
||||
+ if (!attrs) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ /* Initialize each attribute to take the name and size of the cell */
|
||||
+ list_for_each_entry(entry, &nvmem->cells, node) {
|
||||
+ sysfs_bin_attr_init(&attrs[i]);
|
||||
+ attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL,
|
||||
+ "%s@%x", entry->name,
|
||||
+ entry->offset);
|
||||
+ attrs[i].attr.mode = 0444;
|
||||
+ attrs[i].size = entry->bytes;
|
||||
+ attrs[i].read = &nvmem_cell_attr_read;
|
||||
+ attrs[i].private = entry;
|
||||
+ if (!attrs[i].attr.name) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ cells_attrs[i] = &attrs[i];
|
||||
+ i++;
|
||||
+ }
|
||||
+
|
||||
+ nvmem_cells_group.bin_attrs = cells_attrs;
|
||||
+
|
||||
+ ret = devm_device_add_groups(&nvmem->dev, nvmem_cells_groups);
|
||||
+ if (ret)
|
||||
+ goto unlock_mutex;
|
||||
+
|
||||
+ nvmem->sysfs_cells_populated = true;
|
||||
+
|
||||
+unlock_mutex:
|
||||
+ mutex_unlock(&nvmem_mutex);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
#else /* CONFIG_NVMEM_SYSFS */
|
||||
|
||||
static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
|
||||
@@ -740,11 +849,25 @@ static int nvmem_add_cells_from_fixed_la
|
||||
|
||||
int nvmem_layout_register(struct nvmem_layout *layout)
|
||||
{
|
||||
+ int ret;
|
||||
+
|
||||
if (!layout->add_cells)
|
||||
return -EINVAL;
|
||||
|
||||
/* Populate the cells */
|
||||
- return layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
+ ret = layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+ ret = nvmem_populate_sysfs_cells(layout->nvmem);
|
||||
+ if (ret) {
|
||||
+ nvmem_device_remove_all_cells(layout->nvmem);
|
||||
+ return ret;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_layout_register);
|
||||
|
||||
@@ -903,10 +1026,20 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_dev;
|
||||
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+ rval = nvmem_populate_sysfs_cells(nvmem);
|
||||
+ if (rval)
|
||||
+ goto err_destroy_layout;
|
||||
+#endif
|
||||
+
|
||||
blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
|
||||
|
||||
return nvmem;
|
||||
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+err_destroy_layout:
|
||||
+ nvmem_destroy_layout(nvmem);
|
||||
+#endif
|
||||
err_remove_dev:
|
||||
device_del(&nvmem->dev);
|
||||
err_remove_cells:
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -32,6 +32,7 @@ struct nvmem_device {
|
||||
struct gpio_desc *wp_gpio;
|
||||
struct nvmem_layout *layout;
|
||||
void *priv;
|
||||
+ bool sysfs_cells_populated;
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_OF)
|
|
@ -0,0 +1,65 @@
|
|||
From f0ac5b23039610619ca4a4805528553ecb6bc815 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:36 +0000
|
||||
Subject: [PATCH] nvmem: stm32: add support for STM32MP25 BSEC to control OTP
|
||||
data
|
||||
|
||||
On STM32MP25, OTP area may be read/written by using BSEC (boot, security
|
||||
and OTP control). The BSEC internal peripheral is only managed by the
|
||||
secure world.
|
||||
|
||||
The 12 Kbits of OTP (effective) are organized into the following regions:
|
||||
- lower OTP (OTP0 to OTP127) = 4096 lower OTP bits,
|
||||
bitwise (1-bit) programmable
|
||||
- mid OTP (OTP128 to OTP255) = 4096 middle OTP bits,
|
||||
bulk (32-bit) programmable
|
||||
- upper OTP (OTP256 to OTP383) = 4096 upper OTP bits,
|
||||
bulk (32-bit) programmable,
|
||||
only accessible when BSEC is in closed state.
|
||||
|
||||
As HWKEY and ECIES key are only accessible by ROM code;
|
||||
only 368 OTP words are managed in this driver (OTP0 to OTP267).
|
||||
|
||||
This patch adds the STM32MP25 configuration for reading and writing
|
||||
the OTP data using the OP-TEE BSEC TA services.
|
||||
|
||||
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-11-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/stm32-romem.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
--- a/drivers/nvmem/stm32-romem.c
|
||||
+++ b/drivers/nvmem/stm32-romem.c
|
||||
@@ -269,6 +269,19 @@ static const struct stm32_romem_cfg stm3
|
||||
.ta = true,
|
||||
};
|
||||
|
||||
+/*
|
||||
+ * STM32MP25 BSEC OTP: 3 regions of 32-bits data words
|
||||
+ * lower OTP (OTP0 to OTP127), bitwise (1-bit) programmable
|
||||
+ * mid OTP (OTP128 to OTP255), bulk (32-bit) programmable
|
||||
+ * upper OTP (OTP256 to OTP383), bulk (32-bit) programmable
|
||||
+ * but no access to HWKEY and ECIES key: limited at OTP367
|
||||
+ */
|
||||
+static const struct stm32_romem_cfg stm32mp25_bsec_cfg = {
|
||||
+ .size = 368 * 4,
|
||||
+ .lower = 127,
|
||||
+ .ta = true,
|
||||
+};
|
||||
+
|
||||
static const struct of_device_id stm32_romem_of_match[] __maybe_unused = {
|
||||
{ .compatible = "st,stm32f4-otp", }, {
|
||||
.compatible = "st,stm32mp15-bsec",
|
||||
@@ -276,6 +289,9 @@ static const struct of_device_id stm32_r
|
||||
}, {
|
||||
.compatible = "st,stm32mp13-bsec",
|
||||
.data = (void *)&stm32mp13_bsec_cfg,
|
||||
+ }, {
|
||||
+ .compatible = "st,stm32mp25-bsec",
|
||||
+ .data = (void *)&stm32mp25_bsec_cfg,
|
||||
},
|
||||
{ /* sentinel */ },
|
||||
};
|
|
@ -121,7 +121,7 @@ Signed-off-by: T.J. Mercier <tjmercier@google.com>
|
|||
static inline int lru_gen_from_seq(unsigned long seq)
|
||||
{
|
||||
return seq % MAX_NR_GENS;
|
||||
@@ -297,6 +309,11 @@ static inline bool lru_gen_in_fault(void
|
||||
@@ -302,6 +314,11 @@ static inline bool lru_gen_in_fault(void
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Signed-off-by: T.J. Mercier <tjmercier@google.com>
|
|||
|
||||
--- a/include/linux/mm_inline.h
|
||||
+++ b/include/linux/mm_inline.h
|
||||
@@ -595,4 +595,12 @@ pte_install_uffd_wp_if_needed(struct vm_
|
||||
@@ -600,4 +600,12 @@ pte_install_uffd_wp_if_needed(struct vm_
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ Signed-off-by: T.J. Mercier <tjmercier@google.com>
|
|||
|
||||
--- a/include/linux/mm_inline.h
|
||||
+++ b/include/linux/mm_inline.h
|
||||
@@ -600,6 +600,9 @@ static inline bool vma_has_recency(struc
|
||||
@@ -605,6 +605,9 @@ static inline bool vma_has_recency(struc
|
||||
if (vma->vm_flags & (VM_SEQ_READ | VM_RAND_READ))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ Signed-off-by: T.J. Mercier <tjmercier@google.com>
|
|||
static inline int lru_gen_from_seq(unsigned long seq)
|
||||
{
|
||||
return seq % MAX_NR_GENS;
|
||||
@@ -309,11 +297,6 @@ static inline bool lru_gen_in_fault(void
|
||||
@@ -314,11 +302,6 @@ static inline bool lru_gen_in_fault(void
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,229 +0,0 @@
|
|||
From ec51fbd1b8a2bca2948dede99c14ec63dc57ff6b Mon Sep 17 00:00:00 2001
|
||||
From: Bjørn Mork <bjorn@mork.no>
|
||||
Date: Fri, 6 Jan 2023 17:07:38 +0100
|
||||
Subject: [PATCH] r8152: add USB device driver for config selection
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Subclassing the generic USB device driver to override the
|
||||
default configuration selection regardless of matching interface
|
||||
drivers.
|
||||
|
||||
The r815x family devices expose a vendor specific function which
|
||||
the r8152 interface driver wants to handle. This is the preferred
|
||||
device mode. Additionally one or more USB class functions are
|
||||
usually supported for hosts lacking a vendor specific driver. The
|
||||
choice is USB configuration based, with one alternate function per
|
||||
configuration.
|
||||
|
||||
Example device with both NCM and ECM alternate cfgs:
|
||||
|
||||
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0
|
||||
D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 3
|
||||
P: Vendor=0bda ProdID=8156 Rev=31.00
|
||||
S: Manufacturer=Realtek
|
||||
S: Product=USB 10/100/1G/2.5G LAN
|
||||
S: SerialNumber=001000001
|
||||
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=256mA
|
||||
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=00 Driver=r8152
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 2 Ivl=128ms
|
||||
C: #Ifs= 2 Cfg#= 2 Atr=a0 MxPwr=256mA
|
||||
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
|
||||
I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=
|
||||
I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
C: #Ifs= 2 Cfg#= 3 Atr=a0 MxPwr=256mA
|
||||
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=
|
||||
E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=128ms
|
||||
I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=
|
||||
I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=
|
||||
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
|
||||
|
||||
A problem with this is that Linux will prefer class functions over
|
||||
vendor specific functions. Using the above example, Linux defaults
|
||||
to cfg #2, running the device in a sub-optimal NCM mode.
|
||||
|
||||
Previously we've attempted to work around the problem by
|
||||
blacklisting the devices in the ECM class driver "cdc_ether", and
|
||||
matching on the ECM class function in the vendor specific interface
|
||||
driver. The latter has been used to switch back to the vendor
|
||||
specific configuration when the driver is probed for a class
|
||||
function.
|
||||
|
||||
This workaround has several issues;
|
||||
- class driver blacklists is additional maintanence cruft in an
|
||||
unrelated driver
|
||||
- class driver blacklists prevents users from optionally running
|
||||
the devices in class mode
|
||||
- each device needs double match entries in the vendor driver
|
||||
- the initial probing as a class function slows down device
|
||||
discovery
|
||||
|
||||
Now these issues have become even worse with the introduction of
|
||||
firmware supporting both NCM and ECM, where NCM ends up as the
|
||||
default mode in Linux. To use the same workaround, we now have
|
||||
to blacklist the devices in to two different class drivers and
|
||||
add yet another match entry to the vendor specific driver.
|
||||
|
||||
This patch implements an alternative workaround strategy -
|
||||
independent of the interface drivers. It avoids adding a
|
||||
blacklist to the cdc_ncm driver and will let us remove the
|
||||
existing blacklist from the cdc_ether driver.
|
||||
|
||||
As an additional bonus, removing the blacklists allow users to
|
||||
select one of the other device modes if wanted.
|
||||
|
||||
Signed-off-by: Bjørn Mork <bjorn@mork.no>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 113 ++++++++++++++++++++++++++++------------
|
||||
1 file changed, 81 insertions(+), 32 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9661,6 +9661,9 @@ static int rtl8152_probe(struct usb_inte
|
||||
if (version == RTL_VER_UNKNOWN)
|
||||
return -ENODEV;
|
||||
|
||||
+ if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
if (!rtl_vendor_mode(intf))
|
||||
return -ENODEV;
|
||||
|
||||
@@ -9861,43 +9864,35 @@ static void rtl8152_disconnect(struct us
|
||||
}
|
||||
}
|
||||
|
||||
-#define REALTEK_USB_DEVICE(vend, prod) { \
|
||||
- USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC), \
|
||||
-}, \
|
||||
-{ \
|
||||
- USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_COMM, \
|
||||
- USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), \
|
||||
-}
|
||||
|
||||
/* table of devices that work with this driver */
|
||||
static const struct usb_device_id rtl8152_table[] = {
|
||||
/* Realtek */
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8053),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8155),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8156),
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8050) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8053) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8152) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8153) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8155) },
|
||||
+ { USB_DEVICE(VENDOR_ID_REALTEK, 0x8156) },
|
||||
|
||||
/* Microsoft */
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0c5e),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff),
|
||||
- REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601),
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab) },
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6) },
|
||||
+ { USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927) },
|
||||
+ { USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x304f) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3054) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3062) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3069) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x3082) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7205) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x720c) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x7214) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0x721e) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LENOVO, 0xa387) },
|
||||
+ { USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
|
||||
+ { USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
|
||||
+ { USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -9917,7 +9912,61 @@ static struct usb_driver rtl8152_driver
|
||||
.disable_hub_initiated_lpm = 1,
|
||||
};
|
||||
|
||||
-module_usb_driver(rtl8152_driver);
|
||||
+static int rtl8152_cfgselector_probe(struct usb_device *udev)
|
||||
+{
|
||||
+ struct usb_host_config *c;
|
||||
+ int i, num_configs;
|
||||
+
|
||||
+ /* The vendor mode is not always config #1, so to find it out. */
|
||||
+ c = udev->config;
|
||||
+ num_configs = udev->descriptor.bNumConfigurations;
|
||||
+ for (i = 0; i < num_configs; (i++, c++)) {
|
||||
+ struct usb_interface_descriptor *desc = NULL;
|
||||
+
|
||||
+ if (!c->desc.bNumInterfaces)
|
||||
+ continue;
|
||||
+ desc = &c->intf_cache[0]->altsetting->desc;
|
||||
+ if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (i == num_configs)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
|
||||
+ dev_err(&udev->dev, "Failed to set configuration %d\n",
|
||||
+ c->desc.bConfigurationValue);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct usb_device_driver rtl8152_cfgselector_driver = {
|
||||
+ .name = MODULENAME "-cfgselector",
|
||||
+ .probe = rtl8152_cfgselector_probe,
|
||||
+ .id_table = rtl8152_table,
|
||||
+ .generic_subclass = 1,
|
||||
+};
|
||||
+
|
||||
+static int __init rtl8152_driver_init(void)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ return usb_register(&rtl8152_driver);
|
||||
+}
|
||||
+
|
||||
+static void __exit rtl8152_driver_exit(void)
|
||||
+{
|
||||
+ usb_deregister(&rtl8152_driver);
|
||||
+ usb_deregister_device_driver(&rtl8152_cfgselector_driver);
|
||||
+}
|
||||
+
|
||||
+module_init(rtl8152_driver_init);
|
||||
+module_exit(rtl8152_driver_exit);
|
||||
|
||||
MODULE_AUTHOR(DRIVER_AUTHOR);
|
||||
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
@ -1,64 +0,0 @@
|
|||
From 0d4cda805a183bbe523f2407edb5c14ade50b841 Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Tue, 17 Jan 2023 11:03:44 +0800
|
||||
Subject: [PATCH] r8152: avoid to change cfg for all devices
|
||||
|
||||
The rtl8152_cfgselector_probe() should set the USB configuration to the
|
||||
vendor mode only for the devices which the driver (r8152) supports.
|
||||
Otherwise, no driver would be used for such devices.
|
||||
|
||||
Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Reviewed-by: Simon Horman <simon.horman@corigine.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 20 +++++++++++++++++---
|
||||
1 file changed, 17 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9542,9 +9542,8 @@ static int rtl_fw_init(struct r8152 *tp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-u8 rtl8152_get_version(struct usb_interface *intf)
|
||||
+static u8 __rtl_get_hw_ver(struct usb_device *udev)
|
||||
{
|
||||
- struct usb_device *udev = interface_to_usbdev(intf);
|
||||
u32 ocp_data = 0;
|
||||
__le32 *tmp;
|
||||
u8 version;
|
||||
@@ -9614,10 +9613,19 @@ u8 rtl8152_get_version(struct usb_interf
|
||||
break;
|
||||
default:
|
||||
version = RTL_VER_UNKNOWN;
|
||||
- dev_info(&intf->dev, "Unknown version 0x%04x\n", ocp_data);
|
||||
+ dev_info(&udev->dev, "Unknown version 0x%04x\n", ocp_data);
|
||||
break;
|
||||
}
|
||||
|
||||
+ return version;
|
||||
+}
|
||||
+
|
||||
+u8 rtl8152_get_version(struct usb_interface *intf)
|
||||
+{
|
||||
+ u8 version;
|
||||
+
|
||||
+ version = __rtl_get_hw_ver(interface_to_usbdev(intf));
|
||||
+
|
||||
dev_dbg(&intf->dev, "Detected version 0x%04x\n", version);
|
||||
|
||||
return version;
|
||||
@@ -9917,6 +9925,12 @@ static int rtl8152_cfgselector_probe(str
|
||||
struct usb_host_config *c;
|
||||
int i, num_configs;
|
||||
|
||||
+ /* Switch the device to vendor mode, if and only if the vendor mode
|
||||
+ * driver supports it.
|
||||
+ */
|
||||
+ if (__rtl_get_hw_ver(udev) == RTL_VER_UNKNOWN)
|
||||
+ return 0;
|
||||
+
|
||||
/* The vendor mode is not always config #1, so to find it out. */
|
||||
c = udev->config;
|
||||
num_configs = udev->descriptor.bNumConfigurations;
|
|
@ -1,71 +0,0 @@
|
|||
From 95a4c1d617b92cdc4522297741b56e8f6cd01a1e Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Thu, 19 Jan 2023 15:40:42 +0800
|
||||
Subject: [PATCH] r8152: remove rtl_vendor_mode function
|
||||
|
||||
After commit ec51fbd1b8a2 ("r8152: add USB device driver for
|
||||
config selection"), the code about changing USB configuration
|
||||
in rtl_vendor_mode() wouldn't be run anymore. Therefore, the
|
||||
function could be removed.
|
||||
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 39 +--------------------------------------
|
||||
1 file changed, 1 insertion(+), 38 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -8274,43 +8274,6 @@ static bool rtl_check_vendor_ok(struct u
|
||||
return true;
|
||||
}
|
||||
|
||||
-static bool rtl_vendor_mode(struct usb_interface *intf)
|
||||
-{
|
||||
- struct usb_host_interface *alt = intf->cur_altsetting;
|
||||
- struct usb_device *udev;
|
||||
- struct usb_host_config *c;
|
||||
- int i, num_configs;
|
||||
-
|
||||
- if (alt->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC)
|
||||
- return rtl_check_vendor_ok(intf);
|
||||
-
|
||||
- /* The vendor mode is not always config #1, so to find it out. */
|
||||
- udev = interface_to_usbdev(intf);
|
||||
- c = udev->config;
|
||||
- num_configs = udev->descriptor.bNumConfigurations;
|
||||
- if (num_configs < 2)
|
||||
- return false;
|
||||
-
|
||||
- for (i = 0; i < num_configs; (i++, c++)) {
|
||||
- struct usb_interface_descriptor *desc = NULL;
|
||||
-
|
||||
- if (c->desc.bNumInterfaces > 0)
|
||||
- desc = &c->intf_cache[0]->altsetting->desc;
|
||||
- else
|
||||
- continue;
|
||||
-
|
||||
- if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
|
||||
- usb_driver_set_configuration(udev, c->desc.bConfigurationValue);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (i == num_configs)
|
||||
- dev_err(&intf->dev, "Unexpected Device\n");
|
||||
-
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
static int rtl8152_pre_reset(struct usb_interface *intf)
|
||||
{
|
||||
struct r8152 *tp = usb_get_intfdata(intf);
|
||||
@@ -9672,7 +9635,7 @@ static int rtl8152_probe(struct usb_inte
|
||||
if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
|
||||
return -ENODEV;
|
||||
|
||||
- if (!rtl_vendor_mode(intf))
|
||||
+ if (!rtl_check_vendor_ok(intf))
|
||||
return -ENODEV;
|
||||
|
||||
usb_reset_device(udev);
|
|
@ -18,7 +18,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9624,20 +9624,21 @@ static int rtl8152_probe(struct usb_inte
|
||||
@@ -9638,20 +9638,21 @@ static int rtl8152_probe(struct usb_inte
|
||||
const struct usb_device_id *id)
|
||||
{
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
From 0fbd79c01a9a657348f7032df70c57a406468c86 Mon Sep 17 00:00:00 2001
|
||||
From: Hayes Wang <hayeswang@realtek.com>
|
||||
Date: Tue, 2 May 2023 11:36:27 +0800
|
||||
Subject: [PATCH] r8152: fix the autosuspend doesn't work
|
||||
|
||||
Set supports_autosuspend = 1 for the rtl8152_cfgselector_driver.
|
||||
|
||||
Fixes: ec51fbd1b8a2 ("r8152: add USB device driver for config selection")
|
||||
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9925,6 +9925,7 @@ static struct usb_device_driver rtl8152_
|
||||
.probe = rtl8152_cfgselector_probe,
|
||||
.id_table = rtl8152_table,
|
||||
.generic_subclass = 1,
|
||||
+ .supports_autosuspend = 1,
|
||||
};
|
||||
|
||||
static int __init rtl8152_driver_init(void)
|
|
@ -15,7 +15,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -3984,29 +3984,10 @@ static void rtl_reset_bmu(struct r8152 *
|
||||
@@ -3990,29 +3990,10 @@ static void rtl_reset_bmu(struct r8152 *
|
||||
/* Clear the bp to stop the firmware before loading a new one */
|
||||
static void rtl_clear_bp(struct r8152 *tp, u16 type)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
case RTL_VER_08:
|
||||
case RTL_VER_09:
|
||||
case RTL_VER_10:
|
||||
@@ -4014,32 +3995,31 @@ static void rtl_clear_bp(struct r8152 *t
|
||||
@@ -4020,32 +4001,31 @@ static void rtl_clear_bp(struct r8152 *t
|
||||
case RTL_VER_12:
|
||||
case RTL_VER_13:
|
||||
case RTL_VER_15:
|
||||
|
@ -100,7 +100,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
/* wait 3 ms to make sure the firmware is stopped */
|
||||
usleep_range(3000, 6000);
|
||||
@@ -5016,10 +4996,9 @@ static void rtl8152_fw_phy_nc_apply(stru
|
||||
@@ -5022,10 +5002,9 @@ static void rtl8152_fw_phy_nc_apply(stru
|
||||
|
||||
static void rtl8152_fw_mac_apply(struct r8152 *tp, struct fw_mac *mac)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
switch (__le32_to_cpu(mac->blk_hdr.type)) {
|
||||
case RTL_FW_PLA:
|
||||
@@ -5061,12 +5040,8 @@ static void rtl8152_fw_mac_apply(struct
|
||||
@@ -5067,12 +5046,8 @@ static void rtl8152_fw_mac_apply(struct
|
||||
ocp_write_word(tp, type, __le16_to_cpu(mac->bp_ba_addr),
|
||||
__le16_to_cpu(mac->bp_ba_value));
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9770,8 +9770,7 @@ static int rtl8152_probe(struct usb_inte
|
||||
@@ -9784,8 +9784,7 @@ static int rtl8152_probe(struct usb_inte
|
||||
|
||||
usb_set_intfdata(intf, tp);
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
From 72f93a3136ee18fd59fa6579f84c07e93424681e Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Napolitano <anton@polit.no>
|
||||
Date: Sat, 26 Aug 2023 01:05:50 +0200
|
||||
Subject: [PATCH] r8152: add vendor/device ID pair for D-Link DUB-E250
|
||||
|
||||
The D-Link DUB-E250 is an RTL8156 based 2.5G Ethernet controller.
|
||||
|
||||
Add the vendor and product ID values to the driver. This makes Ethernet
|
||||
work with the adapter.
|
||||
|
||||
Signed-off-by: Antonio Napolitano <anton@polit.no>
|
||||
Link: https://lore.kernel.org/r/CV200KJEEUPC.WPKAHXCQJ05I@mercurius
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 1 +
|
||||
include/linux/usb/r8152.h | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
|
||||
--- a/include/linux/usb/r8152.h
|
||||
+++ b/include/linux/usb/r8152.h
|
||||
@@ -29,6 +29,7 @@
|
||||
#define VENDOR_ID_LINKSYS 0x13b1
|
||||
#define VENDOR_ID_NVIDIA 0x0955
|
||||
#define VENDOR_ID_TPLINK 0x2357
|
||||
+#define VENDOR_ID_DLINK 0x2001
|
||||
|
||||
#if IS_REACHABLE(CONFIG_USB_RTL8152)
|
||||
extern u8 rtl8152_get_version(struct usb_interface *intf);
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -9846,6 +9846,7 @@ static const struct usb_device_id rtl815
|
||||
{ USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
|
||||
{ USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
|
||||
{ USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
|
||||
+ { USB_DEVICE(VENDOR_ID_DLINK, 0xb301) },
|
||||
{}
|
||||
};
|
||||
|
|
@ -1,447 +0,0 @@
|
|||
From 715f67f33af45ce2cc3a5b1ef133cc8c8e7787b0 Mon Sep 17 00:00:00 2001
|
||||
From: Douglas Anderson <dianders@chromium.org>
|
||||
Date: Fri, 20 Oct 2023 14:06:58 -0700
|
||||
Subject: [PATCH] r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE
|
||||
|
||||
Whenever the RTL8152_UNPLUG is set that just tells the driver that all
|
||||
accesses will fail and we should just immediately bail. A future patch
|
||||
will use this same concept at a time when the driver hasn't actually
|
||||
been unplugged but is about to be reset. Rename the flag in
|
||||
preparation for the future patch.
|
||||
|
||||
This is a no-op change and just a search and replace.
|
||||
|
||||
Signed-off-by: Douglas Anderson <dianders@chromium.org>
|
||||
Reviewed-by: Grant Grundler <grundler@chromium.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/r8152.c | 96 ++++++++++++++++++++---------------------
|
||||
1 file changed, 48 insertions(+), 48 deletions(-)
|
||||
|
||||
--- a/drivers/net/usb/r8152.c
|
||||
+++ b/drivers/net/usb/r8152.c
|
||||
@@ -763,7 +763,7 @@ enum rtl_register_content {
|
||||
|
||||
/* rtl8152 flags */
|
||||
enum rtl8152_flags {
|
||||
- RTL8152_UNPLUG = 0,
|
||||
+ RTL8152_INACCESSIBLE = 0,
|
||||
RTL8152_SET_RX_MODE,
|
||||
WORK_ENABLE,
|
||||
RTL8152_LINK_CHG,
|
||||
@@ -1244,7 +1244,7 @@ int set_registers(struct r8152 *tp, u16
|
||||
static void rtl_set_unplug(struct r8152 *tp)
|
||||
{
|
||||
if (tp->udev->state == USB_STATE_NOTATTACHED) {
|
||||
- set_bit(RTL8152_UNPLUG, &tp->flags);
|
||||
+ set_bit(RTL8152_INACCESSIBLE, &tp->flags);
|
||||
smp_mb__after_atomic();
|
||||
}
|
||||
}
|
||||
@@ -1255,7 +1255,7 @@ static int generic_ocp_read(struct r8152
|
||||
u16 limit = 64;
|
||||
int ret = 0;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
@@ -1299,7 +1299,7 @@ static int generic_ocp_write(struct r815
|
||||
u16 byteen_start, byteen_end, byen;
|
||||
u16 limit = 512;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
/* both size and indix must be 4 bytes align */
|
||||
@@ -1536,7 +1536,7 @@ static int read_mii_word(struct net_devi
|
||||
struct r8152 *tp = netdev_priv(netdev);
|
||||
int ret;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
if (phy_id != R8152_PHY_ID)
|
||||
@@ -1552,7 +1552,7 @@ void write_mii_word(struct net_device *n
|
||||
{
|
||||
struct r8152 *tp = netdev_priv(netdev);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (phy_id != R8152_PHY_ID)
|
||||
@@ -1757,7 +1757,7 @@ static void read_bulk_callback(struct ur
|
||||
if (!tp)
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
@@ -1849,7 +1849,7 @@ static void write_bulk_callback(struct u
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!skb_queue_empty(&tp->tx_queue))
|
||||
@@ -1870,7 +1870,7 @@ static void intr_callback(struct urb *ur
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
return;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
switch (status) {
|
||||
@@ -2614,7 +2614,7 @@ static void bottom_half(struct tasklet_s
|
||||
{
|
||||
struct r8152 *tp = from_tasklet(tp, t, tx_tl);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (!test_bit(WORK_ENABLE, &tp->flags))
|
||||
@@ -2657,7 +2657,7 @@ int r8152_submit_rx(struct r8152 *tp, st
|
||||
int ret;
|
||||
|
||||
/* The rx would be stopped, so skip submitting */
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags) ||
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) ||
|
||||
!test_bit(WORK_ENABLE, &tp->flags) || !netif_carrier_ok(tp->netdev))
|
||||
return 0;
|
||||
|
||||
@@ -3057,7 +3057,7 @@ static int rtl_enable(struct r8152 *tp)
|
||||
|
||||
static int rtl8152_enable(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -3144,7 +3144,7 @@ static int rtl8153_enable(struct r8152 *
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -3176,7 +3176,7 @@ static void rtl_disable(struct r8152 *tp
|
||||
u32 ocp_data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -3630,7 +3630,7 @@ static u16 r8153_phy_status(struct r8152
|
||||
}
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3662,7 +3662,7 @@ static void r8153b_ups_en(struct r8152 *
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) &
|
||||
AUTOLOAD_DONE)
|
||||
@@ -3704,7 +3704,7 @@ static void r8153c_ups_en(struct r8152 *
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) &
|
||||
AUTOLOAD_DONE)
|
||||
@@ -4049,8 +4049,8 @@ static int rtl_phy_patch_request(struct
|
||||
for (i = 0; wait && i < 5000; i++) {
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
- break;
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
+ return -ENODEV;
|
||||
|
||||
usleep_range(1000, 2000);
|
||||
ocp_data = ocp_reg_read(tp, OCP_PHY_PATCH_STAT);
|
||||
@@ -6008,7 +6008,7 @@ static int rtl8156_enable(struct r8152 *
|
||||
u32 ocp_data;
|
||||
u16 speed;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
r8156_fc_parameter(tp);
|
||||
@@ -6066,7 +6066,7 @@ static int rtl8156b_enable(struct r8152
|
||||
u32 ocp_data;
|
||||
u16 speed;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
set_tx_qlen(tp);
|
||||
@@ -6252,7 +6252,7 @@ out:
|
||||
|
||||
static void rtl8152_up(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8152_aldps_en(tp, false);
|
||||
@@ -6262,7 +6262,7 @@ static void rtl8152_up(struct r8152 *tp)
|
||||
|
||||
static void rtl8152_down(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6277,7 +6277,7 @@ static void rtl8153_up(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_u1u2en(tp, false);
|
||||
@@ -6317,7 +6317,7 @@ static void rtl8153_down(struct r8152 *t
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6338,7 +6338,7 @@ static void rtl8153b_up(struct r8152 *tp
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6362,7 +6362,7 @@ static void rtl8153b_down(struct r8152 *
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6399,7 +6399,7 @@ static void rtl8153c_up(struct r8152 *tp
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6480,7 +6480,7 @@ static void rtl8156_up(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -6553,7 +6553,7 @@ static void rtl8156_down(struct r8152 *t
|
||||
{
|
||||
u32 ocp_data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
return;
|
||||
}
|
||||
@@ -6691,7 +6691,7 @@ static void rtl_work_func_t(struct work_
|
||||
/* If the device is unplugged or !netif_running(), the workqueue
|
||||
* doesn't need to wake the device, and could return directly.
|
||||
*/
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags) || !netif_running(tp->netdev))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags) || !netif_running(tp->netdev))
|
||||
return;
|
||||
|
||||
if (usb_autopm_get_interface(tp->intf) < 0)
|
||||
@@ -6730,7 +6730,7 @@ static void rtl_hw_phy_work_func_t(struc
|
||||
{
|
||||
struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work);
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (usb_autopm_get_interface(tp->intf) < 0)
|
||||
@@ -6857,7 +6857,7 @@ static int rtl8152_close(struct net_devi
|
||||
netif_stop_queue(netdev);
|
||||
|
||||
res = usb_autopm_get_interface(tp->intf);
|
||||
- if (res < 0 || test_bit(RTL8152_UNPLUG, &tp->flags)) {
|
||||
+ if (res < 0 || test_bit(RTL8152_INACCESSIBLE, &tp->flags)) {
|
||||
rtl_drop_queued_tx(tp);
|
||||
rtl_stop_rx(tp);
|
||||
} else {
|
||||
@@ -6890,7 +6890,7 @@ static void r8152b_init(struct r8152 *tp
|
||||
u32 ocp_data;
|
||||
u16 data;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
data = r8152_mdio_read(tp, MII_BMCR);
|
||||
@@ -6934,7 +6934,7 @@ static void r8153_init(struct r8152 *tp)
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_u1u2en(tp, false);
|
||||
@@ -6945,7 +6945,7 @@ static void r8153_init(struct r8152 *tp)
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7074,7 +7074,7 @@ static void r8153b_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -7085,7 +7085,7 @@ static void r8153b_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7156,7 +7156,7 @@ static void r8153c_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_u1u2en(tp, false);
|
||||
@@ -7176,7 +7176,7 @@ static void r8153c_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8005,7 +8005,7 @@ static void r8156_init(struct r8152 *tp)
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_ECM_OP);
|
||||
@@ -8026,7 +8026,7 @@ static void r8156_init(struct r8152 *tp)
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8101,7 +8101,7 @@ static void r8156b_init(struct r8152 *tp
|
||||
u16 data;
|
||||
int i;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_ECM_OP);
|
||||
@@ -8135,7 +8135,7 @@ static void r8156b_init(struct r8152 *tp
|
||||
break;
|
||||
|
||||
msleep(20);
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9164,7 +9164,7 @@ static int rtl8152_ioctl(struct net_devi
|
||||
struct mii_ioctl_data *data = if_mii(rq);
|
||||
int res;
|
||||
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return -ENODEV;
|
||||
|
||||
res = usb_autopm_get_interface(tp->intf);
|
||||
@@ -9266,7 +9266,7 @@ static const struct net_device_ops rtl81
|
||||
|
||||
static void rtl8152_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
if (tp->version != RTL_VER_01)
|
||||
@@ -9275,7 +9275,7 @@ static void rtl8152_unload(struct r8152
|
||||
|
||||
static void rtl8153_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153_power_cut_en(tp, false);
|
||||
@@ -9283,7 +9283,7 @@ static void rtl8153_unload(struct r8152
|
||||
|
||||
static void rtl8153b_unload(struct r8152 *tp)
|
||||
{
|
||||
- if (test_bit(RTL8152_UNPLUG, &tp->flags))
|
||||
+ if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
|
||||
return;
|
||||
|
||||
r8153b_power_cut_en(tp, false);
|
|
@ -232,7 +232,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
}
|
||||
|
||||
static int generic_ocp_read(struct r8152 *tp, u16 index, u16 size,
|
||||
@@ -8261,7 +8355,7 @@ static int rtl8152_pre_reset(struct usb_
|
||||
@@ -8275,7 +8369,7 @@ static int rtl8152_pre_reset(struct usb_
|
||||
struct r8152 *tp = usb_get_intfdata(intf);
|
||||
struct net_device *netdev;
|
||||
|
||||
|
@ -241,7 +241,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
return 0;
|
||||
|
||||
netdev = tp->netdev;
|
||||
@@ -8276,7 +8370,9 @@ static int rtl8152_pre_reset(struct usb_
|
||||
@@ -8290,7 +8384,9 @@ static int rtl8152_pre_reset(struct usb_
|
||||
napi_disable(&tp->napi);
|
||||
if (netif_carrier_ok(netdev)) {
|
||||
mutex_lock(&tp->control);
|
||||
|
@ -251,7 +251,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
mutex_unlock(&tp->control);
|
||||
}
|
||||
|
||||
@@ -8289,9 +8385,11 @@ static int rtl8152_post_reset(struct usb
|
||||
@@ -8303,9 +8399,11 @@ static int rtl8152_post_reset(struct usb
|
||||
struct net_device *netdev;
|
||||
struct sockaddr sa;
|
||||
|
||||
|
@ -264,7 +264,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
/* reset the MAC address in case of policy change */
|
||||
if (determine_ethernet_addr(tp, &sa) >= 0) {
|
||||
rtnl_lock();
|
||||
@@ -9493,17 +9591,29 @@ static u8 __rtl_get_hw_ver(struct usb_de
|
||||
@@ -9507,17 +9605,29 @@ static u8 __rtl_get_hw_ver(struct usb_de
|
||||
__le32 *tmp;
|
||||
u8 version;
|
||||
int ret;
|
||||
|
@ -300,7 +300,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
|
||||
kfree(tmp);
|
||||
|
||||
@@ -9602,25 +9712,14 @@ static bool rtl8152_supports_lenovo_macp
|
||||
@@ -9616,25 +9726,14 @@ static bool rtl8152_supports_lenovo_macp
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
usb_reset_device(udev);
|
||||
netdev = alloc_etherdev(sizeof(struct r8152));
|
||||
if (!netdev) {
|
||||
@@ -9783,10 +9882,20 @@ static int rtl8152_probe(struct usb_inte
|
||||
@@ -9797,10 +9896,20 @@ static int rtl8152_probe(struct usb_inte
|
||||
else
|
||||
device_set_wakeup_enable(&udev->dev, false);
|
||||
|
||||
|
@ -349,7 +349,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
|||
out1:
|
||||
tasklet_kill(&tp->tx_tl);
|
||||
cancel_delayed_work_sync(&tp->hw_phy_work);
|
||||
@@ -9795,10 +9904,46 @@ out1:
|
||||
@@ -9809,10 +9918,46 @@ out1:
|
||||
rtl8152_release_firmware(tp);
|
||||
usb_set_intfdata(intf, NULL);
|
||||
out:
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
From 4d70c74659d9746502b23d055dba03d1d28ec388 Mon Sep 17 00:00:00 2001
|
||||
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
Date: Wed, 30 Nov 2022 15:48:35 +0200
|
||||
Subject: [PATCH] i915: Move list_count() to list.h as list_count_nodes() for
|
||||
broader use
|
||||
|
||||
Some of the existing users, and definitely will be new ones, want to
|
||||
count existing nodes in the list. Provide a generic API for that by
|
||||
moving code from i915 to list.h.
|
||||
|
||||
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
|
||||
Acked-by: Jani Nikula <jani.nikula@intel.com>
|
||||
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
Link: https://lore.kernel.org/r/20221130134838.23805-1-andriy.shevchenko@linux.intel.com
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/gpu/drm/i915/gt/intel_engine_cs.c | 15 ++-------------
|
||||
include/linux/list.h | 15 +++++++++++++++
|
||||
2 files changed, 17 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
|
||||
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
|
||||
@@ -4154,17 +4154,6 @@ void intel_execlists_show_requests(struc
|
||||
spin_unlock_irqrestore(&sched_engine->lock, flags);
|
||||
}
|
||||
|
||||
-static unsigned long list_count(struct list_head *list)
|
||||
-{
|
||||
- struct list_head *pos;
|
||||
- unsigned long count = 0;
|
||||
-
|
||||
- list_for_each(pos, list)
|
||||
- count++;
|
||||
-
|
||||
- return count;
|
||||
-}
|
||||
-
|
||||
void intel_execlists_dump_active_requests(struct intel_engine_cs *engine,
|
||||
struct i915_request *hung_rq,
|
||||
struct drm_printer *m)
|
||||
@@ -4175,8 +4164,8 @@ void intel_execlists_dump_active_request
|
||||
|
||||
intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
|
||||
|
||||
- drm_printf(m, "\tOn hold?: %lu\n",
|
||||
- list_count(&engine->sched_engine->hold));
|
||||
+ drm_printf(m, "\tOn hold?: %zu\n",
|
||||
+ list_count_nodes(&engine->sched_engine->hold));
|
||||
|
||||
spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
|
||||
}
|
||||
--- a/include/linux/list.h
|
||||
+++ b/include/linux/list.h
|
||||
@@ -656,6 +656,21 @@ static inline void list_splice_tail_init
|
||||
pos = n, n = pos->prev)
|
||||
|
||||
/**
|
||||
+ * list_count_nodes - count nodes in the list
|
||||
+ * @head: the head for your list.
|
||||
+ */
|
||||
+static inline size_t list_count_nodes(struct list_head *head)
|
||||
+{
|
||||
+ struct list_head *pos;
|
||||
+ size_t count = 0;
|
||||
+
|
||||
+ list_for_each(pos, head)
|
||||
+ count++;
|
||||
+
|
||||
+ return count;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* list_entry_is_head - test if the entry points to the head of the list
|
||||
* @pos: the type * to cursor
|
||||
* @head: the head for your list.
|
|
@ -0,0 +1,45 @@
|
|||
From b7c1e53751cb3990153084f31c41f25fde3b629c Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 24 Nov 2023 20:38:14 +0100
|
||||
Subject: [PATCH] nvmem: Do not expect fixed layouts to grab a layout driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Two series lived in parallel for some time, which led to this situation:
|
||||
- The nvmem-layout container is used for dynamic layouts
|
||||
- We now expect fixed layouts to also use the nvmem-layout container but
|
||||
this does not require any additional driver, the support is built-in the
|
||||
nvmem core.
|
||||
|
||||
Ensure we don't refuse to probe for wrong reasons.
|
||||
|
||||
Fixes: 27f699e578b1 ("nvmem: core: add support for fixed cells *layout*")
|
||||
Cc: stable@vger.kernel.org
|
||||
Reported-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
|
||||
|
||||
Link: https://lore.kernel.org/r/20231124193814.360552-1-miquel.raynal@bootlin.com
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -797,6 +797,12 @@ static struct nvmem_layout *nvmem_layout
|
||||
if (!layout_np)
|
||||
return NULL;
|
||||
|
||||
+ /* Fixed layouts don't have a matching driver */
|
||||
+ if (of_device_is_compatible(layout_np, "fixed-layout")) {
|
||||
+ of_node_put(layout_np);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* In case the nvmem device was built-in while the layout was built as a
|
||||
* module, we shall manually request the layout driver loading otherwise
|
|
@ -1,5 +1,6 @@
|
|||
From 1e37bf84afacd5ba17b7a13a18ca2bc78aff05c0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Thu, 14 Sep 2023 07:59:09 +0200
|
||||
Date: Fri, 15 Dec 2023 11:13:58 +0000
|
||||
Subject: [PATCH] nvmem: brcm_nvram: store a copy of NVRAM content
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
@ -21,11 +22,15 @@ allocating so much memory check for actual data length.
|
|||
|
||||
Link: https://lore.kernel.org/linux-mtd/CACna6rwf3_9QVjYcM+847biTX=K0EoWXuXcSMkJO1Vy_5vmVqA@mail.gmail.com/
|
||||
Fixes: 3fef9ed0627a ("nvmem: brcm_nvram: new driver exposing Broadcom's NVRAM")
|
||||
Cc: <Stable@vger.kernel.org>
|
||||
Cc: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Cc: Scott Branden <scott.branden@broadcom.com>
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111358.316727-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/brcm_nvram.c | 134 ++++++++++++++++++++++++++-----------
|
||||
1 file changed, 94 insertions(+), 40 deletions(-)
|
|
@ -0,0 +1,140 @@
|
|||
From 7f38b70042fcaa49219045bd1a9a2836e27a58ac Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:27 +0000
|
||||
Subject: [PATCH] of: device: Export of_device_make_bus_id()
|
||||
|
||||
This helper is really handy to create unique device names based on their
|
||||
device tree path, we may need it outside of the OF core (in the NVMEM
|
||||
subsystem) so let's export it. As this helper has nothing patform
|
||||
specific, let's move it to of/device.c instead of of/platform.c so we
|
||||
can add its prototype to of_device.h.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Acked-by: Rob Herring <robh@kernel.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-2-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/of/device.c | 41 +++++++++++++++++++++++++++++++++++++++
|
||||
drivers/of/platform.c | 40 --------------------------------------
|
||||
include/linux/of_device.h | 6 ++++++
|
||||
3 files changed, 47 insertions(+), 40 deletions(-)
|
||||
|
||||
--- a/drivers/of/device.c
|
||||
+++ b/drivers/of/device.c
|
||||
@@ -395,3 +395,44 @@ int of_device_uevent_modalias(struct dev
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_device_uevent_modalias);
|
||||
+
|
||||
+/**
|
||||
+ * of_device_make_bus_id - Use the device node data to assign a unique name
|
||||
+ * @dev: pointer to device structure that is linked to a device tree node
|
||||
+ *
|
||||
+ * This routine will first try using the translated bus address to
|
||||
+ * derive a unique name. If it cannot, then it will prepend names from
|
||||
+ * parent nodes until a unique name can be derived.
|
||||
+ */
|
||||
+void of_device_make_bus_id(struct device *dev)
|
||||
+{
|
||||
+ struct device_node *node = dev->of_node;
|
||||
+ const __be32 *reg;
|
||||
+ u64 addr;
|
||||
+ u32 mask;
|
||||
+
|
||||
+ /* Construct the name, using parent nodes if necessary to ensure uniqueness */
|
||||
+ while (node->parent) {
|
||||
+ /*
|
||||
+ * If the address can be translated, then that is as much
|
||||
+ * uniqueness as we need. Make it the first component and return
|
||||
+ */
|
||||
+ reg = of_get_property(node, "reg", NULL);
|
||||
+ if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) {
|
||||
+ if (!of_property_read_u32(node, "mask", &mask))
|
||||
+ dev_set_name(dev, dev_name(dev) ? "%llx.%x.%pOFn:%s" : "%llx.%x.%pOFn",
|
||||
+ addr, ffs(mask) - 1, node, dev_name(dev));
|
||||
+
|
||||
+ else
|
||||
+ dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn",
|
||||
+ addr, node, dev_name(dev));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* format arguments only used if dev_name() resolves to NULL */
|
||||
+ dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s",
|
||||
+ kbasename(node->full_name), dev_name(dev));
|
||||
+ node = node->parent;
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(of_device_make_bus_id);
|
||||
--- a/drivers/of/platform.c
|
||||
+++ b/drivers/of/platform.c
|
||||
@@ -64,46 +64,6 @@ EXPORT_SYMBOL(of_find_device_by_node);
|
||||
*/
|
||||
|
||||
/**
|
||||
- * of_device_make_bus_id - Use the device node data to assign a unique name
|
||||
- * @dev: pointer to device structure that is linked to a device tree node
|
||||
- *
|
||||
- * This routine will first try using the translated bus address to
|
||||
- * derive a unique name. If it cannot, then it will prepend names from
|
||||
- * parent nodes until a unique name can be derived.
|
||||
- */
|
||||
-static void of_device_make_bus_id(struct device *dev)
|
||||
-{
|
||||
- struct device_node *node = dev->of_node;
|
||||
- const __be32 *reg;
|
||||
- u64 addr;
|
||||
- u32 mask;
|
||||
-
|
||||
- /* Construct the name, using parent nodes if necessary to ensure uniqueness */
|
||||
- while (node->parent) {
|
||||
- /*
|
||||
- * If the address can be translated, then that is as much
|
||||
- * uniqueness as we need. Make it the first component and return
|
||||
- */
|
||||
- reg = of_get_property(node, "reg", NULL);
|
||||
- if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) {
|
||||
- if (!of_property_read_u32(node, "mask", &mask))
|
||||
- dev_set_name(dev, dev_name(dev) ? "%llx.%x.%pOFn:%s" : "%llx.%x.%pOFn",
|
||||
- addr, ffs(mask) - 1, node, dev_name(dev));
|
||||
-
|
||||
- else
|
||||
- dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn",
|
||||
- addr, node, dev_name(dev));
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- /* format arguments only used if dev_name() resolves to NULL */
|
||||
- dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s",
|
||||
- kbasename(node->full_name), dev_name(dev));
|
||||
- node = node->parent;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
* of_device_alloc - Allocate and initialize an of_device
|
||||
* @np: device node to assign to device
|
||||
* @bus_id: Name to assign to the device. May be null to use default name.
|
||||
--- a/include/linux/of_device.h
|
||||
+++ b/include/linux/of_device.h
|
||||
@@ -56,6 +56,9 @@ static inline int of_dma_configure(struc
|
||||
{
|
||||
return of_dma_configure_id(dev, np, force_dma, NULL);
|
||||
}
|
||||
+
|
||||
+void of_device_make_bus_id(struct device *dev);
|
||||
+
|
||||
#else /* CONFIG_OF */
|
||||
|
||||
static inline int of_driver_match_device(struct device *dev,
|
||||
@@ -113,6 +116,9 @@ static inline int of_dma_configure(struc
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+static inline void of_device_make_bus_id(struct device *dev) {}
|
||||
+
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
#endif /* _LINUX_OF_DEVICE_H */
|
|
@ -0,0 +1,95 @@
|
|||
From 4a1a40233b4a9fc159a5c7a27dc34c5c7bc5be55 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:28 +0000
|
||||
Subject: [PATCH] nvmem: Move of_nvmem_layout_get_container() in another header
|
||||
|
||||
nvmem-consumer.h is included by consumer devices, extracting data from
|
||||
NVMEM devices whereas nvmem-provider.h is included by devices providing
|
||||
NVMEM content.
|
||||
|
||||
The only users of of_nvmem_layout_get_container() outside of the core
|
||||
are layout drivers, so better move its prototype to nvmem-provider.h.
|
||||
|
||||
While we do so, we also move the kdoc associated with the function to
|
||||
the header rather than the .c file.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 8 --------
|
||||
include/linux/nvmem-consumer.h | 7 -------
|
||||
include/linux/nvmem-provider.h | 21 +++++++++++++++++++++
|
||||
3 files changed, 21 insertions(+), 15 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -848,14 +848,6 @@ static int nvmem_add_cells_from_layout(s
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_OF)
|
||||
-/**
|
||||
- * of_nvmem_layout_get_container() - Get OF node to layout container.
|
||||
- *
|
||||
- * @nvmem: nvmem device.
|
||||
- *
|
||||
- * Return: a node pointer with refcount incremented or NULL if no
|
||||
- * container exists. Use of_node_put() on it when done.
|
||||
- */
|
||||
struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
{
|
||||
return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
--- a/include/linux/nvmem-consumer.h
|
||||
+++ b/include/linux/nvmem-consumer.h
|
||||
@@ -241,7 +241,6 @@ struct nvmem_cell *of_nvmem_cell_get(str
|
||||
const char *id);
|
||||
struct nvmem_device *of_nvmem_device_get(struct device_node *np,
|
||||
const char *name);
|
||||
-struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
|
||||
#else
|
||||
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
|
||||
const char *id)
|
||||
@@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv
|
||||
{
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
-
|
||||
-static inline struct device_node *
|
||||
-of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- return NULL;
|
||||
-}
|
||||
#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
|
||||
#endif /* ifndef _LINUX_NVMEM_CONSUMER_H */
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -244,6 +244,27 @@ nvmem_layout_get_match_data(struct nvmem
|
||||
|
||||
#endif /* CONFIG_NVMEM */
|
||||
|
||||
+#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
|
||||
+
|
||||
+/**
|
||||
+ * of_nvmem_layout_get_container() - Get OF node of layout container
|
||||
+ *
|
||||
+ * @nvmem: nvmem device
|
||||
+ *
|
||||
+ * Return: a node pointer with refcount incremented or NULL if no
|
||||
+ * container exists. Use of_node_put() on it when done.
|
||||
+ */
|
||||
+struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem);
|
||||
+
|
||||
+#else /* CONFIG_NVMEM && CONFIG_OF */
|
||||
+
|
||||
+static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
+
|
||||
#define module_nvmem_layout_driver(__layout_driver) \
|
||||
module_driver(__layout_driver, nvmem_layout_register, \
|
||||
nvmem_layout_unregister)
|
|
@ -0,0 +1,91 @@
|
|||
From ec9c08a1cb8dc5e8e003f95f5f62de41dde235bb Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:29 +0000
|
||||
Subject: [PATCH] nvmem: Create a header for internal sharing
|
||||
|
||||
Before adding all the NVMEM layout bus infrastructure to the core, let's
|
||||
move the main nvmem_device structure in an internal header, only
|
||||
available to the core. This way all the additional code can be added in
|
||||
a dedicated file in order to keep the current core file tidy.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-4-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 24 +-----------------------
|
||||
drivers/nvmem/internals.h | 35 +++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 36 insertions(+), 23 deletions(-)
|
||||
create mode 100644 drivers/nvmem/internals.h
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -20,29 +20,7 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
-struct nvmem_device {
|
||||
- struct module *owner;
|
||||
- struct device dev;
|
||||
- int stride;
|
||||
- int word_size;
|
||||
- int id;
|
||||
- struct kref refcnt;
|
||||
- size_t size;
|
||||
- bool read_only;
|
||||
- bool root_only;
|
||||
- int flags;
|
||||
- enum nvmem_type type;
|
||||
- struct bin_attribute eeprom;
|
||||
- struct device *base_dev;
|
||||
- struct list_head cells;
|
||||
- const struct nvmem_keepout *keepout;
|
||||
- unsigned int nkeepout;
|
||||
- nvmem_reg_read_t reg_read;
|
||||
- nvmem_reg_write_t reg_write;
|
||||
- struct gpio_desc *wp_gpio;
|
||||
- struct nvmem_layout *layout;
|
||||
- void *priv;
|
||||
-};
|
||||
+#include "internals.h"
|
||||
|
||||
#define to_nvmem_device(d) container_of(d, struct nvmem_device, dev)
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -0,0 +1,35 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+
|
||||
+#ifndef _LINUX_NVMEM_INTERNALS_H
|
||||
+#define _LINUX_NVMEM_INTERNALS_H
|
||||
+
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/nvmem-consumer.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+
|
||||
+struct nvmem_device {
|
||||
+ struct module *owner;
|
||||
+ struct device dev;
|
||||
+ struct list_head node;
|
||||
+ int stride;
|
||||
+ int word_size;
|
||||
+ int id;
|
||||
+ struct kref refcnt;
|
||||
+ size_t size;
|
||||
+ bool read_only;
|
||||
+ bool root_only;
|
||||
+ int flags;
|
||||
+ enum nvmem_type type;
|
||||
+ struct bin_attribute eeprom;
|
||||
+ struct device *base_dev;
|
||||
+ struct list_head cells;
|
||||
+ const struct nvmem_keepout *keepout;
|
||||
+ unsigned int nkeepout;
|
||||
+ nvmem_reg_read_t reg_read;
|
||||
+ nvmem_reg_write_t reg_write;
|
||||
+ struct gpio_desc *wp_gpio;
|
||||
+ struct nvmem_layout *layout;
|
||||
+ void *priv;
|
||||
+};
|
||||
+
|
||||
+#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */
|
|
@ -0,0 +1,79 @@
|
|||
From 1b7c298a4ecbc28cc6ee94005734bff55eb83d22 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:30 +0000
|
||||
Subject: [PATCH] nvmem: Simplify the ->add_cells() hook
|
||||
|
||||
The layout entry is not used and will anyway be made useless by the new
|
||||
layout bus infrastructure coming next, so drop it. While at it, clarify
|
||||
the kdoc entry.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-5-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 2 +-
|
||||
drivers/nvmem/layouts/onie-tlv.c | 3 +--
|
||||
drivers/nvmem/layouts/sl28vpd.c | 3 +--
|
||||
include/linux/nvmem-provider.h | 8 +++-----
|
||||
4 files changed, 6 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -817,7 +817,7 @@ static int nvmem_add_cells_from_layout(s
|
||||
int ret;
|
||||
|
||||
if (layout && layout->add_cells) {
|
||||
- ret = layout->add_cells(&nvmem->dev, nvmem, layout);
|
||||
+ ret = layout->add_cells(&nvmem->dev, nvmem);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
--- a/drivers/nvmem/layouts/onie-tlv.c
|
||||
+++ b/drivers/nvmem/layouts/onie-tlv.c
|
||||
@@ -182,8 +182,7 @@ static bool onie_tlv_crc_is_valid(struct
|
||||
return true;
|
||||
}
|
||||
|
||||
-static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout)
|
||||
+static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *nvmem)
|
||||
{
|
||||
struct onie_tlv_hdr hdr;
|
||||
size_t table_len, data_len, hdr_len;
|
||||
--- a/drivers/nvmem/layouts/sl28vpd.c
|
||||
+++ b/drivers/nvmem/layouts/sl28vpd.c
|
||||
@@ -80,8 +80,7 @@ static int sl28vpd_v1_check_crc(struct d
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int sl28vpd_add_cells(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout)
|
||||
+static int sl28vpd_add_cells(struct device *dev, struct nvmem_device *nvmem)
|
||||
{
|
||||
const struct nvmem_cell_info *pinfo;
|
||||
struct nvmem_cell_info info = {0};
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -156,9 +156,8 @@ struct nvmem_cell_table {
|
||||
*
|
||||
* @name: Layout name.
|
||||
* @of_match_table: Open firmware match table.
|
||||
- * @add_cells: Will be called if a nvmem device is found which
|
||||
- * has this layout. The function will add layout
|
||||
- * specific cells with nvmem_add_one_cell().
|
||||
+ * @add_cells: Called to populate the layout using
|
||||
+ * nvmem_add_one_cell().
|
||||
* @fixup_cell_info: Will be called before a cell is added. Can be
|
||||
* used to modify the nvmem_cell_info.
|
||||
* @owner: Pointer to struct module.
|
||||
@@ -172,8 +171,7 @@ struct nvmem_cell_table {
|
||||
struct nvmem_layout {
|
||||
const char *name;
|
||||
const struct of_device_id *of_match_table;
|
||||
- int (*add_cells)(struct device *dev, struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout);
|
||||
+ int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
void (*fixup_cell_info)(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout,
|
||||
struct nvmem_cell_info *cell);
|
|
@ -0,0 +1,169 @@
|
|||
From 1172460e716784ac7e1049a537bdca8edbf97360 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:31 +0000
|
||||
Subject: [PATCH] nvmem: Move and rename ->fixup_cell_info()
|
||||
|
||||
This hook is meant to be used by any provider and instantiating a layout
|
||||
just for this is useless. Let's instead move this hook to the nvmem
|
||||
device and add it to the config structure to be easily shared by the
|
||||
providers.
|
||||
|
||||
While at moving this hook, rename it ->fixup_dt_cell_info() to clarify
|
||||
its main intended purpose.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-6-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 6 +++---
|
||||
drivers/nvmem/imx-ocotp.c | 11 +++--------
|
||||
drivers/nvmem/internals.h | 2 ++
|
||||
drivers/nvmem/mtk-efuse.c | 11 +++--------
|
||||
include/linux/nvmem-provider.h | 9 ++++-----
|
||||
5 files changed, 15 insertions(+), 24 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -676,7 +676,6 @@ static int nvmem_validate_keepouts(struc
|
||||
|
||||
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
|
||||
{
|
||||
- struct nvmem_layout *layout = nvmem->layout;
|
||||
struct device *dev = &nvmem->dev;
|
||||
struct device_node *child;
|
||||
const __be32 *addr;
|
||||
@@ -706,8 +705,8 @@ static int nvmem_add_cells_from_dt(struc
|
||||
|
||||
info.np = of_node_get(child);
|
||||
|
||||
- if (layout && layout->fixup_cell_info)
|
||||
- layout->fixup_cell_info(nvmem, layout, &info);
|
||||
+ if (nvmem->fixup_dt_cell_info)
|
||||
+ nvmem->fixup_dt_cell_info(nvmem, &info);
|
||||
|
||||
ret = nvmem_add_one_cell(nvmem, &info);
|
||||
kfree(info.name);
|
||||
@@ -896,6 +895,7 @@ struct nvmem_device *nvmem_register(cons
|
||||
|
||||
kref_init(&nvmem->refcnt);
|
||||
INIT_LIST_HEAD(&nvmem->cells);
|
||||
+ nvmem->fixup_dt_cell_info = config->fixup_dt_cell_info;
|
||||
|
||||
nvmem->owner = config->owner;
|
||||
if (!nvmem->owner && config->dev->driver)
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -584,17 +584,12 @@ static const struct of_device_id imx_oco
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
|
||||
|
||||
-static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell)
|
||||
+static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell)
|
||||
{
|
||||
cell->read_post_process = imx_ocotp_cell_pp;
|
||||
}
|
||||
|
||||
-static struct nvmem_layout imx_ocotp_layout = {
|
||||
- .fixup_cell_info = imx_ocotp_fixup_cell_info,
|
||||
-};
|
||||
-
|
||||
static int imx_ocotp_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -620,7 +615,7 @@ static int imx_ocotp_probe(struct platfo
|
||||
imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
|
||||
imx_ocotp_nvmem_config.dev = dev;
|
||||
imx_ocotp_nvmem_config.priv = priv;
|
||||
- imx_ocotp_nvmem_config.layout = &imx_ocotp_layout;
|
||||
+ imx_ocotp_nvmem_config.fixup_dt_cell_info = &imx_ocotp_fixup_dt_cell_info;
|
||||
|
||||
priv->config = &imx_ocotp_nvmem_config;
|
||||
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -23,6 +23,8 @@ struct nvmem_device {
|
||||
struct bin_attribute eeprom;
|
||||
struct device *base_dev;
|
||||
struct list_head cells;
|
||||
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell);
|
||||
const struct nvmem_keepout *keepout;
|
||||
unsigned int nkeepout;
|
||||
nvmem_reg_read_t reg_read;
|
||||
--- a/drivers/nvmem/mtk-efuse.c
|
||||
+++ b/drivers/nvmem/mtk-efuse.c
|
||||
@@ -45,9 +45,8 @@ static int mtk_efuse_gpu_speedbin_pp(voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void mtk_efuse_fixup_cell_info(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell)
|
||||
+static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell)
|
||||
{
|
||||
size_t sz = strlen(cell->name);
|
||||
|
||||
@@ -61,10 +60,6 @@ static void mtk_efuse_fixup_cell_info(st
|
||||
cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
|
||||
}
|
||||
|
||||
-static struct nvmem_layout mtk_efuse_layout = {
|
||||
- .fixup_cell_info = mtk_efuse_fixup_cell_info,
|
||||
-};
|
||||
-
|
||||
static int mtk_efuse_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -91,7 +86,7 @@ static int mtk_efuse_probe(struct platfo
|
||||
econfig.priv = priv;
|
||||
econfig.dev = dev;
|
||||
if (pdata->uses_post_processing)
|
||||
- econfig.layout = &mtk_efuse_layout;
|
||||
+ econfig.fixup_dt_cell_info = &mtk_efuse_fixup_dt_cell_info;
|
||||
nvmem = devm_nvmem_register(dev, &econfig);
|
||||
|
||||
return PTR_ERR_OR_ZERO(nvmem);
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -83,6 +83,8 @@ struct nvmem_cell_info {
|
||||
* @cells: Optional array of pre-defined NVMEM cells.
|
||||
* @ncells: Number of elements in cells.
|
||||
* @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
|
||||
+ * @fixup_dt_cell_info: Will be called before a cell is added. Can be
|
||||
+ * used to modify the nvmem_cell_info.
|
||||
* @keepout: Optional array of keepout ranges (sorted ascending by start).
|
||||
* @nkeepout: Number of elements in the keepout array.
|
||||
* @type: Type of the nvmem storage
|
||||
@@ -113,6 +115,8 @@ struct nvmem_config {
|
||||
const struct nvmem_cell_info *cells;
|
||||
int ncells;
|
||||
bool add_legacy_fixed_of_cells;
|
||||
+ void (*fixup_dt_cell_info)(struct nvmem_device *nvmem,
|
||||
+ struct nvmem_cell_info *cell);
|
||||
const struct nvmem_keepout *keepout;
|
||||
unsigned int nkeepout;
|
||||
enum nvmem_type type;
|
||||
@@ -158,8 +162,6 @@ struct nvmem_cell_table {
|
||||
* @of_match_table: Open firmware match table.
|
||||
* @add_cells: Called to populate the layout using
|
||||
* nvmem_add_one_cell().
|
||||
- * @fixup_cell_info: Will be called before a cell is added. Can be
|
||||
- * used to modify the nvmem_cell_info.
|
||||
* @owner: Pointer to struct module.
|
||||
* @node: List node.
|
||||
*
|
||||
@@ -172,9 +174,6 @@ struct nvmem_layout {
|
||||
const char *name;
|
||||
const struct of_device_id *of_match_table;
|
||||
int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
- void (*fixup_cell_info)(struct nvmem_device *nvmem,
|
||||
- struct nvmem_layout *layout,
|
||||
- struct nvmem_cell_info *cell);
|
||||
|
||||
/* private */
|
||||
struct module *owner;
|
|
@ -0,0 +1,763 @@
|
|||
From fc29fd821d9ac2ae3d32a722fac39ce874efb883 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:32 +0000
|
||||
Subject: [PATCH] nvmem: core: Rework layouts to become regular devices
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Current layout support was initially written without modules support in
|
||||
mind. When the requirement for module support rose, the existing base
|
||||
was improved to adopt modularization support, but kind of a design flaw
|
||||
was introduced. With the existing implementation, when a storage device
|
||||
registers into NVMEM, the core tries to hook a layout (if any) and
|
||||
populates its cells immediately. This means, if the hardware description
|
||||
expects a layout to be hooked up, but no driver was provided for that,
|
||||
the storage medium will fail to probe and try later from
|
||||
scratch. Even if we consider that the hardware description shall be
|
||||
correct, we could still probe the storage device (especially if it
|
||||
contains the rootfs).
|
||||
|
||||
One way to overcome this situation is to consider the layouts as
|
||||
devices, and leverage the native notifier mechanism. When a new NVMEM
|
||||
device is registered, we can populate its nvmem-layout child, if any,
|
||||
and wait for the matching to be done in order to get the cells (the
|
||||
waiting can be easily done with the NVMEM notifiers). If the layout
|
||||
driver is compiled as a module, it should automatically be loaded. This
|
||||
way, there is no strong order to enforce, any NVMEM device creation
|
||||
or NVMEM layout driver insertion will be observed as a new event which
|
||||
may lead to the creation of additional cells, without disturbing the
|
||||
probes with costly (and sometimes endless) deferrals.
|
||||
|
||||
In order to achieve that goal we create a new bus for the nvmem-layouts
|
||||
with minimal logic to match nvmem-layout devices with nvmem-layout
|
||||
drivers. All this infrastructure code is created in the layouts.c file.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-7-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/Kconfig | 1 +
|
||||
drivers/nvmem/Makefile | 2 +
|
||||
drivers/nvmem/core.c | 170 ++++++++++----------------
|
||||
drivers/nvmem/internals.h | 21 ++++
|
||||
drivers/nvmem/layouts.c | 201 +++++++++++++++++++++++++++++++
|
||||
drivers/nvmem/layouts/Kconfig | 8 ++
|
||||
drivers/nvmem/layouts/onie-tlv.c | 24 +++-
|
||||
drivers/nvmem/layouts/sl28vpd.c | 24 +++-
|
||||
include/linux/nvmem-provider.h | 38 +++---
|
||||
9 files changed, 354 insertions(+), 135 deletions(-)
|
||||
create mode 100644 drivers/nvmem/layouts.c
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menuconfig NVMEM
|
||||
bool "NVMEM Support"
|
||||
+ imply NVMEM_LAYOUTS
|
||||
help
|
||||
Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES...
|
||||
|
||||
--- a/drivers/nvmem/Makefile
|
||||
+++ b/drivers/nvmem/Makefile
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
obj-$(CONFIG_NVMEM) += nvmem_core.o
|
||||
nvmem_core-y := core.o
|
||||
+obj-$(CONFIG_NVMEM_LAYOUTS) += nvmem_layouts.o
|
||||
+nvmem_layouts-y := layouts.o
|
||||
obj-y += layouts/
|
||||
|
||||
# Devices
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -56,9 +56,6 @@ static LIST_HEAD(nvmem_lookup_list);
|
||||
|
||||
static BLOCKING_NOTIFIER_HEAD(nvmem_notifier);
|
||||
|
||||
-static DEFINE_SPINLOCK(nvmem_layout_lock);
|
||||
-static LIST_HEAD(nvmem_layouts);
|
||||
-
|
||||
static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
|
||||
void *val, size_t bytes)
|
||||
{
|
||||
@@ -741,97 +738,22 @@ static int nvmem_add_cells_from_fixed_la
|
||||
return err;
|
||||
}
|
||||
|
||||
-int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner)
|
||||
+int nvmem_layout_register(struct nvmem_layout *layout)
|
||||
{
|
||||
- layout->owner = owner;
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
- list_add(&layout->node, &nvmem_layouts);
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
-
|
||||
- blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_ADD, layout);
|
||||
+ if (!layout->add_cells)
|
||||
+ return -EINVAL;
|
||||
|
||||
- return 0;
|
||||
+ /* Populate the cells */
|
||||
+ return layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(__nvmem_layout_register);
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_register);
|
||||
|
||||
void nvmem_layout_unregister(struct nvmem_layout *layout)
|
||||
{
|
||||
- blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_REMOVE, layout);
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
- list_del(&layout->node);
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
+ /* Keep the API even with an empty stub in case we need it later */
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_layout_unregister);
|
||||
|
||||
-static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- struct device_node *layout_np;
|
||||
- struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER);
|
||||
-
|
||||
- layout_np = of_nvmem_layout_get_container(nvmem);
|
||||
- if (!layout_np)
|
||||
- return NULL;
|
||||
-
|
||||
- /* Fixed layouts don't have a matching driver */
|
||||
- if (of_device_is_compatible(layout_np, "fixed-layout")) {
|
||||
- of_node_put(layout_np);
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * In case the nvmem device was built-in while the layout was built as a
|
||||
- * module, we shall manually request the layout driver loading otherwise
|
||||
- * we'll never have any match.
|
||||
- */
|
||||
- of_request_module(layout_np);
|
||||
-
|
||||
- spin_lock(&nvmem_layout_lock);
|
||||
-
|
||||
- list_for_each_entry(l, &nvmem_layouts, node) {
|
||||
- if (of_match_node(l->of_match_table, layout_np)) {
|
||||
- if (try_module_get(l->owner))
|
||||
- layout = l;
|
||||
-
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- spin_unlock(&nvmem_layout_lock);
|
||||
- of_node_put(layout_np);
|
||||
-
|
||||
- return layout;
|
||||
-}
|
||||
-
|
||||
-static void nvmem_layout_put(struct nvmem_layout *layout)
|
||||
-{
|
||||
- if (layout)
|
||||
- module_put(layout->owner);
|
||||
-}
|
||||
-
|
||||
-static int nvmem_add_cells_from_layout(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- struct nvmem_layout *layout = nvmem->layout;
|
||||
- int ret;
|
||||
-
|
||||
- if (layout && layout->add_cells) {
|
||||
- ret = layout->add_cells(&nvmem->dev, nvmem);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-#if IS_ENABLED(CONFIG_OF)
|
||||
-struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
-{
|
||||
- return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
|
||||
-#endif
|
||||
-
|
||||
const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout)
|
||||
{
|
||||
@@ -839,7 +761,7 @@ const void *nvmem_layout_get_match_data(
|
||||
const struct of_device_id *match;
|
||||
|
||||
layout_np = of_nvmem_layout_get_container(nvmem);
|
||||
- match = of_match_node(layout->of_match_table, layout_np);
|
||||
+ match = of_match_node(layout->dev.driver->of_match_table, layout_np);
|
||||
|
||||
return match ? match->data : NULL;
|
||||
}
|
||||
@@ -951,19 +873,6 @@ struct nvmem_device *nvmem_register(cons
|
||||
goto err_put_device;
|
||||
}
|
||||
|
||||
- /*
|
||||
- * If the driver supplied a layout by config->layout, the module
|
||||
- * pointer will be NULL and nvmem_layout_put() will be a noop.
|
||||
- */
|
||||
- nvmem->layout = config->layout ?: nvmem_layout_get(nvmem);
|
||||
- if (IS_ERR(nvmem->layout)) {
|
||||
- rval = PTR_ERR(nvmem->layout);
|
||||
- nvmem->layout = NULL;
|
||||
-
|
||||
- if (rval == -EPROBE_DEFER)
|
||||
- goto err_teardown_compat;
|
||||
- }
|
||||
-
|
||||
if (config->cells) {
|
||||
rval = nvmem_add_cells(nvmem, config->cells, config->ncells);
|
||||
if (rval)
|
||||
@@ -984,24 +893,24 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- rval = nvmem_add_cells_from_layout(nvmem);
|
||||
- if (rval)
|
||||
- goto err_remove_cells;
|
||||
-
|
||||
dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
|
||||
|
||||
rval = device_add(&nvmem->dev);
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
+ rval = nvmem_populate_layout(nvmem);
|
||||
+ if (rval)
|
||||
+ goto err_remove_dev;
|
||||
+
|
||||
blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
|
||||
|
||||
return nvmem;
|
||||
|
||||
+err_remove_dev:
|
||||
+ device_del(&nvmem->dev);
|
||||
err_remove_cells:
|
||||
nvmem_device_remove_all_cells(nvmem);
|
||||
- nvmem_layout_put(nvmem->layout);
|
||||
-err_teardown_compat:
|
||||
if (config->compat)
|
||||
nvmem_sysfs_remove_compat(nvmem, config);
|
||||
err_put_device:
|
||||
@@ -1023,7 +932,7 @@ static void nvmem_device_release(struct
|
||||
device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
|
||||
|
||||
nvmem_device_remove_all_cells(nvmem);
|
||||
- nvmem_layout_put(nvmem->layout);
|
||||
+ nvmem_destroy_layout(nvmem);
|
||||
device_unregister(&nvmem->dev);
|
||||
}
|
||||
|
||||
@@ -1325,6 +1234,12 @@ nvmem_cell_get_from_lookup(struct device
|
||||
return cell;
|
||||
}
|
||||
|
||||
+static void nvmem_layout_module_put(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ if (nvmem->layout && nvmem->layout->dev.driver)
|
||||
+ module_put(nvmem->layout->dev.driver->owner);
|
||||
+}
|
||||
+
|
||||
#if IS_ENABLED(CONFIG_OF)
|
||||
static struct nvmem_cell_entry *
|
||||
nvmem_find_cell_entry_by_node(struct nvmem_device *nvmem, struct device_node *np)
|
||||
@@ -1343,6 +1258,18 @@ nvmem_find_cell_entry_by_node(struct nvm
|
||||
return cell;
|
||||
}
|
||||
|
||||
+static int nvmem_layout_module_get_optional(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ if (!nvmem->layout)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (!nvmem->layout->dev.driver ||
|
||||
+ !try_module_get(nvmem->layout->dev.driver->owner))
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
|
||||
*
|
||||
@@ -1405,16 +1332,29 @@ struct nvmem_cell *of_nvmem_cell_get(str
|
||||
return ERR_CAST(nvmem);
|
||||
}
|
||||
|
||||
+ ret = nvmem_layout_module_get_optional(nvmem);
|
||||
+ if (ret) {
|
||||
+ of_node_put(cell_np);
|
||||
+ __nvmem_device_put(nvmem);
|
||||
+ return ERR_PTR(ret);
|
||||
+ }
|
||||
+
|
||||
cell_entry = nvmem_find_cell_entry_by_node(nvmem, cell_np);
|
||||
of_node_put(cell_np);
|
||||
if (!cell_entry) {
|
||||
__nvmem_device_put(nvmem);
|
||||
- return ERR_PTR(-ENOENT);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
+ if (nvmem->layout)
|
||||
+ return ERR_PTR(-EPROBE_DEFER);
|
||||
+ else
|
||||
+ return ERR_PTR(-ENOENT);
|
||||
}
|
||||
|
||||
cell = nvmem_create_cell(cell_entry, id, cell_index);
|
||||
- if (IS_ERR(cell))
|
||||
+ if (IS_ERR(cell)) {
|
||||
__nvmem_device_put(nvmem);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
+ }
|
||||
|
||||
return cell;
|
||||
}
|
||||
@@ -1528,6 +1468,7 @@ void nvmem_cell_put(struct nvmem_cell *c
|
||||
|
||||
kfree(cell);
|
||||
__nvmem_device_put(nvmem);
|
||||
+ nvmem_layout_module_put(nvmem);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_cell_put);
|
||||
|
||||
@@ -2105,11 +2046,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_name);
|
||||
|
||||
static int __init nvmem_init(void)
|
||||
{
|
||||
- return bus_register(&nvmem_bus_type);
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = bus_register(&nvmem_bus_type);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = nvmem_layout_bus_register();
|
||||
+ if (ret)
|
||||
+ bus_unregister(&nvmem_bus_type);
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static void __exit nvmem_exit(void)
|
||||
{
|
||||
+ nvmem_layout_bus_unregister();
|
||||
bus_unregister(&nvmem_bus_type);
|
||||
}
|
||||
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -34,4 +34,25 @@ struct nvmem_device {
|
||||
void *priv;
|
||||
};
|
||||
|
||||
+#if IS_ENABLED(CONFIG_OF)
|
||||
+int nvmem_layout_bus_register(void);
|
||||
+void nvmem_layout_bus_unregister(void);
|
||||
+int nvmem_populate_layout(struct nvmem_device *nvmem);
|
||||
+void nvmem_destroy_layout(struct nvmem_device *nvmem);
|
||||
+#else /* CONFIG_OF */
|
||||
+static inline int nvmem_layout_bus_register(void)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void nvmem_layout_bus_unregister(void) {}
|
||||
+
|
||||
+static inline int nvmem_populate_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void nvmem_destroy_layout(struct nvmem_device *nvmem) { }
|
||||
+#endif /* CONFIG_OF */
|
||||
+
|
||||
#endif /* ifndef _LINUX_NVMEM_INTERNALS_H */
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/layouts.c
|
||||
@@ -0,0 +1,201 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * NVMEM layout bus handling
|
||||
+ *
|
||||
+ * Copyright (C) 2023 Bootlin
|
||||
+ * Author: Miquel Raynal <miquel.raynal@bootlin.com
|
||||
+ */
|
||||
+
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/dma-mapping.h>
|
||||
+#include <linux/nvmem-consumer.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/of_irq.h>
|
||||
+
|
||||
+#include "internals.h"
|
||||
+
|
||||
+#define to_nvmem_layout_driver(drv) \
|
||||
+ (container_of((drv), struct nvmem_layout_driver, driver))
|
||||
+#define to_nvmem_layout_device(_dev) \
|
||||
+ container_of((_dev), struct nvmem_layout, dev)
|
||||
+
|
||||
+static int nvmem_layout_bus_match(struct device *dev, struct device_driver *drv)
|
||||
+{
|
||||
+ return of_driver_match_device(dev, drv);
|
||||
+}
|
||||
+
|
||||
+static int nvmem_layout_bus_probe(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ if (!drv->probe || !drv->remove)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ return drv->probe(layout);
|
||||
+}
|
||||
+
|
||||
+static void nvmem_layout_bus_remove(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ return drv->remove(layout);
|
||||
+}
|
||||
+
|
||||
+static struct bus_type nvmem_layout_bus_type = {
|
||||
+ .name = "nvmem-layout",
|
||||
+ .match = nvmem_layout_bus_match,
|
||||
+ .probe = nvmem_layout_bus_probe,
|
||||
+ .remove = nvmem_layout_bus_remove,
|
||||
+};
|
||||
+
|
||||
+int nvmem_layout_driver_register(struct nvmem_layout_driver *drv)
|
||||
+{
|
||||
+ drv->driver.bus = &nvmem_layout_bus_type;
|
||||
+
|
||||
+ return driver_register(&drv->driver);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_driver_register);
|
||||
+
|
||||
+void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv)
|
||||
+{
|
||||
+ driver_unregister(&drv->driver);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(nvmem_layout_driver_unregister);
|
||||
+
|
||||
+static void nvmem_layout_release_device(struct device *dev)
|
||||
+{
|
||||
+ struct nvmem_layout *layout = to_nvmem_layout_device(dev);
|
||||
+
|
||||
+ of_node_put(layout->dev.of_node);
|
||||
+ kfree(layout);
|
||||
+}
|
||||
+
|
||||
+static int nvmem_layout_create_device(struct nvmem_device *nvmem,
|
||||
+ struct device_node *np)
|
||||
+{
|
||||
+ struct nvmem_layout *layout;
|
||||
+ struct device *dev;
|
||||
+ int ret;
|
||||
+
|
||||
+ layout = kzalloc(sizeof(*layout), GFP_KERNEL);
|
||||
+ if (!layout)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ /* Create a bidirectional link */
|
||||
+ layout->nvmem = nvmem;
|
||||
+ nvmem->layout = layout;
|
||||
+
|
||||
+ /* Device model registration */
|
||||
+ dev = &layout->dev;
|
||||
+ device_initialize(dev);
|
||||
+ dev->parent = &nvmem->dev;
|
||||
+ dev->bus = &nvmem_layout_bus_type;
|
||||
+ dev->release = nvmem_layout_release_device;
|
||||
+ dev->coherent_dma_mask = DMA_BIT_MASK(32);
|
||||
+ dev->dma_mask = &dev->coherent_dma_mask;
|
||||
+ device_set_node(dev, of_fwnode_handle(of_node_get(np)));
|
||||
+ of_device_make_bus_id(dev);
|
||||
+ of_msi_configure(dev, dev->of_node);
|
||||
+
|
||||
+ ret = device_add(dev);
|
||||
+ if (ret) {
|
||||
+ put_device(dev);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id of_nvmem_layout_skip_table[] = {
|
||||
+ { .compatible = "fixed-layout", },
|
||||
+ {}
|
||||
+};
|
||||
+
|
||||
+static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
|
||||
+ struct device_node *layout_dn)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Make sure it has a compatible property */
|
||||
+ if (!of_get_property(layout_dn, "compatible", NULL)) {
|
||||
+ pr_debug("%s() - skipping %pOF, no compatible prop\n",
|
||||
+ __func__, layout_dn);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Fixed layouts are parsed manually somewhere else for now */
|
||||
+ if (of_match_node(of_nvmem_layout_skip_table, layout_dn)) {
|
||||
+ pr_debug("%s() - skipping %pOF node\n", __func__, layout_dn);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (of_node_check_flag(layout_dn, OF_POPULATED_BUS)) {
|
||||
+ pr_debug("%s() - skipping %pOF, already populated\n",
|
||||
+ __func__, layout_dn);
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* NVMEM layout buses expect only a single device representing the layout */
|
||||
+ ret = nvmem_layout_create_device(nvmem, layout_dn);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ of_node_set_flag(layout_dn, OF_POPULATED_BUS);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container);
|
||||
+
|
||||
+/*
|
||||
+ * Returns the number of devices populated, 0 if the operation was not relevant
|
||||
+ * for this nvmem device, an error code otherwise.
|
||||
+ */
|
||||
+int nvmem_populate_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct device_node *layout_dn;
|
||||
+ int ret;
|
||||
+
|
||||
+ layout_dn = of_nvmem_layout_get_container(nvmem);
|
||||
+ if (!layout_dn)
|
||||
+ return 0;
|
||||
+
|
||||
+ /* Populate the layout device */
|
||||
+ device_links_supplier_sync_state_pause();
|
||||
+ ret = nvmem_layout_bus_populate(nvmem, layout_dn);
|
||||
+ device_links_supplier_sync_state_resume();
|
||||
+
|
||||
+ of_node_put(layout_dn);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+void nvmem_destroy_layout(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct device *dev;
|
||||
+
|
||||
+ if (!nvmem->layout)
|
||||
+ return;
|
||||
+
|
||||
+ dev = &nvmem->layout->dev;
|
||||
+ of_node_clear_flag(dev->of_node, OF_POPULATED_BUS);
|
||||
+ device_unregister(dev);
|
||||
+}
|
||||
+
|
||||
+int nvmem_layout_bus_register(void)
|
||||
+{
|
||||
+ return bus_register(&nvmem_layout_bus_type);
|
||||
+}
|
||||
+
|
||||
+void nvmem_layout_bus_unregister(void)
|
||||
+{
|
||||
+ bus_unregister(&nvmem_layout_bus_type);
|
||||
+}
|
||||
--- a/drivers/nvmem/layouts/Kconfig
|
||||
+++ b/drivers/nvmem/layouts/Kconfig
|
||||
@@ -1,5 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
+config NVMEM_LAYOUTS
|
||||
+ bool
|
||||
+ depends on OF
|
||||
+
|
||||
+if NVMEM_LAYOUTS
|
||||
+
|
||||
menu "Layout Types"
|
||||
|
||||
config NVMEM_LAYOUT_SL28_VPD
|
||||
@@ -21,3 +27,5 @@ config NVMEM_LAYOUT_ONIE_TLV
|
||||
If unsure, say N.
|
||||
|
||||
endmenu
|
||||
+
|
||||
+endif
|
||||
--- a/drivers/nvmem/layouts/onie-tlv.c
|
||||
+++ b/drivers/nvmem/layouts/onie-tlv.c
|
||||
@@ -225,16 +225,32 @@ static int onie_tlv_parse_table(struct d
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int onie_tlv_probe(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ layout->add_cells = onie_tlv_parse_table;
|
||||
+
|
||||
+ return nvmem_layout_register(layout);
|
||||
+}
|
||||
+
|
||||
+static void onie_tlv_remove(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ nvmem_layout_unregister(layout);
|
||||
+}
|
||||
+
|
||||
static const struct of_device_id onie_tlv_of_match_table[] = {
|
||||
{ .compatible = "onie,tlv-layout", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, onie_tlv_of_match_table);
|
||||
|
||||
-static struct nvmem_layout onie_tlv_layout = {
|
||||
- .name = "ONIE tlv layout",
|
||||
- .of_match_table = onie_tlv_of_match_table,
|
||||
- .add_cells = onie_tlv_parse_table,
|
||||
+static struct nvmem_layout_driver onie_tlv_layout = {
|
||||
+ .driver = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .name = "onie-tlv-layout",
|
||||
+ .of_match_table = onie_tlv_of_match_table,
|
||||
+ },
|
||||
+ .probe = onie_tlv_probe,
|
||||
+ .remove = onie_tlv_remove,
|
||||
};
|
||||
module_nvmem_layout_driver(onie_tlv_layout);
|
||||
|
||||
--- a/drivers/nvmem/layouts/sl28vpd.c
|
||||
+++ b/drivers/nvmem/layouts/sl28vpd.c
|
||||
@@ -134,16 +134,32 @@ static int sl28vpd_add_cells(struct devi
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int sl28vpd_probe(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ layout->add_cells = sl28vpd_add_cells;
|
||||
+
|
||||
+ return nvmem_layout_register(layout);
|
||||
+}
|
||||
+
|
||||
+static void sl28vpd_remove(struct nvmem_layout *layout)
|
||||
+{
|
||||
+ nvmem_layout_unregister(layout);
|
||||
+}
|
||||
+
|
||||
static const struct of_device_id sl28vpd_of_match_table[] = {
|
||||
{ .compatible = "kontron,sl28-vpd" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sl28vpd_of_match_table);
|
||||
|
||||
-static struct nvmem_layout sl28vpd_layout = {
|
||||
- .name = "sl28-vpd",
|
||||
- .of_match_table = sl28vpd_of_match_table,
|
||||
- .add_cells = sl28vpd_add_cells,
|
||||
+static struct nvmem_layout_driver sl28vpd_layout = {
|
||||
+ .driver = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .name = "kontron-sl28vpd-layout",
|
||||
+ .of_match_table = sl28vpd_of_match_table,
|
||||
+ },
|
||||
+ .probe = sl28vpd_probe,
|
||||
+ .remove = sl28vpd_remove,
|
||||
};
|
||||
module_nvmem_layout_driver(sl28vpd_layout);
|
||||
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef _LINUX_NVMEM_PROVIDER_H
|
||||
#define _LINUX_NVMEM_PROVIDER_H
|
||||
|
||||
+#include <linux/device.h>
|
||||
#include <linux/device/driver.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/errno.h>
|
||||
@@ -158,12 +159,11 @@ struct nvmem_cell_table {
|
||||
/**
|
||||
* struct nvmem_layout - NVMEM layout definitions
|
||||
*
|
||||
- * @name: Layout name.
|
||||
- * @of_match_table: Open firmware match table.
|
||||
- * @add_cells: Called to populate the layout using
|
||||
- * nvmem_add_one_cell().
|
||||
- * @owner: Pointer to struct module.
|
||||
- * @node: List node.
|
||||
+ * @dev: Device-model layout device.
|
||||
+ * @nvmem: The underlying NVMEM device
|
||||
+ * @add_cells: Will be called if a nvmem device is found which
|
||||
+ * has this layout. The function will add layout
|
||||
+ * specific cells with nvmem_add_one_cell().
|
||||
*
|
||||
* A nvmem device can hold a well defined structure which can just be
|
||||
* evaluated during runtime. For example a TLV list, or a list of "name=val"
|
||||
@@ -171,13 +171,15 @@ struct nvmem_cell_table {
|
||||
* cells.
|
||||
*/
|
||||
struct nvmem_layout {
|
||||
- const char *name;
|
||||
- const struct of_device_id *of_match_table;
|
||||
+ struct device dev;
|
||||
+ struct nvmem_device *nvmem;
|
||||
int (*add_cells)(struct device *dev, struct nvmem_device *nvmem);
|
||||
+};
|
||||
|
||||
- /* private */
|
||||
- struct module *owner;
|
||||
- struct list_head node;
|
||||
+struct nvmem_layout_driver {
|
||||
+ struct device_driver driver;
|
||||
+ int (*probe)(struct nvmem_layout *layout);
|
||||
+ void (*remove)(struct nvmem_layout *layout);
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_NVMEM)
|
||||
@@ -194,11 +196,15 @@ void nvmem_del_cell_table(struct nvmem_c
|
||||
int nvmem_add_one_cell(struct nvmem_device *nvmem,
|
||||
const struct nvmem_cell_info *info);
|
||||
|
||||
-int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner);
|
||||
-#define nvmem_layout_register(layout) \
|
||||
- __nvmem_layout_register(layout, THIS_MODULE)
|
||||
+int nvmem_layout_register(struct nvmem_layout *layout);
|
||||
void nvmem_layout_unregister(struct nvmem_layout *layout);
|
||||
|
||||
+int nvmem_layout_driver_register(struct nvmem_layout_driver *drv);
|
||||
+void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv);
|
||||
+#define module_nvmem_layout_driver(__nvmem_layout_driver) \
|
||||
+ module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \
|
||||
+ nvmem_layout_driver_unregister)
|
||||
+
|
||||
const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem,
|
||||
struct nvmem_layout *layout);
|
||||
|
||||
@@ -262,8 +268,4 @@ static inline struct device_node *of_nvm
|
||||
|
||||
#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
|
||||
-#define module_nvmem_layout_driver(__layout_driver) \
|
||||
- module_driver(__layout_driver, nvmem_layout_register, \
|
||||
- nvmem_layout_unregister)
|
||||
-
|
||||
#endif /* ifndef _LINUX_NVMEM_PROVIDER_H */
|
|
@ -0,0 +1,240 @@
|
|||
From 0331c611949fffdf486652450901a4dc52bc5cca Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:34 +0000
|
||||
Subject: [PATCH] nvmem: core: Expose cells through sysfs
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The binary content of nvmem devices is available to the user so in the
|
||||
easiest cases, finding the content of a cell is rather easy as it is
|
||||
just a matter of looking at a known and fixed offset. However, nvmem
|
||||
layouts have been recently introduced to cope with more advanced
|
||||
situations, where the offset and size of the cells is not known in
|
||||
advance or is dynamic. When using layouts, more advanced parsers are
|
||||
used by the kernel in order to give direct access to the content of each
|
||||
cell, regardless of its position/size in the underlying
|
||||
device. Unfortunately, these information are not accessible by users,
|
||||
unless by fully re-implementing the parser logic in userland.
|
||||
|
||||
Let's expose the cells and their content through sysfs to avoid these
|
||||
situations. Of course the relevant NVMEM sysfs Kconfig option must be
|
||||
enabled for this support to be available.
|
||||
|
||||
Not all nvmem devices expose cells. Indeed, the .bin_attrs attribute
|
||||
group member will be filled at runtime only when relevant and will
|
||||
remain empty otherwise. In this case, as the cells attribute group will
|
||||
be empty, it will not lead to any additional folder/file creation.
|
||||
|
||||
Exposed cells are read-only. There is, in practice, everything in the
|
||||
core to support a write path, but as I don't see any need for that, I
|
||||
prefer to keep the interface simple (and probably safer). The interface
|
||||
is documented as being in the "testing" state which means we can later
|
||||
add a write attribute if though relevant.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Tested-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-9-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 135 +++++++++++++++++++++++++++++++++++++-
|
||||
drivers/nvmem/internals.h | 1 +
|
||||
2 files changed, 135 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -300,6 +300,43 @@ static umode_t nvmem_bin_attr_is_visible
|
||||
return nvmem_bin_attr_get_umode(nvmem);
|
||||
}
|
||||
|
||||
+static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry,
|
||||
+ const char *id, int index);
|
||||
+
|
||||
+static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
|
||||
+ struct bin_attribute *attr, char *buf,
|
||||
+ loff_t pos, size_t count)
|
||||
+{
|
||||
+ struct nvmem_cell_entry *entry;
|
||||
+ struct nvmem_cell *cell = NULL;
|
||||
+ size_t cell_sz, read_len;
|
||||
+ void *content;
|
||||
+
|
||||
+ entry = attr->private;
|
||||
+ cell = nvmem_create_cell(entry, entry->name, 0);
|
||||
+ if (IS_ERR(cell))
|
||||
+ return PTR_ERR(cell);
|
||||
+
|
||||
+ if (!cell)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ content = nvmem_cell_read(cell, &cell_sz);
|
||||
+ if (IS_ERR(content)) {
|
||||
+ read_len = PTR_ERR(content);
|
||||
+ goto destroy_cell;
|
||||
+ }
|
||||
+
|
||||
+ read_len = min_t(unsigned int, cell_sz - pos, count);
|
||||
+ memcpy(buf, content + pos, read_len);
|
||||
+ kfree(content);
|
||||
+
|
||||
+destroy_cell:
|
||||
+ kfree_const(cell->id);
|
||||
+ kfree(cell);
|
||||
+
|
||||
+ return read_len;
|
||||
+}
|
||||
+
|
||||
/* default read/write permissions */
|
||||
static struct bin_attribute bin_attr_rw_nvmem = {
|
||||
.attr = {
|
||||
@@ -321,11 +358,21 @@ static const struct attribute_group nvme
|
||||
.is_bin_visible = nvmem_bin_attr_is_visible,
|
||||
};
|
||||
|
||||
+/* Cell attributes will be dynamically allocated */
|
||||
+static struct attribute_group nvmem_cells_group = {
|
||||
+ .name = "cells",
|
||||
+};
|
||||
+
|
||||
static const struct attribute_group *nvmem_dev_groups[] = {
|
||||
&nvmem_bin_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
+static const struct attribute_group *nvmem_cells_groups[] = {
|
||||
+ &nvmem_cells_group,
|
||||
+ NULL,
|
||||
+};
|
||||
+
|
||||
static struct bin_attribute bin_attr_nvmem_eeprom_compat = {
|
||||
.attr = {
|
||||
.name = "eeprom",
|
||||
@@ -381,6 +428,68 @@ static void nvmem_sysfs_remove_compat(st
|
||||
device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
|
||||
}
|
||||
|
||||
+static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
|
||||
+{
|
||||
+ struct bin_attribute **cells_attrs, *attrs;
|
||||
+ struct nvmem_cell_entry *entry;
|
||||
+ unsigned int ncells = 0, i = 0;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ mutex_lock(&nvmem_mutex);
|
||||
+
|
||||
+ if (list_empty(&nvmem->cells) || nvmem->sysfs_cells_populated) {
|
||||
+ nvmem_cells_group.bin_attrs = NULL;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ /* Allocate an array of attributes with a sentinel */
|
||||
+ ncells = list_count_nodes(&nvmem->cells);
|
||||
+ cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
|
||||
+ sizeof(struct bin_attribute *), GFP_KERNEL);
|
||||
+ if (!cells_attrs) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ attrs = devm_kcalloc(&nvmem->dev, ncells, sizeof(struct bin_attribute), GFP_KERNEL);
|
||||
+ if (!attrs) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ /* Initialize each attribute to take the name and size of the cell */
|
||||
+ list_for_each_entry(entry, &nvmem->cells, node) {
|
||||
+ sysfs_bin_attr_init(&attrs[i]);
|
||||
+ attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL,
|
||||
+ "%s@%x", entry->name,
|
||||
+ entry->offset);
|
||||
+ attrs[i].attr.mode = 0444;
|
||||
+ attrs[i].size = entry->bytes;
|
||||
+ attrs[i].read = &nvmem_cell_attr_read;
|
||||
+ attrs[i].private = entry;
|
||||
+ if (!attrs[i].attr.name) {
|
||||
+ ret = -ENOMEM;
|
||||
+ goto unlock_mutex;
|
||||
+ }
|
||||
+
|
||||
+ cells_attrs[i] = &attrs[i];
|
||||
+ i++;
|
||||
+ }
|
||||
+
|
||||
+ nvmem_cells_group.bin_attrs = cells_attrs;
|
||||
+
|
||||
+ ret = devm_device_add_groups(&nvmem->dev, nvmem_cells_groups);
|
||||
+ if (ret)
|
||||
+ goto unlock_mutex;
|
||||
+
|
||||
+ nvmem->sysfs_cells_populated = true;
|
||||
+
|
||||
+unlock_mutex:
|
||||
+ mutex_unlock(&nvmem_mutex);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
#else /* CONFIG_NVMEM_SYSFS */
|
||||
|
||||
static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
|
||||
@@ -740,11 +849,25 @@ static int nvmem_add_cells_from_fixed_la
|
||||
|
||||
int nvmem_layout_register(struct nvmem_layout *layout)
|
||||
{
|
||||
+ int ret;
|
||||
+
|
||||
if (!layout->add_cells)
|
||||
return -EINVAL;
|
||||
|
||||
/* Populate the cells */
|
||||
- return layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
+ ret = layout->add_cells(&layout->nvmem->dev, layout->nvmem);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+ ret = nvmem_populate_sysfs_cells(layout->nvmem);
|
||||
+ if (ret) {
|
||||
+ nvmem_device_remove_all_cells(layout->nvmem);
|
||||
+ return ret;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvmem_layout_register);
|
||||
|
||||
@@ -903,10 +1026,20 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_dev;
|
||||
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+ rval = nvmem_populate_sysfs_cells(nvmem);
|
||||
+ if (rval)
|
||||
+ goto err_destroy_layout;
|
||||
+#endif
|
||||
+
|
||||
blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
|
||||
|
||||
return nvmem;
|
||||
|
||||
+#ifdef CONFIG_NVMEM_SYSFS
|
||||
+err_destroy_layout:
|
||||
+ nvmem_destroy_layout(nvmem);
|
||||
+#endif
|
||||
err_remove_dev:
|
||||
device_del(&nvmem->dev);
|
||||
err_remove_cells:
|
||||
--- a/drivers/nvmem/internals.h
|
||||
+++ b/drivers/nvmem/internals.h
|
||||
@@ -32,6 +32,7 @@ struct nvmem_device {
|
||||
struct gpio_desc *wp_gpio;
|
||||
struct nvmem_layout *layout;
|
||||
void *priv;
|
||||
+ bool sysfs_cells_populated;
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_OF)
|
|
@ -0,0 +1,65 @@
|
|||
From f0ac5b23039610619ca4a4805528553ecb6bc815 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
|
||||
Date: Fri, 15 Dec 2023 11:15:36 +0000
|
||||
Subject: [PATCH] nvmem: stm32: add support for STM32MP25 BSEC to control OTP
|
||||
data
|
||||
|
||||
On STM32MP25, OTP area may be read/written by using BSEC (boot, security
|
||||
and OTP control). The BSEC internal peripheral is only managed by the
|
||||
secure world.
|
||||
|
||||
The 12 Kbits of OTP (effective) are organized into the following regions:
|
||||
- lower OTP (OTP0 to OTP127) = 4096 lower OTP bits,
|
||||
bitwise (1-bit) programmable
|
||||
- mid OTP (OTP128 to OTP255) = 4096 middle OTP bits,
|
||||
bulk (32-bit) programmable
|
||||
- upper OTP (OTP256 to OTP383) = 4096 upper OTP bits,
|
||||
bulk (32-bit) programmable,
|
||||
only accessible when BSEC is in closed state.
|
||||
|
||||
As HWKEY and ECIES key are only accessible by ROM code;
|
||||
only 368 OTP words are managed in this driver (OTP0 to OTP267).
|
||||
|
||||
This patch adds the STM32MP25 configuration for reading and writing
|
||||
the OTP data using the OP-TEE BSEC TA services.
|
||||
|
||||
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231215111536.316972-11-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/stm32-romem.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
--- a/drivers/nvmem/stm32-romem.c
|
||||
+++ b/drivers/nvmem/stm32-romem.c
|
||||
@@ -269,6 +269,19 @@ static const struct stm32_romem_cfg stm3
|
||||
.ta = true,
|
||||
};
|
||||
|
||||
+/*
|
||||
+ * STM32MP25 BSEC OTP: 3 regions of 32-bits data words
|
||||
+ * lower OTP (OTP0 to OTP127), bitwise (1-bit) programmable
|
||||
+ * mid OTP (OTP128 to OTP255), bulk (32-bit) programmable
|
||||
+ * upper OTP (OTP256 to OTP383), bulk (32-bit) programmable
|
||||
+ * but no access to HWKEY and ECIES key: limited at OTP367
|
||||
+ */
|
||||
+static const struct stm32_romem_cfg stm32mp25_bsec_cfg = {
|
||||
+ .size = 368 * 4,
|
||||
+ .lower = 127,
|
||||
+ .ta = true,
|
||||
+};
|
||||
+
|
||||
static const struct of_device_id stm32_romem_of_match[] __maybe_unused = {
|
||||
{ .compatible = "st,stm32f4-otp", }, {
|
||||
.compatible = "st,stm32mp15-bsec",
|
||||
@@ -276,6 +289,9 @@ static const struct of_device_id stm32_r
|
||||
}, {
|
||||
.compatible = "st,stm32mp13-bsec",
|
||||
.data = (void *)&stm32mp13_bsec_cfg,
|
||||
+ }, {
|
||||
+ .compatible = "st,stm32mp25-bsec",
|
||||
+ .data = (void *)&stm32mp25_bsec_cfg,
|
||||
},
|
||||
{ /* sentinel */ },
|
||||
};
|
|
@ -22,7 +22,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
#include <linux/crc32.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -6980,6 +6981,22 @@ static void rtl_tally_reset(struct r8152
|
||||
@@ -6994,6 +6995,22 @@ static void rtl_tally_reset(struct r8152
|
||||
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
static void r8152b_init(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
@@ -7021,6 +7038,8 @@ static void r8152b_init(struct r8152 *tp
|
||||
@@ -7035,6 +7052,8 @@ static void r8152b_init(struct r8152 *tp
|
||||
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
|
||||
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
|
||||
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
|
||||
|
@ -54,7 +54,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
}
|
||||
|
||||
static void r8153_init(struct r8152 *tp)
|
||||
@@ -7161,6 +7180,8 @@ static void r8153_init(struct r8152 *tp)
|
||||
@@ -7175,6 +7194,8 @@ static void r8153_init(struct r8152 *tp)
|
||||
tp->coalesce = COALESCE_SLOW;
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
}
|
||||
|
||||
static void r8153b_init(struct r8152 *tp)
|
||||
@@ -7243,6 +7264,8 @@ static void r8153b_init(struct r8152 *tp
|
||||
@@ -7257,6 +7278,8 @@ static void r8153b_init(struct r8152 *tp
|
||||
rtl_tally_reset(tp);
|
||||
|
||||
tp->coalesce = 15000; /* 15 us */
|
||||
|
|
|
@ -157,7 +157,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
|
|||
{
|
||||
--- a/drivers/gpio/gpiolib-sysfs.c
|
||||
+++ b/drivers/gpio/gpiolib-sysfs.c
|
||||
@@ -561,7 +561,7 @@ static struct class gpio_class = {
|
||||
@@ -564,7 +564,7 @@ static struct class gpio_class = {
|
||||
*
|
||||
* Returns zero on success, else an error.
|
||||
*/
|
||||
|
@ -166,7 +166,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
|
|||
{
|
||||
struct gpio_chip *chip;
|
||||
struct gpio_device *gdev;
|
||||
@@ -623,6 +623,8 @@ int gpiod_export(struct gpio_desc *desc,
|
||||
@@ -626,6 +626,8 @@ int gpiod_export(struct gpio_desc *desc,
|
||||
offset = gpio_chip_hwgpio(desc);
|
||||
if (chip->names && chip->names[offset])
|
||||
ioname = chip->names[offset];
|
||||
|
@ -175,7 +175,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
|
|||
|
||||
dev = device_create_with_groups(&gpio_class, &gdev->dev,
|
||||
MKDEV(0, 0), data, gpio_groups,
|
||||
@@ -644,6 +646,12 @@ err_unlock:
|
||||
@@ -647,6 +649,12 @@ err_unlock:
|
||||
gpiod_dbg(desc, "%s: status %d\n", __func__, status);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
#include <linux/crc32.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/uaccess.h>
|
||||
@@ -7020,6 +7021,22 @@ static void rtl_tally_reset(struct r8152
|
||||
@@ -7034,6 +7035,22 @@ static void rtl_tally_reset(struct r8152
|
||||
ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
static void r8152b_init(struct r8152 *tp)
|
||||
{
|
||||
u32 ocp_data;
|
||||
@@ -7061,6 +7078,8 @@ static void r8152b_init(struct r8152 *tp
|
||||
@@ -7075,6 +7092,8 @@ static void r8152b_init(struct r8152 *tp
|
||||
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
|
||||
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
|
||||
ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
|
||||
|
@ -54,7 +54,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
}
|
||||
|
||||
static void r8153_init(struct r8152 *tp)
|
||||
@@ -7201,6 +7220,8 @@ static void r8153_init(struct r8152 *tp)
|
||||
@@ -7215,6 +7234,8 @@ static void r8153_init(struct r8152 *tp)
|
||||
tp->coalesce = COALESCE_SLOW;
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
|
|||
}
|
||||
|
||||
static void r8153b_init(struct r8152 *tp)
|
||||
@@ -7283,6 +7304,8 @@ static void r8153b_init(struct r8152 *tp
|
||||
@@ -7297,6 +7318,8 @@ static void r8153b_init(struct r8152 *tp
|
||||
rtl_tally_reset(tp);
|
||||
|
||||
tp->coalesce = 15000; /* 15 us */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue