Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp78699pxk; Wed, 30 Sep 2020 18:30:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBtA0xDVq/TOjI0yE9ofClKk1/UGzqrEqDnSYgCUguC5acKHCy4PzOGxmfJklWsLLO2/OR X-Received: by 2002:aa7:c896:: with SMTP id p22mr5656462eds.382.1601515812109; Wed, 30 Sep 2020 18:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601515812; cv=none; d=google.com; s=arc-20160816; b=aykxfXCi3w0JWlkKaOHR7lLS6Tr5AiTJPx7JXWaLovF7gFouf0BCXDXvhlyBkUNfgn +bcHbWJ09ZJVnEYAQVSRZ6XPfCqPK9oDLs7o86WCRlJlb5nLbmYaNXpRGpVEJiDuoKsT SFeVXXSYyLWgek40MHYbwC+QCrOjEtjyBRZ48+825EfXYy8jYlalntvEz5XfoV3Jjf05 lWpame8/HvOl9DXM5PZaY3Se0h6djri7HguVeQ40a7GV4v4H1Bu7YDSJvBF/keptlzfN o14f8ddzJcAfiQ89E9EkOA9z+pqhRoiqJB7CblMAKjKA0itb0Vm3PeaPGvbGKa6rTi/6 5chw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=RCiKnABAxIq6LJlqHOFCYjSXBGLDZiXcWT/nVN3ro+0=; b=YazoamqAaa6JfMAUa6Wz2wipSpFG4uqyrgSazb3RwDVAwCQE5aZsa6t2V5Ico+Q4BY rvge4g6l0gRr6qqMeWE2mtgWAbpSlBlvsvyJJdui1Y5qMkXtRfWmkQiZHt3WszgGGz8g QIwUOX1klfJDL3ruzvyQ5KBBv11t4opzvQQF7QnshUZnzi1Y9k0Xo5ybz4ReboD5OKYT 0JQQLAqrRq6qvcGCgcy36vMJRq3rPMgjKwKUk0Qsktl8xcOnlw9hIkxT2Kx0VXIJq67I zOqBTzIcDaTsdC9MR9IY2t1xoXbcwHeT5T6sv5otN6rEXrnaXowJ2X8cnUlubwtc5BO4 ywqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=f0OiNArd; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si2351686edv.36.2020.09.30.18.29.49; Wed, 30 Sep 2020 18:30:12 -0700 (PDT) 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=@broadcom.com header.s=google header.b=f0OiNArd; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730349AbgJAB2v (ORCPT + 99 others); Wed, 30 Sep 2020 21:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbgJAB2s (ORCPT ); Wed, 30 Sep 2020 21:28:48 -0400 Received: from mail-vs1-xe62.google.com (mail-vs1-xe62.google.com [IPv6:2607:f8b0:4864:20::e62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC099C0613D1 for ; Wed, 30 Sep 2020 18:28:47 -0700 (PDT) Received: by mail-vs1-xe62.google.com with SMTP id u7so1504955vsq.11 for ; Wed, 30 Sep 2020 18:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RCiKnABAxIq6LJlqHOFCYjSXBGLDZiXcWT/nVN3ro+0=; b=f0OiNArdM1UdatgbywmhF88aHsCpC4R6kuwwcB+1aKLCKVDbMY3+vEyQTHINOlfbSv LLhMkEOle3LNfK3da4Si1cZXxTlqUJ2DXsk3VFWn1kmPp0e/ljUwECHwpIlRt3r0hUdo b3E4jAhyn993kbbzGSiIIRDK0L8Qa60QEtqUM= 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; bh=RCiKnABAxIq6LJlqHOFCYjSXBGLDZiXcWT/nVN3ro+0=; b=RzW5bQoCtOkZaGSkbA7xFiWeCHecIMr1Mcj7gq/wfTXlz/NBUc4XzLlGyJy7uBcX6Q L/N3g98HRZT3VRSrp90g52bN+UdM8WaxB2XoFdFsv4lA0oojxIoIVnxi8X3zO2VcE9OU 8aYljtCqG7LvwRLY1z1jaS58JChKs72NdWL3E+zvOIY4D8QqSaMSe+oDUaSCeTCcjsVZ PCRE+MOOEI66j2Qsr2FH3X2f9Y1CiH6WiQUW2R/ScFOtXf71YS4tGoDXcyZ7r8ApDDsW h1FdolwQjorvjXtLJcRcSVXM3ZCd79lXg2wWPV96UN8AtUerCwUbCPjHdCCWrxdbT9p4 sCHQ== X-Gm-Message-State: AOAM5319Ep1w9f1tY/ZdibscceRgRs7xak94ZvygHUnX9c9lHLQCe6dQ y8Vcfe0rJG3CvxTXThDIj3wlzhn6MQ3YfJ9AIUyoW61+ipEf X-Received: by 2002:a67:e2c3:: with SMTP id i3mr3746450vsm.13.1601515726946; Wed, 30 Sep 2020 18:28:46 -0700 (PDT) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp-relay.gmail.com with ESMTPS id r25sm520472vkq.14.2020.09.30.18.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 18:28:46 -0700 (PDT) X-Relaying-Domain: broadcom.com From: Scott Branden To: Arnd Bergmann , Greg Kroah-Hartman , Scott Branden Cc: Kees Cook , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Desmond Yan Subject: [PATCH v5 05/15] misc: bcm-vk: add triggers when host panic or reboots to notify card Date: Wed, 30 Sep 2020 18:28:00 -0700 Message-Id: <20201001012810.4172-6-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201001012810.4172-1-scott.branden@broadcom.com> References: <20201001012810.4172-1-scott.branden@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pass down an interrupt to card in case of panic or reboot so that card can take appropriate action to perform a clean reset. Uses kernel notifier block either directly (register on panic list), or implicitly (add shutdown method for PCI device). Co-developed-by: Desmond Yan Signed-off-by: Desmond Yan Signed-off-by: Scott Branden --- drivers/misc/bcm-vk/bcm_vk.h | 2 ++ drivers/misc/bcm-vk/bcm_vk_dev.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/misc/bcm-vk/bcm_vk.h b/drivers/misc/bcm-vk/bcm_vk.h index 0a366db693c8..f428ad9a0c3d 100644 --- a/drivers/misc/bcm-vk/bcm_vk.h +++ b/drivers/misc/bcm-vk/bcm_vk.h @@ -223,6 +223,8 @@ struct bcm_vk { unsigned long wq_offload[1]; /* various flags on wq requested */ void *tdma_vaddr; /* test dma segment virtual addr */ dma_addr_t tdma_addr; /* test dma segment bus addr */ + + struct notifier_block panic_nb; }; /* wq offload work items bits definitions */ diff --git a/drivers/misc/bcm-vk/bcm_vk_dev.c b/drivers/misc/bcm-vk/bcm_vk_dev.c index c46591124eb4..7ff43d406950 100644 --- a/drivers/misc/bcm-vk/bcm_vk_dev.c +++ b/drivers/misc/bcm-vk/bcm_vk_dev.c @@ -630,6 +630,16 @@ static int bcm_vk_trigger_reset(struct bcm_vk *vk) return 0; } +static int bcm_vk_on_panic(struct notifier_block *nb, + unsigned long e, void *p) +{ + struct bcm_vk *vk = container_of(nb, struct bcm_vk, panic_nb); + + bcm_to_v_reset_doorbell(vk, VK_BAR0_RESET_DB_HARD); + + return 0; +} + static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err; @@ -742,6 +752,15 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* sync other info */ bcm_vk_sync_card_info(vk); + /* register for panic notifier */ + vk->panic_nb.notifier_call = bcm_vk_on_panic; + err = atomic_notifier_chain_register(&panic_notifier_list, + &vk->panic_nb); + if (err) { + dev_err(dev, "Fail to register panic notifier\n"); + goto err_destroy_workqueue; + } + /* * lets trigger an auto download. We don't want to do it serially here * because at probing time, it is not supposed to block for a long time. @@ -750,7 +769,7 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (auto_load) { if ((boot_status & BOOT_STATE_MASK) == BROM_RUNNING) { if (bcm_vk_trigger_autoload(vk)) - goto err_destroy_workqueue; + goto err_unregister_panic_notifier; } else { dev_err(dev, "Auto-load skipped - BROM not in proper state (0x%x)\n", @@ -762,6 +781,10 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; +err_unregister_panic_notifier: + atomic_notifier_chain_unregister(&panic_notifier_list, + &vk->panic_nb); + err_destroy_workqueue: destroy_workqueue(vk->wq_thread); @@ -812,6 +835,10 @@ static void bcm_vk_remove(struct pci_dev *pdev) bcm_vk_trigger_reset(vk); usleep_range(BCM_VK_UCODE_BOOT_US, BCM_VK_UCODE_BOOT_MAX_US); + /* unregister panic notifier */ + atomic_notifier_chain_unregister(&panic_notifier_list, + &vk->panic_nb); + if (vk->tdma_vaddr) dma_free_coherent(&pdev->dev, nr_scratch_pages * PAGE_SIZE, vk->tdma_vaddr, vk->tdma_addr); -- 2.17.1