Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3696470ybl; Mon, 13 Jan 2020 00:42:02 -0800 (PST) X-Google-Smtp-Source: APXvYqyFLbVciGcnarE2ub+FGoO1d3uSUA3cKh9IUsioyWhpp6yuS16SoRn/siKyLWELvyt6MGxo X-Received: by 2002:aca:1b08:: with SMTP id b8mr3458639oib.62.1578904922435; Mon, 13 Jan 2020 00:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578904922; cv=none; d=google.com; s=arc-20160816; b=pyN+l0PBSZvb44TfRv/rQxgIKBNb8jnNbp23glljYd+MztMIjiTCdoTq9zooATZE+k 7pmO2rv+24npq6yIHKdiLMKTb+0X6os1fhPhysrV91S5iFy4uN/jcv8SboFA0RDmA+5B QhCyhzPkF17lbnAn9kUfKpcMWJRy0BsD7++1x0EU1PPj6LjXi17/aR30pYJOjBHLKBIK u3fK1XgDFYJzRrpm/3DYWPh2k1ifZQb/swS9JaegXeKIjdkac/Y+1xlrCaKN2lFjF/vS 8ezJpj9COCZdfhmHTYy8nJ3sKCCjOw2GIMjJ11E4UHCPzX2M7votPfpAuPJyAo2UZyRX dzAw== 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=fK4Afn332eQ057/nElvVtGn8AXwkQC338S8c032Z8KU=; b=edbgfnZR6jek2nOoqBA9Jytjiikmz5SnczgNzlwDrOmm5eTG5iT+MTEAefTfrpCGKb INQkAQ+SlsII7vDvoO94sNu/A5yh2r0adcUpZwO+AWiQ8OLxgPZ7comY9ljzNzxOTlF0 HYmArR3A2Io1+oDM93HwxDp8gu0lmaD8Lpv1yaIyuSBUo7n+o6bdphFapyMZWLCcUSaW b2Vda8uXpLJvMoUVY0xBuy/9DiTI1dfi86Q/IxSCu2tZ4eMHUvPCOeDTye3Tv2GNOF3q 2+FfMRCvQXKBBB1qTRYdlbutFQOYi/Wf2a2WtxPt8vyGW6F/X3pSBHhINziCC8h6SyXz 9ZGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gx4q8ig5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h22si6675652otk.18.2020.01.13.00.41.50; Mon, 13 Jan 2020 00:42:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=gx4q8ig5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728993AbgAMIkr (ORCPT + 99 others); Mon, 13 Jan 2020 03:40:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:43612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728950AbgAMIkl (ORCPT ); Mon, 13 Jan 2020 03:40:41 -0500 Received: from localhost.localdomain (unknown [106.200.247.255]) (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 2670D207FF; Mon, 13 Jan 2020 08:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578904841; bh=jZl8xgRoQpS61f5V158YZ1RZcDbf9UZ3oLAOvnSRF0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gx4q8ig5vDM0d2EF5D4raTi+e0zPRc+aeDbhl6v7pXyWEqquX6d1RVp4/MQYWUC2r DppAPBRU2dwTWPuHq01nEJ3cxIeKoZFsqvxJEuXOyt2If8+HbgPIEaY5nuUhqn7Cir A69ZYUI/MpQQoTmwhoGNIGTK7Rnbc1ctBrJq8Yus= 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 v6 5/5] usb: xhci: provide a debugfs hook for erasing rom Date: Mon, 13 Jan 2020 14:10:05 +0530 Message-Id: <20200113084005.849071-6-vkoul@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200113084005.849071-1-vkoul@kernel.org> References: <20200113084005.849071-1-vkoul@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 fe95487ca888..be2e7eff492f 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 @@ -229,6 +230,9 @@ 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; @@ -252,6 +256,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) @@ -536,6 +541,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) { @@ -889,6 +922,8 @@ static int renesas_xhci_pci_probe(struct pci_dev *dev, static void renesas_xhci_pci_remove(struct pci_dev *dev) { + debugfs_exit(); + if (renesas_fw_alive_check(dev)) { /* * bail out early, if this was a renesas device w/o FW. -- 2.24.1