Skip to content

Commit

Permalink
Merge branch 'crypto-chelsio-Fixes-issues-during-chcr-driver-registra…
Browse files Browse the repository at this point in the history
…tion'

Ayush Sawal says:

====================
crypto: chelsio: Fixes issues during chcr driver registration

Patch 1: Avoid the accessing of wrong u_ctx pointer.
Patch 2: Fixes a deadlock between rtnl_lock and uld_mutex.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 30, 2020
2 parents 3aeaaa5 + 876aa9f commit 07c9f74
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
34 changes: 28 additions & 6 deletions drivers/crypto/chelsio/chcr_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ static int cpl_fw6_pld_handler(struct adapter *adap, unsigned char *input);
static void *chcr_uld_add(const struct cxgb4_lld_info *lld);
static int chcr_uld_state_change(void *handle, enum cxgb4_state state);

#ifdef CONFIG_CHELSIO_IPSEC_INLINE
static void update_netdev_features(void);
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */

static chcr_handler_func work_handlers[NUM_CPL_CMDS] = {
[CPL_FW6_PLD] = cpl_fw6_pld_handler,
#ifdef CONFIG_CHELSIO_TLS_DEVICE
Expand Down Expand Up @@ -129,8 +133,6 @@ static void chcr_dev_init(struct uld_ctx *u_ctx)
atomic_set(&dev->inflight, 0);
mutex_lock(&drv_data.drv_mutex);
list_add_tail(&u_ctx->entry, &drv_data.inact_dev);
if (!drv_data.last_dev)
drv_data.last_dev = u_ctx;
mutex_unlock(&drv_data.drv_mutex);
}

Expand Down Expand Up @@ -204,10 +206,6 @@ static void *chcr_uld_add(const struct cxgb4_lld_info *lld)
}
u_ctx->lldi = *lld;
chcr_dev_init(u_ctx);
#ifdef CONFIG_CHELSIO_IPSEC_INLINE
if (lld->crypto & ULP_CRYPTO_IPSEC_INLINE)
chcr_add_xfrmops(lld);
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */

#ifdef CONFIG_CHELSIO_TLS_DEVICE
if (lld->ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
Expand Down Expand Up @@ -299,6 +297,24 @@ static int chcr_uld_state_change(void *handle, enum cxgb4_state state)
return ret;
}

#ifdef CONFIG_CHELSIO_IPSEC_INLINE
static void update_netdev_features(void)
{
struct uld_ctx *u_ctx, *tmp;

mutex_lock(&drv_data.drv_mutex);
list_for_each_entry_safe(u_ctx, tmp, &drv_data.inact_dev, entry) {
if (u_ctx->lldi.crypto & ULP_CRYPTO_IPSEC_INLINE)
chcr_add_xfrmops(&u_ctx->lldi);
}
list_for_each_entry_safe(u_ctx, tmp, &drv_data.act_dev, entry) {
if (u_ctx->lldi.crypto & ULP_CRYPTO_IPSEC_INLINE)
chcr_add_xfrmops(&u_ctx->lldi);
}
mutex_unlock(&drv_data.drv_mutex);
}
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */

static int __init chcr_crypto_init(void)
{
INIT_LIST_HEAD(&drv_data.act_dev);
Expand All @@ -308,6 +324,12 @@ static int __init chcr_crypto_init(void)
drv_data.last_dev = NULL;
cxgb4_register_uld(CXGB4_ULD_CRYPTO, &chcr_uld_info);

#ifdef CONFIG_CHELSIO_IPSEC_INLINE
rtnl_lock();
update_netdev_features();
rtnl_unlock();
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */

return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/crypto/chelsio/chcr_ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ void chcr_add_xfrmops(const struct cxgb4_lld_info *lld)
netdev->xfrmdev_ops = &chcr_xfrmdev_ops;
netdev->hw_enc_features |= NETIF_F_HW_ESP;
netdev->features |= NETIF_F_HW_ESP;
rtnl_lock();
netdev_change_features(netdev);
rtnl_unlock();
}
}

Expand Down

0 comments on commit 07c9f74

Please sign in to comment.