]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
s390/zcrypt: move ap device reset from bus to driver code
authorHarald Freudenberger <freude@linux.ibm.com>
Fri, 22 Nov 2019 15:30:06 +0000 (16:30 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Thu, 6 Feb 2020 16:32:38 +0000 (16:32 +0000)
BugLink: https://bugs.launchpad.net/bugs/1862203
[ Upstream commit 0c874cd04292c7ee22d70eefc341fa2648f41f46 ]

This patch moves the reset invocation of an ap device when
fresh detected from the ap bus to the probe() function of
the driver responsible for this device.

The virtualisation of ap devices makes it necessary to
remove unconditioned resets on fresh appearing apqn devices.
It may be that such a device is already enabled for guest
usage. So there may be a race condition between host ap bus
and guest ap bus doing the reset. This patch moves the
reset from the ap bus to the zcrypt drivers. So if there
is no zcrypt driver bound to an ap device - for example
the ap device is bound to the vfio device driver - the
ap device is untouched passed to the vfio device driver.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/ap_bus.h
drivers/s390/crypto/ap_queue.c
drivers/s390/crypto/zcrypt_cex2a.c
drivers/s390/crypto/zcrypt_cex2c.c
drivers/s390/crypto/zcrypt_cex4.c

index a1915061932eb0325d95a644c6e8d6249bd09d47..5256e3ce84e56a5144368d9017c17da5bb336c12 100644 (file)
@@ -793,8 +793,6 @@ static int ap_device_probe(struct device *dev)
                drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT;
                if (!!devres != !!drvres)
                        return -ENODEV;
-               /* (re-)init queue's state machine */
-               ap_queue_reinit_state(to_ap_queue(dev));
        }
 
        /* Add queue/card to list of active queues/cards */
index 433b7b64368d6710523c468eaac5f3270cc5701f..bb35ba4a8d243955545596908170fbdd10620400 100644 (file)
@@ -261,7 +261,7 @@ void ap_queue_prepare_remove(struct ap_queue *aq);
 void ap_queue_remove(struct ap_queue *aq);
 void ap_queue_suspend(struct ap_device *ap_dev);
 void ap_queue_resume(struct ap_device *ap_dev);
-void ap_queue_reinit_state(struct ap_queue *aq);
+void ap_queue_init_state(struct ap_queue *aq);
 
 struct ap_card *ap_card_create(int id, int queue_depth, int raw_device_type,
                               int comp_device_type, unsigned int functions);
index dad2be333d826fd5d49601e6b9c11f11b118b755..37c3bdc3642dc6756dbcf10a6a34f2d9974fb930 100644 (file)
@@ -638,7 +638,7 @@ struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type)
        aq->ap_dev.device.type = &ap_queue_type;
        aq->ap_dev.device_type = device_type;
        aq->qid = qid;
-       aq->state = AP_STATE_RESET_START;
+       aq->state = AP_STATE_UNBOUND;
        aq->interrupt = AP_INTR_DISABLED;
        spin_lock_init(&aq->lock);
        INIT_LIST_HEAD(&aq->list);
@@ -771,10 +771,11 @@ void ap_queue_remove(struct ap_queue *aq)
        spin_unlock_bh(&aq->lock);
 }
 
-void ap_queue_reinit_state(struct ap_queue *aq)
+void ap_queue_init_state(struct ap_queue *aq)
 {
        spin_lock_bh(&aq->lock);
        aq->state = AP_STATE_RESET_START;
        ap_wait(ap_sm_event(aq, AP_EVENT_POLL));
        spin_unlock_bh(&aq->lock);
 }
+EXPORT_SYMBOL(ap_queue_init_state);
index c50f3e86cc7487377e09211264a4d4cc43ec4b61..7cbb384ec5352d618d15f0015f7e60f87c9e4a09 100644 (file)
@@ -175,6 +175,7 @@ static int zcrypt_cex2a_queue_probe(struct ap_device *ap_dev)
        zq->queue = aq;
        zq->online = 1;
        atomic_set(&zq->load, 0);
+       ap_queue_init_state(aq);
        ap_queue_init_reply(aq, &zq->reply);
        aq->request_timeout = CEX2A_CLEANUP_TIME,
        aq->private = zq;
index 35c7c6672713b70b33959b48322de5c0254c4a29..c78c0d119806f17784a0a38dac53f6a48b616b6d 100644 (file)
@@ -220,6 +220,7 @@ static int zcrypt_cex2c_queue_probe(struct ap_device *ap_dev)
        zq->queue = aq;
        zq->online = 1;
        atomic_set(&zq->load, 0);
+       ap_rapq(aq->qid);
        rc = zcrypt_cex2c_rng_supported(aq);
        if (rc < 0) {
                zcrypt_queue_free(zq);
@@ -231,6 +232,7 @@ static int zcrypt_cex2c_queue_probe(struct ap_device *ap_dev)
        else
                zq->ops = zcrypt_msgtype(MSGTYPE06_NAME,
                                         MSGTYPE06_VARIANT_NORNG);
+       ap_queue_init_state(aq);
        ap_queue_init_reply(aq, &zq->reply);
        aq->request_timeout = CEX2C_CLEANUP_TIME;
        aq->private = zq;
index 442e3d6162f761645d5f1df2849d28c3b486c855..6fabc906114c0e3b9de976bc6a5670923662de20 100644 (file)
@@ -381,6 +381,7 @@ static int zcrypt_cex4_queue_probe(struct ap_device *ap_dev)
        zq->queue = aq;
        zq->online = 1;
        atomic_set(&zq->load, 0);
+       ap_queue_init_state(aq);
        ap_queue_init_reply(aq, &zq->reply);
        aq->request_timeout = CEX4_CLEANUP_TIME,
        aq->private = zq;