All of lore.kernel.org
 help / color / mirror / Atom feed
From: Don Brace <don.brace@microsemi.com>
To: joseph.szczypek@hpe.com, gerry.morong@microsemi.com,
	john.hall@microsemi.com, jejb@linux.vnet.ibm.com,
	Kevin.Barnett@microsemi.com, Mahesh.Rajashekhara@microsemi.com,
	bader.alisaleh@microsemi.com, hch@infradead.org,
	scott.teel@microsemi.com, Viswas.G@microsemi.com,
	Justin.Lindley@microsemi.com, scott.benesh@microsemi.com,
	POSWALD@suse.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 06/37] smartpqi: add supporting events
Date: Tue, 25 Apr 2017 14:46:28 -0500	[thread overview]
Message-ID: <149314958855.13903.9251402197085939854.stgit@brunhilda> (raw)
In-Reply-To: <149314950730.13903.644081079070695025.stgit@brunhilda>

From: Kevin Barnett <kevin.barnett@hpe.com>

Only register for controller events that driver supports
cleanup event handling.

Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |   11 +--
 drivers/scsi/smartpqi/smartpqi_init.c |  110 ++++++++++++++++++---------------
 2 files changed, 61 insertions(+), 60 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index 62045c1..02b3196 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -860,15 +860,8 @@ struct pqi_io_request {
 	struct list_head request_list_entry;
 };
 
-/* for indexing into the pending_events[] field of struct pqi_ctrl_info */
 #define PQI_EVENT_HEARTBEAT		0
