From patchwork Wed Dec 12 20:23:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1012259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FSvK20hyz9s2P for ; Thu, 13 Dec 2018 07:23:57 +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 43FSvK0jmKzDqVY for ; Thu, 13 Dec 2018 07:23:57 +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 43FSvB3ZfGzDqTn for ; Thu, 13 Dec 2018 07:23:50 +1100 (AEDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8D9B7F6C8; Wed, 12 Dec 2018 20:23:48 +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 5F077608C6; Wed, 12 Dec 2018 20:23:47 +0000 (UTC) From: Laurent Vivier To: Alexey Kardashevskiy , slof@lists.ozlabs.org Date: Wed, 12 Dec 2018 21:23:43 +0100 Message-Id: <20181212202344.14818-2-lvivier@redhat.com> In-Reply-To: <20181212202344.14818-1-lvivier@redhat.com> References: <20181212202344.14818-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Dec 2018 20:23:48 +0000 (UTC) Subject: [SLOF] [PATCH v4 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 Reviewed-by: Thomas Huth --- 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:23:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1012260 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 43FSvP42xLz9s2P for ; Thu, 13 Dec 2018 07:24:01 +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 43FSvP2ftpzDqVf for ; Thu, 13 Dec 2018 07:24:01 +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 43FSvD2K7RzDqVW for ; Thu, 13 Dec 2018 07:23:52 +1100 (AEDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 815BABDEA; Wed, 12 Dec 2018 20:23:50 +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 26000608C6; Wed, 12 Dec 2018 20:23:48 +0000 (UTC) From: Laurent Vivier To: Alexey Kardashevskiy , slof@lists.ozlabs.org Date: Wed, 12 Dec 2018 21:23:44 +0100 Message-Id: <20181212202344.14818-3-lvivier@redhat.com> In-Reply-To: <20181212202344.14818-1-lvivier@redhat.com> References: <20181212202344.14818-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 12 Dec 2018 20:23:50 +0000 (UTC) Subject: [SLOF] [PATCH v4 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 Reviewed-by: Thomas Huth --- slof/fs/usb/dev-storage.fs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/slof/fs/usb/dev-storage.fs b/slof/fs/usb/dev-storage.fs index a0a0bac..db5d0a8 100644 --- a/slof/fs/usb/dev-storage.fs +++ b/slof/fs/usb/dev-storage.fs @@ -103,23 +103,30 @@ 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 usb-transfer-bulk 0= IF - FALSE EXIT + drop FALSE EXIT THEN \ 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