mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 12:35:52 +02:00
Merge branch 'bug-fixes-from-xdp-and-perout-series'
Meghana Malladi says: ==================== Bug fixes from XDP and perout series This patch series consists of bug fixes from the XDP series: 1. Fixes a kernel warning that occurs when bringing down the network interface. 2. Resolves a potential NULL pointer dereference in the emac_xmit_xdp_frame() function. 3. Resolves a potential NULL pointer dereference in the icss_iep_perout_enable() function v3: https://lore.kernel.org/all/20250328102403.2626974-1-m-malladi@ti.com/ ==================== Link: https://patch.msgid.link/20250415090543.717991-1-m-malladi@ti.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
f49a372361
|
|
@ -412,6 +412,22 @@ static int icss_iep_perout_enable_hw(struct icss_iep *iep,
|
|||
int ret;
|
||||
u64 cmp;
|
||||
|
||||
if (!on) {
|
||||
/* Disable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), 0);
|
||||
|
||||
/* clear CMP regs */
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG0, 0);
|
||||
if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG1, 0);
|
||||
|
||||
/* Disable sync */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculate width of the signal for PPS/PEROUT handling */
|
||||
ts.tv_sec = req->on.sec;
|
||||
ts.tv_nsec = req->on.nsec;
|
||||
|
|
@ -430,64 +446,39 @@ static int icss_iep_perout_enable_hw(struct icss_iep *iep,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (on) {
|
||||
/* Configure CMP */
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG0, lower_32_bits(cmp));
|
||||
if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG1, upper_32_bits(cmp));
|
||||
/* Configure SYNC, based on req on width */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
|
||||
div_u64(ns_width, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC0_PERIOD_REG, 0);
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
|
||||
div_u64(ns_start, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0); /* one-shot mode */
|
||||
/* Enable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
|
||||
} else {
|
||||
/* Disable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), 0);
|
||||
|
||||
/* clear regs */
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG0, 0);
|
||||
if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG1, 0);
|
||||
}
|
||||
/* Configure CMP */
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG0, lower_32_bits(cmp));
|
||||
if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG1, upper_32_bits(cmp));
|
||||
/* Configure SYNC, based on req on width */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
|
||||
div_u64(ns_width, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC0_PERIOD_REG, 0);
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
|
||||
div_u64(ns_start, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0); /* one-shot mode */
|
||||
/* Enable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
|
||||
} else {
|
||||
if (on) {
|
||||
u64 start_ns;
|
||||
u64 start_ns;
|
||||
|
||||
iep->period = ((u64)req->period.sec * NSEC_PER_SEC) +
|
||||
req->period.nsec;
|
||||
start_ns = ((u64)req->period.sec * NSEC_PER_SEC)
|
||||
+ req->period.nsec;
|
||||
icss_iep_update_to_next_boundary(iep, start_ns);
|
||||
iep->period = ((u64)req->period.sec * NSEC_PER_SEC) +
|
||||
req->period.nsec;
|
||||
start_ns = ((u64)req->period.sec * NSEC_PER_SEC)
|
||||
+ req->period.nsec;
|
||||
icss_iep_update_to_next_boundary(iep, start_ns);
|
||||
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
|
||||
div_u64(ns_width, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
|
||||
div_u64(ns_start, iep->def_inc));
|
||||
/* Enable Sync in single shot mode */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG,
|
||||
IEP_SYNC_CTRL_SYNC_N_EN(0) | IEP_SYNC_CTRL_SYNC_EN);
|
||||
/* Enable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
|
||||
} else {
|
||||
/* Disable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), 0);
|
||||
|
||||
/* clear CMP regs */
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG0, 0);
|
||||
if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
|
||||
regmap_write(iep->map, ICSS_IEP_CMP1_REG1, 0);
|
||||
|
||||
/* Disable sync */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0);
|
||||
}
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
|
||||
div_u64(ns_width, iep->def_inc));
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
|
||||
div_u64(ns_start, iep->def_inc));
|
||||
/* Enable Sync in single shot mode */
|
||||
regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG,
|
||||
IEP_SYNC_CTRL_SYNC_N_EN(0) | IEP_SYNC_CTRL_SYNC_EN);
|
||||
/* Enable CMP 1 */
|
||||
regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
|
||||
IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -498,11 +489,21 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!on)
|
||||
goto disable;
|
||||
|
||||
/* Reject requests with unsupported flags */
|
||||
if (req->flags & ~(PTP_PEROUT_DUTY_CYCLE |
|
||||
PTP_PEROUT_PHASE))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Set default "on" time (1ms) for the signal if not passed by the app */
|
||||
if (!(req->flags & PTP_PEROUT_DUTY_CYCLE)) {
|
||||
req->on.sec = 0;
|
||||
req->on.nsec = NSEC_PER_MSEC;
|
||||
}
|
||||
|
||||
disable:
|
||||
mutex_lock(&iep->ptp_clk_mutex);
|
||||
|
||||
if (iep->pps_enabled) {
|
||||
|
|
@ -513,12 +514,6 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
|
|||
if (iep->perout_enabled == !!on)
|
||||
goto exit;
|
||||
|
||||
/* Set default "on" time (1ms) for the signal if not passed by the app */
|
||||
if (!(req->flags & PTP_PEROUT_DUTY_CYCLE)) {
|
||||
req->on.sec = 0;
|
||||
req->on.nsec = NSEC_PER_MSEC;
|
||||
}
|
||||
|
||||
ret = icss_iep_perout_enable_hw(iep, req, on);
|
||||
if (!ret)
|
||||
iep->perout_enabled = !!on;
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,
|
|||
first_desc = k3_cppi_desc_pool_alloc(tx_chn->desc_pool);
|
||||
if (!first_desc) {
|
||||
netdev_dbg(ndev, "xdp tx: failed to allocate descriptor\n");
|
||||
goto drop_free_descs; /* drop */
|
||||
return ICSSG_XDP_CONSUMED; /* drop */
|
||||
}
|
||||
|
||||
if (page) { /* already DMA mapped by page_pool */
|
||||
|
|
@ -671,8 +671,10 @@ static u32 emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
|
|||
|
||||
q_idx = smp_processor_id() % emac->tx_ch_num;
|
||||
result = emac_xmit_xdp_frame(emac, xdpf, page, q_idx);
|
||||
if (result == ICSSG_XDP_CONSUMED)
|
||||
if (result == ICSSG_XDP_CONSUMED) {
|
||||
ndev->stats.tx_dropped++;
|
||||
goto drop;
|
||||
}
|
||||
|
||||
dev_sw_netstats_rx_add(ndev, xdpf->len);
|
||||
return result;
|
||||
|
|
@ -1215,9 +1217,6 @@ void prueth_reset_rx_chan(struct prueth_rx_chn *chn,
|
|||
prueth_rx_cleanup);
|
||||
if (disable)
|
||||
k3_udma_glue_disable_rx_chn(chn->rx_chn);
|
||||
|
||||
page_pool_destroy(chn->pg_pool);
|
||||
chn->pg_pool = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(prueth_reset_rx_chan);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user