linux/drivers/net
Alex Elder 064c9c32b1 net: ipa: lock when freeing transaction
Transactions sit on one of several lists, depending on their state
(allocated, pending, complete, or polled).  A spinlock protects
against concurrent access when transactions are moved between these
lists.

Transactions are also reference counted.  A newly-allocated
transaction has an initial count of 1; a transaction is released in
gsi_trans_free() only if its decremented reference count reaches 0.
Releasing a transaction includes removing it from the polled (or if
unused, allocated) list, so the spinlock is acquired when we release
a transaction.

The reference count is used to allow a caller to synchronously wait
for a committed transaction to complete.  In this case, the waiter
takes an extra reference to the transaction *before* committing it
(so it won't be freed), and releases its reference (calls
gsi_trans_free()) when it is done with it.

Similarly, gsi_channel_update() takes an extra reference to ensure a
transaction isn't released before the function is done operating on
it.  Until the transaction is moved to the completed list (by this
function) it won't be freed, so this reference is taken "safely."

But in the quiesce path, we want to wait for the "last" transaction,
which we find in the completed or polled list.  Transactions on
these lists can be freed at any time, so we (try to) prevent that
by taking the reference while holding the spinlock.

Currently gsi_trans_free() decrements a transaction's reference
count unconditionally, acquiring the lock to remove the transaction
from its list *only* when the count reaches 0.  This does not
protect the quiesce path, which depends on the lock to ensure its
extra reference prevents release of the transaction.

Fix this by only dropping the last reference to a transaction
in gsi_trans_free() while holding the spinlock.

Fixes: 9dd441e4ed ("soc: qcom: ipa: GSI transactions")
Reported-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20201114182017.28270-1-elder@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-16 17:32:22 -08:00
..
appletalk docs updates for v5.10-rc1 2020-10-16 15:02:21 -07:00
arcnet
bonding net: core: introduce struct netdev_nested_priv for nested interface infrastructure 2020-09-28 15:00:15 -07:00
caif caif_virtio: Remove redundant initialization of variable err 2020-10-01 18:46:16 -07:00
can can: m_can: m_can_stop(): set device to software init mode before closing 2020-11-15 18:33:45 +01:00
dsa net: lantiq: Wait for the GPHY firmware to be ready 2020-11-16 13:38:18 -08:00
ethernet net: qualcomm: rmnet: Fix incorrect receive packet handling during cleanup 2020-11-16 16:34:49 -08:00
fddi fddi/skfp: Avoid the use of one-element array 2020-09-29 13:27:43 -07:00
fjes
hamradio drivers: net: hamradio: fix document location 2020-10-15 07:49:47 +02:00
hippi
hyperv hyperv-next for 5.10 2020-10-14 10:32:10 -07:00
ieee802154 genetlink: move to smaller ops wherever possible 2020-10-02 19:11:11 -07:00
ipa net: ipa: lock when freeing transaction 2020-11-16 17:32:22 -08:00
ipvlan
mdio net: phy: Move of_mdio from drivers/of to drivers/net/mdio 2020-10-10 10:55:05 -07:00
netdevsim devlink: Add devlink reload limit option 2020-10-09 12:06:52 -07:00
pcs net: pcs-xpcs: depend on MDIO_BUS instead of selecting it 2020-10-16 16:54:11 -07:00
phy net: phy: smsc: add missed clk_disable_unprepare in smsc_phy_probe() 2020-11-14 11:21:13 -08:00
plip
ppp
slip
team Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-10-05 18:40:01 -07:00
usb cx82310_eth: fix error return code in cx82310_bind() 2020-11-16 15:23:44 -08:00
vmxnet3 vmxnet3: fix cksum offload issues for non-udp tunnels 2020-09-25 16:41:40 -07:00
wan cosa: Add missing kfree in error path of cosa_write 2020-11-11 17:52:01 -08:00
wimax
wireguard
wireless networking changes for the 5.10 merge window 2020-10-15 18:42:13 -07:00
xen-netback xen/netback: use lateeoi irq binding 2020-10-20 10:22:03 +02:00
bareudp.c bareudp: use dev_sw_netstats_rx_add() 2020-10-06 06:23:21 -07:00
dummy.c
eql.c
geneve.c ip_tunnels: Set tunnel option flag when tunnel metadata is present 2020-11-13 16:58:10 -08:00
gtp.c gtp: fix an use-before-init in gtp_newlink() 2020-10-29 09:43:21 -07:00
ifb.c
Kconfig
LICENSE.SRC
loopback.c
macsec.c net: macsec: use new function dev_fetch_sw_netstats 2020-10-13 17:33:48 -07:00
macvlan.c
macvtap.c
Makefile
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c
veth.c bpf: Add redirect_peer helper 2020-10-11 10:21:04 -07:00
virtio_net.c Revert "virtio-net: ethtool configurable RXCSUM" 2020-10-21 20:33:19 -07:00
vrf.c vrf: Fix fast path output packet handling with async Netfilter rules 2020-11-12 07:47:06 -08:00
vsockmon.c
vxlan.c vxlan: use dev_sw_netstats_rx_add() 2020-10-06 06:23:21 -07:00
xen-netfront.c