From patchwork Thu Jul 12 11:05:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Panizzo X-Patchwork-Id: 942925 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="bjyq6HU3"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41RCwy5Mv0z9rxx for ; Thu, 12 Jul 2018 21:13:38 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 60656C21FB5; Thu, 12 Jul 2018 11:12:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 71E29C21FC3; Thu, 12 Jul 2018 11:09:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 963BAC21FB4; Thu, 12 Jul 2018 11:09:00 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by lists.denx.de (Postfix) with ESMTPS id BAA92C21E7E for ; Thu, 12 Jul 2018 11:07:27 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id s12-v6so5292378wmc.1 for ; Thu, 12 Jul 2018 04:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TD9e57kOYfGiQ1M23GLOFCwNXzXH54pz5Y5o5FnjWqk=; b=bjyq6HU3tfgMaEo7WCeaA00hQy/4CPsh1xNRnEy54v0y+y/jTuHb1QS3HzxsdvN63n pkuFkngY25ODJWgaIjeD0UHcm6EIybkTh1mGQ0uGP+ulCvbwHFsGc1183Q/xWDh/7Pif sjkGNEHpNByjQiDgt4GGzJ/VNYpFFtuis1A/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TD9e57kOYfGiQ1M23GLOFCwNXzXH54pz5Y5o5FnjWqk=; b=K6BSf67HDV8zFhKC4QoaEVKhXF8/VLCxdeIsb+ywtdTshfmDViDVbcvjl2CCIyFAtH SwbWD0gVBeklkKJCzACxNFNVZT8WYzFsJO+vZdzU4QNRFB6f6CeTN7Swo1G3lGsl9gjo Gb2zXK3aYVkHmnEN7+f1PeMFTWHnsGPsHATzjoiXY6pHx2mcbDB2Rj+j2x5uke7/mytf Ei29gysH+R8dq2u++S7w8vhf6sQokIlXcv2XAQz4HZXDNph9CDu/lNS96NEtC+A8sErq 0mwmpm7pZtZfDRcQbsgOXUvOkIVoh0SRvyF/n+Opm1pMJNXynB8mibiSXVeSAKbFWobt EvyQ== X-Gm-Message-State: AOUpUlHz7EKLOAODQ7/4iBFJ9jTln4ur2lbGfIxCY7CvHXfCngcvzLYp UrptdvCdrO1HwfBZuI4mivxMVMD2 X-Google-Smtp-Source: AAOMgpfx9Zph7wi5PNJ7xYj9QaYuu4zWit0sr26+bY373HoxB2EDeEfn62yc2R+Gu4oxMp8C8P+/nw== X-Received: by 2002:a1c:2807:: with SMTP id o7-v6mr1009139wmo.11.1531393647281; Thu, 12 Jul 2018 04:07:27 -0700 (PDT) Received: from localhost.localdomain (host-9473-86-113.popwifi.it. [94.73.86.113]) by smtp.googlemail.com with ESMTPSA id t140-v6sm6982421wmd.14.2018.07.12.04.07.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jul 2018 04:07:26 -0700 (PDT) From: Alberto Panizzo To: u-boot@lists.denx.de Date: Thu, 12 Jul 2018 13:05:49 +0200 Message-Id: <1531393559-28958-10-git-send-email-alberto@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531393559-28958-1-git-send-email-alberto@amarulasolutions.com> References: <1531393559-28958-1-git-send-email-alberto@amarulasolutions.com> Cc: Marek Vasut Subject: [U-Boot] [PATCH v3 9/9] usb: rockchip: on K_FW_LBA_WRITE_10 remove magic block size of 512 bytes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" As well as in K_FW_LBA_READ_10 and K_FW_LBA_ERASE_10 take device's block size from f_rkusb->desc->blksz instead of the fixed 512 bytes. Keep original behaviour of retry probing assigned block device on every host request to manage late SDCard plugs. Signed-off-by: Alberto Panizzo --- drivers/usb/gadget/f_rockusb.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c index 574d610..e81eb16 100644 --- a/drivers/usb/gadget/f_rockusb.c +++ b/drivers/usb/gadget/f_rockusb.c @@ -490,19 +490,6 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) unsigned int buffer_size = req->actual; transfer_size = f_rkusb->dl_size - f_rkusb->dl_bytes; - if (!f_rkusb->desc) { - char *type = f_rkusb->dev_type; - int index = f_rkusb->dev_index; - - f_rkusb->desc = blk_get_dev(type, index); - if (!f_rkusb->desc || - f_rkusb->desc->type == DEV_TYPE_UNKNOWN) { - puts("invalid mmc device\n"); - rockusb_tx_write_csw(f_rkusb->tag, 0, CSW_FAIL, - USB_BULK_CS_WRAP_LEN); - return; - } - } if (req->status != 0) { printf("Bad status: %d\n", req->status); @@ -516,7 +503,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) memcpy((void *)f_rkusb->buf, buffer, transfer_size); f_rkusb->dl_bytes += transfer_size; - int blks = 0, blkcnt = transfer_size / 512; + int blks = 0, blkcnt = transfer_size / f_rkusb->desc->blksz; debug("dl %x bytes, %x blks, write lba %x, dl_size:%x, dl_bytes:%x, ", transfer_size, blkcnt, f_rkusb->lba, f_rkusb->dl_size, @@ -547,8 +534,8 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) else f_rkusb->buf = f_rkusb->buf_head; - debug("remain %x bytes, %x sectors\n", req->length, - req->length / 512); + debug("remain %x bytes, %lx sectors\n", req->length, + req->length / f_rkusb->desc->blksz); } req->actual = 0; @@ -676,10 +663,26 @@ static void cb_write_lba(struct usb_ep *ep, struct usb_request *req) memcpy((char *)cbw, req->buf, USB_BULK_CB_WRAP_LEN); sector_count = (int)get_unaligned_be16(&cbw->CDB[7]); + f_rkusb->tag = cbw->tag; + + if (!f_rkusb->desc) { + char *type = f_rkusb->dev_type; + int index = f_rkusb->dev_index; + + f_rkusb->desc = blk_get_dev(type, index); + if (!f_rkusb->desc || + f_rkusb->desc->type == DEV_TYPE_UNKNOWN) { + printf("invalid device \"%s\", %d\n", type, index); + rockusb_tx_write_csw(f_rkusb->tag, 0, CSW_FAIL, + USB_BULK_CS_WRAP_LEN); + return; + } + } + f_rkusb->lba = get_unaligned_be32(&cbw->CDB[2]); - f_rkusb->dl_size = sector_count * 512; + f_rkusb->dl_size = sector_count * f_rkusb->desc->blksz; f_rkusb->dl_bytes = 0; - f_rkusb->tag = cbw->tag; + debug("require write %x bytes, %x sectors to lba %x\n", f_rkusb->dl_size, sector_count, f_rkusb->lba);