Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3922585ybb; Mon, 23 Mar 2020 10:08:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuab8bQM1qmnkOK9/qVIOnuiQJIcjqaULY3CGPs5qrfKeLdbpJ8ol2Jgml7+6wxd1LN/xH5 X-Received: by 2002:aca:b245:: with SMTP id b66mr261668oif.170.1584983335226; Mon, 23 Mar 2020 10:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584983335; cv=none; d=google.com; s=arc-20160816; b=DaN4Udpi8ftr1MWNIeNcby6UlELN5wqcr81j3W/n+/9gwZ3qkAyhdUjNpRcoZ3Bhni Cqhg5kSwyWLBI0YuG0QEELf7bHU1G6Eyctvgf2cSHpYx/nIoG+H3a5/nFPf9GTn95n4Y qCMcrSakfWy64ux1jl2OfezEnHcx7p/GLG3Xl2N02KxbrWmuzpX8jVWoX4HzqMSvc98Z NxhNR8+0J5154LZYw9loX8l/6ch4VupLR0570nUDvPbEpghYDJTVok7QJ1IVHKdDtd7E IIGbZ4ipFR1oZe//2O/B4EaCbzJ9PAnqDnF7I0btSoThu1RZXLeBAtqHFpLq4acXWA4A s3Cw== 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=8CS43dErnqCk0GoxApIfl9vYrs+dDbfnj5+DVzO43Eg=; b=GbttRYzxrHJjpfOGq1VikpGSsIrSNsxUhWTibVWicgtt5Cw+hRTLTpYgTH4P8jfR9x HtsCNTeGnxFczQnPHOGUkTPVlwWf1+aLOASb/lsQj4+nLZ0OdOrFf6OwH/w+x+KrnpCP ScVYo3N72oWrdu8VYyhvhUZ16NRyxyhFGgt8QKcsDux67cK1eXeg90JhqHsqFsB0r/2h Ir8Ovsa36lOv4zlgPjKqtGXCuJYC321b/A3SK2VR1vA9uq7YMhzVivXWug4SPZKiq4Yn nDNERPGm1e2OCLF2cPHqkynXraBwNWyPoNK/gH1yNHjpnApuL0xA6UaFktZW0o6V/Hbp UvfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E51SSEP3; 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 g141si7908702oib.45.2020.03.23.10.08.31; Mon, 23 Mar 2020 10:08:55 -0700 (PDT) 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=E51SSEP3; 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 S1727903AbgCWRHf (ORCPT + 99 others); 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=20B=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 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 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. -- 2.25.1