From patchwork Sat Jul 9 00:10:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Schmitz X-Patchwork-Id: 12912004 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 0D663CCA47B for ; Sat, 9 Jul 2022 00:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbiGIAKd (ORCPT ); Fri, 8 Jul 2022 20:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbiGIAKb (ORCPT ); Fri, 8 Jul 2022 20:10:31 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 239357AB35; Fri, 8 Jul 2022 17:10:28 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id i190so242271pge.7; Fri, 08 Jul 2022 17:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QSLBth1UAZoBdoCqm60VueY2vh2tMmMd00GyQMuP4pM=; b=fyqQ0kmQym1qJMzxFDJcXdWrvlEeq/kKMKzXoSjgTwx+lxne5bQloX9z7FWl3Ivvs4 LvRV1PCTOMHl5I8UouFypkEEgOvFW6vF6kbLDFE/oer1jzVi01eAwnmtplhgM1Hvz5J+ QOglfCtgzqi+B6xKzhMGinG5P7EADMOvQGyI+1oMBBcviZw8xq+gokFVtO+DjgL5G+vk yj+gWQkw3NaYbw89LqQVRn+m5leMlArKIHVJZBPHjUy3g94eYyC9zBAJ+BYKSxgoZzLB +GEl2qzJyiYrTejkLRz1RfPd4Bw3zBY/JkJQ5180FEsdNXGvF2fKxzPpzCWYhS1PCmgU MHKw== 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; bh=QSLBth1UAZoBdoCqm60VueY2vh2tMmMd00GyQMuP4pM=; b=hs41R1aCd5a/xIu+YvsMnTOQAkgK4k1pQvA1dnskpoo0+vgptrBJwXuTM9f9rfHwsd NJA6zjjwXL5BgB4gtYWZ96hHHG1kOULbvOxqf9FYVj7rUf2IcDJyKfNUNcHQ2bAP9x0o LHbfGKI6L4Zw1M3AXzH0M0mvTMg2cTWBRQkdFGy5q/otur09P0OpGo0wrEfBHrwwtpHl mGYZHwDQBJKGxIo7FA02S1ocvTD1BovaTbA62Cws18i4OvnxWrYAqOELwXilUXgyH4f8 ft2TaxIy7GGYjVqZHEu93rESIghltYnOEmpPDHBW7rSUpgJbvry4fi8Q33hFKXkaP5wl Os5w== X-Gm-Message-State: AJIora+DjWgpdOP+OHju5Ha7iGok4oMfJVuy5nTH6K6+RvD989ziSTqP /Sba5+c3F/9eV+8iTPLyaTOcJzMbgak= X-Google-Smtp-Source: AGRyM1vBVCVVGdL5Ri1rNTj/rq6K2W59YePwQ6w+jAmwdPF2BYg7xmdVjCx1ygpAXAJDnfifPZQTtg== X-Received: by 2002:a65:6bc4:0:b0:3c2:2f7c:cc74 with SMTP id e4-20020a656bc4000000b003c22f7ccc74mr5380188pgw.307.1657325425939; Fri, 08 Jul 2022 17:10:25 -0700 (PDT) Received: from xplor.waratah.dyndns.org (222-155-0-244-adsl.sparkbb.co.nz. [222.155.0.244]) by smtp.gmail.com with ESMTPSA id y11-20020aa79aeb000000b0052ab3039c4esm176297pfp.8.2022.07.08.17.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 17:10:25 -0700 (PDT) Received: by xplor.waratah.dyndns.org (Postfix, from userid 1000) id 2742C360331; Sat, 9 Jul 2022 12:10:22 +1200 (NZST) From: Michael Schmitz To: linux-m68k@vger.kernel.org, arnd@kernel.org Cc: linux-scsi@vger.kernel.org, geert@linux-m68k.org, Michael Schmitz Subject: [PATCH v1 1/4] m68k - add MVME147 SCSI base address to mvme147hw.h Date: Sat, 9 Jul 2022 12:10:16 +1200 Message-Id: <20220709001019.11149-2-schmitzmic@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220709001019.11149-1-schmitzmic@gmail.com> References: <20220709001019.11149-1-schmitzmic@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The base address for the WD33C93 SCSI host adapter on mvme147 boards is missing from mvme147hw.h. This information will be needed for platform device conversion of the mvme147_scsi driver, so add it here. CC: linux-scsi@vger.kernel.org Link: https://lore.kernel.org/r/6d1d88ee-1cf6-c735-1e6d-bafd2096e322@gmail.com Signed-off-by: Michael Schmitz --- arch/m68k/include/asm/mvme147hw.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/m68k/include/asm/mvme147hw.h b/arch/m68k/include/asm/mvme147hw.h index e28eb1c0e0bf..fd8c1e4fc7be 100644 --- a/arch/m68k/include/asm/mvme147hw.h +++ b/arch/m68k/include/asm/mvme147hw.h @@ -93,6 +93,7 @@ struct pcc_regs { #define M147_SCC_B_ADDR 0xfffe3000 #define M147_SCC_PCLK 5000000 +#define MVME147_SCSI_BASE 0xfffe4000 #define MVME147_IRQ_SCSI_PORT (IRQ_USER+0x45) #define MVME147_IRQ_SCSI_DMA (IRQ_USER+0x46) From patchwork Sat Jul 9 00:10:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Schmitz X-Patchwork-Id: 12912005 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 3CD22C433EF for ; Sat, 9 Jul 2022 00:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiGIAKe (ORCPT ); Fri, 8 Jul 2022 20:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbiGIAKb (ORCPT ); Fri, 8 Jul 2022 20:10:31 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B6887CB43; Fri, 8 Jul 2022 17:10:28 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id g4so283827pgc.1; Fri, 08 Jul 2022 17:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=llxMpF9nJlCaL45HHzQOxFiHqiNr+0CVyGM12/RbJls=; b=Hdgmru4azIMCHkiN7WWiKRHznIdDne2GBhYrDXJ89u8nbvR1APuC4Kf4ifKi2Ed/MW NOb/b2juQIHSw6VWfzi4qE83Y7a0OwoSF6wK5DxbhiNc5Fy5X56BrM0hF+rxwyl0QdRZ QysmeBSEFy9hjb9bEJlOdMnuo+KXniu+uS1H9ePzv+UiLmgeB5qJATN5k6FET7gaOt10 AtRBrcY2fVENx2WRPxsOjuPyDdPXFG98NXfITJ/rnNNsjN29mC6wMW55QPSCm/hlnCyV BJ7Cllef+SL0O3GLi57Q4sFTsxSsc/6oeBNIOzeHPRA7w3paTWlronus2w4Opy6jGmj8 ii0w== 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; bh=llxMpF9nJlCaL45HHzQOxFiHqiNr+0CVyGM12/RbJls=; b=tvnNKatjEWgxHhDzB/cacNBTYR6lqBLGbCxX+cYidA2VXkHK8xsKEiLhvvhaJ3f6f4 Hd235D+cb80gyndLucxgDY3u9/aIYcmNPbG11Gl1xo4rc7Motrf5/5kHFTjR3+bYnn/F X+HSXj7e5qIDWbk2tw0Wi4YYxzHQP7nLiumK0rUXvAmU72jOc0buFfzDK60gfigOVrXH qaQlu1TGBojxt/WJhJJ5M5vGdupbPpjZVeOjfH38l5Y+qXtb1d+8YQqEH/d4/J9NLUAw JiZRnD6Q9LiG6bb0SmyEmiHk9mrE6dpxG20cOGumkNrX4/ZHP1/HancXmiwvsaY8mHa7 icCw== X-Gm-Message-State: AJIora8cf22cctPd4ZGZZhhM+BXicJwhkn7NysRq6WDBrj1Vwb6JdZsd fvhx1C9aP39vZiVCDiEqpwo= X-Google-Smtp-Source: AGRyM1s2vof3t0moifI8p42i6NgbdqmXAsLOiroR+B91T6gAajr8uSb2d1SJdxCgF12VpE+fi+5J+A== X-Received: by 2002:a05:6a00:c92:b0:525:8782:71f2 with SMTP id a18-20020a056a000c9200b00525878271f2mr6509820pfv.50.1657325426791; Fri, 08 Jul 2022 17:10:26 -0700 (PDT) Received: from xplor.waratah.dyndns.org (222-155-0-244-adsl.sparkbb.co.nz. [222.155.0.244]) by smtp.gmail.com with ESMTPSA id a10-20020aa78e8a000000b00528c22038f5sm179850pfr.14.2022.07.08.17.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 17:10:26 -0700 (PDT) Received: by xplor.waratah.dyndns.org (Postfix, from userid 1000) id D07F4360333; Sat, 9 Jul 2022 12:10:22 +1200 (NZST) From: Michael Schmitz To: linux-m68k@vger.kernel.org, arnd@kernel.org Cc: linux-scsi@vger.kernel.org, geert@linux-m68k.org, Michael Schmitz Subject: [PATCH v1 2/4] m68k - set up platform device for mvme147_scsi Date: Sat, 9 Jul 2022 12:10:17 +1200 Message-Id: <20220709001019.11149-3-schmitzmic@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220709001019.11149-1-schmitzmic@gmail.com> References: <20220709001019.11149-1-schmitzmic@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Set up a platform device for the mvme147_scsi driver. The platform device is required for conversion of the driver to the DMA API. CC: linux-scsi@vger.kernel.org Link: https://lore.kernel.org/r/6d1d88ee-1cf6-c735-1e6d-bafd2096e322@gmail.com Signed-off-by: Michael Schmitz Reported-by: kernel test robot --- arch/m68k/mvme147/config.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c index 4e6218115f43..c6e7dfe3eb54 100644 --- a/arch/m68k/mvme147/config.c +++ b/arch/m68k/mvme147/config.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -188,3 +189,23 @@ int mvme147_hwclk(int op, struct rtc_time *t) } return 0; } + +static const struct resource mvme147_scsi_rsrc[] __initconst = { + DEFINE_RES_MEM(MVME147_SCSI_BASE, 0xff), + DEFINE_RES_IRQ(MVME147_IRQ_SCSI_PORT), +}; + +int __init mvme147_platform_init(void) +{ + struct platform_device *pdev; + int rv = 0; + + pdev = platform_device_register_simple("mvme147-scsi", -1, + mvme147_scsi_rsrc, ARRAY_SIZE(mvme147_scsi_rsrc)); + if (IS_ERR(pdev)) + rv = PTR_ERR(pdev); + + return rv; +} + +arch_initcall(mvme147_platform_init); From patchwork Sat Jul 9 00:10:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Schmitz X-Patchwork-Id: 12912006 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 F305FCCA47B for ; Sat, 9 Jul 2022 00:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiGIAKg (ORCPT ); Fri, 8 Jul 2022 20:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiGIAKb (ORCPT ); Fri, 8 Jul 2022 20:10:31 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D577CB45; Fri, 8 Jul 2022 17:10:28 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id r1so85543plo.10; Fri, 08 Jul 2022 17:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9ULivGPT7hmqeNxcKMPRUFSX3KZmis0fdluyTBOTsWs=; b=YCFPYOBgwKKExSXr6X3TeGB17Nq4yWdSznIm9MQXTjXJIz7sxg6fM7uQhO6/aCIHbc j+Jk6h5UOV0DLEbnTkbnkxLhuidDDIwCnfpjgwhlxYZG7bbU5C8Zj1ktZ6CFEGLmVluU TqvOwQUencW1B5zAQrgoNun7FUEN0FwUXLeK8OSj1R4in0/BYyxM4fAz+JSAfu3kE/KH uZAgF4D4dXTsKb66b5z45m70xvg/Gy/waHfgE4gHMAoR794UliKn9Hl3DlnCVIHsp7oV PjbP4zruIEDg+Xb9ekVCWhdTd+oWw8ndrmfoa6cE3WI3sQUHiGccyy2Rhq3VqQClQokZ cIDQ== 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; bh=9ULivGPT7hmqeNxcKMPRUFSX3KZmis0fdluyTBOTsWs=; b=mmggTzR36HnMRDXGHWXUUcwUJZeLr1ZAD+OpCS6elWd6a/YKXjT2dmac0KsNC7+4lK yPtWBey4q5dvvqZwHPwHoGyAMNbz1I81hxUcpf1VYxtK8ren3FZul9/AvNpsjCt1+IY9 qJAIslcprN/IcpsLQ/870pjOB5g/in0uMFq5moOwPj/8n8a8imEr5UE1jwOVPr5BuyJV mdYGsnDmWAu1lGUL8JLDH+5Eks0apAIQZ4osZfA6Q32LpWXuzFgFFqBsE3yksuMC91CP zM8/IFE0MEefMfi94rPiaFd0Dy+dRjrD/D5qCqCDLa6XDUNus5Jy9ZSAD/2QUgcBPfKr sB/w== X-Gm-Message-State: AJIora/3qOoh0r60iMM8A3avPpybyuvHYC2S7+dHc8CnhWl917kmg+6D oqHNZxv9iOSRZqKB3X6EMPs= X-Google-Smtp-Source: AGRyM1uaprUB93915oK6sLdVf2PqUYRBd2Yd34JJG5ahp7uTuy0V2X/siKN9XW7Be0DF/dEMcHwycw== X-Received: by 2002:a17:902:f54e:b0:16a:75a9:9a39 with SMTP id h14-20020a170902f54e00b0016a75a99a39mr6161963plf.70.1657325427588; Fri, 08 Jul 2022 17:10:27 -0700 (PDT) Received: from xplor.waratah.dyndns.org (222-155-0-244-adsl.sparkbb.co.nz. [222.155.0.244]) by smtp.gmail.com with ESMTPSA id b4-20020a1709027e0400b0016b81679c2asm93579plm.214.2022.07.08.17.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 17:10:27 -0700 (PDT) Received: by xplor.waratah.dyndns.org (Postfix, from userid 1000) id B003A3603F6; Sat, 9 Jul 2022 12:10:23 +1200 (NZST) From: Michael Schmitz To: linux-m68k@vger.kernel.org, arnd@kernel.org Cc: linux-scsi@vger.kernel.org, geert@linux-m68k.org, Michael Schmitz Subject: [PATCH v1 3/4] scsi - convert mvme146_scsi.c to platform device Date: Sat, 9 Jul 2022 12:10:18 +1200 Message-Id: <20220709001019.11149-4-schmitzmic@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220709001019.11149-1-schmitzmic@gmail.com> References: <20220709001019.11149-1-schmitzmic@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Convert the mvme147_scsi driver to a platform device driver. This is required for conversion of the driver to the DMA API. CC: linux-scsi@vger.kernel.org Link: https://lore.kernel.org/r/6d1d88ee-1cf6-c735-1e6d-bafd2096e322@gmail.com Signed-off-by: Michael Schmitz --- drivers/scsi/mvme147.c | 86 ++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index 472fa043094f..aa6476c3e70c 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -85,40 +86,50 @@ static struct scsi_host_template mvme147_host_template = { .cmd_size = sizeof(struct scsi_pointer), }; -static struct Scsi_Host *mvme147_shost; - -static int __init mvme147_init(void) +static int __init mvme147_scsi_probe(struct platform_device *pdev) { + struct resource *mres, *ires; + struct Scsi_Host *mvme147_inst; wd33c93_regs regs; struct WD33C93_hostdata *hdata; int error = -ENOMEM; - if (!MACH_IS_MVME147) - return 0; + mres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mres) + return -ENODEV; + + ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!ires) + return -ENODEV; + + if (!request_mem_region(mres->start, resource_size(mres), "wd33c93")) + return -EBUSY; - mvme147_shost = scsi_host_alloc(&mvme147_host_template, + mvme147_inst = scsi_host_alloc(&mvme147_host_template, sizeof(struct WD33C93_hostdata)); - if (!mvme147_shost) + if (!mvme147_inst) goto err_out; - mvme147_shost->base = 0xfffe4000; - mvme147_shost->irq = MVME147_IRQ_SCSI_PORT; - regs.SASR = (volatile unsigned char *)0xfffe4000; - regs.SCMD = (volatile unsigned char *)0xfffe4001; - hdata = shost_priv(mvme147_shost); + mvme147_inst->base = mres->start; + mvme147_inst->irq = ires->start; + + regs.SASR = (volatile unsigned char *)mres->start; + regs.SCMD = (volatile unsigned char *)(mres->start)+0x1; + + hdata = shost_priv(mvme147_inst); hdata->no_sync = 0xff; hdata->fast = 0; hdata->dma_mode = CTRL_DMA; - wd33c93_init(mvme147_shost, regs, dma_setup, dma_stop, WD33C93_FS_8_10); + wd33c93_init(mvme147_inst, regs, dma_setup, dma_stop, WD33C93_FS_8_10); - error = request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0, - "MVME147 SCSI PORT", mvme147_shost); + error = request_irq(ires->start, mvme147_intr, 0, + "MVME147 SCSI PORT", mvme147_inst); if (error) goto err_unregister; - error = request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0, - "MVME147 SCSI DMA", mvme147_shost); + error = request_irq(ires->start+1, mvme147_intr, 0, + "MVME147 SCSI DMA", mvme147_inst); if (error) goto err_free_irq; #if 0 /* Disabled; causes problems booting */ @@ -133,30 +144,49 @@ static int __init mvme147_init(void) m147_pcc->dma_cntrl = 0x00; /* ensure DMA is stopped */ m147_pcc->dma_intr = 0x89; /* Ack and enable ints */ - error = scsi_add_host(mvme147_shost, NULL); + error = scsi_add_host(mvme147_inst, &pdev->dev); if (error) goto err_free_irq; - scsi_scan_host(mvme147_shost); + + platform_set_drvdata(pdev, mvme147_inst); + + scsi_scan_host(mvme147_inst); return 0; err_free_irq: - free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost); + free_irq(ires->start, mvme147_inst); err_unregister: - scsi_host_put(mvme147_shost); + scsi_host_put(mvme147_inst); err_out: return error; } -static void __exit mvme147_exit(void) +static int __exit mvme147_scsi_remove(struct platform_device *pdev) { - scsi_remove_host(mvme147_shost); + struct Scsi_Host *mvme147_inst = platform_get_drvdata(pdev); + struct resource *mres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + struct resource *ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + + scsi_remove_host(mvme147_inst); /* XXX Make sure DMA is stopped! */ - free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost); - free_irq(MVME147_IRQ_SCSI_DMA, mvme147_shost); + free_irq(ires->start, mvme147_inst); + free_irq(ires->start+1, mvme147_inst); - scsi_host_put(mvme147_shost); + scsi_host_put(mvme147_inst); + release_mem_region(mres->start, resource_size(mres)); + return 0; } -module_init(mvme147_init); -module_exit(mvme147_exit); +static struct platform_driver mvme147_scsi_driver = { + .remove = __exit_p(mvme147_scsi_remove), + .driver = { + .name = "mvme147-scsi", + }, +}; + +module_platform_driver_probe(mvme147_scsi_driver, mvme147_scsi_probe); + +MODULE_DESCRIPTION("MVME147 built-in SCSI"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:mvme147-scsi"); From patchwork Sat Jul 9 00:10:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Schmitz X-Patchwork-Id: 12912007 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 6B09BCCA481 for ; Sat, 9 Jul 2022 00:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229952AbiGIAKg (ORCPT ); Fri, 8 Jul 2022 20:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbiGIAKc (ORCPT ); Fri, 8 Jul 2022 20:10:32 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D800B7CB50; Fri, 8 Jul 2022 17:10:29 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id g4so283862pgc.1; Fri, 08 Jul 2022 17:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ufXk8FbbGAqNsL++C+ffXL+0StpdtfyJkwi67F2ahYw=; b=Rq/GFAsLj8kSzJYEU2j8mS+M5B69zt5z8Zctz9L0pLE4sGqBuvhOLlcEWjcf3SKmqQ PoGuBOdmF/Ap+eM6yTangUVgJRwm8FPV7n0509PdAt/rkhHihqttz7IJz3pN/lUi/w+X nk2qE/8EBwLndEYcEJUKK0pboHEnKBodFAP42f0+9FPeP2xGBAxwcUKZRsZF4Yeqa8// UwxQ34ndwTFaq0pLtwm/srAYwSTpAPkbHDsULSdDj6j840j/XEuTA89xAW6VR5VJUS1U roiFFbDUx4sHckbVgAEYPnTs2BRlSnVZHY6haLowGMJoS3brLxQ6slpPX5zqh0nO1meB X6nA== 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; bh=ufXk8FbbGAqNsL++C+ffXL+0StpdtfyJkwi67F2ahYw=; b=Ec4SJUXyM2PzNTkrHnywrpX6RXHTpq1fBCgjL7Memz92RA4j+uA8FqKS/jNrHK85AE kVWJJ2ZxkdFKxQ/5HyctrhnwdLht7cRq4iQdXM9i8eEeHDeaU8wtuRlJQxcUzBbUtXw5 BlCqD42IJ4mSmyXfA67ntwdxcuJnWMvIAtuYs77Ldg/w4p9O80ao7Lt+n0/yTWl7OECV ZLsRAQ4ic0U8ajehSnlWqzwfQJ7CFEUHu+w80gdwSfvPPJpk5q1kYKQ22HFea+wsPWZT +t/loJ2IPwQrYahR0kukj2g6FE8Z1Mooo987H99Ohj9E1wnH4GsnPCgzOVQLMG+By5mY JpZg== X-Gm-Message-State: AJIora/ouj4s4T+e4ATwzwRV83TmY7dw9dq0nNwuBfJvAfdXDb27q9ET hjQFRlNIWIRetebOgu9M590utaUMfq8= X-Google-Smtp-Source: AGRyM1tCDgyLLNh5+7wuKqZxI7GFhu6lVWZpMqphcumkOhPn5wiEtChcUN+PVc0rhtIyJhx4ieAXIg== X-Received: by 2002:a05:6a02:113:b0:412:a7c0:da8e with SMTP id bg19-20020a056a02011300b00412a7c0da8emr5646066pgb.113.1657325428257; Fri, 08 Jul 2022 17:10:28 -0700 (PDT) Received: from xplor.waratah.dyndns.org (222-155-0-244-adsl.sparkbb.co.nz. [222.155.0.244]) by smtp.gmail.com with ESMTPSA id e25-20020aa79819000000b00528d580cb45sm157054pfl.127.2022.07.08.17.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 17:10:27 -0700 (PDT) Received: by xplor.waratah.dyndns.org (Postfix, from userid 1000) id B1FDD3603FB; Sat, 9 Jul 2022 12:10:24 +1200 (NZST) From: Michael Schmitz To: linux-m68k@vger.kernel.org, arnd@kernel.org Cc: linux-scsi@vger.kernel.org, geert@linux-m68k.org, Michael Schmitz Subject: [PATCH v1 4/4] scsi - convert mvme147_scsi driver to DMA API Date: Sat, 9 Jul 2022 12:10:19 +1200 Message-Id: <20220709001019.11149-5-schmitzmic@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220709001019.11149-1-schmitzmic@gmail.com> References: <20220709001019.11149-1-schmitzmic@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Convert mvme147_scsi to DMA API to eliminate one of the last usages of virt_to_bus(). CC: linux-scsi@vger.kernel.org Link: https://lore.kernel.org/r/6d1d88ee-1cf6-c735-1e6d-bafd2096e322@gmail.com Signed-off-by: Michael Schmitz --- drivers/scsi/mvme147.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index aa6476c3e70c..6ffd15f08629 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -21,6 +21,8 @@ #include "wd33c93.h" #include "mvme147.h" +#define DMA_DIR(d) ((d == DATA_OUT_DIR) ? DMA_TO_DEVICE : DMA_FROM_DEVICE) + static irqreturn_t mvme147_intr(int irq, void *data) { struct Scsi_Host *instance = data; @@ -35,10 +37,20 @@ 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); + unsigned long len = scsi_pointer->this_residual; struct Scsi_Host *instance = cmd->device->host; struct WD33C93_hostdata *hdata = shost_priv(instance); unsigned char flags = 0x01; - unsigned long addr = virt_to_bus(scsi_pointer->ptr); + dma_addr_t addr; + + addr = dma_map_single(instance->dma_dev, scsi_pointer->ptr, + len, DMA_DIR(dir_in)); + if (dma_mapping_error(instance->dma_dev, addr)) { + dev_warn(instance->dma_dev, "cannot map SCSI data block %p\n", + scsi_pointer->ptr); + return 1; + } + scsi_pointer->dma_handle = addr; /* setup dma direction */ if (!dir_in) @@ -47,14 +59,6 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) /* remember direction */ hdata->dma_dir = dir_in; - if (dir_in) { - /* invalidate any cache */ - cache_clear(addr, scsi_pointer->this_residual); - } else { - /* push any dirty cache */ - cache_push(addr, scsi_pointer->this_residual); - } - /* start DMA */ m147_pcc->dma_bcr = scsi_pointer->this_residual | (1 << 24); m147_pcc->dma_dadr = addr; @@ -67,7 +71,13 @@ 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 WD33C93_hostdata *hdata = shost_priv(instance); + m147_pcc->dma_cntrl = 0; + dma_unmap_single(instance->dma_dev, scsi_pointer->dma_handle, + scsi_pointer->this_residual, + DMA_DIR(hdata->dma_dir)); } static struct scsi_host_template mvme147_host_template = { @@ -94,6 +104,11 @@ static int __init mvme147_scsi_probe(struct platform_device *pdev) struct WD33C93_hostdata *hdata; int error = -ENOMEM; + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) { + dev_warn(&pdev->dev, "cannot use 32 bit DMA\n"); + return -ENODEV; + } + mres = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mres) return -ENODEV;