[PATCH 1/2] ppc64: ibmvscsi: Harden driver initilisation for kexec

Michael Ellerman michael at ellerman.id.au
Mon Aug 8 13:55:37 EST 2005


After a kexec the vscsi driver will fail when trying to register with the
Hypervisor because the previous kernel has not unregistered.

So if the registration fails, we unregister and then try again.

Signed-off-by: Michael Ellerman <michael at ellerman.id.au>

 drivers/scsi/ibmvscsi/rpa_vscsi.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

Index: kexec/drivers/scsi/ibmvscsi/rpa_vscsi.c
===================================================================
--- kexec.orig/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ kexec/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -194,6 +194,28 @@ static void set_adapter_info(struct ibmv
 	hostdata->madapter_info.os_type = 2;
 }
 
+static int ibmvscsi_reg_crq_queue(uint32_t unit_addr, dma_addr_t token)
+{
+	int rc, try_again = 1;
+
+	/* After a kexec the crq will still be open, so our attempt to
+	 * open it will fail. So if we get a failure we free the crq and
+	 * try again, but only once. */
+retry:
+	rc = plpar_hcall_norets(H_REG_CRQ, unit_addr, token, PAGE_SIZE);
+
+	if (rc != H_Success && rc != 2 && try_again) {
+		do {
+			rc = plpar_hcall_norets(H_FREE_CRQ, unit_addr);
+		} while ((rc == H_Busy) || (H_isLongBusy(rc)));
+
+		try_again = 0;
+		goto retry;
+	}
+
+	return rc;
+}
+
 /**
  * initialize_crq_queue: - Initializes and registers CRQ with hypervisor
  * @queue:	crq_queue to initialize and register
@@ -226,9 +248,8 @@ int ibmvscsi_init_crq_queue(struct crq_q
 	gather_partition_info();
 	set_adapter_info(hostdata);
 
-	rc = plpar_hcall_norets(H_REG_CRQ,
-				vdev->unit_address,
-				queue->msg_token, PAGE_SIZE);
+	rc = ibmvscsi_reg_crq_queue(vdev->unit_address, queue->msg_token);
+
 	if (rc == 2) {
 		/* Adapter is good, but other end is not ready */
 		printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n");



More information about the Linuxppc64-dev mailing list