From patchwork Thu Apr 30 16:59:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 11521043 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 4632292A for ; Thu, 30 Apr 2020 17:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DB5121973 for ; Thu, 30 Apr 2020 17:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588266008; bh=cBBOkr8Xv31S9xr1BvALBUdHSj8emmus8DnnBktbEAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=J0F0dYWPrLh1Cf9mdeUppJX9jaBIrqxENpJgu52HeTHHviL1hBpQpA1wvuGPZ6m2E ANC9qQCFLUZtDtfjuOd+S3SCqr0siAwd8ArcOwFsCp1CYrIU1GN2q5ARQq2WHTvMZP urY6SYpYQQVoy2xMQ25uyGLAaZgwP/JQ4SUGKocg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgD3RAE (ORCPT ); Thu, 30 Apr 2020 13:00:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:48826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726333AbgD3RAD (ORCPT ); Thu, 30 Apr 2020 13:00:03 -0400 Received: from localhost.localdomain (unknown [122.182.217.38]) (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 BE87920873; Thu, 30 Apr 2020 16:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588266003; bh=cBBOkr8Xv31S9xr1BvALBUdHSj8emmus8DnnBktbEAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/lfoA4RnwmEtSxFTRyTSD/TOMfRo6Si/gqyy79KnNOMV/QZm7f9AseH0W9Ja1qYf nxH8oPXwz7Hs/NzlWwDZ9uXcc6WkPaxdl5BSz1GZvN/sAOWOss8l2t2pis4lWS4Q8L 5bLxeSWVsA4NMd1EFEZiZQZeUnYFlrXKUJzFx8Zw= 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 v12 5/5] usb: xhci: provide a debugfs hook for erasing rom Date: Thu, 30 Apr 2020 22:29:20 +0530 Message-Id: <20200430165920.1345409-6-vkoul@kernel.org> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200430165920.1345409-1-vkoul@kernel.org> References: <20200430165920.1345409-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);