From patchwork Sun Oct 25 11:15:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Rozenfeld X-Patchwork-Id: 55744 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9PBFB37004954 for ; Sun, 25 Oct 2009 11:15:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753382AbZJYLPF (ORCPT ); Sun, 25 Oct 2009 07:15:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753359AbZJYLPF (ORCPT ); Sun, 25 Oct 2009 07:15:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57123 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354AbZJYLPD (ORCPT ); Sun, 25 Oct 2009 07:15:03 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9PBF7vq032176 for ; Sun, 25 Oct 2009 07:15:08 -0400 Received: from localhost.localdomain (vpn-10-20.str.redhat.com [10.32.10.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9PBF43e025386 for ; Sun, 25 Oct 2009 07:15:05 -0400 Message-ID: <4AE43337.1030808@redhat.com> Date: Sun, 25 Oct 2009 13:15:03 +0200 From: Vadim Rozenfeld User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Thunderbird/3.0b4 MIME-Version: 1.0 To: kvm@vger.kernel.org Subject: [PATCH] viostor driver. Complete SRBs at DPC level X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c index 297949a..375021b 100644 --- a/viostor/virtio_stor.c +++ b/viostor/virtio_stor.c @@ -30,6 +30,14 @@ VirtIoBuildIo( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb ); + +VOID +CompleteDpcRoutine( + IN PSTOR_DPC Dpc, + IN PVOID Context, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2 + ) ; #endif BOOLEAN @@ -91,6 +99,13 @@ CompleteSRB( IN PSCSI_REQUEST_BLOCK Srb ); +VOID +FORCEINLINE +CompleteDPC( + IN PVOID DeviceExtension, + IN pblk_req vbr + ); + ULONG DriverEntry( IN PVOID DriverObject, @@ -325,10 +340,28 @@ VirtIoFindAdapter( } InitializeListHead(&adaptExt->list_head); + InitializeListHead(&adaptExt->complete_list); return SP_RETURN_FOUND; } +#ifdef USE_STORPORT +BOOLEAN +VirtIoPassiveInitializeRoutine ( + IN PVOID DeviceExtension + ) +{ + PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; + + StorPortInitializeDpc(DeviceExtension, +&adaptExt->completion_dpc, + CompleteDpcRoutine); + + return TRUE; +} +#endif + + BOOLEAN VirtIoHwInitialize( IN PVOID DeviceExtension @@ -400,6 +433,13 @@ VirtIoHwInitialize( ScsiPortMoveMemory(&adaptExt->inquiry_data.ProductRevisionLevel, "0001", sizeof("0001")); ScsiPortMoveMemory(&adaptExt->inquiry_data.VendorSpecific, "0001", sizeof("0001")); +#ifdef USE_STORPORT + if(!adaptExt->dump_mode) + { + return StorPortEnablePassiveInitialization(DeviceExtension, VirtIoPassiveInitializeRoutine); + } +#endif + return TRUE; } @@ -564,8 +604,7 @@ VirtIoInterrupt( Srb->SrbStatus = SRB_STATUS_ERROR; break; } - RemoveEntryList(&vbr->list_entry); - CompleteSRB(DeviceExtension, Srb); + CompleteDPC(DeviceExtension, vbr); } } RhelDbgPrint(TRACE_LEVEL_VERBOSE, ("%s isInterruptServiced = %d\n", __FUNCTION__, isInterruptServiced)); @@ -974,3 +1013,63 @@ CompleteSRB( Srb->Lun); #endif } + +VOID +FORCEINLINE +CompleteDPC( + IN PVOID DeviceExtension, + IN pblk_req vbr + ) +{ + PSCSI_REQUEST_BLOCK Srb = (PSCSI_REQUEST_BLOCK)vbr->req; + PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; + + RemoveEntryList(&vbr->list_entry); + +#ifdef USE_STORPORT + if(!adaptExt->dump_mode) { + InsertTailList(&adaptExt->complete_list,&vbr->list_entry); + StorPortIssueDpc(DeviceExtension, +&adaptExt->completion_dpc, + NULL, + NULL); + return; + } +#endif + CompleteSRB(DeviceExtension, Srb); +} + + +VOID +CompleteDpcRoutine( + IN PSTOR_DPC Dpc, + IN PVOID Context, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2 + ) +{ + STOR_LOCK_HANDLE LockHandle; + PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)Context; + + StorPortAcquireSpinLock ( Context, InterruptLock , NULL,&LockHandle); + + while (!IsListEmpty(&adaptExt->complete_list)) { + PSCSI_REQUEST_BLOCK Srb; + pblk_req vbr; + vbr = (pblk_req) RemoveHeadList(&adaptExt->complete_list); + Srb = (PSCSI_REQUEST_BLOCK)vbr->req; + + StorPortReleaseSpinLock (Context,&LockHandle); + + ScsiPortNotification(RequestComplete, + Context, + Srb); + + StorPortAcquireSpinLock ( Context, InterruptLock , NULL,&LockHandle); + + } + + StorPortReleaseSpinLock (Context,&LockHandle); + + return; +} diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h index 2d98738..2533148 100644 --- a/viostor/virtio_stor.h +++ b/viostor/virtio_stor.h @@ -95,6 +95,8 @@ typedef struct _ADAPTER_EXTENSION { ULONG queue_depth; BOOLEAN dump_mode; LIST_ENTRY list_head; + LIST_ENTRY complete_list; + STOR_DPC completion_dpc; }ADAPTER_EXTENSION, *PADAPTER_EXTENSION; typedef struct _RHEL_SRB_EXTENSION {