Commit 0c3b7f4b authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'ionic-memory-usage-fixes'

Shannon Nelson says:

====================
ionic: memory usage fixes

This patchset addresses some memory leaks and incorrect
io reads.
====================

Link: https://lore.kernel.org/r/20201022235531.65956-1-snelson@pensando.ioSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4f3391ce 0c32a28e
...@@ -333,7 +333,7 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data) ...@@ -333,7 +333,7 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data)
union ionic_dev_cmd cmd = { union ionic_dev_cmd cmd = {
.vf_setattr.opcode = IONIC_CMD_VF_SETATTR, .vf_setattr.opcode = IONIC_CMD_VF_SETATTR,
.vf_setattr.attr = attr, .vf_setattr.attr = attr,
.vf_setattr.vf_index = vf, .vf_setattr.vf_index = cpu_to_le16(vf),
}; };
int err; int err;
...@@ -391,7 +391,7 @@ void ionic_dev_cmd_queue_identify(struct ionic_dev *idev, ...@@ -391,7 +391,7 @@ void ionic_dev_cmd_queue_identify(struct ionic_dev *idev,
{ {
union ionic_dev_cmd cmd = { union ionic_dev_cmd cmd = {
.q_identify.opcode = IONIC_CMD_Q_IDENTIFY, .q_identify.opcode = IONIC_CMD_Q_IDENTIFY,
.q_identify.lif_type = lif_type, .q_identify.lif_type = cpu_to_le16(lif_type),
.q_identify.type = qtype, .q_identify.type = qtype,
.q_identify.ver = qver, .q_identify.ver = qver,
}; };
......
...@@ -29,6 +29,7 @@ struct ionic_dev_bar { ...@@ -29,6 +29,7 @@ struct ionic_dev_bar {
int res_index; int res_index;
}; };
#ifndef __CHECKER__
/* Registers */ /* Registers */
static_assert(sizeof(struct ionic_intr) == 32); static_assert(sizeof(struct ionic_intr) == 32);
...@@ -119,6 +120,7 @@ static_assert(sizeof(struct ionic_vf_setattr_cmd) == 64); ...@@ -119,6 +120,7 @@ static_assert(sizeof(struct ionic_vf_setattr_cmd) == 64);
static_assert(sizeof(struct ionic_vf_setattr_comp) == 16); static_assert(sizeof(struct ionic_vf_setattr_comp) == 16);
static_assert(sizeof(struct ionic_vf_getattr_cmd) == 64); static_assert(sizeof(struct ionic_vf_getattr_cmd) == 64);
static_assert(sizeof(struct ionic_vf_getattr_comp) == 16); static_assert(sizeof(struct ionic_vf_getattr_comp) == 16);
#endif /* __CHECKER__ */
struct ionic_devinfo { struct ionic_devinfo {
u8 asic_type; u8 asic_type;
......
...@@ -27,9 +27,9 @@ static void ionic_dev_cmd_firmware_download(struct ionic_dev *idev, u64 addr, ...@@ -27,9 +27,9 @@ static void ionic_dev_cmd_firmware_download(struct ionic_dev *idev, u64 addr,
{ {
union ionic_dev_cmd cmd = { union ionic_dev_cmd cmd = {
.fw_download.opcode = IONIC_CMD_FW_DOWNLOAD, .fw_download.opcode = IONIC_CMD_FW_DOWNLOAD,
.fw_download.offset = offset, .fw_download.offset = cpu_to_le32(offset),
.fw_download.addr = addr, .fw_download.addr = cpu_to_le64(addr),
.fw_download.length = length .fw_download.length = cpu_to_le32(length),
}; };
ionic_dev_cmd_go(idev, &cmd); ionic_dev_cmd_go(idev, &cmd);
......
...@@ -1656,7 +1656,6 @@ static void ionic_txrx_deinit(struct ionic_lif *lif) ...@@ -1656,7 +1656,6 @@ static void ionic_txrx_deinit(struct ionic_lif *lif)
if (lif->rxqcqs) { if (lif->rxqcqs) {
for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) { for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) {
ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]);
ionic_rx_flush(&lif->rxqcqs[i]->cq);
ionic_rx_empty(&lif->rxqcqs[i]->q); ionic_rx_empty(&lif->rxqcqs[i]->q);
} }
} }
...@@ -1915,11 +1914,11 @@ static int ionic_get_vf_config(struct net_device *netdev, ...@@ -1915,11 +1914,11 @@ static int ionic_get_vf_config(struct net_device *netdev,
ret = -EINVAL; ret = -EINVAL;
} else { } else {
ivf->vf = vf; ivf->vf = vf;
ivf->vlan = ionic->vfs[vf].vlanid; ivf->vlan = le16_to_cpu(ionic->vfs[vf].vlanid);
ivf->qos = 0; ivf->qos = 0;
ivf->spoofchk = ionic->vfs[vf].spoofchk; ivf->spoofchk = ionic->vfs[vf].spoofchk;
ivf->linkstate = ionic->vfs[vf].linkstate; ivf->linkstate = ionic->vfs[vf].linkstate;
ivf->max_tx_rate = ionic->vfs[vf].maxrate; ivf->max_tx_rate = le32_to_cpu(ionic->vfs[vf].maxrate);
ivf->trusted = ionic->vfs[vf].trusted; ivf->trusted = ionic->vfs[vf].trusted;
ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr); ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr);
} }
...@@ -2019,7 +2018,7 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, ...@@ -2019,7 +2018,7 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
ret = ionic_set_vf_config(ionic, vf, ret = ionic_set_vf_config(ionic, vf,
IONIC_VF_ATTR_VLAN, (u8 *)&vlan); IONIC_VF_ATTR_VLAN, (u8 *)&vlan);
if (!ret) if (!ret)
ionic->vfs[vf].vlanid = vlan; ionic->vfs[vf].vlanid = cpu_to_le16(vlan);
} }
up_write(&ionic->vf_op_lock); up_write(&ionic->vf_op_lock);
...@@ -2048,7 +2047,7 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf, ...@@ -2048,7 +2047,7 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf,
ret = ionic_set_vf_config(ionic, vf, ret = ionic_set_vf_config(ionic, vf,
IONIC_VF_ATTR_RATE, (u8 *)&tx_max); IONIC_VF_ATTR_RATE, (u8 *)&tx_max);
if (!ret) if (!ret)
lif->ionic->vfs[vf].maxrate = tx_max; lif->ionic->vfs[vf].maxrate = cpu_to_le32(tx_max);
} }
up_write(&ionic->vf_op_lock); up_write(&ionic->vf_op_lock);
...@@ -2981,14 +2980,14 @@ void ionic_lif_unregister(struct ionic_lif *lif) ...@@ -2981,14 +2980,14 @@ void ionic_lif_unregister(struct ionic_lif *lif)
static void ionic_lif_queue_identify(struct ionic_lif *lif) static void ionic_lif_queue_identify(struct ionic_lif *lif)
{ {
union ionic_q_identity __iomem *q_ident;
struct ionic *ionic = lif->ionic; struct ionic *ionic = lif->ionic;
union ionic_q_identity *q_ident;
struct ionic_dev *idev; struct ionic_dev *idev;
int qtype; int qtype;
int err; int err;
idev = &lif->ionic->idev; idev = &lif->ionic->idev;
q_ident = (union ionic_q_identity *)&idev->dev_cmd_regs->data; q_ident = (union ionic_q_identity __iomem *)&idev->dev_cmd_regs->data;
for (qtype = 0; qtype < ARRAY_SIZE(ionic_qtype_versions); qtype++) { for (qtype = 0; qtype < ARRAY_SIZE(ionic_qtype_versions); qtype++) {
struct ionic_qtype_info *qti = &lif->qtype_info[qtype]; struct ionic_qtype_info *qti = &lif->qtype_info[qtype];
...@@ -3011,14 +3010,14 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif) ...@@ -3011,14 +3010,14 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif)
ionic_qtype_versions[qtype]); ionic_qtype_versions[qtype]);
err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
if (!err) { if (!err) {
qti->version = q_ident->version; qti->version = readb(&q_ident->version);
qti->supported = q_ident->supported; qti->supported = readb(&q_ident->supported);
qti->features = le64_to_cpu(q_ident->features); qti->features = readq(&q_ident->features);
qti->desc_sz = le16_to_cpu(q_ident->desc_sz); qti->desc_sz = readw(&q_ident->desc_sz);
qti->comp_sz = le16_to_cpu(q_ident->comp_sz); qti->comp_sz = readw(&q_ident->comp_sz);
qti->sg_desc_sz = le16_to_cpu(q_ident->sg_desc_sz); qti->sg_desc_sz = readw(&q_ident->sg_desc_sz);
qti->max_sg_elems = le16_to_cpu(q_ident->max_sg_elems); qti->max_sg_elems = readw(&q_ident->max_sg_elems);
qti->sg_desc_stride = le16_to_cpu(q_ident->sg_desc_stride); qti->sg_desc_stride = readw(&q_ident->sg_desc_stride);
} }
mutex_unlock(&ionic->dev_cmd_lock); mutex_unlock(&ionic->dev_cmd_lock);
......
...@@ -311,7 +311,7 @@ int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx) ...@@ -311,7 +311,7 @@ int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
static void ionic_dev_cmd_clean(struct ionic *ionic) static void ionic_dev_cmd_clean(struct ionic *ionic)
{ {
union ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs; union __iomem ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs;
iowrite32(0, &regs->doorbell); iowrite32(0, &regs->doorbell);
memset_io(&regs->cmd, 0, sizeof(regs->cmd)); memset_io(&regs->cmd, 0, sizeof(regs->cmd));
...@@ -333,7 +333,7 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) ...@@ -333,7 +333,7 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds)
*/ */
max_wait = jiffies + (max_seconds * HZ); max_wait = jiffies + (max_seconds * HZ);
try_again: try_again:
opcode = idev->dev_cmd_regs->cmd.cmd.opcode; opcode = readb(&idev->dev_cmd_regs->cmd.cmd.opcode);
start_time = jiffies; start_time = jiffies;
do { do {
done = ionic_dev_cmd_done(idev); done = ionic_dev_cmd_done(idev);
......
...@@ -49,7 +49,7 @@ extern const int ionic_num_stats_grps; ...@@ -49,7 +49,7 @@ extern const int ionic_num_stats_grps;
(*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) (*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset)))
#define IONIC_READ_STAT_LE64(base_ptr, desc_ptr) \ #define IONIC_READ_STAT_LE64(base_ptr, desc_ptr) \
__le64_to_cpu(*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset))) __le64_to_cpu(*((__le64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset)))
struct ionic_stat_desc { struct ionic_stat_desc {
char name[ETH_GSTRING_LEN]; char name[ETH_GSTRING_LEN];
......
...@@ -200,7 +200,7 @@ static void ionic_rx_clean(struct ionic_queue *q, ...@@ -200,7 +200,7 @@ static void ionic_rx_clean(struct ionic_queue *q,
if (likely(netdev->features & NETIF_F_RXCSUM)) { if (likely(netdev->features & NETIF_F_RXCSUM)) {
if (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC) { if (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC) {
skb->ip_summed = CHECKSUM_COMPLETE; skb->ip_summed = CHECKSUM_COMPLETE;
skb->csum = (__wsum)le16_to_cpu(comp->csum); skb->csum = (__force __wsum)le16_to_cpu(comp->csum);
stats->csum_complete++; stats->csum_complete++;
} }
} else { } else {
...@@ -253,19 +253,6 @@ static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info) ...@@ -253,19 +253,6 @@ static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
return true; return true;
} }
void ionic_rx_flush(struct ionic_cq *cq)
{
struct ionic_dev *idev = &cq->lif->ionic->idev;
u32 work_done;
work_done = ionic_cq_service(cq, cq->num_descs,
ionic_rx_service, NULL, NULL);
if (work_done)
ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
work_done, IONIC_INTR_CRED_RESET_COALESCE);
}
static int ionic_rx_page_alloc(struct ionic_queue *q, static int ionic_rx_page_alloc(struct ionic_queue *q,
struct ionic_page_info *page_info) struct ionic_page_info *page_info)
{ {
...@@ -413,22 +400,20 @@ static void ionic_rx_fill_cb(void *arg) ...@@ -413,22 +400,20 @@ static void ionic_rx_fill_cb(void *arg)
void ionic_rx_empty(struct ionic_queue *q) void ionic_rx_empty(struct ionic_queue *q)
{ {
struct ionic_desc_info *desc_info; struct ionic_desc_info *desc_info;
struct ionic_rxq_desc *desc; struct ionic_page_info *page_info;
unsigned int i; unsigned int i, j;
u16 idx;
idx = q->tail_idx;
while (idx != q->head_idx) {
desc_info = &q->info[idx];
desc = desc_info->desc;
desc->addr = 0;
desc->len = 0;
for (i = 0; i < desc_info->npages; i++) for (i = 0; i < q->num_descs; i++) {
ionic_rx_page_free(q, &desc_info->pages[i]); desc_info = &q->info[i];
for (j = 0; j < IONIC_RX_MAX_SG_ELEMS + 1; j++) {
page_info = &desc_info->pages[j];
if (page_info->page)
ionic_rx_page_free(q, page_info);
}
desc_info->npages = 0;
desc_info->cb = NULL;
desc_info->cb_arg = NULL; desc_info->cb_arg = NULL;
idx = (idx + 1) & (q->num_descs - 1);
} }
} }
...@@ -812,6 +797,7 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb) ...@@ -812,6 +797,7 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
skb_frag_t *frag; skb_frag_t *frag;
bool start, done; bool start, done;
bool outer_csum; bool outer_csum;
dma_addr_t addr;
bool has_vlan; bool has_vlan;
u16 desc_len; u16 desc_len;
u8 desc_nsge; u8 desc_nsge;
...@@ -893,11 +879,10 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb) ...@@ -893,11 +879,10 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
if (frag_left > 0) { if (frag_left > 0) {
len = min(frag_left, left); len = min(frag_left, left);
frag_left -= len; frag_left -= len;
elem->addr = addr = ionic_tx_map_frag(q, frag, offset, len);
cpu_to_le64(ionic_tx_map_frag(q, frag, if (dma_mapping_error(dev, addr))
offset, len));
if (dma_mapping_error(dev, elem->addr))
goto err_out_abort; goto err_out_abort;
elem->addr = cpu_to_le64(addr);
elem->len = cpu_to_le16(len); elem->len = cpu_to_le16(len);
elem++; elem++;
desc_nsge++; desc_nsge++;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#ifndef _IONIC_TXRX_H_ #ifndef _IONIC_TXRX_H_
#define _IONIC_TXRX_H_ #define _IONIC_TXRX_H_
void ionic_rx_flush(struct ionic_cq *cq);
void ionic_tx_flush(struct ionic_cq *cq); void ionic_tx_flush(struct ionic_cq *cq);
void ionic_rx_fill(struct ionic_queue *q); void ionic_rx_fill(struct ionic_queue *q);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment