From patchwork Wed May 6 06:00:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 11530303 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 397B6912 for ; Wed, 6 May 2020 06:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 224A9206E6 for ; Wed, 6 May 2020 06:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588744879; bh=QE2O4NmZWuMgq3dzWY6VkmjrNNWEfrdj8tccmJPdKVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KHhyK7Xg9dtusQB3T7N5VOoO1RIOzv/+7icthOuxvjE7eknWVDw8o1rtPqw3CCnHp gDH9jZE5wvxwppnfAkJd+z7o8uTO0xUp1Z9DoX/wndL9siFiSiSNUxbto5PgeTb+3b 4sVdGzwYEDD6iN+0OqBmtNXILpOZe4amL9e0O84s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727852AbgEFGBP (ORCPT ); Wed, 6 May 2020 02:01:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgEFGBO (ORCPT ); Wed, 6 May 2020 02:01:14 -0400 Received: from localhost.localdomain (unknown [122.181.213.114]) (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 442A520721; Wed, 6 May 2020 06:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588744874; bh=QE2O4NmZWuMgq3dzWY6VkmjrNNWEfrdj8tccmJPdKVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VUdiaV3oQ4Uua+/CDFaeHUosciSm9DkalDKjetlfg72FR15bBAC8LyE4VIFRkJIlh 0BN1dvi+Jf674pym875s/N8lXfvAOOXFnFJNKmPVXDQNkDHid1H4WoK8xSp1eyuXOm LKd4+b/L3PEAtqY3U7gpZa3BZocREnhuTIoCCruk= 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 v13 5/5] usb: xhci: provide a debugfs hook for erasing rom Date: Wed, 6 May 2020 11:30:25 +0530 Message-Id: <20200506060025.1535960-6-vkoul@kernel.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200506060025.1535960-1-vkoul@kernel.org> References: <20200506060025.1535960-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 | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c index f7d2445d30ec..fa32ec352dc8 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 @@ -170,6 +171,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; @@ -183,6 +186,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 */ } @@ -449,6 +453,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_setup_rom(struct pci_dev *pdev, const struct firmware *fw) { const u32 *fw_data = (const u32 *)fw->data; @@ -639,6 +671,7 @@ EXPORT_SYMBOL_GPL(renesas_xhci_check_request_fw); void renesas_xhci_pci_exit(struct pci_dev *dev) { + debugfs_exit(); } EXPORT_SYMBOL_GPL(renesas_xhci_pci_exit);