From patchwork Tue Apr 14 16:41:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 11488603 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 107FC81 for ; Tue, 14 Apr 2020 16:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC53D20737 for ; Tue, 14 Apr 2020 16:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586882573; bh=TTNv/zBcssUd74g7e5HBVWNfIQE66LmUlzcnYLSncuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vo4wcLOFAho61EXLKA790/cgKbJfoe/Y9Y4K+Q/eNZD0T1vUYB0X4EdQECSfhssme 1JK69BumTPrfKBqcnOSMH4qj5IS+s/Pce89y3ghgsXAnks4gjCbKfdxUpbKCYeBGW3 FPzF+Hna6aQ1UCuDJ15wBiaZSy2W1N8qXhrQGk7M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407485AbgDNQmu (ORCPT ); Tue, 14 Apr 2020 12:42:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407453AbgDNQmb (ORCPT ); Tue, 14 Apr 2020 12:42:31 -0400 Received: from localhost.localdomain (unknown [122.167.127.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64B11206E9; Tue, 14 Apr 2020 16:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586882551; bh=TTNv/zBcssUd74g7e5HBVWNfIQE66LmUlzcnYLSncuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b3vj97U4V8++qv3mMbyRL8A3QwAY0eeMLtIgZT1zqX7n2V8520HaJu37Pi1GDaNJY GQ0W1mrT77Cqci1FxQdlPTis7FEtS6GKMw9XavUWMm0Iay1wxK1PoNIVO1N28e2Fww 7gV//4hpDkf6P8eEAo/pfg+fR0xip4BAUfzaelPc= From: Vinod Koul To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Vinod Koul , Yoshihiro Shimoda , Christian Lamparter , John Stultz , Alan Stern , =?utf-8?q?Andreas_B=C3=B6hler?= , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 5/5] usb: xhci: provide a debugfs hook for erasing rom Date: Tue, 14 Apr 2020 22:11:52 +0530 Message-Id: <20200414164152.2786474-6-vkoul@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414164152.2786474-1-vkoul@kernel.org> References: <20200414164152.2786474-1-vkoul@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org run "echo 1 > /sys/kernel/debug/renesas-usb/rom_erase" to erase firmware when driver is loaded. Subsequent init of driver shall reload the firmware Signed-off-by: Vinod Koul --- drivers/usb/host/xhci-pci-renesas.c | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c index b321d55f1e24..c7e18e70f0f8 100644 --- a/drivers/usb/host/xhci-pci-renesas.c +++ b/drivers/usb/host/xhci-pci-renesas.c @@ -2,6 +2,7 @@ /* Copyright (C) 2019-2020 Linaro Limited */ #include +#include #include #include #include @@ -160,6 +161,8 @@ static int renesas_fw_verify(const void *fw_data, return 0; } +static void debugfs_init(struct pci_dev *pdev); + static bool renesas_check_rom(struct pci_dev *pdev) { u16 rom_status; @@ -173,6 +176,7 @@ static bool renesas_check_rom(struct pci_dev *pdev) rom_status &= RENESAS_ROM_STATUS_ROM_EXISTS; if (rom_status) { dev_dbg(&pdev->dev, "External ROM exists\n"); + debugfs_init(pdev); return true; /* External ROM exists */ } @@ -439,6 +443,34 @@ static void renesas_rom_erase(struct pci_dev *pdev) dev_dbg(&pdev->dev, "ROM Erase... Done success\n"); } +static int debugfs_rom_erase(void *data, u64 value) +{ + struct pci_dev *pdev = data; + + if (value == 1) { + dev_dbg(&pdev->dev, "Userspace requested ROM erase\n"); + renesas_rom_erase(pdev); + return 0; + } + return -EINVAL; +} +DEFINE_DEBUGFS_ATTRIBUTE(rom_erase_ops, NULL, debugfs_rom_erase, "%llu\n"); + +static struct dentry *debugfs_root; + +static void debugfs_init(struct pci_dev *pdev) +{ + debugfs_root = debugfs_create_dir("renesas_usb", NULL); + + debugfs_create_file("rom_erase", 0200, debugfs_root, + pdev, &rom_erase_ops); +} + +static void debugfs_exit(void) +{ + debugfs_remove_recursive(debugfs_root); +} + static bool renesas_download_rom(struct pci_dev *pdev, const u32 *fw, size_t step) { @@ -696,6 +728,8 @@ int renesas_xhci_pci_probe(struct pci_dev *dev, int renesas_xhci_pci_remove(struct pci_dev *dev) { + debugfs_exit(); + if (renesas_fw_check_running(dev)) { /* * bail out early, if this was a renesas device w/o FW.