From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8072DA00C4; Wed, 2 Nov 2022 07:52:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FB7540693; Wed, 2 Nov 2022 07:52:16 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id EAB2240223 for ; Wed, 2 Nov 2022 07:52:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667371934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nA6RWnnouEZ7ln2K/qVplAqFgWDjVdP+ztkVoB2FYxs=; b=VcJgNrOPipDgZ0ppGaq9MDaJVebVXyhRZstWyVa4ddLsJUeulH6PGkBZJUcgDalBUrHhlm CNnrcDhEsvId0y4i6BYTas2xpC85Q+P38EE6zJljF0RNFagQyFLEFKfXoq1aggRTdvaj7L rYk3IGCZA+rR9ZnC8wer2FN0hM94diQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-6gvZ52XbMQeIyJVZD_wkIQ-1; Wed, 02 Nov 2022 02:52:12 -0400 X-MC-Unique: 6gvZ52XbMQeIyJVZD_wkIQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF7A22932493; Wed, 2 Nov 2022 06:52:11 +0000 (UTC) Received: from [10.39.208.11] (unknown [10.39.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCC9D141511F; Wed, 2 Nov 2022 06:52:10 +0000 (UTC) Message-ID: Date: Wed, 2 Nov 2022 07:52:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v1 3/6] baseband/acc: fix to acc200 access corner case To: Nicolas Chautru , dev@dpdk.org, gakhil@marvell.com, hernan.vargas@intel.com References: <20221101230459.50891-1-nicolas.chautru@intel.com> <20221101230459.50891-4-nicolas.chautru@intel.com> From: Maxime Coquelin In-Reply-To: <20221101230459.50891-4-nicolas.chautru@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 11/2/22 00:04, Nicolas Chautru wrote: > To enforce safe access to the ACC200 device, the PMD requires > to explicitly check that the device is in configured and > enabled state prior to accessing queue resources. > This is done by checking the Qmgr ingress queue status. > > Fixes: 40e3adbdd3 ("baseband/acc200: add queue configuration") > > Signed-off-by: Nicolas Chautru > --- > drivers/baseband/acc/rte_acc200_pmd.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/baseband/acc/rte_acc200_pmd.c b/drivers/baseband/acc/rte_acc200_pmd.c > index 76a5986448..10511d8b56 100644 > --- a/drivers/baseband/acc/rte_acc200_pmd.c > +++ b/drivers/baseband/acc/rte_acc200_pmd.c > @@ -172,6 +172,21 @@ updateQtop(uint8_t acc, uint8_t qg, struct rte_acc_conf *acc_conf, struct acc_de > } > } > > +/* Check device Qmgr is enabled for protection */ > +static inline bool > +acc200_check_device_enable(struct rte_bbdev *dev) > +{ > + uint32_t reg_aq, qg; > + struct acc_device *d = dev->data->dev_private; > + > + for (qg = 0; qg < ACC200_NUM_QGRPS; qg++) { > + reg_aq = acc_reg_read(d, queue_offset(d->pf_device, 0, qg, 0)); > + if (reg_aq & ACC_QUEUE_ENABLE) > + return true; > + } > + return false; > +} > + > /* Fetch configuration enabled for the PF/VF using MMIO Read (slow). */ > static inline void > fetch_acc200_config(struct rte_bbdev *dev) > @@ -190,6 +205,12 @@ fetch_acc200_config(struct rte_bbdev *dev) > if (d->configured) > return; > > + if (!acc200_check_device_enable(dev)) { > + rte_bbdev_log(NOTICE, "%s has no queue enabled and can't be used.", > + dev->data->name); > + return; > + } > + > /* Choose correct registry addresses for the device type. */ > if (d->pf_device) > reg_addr = &pf_reg_addr; > @@ -454,6 +475,12 @@ acc200_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id) > return -ENODEV; > } > > + if (!acc200_check_device_enable(dev)) { > + rte_bbdev_log(NOTICE, "%s has no queue enabled and can't be used.", > + dev->data->name); > + return -ENODEV; > + } > + > alloc_sw_rings_min_mem(dev, d, num_queues, socket_id); > > /* If minimal memory space approach failed, then allocate Reviewed-by: Maxime Coquelin Thanks, Maxime