From patchwork Mon Mar 23 17:06:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 11453555 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 0425C15AB for ; Mon, 23 Mar 2020 17:07:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D788820722 for ; Mon, 23 Mar 2020 17:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584983255; bh=fomihoNKlPSOdDcQeFVhX/QuKjKtyu63YoEHBqorJ4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jpxvhBKWm38PXcwHG+MI60l8NARiylu8/+FS0c+kQCAOKr0J3UEGYwv4tfV9lMCMt 9G/BfQDQfHDhav/XLZ2Sc4LCfbADpfcrtB37D7cnXdjV7cwGIRlqW/d/Tm99dvm/b8 cB8lPPeWtIDTkO4vzqJedhLoBhxkdPZ+9tBIpEMM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgCWRHf (ORCPT ); Mon, 23 Mar 2020 13:07:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:45594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbgCWRHc (ORCPT ); Mon, 23 Mar 2020 13:07:32 -0400 Received: from localhost.localdomain (unknown [122.178.205.141]) (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 7D21E20719; Mon, 23 Mar 2020 17:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584983251; bh=fomihoNKlPSOdDcQeFVhX/QuKjKtyu63YoEHBqorJ4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E51SSEP3w99hro3rEvMthEnIMeD48rKshU0vLz4Cj8bpcu6q4oxhDC5FsmRM3Cn26 ST7Z7ohhBVRNdZMuXgahB+k5V0JYXUO83L05ShDLfaoG7Dxjj29/ZLlAcwzW89OeQr FF8rJFE3c+2VZdWS2DevX1bNBvkeVZR+QEHS4VOk= 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 v8 5/5] usb: xhci: provide a debugfs hook for erasing rom Date: Mon, 23 Mar 2020 22:36:01 +0530 Message-Id: <20200323170601.419809-6-vkoul@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200323170601.419809-1-vkoul@kernel.org> References: <20200323170601.419809-1-vkoul@kernel.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c index 6301730b1f8d..714932eaac90 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 @@ -162,6 +163,8 @@ static int renesas_fw_verify(struct pci_dev *dev, return 0; } +static void debugfs_init(struct pci_dev *pdev); + static int renesas_check_rom_state(struct pci_dev *pdev) { u16 rom_state; @@ -194,9 +197,11 @@ static int renesas_check_rom_state(struct pci_dev *pdev) /* Check the "Result Code" Bits (6:4) and act accordingly */ switch (rom_state & RENESAS_ROM_STATUS_RESULT) { case RENESAS_ROM_STATUS_SUCCESS: + debugfs_init(pdev); return 0; case RENESAS_ROM_STATUS_NO_RESULT: /* No result yet */ + debugfs_init(pdev); return 0; case RENESAS_ROM_STATUS_ERROR: /* Error State */ @@ -443,6 +448,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) { @@ -754,6 +787,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.