From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C42CA0527 for ; Wed, 25 Nov 2020 10:03:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 83572C952; Wed, 25 Nov 2020 10:03:28 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id DED48C95E for ; Wed, 25 Nov 2020 10:03:24 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id 64so1080659wra.11 for ; Wed, 25 Nov 2020 01:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ve6L6GdayjiI0OBrBy61f40peSRSEHEvBTMAcKDdFDg=; b=C2UbSnp+6HCjIWdPAY6qXzyF0SaSJuAQILnB+gRGV9wNUEfiqZmvTKi+QIdGg+TbGt 4qzY7AhdtTZHbqH5wRH+95/2gE0kXY+7gg8lVpCr7o/ECmMbKJpd9a7GDURY/C5m7gWu k3F4bcRR5IHZ73KlKcd3E3wstqCz0SZ+xEGEUySspTxezzRW18h055uuJLNPW30o5jyo mFJuEYQVRwqO9fedT+JQz/EHBt0g+xcmsGLCdTw5spElFxo1eF9P2hAWC6Ytv27+yVNh on4747yHl/oR5jlIspEGJKEg9FWG8CAEzc/6OIqXTjuwjZoKxn2si2R7rVx7RaXFpdiD fEKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ve6L6GdayjiI0OBrBy61f40peSRSEHEvBTMAcKDdFDg=; b=t/9B4yolN9l+GLhLJOIkUTdWrXzmn+g3hZpElUymk8b6ND3SeChe0qnaMa7/T77Lr8 YbN73rT5HZki0KMm4IDwsAhLb+L4HeCuf6LcBo/PFi57XdaFDs9RQ2dYOTje3qMBLp/g YCXgK75PSCctJ15MxzR4/fdlH7hocGvZqkNy+PJHxoNU7DWgkotoTIz2AU07nLiBTP4P 9QITL9zHCdlzhMpLtC4mW+eW7qjrHBG+EOd/t0fLAMj0XiQOpyVMrDXkSEX9ukzX5mxC GnfmX+g6BPCG+2W/Kx5Td9wXxEJN9/MJiQC6CiKBb18IwMsEbTeLCfiaLr+n1Y+OLvU2 aY2w== X-Gm-Message-State: AOAM531irZdEHkqaliKswyLsMTC9bPI0NsmG+1TobNLgCu9n99O8qA85 iLCDAsAYTXPBA5oTS0k4YXsZQM4P+cMbtw== X-Google-Smtp-Source: ABdhPJxcK7QSQRC87WycFvIUGkG0ovnl7SfSKGxR52AB+lpjxu68DnyuNnASnxIdDM4Lvv3f2Q8q+A== X-Received: by 2002:a5d:5651:: with SMTP id j17mr2862710wrw.221.1606295004570; Wed, 25 Nov 2020 01:03:24 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id c62sm3392161wme.22.2020.11.25.01.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 01:03:23 -0800 (PST) From: luca.boccassi@gmail.com To: Shijith Thotton Cc: Pavan Nikhilesh , dpdk stable Date: Wed, 25 Nov 2020 09:02:52 +0000 Message-Id: <20201125090258.21457-10-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201125090258.21457-1-luca.boccassi@gmail.com> References: <20201117111416.1961049-42-luca.boccassi@gmail.com> <20201125090258.21457-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'event/octeontx2: unlink queues during port release' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/26/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/fac23bf6f0a0c631f17cd71762f3b79a51d56c95 Thanks. Luca Boccassi --- >From fac23bf6f0a0c631f17cd71762f3b79a51d56c95 Mon Sep 17 00:00:00 2001 From: Shijith Thotton Date: Thu, 19 Nov 2020 14:16:11 +0530 Subject: [PATCH] event/octeontx2: unlink queues during port release [ upstream commit 8e6663b8c145a3dcbd7b298b93682814973c7fcd ] Unlinking queues from port should be done during port release. Doing it during device re-configuration could result in segfault as ports array is re-allocated based on new number of ports. Fixes: f7ac8b66b23c ("event/octeontx2: support linking queues to ports") Signed-off-by: Shijith Thotton Signed-off-by: Pavan Nikhilesh --- drivers/event/octeontx2/otx2_evdev.c | 100 ++++++++++++++++----------- drivers/event/octeontx2/otx2_evdev.h | 12 ++++ 2 files changed, 72 insertions(+), 40 deletions(-) diff --git a/drivers/event/octeontx2/otx2_evdev.c b/drivers/event/octeontx2/otx2_evdev.c index f7766812bb..5bdf23c362 100644 --- a/drivers/event/octeontx2/otx2_evdev.c +++ b/drivers/event/octeontx2/otx2_evdev.c @@ -648,7 +648,36 @@ sso_lf_cfg(struct otx2_sso_evdev *dev, struct otx2_mbox *mbox, static void otx2_sso_port_release(void *port) { - rte_free(port); + struct otx2_ssogws_cookie *gws_cookie = ssogws_get_cookie(port); + struct otx2_sso_evdev *dev; + int i; + + if (!gws_cookie->configured) + goto free; + + dev = sso_pmd_priv(gws_cookie->event_dev); + if (dev->dual_ws) { + struct otx2_ssogws_dual *ws = port; + + for (i = 0; i < dev->nb_event_queues; i++) { + sso_port_link_modify((struct otx2_ssogws *) + &ws->ws_state[0], i, false); + sso_port_link_modify((struct otx2_ssogws *) + &ws->ws_state[1], i, false); + } + memset(ws, 0, sizeof(*ws)); + } else { + struct otx2_ssogws *ws = port; + + for (i = 0; i < dev->nb_event_queues; i++) + sso_port_link_modify(ws, i, false); + memset(ws, 0, sizeof(*ws)); + } + + memset(gws_cookie, 0, sizeof(*gws_cookie)); + +free: + rte_free(gws_cookie); } static void @@ -658,33 +687,6 @@ otx2_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id) RTE_SET_USED(queue_id); } -static void -sso_clr_links(const struct rte_eventdev *event_dev) -{ - struct otx2_sso_evdev *dev = sso_pmd_priv(event_dev); - int i, j; - - for (i = 0; i < dev->nb_event_ports; i++) { - if (dev->dual_ws) { - struct otx2_ssogws_dual *ws; - - ws = event_dev->data->ports[i]; - for (j = 0; j < dev->nb_event_queues; j++) { - sso_port_link_modify((struct otx2_ssogws *) - &ws->ws_state[0], j, false); - sso_port_link_modify((struct otx2_ssogws *) - &ws->ws_state[1], j, false); - } - } else { - struct otx2_ssogws *ws; - - ws = event_dev->data->ports[i]; - for (j = 0; j < dev->nb_event_queues; j++) - sso_port_link_modify(ws, j, false); - } - } -} - static void sso_restore_links(const struct rte_eventdev *event_dev) { @@ -762,6 +764,7 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) } for (i = 0; i < dev->nb_event_ports; i++) { + struct otx2_ssogws_cookie *gws_cookie; struct otx2_ssogws_dual *ws; uintptr_t base; @@ -770,14 +773,20 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) } else { /* Allocate event port memory */ ws = rte_zmalloc_socket("otx2_sso_ws", - sizeof(struct otx2_ssogws_dual), + sizeof(struct otx2_ssogws_dual) + + RTE_CACHE_LINE_SIZE, RTE_CACHE_LINE_SIZE, event_dev->data->socket_id); - } - if (ws == NULL) { - otx2_err("Failed to alloc memory for port=%d", i); - rc = -ENOMEM; - break; + if (ws == NULL) { + otx2_err("Failed to alloc memory for port=%d", + i); + rc = -ENOMEM; + break; + } + + /* First cache line is reserved for cookie */ + ws = (struct otx2_ssogws_dual *) + ((uint8_t *)ws + RTE_CACHE_LINE_SIZE); } ws->port = i; @@ -789,6 +798,10 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) sso_set_port_ops((struct otx2_ssogws *)&ws->ws_state[1], base); vws++; + gws_cookie = ssogws_get_cookie(ws); + gws_cookie->event_dev = event_dev; + gws_cookie->configured = 1; + event_dev->data->ports[i] = ws; } @@ -825,19 +838,21 @@ sso_configure_ports(const struct rte_eventdev *event_dev) } for (i = 0; i < nb_lf; i++) { + struct otx2_ssogws_cookie *gws_cookie; struct otx2_ssogws *ws; uintptr_t base; /* Free memory prior to re-allocation if needed */ if (event_dev->data->ports[i] != NULL) { ws = event_dev->data->ports[i]; - rte_free(ws); + rte_free(ssogws_get_cookie(ws)); ws = NULL; } /* Allocate event port memory */ ws = rte_zmalloc_socket("otx2_sso_ws", - sizeof(struct otx2_ssogws), + sizeof(struct otx2_ssogws) + + RTE_CACHE_LINE_SIZE, RTE_CACHE_LINE_SIZE, event_dev->data->socket_id); if (ws == NULL) { @@ -846,10 +861,18 @@ sso_configure_ports(const struct rte_eventdev *event_dev) break; } + /* First cache line is reserved for cookie */ + ws = (struct otx2_ssogws *) + ((uint8_t *)ws + RTE_CACHE_LINE_SIZE); + ws->port = i; base = dev->bar2 + (RVU_BLOCK_ADDR_SSOW << 20 | i << 12); sso_set_port_ops(ws, base); + gws_cookie = ssogws_get_cookie(ws); + gws_cookie->event_dev = event_dev; + gws_cookie->configured = 1; + event_dev->data->ports[i] = ws; } @@ -1058,11 +1081,8 @@ otx2_sso_configure(const struct rte_eventdev *event_dev) return -EINVAL; } - if (dev->configured) { + if (dev->configured) sso_unregister_irqs(event_dev); - /* Clear any prior port-queue mapping. */ - sso_clr_links(event_dev); - } if (dev->nb_event_queues) { /* Finit any previous queues. */ diff --git a/drivers/event/octeontx2/otx2_evdev.h b/drivers/event/octeontx2/otx2_evdev.h index ef523dc9da..e134ea5ea3 100644 --- a/drivers/event/octeontx2/otx2_evdev.h +++ b/drivers/event/octeontx2/otx2_evdev.h @@ -212,6 +212,18 @@ sso_pmd_priv(const struct rte_eventdev *event_dev) return event_dev->data->dev_private; } +struct otx2_ssogws_cookie { + const struct rte_eventdev *event_dev; + bool configured; +}; + +static inline struct otx2_ssogws_cookie * +ssogws_get_cookie(void *ws) +{ + return (struct otx2_ssogws_cookie *) + ((uint8_t *)ws - RTE_CACHE_LINE_SIZE); +} + static const union mbuf_initializer mbuf_init = { .fields = { .data_off = RTE_PKTMBUF_HEADROOM, -- 2.27.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-24 16:50:36.988893850 +0000 +++ 0010-event-octeontx2-unlink-queues-during-port-release.patch 2020-11-24 16:50:36.569496315 +0000 @@ -1 +1 @@ -From 8e6663b8c145a3dcbd7b298b93682814973c7fcd Mon Sep 17 00:00:00 2001 +From fac23bf6f0a0c631f17cd71762f3b79a51d56c95 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 8e6663b8c145a3dcbd7b298b93682814973c7fcd ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -16,4 +17,3 @@ - drivers/event/octeontx2/otx2_evdev.c | 100 ++++++++++++--------- - drivers/event/octeontx2/otx2_evdev.h | 12 +++ - drivers/event/octeontx2/otx2_evdev_adptr.c | 24 +++-- - 3 files changed, 89 insertions(+), 47 deletions(-) + drivers/event/octeontx2/otx2_evdev.c | 100 ++++++++++++++++----------- + drivers/event/octeontx2/otx2_evdev.h | 12 ++++ + 2 files changed, 72 insertions(+), 40 deletions(-) @@ -22 +22 @@ -index c1a5916cd2..0fe014c24a 100644 +index f7766812bb..5bdf23c362 100644 @@ -25 +25 @@ -@@ -689,7 +689,36 @@ sso_lf_cfg(struct otx2_sso_evdev *dev, struct otx2_mbox *mbox, +@@ -648,7 +648,36 @@ sso_lf_cfg(struct otx2_sso_evdev *dev, struct otx2_mbox *mbox, @@ -63 +63 @@ -@@ -699,33 +728,6 @@ otx2_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id) +@@ -658,33 +687,6 @@ otx2_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id) @@ -97 +97 @@ -@@ -803,6 +805,7 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) +@@ -762,6 +764,7 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) @@ -105 +105 @@ -@@ -811,14 +814,20 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) +@@ -770,14 +773,20 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) @@ -132 +132 @@ -@@ -830,6 +839,10 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) +@@ -789,6 +798,10 @@ sso_configure_dual_ports(const struct rte_eventdev *event_dev) @@ -143 +143 @@ -@@ -866,19 +879,21 @@ sso_configure_ports(const struct rte_eventdev *event_dev) +@@ -825,19 +838,21 @@ sso_configure_ports(const struct rte_eventdev *event_dev) @@ -167 +167 @@ -@@ -887,10 +902,18 @@ sso_configure_ports(const struct rte_eventdev *event_dev) +@@ -846,10 +861,18 @@ sso_configure_ports(const struct rte_eventdev *event_dev) @@ -186 +186 @@ -@@ -1099,11 +1122,8 @@ otx2_sso_configure(const struct rte_eventdev *event_dev) +@@ -1058,11 +1081,8 @@ otx2_sso_configure(const struct rte_eventdev *event_dev) @@ -200 +200 @@ -index d0f5b3fcf0..0513cb81c9 100644 +index ef523dc9da..e134ea5ea3 100644 @@ -203 +203 @@ -@@ -217,6 +217,18 @@ sso_pmd_priv(const struct rte_eventdev *event_dev) +@@ -212,6 +212,18 @@ sso_pmd_priv(const struct rte_eventdev *event_dev) @@ -222,55 +221,0 @@ -diff --git a/drivers/event/octeontx2/otx2_evdev_adptr.c b/drivers/event/octeontx2/otx2_evdev_adptr.c -index 0a5d7924ad..d69f269df6 100644 ---- a/drivers/event/octeontx2/otx2_evdev_adptr.c -+++ b/drivers/event/octeontx2/otx2_evdev_adptr.c -@@ -453,9 +453,10 @@ sso_add_tx_queue_data(const struct rte_eventdev *event_dev, - struct otx2_ssogws_dual *dws; - - old_dws = event_dev->data->ports[i]; -- dws = rte_realloc_socket(old_dws, -+ dws = rte_realloc_socket(ssogws_get_cookie(old_dws), - sizeof(struct otx2_ssogws_dual) -- + (sizeof(uint64_t) * -+ + RTE_CACHE_LINE_SIZE + -+ (sizeof(uint64_t) * - (dev->max_port_id + 1) * - RTE_MAX_QUEUES_PER_PORT), - RTE_CACHE_LINE_SIZE, -@@ -463,6 +464,10 @@ sso_add_tx_queue_data(const struct rte_eventdev *event_dev, - if (dws == NULL) - return -ENOMEM; - -+ /* First cache line is reserved for cookie */ -+ dws = (struct otx2_ssogws_dual *) -+ ((uint8_t *)dws + RTE_CACHE_LINE_SIZE); -+ - ((uint64_t (*)[RTE_MAX_QUEUES_PER_PORT] - )&dws->tx_adptr_data)[eth_port_id][tx_queue_id] = - (uint64_t)txq; -@@ -472,16 +477,21 @@ sso_add_tx_queue_data(const struct rte_eventdev *event_dev, - struct otx2_ssogws *ws; - - old_ws = event_dev->data->ports[i]; -- ws = rte_realloc_socket(old_ws, -- sizeof(struct otx2_ssogws_dual) -- + (sizeof(uint64_t) * -- (dev->max_port_id + 1) * -- RTE_MAX_QUEUES_PER_PORT), -+ ws = rte_realloc_socket(ssogws_get_cookie(old_ws), -+ sizeof(struct otx2_ssogws) + -+ RTE_CACHE_LINE_SIZE + -+ (sizeof(uint64_t) * -+ (dev->max_port_id + 1) * -+ RTE_MAX_QUEUES_PER_PORT), - RTE_CACHE_LINE_SIZE, - event_dev->data->socket_id); - if (ws == NULL) - return -ENOMEM; - -+ /* First cache line is reserved for cookie */ -+ ws = (struct otx2_ssogws *) -+ ((uint8_t *)ws + RTE_CACHE_LINE_SIZE); -+ - ((uint64_t (*)[RTE_MAX_QUEUES_PER_PORT] - )&ws->tx_adptr_data)[eth_port_id][tx_queue_id] = - (uint64_t)txq;