From patchwork Fri Jun 7 16:23:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Myron Stowe X-Patchwork-Id: 2688111 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A892A40077 for ; Fri, 7 Jun 2013 16:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756442Ab3FGQXr (ORCPT ); Fri, 7 Jun 2013 12:23:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18009 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756214Ab3FGQXp (ORCPT ); Fri, 7 Jun 2013 12:23:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r57GNglK022890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Jun 2013 12:23:42 -0400 Received: from amt.stowe (ovpn-113-153.phx2.redhat.com [10.3.113.153]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r57GNfUH003239; Fri, 7 Jun 2013 12:23:41 -0400 From: Myron Stowe Subject: [PATCH 2/3] [SCSI] megaraid: Remove local (struct pci_dev) pdev's To: megaraidlinux@lsi.com, JBottomley@parallels.com Cc: linux-scsi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 07 Jun 2013 10:23:41 -0600 Message-ID: <20130607162341.11205.76720.stgit@amt.stowe> In-Reply-To: <20130607162329.11205.95093.stgit@amt.stowe> References: <20130607162329.11205.95093.stgit@amt.stowe> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org With the driver now setup for default 32-bit DMA capabilities, remove the broken make_local_pdev() implementation and usages. Signed-off-by: Myron Stowe --- drivers/scsi/megaraid.c | 98 ++++++++--------------------------------------- 1 files changed, 16 insertions(+), 82 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 32cca61..316924c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -2023,29 +2023,6 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor) return FALSE; } -static inline int -make_local_pdev(adapter_t *adapter, struct pci_dev **pdev) -{ - *pdev = alloc_pci_dev(); - - if( *pdev == NULL ) return -1; - - memcpy(*pdev, adapter->dev, sizeof(struct pci_dev)); - - if( pci_set_dma_mask(*pdev, DMA_BIT_MASK(32)) != 0 ) { - kfree(*pdev); - return -1; - } - - return 0; -} - -static inline void -free_local_pdev(struct pci_dev *pdev) -{ - kfree(pdev); -} - /** * mega_allocate_inquiry() * @dma_handle - handle returned for dma address @@ -2209,13 +2186,10 @@ proc_show_rebuild_rate(struct seq_file *m, void *v) adapter_t *adapter = m->private; dma_addr_t dma_handle; caddr_t inquiry; - struct pci_dev *pdev; - - if( make_local_pdev(adapter, &pdev) != 0 ) - return 0; + struct pci_dev *pdev = adapter->dev; if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) - goto free_pdev; + return 0; if( mega_adapinq(adapter, dma_handle) != 0 ) { seq_puts(m, "Adapter inquiry failed.\n"); @@ -2233,8 +2207,6 @@ proc_show_rebuild_rate(struct seq_file *m, void *v) free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); -free_pdev: - free_local_pdev(pdev); return 0; } @@ -2252,14 +2224,11 @@ proc_show_battery(struct seq_file *m, void *v) adapter_t *adapter = m->private; dma_addr_t dma_handle; caddr_t inquiry; - struct pci_dev *pdev; + struct pci_dev *pdev = adapter->dev; u8 battery_status; - if( make_local_pdev(adapter, &pdev) != 0 ) - return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) - goto free_pdev; + return 0; if( mega_adapinq(adapter, dma_handle) != 0 ) { seq_printf(m, "Adapter inquiry failed.\n"); @@ -2308,8 +2277,6 @@ proc_show_battery(struct seq_file *m, void *v) free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); -free_pdev: - free_local_pdev(pdev); return 0; } @@ -2357,18 +2324,15 @@ proc_show_pdrv(struct seq_file *m, adapter_t *adapter, int channel) char *scsi_inq; dma_addr_t scsi_inq_dma_handle; caddr_t inquiry; - struct pci_dev *pdev; + struct pci_dev *pdev = adapter->dev; u8 *pdrv_state; u8 state; int tgt; int max_channels; int i; - if( make_local_pdev(adapter, &pdev) != 0 ) - return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) - goto free_pdev; + return 0; if( mega_adapinq(adapter, dma_handle) != 0 ) { seq_puts(m, "Adapter inquiry failed.\n"); @@ -2453,8 +2417,6 @@ free_pci: pci_free_consistent(pdev, 256, scsi_inq, scsi_inq_dma_handle); free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); -free_pdev: - free_local_pdev(pdev); return 0; } @@ -2533,17 +2495,14 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end ) char *disk_array; dma_addr_t disk_array_dma_handle; caddr_t inquiry; - struct pci_dev *pdev; + struct pci_dev *pdev = adapter->dev; u8 *rdrv_state; int num_ldrv; u32 array_sz; int i; - if( make_local_pdev(adapter, &pdev) != 0 ) - return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) - goto free_pdev; + return 0; if( mega_adapinq(adapter, dma_handle) != 0 ) { seq_puts(m, "Adapter inquiry failed.\n"); @@ -2694,8 +2653,6 @@ free_pci: disk_array_dma_handle); free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); -free_pdev: - free_local_pdev(pdev); return 0; } @@ -3164,6 +3121,7 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) return (-ENODEV); adapter = hba_soft_state[adapno]; + pdev = adapter->dev; /* * Deletion of logical drive is a special case. The adapter @@ -3208,12 +3166,10 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) /* * For all internal commands, the buffer must be allocated in - * <4GB address range + * <4GB address range. + * + * Is it a passthru command or a DCMD */ - if( make_local_pdev(adapter, &pdev) != 0 ) - return -EIO; - - /* Is it a passthru command or a DCMD */ if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) { /* Passthru commands */ @@ -3221,10 +3177,8 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) sizeof(mega_passthru), &pthru_dma_hndl); - if( pthru == NULL ) { - free_local_pdev(pdev); + if( pthru == NULL ) return (-ENOMEM); - } /* * The user passthru structure @@ -3241,8 +3195,6 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) sizeof(mega_passthru), pthru, pthru_dma_hndl); - free_local_pdev(pdev); - return (-EFAULT); } @@ -3260,8 +3212,6 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) pthru, pthru_dma_hndl); - free_local_pdev(pdev); - return (-ENOMEM); } @@ -3331,8 +3281,6 @@ freemem_and_return: pci_free_consistent(pdev, sizeof(mega_passthru), pthru, pthru_dma_hndl); - free_local_pdev(pdev); - return rval; } else { @@ -3345,10 +3293,8 @@ freemem_and_return: data = pci_alloc_consistent(pdev, uioc.xferlen, &data_dma_hndl); - if( data == NULL ) { - free_local_pdev(pdev); + if( data == NULL ) return (-ENOMEM); - } uxferaddr = MBOX(uioc)->xferaddr; } @@ -3367,8 +3313,6 @@ freemem_and_return: uioc.xferlen, data, data_dma_hndl); - free_local_pdev(pdev); - return (-EFAULT); } } @@ -3391,8 +3335,6 @@ freemem_and_return: data_dma_hndl); } - free_local_pdev(pdev); - return rval; } @@ -3413,8 +3355,6 @@ freemem_and_return: data_dma_hndl); } - free_local_pdev(pdev); - return rval; } @@ -4068,22 +4008,18 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt, dma_addr_t pthru_dma_handle; megacmd_t mc; int rval; - struct pci_dev *pdev; + struct pci_dev *pdev = adapter->dev; /* * For all internal commands, the buffer must be allocated in <4GB * address range */ - if( make_local_pdev(adapter, &pdev) != 0 ) return -1; - pthru = pci_alloc_consistent(pdev, sizeof(mega_passthru), &pthru_dma_handle); - if( pthru == NULL ) { - free_local_pdev(pdev); + if( pthru == NULL ) return -1; - } pthru->timeout = 2; pthru->ars = 1; @@ -4117,8 +4053,6 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt, pci_free_consistent(pdev, sizeof(mega_passthru), pthru, pthru_dma_handle); - free_local_pdev(pdev); - return rval; } #endif