Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp451090ima; Wed, 6 Feb 2019 02:55:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ7a7XvEvjcjVkBe0YX+E2BbOCQghnRxxzwkSAAueZqwGXLLUWSoRMmpnfKUMZVjZMXqUFY X-Received: by 2002:a63:4611:: with SMTP id t17mr8998895pga.119.1549450536194; Wed, 06 Feb 2019 02:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549450536; cv=none; d=google.com; s=arc-20160816; b=ZXoIuVilbTlF6LPX8BLK3tgEpXSF0bgRPoSzLZHPNshmIadZWoD58uSdQlibZamVwJ h8kp3QfyMW5Wpui8XY7g+wnSQ1a74s48p2PREsLcg/vdTibQ+XCaBzvpmumnT7bHXnuP xIQO15gtbOlYCvMfrRgOVDb/3cYCkmVRTKgHXNlAl1nEhLXR03C4TtejweglvCmC3ech 7zSf7u7TXLkPY9SbnR3uQc6qxrQiPI1oyQJxknhmevLFtGIQc7biZ1sKkTRRDkWiVJDS 8AP1bcdPvswIfheEDpStzyEfyYOTq405tFMa7vlW3qEW2pnV0HAl/kYwcOR/QzUf00u6 7iLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=i/+4aCRBJX3O0kwB2OVPDUZ0c2QQIla2h4p/xu1GijM=; b=e8l/98G5sOaiyO9hsTzwChFbwFdyErqszbAxigTa1FIdEAo7kwld85vtzatfLoN80E 76EgPmeqymMobw9bSIZOdhQR/MrfCP6Af3fvPxdkOwbLm2M0BVLzltVyvF94NRzM/JbR 9/c5ag9pWaEd0/4e+UKNYxipF2KFLWy7adI83dMitK/0kTdodBmcL3V7C5+586sGEYvR qAc1HDmJOy1wgV4pB9+Raniii8gaPFu28JqXtwLrz6mlN4RkMT1Y4WQTsOvCz/5+g0AT fUNrUk1+Ofau1y0wc5kGLB48Sna1VOvOMHUFmPUGVDw08MOw9CtjeVb8vvvGNDbfQy8l un1Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si5988316pfc.95.2019.02.06.02.55.20; Wed, 06 Feb 2019 02:55:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727644AbfBFKwd (ORCPT + 99 others); Wed, 6 Feb 2019 05:52:33 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3272 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725965AbfBFKwc (ORCPT ); Wed, 6 Feb 2019 05:52:32 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D2D632969FCB81E003F3; Wed, 6 Feb 2019 18:52:30 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Wed, 6 Feb 2019 18:52:24 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , John Garry Subject: [PATCH 2/6] scsi: hisi_sas: Add manual trigger for debugfs dump Date: Wed, 6 Feb 2019 18:52:52 +0800 Message-ID: <1549450376-114929-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1549450376-114929-1-git-send-email-john.garry@huawei.com> References: <1549450376-114929-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo Jiaxing Add an interface to manually trigger a debugfs dump. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 1a3d31d4258c..35619bdad1d5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2977,6 +2977,36 @@ static void hisi_sas_debugfs_snapshot_regs(struct hisi_hba *hisi_hba) hisi_hba->hw->snapshot_restore(hisi_hba); } +static ssize_t hisi_sas_debugfs_trigger_dump_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct hisi_hba *hisi_hba = file->f_inode->i_private; + char buf[8]; + + /* A bit racy, but don't care too much since it's only debugfs */ + if (hisi_hba->debugfs_snapshot) + return -EFAULT; + + if (count > 8) + return -EFAULT; + + if (copy_from_user(buf, user_buf, count)) + return -EFAULT; + + if (buf[0] != '1') + return -EFAULT; + + queue_work(hisi_hba->wq, &hisi_hba->debugfs_work); + + return count; +} + +static const struct file_operations hisi_sas_debugfs_trigger_dump_fops = { + .write = &hisi_sas_debugfs_trigger_dump_write, + .owner = THIS_MODULE, +}; + void hisi_sas_debugfs_work_handler(struct work_struct *work) { struct hisi_hba *hisi_hba = @@ -2999,6 +3029,10 @@ void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba) hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev), hisi_sas_debugfs_dir); + debugfs_create_file("trigger_dump", 0600, + hisi_hba->debugfs_dir, + hisi_hba, + &hisi_sas_debugfs_trigger_dump_fops); /* Alloc buffer for global */ sz = hisi_hba->hw->debugfs_reg_global->count * 4; -- 2.17.1