From patchwork Sat Jan 30 07:05:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8169911 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E8F049FBE9 for ; Sat, 30 Jan 2016 07:09:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA7BE20396 for ; Sat, 30 Jan 2016 07:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE26620395 for ; Sat, 30 Jan 2016 07:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756616AbcA3HJK (ORCPT ); Sat, 30 Jan 2016 02:09:10 -0500 Received: from mail-oi0-f50.google.com ([209.85.218.50]:34082 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756515AbcA3HJC (ORCPT ); Sat, 30 Jan 2016 02:09:02 -0500 Received: by mail-oi0-f50.google.com with SMTP id k206so61233540oia.1 for ; Fri, 29 Jan 2016 23:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qOLhLRRTHoq1bJy8VWa/5knZ1V6mceK0e1blVJspwOg=; b=YzijEoTZ6qe4GcdwK00Vxmu6AmX0/pVgybUKTr9+ff/hi9eQtCaFWHV/k5um9gVGzZ B67lRZdWb7gUkWnqTp7PlvqejLNzigIAViSOjoW1sDIYTvuDUg8oVG5LZiiQ4rs3BBiq rsAxaXH7cL2OkDtPqaYxl4wgx1TK456lnXlQ5D+i0s7qxIgJ22NuKQrJT/b2GWfW94jb 8FIGLVtGaJyFyL/UiTq9NXOjyZyVLk4KfHp3tKCytMcCAhMHQSZhCbT/MJhUmx+tzmGc VBzwSLaq5uryWX7OqC7obWceuboemNOzBEPzIJlwlPBV4VZoZQOgwV/zm2L3nEgPiN2A KUcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qOLhLRRTHoq1bJy8VWa/5knZ1V6mceK0e1blVJspwOg=; b=TwY0INPcj3tQdTxO0/j7oqd5Rn1rf2jCsOXj0O0I550Tcvg/S35ChFOigkvrlJ294v QHNI0WFw7ZjdAImzIvkXrBsR4kZX3O8UHJmxsPyvmDuPsKxlCrB0+2MC3GyesnHc6LRO Orqe3xgoDgCzCDG2LfacgDYAKGfA7rFSYjLXZxbX01ZbdUER13gbGqF9f+TkvXhVUp1H x7BHWOsBYFEFSpzed2oViLF5UPz5smsV9LjUl62Z/h5h2hd/L/ql2rMSyCRGUxu+q8bx 3dznPahwjstFnOrdzWFJP6lifOxZuReFqkWgZVMWWUBQfjdCaRDm4Djf3d6geS7XgOTH CVQg== X-Gm-Message-State: AG10YOQaMwGTlAtXIEdaa9U4NCOmvgc2/u61/anXD/o5Ca61HprMEMVoFXgu8pXzYQjmqA== X-Received: by 10.202.49.82 with SMTP id x79mr3168496oix.81.1454137741868; Fri, 29 Jan 2016 23:09:01 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id f8sm8655678obs.3.2016.01.29.23.09.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jan 2016 23:09:01 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Juergen Gross , Andrzej Pietrasiewicz , Chris Boot , Nicholas Bellinger Subject: [PATCH-v3 10/14] usb-gadget/tcm: Convert to TARGET_SCF_ACK_KREF I/O krefs Date: Sat, 30 Jan 2016 07:05:54 +0000 Message-Id: <1454137558-30396-11-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1454137558-30396-1-git-send-email-nab@daterainc.com> References: <1454137558-30396-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch drops struct usbg_cmd->kref internal kref-erence usage, for proper TARGET_SCF_ACK_KREF conversion. Cc: Sebastian Andrzej Siewior Cc: Andrzej Pietrasiewicz Signed-off-by: Nicholas Bellinger --- drivers/usb/gadget/function/f_tcm.c | 51 ++++++++----------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 8773572..7276a73 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -41,13 +41,6 @@ static inline struct f_uas *to_f_uas(struct usb_function *f) return container_of(f, struct f_uas, function); } -static void usbg_cmd_release(struct kref *); - -static inline void usbg_cleanup_cmd(struct usbg_cmd *cmd) -{ - kref_put(&cmd->ref, usbg_cmd_release); -} - /* Start bot.c code */ static int bot_enqueue_cmd_cbw(struct f_uas *fu) @@ -68,7 +61,7 @@ static void bot_status_complete(struct usb_ep *ep, struct usb_request *req) struct usbg_cmd *cmd = req->context; struct f_uas *fu = cmd->fu; - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); if (req->status < 0) { pr_err("ERR %s(%d)\n", __func__, __LINE__); return; @@ -605,7 +598,7 @@ static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req) break; case UASP_QUEUE_COMMAND: - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); usb_ep_queue(fu->ep_cmd, fu->cmd.req, GFP_ATOMIC); break; @@ -615,7 +608,7 @@ static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req) return; cleanup: - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); } static int uasp_send_status_response(struct usbg_cmd *cmd) @@ -977,7 +970,7 @@ static void usbg_data_write_cmpl(struct usb_ep *ep, struct usb_request *req) return; cleanup: - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); } static int usbg_prepare_w_request(struct usbg_cmd *cmd, struct usb_request *req) @@ -1046,7 +1039,7 @@ static void usbg_cmd_work(struct work_struct *work) struct se_cmd *se_cmd; struct tcm_usbg_nexus *tv_nexus; struct usbg_tpg *tpg; - int dir; + int dir, flags = (TARGET_SCF_UNKNOWN_SIZE | TARGET_SCF_ACK_KREF); se_cmd = &cmd->se_cmd; tpg = cmd->fu->tpg; @@ -1060,9 +1053,9 @@ static void usbg_cmd_work(struct work_struct *work) goto out; } - if (target_submit_cmd(se_cmd, tv_nexus->tvn_se_sess, - cmd->cmd_buf, cmd->sense_iu.sense, cmd->unpacked_lun, - 0, cmd->prio_attr, dir, TARGET_SCF_UNKNOWN_SIZE) < 0) + if (target_submit_cmd(se_cmd, tv_nexus->tvn_se_sess, cmd->cmd_buf, + cmd->sense_iu.sense, cmd->unpacked_lun, 0, + cmd->prio_attr, dir, flags) < 0) goto out; return; @@ -1070,7 +1063,7 @@ static void usbg_cmd_work(struct work_struct *work) out: transport_send_check_condition_and_sense(se_cmd, TCM_UNSUPPORTED_SCSI_OPCODE, 1); - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); } static struct usbg_cmd *usbg_get_cmd(struct f_uas *fu, @@ -1125,11 +1118,6 @@ static int usbg_submit_command(struct f_uas *fu, pr_err("usbg_get_cmd failed\n"); return -ENOMEM; } - - /* XXX until I figure out why I can't free in on complete */ - kref_init(&cmd->ref); - kref_get(&cmd->ref); - memcpy(cmd->cmd_buf, cmd_iu->cdb, cmd_len); if (fu->flags & USBG_USE_STREAMS) { @@ -1202,7 +1190,7 @@ static void bot_cmd_work(struct work_struct *work) out: transport_send_check_condition_and_sense(se_cmd, TCM_UNSUPPORTED_SCSI_OPCODE, 1); - usbg_cleanup_cmd(cmd); + transport_generic_free_cmd(&cmd->se_cmd, 0); } static int bot_submit_command(struct f_uas *fu, @@ -1238,11 +1226,6 @@ static int bot_submit_command(struct f_uas *fu, pr_err("usbg_get_cmd failed\n"); return -ENOMEM; } - - /* XXX until I figure out why I can't free in on complete */ - kref_init(&cmd->ref); - kref_get(&cmd->ref); - memcpy(cmd->cmd_buf, cbw->CDB, cmd_len); cmd->bot_tag = cbw->Tag; @@ -1296,14 +1279,6 @@ static u32 usbg_tpg_get_inst_index(struct se_portal_group *se_tpg) return 1; } -static void usbg_cmd_release(struct kref *ref) -{ - struct usbg_cmd *cmd = container_of(ref, struct usbg_cmd, - ref); - - transport_generic_free_cmd(&cmd->se_cmd, 0); -} - static void usbg_release_cmd(struct se_cmd *se_cmd) { struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, @@ -1733,11 +1708,7 @@ static void usbg_port_unlink(struct se_portal_group *se_tpg, static int usbg_check_stop_free(struct se_cmd *se_cmd) { - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - - kref_put(&cmd->ref, usbg_cmd_release); - return 1; + return target_put_sess_cmd(se_cmd); } static const struct target_core_fabric_ops usbg_ops = {