From patchwork Wed Dec 12 20:16:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1012254 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FSl71ZfMz9s2P for ; Thu, 13 Dec 2018 07:16:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43FSl66NK8zDqVW for ; Thu, 13 Dec 2018 07:16:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lvivier@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43FSkz3StLzDqVT for ; Thu, 13 Dec 2018 07:16:43 +1100 (AEDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9083E308FF30; Wed, 12 Dec 2018 20:16:41 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-190.brq.redhat.com [10.40.204.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 558B01001925; Wed, 12 Dec 2018 20:16:39 +0000 (UTC) From: Laurent Vivier To: Alexey Kardashevskiy , slof@lists.ozlabs.org Date: Wed, 12 Dec 2018 21:16:32 +0100 Message-Id: <20181212201633.13641-2-lvivier@redhat.com> In-Reply-To: <20181212201633.13641-1-lvivier@redhat.com> References: <20181212201633.13641-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 12 Dec 2018 20:16:41 +0000 (UTC) Subject: [SLOF] [PATCH v3 1/2] usb/storage: Invert the logic of the IF-statements X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" to prepare write implementation Signed-off-by: Laurent Vivier --- slof/fs/usb/dev-storage.fs | 39 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/slof/fs/usb/dev-storage.fs b/slof/fs/usb/dev-storage.fs index 94f8421..a0a0bac 100644 --- a/slof/fs/usb/dev-storage.fs +++ b/slof/fs/usb/dev-storage.fs @@ -107,23 +107,23 @@ scsi-open TO resp-size TO resp-buffer udev USB_PIPE_OUT td-buf td-buf-phys dma-buf-phys usb>cmd 1F - usb-transfer-bulk IF \ transfer CBW - resp-size IF - d# 125 us - udev USB_PIPE_IN td-buf td-buf-phys resp-buffer resp-size - usb-transfer-bulk 1 = not IF \ transfer data - usb-disk-debug? IF ." Data phase failed " cr THEN - \ FALSE EXIT - \ in case of a stall/halted endpoint we clear the halt - \ Fall through and try reading the CSW - THEN - THEN - d# 125 us - udev USB_PIPE_IN td-buf td-buf-phys dma-buf-phys usb>csw 0D - usb-transfer-bulk \ transfer CSW - ELSE - FALSE EXIT + usb-transfer-bulk 0= IF + FALSE EXIT THEN + \ transfer CBW + resp-size IF + d# 125 us + udev USB_PIPE_IN td-buf td-buf-phys resp-buffer resp-size + usb-transfer-bulk 0= IF \ transfer data + usb-disk-debug? IF ." Data phase failed " cr THEN + \ FALSE EXIT + \ in case of a stall/halted endpoint we clear the halt + \ Fall through and try reading the CSW + THEN + THEN + d# 125 us + udev USB_PIPE_IN td-buf td-buf-phys dma-buf-phys usb>csw 0D + usb-transfer-bulk \ transfer CSW ; STRUCT \ cbw @@ -189,12 +189,11 @@ CONSTANT cbw-length \ Send it dma-buf-phys usb>data usb-buf-len - do-bulk-command IF - dma-buf usb>data usb-buf-addr usb-buf-len move - ELSE - ." USB-DISK: Bulk commad failed!" cr + do-bulk-command 0= IF + ." USB-DISK: Bulk command failed!" cr 0 0 -1 EXIT THEN + dma-buf usb>data usb-buf-addr usb-buf-len move dma-buf usb>csw to csw-addr csw-addr csw>sig l@ 55534253 <> IF From patchwork Wed Dec 12 20:16:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1012255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FSlC1mj2z9s2P for ; Thu, 13 Dec 2018 07:16:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43FSlC0VdqzDqVb for ; Thu, 13 Dec 2018 07:16:55 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lvivier@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43FSl10hfXzDqVj for ; Thu, 13 Dec 2018 07:16:45 +1100 (AEDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DCCFC0528AC; Wed, 12 Dec 2018 20:16:43 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-190.brq.redhat.com [10.40.204.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id F31D61001925; Wed, 12 Dec 2018 20:16:41 +0000 (UTC) From: Laurent Vivier To: Alexey Kardashevskiy , slof@lists.ozlabs.org Date: Wed, 12 Dec 2018 21:16:33 +0100 Message-Id: <20181212201633.13641-3-lvivier@redhat.com> In-Reply-To: <20181212201633.13641-1-lvivier@redhat.com> References: <20181212201633.13641-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Dec 2018 20:16:43 +0000 (UTC) Subject: [SLOF] [PATCH v3 2/2] usb/storage: Implement block write support X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" The only missing parts were to manage the transfer direction in do-bulk-command and to copy the data to the buffer before the write operation. This is needed as GRUB2 wants to write the grubenv file at start and hangs because the data are not provided to the disk controller. I've checked the file is correctly modified by modifying an environment variable in GRUB2 with "set saved_entry=2" then "save_env saved_entry" and checking the result in linux with "grub2-editenv list". Fixes: Fixes: a0b96fe66fcd991b407c1d67ca842921e477a6fd (Provide "write" function in the disk-label package) Signed-off-by: Laurent Vivier --- slof/fs/usb/dev-storage.fs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/slof/fs/usb/dev-storage.fs b/slof/fs/usb/dev-storage.fs index a0a0bac..3c73075 100644 --- a/slof/fs/usb/dev-storage.fs +++ b/slof/fs/usb/dev-storage.fs @@ -103,7 +103,7 @@ scsi-open \ if sense-len is 0 then no sense data is actually present \ -: do-bulk-command ( resp-buffer resp-size -- TRUE | FALSE ) +: do-bulk-command ( dir resp-buffer resp-size -- TRUE | FALSE ) TO resp-size TO resp-buffer udev USB_PIPE_OUT td-buf td-buf-phys dma-buf-phys usb>cmd 1F @@ -113,13 +113,20 @@ scsi-open \ transfer CBW resp-size IF d# 125 us - udev USB_PIPE_IN td-buf td-buf-phys resp-buffer resp-size + IF + udev USB_PIPE_IN + ELSE + udev USB_PIPE_OUT + THEN + td-buf td-buf-phys resp-buffer resp-size usb-transfer-bulk 0= IF \ transfer data usb-disk-debug? IF ." Data phase failed " cr THEN \ FALSE EXIT \ in case of a stall/halted endpoint we clear the halt \ Fall through and try reading the CSW THEN + ELSE + drop THEN d# 125 us udev USB_PIPE_IN td-buf td-buf-phys dma-buf-phys usb>csw 0D @@ -182,18 +189,28 @@ CONSTANT cbw-length build-cbw 1 tag + to tag + \ copy command usb-cmd-addr dma-buf usb>cmd SCSI-COMMAND-OFFSET + usb-cmd-len move + \ copy data to write + usb-dir not IF + usb-buf-addr dma-buf usb>data usb-buf-len move + THEN + \ Send it - dma-buf-phys usb>data usb-buf-len + usb-dir dma-buf-phys usb>data usb-buf-len do-bulk-command 0= IF ." USB-DISK: Bulk command failed!" cr 0 0 -1 EXIT THEN - dma-buf usb>data usb-buf-addr usb-buf-len move + + \ copy read data + usb-dir IF + dma-buf usb>data usb-buf-addr usb-buf-len move + THEN dma-buf usb>csw to csw-addr csw-addr csw>sig l@ 55534253 <> IF