Skip to content

Commit 01c89ab

Browse files
hfreudeVasily Gorbik
authored andcommitted
s390/ap: rework to use irq info from ap queue status
This patch reworks the irq handling and reporting code for the AP queue interrupt handling to always use the irq info from the queue status. Until now the interrupt status of an AP queue was stored into a bool variable within the ap_queue struct. This variable was set on a successful interrupt enablement and cleared with kicking a reset. However, it may be that the interrupt state is manipulated outband for example by a hypervisor. This patch removes this variable and instead the irq bit from the AP queue status which is always reflecting the current irq state is used. Reviewed-by: Tony Krowiak <[email protected]> Reviewed-by: Holger Dengler <[email protected]> Signed-off-by: Harald Freudenberger <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 0547e0b commit 01c89ab

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

drivers/s390/crypto/ap_bus.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ struct ap_queue {
206206
bool config; /* configured state */
207207
bool chkstop; /* checkstop state */
208208
ap_qid_t qid; /* AP queue id. */
209-
bool interrupt; /* indicate if interrupts are enabled */
210209
bool se_bound; /* SE bound state */
211210
unsigned int assoc_idx; /* SE association index */
212211
int queue_count; /* # messages currently on AP queue. */

drivers/s390/crypto/ap_queue.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static enum ap_sm_wait ap_sm_read(struct ap_queue *aq)
203203
return AP_SM_WAIT_NONE;
204204
case AP_RESPONSE_NO_PENDING_REPLY:
205205
if (aq->queue_count > 0)
206-
return aq->interrupt ?
206+
return status.irq_enabled ?
207207
AP_SM_WAIT_INTERRUPT : AP_SM_WAIT_HIGH_TIMEOUT;
208208
aq->sm_state = AP_SM_STATE_IDLE;
209209
return AP_SM_WAIT_NONE;
@@ -254,7 +254,7 @@ static enum ap_sm_wait ap_sm_write(struct ap_queue *aq)
254254
fallthrough;
255255
case AP_RESPONSE_Q_FULL:
256256
aq->sm_state = AP_SM_STATE_QUEUE_FULL;
257-
return aq->interrupt ?
257+
return status.irq_enabled ?
258258
AP_SM_WAIT_INTERRUPT : AP_SM_WAIT_HIGH_TIMEOUT;
259259
case AP_RESPONSE_RESET_IN_PROGRESS:
260260
aq->sm_state = AP_SM_STATE_RESET_WAIT;
@@ -307,7 +307,6 @@ static enum ap_sm_wait ap_sm_reset(struct ap_queue *aq)
307307
case AP_RESPONSE_NORMAL:
308308
case AP_RESPONSE_RESET_IN_PROGRESS:
309309
aq->sm_state = AP_SM_STATE_RESET_WAIT;
310-
aq->interrupt = false;
311310
aq->rapq_fbit = 0;
312311
aq->se_bound = false;
313312
return AP_SM_WAIT_LOW_TIMEOUT;
@@ -383,7 +382,6 @@ static enum ap_sm_wait ap_sm_setirq_wait(struct ap_queue *aq)
383382

384383
if (status.irq_enabled == 1) {
385384
/* Irqs are now enabled */
386-
aq->interrupt = true;
387385
aq->sm_state = (aq->queue_count > 0) ?
388386
AP_SM_STATE_WORKING : AP_SM_STATE_IDLE;
389387
}
@@ -626,16 +624,21 @@ static ssize_t interrupt_show(struct device *dev,
626624
struct device_attribute *attr, char *buf)
627625
{
628626
struct ap_queue *aq = to_ap_queue(dev);
627+
struct ap_queue_status status;
629628
int rc = 0;
630629

631630
spin_lock_bh(&aq->lock);
632-
if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT)
631+
if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT) {
633632
rc = sysfs_emit(buf, "Enable Interrupt pending.\n");
634-
else if (aq->interrupt)
635-
rc = sysfs_emit(buf, "Interrupts enabled.\n");
636-
else
637-
rc = sysfs_emit(buf, "Interrupts disabled.\n");
633+
} else {
634+
status = ap_tapq(aq->qid, NULL);
635+
if (status.irq_enabled)
636+
rc = sysfs_emit(buf, "Interrupts enabled.\n");
637+
else
638+
rc = sysfs_emit(buf, "Interrupts disabled.\n");
639+
}
638640
spin_unlock_bh(&aq->lock);
641+
639642
return rc;
640643
}
641644

@@ -1032,7 +1035,6 @@ struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type)
10321035
if (ap_sb_available() && is_prot_virt_guest())
10331036
aq->ap_dev.device.groups = ap_queue_dev_sb_attr_groups;
10341037
aq->qid = qid;
1035-
aq->interrupt = false;
10361038
spin_lock_init(&aq->lock);
10371039
INIT_LIST_HEAD(&aq->pendingq);
10381040
INIT_LIST_HEAD(&aq->requestq);

0 commit comments

Comments
 (0)