-#define PQI_EVENT_HOTPLUG		1
-#define PQI_EVENT_HARDWARE		2
-#define PQI_EVENT_PHYSICAL_DEVICE	3
-#define PQI_EVENT_LOGICAL_DEVICE	4
-#define PQI_EVENT_AIO_STATE_CHANGE	5
-#define PQI_EVENT_AIO_CONFIG_CHANGE	6
-#define PQI_NUM_SUPPORTED_EVENTS	7
+#define PQI_NUM_SUPPORTED_EVENTS	6
 
 struct pqi_event {
 	bool	pending;
@@ -951,7 +944,7 @@ struct pqi_ctrl_info {
 	struct pqi_io_request *io_request_pool;
 	u16		next_io_request_slot;
 
-	struct pqi_event pending_events[PQI_NUM_SUPPORTED_EVENTS];
+	struct pqi_event events[PQI_NUM_SUPPORTED_EVENTS];
 	struct work_struct event_work;
 
 	atomic_t	num_interrupts;
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index d28e694..174867d 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -81,6 +81,15 @@ static struct scsi_transport_template *pqi_sas_transport_template;
 
 static atomic_t pqi_controller_count = ATOMIC_INIT(0);
 
+static unsigned int pqi_supported_event_types[] = {
+	PQI_EVENT_TYPE_HOTPLUG,
+	PQI_EVENT_TYPE_HARDWARE,
+	PQI_EVENT_TYPE_PHYSICAL_DEVICE,
+	PQI_EVENT_TYPE_LOGICAL_DEVICE,
+	PQI_EVENT_TYPE_AIO_STATE_CHANGE,
+	PQI_EVENT_TYPE_AIO_CONFIG_CHANGE,
+};
+
 static int pqi_disable_device_id_wildcards;
 module_param_named(disable_device_id_wildcards,
 	pqi_disable_device_id_wildcards, int, S_IRUGO | S_IWUSR);
@@ -2665,20 +2674,20 @@ static void pqi_event_worker(struct work_struct *work)
 {
 	unsigned int i;
 	struct pqi_ctrl_info *ctrl_info;
-	struct pqi_event *pending_event;
+	struct pqi_event *event;
 	bool got_non_heartbeat_event = false;
 
 	ctrl_info = container_of(work, struct pqi_ctrl_info, event_work);
 
-	pending_event = ctrl_info->pending_events;
+	event = ctrl_info->events;
 	for (i = 0; i < PQI_NUM_SUPPORTED_EVENTS; i++) {
-		if (pending_event->pending) {
-			pending_event->pending = false;
-			pqi_acknowledge_event(ctrl_info, pending_event);
-			if (i != PQI_EVENT_HEARTBEAT)
+		if (event->pending) {
+			event->pending = false;
+			pqi_acknowledge_event(ctrl_info, event);
+			if (i != PQI_EVENT_TYPE_HEARTBEAT)
 				got_non_heartbeat_event = true;
 		}
-		pending_event++;
+		event++;
 	}
 
 	if (got_non_heartbeat_event)
@@ -2742,7 +2751,7 @@ static void pqi_heartbeat_timer_handler(unsigned long data)
 			pqi_take_ctrl_offline(ctrl_info);
 			return;
 		}
-		ctrl_info->pending_events[PQI_EVENT_HEARTBEAT].pending = true;
+		ctrl_info->events[PQI_EVENT_HEARTBEAT].pending = true;
 		schedule_work(&ctrl_info->event_work);
 	} else {
 		ctrl_info->num_heartbeats_requested = 0;
@@ -2773,38 +2782,20 @@ static inline void pqi_stop_heartbeat_timer(struct pqi_ctrl_info *ctrl_info)
 		del_timer_sync(&ctrl_info->heartbeat_timer);
 }
 
-static int pqi_event_type_to_event_index(unsigned int event_type)
+static inline int pqi_event_type_to_event_index(unsigned int event_type)
 {
 	int index;
 
-	switch (event_type) {
-	case PQI_EVENT_TYPE_HEARTBEAT:
-		index = PQI_EVENT_HEARTBEAT;
-		break;
-	case PQI_EVENT_TYPE_HOTPLUG:
-		index = PQI_EVENT_HOTPLUG;
-		break;
-	case PQI_EVENT_TYPE_HARDWARE:
-		index = PQI_EVENT_HARDWARE;
-		break;
-	case PQI_EVENT_TYPE_PHYSICAL_DEVICE:
-		index = PQI_EVENT_PHYSICAL_DEVICE;
-		break;
-	case PQI_EVENT_TYPE_LOGICAL_DEVICE:
-		index = PQI_EVENT_LOGICAL_DEVICE;
-		break;
-	case PQI_EVENT_TYPE_AIO_STATE_CHANGE:
-		index = PQI_EVENT_AIO_STATE_CHANGE;
-		break;
-	case PQI_EVENT_TYPE_AIO_CONFIG_CHANGE:
-		index = PQI_EVENT_AIO_CONFIG_CHANGE;
-		break;
-	default:
-		index = -1;
-		break;
-	}
+	for (index = 0; index < ARRAY_SIZE(pqi_supported_event_types); index++)
+		if (event_type == pqi_supported_event_types[index])
+			return index;
 
-	return index;
+	return -1;
+}
+
+static inline bool pqi_is_supported_event(unsigned int event_type)
+{
+	return pqi_event_type_to_event_index(event_type) != -1;
 }
 
 static unsigned int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
@@ -2814,7 +2805,7 @@ static unsigned int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
 	pqi_index_t oq_ci;
 	struct pqi_event_queue *event_queue;
 	struct pqi_event_response *response;
-	struct pqi_event *pending_event;
+	struct pqi_event *event;
 	bool need_delayed_work;
 	int event_index;
 
@@ -2837,15 +2828,14 @@ static unsigned int pqi_process_event_intr(struct pqi_ctrl_info *ctrl_info)
 
 		if (event_index >= 0) {
 			if (response->request_acknowlege) {
-				pending_event =
-					&ctrl_info->pending_events[event_index];
-				pending_event->event_type =
-					response->event_type;
-				pending_event->event_id = response->event_id;
-				pending_event->additional_event_id =
+				event = &ctrl_info->events[event_index];
+				event->pending = true;
+				event->event_type = response->event_type;
+				event->event_id = response->event_id;
+				event->additional_event_id =
 					response->additional_event_id;
-				if (event_index != PQI_EVENT_HEARTBEAT) {
-					pending_event->pending = true;
+				if (event_index != PQI_EVENT_TYPE_HEARTBEAT) {
+					event->pending = true;
 					need_delayed_work = true;
 				}
 			}
@@ -3899,11 +3889,13 @@ static int pqi_create_queues(struct pqi_ctrl_info *ctrl_info)
 	(offsetof(struct pqi_event_config, descriptors) + \
 	(PQI_MAX_EVENT_DESCRIPTORS * sizeof(struct pqi_event_descriptor)))
 
-static int pqi_configure_events(struct pqi_ctrl_info *ctrl_info)
+static int pqi_configure_events(struct pqi_ctrl_info *ctrl_info,
+	bool enable_events)
 {
 	int rc;
 	unsigned int i;
 	struct pqi_event_config *event_config;
+	struct pqi_event_descriptor *event_descriptor;
 	struct pqi_general_management_request request;
 
 	event_config = kmalloc(PQI_REPORT_EVENT_CONFIG_BUFFER_LENGTH,
@@ -3937,9 +3929,15 @@ static int pqi_configure_events(struct pqi_ctrl_info *ctrl_info)
 	if (rc)
 		goto out;
 
-	for (i = 0; i < event_config->num_event_descriptors; i++)
-		put_unaligned_le16(ctrl_info->event_queue.oq_id,
-			&event_config->descriptors[i].oq_id);
+	for (i = 0; i < event_config->num_event_descriptors; i++) {
+		event_descriptor = &event_config->descriptors[i];
+		if (enable_events &&
+			pqi_is_supported_event(event_descriptor->event_type))
+			put_unaligned_le16(ctrl_info->event_queue.oq_id,
+					&event_descriptor->oq_id);
+		else
+			put_unaligned_le16(0, &event_descriptor->oq_id);
+	}
 
 	memset(&request, 0, sizeof(request));
 
@@ -3970,6 +3968,16 @@ static int pqi_configure_events(struct pqi_ctrl_info *ctrl_info)
 	return rc;
 }
 
+static inline int pqi_enable_events(struct pqi_ctrl_info *ctrl_info)
+{
+	return pqi_configure_events(ctrl_info, true);
+}
+
+static inline int pqi_disable_events(struct pqi_ctrl_info *ctrl_info)
+{
+	return pqi_configure_events(ctrl_info, false);
+}
+
 static void pqi_free_all_io_requests(struct pqi_ctrl_info *ctrl_info)
 {
 	unsigned int i;
@@ -5413,10 +5421,10 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info)
 
 	sis_enable_msix(ctrl_info);
 
-	rc = pqi_configure_events(ctrl_info);
+	rc = pqi_enable_events(ctrl_info);
 	if (rc) {
 		dev_err(&ctrl_info->pci_dev->dev,
-			"error configuring events\n");
+			"error enabling events\n");
 		return rc;
 	}
 

  parent reply	other threads:[~2017-04-25 19:46 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25 19:45 [PATCH 00/37] smartpqi updates Don Brace
2017-04-25 19:45 ` [PATCH 01/37] smartpqi: correct remove scsi devices Don Brace
2017-04-25 19:46 ` [PATCH 02/37] smartpqi: cleanup interrupt management Don Brace
2017-04-25 19:54   ` Bart Van Assche
2017-05-03 15:23     ` Don Brace
2017-04-25 19:46 ` [PATCH 03/37] smartpqi: set pci completion timeout Don Brace
2017-04-25 19:46 ` [PATCH 04/37] smartpqi: add in controller checkpoint for controller lockups Don Brace
2017-04-25 19:46 ` [PATCH 05/37] smartpqi: ensure controller is in SIS mode at init Don Brace
2017-04-25 19:57   ` Bart Van Assche
2017-05-03 15:46     ` Don Brace
2017-04-25 19:46 ` Don Brace [this message]
2017-04-25 19:46 ` [PATCH 07/37] smartpqi: enhance resets Don Brace
2017-04-25 20:01   ` Bart Van Assche
2017-05-03 19:19     ` Don Brace
2017-04-25 19:46 ` [PATCH 08/37] smartpqi: add suspend and resume support Don Brace
2017-04-25 20:05   ` Bart Van Assche
2017-05-03 19:21     ` Don Brace
2017-04-25 19:46 ` [PATCH 09/37] smartpqi: add heartbeat check Don Brace
2017-04-25 19:46 ` [PATCH 10/37] smartpqi: correct bdma hw bug Don Brace
2017-04-25 19:46 ` [PATCH 11/37] smartpqi: add pqi_wait_for_completion_io Don Brace
2017-04-25 19:47 ` [PATCH 12/37] smartpqi: change functions to inline Don Brace
2017-04-25 20:07   ` Bart Van Assche
2017-05-03 19:32     ` Don Brace
2017-04-25 19:47 ` [PATCH 13/37] smartpqi: make pdev pointer names consistent Don Brace
2017-04-25 19:47 ` [PATCH 14/37] smartpqi: eliminate redundant error messages Don Brace
2017-04-25 19:47 ` [PATCH 15/37] smartpqi: correct BMIC identify physical drive Don Brace
2017-04-25 19:47 ` [PATCH 16/37] smartpqi: minor driver cleanup Don Brace
2017-04-25 20:09   ` Bart Van Assche
2017-05-03 19:43     ` Don Brace
2017-04-25 19:47 ` [PATCH 17/37] smartpqi: add new PCI device IDs Don Brace
2017-04-25 19:47 ` [PATCH 18/37] smartpqi: cleanup messages Don Brace
2017-04-25 20:11   ` Bart Van Assche
2017-05-03 19:47     ` Don Brace
2017-04-25 19:47 ` [PATCH 19/37] smartpqi: update copyright Don Brace
2017-04-25 19:47 ` [PATCH 20/37] smartpqi: add ptraid support Don Brace
2017-04-25 20:13   ` Bart Van Assche
2017-05-03 20:06     ` Don Brace
2017-04-25 19:48 ` [PATCH 21/37] smartpqi: change return value for LUN reset operations Don Brace
2017-04-25 19:48 ` [PATCH 22/37] smartpqi: enhance kdump Don Brace
2017-04-25 19:48 ` [PATCH 23/37] smartpqi: remove qdepth calculations for logical volumes Don Brace
2017-04-25 19:48 ` [PATCH 24/37] smartpqi: add lockup action Don Brace
2017-04-25 19:48 ` [PATCH 25/37] smartpqi: correct aio error path Don Brace
2017-04-25 19:48 ` [PATCH 26/37] smartpqi: update device offline Don Brace
2017-04-25 19:48 ` [PATCH 27/37] smartpqi: controller offline improvements Don Brace
2017-04-25 19:48 ` [PATCH 28/37] smartpqi: cleanup controller branding Don Brace
2017-04-25 19:48 ` [PATCH 29/37] smartpqi: map more raid errors to SCSI errors Don Brace
2017-04-25 19:48 ` [PATCH 30/37] smartpqi: update timeout on admin commands Don Brace
2017-04-25 19:49 ` [PATCH 31/37] smartpqi: enhance device add and remove messages Don Brace
2017-04-25 19:49 ` [PATCH 32/37] smartpqi: make raid bypass references consistent Don Brace
2017-04-25 19:49 ` [PATCH 33/37] smartpqi: add raid level show Don Brace
2017-04-25 19:49 ` [PATCH 34/37] smartpqi: cleanup list initialization Don Brace
2017-04-25 19:49 ` [PATCH 35/37] smartpqi: add module parameters Don Brace
2017-04-25 19:49 ` [PATCH 36/37] smartpqi: remove writeq/readq function definitions Don Brace
2017-04-26  9:35   ` kbuild test robot
2017-04-25 19:49 ` [PATCH 37/37] smartpqi: bump driver version Don Brace

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=149314958855.13903.9251402197085939854.stgit@brunhilda \
    --to=don.brace@microsemi.com \
    --cc=Justin.Lindley@microsemi.com \
    --cc=Kevin.Barnett@microsemi.com \
    --cc=Mahesh.Rajashekhara@microsemi.com \
    --cc=POSWALD@suse.com \
    --cc=Viswas.G@microsemi.com \
    --cc=bader.alisaleh@microsemi.com \
    --cc=gerry.morong@microsemi.com \
    --cc=hch@infradead.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=john.hall@microsemi.com \
    --cc=joseph.szczypek@hpe.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=scott.benesh@microsemi.com \
    --cc=scott.teel@microsemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.