From patchwork Wed Feb 16 21:01:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30898C433EF for ; Wed, 16 Feb 2022 21:02:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbiBPVDC (ORCPT ); Wed, 16 Feb 2022 16:03:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232077AbiBPVC6 (ORCPT ); Wed, 16 Feb 2022 16:02:58 -0500 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99C112069A9 for ; Wed, 16 Feb 2022 13:02:45 -0800 (PST) Received: by mail-pf1-f172.google.com with SMTP id d187so3154010pfa.10 for ; Wed, 16 Feb 2022 13:02:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k7lGi5V8UE+vYk8leuP3XDOCvMS0Ir4ShlsC6V+WdRQ=; b=vXu9UnULNhy/dC4thSV6RfG/K/iTdOIUaTFxQeKYv/lmGj9JOIUGdLlFdodff4gqjk wagZEEAddp0jlMRhuJeemL2eYsHYlJBhB5i6sS2JDcraT4IdeJvYmj1rBDDuetY75OV4 M4ILBu4aGlY6Cr+Pni/kObGgY+jIMQ8em2khkV9xGWowbS8uB/upevmjYCZSb2nSGdKV x7CrjYUUSn57SmMiE2Pw9VIlqIiuoGu3jRX2OsiLn+lfFhPCHMBlxxASjI+Q3x3wd/DK frWe+/FmvVn+ERdUSz48rIL436s1QFBoSkHXSS/8f1N2zuJl8idjg+AmhOvg5r+3/2wO eMVA== X-Gm-Message-State: AOAM532SzFrSNNaNPP5z0XMmV9tYOJp52W10tNQenPbvFXZCXEvoo/RF UPJeaxmhpFRFxEdJ+FJoHMclNA3hnt9QWQ== X-Google-Smtp-Source: ABdhPJxfH8RDTNg7APZ2jftkCQsAJP7FwubWTRQfbzXvSyv0Hq3ppfEc3pFYT8dQJSUvyoqr0gkWlw== X-Received: by 2002:a63:6b8a:0:b0:373:1037:1c65 with SMTP id g132-20020a636b8a000000b0037310371c65mr3744584pgc.7.1645045365025; Wed, 16 Feb 2022 13:02:45 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:44 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , John Garry , Adaptec OEM Raid Solutions , "James E.J. Bottomley" Subject: [PATCH v4 01/50] scsi: ips: Remove an unreachable statement Date: Wed, 16 Feb 2022 13:01:44 -0800 Message-Id: <20220216210233.28774-2-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Whether or not CONFIG_BUG is enabled, BUG() never returns. Hence, code past a BUG() statement is unreachable. Remove one such unreachable statement. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Johannes Thumshirn Cc: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/ips.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 498bf04499ce..0db35e97ce8f 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -655,7 +655,6 @@ ips_release(struct Scsi_Host *sh) printk(KERN_WARNING "(%s) release, invalid Scsi_Host pointer.\n", ips_name); BUG(); - return (FALSE); } ha = IPS_HA(sh); From patchwork Wed Feb 16 21:01:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1725C433FE for ; Wed, 16 Feb 2022 21:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233360AbiBPVDD (ORCPT ); Wed, 16 Feb 2022 16:03:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233328AbiBPVDA (ORCPT ); Wed, 16 Feb 2022 16:03:00 -0500 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52ADB207556 for ; Wed, 16 Feb 2022 13:02:47 -0800 (PST) Received: by mail-pl1-f181.google.com with SMTP id l9so2999239plg.0 for ; Wed, 16 Feb 2022 13:02:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f/tyf6xX9BmyWKtKTQi812+2T5RV6GzN1mDcL3nDAAM=; b=6hAR82hAWZd4PNHrfMLzd1iAfLzWoFR552jrELklKBBbEy3VW6VIAeYBukFBDE5qtv +B4bk5orNYGtc3yDK9ChQFimb3+bGsukzLmxlCEKijcQKlR5+VNmjipO+MvuTsK2XZWY DhS/Yzat8TCdMF64YcnNbe/XlSNe/N52OQWWIa7dkhknODzLl0NEQlHl+HAUv8C2gn99 cvYK0zNKmyU8f8nvemhJhFBVIj3ZPGi2Ch194EwI0lIptzrO/XpmjOdi5iK7LQUcWb63 Eh2YmyeZR+HQZ++nwkXklk55vbbKjdAliCo0bKa9durkOqkk32pgX5smH/NMGutPHR2h 8UQQ== X-Gm-Message-State: AOAM533Z30MmEaD/OMdMq/nIA5Na86DVMevf3xpFYPBfizvG8upkPzqa 3pJ1kVZf/ecY6TQgUjH4re8= X-Google-Smtp-Source: ABdhPJzYQd4SxqbrT7IWt3cHaLb4wVWAWIp1Sjc3FSRtn8DGqEPljCh8Hg70J7xlkDLQG/DHsUEQdQ== X-Received: by 2002:a17:902:e80f:b0:14d:c482:66a3 with SMTP id u15-20020a170902e80f00b0014dc48266a3mr4269657plg.41.1645045366703; Wed, 16 Feb 2022 13:02:46 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:46 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , John Garry , Adaptec OEM Raid Solutions , "James E.J. Bottomley" Subject: [PATCH v4 02/50] scsi: ips: Change the return type of ips_release() into 'void' Date: Wed, 16 Feb 2022 13:01:45 -0800 Message-Id: <20220216210233.28774-3-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org ips_release() has one caller and that caller ignores the value returned by ips_release(). Hence change the return type of that function into 'void'. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Johannes Thumshirn Cc: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/ips.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 0db35e97ce8f..59664e92ec8a 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -638,8 +638,7 @@ ips_setup_funclist(ips_ha_t * ha) /* Remove a driver */ /* */ /****************************************************************************/ -static int -ips_release(struct Scsi_Host *sh) +static void ips_release(struct Scsi_Host *sh) { ips_scb_t *scb; ips_ha_t *ha; @@ -660,7 +659,7 @@ ips_release(struct Scsi_Host *sh) ha = IPS_HA(sh); if (!ha) - return (FALSE); + return; /* flush the cache on the controller */ scb = &ha->scbs[ha->max_cmds - 1]; @@ -698,8 +697,6 @@ ips_release(struct Scsi_Host *sh) scsi_host_put(sh); ips_released_controllers++; - - return (FALSE); } /****************************************************************************/ From patchwork Wed Feb 16 21:01:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46322C433F5 for ; Wed, 16 Feb 2022 21:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbiBPVDE (ORCPT ); Wed, 16 Feb 2022 16:03:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbiBPVDB (ORCPT ); Wed, 16 Feb 2022 16:03:01 -0500 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B01B207FEF for ; Wed, 16 Feb 2022 13:02:49 -0800 (PST) Received: by mail-pl1-f171.google.com with SMTP id w20so2940537plq.12 for ; Wed, 16 Feb 2022 13:02:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F6hcTPTAbcTrOtT8jY+FWg4iCNywlNyNbCJma56j84E=; b=ogNEjq/3WCWifbo94M7gUPBZqDs7p0+DHoRhQu8+y1qwycBQxnqLnvjIOMuVhu6Q6Q mjlSN3PdgC1CC2ZpXRt2pWDOEhbmtdLe/uocrZNezS7o/T6WB9ddweC7XhORyLRp+sV9 oV5aGmLtG1a+FHIzQsa9J77QAC29JuiCFD69oU9D1322AtU3IoBO6u317wcaNnGYMN8g NtjX9Xx8I+OGaCFHHgwW2rF0vcJvjhZrJ4cL5T6dPhy+VV5ulW+kCeYAtjcRGOkvo3PH V0NrOhj6Gw4vY6iwgFqUZ+jQvEcwJyPAKNwfs8hFuQbaUkjrNZa1paSwybfcQFJaYGFT qxcA== X-Gm-Message-State: AOAM5328vsD9EHwa3Woyyn8NbHe1ciu+9+bBayzUsM2E6y96gvLEbsD+ n/8tQWGY+EbUXvl1V7Sr+6U= X-Google-Smtp-Source: ABdhPJz1XAqFaQl3wKxmcIHPUqUgY15/T7Cb/3SSI4F+/KRC8jhwHt3RTZpPmO+koWPjee3bogWZOg== X-Received: by 2002:a17:902:b410:b0:14b:e53:7aa0 with SMTP id x16-20020a170902b41000b0014b0e537aa0mr4307249plr.101.1645045368468; Wed, 16 Feb 2022 13:02:48 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:47 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , John Garry , Adaptec OEM Raid Solutions , "James E.J. Bottomley" Subject: [PATCH v4 03/50] scsi: ips: Use true and false instead of TRUE and FALSE Date: Wed, 16 Feb 2022 13:01:46 -0800 Message-Id: <20220216210233.28774-4-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch prepares for removal of the drivers/scsi/scsi.h header file. That header file defines the 'TRUE' and 'FALSE' constants. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Johannes Thumshirn Cc: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/ips.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 59664e92ec8a..d22ba53d6028 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -945,7 +945,7 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) scsi_done(scsi_cmd); } - ha->active = FALSE; + ha->active = false; return (FAILED); } @@ -974,7 +974,7 @@ static int __ips_eh_reset(struct scsi_cmnd *SC) scsi_done(scsi_cmd); } - ha->active = FALSE; + ha->active = false; return (FAILED); } @@ -1287,7 +1287,7 @@ ips_intr_copperhead(ips_ha_t * ha) return 0; } - while (TRUE) { + while (true) { sp = &ha->sp; intrstatus = (*ha->func.isintr) (ha); @@ -1351,7 +1351,7 @@ ips_intr_morpheus(ips_ha_t * ha) return 0; } - while (TRUE) { + while (true) { sp = &ha->sp; intrstatus = (*ha->func.isintr) (ha); @@ -3086,8 +3086,8 @@ ipsintr_blocking(ips_ha_t * ha, ips_scb_t * scb) METHOD_TRACE("ipsintr_blocking", 2); ips_freescb(ha, scb); - if ((ha->waitflag == TRUE) && (ha->cmd_in_progress == scb->cdb[0])) { - ha->waitflag = FALSE; + if (ha->waitflag && ha->cmd_in_progress == scb->cdb[0]) { + ha->waitflag = false; return; } @@ -3387,7 +3387,7 @@ ips_send_wait(ips_ha_t * ha, ips_scb_t * scb, int timeout, int intr) METHOD_TRACE("ips_send_wait", 1); if (intr != IPS_FFDC) { /* Won't be Waiting if this is a Time Stamp */ - ha->waitflag = TRUE; + ha->waitflag = true; ha->cmd_in_progress = scb->cdb[0]; } scb->callback = ipsintr_blocking; @@ -3464,10 +3464,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) if (scb->bus > 0) { /* Controller commands can't be issued */ /* to real devices -- fail them */ - if ((ha->waitflag == TRUE) && - (ha->cmd_in_progress == scb->cdb[0])) { - ha->waitflag = FALSE; - } + if (ha->waitflag && ha->cmd_in_progress == scb->cdb[0]) + ha->waitflag = false; return (1); } @@ -4615,7 +4613,7 @@ ips_poll_for_flush_complete(ips_ha_t * ha) { IPS_STATUS cstatus; - while (TRUE) { + while (true) { cstatus.value = (*ha->func.statupd) (ha); if (cstatus.value == 0xffffffff) /* If No Interrupt to process */ @@ -5538,26 +5536,26 @@ ips_wait(ips_ha_t * ha, int time, int intr) METHOD_TRACE("ips_wait", 1); ret = IPS_FAILURE; - done = FALSE; + done = false; time *= IPS_ONE_SEC; /* convert seconds */ while ((time > 0) && (!done)) { if (intr == IPS_INTR_ON) { - if (ha->waitflag == FALSE) { + if (!ha->waitflag) { ret = IPS_SUCCESS; - done = TRUE; + done = true; break; } } else if (intr == IPS_INTR_IORL) { - if (ha->waitflag == FALSE) { + if (!ha->waitflag) { /* * controller generated an interrupt to * acknowledge completion of the command * and ips_intr() has serviced the interrupt. */ ret = IPS_SUCCESS; - done = TRUE; + done = true; break; } @@ -5592,7 +5590,7 @@ ips_write_driver_status(ips_ha_t * ha, int intr) { METHOD_TRACE("ips_write_driver_status", 1); - if (!ips_readwrite_page5(ha, FALSE, intr)) { + if (!ips_readwrite_page5(ha, false, intr)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to read NVRAM page 5.\n"); @@ -5630,7 +5628,7 @@ ips_write_driver_status(ips_ha_t * ha, int intr) ha->nvram->versioning = 0; /* Indicate the Driver Does Not Support Versioning */ /* now update the page */ - if (!ips_readwrite_page5(ha, TRUE, intr)) { + if (!ips_readwrite_page5(ha, true, intr)) { IPS_PRINTK(KERN_WARNING, ha->pcidev, "unable to write NVRAM page 5.\n"); From patchwork Wed Feb 16 21:01:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543242 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3B8C433F5 for ; Wed, 16 Feb 2022 21:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233214AbiBPVDJ (ORCPT ); Wed, 16 Feb 2022 16:03:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbiBPVDD (ORCPT ); Wed, 16 Feb 2022 16:03:03 -0500 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9D8209D3C for ; Wed, 16 Feb 2022 13:02:50 -0800 (PST) Received: by mail-pl1-f173.google.com with SMTP id i10so2976410plr.2 for ; Wed, 16 Feb 2022 13:02:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KnYVhSEwp8HZrTUijCkGbfKURzm28Jjo+1PjtXRA8Y8=; b=3FXHFMWpr5kVnaS15HCW4E+jZbW8hlZQAvtCCpzc9bMl8DYSpFj9brb2r0Q2uFwuz4 JAUGCuOjvTjr6ToYLeZrmyKgPC4CtNAdc/GeVvm2k519I8tpP2nZRZW1KBGavoFRdrS7 bROpZAJ8Kc3gFC0Btb7VJIBtqiXhZtxCiUjg6MdB8K3fRMahRMnyPNNYrB0XMuxbMrSh Gy7CIN5JNxz9krKzofUF4ZMIgfAKdfwLHdKLr4D+viRfbJgFOjsYPcigypRetpjq8b2e gZQrySnn+ESaXksJS80V88egO4mqcIwekzhpTKAbLCvQr716r2rJihq5swWTTCYnE8fm 670g== X-Gm-Message-State: AOAM530Jumz0gkgqSr5UXbrV4dE5Tn6PoPBhbU3oTfZRJVD6wtNI63oN LrV4lMqZB41c8e6ZPZyYgAU= X-Google-Smtp-Source: ABdhPJzOfYms8Jwa2YELQlCfhncnYu/rhhLFzUBqeh0jYjzCMhlDyij3YXZt+GHJhSZmQysQszMSfA== X-Received: by 2002:a17:902:dacd:b0:14f:4e5d:fe0d with SMTP id q13-20020a170902dacd00b0014f4e5dfe0dmr3108978plx.128.1645045370210; Wed, 16 Feb 2022 13:02:50 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:49 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , John Garry , "James E.J. Bottomley" Subject: [PATCH v4 04/50] scsi: nsp_cs: Change the return type of two functions into 'void' Date: Wed, 16 Feb 2022 13:01:47 -0800 Message-Id: <20220216210233.28774-5-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org nsp_reselected() and nsphw_init() always return TRUE. Change the return type of these functions into 'void'. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Johannes Thumshirn Cc: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/pcmcia/nsp_cs.c | 17 +++++------------ drivers/scsi/pcmcia/nsp_cs.h | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 92c818a8a84a..a5c2dd7ebc16 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -298,7 +298,7 @@ static void nsphw_init_sync(nsp_hw_data *data) /* * Initialize Ninja hardware */ -static int nsphw_init(nsp_hw_data *data) +static void nsphw_init(nsp_hw_data *data) { unsigned int base = data->BaseAddress; @@ -349,8 +349,6 @@ static int nsphw_init(nsp_hw_data *data) nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); nsp_setup_fifo(data, FALSE); - - return TRUE; } /* @@ -643,7 +641,7 @@ static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt) /* * accept reselection */ -static int nsp_reselected(struct scsi_cmnd *SCpnt) +static void nsp_reselected(struct scsi_cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; unsigned int host_id = SCpnt->device->host->this_id; @@ -675,8 +673,6 @@ static int nsp_reselected(struct scsi_cmnd *SCpnt) bus_reg = nsp_index_read(base, SCSIBUSCTRL) & ~(SCSI_BSY | SCSI_ATN); nsp_index_write(base, SCSIBUSCTRL, bus_reg); nsp_index_write(base, SCSIBUSCTRL, bus_reg | AUTODIRECTION | ACKENB); - - return TRUE; } /* @@ -1057,9 +1053,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) if (irq_phase & RESELECT_IRQ) { nsp_dbg(NSP_DEBUG_INTR, "reselect"); nsp_write(base, IRQCONTROL, IRQCONTROL_RESELECT_CLEAR); - if (nsp_reselected(tmpSC) != FALSE) { - return IRQ_HANDLED; - } + nsp_reselected(tmpSC); + return IRQ_HANDLED; } if ((irq_phase & (PHASE_CHANGE_IRQ | LATCHED_BUS_FREE)) == 0) { @@ -1614,9 +1609,7 @@ static int nsp_cs_config(struct pcmcia_device *link) nsp_dbg(NSP_DEBUG_INIT, "I/O[0x%x+0x%x] IRQ %d", data->BaseAddress, data->NumAddress, data->IrqNumber); - if(nsphw_init(data) == FALSE) { - goto cs_failed; - } + nsphw_init(data); host = nsp_detect(&nsp_driver_template); diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 665bf8d0faf7..94c1f6c7c601 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -304,7 +304,7 @@ static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt); static int nsp_bus_reset (nsp_hw_data *data); /* */ -static int nsphw_init (nsp_hw_data *data); +static void nsphw_init (nsp_hw_data *data); static int nsphw_start_selection(struct scsi_cmnd *SCpnt); static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time); static int nsp_fifo_count (struct scsi_cmnd *SCpnt); @@ -320,7 +320,7 @@ static int nsp_expect_signal (struct scsi_cmnd *SCpnt, unsigned char mask); static int nsp_xfer (struct scsi_cmnd *SCpnt, int phase); static int nsp_dataphase_bypass (struct scsi_cmnd *SCpnt); -static int nsp_reselected (struct scsi_cmnd *SCpnt); +static void nsp_reselected (struct scsi_cmnd *SCpnt); static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht); /* Interrupt handler */ From patchwork Wed Feb 16 21:01:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C0C6C4332F for ; Wed, 16 Feb 2022 21:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233416AbiBPVDJ (ORCPT ); Wed, 16 Feb 2022 16:03:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233114AbiBPVDF (ORCPT ); Wed, 16 Feb 2022 16:03:05 -0500 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 925EE20A364 for ; Wed, 16 Feb 2022 13:02:52 -0800 (PST) Received: by mail-pl1-f176.google.com with SMTP id u12so2933074plf.13 for ; Wed, 16 Feb 2022 13:02:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VTQFdYWzbePqO2QX4ieGC0QWMP0O+/4m+up6UMV8PjI=; b=yhpGWGdKkvdkbYYjFgFULgLZ8STpZuSSq7AlBCuoNd7QSeIUZzXBwUF1fHolxwVXT7 4to+WrS4qa5rIKmU/pLUKyvFVEDv0fiFArod/seIkgtQWnCkNp+mlkYdMRAPY360efcD cQUbQKSmz1ynd73yMOC5xkXe1iolDx1Fc09lNm+slstdcj8f9hwz7bdP+q/b3RAfPo2b UxcbA44LplrViWhkPxMZWgAkDq5UN2gEqm6Kv9AYmHQG13Z3jceFWL2iScTnwsv79b5b dn6YoV3SzJH8v9XjabYxJx1lOLh9SiaSgLkGEj+2zGIi7o2oP2Nke85rf25XN+QIrOpc srTg== X-Gm-Message-State: AOAM531C6ervyNffXaxbTejwnbtiCSVbmy9+B1vIpqp+ddRYgrfWNltD fa75Q3qSGrzvNUpISepO6+g= X-Google-Smtp-Source: ABdhPJxIIkzCZs8lHS5OByUg8uD/I1f0/dqwCNG6kO2ic2tmLUfeyO717/JxZ2bqPaqurl69e53jUA== X-Received: by 2002:a17:902:e944:b0:14e:dc4f:f099 with SMTP id b4-20020a170902e94400b0014edc4ff099mr4071688pll.161.1645045371898; Wed, 16 Feb 2022 13:02:51 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:51 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , John Garry , "James E.J. Bottomley" Subject: [PATCH v4 05/50] scsi: nsp_cs: Use true and false instead of TRUE and FALSE Date: Wed, 16 Feb 2022 13:01:48 -0800 Message-Id: <20220216210233.28774-6-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch prepares for removal of the drivers/scsi/scsi.h header file. That header file defines the 'TRUE' and 'FALSE' constants. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Johannes Thumshirn Cc: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/pcmcia/nsp_cs.c | 26 +++++++++++++------------- drivers/scsi/pcmcia/nsp_cs.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index a5c2dd7ebc16..a78a86511e94 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -243,7 +243,7 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt) SCpnt->SCp.buffers_residual = 0; } - if (nsphw_start_selection(SCpnt) == FALSE) { + if (!nsphw_start_selection(SCpnt)) { nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "selection fail"); SCpnt->result = DID_BUS_BUSY << 16; nsp_scsi_done(SCpnt); @@ -263,14 +263,14 @@ static DEF_SCSI_QCMD(nsp_queuecommand) /* * setup PIO FIFO transfer mode and enable/disable to data out */ -static void nsp_setup_fifo(nsp_hw_data *data, int enabled) +static void nsp_setup_fifo(nsp_hw_data *data, bool enabled) { unsigned int base = data->BaseAddress; unsigned char transfer_mode_reg; //nsp_dbg(NSP_DEBUG_DATA_IO, "enabled=%d", enabled); - if (enabled != FALSE) { + if (enabled) { transfer_mode_reg = TRANSFER_GO | BRAIND; } else { transfer_mode_reg = 0; @@ -348,13 +348,13 @@ static void nsphw_init(nsp_hw_data *data) SCSI_RESET_IRQ_EI ); nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); - nsp_setup_fifo(data, FALSE); + nsp_setup_fifo(data, false); } /* * Start selection phase */ -static int nsphw_start_selection(struct scsi_cmnd *SCpnt) +static bool nsphw_start_selection(struct scsi_cmnd *SCpnt) { unsigned int host_id = SCpnt->device->host->this_id; unsigned int base = SCpnt->device->host->io_port; @@ -368,7 +368,7 @@ static int nsphw_start_selection(struct scsi_cmnd *SCpnt) phase = nsp_index_read(base, SCSIBUSMON); if(phase != BUSMON_BUS_FREE) { //nsp_dbg(NSP_DEBUG_RESELECTION, "bus busy"); - return FALSE; + return false; } /* start arbitration */ @@ -388,7 +388,7 @@ static int nsphw_start_selection(struct scsi_cmnd *SCpnt) if (!(arbit & ARBIT_WIN)) { //nsp_dbg(NSP_DEBUG_RESELECTION, "arbit fail"); nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); - return FALSE; + return false; } /* assert select line */ @@ -407,7 +407,7 @@ static int nsphw_start_selection(struct scsi_cmnd *SCpnt) nsp_start_timer(SCpnt, 1000/51); data->SelectionTimeOut = 1; - return TRUE; + return true; } struct nsp_sync_table { @@ -477,7 +477,7 @@ static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt) sync->SyncRegister = 0; sync->AckWidth = 0; - return FALSE; + return false; } sync->SyncRegister = (sync_table->chip_period << SYNCREG_PERIOD_SHIFT) | @@ -486,7 +486,7 @@ static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt) nsp_dbg(NSP_DEBUG_SYNC, "sync_reg=0x%x, ack_width=0x%x", sync->SyncRegister, sync->AckWidth); - return TRUE; + return true; } @@ -633,7 +633,7 @@ static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt) nsp_dbg(NSP_DEBUG_DATA_IO, "use bypass quirk"); SCpnt->SCp.phase = PH_DATA; nsp_pio_read(SCpnt); - nsp_setup_fifo(data, FALSE); + nsp_setup_fifo(data, false); return 0; } @@ -927,7 +927,7 @@ static int nsp_nexus(struct scsi_cmnd *SCpnt) } /* setup pdma fifo */ - nsp_setup_fifo(data, TRUE); + nsp_setup_fifo(data, true); /* clear ack counter */ data->FifoCount = 0; @@ -1210,7 +1210,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) //*sync_neg = SYNC_NOT_YET; data->MsgLen = i = 0; - data->MsgBuffer[i] = IDENTIFY(TRUE, lun); i++; + data->MsgBuffer[i] = IDENTIFY(true, lun); i++; if (*sync_neg == SYNC_NOT_YET) { data->Sync[target].SyncPeriod = 0; diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 94c1f6c7c601..7d5d1a5b36e0 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -305,7 +305,7 @@ static int nsp_bus_reset (nsp_hw_data *data); /* */ static void nsphw_init (nsp_hw_data *data); -static int nsphw_start_selection(struct scsi_cmnd *SCpnt); +static bool nsphw_start_selection(struct scsi_cmnd *SCpnt); static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time); static int nsp_fifo_count (struct scsi_cmnd *SCpnt); static void nsp_pio_read (struct scsi_cmnd *SCpnt); From patchwork Wed Feb 16 21:01:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55E1AC433EF for ; Wed, 16 Feb 2022 21:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbiBPVDO (ORCPT ); Wed, 16 Feb 2022 16:03:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiBPVDM (ORCPT ); Wed, 16 Feb 2022 16:03:12 -0500 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9854920D341 for ; Wed, 16 Feb 2022 13:02:59 -0800 (PST) Received: by mail-pl1-f182.google.com with SMTP id u5so2972153ple.3 for ; Wed, 16 Feb 2022 13:02:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oBZur1j94swesFMO/Rhft03hULBidhGTyMWvzluk+nc=; b=e3kgxzRdrBFgT3h7h+EOcooTRPr9hsOpG7+e0p7vaW3Sj6Zj/gc23m82u3IZDhr7B6 L9twffwGOfKZPB5zT42NZ7cn99OoCDVYw9Qvhf3HJkX4aKv2FkpYKmZZB3lfnnTv++z7 UPcewrZi+uFe8s4EoNakBhAO1hPWxXRQigaCGy7KFql9uxSXPPi94aOZ5jUFOq2AFDJz ivjt6ZzyIwStolvH4VIW3TvGgYXnycAaCJZBFVZpKMDsjWdU9a3eUCbJPAFYJrMSktRi hqBeefVaM6fLyzPxEbPne6Rz3zcEb6Ca7j7HDLFHNw/Qp+ZBllwIuZPfjh7Dk6alIbHB fISQ== X-Gm-Message-State: AOAM531PdWc0f32mxurOOjOGNM/sjCypwEK6Spft+CjKFdquNf6rLuCf eS4tUdYbsSoy1uaHBvfrH6Q= X-Google-Smtp-Source: ABdhPJzh0HjaMA4kCOJwqeb2PoIsL7n4XJx7+WJfYzG3C9oOhVVXYhkC6AtX1rzP2mF52Y1wMo2tkg== X-Received: by 2002:a17:90a:9f82:b0:1b9:e290:8960 with SMTP id o2-20020a17090a9f8200b001b9e2908960mr3860038pjp.222.1645045378877; Wed, 16 Feb 2022 13:02:58 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:02:58 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Ming Lei , Greg Kroah-Hartman , Hannes Reinecke , Himanshu Madhani , Johannes Thumshirn , "James E.J. Bottomley" , "Juergen E. Fischer" , Russell King , Adaptec OEM Raid Solutions , Kashyap Desai , Sumit Saxena , Shivasharan S , Doug Gilbert , Oliver Neukum , Alan Stern Subject: [PATCH v4 06/50] scsi: Remove drivers/scsi/scsi.h Date: Wed, 16 Feb 2022 13:01:49 -0800 Message-Id: <20220216210233.28774-7-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The following two header files have the same file name: include/scsi/scsi.h and drivers/scsi/scsi.h. This is confusing. Remove the latter since the following note was added in drivers/scsi/scsi.h in 2004: "NOTE: this file only contains compatibility glue for old drivers. All these wrappers will be removed sooner or later. For new code please use the interfaces declared in the headers in include/scsi/" Cc: Christoph Hellwig Cc: Ming Lei Acked-by: Greg Kroah-Hartman Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Reviewed-by: Johannes Thumshirn Signed-off-by: Bart Van Assche --- drivers/scsi/a2091.c | 6 +++- drivers/scsi/a3000.c | 6 +++- drivers/scsi/aha152x.c | 9 ++++-- drivers/scsi/aha1740.c | 6 +++- drivers/scsi/arm/acornscsi.c | 6 +++- drivers/scsi/arm/arxescsi.c | 6 +++- drivers/scsi/arm/cumana_2.c | 6 +++- drivers/scsi/arm/eesox.c | 6 +++- drivers/scsi/arm/fas216.c | 6 +++- drivers/scsi/arm/powertec.c | 6 +++- drivers/scsi/arm/queue.c | 6 +++- drivers/scsi/gvp11.c | 6 +++- drivers/scsi/ips.c | 8 ++++-- drivers/scsi/megaraid.c | 8 ++++-- drivers/scsi/mvme147.c | 6 +++- drivers/scsi/pcmcia/aha152x_stub.c | 9 ++++-- drivers/scsi/pcmcia/nsp_cs.c | 5 ++-- drivers/scsi/pcmcia/qlogic_stub.c | 9 ++++-- drivers/scsi/qlogicfas.c | 6 +++- drivers/scsi/qlogicfas408.c | 6 +++- drivers/scsi/scsi.h | 46 ------------------------------ drivers/scsi/sg.c | 8 ++++-- drivers/scsi/sgiwd93.c | 6 +++- drivers/usb/image/microtek.c | 8 ++++-- drivers/usb/storage/debug.c | 1 - 25 files changed, 119 insertions(+), 82 deletions(-) delete mode 100644 drivers/scsi/scsi.h diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index 5853db36eceb..bcbce23478b8 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c @@ -12,7 +12,11 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include +#include #include "wd33c93.h" #include "a2091.h" diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c index 86f1da22aaa5..23f34411f7bf 100644 --- a/drivers/scsi/a3000.c +++ b/drivers/scsi/a3000.c @@ -13,7 +13,11 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include +#include #include "wd33c93.h" #include "a3000.h" diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index d17880b57d17..901b78e8ffe6 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -243,13 +243,16 @@ #include #include #include -#include -#include "scsi.h" +#include +#include #include +#include +#include #include +#include #include -#include +#include #include "aha152x.h" static LIST_HEAD(aha152x_host_list); diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c index 18eb4cfcef9a..134255751819 100644 --- a/drivers/scsi/aha1740.c +++ b/drivers/scsi/aha1740.c @@ -55,8 +55,12 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include #include +#include #include "aha1740.h" /* IF YOU ARE HAVING PROBLEMS WITH THIS DRIVER, AND WANT TO WATCH diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 81eb3bbdfc51..a8a72d822862 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -126,9 +126,13 @@ #include -#include "../scsi.h" +#include +#include #include +#include +#include #include +#include #include #include "acornscsi.h" #include "msgqueue.h" diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 7f667c198f6d..2527b542bcdd 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c @@ -35,8 +35,12 @@ #include #include -#include "../scsi.h" +#include +#include +#include +#include #include +#include #include "fas216.h" struct arxescsi_info { diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 3c00d7773876..536d6646e40b 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c @@ -29,8 +29,12 @@ #include #include -#include "../scsi.h" +#include +#include +#include +#include #include +#include #include "fas216.h" #include "scsi.h" diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index 1394590eecea..ab0f6422a6a9 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c @@ -35,8 +35,12 @@ #include #include -#include "../scsi.h" +#include +#include +#include +#include #include +#include #include "fas216.h" #include "scsi.h" diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 7019b91f0ce6..0d6df5ebf934 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -47,9 +47,13 @@ #include #include -#include "../scsi.h" +#include +#include #include +#include +#include #include +#include #include "fas216.h" #include "scsi.h" diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index 8fec435cee18..797568b271e3 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c @@ -20,8 +20,12 @@ #include #include -#include "../scsi.h" +#include +#include +#include +#include #include +#include #include "fas216.h" #include "scsi.h" diff --git a/drivers/scsi/arm/queue.c b/drivers/scsi/arm/queue.c index c6f71a7d1b8e..978df23ce188 100644 --- a/drivers/scsi/arm/queue.c +++ b/drivers/scsi/arm/queue.c @@ -20,7 +20,11 @@ #include #include -#include "../scsi.h" +#include +#include +#include +#include +#include #define DEBUG diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index 727f8c8f30b5..43754c2f36b3 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c @@ -12,7 +12,11 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include +#include #include "wd33c93.h" #include "gvp11.h" diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index d22ba53d6028..16419aeec02d 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -180,9 +180,13 @@ #include #include -#include -#include "scsi.h" +#include +#include +#include +#include #include +#include +#include #include "ips.h" diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index bf987f3a7f3f..2061e3fe9824 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -44,10 +44,14 @@ #include #include #include -#include -#include "scsi.h" +#include +#include +#include +#include #include +#include +#include #include "megaraid.h" diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index 869b8b058a43..0893d4c3a916 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -11,8 +11,12 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include #include +#include #include "wd33c93.h" #include "mvme147.h" diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index df82a349e969..6a6621728c69 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -40,13 +40,16 @@ #include #include #include -#include #include #include -#include -#include "scsi.h" +#include +#include +#include +#include #include +#include +#include #include "aha152x.h" #include diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index a78a86511e94..dcffda384eaf 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -41,10 +41,9 @@ #include #include -#include <../drivers/scsi/scsi.h> -#include - #include +#include +#include #include #include diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 828d53faf09a..310d0b6586a6 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -38,14 +38,17 @@ #include #include #include -#include #include #include -#include #include -#include "scsi.h" +#include +#include +#include +#include #include +#include +#include #include "../qlogicfas408.h" #include diff --git a/drivers/scsi/qlogicfas.c b/drivers/scsi/qlogicfas.c index 8f709002f746..8f05e3707d69 100644 --- a/drivers/scsi/qlogicfas.c +++ b/drivers/scsi/qlogicfas.c @@ -31,8 +31,12 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include #include +#include #include "qlogicfas408.h" /* Set the following to 2 to use normal interrupt (active high/totempole- diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 30a88849a626..3e065d5fc80c 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c @@ -55,8 +55,12 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include #include +#include #include "qlogicfas408.h" /*----------------------------------------------------------------*/ diff --git a/drivers/scsi/scsi.h b/drivers/scsi/scsi.h deleted file mode 100644 index 4fd75a3aff66..000000000000 --- a/drivers/scsi/scsi.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * scsi.h Copyright (C) 1992 Drew Eckhardt - * Copyright (C) 1993, 1994, 1995, 1998, 1999 Eric Youngdale - * generic SCSI package header file by - * Initial versions: Drew Eckhardt - * Subsequent revisions: Eric Youngdale - * - * - * - * Modified by Eric Youngdale eric@andante.org to - * add scatter-gather, multiple outstanding request, and other - * enhancements. - */ -/* - * NOTE: this file only contains compatibility glue for old drivers. All - * these wrappers will be removed sooner or later. For new code please use - * the interfaces declared in the headers in include/scsi/ - */ - -#ifndef _SCSI_H -#define _SCSI_H - -#include -#include -#include -#include -#include - -/* - * Some defs, in case these are not defined elsewhere. - */ -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -struct Scsi_Host; -struct scsi_cmnd; -struct scsi_device; -struct scsi_target; -struct scatterlist; - -#endif /* _SCSI_H */ diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 6b43e97bd417..bbd75026ec93 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -49,11 +49,15 @@ static int sg_version_num = 30536; /* 2 digits for each component */ #include #include /* for sg_check_file_access() */ -#include "scsi.h" +#include +#include #include -#include +#include #include +#include +#include #include +#include #include #include "scsi_logging.h" diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c index cf1030c9dda1..e797d89c873b 100644 --- a/drivers/scsi/sgiwd93.c +++ b/drivers/scsi/sgiwd93.c @@ -28,7 +28,11 @@ #include #include -#include "scsi.h" +#include +#include +#include +#include +#include #include "wd33c93.h" struct ip22_hostdata { diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index b8dc6fa6a5a3..874ea4b54ced 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -130,11 +130,15 @@ #include #include #include - #include #include -#include "../../scsi/scsi.h" + +#include +#include +#include +#include #include +#include #include "microtek.h" diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c index d7f50b7a079e..576be66ad962 100644 --- a/drivers/usb/storage/debug.c +++ b/drivers/usb/storage/debug.c @@ -36,7 +36,6 @@ #include "usb.h" #include "debug.h" -#include "scsi.h" void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb) From patchwork Wed Feb 16 21:01:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F032C433EF for ; Wed, 16 Feb 2022 21:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233114AbiBPVDW (ORCPT ); Wed, 16 Feb 2022 16:03:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiBPVDP (ORCPT ); Wed, 16 Feb 2022 16:03:15 -0500 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA4F220B3AF for ; Wed, 16 Feb 2022 13:03:01 -0800 (PST) Received: by mail-pg1-f174.google.com with SMTP id 75so3178383pgb.4 for ; Wed, 16 Feb 2022 13:03:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jMeDqllGrrV3FbKNEHoPaxGteEcY2XkYj7IhwAA65+w=; b=R4kT7pm3SBKsQi+L+/LDsUbVcbWo51Vxi5DQXuDguVRHhXdZSl9p+6owBn9z8uHiIC PJazVsNswY076N0Yx8YzO8AigQp6+AVTVcMPu4GAPs1FN4MHH0aNnG3RRIp0UF+3dky6 O2xSgpXl3Zhqm8baOWtdmTxe0KNJvv7FihQu0twYPH/jCM3f4KcWSsiu4FbYqBOft8n5 Pf5VoADtNWL084tM3Mcpf48DNd5NeS9oNZCGA3+wOrsjFQvqiQ2mVqcp1FsWYqfjDh59 VPR44B/o4p6MdFeOD1oz4EcUkDjfPTRz2Fq2ysk+T+jfSuctzXGM22pamJ7Fr/5HhHN4 HuZg== X-Gm-Message-State: AOAM530dlg+8nYLRqz2dkFwOkRE7FbV9trV5X6+073P9zP8XFARYUegp BhfBQ1tcPhQySotX0/8VpVA= X-Google-Smtp-Source: ABdhPJwfAZ5qmty/ey8lylLrsKZX3Htbqommdu+w+DbXP8j6ZWJ8QMLxCx4+Zf1gop7CjZTDFaMqpQ== X-Received: by 2002:a63:3487:0:b0:373:4c14:59b1 with SMTP id b129-20020a633487000000b003734c1459b1mr3851729pga.68.1645045381097; Wed, 16 Feb 2022 13:03:01 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:00 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Finn Thain , Hannes Reinecke , Finn Thain , Hannes Reinecke , Ondrej Zary , Michael Schmitz , "James E.J. Bottomley" , Russell King Subject: [PATCH v4 07/50] scsi: NCR5380: Remove the NCR5380_CMD_SIZE macro Date: Wed, 16 Feb 2022 13:01:50 -0800 Message-Id: <20220216210233.28774-8-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This makes it easier to find users of the NCR5380_cmd data structure with 'grep'. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Acked-by: Finn Thain Reviewed-by: Hannes Reinecke Cc: Finn Thain Cc: Hannes Reinecke Cc: Ondrej Zary Cc: Michael Schmitz Signed-off-by: Bart Van Assche --- drivers/scsi/NCR5380.h | 2 -- drivers/scsi/arm/cumana_1.c | 2 +- drivers/scsi/arm/oak.c | 2 +- drivers/scsi/atari_scsi.c | 2 +- drivers/scsi/dmx3191d.c | 2 +- drivers/scsi/g_NCR5380.c | 2 +- drivers/scsi/mac_scsi.c | 2 +- drivers/scsi/sun3_scsi.c | 2 +- 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 8a3b41932288..845bd2423e66 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -230,8 +230,6 @@ struct NCR5380_cmd { struct list_head list; }; -#define NCR5380_CMD_SIZE (sizeof(struct NCR5380_cmd)) - #define NCR5380_PIO_CHUNK_SIZE 256 /* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */ diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 3fd944374631..5d4f67ba74c0 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c @@ -223,7 +223,7 @@ static struct scsi_host_template cumanascsi_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 2, .proc_name = "CumanaSCSI-1", - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), .max_sectors = 128, .dma_boundary = PAGE_SIZE - 1, }; diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index 78f33d57c3e8..f18a0620c808 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c @@ -113,7 +113,7 @@ static struct scsi_host_template oakscsi_template = { .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, .proc_name = "oakscsi", - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), .max_sectors = 128, }; diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 95d7a3586083..e9d0d99abc86 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -711,7 +711,7 @@ static struct scsi_host_template atari_scsi_template = { .this_id = 7, .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), }; static int __init atari_scsi_probe(struct platform_device *pdev) diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index 6df60b31ecb0..a171ce6b70b2 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c @@ -52,7 +52,7 @@ static struct scsi_host_template dmx3191d_driver_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), }; static int dmx3191d_probe_one(struct pci_dev *pdev, diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 7ba3c9312731..5923f86a384e 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -702,7 +702,7 @@ static struct scsi_host_template driver_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), .max_sectors = 128, }; diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 5c808fbc6ce2..71d493a0bb43 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -434,7 +434,7 @@ static struct scsi_host_template mac_scsi_template = { .sg_tablesize = 1, .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), .max_sectors = 128, }; diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index f7f724a3ff1d..82a253270c3b 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -505,7 +505,7 @@ static struct scsi_host_template sun3_scsi_template = { .sg_tablesize = 1, .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, - .cmd_size = NCR5380_CMD_SIZE, + .cmd_size = sizeof(struct NCR5380_cmd), }; static int __init sun3_scsi_probe(struct platform_device *pdev) From patchwork Wed Feb 16 21:01:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95D34C433FE for ; Wed, 16 Feb 2022 21:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233214AbiBPVDX (ORCPT ); Wed, 16 Feb 2022 16:03:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233429AbiBPVDR (ORCPT ); Wed, 16 Feb 2022 16:03:17 -0500 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB6220F85F for ; Wed, 16 Feb 2022 13:03:03 -0800 (PST) Received: by mail-pj1-f42.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso7598462pjg.0 for ; Wed, 16 Feb 2022 13:03:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iiZX6sV4CwW6jvcUw8nIxaJhZYQIR8ZaripFwFVV2nM=; b=rv5a1i5TxFbCdxe6B/17I20hu/DkvX4x6DGfbttfqXFyUSyGYmB2Nr/hDL/j06f9kX XKqm6TRIKSBCPJ4H+u4m3dtCzj/8hngATKg/PrsUi2KvQD752SETcwwrz6GRHYnegOFi 2u18iLqWk4w96voQ6uIVZKKaF1m42t5FgQiDm4RMOtxFL3wlMYl3xmFoJnA4+vcyPsbe uoLOahUrRmD+8SfL4tJiRcWtnp1mR/LyTkJjWWnrT1A0gtcXsk5Ocar2R9acHI+1lVdI OXiywbr9Kxf8Q10Bo2l78rKkq+x1HsTwZ5BiM0MWCj+0t2ZMXfcSmr/9cFjjLPUEwLSj gLlg== X-Gm-Message-State: AOAM530Bs/JZGPAE0JqoMMzkr5y5/riIlzTBIZIHzbGN43LfRSCDg07X 0x0HBiH3TBrTT4fT6Y9Q2kQ= X-Google-Smtp-Source: ABdhPJwCTgmFbSM+pq8/hJTMXBidzZ599+lmhk0cJy/BiMqjcUhBC+p/7CP59KIxx+8hfHdMIgaKug== X-Received: by 2002:a17:90b:4a11:b0:1b9:9685:eea4 with SMTP id kk17-20020a17090b4a1100b001b99685eea4mr3883403pjb.136.1645045382952; Wed, 16 Feb 2022 13:03:02 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:02 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Finn Thain , Johannes Thumshirn , Finn Thain , Michael Schmitz , "James E.J. Bottomley" Subject: [PATCH v4 08/50] scsi: NCR5380: Introduce the NCR5380_cmd_priv() function Date: Wed, 16 Feb 2022 13:01:51 -0800 Message-Id: <20220216210233.28774-9-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduce the NCR5380_cmd_priv() function. This function will allow to access the SCSI pointer in the next patch with a single statement instead of two, e.g. as follows: struct scsi_pointer *scsi_pointer = &NCR5380_cmd_priv(cmd)->scsi_pointer; Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Finn Thain Cc: Johannes Thumshirn Signed-off-by: Bart Van Assche --- drivers/scsi/NCR5380.c | 8 ++++---- drivers/scsi/NCR5380.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 55af3e245a92..6fa5e363945a 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -564,7 +564,7 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, struct scsi_cmnd *cmd) { struct NCR5380_hostdata *hostdata = shost_priv(instance); - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); + struct NCR5380_cmd *ncmd = NCR5380_cmd_priv(cmd); unsigned long flags; #if (NDEBUG & NDEBUG_NO_WRITE) @@ -672,7 +672,7 @@ static struct scsi_cmnd *dequeue_next_cmd(struct Scsi_Host *instance) static void requeue_cmd(struct Scsi_Host *instance, struct scsi_cmnd *cmd) { struct NCR5380_hostdata *hostdata = shost_priv(instance); - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); + struct NCR5380_cmd *ncmd = NCR5380_cmd_priv(cmd); if (hostdata->sensing == cmd) { scsi_eh_restore_cmnd(cmd, &hostdata->ses); @@ -1690,7 +1690,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) #endif while ((cmd = hostdata->connected)) { - struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd); + struct NCR5380_cmd *ncmd = NCR5380_cmd_priv(cmd); tmp = NCR5380_read(STATUS_REG); /* We only have a valid SCSI phase when REQ is asserted */ @@ -2206,7 +2206,7 @@ static bool list_del_cmd(struct list_head *haystack, struct scsi_cmnd *needle) { if (list_find_cmd(haystack, needle)) { - struct NCR5380_cmd *ncmd = scsi_cmd_priv(needle); + struct NCR5380_cmd *ncmd = NCR5380_cmd_priv(needle); list_del(&ncmd->list); return true; diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 845bd2423e66..88a1bb41b72e 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -230,6 +230,11 @@ struct NCR5380_cmd { struct list_head list; }; +static inline struct NCR5380_cmd *NCR5380_cmd_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + #define NCR5380_PIO_CHUNK_SIZE 256 /* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */ From patchwork Wed Feb 16 21:01:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01259C4332F for ; Wed, 16 Feb 2022 21:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbiBPVDZ (ORCPT ); Wed, 16 Feb 2022 16:03:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233460AbiBPVDV (ORCPT ); Wed, 16 Feb 2022 16:03:21 -0500 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D6E210AF9 for ; Wed, 16 Feb 2022 13:03:05 -0800 (PST) Received: by mail-pl1-f179.google.com with SMTP id x4so2965438plb.4 for ; Wed, 16 Feb 2022 13:03:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jf37RiC7VTWSTTIvoAPn+KulZ/XfV+x9UpQ5CyJbKq8=; b=2a4Gqm4mllhvU+mCmE0vzMGVHIByo+kWYjEJbfUhmCz247X8LE/4aw8hFYYswZ9UDF S4oHZYNXK1uD4jhSuarQfK6KD6R5pmfCVXwG84ofqDWtmQFwgcX2t4Ll1pO+yvBRfGuk 1wHcr1qLHoIeIwLw8mI3SW6TnCKvlt79Rm9RkhEedV6lBnjIPDubZjURgOqSKNXK8cPV Ff6/EToEOCZ5U1eAC+ghpmtIYPeS1VoaAJQzW29+rPg++FPyFsw1ue+xVBKBdS1xukCJ tXKTsWD3eCEJ2SU0tizk5Q4ElNyvcdXW6OzzWbVtcsE2EZb0MrEx5AGiKdhs+quVhNVI m/8g== X-Gm-Message-State: AOAM532jhRtkZg3/K+5TOtBVyiO2PL4NEu76YrQp1QKOpJr9CLNea4HQ CnZOUw8u8haAGRXshaE6r9w= X-Google-Smtp-Source: ABdhPJzwrRVOWBauTmkddQQYTWmH22D4402goyYfxTUG4lCs04oifwCBrieVeRLeeza6Fv/GTjVKfQ== X-Received: by 2002:a17:90b:3a85:b0:1b5:58c8:6d87 with SMTP id om5-20020a17090b3a8500b001b558c86d87mr3885919pjb.192.1645045385088; Wed, 16 Feb 2022 13:03:05 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:04 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Finn Thain , Ondrej Zary , Michael Schmitz , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , Finn Thain , "James E.J. Bottomley" Subject: [PATCH v4 09/50] scsi: NCR5380: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:01:52 -0800 Message-Id: <20220216210233.28774-10-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move the SCSI pointer into the NCR5380 private command data instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. The NCR5380 drivers have been identified as follows: $ git grep -l '#include.*NCR5380.h' drivers/scsi/arm/cumana_1.c drivers/scsi/arm/oak.c drivers/scsi/atari_scsi.c drivers/scsi/dmx3191d.c drivers/scsi/g_NCR5380.c drivers/scsi/mac_scsi.c drivers/scsi/sun3_scsi.c Cc: Finn Thain Cc: Ondrej Zary Cc: Michael Schmitz Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/NCR5380.c | 89 ++++++++++++++++++++++++--------------- drivers/scsi/NCR5380.h | 1 + drivers/scsi/atari_scsi.c | 7 ++- drivers/scsi/g_NCR5380.c | 6 ++- drivers/scsi/mac_scsi.c | 7 ++- drivers/scsi/sun3_scsi.c | 4 +- 6 files changed, 72 insertions(+), 42 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 6fa5e363945a..974b15cf8415 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -145,40 +145,47 @@ static void bus_reset_cleanup(struct Scsi_Host *); static inline void initialize_SCp(struct scsi_cmnd *cmd) { + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + /* * Initialize the Scsi Pointer field so that all of the commands in the * various queues are valid. */ if (scsi_bufflen(cmd)) { - cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - cmd->SCp.this_residual = cmd->SCp.buffer->length; + scsi_pointer->buffer = scsi_sglist(cmd); + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } else { - cmd->SCp.buffer = NULL; - cmd->SCp.ptr = NULL; - cmd->SCp.this_residual = 0; + scsi_pointer->buffer = NULL; + scsi_pointer->ptr = NULL; + scsi_pointer->this_residual = 0; } - cmd->SCp.Status = 0; - cmd->SCp.Message = 0; + scsi_pointer->Status = 0; + scsi_pointer->Message = 0; } static inline void advance_sg_buffer(struct scsi_cmnd *cmd) { - struct scatterlist *s = cmd->SCp.buffer; - - if (!cmd->SCp.this_residual && s && !sg_is_last(s)) { - cmd->SCp.buffer = sg_next(s); - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - cmd->SCp.this_residual = cmd->SCp.buffer->length; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + struct scatterlist *s = scsi_pointer->buffer; + + if (!scsi_pointer->this_residual && s && !sg_is_last(s)) { + scsi_pointer->buffer = sg_next(s); + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } } static inline void set_resid_from_SCp(struct scsi_cmnd *cmd) { - int resid = cmd->SCp.this_residual; - struct scatterlist *s = cmd->SCp.buffer; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + int resid = scsi_pointer->this_residual; + struct scatterlist *s = scsi_pointer->buffer; if (s) while (!sg_is_last(s)) { @@ -757,6 +764,7 @@ static void NCR5380_main(struct work_struct *work) static void NCR5380_dma_complete(struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata = shost_priv(instance); + struct scsi_pointer *scsi_pointer; int transferred; unsigned char **data; int *count; @@ -764,7 +772,10 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) unsigned char p; if (hostdata->read_overruns) { - p = hostdata->connected->SCp.phase; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(hostdata->connected)->scsi_pointer; + + p = scsi_pointer->phase; if (p & SR_IO) { udelay(10); if ((NCR5380_read(BUS_AND_STATUS_REG) & @@ -801,8 +812,9 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); hostdata->dma_len = 0; - data = (unsigned char **)&hostdata->connected->SCp.ptr; - count = &hostdata->connected->SCp.this_residual; + scsi_pointer = &NCR5380_cmd_priv(hostdata->connected)->scsi_pointer; + data = (unsigned char **)&scsi_pointer->ptr; + count = &scsi_pointer->this_residual; *data += transferred; *count -= transferred; @@ -1487,6 +1499,8 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char **data) { struct NCR5380_hostdata *hostdata = shost_priv(instance); + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(hostdata->connected)->scsi_pointer; int c = *count; unsigned char p = *phase; unsigned char *d = *data; @@ -1498,7 +1512,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, return -1; } - hostdata->connected->SCp.phase = p; + scsi_pointer->phase = p; if (p & SR_IO) { if (hostdata->read_overruns) @@ -1691,6 +1705,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) while ((cmd = hostdata->connected)) { struct NCR5380_cmd *ncmd = NCR5380_cmd_priv(cmd); + struct scsi_pointer *scsi_pointer = &ncmd->scsi_pointer; tmp = NCR5380_read(STATUS_REG); /* We only have a valid SCSI phase when REQ is asserted */ @@ -1712,10 +1727,10 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) if (count > 0) { if (cmd->sc_data_direction == DMA_TO_DEVICE) sun3scsi_dma_send_setup(hostdata, - cmd->SCp.ptr, count); + scsi_pointer->ptr, count); else sun3scsi_dma_recv_setup(hostdata, - cmd->SCp.ptr, count); + scsi_pointer->ptr, count); sun3_dma_setup_done = cmd; } #ifdef SUN3_SCSI_VME @@ -1758,8 +1773,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) advance_sg_buffer(cmd); dsprintk(NDEBUG_INFORMATION, instance, "this residual %d, sg ents %d\n", - cmd->SCp.this_residual, - sg_nents(cmd->SCp.buffer)); + scsi_pointer->this_residual, + sg_nents(scsi_pointer->buffer)); /* * The preferred transfer method is going to be @@ -1778,7 +1793,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) if (transfersize > 0) { len = transfersize; if (NCR5380_transfer_dma(instance, &phase, - &len, (unsigned char **)&cmd->SCp.ptr)) { + &len, (unsigned char **)&scsi_pointer->ptr)) { /* * If the watchdog timer fires, all future * accesses to this device will use the @@ -1794,13 +1809,13 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) /* Transfer a small chunk so that the * irq mode lock is not held too long. */ - transfersize = min(cmd->SCp.this_residual, + transfersize = min(scsi_pointer->this_residual, NCR5380_PIO_CHUNK_SIZE); len = transfersize; NCR5380_transfer_pio(instance, &phase, &len, - (unsigned char **)&cmd->SCp.ptr, + (unsigned char **)&scsi_pointer->ptr, 0); - cmd->SCp.this_residual -= transfersize - len; + scsi_pointer->this_residual -= transfersize - len; } #ifdef CONFIG_SUN3 if (sun3_dma_setup_done == cmd) @@ -1811,7 +1826,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) len = 1; data = &tmp; NCR5380_transfer_pio(instance, &phase, &len, &data, 0); - cmd->SCp.Message = tmp; + scsi_pointer->Message = tmp; switch (tmp) { case ABORT: @@ -1828,15 +1843,15 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) hostdata->connected = NULL; hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); - set_status_byte(cmd, cmd->SCp.Status); + set_status_byte(cmd, scsi_pointer->Status); set_resid_from_SCp(cmd); if (cmd->cmnd[0] == REQUEST_SENSE) complete_cmd(instance, cmd); else { - if (cmd->SCp.Status == SAM_STAT_CHECK_CONDITION || - cmd->SCp.Status == SAM_STAT_COMMAND_TERMINATED) { + if (scsi_pointer->Status == SAM_STAT_CHECK_CONDITION || + scsi_pointer->Status == SAM_STAT_COMMAND_TERMINATED) { dsprintk(NDEBUG_QUEUES, instance, "autosense: adding cmd %p to tail of autosense queue\n", cmd); list_add_tail(&ncmd->list, @@ -2000,7 +2015,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) len = 1; data = &tmp; NCR5380_transfer_pio(instance, &phase, &len, &data, 0); - cmd->SCp.Status = tmp; + scsi_pointer->Status = tmp; break; default: shost_printk(KERN_ERR, instance, "unknown phase\n"); @@ -2151,6 +2166,8 @@ static void NCR5380_reselect(struct Scsi_Host *instance) #ifdef CONFIG_SUN3 if (sun3_dma_setup_done != tmp) { + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(tmp)->scsi_pointer; int count; advance_sg_buffer(tmp); @@ -2160,10 +2177,12 @@ static void NCR5380_reselect(struct Scsi_Host *instance) if (count > 0) { if (tmp->sc_data_direction == DMA_TO_DEVICE) sun3scsi_dma_send_setup(hostdata, - tmp->SCp.ptr, count); + scsi_pointer->ptr, + count); else sun3scsi_dma_recv_setup(hostdata, - tmp->SCp.ptr, count); + scsi_pointer->ptr, + count); sun3_dma_setup_done = tmp; } } diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 88a1bb41b72e..a4291e7c24dd 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -227,6 +227,7 @@ struct NCR5380_hostdata { }; struct NCR5380_cmd { + struct scsi_pointer scsi_pointer; struct list_head list; }; diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index e9d0d99abc86..17e6a6262abf 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -538,7 +538,9 @@ static int falcon_classify_cmd(struct scsi_cmnd *cmd) static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, struct scsi_cmnd *cmd) { - int wanted_len = cmd->SCp.this_residual; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + int wanted_len = scsi_pointer->this_residual; int possible_len, limit; if (wanted_len < DMA_MIN_SIZE) @@ -610,7 +612,8 @@ static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, } /* Last step: apply the hard limit on DMA transfers */ - limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(cmd->SCp.ptr))) ? + limit = (atari_dma_buffer && + !STRAM_ADDR(virt_to_phys(scsi_pointer->ptr))) ? STRAM_BUFFER_SIZE : 255*512; if (possible_len > limit) possible_len = limit; diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 5923f86a384e..f887ed2e0a8e 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -663,7 +663,9 @@ static inline int generic_NCR5380_psend(struct NCR5380_hostdata *hostdata, static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata, struct scsi_cmnd *cmd) { - int transfersize = cmd->SCp.this_residual; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + int transfersize = scsi_pointer->this_residual; if (hostdata->flags & FLAG_NO_PSEUDO_DMA) return 0; @@ -675,7 +677,7 @@ static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata, /* Limit PDMA send to 512 B to avoid random corruption on DTC3181E */ if (hostdata->board == BOARD_DTC3181E && cmd->sc_data_direction == DMA_TO_DEVICE) - transfersize = min(cmd->SCp.this_residual, 512); + transfersize = min(scsi_pointer->this_residual, 512); return min(transfersize, DMA_MAX_SIZE); } diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 71d493a0bb43..d44ad35621fb 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -404,11 +404,14 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata, static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, struct scsi_cmnd *cmd) { + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + if (hostdata->flags & FLAG_NO_PSEUDO_DMA || - cmd->SCp.this_residual < setup_use_pdma) + scsi_pointer->this_residual < setup_use_pdma) return 0; - return cmd->SCp.this_residual; + return scsi_pointer->this_residual; } static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata) diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 82a253270c3b..3a584a1b7944 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -334,7 +334,9 @@ static int sun3scsi_dma_residual(struct NCR5380_hostdata *hostdata) static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, struct scsi_cmnd *cmd) { - int wanted_len = cmd->SCp.this_residual; + struct scsi_pointer *scsi_pointer = + &NCR5380_cmd_priv(cmd)->scsi_pointer; + int wanted_len = scsi_pointer->this_residual; if (wanted_len < DMA_MIN_SIZE || blk_rq_is_passthrough(scsi_cmd_to_rq(cmd))) return 0; From patchwork Wed Feb 16 21:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D90BC433F5 for ; Wed, 16 Feb 2022 21:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233472AbiBPVDY (ORCPT ); Wed, 16 Feb 2022 16:03:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233416AbiBPVDV (ORCPT ); Wed, 16 Feb 2022 16:03:21 -0500 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1939212891 for ; Wed, 16 Feb 2022 13:03:07 -0800 (PST) Received: by mail-pf1-f175.google.com with SMTP id c4so3172228pfl.7 for ; Wed, 16 Feb 2022 13:03:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tiRy83pbS8JbqPhLaht2SxkCi86NZhxk2F+HsvH7mWg=; b=k82/DAq5HCxVG8tHn6BGozRG6EPArAkEGRZDfr1EU0MqQdIXqQh+z/HeQ1aj44Z4CW DfOC14QJK//bUnSrAV1616HQcNCg72Db5rwrPd84nbjjjhhMbtS1oiWMxzhFSS7HJLkH emmzBBmKkeFlxB/0URsXP3Jczjs7R5cVnwGOR9bqWng6htomFiix5/UBhBvGbTP/QDiF aOF22L0yXmF+o84fqn+cNxqc9kGWQ/rzPZc89hMJ/PFzn700OKIPkpjEd3mt36Dt3Rpa OWw/XulbvUhSsRJ5Fcr1cZL3hCjQG1LUR6VSkQsE4ai6SUoZ5cEFwSxnzhssROH3oX81 FFdg== X-Gm-Message-State: AOAM530tJXwrWNfmegHkE24et8OF6iAUq+KMuDhvC76OCCQFluO2Nlnp HE6FOMl+G8qEfMmPMne7KEE= X-Google-Smtp-Source: ABdhPJzzr+RGCX9hXBRdFNVZ1Rcj5OmY5Rtwk88q0Usa8Pkwt08Pwz5KMXr0fZ3Koi91oVaK93CdTw== X-Received: by 2002:a05:6a00:13a4:b0:4ce:118f:a822 with SMTP id t36-20020a056a0013a400b004ce118fa822mr5174871pfg.33.1645045387006; Wed, 16 Feb 2022 13:03:07 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:06 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Russell King , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , "James E.J. Bottomley" Subject: [PATCH v4 10/50] scsi: arm: Rename arm/scsi.h into arm/arm_scsi.h Date: Wed, 16 Feb 2022 13:01:53 -0800 Message-Id: <20220216210233.28774-11-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The new name makes the purpose of this header file more clear and also makes it easier to find this header file with grep. Cc: Russell King Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/arm/acornscsi.c | 2 +- drivers/scsi/arm/{scsi.h => arm_scsi.h} | 4 +--- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/fas216.c | 2 +- drivers/scsi/arm/powertec.c | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) rename drivers/scsi/arm/{scsi.h => arm_scsi.h} (97%) diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index a8a72d822862..38aa9333631b 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -136,7 +136,7 @@ #include #include "acornscsi.h" #include "msgqueue.h" -#include "scsi.h" +#include "arm_scsi.h" #include diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/arm_scsi.h similarity index 97% rename from drivers/scsi/arm/scsi.h rename to drivers/scsi/arm/arm_scsi.h index 4d5ff7b4e864..3eb5c6aa93c9 100644 --- a/drivers/scsi/arm/scsi.h +++ b/drivers/scsi/arm/arm_scsi.h @@ -1,10 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * linux/drivers/acorn/scsi/scsi.h - * * Copyright (C) 2002 Russell King * - * Commonly used scsi driver functions. + * Commonly used functions by the ARM SCSI-II drivers. */ #include diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 536d6646e40b..d15053f02472 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c @@ -36,7 +36,7 @@ #include #include #include "fas216.h" -#include "scsi.h" +#include "arm_scsi.h" #include diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index ab0f6422a6a9..6f374af9f45f 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c @@ -42,7 +42,7 @@ #include #include #include "fas216.h" -#include "scsi.h" +#include "arm_scsi.h" #include diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 0d6df5ebf934..a23e34c9f7de 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -55,7 +55,7 @@ #include #include #include "fas216.h" -#include "scsi.h" +#include "arm_scsi.h" /* NOTE: SCSI2 Synchronous transfers *require* DMA according to * the data sheet. This restriction is crazy, especially when diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index 797568b271e3..7586d2a03812 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c @@ -27,7 +27,7 @@ #include #include #include "fas216.h" -#include "scsi.h" +#include "arm_scsi.h" #include From patchwork Wed Feb 16 21:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB8DC433F5 for ; Wed, 16 Feb 2022 21:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbiBPVD0 (ORCPT ); Wed, 16 Feb 2022 16:03:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233398AbiBPVDW (ORCPT ); Wed, 16 Feb 2022 16:03:22 -0500 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D90212E12 for ; Wed, 16 Feb 2022 13:03:09 -0800 (PST) Received: by mail-pl1-f169.google.com with SMTP id z17so2951105plb.9 for ; Wed, 16 Feb 2022 13:03:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/Ba4bEJmtkM/3WJAT4TgzDstqDhaDKX2I2VSFRMVcdg=; b=PyDWs+HKRjZ+SpUq0vhXvJqxP94ZiGTHc76wJvuILCpi+OlbZ5/72zquj1FYY6zwcH d0r6goisqLFwpnx5xInLUE2CjlvsVYjMNge6+K/YVNvYOkPGFh1Dn7/7cl2yQeDN369Y u3Jd3O8fIhagQf2A9tkDci7zp0PkD5e4VhPLb0X+v2a4jlLcz8O6f0s4iX4lPeoKHPAT FmwMfbSMC6mC4K0htHPGCO08pKHLtleC1his35qjTVCXbtuUMkmqdfF5tCy/cikaV08/ 8yLW3hmf0GHc84yXRIVkruTS9Q5mBB5vSybsItvr4oNC0ce0RJh9vbgva5m3BuCcFKC+ 3LjQ== X-Gm-Message-State: AOAM531SoIkAxj/GV5/wXVzFelQhN1WZ7d4QP2oXFhxoORdYKkNuDVFJ s+VHWrmgdmS69UdS9jo6I/Y= X-Google-Smtp-Source: ABdhPJwFSAVLI7PziCGNnUcaIUSVPgGNkpmUv3mJQG6+ddUCEHjfM+wsRt148UOeEfrac1xzGyoRQQ== X-Received: by 2002:a17:903:3002:b0:14e:e705:cd37 with SMTP id o2-20020a170903300200b0014ee705cd37mr4113071pla.71.1645045388759; Wed, 16 Feb 2022 13:03:08 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:08 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Russell King , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 11/50] scsi: arm: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:01:54 -0800 Message-Id: <20220216210233.28774-12-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. The ARM SCSI drivers have been identified as follows: $ git grep -l '#include.*arm_scsi.h' drivers/scsi/arm/acornscsi.c drivers/scsi/arm/cumana_2.c drivers/scsi/arm/eesox.c drivers/scsi/arm/fas216.c drivers/scsi/arm/powertec.c Cc: Russell King Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/arm/acornscsi.c | 20 ++++++++++++-------- drivers/scsi/arm/arm_scsi.h | 33 +++++++++++++++++++++++---------- drivers/scsi/arm/fas216.c | 28 +++++++++++++++++----------- drivers/scsi/arm/fas216.h | 4 ++++ 4 files changed, 56 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 38aa9333631b..7602639da9b3 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -729,7 +729,7 @@ intr_ret_t acornscsi_kick(AS_Host *host) */ host->scsi.phase = PHASE_CONNECTING; host->SCpnt = SCpnt; - host->scsi.SCp = SCpnt->SCp; + host->scsi.SCp = *arm_scsi_pointer(SCpnt); host->dma.xfer_setup = 0; host->dma.xfer_required = 0; host->dma.xfer_done = 0; @@ -1424,6 +1424,7 @@ unsigned char acornscsi_readmessagebyte(AS_Host *host) static void acornscsi_message(AS_Host *host) { + struct scsi_pointer *scsi_pointer; unsigned char message[16]; unsigned int msgidx = 0, msglen = 1; @@ -1493,8 +1494,9 @@ void acornscsi_message(AS_Host *host) * the saved data pointer for the current I/O process. */ acornscsi_dma_cleanup(host); - host->SCpnt->SCp = host->scsi.SCp; - host->SCpnt->SCp.sent_command = 0; + scsi_pointer = arm_scsi_pointer(host->SCpnt); + *scsi_pointer = host->scsi.SCp; + scsi_pointer->sent_command = 0; host->scsi.phase = PHASE_MSGIN; break; @@ -1509,7 +1511,7 @@ void acornscsi_message(AS_Host *host) * the present command and status areas.' */ acornscsi_dma_cleanup(host); - host->scsi.SCp = host->SCpnt->SCp; + host->scsi.SCp = *arm_scsi_pointer(host->SCpnt); host->scsi.phase = PHASE_MSGIN; break; @@ -1809,7 +1811,7 @@ int acornscsi_reconnect_finish(AS_Host *host) /* * Restore data pointer from SAVED pointers. */ - host->scsi.SCp = host->SCpnt->SCp; + host->scsi.SCp = *arm_scsi_pointer(host->SCpnt); #if (DEBUG & (DEBUG_QUEUES|DEBUG_DISCON)) printk(", data pointers: [%p, %X]", host->scsi.SCp.ptr, host->scsi.SCp.this_residual); @@ -2408,6 +2410,7 @@ acornscsi_intr(int irq, void *dev_id) */ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt) { + struct scsi_pointer *scsi_pointer = arm_scsi_pointer(SCpnt); void (*done)(struct scsi_cmnd *) = scsi_done; AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; @@ -2423,9 +2426,9 @@ static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt) SCpnt->host_scribble = NULL; SCpnt->result = 0; - SCpnt->SCp.phase = (int)acornscsi_datadirection(SCpnt->cmnd[0]); - SCpnt->SCp.sent_command = 0; - SCpnt->SCp.scsi_xferred = 0; + scsi_pointer->phase = (int)acornscsi_datadirection(SCpnt->cmnd[0]); + scsi_pointer->sent_command = 0; + scsi_pointer->scsi_xferred = 0; init_SCp(SCpnt); @@ -2791,6 +2794,7 @@ static struct scsi_host_template acornscsi_template = { .cmd_per_lun = 2, .dma_boundary = PAGE_SIZE - 1, .proc_name = "acornscsi", + .cmd_size = sizeof(struct arm_cmd_priv), }; static int acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id) diff --git a/drivers/scsi/arm/arm_scsi.h b/drivers/scsi/arm/arm_scsi.h index 3eb5c6aa93c9..ea9fcd92c6de 100644 --- a/drivers/scsi/arm/arm_scsi.h +++ b/drivers/scsi/arm/arm_scsi.h @@ -9,6 +9,17 @@ #define BELT_AND_BRACES +struct arm_cmd_priv { + struct scsi_pointer scsi_pointer; +}; + +static inline struct scsi_pointer *arm_scsi_pointer(struct scsi_cmnd *cmd) +{ + struct arm_cmd_priv *acmd = scsi_cmd_priv(cmd); + + return &acmd->scsi_pointer; +} + /* * The scatter-gather list handling. This contains all * the yucky stuff that needs to be fixed properly. @@ -76,16 +87,18 @@ static inline void put_next_SCp_byte(struct scsi_pointer *SCp, unsigned char c) static inline void init_SCp(struct scsi_cmnd *SCpnt) { - memset(&SCpnt->SCp, 0, sizeof(struct scsi_pointer)); + struct scsi_pointer *scsi_pointer = arm_scsi_pointer(SCpnt); + + memset(scsi_pointer, 0, sizeof(struct scsi_pointer)); if (scsi_bufflen(SCpnt)) { unsigned long len = 0; - SCpnt->SCp.buffer = scsi_sglist(SCpnt); - SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; - SCpnt->SCp.ptr = sg_virt(SCpnt->SCp.buffer); - SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; - SCpnt->SCp.phase = scsi_bufflen(SCpnt); + scsi_pointer->buffer = scsi_sglist(SCpnt); + scsi_pointer->buffers_residual = scsi_sg_count(SCpnt) - 1; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; + scsi_pointer->phase = scsi_bufflen(SCpnt); #ifdef BELT_AND_BRACES { /* @@ -109,15 +122,15 @@ static inline void init_SCp(struct scsi_cmnd *SCpnt) * FIXME: Totaly naive fixup. We should abort * with error */ - SCpnt->SCp.phase = + scsi_pointer->phase = min_t(unsigned long, len, scsi_bufflen(SCpnt)); } } #endif } else { - SCpnt->SCp.ptr = NULL; - SCpnt->SCp.this_residual = 0; - SCpnt->SCp.phase = 0; + scsi_pointer->ptr = NULL; + scsi_pointer->this_residual = 0; + scsi_pointer->phase = 0; } } diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index a23e34c9f7de..4ce0b2d73614 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -761,7 +761,7 @@ static void fas216_transfer(FAS216_Info *info) fas216_log(info, LOG_ERROR, "null buffer passed to " "fas216_starttransfer"); print_SCp(&info->scsi.SCp, "SCp: ", "\n"); - print_SCp(&info->SCpnt->SCp, "Cmnd SCp: ", "\n"); + print_SCp(arm_scsi_pointer(info->SCpnt), "Cmnd SCp: ", "\n"); return; } @@ -1011,7 +1011,7 @@ fas216_reselected_intr(FAS216_Info *info) /* * Restore data pointer from SAVED data pointer */ - info->scsi.SCp = info->SCpnt->SCp; + info->scsi.SCp = *arm_scsi_pointer(info->SCpnt); fas216_log(info, LOG_CONNECT, "data pointers: [%p, %X]", info->scsi.SCp.ptr, info->scsi.SCp.this_residual); @@ -1054,6 +1054,7 @@ fas216_reselected_intr(FAS216_Info *info) static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int msglen) { + struct scsi_pointer *scsi_pointer; int i; switch (message[0]) { @@ -1078,8 +1079,9 @@ static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int * as required by the SCSI II standard. These always * point to the start of their respective areas. */ - info->SCpnt->SCp = info->scsi.SCp; - info->SCpnt->SCp.sent_command = 0; + scsi_pointer = arm_scsi_pointer(info->SCpnt); + *scsi_pointer = info->scsi.SCp; + scsi_pointer->sent_command = 0; fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER, "save data pointers: [%p, %X]", info->scsi.SCp.ptr, info->scsi.SCp.this_residual); @@ -1092,7 +1094,7 @@ static void fas216_parse_message(FAS216_Info *info, unsigned char *message, int /* * Restore current data pointer from SAVED data pointer */ - info->scsi.SCp = info->SCpnt->SCp; + info->scsi.SCp = *arm_scsi_pointer(info->SCpnt); fas216_log(info, LOG_CONNECT | LOG_MESSAGES | LOG_BUFFER, "restore data pointers: [%p, 0x%x]", info->scsi.SCp.ptr, info->scsi.SCp.this_residual); @@ -1770,7 +1772,7 @@ static void fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt) * claim host busy */ info->scsi.phase = PHASE_SELECTION; - info->scsi.SCp = SCpnt->SCp; + info->scsi.SCp = *arm_scsi_pointer(SCpnt); info->SCpnt = SCpnt; info->dma.transfer_type = fasdma_none; @@ -1849,7 +1851,7 @@ static void fas216_do_bus_device_reset(FAS216_Info *info, * claim host busy */ info->scsi.phase = PHASE_SELECTION; - info->scsi.SCp = SCpnt->SCp; + info->scsi.SCp = *arm_scsi_pointer(SCpnt); info->SCpnt = SCpnt; info->dma.transfer_type = fasdma_none; @@ -1999,11 +2001,13 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) { + struct scsi_pointer *scsi_pointer = arm_scsi_pointer(SCpnt); + fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, "request sense complete, result=0x%04x%02x%02x", - result, SCpnt->SCp.Message, SCpnt->SCp.Status); + result, scsi_pointer->Message, scsi_pointer->Status); - if (result != DID_OK || SCpnt->SCp.Status != SAM_STAT_GOOD) + if (result != DID_OK || scsi_pointer->Status != SAM_STAT_GOOD) /* * Something went wrong. Make sure that we don't * have valid data in the sense buffer that could @@ -2033,6 +2037,8 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, static void fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) { + struct scsi_pointer *scsi_pointer = arm_scsi_pointer(SCpnt); + info->stats.fins += 1; set_host_byte(SCpnt, result); @@ -2107,8 +2113,8 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) fas216_log_target(info, LOG_CONNECT, SCpnt->device->id, "requesting sense"); init_SCp(SCpnt); - SCpnt->SCp.Message = 0; - SCpnt->SCp.Status = 0; + scsi_pointer->Message = 0; + scsi_pointer->Status = 0; SCpnt->host_scribble = (void *)fas216_rq_sns_done; /* diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index abf960487314..08113277a2a9 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -312,6 +312,10 @@ typedef struct { /* driver-private data per SCSI command. */ struct fas216_cmd_priv { + /* + * @scsi_pointer must be the first member. See also arm_scsi_pointer(). + */ + struct scsi_pointer scsi_pointer; void (*scsi_done)(struct scsi_cmnd *cmd); }; From patchwork Wed Feb 16 21:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB4E9C433EF for ; Wed, 16 Feb 2022 21:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233535AbiBPVD2 (ORCPT ); Wed, 16 Feb 2022 16:03:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbiBPVDX (ORCPT ); Wed, 16 Feb 2022 16:03:23 -0500 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97FE213409 for ; Wed, 16 Feb 2022 13:03:10 -0800 (PST) Received: by mail-pf1-f182.google.com with SMTP id i6so3167321pfc.9 for ; Wed, 16 Feb 2022 13:03:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Woqxw/zqQxyqs/Ud74tzjcz1WT0YRS65oBUeDleTKn8=; b=ElBcNZ0KORm0xd+z/Lu5IPoBnbpeWMq3ea4yO+hzkgowrpazDdSnwosJXSGgFEO7aF G4I82Wr4zJ2EHqKw1jwCmmbbgpAwTknBfZbyhEScdKSV2dzK/rF/w17l9tGlepNdOYqV gsETdRDEt8FvRJERLU4n9XFhA2aDcUCZ4QhtjmwG6jP5g05izRmUEY8pVCAnh1r0aV3h RIc3idBYHlVjLgF6BANy8p++9yNd33JgnCjEALg2/3jLC/WDBxC955ZO25iwf2hgx1PK NhPLHlkSCfTDoPKWuBjhk2LGS4GIbvy0PEp/N5YgS5Sq7IcGInw1M5Hr0N5vxd+Zio0z YjFQ== X-Gm-Message-State: AOAM5320HAxUBNJYE8tYdtQ01r22r5jIlg/KtRzlykUdfWV3V+2VUmRZ D3xzPAC5ld6zPHk8FKox6Ig= X-Google-Smtp-Source: ABdhPJxMkxHw1byr6i8CYzI/6vvR1jMcQYAKrFJI2jHYiYpfsggANtptPlnr5DpZYgkBd9NomQxOAg== X-Received: by 2002:a63:f912:0:b0:372:bac6:b92d with SMTP id h18-20020a63f912000000b00372bac6b92dmr3709954pgi.265.1645045390356; Wed, 16 Feb 2022 13:03:10 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:09 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , "James E.J. Bottomley" Subject: [PATCH v4 12/50] scsi: 53c700: Stop clearing SCSI pointer fields Date: Wed, 16 Feb 2022 13:01:55 -0800 Message-Id: <20220216210233.28774-13-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org None of the 53c700 drivers uses the SCSI pointer. Hence remove the code from 53c700.c that clears two SCSI pointer fields. The 53c700 drivers are: $ git grep -l 'include.*53c700' drivers/scsi/53c700.c drivers/scsi/a4000t.c drivers/scsi/bvme6000_scsi.c drivers/scsi/lasi700.c drivers/scsi/mvme16x_scsi.c drivers/scsi/sim710.c drivers/scsi/sni_53c710.c drivers/scsi/zorro7xx.c Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/53c700.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 3ad3ebaca8e9..df469a411fdb 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -1792,8 +1792,6 @@ static int NCR_700_queuecommand_lck(struct scsi_cmnd *SCp) slot->cmnd = SCp; SCp->host_scribble = (unsigned char *)slot; - SCp->SCp.ptr = NULL; - SCp->SCp.buffer = NULL; #ifdef NCR_700_DEBUG printk("53c700: scsi%d, command ", SCp->device->host->host_no); From patchwork Wed Feb 16 21:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CC7EC433EF for ; Wed, 16 Feb 2022 21:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233214AbiBPVDe (ORCPT ); Wed, 16 Feb 2022 16:03:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233529AbiBPVD0 (ORCPT ); Wed, 16 Feb 2022 16:03:26 -0500 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE1A213920 for ; Wed, 16 Feb 2022 13:03:12 -0800 (PST) Received: by mail-pj1-f54.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso7530453pjt.4 for ; Wed, 16 Feb 2022 13:03:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rzT3EzQ4DCE8qaMk2M0orsVE5XN2yxnIAxRkAgTIWg4=; b=FULBpdiftBM23CEENOZoYgT/7Yp9SdzfYvHUCE9QrY0+Kz+nsAr05Sxe2J0gfSZOZy hhWGkXeNwEGeYdXlAgzcN4ymt1b5dcXoXwJWdMASocYcJi/cAs0pdIGRjiM+fi66bIZy KpdN5HNgNduGDKyXGeueFxr1nuv5h/M7xliXqR04j2ULDYzNSLmDlhemBMblJTmSScGS oSworW+8Ax+aOFhyURCqhTJCanbYiBdBFwwyLwtVA4EoXTpbv6kCvClBuJzO5Z55eLTP b0yQ2Rn5QXQLpwd0d+dnjxPg8N50YcRO8marh3OXZRJieNIhi8MGMUuFvV8Vi9wIofh7 O9WQ== X-Gm-Message-State: AOAM533EaVRThNGYkBztKlWB8/5pNrcrlIhXM3i5kHypIodUVPH3Izqw jh1K9Z2FNgUWO6+8ofxXf4RSmFLDNLoqlQ== X-Google-Smtp-Source: ABdhPJwiV5SmLdULAtPkuAhQOO/H7AHs1LHpWsksXrC5imm1acfJtt95rljXAHVL4ehoA5Hk9I2fiQ== X-Received: by 2002:a17:90a:1b04:b0:1b9:92e1:6264 with SMTP id q4-20020a17090a1b0400b001b992e16264mr3876382pjq.116.1645045392239; Wed, 16 Feb 2022 13:03:12 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:11 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Adaptec OEM Raid Solutions , "James E.J. Bottomley" Subject: [PATCH v4 13/50] scsi: aacraid: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:01:56 -0800 Message-Id: <20220216210233.28774-14-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/aacraid/aachba.c | 43 ++++++++++++++++++--------------- drivers/scsi/aacraid/aacraid.h | 24 ++++++++++++++---- drivers/scsi/aacraid/comminit.c | 2 +- drivers/scsi/aacraid/linit.c | 21 ++++++++-------- 4 files changed, 54 insertions(+), 36 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index b04d039da276..81462f4ddb90 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -338,7 +338,7 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd, aac_fib_complete(fibptr); return 0; } - scsicmd->SCp.phase = AAC_OWNER_MIDLEVEL; + aac_priv(scsicmd)->owner = AAC_OWNER_MIDLEVEL; device = scsicmd->device; if (unlikely(!device)) { dprintk((KERN_WARNING "aac_valid_context: scsi device corrupt\n")); @@ -592,7 +592,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd) aac_fib_init(cmd_fibcontext); dinfo = (struct aac_get_name *) fib_data(cmd_fibcontext); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; dinfo->command = cpu_to_le32(VM_ContainerConfig); dinfo->type = cpu_to_le32(CT_READ_NAME); @@ -634,14 +634,15 @@ static void _aac_probe_container2(void * context, struct fib * fibptr) { struct fsa_dev_info *fsa_dev_ptr; int (*callback)(struct scsi_cmnd *); - struct scsi_cmnd * scsicmd = (struct scsi_cmnd *)context; + struct scsi_cmnd *scsicmd = context; + struct aac_cmd_priv *cmd_priv = aac_priv(scsicmd); int i; if (!aac_valid_context(scsicmd, fibptr)) return; - scsicmd->SCp.Status = 0; + cmd_priv->status = 0; fsa_dev_ptr = fibptr->dev->fsa_dev; if (fsa_dev_ptr) { struct aac_mount * dresp = (struct aac_mount *) fib_data(fibptr); @@ -679,12 +680,12 @@ static void _aac_probe_container2(void * context, struct fib * fibptr) } if ((fsa_dev_ptr->valid & 1) == 0) fsa_dev_ptr->valid = 0; - scsicmd->SCp.Status = le32_to_cpu(dresp->count); + cmd_priv->status = le32_to_cpu(dresp->count); } aac_fib_complete(fibptr); aac_fib_free(fibptr); - callback = (int (*)(struct scsi_cmnd *))(scsicmd->SCp.ptr); - scsicmd->SCp.ptr = NULL; + callback = cmd_priv->callback; + cmd_priv->callback = NULL; (*callback)(scsicmd); return; } @@ -722,7 +723,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr) dinfo->count = cpu_to_le32(scmd_id(scsicmd)); dinfo->type = cpu_to_le32(FT_FILESYS); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_fib_send(ContainerCommand, fibptr, @@ -743,6 +744,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr) static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(struct scsi_cmnd *)) { + struct aac_cmd_priv *cmd_priv = aac_priv(scsicmd); struct fib * fibptr; int status = -ENOMEM; @@ -761,8 +763,8 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru dinfo->count = cpu_to_le32(scmd_id(scsicmd)); dinfo->type = cpu_to_le32(FT_FILESYS); - scsicmd->SCp.ptr = (char *)callback; - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + cmd_priv->callback = callback; + cmd_priv->owner = AAC_OWNER_FIRMWARE; status = aac_fib_send(ContainerCommand, fibptr, @@ -778,7 +780,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru return 0; if (status < 0) { - scsicmd->SCp.ptr = NULL; + cmd_priv->callback = NULL; aac_fib_complete(fibptr); aac_fib_free(fibptr); } @@ -817,6 +819,7 @@ static void aac_probe_container_scsi_done(struct scsi_cmnd *scsi_cmnd) int aac_probe_container(struct aac_dev *dev, int cid) { struct scsi_cmnd *scsicmd = kzalloc(sizeof(*scsicmd), GFP_KERNEL); + struct aac_cmd_priv *cmd_priv = aac_priv(scsicmd); struct scsi_device *scsidev = kzalloc(sizeof(*scsidev), GFP_KERNEL); int status; @@ -835,7 +838,7 @@ int aac_probe_container(struct aac_dev *dev, int cid) while (scsicmd->device == scsidev) schedule(); kfree(scsidev); - status = scsicmd->SCp.Status; + status = cmd_priv->status; kfree(scsicmd); return status; } @@ -1128,7 +1131,7 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd) dinfo->command = cpu_to_le32(VM_ContainerConfig); dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID); dinfo->cid = cpu_to_le32(scmd_id(scsicmd)); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_fib_send(ContainerCommand, cmd_fibcontext, @@ -2486,7 +2489,7 @@ static int aac_read(struct scsi_cmnd * scsicmd) * Alocate and initialize a Fib */ cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_adapter_read(cmd_fibcontext, scsicmd, lba, count); /* @@ -2577,7 +2580,7 @@ static int aac_write(struct scsi_cmnd * scsicmd) * Allocate and initialize a Fib then setup a BlockWrite command */ cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_adapter_write(cmd_fibcontext, scsicmd, lba, count, fua); /* @@ -2660,7 +2663,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd) synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); synchronizecmd->count = cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; /* * Now send the Fib to the adapter @@ -2736,7 +2739,7 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd) pmcmd->cid = cpu_to_le32(sdev_id(sdev)); pmcmd->parm = (scsicmd->cmnd[1] & 1) ? cpu_to_le32(CT_PM_UNIT_IMMEDIATE) : 0; - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; /* * Now send the Fib to the adapter @@ -3695,7 +3698,7 @@ void aac_hba_callback(void *context, struct fib *fibptr) aac_fib_complete(fibptr); if (fibptr->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF) - scsicmd->SCp.sent_command = 1; + aac_priv(scsicmd)->sent_command = 1; else aac_scsi_done(scsicmd); } @@ -3725,7 +3728,7 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) * Allocate and initialize a Fib then setup a BlockWrite command */ cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_adapter_scsi(cmd_fibcontext, scsicmd); /* @@ -3769,7 +3772,7 @@ static int aac_send_hba_fib(struct scsi_cmnd *scsicmd) if (!cmd_fibcontext) return -1; - scsicmd->SCp.phase = AAC_OWNER_FIRMWARE; + aac_priv(scsicmd)->owner = AAC_OWNER_FIRMWARE; status = aac_adapter_hba(cmd_fibcontext, scsicmd); /* diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3733df77bc65..f849e7c9d428 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -29,6 +29,7 @@ #include #include #include +#include /*------------------------------------------------------------------------------ * D E F I N E S @@ -2673,11 +2674,24 @@ static inline void aac_cancel_rescan_worker(struct aac_dev *dev) cancel_delayed_work_sync(&dev->src_reinit_aif_worker); } -/* SCp.phase values */ -#define AAC_OWNER_MIDLEVEL 0x101 -#define AAC_OWNER_LOWLEVEL 0x102 -#define AAC_OWNER_ERROR_HANDLER 0x103 -#define AAC_OWNER_FIRMWARE 0x106 +enum aac_cmd_owner { + AAC_OWNER_MIDLEVEL = 0x101, + AAC_OWNER_LOWLEVEL = 0x102, + AAC_OWNER_ERROR_HANDLER = 0x103, + AAC_OWNER_FIRMWARE = 0x106, +}; + +struct aac_cmd_priv { + int (*callback)(struct scsi_cmnd *); + int status; + enum aac_cmd_owner owner; + bool sent_command; +}; + +static inline struct aac_cmd_priv *aac_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} void aac_safw_rescan_worker(struct work_struct *work); void aac_src_reinit_aif_worker(struct work_struct *work); diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 355b16f0b145..940a6deab38f 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -276,7 +276,7 @@ static bool wait_for_io_iter(struct scsi_cmnd *cmd, void *data, bool rsvd) { int *active = data; - if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) + if (aac_priv(cmd)->owner == AAC_OWNER_FIRMWARE) *active = *active + 1; return true; } diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index a911252075a6..b91b72b923ec 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -241,10 +241,9 @@ static struct aac_driver_ident aac_drivers[] = { static int aac_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmd) { - int r = 0; - cmd->SCp.phase = AAC_OWNER_LOWLEVEL; - r = (aac_scsi_cmd(cmd) ? FAILED : 0); - return r; + aac_priv(cmd)->owner = AAC_OWNER_LOWLEVEL; + + return aac_scsi_cmd(cmd) ? FAILED : 0; } /** @@ -638,7 +637,7 @@ static bool fib_count_iter(struct scsi_cmnd *scmnd, void *data, bool reserved) { struct fib_count_data *fib_count = data; - switch (scmnd->SCp.phase) { + switch (aac_priv(scmnd)->owner) { case AAC_OWNER_FIRMWARE: fib_count->fwcnt++; break; @@ -680,6 +679,7 @@ static int get_num_of_incomplete_fibs(struct aac_dev *aac) static int aac_eh_abort(struct scsi_cmnd* cmd) { + struct aac_cmd_priv *cmd_priv = aac_priv(cmd); struct scsi_device * dev = cmd->device; struct Scsi_Host * host = dev->host; struct aac_dev * aac = (struct aac_dev *)host->hostdata; @@ -732,7 +732,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) tmf->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); fib->hbacmd_size = sizeof(*tmf); - cmd->SCp.sent_command = 0; + cmd_priv->sent_command = 0; status = aac_hba_send(HBA_IU_TYPE_SCSI_TM_REQ, fib, (fib_callback) aac_hba_callback, @@ -744,7 +744,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) } /* Wait up to 15 secs for completion */ for (count = 0; count < 15; ++count) { - if (cmd->SCp.sent_command) { + if (cmd_priv->sent_command) { ret = SUCCESS; break; } @@ -784,7 +784,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) (fib->callback_data == cmd)) { fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT; - cmd->SCp.phase = + cmd_priv->owner = AAC_OWNER_ERROR_HANDLER; ret = SUCCESS; } @@ -811,7 +811,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) (command->device == cmd->device)) { fib->flags |= FIB_CONTEXT_FLAG_TIMED_OUT; - command->SCp.phase = + aac_priv(command)->owner = AAC_OWNER_ERROR_HANDLER; if (command == cmd) ret = SUCCESS; @@ -1058,7 +1058,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd) if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS || info->devtype != AAC_DEVTYPE_NATIVE_RAW) { fib->flags |= FIB_CONTEXT_FLAG_EH_RESET; - cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER; + aac_priv(cmd)->owner = AAC_OWNER_ERROR_HANDLER; } } } @@ -1507,6 +1507,7 @@ static struct scsi_host_template aac_driver_template = { #endif .emulated = 1, .no_write_same = 1, + .cmd_size = sizeof(struct aac_cmd_priv), }; static void __aac_shutdown(struct aac_dev * aac) From patchwork Wed Feb 16 21:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10464C433F5 for ; Wed, 16 Feb 2022 21:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbiBPVDk (ORCPT ); Wed, 16 Feb 2022 16:03:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbiBPVDc (ORCPT ); Wed, 16 Feb 2022 16:03:32 -0500 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 866E8213F14 for ; Wed, 16 Feb 2022 13:03:14 -0800 (PST) Received: by mail-pl1-f171.google.com with SMTP id x4so2965791plb.4 for ; Wed, 16 Feb 2022 13:03:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2vuShzWu3ZIh6QSM2HQ53oBiJIY+AOjKbypfgrmVa24=; b=TQOWP0CxcogfJojb5jqapLUBi4PDIuZ4Z8KYEUFiGIgE/Egbq235y2B8VwM91nGcAB XXtWpMTcTktbF4xXDCJtRbCl/gBoVeaQhhlfL8fxGP9WOhHn7Otr4nyXalDA9uRMyBTc HoMZNweWI3TmaBLC1TZFmvyvd0PvaTrNMIRzboXhtiI2EODpFOE38utUaWb4t3fPq/AK MMnD3hQcu42AkQsFU1JUljJg/fUy9ny+Z+TlJ/fz65L+gqfMDtH2C37zZ5/FS7kxjIQi z9iMe/8bOzaKIcNv/5Uc9ZUh55oz/7rAmODxuMiJoIaFNuWiscg7Xy9ShoUhyPxOdiMa 0yrA== X-Gm-Message-State: AOAM5314vaQN64IKfWoIgNASCLcQQ5xOu2CxB+TqaAngo4UyYo5U331V VdEIkFTDljhnDZDn7sa2fAA= X-Google-Smtp-Source: ABdhPJwi8r71dJP2twe6Zsnpc81Vrk6RCBE8U+exWKbWWSUyvE3pP6kuTTcK2sai6ATqAoQ6lDh8dQ== X-Received: by 2002:a17:90a:b017:b0:1b9:485b:3005 with SMTP id x23-20020a17090ab01700b001b9485b3005mr3858532pjq.33.1645045393854; Wed, 16 Feb 2022 13:03:13 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:13 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Matthew Wilcox , Hannes Reinecke , "James E.J. Bottomley" Subject: [PATCH v4 14/50] scsi: advansys: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:01:57 -0800 Message-Id: <20220216210233.28774-15-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/advansys.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index ace5eff828e9..f301aec044bb 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -2277,6 +2277,15 @@ struct asc_board { dvc_var.adv_dvc_var) #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev) +struct advansys_cmd { + dma_addr_t dma_handle; +}; + +static struct advansys_cmd *advansys_cmd(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + #ifdef ADVANSYS_DEBUG static int asc_dbglvl = 3; @@ -6681,7 +6690,7 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) ASC_STATS(boardp->shost, callback); - dma_unmap_single(boardp->dev, scp->SCp.dma_handle, + dma_unmap_single(boardp->dev, advansys_cmd(scp)->dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); /* * 'qdonep' contains the command's ending status. @@ -7399,15 +7408,15 @@ static int advansys_slave_configure(struct scsi_device *sdev) static __le32 asc_get_sense_buffer_dma(struct scsi_cmnd *scp) { struct asc_board *board = shost_priv(scp->device->host); + struct advansys_cmd *acmd = advansys_cmd(scp); - scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer, - SCSI_SENSE_BUFFERSIZE, - DMA_FROM_DEVICE); - if (dma_mapping_error(board->dev, scp->SCp.dma_handle)) { + acmd->dma_handle = dma_map_single(board->dev, scp->sense_buffer, + SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(board->dev, acmd->dma_handle)) { ASC_DBG(1, "failed to map sense buffer\n"); return 0; } - return cpu_to_le32(scp->SCp.dma_handle); + return cpu_to_le32(acmd->dma_handle); } static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, @@ -10604,6 +10613,7 @@ static struct scsi_host_template advansys_template = { .eh_host_reset_handler = advansys_reset, .bios_param = advansys_biosparam, .slave_configure = advansys_slave_configure, + .cmd_size = sizeof(struct advansys_cmd), }; static int advansys_wide_init_chip(struct Scsi_Host *shost) From patchwork Wed Feb 16 21:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27BF6C433EF for ; Wed, 16 Feb 2022 21:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233570AbiBPVDl (ORCPT ); Wed, 16 Feb 2022 16:03:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233568AbiBPVDd (ORCPT ); Wed, 16 Feb 2022 16:03:33 -0500 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1CA21489F for ; Wed, 16 Feb 2022 13:03:16 -0800 (PST) Received: by mail-pl1-f173.google.com with SMTP id w1so2960574plb.6 for ; Wed, 16 Feb 2022 13:03:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nwYKhyFHil4fSG2RLAlZPEkTLtDpBryjbZMFKiNxE5M=; b=52aRrX4jSImz5z8ztYLA5pY/cwgLAYH9kvENjT18EsT/Ky1AzoWP6TMASpZmyJtF1S 4UAV73BFCxf0b6obTGNROKIB3CZuavtDe/21mc9BWYwbraQsiyffQpPgFGZbFhqL9eSs 8Xs7Ygfjsoia1JMQ3QMftw+SX0ermqCZPrWqLRS+UYYzfhAl523vxFY+JUmKv3EJSOwN xvpij66JD9nBHtjBrCjvD+Ef9lcZdamEQq+68ckMuoMamKBXu7FIfE18RGy8De7K04se oWbfJhpK3ZmHp0Xr/e7pVU8m8RPV9wic20zhe6wJu9xl/bllv5+Cn6mVQfrRcUu37iXU jMQg== X-Gm-Message-State: AOAM532INVgNYqWx7kEZBidaga+YRFe+QnZqBTTDN9ejpbjJbwiFcS7C q/POsryy25lE89pAxqaDz6k= X-Google-Smtp-Source: ABdhPJzfBkduG8GWorq5vqXudEeeqqY7DDIHV/GgblEfhwXjkDvoly9uBeT0TZ8vEn/nUOjSvFMZkA== X-Received: by 2002:a17:90b:3698:b0:1b9:e011:b942 with SMTP id mj24-20020a17090b369800b001b9e011b942mr3811243pjb.189.1645045395416; Wed, 16 Feb 2022 13:03:15 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:14 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 15/50] scsi: aha1542: Remove a set-but-not-used array Date: Wed, 16 Feb 2022 13:01:58 -0800 Message-Id: <20220216210233.28774-16-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch fixes the following W=1 warning: drivers/scsi/aha1542.c:209:12: warning: variable ‘inquiry_result’ set but not used [-Wunused-but-set-variable] 209 | u8 inquiry_result[4]; Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/aha1542.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index f0e8ae9f5e40..cf7bba2ca68d 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -206,7 +206,6 @@ static int makecode(unsigned hosterr, unsigned scsierr) static int aha1542_test_port(struct Scsi_Host *sh) { - u8 inquiry_result[4]; int i; /* Quick and dirty test for presence of the card. */ @@ -240,7 +239,7 @@ static int aha1542_test_port(struct Scsi_Host *sh) for (i = 0; i < 4; i++) { if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0)) return 0; - inquiry_result[i] = inb(DATA(sh->io_port)); + (void)inb(DATA(sh->io_port)); } /* Reading port should reset DF */ From patchwork Wed Feb 16 21:01:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8403BC433FE for ; Wed, 16 Feb 2022 21:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbiBPVDm (ORCPT ); Wed, 16 Feb 2022 16:03:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbiBPVDd (ORCPT ); Wed, 16 Feb 2022 16:03:33 -0500 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F094B217489 for ; Wed, 16 Feb 2022 13:03:17 -0800 (PST) Received: by mail-pl1-f174.google.com with SMTP id 10so2980901plj.1 for ; Wed, 16 Feb 2022 13:03:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M606XAph7ghdXmUFxKYRv7kzlFluM4QcK7HymImpOY4=; b=Q6YTlz38+vEJQimbxb1f7rsVPAXOlAoWMlHRwZ5E9aDifI6wqqUopC91XyN7Y0L+mf iZ4SvnaJvM0gLULta3nUtzoOZn65Qmyz+COspREZA/yoRfD3v4wXQLnQJDu/x8PvKr+W Hr3ipq9SwdxA4UTqi5LxeW46NDAxOq0OTI/1vQvhSATDpR3B+nLEHq72GISmakJgCzDS CC/LjrNs77lmIQ+sKrTHGoVZAb2A2SoZde/QIQSWSMFN8Mc7SVDZyicxAYmIryiKXXxN TMx50ANIjRKibXezkBo91KA+m6hIIHQDTpJxvdklFl/y5yIkyiPiDMT33QJJmkarFJBu 8RkA== X-Gm-Message-State: AOAM533j1JNbJsjEaenKaFgpUiEpa61pmCkg++ow/wMJlmqNvjA2UBFi yO3jwoISLVi04ZcjoJLpuFM= X-Google-Smtp-Source: ABdhPJzm6UuSstTvCzjYwUUBaK5rHJHbAyIuNS9MPcRMz2eGcbntNpZKQMn/fMHjG7+dD0/3gHn67g== X-Received: by 2002:a17:902:e846:b0:14f:4580:4f23 with SMTP id t6-20020a170902e84600b0014f45804f23mr4300592plg.63.1645045397220; Wed, 16 Feb 2022 13:03:17 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:16 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "Juergen E. Fischer" , "James E.J. Bottomley" Subject: [PATCH v4 16/50] scsi: aha152x: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:01:59 -0800 Message-Id: <20220216210233.28774-17-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/aha152x.c | 259 ++++++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 104 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 901b78e8ffe6..34b2378075fd 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -316,6 +316,17 @@ enum { check_condition = 0x0800, /* requesting sense after CHECK CONDITION */ }; +struct aha152x_cmd_priv { + struct scsi_pointer scsi_pointer; +}; + +static struct scsi_pointer *aha152x_scsi_pointer(struct scsi_cmnd *cmd) +{ + struct aha152x_cmd_priv *acmd = scsi_cmd_priv(cmd); + + return &acmd->scsi_pointer; +} + MODULE_AUTHOR("Jürgen Fischer"); MODULE_DESCRIPTION(AHA152X_REVID); MODULE_LICENSE("GPL"); @@ -879,14 +890,17 @@ void aha152x_release(struct Scsi_Host *shpnt) static int setup_expected_interrupts(struct Scsi_Host *shpnt) { if(CURRENT_SC) { - CURRENT_SC->SCp.phase |= 1 << 16; + struct scsi_pointer *scsi_pointer = + aha152x_scsi_pointer(CURRENT_SC); - if(CURRENT_SC->SCp.phase & selecting) { + scsi_pointer->phase |= 1 << 16; + + if (scsi_pointer->phase & selecting) { SETPORT(SSTAT1, SELTO); SETPORT(SIMODE0, ENSELDO | (DISCONNECTED_SC ? ENSELDI : 0)); SETPORT(SIMODE1, ENSELTIMO); } else { - SETPORT(SIMODE0, (CURRENT_SC->SCp.phase & spiordy) ? ENSPIORDY : 0); + SETPORT(SIMODE0, (scsi_pointer->phase & spiordy) ? ENSPIORDY : 0); SETPORT(SIMODE1, ENPHASEMIS | ENSCSIRST | ENSCSIPERR | ENBUSFREE); } } else if(STATE==seldi) { @@ -910,16 +924,17 @@ static int setup_expected_interrupts(struct Scsi_Host *shpnt) static int aha152x_internal_queue(struct scsi_cmnd *SCpnt, struct completion *complete, int phase) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(SCpnt); struct Scsi_Host *shpnt = SCpnt->device->host; unsigned long flags; - SCpnt->SCp.phase = not_issued | phase; - SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */ - SCpnt->SCp.Message = 0; - SCpnt->SCp.have_data_in = 0; - SCpnt->SCp.sent_command = 0; + scsi_pointer->phase = not_issued | phase; + scsi_pointer->Status = 0x1; /* Ilegal status by SCSI standard */ + scsi_pointer->Message = 0; + scsi_pointer->have_data_in = 0; + scsi_pointer->sent_command = 0; - if(SCpnt->SCp.phase & (resetting|check_condition)) { + if (scsi_pointer->phase & (resetting | check_condition)) { if (!SCpnt->host_scribble || SCSEM(SCpnt) || SCNEXT(SCpnt)) { scmd_printk(KERN_ERR, SCpnt, "cannot reuse command\n"); return FAILED; @@ -942,15 +957,15 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt, SCp.phase : current state of the command */ if ((phase & resetting) || !scsi_sglist(SCpnt)) { - SCpnt->SCp.ptr = NULL; - SCpnt->SCp.this_residual = 0; + scsi_pointer->ptr = NULL; + scsi_pointer->this_residual = 0; scsi_set_resid(SCpnt, 0); - SCpnt->SCp.buffer = NULL; + scsi_pointer->buffer = NULL; } else { scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); - SCpnt->SCp.buffer = scsi_sglist(SCpnt); - SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); - SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; + scsi_pointer->buffer = scsi_sglist(SCpnt); + scsi_pointer->ptr = SG_ADDRESS(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } DO_LOCK(flags); @@ -1000,7 +1015,7 @@ static void reset_done(struct scsi_cmnd *SCpnt) static void aha152x_scsi_done(struct scsi_cmnd *SCpnt) { - if (SCpnt->SCp.phase & resetting) + if (aha152x_scsi_pointer(SCpnt)->phase & resetting) reset_done(SCpnt); else scsi_done(SCpnt); @@ -1086,7 +1101,7 @@ static int aha152x_device_reset(struct scsi_cmnd * SCpnt) DO_LOCK(flags); - if(SCpnt->SCp.phase & resetted) { + if (aha152x_scsi_pointer(SCpnt)->phase & resetted) { HOSTDATA(shpnt)->commands--; if (!HOSTDATA(shpnt)->commands) SETPORT(PORTA, 0); @@ -1380,28 +1395,31 @@ static void busfree_run(struct Scsi_Host *shpnt) SETPORT(SSTAT1, CLRBUSFREE); if(CURRENT_SC) { + struct scsi_pointer *scsi_pointer = + aha152x_scsi_pointer(CURRENT_SC); + #if defined(AHA152X_STAT) action++; #endif - CURRENT_SC->SCp.phase &= ~syncneg; + scsi_pointer->phase &= ~syncneg; - if(CURRENT_SC->SCp.phase & completed) { + if (scsi_pointer->phase & completed) { /* target sent COMMAND COMPLETE */ - done(shpnt, CURRENT_SC->SCp.Status, DID_OK); + done(shpnt, scsi_pointer->Status, DID_OK); - } else if(CURRENT_SC->SCp.phase & aborted) { - done(shpnt, CURRENT_SC->SCp.Status, DID_ABORT); + } else if (scsi_pointer->phase & aborted) { + done(shpnt, scsi_pointer->Status, DID_ABORT); - } else if(CURRENT_SC->SCp.phase & resetted) { - done(shpnt, CURRENT_SC->SCp.Status, DID_RESET); + } else if (scsi_pointer->phase & resetted) { + done(shpnt, scsi_pointer->Status, DID_RESET); - } else if(CURRENT_SC->SCp.phase & disconnected) { + } else if (scsi_pointer->phase & disconnected) { /* target sent DISCONNECT */ #if defined(AHA152X_STAT) HOSTDATA(shpnt)->disconnections++; #endif append_SC(&DISCONNECTED_SC, CURRENT_SC); - CURRENT_SC->SCp.phase |= 1 << 16; + scsi_pointer->phase |= 1 << 16; CURRENT_SC = NULL; } else { @@ -1420,23 +1438,24 @@ static void busfree_run(struct Scsi_Host *shpnt) action++; #endif - if(DONE_SC->SCp.phase & check_condition) { + if (aha152x_scsi_pointer(DONE_SC)->phase & check_condition) { struct scsi_cmnd *cmd = HOSTDATA(shpnt)->done_SC; struct aha152x_scdata *sc = SCDATA(cmd); scsi_eh_restore_cmnd(cmd, &sc->ses); - cmd->SCp.Status = SAM_STAT_CHECK_CONDITION; + aha152x_scsi_pointer(cmd)->Status = SAM_STAT_CHECK_CONDITION; HOSTDATA(shpnt)->commands--; if (!HOSTDATA(shpnt)->commands) SETPORT(PORTA, 0); /* turn led off */ - } else if(DONE_SC->SCp.Status==SAM_STAT_CHECK_CONDITION) { + } else if (aha152x_scsi_pointer(DONE_SC)->Status == + SAM_STAT_CHECK_CONDITION) { #if defined(AHA152X_STAT) HOSTDATA(shpnt)->busfree_with_check_condition++; #endif - if(!(DONE_SC->SCp.phase & not_issued)) { + if(!(aha152x_scsi_pointer(DONE_SC)->phase & not_issued)) { struct aha152x_scdata *sc; struct scsi_cmnd *ptr = DONE_SC; DONE_SC=NULL; @@ -1461,7 +1480,7 @@ static void busfree_run(struct Scsi_Host *shpnt) if (!HOSTDATA(shpnt)->commands) SETPORT(PORTA, 0); /* turn led off */ - if (!(ptr->SCp.phase & resetting)) { + if (!(aha152x_scsi_pointer(ptr)->phase & resetting)) { kfree(ptr->host_scribble); ptr->host_scribble=NULL; } @@ -1484,10 +1503,13 @@ static void busfree_run(struct Scsi_Host *shpnt) DO_UNLOCK(flags); if(CURRENT_SC) { + struct scsi_pointer *scsi_pointer = + aha152x_scsi_pointer(CURRENT_SC); + #if defined(AHA152X_STAT) action++; #endif - CURRENT_SC->SCp.phase |= selecting; + scsi_pointer->phase |= selecting; /* clear selection timeout */ SETPORT(SSTAT1, SELTO); @@ -1515,11 +1537,13 @@ static void busfree_run(struct Scsi_Host *shpnt) */ static void seldo_run(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + SETPORT(SCSISIG, 0); SETPORT(SSTAT1, CLRBUSFREE); SETPORT(SSTAT1, CLRPHASECHG); - CURRENT_SC->SCp.phase &= ~(selecting|not_issued); + scsi_pointer->phase &= ~(selecting | not_issued); SETPORT(SCSISEQ, 0); @@ -1534,12 +1558,12 @@ static void seldo_run(struct Scsi_Host *shpnt) ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); - if (CURRENT_SC->SCp.phase & aborting) { + if (scsi_pointer->phase & aborting) { ADDMSGO(ABORT); - } else if (CURRENT_SC->SCp.phase & resetting) { + } else if (scsi_pointer->phase & resetting) { ADDMSGO(BUS_DEVICE_RESET); } else if (SYNCNEG==0 && SYNCHRONOUS) { - CURRENT_SC->SCp.phase |= syncneg; + scsi_pointer->phase |= syncneg; MSGOLEN += spi_populate_sync_msg(&MSGO(MSGOLEN), 50, 8); SYNCNEG=1; /* negotiation in progress */ } @@ -1554,15 +1578,17 @@ static void seldo_run(struct Scsi_Host *shpnt) */ static void selto_run(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + SETPORT(SCSISEQ, 0); SETPORT(SSTAT1, CLRSELTIMO); if (!CURRENT_SC) return; - CURRENT_SC->SCp.phase &= ~selecting; + scsi_pointer->phase &= ~selecting; - if (CURRENT_SC->SCp.phase & aborted) + if (scsi_pointer->phase & aborted) done(shpnt, SAM_STAT_GOOD, DID_ABORT); else if (TESTLO(SSTAT0, SELINGO)) done(shpnt, SAM_STAT_GOOD, DID_BUS_BUSY); @@ -1590,7 +1616,10 @@ static void seldi_run(struct Scsi_Host *shpnt) SETPORT(SSTAT1, CLRPHASECHG); if(CURRENT_SC) { - if(!(CURRENT_SC->SCp.phase & not_issued)) + struct scsi_pointer *scsi_pointer = + aha152x_scsi_pointer(CURRENT_SC); + + if (!(scsi_pointer->phase & not_issued)) scmd_printk(KERN_ERR, CURRENT_SC, "command should not have been issued yet\n"); @@ -1647,6 +1676,7 @@ static void seldi_run(struct Scsi_Host *shpnt) static void msgi_run(struct Scsi_Host *shpnt) { for(;;) { + struct scsi_pointer *scsi_pointer; int sstat1 = GETPORT(SSTAT1); if(sstat1 & (PHASECHG|PHASEMIS|BUSFREE) || !(sstat1 & REQINIT)) @@ -1684,8 +1714,9 @@ static void msgi_run(struct Scsi_Host *shpnt) continue; } - CURRENT_SC->SCp.Message = MSGI(0); - CURRENT_SC->SCp.phase &= ~disconnected; + scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + scsi_pointer->Message = MSGI(0); + scsi_pointer->phase &= ~disconnected; MSGILEN=0; @@ -1693,7 +1724,8 @@ static void msgi_run(struct Scsi_Host *shpnt) continue; } - CURRENT_SC->SCp.Message = MSGI(0); + scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + scsi_pointer->Message = MSGI(0); switch (MSGI(0)) { case DISCONNECT: @@ -1701,11 +1733,11 @@ static void msgi_run(struct Scsi_Host *shpnt) scmd_printk(KERN_WARNING, CURRENT_SC, "target was not allowed to disconnect\n"); - CURRENT_SC->SCp.phase |= disconnected; + scsi_pointer->phase |= disconnected; break; case COMMAND_COMPLETE: - CURRENT_SC->SCp.phase |= completed; + scsi_pointer->phase |= completed; break; case MESSAGE_REJECT: @@ -1835,8 +1867,11 @@ static void msgi_end(struct Scsi_Host *shpnt) */ static void msgo_init(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + if(MSGOLEN==0) { - if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) { + if ((scsi_pointer->phase & syncneg) && SYNCNEG==2 && + SYNCRATE==0) { ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun)); } else { scmd_printk(KERN_INFO, CURRENT_SC, @@ -1853,6 +1888,8 @@ static void msgo_init(struct Scsi_Host *shpnt) */ static void msgo_run(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + while(MSGO_ISCp.phase |= identified; + scsi_pointer->phase |= identified; if (MSGO(MSGO_I)==ABORT) - CURRENT_SC->SCp.phase |= aborted; + scsi_pointer->phase |= aborted; if (MSGO(MSGO_I)==BUS_DEVICE_RESET) - CURRENT_SC->SCp.phase |= resetted; + scsi_pointer->phase |= resetted; SETPORT(SCSIDAT, MSGO(MSGO_I++)); } @@ -1899,7 +1936,7 @@ static void msgo_end(struct Scsi_Host *shpnt) */ static void cmd_init(struct Scsi_Host *shpnt) { - if (CURRENT_SC->SCp.sent_command) { + if (aha152x_scsi_pointer(CURRENT_SC)->sent_command) { scmd_printk(KERN_ERR, CURRENT_SC, "command already sent\n"); done(shpnt, SAM_STAT_GOOD, DID_ERROR); @@ -1930,7 +1967,7 @@ static void cmd_end(struct Scsi_Host *shpnt) "command sent incompletely (%d/%d)\n", CMD_I, CURRENT_SC->cmd_len); else - CURRENT_SC->SCp.sent_command++; + aha152x_scsi_pointer(CURRENT_SC)->sent_command++; } /* @@ -1942,7 +1979,7 @@ static void status_run(struct Scsi_Host *shpnt) if (TESTLO(SSTAT0, SPIORDY)) return; - CURRENT_SC->SCp.Status = GETPORT(SCSIDAT); + aha152x_scsi_pointer(CURRENT_SC)->Status = GETPORT(SCSIDAT); } @@ -1966,6 +2003,7 @@ static void datai_init(struct Scsi_Host *shpnt) static void datai_run(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer; unsigned long the_time; int fifodata, data_count; @@ -2003,35 +2041,36 @@ static void datai_run(struct Scsi_Host *shpnt) fifodata = GETPORT(FIFOSTAT); } - if(CURRENT_SC->SCp.this_residual>0) { - while(fifodata>0 && CURRENT_SC->SCp.this_residual>0) { - data_count = fifodata > CURRENT_SC->SCp.this_residual ? - CURRENT_SC->SCp.this_residual : + scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + if (scsi_pointer->this_residual > 0) { + while (fifodata > 0 && scsi_pointer->this_residual > 0) { + data_count = fifodata > scsi_pointer->this_residual ? + scsi_pointer->this_residual : fifodata; fifodata -= data_count; if (data_count & 1) { SETPORT(DMACNTRL0, ENDMA|_8BIT); - *CURRENT_SC->SCp.ptr++ = GETPORT(DATAPORT); - CURRENT_SC->SCp.this_residual--; + *scsi_pointer->ptr++ = GETPORT(DATAPORT); + scsi_pointer->this_residual--; DATA_LEN++; SETPORT(DMACNTRL0, ENDMA); } if (data_count > 1) { data_count >>= 1; - insw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); - CURRENT_SC->SCp.ptr += 2 * data_count; - CURRENT_SC->SCp.this_residual -= 2 * data_count; + insw(DATAPORT, scsi_pointer->ptr, data_count); + scsi_pointer->ptr += 2 * data_count; + scsi_pointer->this_residual -= 2 * data_count; DATA_LEN += 2 * data_count; } - if (CURRENT_SC->SCp.this_residual == 0 && - !sg_is_last(CURRENT_SC->SCp.buffer)) { + if (scsi_pointer->this_residual == 0 && + !sg_is_last(scsi_pointer->buffer)) { /* advance to next buffer */ - CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; + scsi_pointer->buffer = sg_next(scsi_pointer->buffer); + scsi_pointer->ptr = SG_ADDRESS(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } } } else if (fifodata > 0) { @@ -2099,14 +2138,15 @@ static void datao_init(struct Scsi_Host *shpnt) static void datao_run(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); unsigned long the_time; int data_count; /* until phase changes or all data sent */ - while(TESTLO(DMASTAT, INTSTAT) && CURRENT_SC->SCp.this_residual>0) { + while (TESTLO(DMASTAT, INTSTAT) && scsi_pointer->this_residual > 0) { data_count = 128; - if(data_count > CURRENT_SC->SCp.this_residual) - data_count=CURRENT_SC->SCp.this_residual; + if (data_count > scsi_pointer->this_residual) + data_count = scsi_pointer->this_residual; if(TESTLO(DMASTAT, DFIFOEMP)) { scmd_printk(KERN_ERR, CURRENT_SC, @@ -2117,26 +2157,26 @@ static void datao_run(struct Scsi_Host *shpnt) if(data_count & 1) { SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); - SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); - CURRENT_SC->SCp.this_residual--; + SETPORT(DATAPORT, *scsi_pointer->ptr++); + scsi_pointer->this_residual--; CMD_INC_RESID(CURRENT_SC, -1); SETPORT(DMACNTRL0,WRITE_READ|ENDMA); } if(data_count > 1) { data_count >>= 1; - outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); - CURRENT_SC->SCp.ptr += 2 * data_count; - CURRENT_SC->SCp.this_residual -= 2 * data_count; + outsw(DATAPORT, scsi_pointer->ptr, data_count); + scsi_pointer->ptr += 2 * data_count; + scsi_pointer->this_residual -= 2 * data_count; CMD_INC_RESID(CURRENT_SC, -2 * data_count); } - if (CURRENT_SC->SCp.this_residual == 0 && - !sg_is_last(CURRENT_SC->SCp.buffer)) { + if (scsi_pointer->this_residual == 0 && + !sg_is_last(scsi_pointer->buffer)) { /* advance to next buffer */ - CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer); - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer); - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length; + scsi_pointer->buffer = sg_next(scsi_pointer->buffer); + scsi_pointer->ptr = SG_ADDRESS(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } the_time=jiffies + 100*HZ; @@ -2152,6 +2192,8 @@ static void datao_run(struct Scsi_Host *shpnt) static void datao_end(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); + if(TESTLO(DMASTAT, DFIFOEMP)) { u32 datao_cnt = GETSTCNT(); int datao_out = DATA_LEN - scsi_get_resid(CURRENT_SC); @@ -2169,9 +2211,9 @@ static void datao_end(struct Scsi_Host *shpnt) sg = sg_next(sg); } - CURRENT_SC->SCp.buffer = sg; - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + done; - CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length - + scsi_pointer->buffer = sg; + scsi_pointer->ptr = SG_ADDRESS(scsi_pointer->buffer) + done; + scsi_pointer->this_residual = scsi_pointer->buffer->length - done; } @@ -2187,6 +2229,7 @@ static void datao_end(struct Scsi_Host *shpnt) */ static int update_state(struct Scsi_Host *shpnt) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(CURRENT_SC); int dataphase=0; unsigned int stat0 = GETPORT(SSTAT0); unsigned int stat1 = GETPORT(SSTAT1); @@ -2200,7 +2243,8 @@ static int update_state(struct Scsi_Host *shpnt) SETPORT(SSTAT1,SCSIRSTI); } else if (stat0 & SELDI && PREVSTATE == busfree) { STATE=seldi; - } else if(stat0 & SELDO && CURRENT_SC && (CURRENT_SC->SCp.phase & selecting)) { + } else if (stat0 & SELDO && CURRENT_SC && + (scsi_pointer->phase & selecting)) { STATE=seldo; } else if(stat1 & SELTO) { STATE=selto; @@ -2332,7 +2376,8 @@ static void is_complete(struct Scsi_Host *shpnt) SETPORT(SXFRCTL0, CH1); SETPORT(DMACNTRL0, 0); if(CURRENT_SC) - CURRENT_SC->SCp.phase &= ~spiordy; + aha152x_scsi_pointer(CURRENT_SC)->phase &= + ~spiordy; } /* @@ -2354,7 +2399,8 @@ static void is_complete(struct Scsi_Host *shpnt) SETPORT(DMACNTRL0, 0); SETPORT(SXFRCTL0, CH1|SPIOEN); if(CURRENT_SC) - CURRENT_SC->SCp.phase |= spiordy; + aha152x_scsi_pointer(CURRENT_SC)->phase |= + spiordy; } /* @@ -2444,21 +2490,23 @@ static void disp_enintr(struct Scsi_Host *shpnt) */ static void show_command(struct scsi_cmnd *ptr) { + const int phase = aha152x_scsi_pointer(ptr)->phase; + scsi_print_command(ptr); scmd_printk(KERN_DEBUG, ptr, "request_bufflen=%d; resid=%d; " "phase |%s%s%s%s%s%s%s%s%s; next=0x%p", scsi_bufflen(ptr), scsi_get_resid(ptr), - (ptr->SCp.phase & not_issued) ? "not issued|" : "", - (ptr->SCp.phase & selecting) ? "selecting|" : "", - (ptr->SCp.phase & identified) ? "identified|" : "", - (ptr->SCp.phase & disconnected) ? "disconnected|" : "", - (ptr->SCp.phase & completed) ? "completed|" : "", - (ptr->SCp.phase & spiordy) ? "spiordy|" : "", - (ptr->SCp.phase & syncneg) ? "syncneg|" : "", - (ptr->SCp.phase & aborted) ? "aborted|" : "", - (ptr->SCp.phase & resetted) ? "resetted|" : "", - (SCDATA(ptr)) ? SCNEXT(ptr) : NULL); + phase & not_issued ? "not issued|" : "", + phase & selecting ? "selecting|" : "", + phase & identified ? "identified|" : "", + phase & disconnected ? "disconnected|" : "", + phase & completed ? "completed|" : "", + phase & spiordy ? "spiordy|" : "", + phase & syncneg ? "syncneg|" : "", + phase & aborted ? "aborted|" : "", + phase & resetted ? "resetted|" : "", + SCDATA(ptr) ? SCNEXT(ptr) : NULL); } /* @@ -2490,6 +2538,8 @@ static void show_queues(struct Scsi_Host *shpnt) static void get_command(struct seq_file *m, struct scsi_cmnd * ptr) { + struct scsi_pointer *scsi_pointer = aha152x_scsi_pointer(ptr); + const int phase = scsi_pointer->phase; int i; seq_printf(m, "%p: target=%d; lun=%d; cmnd=( ", @@ -2499,24 +2549,24 @@ static void get_command(struct seq_file *m, struct scsi_cmnd * ptr) seq_printf(m, "0x%02x ", ptr->cmnd[i]); seq_printf(m, "); resid=%d; residual=%d; buffers=%d; phase |", - scsi_get_resid(ptr), ptr->SCp.this_residual, - sg_nents(ptr->SCp.buffer) - 1); + scsi_get_resid(ptr), scsi_pointer->this_residual, + sg_nents(scsi_pointer->buffer) - 1); - if (ptr->SCp.phase & not_issued) + if (phase & not_issued) seq_puts(m, "not issued|"); - if (ptr->SCp.phase & selecting) + if (phase & selecting) seq_puts(m, "selecting|"); - if (ptr->SCp.phase & disconnected) + if (phase & disconnected) seq_puts(m, "disconnected|"); - if (ptr->SCp.phase & aborted) + if (phase & aborted) seq_puts(m, "aborted|"); - if (ptr->SCp.phase & identified) + if (phase & identified) seq_puts(m, "identified|"); - if (ptr->SCp.phase & completed) + if (phase & completed) seq_puts(m, "completed|"); - if (ptr->SCp.phase & spiordy) + if (phase & spiordy) seq_puts(m, "spiordy|"); - if (ptr->SCp.phase & syncneg) + if (phase & syncneg) seq_puts(m, "syncneg|"); seq_printf(m, "; next=0x%p\n", SCNEXT(ptr)); } @@ -2921,6 +2971,7 @@ static struct scsi_host_template aha152x_driver_template = { .sg_tablesize = SG_ALL, .dma_boundary = PAGE_SIZE - 1, .slave_alloc = aha152x_adjust_queue, + .cmd_size = sizeof(struct aha152x_cmd_priv), }; #if !defined(AHA152X_PCMCIA) From patchwork Wed Feb 16 21:02:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6941AC433F5 for ; Wed, 16 Feb 2022 21:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233529AbiBPVDo (ORCPT ); Wed, 16 Feb 2022 16:03:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233608AbiBPVDd (ORCPT ); Wed, 16 Feb 2022 16:03:33 -0500 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95AAD219225 for ; Wed, 16 Feb 2022 13:03:19 -0800 (PST) Received: by mail-pl1-f169.google.com with SMTP id 10so2980941plj.1 for ; Wed, 16 Feb 2022 13:03:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tc5twZAeUFlYiGHnzMUwF6Wqn/lA5wVbiTacuuNXQCw=; b=BiU0XBDSOBUbJ4Mi9/LbWA2wuVqVbUe39wC3GCm+B8cN8waZi1xWsogrCNC7X4EUWz cbmrqg41aQ8i4fIZIkwvlsey66bH7u3qRNPq1Ah0MqPYL6/ewNRgqv9PXMd3316xzbOL ScxW83VgtEzWSJv+ex2M5nkG2Mvk7wR1bvhntPRoSXepp8PJrJoymMs8JKsOJoDpU90m 7E8scV1QROnSKqLjtYcCawWUlOJyCZhUgCR9VcfZ+5gpAMjG6JflAyhpVP6keKlbtOsC Tr9AuLdYsHCOAEzNAqaj56EEyOCVasfK2145/OiiCpK0jefBvkMJbffiOUOqpzuL8NEQ Yxuw== X-Gm-Message-State: AOAM530riQbo5tGs8rjjAy9cMI+ZYHurzp+FkC/Pb4ytRqDzkIonDzeI H/mTYvX8aT6zWPAdQUF6Gd8= X-Google-Smtp-Source: ABdhPJwmhENMxV3KWeoUzFEFFK16kMPpjHGc/Fthmqlk1prPWIm5OW3U9m7M18g2XOYKpoS/x5TXoQ== X-Received: by 2002:a17:90a:eacb:b0:1b8:78a1:4d54 with SMTP id ev11-20020a17090aeacb00b001b878a14d54mr3813903pjb.212.1645045399020; Wed, 16 Feb 2022 13:03:19 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:18 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Himanshu Madhani , Hannes Reinecke , Anil Gurumurthy , Sudarsana Kalluru , "James E.J. Bottomley" Subject: [PATCH v4 17/50] scsi: bfa: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:00 -0800 Message-Id: <20220216210233.28774-18-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/bfa/bfad_im.c | 27 ++++++++++++++------------- drivers/scsi/bfa/bfad_im.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 759d2bb1ecdd..8419a1a89485 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -150,10 +150,10 @@ bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk; wait_queue_head_t *wq; - cmnd->SCp.Status |= tsk_status << 1; - set_bit(IO_DONE_BIT, (unsigned long *)&cmnd->SCp.Status); - wq = (wait_queue_head_t *) cmnd->SCp.ptr; - cmnd->SCp.ptr = NULL; + bfad_priv(cmnd)->status |= tsk_status << 1; + set_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status); + wq = bfad_priv(cmnd)->wq; + bfad_priv(cmnd)->wq = NULL; if (wq) wake_up(wq); @@ -259,7 +259,7 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, * happens. */ cmnd->host_scribble = NULL; - cmnd->SCp.Status = 0; + bfad_priv(cmnd)->status = 0; bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); /* * bfa_itnim can be NULL if the port gets disconnected and the bfa @@ -326,8 +326,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) * if happens. */ cmnd->host_scribble = NULL; - cmnd->SCp.ptr = (char *)&wq; - cmnd->SCp.Status = 0; + bfad_priv(cmnd)->wq = &wq; + bfad_priv(cmnd)->status = 0; bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); /* * bfa_itnim can be NULL if the port gets disconnected and the bfa @@ -347,10 +347,9 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO); spin_unlock_irqrestore(&bfad->bfad_lock, flags); - wait_event(wq, test_bit(IO_DONE_BIT, - (unsigned long *)&cmnd->SCp.Status)); + wait_event(wq, test_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status)); - task_status = cmnd->SCp.Status >> 1; + task_status = bfad_priv(cmnd)->status >> 1; if (task_status != BFI_TSKIM_STS_OK) { BFA_LOG(KERN_ERR, bfad, bfa_log_level, "LUN reset failure, status: %d\n", task_status); @@ -381,16 +380,16 @@ bfad_im_reset_target_handler(struct scsi_cmnd *cmnd) spin_lock_irqsave(&bfad->bfad_lock, flags); itnim = bfad_get_itnim(im_port, starget->id); if (itnim) { - cmnd->SCp.ptr = (char *)&wq; + bfad_priv(cmnd)->wq = &wq; rc = bfad_im_target_reset_send(bfad, cmnd, itnim); if (rc == BFA_STATUS_OK) { /* wait target reset to complete */ spin_unlock_irqrestore(&bfad->bfad_lock, flags); wait_event(wq, test_bit(IO_DONE_BIT, - (unsigned long *)&cmnd->SCp.Status)); + &bfad_priv(cmnd)->status)); spin_lock_irqsave(&bfad->bfad_lock, flags); - task_status = cmnd->SCp.Status >> 1; + task_status = bfad_priv(cmnd)->status >> 1; if (task_status != BFI_TSKIM_STS_OK) BFA_LOG(KERN_ERR, bfad, bfa_log_level, "target reset failure," @@ -797,6 +796,7 @@ struct scsi_host_template bfad_im_scsi_host_template = { .name = BFAD_DRIVER_NAME, .info = bfad_im_info, .queuecommand = bfad_im_queuecommand, + .cmd_size = sizeof(struct bfad_cmd_priv), .eh_timed_out = fc_eh_timed_out, .eh_abort_handler = bfad_im_abort_handler, .eh_device_reset_handler = bfad_im_reset_lun_handler, @@ -819,6 +819,7 @@ struct scsi_host_template bfad_im_vport_template = { .name = BFAD_DRIVER_NAME, .info = bfad_im_info, .queuecommand = bfad_im_queuecommand, + .cmd_size = sizeof(struct bfad_cmd_priv), .eh_timed_out = fc_eh_timed_out, .eh_abort_handler = bfad_im_abort_handler, .eh_device_reset_handler = bfad_im_reset_lun_handler, diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index 829345b514d1..c03b225ea1ba 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -43,6 +43,22 @@ u32 bfad_im_supported_speeds(struct bfa_s *bfa); */ #define IO_DONE_BIT 0 +/** + * struct bfad_cmd_priv - private data per SCSI command. + * @status: Lowest bit represents IO_DONE. The next seven bits hold a value of + * type enum bfi_tskim_status. + * @wq: Wait queue used to wait for completion of an operation. + */ +struct bfad_cmd_priv { + unsigned long status; + wait_queue_head_t *wq; +}; + +static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + struct bfad_itnim_data_s { struct bfad_itnim_s *itnim; }; From patchwork Wed Feb 16 21:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 351C5C433F5 for ; Wed, 16 Feb 2022 21:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233634AbiBPVDr (ORCPT ); Wed, 16 Feb 2022 16:03:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233534AbiBPVDj (ORCPT ); Wed, 16 Feb 2022 16:03:39 -0500 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E79421FC58 for ; Wed, 16 Feb 2022 13:03:24 -0800 (PST) Received: by mail-pj1-f54.google.com with SMTP id qe15so3603652pjb.3 for ; Wed, 16 Feb 2022 13:03:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/EJX+/vkV4EsrKmfGAOP1zH1m5L+rWp/rxO1zE55iJM=; b=rriL9oBzBA5PTyg66PbtmdM4NNVaR8UZnsMqVfuoAUFMkmhsq6PmOkeaTLvj+pthN/ mlZujyhP3kCA62cDLRUk3zi1NWcJy6hq7C0j34dl7+n0Ec6QDJVmwcaphBTMOw3Vm1r2 LNyqsGMbUcG9rD5uHIrmAPMJ+MYZoW1xadkBbwJGcMP5bUWjdlgGjg/SyxnPQd7ygi9U gTG1ZIArJRrOl2ZVIBim0VhtD5ttM1uLkZzfsWa35V6ER4s7zTu7sGvY15mKf5rob3Tg efElnZa3ibRQC86XaUR8jwdjcFJAk7nwq96U6w49KtgtE6HAWp08FOW1v4GG3y00jen+ 2jLw== X-Gm-Message-State: AOAM533gl44E1P2sWkjBoxkcahGALfYgzp25qM/hEqOVGt3gBhPIf5VF zEGKUD3/8nRIKkEJa6QFGcc= X-Google-Smtp-Source: ABdhPJzIVAe0RJQbvT6ZXM+KMPLSZwU/kfomzabCVyinNwsvtdbXazeM7RlKfKXD7qJyUGjDZzRrow== X-Received: by 2002:a17:90a:d243:b0:1b9:cbac:a775 with SMTP id o3-20020a17090ad24300b001b9cbaca775mr3885668pjw.196.1645045403590; Wed, 16 Feb 2022 13:03:23 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:23 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" , Jiapeng Chong Subject: [PATCH v4 18/50] scsi: csio: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:01 -0800 Message-Id: <20220216210233.28774-19-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/csiostor/csio_scsi.c | 20 +++++++++++--------- drivers/scsi/csiostor/csio_scsi.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c index 55db02521221..9aafe0002ab1 100644 --- a/drivers/scsi/csiostor/csio_scsi.c +++ b/drivers/scsi/csiostor/csio_scsi.c @@ -166,7 +166,7 @@ csio_scsi_fcp_cmnd(struct csio_ioreq *req, void *addr) struct scsi_cmnd *scmnd = csio_scsi_cmnd(req); /* Check for Task Management */ - if (likely(scmnd->SCp.Message == 0)) { + if (likely(csio_priv(scmnd)->fc_tm_flags == 0)) { int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun); fcp_cmnd->fc_tm_flags = 0; fcp_cmnd->fc_cmdref = 0; @@ -185,7 +185,7 @@ csio_scsi_fcp_cmnd(struct csio_ioreq *req, void *addr) } else { memset(fcp_cmnd, 0, sizeof(*fcp_cmnd)); int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun); - fcp_cmnd->fc_tm_flags = (uint8_t)scmnd->SCp.Message; + fcp_cmnd->fc_tm_flags = csio_priv(scmnd)->fc_tm_flags; } } @@ -1855,7 +1855,7 @@ csio_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmnd) /* Needed during abort */ cmnd->host_scribble = (unsigned char *)ioreq; - cmnd->SCp.Message = 0; + csio_priv(cmnd)->fc_tm_flags = 0; /* Kick off SCSI IO SM on the ioreq */ spin_lock_irqsave(&hw->lock, flags); @@ -2026,7 +2026,7 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req) req, req->wr_status); /* Cache FW return status */ - cmnd->SCp.Status = req->wr_status; + csio_priv(cmnd)->wr_status = req->wr_status; /* Special handling based on FCP response */ @@ -2049,7 +2049,7 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req) /* Modify return status if flags indicate success */ if (flags & FCP_RSP_LEN_VAL) if (rsp_info->rsp_code == FCP_TMF_CMPL) - cmnd->SCp.Status = FW_SUCCESS; + csio_priv(cmnd)->wr_status = FW_SUCCESS; csio_dbg(hw, "TM FCP rsp code: %d\n", rsp_info->rsp_code); } @@ -2125,9 +2125,9 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) csio_scsi_cmnd(ioreq) = cmnd; cmnd->host_scribble = (unsigned char *)ioreq; - cmnd->SCp.Status = 0; + csio_priv(cmnd)->wr_status = 0; - cmnd->SCp.Message = FCP_TMF_LUN_RESET; + csio_priv(cmnd)->fc_tm_flags = FCP_TMF_LUN_RESET; ioreq->tmo = CSIO_SCSI_LUNRST_TMO_MS / 1000; /* @@ -2178,9 +2178,10 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) } /* LUN reset returned, check cached status */ - if (cmnd->SCp.Status != FW_SUCCESS) { + if (csio_priv(cmnd)->wr_status != FW_SUCCESS) { csio_err(hw, "LUN reset failed (%d:%llu), status: %d\n", - cmnd->device->id, cmnd->device->lun, cmnd->SCp.Status); + cmnd->device->id, cmnd->device->lun, + csio_priv(cmnd)->wr_status); goto fail; } @@ -2271,6 +2272,7 @@ struct scsi_host_template csio_fcoe_shost_template = { .name = CSIO_DRV_DESC, .proc_name = KBUILD_MODNAME, .queuecommand = csio_queuecommand, + .cmd_size = sizeof(struct csio_cmd_priv), .eh_timed_out = fc_eh_timed_out, .eh_abort_handler = csio_eh_abort_handler, .eh_device_reset_handler = csio_eh_lun_reset_handler, diff --git a/drivers/scsi/csiostor/csio_scsi.h b/drivers/scsi/csiostor/csio_scsi.h index 2257c3dcf724..39dda3c88f0d 100644 --- a/drivers/scsi/csiostor/csio_scsi.h +++ b/drivers/scsi/csiostor/csio_scsi.h @@ -188,6 +188,16 @@ struct csio_scsi_level_data { uint64_t oslun; }; +struct csio_cmd_priv { + uint8_t fc_tm_flags; /* task management flags */ + uint16_t wr_status; +}; + +static inline struct csio_cmd_priv *csio_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static inline struct csio_ioreq * csio_get_scsi_ioreq(struct csio_scsim *scm) { From patchwork Wed Feb 16 21:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543644 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CCAFC4332F for ; Wed, 16 Feb 2022 21:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233606AbiBPVDp (ORCPT ); Wed, 16 Feb 2022 16:03:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233634AbiBPVDj (ORCPT ); Wed, 16 Feb 2022 16:03:39 -0500 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE2121FEEA for ; Wed, 16 Feb 2022 13:03:26 -0800 (PST) Received: by mail-pl1-f182.google.com with SMTP id x4so2966192plb.4 for ; Wed, 16 Feb 2022 13:03:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uD1tH8wDMn3Wm4Fc6dGeyWCxFL02tMZz49ogOKnrwOU=; b=MzZ2YshO+N8/q2EV7Y3LYDbbjRX9xoOd6CRyfQNNBPEds0liudgaTzfb0DwVH6m3tx Ymv6mrEviT7ZhoT8vThO0wTZdN7pIUt01BxBIcSYGpRD/6cnOu/xJ5e3G+b0vtTlrf+x hKAESKntWaLj2LI23RgWIAQgdAhPSf3hSihNrqB+5WWcU0MBzjGeF8GQAh01gDyH18Sc Cfu+VReokdFTIH8fvOATVry5Dv5+S+ZIK8mTsNYQzsVrO92T/tfmgB2yabSaPWCAstku zy02XC/6RdicbMQpTSDmYjdQWH0HQCbURcQaFY6Mce5DAaqWSKk1T22UppDaPtRF2m1h N+eg== X-Gm-Message-State: AOAM531eQ2DYHNFlJvyp0CUEwMmqLg0jvWt64EPpFb1vwHBGh2n3tYET XY8x+gf0EWMDnCbBULhkeIE= X-Google-Smtp-Source: ABdhPJycK/D48qfWldknXt0mNh5iw+qXxqoMJhA5j0jYNlgcdVUeJ86/DXcgWViNB70nj9bWqHlWwg== X-Received: by 2002:a17:90b:4a92:b0:1b8:a3c5:1afe with SMTP id lp18-20020a17090b4a9200b001b8a3c51afemr3875276pjb.69.1645045405421; Wed, 16 Feb 2022 13:03:25 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:24 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Oliver Neukum , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , Oliver Neukum , Ali Akcaagac , Jamie Lenehan , "James E.J. Bottomley" Subject: [PATCH v4 19/50] scsi: dc395x: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:02 -0800 Message-Id: <20220216210233.28774-20-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove the code that sets SCSI pointer members since there is no code in this driver that reads these members. Cc: Oliver Neukum Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/dc395x.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index c11916b8ae00..67a89715c863 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -3314,9 +3314,6 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, /* Here is the info for Doug Gilbert's sg3 ... */ scsi_set_resid(cmd, srb->total_xfer_length); - /* This may be interpreted by sb. or not ... */ - cmd->SCp.this_residual = srb->total_xfer_length; - cmd->SCp.buffers_residual = 0; if (debug_enabled(DBG_KG)) { if (srb->total_xfer_length) dprintkdbg(DBG_KG, "srb_done: (0x%p) <%02i-%i> " From patchwork Wed Feb 16 21:02:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF440C433EF for ; Wed, 16 Feb 2022 21:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbiBPVDq (ORCPT ); Wed, 16 Feb 2022 16:03:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233439AbiBPVDk (ORCPT ); Wed, 16 Feb 2022 16:03:40 -0500 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2133B222193 for ; Wed, 16 Feb 2022 13:03:27 -0800 (PST) Received: by mail-pl1-f180.google.com with SMTP id x11so2945903pll.10 for ; Wed, 16 Feb 2022 13:03:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o/DjmKMEQ/TICGYiG1zbJphAMWsxSd5D/VpqW7WFmMA=; b=qw9dR30iz7Nmy0CCA6PDbEs71/HPMXHHEkv/fY83VC6nWtNoMn2ak4qlc5fbUjwPyQ QuOXTasRtFqfiT5zBxR9OvFpZXccrC2fuiadk19dO/x5N35sK1bAd461VcYl0KP9Vg4T 9s7w07aOcCf/wHeBZGd/ZW4lIJDgBI6bbDgi4FvjURhHmfkAnJVKrZ000Zu4i6uMcUZm 7aFxTiZ+f+y0gCGipkubFDGobpMW1/z/TjPIrc2J/ahXg1WewoASj2cwc1H0V5JH8tAw AZdzLg+aDmKPl9wswXu5A2oAmor8h0oTbk60Y2MZhCsSiHD2Rco59+lzZoRGmRUg4OHg id5Q== X-Gm-Message-State: AOAM531pgDJfsIoPFggzV+cuWT4OVI4brRwbNnuepBOU9oMIE9PQA7MO 1CL3yPcrvP2TQP+KRU+FoIs= X-Google-Smtp-Source: ABdhPJy02UEOrY8zIY+12tjQR8JrmJhItjyI17D4b0Y20AOs0x8Oq6GwDrLFIhzcxQXFUPSRpc5+Bw== X-Received: by 2002:a17:90b:33c4:b0:1b9:3aa6:e3e0 with SMTP id lk4-20020a17090b33c400b001b93aa6e3e0mr3900460pjb.182.1645045407083; Wed, 16 Feb 2022 13:03:27 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:26 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 20/50] scsi: esp_scsi: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:03 -0800 Message-Id: <20220216210233.28774-21-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/esp_scsi.c | 4 +--- drivers/scsi/esp_scsi.h | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 57787537285a..64ec6bb84550 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c @@ -2678,6 +2678,7 @@ struct scsi_host_template scsi_esp_template = { .sg_tablesize = SG_ALL, .max_sectors = 0xffff, .skip_settle_delay = 1, + .cmd_size = sizeof(struct esp_cmd_priv), }; EXPORT_SYMBOL(scsi_esp_template); @@ -2739,9 +2740,6 @@ static struct spi_function_template esp_transport_ops = { static int __init esp_init(void) { - BUILD_BUG_ON(sizeof(struct scsi_pointer) < - sizeof(struct esp_cmd_priv)); - esp_transport_template = spi_attach_transport(&esp_transport_ops); if (!esp_transport_template) return -ENODEV; diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h index 446a3d18c022..c73760d3cf83 100644 --- a/drivers/scsi/esp_scsi.h +++ b/drivers/scsi/esp_scsi.h @@ -262,7 +262,8 @@ struct esp_cmd_priv { struct scatterlist *cur_sg; int tot_residue; }; -#define ESP_CMD_PRIV(CMD) ((struct esp_cmd_priv *)(&(CMD)->SCp)) + +#define ESP_CMD_PRIV(cmd) ((struct esp_cmd_priv *)scsi_cmd_priv(cmd)) /* NOTE: this enum is ordered based on chip features! */ enum esp_rev { From patchwork Wed Feb 16 21:02:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 295E6C433FE for ; Wed, 16 Feb 2022 21:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233654AbiBPVDs (ORCPT ); Wed, 16 Feb 2022 16:03:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbiBPVDm (ORCPT ); Wed, 16 Feb 2022 16:03:42 -0500 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A34B222193 for ; Wed, 16 Feb 2022 13:03:29 -0800 (PST) Received: by mail-pj1-f42.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so7571348pjl.2 for ; Wed, 16 Feb 2022 13:03:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cpcKWeF4eOeGIU7dsXHWDuSosdfxHXKOqrJDc3sWxnM=; b=w6nZLYZdE0aHpZP5mJJkjLCPAjM/ZOHl2w7UmoUaMSL8Nw3mqvqHdunE7FYCe5QQq7 Qehx2TjUivOw5d3tUsicbEqfYjOBwiKh9EaPRLkvPGf0ySce01motljvZdGDoh6LCl8V MEvxtVB5OWNf0nA7Clmlsic419V7lRoGwXpANWXYj3kZDQD4Z6zwXG0z9/pzOOst9qEr W3i2YXy90AGfufzhs3GASLNE0GOzD7e0nqkS7vXDgNmx1JFiWOhDxiVOQMWeFXt5f0cE 5oS0vFgZfbhqFe10fQ7fUM/bVBaKmXN7pMQ+Rveq+O3a0+bwMROilC3LpFkQtW7BWOYT BEMA== X-Gm-Message-State: AOAM532R8uUaMlNMew9ZT9tIAsORyILJ2eJGAxsL89dcG/vFPZOK8602 JBQg/twouGOCzX322vhXeac= X-Google-Smtp-Source: ABdhPJw0LBY4SOy7/F2i2BDodtUp0fGXqf3nPHaG5/5cUVKqIhXYwcK7ldJATRpK4aAGoEZnS4bLdQ== X-Received: by 2002:a17:903:120b:b0:14f:14b:3485 with SMTP id l11-20020a170903120b00b0014f014b3485mr4276320plh.18.1645045408717; Wed, 16 Feb 2022 13:03:28 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:28 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , "James E.J. Bottomley" Subject: [PATCH v4 21/50] scsi: fdomain: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:04 -0800 Message-Id: <20220216210233.28774-22-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/fdomain.c | 64 ++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index 9159b4057c5d..444eac9b2466 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -115,6 +115,11 @@ struct fdomain { struct work_struct work; }; +static struct scsi_pointer *fdomain_scsi_pointer(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static inline void fdomain_make_bus_idle(struct fdomain *fd) { outb(0, fd->base + REG_BCTL); @@ -263,20 +268,21 @@ static void fdomain_work(struct work_struct *work) struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host, hostdata); struct scsi_cmnd *cmd = fd->cur_cmd; + struct scsi_pointer *scsi_pointer = fdomain_scsi_pointer(cmd); unsigned long flags; int status; int done = 0; spin_lock_irqsave(sh->host_lock, flags); - if (cmd->SCp.phase & in_arbitration) { + if (scsi_pointer->phase & in_arbitration) { status = inb(fd->base + REG_ASTAT); if (!(status & ASTAT_ARB)) { set_host_byte(cmd, DID_BUS_BUSY); fdomain_finish_cmd(fd); goto out; } - cmd->SCp.phase = in_selection; + scsi_pointer->phase = in_selection; outb(ICTL_SEL | FIFO_COUNT, fd->base + REG_ICTL); outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL); @@ -285,7 +291,7 @@ static void fdomain_work(struct work_struct *work) /* Stop arbitration and enable parity */ outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL); goto out; - } else if (cmd->SCp.phase & in_selection) { + } else if (scsi_pointer->phase & in_selection) { status = inb(fd->base + REG_BSTAT); if (!(status & BSTAT_BSY)) { /* Try again, for slow devices */ @@ -297,75 +303,75 @@ static void fdomain_work(struct work_struct *work) /* Stop arbitration and enable parity */ outb(ACTL_IRQEN | PARITY_MASK, fd->base + REG_ACTL); } - cmd->SCp.phase = in_other; + scsi_pointer->phase = in_other; outb(ICTL_FIFO | ICTL_REQ | FIFO_COUNT, fd->base + REG_ICTL); outb(BCTL_BUSEN, fd->base + REG_BCTL); goto out; } - /* cur_cmd->SCp.phase == in_other: this is the body of the routine */ + /* fdomain_scsi_pointer(cur_cmd)->phase == in_other: this is the body of the routine */ status = inb(fd->base + REG_BSTAT); if (status & BSTAT_REQ) { switch (status & (BSTAT_MSG | BSTAT_CMD | BSTAT_IO)) { case BSTAT_CMD: /* COMMAND OUT */ - outb(cmd->cmnd[cmd->SCp.sent_command++], + outb(cmd->cmnd[scsi_pointer->sent_command++], fd->base + REG_SCSI_DATA); break; case 0: /* DATA OUT -- tmc18c50/tmc18c30 only */ - if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) { - cmd->SCp.have_data_in = -1; + if (fd->chip != tmc1800 && !scsi_pointer->have_data_in) { + scsi_pointer->have_data_in = -1; outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN | PARITY_MASK, fd->base + REG_ACTL); } break; case BSTAT_IO: /* DATA IN -- tmc18c50/tmc18c30 only */ - if (fd->chip != tmc1800 && !cmd->SCp.have_data_in) { - cmd->SCp.have_data_in = 1; + if (fd->chip != tmc1800 && !scsi_pointer->have_data_in) { + scsi_pointer->have_data_in = 1; outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK, fd->base + REG_ACTL); } break; case BSTAT_CMD | BSTAT_IO: /* STATUS IN */ - cmd->SCp.Status = inb(fd->base + REG_SCSI_DATA); + scsi_pointer->Status = inb(fd->base + REG_SCSI_DATA); break; case BSTAT_MSG | BSTAT_CMD: /* MESSAGE OUT */ outb(MESSAGE_REJECT, fd->base + REG_SCSI_DATA); break; case BSTAT_MSG | BSTAT_CMD | BSTAT_IO: /* MESSAGE IN */ - cmd->SCp.Message = inb(fd->base + REG_SCSI_DATA); - if (cmd->SCp.Message == COMMAND_COMPLETE) + scsi_pointer->Message = inb(fd->base + REG_SCSI_DATA); + if (scsi_pointer->Message == COMMAND_COMPLETE) ++done; break; } } - if (fd->chip == tmc1800 && !cmd->SCp.have_data_in && - cmd->SCp.sent_command >= cmd->cmd_len) { + if (fd->chip == tmc1800 && !scsi_pointer->have_data_in && + scsi_pointer->sent_command >= cmd->cmd_len) { if (cmd->sc_data_direction == DMA_TO_DEVICE) { - cmd->SCp.have_data_in = -1; + scsi_pointer->have_data_in = -1; outb(ACTL_IRQEN | ACTL_FIFOWR | ACTL_FIFOEN | PARITY_MASK, fd->base + REG_ACTL); } else { - cmd->SCp.have_data_in = 1; + scsi_pointer->have_data_in = 1; outb(ACTL_IRQEN | ACTL_FIFOEN | PARITY_MASK, fd->base + REG_ACTL); } } - if (cmd->SCp.have_data_in == -1) /* DATA OUT */ + if (scsi_pointer->have_data_in == -1) /* DATA OUT */ fdomain_write_data(cmd); - if (cmd->SCp.have_data_in == 1) /* DATA IN */ + if (scsi_pointer->have_data_in == 1) /* DATA IN */ fdomain_read_data(cmd); if (done) { - set_status_byte(cmd, cmd->SCp.Status); + set_status_byte(cmd, scsi_pointer->Status); set_host_byte(cmd, DID_OK); - scsi_msg_to_host_byte(cmd, cmd->SCp.Message); + scsi_msg_to_host_byte(cmd, scsi_pointer->Message); fdomain_finish_cmd(fd); } else { - if (cmd->SCp.phase & disconnect) { + if (scsi_pointer->phase & disconnect) { outb(ICTL_FIFO | ICTL_SEL | ICTL_REQ | FIFO_COUNT, fd->base + REG_ICTL); outb(0, fd->base + REG_BCTL); @@ -398,14 +404,15 @@ static irqreturn_t fdomain_irq(int irq, void *dev_id) static int fdomain_queue(struct Scsi_Host *sh, struct scsi_cmnd *cmd) { + struct scsi_pointer *scsi_pointer = fdomain_scsi_pointer(cmd); struct fdomain *fd = shost_priv(cmd->device->host); unsigned long flags; - cmd->SCp.Status = 0; - cmd->SCp.Message = 0; - cmd->SCp.have_data_in = 0; - cmd->SCp.sent_command = 0; - cmd->SCp.phase = in_arbitration; + scsi_pointer->Status = 0; + scsi_pointer->Message = 0; + scsi_pointer->have_data_in = 0; + scsi_pointer->sent_command = 0; + scsi_pointer->phase = in_arbitration; scsi_set_resid(cmd, scsi_bufflen(cmd)); spin_lock_irqsave(sh->host_lock, flags); @@ -440,7 +447,7 @@ static int fdomain_abort(struct scsi_cmnd *cmd) spin_lock_irqsave(sh->host_lock, flags); fdomain_make_bus_idle(fd); - fd->cur_cmd->SCp.phase |= aborted; + fdomain_scsi_pointer(fd->cur_cmd)->phase |= aborted; /* Aborts are not done well. . . */ set_host_byte(fd->cur_cmd, DID_ABORT); @@ -501,6 +508,7 @@ static struct scsi_host_template fdomain_template = { .this_id = 7, .sg_tablesize = 64, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct scsi_pointer), }; struct Scsi_Host *fdomain_create(int base, int irq, int this_id, From patchwork Wed Feb 16 21:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65B7EC433EF for ; Wed, 16 Feb 2022 21:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbiBPVEB (ORCPT ); Wed, 16 Feb 2022 16:04:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233573AbiBPVDo (ORCPT ); Wed, 16 Feb 2022 16:03:44 -0500 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 467082221A9 for ; Wed, 16 Feb 2022 13:03:31 -0800 (PST) Received: by mail-pg1-f176.google.com with SMTP id 75so3179145pgb.4 for ; Wed, 16 Feb 2022 13:03:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mPpFGanc5O2VtDF8xLPur0DYQVt1vugjv+KVWyukjrk=; b=rwu3uX21XhuswxuSwvf4aTjLRu6eDVw1nL/XFYfRaWwKIS/6Djez9Gjdhe9JGfdqgS YGLQ+MgwqAa2kjYtMUsh/sfJW3Ec98ds5m2ayJ4w/GBrBQ1SLJTMoTtbFmekmdOv8o2b ZkuHlGDdRIilM4mJrqeJoIubwFdKcmIGezskaLaKGpd4yDGorJOYaRi5sNNibVUje5UI FwwG2DXGKiHk84wUu20OlPl19EEdeoLR+IDwz5pFUmhsVSD53jkzb9Egexf1awcU3gIV wTYxN1P+0wZ8yRS/iu1lEO96UHSWKFwOtlvH3A8VlRz5uoVbHwOhvRfu86pa6Hz4hIR6 UvuQ== X-Gm-Message-State: AOAM531doLX/VHoLk1dUVRStKg4u9ZpB5XiryRqQ88nUNojpCshx4seI 2hXooTa0GRZL3+P9bFwNd39SnWnCJRlTnEtS X-Google-Smtp-Source: ABdhPJz7w7AL1ErBJAbWyzHswSZn5OEHTEdocTWtA8xnj5f2UqLAllmaXP2Ip2Akn7De4UCYvieoAQ== X-Received: by 2002:a62:770a:0:b0:4e0:2547:9219 with SMTP id s10-20020a62770a000000b004e025479219mr4864800pfc.43.1645045410602; Wed, 16 Feb 2022 13:03:30 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:29 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hiral Patel , Hannes Reinecke , Himanshu Madhani , Satish Kharat , Sesidhar Baddela , Karan Tilak Kumar , "James E.J. Bottomley" , James Bottomley Subject: [PATCH v4 22/50] scsi: fnic: Fix a tracing statement Date: Wed, 16 Feb 2022 13:02:05 -0800 Message-Id: <20220216210233.28774-23-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Report both the command flags and command state instead of only the command state. Cc: Hiral Patel Fixes: 4d7007b49d52 ("[SCSI] fnic: Fnic Trace Utility") Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/fnic/fnic_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 88c549f257db..549754245f7a 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -604,7 +604,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, tag, sc, io_req, sg_count, cmd_trace, - (((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc))); + (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); /* if only we issued IO, will we have the io lock */ if (io_lock_acquired) From patchwork Wed Feb 16 21:02:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A441C433F5 for ; Wed, 16 Feb 2022 21:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233629AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbiBPVEA (ORCPT ); Wed, 16 Feb 2022 16:04:00 -0500 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE4D52AFE9D for ; Wed, 16 Feb 2022 13:03:33 -0800 (PST) Received: by mail-pj1-f51.google.com with SMTP id om7so3593556pjb.5 for ; Wed, 16 Feb 2022 13:03:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/NeNAG1Ei27GsQ9hxdSmu4jwEVUfh7t45yBwVciL8Ws=; b=RqKyp2jWg6DNcZ7ccFDFQneF5n/AE3BGKCklp0bNMyYGQbG+UTEtiE0Q1jqUQZY/3t Oh9p5piikx40yOt5KPjH3FThlZoNa4xVobYbfmRJJYOM9IpUQCrqZabEMa/Y4NxJNHkC LoFzUl8upSzadvxry/XV3uuvyHJpdWkgfAUjk3RdbtsQphUkPSAZy++jonuGudE8yVAa mmMHIl1egOzk3BwUOI02DGBmwgHfUu6dVOD1ERVPuLDBZc4GjiF2uWRhC/fzkF1+LT5Y GWiNkTD4GophjwP47IF/GgiB9n0tl33HhO/iI7uZ8yBSZQlktIWNrGkwWIuIDpJ+ETxl jUGg== X-Gm-Message-State: AOAM531BXpdbOycDNMJpoMI6oKuB1ubA0g3qKOsxVYUsfO9X0mcRAwT5 B0JzxRXDtYZUUCIdHHxR2lQ= X-Google-Smtp-Source: ABdhPJxcSrafVVYYz2D+gm4aJ/AGOgl+eX+PUe7EahobIzK8/+6OxgrNAPF1XOFk5w/sL3+T30W6Aw== X-Received: by 2002:a17:90b:4d0e:b0:1b9:10f:7e49 with SMTP id mw14-20020a17090b4d0e00b001b9010f7e49mr3893477pjb.114.1645045412750; Wed, 16 Feb 2022 13:03:32 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:32 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , Satish Kharat , Sesidhar Baddela , Karan Tilak Kumar , "James E.J. Bottomley" Subject: [PATCH v4 23/50] scsi: fnic: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:06 -0800 Message-Id: <20220216210233.28774-24-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/fnic/fnic.h | 27 +++- drivers/scsi/fnic/fnic_main.c | 1 + drivers/scsi/fnic/fnic_scsi.c | 289 +++++++++++++++++----------------- 3 files changed, 163 insertions(+), 154 deletions(-) diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index b95d0063dedb..aa07189fb5fb 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -89,15 +89,28 @@ #define FNIC_DEV_RST_ABTS_PENDING BIT(21) /* - * Usage of the scsi_cmnd scratchpad. + * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. */ -#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) -#define CMD_STATE(Cmnd) ((Cmnd)->SCp.phase) -#define CMD_ABTS_STATUS(Cmnd) ((Cmnd)->SCp.Message) -#define CMD_LR_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in) -#define CMD_TAG(Cmnd) ((Cmnd)->SCp.sent_command) -#define CMD_FLAGS(Cmnd) ((Cmnd)->SCp.Status) +struct fnic_cmd_priv { + struct fnic_io_req *io_req; + enum fnic_ioreq_state state; + u32 flags; + u16 abts_status; + u16 lr_status; +}; + +static inline struct fnic_cmd_priv *fnic_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + +static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd) +{ + struct fnic_cmd_priv *fcmd = fnic_priv(cmd); + + return ((u64)fcmd->flags << 32) | fcmd->state; +} #define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */ diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 44dbaa662d94..9161bd2fd421 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -124,6 +124,7 @@ static struct scsi_host_template fnic_host_template = { .max_sectors = 0xffff, .shost_groups = fnic_host_groups, .track_queue_depth = 1, + .cmd_size = sizeof(struct fnic_cmd_priv), }; static void diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 549754245f7a..3c00e5b88350 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -497,8 +497,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) * caller disabling them. */ spin_unlock(lp->host->host_lock); - CMD_STATE(sc) = FNIC_IOREQ_NOT_INITED; - CMD_FLAGS(sc) = FNIC_NO_FLAGS; + fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED; + fnic_priv(sc)->flags = FNIC_NO_FLAGS; /* Get a new io_req for this SCSI IO */ io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); @@ -513,7 +513,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) sg_count = scsi_dma_map(sc); if (sg_count < 0) { FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, - tag, sc, 0, sc->cmnd[0], sg_count, CMD_STATE(sc)); + tag, sc, 0, sc->cmnd[0], sg_count, fnic_priv(sc)->state); mempool_free(io_req, fnic->io_req_pool); goto out; } @@ -558,9 +558,9 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) io_lock_acquired = 1; io_req->port_id = rport->port_id; io_req->start_time = jiffies; - CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; - CMD_SP(sc) = (char *)io_req; - CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED; + fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; + fnic_priv(sc)->io_req = io_req; + fnic_priv(sc)->flags |= FNIC_IO_INITIALIZED; /* create copy wq desc and enqueue it */ wq = &fnic->wq_copy[0]; @@ -571,11 +571,10 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) * refetch the pointer under the lock. */ FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, - tag, sc, 0, 0, 0, - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); - io_req = (struct fnic_io_req *)CMD_SP(sc); - CMD_SP(sc) = NULL; - CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; + tag, sc, 0, 0, 0, fnic_flags_and_state(sc)); + io_req = fnic_priv(sc)->io_req; + fnic_priv(sc)->io_req = NULL; + fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; spin_unlock_irqrestore(io_lock, flags); if (io_req) { fnic_release_ioreq_buf(fnic, io_req, sc); @@ -594,7 +593,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) atomic64_read(&fnic_stats->io_stats.active_ios)); /* REVISIT: Use per IO lock in the final code */ - CMD_FLAGS(sc) |= FNIC_IO_ISSUED; + fnic_priv(sc)->flags |= FNIC_IO_ISSUED; } out: cmd_trace = ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 | @@ -603,8 +602,8 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc) sc->cmnd[5]); FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, - tag, sc, io_req, sg_count, cmd_trace, - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + tag, sc, io_req, sg_count, cmd_trace, + fnic_flags_and_state(sc)); /* if only we issued IO, will we have the io lock */ if (io_lock_acquired) @@ -867,11 +866,11 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; WARN_ON_ONCE(!io_req); if (!io_req) { atomic64_inc(&fnic_stats->io_stats.ioreq_null); - CMD_FLAGS(sc) |= FNIC_IO_REQ_NULL; + fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL; spin_unlock_irqrestore(io_lock, flags); shost_printk(KERN_ERR, fnic->lport->host, "icmnd_cmpl io_req is null - " @@ -888,17 +887,17 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, * if SCSI-ML has already issued abort on this command, * set completion of the IO. The abts path will clean it up */ - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { /* * set the FNIC_IO_DONE so that this doesn't get * flagged as 'out of order' if it was not aborted */ - CMD_FLAGS(sc) |= FNIC_IO_DONE; - CMD_FLAGS(sc) |= FNIC_IO_ABTS_PENDING; + fnic_priv(sc)->flags |= FNIC_IO_DONE; + fnic_priv(sc)->flags |= FNIC_IO_ABTS_PENDING; spin_unlock_irqrestore(io_lock, flags); if(FCPIO_ABORTED == hdr_status) - CMD_FLAGS(sc) |= FNIC_IO_ABORTED; + fnic_priv(sc)->flags |= FNIC_IO_ABORTED; FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, "icmnd_cmpl abts pending " @@ -912,7 +911,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, } /* Mark the IO as complete */ - CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; + fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; icmnd_cmpl = &desc->u.icmnd_cmpl; @@ -983,8 +982,8 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, } /* Break link with the SCSI command */ - CMD_SP(sc) = NULL; - CMD_FLAGS(sc) |= FNIC_IO_DONE; + fnic_priv(sc)->io_req = NULL; + fnic_priv(sc)->flags |= FNIC_IO_DONE; spin_unlock_irqrestore(io_lock, flags); @@ -1009,8 +1008,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, ((u64)icmnd_cmpl->_resvd0[1] << 56 | (u64)icmnd_cmpl->_resvd0[0] << 48 | jiffies_to_msecs(jiffies - start_time)), - desc, cmd_trace, - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + desc, cmd_trace, fnic_flags_and_state(sc)); if (sc->sc_data_direction == DMA_FROM_DEVICE) { fnic->lport->host_stats.fcp_input_requests++; @@ -1095,12 +1093,12 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, } io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; WARN_ON_ONCE(!io_req); if (!io_req) { atomic64_inc(&fnic_stats->io_stats.ioreq_null); spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; shost_printk(KERN_ERR, fnic->lport->host, "itmf_cmpl io_req is null - " "hdr status = %s tag = 0x%x sc 0x%p\n", @@ -1115,9 +1113,9 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "dev reset abts cmpl recd. id %x status %s\n", id, fnic_fcpio_status_to_str(hdr_status)); - CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; - CMD_ABTS_STATUS(sc) = hdr_status; - CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; + fnic_priv(sc)->abts_status = hdr_status; + fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; if (io_req->abts_done) complete(io_req->abts_done); spin_unlock_irqrestore(io_lock, flags); @@ -1127,7 +1125,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, case FCPIO_SUCCESS: break; case FCPIO_TIMEOUT: - if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED) + if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) atomic64_inc(&abts_stats->abort_fw_timeouts); else atomic64_inc( @@ -1139,34 +1137,34 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, (int)(id & FNIC_TAG_MASK)); break; case FCPIO_IO_NOT_FOUND: - if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED) + if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) atomic64_inc(&abts_stats->abort_io_not_found); else atomic64_inc( &term_stats->terminate_io_not_found); break; default: - if (CMD_FLAGS(sc) & FNIC_IO_ABTS_ISSUED) + if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) atomic64_inc(&abts_stats->abort_failures); else atomic64_inc( &term_stats->terminate_failures); break; } - if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) { + if (fnic_priv(sc)->state != FNIC_IOREQ_ABTS_PENDING) { /* This is a late completion. Ignore it */ spin_unlock_irqrestore(io_lock, flags); return; } - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE; - CMD_ABTS_STATUS(sc) = hdr_status; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE; + fnic_priv(sc)->abts_status = hdr_status; /* If the status is IO not found consider it as success */ if (hdr_status == FCPIO_IO_NOT_FOUND) - CMD_ABTS_STATUS(sc) = FCPIO_SUCCESS; + fnic_priv(sc)->abts_status = FCPIO_SUCCESS; - if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE))) + if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -1185,7 +1183,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, } else { FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "abts cmpl, completing IO\n"); - CMD_SP(sc) = NULL; + fnic_priv(sc)->io_req = NULL; sc->result = (DID_ERROR << 16); spin_unlock_irqrestore(io_lock, flags); @@ -1202,8 +1200,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | - CMD_STATE(sc))); + fnic_flags_and_state(sc)); scsi_done(sc); atomic64_dec(&fnic_stats->io_stats.active_ios); if (atomic64_read(&fnic->io_cmpl_skip)) @@ -1213,15 +1210,14 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, } } else if (id & FNIC_TAG_DEV_RST) { /* Completion of device reset */ - CMD_LR_STATUS(sc) = hdr_status; - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { + fnic_priv(sc)->lr_status = hdr_status; + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING; + fnic_priv(sc)->flags |= FNIC_DEV_RST_ABTS_PENDING; FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, sc->device->host->host_no, id, sc, jiffies_to_msecs(jiffies - start_time), - desc, 0, - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + desc, 0, fnic_flags_and_state(sc)); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Terminate pending " "dev reset cmpl recd. id %d status %s\n", @@ -1229,14 +1225,13 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, fnic_fcpio_status_to_str(hdr_status)); return; } - if (CMD_FLAGS(sc) & FNIC_DEV_RST_TIMED_OUT) { + if (fnic_priv(sc)->flags & FNIC_DEV_RST_TIMED_OUT) { /* Need to wait for terminate completion */ spin_unlock_irqrestore(io_lock, flags); FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, sc->device->host->host_no, id, sc, jiffies_to_msecs(jiffies - start_time), - desc, 0, - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + desc, 0, fnic_flags_and_state(sc)); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "dev reset cmpl recd after time out. " "id %d status %s\n", @@ -1244,8 +1239,8 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, fnic_fcpio_status_to_str(hdr_status)); return; } - CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; - CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE; + fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; + fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "dev reset cmpl recd. id %d status %s\n", (int)(id & FNIC_TAG_MASK), @@ -1257,7 +1252,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, } else { shost_printk(KERN_ERR, fnic->lport->host, "Unexpected itmf io state %s tag %x\n", - fnic_ioreq_state_to_str(CMD_STATE(sc)), id); + fnic_ioreq_state_to_str(fnic_priv(sc)->state), id); spin_unlock_irqrestore(io_lock, flags); } @@ -1370,21 +1365,21 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data, io_lock = fnic_io_lock_tag(fnic, tag); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); - if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && - !(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) { + io_req = fnic_priv(sc)->io_req; + if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && + !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { /* * We will be here only when FW completes reset * without sending completions for outstanding ios. */ - CMD_FLAGS(sc) |= FNIC_DEV_RST_DONE; + fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; if (io_req && io_req->dr_done) complete(io_req->dr_done); else if (io_req && io_req->abts_done) complete(io_req->abts_done); spin_unlock_irqrestore(io_lock, flags); return true; - } else if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) { + } else if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { spin_unlock_irqrestore(io_lock, flags); return true; } @@ -1393,7 +1388,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data, goto cleanup_scsi_cmd; } - CMD_SP(sc) = NULL; + fnic_priv(sc)->io_req = NULL; spin_unlock_irqrestore(io_lock, flags); @@ -1417,7 +1412,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data, atomic64_inc(&fnic_stats->io_stats.io_completions); /* Complete the command to SCSI */ - if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) + if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) shost_printk(KERN_ERR, fnic->lport->host, "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n", tag, sc); @@ -1429,7 +1424,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data, (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + fnic_flags_and_state(sc)); scsi_done(sc); @@ -1468,7 +1463,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, spin_lock_irqsave(io_lock, flags); /* Get the IO context which this desc refers to */ - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; /* fnic interrupts are turned off by now */ @@ -1477,7 +1472,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, goto wq_copy_cleanup_scsi_cmd; } - CMD_SP(sc) = NULL; + fnic_priv(sc)->io_req = NULL; spin_unlock_irqrestore(io_lock, flags); @@ -1496,7 +1491,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, 0, ((u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + fnic_flags_and_state(sc)); scsi_done(sc); } @@ -1571,15 +1566,15 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data, io_lock = fnic_io_lock_tag(fnic, abt_tag); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req || io_req->port_id != iter_data->port_id) { spin_unlock_irqrestore(io_lock, flags); return true; } - if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && - (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) { + if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && + !(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) { FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "fnic_rport_exch_reset dev rst not pending sc 0x%p\n", sc); @@ -1591,7 +1586,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data, * Found IO that is still pending with firmware and * belongs to rport that went away */ - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { spin_unlock_irqrestore(io_lock, flags); return true; } @@ -1599,20 +1594,20 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data, shost_printk(KERN_ERR, fnic->lport->host, "fnic_rport_exch_reset: io_req->abts_done is set " "state is %s\n", - fnic_ioreq_state_to_str(CMD_STATE(sc))); + fnic_ioreq_state_to_str(fnic_priv(sc)->state)); } - if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) { + if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) { shost_printk(KERN_ERR, fnic->lport->host, "rport_exch_reset " "IO not yet issued %p tag 0x%x flags " "%x state %d\n", - sc, abt_tag, CMD_FLAGS(sc), CMD_STATE(sc)); + sc, abt_tag, fnic_priv(sc)->flags, fnic_priv(sc)->state); } - old_ioreq_state = CMD_STATE(sc); - CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; - CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; - if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) { + old_ioreq_state = fnic_priv(sc)->state; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; + fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; + if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { atomic64_inc(&reset_stats->device_reset_terminates); abt_tag |= FNIC_TAG_DEV_RST; } @@ -1638,15 +1633,15 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data, * lun reset */ spin_lock_irqsave(io_lock, flags); - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) - CMD_STATE(sc) = old_ioreq_state; + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) + fnic_priv(sc)->state = old_ioreq_state; spin_unlock_irqrestore(io_lock, flags); } else { spin_lock_irqsave(io_lock, flags); - if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) - CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; + if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) + fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; else - CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED; + fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; spin_unlock_irqrestore(io_lock, flags); atomic64_inc(&term_stats->terminates); iter_data->term_cnt++; @@ -1754,9 +1749,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Abort Cmd called FCID 0x%x, LUN 0x%llx TAG %x flags %x\n", - rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc)); + rport->port_id, sc->device->lun, tag, fnic_priv(sc)->flags); - CMD_FLAGS(sc) = FNIC_NO_FLAGS; + fnic_priv(sc)->flags = FNIC_NO_FLAGS; if (lp->state != LPORT_ST_READY || !(lp->link_up)) { ret = FAILED; @@ -1773,11 +1768,11 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) * happened, the completion wont actually complete the command * and it will be considered as an aborted command * - * The CMD_SP will not be cleared except while holding io_req_lock. + * .io_req will not be cleared except while holding io_req_lock. */ io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(io_lock, flags); goto fnic_abort_cmd_end; @@ -1785,7 +1780,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) io_req->abts_done = &tm_done; - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { spin_unlock_irqrestore(io_lock, flags); goto wait_pending; } @@ -1814,9 +1809,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) * the completion wont be done till mid-layer, since abort * has already started. */ - old_ioreq_state = CMD_STATE(sc); - CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; - CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; + old_ioreq_state = fnic_priv(sc)->state; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; + fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; spin_unlock_irqrestore(io_lock, flags); @@ -1838,9 +1833,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) if (fnic_queue_abort_io_req(fnic, tag, task_req, fc_lun.scsi_lun, io_req)) { spin_lock_irqsave(io_lock, flags); - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) - CMD_STATE(sc) = old_ioreq_state; - io_req = (struct fnic_io_req *)CMD_SP(sc); + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) + fnic_priv(sc)->state = old_ioreq_state; + io_req = fnic_priv(sc)->io_req; if (io_req) io_req->abts_done = NULL; spin_unlock_irqrestore(io_lock, flags); @@ -1848,10 +1843,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) goto fnic_abort_cmd_end; } if (task_req == FCPIO_ITMF_ABT_TASK) { - CMD_FLAGS(sc) |= FNIC_IO_ABTS_ISSUED; + fnic_priv(sc)->flags |= FNIC_IO_ABTS_ISSUED; atomic64_inc(&fnic_stats->abts_stats.aborts); } else { - CMD_FLAGS(sc) |= FNIC_IO_TERM_ISSUED; + fnic_priv(sc)->flags |= FNIC_IO_TERM_ISSUED; atomic64_inc(&fnic_stats->term_stats.terminates); } @@ -1869,32 +1864,32 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) /* Check the abort status */ spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { atomic64_inc(&fnic_stats->io_stats.ioreq_null); spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; ret = FAILED; goto fnic_abort_cmd_end; } io_req->abts_done = NULL; /* fw did not complete abort, timed out */ - if (CMD_ABTS_STATUS(sc) == FCPIO_INVALID_CODE) { + if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { spin_unlock_irqrestore(io_lock, flags); if (task_req == FCPIO_ITMF_ABT_TASK) { atomic64_inc(&abts_stats->abort_drv_timeouts); } else { atomic64_inc(&term_stats->terminate_drv_timeouts); } - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_TIMED_OUT; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_TIMED_OUT; ret = FAILED; goto fnic_abort_cmd_end; } /* IO out of order */ - if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { + if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { spin_unlock_irqrestore(io_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Issuing Host reset due to out of order IO\n"); @@ -1903,7 +1898,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) goto fnic_abort_cmd_end; } - CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; start_time = io_req->start_time; /* @@ -1911,9 +1906,9 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) * free the io_req if successful. If abort fails, * Device reset will clean the I/O. */ - if (CMD_ABTS_STATUS(sc) == FCPIO_SUCCESS) - CMD_SP(sc) = NULL; - else { + if (fnic_priv(sc)->abts_status == FCPIO_SUCCESS) { + fnic_priv(sc)->io_req = NULL; + } else { ret = FAILED; spin_unlock_irqrestore(io_lock, flags); goto fnic_abort_cmd_end; @@ -1939,7 +1934,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) 0, ((u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + fnic_flags_and_state(sc)); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Returning from abort cmd type %x %s\n", task_req, @@ -2030,7 +2025,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, io_lock = fnic_io_lock_tag(fnic, abt_tag); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(io_lock, flags); return true; @@ -2042,14 +2037,14 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, */ FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Found IO in %s on lun\n", - fnic_ioreq_state_to_str(CMD_STATE(sc))); + fnic_ioreq_state_to_str(fnic_priv(sc)->state)); - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { spin_unlock_irqrestore(io_lock, flags); return true; } - if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && - (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) { + if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && + (!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) { FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, "%s dev rst not pending sc 0x%p\n", __func__, sc); @@ -2060,8 +2055,8 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, if (io_req->abts_done) shost_printk(KERN_ERR, fnic->lport->host, "%s: io_req->abts_done is set state is %s\n", - __func__, fnic_ioreq_state_to_str(CMD_STATE(sc))); - old_ioreq_state = CMD_STATE(sc); + __func__, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); + old_ioreq_state = fnic_priv(sc)->state; /* * Any pending IO issued prior to reset is expected to be * in abts pending state, if not we need to set @@ -2069,17 +2064,17 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, * When IO is completed, the IO will be handed over and * handled in this function. */ - CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; BUG_ON(io_req->abts_done); - if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) { + if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { abt_tag |= FNIC_TAG_DEV_RST; FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, "%s: dev rst sc 0x%p\n", __func__, sc); } - CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; + fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; io_req->abts_done = &tm_done; spin_unlock_irqrestore(io_lock, flags); @@ -2090,48 +2085,48 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, FCPIO_ITMF_ABT_TASK_TERM, fc_lun.scsi_lun, io_req)) { spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (io_req) io_req->abts_done = NULL; - if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) - CMD_STATE(sc) = old_ioreq_state; + if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) + fnic_priv(sc)->state = old_ioreq_state; spin_unlock_irqrestore(io_lock, flags); iter_data->ret = FAILED; return false; } else { spin_lock_irqsave(io_lock, flags); - if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) - CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; + if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) + fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; spin_unlock_irqrestore(io_lock, flags); } - CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED; + fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; wait_for_completion_timeout(&tm_done, msecs_to_jiffies (fnic->config.ed_tov)); /* Recheck cmd state to check if it is now aborted */ spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; return true; } io_req->abts_done = NULL; /* if abort is still pending with fw, fail */ - if (CMD_ABTS_STATUS(sc) == FCPIO_INVALID_CODE) { + if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { spin_unlock_irqrestore(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE; + fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE; iter_data->ret = FAILED; return false; } - CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; /* original sc used for lr is handled by dev reset code */ if (sc != iter_data->lr_sc) - CMD_SP(sc) = NULL; + fnic_priv(sc)->io_req = NULL; spin_unlock_irqrestore(io_lock, flags); /* original sc used for lr is handled by dev reset code */ @@ -2272,7 +2267,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) goto fnic_device_reset_end; } - CMD_FLAGS(sc) = FNIC_DEVICE_RESET; + fnic_priv(sc)->flags = FNIC_DEVICE_RESET; /* Allocate tag if not present */ if (unlikely(tag < 0)) { @@ -2288,7 +2283,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) } io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; /* * If there is a io_req attached to this command, then use it, @@ -2302,11 +2297,11 @@ int fnic_device_reset(struct scsi_cmnd *sc) } memset(io_req, 0, sizeof(*io_req)); io_req->port_id = rport->port_id; - CMD_SP(sc) = (char *)io_req; + fnic_priv(sc)->io_req = io_req; } io_req->dr_done = &tm_done; - CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; - CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE; + fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; + fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE; spin_unlock_irqrestore(io_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %x\n", tag); @@ -2317,13 +2312,13 @@ int fnic_device_reset(struct scsi_cmnd *sc) */ if (fnic_queue_dr_io_req(fnic, sc, io_req)) { spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (io_req) io_req->dr_done = NULL; goto fnic_device_reset_clean; } spin_lock_irqsave(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_DEV_RST_ISSUED; + fnic_priv(sc)->flags |= FNIC_DEV_RST_ISSUED; spin_unlock_irqrestore(io_lock, flags); /* @@ -2334,7 +2329,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(io_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -2343,7 +2338,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) } io_req->dr_done = NULL; - status = CMD_LR_STATUS(sc); + status = fnic_priv(sc)->lr_status; /* * If lun reset not completed, bail out with failed. io_req @@ -2353,7 +2348,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) atomic64_inc(&reset_stats->device_reset_timeouts); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Device reset timed out\n"); - CMD_FLAGS(sc) |= FNIC_DEV_RST_TIMED_OUT; + fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT; spin_unlock_irqrestore(io_lock, flags); int_to_scsilun(sc->device->lun, &fc_lun); /* @@ -2362,7 +2357,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) */ while (1) { spin_lock_irqsave(io_lock, flags); - if (CMD_FLAGS(sc) & FNIC_DEV_RST_TERM_ISSUED) { + if (fnic_priv(sc)->flags & FNIC_DEV_RST_TERM_ISSUED) { spin_unlock_irqrestore(io_lock, flags); break; } @@ -2375,8 +2370,8 @@ int fnic_device_reset(struct scsi_cmnd *sc) msecs_to_jiffies(FNIC_ABT_TERM_DELAY_TIMEOUT)); } else { spin_lock_irqsave(io_lock, flags); - CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; - CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; + fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; + fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; io_req->abts_done = &tm_done; spin_unlock_irqrestore(io_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, @@ -2387,13 +2382,13 @@ int fnic_device_reset(struct scsi_cmnd *sc) } while (1) { spin_lock_irqsave(io_lock, flags); - if (!(CMD_FLAGS(sc) & FNIC_DEV_RST_DONE)) { + if (!(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { spin_unlock_irqrestore(io_lock, flags); wait_for_completion_timeout(&tm_done, msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); break; } else { - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; io_req->abts_done = NULL; goto fnic_device_reset_clean; } @@ -2408,7 +2403,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Device reset completed - failed\n"); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; goto fnic_device_reset_clean; } @@ -2421,7 +2416,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) */ if (fnic_clean_pending_aborts(fnic, sc, new_sc)) { spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Device reset failed" " since could not abort all IOs\n"); @@ -2430,14 +2425,14 @@ int fnic_device_reset(struct scsi_cmnd *sc) /* Clean lun reset command */ spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (io_req) /* Completed, and successful */ ret = SUCCESS; fnic_device_reset_clean: if (io_req) - CMD_SP(sc) = NULL; + fnic_priv(sc)->io_req = NULL; spin_unlock_irqrestore(io_lock, flags); @@ -2453,7 +2448,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) 0, ((u64)sc->cmnd[0] << 32 | (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); + fnic_flags_and_state(sc)); /* free tag if it is allocated */ if (unlikely(tag_gen_flag)) @@ -2698,7 +2693,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data, io_lock = fnic_io_lock_hash(fnic, sc); spin_lock_irqsave(io_lock, flags); - io_req = (struct fnic_io_req *)CMD_SP(sc); + io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(io_lock, flags); return true; @@ -2710,8 +2705,8 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data, */ FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, "Found IO in %s on lun\n", - fnic_ioreq_state_to_str(CMD_STATE(sc))); - cmd_state = CMD_STATE(sc); + fnic_ioreq_state_to_str(fnic_priv(sc)->state)); + cmd_state = fnic_priv(sc)->state; spin_unlock_irqrestore(io_lock, flags); if (cmd_state == FNIC_IOREQ_ABTS_PENDING) iter_data->ret = 1; From patchwork Wed Feb 16 21:02:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77420C4332F for ; Wed, 16 Feb 2022 21:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233573AbiBPVEJ (ORCPT ); Wed, 16 Feb 2022 16:04:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233570AbiBPVEA (ORCPT ); Wed, 16 Feb 2022 16:04:00 -0500 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF8D2AFEA3 for ; Wed, 16 Feb 2022 13:03:35 -0800 (PST) Received: by mail-pg1-f179.google.com with SMTP id v22so2501783pgb.0 for ; Wed, 16 Feb 2022 13:03:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cq307zyqkGB81Y1HPwnROoKgGyu5K7bZpTYHOrkG/uA=; b=vpgKcwHF3qWZNctx5oDgdYNTGxQzBZludZb0J1qoL+0wr3jPDxglXIs4o4aXrxcdkN N70c+6e0JpKkXR/nDYei44lOBXL+CS5p/aWiuRRE8D5zXN/kM1dgZWKV74KIE2zKLG45 DN9gEasflgTYEZFg1TynBryIZ47V5Z70qwAgeM2HkfzDIkgeLHu01knKEc0/of60CmPU FMMyz5EILmQKYS2hgW7Q2bjb2GepVsj0Wiw6JilA8uFjUAegwXVrbzqJjptyWVEHLEm/ daIbuhXQ1H3atOFwBLEHRwuWSnq8DKh8NLceuTxFrfOS9xSXi+1Q1OuE61xCUfp/cR11 ZGHQ== X-Gm-Message-State: AOAM531DosKkMBDOw2KBv9qL51iiHR5ZVslcR/OPc/WUL3Camp9xI2o2 rWxRZWIveDANQ/TWnhI2Xwc= X-Google-Smtp-Source: ABdhPJzTMfzRmq5F6fYzUytqlNjDSM3nm6Fr4J2NE0UnybGo7FjuDt3S4qf3CZFtI/Ax8uBkDH3jcg== X-Received: by 2002:a05:6a00:26c1:b0:4e1:3135:97a9 with SMTP id p1-20020a056a0026c100b004e1313597a9mr5237994pfw.13.1645045414536; Wed, 16 Feb 2022 13:03:34 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:33 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , HighPoint Linux Team , "James E.J. Bottomley" Subject: [PATCH v4 24/50] scsi: hptiop: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:07 -0800 Message-Id: <20220216210233.28774-25-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Rename hpt_scsi_pointer into hpt_cmd_priv because that data structure is not related to struct scsi_pointer. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/hptiop.c | 1 + drivers/scsi/hptiop.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index d04245e379d7..f18b770626e6 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -1174,6 +1174,7 @@ static struct scsi_host_template driver_template = { .slave_configure = hptiop_slave_config, .this_id = -1, .change_queue_depth = hptiop_adjust_disk_queue_depth, + .cmd_size = sizeof(struct hpt_cmd_priv), }; static int hptiop_internal_memalloc_itl(struct hptiop_hba *hba) diff --git a/drivers/scsi/hptiop.h b/drivers/scsi/hptiop.h index 35184c2008af..363d5a16243f 100644 --- a/drivers/scsi/hptiop.h +++ b/drivers/scsi/hptiop.h @@ -251,13 +251,13 @@ struct hptiop_request { int index; }; -struct hpt_scsi_pointer { +struct hpt_cmd_priv { int mapped; int sgcnt; dma_addr_t dma_handle; }; -#define HPT_SCP(scp) ((struct hpt_scsi_pointer *)&(scp)->SCp) +#define HPT_SCP(scp) ((struct hpt_cmd_priv *)scsi_cmd_priv(scp)) enum hptiop_family { UNKNOWN_BASED_IOP, From patchwork Wed Feb 16 21:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F558C433FE for ; Wed, 16 Feb 2022 21:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbiBPVEK (ORCPT ); Wed, 16 Feb 2022 16:04:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233705AbiBPVEA (ORCPT ); Wed, 16 Feb 2022 16:04:00 -0500 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E470C2AFEB2 for ; Wed, 16 Feb 2022 13:03:36 -0800 (PST) Received: by mail-pj1-f47.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso7599547pjg.0 for ; Wed, 16 Feb 2022 13:03:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yQ+qPRmpV+XDb0VWxemarBzaOzx41XEbKJUiDIXT3Aw=; b=YEUrnk8gu6XNRcGrWJod18FzKFw5GjXdExP2iSN0FNttkmcQGzduKezQGQpnwIqj8u BiHJ808YfDsguoia5DntGk1W5Px2zOiTChAu8kkz0Lf9Os4QvXt08+YzU4zz96DkCyoW U5KoVk4FcQ1AZB/lmGWNRwB7V7ixlhHX6YZQnNJrSW4/Sdq8ihFitCuSJ2h00lSupa8+ Ij3clQh9GqukGUc2Aj2GkJ0LK3RUkrZkyRH1fuJiByK3Zkbhttoa42M1o1aX1dzS25sr BRmsX3lY15B3+fv9caMiYWlODSiQRmmJ4alF7GDlqRaFE6q64r8NbhDJey9HU6NXcpZ4 oIGA== X-Gm-Message-State: AOAM531CnQrNsqjRlIaGjUpqBUzUYfpgTOubYcRgQFLWflsJukNSlIlG VAkPZr6nhPVQ4qUzb44Y147VMT4DRdFBBw== X-Google-Smtp-Source: ABdhPJw/BeGIwm8AnOoxsSOqEHFeAHIi4s7HL6JCHHWatssVfFIAP2r2w41XhWwRBbSnatRTRwUjfQ== X-Received: by 2002:a17:90b:3b88:b0:1b9:31dc:adad with SMTP id pc8-20020a17090b3b8800b001b931dcadadmr3821812pjb.159.1645045416172; Wed, 16 Feb 2022 13:03:36 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:35 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 25/50] scsi: imm: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:08 -0800 Message-Id: <20220216210233.28774-26-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/imm.c | 88 ++++++++++++++++++++++++---------------------- drivers/scsi/imm.h | 5 +++ 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index 8afdb4dba2be..7a499d621c25 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c @@ -66,7 +66,7 @@ static void got_it(imm_struct *dev) { dev->base = dev->dev->port->base; if (dev->cur_cmd) - dev->cur_cmd->SCp.phase = 1; + imm_scsi_pointer(dev->cur_cmd)->phase = 1; else wake_up(dev->waiting); } @@ -618,13 +618,14 @@ static inline int imm_send_command(struct scsi_cmnd *cmd) * The driver appears to remain stable if we speed up the parallel port * i/o in this function, but not elsewhere. */ -static int imm_completion(struct scsi_cmnd *cmd) +static int imm_completion(struct scsi_cmnd *const cmd) { /* Return codes: * -1 Error * 0 Told to schedule * 1 Finished data transfer */ + struct scsi_pointer *scsi_pointer = imm_scsi_pointer(cmd); imm_struct *dev = imm_dev(cmd->device->host); unsigned short ppb = dev->base; unsigned long start_jiffies = jiffies; @@ -660,44 +661,43 @@ static int imm_completion(struct scsi_cmnd *cmd) * a) Drive status is screwy (!ready && !present) * b) Drive is requesting/sending more data than expected */ - if (((r & 0x88) != 0x88) || (cmd->SCp.this_residual <= 0)) { + if ((r & 0x88) != 0x88 || scsi_pointer->this_residual <= 0) { imm_fail(dev, DID_ERROR); return -1; /* ERROR_RETURN */ } /* determine if we should use burst I/O */ if (dev->rd == 0) { - fast = (bulk - && (cmd->SCp.this_residual >= - IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 2; - status = imm_out(dev, cmd->SCp.ptr, fast); + fast = bulk && scsi_pointer->this_residual >= + IMM_BURST_SIZE ? IMM_BURST_SIZE : 2; + status = imm_out(dev, scsi_pointer->ptr, fast); } else { - fast = (bulk - && (cmd->SCp.this_residual >= - IMM_BURST_SIZE)) ? IMM_BURST_SIZE : 1; - status = imm_in(dev, cmd->SCp.ptr, fast); + fast = bulk && scsi_pointer->this_residual >= + IMM_BURST_SIZE ? IMM_BURST_SIZE : 1; + status = imm_in(dev, scsi_pointer->ptr, fast); } - cmd->SCp.ptr += fast; - cmd->SCp.this_residual -= fast; + scsi_pointer->ptr += fast; + scsi_pointer->this_residual -= fast; if (!status) { imm_fail(dev, DID_BUS_BUSY); return -1; /* ERROR_RETURN */ } - if (cmd->SCp.buffer && !cmd->SCp.this_residual) { + if (scsi_pointer->buffer && !scsi_pointer->this_residual) { /* if scatter/gather, advance to the next segment */ - if (cmd->SCp.buffers_residual--) { - cmd->SCp.buffer = sg_next(cmd->SCp.buffer); - cmd->SCp.this_residual = - cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + if (scsi_pointer->buffers_residual--) { + scsi_pointer->buffer = + sg_next(scsi_pointer->buffer); + scsi_pointer->this_residual = + scsi_pointer->buffer->length; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); /* * Make sure that we transfer even number of bytes * otherwise it makes imm_byte_out() messy. */ - if (cmd->SCp.this_residual & 0x01) - cmd->SCp.this_residual++; + if (scsi_pointer->this_residual & 0x01) + scsi_pointer->this_residual++; } } /* Now check to see if the drive is ready to comunicate */ @@ -762,7 +762,7 @@ static void imm_interrupt(struct work_struct *work) } #endif - if (cmd->SCp.phase > 1) + if (imm_scsi_pointer(cmd)->phase > 1) imm_disconnect(dev); imm_pb_dismiss(dev); @@ -774,8 +774,9 @@ static void imm_interrupt(struct work_struct *work) return; } -static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) +static int imm_engine(imm_struct *dev, struct scsi_cmnd *const cmd) { + struct scsi_pointer *scsi_pointer = imm_scsi_pointer(cmd); unsigned short ppb = dev->base; unsigned char l = 0, h = 0; int retv, x; @@ -786,7 +787,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) if (dev->failed) return 0; - switch (cmd->SCp.phase) { + switch (scsi_pointer->phase) { case 0: /* Phase 0 - Waiting for parport */ if (time_after(jiffies, dev->jstart + HZ)) { /* @@ -800,7 +801,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) case 1: /* Phase 1 - Connected */ imm_connect(dev, CONNECT_EPP_MAYBE); - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 2: /* Phase 2 - We are now talking to the scsi bus */ @@ -808,7 +809,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) imm_fail(dev, DID_NO_CONNECT); return 0; } - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 3: /* Phase 3 - Ready to accept a command */ @@ -818,23 +819,23 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) if (!imm_send_command(cmd)) return 0; - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 4: /* Phase 4 - Setup scatter/gather buffers */ if (scsi_bufflen(cmd)) { - cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + scsi_pointer->buffer = scsi_sglist(cmd); + scsi_pointer->this_residual = scsi_pointer->buffer->length; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); } else { - cmd->SCp.buffer = NULL; - cmd->SCp.this_residual = 0; - cmd->SCp.ptr = NULL; + scsi_pointer->buffer = NULL; + scsi_pointer->this_residual = 0; + scsi_pointer->ptr = NULL; } - cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; - cmd->SCp.phase++; - if (cmd->SCp.this_residual & 0x01) - cmd->SCp.this_residual++; + scsi_pointer->buffers_residual = scsi_sg_count(cmd) - 1; + scsi_pointer->phase++; + if (scsi_pointer->this_residual & 0x01) + scsi_pointer->this_residual++; fallthrough; case 5: /* Phase 5 - Pre-Data transfer stage */ @@ -851,7 +852,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) if ((dev->dp) && (dev->rd)) if (imm_negotiate(dev)) return 0; - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 6: /* Phase 6 - Data transfer stage */ @@ -867,7 +868,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) if (retv == 0) return 1; } - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 7: /* Phase 7 - Post data transfer stage */ @@ -879,7 +880,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) w_ctr(ppb, 0x4); } } - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 8: /* Phase 8 - Read status/message */ @@ -922,7 +923,7 @@ static int imm_queuecommand_lck(struct scsi_cmnd *cmd) dev->jstart = jiffies; dev->cur_cmd = cmd; cmd->result = DID_ERROR << 16; /* default return code */ - cmd->SCp.phase = 0; /* bus free */ + imm_scsi_pointer(cmd)->phase = 0; /* bus free */ schedule_delayed_work(&dev->imm_tq, 0); @@ -961,7 +962,7 @@ static int imm_abort(struct scsi_cmnd *cmd) * have tied the SCSI_MESSAGE line high in the interface */ - switch (cmd->SCp.phase) { + switch (imm_scsi_pointer(cmd)->phase) { case 0: /* Do not have access to parport */ case 1: /* Have not connected to interface */ dev->cur_cmd = NULL; /* Forget the problem */ @@ -987,7 +988,7 @@ static int imm_reset(struct scsi_cmnd *cmd) { imm_struct *dev = imm_dev(cmd->device->host); - if (cmd->SCp.phase) + if (imm_scsi_pointer(cmd)->phase) imm_disconnect(dev); dev->cur_cmd = NULL; /* Forget the problem */ @@ -1109,6 +1110,7 @@ static struct scsi_host_template imm_template = { .sg_tablesize = SG_ALL, .can_queue = 1, .slave_alloc = imm_adjust_queue, + .cmd_size = sizeof(struct scsi_pointer), }; /*************************************************************************** diff --git a/drivers/scsi/imm.h b/drivers/scsi/imm.h index 7f2bb35b1b87..411cf94af5b0 100644 --- a/drivers/scsi/imm.h +++ b/drivers/scsi/imm.h @@ -139,6 +139,11 @@ static char *IMM_MODE_STRING[] = #define w_ctr(x,y) outb(y, (x)+2) #endif +static inline struct scsi_pointer *imm_scsi_pointer(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static int imm_engine(imm_struct *, struct scsi_cmnd *); #endif /* _IMM_H */ From patchwork Wed Feb 16 21:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B04FC4332F for ; Wed, 16 Feb 2022 21:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbiBPVES (ORCPT ); Wed, 16 Feb 2022 16:04:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233720AbiBPVEA (ORCPT ); Wed, 16 Feb 2022 16:04:00 -0500 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8429E2B0486 for ; Wed, 16 Feb 2022 13:03:39 -0800 (PST) Received: by mail-pj1-f49.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so7571663pjl.2 for ; Wed, 16 Feb 2022 13:03:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cPWm6i0GNUtIFBB1216hnt9s+p4BUsaGwwaR3/UbOic=; b=UGsQg5Nayrf8y74DSGRoGabRlOSIUVaA7iUIIWrveSB81Bvzj/tp5lmPCs/4FGKHf2 /EgW01OyVwgaLkBeci9JoBrx56Byt9j0Gzgu5UBRlJ4X6uQ38Z6JN5YjxQwgOIF8Nl+p CtewG5FWU72lklYb884n8d+irC8nBuMI4lCke9ofgxH+DPm8d81p2pGckEfYsBkvVj98 mEJ7Crk46QzHMRCW8jldagwbdfPqtuMVAc3tstyl/SaPN0TwHWBDs8C2MG5bOdroNi5M xzTEDwFnzpVyMPfd0PJayxiDLnVbnhK9GFTIE6Sq9CKtyxKXwzf+5T+nGXPZNri5lXJe eTpw== X-Gm-Message-State: AOAM5300ZJLUX8E7k1HYXAOInVPVGlHmWdAjN2E8nuVHK42jfm67NBwh yvnMBdIWYBumd78kzPc8qYM= X-Google-Smtp-Source: ABdhPJwuI8NVNsJpi1iBqHCYwT/2ObUzWYwf+n2nK3zgLXkQ189NZOSlDyUL1XBouw4/Ic9nvIRENQ== X-Received: by 2002:a17:902:ce91:b0:14e:d9a9:5d7c with SMTP id f17-20020a170902ce9100b0014ed9a95d7cmr4397698plg.40.1645045418810; Wed, 16 Feb 2022 13:03:38 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:38 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Lee Duncan , Hannes Reinecke , Himanshu Madhani , Chris Leech , Sagi Grimberg , Nilesh Javali , Manish Rangankar , Karen Xie , Ketan Mukadam , Max Gurtovoy , Jason Gunthorpe , "James E.J. Bottomley" , GR-QLogic-Storage-Upstream@marvell.com Subject: [PATCH v4 26/50] scsi: iscsi: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:09 -0800 Message-Id: <20220216210233.28774-27-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of storing the iSCSI task pointer and the session age in the SCSI pointer, use command-private variables. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. The list of iSCSI drivers has been obtained as follows: $ git grep -lw iscsi_host_alloc drivers/infiniband/ulp/iser/iscsi_iser.c drivers/scsi/be2iscsi/be_main.c drivers/scsi/bnx2i/bnx2i_iscsi.c drivers/scsi/cxgbi/libcxgbi.c drivers/scsi/iscsi_tcp.c drivers/scsi/libiscsi.c drivers/scsi/qedi/qedi_main.c drivers/scsi/qla4xxx/ql4_os.c include/scsi/libiscsi.h Note: it is not clear to me how the qla4xxx driver can work without this patch since it uses the scsi_cmnd::SCp.ptr member for two different purposes: - The qla4xxx driver uses this member to store a struct srb pointer. - libiscsi uses this member to store a struct iscsi_task pointer. Reviewed-by: Lee Duncan Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Cc: Chris Leech Cc: Sagi Grimberg Cc: Nilesh Javali Cc: Manish Rangankar Cc: Karen Xie Cc: Ketan Mukadam Signed-off-by: Bart Van Assche iscsi --- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/be2iscsi/be_main.c | 3 ++- drivers/scsi/bnx2i/bnx2i_iscsi.c | 1 + drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 1 + drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 1 + drivers/scsi/iscsi_tcp.c | 1 + drivers/scsi/libiscsi.c | 20 ++++++++++---------- drivers/scsi/qedi/qedi_fw.c | 4 ++-- drivers/scsi/qedi/qedi_iscsi.c | 1 + drivers/scsi/qla4xxx/ql4_def.h | 16 +++++++++++++--- drivers/scsi/qla4xxx/ql4_os.c | 13 +++++++------ include/scsi/libiscsi.h | 12 ++++++++++++ 12 files changed, 52 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 07e47021a71f..f8d0bab4424c 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -971,6 +971,7 @@ static struct scsi_host_template iscsi_iser_sht = { .proc_name = "iscsi_iser", .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; static struct iscsi_transport iscsi_iser_transport = { diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index ab55681145f8..3bb0adefbe06 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -218,7 +218,7 @@ static char const *cqe_desc[] = { static int beiscsi_eh_abort(struct scsi_cmnd *sc) { - struct iscsi_task *abrt_task = (struct iscsi_task *)sc->SCp.ptr; + struct iscsi_task *abrt_task = iscsi_cmd(sc)->task; struct iscsi_cls_session *cls_session; struct beiscsi_io_task *abrt_io_task; struct beiscsi_conn *beiscsi_conn; @@ -403,6 +403,7 @@ static struct scsi_host_template beiscsi_sht = { .cmd_per_lun = BEISCSI_CMD_PER_LUN, .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; static struct scsi_transport_template *beiscsi_scsi_transport; diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index e21b053b4f3e..fe86fd61a995 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -2268,6 +2268,7 @@ static struct scsi_host_template bnx2i_host_template = { .sg_tablesize = ISCSI_MAX_BDS_PER_CMD, .shost_groups = bnx2i_dev_groups, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; struct iscsi_transport bnx2i_iscsi_transport = { diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c index f949a4e00783..ff9d4287937a 100644 --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c @@ -98,6 +98,7 @@ static struct scsi_host_template cxgb3i_host_template = { .dma_boundary = PAGE_SIZE - 1, .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; static struct iscsi_transport cxgb3i_iscsi_transport = { diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index efb3e2b3398e..53d91bf9c12a 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c @@ -116,6 +116,7 @@ static struct scsi_host_template cxgb4i_host_template = { .dma_boundary = PAGE_SIZE - 1, .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; static struct iscsi_transport cxgb4i_iscsi_transport = { diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 1bc37593c88f..9fee70d6434a 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -1007,6 +1007,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = { .proc_name = "iscsi_tcp", .this_id = -1, .track_queue_depth = 1, + .cmd_size = sizeof(struct iscsi_cmd), }; static struct iscsi_transport iscsi_sw_tcp_transport = { diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 059dae8909ee..d69203d19f2c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -462,7 +462,7 @@ static void iscsi_free_task(struct iscsi_task *task) if (sc) { /* SCSI eh reuses commands to verify us */ - sc->SCp.ptr = NULL; + iscsi_cmd(sc)->task = NULL; /* * queue command may call this to free the task, so * it will decide how to return sc to scsi-ml. @@ -1344,10 +1344,10 @@ struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) if (!task || !task->sc) return NULL; - if (task->sc->SCp.phase != conn->session->age) { + if (iscsi_cmd(task->sc)->age != conn->session->age) { iscsi_session_printk(KERN_ERR, conn->session, "task's session age %d, expected %d\n", - task->sc->SCp.phase, conn->session->age); + iscsi_cmd(task->sc)->age, conn->session->age); return NULL; } @@ -1645,8 +1645,8 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn, (void *) &task, sizeof(void *))) return NULL; - sc->SCp.phase = conn->session->age; - sc->SCp.ptr = (char *) task; + iscsi_cmd(sc)->age = conn->session->age; + iscsi_cmd(sc)->task = task; refcount_set(&task->refcount, 1); task->state = ISCSI_TASK_PENDING; @@ -1683,7 +1683,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) struct iscsi_task *task = NULL; sc->result = 0; - sc->SCp.ptr = NULL; + iscsi_cmd(sc)->task = NULL; ihost = shost_priv(host); @@ -1997,7 +1997,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) spin_lock_bh(&session->frwd_lock); spin_lock(&session->back_lock); - task = (struct iscsi_task *)sc->SCp.ptr; + task = iscsi_cmd(sc)->task; if (!task) { /* * Raced with completion. Blk layer has taken ownership @@ -2260,7 +2260,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) * if session was ISCSI_STATE_IN_RECOVERY then we may not have * got the command. */ - if (!sc->SCp.ptr) { + if (!iscsi_cmd(sc)->task) { ISCSI_DBG_EH(session, "sc never reached iscsi layer or " "it completed.\n"); spin_unlock_bh(&session->frwd_lock); @@ -2273,7 +2273,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) * then let the host reset code handle this */ if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN || - sc->SCp.phase != session->age) { + iscsi_cmd(sc)->age != session->age) { spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); ISCSI_DBG_EH(session, "failing abort due to dropped " @@ -2282,7 +2282,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) } spin_lock(&session->back_lock); - task = (struct iscsi_task *)sc->SCp.ptr; + task = iscsi_cmd(sc)->task; if (!task || !task->sc) { /* task completed before time out */ ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 5916ed7662d5..4e99508ff95d 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -603,9 +603,9 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, goto error; } - if (!sc_cmd->SCp.ptr) { + if (!iscsi_cmd(sc_cmd)->task) { QEDI_WARN(&qedi->dbg_ctx, - "SCp.ptr is NULL, returned in another context.\n"); + "NULL task pointer, returned in another context.\n"); goto error; } diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 282ecb4e39bb..8196f89f404e 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -59,6 +59,7 @@ struct scsi_host_template qedi_host_template = { .dma_boundary = QEDI_HW_DMA_BOUNDARY, .cmd_per_lun = 128, .shost_groups = qedi_shost_groups, + .cmd_size = sizeof(struct iscsi_cmd), }; static void qedi_conn_free_login_resources(struct qedi_ctx *qedi, diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h index 69a590546bf9..5f82c8afd5e0 100644 --- a/drivers/scsi/qla4xxx/ql4_def.h +++ b/drivers/scsi/qla4xxx/ql4_def.h @@ -216,11 +216,21 @@ #define IDC_COMP_TOV 5 #define LINK_UP_COMP_TOV 30 -#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) +/* + * Note: the data structure below does not have a struct iscsi_cmd member since + * the qla4xxx driver does not use libiscsi for SCSI I/O. + */ +struct qla4xxx_cmd_priv { + struct srb *srb; +}; + +static inline struct qla4xxx_cmd_priv *qla4xxx_cmd_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} /* - * SCSI Request Block structure (srb) that is placed - * on cmd->SCp location of every I/O [We have 22 bytes available] + * SCSI Request Block structure (srb) that is associated with each scsi_cmnd. */ struct srb { struct list_head list; /* (8) */ diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 0ae936d839f1..d64eda961412 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -226,6 +226,7 @@ static struct scsi_host_template qla4xxx_driver_template = { .name = DRIVER_NAME, .proc_name = DRIVER_NAME, .queuecommand = qla4xxx_queuecommand, + .cmd_size = sizeof(struct qla4xxx_cmd_priv), .eh_abort_handler = qla4xxx_eh_abort, .eh_device_reset_handler = qla4xxx_eh_device_reset, @@ -4054,7 +4055,7 @@ static struct srb* qla4xxx_get_new_srb(struct scsi_qla_host *ha, srb->ddb = ddb_entry; srb->cmd = cmd; srb->flags = 0; - CMD_SP(cmd) = (void *)srb; + qla4xxx_cmd_priv(cmd)->srb = srb; return srb; } @@ -4067,7 +4068,7 @@ static void qla4xxx_srb_free_dma(struct scsi_qla_host *ha, struct srb *srb) scsi_dma_unmap(cmd); srb->flags &= ~SRB_DMA_VALID; } - CMD_SP(cmd) = NULL; + qla4xxx_cmd_priv(cmd)->srb = NULL; } void qla4xxx_srb_compl(struct kref *ref) @@ -4640,7 +4641,7 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha) * the scsi/block layer is going to prevent * the tag from being released. */ - if (cmd != NULL && CMD_SP(cmd)) + if (cmd != NULL && qla4xxx_cmd_priv(cmd)->srb) break; } spin_unlock_irqrestore(&ha->hardware_lock, flags); @@ -9079,7 +9080,7 @@ struct srb *qla4xxx_del_from_active_array(struct scsi_qla_host *ha, if (!cmd) return srb; - srb = (struct srb *)CMD_SP(cmd); + srb = qla4xxx_cmd_priv(cmd)->srb; if (!srb) return srb; @@ -9121,7 +9122,7 @@ static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha, do { /* Checking to see if its returned to OS */ - rp = (struct srb *) CMD_SP(cmd); + rp = qla4xxx_cmd_priv(cmd)->srb; if (rp == NULL) { done++; break; @@ -9215,7 +9216,7 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd) } spin_lock_irqsave(&ha->hardware_lock, flags); - srb = (struct srb *) CMD_SP(cmd); + srb = qla4xxx_cmd_priv(cmd)->srb; if (!srb) { spin_unlock_irqrestore(&ha->hardware_lock, flags); ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Specified command has already completed.\n", diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 4ee233e5a6ff..cb805ed9cbf1 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -19,6 +19,7 @@ #include #include #include +#include #include struct scsi_transport_template; @@ -152,6 +153,17 @@ static inline bool iscsi_task_is_completed(struct iscsi_task *task) task->state == ISCSI_TASK_ABRT_SESS_RECOV; } +/* Private data associated with struct scsi_cmnd. */ +struct iscsi_cmd { + struct iscsi_task *task; + int age; +}; + +static inline struct iscsi_cmd *iscsi_cmd(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + /* Connection's states */ enum { ISCSI_CONN_INITIAL_STAGE, From patchwork Wed Feb 16 21:02:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97740C4321E for ; Wed, 16 Feb 2022 21:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234286AbiBPVEM (ORCPT ); Wed, 16 Feb 2022 16:04:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233723AbiBPVEB (ORCPT ); Wed, 16 Feb 2022 16:04:01 -0500 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D792B048E for ; Wed, 16 Feb 2022 13:03:41 -0800 (PST) Received: by mail-pj1-f43.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so3529896pjh.3 for ; Wed, 16 Feb 2022 13:03:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a6urj33gaKkePqg1xUPmjUt8DwssrZsVJTG4tFiazOI=; b=dfn4vOR1G45U5s2RokAunvZp9dUnRjAzWVrUSaSXDb9t0o5WfXChBORYrQ9f0moKVe 9n3gF2EdZAT5TSTZjnxGhZWhK2EewkKNPO2hPfoxNo0VxTnHQPlrZcfS0UtsVMBT/hwd U+vUPOfFmCCtXuFMauLW/Sy1U/EC496id1XmFvGT80k+lvuVd0Ro4Lm35msn9CRlOshJ DelV3GznOaUNDa4HS/iIVq+ivMbbwNw/vtKz1YtWr+6it0w9U9mvEe38uZ50uo27Aibd 2K/FInI4V9zgfx5NOPNFjNBdUu2cez8Vn31Adjpp93lP28coPr2AxS6rRf5wL5wWc/rB 6snQ== X-Gm-Message-State: AOAM530lUahZ3RP4Y1yWpP6v0jFM+SNRG0pmFlG0eVU7YcB6zn/XLqtJ tlnLjUzEQY/xgmvA431p1qQ= X-Google-Smtp-Source: ABdhPJxNThEZ6PcB9WssDRjhR2pWVfyuBKiL4XYEBy6BLX5JvT2EeF761RcMzGCSGe7I9DM0XCikXQ== X-Received: by 2002:a17:903:204a:b0:14e:b8d9:b13a with SMTP id q10-20020a170903204a00b0014eb8d9b13amr4398367pla.10.1645045420397; Wed, 16 Feb 2022 13:03:40 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:39 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 27/50] scsi: initio: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:10 -0800 Message-Id: <20220216210233.28774-28-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/initio.c | 14 ++++++++------ drivers/scsi/initio.h | 9 +++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 5f96ac47d7fd..f585d6e5fab9 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2553,7 +2553,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c SENSE_SIZE, DMA_FROM_DEVICE); cblk->senseptr = (u32)dma_addr; cblk->senselen = SENSE_SIZE; - cmnd->SCp.ptr = (char *)(unsigned long)dma_addr; + initio_priv(cmnd)->sense_dma_addr = dma_addr; cblk->cdblen = cmnd->cmd_len; /* Clear the returned status */ @@ -2577,7 +2577,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c sizeof(struct sg_entry) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); cblk->bufptr = (u32)dma_addr; - cmnd->SCp.dma_handle = dma_addr; + initio_priv(cmnd)->sglist_dma_addr = dma_addr; cblk->sglen = nseg; @@ -2704,16 +2704,17 @@ static int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev, static void i91u_unmap_scb(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) { /* auto sense buffer */ - if (cmnd->SCp.ptr) { + if (initio_priv(cmnd)->sense_dma_addr) { dma_unmap_single(&pci_dev->dev, - (dma_addr_t)((unsigned long)cmnd->SCp.ptr), + initio_priv(cmnd)->sense_dma_addr, SENSE_SIZE, DMA_FROM_DEVICE); - cmnd->SCp.ptr = NULL; + initio_priv(cmnd)->sense_dma_addr = 0; } /* request buffer */ if (scsi_sg_count(cmnd)) { - dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, + dma_unmap_single(&pci_dev->dev, + initio_priv(cmnd)->sglist_dma_addr, sizeof(struct sg_entry) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); @@ -2796,6 +2797,7 @@ static struct scsi_host_template initio_template = { .can_queue = MAX_TARGETS * i91u_MAXQUEUE, .this_id = 1, .sg_tablesize = SG_ALL, + .cmd_size = sizeof(struct initio_cmd_priv), }; static int initio_probe_one(struct pci_dev *pdev, diff --git a/drivers/scsi/initio.h b/drivers/scsi/initio.h index 9fd010cf1f8a..7c9741552654 100644 --- a/drivers/scsi/initio.h +++ b/drivers/scsi/initio.h @@ -640,3 +640,12 @@ typedef struct _NVRAM { #define SCSI_RESET_HOST_RESET 0x200 #define SCSI_RESET_ACTION 0xff +struct initio_cmd_priv { + dma_addr_t sense_dma_addr; + dma_addr_t sglist_dma_addr; +}; + +static inline struct initio_cmd_priv *initio_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} From patchwork Wed Feb 16 21:02:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B5EC433F5 for ; Wed, 16 Feb 2022 21:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233822AbiBPVEQ (ORCPT ); Wed, 16 Feb 2022 16:04:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233869AbiBPVEG (ORCPT ); Wed, 16 Feb 2022 16:04:06 -0500 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA55E2B04B1 for ; Wed, 16 Feb 2022 13:03:42 -0800 (PST) Received: by mail-pj1-f48.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso7531420pjt.4 for ; Wed, 16 Feb 2022 13:03:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yav6r05vxK8907t8q2M2B6D+PLZVf3wmq1Na5MjpaTQ=; b=pmDkHD01q+lfySciP6vFTgpoiTHgEzeR6oCAm4KwSC+Kh4ysNSRhp73vOhaU5x9gPc /8s1hVC8yHqhIXeY3YkiXrW/QcfVaFF1RD1qKv08jGwE5WrIKrY+RTvH+3CeqoRYmzei mhPbC//7eiBViHBd0zZVSTOlSsmZbyByt7XK8KTVy6rhQvI6ulen4usDIVDwEsR7+QtV 85DjHQuXR/9Klbr0UFC+d7vt+e1o2FQDovkYj+cw9cHqNzZpSPIFRu5iqKsvU2I4UIir NMM3dGcVe0JtJKDjdCCGLgZWWt3wCIQFyvp3ZQIYcqBVFCyBcuR23Q9QvnNEITNxdbS8 HrgA== X-Gm-Message-State: AOAM5306IVRthKYY1E77i7Xsm7NcrRmPTLzz2tsQSgbyCtPwhFrnlx+q 4rWYYkkw2ybZTYu8kPaXhi8= X-Google-Smtp-Source: ABdhPJwX8zD3tmAfMbNXdejW5xiN2XKYJOyT4XsRTA5XPyDnJtRZS02j1AM6+syH2ymQoJGO6GWlLQ== X-Received: by 2002:a17:902:eb52:b0:14d:5b6c:a27c with SMTP id i18-20020a170902eb5200b0014d5b6ca27cmr4499761pli.4.1645045422288; Wed, 16 Feb 2022 13:03:42 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:41 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Saurav Kashyap , Javed Hasan , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 28/50] scsi: libfc: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:11 -0800 Message-Id: <20220216210233.28774-29-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move the fc_fcp_pkt pointer, the residual length and the SCSI status into the new data structure libfc_cmd_priv. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. The user of the libfc data path functions have been identified as follows: $ git grep -lw fc_queuecommand | grep -v scsi/libfc/ drivers/scsi/fcoe/fcoe.c Cc: Hannes Reinecke Cc: Saurav Kashyap Cc: Javed Hasan Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/fcoe/fcoe.c | 1 + drivers/scsi/libfc/fc_fcp.c | 26 +++++++++++--------------- include/scsi/libfc.h | 9 +++++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 6415f88738ad..44ca6110213c 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -277,6 +277,7 @@ static struct scsi_host_template fcoe_shost_template = { .sg_tablesize = SG_ALL, .max_sectors = 0xffff, .track_queue_depth = 1, + .cmd_size = sizeof(struct libfc_cmd_priv), }; /** diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 871b11edb586..bce90eb56c9c 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -45,14 +45,10 @@ static struct kmem_cache *scsi_pkt_cachep; #define FC_SRB_READ (1 << 1) #define FC_SRB_WRITE (1 << 0) -/* - * The SCp.ptr should be tested and set under the scsi_pkt_queue lock - */ -#define CMD_SP(Cmnd) ((struct fc_fcp_pkt *)(Cmnd)->SCp.ptr) -#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in) -#define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual) -#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) -#define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual) +static struct libfc_cmd_priv *libfc_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} /** * struct fc_fcp_internal - FCP layer internal data @@ -1137,7 +1133,7 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp) unsigned long flags; int rc; - fsp->cmd->SCp.ptr = (char *)fsp; + libfc_priv(fsp->cmd)->fsp = fsp; fsp->cdb_cmd.fc_dl = htonl(fsp->data_len); fsp->cdb_cmd.fc_flags = fsp->req_flags & ~FCP_CFL_LEN_MASK; @@ -1150,7 +1146,7 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp) rc = lport->tt.fcp_cmd_send(lport, fsp, fc_fcp_recv); if (unlikely(rc)) { spin_lock_irqsave(&si->scsi_queue_lock, flags); - fsp->cmd->SCp.ptr = NULL; + libfc_priv(fsp->cmd)->fsp = NULL; list_del(&fsp->list); spin_unlock_irqrestore(&si->scsi_queue_lock, flags); } @@ -1983,7 +1979,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) fc_fcp_can_queue_ramp_up(lport); sc_cmd = fsp->cmd; - CMD_SCSI_STATUS(sc_cmd) = fsp->cdb_status; + libfc_priv(sc_cmd)->status = fsp->cdb_status; switch (fsp->status_code) { case FC_COMPLETE: if (fsp->cdb_status == 0) { @@ -1992,7 +1988,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) */ sc_cmd->result = DID_OK << 16; if (fsp->scsi_resid) - CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid; + libfc_priv(sc_cmd)->resid_len = fsp->scsi_resid; } else { /* * transport level I/O was ok but scsi @@ -2025,7 +2021,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) */ FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml " "due to FC_DATA_UNDRUN (scsi)\n"); - CMD_RESID_LEN(sc_cmd) = fsp->scsi_resid; + libfc_priv(sc_cmd)->resid_len = fsp->scsi_resid; sc_cmd->result = (DID_ERROR << 16) | fsp->cdb_status; } break; @@ -2085,7 +2081,7 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp) spin_lock_irqsave(&si->scsi_queue_lock, flags); list_del(&fsp->list); - sc_cmd->SCp.ptr = NULL; + libfc_priv(sc_cmd)->fsp = NULL; spin_unlock_irqrestore(&si->scsi_queue_lock, flags); scsi_done(sc_cmd); @@ -2121,7 +2117,7 @@ int fc_eh_abort(struct scsi_cmnd *sc_cmd) si = fc_get_scsi_internal(lport); spin_lock_irqsave(&si->scsi_queue_lock, flags); - fsp = CMD_SP(sc_cmd); + fsp = libfc_priv(sc_cmd)->fsp; if (!fsp) { /* command completed while scsi eh was setting up */ spin_unlock_irqrestore(&si->scsi_queue_lock, flags); diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index eeb8d689ff6b..6e29e1719db1 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -351,6 +351,15 @@ struct fc_fcp_pkt { struct completion tm_done; } ____cacheline_aligned_in_smp; +/* + * @fsp should be tested and set under the scsi_pkt_queue lock + */ +struct libfc_cmd_priv { + struct fc_fcp_pkt *fsp; + u32 resid_len; + u8 status; +}; + /* * Structure and function definitions for managing Fibre Channel Exchanges * and Sequences From patchwork Wed Feb 16 21:02:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3F42C433EF for ; Wed, 16 Feb 2022 21:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbiBPVEO (ORCPT ); Wed, 16 Feb 2022 16:04:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085492B0B06 for ; Wed, 16 Feb 2022 13:03:45 -0800 (PST) Received: by mail-pl1-f181.google.com with SMTP id w1so2961607plb.6 for ; Wed, 16 Feb 2022 13:03:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kna+1/whBHm/Uup0ECCatq0EmWr/zlx7nzTrjC/MKew=; b=bHKvVGUMsjsvFJTxhmpjLeN6Moa4/DwW4KFkliCbqXaifM6dwfTyCUZpAZZeGGLBbr GmVEvD/UpHRCNGLOeD5oQXLgBot1BI+eOW4yJ5T2+Us4Mt27a7YUaFeqjX/dUbiqbt2c y5LkKJ7PM5BfwwW8d+SIPKJ8cAAj51N9Jw7+SsbAtk5mnwCadml+lrKiVo/u4bMK9rK/ eHHQq2y0K47UvSHabiu0GIv7KjR3qoyXlrBVXqj+geYK4ZaaSsBE/WZq+Whw70aKnN1z 3F59ZlgeAIvovMvWoDacRRXU2lFqzbZAmTeFhpr4fWj3ZiJ3C415aQutpCrJM6qAQgXZ 8Y7A== X-Gm-Message-State: AOAM533UQ0LoVlZ8FGBbs4hzAg3YV6JyUcwHUWaIk2gAzbkJccJWXBlP 9b7ienVb8z5UCopFLyGXHQc= X-Google-Smtp-Source: ABdhPJyWMRGA6pAsNyqVYET0DwzTHxHWOf3QWI4pvNVMwtQ/qLRZgfVV4Eea0KZkkgpVOCmzGtpaJg== X-Received: by 2002:a17:902:654b:b0:14d:964d:7578 with SMTP id d11-20020a170902654b00b0014d964d7578mr4322326pln.166.1645045424373; Wed, 16 Feb 2022 13:03:44 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:43 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" Subject: [PATCH v4 29/50] scsi: bnx2fc: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:12 -0800 Message-Id: <20220216210233.28774-30-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. Remove the CMD_SCSI_STATUS() assignment because the assigned value is not used. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: Hannes Reinecke Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/scsi/bnx2fc/bnx2fc.h | 9 +++++++-- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 1 + drivers/scsi/bnx2fc/bnx2fc_io.c | 23 +++++++++++------------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h index b4cea8b06ea1..046247420cfa 100644 --- a/drivers/scsi/bnx2fc/bnx2fc.h +++ b/drivers/scsi/bnx2fc/bnx2fc.h @@ -137,8 +137,6 @@ #define BNX2FC_FW_TIMEOUT (3 * HZ) #define PORT_MAX 2 -#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) - /* FC FCP Status */ #define FC_GOOD 0 @@ -493,7 +491,14 @@ struct bnx2fc_unsol_els { struct work_struct unsol_els_work; }; +struct bnx2fc_priv { + struct bnx2fc_cmd *io_req; +}; +static inline struct bnx2fc_priv *bnx2fc_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt); struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type); diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 68c4e3c3e7bb..f9a37ef57f1c 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2979,6 +2979,7 @@ static struct scsi_host_template bnx2fc_shost_template = { .track_queue_depth = 1, .slave_configure = bnx2fc_slave_configure, .shost_groups = bnx2fc_host_groups, + .cmd_size = sizeof(struct bnx2fc_priv), }; static struct libfc_function_template bnx2fc_libfc_fcn_templ = { diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index b9114113ee73..962454f2e2b1 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -204,7 +204,7 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries, sc_cmd->allowed); scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd)); - sc_cmd->SCp.ptr = NULL; + bnx2fc_priv(sc_cmd)->io_req = NULL; scsi_done(sc_cmd); } @@ -765,7 +765,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) task = &(task_page[index]); bnx2fc_init_mp_task(io_req, task); - sc_cmd->SCp.ptr = (char *)io_req; + bnx2fc_priv(sc_cmd)->io_req = io_req; /* Obtain free SQ entry */ spin_lock_bh(&tgt->tgt_lock); @@ -1147,7 +1147,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd) BNX2FC_TGT_DBG(tgt, "Entered bnx2fc_eh_abort\n"); spin_lock_bh(&tgt->tgt_lock); - io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; + io_req = bnx2fc_priv(sc_cmd)->io_req; if (!io_req) { /* Command might have just completed */ printk(KERN_ERR PFX "eh_abort: io_req is NULL\n"); @@ -1572,8 +1572,8 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n", fc_hdr->fh_r_ctl); } - if (!sc_cmd->SCp.ptr) { - printk(KERN_ERR PFX "tm_compl: SCp.ptr is NULL\n"); + if (!bnx2fc_priv(sc_cmd)->io_req) { + printk(KERN_ERR PFX "tm_compl: io_req is NULL\n"); return; } switch (io_req->fcp_status) { @@ -1609,7 +1609,7 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, return; } - sc_cmd->SCp.ptr = NULL; + bnx2fc_priv(sc_cmd)->io_req = NULL; scsi_done(sc_cmd); kref_put(&io_req->refcount, bnx2fc_cmd_release); @@ -1773,8 +1773,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, io_req->fcp_resid = fcp_rsp->fcp_resid; io_req->scsi_comp_flags = rsp_flags; - CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = - fcp_rsp->scsi_status_code; + io_req->cdb_status = fcp_rsp->scsi_status_code; /* Fetch fcp_rsp_info and fcp_sns_info if available */ if (num_rq) { @@ -1946,8 +1945,8 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, /* parse fcp_rsp and obtain sense data from RQ if available */ bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data); - if (!sc_cmd->SCp.ptr) { - printk(KERN_ERR PFX "SCp.ptr is NULL\n"); + if (!bnx2fc_priv(sc_cmd)->io_req) { + printk(KERN_ERR PFX "io_req is NULL\n"); return; } @@ -2018,7 +2017,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, io_req->fcp_status); break; } - sc_cmd->SCp.ptr = NULL; + bnx2fc_priv(sc_cmd)->io_req = NULL; scsi_done(sc_cmd); kref_put(&io_req->refcount, bnx2fc_cmd_release); } @@ -2044,7 +2043,7 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, io_req->port = port; io_req->tgt = tgt; io_req->data_xfer_len = scsi_bufflen(sc_cmd); - sc_cmd->SCp.ptr = (char *)io_req; + bnx2fc_priv(sc_cmd)->io_req = io_req; stats = per_cpu_ptr(lport->stats, get_cpu()); if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { From patchwork Wed Feb 16 21:02:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9D37C4332F for ; Wed, 16 Feb 2022 21:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233677AbiBPVEN (ORCPT ); Wed, 16 Feb 2022 16:04:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233969AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0219F2B0B1F for ; Wed, 16 Feb 2022 13:03:47 -0800 (PST) Received: by mail-pj1-f41.google.com with SMTP id b8so3602527pjb.4 for ; Wed, 16 Feb 2022 13:03:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jrgrlDXlfqpGxL/hjXKS6qYXTNxm9xWSl7rApxGt8Iw=; b=RhERJC3Pm+mA2VKtaIVjfRv9tb9k218wPYbE/XYh5J3uJCtVX0UmXOP9iO+pDDprCj 1e5iTC6sSztfAj9XGpwcPkQVNJXwh4FaehwRJkh74mmnpoL49rD3on3aN0cgx/r4P4Wg hkBbMD8DSUMYw/fUu55GGl3Kbaci1G5VrUexnMiBo9VUwI3Q/in71c4T5OfkyX1FxEyK 27EE+FIi4ADkwOkZmWbPGhXy/2+0LUuNo/RBbIUlOon4KcVV0/HMqYJuxxzRJ51EH6Se YhFEgukV35HvW5+VgkJfK0WC1TJnL6S0Q88/FkcFs19rluTo2GwtU2Ok6QG1pqje08aM dEBw== X-Gm-Message-State: AOAM533i8f2T+xz4B4h00tho7bnGFiqt2y8xzA6pEriwdB8ReKNfRq6A MO9rkNT0031Vcu/MnTAHbfc= X-Google-Smtp-Source: ABdhPJxAzOAftRvUIR8cG6W1WVXUgJX8DPGZkx7YD5PZkQb7ze5brxYkIjTk/FjqSDHtT+Jidpm6hQ== X-Received: by 2002:a17:902:d502:b0:14b:4520:9380 with SMTP id b2-20020a170902d50200b0014b45209380mr4387508plg.53.1645045426279; Wed, 16 Feb 2022 13:03:46 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:45 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" Subject: [PATCH v4 30/50] scsi: qedf: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:13 -0800 Message-Id: <20220216210233.28774-31-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. Remove the CMD_SCSI_STATUS() assignment because the assigned value is not used. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: Hannes Reinecke Signed-off-by: Bart Van Assche --- drivers/scsi/qedf/qedf.h | 10 +++++++++- drivers/scsi/qedf/qedf_io.c | 25 ++++++++++++------------- drivers/scsi/qedf/qedf_main.c | 3 ++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h index ca987451b17e..c5c0bbdafc4e 100644 --- a/drivers/scsi/qedf/qedf.h +++ b/drivers/scsi/qedf/qedf.h @@ -91,7 +91,6 @@ enum qedf_ioreq_event { #define FC_GOOD 0 #define FCOE_FCP_RSP_FLAGS_FCP_RESID_OVER (0x1<<2) #define FCOE_FCP_RSP_FLAGS_FCP_RESID_UNDER (0x1<<3) -#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status) #define FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID (0x1<<0) #define FCOE_FCP_RSP_FLAGS_FCP_SNS_LEN_VALID (0x1<<1) struct qedf_ioreq { @@ -189,6 +188,15 @@ struct qedf_ioreq { unsigned int alloc; }; +struct qedf_cmd_priv { + struct qedf_ioreq *io_req; +}; + +static inline struct qedf_cmd_priv *qedf_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + extern struct workqueue_struct *qedf_io_wq; struct qedf_rport { diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index 99a56ca1fb16..81668cfcdd55 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -857,7 +857,7 @@ int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req) /* Initialize rest of io_req fileds */ io_req->data_xfer_len = scsi_bufflen(sc_cmd); - sc_cmd->SCp.ptr = (char *)io_req; + qedf_priv(sc_cmd)->io_req = io_req; io_req->sge_type = QEDF_IOREQ_FAST_SGE; /* Assume fast SGL by default */ /* Record which cpu this request is associated with */ @@ -1065,8 +1065,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, io_req->fcp_resid = fcp_rsp->fcp_resid; io_req->scsi_comp_flags = rsp_flags; - CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = - fcp_rsp->scsi_status_code; + io_req->cdb_status = fcp_rsp->scsi_status_code; if (rsp_flags & FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID) @@ -1150,9 +1149,9 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, return; } - if (!sc_cmd->SCp.ptr) { - QEDF_WARN(&(qedf->dbg_ctx), "SCp.ptr is NULL, returned in " - "another context.\n"); + if (!qedf_priv(sc_cmd)->io_req) { + QEDF_WARN(&(qedf->dbg_ctx), + "io_req is NULL, returned in another context.\n"); return; } @@ -1312,7 +1311,7 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); io_req->sc_cmd = NULL; - sc_cmd->SCp.ptr = NULL; + qedf_priv(sc_cmd)->io_req = NULL; scsi_done(sc_cmd); kref_put(&io_req->refcount, qedf_release_cmd); } @@ -1354,9 +1353,9 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, goto bad_scsi_ptr; } - if (!sc_cmd->SCp.ptr) { - QEDF_WARN(&(qedf->dbg_ctx), "SCp.ptr is NULL, returned in " - "another context.\n"); + if (!qedf_priv(sc_cmd)->io_req) { + QEDF_WARN(&(qedf->dbg_ctx), + "io_req is NULL, returned in another context.\n"); return; } @@ -1409,7 +1408,7 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, qedf_trace_io(io_req->fcport, io_req, QEDF_IO_TRACE_RSP); io_req->sc_cmd = NULL; - sc_cmd->SCp.ptr = NULL; + qedf_priv(sc_cmd)->io_req = NULL; scsi_done(sc_cmd); kref_put(&io_req->refcount, qedf_release_cmd); return; @@ -2432,8 +2431,8 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) (tm_flags == FCP_TMF_TGT_RESET) ? "TARGET RESET" : "LUN RESET"); - if (sc_cmd->SCp.ptr) { - io_req = (struct qedf_ioreq *)sc_cmd->SCp.ptr; + if (qedf_priv(sc_cmd)->io_req) { + io_req = qedf_priv(sc_cmd)->io_req; ref_cnt = kref_read(&io_req->refcount); QEDF_ERR(NULL, "orig io_req = %p xid = 0x%x ref_cnt = %d.\n", diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index cdc66e2a9488..05b609a0e80d 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -740,7 +740,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) } - io_req = (struct qedf_ioreq *)sc_cmd->SCp.ptr; + io_req = qedf_priv(sc_cmd)->io_req; if (!io_req) { QEDF_ERR(&qedf->dbg_ctx, "sc_cmd not queued with lld, sc_cmd=%p op=0x%02x, port_id=%06x\n", @@ -996,6 +996,7 @@ static struct scsi_host_template qedf_host_template = { .sg_tablesize = QEDF_MAX_BDS_PER_CMD, .can_queue = FCOE_PARAMS_NUM_TASKS, .change_queue_depth = scsi_change_queue_depth, + .cmd_size = sizeof(struct qedf_cmd_priv), }; static int qedf_get_paged_crc_eof(struct sk_buff *skb, int tlen) From patchwork Wed Feb 16 21:02:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9990FC4321E for ; Wed, 16 Feb 2022 21:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234391AbiBPVET (ORCPT ); Wed, 16 Feb 2022 16:04:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234088AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7409222DCD for ; Wed, 16 Feb 2022 13:03:48 -0800 (PST) Received: by mail-pj1-f45.google.com with SMTP id m7so3653332pjk.0 for ; Wed, 16 Feb 2022 13:03:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rnPGc2HmiwKa1PtCl2I0Ff3xuRZvI73UsIWDdkAtGSY=; b=xfmEZPV3fwZNCrqG6pJqa/evgwTpF81//7Nr1W6v41mFX0r/virYNiyW5cD57ifogT F/uikVnwPmlDIHSIUqrdF+z5Sr/4+z4wmSv9GXzR8qNmmcyjBx1VghKg6h47TDmCGjvN d/yFFf2TTACnUbiMgW7UqJ17TnMXCvXp7zY2c7BzgkRPWLn4sXX7AqUM/t728/mymYr5 l9caCG58atvWr/aJM9gu7xnvXTb1EZEZx0mThZJbC2e9gMZ5zx9ScATiUxd5xbXE4vg/ wxDcLvpcfQvJXn6VEXIgr2NUfkF2o+vz8XBi0lBFv30vkypaVW9h6glD+E2tZnTYL8xG j+Bw== X-Gm-Message-State: AOAM533D8ASBx9tm5iP0HymdNXTx3dbdeEEl7dXkeu6TfoL2XUZQztVD N+S76SIV9vPxGhOpumFZpi4= X-Google-Smtp-Source: ABdhPJxUqYn9vQGoloc5GozziNoaeh0vhJE2hPdNex9StgI0VVewzcKXOV+lVoHI4fE/FrSugPVKzw== X-Received: by 2002:a17:903:120b:b0:14f:14b:3485 with SMTP id l11-20020a170903120b00b0014f014b3485mr4277761plh.18.1645045428314; Wed, 16 Feb 2022 13:03:48 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:47 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Benjamin Herrenschmidt , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 31/50] scsi: mac53c94: Fix a set-but-not-used compiler warning Date: Wed, 16 Feb 2022 13:02:14 -0800 Message-Id: <20220216210233.28774-32-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Fix the following compiler warning: drivers/scsi/mac53c94.c: In function 'mac53c94_init': drivers/scsi/mac53c94.c:128:13: warning: variable 'x' set but not used [-Wunused-but-set-variable] 128 | int x; Cc: Benjamin Herrenschmidt Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/mac53c94.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index 3976a18f6333..afa08309de36 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c @@ -125,7 +125,6 @@ static void mac53c94_init(struct fsc_state *state) { struct mac53c94_regs __iomem *regs = state->regs; struct dbdma_regs __iomem *dma = state->dma; - int x; writeb(state->host->this_id | CF1_PAR_ENABLE, ®s->config1); writeb(TIMO_VAL(250), ®s->sel_timeout); /* 250ms */ @@ -134,7 +133,7 @@ static void mac53c94_init(struct fsc_state *state) writeb(0, ®s->config3); writeb(0, ®s->sync_period); writeb(0, ®s->sync_offset); - x = readb(®s->interrupt); + (void)readb(®s->interrupt); writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control); } From patchwork Wed Feb 16 21:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DB1CC433F5 for ; Wed, 16 Feb 2022 21:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbiBPVEc (ORCPT ); Wed, 16 Feb 2022 16:04:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234135AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18372B0B2D for ; Wed, 16 Feb 2022 13:03:50 -0800 (PST) Received: by mail-pf1-f172.google.com with SMTP id g1so3201041pfv.1 for ; Wed, 16 Feb 2022 13:03:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RXFHg0yTOuB/QS7nUh7XRAJJPPSKx3N3iXfv6RVU628=; b=gTkE0tva62G6sg2H9/u2UTD2eYj060duuXPLlHf8S8wVX+7UhcF3hfzOA/ct3P8TS2 aPNyBQLoxiP2pWbMLRVqipydGvgLgz8R3fXnBofKQNX2Wvc3Eth2E+78W79vOXaDmdIr SU7pL/RdFYCqzyQ9cRyO5O01+7GAwEIsFpVTS9hmCfi7hVOxCIT38BeRhhVSnf2Nu5t2 Jjw7YNHN1uPZEGXmdQGPuSNJMMmwk2QnwMVIp7gsx/tvEp1qon+fKx99mV1gi8jUW8f0 jz4bhMwRLQ5fG1y83sT1iAJ5Z6e2se9A/Yf7UAAwRleTNZtQDplu+WoGcMQux6f8mCDK eSQA== X-Gm-Message-State: AOAM533cQaIZDMZVVupSp7qt2QfEDPhiky+RwF0ljoOH8DFR5ymgwfNi C4PbHkWd4pJHaoO7fitVz0mUj1Io8d2LUSfA X-Google-Smtp-Source: ABdhPJwZPfJ3HbibS0RE2xEwU5Rn3J3dMAJ1kKuwv2Hw6+iWf4Zc11DaS9eZucFV5sY1COrEJDPGIw== X-Received: by 2002:aa7:90cc:0:b0:4e0:2270:2f71 with SMTP id k12-20020aa790cc000000b004e022702f71mr5101471pfk.17.1645045429898; Wed, 16 Feb 2022 13:03:49 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:49 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 32/50] scsi: mac53c94: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:15 -0800 Message-Id: <20220216210233.28774-33-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/mac53c94.c | 24 +++++++++++++----------- drivers/scsi/mac53c94.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index afa08309de36..f3005b38931f 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c @@ -193,7 +193,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) struct fsc_state *state = (struct fsc_state *) dev_id; struct mac53c94_regs __iomem *regs = state->regs; struct dbdma_regs __iomem *dma = state->dma; - struct scsi_cmnd *cmd = state->current_req; + struct scsi_cmnd *const cmd = state->current_req; + struct scsi_pointer *const scsi_pointer = mac53c94_scsi_pointer(cmd); int nb, stat, seq, intr; static int mac53c94_errors; @@ -263,10 +264,10 @@ static void mac53c94_interrupt(int irq, void *dev_id) /* set DMA controller going if any data to transfer */ if ((stat & (STAT_MSG|STAT_CD)) == 0 && (scsi_sg_count(cmd) > 0 || scsi_bufflen(cmd))) { - nb = cmd->SCp.this_residual; + nb = scsi_pointer->this_residual; if (nb > 0xfff0) nb = 0xfff0; - cmd->SCp.this_residual -= nb; + scsi_pointer->this_residual -= nb; writeb(nb, ®s->count_lo); writeb(nb >> 8, ®s->count_mid); writeb(CMD_DMA_MODE + CMD_NOP, ®s->command); @@ -293,13 +294,13 @@ static void mac53c94_interrupt(int irq, void *dev_id) cmd_done(state, DID_ERROR << 16); return; } - if (cmd->SCp.this_residual != 0 + if (scsi_pointer->this_residual != 0 && (stat & (STAT_MSG|STAT_CD)) == 0) { /* Set up the count regs to transfer more */ - nb = cmd->SCp.this_residual; + nb = scsi_pointer->this_residual; if (nb > 0xfff0) nb = 0xfff0; - cmd->SCp.this_residual -= nb; + scsi_pointer->this_residual -= nb; writeb(nb, ®s->count_lo); writeb(nb >> 8, ®s->count_mid); writeb(CMD_DMA_MODE + CMD_NOP, ®s->command); @@ -321,8 +322,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) cmd_done(state, DID_ERROR << 16); return; } - cmd->SCp.Status = readb(®s->fifo); - cmd->SCp.Message = readb(®s->fifo); + scsi_pointer->Status = readb(®s->fifo); + scsi_pointer->Message = readb(®s->fifo); writeb(CMD_ACCEPT_MSG, ®s->command); state->phase = busfreeing; break; @@ -330,8 +331,8 @@ static void mac53c94_interrupt(int irq, void *dev_id) if (intr != INTR_DISCONNECT) { printk(KERN_DEBUG "got intr %x when expected disconnect\n", intr); } - cmd_done(state, (DID_OK << 16) + (cmd->SCp.Message << 8) - + cmd->SCp.Status); + cmd_done(state, (DID_OK << 16) + (scsi_pointer->Message << 8) + + scsi_pointer->Status); break; default: printk(KERN_DEBUG "don't know about phase %d\n", state->phase); @@ -389,7 +390,7 @@ static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd) dma_cmd += OUTPUT_LAST - OUTPUT_MORE; dcmds[-1].command = cpu_to_le16(dma_cmd); dcmds->command = cpu_to_le16(DBDMA_STOP); - cmd->SCp.this_residual = total; + mac53c94_scsi_pointer(cmd)->this_residual = total; } static struct scsi_host_template mac53c94_template = { @@ -401,6 +402,7 @@ static struct scsi_host_template mac53c94_template = { .this_id = 7, .sg_tablesize = SG_ALL, .max_segment_size = 65535, + .cmd_size = sizeof(struct mac53c94_cmd_priv), }; static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match) diff --git a/drivers/scsi/mac53c94.h b/drivers/scsi/mac53c94.h index 5df6e81f78a8..37d7d30f42ef 100644 --- a/drivers/scsi/mac53c94.h +++ b/drivers/scsi/mac53c94.h @@ -212,4 +212,15 @@ struct mac53c94_regs { #define CF4_TEST 0x02 #define CF4_BBTE 0x01 +struct mac53c94_cmd_priv { + struct scsi_pointer scsi_pointer; +}; + +static inline struct scsi_pointer *mac53c94_scsi_pointer(struct scsi_cmnd *cmd) +{ + struct mac53c94_cmd_priv *mcmd = scsi_cmd_priv(cmd); + + return &mcmd->scsi_pointer; +} + #endif /* _MAC53C94_H */ From patchwork Wed Feb 16 21:02:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 220A7C43219 for ; Wed, 16 Feb 2022 21:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234149AbiBPVEd (ORCPT ); Wed, 16 Feb 2022 16:04:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234182AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BC72B0B2F for ; Wed, 16 Feb 2022 13:03:52 -0800 (PST) Received: by mail-pj1-f46.google.com with SMTP id m7so3653453pjk.0 for ; Wed, 16 Feb 2022 13:03:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n+ftz6rZifOckZ2d1iAwIpAJCAY8J0AJBDadpTM8K0k=; b=uwdMntU3GSZzuD/3TI5g2emepJsX5t45IIynkuKOLAZXQrn/E4DFRNOFjJn8M/WZMc iLVfI6BiR7pGTg6oGvW0tb+viFNpbxKCKa93GZQfjQ+ELO6ncmjIoUiruARTC6EleIie TsUEKEURGo2ru1sAJeGp+/2XXeshv1UICrHPdJ8rmKc1h6sUhHRMRh6Oai5xrUacMkF4 2K3218znK5EDVc9bg/ahcWMizADKtyliBIbTnG7xbZ3l/bXQg9f4kqvDQSzEHU4Ck8yJ PtZeoF4bQd5gY9ncI8vUZ6fcsU33fdmTEIz4qmjdylwvvgBXndHbg8HCZX5BcP/XKO9h Md0Q== X-Gm-Message-State: AOAM531Th8MbDbAKfatPtcuwt5kQ27l5SDhvw5Ls3/7zDHpdL2O204/D SMvocu4mwBKAa83CSrAJDObvP4H28+nWMu6Q X-Google-Smtp-Source: ABdhPJwOyAewVuSZ6T5j69os+/yc9Yo3wzQdpIJpzQX5YI3FcLxh/4sdLmH/lzYUuxLEgUYLUs45dA== X-Received: by 2002:a17:902:c9c3:b0:14f:e0b:2abe with SMTP id q3-20020a170902c9c300b0014f0e0b2abemr695730pld.114.1645045431749; Wed, 16 Feb 2022 13:03:51 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:51 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , Kashyap Desai , Sumit Saxena , Shivasharan S , "James E.J. Bottomley" Subject: [PATCH v4 33/50] scsi: megaraid: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:16 -0800 Message-Id: <20220216210233.28774-34-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/megaraid.c | 13 ++++--------- drivers/scsi/megaraid.h | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 2061e3fe9824..a5d8cee2d510 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1644,16 +1644,10 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) static void mega_rundoneq (adapter_t *adapter) { - struct scsi_cmnd *cmd; - struct list_head *pos; + struct megaraid_cmd_priv *cmd_priv; - list_for_each(pos, &adapter->completed_list) { - - struct scsi_pointer* spos = (struct scsi_pointer *)pos; - - cmd = list_entry(spos, struct scsi_cmnd, SCp); - scsi_done(cmd); - } + list_for_each_entry(cmd_priv, &adapter->completed_list, entry) + scsi_done(megaraid_to_scsi_cmd(cmd_priv)); INIT_LIST_HEAD(&adapter->completed_list); } @@ -4123,6 +4117,7 @@ static struct scsi_host_template megaraid_template = { .eh_bus_reset_handler = megaraid_reset, .eh_host_reset_handler = megaraid_reset, .no_write_same = 1, + .cmd_size = sizeof(struct megaraid_cmd_priv), }; static int diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index cce23a086fbe..013fbfb911b9 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h @@ -4,6 +4,7 @@ #include #include +#include #define MEGARAID_VERSION \ "v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n" @@ -756,8 +757,28 @@ struct private_bios_data { #define CACHED_IO 0 #define DIRECT_IO 1 +struct megaraid_cmd_priv { + struct list_head entry; +}; + +#define SCSI_LIST(scp) \ + (&((struct megaraid_cmd_priv *)scsi_cmd_priv(scp))->entry) + +struct scsi_cmd_and_priv { + struct scsi_cmnd cmd; + struct megaraid_cmd_priv priv; +}; + +static inline struct scsi_cmnd * +megaraid_to_scsi_cmd(struct megaraid_cmd_priv *cmd_priv) +{ + /* See also scsi_mq_setup_tags() */ + BUILD_BUG_ON(sizeof(struct scsi_cmd_and_priv) != + sizeof(struct scsi_cmnd) + + sizeof(struct megaraid_cmd_priv)); -#define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp)) + return &container_of(cmd_priv, struct scsi_cmd_and_priv, priv)->cmd; +} /* * Each controller's soft state From patchwork Wed Feb 16 21:02:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43CD1C4321E for ; Wed, 16 Feb 2022 21:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234182AbiBPVEe (ORCPT ); Wed, 16 Feb 2022 16:04:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61ECF2B1001 for ; Wed, 16 Feb 2022 13:03:54 -0800 (PST) Received: by mail-pg1-f176.google.com with SMTP id 139so3194204pge.1 for ; Wed, 16 Feb 2022 13:03:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u/qBRBLM1r2yTY4VduEFKfWhYTThTW41WBM80pT8DTc=; b=79gLYNbCKklXrL/LYhjgxv2k96eKGSKT3EaAh+K3szKO7uD6JLiIhIca9UDOwCdB5V +d4n4iyMrNvsgQbQ9Koxa7zCffHhtp+E3MUzF6S/1Wfb58nNn4REHc1xxPjjibMEbuN/ Np6kGgO9WyGmo1MG42zfQyWjY/SszmVBk012mLit4zZQB/sbXU7ToNvmkffv/fk1xLcz c2vZfYO2NXjNOM16h/13aY8YHxqDOSPSLQBgSQ+jSk0V8BmIRz6PoHYaMXtvAFDTMsHd dV15i3LE00EJfB1rs9z46xqeotJpRL/liTWD3SLS8XL8jJKJIiuwZKm9asi7eGOVIvLy PbjA== X-Gm-Message-State: AOAM530hKEvsjYRsD0kq5x7TKv4BX17Nd2+RDtoHKiSyMoayKOFY3A05 G6190VZG0KYG0d2Nz7gLtKg= X-Google-Smtp-Source: ABdhPJztGCRZyX2eFyclG2Pz6SCdX/TsOp3iamXJ3j32xjt5gC68j6xKH/EI4qY24FiXFer/J5dv3Q== X-Received: by 2002:a63:ff54:0:b0:373:520f:a01d with SMTP id s20-20020a63ff54000000b00373520fa01dmr3761828pgk.394.1645045433704; Wed, 16 Feb 2022 13:03:53 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:53 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , Kashyap Desai , Sumit Saxena , Shivasharan S , "James E.J. Bottomley" Subject: [PATCH v4 34/50] scsi: megasas: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:17 -0800 Message-Id: <20220216210233.28774-35-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/megaraid/megaraid_sas.h | 12 ++++++++++++ drivers/scsi/megaraid/megaraid_sas_base.c | 8 ++++---- drivers/scsi/megaraid/megaraid_sas_fusion.c | 15 ++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 2c9d1b796475..611871ef15b5 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -18,6 +18,8 @@ #ifndef LSI_MEGARAID_SAS_H #define LSI_MEGARAID_SAS_H +#include + /* * MegaRAID SAS Driver meta data */ @@ -2594,6 +2596,16 @@ struct megasas_cmd { }; }; +struct megasas_cmd_priv { + void *cmd_priv; + u8 status; +}; + +static inline struct megasas_cmd_priv *megasas_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + #define MAX_MGMT_ADAPTERS 1024 #define MAX_IOCTL_SGE 16 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 82e1e24257bc..8bf72dbc33b7 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1760,7 +1760,7 @@ megasas_build_and_issue_cmd(struct megasas_instance *instance, goto out_return_cmd; cmd->scmd = scmd; - scmd->SCp.ptr = (char *)cmd; + megasas_priv(scmd)->cmd_priv = cmd; /* * Issue the command to the FW @@ -2992,11 +2992,10 @@ megasas_dump_reg_set(void __iomem *reg_set) void megasas_dump_fusion_io(struct scsi_cmnd *scmd) { - struct megasas_cmd_fusion *cmd; + struct megasas_cmd_fusion *cmd = megasas_priv(scmd)->cmd_priv; union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc; struct megasas_instance *instance; - cmd = (struct megasas_cmd_fusion *)scmd->SCp.ptr; instance = (struct megasas_instance *)scmd->device->host->hostdata; scmd_printk(KERN_INFO, scmd, @@ -3518,6 +3517,7 @@ static struct scsi_host_template megasas_template = { .mq_poll = megasas_blk_mq_poll, .change_queue_depth = scsi_change_queue_depth, .max_segment_size = 0xffffffff, + .cmd_size = sizeof(struct megasas_cmd_priv), }; /** @@ -3601,7 +3601,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, cmd->retry_for_fw_reset = 0; if (cmd->scmd) - cmd->scmd->SCp.ptr = NULL; + megasas_priv(cmd->scmd)->cmd_priv = NULL; switch (hdr->cmd) { case MFI_CMD_INVALID: diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index fc90a0a687b5..c72364864bf4 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -2915,7 +2915,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, get_updated_dev_handle(instance, &fusion->load_balance_info[device_id], &io_info, local_map_ptr); - scp->SCp.Status |= MEGASAS_LOAD_BALANCE_FLAG; + megasas_priv(scp)->status |= MEGASAS_LOAD_BALANCE_FLAG; cmd->pd_r1_lb = io_info.pd_after_lb; if (instance->adapter_type >= VENTURA_SERIES) rctx_g35->span_arm = io_info.span_arm; @@ -2923,7 +2923,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, rctx->span_arm = io_info.span_arm; } else - scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG; + megasas_priv(scp)->status &= ~MEGASAS_LOAD_BALANCE_FLAG; if (instance->adapter_type >= VENTURA_SERIES) cmd->r1_alt_dev_handle = io_info.r1_alt_dev_handle; @@ -3293,7 +3293,7 @@ megasas_build_io_fusion(struct megasas_instance *instance, io_request->SenseBufferLength = SCSI_SENSE_BUFFERSIZE; cmd->scmd = scp; - scp->SCp.ptr = (char *)cmd; + megasas_priv(scp)->cmd_priv = cmd; return 0; } @@ -3489,7 +3489,7 @@ megasas_complete_r1_command(struct megasas_instance *instance, if (instance->ldio_threshold && megasas_cmd_type(scmd_local) == READ_WRITE_LDIO) atomic_dec(&instance->ldio_outstanding); - scmd_local->SCp.ptr = NULL; + megasas_priv(scmd_local)->cmd_priv = NULL; megasas_return_cmd_fusion(instance, cmd); scsi_dma_unmap(scmd_local); megasas_sdev_busy_dec(instance, scmd_local); @@ -3613,12 +3613,13 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, case MPI2_FUNCTION_SCSI_IO_REQUEST: /*Fast Path IO.*/ /* Update load balancing info */ if (fusion->load_balance_info && - (cmd_fusion->scmd->SCp.Status & + (megasas_priv(cmd_fusion->scmd)->status & MEGASAS_LOAD_BALANCE_FLAG)) { device_id = MEGASAS_DEV_INDEX(scmd_local); lbinfo = &fusion->load_balance_info[device_id]; atomic_dec(&lbinfo->scsi_pending_cmds[cmd_fusion->pd_r1_lb]); - cmd_fusion->scmd->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG; + megasas_priv(cmd_fusion->scmd)->status &= + ~MEGASAS_LOAD_BALANCE_FLAG; } fallthrough; /* and complete IO */ case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */ @@ -3630,7 +3631,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, if (instance->ldio_threshold && (megasas_cmd_type(scmd_local) == READ_WRITE_LDIO)) atomic_dec(&instance->ldio_outstanding); - scmd_local->SCp.ptr = NULL; + megasas_priv(scmd_local)->cmd_priv = NULL; megasas_return_cmd_fusion(instance, cmd_fusion); scsi_dma_unmap(scmd_local); megasas_sdev_busy_dec(instance, scmd_local); From patchwork Wed Feb 16 21:02:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C9FDC433FE for ; Wed, 16 Feb 2022 21:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234157AbiBPVFG (ORCPT ); Wed, 16 Feb 2022 16:05:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbiBPVEI (ORCPT ); Wed, 16 Feb 2022 16:04:08 -0500 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3522AFE9E for ; Wed, 16 Feb 2022 13:03:55 -0800 (PST) Received: by mail-pf1-f175.google.com with SMTP id u16so3149894pfg.12 for ; Wed, 16 Feb 2022 13:03:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8KYU+BdU6PlksD78VB0yUTvt/EaDu45QnauSkwKpQfw=; b=EPFYKPnYfmGvALrbsr+iU8KMSbfyOXXWp9LwMwtBcVufGD+3tQ7W8jGb+QlrY9iENf k6rEGTUk3E41X70LNl00ioXYEkh5nnAL/MkfmUH5wPtWYtlOsS3xgWMsgf4pW7Zl33ux uu5YqplzAKhGphXBjUZPS9F4bSm5XAqlhc7dJgQqlh2ba7Aw8+sf+t7tDU4+gJUP/ROk 0wlGor/XuE2n+TLPwR2Zd3a+X6IcumwSpSZLlIPDO8gxMRW/QLT1QYjrz8+XBuxSio4w cLJc3XjLsODuMpoMdi/Hk0NQJmc/WiL40g3jtUvGLgSx3y4zBsRxQ3xdTLhqeHqwtk+3 ytGw== X-Gm-Message-State: AOAM532eNOepDtn2+i738X744l2hwFiCFDTqjvjeegaxJBSphduEWbfw bEcWPz6sqQJDbyyYhR4TFWQ= X-Google-Smtp-Source: ABdhPJyS4pBgWkbAAbtNWWAKNhlgmD3fxxBcZqo4n7QjXWDR9Lzh9++h+aqK+JgemjCLMhIxy69H+w== X-Received: by 2002:a63:64c5:0:b0:34d:3d6c:31d2 with SMTP id y188-20020a6364c5000000b0034d3d6c31d2mr3711803pgb.499.1645045435336; Wed, 16 Feb 2022 13:03:55 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:54 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 35/50] scsi: mesh: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:18 -0800 Message-Id: <20220216210233.28774-36-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/mesh.c | 20 +++++++++++++------- drivers/scsi/mesh.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index ca133e0a140a..de9ae36def42 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c @@ -586,10 +586,12 @@ static void mesh_done(struct mesh_state *ms, int start_next) ms->current_req = NULL; tp->current_req = NULL; if (cmd) { + struct scsi_pointer *scsi_pointer = mesh_scsi_pointer(cmd); + set_host_byte(cmd, ms->stat); - set_status_byte(cmd, cmd->SCp.Status); + set_status_byte(cmd, scsi_pointer->Status); if (ms->stat == DID_OK) - scsi_msg_to_host_byte(cmd, cmd->SCp.Message); + scsi_msg_to_host_byte(cmd, scsi_pointer->Message); if (DEBUG_TARGET(cmd)) { printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", cmd->result, ms->data_ptr, scsi_bufflen(cmd)); @@ -603,7 +605,7 @@ static void mesh_done(struct mesh_state *ms, int start_next) } #endif } - cmd->SCp.this_residual -= ms->data_ptr; + scsi_pointer->this_residual -= ms->data_ptr; scsi_done(cmd); } if (start_next) { @@ -1171,7 +1173,7 @@ static void handle_msgin(struct mesh_state *ms) if (ms->n_msgin < msgin_length(ms)) goto reject; if (cmd) - cmd->SCp.Message = code; + mesh_scsi_pointer(cmd)->Message = code; switch (code) { case COMMAND_COMPLETE: break; @@ -1262,7 +1264,7 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd) if (cmd) { int nseg; - cmd->SCp.this_residual = scsi_bufflen(cmd); + mesh_scsi_pointer(cmd)->this_residual = scsi_bufflen(cmd); nseg = scsi_dma_map(cmd); BUG_ON(nseg < 0); @@ -1592,10 +1594,13 @@ static void cmd_complete(struct mesh_state *ms) break; case statusing: if (cmd) { - cmd->SCp.Status = mr->fifo; + struct scsi_pointer *scsi_pointer = + mesh_scsi_pointer(cmd); + + scsi_pointer->Status = mr->fifo; if (DEBUG_TARGET(cmd)) printk(KERN_DEBUG "mesh: status is %x\n", - cmd->SCp.Status); + scsi_pointer->Status); } ms->msgphase = msg_in; break; @@ -1837,6 +1842,7 @@ static struct scsi_host_template mesh_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 2, .max_segment_size = 65535, + .cmd_size = sizeof(struct mesh_cmd_priv), }; static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) diff --git a/drivers/scsi/mesh.h b/drivers/scsi/mesh.h index ee53c05ace95..1afa8b37295b 100644 --- a/drivers/scsi/mesh.h +++ b/drivers/scsi/mesh.h @@ -8,6 +8,17 @@ #ifndef _MESH_H #define _MESH_H +struct mesh_cmd_priv { + struct scsi_pointer scsi_pointer; +}; + +static inline struct scsi_pointer *mesh_scsi_pointer(struct scsi_cmnd *cmd) +{ + struct mesh_cmd_priv *mcmd = scsi_cmd_priv(cmd); + + return &mcmd->scsi_pointer; +} + /* * Registers in the MESH controller. */ From patchwork Wed Feb 16 21:02:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C51E5C433EF for ; Wed, 16 Feb 2022 21:04:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234536AbiBPVFD (ORCPT ); Wed, 16 Feb 2022 16:05:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234300AbiBPVEN (ORCPT ); Wed, 16 Feb 2022 16:04:13 -0500 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564472225C5 for ; Wed, 16 Feb 2022 13:03:59 -0800 (PST) Received: by mail-pl1-f175.google.com with SMTP id 10so2982503plj.1 for ; Wed, 16 Feb 2022 13:03:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x5776Xb1ZxOoCWofKgeVtEzZnuJVmA+hEux/0pEWZW4=; b=upr2NwsNH2oD4zfK3bot4okPlqelqf+ETEnFuQmi+yWgBIRmGrHjx8KL8gBdXhgCtP VZHABKlWUxztR+TfAuNvfWEmbAkpWeRE0SdkWpFSx7O/W1Yv5zB8e8FbY9knq9a+Enoc Ofc2id7VGyvuYCIdHdKYoSqA2nljNS6aTGmFZyMOme+AGODvbKREjzdcYKdSeJqdyNpT 2m6Q3njYjICRSdi9YtE3htnWABpJb7mAOyiBxRVITzGGpSmyW+DKJTpoxegJZK7lSJPK QDHa7CLEDv++SCH1AiLoX4rXbf/93rUgKc8wgurXp9k6X+T5SUSfP/WD5fl2ukVj7wVs gHcQ== X-Gm-Message-State: AOAM531lsNa1fetCdaLnzu6lURyrzZM4+mrFG9R09/s9zQMIhuDUH6np bxK/zgfNRXS8PAl4EgnkGJA= X-Google-Smtp-Source: ABdhPJx9dts17MJOV8t60RLZnQ59930CywzZYtUrIusIUerhoSSkQ3TsgPz+Zp8rumgIF9kJ78ATDA== X-Received: by 2002:a17:90b:3a85:b0:1b5:58c8:6d87 with SMTP id om5-20020a17090b3a8500b001b558c86d87mr3890077pjb.192.1645045438685; Wed, 16 Feb 2022 13:03:58 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:58 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , John Garry , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" , Yufen Yu , Yang Guang , Zhen Lei Subject: [PATCH v4 36/50] scsi: mvsas: Fix a set-but-not-used warning Date: Wed, 16 Feb 2022 13:02:19 -0800 Message-Id: <20220216210233.28774-37-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch fixes the following compiler warning: drivers/scsi/mvsas/mv_init.c: In function ‘mvs_pci_init’: drivers/scsi/mvsas/mv_init.c:497:30: warning: variable ‘mpi’ set but not used [-Wunused-but-set-variable] 497 | struct mvs_prv_info *mpi; | ^~~ Reviewed-by: Johannes Thumshirn Reviewed-by: John Garry Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/mvsas/mv_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 44df7c03aab8..35406abeb852 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -494,7 +494,6 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent) { unsigned int rc, nhost = 0; struct mvs_info *mvi; - struct mvs_prv_info *mpi; irq_handler_t irq_handler = mvs_interrupt; struct Scsi_Host *shost = NULL; const struct mvs_chip_info *chip; @@ -559,10 +558,13 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent) } nhost++; } while (nhost < chip->n_host); - mpi = (struct mvs_prv_info *)(SHOST_TO_SAS_HA(shost)->lldd_ha); #ifdef CONFIG_SCSI_MVSAS_TASKLET + { + struct mvs_prv_info *mpi = SHOST_TO_SAS_HA(shost)->lldd_ha; + tasklet_init(&(mpi->mv_tasklet), mvs_tasklet, (unsigned long)SHOST_TO_SAS_HA(shost)); + } #endif mvs_post_sas_ha_init(shost, chip); From patchwork Wed Feb 16 21:02:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 896C7C35275 for ; Wed, 16 Feb 2022 21:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbiBPVEj (ORCPT ); Wed, 16 Feb 2022 16:04:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbiBPVEN (ORCPT ); Wed, 16 Feb 2022 16:04:13 -0500 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1783B2B048B for ; Wed, 16 Feb 2022 13:04:01 -0800 (PST) Received: by mail-pl1-f178.google.com with SMTP id 10so2982615plj.1 for ; Wed, 16 Feb 2022 13:04:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lHPHxz+0fUNEna5QsRJQJZs6i2Z4BPsfQCMVcXEb8iM=; b=XAEDvup+kHjKiqJ49cLCkdprA0/V+hTo8SbM+grK/FQVZU1zWA1i/JiIvY9Rdm6YnV 7XLQdCPA5QP2+YI9AiIV+fGSvPQMyB9fAF3sE3nyzAftX2Styfjfe3MYY5Y6f/2VSOsA dok08ISJxsMYmdKRJI5Y2VXRkZoBwDLxZkFbR4qxYU5e1VxLHk7icgL3tYvf9nko10g2 NB89DbAm7DHmPQ86m346zu4qnkoXUSZikaIU/FO+jV5VPaz00nim2BUAo63WPGNKZf/0 DvTKy41XgON96YKA+38j+H6C87yfjlukx1UxYypf7I8r41lQEdJJKfJEPiFGPnKT00mG ZZ/Q== X-Gm-Message-State: AOAM531b624QqU5lGm1wX/0YeWwIwjQYTcr2xGwkCtWC6cBGb9UJY81S Aqs0yOBCcad8+t7OxNpK8GI= X-Google-Smtp-Source: ABdhPJwsOYhAA8+UgGu/scPVYkgkZmtMNm7P11s/pbYUhZ3Z3LYpURZBWzPRm5NfEb+XEq8QtbKXTw== X-Received: by 2002:a17:90a:1b04:b0:1b9:92e1:6264 with SMTP id q4-20020a17090a1b0400b001b992e16264mr3880170pjq.116.1645045440422; Wed, 16 Feb 2022 13:04:00 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:03:59 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 37/50] scsi: mvumi: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:20 -0800 Message-Id: <20220216210233.28774-38-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/mvumi.c | 9 +++++---- drivers/scsi/mvumi.h | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 904de62c974c..05d3ce9b72db 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -1302,7 +1302,7 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd, { struct scsi_cmnd *scmd = cmd->scmd; - cmd->scmd->SCp.ptr = NULL; + mvumi_priv(cmd->scmd)->cmd_priv = NULL; scmd->result = ob_frame->req_status; switch (ob_frame->req_status) { @@ -2097,7 +2097,7 @@ static int mvumi_queue_command(struct Scsi_Host *shost, goto out_return_cmd; cmd->scmd = scmd; - scmd->SCp.ptr = (char *) cmd; + mvumi_priv(scmd)->cmd_priv = cmd; mhba->instancet->fire_cmd(mhba, cmd); spin_unlock_irqrestore(shost->host_lock, irq_flags); return 0; @@ -2111,7 +2111,7 @@ static int mvumi_queue_command(struct Scsi_Host *shost, static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd) { - struct mvumi_cmd *cmd = (struct mvumi_cmd *) scmd->SCp.ptr; + struct mvumi_cmd *cmd = mvumi_priv(scmd)->cmd_priv; struct Scsi_Host *host = scmd->device->host; struct mvumi_hba *mhba = shost_priv(host); unsigned long flags; @@ -2128,7 +2128,7 @@ static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd) atomic_dec(&mhba->fw_outstanding); scmd->result = (DID_ABORT << 16); - scmd->SCp.ptr = NULL; + mvumi_priv(scmd)->cmd_priv = NULL; if (scsi_bufflen(scmd)) { dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd), scsi_sg_count(scmd), @@ -2179,6 +2179,7 @@ static struct scsi_host_template mvumi_template = { .bios_param = mvumi_bios_param, .dma_boundary = PAGE_SIZE - 1, .this_id = -1, + .cmd_size = sizeof(struct mvumi_cmd_priv), }; static int mvumi_cfg_hw_reg(struct mvumi_hba *mhba) diff --git a/drivers/scsi/mvumi.h b/drivers/scsi/mvumi.h index 60d5691fc4ab..a88c58787b68 100644 --- a/drivers/scsi/mvumi.h +++ b/drivers/scsi/mvumi.h @@ -254,6 +254,15 @@ struct mvumi_cmd { unsigned char cmd_status; }; +struct mvumi_cmd_priv { + struct mvumi_cmd *cmd_priv; +}; + +static inline struct mvumi_cmd_priv *mvumi_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + /* * the function type of the in bound frame */ From patchwork Wed Feb 16 21:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 954E7C4332F for ; Wed, 16 Feb 2022 21:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235071AbiBPVEh (ORCPT ); Wed, 16 Feb 2022 16:04:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbiBPVEQ (ORCPT ); Wed, 16 Feb 2022 16:04:16 -0500 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3162B04A9 for ; Wed, 16 Feb 2022 13:04:02 -0800 (PST) Received: by mail-pl1-f169.google.com with SMTP id c3so2965653pls.5 for ; Wed, 16 Feb 2022 13:04:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tnHuLBSxaziml5aSmalKdD+1YoupdlPfcjSx6lYIiq0=; b=tdFFj8cWkpfHFL88SvGpkhsdolGwUptUlku5R/q74vXG0qNNtbPTno2gWKqrs1Rjc8 XH4kZd+kaWCPthTkY/AeslcZ79mR82uBuSHd4dCKIbx5s81LO+Klei6VjGHkmrhWcHhg DwOrBHfor8H+xMQRSYbRVyyWYTfkiOlfHVYPXXdkjYKMLAE+1xnXf9P1q+StmnZkP4k5 HDkplaCdmDlpwxt4PGrnpZTJsmb5D5uhC5bIGRB1FMu/Vz+XsJk3ABOKPo0GSUxXFGZn Cj0pMGyiktu0A3+KYUyLYxZ9mtX434nUh6zeNyF3fmCqS7As5CNYAr0o8Sc/JYZjhDMG wuSw== X-Gm-Message-State: AOAM5322n4qz8f/Yt6I1EzZAxNvS2smuF70ew9Prz5R5N3I/piFb7txD 3eN9Rq0317bVkeEsE56Wzxs= X-Google-Smtp-Source: ABdhPJyIcU4VTbuaxMTEMZ1ghKzIsAl99/H/nJaZwfWIt4g4enRmTgkmvek8uMYyWwXMZxAPqWxaCw== X-Received: by 2002:a17:90b:3698:b0:1b9:e011:b942 with SMTP id mj24-20020a17090b369800b001b9e011b942mr3814835pjb.189.1645045442056; Wed, 16 Feb 2022 13:04:02 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:01 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Hannes Reinecke , Himanshu Madhani , Masanori Goto , "James E.J. Bottomley" Subject: [PATCH v4 38/50] scsi: nsp32: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:21 -0800 Message-Id: <20220216210233.28774-39-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move the SCSI status field to private data. Stop setting the .ptr, .this_residual, .buffer and .buffer_residual SCSI pointer members since no code in this driver reads these members. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Reviewed-by: Masanori Goto Signed-off-by: Bart Van Assche --- drivers/scsi/nsp32.c | 20 +++++++------------- drivers/scsi/nsp32.h | 9 +++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index bd3ee3bf08ee..75bb0028ed74 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -273,6 +273,7 @@ static struct scsi_host_template nsp32_template = { .eh_abort_handler = nsp32_eh_abort, .eh_host_reset_handler = nsp32_eh_host_reset, /* .highmem_io = 1, */ + .cmd_size = sizeof(struct nsp32_cmd_priv), }; #include "nsp32_io.h" @@ -946,14 +947,9 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt) show_command(SCpnt); data->CurrentSC = SCpnt; - SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; + nsp32_priv(SCpnt)->status = SAM_STAT_CHECK_CONDITION; scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); - SCpnt->SCp.ptr = (char *)scsi_sglist(SCpnt); - SCpnt->SCp.this_residual = scsi_bufflen(SCpnt); - SCpnt->SCp.buffer = NULL; - SCpnt->SCp.buffers_residual = 0; - /* initialize data */ data->msgout_len = 0; data->msgin_len = 0; @@ -1376,7 +1372,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) case BUSPHASE_STATUS: nsp32_dbg(NSP32_DEBUG_INTR, "fifo/status"); - SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); + nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); break; default: @@ -1687,18 +1683,18 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) /* MsgIn 00: Command Complete */ nsp32_dbg(NSP32_DEBUG_BUSFREE, "command complete"); - SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); + nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); nsp32_dbg(NSP32_DEBUG_BUSFREE, "normal end stat=0x%x resid=0x%x\n", - SCpnt->SCp.Status, scsi_get_resid(SCpnt)); + nsp32_priv(SCpnt)->status, scsi_get_resid(SCpnt)); SCpnt->result = (DID_OK << 16) | - (SCpnt->SCp.Status << 0); + (nsp32_priv(SCpnt)->status << 0); nsp32_scsi_done(SCpnt); /* All operation is done */ return TRUE; } else if (execph & MSGIN_04_VALID) { /* MsgIn 04: Disconnect */ - SCpnt->SCp.Status = nsp32_read1(base, SCSI_CSB_IN); + nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); nsp32_dbg(NSP32_DEBUG_BUSFREE, "disconnect"); return TRUE; @@ -1706,8 +1702,6 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) /* Unexpected bus free */ nsp32_msg(KERN_WARNING, "unexpected bus free occurred"); - /* DID_ERROR? */ - //SCpnt->result = (DID_OK << 16) | (SCpnt->SCp.Status << 0); SCpnt->result = DID_ERROR << 16; nsp32_scsi_done(SCpnt); return TRUE; diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index ab0726c070f7..924889f8bd37 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h @@ -534,6 +534,15 @@ typedef struct _nsp32_sync_table { ---PERIOD-- ---OFFSET-- */ #define TO_SYNCREG(period, offset) (((period) & 0x0f) << 4 | ((offset) & 0x0f)) +struct nsp32_cmd_priv { + enum sam_status status; +}; + +static inline struct nsp32_cmd_priv *nsp32_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + typedef struct _nsp32_target { unsigned char syncreg; /* value for SYNCREG */ unsigned char ackwidth; /* value for ACKWIDTH */ From patchwork Wed Feb 16 21:02:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D41D6C4167B for ; Wed, 16 Feb 2022 21:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234444AbiBPVEi (ORCPT ); Wed, 16 Feb 2022 16:04:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234338AbiBPVES (ORCPT ); Wed, 16 Feb 2022 16:04:18 -0500 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FEE2B04B0 for ; Wed, 16 Feb 2022 13:04:04 -0800 (PST) Received: by mail-pf1-f180.google.com with SMTP id y11so181086pfi.11 for ; Wed, 16 Feb 2022 13:04:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A/S3KCrXBTTtSusQUVdYWBf1AOREHH7guodEm933rqA=; b=0qU6JdtKmLREZilqUBNZnG0cuF9yg4OfgXPwsP8nB/ITSJjIA5fdLhx2tZ+TkFD0K9 lxCs8qgC3vkmM0IoF/OxjCa4+yQDaKXz/JMFvYX12q77Aq3eR23I1m8AlYagXnfwR57x mvleiJVmBGyDGolfqMftWlHY7vxcmP/HV87i2ggHGApg8oS/Nz2k5Ckv1zqXmkctbUvZ 7xVB3/IO9uc+kqFJQFpXBlnObUq7rKc15/B6lq0sYfKX6GVDro449Sfx1ADtbBC1beyl L1H90SvGUd4SK+rqcBIq9pqfy644S302QmDPzpMBemHFZaYrw8e+TzSxKtjq5Y6J/vAu sSAw== X-Gm-Message-State: AOAM533nnAJ1D7m9OdEplsh30wj+FubKlgF5VcTLI9WMF0dKcNKTC4OD tKQQXL0IHOsfmzrouJZzFNA= X-Google-Smtp-Source: ABdhPJwOzUr0Ypm35O7TvCwjewOOY+g4cvL5psuKCMJrxzPJdYx8d3oSvF96odw2cpCYglG8mK+H9A== X-Received: by 2002:a05:6a00:1787:b0:4e0:6135:d5e8 with SMTP id s7-20020a056a00178700b004e06135d5e8mr773498pfg.55.1645045443712; Wed, 16 Feb 2022 13:04:03 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:03 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 39/50] scsi: nsp_cs: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:22 -0800 Message-Id: <20220216210233.28774-40-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer in struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/pcmcia/nsp_cs.c | 200 ++++++++++++++++++-------------- drivers/scsi/pcmcia/nsp_cs.h | 2 +- drivers/scsi/pcmcia/nsp_debug.c | 2 +- 3 files changed, 114 insertions(+), 90 deletions(-) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index dcffda384eaf..48acab03a8a0 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -70,6 +70,11 @@ static bool free_ports = 0; module_param(free_ports, bool, 0); MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))"); +static struct scsi_pointer *nsp_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static struct scsi_host_template nsp_driver_template = { .proc_name = "nsp_cs", .show_info = nsp_show_info, @@ -83,6 +88,7 @@ static struct scsi_host_template nsp_driver_template = { .this_id = NSP_INITIATOR_ID, .sg_tablesize = SG_ALL, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct scsi_pointer), }; static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ @@ -180,8 +186,9 @@ static void nsp_scsi_done(struct scsi_cmnd *SCpnt) scsi_done(SCpnt); } -static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt) +static int nsp_queuecommand_lck(struct scsi_cmnd *const SCpnt) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); #ifdef NSP_DEBUG /*unsigned int host_id = SCpnt->device->host->this_id;*/ /*unsigned int base = SCpnt->device->host->io_port;*/ @@ -217,11 +224,11 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt) data->CurrentSC = SCpnt; - SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; - SCpnt->SCp.Message = 0; - SCpnt->SCp.have_data_in = IO_UNKNOWN; - SCpnt->SCp.sent_command = 0; - SCpnt->SCp.phase = PH_UNDETERMINED; + scsi_pointer->Status = SAM_STAT_CHECK_CONDITION; + scsi_pointer->Message = 0; + scsi_pointer->have_data_in = IO_UNKNOWN; + scsi_pointer->sent_command = 0; + scsi_pointer->phase = PH_UNDETERMINED; scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); /* setup scratch area @@ -231,15 +238,15 @@ static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt) SCp.buffers_residual : left buffers in list SCp.phase : current state of the command */ if (scsi_bufflen(SCpnt)) { - SCpnt->SCp.buffer = scsi_sglist(SCpnt); - SCpnt->SCp.ptr = BUFFER_ADDR; - SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; - SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; + scsi_pointer->buffer = scsi_sglist(SCpnt); + scsi_pointer->ptr = BUFFER_ADDR(SCpnt); + scsi_pointer->this_residual = scsi_pointer->buffer->length; + scsi_pointer->buffers_residual = scsi_sg_count(SCpnt) - 1; } else { - SCpnt->SCp.ptr = NULL; - SCpnt->SCp.this_residual = 0; - SCpnt->SCp.buffer = NULL; - SCpnt->SCp.buffers_residual = 0; + scsi_pointer->ptr = NULL; + scsi_pointer->this_residual = 0; + scsi_pointer->buffer = NULL; + scsi_pointer->buffers_residual = 0; } if (!nsphw_start_selection(SCpnt)) { @@ -353,8 +360,9 @@ static void nsphw_init(nsp_hw_data *data) /* * Start selection phase */ -static bool nsphw_start_selection(struct scsi_cmnd *SCpnt) +static bool nsphw_start_selection(struct scsi_cmnd *const SCpnt) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); unsigned int host_id = SCpnt->device->host->this_id; unsigned int base = SCpnt->device->host->io_port; unsigned char target = scmd_id(SCpnt); @@ -372,7 +380,7 @@ static bool nsphw_start_selection(struct scsi_cmnd *SCpnt) /* start arbitration */ //nsp_dbg(NSP_DEBUG_RESELECTION, "start arbit"); - SCpnt->SCp.phase = PH_ARBSTART; + scsi_pointer->phase = PH_ARBSTART; nsp_index_write(base, SETARBIT, ARBIT_GO); time_out = 1000; @@ -392,7 +400,7 @@ static bool nsphw_start_selection(struct scsi_cmnd *SCpnt) /* assert select line */ //nsp_dbg(NSP_DEBUG_RESELECTION, "assert SEL line"); - SCpnt->SCp.phase = PH_SELSTART; + scsi_pointer->phase = PH_SELSTART; udelay(3); /* wait 2.4us */ nsp_index_write(base, SCSIDATALATCH, BIT(host_id) | BIT(target)); nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_ATN); @@ -568,8 +576,9 @@ static int nsp_expect_signal(struct scsi_cmnd *SCpnt, /* * transfer SCSI message */ -static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase) +static int nsp_xfer(struct scsi_cmnd *const SCpnt, int phase) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); unsigned int base = SCpnt->device->host->io_port; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; char *buf = data->MsgBuffer; @@ -587,7 +596,7 @@ static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase) } /* if last byte, negate ATN */ - if (len == 1 && SCpnt->SCp.phase == PH_MSG_OUT) { + if (len == 1 && scsi_pointer->phase == PH_MSG_OUT) { nsp_index_write(base, SCSIBUSCTRL, AUTODIRECTION | ACKENB); } @@ -608,14 +617,15 @@ static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase) /* * get extra SCSI data from fifo */ -static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt) +static int nsp_dataphase_bypass(struct scsi_cmnd *const SCpnt) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; unsigned int count; //nsp_dbg(NSP_DEBUG_DATA_IO, "in"); - if (SCpnt->SCp.have_data_in != IO_IN) { + if (scsi_pointer->have_data_in != IO_IN) { return 0; } @@ -630,7 +640,7 @@ static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt) * data phase skip only occures in case of SCSI_LOW_READ */ nsp_dbg(NSP_DEBUG_DATA_IO, "use bypass quirk"); - SCpnt->SCp.phase = PH_DATA; + scsi_pointer->phase = PH_DATA; nsp_pio_read(SCpnt); nsp_setup_fifo(data, false); @@ -704,8 +714,9 @@ static int nsp_fifo_count(struct scsi_cmnd *SCpnt) /* * read data in DATA IN phase */ -static void nsp_pio_read(struct scsi_cmnd *SCpnt) +static void nsp_pio_read(struct scsi_cmnd *const SCpnt) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); unsigned int base = SCpnt->device->host->io_port; unsigned long mmio_base = SCpnt->device->host->base; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -716,24 +727,25 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) ocount = data->FifoCount; nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p resid=%d ocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d", - SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt->SCp.ptr, - SCpnt->SCp.this_residual, SCpnt->SCp.buffer, - SCpnt->SCp.buffers_residual); + SCpnt, scsi_get_resid(SCpnt), ocount, scsi_pointer->ptr, + scsi_pointer->this_residual, scsi_pointer->buffer, + scsi_pointer->buffers_residual); time_out = 1000; while ((time_out-- != 0) && - (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0 ) ) { + (scsi_pointer->this_residual > 0 || + scsi_pointer->buffers_residual > 0)) { stat = nsp_index_read(base, SCSIBUSMON); stat &= BUSMON_PHASE_MASK; res = nsp_fifo_count(SCpnt) - ocount; - //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x ocount=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, ocount, res); + //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x ocount=0x%x res=0x%x", scsi_pointer->ptr, scsi_pointer->this_residual, ocount, res); if (res == 0) { /* if some data available ? */ if (stat == BUSPHASE_DATA_IN) { /* phase changed? */ - //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", SCpnt->SCp.this_residual); + //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", scsi_pointer->this_residual); continue; } else { nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x", stat); @@ -747,20 +759,21 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) continue; } - res = min(res, SCpnt->SCp.this_residual); + res = min(res, scsi_pointer->this_residual); switch (data->TransferMode) { case MODE_IO32: res &= ~(BIT(1)|BIT(0)); /* align 4 */ - nsp_fifo32_read(base, SCpnt->SCp.ptr, res >> 2); + nsp_fifo32_read(base, scsi_pointer->ptr, res >> 2); break; case MODE_IO8: - nsp_fifo8_read (base, SCpnt->SCp.ptr, res ); + nsp_fifo8_read(base, scsi_pointer->ptr, res); break; case MODE_MEM32: res &= ~(BIT(1)|BIT(0)); /* align 4 */ - nsp_mmio_fifo32_read(mmio_base, SCpnt->SCp.ptr, res >> 2); + nsp_mmio_fifo32_read(mmio_base, scsi_pointer->ptr, + res >> 2); break; default: @@ -769,22 +782,23 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) } nsp_inc_resid(SCpnt, -res); - SCpnt->SCp.ptr += res; - SCpnt->SCp.this_residual -= res; + scsi_pointer->ptr += res; + scsi_pointer->this_residual -= res; ocount += res; - //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this_residual=0x%x ocount=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, ocount); + //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this_residual=0x%x ocount=0x%x", scsi_pointer->ptr, scsi_pointer->this_residual, ocount); /* go to next scatter list if available */ - if (SCpnt->SCp.this_residual == 0 && - SCpnt->SCp.buffers_residual != 0 ) { + if (scsi_pointer->this_residual == 0 && + scsi_pointer->buffers_residual != 0 ) { //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next timeout=%d", time_out); - SCpnt->SCp.buffers_residual--; - SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); - SCpnt->SCp.ptr = BUFFER_ADDR; - SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; + scsi_pointer->buffers_residual--; + scsi_pointer->buffer = sg_next(scsi_pointer->buffer); + scsi_pointer->ptr = BUFFER_ADDR(SCpnt); + scsi_pointer->this_residual = + scsi_pointer->buffer->length; time_out = 1000; - //nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", SCpnt->SCp.buffer->page, SCpnt->SCp.buffer->offset); + //nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", scsi_pointer->buffer->page, scsi_pointer->buffer->offset); } } @@ -792,8 +806,8 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) if (time_out < 0) { nsp_msg(KERN_DEBUG, "pio read timeout resid=%d this_residual=%d buffers_residual=%d", - scsi_get_resid(SCpnt), SCpnt->SCp.this_residual, - SCpnt->SCp.buffers_residual); + scsi_get_resid(SCpnt), scsi_pointer->this_residual, + scsi_pointer->buffers_residual); } nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount); nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, @@ -805,6 +819,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt) */ static void nsp_pio_write(struct scsi_cmnd *SCpnt) { + struct scsi_pointer *scsi_pointer = nsp_priv(SCpnt); unsigned int base = SCpnt->device->host->io_port; unsigned long mmio_base = SCpnt->device->host->base; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -815,14 +830,15 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt) ocount = data->FifoCount; nsp_dbg(NSP_DEBUG_DATA_IO, "in fifocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d resid=0x%x", - data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, - SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, + data->FifoCount, scsi_pointer->ptr, scsi_pointer->this_residual, + scsi_pointer->buffer, scsi_pointer->buffers_residual, scsi_get_resid(SCpnt)); time_out = 1000; while ((time_out-- != 0) && - (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0)) { + (scsi_pointer->this_residual > 0 || + scsi_pointer->buffers_residual > 0)) { stat = nsp_index_read(base, SCSIBUSMON); stat &= BUSMON_PHASE_MASK; @@ -832,9 +848,9 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt) nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res); /* Put back pointer */ nsp_inc_resid(SCpnt, res); - SCpnt->SCp.ptr -= res; - SCpnt->SCp.this_residual += res; - ocount -= res; + scsi_pointer->ptr -= res; + scsi_pointer->this_residual += res; + ocount -= res; break; } @@ -845,21 +861,22 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt) continue; } - res = min(SCpnt->SCp.this_residual, WFIFO_CRIT); + res = min(scsi_pointer->this_residual, WFIFO_CRIT); - //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, res); + //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x res=0x%x", scsi_pointer->ptr, scsi_pointer->this_residual, res); switch (data->TransferMode) { case MODE_IO32: res &= ~(BIT(1)|BIT(0)); /* align 4 */ - nsp_fifo32_write(base, SCpnt->SCp.ptr, res >> 2); + nsp_fifo32_write(base, scsi_pointer->ptr, res >> 2); break; case MODE_IO8: - nsp_fifo8_write (base, SCpnt->SCp.ptr, res ); + nsp_fifo8_write(base, scsi_pointer->ptr, res); break; case MODE_MEM32: res &= ~(BIT(1)|BIT(0)); /* align 4 */ - nsp_mmio_fifo32_write(mmio_base, SCpnt->SCp.ptr, res >> 2); + nsp_mmio_fifo32_write(mmio_base, scsi_pointer->ptr, + res >> 2); break; default: @@ -868,18 +885,19 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt) } nsp_inc_resid(SCpnt, -res); - SCpnt->SCp.ptr += res; - SCpnt->SCp.this_residual -= res; - ocount += res; + scsi_pointer->ptr += res; + scsi_pointer->this_residual -= res; + ocount += res; /* go to next scatter list if available */ - if (SCpnt->SCp.this_residual == 0 && - SCpnt->SCp.buffers_residual != 0 ) { + if (scsi_pointer->this_residual == 0 && + scsi_pointer->buffers_residual != 0 ) { //nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next"); - SCpnt->SCp.buffers_residual--; - SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); - SCpnt->SCp.ptr = BUFFER_ADDR; - SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; + scsi_pointer->buffers_residual--; + scsi_pointer->buffer = sg_next(scsi_pointer->buffer); + scsi_pointer->ptr = BUFFER_ADDR(SCpnt); + scsi_pointer->this_residual = + scsi_pointer->buffer->length; time_out = 1000; } } @@ -947,6 +965,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) unsigned int base; unsigned char irq_status, irq_phase, phase; struct scsi_cmnd *tmpSC; + struct scsi_pointer *scsi_pointer; unsigned char target, lun; unsigned int *sync_neg; int i, tmp; @@ -1025,9 +1044,10 @@ static irqreturn_t nspintr(int irq, void *dev_id) if(data->CurrentSC != NULL) { tmpSC = data->CurrentSC; - tmpSC->result = (DID_RESET << 16) | - ((tmpSC->SCp.Message & 0xff) << 8) | - ((tmpSC->SCp.Status & 0xff) << 0); + scsi_pointer = nsp_priv(tmpSC); + tmpSC->result = (DID_RESET << 16) | + ((scsi_pointer->Message & 0xff) << 8) | + ((scsi_pointer->Status & 0xff) << 0); nsp_scsi_done(tmpSC); } return IRQ_HANDLED; @@ -1041,6 +1061,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) } tmpSC = data->CurrentSC; + scsi_pointer = nsp_priv(tmpSC); target = tmpSC->device->id; lun = tmpSC->device->lun; sync_neg = &(data->Sync[target].SyncNegotiation); @@ -1063,7 +1084,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) //show_phase(tmpSC); - switch(tmpSC->SCp.phase) { + switch (scsi_pointer->phase) { case PH_SELSTART: // *sync_neg = SYNC_NOT_YET; if ((phase & BUSMON_BSY) == 0) { @@ -1086,7 +1107,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) /* attention assert */ //nsp_dbg(NSP_DEBUG_INTR, "attention assert"); data->SelectionTimeOut = 0; - tmpSC->SCp.phase = PH_SELECTED; + scsi_pointer->phase = PH_SELECTED; nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN); udelay(1); nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN | AUTODIRECTION | ACKENB); @@ -1115,17 +1136,18 @@ static irqreturn_t nspintr(int irq, void *dev_id) //nsp_dbg(NSP_DEBUG_INTR, "start scsi seq"); /* normal disconnect */ - if (((tmpSC->SCp.phase == PH_MSG_IN) || (tmpSC->SCp.phase == PH_MSG_OUT)) && - (irq_phase & LATCHED_BUS_FREE) != 0 ) { + if ((scsi_pointer->phase == PH_MSG_IN || + scsi_pointer->phase == PH_MSG_OUT) && + (irq_phase & LATCHED_BUS_FREE) != 0) { nsp_dbg(NSP_DEBUG_INTR, "normal disconnect irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_status, phase, irq_phase); //*sync_neg = SYNC_NOT_YET; /* all command complete and return status */ - if (tmpSC->SCp.Message == COMMAND_COMPLETE) { - tmpSC->result = (DID_OK << 16) | - ((tmpSC->SCp.Message & 0xff) << 8) | - ((tmpSC->SCp.Status & 0xff) << 0); + if (scsi_pointer->Message == COMMAND_COMPLETE) { + tmpSC->result = (DID_OK << 16) | + ((scsi_pointer->Message & 0xff) << 8) | + ((scsi_pointer->Status & 0xff) << 0); nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->result); nsp_scsi_done(tmpSC); @@ -1154,7 +1176,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) return IRQ_HANDLED; } - tmpSC->SCp.phase = PH_COMMAND; + scsi_pointer->phase = PH_COMMAND; nsp_nexus(tmpSC); @@ -1170,8 +1192,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) case BUSPHASE_DATA_OUT: nsp_dbg(NSP_DEBUG_INTR, "BUSPHASE_DATA_OUT"); - tmpSC->SCp.phase = PH_DATA; - tmpSC->SCp.have_data_in = IO_OUT; + scsi_pointer->phase = PH_DATA; + scsi_pointer->have_data_in = IO_OUT; nsp_pio_write(tmpSC); @@ -1180,8 +1202,8 @@ static irqreturn_t nspintr(int irq, void *dev_id) case BUSPHASE_DATA_IN: nsp_dbg(NSP_DEBUG_INTR, "BUSPHASE_DATA_IN"); - tmpSC->SCp.phase = PH_DATA; - tmpSC->SCp.have_data_in = IO_IN; + scsi_pointer->phase = PH_DATA; + scsi_pointer->have_data_in = IO_IN; nsp_pio_read(tmpSC); @@ -1191,10 +1213,11 @@ static irqreturn_t nspintr(int irq, void *dev_id) nsp_dataphase_bypass(tmpSC); nsp_dbg(NSP_DEBUG_INTR, "BUSPHASE_STATUS"); - tmpSC->SCp.phase = PH_STATUS; + scsi_pointer->phase = PH_STATUS; - tmpSC->SCp.Status = nsp_index_read(base, SCSIDATAWITHACK); - nsp_dbg(NSP_DEBUG_INTR, "message=0x%x status=0x%x", tmpSC->SCp.Message, tmpSC->SCp.Status); + scsi_pointer->Status = nsp_index_read(base, SCSIDATAWITHACK); + nsp_dbg(NSP_DEBUG_INTR, "message=0x%x status=0x%x", + scsi_pointer->Message, scsi_pointer->Status); break; @@ -1204,7 +1227,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) goto timer_out; } - tmpSC->SCp.phase = PH_MSG_OUT; + scsi_pointer->phase = PH_MSG_OUT; //*sync_neg = SYNC_NOT_YET; @@ -1237,7 +1260,7 @@ static irqreturn_t nspintr(int irq, void *dev_id) goto timer_out; } - tmpSC->SCp.phase = PH_MSG_IN; + scsi_pointer->phase = PH_MSG_IN; nsp_message_in(tmpSC); /**/ @@ -1269,9 +1292,10 @@ static irqreturn_t nspintr(int irq, void *dev_id) i += (1 + data->MsgBuffer[i+1]); } } - tmpSC->SCp.Message = tmp; + scsi_pointer->Message = tmp; - nsp_dbg(NSP_DEBUG_INTR, "message=0x%x len=%d", tmpSC->SCp.Message, data->MsgLen); + nsp_dbg(NSP_DEBUG_INTR, "message=0x%x len=%d", + scsi_pointer->Message, data->MsgLen); show_message(data); break; diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 7d5d1a5b36e0..e1ee8ef90ad3 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -371,7 +371,7 @@ enum _burst_mode { }; /* scatter-gather table */ -# define BUFFER_ADDR ((char *)((sg_virt(SCpnt->SCp.buffer)))) +#define BUFFER_ADDR(SCpnt) ((char *)(sg_virt(nsp_priv(SCpnt)->buffer))) #endif /*__nsp_cs__*/ /* end */ diff --git a/drivers/scsi/pcmcia/nsp_debug.c b/drivers/scsi/pcmcia/nsp_debug.c index 6aa7d269d3b3..23b68dd26f74 100644 --- a/drivers/scsi/pcmcia/nsp_debug.c +++ b/drivers/scsi/pcmcia/nsp_debug.c @@ -145,7 +145,7 @@ static void show_command(struct scsi_cmnd *SCpnt) static void show_phase(struct scsi_cmnd *SCpnt) { - int i = SCpnt->SCp.phase; + int i = nsp_scsi_pointer(SCpnt)->phase; char *ph[] = { "PH_UNDETERMINED", From patchwork Wed Feb 16 21:02:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82768C433F5 for ; Wed, 16 Feb 2022 21:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234478AbiBPVFC (ORCPT ); Wed, 16 Feb 2022 16:05:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbiBPVEc (ORCPT ); Wed, 16 Feb 2022 16:04:32 -0500 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849182B0B05 for ; Wed, 16 Feb 2022 13:04:07 -0800 (PST) Received: by mail-pl1-f177.google.com with SMTP id l9so3002575plg.0 for ; Wed, 16 Feb 2022 13:04:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KZRyurWwIUCUHUSCOl7sC1WUzmpUgrP0RhTAYS0PbCg=; b=ImGfd+xlZqDBfbykfQLr4fBsTLRpiVR2xKl2RPoh6KI13PvHQwMwlijowYiZqb6FLw v3KudnBrf5JpLsM7iGFrzK5SAT5UeD1MkdUrALHOtKeSwD7AnUUHxm6PbhmjyKDEH+Wo rzCVm1oU5lVPQovfRZT7xchrzCkPKpP0+kGn9tc+KWLNwOw8RLUkbEiZlvDEF/SShBXH CKJ5SgQhlb3I67/5pDOMoiqKYgVHKz5KaeqZj8yDNfSB0iMVbJXOvZ6l6SyvGnZzAILH A3U2Nk3eH8dyYNJSLMvkHndxse3oMgMjiqB1qlIV27Z1Nn9ASMuptmNSboNSFe7nENlI QXDg== X-Gm-Message-State: AOAM530gwqVthyAXkLJ/BW6GjffwOMyJ2DZ1myNjnuYNsuTBGuHxlm9O BJEocZDfmGSNjMF6EzlJHNnKziqu10O6DyKb X-Google-Smtp-Source: ABdhPJz5foX2JczzXFZUoINo5kDW6gk80YRBiNxU9E3kcCLlWAJr7voI5zM3y9g4n3Vih6w7lPm6OQ== X-Received: by 2002:a17:90b:4a92:b0:1b8:a3c5:1afe with SMTP id lp18-20020a17090b4a9200b001b8a3c51afemr3878460pjb.69.1645045446841; Wed, 16 Feb 2022 13:04:06 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:06 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 40/50] scsi: sym53c500_cs: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:23 -0800 Message-Id: <20220216210233.28774-41-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/pcmcia/sym53c500_cs.c | 47 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index fc93d2a57e1e..c4a838635893 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -192,6 +192,11 @@ struct sym53c500_data { int fast_pio; }; +static struct scsi_pointer *sym53c500_scsi_pointer(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + enum Phase { idle, data_out, @@ -351,6 +356,7 @@ SYM53C500_intr(int irq, void *dev_id) struct sym53c500_data *data = (struct sym53c500_data *)dev->hostdata; struct scsi_cmnd *curSC = data->current_SC; + struct scsi_pointer *scsi_pointer = sym53c500_scsi_pointer(curSC); int fast_pio = data->fast_pio; spin_lock_irqsave(dev->host_lock, flags); @@ -397,11 +403,12 @@ SYM53C500_intr(int irq, void *dev_id) if (int_reg & 0x20) { /* Disconnect */ DEB(printk("SYM53C500: disconnect intr received\n")); - if (curSC->SCp.phase != message_in) { /* Unexpected disconnect */ + if (scsi_pointer->phase != message_in) { /* Unexpected disconnect */ curSC->result = DID_NO_CONNECT << 16; } else { /* Command complete, return status and message */ - curSC->result = (curSC->SCp.Status & 0xff) - | ((curSC->SCp.Message & 0xff) << 8) | (DID_OK << 16); + curSC->result = (scsi_pointer->Status & 0xff) | + ((scsi_pointer->Message & 0xff) << 8) | + (DID_OK << 16); } goto idle_out; } @@ -412,7 +419,7 @@ SYM53C500_intr(int irq, void *dev_id) struct scatterlist *sg; int i; - curSC->SCp.phase = data_out; + scsi_pointer->phase = data_out; VDEB(printk("SYM53C500: Data-Out phase\n")); outb(FLUSH_FIFO, port_base + CMD_REG); LOAD_DMA_COUNT(port_base, scsi_bufflen(curSC)); /* Max transfer size */ @@ -431,7 +438,7 @@ SYM53C500_intr(int irq, void *dev_id) struct scatterlist *sg; int i; - curSC->SCp.phase = data_in; + scsi_pointer->phase = data_in; VDEB(printk("SYM53C500: Data-In phase\n")); outb(FLUSH_FIFO, port_base + CMD_REG); LOAD_DMA_COUNT(port_base, scsi_bufflen(curSC)); /* Max transfer size */ @@ -446,12 +453,12 @@ SYM53C500_intr(int irq, void *dev_id) break; case 0x02: /* COMMAND */ - curSC->SCp.phase = command_ph; + scsi_pointer->phase = command_ph; printk("SYM53C500: Warning: Unknown interrupt occurred in command phase!\n"); break; case 0x03: /* STATUS */ - curSC->SCp.phase = status_ph; + scsi_pointer->phase = status_ph; VDEB(printk("SYM53C500: Status phase\n")); outb(FLUSH_FIFO, port_base + CMD_REG); outb(INIT_CMD_COMPLETE, port_base + CMD_REG); @@ -464,22 +471,24 @@ SYM53C500_intr(int irq, void *dev_id) case 0x06: /* MESSAGE-OUT */ DEB(printk("SYM53C500: Message-Out phase\n")); - curSC->SCp.phase = message_out; + scsi_pointer->phase = message_out; outb(SET_ATN, port_base + CMD_REG); /* Reject the message */ outb(MSG_ACCEPT, port_base + CMD_REG); break; case 0x07: /* MESSAGE-IN */ VDEB(printk("SYM53C500: Message-In phase\n")); - curSC->SCp.phase = message_in; + scsi_pointer->phase = message_in; - curSC->SCp.Status = inb(port_base + SCSI_FIFO); - curSC->SCp.Message = inb(port_base + SCSI_FIFO); + scsi_pointer->Status = inb(port_base + SCSI_FIFO); + scsi_pointer->Message = inb(port_base + SCSI_FIFO); VDEB(printk("SCSI FIFO size=%d\n", inb(port_base + FIFO_FLAGS) & 0x1f)); - DEB(printk("Status = %02x Message = %02x\n", curSC->SCp.Status, curSC->SCp.Message)); + DEB(printk("Status = %02x Message = %02x\n", + scsi_pointer->Status, scsi_pointer->Message)); - if (curSC->SCp.Message == SAVE_POINTERS || curSC->SCp.Message == DISCONNECT) { + if (scsi_pointer->Message == SAVE_POINTERS || + scsi_pointer->Message == DISCONNECT) { outb(SET_ATN, port_base + CMD_REG); /* Reject message */ DEB(printk("Discarding SAVE_POINTERS message\n")); } @@ -491,7 +500,7 @@ SYM53C500_intr(int irq, void *dev_id) return IRQ_HANDLED; idle_out: - curSC->SCp.phase = idle; + scsi_pointer->phase = idle; scsi_done(curSC); goto out; } @@ -539,6 +548,7 @@ SYM53C500_info(struct Scsi_Host *SChost) static int SYM53C500_queue_lck(struct scsi_cmnd *SCpnt) { + struct scsi_pointer *scsi_pointer = sym53c500_scsi_pointer(SCpnt); int i; int port_base = SCpnt->device->host->io_port; struct sym53c500_data *data = @@ -555,9 +565,9 @@ static int SYM53C500_queue_lck(struct scsi_cmnd *SCpnt) VDEB(printk("\n")); data->current_SC = SCpnt; - data->current_SC->SCp.phase = command_ph; - data->current_SC->SCp.Status = 0; - data->current_SC->SCp.Message = 0; + scsi_pointer->phase = command_ph; + scsi_pointer->Status = 0; + scsi_pointer->Message = 0; /* We are locked here already by the mid layer */ REG0(port_base); @@ -671,7 +681,8 @@ static struct scsi_host_template sym53c500_driver_template = { .can_queue = 1, .this_id = 7, .sg_tablesize = 32, - .shost_groups = SYM53C500_shost_groups + .shost_groups = SYM53C500_shost_groups, + .cmd_size = sizeof(struct scsi_pointer), }; static int SYM53C500_config_check(struct pcmcia_device *p_dev, void *priv_data) From patchwork Wed Feb 16 21:02:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D58BC433EF for ; Wed, 16 Feb 2022 21:04:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234409AbiBPVFA (ORCPT ); Wed, 16 Feb 2022 16:05:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234536AbiBPVEc (ORCPT ); Wed, 16 Feb 2022 16:04:32 -0500 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E8002B0B08 for ; Wed, 16 Feb 2022 13:04:09 -0800 (PST) Received: by mail-pj1-f42.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so7549003pja.3 for ; Wed, 16 Feb 2022 13:04:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B/rU5Uug+wbiRRO+qJny3vIUPXj+4jiEJ1epi+oHgJs=; b=0h5a4SIQnTwFhvh/7/9I6poFgSALx3JF2qOU2cbSijVsfpfn5qFR9RNNZk3V9jcQOF 1MgQAie4YVzoH2b3VN7XLlos4ZGP1TdX66HNpk7kFMEXX5z7M17yrLaeeOgQfjOPkJv+ 53OuVqPGyksdjpSPn0m4syWDYqPN+9qlGJl7jZtlc46VrSv7f/jsvjX1nI/79QSsPn6X npB/j2wWnfFnjdLrckoZ93xH+YSDxd3WxloXmk+WYVu7wqwmPZDQEYFEoLi683b96D/I PQPKOfoO6bihs3DDDWaQ1QofXkipzfL25g6R5UcwFQu5uilJEicFnjTLql8pao5e7M/m FfSA== X-Gm-Message-State: AOAM531Oz24UOiCRzMeslfX+xx3aP4/lmrmI4cveKkMy+/S/XU/Mt0vJ m9yus/aQT0VVHKLzZuZAriU= X-Google-Smtp-Source: ABdhPJwEe1PJMNi1G42J9t7bbPb7FHoKv/y3NpskW/odGO5sg1SXWBtLGxy90nSon2nHGka6/OuK0A== X-Received: by 2002:a17:90a:ac1:b0:1b9:7dd3:ba5f with SMTP id r1-20020a17090a0ac100b001b97dd3ba5fmr3875372pje.178.1645045448408; Wed, 16 Feb 2022 13:04:08 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:07 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 41/50] scsi: ppa: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:24 -0800 Message-Id: <20220216210233.28774-42-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/ppa.c | 75 ++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 003043de23a5..00a68037e0e4 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -45,6 +45,11 @@ typedef struct { #include "ppa.h" +static struct scsi_pointer *ppa_scsi_pointer(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static inline ppa_struct *ppa_dev(struct Scsi_Host *host) { return *(ppa_struct **)&host->hostdata; @@ -56,7 +61,7 @@ static void got_it(ppa_struct *dev) { dev->base = dev->dev->port->base; if (dev->cur_cmd) - dev->cur_cmd->SCp.phase = 1; + ppa_scsi_pointer(dev->cur_cmd)->phase = 1; else wake_up(dev->waiting); } @@ -511,13 +516,14 @@ static inline int ppa_send_command(struct scsi_cmnd *cmd) * The driver appears to remain stable if we speed up the parallel port * i/o in this function, but not elsewhere. */ -static int ppa_completion(struct scsi_cmnd *cmd) +static int ppa_completion(struct scsi_cmnd *const cmd) { /* Return codes: * -1 Error * 0 Told to schedule * 1 Finished data transfer */ + struct scsi_pointer *scsi_pointer = ppa_scsi_pointer(cmd); ppa_struct *dev = ppa_dev(cmd->device->host); unsigned short ppb = dev->base; unsigned long start_jiffies = jiffies; @@ -543,7 +549,7 @@ static int ppa_completion(struct scsi_cmnd *cmd) if (time_after(jiffies, start_jiffies + 1)) return 0; - if ((cmd->SCp.this_residual <= 0)) { + if (scsi_pointer->this_residual <= 0) { ppa_fail(dev, DID_ERROR); return -1; /* ERROR_RETURN */ } @@ -572,28 +578,30 @@ static int ppa_completion(struct scsi_cmnd *cmd) } /* determine if we should use burst I/O */ - fast = (bulk && (cmd->SCp.this_residual >= PPA_BURST_SIZE)) - ? PPA_BURST_SIZE : 1; + fast = bulk && scsi_pointer->this_residual >= PPA_BURST_SIZE ? + PPA_BURST_SIZE : 1; if (r == (unsigned char) 0xc0) - status = ppa_out(dev, cmd->SCp.ptr, fast); + status = ppa_out(dev, scsi_pointer->ptr, fast); else - status = ppa_in(dev, cmd->SCp.ptr, fast); + status = ppa_in(dev, scsi_pointer->ptr, fast); - cmd->SCp.ptr += fast; - cmd->SCp.this_residual -= fast; + scsi_pointer->ptr += fast; + scsi_pointer->this_residual -= fast; if (!status) { ppa_fail(dev, DID_BUS_BUSY); return -1; /* ERROR_RETURN */ } - if (cmd->SCp.buffer && !cmd->SCp.this_residual) { + if (scsi_pointer->buffer && !scsi_pointer->this_residual) { /* if scatter/gather, advance to the next segment */ - if (cmd->SCp.buffers_residual--) { - cmd->SCp.buffer = sg_next(cmd->SCp.buffer); - cmd->SCp.this_residual = - cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + if (scsi_pointer->buffers_residual--) { + scsi_pointer->buffer = + sg_next(scsi_pointer->buffer); + scsi_pointer->this_residual = + scsi_pointer->buffer->length; + scsi_pointer->ptr = + sg_virt(scsi_pointer->buffer); } } /* Now check to see if the drive is ready to comunicate */ @@ -658,7 +666,7 @@ static void ppa_interrupt(struct work_struct *work) } #endif - if (cmd->SCp.phase > 1) + if (ppa_scsi_pointer(cmd)->phase > 1) ppa_disconnect(dev); ppa_pb_dismiss(dev); @@ -670,6 +678,7 @@ static void ppa_interrupt(struct work_struct *work) static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) { + struct scsi_pointer *scsi_pointer = ppa_scsi_pointer(cmd); unsigned short ppb = dev->base; unsigned char l = 0, h = 0; int retv; @@ -680,7 +689,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) if (dev->failed) return 0; - switch (cmd->SCp.phase) { + switch (scsi_pointer->phase) { case 0: /* Phase 0 - Waiting for parport */ if (time_after(jiffies, dev->jstart + HZ)) { /* @@ -715,7 +724,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) return 1; /* Try again in a jiffy */ } } - cmd->SCp.phase++; + scsi_pointer->phase++; } fallthrough; @@ -724,7 +733,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) ppa_fail(dev, DID_NO_CONNECT); return 0; } - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 3: /* Phase 3 - Ready to accept a command */ @@ -734,21 +743,22 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) if (!ppa_send_command(cmd)) return 0; - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 4: /* Phase 4 - Setup scatter/gather buffers */ if (scsi_bufflen(cmd)) { - cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + scsi_pointer->buffer = scsi_sglist(cmd); + scsi_pointer->this_residual = + scsi_pointer->buffer->length; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); } else { - cmd->SCp.buffer = NULL; - cmd->SCp.this_residual = 0; - cmd->SCp.ptr = NULL; + scsi_pointer->buffer = NULL; + scsi_pointer->this_residual = 0; + scsi_pointer->ptr = NULL; } - cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; - cmd->SCp.phase++; + scsi_pointer->buffers_residual = scsi_sg_count(cmd) - 1; + scsi_pointer->phase++; fallthrough; case 5: /* Phase 5 - Data transfer stage */ @@ -761,7 +771,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) return 0; if (retv == 0) return 1; - cmd->SCp.phase++; + scsi_pointer->phase++; fallthrough; case 6: /* Phase 6 - Read status/message */ @@ -798,7 +808,7 @@ static int ppa_queuecommand_lck(struct scsi_cmnd *cmd) dev->jstart = jiffies; dev->cur_cmd = cmd; cmd->result = DID_ERROR << 16; /* default return code */ - cmd->SCp.phase = 0; /* bus free */ + ppa_scsi_pointer(cmd)->phase = 0; /* bus free */ schedule_delayed_work(&dev->ppa_tq, 0); @@ -839,7 +849,7 @@ static int ppa_abort(struct scsi_cmnd *cmd) * have tied the SCSI_MESSAGE line high in the interface */ - switch (cmd->SCp.phase) { + switch (ppa_scsi_pointer(cmd)->phase) { case 0: /* Do not have access to parport */ case 1: /* Have not connected to interface */ dev->cur_cmd = NULL; /* Forget the problem */ @@ -861,7 +871,7 @@ static int ppa_reset(struct scsi_cmnd *cmd) { ppa_struct *dev = ppa_dev(cmd->device->host); - if (cmd->SCp.phase) + if (ppa_scsi_pointer(cmd)->phase) ppa_disconnect(dev); dev->cur_cmd = NULL; /* Forget the problem */ @@ -976,6 +986,7 @@ static struct scsi_host_template ppa_template = { .sg_tablesize = SG_ALL, .can_queue = 1, .slave_alloc = ppa_adjust_queue, + .cmd_size = sizeof(struct scsi_pointer), }; /*************************************************************************** From patchwork Wed Feb 16 21:02:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6111DC433FE for ; Wed, 16 Feb 2022 21:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234840AbiBPVE6 (ORCPT ); Wed, 16 Feb 2022 16:04:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234556AbiBPVEc (ORCPT ); Wed, 16 Feb 2022 16:04:32 -0500 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01E52B101A for ; Wed, 16 Feb 2022 13:04:10 -0800 (PST) Received: by mail-pl1-f169.google.com with SMTP id l8so2960412pls.7 for ; Wed, 16 Feb 2022 13:04:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cxknL8rORaVxDDihqRXFx1elb8NLsNOt5DCGPmZQq24=; b=fUW55DewVqp+huE1UbpF5ocPXd+alTGZOUZfdOe97lDkbwPyKXjs52flnz2Woo2UdN 0ml8bT54x0MKiWXwb6EF/XG0LQo4DjvalbTPvlP3fZorYTJmY/MpCPMlImpWBcPQ2jhg La8abe3t2UA5wrlGPZ+XQnpUM+5yKYESfEcr1ixstk2zQTQLDf7ktPsOYhNPR67+yMKk bapLe1/GjjQC6u5SxoVK3yJPBlinUWd7A+HC7Mr/Jkg8+FbRHqxAI69BfAzH2+lbzNbK q1cfa3VpdncCG1asmmuvrPUOavCfnnXVZbqXTPGxgG4X+t+NzPJMEz7itocByUNSg17P LFmg== X-Gm-Message-State: AOAM5336zDx3OMuDYvEKb5/ifTHOQ0cxCPvAGJmP++aAqG5FwR45Mlus QNyaZhO27GzZHGaJ0B+NpiQ= X-Google-Smtp-Source: ABdhPJxS0FrgNqjk+/AbgvZiKlr0mEDf8M24p0hoeo819Li04CgTeN2/ISVNjoZhftiihKd2Qvr0pg== X-Received: by 2002:a17:90a:c981:b0:1b8:b14b:6913 with SMTP id w1-20020a17090ac98100b001b8b14b6913mr3870074pjt.131.1645045450024; Wed, 16 Feb 2022 13:04:10 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:09 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 42/50] scsi: qla1280: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:25 -0800 Message-Id: <20220216210233.28774-43-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/qla1280.c | 21 ++++----------------- drivers/scsi/qla1280.h | 3 +-- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 1dc56f4c89d8..0ab595c0870a 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -477,13 +477,6 @@ __setup("qla1280=", qla1280_setup); #endif -/* - * We use the scsi_pointer structure that's included with each scsi_command - * to overlay our struct srb over it. qla1280_init() checks that a srb is not - * bigger than a scsi_pointer. - */ - -#define CMD_SP(Cmnd) &Cmnd->SCp #define CMD_CDBLEN(Cmnd) Cmnd->cmd_len #define CMD_CDBP(Cmnd) Cmnd->cmnd #define CMD_SNSP(Cmnd) Cmnd->sense_buffer @@ -693,7 +686,7 @@ static int qla1280_queuecommand_lck(struct scsi_cmnd *cmd) { struct Scsi_Host *host = cmd->device->host; struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; - struct srb *sp = (struct srb *)CMD_SP(cmd); + struct srb *sp = scsi_cmd_priv(cmd); int status; sp->cmd = cmd; @@ -828,7 +821,7 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) ENTER("qla1280_error_action"); ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata); - sp = (struct srb *)CMD_SP(cmd); + sp = scsi_cmd_priv(cmd); bus = SCSI_BUS_32(cmd); target = SCSI_TCN_32(cmd); lun = SCSI_LUN_32(cmd); @@ -3959,7 +3952,7 @@ __qla1280_print_scsi_cmd(struct scsi_cmnd *cmd) int i; ha = (struct scsi_qla_host *)host->hostdata; - sp = (struct srb *)CMD_SP(cmd); + sp = scsi_cmd_priv(cmd); printk("SCSI Command @= 0x%p, Handle=0x%p\n", cmd, CMD_HANDLE(cmd)); printk(" chan=%d, target = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd), @@ -3979,7 +3972,6 @@ __qla1280_print_scsi_cmd(struct scsi_cmnd *cmd) } */ printk(" tag=%d, transfersize=0x%x \n", scsi_cmd_to_rq(cmd)->tag, cmd->transfersize); - printk(" SP=0x%p\n", CMD_SP(cmd)); printk(" underflow size = 0x%x, direction=0x%x\n", cmd->underflow, cmd->sc_data_direction); } @@ -4139,6 +4131,7 @@ static struct scsi_host_template qla1280_driver_template = { .can_queue = MAX_OUTSTANDING_COMMANDS, .this_id = -1, .sg_tablesize = SG_ALL, + .cmd_size = sizeof(struct srb), }; @@ -4351,12 +4344,6 @@ static struct pci_driver qla1280_pci_driver = { static int __init qla1280_init(void) { - if (sizeof(struct srb) > sizeof(struct scsi_pointer)) { - printk(KERN_WARNING - "qla1280: struct srb too big, aborting\n"); - return -EINVAL; - } - #ifdef MODULE /* * If we are called as a module, the qla1280 pointer may not be null diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h index e7820b5bca38..d309e2ca14de 100644 --- a/drivers/scsi/qla1280.h +++ b/drivers/scsi/qla1280.h @@ -87,8 +87,7 @@ #define RESPONSE_ENTRY_CNT 63 /* Number of response entries. */ /* - * SCSI Request Block structure (sp) that is placed - * on cmd->SCp location of every I/O + * SCSI Request Block structure (sp) that occurs after each struct scsi_cmnd. */ struct srb { struct list_head list; /* (8/16) LU queue */ From patchwork Wed Feb 16 21:02:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543630 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E640CC433EF for ; Wed, 16 Feb 2022 21:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233634AbiBPVE4 (ORCPT ); Wed, 16 Feb 2022 16:04:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234011AbiBPVEd (ORCPT ); Wed, 16 Feb 2022 16:04:33 -0500 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76C5E2B1679 for ; Wed, 16 Feb 2022 13:04:12 -0800 (PST) Received: by mail-pl1-f176.google.com with SMTP id j4so2951754plj.8 for ; Wed, 16 Feb 2022 13:04:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nBwtGryv3+hjFI6gPofqHnRhTZ05RYrc/eDIGaEQe1I=; b=kSGrsv91IjDZW540efBzYIJccRkz+ekQ2tyCgD+2XHxk9ijji9a61jd2IzUEUp+qgz IYfjhg9mYcAn5foDBkDO0fVtAw5A0UCODCxRhou7gerfKaWaDsLzVByEubJtbYCC/F58 mwztTCPHXM3jESV8t0mYn1CO7HOWruSCNRMsq2TeEiDXyhQpkU2iJPxcUiw5xSUMIRVb ui/ds1lPsEhCNGYEt2GLpNOflEp+a55+XP8t340YpWKQFgI6HSfHSrS6Vqqq6ht+6MKA aMCwYhLlfyySCoJpD0CII06sOS3HZ4jbG0cFRfbh98hTGz0UJwVpNKaCC5yF8ONv93lu WVwQ== X-Gm-Message-State: AOAM533ONo3066xC0WxlvrFSQbHHjJVXevRc1PagowZM1qdrT5+gyAWj ODgx/Ka/SxICKkoyVifNDi8= X-Google-Smtp-Source: ABdhPJwTC6jV4sboA6BHVAtJ/YxLQFu03S6ovz9hTF5Fg97+HnuyXlNx9dU6+WAWO/mq/NA3I+vs7A== X-Received: by 2002:a17:90b:f0c:b0:1b9:c6b7:7cd6 with SMTP id br12-20020a17090b0f0c00b001b9c6b77cd6mr3780577pjb.231.1645045451829; Wed, 16 Feb 2022 13:04:11 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:11 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Nilesh Javali , "Ewan D . Milne" , Himanshu Madhani , Hannes Reinecke , Daniel Wagner , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" Subject: [PATCH v4 43/50] scsi: qla2xxx: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:26 -0800 Message-Id: <20220216210233.28774-44-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of using the SCp.ptr field to track whether or not a command is in flight, use the sp->type field to track this information. sp->type must be set for proper operation of the qla2xxx driver. See e.g. the switch (sp->type) statement in qla2x00_ct_entry(). This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: Nilesh Javali Cc: Ewan D. Milne Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Reviewed-by: Daniel Wagner Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 2 -- drivers/scsi/qla2xxx/qla_os.c | 13 +++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 47d7fa1c7ae8..174e80fbbdae 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -5201,8 +5201,6 @@ struct secure_flash_update_block_pk { #define QLA_DSDS_PER_IOCB 37 -#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) - #define QLA_SG_ALL 1024 enum nexus_wait_type { diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a4546346c18b..58c83525f006 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -739,7 +739,7 @@ void qla2x00_sp_compl(srb_t *sp, int res) /* kref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); cmd->result = res; - CMD_SP(cmd) = NULL; + sp->type = 0; scsi_done(cmd); if (comp) complete(comp); @@ -831,7 +831,7 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, int res) /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); cmd->result = res; - CMD_SP(cmd) = NULL; + sp->type = 0; scsi_done(cmd); if (comp) complete(comp); @@ -934,8 +934,6 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) sp->u.scmd.cmd = cmd; sp->type = SRB_SCSI_CMD; - - CMD_SP(cmd) = (void *)sp; sp->free = qla2x00_sp_free_dma; sp->done = qla2x00_sp_compl; @@ -1025,7 +1023,6 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, sp->u.scmd.cmd = cmd; sp->type = SRB_SCSI_CMD; - CMD_SP(cmd) = (void *)sp; sp->free = qla2xxx_qpair_sp_free_dma; sp->done = qla2xxx_qpair_sp_compl; @@ -1071,6 +1068,7 @@ qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) unsigned long wait_iter = ABORT_WAIT_ITER; scsi_qla_host_t *vha = shost_priv(cmd->device->host); struct qla_hw_data *ha = vha->hw; + srb_t *sp = scsi_cmd_priv(cmd); int ret = QLA_SUCCESS; if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { @@ -1079,10 +1077,9 @@ qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) return ret; } - while (CMD_SP(cmd) && wait_iter--) { + while (sp->type && wait_iter--) msleep(ABORT_POLLING_PERIOD); - } - if (CMD_SP(cmd)) + if (sp->type) ret = QLA_FUNCTION_FAILED; return ret; From patchwork Wed Feb 16 21:02:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E71D2C433EF for ; Wed, 16 Feb 2022 21:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234753AbiBPVEk (ORCPT ); Wed, 16 Feb 2022 16:04:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234723AbiBPVEe (ORCPT ); Wed, 16 Feb 2022 16:04:34 -0500 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FCA2B1A83 for ; Wed, 16 Feb 2022 13:04:14 -0800 (PST) Received: by mail-pf1-f181.google.com with SMTP id d17so3236593pfl.0 for ; Wed, 16 Feb 2022 13:04:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rJEfpYZmesmFuk0UQfGK2rmVME1mv8OVxEoziN58YoM=; b=POy5dOKrdaBXmqKLt1qh1uMv6Bjh3hWl/b+AuW2a4hX1cSOyMJS2QD6DxRUA0KyOSJ rSdDc27HEll4j5oDcw5AzFA/Etn8kac/OvkwpzoFmWhwb7WMCtPw7ZrJkxDCtYChrxv2 uwSuVuCmhZkLDKW1riemPtOwfKiXYRr2pFO1EFcJUoM6T5nms3ffQZkb1PcL3TQGEtbg UO/Q6z0ny3PHy84+LFpuidi3Xq/lK42jvj1/wOPsJVBz1mqvTds6FFhQgRP4zHj0WLW3 pqhU7Pnmtl0tEfv3TBRXhD3qeSMzWm4d0vR7TA3AJxeUJKKGVN85woexSyf2V0r4LS2K U7tg== X-Gm-Message-State: AOAM532o0kQBPRRF61XfKzjQMJsubTf4MH/FVmaQxqbqJgD3RFkiqbD3 iVxfMD995+m8ndVupl3i7xk= X-Google-Smtp-Source: ABdhPJzs7ll1JOklhlZ81B/xoODjls3+gWBDy1xPengQWATZ/sYp/HNoGkeOxOmxpq2Kqh0lRbPp3A== X-Received: by 2002:a05:6a00:130b:b0:4e1:7b1e:6c6 with SMTP id j11-20020a056a00130b00b004e17b1e06c6mr5247279pfu.22.1645045453465; Wed, 16 Feb 2022 13:04:13 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:12 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , Don Brace , "James E.J. Bottomley" Subject: [PATCH v4 44/50] scsi: smartpqi: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:27 -0800 Message-Id: <20220216210233.28774-45-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/smartpqi/smartpqi_init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 4611912ae261..7c0d069a3158 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -54,6 +54,15 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version " MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL"); +struct pqi_cmd_priv { + int this_residual; +}; + +static struct pqi_cmd_priv *pqi_cmd_priv(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} + static void pqi_verify_structures(void); static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info, enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason); @@ -5552,7 +5561,7 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request, scsi_dma_unmap(scmd); if (io_request->status == -EAGAIN || pqi_raid_bypass_retry_needed(io_request)) { set_host_byte(scmd, DID_IMM_RETRY); - scmd->SCp.this_residual++; + pqi_cmd_priv(scmd)->this_residual++; } pqi_free_io_request(io_request); @@ -5814,7 +5823,7 @@ static inline bool pqi_is_bypass_eligible_request(struct scsi_cmnd *scmd) if (blk_rq_is_passthrough(scsi_cmd_to_rq(scmd))) return false; - return scmd->SCp.this_residual == 0; + return pqi_cmd_priv(scmd)->this_residual == 0; } /* @@ -7262,6 +7271,7 @@ static struct scsi_host_template pqi_driver_template = { .map_queues = pqi_map_queues, .sdev_groups = pqi_sdev_groups, .shost_groups = pqi_shost_groups, + .cmd_size = sizeof(struct pqi_cmd_priv), }; static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info) From patchwork Wed Feb 16 21:02:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DFC8C433EF for ; Wed, 16 Feb 2022 21:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233619AbiBPVEx (ORCPT ); Wed, 16 Feb 2022 16:04:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234792AbiBPVEe (ORCPT ); Wed, 16 Feb 2022 16:04:34 -0500 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C32082B1A93 for ; Wed, 16 Feb 2022 13:04:15 -0800 (PST) Received: by mail-pg1-f179.google.com with SMTP id l73so3157823pge.11 for ; Wed, 16 Feb 2022 13:04:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wWx0oD4y/h5fR0o1HnTS+lemIDFT4V4tl6fYkeJP2UA=; b=GcOlPcC7A6oRHhTnvKrLHE2QIvpp9YCRkTnKAbKE+8xLtOYywUeBZkwmSXPr+mHVse gJOG1mCionM+O624310O21oV2n8VnMY8OtugH9vcy10wDjD9Ktz0VK4+qtBgqHVFdiE2 oFwbzs6N2brYw6SiYZbfHf3jKB1s3+l7t+xulN0idnk6anHw70jUJUESiSId7TfGVHlf ddAfciBa4dL5ztYMwEFAbNjWEtLDXJeK3Bkf7ISaxbd19qCu7n4OXkvBvwbP1xRyuNzG IG8gkQVEaOsE+m5tuRr67Fs/QtI88q0DH6Vu+ZCWLetiiworOAyZloYPQ1XduY7ZZvhR SpMw== X-Gm-Message-State: AOAM532/gwNWr3MlJC9sXZyaqgMmO4tnyjoi/RH+ObWXmW/UKaNSXnCl X1RJHZkAFrsY0aSguBVH/IQ= X-Google-Smtp-Source: ABdhPJysJ6MCJyHmg1Y5UlaGSMQhfihNRNxzjqjcf2azSkt2m5XHBvHWNSQ4/G7xj2ZA+Ctf2axmJg== X-Received: by 2002:a62:be0f:0:b0:4e1:9222:1ef3 with SMTP id l15-20020a62be0f000000b004e192221ef3mr5097060pff.18.1645045455110; Wed, 16 Feb 2022 13:04:15 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:14 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , Matthew Wilcox , "James E.J. Bottomley" Subject: [PATCH v4 45/50] scsi: sym53c8xx_2: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:28 -0800 Message-Id: <20220216210233.28774-46-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/sym53c8xx_2/sym_glue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index b04bfde65e3f..2e2852bd5860 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -118,7 +118,7 @@ struct sym_ucmd { /* Override the SCSI pointer structure */ struct completion *eh_done; /* SCSI error handling */ }; -#define SYM_UCMD_PTR(cmd) ((struct sym_ucmd *)(&(cmd)->SCp)) +#define SYM_UCMD_PTR(cmd) ((struct sym_ucmd *)scsi_cmd_priv(cmd)) #define SYM_SOFTC_PTR(cmd) sym_get_hcb(cmd->device->host) /* @@ -127,7 +127,6 @@ struct sym_ucmd { /* Override the SCSI pointer structure */ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *cmd) { struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); - BUILD_BUG_ON(sizeof(struct scsi_pointer) < sizeof(struct sym_ucmd)); if (ucmd->eh_done) complete(ucmd->eh_done); @@ -1630,6 +1629,7 @@ static struct scsi_host_template sym2_template = { .module = THIS_MODULE, .name = "sym53c8xx", .info = sym53c8xx_info, + .cmd_size = sizeof(struct sym_ucmd), .queuecommand = sym53c8xx_queue_command, .slave_alloc = sym53c8xx_slave_alloc, .slave_configure = sym53c8xx_slave_configure, From patchwork Wed Feb 16 21:02:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5A11C433EF for ; Wed, 16 Feb 2022 21:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233214AbiBPVEv (ORCPT ); Wed, 16 Feb 2022 16:04:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233439AbiBPVEg (ORCPT ); Wed, 16 Feb 2022 16:04:36 -0500 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A35252B1A9C; Wed, 16 Feb 2022 13:04:17 -0800 (PST) Received: by mail-pf1-f176.google.com with SMTP id z16so3200212pfh.3; Wed, 16 Feb 2022 13:04:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=efotMu/0Uf1dkcc1uJu6R6InV4FTKLkaJ5+cOM9IBjM=; b=YNzvZXNrKmGXY1Laq3r9Dp0sCay3MoocBSkVVO23V0knUZoi1yTIXjXnSsg7UyePux kMjea/iLD4ouZOR8FeZDhPbezVgwFCYsB2+Szsbn4O+92qD+mLPHxDoNXjFfEM3T3/TV K06sCcCIEbydbBsO9e0wH1c99LrWGHEko+9q0dutHYa3OOBijPE1xvKvdEzfBC+qKsAc 8PND8JW0qhyi2nlQZGhjtXUxREa86XxSr2VyPMyKE+AoOLkEw2GHibD7HU1LQPaih4xO ngjL4NnaWBJLljCRpvnlUkfLHrFXjzNV/3+94+WkOQ41dWjp5iYYnMHZboJMX08VXEP/ 9qyQ== X-Gm-Message-State: AOAM5332jm2MGREdbEtWnzx1Q4RnXH546NUXeQkWst2fxjkMj/G0w1uJ p/ZdgLaFqsyrQkncBIyJKTs= X-Google-Smtp-Source: ABdhPJzn0mO14RAk6j0393pnnsdgoQ+wZ8bAOLsQhmAHfrNbEFfhQVoBgyKzYvQ4wPnOneCxKSkfSQ== X-Received: by 2002:a05:6a00:13a4:b0:4ce:118f:a822 with SMTP id t36-20020a056a0013a400b004ce118fa822mr5180459pfg.33.1645045456992; Wed, 16 Feb 2022 13:04:16 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:16 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , linux-usb@vger.kernel.org, Greg Kroah-Hartman , Oliver Neukum , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , Alan Stern Subject: [PATCH v4 46/50] scsi: usb: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:29 -0800 Message-Id: <20220216210233.28774-47-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set scsi_host_template.cmd_size instead of using the SCSI pointer for storing driver-private data. Change the type of the argument of uas_add_work() from struct uas_cmd_info * into struct scsi_cmnd * because it is easier to convert a SCSI command pointer into a uas_cmd_info pointer than the other way around. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: linux-usb@vger.kernel.org Acked-by: Greg Kroah-Hartman Acked-by: Oliver Neukum Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/usb/storage/uas.c | 43 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 7f2944729ecd..84dc270f6f73 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -113,7 +113,7 @@ static void uas_do_work(struct work_struct *work) continue; cmnd = devinfo->cmnd[i]; - cmdinfo = (void *)&cmnd->SCp; + cmdinfo = scsi_cmd_priv(cmnd); if (!(cmdinfo->state & IS_IN_WORK_LIST)) continue; @@ -139,10 +139,9 @@ static void uas_scan_work(struct work_struct *work) dev_dbg(&devinfo->intf->dev, "scan complete\n"); } -static void uas_add_work(struct uas_cmd_info *cmdinfo) +static void uas_add_work(struct scsi_cmnd *cmnd) { - struct scsi_pointer *scp = (void *)cmdinfo; - struct scsi_cmnd *cmnd = container_of(scp, struct scsi_cmnd, SCp); + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct uas_dev_info *devinfo = cmnd->device->hostdata; lockdep_assert_held(&devinfo->lock); @@ -163,7 +162,7 @@ static void uas_zap_pending(struct uas_dev_info *devinfo, int result) continue; cmnd = devinfo->cmnd[i]; - cmdinfo = (void *)&cmnd->SCp; + cmdinfo = scsi_cmd_priv(cmnd); uas_log_cmd_state(cmnd, __func__, 0); /* Sense urbs were killed, clear COMMAND_INFLIGHT manually */ cmdinfo->state &= ~COMMAND_INFLIGHT; @@ -200,15 +199,14 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix, int status) { - struct uas_cmd_info *ci = (void *)&cmnd->SCp; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *ci = scsi_cmd_priv(cmnd); if (status == -ENODEV) /* too late */ return; scmd_printk(KERN_INFO, cmnd, "%s %d uas-tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ", - prefix, status, cmdinfo->uas_tag, + prefix, status, ci->uas_tag, (ci->state & SUBMIT_STATUS_URB) ? " s-st" : "", (ci->state & ALLOC_DATA_IN_URB) ? " a-in" : "", (ci->state & SUBMIT_DATA_IN_URB) ? " s-in" : "", @@ -231,7 +229,7 @@ static void uas_free_unsubmitted_urbs(struct scsi_cmnd *cmnd) if (!cmnd) return; - cmdinfo = (void *)&cmnd->SCp; + cmdinfo = scsi_cmd_priv(cmnd); if (cmdinfo->state & SUBMIT_CMD_URB) usb_free_urb(cmdinfo->cmd_urb); @@ -245,7 +243,7 @@ static void uas_free_unsubmitted_urbs(struct scsi_cmnd *cmnd) static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) { - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; lockdep_assert_held(&devinfo->lock); @@ -263,13 +261,13 @@ static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller) static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, unsigned direction) { - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); int err; cmdinfo->state |= direction | SUBMIT_STATUS_URB; err = uas_submit_urbs(cmnd, cmnd->device->hostdata); if (err) { - uas_add_work(cmdinfo); + uas_add_work(cmnd); } } @@ -329,7 +327,7 @@ static void uas_stat_cmplt(struct urb *urb) } cmnd = devinfo->cmnd[idx]; - cmdinfo = (void *)&cmnd->SCp; + cmdinfo = scsi_cmd_priv(cmnd); if (!(cmdinfo->state & COMMAND_INFLIGHT)) { uas_log_cmd_state(cmnd, "unexpected status cmplt", 0); @@ -394,7 +392,7 @@ static void uas_stat_cmplt(struct urb *urb) static void uas_data_cmplt(struct urb *urb) { struct scsi_cmnd *cmnd = urb->context; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; struct scsi_data_buffer *sdb = &cmnd->sdb; unsigned long flags; @@ -446,7 +444,7 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, enum dma_data_direction dir) { struct usb_device *udev = devinfo->udev; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct urb *urb = usb_alloc_urb(0, gfp); struct scsi_data_buffer *sdb = &cmnd->sdb; unsigned int pipe = (dir == DMA_FROM_DEVICE) @@ -468,7 +466,7 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, struct scsi_cmnd *cmnd) { struct usb_device *udev = devinfo->udev; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct urb *urb = usb_alloc_urb(0, gfp); struct sense_iu *iu; @@ -496,7 +494,7 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, { struct usb_device *udev = devinfo->udev; struct scsi_device *sdev = cmnd->device; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct urb *urb = usb_alloc_urb(0, gfp); struct command_iu *iu; int len; @@ -558,7 +556,7 @@ static struct urb *uas_submit_sense_urb(struct scsi_cmnd *cmnd, gfp_t gfp) static int uas_submit_urbs(struct scsi_cmnd *cmnd, struct uas_dev_info *devinfo) { - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct urb *urb; int err; @@ -637,12 +635,10 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd) { struct scsi_device *sdev = cmnd->device; struct uas_dev_info *devinfo = sdev->hostdata; - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); unsigned long flags; int idx, err; - BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); - /* Re-check scsi_block_requests now that we've the host-lock */ if (cmnd->device->host->host_self_blocked) return SCSI_MLQUEUE_DEVICE_BUSY; @@ -712,7 +708,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd) spin_unlock_irqrestore(&devinfo->lock, flags); return SCSI_MLQUEUE_DEVICE_BUSY; } - uas_add_work(cmdinfo); + uas_add_work(cmnd); } devinfo->cmnd[idx] = cmnd; @@ -730,7 +726,7 @@ static DEF_SCSI_QCMD(uas_queuecommand) */ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) { - struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; + struct uas_cmd_info *cmdinfo = scsi_cmd_priv(cmnd); struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; struct urb *data_in_urb = NULL; struct urb *data_out_urb = NULL; @@ -910,6 +906,7 @@ static struct scsi_host_template uas_host_template = { .this_id = -1, .skip_settle_delay = 1, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct uas_cmd_info), }; #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ From patchwork Wed Feb 16 21:02:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72042C433F5 for ; Wed, 16 Feb 2022 21:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234723AbiBPVEm (ORCPT ); Wed, 16 Feb 2022 16:04:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234940AbiBPVEh (ORCPT ); Wed, 16 Feb 2022 16:04:37 -0500 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CFE22B1AA3 for ; Wed, 16 Feb 2022 13:04:19 -0800 (PST) Received: by mail-pf1-f182.google.com with SMTP id i6so3170410pfc.9 for ; Wed, 16 Feb 2022 13:04:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pnNf2VjhuumTX82Rj4aqfhA6PYW6ngKJyQvWPbUR7rY=; b=X9/3AEBSD7R2AwHxykfHYCZdwIt6mgIRCux7VQw972sVhJqH/8wnhd8RIpncOMkmVi 7adjbgDtWe0/P/W/GTtVS0aTb/yk7it3WsK0Bc0cMQ188nl7tbeAUpOxps6OHTK/xd/J /tcgeT3K9b4ZXCdoo9HwacdFLghnH9z4TKIgDzz4b2qO16y26gOi0GmmpAoa2B8165JU p37RuZDCCGLgHg7ny+rWcDpDAnWiMM0dKB+51+TvmjfrJ7hl+dv9OjaME24W8dsKOAG2 PKat9lZxfAR8/qpfeYIB31xI60IEu3DYX42aZhdIzO/MKjRvvACZYqFhhLhxYn7mzMK1 y48Q== X-Gm-Message-State: AOAM531m1jY5++UXXMfor92QuBTnRe5bfM5nsyQj1h4hmVuschdwxOL2 VgL31eGPgQaWclz6SoeLBr4= X-Google-Smtp-Source: ABdhPJykOhUvH73HHkwelj7BhJ1KvFwv/5Fm8LhPPaZ5qSuHXJ8oH+OE32sp4ooitmKnAOeA3eeVeg== X-Received: by 2002:a62:8c8f:0:b0:4cf:4c5:b2ad with SMTP id m137-20020a628c8f000000b004cf04c5b2admr777340pfd.71.1645045458780; Wed, 16 Feb 2022 13:04:18 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:18 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Ondrej Zary , Christoph Hellwig , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 47/50] scsi: wd719x: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:30 -0800 Message-Id: <20220216210233.28774-48-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move the DMA handle into the per-command private data instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: Ondrej Zary Cc: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/wd719x.c | 12 ++++++------ drivers/scsi/wd719x.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c index 1a7947554581..f341b79d8036 100644 --- a/drivers/scsi/wd719x.c +++ b/drivers/scsi/wd719x.c @@ -196,7 +196,7 @@ static void wd719x_finish_cmd(struct wd719x_scb *scb, int result) dma_unmap_single(&wd->pdev->dev, scb->phys, sizeof(struct wd719x_scb), DMA_BIDIRECTIONAL); scsi_dma_unmap(cmd); - dma_unmap_single(&wd->pdev->dev, cmd->SCp.dma_handle, + dma_unmap_single(&wd->pdev->dev, scb->dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); cmd->result = result << 16; @@ -229,11 +229,11 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) /* map sense buffer */ scb->sense_buf_length = SCSI_SENSE_BUFFERSIZE; - cmd->SCp.dma_handle = dma_map_single(&wd->pdev->dev, cmd->sense_buffer, - SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); - if (dma_mapping_error(&wd->pdev->dev, cmd->SCp.dma_handle)) + scb->dma_handle = dma_map_single(&wd->pdev->dev, cmd->sense_buffer, + SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(&wd->pdev->dev, scb->dma_handle)) goto out_unmap_scb; - scb->sense_buf = cpu_to_le32(cmd->SCp.dma_handle); + scb->sense_buf = cpu_to_le32(scb->dma_handle); /* request autosense */ scb->SCB_options |= WD719X_SCB_FLAGS_AUTO_REQUEST_SENSE; @@ -288,7 +288,7 @@ static int wd719x_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) return 0; out_unmap_sense: - dma_unmap_single(&wd->pdev->dev, cmd->SCp.dma_handle, + dma_unmap_single(&wd->pdev->dev, scb->dma_handle, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); out_unmap_scb: dma_unmap_single(&wd->pdev->dev, scb->phys, sizeof(*scb), diff --git a/drivers/scsi/wd719x.h b/drivers/scsi/wd719x.h index abaabd419a54..966ab0fb4621 100644 --- a/drivers/scsi/wd719x.h +++ b/drivers/scsi/wd719x.h @@ -56,6 +56,7 @@ struct wd719x_scb { u8 flags[2]; /* 62-63 SCB specific flags (local to each thread) */ /* everything below is for driver use (not used by card) */ dma_addr_t phys; /* bus address of the SCB */ + dma_addr_t dma_handle; struct scsi_cmnd *cmd; /* a copy of the pointer we were passed */ struct list_head list; struct wd719x_sglist sg_list[WD719X_SG] __aligned(8); /* SG list */ From patchwork Wed Feb 16 21:02:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0516EC433FE for ; Wed, 16 Feb 2022 21:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234977AbiBPVEu (ORCPT ); Wed, 16 Feb 2022 16:04:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235028AbiBPVEh (ORCPT ); Wed, 16 Feb 2022 16:04:37 -0500 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1D52AFEA3 for ; Wed, 16 Feb 2022 13:04:21 -0800 (PST) Received: by mail-pl1-f177.google.com with SMTP id z17so2953828plb.9 for ; Wed, 16 Feb 2022 13:04:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WEZpjTISkRnssBmgxMOGJqsMu7OjeIUszjwLIBLxk6c=; b=MKsEZ9Zcwp8KVss7lZksjAzSsS04t/AJwyKhnwTmVIURoaGfpj5MVCgWGIjGpEDX0c B/WXzzEP3JlQ+dfVOicZ1i4xiNyTCkp1FGAPDw6InOJI9p0yJFRzVAeiaHRZO1pk9O33 r6qlLMXzfIcu1OauDDE+jKxud4EVFhD1zwuSFET7oz8sjQb203FYZXxPzOnX9ZNQvbpe T8imgtptQQ6zqRkxBxz42h2haqhEtFiHEXbKbR5HE4HCR1jBLNXN5mdHjclN9r2I/4UZ ckTc9UY99mr1Wf+OXi9TjoW8WPh0mip936ciDacVAH1N/vvGC1bWvocLo8zYDKV5yWP9 iBdA== X-Gm-Message-State: AOAM531hVO+bTmCbdoRr+Qa9ceiFWKH55KtzTwpq5zm+5xZXwkarki5D VRR6hlEtLWfOxhVIIv/iUec= X-Google-Smtp-Source: ABdhPJyegj+/VkVMIgjJk1OYG5qNCJuUGgQEcnrfzAIeO35e0G55TO5qLFrz2rGuVdKcG/ZPVO0ilw== X-Received: by 2002:a17:903:244b:b0:14d:8437:5114 with SMTP id l11-20020a170903244b00b0014d84375114mr4187706pls.151.1645045460748; Wed, 16 Feb 2022 13:04:20 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:20 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 48/50] scsi: wd33c93: Move the SCSI pointer to private command data Date: Wed, 16 Feb 2022 13:02:31 -0800 Message-Id: <20220216210233.28774-49-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/a2091.c | 19 ++++--- drivers/scsi/a3000.c | 19 ++++--- drivers/scsi/gvp11.c | 19 ++++--- drivers/scsi/mvme147.c | 10 ++-- drivers/scsi/sgiwd93.c | 18 ++++--- drivers/scsi/wd33c93.c | 119 ++++++++++++++++++++++------------------- drivers/scsi/wd33c93.h | 4 ++ 7 files changed, 117 insertions(+), 91 deletions(-) diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index bcbce23478b8..cf703a1ecdda 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c @@ -44,16 +44,17 @@ static irqreturn_t a2091_intr(int irq, void *data) static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct Scsi_Host *instance = cmd->device->host; struct a2091_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct a2091_scsiregs *regs = hdata->regs; unsigned short cntr = CNTR_PDMD | CNTR_INTEN; - unsigned long addr = virt_to_bus(cmd->SCp.ptr); + unsigned long addr = virt_to_bus(scsi_pointer->ptr); /* don't allow DMA if the physical address is bad */ if (addr & A2091_XFER_MASK) { - wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; + wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, GFP_KERNEL); @@ -77,8 +78,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (!dir_in) { /* copy to bounce buffer for a write */ - memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, - cmd->SCp.this_residual); + memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr, + scsi_pointer->this_residual); } } @@ -96,10 +97,10 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (dir_in) { /* invalidate any cache */ - cache_clear(addr, cmd->SCp.this_residual); + cache_clear(addr, scsi_pointer->this_residual); } else { /* push any dirty cache */ - cache_push(addr, cmd->SCp.this_residual); + cache_push(addr, scsi_pointer->this_residual); } /* start DMA */ regs->ST_DMA = 1; @@ -111,6 +112,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, int status) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(SCpnt); struct a2091_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct a2091_scsiregs *regs = hdata->regs; @@ -143,8 +145,8 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, /* copy from a bounce buffer, if necessary */ if (status && wh->dma_bounce_buffer) { if (wh->dma_dir) - memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, - SCpnt->SCp.this_residual); + memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer, + scsi_pointer->this_residual); kfree(wh->dma_bounce_buffer); wh->dma_bounce_buffer = NULL; wh->dma_bounce_len = 0; @@ -165,6 +167,7 @@ static struct scsi_host_template a2091_scsi_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct scsi_pointer), }; static int a2091_probe(struct zorro_dev *z, const struct zorro_device_id *ent) diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c index 23f34411f7bf..dd161885eed1 100644 --- a/drivers/scsi/a3000.c +++ b/drivers/scsi/a3000.c @@ -48,12 +48,13 @@ static irqreturn_t a3000_intr(int irq, void *data) static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct Scsi_Host *instance = cmd->device->host; struct a3000_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct a3000_scsiregs *regs = hdata->regs; unsigned short cntr = CNTR_PDMD | CNTR_INTEN; - unsigned long addr = virt_to_bus(cmd->SCp.ptr); + unsigned long addr = virt_to_bus(scsi_pointer->ptr); /* * if the physical address has the wrong alignment, or if @@ -62,7 +63,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) * buffer */ if (addr & A3000_XFER_MASK) { - wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; + wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len, GFP_KERNEL); @@ -74,8 +75,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (!dir_in) { /* copy to bounce buffer for a write */ - memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, - cmd->SCp.this_residual); + memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr, + scsi_pointer->this_residual); } addr = virt_to_bus(wh->dma_bounce_buffer); @@ -95,10 +96,10 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (dir_in) { /* invalidate any cache */ - cache_clear(addr, cmd->SCp.this_residual); + cache_clear(addr, scsi_pointer->this_residual); } else { /* push any dirty cache */ - cache_push(addr, cmd->SCp.this_residual); + cache_push(addr, scsi_pointer->this_residual); } /* start DMA */ @@ -113,6 +114,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, int status) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(SCpnt); struct a3000_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct a3000_scsiregs *regs = hdata->regs; @@ -153,8 +155,8 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, if (status && wh->dma_bounce_buffer) { if (SCpnt) { if (wh->dma_dir && SCpnt) - memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, - SCpnt->SCp.this_residual); + memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer, + scsi_pointer->this_residual); kfree(wh->dma_bounce_buffer); wh->dma_bounce_buffer = NULL; wh->dma_bounce_len = 0; @@ -179,6 +181,7 @@ static struct scsi_host_template amiga_a3000_scsi_template = { .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, + .cmd_size = sizeof(struct scsi_pointer), }; static int __init amiga_a3000_scsi_probe(struct platform_device *pdev) diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index 43754c2f36b3..2f6c56aabe1d 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c @@ -53,18 +53,19 @@ void gvp11_setup(char *str, int *ints) static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct Scsi_Host *instance = cmd->device->host; struct gvp11_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct gvp11_scsiregs *regs = hdata->regs; unsigned short cntr = GVP11_DMAC_INT_ENABLE; - unsigned long addr = virt_to_bus(cmd->SCp.ptr); + unsigned long addr = virt_to_bus(scsi_pointer->ptr); int bank_mask; static int scsi_alloc_out_of_range = 0; /* use bounce buffer if the physical address is bad */ if (addr & wh->dma_xfer_mask) { - wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; + wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff; if (!scsi_alloc_out_of_range) { wh->dma_bounce_buffer = @@ -113,8 +114,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (!dir_in) { /* copy to bounce buffer for a write */ - memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, - cmd->SCp.this_residual); + memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr, + scsi_pointer->this_residual); } } @@ -130,10 +131,10 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (dir_in) { /* invalidate any cache */ - cache_clear(addr, cmd->SCp.this_residual); + cache_clear(addr, scsi_pointer->this_residual); } else { /* push any dirty cache */ - cache_push(addr, cmd->SCp.this_residual); + cache_push(addr, scsi_pointer->this_residual); } bank_mask = (~wh->dma_xfer_mask >> 18) & 0x01c0; @@ -150,6 +151,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, int status) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(SCpnt); struct gvp11_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = &hdata->wh; struct gvp11_scsiregs *regs = hdata->regs; @@ -162,8 +164,8 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, /* copy from a bounce buffer, if necessary */ if (status && wh->dma_bounce_buffer) { if (wh->dma_dir && SCpnt) - memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, - SCpnt->SCp.this_residual); + memcpy(scsi_pointer->ptr, wh->dma_bounce_buffer, + scsi_pointer->this_residual); if (wh->dma_buffer_pool == BUF_SCSI_ALLOCED) kfree(wh->dma_bounce_buffer); @@ -189,6 +191,7 @@ static struct scsi_host_template gvp11_scsi_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct scsi_pointer), }; static int check_wd33c93(struct gvp11_scsiregs *regs) diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index 0893d4c3a916..472fa043094f 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -33,10 +33,11 @@ static irqreturn_t mvme147_intr(int irq, void *data) static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct Scsi_Host *instance = cmd->device->host; struct WD33C93_hostdata *hdata = shost_priv(instance); unsigned char flags = 0x01; - unsigned long addr = virt_to_bus(cmd->SCp.ptr); + unsigned long addr = virt_to_bus(scsi_pointer->ptr); /* setup dma direction */ if (!dir_in) @@ -47,14 +48,14 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) if (dir_in) { /* invalidate any cache */ - cache_clear(addr, cmd->SCp.this_residual); + cache_clear(addr, scsi_pointer->this_residual); } else { /* push any dirty cache */ - cache_push(addr, cmd->SCp.this_residual); + cache_push(addr, scsi_pointer->this_residual); } /* start DMA */ - m147_pcc->dma_bcr = cmd->SCp.this_residual | (1 << 24); + m147_pcc->dma_bcr = scsi_pointer->this_residual | (1 << 24); m147_pcc->dma_dadr = addr; m147_pcc->dma_cntrl = flags; @@ -81,6 +82,7 @@ static struct scsi_host_template mvme147_host_template = { .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, + .cmd_size = sizeof(struct scsi_pointer), }; static struct Scsi_Host *mvme147_shost; diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c index e797d89c873b..57d5dff62f63 100644 --- a/drivers/scsi/sgiwd93.c +++ b/drivers/scsi/sgiwd93.c @@ -69,14 +69,15 @@ static irqreturn_t sgiwd93_intr(int irq, void *dev_id) static inline void fill_hpc_entries(struct ip22_hostdata *hd, struct scsi_cmnd *cmd, int din) { - unsigned long len = cmd->SCp.this_residual; - void *addr = cmd->SCp.ptr; + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); + unsigned long len = scsi_pointer->this_residual; + void *addr = scsi_pointer->ptr; dma_addr_t physaddr; unsigned long count; struct hpc_chunk *hcp; physaddr = dma_map_single(hd->dev, addr, len, DMA_DIR(din)); - cmd->SCp.dma_handle = physaddr; + scsi_pointer->dma_handle = physaddr; hcp = hd->cpu; while (len) { @@ -106,6 +107,7 @@ void fill_hpc_entries(struct ip22_hostdata *hd, struct scsi_cmnd *cmd, int din) static int dma_setup(struct scsi_cmnd *cmd, int datainp) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct ip22_hostdata *hdata = host_to_hostdata(cmd->device->host); struct hpc3_scsiregs *hregs = (struct hpc3_scsiregs *) cmd->device->host->base; @@ -120,7 +122,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) * obvious). IMHO a better fix would be, not to do these dma setups * in the first place. */ - if (cmd->SCp.ptr == NULL || cmd->SCp.this_residual == 0) + if (scsi_pointer->ptr == NULL || scsi_pointer->this_residual == 0) return 1; fill_hpc_entries(hdata, cmd, datainp); @@ -140,13 +142,14 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp) static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, int status) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(SCpnt); struct ip22_hostdata *hdata = host_to_hostdata(instance); struct hpc3_scsiregs *hregs; if (!SCpnt) return; - if (SCpnt->SCp.ptr == NULL || SCpnt->SCp.this_residual == 0) + if (scsi_pointer->ptr == NULL || scsi_pointer->this_residual == 0) return; hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; @@ -160,8 +163,8 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, barrier(); } hregs->ctrl = 0; - dma_unmap_single(hdata->dev, SCpnt->SCp.dma_handle, - SCpnt->SCp.this_residual, + dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, + scsi_pointer->this_residual, DMA_DIR(hdata->wh.dma_dir)); pr_debug("\n"); @@ -213,6 +216,7 @@ static struct scsi_host_template sgiwd93_template = { .sg_tablesize = SG_ALL, .cmd_per_lun = 8, .dma_boundary = PAGE_SIZE - 1, + .cmd_size = sizeof(struct scsi_pointer), }; static int sgiwd93_probe(struct platform_device *pdev) diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index 7d2f00f3571a..3fe562047d85 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -364,6 +364,7 @@ calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast, static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct WD33C93_hostdata *hostdata; struct scsi_cmnd *tmp; @@ -395,15 +396,15 @@ static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd) */ if (scsi_bufflen(cmd)) { - cmd->SCp.buffer = scsi_sglist(cmd); - cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); - cmd->SCp.this_residual = cmd->SCp.buffer->length; + scsi_pointer->buffer = scsi_sglist(cmd); + scsi_pointer->buffers_residual = scsi_sg_count(cmd) - 1; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); + scsi_pointer->this_residual = scsi_pointer->buffer->length; } else { - cmd->SCp.buffer = NULL; - cmd->SCp.buffers_residual = 0; - cmd->SCp.ptr = NULL; - cmd->SCp.this_residual = 0; + scsi_pointer->buffer = NULL; + scsi_pointer->buffers_residual = 0; + scsi_pointer->ptr = NULL; + scsi_pointer->this_residual = 0; } /* WD docs state that at the conclusion of a "LEVEL2" command, the @@ -423,7 +424,7 @@ static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd) * status byte is stored. */ - cmd->SCp.Status = ILLEGAL_STATUS_BYTE; + scsi_pointer->Status = ILLEGAL_STATUS_BYTE; /* * Add the cmd to the end of 'input_Q'. Note that REQUEST SENSE @@ -470,6 +471,7 @@ DEF_SCSI_QCMD(wd33c93_queuecommand) static void wd33c93_execute(struct Scsi_Host *instance) { + struct scsi_pointer *scsi_pointer; struct WD33C93_hostdata *hostdata = (struct WD33C93_hostdata *) instance->hostdata; const wd33c93_regs regs = hostdata->regs; @@ -546,7 +548,8 @@ wd33c93_execute(struct Scsi_Host *instance) * to change around and experiment with for now. */ - cmd->SCp.phase = 0; /* assume no disconnect */ + scsi_pointer = WD33C93_scsi_pointer(cmd); + scsi_pointer->phase = 0; /* assume no disconnect */ if (hostdata->disconnect == DIS_NEVER) goto no; if (hostdata->disconnect == DIS_ALWAYS) @@ -563,7 +566,7 @@ wd33c93_execute(struct Scsi_Host *instance) (prev->device->lun != cmd->device->lun)) { for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev; prev = (struct scsi_cmnd *) prev->host_scribble) - prev->SCp.phase = 1; + WD33C93_scsi_pointer(prev)->phase = 1; goto yes; } } @@ -571,7 +574,7 @@ wd33c93_execute(struct Scsi_Host *instance) goto no; yes: - cmd->SCp.phase = 1; + scsi_pointer->phase = 1; #ifdef PROC_STATISTICS hostdata->disc_allowed_cnt[cmd->device->id]++; @@ -579,7 +582,7 @@ wd33c93_execute(struct Scsi_Host *instance) no: - write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0)); + write_wd33c93(regs, WD_SOURCE_ID, scsi_pointer->phase ? SRCID_ER : 0); write_wd33c93(regs, WD_TARGET_LUN, (u8)cmd->device->lun); write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, @@ -648,14 +651,14 @@ wd33c93_execute(struct Scsi_Host *instance) * up ahead of time. */ - if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) { + if (scsi_pointer->phase == 0 && hostdata->no_dma == 0) { if (hostdata->dma_setup(cmd, (cmd->sc_data_direction == DMA_TO_DEVICE) ? DATA_OUT_DIR : DATA_IN_DIR)) write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ else { write_wd33c93_count(regs, - cmd->SCp.this_residual); + scsi_pointer->this_residual); write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode); hostdata->dma = D_DMA_RUNNING; @@ -675,7 +678,7 @@ wd33c93_execute(struct Scsi_Host *instance) */ DB(DB_EXECUTE, - printk("%s)EX-2 ", (cmd->SCp.phase) ? "d:" : "")) + printk("%s)EX-2 ", scsi_pointer->phase ? "d:" : "")) } static void @@ -717,6 +720,7 @@ static void transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, int data_in_dir) { + struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); struct WD33C93_hostdata *hostdata; unsigned long length; @@ -730,13 +734,13 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, * now we need to setup the next scatter-gather buffer as the * source or destination for THIS transfer. */ - if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { - cmd->SCp.buffer = sg_next(cmd->SCp.buffer); - --cmd->SCp.buffers_residual; - cmd->SCp.this_residual = cmd->SCp.buffer->length; - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); + if (!scsi_pointer->this_residual && scsi_pointer->buffers_residual) { + scsi_pointer->buffer = sg_next(scsi_pointer->buffer); + --scsi_pointer->buffers_residual; + scsi_pointer->this_residual = scsi_pointer->buffer->length; + scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); } - if (!cmd->SCp.this_residual) /* avoid bogus setups */ + if (!scsi_pointer->this_residual) /* avoid bogus setups */ return; write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER, @@ -750,11 +754,12 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, #ifdef PROC_STATISTICS hostdata->pio_cnt++; #endif - transfer_pio(regs, (uchar *) cmd->SCp.ptr, - cmd->SCp.this_residual, data_in_dir, hostdata); - length = cmd->SCp.this_residual; - cmd->SCp.this_residual = read_wd33c93_count(regs); - cmd->SCp.ptr += (length - cmd->SCp.this_residual); + transfer_pio(regs, (uchar *) scsi_pointer->ptr, + scsi_pointer->this_residual, data_in_dir, + hostdata); + length = scsi_pointer->this_residual; + scsi_pointer->this_residual = read_wd33c93_count(regs); + scsi_pointer->ptr += length - scsi_pointer->this_residual; } /* We are able to do DMA (in fact, the Amiga hardware is @@ -771,10 +776,10 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, hostdata->dma_cnt++; #endif write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode); - write_wd33c93_count(regs, cmd->SCp.this_residual); + write_wd33c93_count(regs, scsi_pointer->this_residual); if ((hostdata->level2 >= L2_DATA) || - (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) { + (hostdata->level2 == L2_BASIC && scsi_pointer->phase == 0)) { write_wd33c93(regs, WD_COMMAND_PHASE, 0x45); write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER); hostdata->state = S_RUNNING_LEVEL2; @@ -788,6 +793,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, void wd33c93_intr(struct Scsi_Host *instance) { + struct scsi_pointer *scsi_pointer; struct WD33C93_hostdata *hostdata = (struct WD33C93_hostdata *) instance->hostdata; const wd33c93_regs regs = hostdata->regs; @@ -806,6 +812,7 @@ wd33c93_intr(struct Scsi_Host *instance) #endif cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */ + scsi_pointer = WD33C93_scsi_pointer(cmd); sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */ phs = read_wd33c93(regs, WD_COMMAND_PHASE); @@ -827,14 +834,14 @@ wd33c93_intr(struct Scsi_Host *instance) */ if (hostdata->dma == D_DMA_RUNNING) { DB(DB_TRANSFER, - printk("[%p/%d:", cmd->SCp.ptr, cmd->SCp.this_residual)) + printk("[%p/%d:", scsi_pointer->ptr, scsi_pointer->this_residual)) hostdata->dma_stop(cmd->device->host, cmd, 1); hostdata->dma = D_DMA_OFF; - length = cmd->SCp.this_residual; - cmd->SCp.this_residual = read_wd33c93_count(regs); - cmd->SCp.ptr += (length - cmd->SCp.this_residual); + length = scsi_pointer->this_residual; + scsi_pointer->this_residual = read_wd33c93_count(regs); + scsi_pointer->ptr += length - scsi_pointer->this_residual; DB(DB_TRANSFER, - printk("%p/%d]", cmd->SCp.ptr, cmd->SCp.this_residual)) + printk("%p/%d]", scsi_pointer->ptr, scsi_pointer->this_residual)) } /* Respond to the specific WD3393 interrupt - there are quite a few! */ @@ -884,7 +891,7 @@ wd33c93_intr(struct Scsi_Host *instance) /* construct an IDENTIFY message with correct disconnect bit */ hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun); - if (cmd->SCp.phase) + if (scsi_pointer->phase) hostdata->outgoing_msg[0] |= 0x40; if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) { @@ -926,8 +933,8 @@ wd33c93_intr(struct Scsi_Host *instance) case CSR_UNEXP | PHS_DATA_IN: case CSR_SRV_REQ | PHS_DATA_IN: DB(DB_INTR, - printk("IN-%d.%d", cmd->SCp.this_residual, - cmd->SCp.buffers_residual)) + printk("IN-%d.%d", scsi_pointer->this_residual, + scsi_pointer->buffers_residual)) transfer_bytes(regs, cmd, DATA_IN_DIR); if (hostdata->state != S_RUNNING_LEVEL2) hostdata->state = S_CONNECTED; @@ -938,8 +945,8 @@ wd33c93_intr(struct Scsi_Host *instance) case CSR_UNEXP | PHS_DATA_OUT: case CSR_SRV_REQ | PHS_DATA_OUT: DB(DB_INTR, - printk("OUT-%d.%d", cmd->SCp.this_residual, - cmd->SCp.buffers_residual)) + printk("OUT-%d.%d", scsi_pointer->this_residual, + scsi_pointer->buffers_residual)) transfer_bytes(regs, cmd, DATA_OUT_DIR); if (hostdata->state != S_RUNNING_LEVEL2) hostdata->state = S_CONNECTED; @@ -962,8 +969,8 @@ wd33c93_intr(struct Scsi_Host *instance) case CSR_UNEXP | PHS_STATUS: case CSR_SRV_REQ | PHS_STATUS: DB(DB_INTR, printk("STATUS=")) - cmd->SCp.Status = read_1_byte(regs); - DB(DB_INTR, printk("%02x", cmd->SCp.Status)) + scsi_pointer->Status = read_1_byte(regs); + DB(DB_INTR, printk("%02x", scsi_pointer->Status)) if (hostdata->level2 >= L2_BASIC) { sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */ udelay(7); @@ -991,7 +998,7 @@ wd33c93_intr(struct Scsi_Host *instance) else hostdata->incoming_ptr = 0; - cmd->SCp.Message = msg; + scsi_pointer->Message = msg; switch (msg) { case COMMAND_COMPLETE: @@ -1163,21 +1170,21 @@ wd33c93_intr(struct Scsi_Host *instance) write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER); if (phs == 0x60) { DB(DB_INTR, printk("SX-DONE")) - cmd->SCp.Message = COMMAND_COMPLETE; + scsi_pointer->Message = COMMAND_COMPLETE; lun = read_wd33c93(regs, WD_TARGET_LUN); - DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun)) + DB(DB_INTR, printk(":%d.%d", scsi_pointer->Status, lun)) hostdata->connected = NULL; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; - if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE) - cmd->SCp.Status = lun; + if (scsi_pointer->Status == ILLEGAL_STATUS_BYTE) + scsi_pointer->Status = lun; if (cmd->cmnd[0] == REQUEST_SENSE - && cmd->SCp.Status != SAM_STAT_GOOD) { + && scsi_pointer->Status != SAM_STAT_GOOD) { set_host_byte(cmd, DID_ERROR); } else { set_host_byte(cmd, DID_OK); - scsi_msg_to_host_byte(cmd, cmd->SCp.Message); - set_status_byte(cmd, cmd->SCp.Status); + scsi_msg_to_host_byte(cmd, scsi_pointer->Message); + set_status_byte(cmd, scsi_pointer->Status); } scsi_done(cmd); @@ -1259,12 +1266,12 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; if (cmd->cmnd[0] == REQUEST_SENSE && - cmd->SCp.Status != SAM_STAT_GOOD) { + scsi_pointer->Status != SAM_STAT_GOOD) { set_host_byte(cmd, DID_ERROR); } else { set_host_byte(cmd, DID_OK); - scsi_msg_to_host_byte(cmd, cmd->SCp.Message); - set_status_byte(cmd, cmd->SCp.Status); + scsi_msg_to_host_byte(cmd, scsi_pointer->Message); + set_status_byte(cmd, scsi_pointer->Status); } scsi_done(cmd); @@ -1293,14 +1300,14 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected = NULL; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff)); hostdata->state = S_UNCONNECTED; - DB(DB_INTR, printk(":%d", cmd->SCp.Status)) + DB(DB_INTR, printk(":%d", scsi_pointer->Status)) if (cmd->cmnd[0] == REQUEST_SENSE - && cmd->SCp.Status != SAM_STAT_GOOD) { + && scsi_pointer->Status != SAM_STAT_GOOD) { set_host_byte(cmd, DID_ERROR); } else { set_host_byte(cmd, DID_OK); - scsi_msg_to_host_byte(cmd, cmd->SCp.Message); - set_status_byte(cmd, cmd->SCp.Status); + scsi_msg_to_host_byte(cmd, scsi_pointer->Message); + set_status_byte(cmd, scsi_pointer->Status); } scsi_done(cmd); break; diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h index 2edec34c5a42..b3800baccd2c 100644 --- a/drivers/scsi/wd33c93.h +++ b/drivers/scsi/wd33c93.h @@ -262,6 +262,10 @@ struct WD33C93_hostdata { #endif }; +static inline struct scsi_pointer *WD33C93_scsi_pointer(struct scsi_cmnd *cmd) +{ + return scsi_cmd_priv(cmd); +} /* defines for hostdata->chip */ From patchwork Wed Feb 16 21:02:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ADAEC4332F for ; Wed, 16 Feb 2022 21:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234786AbiBPVEp (ORCPT ); Wed, 16 Feb 2022 16:04:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235125AbiBPVEh (ORCPT ); Wed, 16 Feb 2022 16:04:37 -0500 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1717C2AFEA6 for ; Wed, 16 Feb 2022 13:04:23 -0800 (PST) Received: by mail-pl1-f182.google.com with SMTP id l8so2960897pls.7 for ; Wed, 16 Feb 2022 13:04:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ik4fUFCkFlenhZPbOaqGtMyvz7ystmwHP7ZXn9Wxrx0=; b=6PY/cjXlEDyIsO8f5LCAPm5aMiuEZ2ys21Mf78pOSGYVvCKD40wFn/FhF2+HcOPOgi VCT3xt1TGCQ6pw9SArIlyh8sVrs5Mq3Y7KzFa+e63XGU7UlvoVmTIj0ZZhcNrIgyQkgn 2wbDqGEG8bdoaIOLx6gFB0TqL8iK7ySZWerTnXUhb5qdKN4GE1dXEVCJTHoLlireWCGD p3/Nx5hF1fSe7BGyT+v9AWHef6yYO363N/SelQSF8YySvYvY6FGJgU23RK87HE/A1ipF 7xZDxtZNZq4ZB05nqRO8WivT9lh8RKZOTC1M/FnrDiFxTw3FAVbyyvYDW2t8VwIUFkoD DjOw== X-Gm-Message-State: AOAM532iDIFFRtv8pViLV6anCJyhQUGWf1+7yoe5vO5RvGCC2m3XHt6L 2ypcRqQI+1SSyJ+0sUwpgMCn07tqXhUdQC66 X-Google-Smtp-Source: ABdhPJxgOTXVyG/YzJ0BKiAi2O4WpUfxy24ITOFiX3AMR5K+EL1u3x19UNcpv5N4O9keBPNty9XLmw== X-Received: by 2002:a17:90a:9f82:b0:1b9:e290:8960 with SMTP id o2-20020a17090a9f8200b001b9e2908960mr3866527pjp.222.1645045462510; Wed, 16 Feb 2022 13:04:22 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:21 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Helge Deller , Johannes Thumshirn , Hannes Reinecke , Himanshu Madhani , "James E.J. Bottomley" Subject: [PATCH v4 49/50] scsi: zalon: Stop using the SCSI pointer Date: Wed, 16 Feb 2022 13:02:32 -0800 Message-Id: <20220216210233.28774-50-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set .cmd_size in the SCSI host template instead of using the SCSI pointer from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer from struct scsi_cmnd. Cc: Helge Deller Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/ncr53c8xx.c | 22 ++++++++++++---------- drivers/scsi/ncr53c8xx.h | 6 ++++++ drivers/scsi/zalon.c | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index fc8abe05fa8f..4458449c960b 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -514,30 +514,29 @@ static m_addr_t __vtobus(m_bush_t bush, void *m) * Deal with DMA mapping/unmapping. */ -/* To keep track of the dma mapping (sg/single) that has been set */ -#define __data_mapped SCp.phase -#define __data_mapping SCp.have_data_in - static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd) { - switch(cmd->__data_mapped) { + struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd); + + switch(cmd_priv->data_mapped) { case 2: scsi_dma_unmap(cmd); break; } - cmd->__data_mapped = 0; + cmd_priv->data_mapped = 0; } static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) { + struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd); int use_sg; use_sg = scsi_dma_map(cmd); if (!use_sg) return 0; - cmd->__data_mapped = 2; - cmd->__data_mapping = use_sg; + cmd_priv->data_mapped = 2; + cmd_priv->data_mapping = use_sg; return use_sg; } @@ -7854,6 +7853,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device) static int ncr53c8xx_queue_command_lck(struct scsi_cmnd *cmd) { + struct ncr_cmd_priv *cmd_priv = scsi_cmd_priv(cmd); void (*done)(struct scsi_cmnd *) = scsi_done; struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; unsigned long flags; @@ -7864,8 +7864,8 @@ printk("ncr53c8xx_queue_command\n"); #endif cmd->host_scribble = NULL; - cmd->__data_mapped = 0; - cmd->__data_mapping = 0; + cmd_priv->data_mapped = 0; + cmd_priv->data_mapping = 0; spin_lock_irqsave(&np->smp_lock, flags); @@ -8085,6 +8085,8 @@ struct Scsi_Host * __init ncr_attach(struct scsi_host_template *tpnt, u_long flags = 0; int i; + WARN_ON_ONCE(tpnt->cmd_size < sizeof(struct ncr_cmd_priv)); + if (!tpnt->name) tpnt->name = SCSI_NCR_DRIVER_NAME; if (!tpnt->shost_groups) diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h index fa14b5ca8783..be38c902859e 100644 --- a/drivers/scsi/ncr53c8xx.h +++ b/drivers/scsi/ncr53c8xx.h @@ -1288,6 +1288,12 @@ struct ncr_device { u8 differential; }; +/* To keep track of the dma mapping (sg/single) that has been set */ +struct ncr_cmd_priv { + int data_mapped; + int data_mapping; +}; + extern struct Scsi_Host *ncr_attach(struct scsi_host_template *tpnt, int unit, struct ncr_device *device); extern void ncr53c8xx_release(struct Scsi_Host *host); irqreturn_t ncr53c8xx_intr(int irq, void *dev_id); diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c index f1e5cf8a17d9..22d412cab91d 100644 --- a/drivers/scsi/zalon.c +++ b/drivers/scsi/zalon.c @@ -81,6 +81,7 @@ lasi_scsi_clock(void * hpa, int defaultclock) static struct scsi_host_template zalon7xx_template = { .module = THIS_MODULE, .proc_name = "zalon7xx", + .cmd_size = sizeof(struct ncr_cmd_priv), }; static int __init From patchwork Wed Feb 16 21:02:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 543632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA8F7C433F5 for ; Wed, 16 Feb 2022 21:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234624AbiBPVEs (ORCPT ); Wed, 16 Feb 2022 16:04:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235161AbiBPVEh (ORCPT ); Wed, 16 Feb 2022 16:04:37 -0500 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D02AF2B0483 for ; Wed, 16 Feb 2022 13:04:24 -0800 (PST) Received: by mail-pj1-f42.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so7572994pjl.2 for ; Wed, 16 Feb 2022 13:04:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gXAcwAjg+3y4mhvxhJT9Ev7Cj8iE4juolwO8/6/Gqn8=; b=x4w6nCH31vgnv9y6aw5xfN4lbq1C01LR7GK0nlDteqU0X73WKGq64N9JIVDwIr2YVv u78imvZC3VQv46yn42f5GYKEpqgU5/BBcda0lIXUVTwkFAy87k6BmIwdLIIZ1iAq68Po HbtFO9rapKeBt+wsPxi/Sl5gzJFpk08ghVbpR2Ra8eSqeMfyEN0BP6fpcfs9Pb+Bpm2P cNFzwAjMuabYk24h2XRPS0L7BkUchv/7F3uupmNIVJyBvm0920iux2oyp+ibmoqWdRWZ UuM3xNfVclEaUufG+zce9gmP9u4+tfB+mydcclDZ8Kct1Naejt/xTD/la9T01x1+QJJj Oplw== X-Gm-Message-State: AOAM532qQaoX/Ln4R8SR09izQoc2evEBYnP2cP0NQHZ8T3Yg3jwPWLtJ TojuPWvCxc+GtS3nbH5bQno= X-Google-Smtp-Source: ABdhPJziPcoiTk6Gy58ai/cPVue2UEdnGum2iEjdhbJKhTutG2eH1xOmL4jvGLRrUBvL738yZyb0Ow== X-Received: by 2002:a17:90a:4386:b0:1b9:24b9:b205 with SMTP id r6-20020a17090a438600b001b924b9b205mr3825679pjg.218.1645045464271; Wed, 16 Feb 2022 13:04:24 -0800 (PST) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id c8sm46591222pfv.57.2022.02.16.13.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 13:04:23 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Ming Lei , Hannes Reinecke , Christoph Hellwig , Johannes Thumshirn , Himanshu Madhani , Hannes Reinecke , "James E.J. Bottomley" Subject: [PATCH v4 50/50] scsi: core: Remove struct scsi_pointer from struct scsi_cmnd Date: Wed, 16 Feb 2022 13:02:33 -0800 Message-Id: <20220216210233.28774-51-bvanassche@acm.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220216210233.28774-1-bvanassche@acm.org> References: <20220216210233.28774-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove struct scsi_pointer from struct scsi_cmnd since the previous patches removed all users of that member of struct scsi_cmnd. Additionally, reorder the members of struct scsi_cmnd such that the statement that the field below can be modified by the SCSI LLD is again correct. Cc: Ming Lei Cc: Hannes Reinecke Cc: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Bart Van Assche --- include/scsi/scsi_cmnd.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index ff1c4b51f7ae..7a19c8bbaed9 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -123,11 +123,15 @@ struct scsi_cmnd { * command (auto-sense). Length must be * SCSI_SENSE_BUFFERSIZE bytes. */ + int flags; /* Command flags */ + unsigned long state; /* Command completion state */ + + unsigned int extra_len; /* length of alignment and padding */ + /* - * The following fields can be written to by the host specific code. - * Everything else should be left alone. + * The fields below can be modified by the LLD but the fields above + * must not be modified. */ - struct scsi_pointer SCp; /* Scratchpad used by some host adapters */ unsigned char *host_scribble; /* The host adapter is allowed to * call scsi_malloc and get some memory @@ -138,10 +142,6 @@ struct scsi_cmnd { * to be at an address < 16Mb). */ int result; /* Status code from lower level driver */ - int flags; /* Command flags */ - unsigned long state; /* Command completion state */ - - unsigned int extra_len; /* length of alignment and padding */ }; /* Variant of blk_mq_rq_from_pdu() that verifies the type of its argument. */