From patchwork Wed Nov 6 08:38:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 178630 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp297756ilf; Wed, 6 Nov 2019 00:39:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwXihq2QecwnVfGxxrJ2aq9odVouqxjYoNVsuB5Dmbe96cDeNSAsKUcMG7K3xvnjN94T26f X-Received: by 2002:a50:a69b:: with SMTP id e27mr1356248edc.188.1573029588021; Wed, 06 Nov 2019 00:39:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573029588; cv=none; d=google.com; s=arc-20160816; b=DvrMwMVhOkZqFl7MqhnizPYV2wrOgNVk6A29K64k7U+REAhU2mswOLUDzbWXsBN82o qcRFq3sIOIgf9E6zXIxXBb/3bTJFMcQjnjISOKts+IZGfv5DFzZ4C/p3AOlFJMTj38Wr p+noOMHiqg2sXNWZNWmw/D3i9e02zxxRFwV8rtt6HPviczInmZXHmv71lO8aPNnw4G1T DsMchQ6RQKypHu7ICXPLPRpkoLQ2SUxz8yVQVOYT9yUPK9+ndaatpqDRSorAniQJ3+dJ CMpXpW9roRHj/pxmUHlF+NbVDCcV9mapUF+Ms1omB87vUeGWhB8/fNvyRtQokXtrmzKB TR/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pO293vPmInBiNYlR9LzYSK1tP1/lLC88v5/BOzDIHJM=; b=j1BsZ+oZZyqdXo8Egg0ryf4j0hWiNehaXDud9Hq0lfpLwdp3jI8OtnBm5NziTantQE Uy6Kvxr7D5Zmf6SMfDLYvBqzVJ4lf5VXtz3fjKXUn8RdZ093qQK4YtmYHgE1eemHp2+X x31sR68n5oWOMhtNkG7qTYp691Fnv+RmCwdFUBUGR3CeUxAFzsnytb/mnZpLU/wMLh23 22ovmv4qfgNm6M+94IQSSVhGX++OHK88ODN8wtuwYvBmk82IUb27xbyO8iRx4VKfaiax K0yblleHG9w6yMQXZ0yHTfwveB/QXVPjPxg8B2CVA4mAljhQ7L8s4XdcAtMmY4s8T9Aj da3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rNnTVDZG; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23si10699455ejx.366.2019.11.06.00.39.47; Wed, 06 Nov 2019 00:39:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rNnTVDZG; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731610AbfKFIjp (ORCPT + 5 others); Wed, 6 Nov 2019 03:39:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:48368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731551AbfKFIjo (ORCPT ); Wed, 6 Nov 2019 03:39:44 -0500 Received: from localhost.localdomain (unknown [223.226.46.117]) (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 BDA752187F; Wed, 6 Nov 2019 08:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573029583; bh=3n0e0WMZun+KvTCKIcTClGi7plTjhUdFq8O6kRTeDpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNnTVDZGvuJNE9U/We2e99vZEei5l67uDysMZQG5l4KeRRK5bLB0QKTTK2vUeuwxT UOMjAP+CA54iijJNe7JhwkSSmOonkbBluMlisDtt28ngF03460l9OjF8j2ypFjRmRb OSjcOu11IBo20xstiJ7qJ1ZtCFixFc3bu7j10dYU= From: Vinod Koul To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Vinod Koul , Yoshihiro Shimoda , Christian Lamparter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/4] usb: xhci: provide a debugfs hook for erasing rom Date: Wed, 6 Nov 2019 14:08:43 +0530 Message-Id: <20191106083843.1718437-5-vkoul@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191106083843.1718437-1-vkoul@kernel.org> References: <20191106083843.1718437-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.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) -- 2.23.0 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 4d0c0fd18c23..ac8f433861e9 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "xhci.h" #include "xhci-trace.h" @@ -493,6 +494,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) { const struct renesas_fw_entry *entry; @@ -516,6 +519,7 @@ static int renesas_check_rom_state(struct pci_dev *pdev) if (version == entry->expected_version) { dev_dbg(&pdev->dev, "Detected valid ROM version..\n"); valid_version = true; + debugfs_init(pdev); } } if (valid_version == false) @@ -803,6 +807,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) { @@ -1248,6 +1280,8 @@ static void xhci_pci_remove(struct pci_dev *dev) { struct xhci_hcd *xhci; + debugfs_exit(); + if (renesas_fw_alive_check(dev)) { /* * bail out early, if this was a renesas device w/o FW.