From patchwork Fri Apr 26 09:37:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10918947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 928F71575 for ; Fri, 26 Apr 2019 09:38:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80E7328D56 for ; Fri, 26 Apr 2019 09:38:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7538E28D6E; Fri, 26 Apr 2019 09:38:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BF4928D56 for ; Fri, 26 Apr 2019 09:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726279AbfDZJiy (ORCPT ); Fri, 26 Apr 2019 05:38:54 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35227 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbfDZJiy (ORCPT ); Fri, 26 Apr 2019 05:38:54 -0400 Received: by mail-pl1-f193.google.com with SMTP id w24so1303776plp.2 for ; Fri, 26 Apr 2019 02:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bKEkF/RP/Uj6DsuhWWt0OMgcf0YUysezEt+iSASd9Zs=; b=E3lqg1WnryJ0vlZgeDpZo+NxskmDiHie+jqZcbYVFsTP/1w+eL31jroT+Rkef0WCym 0lZDqCXHT783jvLEg4rlkHPmQoS0EQuhq//SqG3+FkTjMWvADUzIFlS1IPIEUBGrFhcb nPWuULPKdKnM1msh/aeS7i43YdyTJXdemPFMI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bKEkF/RP/Uj6DsuhWWt0OMgcf0YUysezEt+iSASd9Zs=; b=LZD1dmRa7fQ118VozK8x0DxafuZA5UUlk6kLYV+k99sHIlFrzKJ2RGTTUZ0I7H8rK7 4tnBq3s3dEOK13PCF/mG0kiyS8OYFrfSzagnVnpB94PzJrr5t+t07zMXTZu699323rEp W3Ew9ml657vhQd+U1O736hwvyhhwnEA/5/3ciFqijcIWXZoRUFg3bwSnel8Idfb2CXpE y5VdIKtTRP/qWI8tg1Z0Esyq9gmt5qdbkDkHJ+HysVvZ8L+0j1C/VGYYZ0l0VptKgvN4 0a9pto04MbVNlpg/ZpLhWHnNXuhRYRDwqXPdNhWxWnrwl5Yt8PezEmxjNf9Wbjt40ZO1 0zhg== X-Gm-Message-State: APjAAAVSGOg+XkfduDAbCIg81lEUpXbWF9gGQYVMeWi8fDGDd6nndYNi J2K8X5uM2QK6Vo7BCp4e0i6kNldX/tugVGiNYQsnIh1JbzT/jysEYgq81fxHYp7h6dXSg+Xah0A yjnxGqQb6HU1awWudY8YCSOk67RoTLvHU3D04A1TLIWblWxAsAsuzPp1xKeT8Hp+2s3BVaTVem8 L/7TXjD0DBpjLXB4cwoAYa X-Google-Smtp-Source: APXvYqzlfywaCgfuikzqt8L6PsPth4dDVO6j6Oa+HGI3Guqu0HdderaRG6gvpRcv7hYkPwg2x194QA== X-Received: by 2002:a17:902:3064:: with SMTP id u91mr653653plb.181.1556271533447; Fri, 26 Apr 2019 02:38:53 -0700 (PDT) Received: from dhcp-135-24-192-142.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id r4sm37994649pgl.69.2019.04.26.02.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 02:38:52 -0700 (PDT) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, kiran-kumar.kasturi@broadcom.com, sankar.patra@broadcom.com, sasikumar.pc@broadcom.com, chandrakanth.patil@broadcom.com, Shivasharan S Subject: [PATCH 11/21] megaraid_sas: Dump system interface regs from sysfs Date: Fri, 26 Apr 2019 02:37:05 -0700 Message-Id: <1556271435-27252-12-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1556271435-27252-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1556271435-27252-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a sysfs interface to dump the controller's system interface registers. Signed-off-by: Sumit Saxena Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas_base.c | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index d0fd307e30af..5d2f346f3f49 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2901,6 +2901,29 @@ megasas_dump_fusion_io(struct scsi_cmnd *scmd) } +/* + * megasas_dump_sys_regs - This function will dump system registers through + * sysfs. + * @reg_set: Pointer to System register set. + * @buf: Buffer to which output is to be written. + * @return: Number of bytes written to buffer. + */ +static inline ssize_t +megasas_dump_sys_regs(void __iomem *reg_set, char *buf) +{ + unsigned int i, sz = 256; + int bytes_wrote = 0; + char *loc = (char *)buf; + + __le32 *reg = (__le32 *)reg_set; + + for (i = 0; i < sz / sizeof(__le32); i++) { + bytes_wrote += snprintf(loc + bytes_wrote, PAGE_SIZE, + "%08x: %08x\n", (i * 4), + le32_to_cpu(readl(®[i]))); + } + return bytes_wrote; +} /** * megasas_reset_bus_host - Bus & host reset handler entry point */ @@ -3223,6 +3246,17 @@ megasas_fw_cmds_outstanding_show(struct device *cdev, return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding)); } +static ssize_t +megasas_dump_system_regs_show(struct device *cdev, + struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(cdev); + struct megasas_instance *instance = + (struct megasas_instance *)shost->hostdata; + + return megasas_dump_sys_regs(instance->reg_set, buf); +} + static DEVICE_ATTR(fw_crash_buffer, S_IRUGO | S_IWUSR, megasas_fw_crash_buffer_show, megasas_fw_crash_buffer_store); static DEVICE_ATTR(fw_crash_buffer_size, S_IRUGO, @@ -3235,6 +3269,8 @@ static DEVICE_ATTR(ldio_outstanding, S_IRUGO, megasas_ldio_outstanding_show, NULL); static DEVICE_ATTR(fw_cmds_outstanding, S_IRUGO, megasas_fw_cmds_outstanding_show, NULL); +static DEVICE_ATTR(dump_system_regs, S_IRUGO, + megasas_dump_system_regs_show, NULL); struct device_attribute *megaraid_host_attrs[] = { &dev_attr_fw_crash_buffer_size, @@ -3243,6 +3279,7 @@ struct device_attribute *megaraid_host_attrs[] = { &dev_attr_page_size, &dev_attr_ldio_outstanding, &dev_attr_fw_cmds_outstanding, + &dev_attr_dump_system_regs, NULL, };