Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3308056pxx; Mon, 2 Nov 2020 05:44:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4LyRi/nHJBM+VqgsH3CNF4pjpBNXJR7N/+gHRS8TJ5unMDjkekDNWeciaCIbkpSM1CsTT X-Received: by 2002:a50:e686:: with SMTP id z6mr8882768edm.188.1604324682839; Mon, 02 Nov 2020 05:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604324682; cv=none; d=google.com; s=arc-20160816; b=dJ0GgYyX3cmUnAdIIOtl3s4/2EWwA6Sirg9HkPLQi7OzS5+BM2TYuOibfgcn3ULbPi QGYjUtBwkLp93UjS2AfK770S9EW2Eoiloe9IRvk4IO9h6nxLaB/oQrJ9DyZMYQ/tke+s G1P7VGa7SfPq2fov5akqeJ2XZRJWPCKGBmkRow541V2rpcDjBrfbbPv/9dh1nIjlLUcl Tv33JePdKHf0um3EBV/Cxn4kyVOQYedA+YIdL1t8TVcRgKvuAWNm5FRABhIGE2gafsYO wJJUIzdChSfV3j95Kg/4kiiF810H3+eJxK3Y/2XOi+yjnuxkctxKQQW+LqCnR/G5ZjUR 8xng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w7fhUV+6bBDwIWvWYWm4qzgc2Tgg6Ck17a0sKop4sS4=; b=AEu5RuGl6joNLfce0ZdhQDbtZaDvDEFIVUKvdD73jzfDdDuIEuGrj0R0CviPfkxxRs em5EgFtPS8zAI2XG/Ag8pDKNjGcAEkntwyXIMh56Wyt2YW9hFt89gNN1navkjiYLxEIi C8JNBvDLlmcuokQyPI6LVZgxmpYCTAmFUW6NgsLGismMgBOQB+1zII6DoEHevyCcaTNM iQGBjr9IAzuAoYXnl+KGw3yBZc4vb9y/qhhLhH4T3CXqfidB7Zaq5q6sWCQAlVaYHPAI ZCUkfV2NCxuHiYy9vqBV0QcM95DySKpEhff3qG0TYn0ChovlhY2QqMyXBHT3RV5p0fkN 1IqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ic6XVrrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si11851460edn.361.2020.11.02.05.44.20; Mon, 02 Nov 2020 05:44:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ic6XVrrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgKBNmn (ORCPT + 99 others); Mon, 2 Nov 2020 08:42:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgKBNmn (ORCPT ); Mon, 2 Nov 2020 08:42:43 -0500 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52402C0617A6 for ; Mon, 2 Nov 2020 05:42:43 -0800 (PST) Received: by mail-vs1-xe41.google.com with SMTP id r14so2518190vsa.13 for ; Mon, 02 Nov 2020 05:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w7fhUV+6bBDwIWvWYWm4qzgc2Tgg6Ck17a0sKop4sS4=; b=Ic6XVrrBWhp30/aoiO7OZXxb0hU/e+26QEREmZFnngioZVXv0LNA2W+FFJpdfHDENo 9EDGeWpnUqH8JyuOUsfoEmnK84AyYCCj9yRhQWbitjaGAN8zB3MrAnT1sqOXmvpDcIrt /7AbcI4p4vNJdTronx+CJ+PBALWtyRL0xcDNXHi904Ag0OlHm1PvFh/oNCA53Wo6259m Esz1sHfLuaC5SYWkTtYj8F8NstcHMuAvaToxr2adBsMOdaZnjCBmfaQXPrZZzpGb1FU9 fTX9Eqf7wxxZYwJhqWspA/CIuV4MkTM8H2iY0SOoveRZZ4WlsgJXoKqaRFSYFGKHoC50 JNTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w7fhUV+6bBDwIWvWYWm4qzgc2Tgg6Ck17a0sKop4sS4=; b=aq/TrscfB/zI6S/Cb0rorT+6z5ucqH2i9BuSR62UaXf4Kl1RkpCWiDIqHAXHe9De+q clL7NFGwBTL220YC04P5jhRkkX44FV7iTs0gmutYpw4vCWwxpJfVYMA0uiJAGZjWUajR pRCbiY4DbadocTFwcsDwLv2+WrJlaRYNXfr+6aWYIfHCOeQC7id9EfWDhTZmALKaxhG6 RAl7L6HRIrkt5+EySkxXBikI9qrQkTxcB2i2CSLsgSr+rnD9GiCsXwXc0Brg5/Jd5t1h 5yKcx2p5MQNH0Vv7exDq3aEBACJT07EHdknKGVuQhXwKAspOJft1Vz/Clx9bQX/I7+6B S76w== X-Gm-Message-State: AOAM533trU0+sZA5GvKAY3KZySkpZ/cFPsuDaNDpVPX0quA+8MiEMbAv 6NPlqEenG1F8e6Ray6sfRrl6HtG7bNc= X-Received: by 2002:a67:3256:: with SMTP id y83mr8621998vsy.48.1604324561524; Mon, 02 Nov 2020 05:42:41 -0800 (PST) Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com. [209.85.217.46]) by smtp.gmail.com with ESMTPSA id 15sm1830412vkx.19.2020.11.02.05.42.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Nov 2020 05:42:40 -0800 (PST) Received: by mail-vs1-f46.google.com with SMTP id b129so7475153vsb.1 for ; Mon, 02 Nov 2020 05:42:40 -0800 (PST) X-Received: by 2002:a67:c981:: with SMTP id y1mr13655657vsk.14.1604324559568; Mon, 02 Nov 2020 05:42:39 -0800 (PST) MIME-Version: 1.0 References: <20201102050649.2188434-1-george.cherian@marvell.com> <20201102050649.2188434-3-george.cherian@marvell.com> In-Reply-To: <20201102050649.2188434-3-george.cherian@marvell.com> From: Willem de Bruijn Date: Mon, 2 Nov 2020 08:42:03 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [net-next PATCH 2/3] octeontx2-af: Add devlink health reporters for NPA To: George Cherian Cc: Network Development , linux-kernel , Jakub Kicinski , David Miller , sgoutham@marvell.com, lcherian@marvell.com, gakula@marvell.com, masahiroy@kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 2, 2020 at 12:07 AM George Cherian wrote: > > Add health reporters for RVU NPA block. > Only reporter dump is supported > > Output: > # devlink health > pci/0002:01:00.0: > reporter npa > state healthy error 0 recover 0 > # devlink health dump show pci/0002:01:00.0 reporter npa > NPA_AF_GENERAL: > Unmap PF Error: 0 > Free Disabled for NIX0 RX: 0 > Free Disabled for NIX0 TX: 0 > Free Disabled for NIX1 RX: 0 > Free Disabled for NIX1 TX: 0 > Free Disabled for SSO: 0 > Free Disabled for TIM: 0 > Free Disabled for DPI: 0 > Free Disabled for AURA: 0 > Alloc Disabled for Resvd: 0 > NPA_AF_ERR: > Memory Fault on NPA_AQ_INST_S read: 0 > Memory Fault on NPA_AQ_RES_S write: 0 > AQ Doorbell Error: 0 > Poisoned data on NPA_AQ_INST_S read: 0 > Poisoned data on NPA_AQ_RES_S write: 0 > Poisoned data on HW context read: 0 > NPA_AF_RVU: > Unmap Slot Error: 0 > > Signed-off-by: Sunil Kovvuri Goutham > Signed-off-by: Jerin Jacob > Signed-off-by: George Cherian > +static bool rvu_npa_af_request_irq(struct rvu *rvu, int blkaddr, int offset, > + const char *name, irq_handler_t fn) > +{ > + struct rvu_devlink *rvu_dl = rvu->rvu_dl; > + int rc; > + > + WARN_ON(rvu->irq_allocated[offset]); Please use WARN_ON sparingly for important unrecoverable events. This seems like a basic precondition. If it can happen at all, can probably catch in a normal branch with a netdev_err. The stacktrace in the oops is not likely to point at the source of the non-zero value, anyway. > + rvu->irq_allocated[offset] = false; Why initialize this here? Are these fields not zeroed on alloc? Is this here only to safely call rvu_npa_unregister_interrupts on partial alloc? Then it might be simpler to just have jump labels in this function to free the successfully requested irqs. > + sprintf(&rvu->irq_name[offset * NAME_SIZE], name); > + rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0, > + &rvu->irq_name[offset * NAME_SIZE], rvu_dl); > + if (rc) > + dev_warn(rvu->dev, "Failed to register %s irq\n", name); > + else > + rvu->irq_allocated[offset] = true; > + > + return rvu->irq_allocated[offset]; > +} > +static int rvu_npa_health_reporters_create(struct rvu_devlink *rvu_dl) > +{ > + struct devlink_health_reporter *rvu_npa_health_reporter; > + struct rvu_npa_event_cnt *npa_event_count; > + struct rvu *rvu = rvu_dl->rvu; > + > + npa_event_count = kzalloc(sizeof(*npa_event_count), GFP_KERNEL); > + if (!npa_event_count) > + return -ENOMEM; > + > + rvu_dl->npa_event_cnt = npa_event_count; > + rvu_npa_health_reporter = devlink_health_reporter_create(rvu_dl->dl, > + &rvu_npa_hw_fault_reporter_ops, > + 0, rvu); > + if (IS_ERR(rvu_npa_health_reporter)) { > + dev_warn(rvu->dev, "Failed to create npa reporter, err =%ld\n", > + PTR_ERR(rvu_npa_health_reporter)); > + return PTR_ERR(rvu_npa_health_reporter); > + } > + > + rvu_dl->rvu_npa_health_reporter = rvu_npa_health_reporter; > + return 0; > +} > + > +static void rvu_npa_health_reporters_destroy(struct rvu_devlink *rvu_dl) > +{ > + if (!rvu_dl->rvu_npa_health_reporter) > + return; > + > + devlink_health_reporter_destroy(rvu_dl->rvu_npa_health_reporter); > +} > + > +static int rvu_health_reporters_create(struct rvu *rvu) > +{ > + struct rvu_devlink *rvu_dl; > + > + if (!rvu->rvu_dl) > + return -EINVAL; > + > + rvu_dl = rvu->rvu_dl; > + return rvu_npa_health_reporters_create(rvu_dl); No need for local var rvu_dl. Here and below. Without that, the entire helper is probably not needed. > +} > + > +static void rvu_health_reporters_destroy(struct rvu *rvu) > +{ > + struct rvu_devlink *rvu_dl; > + > + if (!rvu->rvu_dl) > + return; > + > + rvu_dl = rvu->rvu_dl; > + rvu_npa_health_reporters_destroy(rvu_dl); > +} > + > static int rvu_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, > struct netlink_ext_ack *extack) > { > @@ -53,7 +483,8 @@ int rvu_register_dl(struct rvu *rvu) > rvu_dl->dl = dl; > rvu_dl->rvu = rvu; > rvu->rvu_dl = rvu_dl; > - return 0; > + > + return rvu_health_reporters_create(rvu); when would this be called with rvu->rvu_dl == NULL?