From patchwork Wed Feb 6 10:52:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 157605 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6262242jaa; Wed, 6 Feb 2019 02:52:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IZnIALBu/Df0BALhOrSCl2JhUFlRBgEwOuAQCzybRyK734NDIkxviZMwKgMAQrMrGMqTvxd X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr10161198plo.210.1549450355559; Wed, 06 Feb 2019 02:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549450355; cv=none; d=google.com; s=arc-20160816; b=j8iIee0vbkdgS8IWyk9o1Byr5E7hjLzhrgm9fWAZ2hZmLnd5NXu44DZp+pvchpEgFn P9PfKSj6g3xv/xanRI9LqZleldj6qavjQ8UjYsuo2nznsxD6RCS7fPZhxxKSPdyxIOLx 32541zYeNmxXBEpySY8ySqAOwYhSN4uYkPHT1S7btHIDeJXdyQHipBXRy31rAkzNI5nT zVnAeJqy6pULHp+V1K8AuMh7+hisXJgVqSgH/DSmmOGy2YqVPvyddmgAdQknAQqpl7gx myDt3CAzhDBNKaTPFz9d6yxvvuc07MOkuLjsMqx2h5eJB4cJyH+WJdv+U+QtEavslf9K 10HA== 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 q16si5534677pgh.185.2019.02.06.02.52.35; Wed, 06 Feb 2019 02:52:35 -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 S1728098AbfBFKwd (ORCPT + 31 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 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(+) -- 2.17.1 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;