Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: fsl: qbman: Add CGR update function

This adds a function to update a CGR with new parameters. qman_create_cgr
can almost be used for this (with flags=0), but it's not suitable because
it also registers the callback function. The _safe variant was modeled off
of qman_cgr_delete_safe. However, we handle multiple arguments and a return
value.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sean Anderson and committed by
David S. Miller
914f8b22 d0e17a46

+57
+48
drivers/soc/fsl/qbman/qman.c
··· 2568 2568 } 2569 2569 EXPORT_SYMBOL(qman_delete_cgr_safe); 2570 2570 2571 + static int qman_update_cgr(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts) 2572 + { 2573 + int ret; 2574 + unsigned long irqflags; 2575 + struct qman_portal *p = qman_cgr_get_affine_portal(cgr); 2576 + 2577 + if (!p) 2578 + return -EINVAL; 2579 + 2580 + spin_lock_irqsave(&p->cgr_lock, irqflags); 2581 + ret = qm_modify_cgr(cgr, 0, opts); 2582 + spin_unlock_irqrestore(&p->cgr_lock, irqflags); 2583 + put_affine_portal(); 2584 + return ret; 2585 + } 2586 + 2587 + struct update_cgr_params { 2588 + struct qman_cgr *cgr; 2589 + struct qm_mcc_initcgr *opts; 2590 + int ret; 2591 + }; 2592 + 2593 + static void qman_update_cgr_smp_call(void *p) 2594 + { 2595 + struct update_cgr_params *params = p; 2596 + 2597 + params->ret = qman_update_cgr(params->cgr, params->opts); 2598 + } 2599 + 2600 + int qman_update_cgr_safe(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts) 2601 + { 2602 + struct update_cgr_params params = { 2603 + .cgr = cgr, 2604 + .opts = opts, 2605 + }; 2606 + 2607 + preempt_disable(); 2608 + if (qman_cgr_cpus[cgr->cgrid] != smp_processor_id()) 2609 + smp_call_function_single(qman_cgr_cpus[cgr->cgrid], 2610 + qman_update_cgr_smp_call, &params, 2611 + true); 2612 + else 2613 + params.ret = qman_update_cgr(cgr, opts); 2614 + preempt_enable(); 2615 + return params.ret; 2616 + } 2617 + EXPORT_SYMBOL(qman_update_cgr_safe); 2618 + 2571 2619 /* Cleanup FQs */ 2572 2620 2573 2621 static int _qm_mr_consume_and_match_verb(struct qm_portal *p, int v)
+9
include/soc/fsl/qman.h
··· 1172 1172 void qman_delete_cgr_safe(struct qman_cgr *cgr); 1173 1173 1174 1174 /** 1175 + * qman_update_cgr_safe - Modifies a congestion group object from any CPU 1176 + * @cgr: the 'cgr' object to modify 1177 + * @opts: state of the CGR settings 1178 + * 1179 + * This will select the proper CPU and modify the CGR settings. 1180 + */ 1181 + int qman_update_cgr_safe(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts); 1182 + 1183 + /** 1175 1184 * qman_query_cgr_congested - Queries CGR's congestion status 1176 1185 * @cgr: the 'cgr' object to query 1177 1186 * @result: returns 'cgr's congestion status, 1 (true) if congested