* [PATCH 00/22] Add and use pci_zalloc_consistent
@ 2014-06-23 13:41 Joe Perches
2014-06-23 13:41 ` [PATCH 19/22] scsi: Use pci_zalloc_consistent Joe Perches
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Joe Perches @ 2014-06-23 13:41 UTC (permalink / raw)
To: linux-kernel
Cc: devel, linux-arch, linux-scsi, iss_storagedev, linux-rdma, netdev,
linux-atm-general, linux-wireless, dri-devel, linux-crypto,
linux-eata, linux-media
Adding the helper reduces object code size as well as overall
source size line count.
It's also consistent with all the various zalloc mechanisms
in the kernel.
Done with a simple cocci script and some typing.
Joe Perches (22):
pci-dma-compat: Add pci_zalloc_consistent helper
atm: Use pci_zalloc_consistent
block: Use pci_zalloc_consistent
crypto: Use pci_zalloc_consistent
infiniband: Use pci_zalloc_consistent
i810: Use pci_zalloc_consistent
media: Use pci_zalloc_consistent
amd: Use pci_zalloc_consistent
atl1e: Use pci_zalloc_consistent
enic: Use pci_zalloc_consistent
sky2: Use pci_zalloc_consistent
micrel: Use pci_zalloc_consistent
qlogic: Use pci_zalloc_consistent
irda: Use pci_zalloc_consistent
ipw2100: Use pci_zalloc_consistent
mwl8k: Use pci_zalloc_consistent
rtl818x: Use pci_zalloc_consistent
rtlwifi: Use pci_zalloc_consistent
scsi: Use pci_zalloc_consistent
staging: Use pci_zalloc_consistent
synclink_gt: Use pci_zalloc_consistent
vme: bridges: Use pci_zalloc_consistent
drivers/atm/he.c | 31 ++++++++---------
drivers/atm/idt77252.c | 15 ++++----
drivers/block/DAC960.c | 18 +++++-----
drivers/block/cciss.c | 11 +++---
drivers/block/skd_main.c | 25 +++++---------
drivers/crypto/hifn_795x.c | 5 ++-
drivers/gpu/drm/i810/i810_dma.c | 5 ++-
drivers/infiniband/hw/amso1100/c2.c | 6 ++--
drivers/infiniband/hw/nes/nes_hw.c | 12 +++----
drivers/infiniband/hw/nes/nes_verbs.c | 5 ++-
drivers/media/common/saa7146/saa7146_core.c | 15 ++++----
drivers/media/common/saa7146/saa7146_fops.c | 5 +--
drivers/media/pci/bt8xx/bt878.c | 16 +++------
drivers/media/pci/ngene/ngene-core.c | 7 ++--
drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 11 ++----
drivers/media/usb/ttusb-dec/ttusb_dec.c | 11 ++----
drivers/net/ethernet/amd/pcnet32.c | 16 ++++-----
drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 7 ++--
drivers/net/ethernet/cisco/enic/vnic_dev.c | 8 ++---
drivers/net/ethernet/marvell/sky2.c | 5 ++-
drivers/net/ethernet/micrel/ksz884x.c | 7 ++--
.../net/ethernet/qlogic/netxen/netxen_nic_ctx.c | 4 +--
drivers/net/ethernet/qlogic/qlge/qlge_main.c | 11 +++---
drivers/net/irda/vlsi_ir.c | 4 +--
drivers/net/wireless/ipw2x00/ipw2100.c | 16 +++------
drivers/net/wireless/mwl8k.c | 6 ++--
drivers/net/wireless/rtl818x/rtl8180/dev.c | 11 +++---
drivers/net/wireless/rtlwifi/pci.c | 17 +++------
drivers/scsi/3w-sas.c | 5 ++-
drivers/scsi/a100u2w.c | 8 ++---
drivers/scsi/be2iscsi/be_main.c | 10 +++---
drivers/scsi/be2iscsi/be_mgmt.c | 3 +-
drivers/scsi/csiostor/csio_wr.c | 8 +----
drivers/scsi/eata.c | 5 ++-
drivers/scsi/hpsa.c | 8 ++---
drivers/scsi/megaraid/megaraid_mbox.c | 16 ++++-----
drivers/scsi/megaraid/megaraid_sas_base.c | 8 ++---
drivers/scsi/mesh.c | 6 ++--
drivers/scsi/mvumi.c | 9 ++---
drivers/scsi/pm8001/pm8001_sas.c | 5 ++-
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 15 +++-----
drivers/staging/rtl8192ee/pci.c | 37 +++++++-------------
drivers/staging/rtl8821ae/pci.c | 36 +++++++------------
drivers/staging/slicoss/slicoss.c | 9 ++---
drivers/staging/vt6655/device_main.c | 40 +++++++---------------
drivers/tty/synclink_gt.c | 5 ++-
drivers/vme/bridges/vme_ca91cx42.c | 6 ++--
drivers/vme/bridges/vme_tsi148.c | 6 ++--
include/asm-generic/pci-dma-compat.h | 8 +++++
49 files changed, 209 insertions(+), 354 deletions(-)
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 19/22] scsi: Use pci_zalloc_consistent
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
@ 2014-06-23 13:41 ` Joe Perches
2014-06-23 17:25 ` [PATCH 00/22] Add and use pci_zalloc_consistent Luis R. Rodriguez
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2014-06-23 13:41 UTC (permalink / raw)
To: linux-kernel
Cc: Adam Radford, James E.J. Bottomley, Jayamohan Kallickal,
Dario Ballabio, Michael Neuffer, Stephen M. Cameron,
Neela Syam Kolli, xjtuwjp, lindar_liu, linux-scsi, linux-eata,
iss_storagedev
Remove the now unnecessary memset too.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/scsi/3w-sas.c | 5 ++---
drivers/scsi/a100u2w.c | 8 ++------
drivers/scsi/be2iscsi/be_main.c | 10 ++++------
drivers/scsi/be2iscsi/be_mgmt.c | 3 +--
drivers/scsi/csiostor/csio_wr.c | 8 +-------
drivers/scsi/eata.c | 5 ++---
drivers/scsi/hpsa.c | 8 +++-----
drivers/scsi/megaraid/megaraid_mbox.c | 16 +++++++---------
drivers/scsi/megaraid/megaraid_sas_base.c | 8 +++-----
drivers/scsi/mesh.c | 6 ++----
drivers/scsi/mvumi.c | 9 +++------
drivers/scsi/pm8001/pm8001_sas.c | 5 ++---
12 files changed, 32 insertions(+), 59 deletions(-)
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 4de3460..6da6cec 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -683,14 +683,13 @@ static int twl_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
unsigned long *cpu_addr;
int retval = 1;
- cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle);
+ cpu_addr = pci_zalloc_consistent(tw_dev->tw_pci_dev, size * TW_Q_LENGTH,
+ &dma_handle);
if (!cpu_addr) {
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
goto out;
}
- memset(cpu_addr, 0, size*TW_Q_LENGTH);
-
for (i = 0; i < TW_Q_LENGTH; i++) {
switch(which) {
case 0:
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index 0163457..d1474611 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -1125,23 +1125,19 @@ static int inia100_probe_one(struct pci_dev *pdev,
/* Get total memory needed for SCB */
sz = ORC_MAXQUEUE * sizeof(struct orc_scb);
- host->scb_virt = pci_alloc_consistent(pdev, sz,
- &host->scb_phys);
+ host->scb_virt = pci_zalloc_consistent(pdev, sz, &host->scb_phys);
if (!host->scb_virt) {
printk("inia100: SCB memory allocation error\n");
goto out_host_put;
}
- memset(host->scb_virt, 0, sz);
/* Get total memory needed for ESCB */
sz = ORC_MAXQUEUE * sizeof(struct orc_extended_scb);
- host->escb_virt = pci_alloc_consistent(pdev, sz,
- &host->escb_phys);
+ host->escb_virt = pci_zalloc_consistent(pdev, sz, &host->escb_phys);
if (!host->escb_virt) {
printk("inia100: ESCB memory allocation error\n");
goto out_free_scb_array;
}
- memset(host->escb_virt, 0, sz);
biosaddr = host->BIOScfg;
biosaddr = (biosaddr << 4);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 5543490..e08def2 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3538,10 +3538,9 @@ static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q,
q->len = len;
q->entry_size = entry_size;
mem->size = len * entry_size;
- mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma);
+ mem->va = pci_zalloc_consistent(phba->pcidev, mem->size, &mem->dma);
if (!mem->va)
return -ENOMEM;
- memset(mem->va, 0, mem->size);
return 0;
}
@@ -4318,9 +4317,9 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
"BM_%d : No boot session\n");
return ret;
}
- nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
- sizeof(*session_resp),
- &nonemb_cmd.dma);
+ nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
+ sizeof(*session_resp),
+ &nonemb_cmd.dma);
if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR,
BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
@@ -4330,7 +4329,6 @@ static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
return -ENOMEM;
}
- memset(nonemb_cmd.va, 0, sizeof(*session_resp));
tag = mgmt_get_session_info(phba, s_handle,
&nonemb_cmd);
if (!tag) {
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 6045aa7..49bf8fb 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -900,13 +900,12 @@ free_cmd:
static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd,
int iscsi_cmd, int size)
{
- cmd->va = pci_alloc_consistent(phba->ctrl.pdev, size, &cmd->dma);
+ cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma);
if (!cmd->va) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BG_%d : Failed to allocate memory for if info\n");
return -ENOMEM;
}
- memset(cmd->va, 0, size);
cmd->size = size;
be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size);
return 0;
diff --git a/drivers/scsi/csiostor/csio_wr.c b/drivers/scsi/csiostor/csio_wr.c
index 4255ce2..773da14 100644
--- a/drivers/scsi/csiostor/csio_wr.c
+++ b/drivers/scsi/csiostor/csio_wr.c
@@ -232,7 +232,7 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize,
q = wrm->q_arr[free_idx];
- q->vstart = pci_alloc_consistent(hw->pdev, qsz, &q->pstart);
+ q->vstart = pci_zalloc_consistent(hw->pdev, qsz, &q->pstart);
if (!q->vstart) {
csio_err(hw,
"Failed to allocate DMA memory for "
@@ -240,12 +240,6 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize,
return -1;
}
- /*
- * We need to zero out the contents, importantly for ingress,
- * since we start with a generatiom bit of 1 for ingress.
- */
- memset(q->vstart, 0, qsz);
-
q->type = type;
q->owner = owner;
q->pidx = q->cidx = q->inc_idx = 0;
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index ebf5736..e3f746d 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -1238,8 +1238,8 @@ static int port_detect(unsigned long port_base, unsigned int j,
struct eata_config *cf;
dma_addr_t cf_dma_addr;
- cf = pci_alloc_consistent(pdev, sizeof(struct eata_config),
- &cf_dma_addr);
+ cf = pci_zalloc_consistent(pdev, sizeof(struct eata_config),
+ &cf_dma_addr);
if (!cf) {
printk
@@ -1249,7 +1249,6 @@ static int port_detect(unsigned long port_base, unsigned int j,
}
/* Set board configuration */
- memset((char *)cf, 0, sizeof(struct eata_config));
cf->len = (ushort) H2DEV16((ushort) 510);
cf->ocena = 1;
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 31184b3..5c465cd 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4731,23 +4731,21 @@ static struct CommandList *cmd_special_alloc(struct ctlr_info *h)
union u64bit temp64;
dma_addr_t cmd_dma_handle, err_dma_handle;
- c = pci_alloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle);
+ c = pci_zalloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle);
if (c == NULL)
return NULL;
- memset(c, 0, sizeof(*c));
c->cmd_type = CMD_SCSI;
c->cmdindex = -1;
- c->err_info = pci_alloc_consistent(h->pdev, sizeof(*c->err_info),
- &err_dma_handle);
+ c->err_info = pci_zalloc_consistent(h->pdev, sizeof(*c->err_info),
+ &err_dma_handle);
if (c->err_info == NULL) {
pci_free_consistent(h->pdev,
sizeof(*c), c, cmd_dma_handle);
return NULL;
}
- memset(c->err_info, 0, sizeof(*c->err_info));
INIT_LIST_HEAD(&c->list);
c->busaddr = (u32) cmd_dma_handle;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index e2237a9..531dce4 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -998,8 +998,9 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
* Allocate the common 16-byte aligned memory for the handshake
* mailbox.
*/
- raid_dev->una_mbox64 = pci_alloc_consistent(adapter->pdev,
- sizeof(mbox64_t), &raid_dev->una_mbox64_dma);
+ raid_dev->una_mbox64 = pci_zalloc_consistent(adapter->pdev,
+ sizeof(mbox64_t),
+ &raid_dev->una_mbox64_dma);
if (!raid_dev->una_mbox64) {
con_log(CL_ANN, (KERN_WARNING
@@ -1007,7 +1008,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
__LINE__));
return -1;
}
- memset(raid_dev->una_mbox64, 0, sizeof(mbox64_t));
/*
* Align the mailbox at 16-byte boundary
@@ -1026,8 +1026,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
align;
// Allocate memory for commands issued internally
- adapter->ibuf = pci_alloc_consistent(pdev, MBOX_IBUF_SIZE,
- &adapter->ibuf_dma_h);
+ adapter->ibuf = pci_zalloc_consistent(pdev, MBOX_IBUF_SIZE,
+ &adapter->ibuf_dma_h);
if (!adapter->ibuf) {
con_log(CL_ANN, (KERN_WARNING
@@ -1036,7 +1036,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
goto out_free_common_mbox;
}
- memset(adapter->ibuf, 0, MBOX_IBUF_SIZE);
// Allocate memory for our SCSI Command Blocks and their associated
// memory
@@ -2972,8 +2971,8 @@ megaraid_mbox_product_info(adapter_t *adapter)
* Issue an ENQUIRY3 command to find out certain adapter parameters,
* e.g., max channels, max commands etc.
*/
- pinfo = pci_alloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t),
- &pinfo_dma_h);
+ pinfo = pci_zalloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t),
+ &pinfo_dma_h);
if (pinfo == NULL) {
con_log(CL_ANN, (KERN_WARNING
@@ -2982,7 +2981,6 @@ megaraid_mbox_product_info(adapter_t *adapter)
return -1;
}
- memset(pinfo, 0, sizeof(mraid_pinfo_t));
mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h;
memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE);
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 112799b..22a04e3 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2038,9 +2038,9 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
if (initial) {
instance->hb_host_mem =
- pci_alloc_consistent(instance->pdev,
- sizeof(struct MR_CTRL_HB_HOST_MEM),
- &instance->hb_host_mem_h);
+ pci_zalloc_consistent(instance->pdev,
+ sizeof(struct MR_CTRL_HB_HOST_MEM),
+ &instance->hb_host_mem_h);
if (!instance->hb_host_mem) {
printk(KERN_DEBUG "megasas: SR-IOV: Couldn't allocate"
" memory for heartbeat host memory for "
@@ -2048,8 +2048,6 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
retval = -ENOMEM;
goto out;
}
- memset(instance->hb_host_mem, 0,
- sizeof(struct MR_CTRL_HB_HOST_MEM));
}
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index e8a04ae..b4f0552 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1915,14 +1915,12 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
/* We use the PCI APIs for now until the generic one gets fixed
* enough or until we get some macio-specific versions
*/
- dma_cmd_space = pci_alloc_consistent(macio_get_pci_dev(mdev),
- ms->dma_cmd_size,
- &dma_cmd_bus);
+ dma_cmd_space = pci_zalloc_consistent(macio_get_pci_dev(mdev),
+ ms->dma_cmd_size, &dma_cmd_bus);
if (dma_cmd_space == NULL) {
printk(KERN_ERR "mesh: can't allocate DMA table\n");
goto out_unmap;
}
- memset(dma_cmd_space, 0, ms->dma_cmd_size);
ms->dma_cmds = (struct dbdma_cmd *) DBDMA_ALIGN(dma_cmd_space);
ms->dma_cmd_space = dma_cmd_space;
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index edbee8d..3e716b2 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -142,8 +142,8 @@ static struct mvumi_res *mvumi_alloc_mem_resource(struct mvumi_hba *mhba,
case RESOURCE_UNCACHED_MEMORY:
size = round_up(size, 8);
- res->virt_addr = pci_alloc_consistent(mhba->pdev, size,
- &res->bus_addr);
+ res->virt_addr = pci_zalloc_consistent(mhba->pdev, size,
+ &res->bus_addr);
if (!res->virt_addr) {
dev_err(&mhba->pdev->dev,
"unable to allocate consistent mem,"
@@ -151,7 +151,6 @@ static struct mvumi_res *mvumi_alloc_mem_resource(struct mvumi_hba *mhba,
kfree(res);
return NULL;
}
- memset(res->virt_addr, 0, size);
break;
default:
@@ -258,12 +257,10 @@ static int mvumi_internal_cmd_sgl(struct mvumi_hba *mhba, struct mvumi_cmd *cmd,
if (size == 0)
return 0;
- virt_addr = pci_alloc_consistent(mhba->pdev, size, &phy_addr);
+ virt_addr = pci_zalloc_consistent(mhba->pdev, size, &phy_addr);
if (!virt_addr)
return -1;
- memset(virt_addr, 0, size);
-
m_sg = (struct mvumi_sgl *) &cmd->frame->payload[0];
cmd->frame->sg_counts = 1;
cmd->data_buf = virt_addr;
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 8a44bc9..6107e06 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -123,13 +123,12 @@ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr,
u64 align_offset = 0;
if (align)
align_offset = (dma_addr_t)align - 1;
- mem_virt_alloc =
- pci_alloc_consistent(pdev, mem_size + align, &mem_dma_handle);
+ mem_virt_alloc = pci_zalloc_consistent(pdev, mem_size + align,
+ &mem_dma_handle);
if (!mem_virt_alloc) {
pm8001_printk("memory allocation error\n");
return -1;
}
- memset((void *)mem_virt_alloc, 0, mem_size+align);
*pphys_addr = mem_dma_handle;
phys_align = (*pphys_addr + align_offset) & ~align_offset;
*virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr;
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` [PATCH 19/22] scsi: Use pci_zalloc_consistent Joe Perches
@ 2014-06-23 17:25 ` Luis R. Rodriguez
2014-06-23 19:13 ` Joe Perches
[not found] ` <cover.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2014-06-25 19:41 ` John W. Linville
3 siblings, 1 reply; 8+ messages in thread
From: Luis R. Rodriguez @ 2014-06-23 17:25 UTC (permalink / raw)
To: Joe Perches
Cc: devel, linux-arch, linux-scsi, iss_storagedev, linux-rdma, netdev,
linux-atm-general, linux-wireless, linux-kernel, dri-devel,
linux-crypto, linux-media, linux-eata
On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
> Adding the helper reduces object code size as well as overall
> source size line count.
>
> It's also consistent with all the various zalloc mechanisms
> in the kernel.
>
> Done with a simple cocci script and some typing.
Awesome, any chance you can paste in the SmPL? Also any chance
we can get this added to a make coccicheck so that maintainers
moving forward can use that to ensure that no new code is
added that uses the old school API?
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
2014-06-23 17:25 ` [PATCH 00/22] Add and use pci_zalloc_consistent Luis R. Rodriguez
@ 2014-06-23 19:13 ` Joe Perches
2014-06-23 23:27 ` Julian Calaby
0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2014-06-23 19:13 UTC (permalink / raw)
To: Luis R. Rodriguez, Arnd Bergmann
Cc: devel, linux-arch, linux-scsi, iss_storagedev, linux-rdma, netdev,
linux-atm-general, linux-wireless, linux-kernel, dri-devel,
linux-crypto, linux-media, linux-eata
On Mon, 2014-06-23 at 10:25 -0700, Luis R. Rodriguez wrote:
> On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
> > Adding the helper reduces object code size as well as overall
> > source size line count.
> >
> > It's also consistent with all the various zalloc mechanisms
> > in the kernel.
> >
> > Done with a simple cocci script and some typing.
>
> Awesome, any chance you can paste in the SmPL? Also any chance
> we can get this added to a make coccicheck so that maintainers
> moving forward can use that to ensure that no new code is
> added that uses the old school API?
Not many of these are recent.
Arnd Bergmann reasonably suggested that the pci_alloc_consistent
api be converted the the more widely used dma_alloc_coherent.
https://lkml.org/lkml/2014/6/23/513
> Shouldn't these drivers just use the normal dma-mapping API now?
and I replied:
https://lkml.org/lkml/2014/6/23/525
> Maybe. I wouldn't mind.
> They do seem to have a trivial bit of unnecessary overhead for
> hwdev == NULL ? NULL : &hwdev->dev
Anyway, here's the little script.
I'm not sure it's worthwhile to add it though.
$ cat ./scripts/coccinelle/api/alloc/pci_zalloc_consistent.cocci
///
/// Use pci_zalloc_consistent rather than
/// pci_alloc_consistent followed by memset with 0
///
/// This considers some simple cases that are common and easy to validate
/// Note in particular that there are no ...s in the rule, so all of the
/// matched code has to be contiguous
///
/// Blatantly cribbed from: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
@@
type T, T2;
expression x;
expression E1,E2,E3;
statement S;
@@
- x = (T)pci_alloc_consistent(E1,E2,E3);
+ x = pci_zalloc_consistent(E1,E2,E3);
if ((x==NULL) || ...) S
- memset((T2)x,0,E2);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
[not found] ` <cover.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
@ 2014-06-23 21:49 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2014-06-23 21:49 UTC (permalink / raw)
To: joe-6d6DIl74uiNBDgjK7y7TUQ
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-atm-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
netdev-u79uwXL29TY76Z2rM5mHXA, iss_storagedev-VXdhtT5mjnY,
linux-crypto-u79uwXL29TY76Z2rM5mHXA,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-media-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA,
linux-eata-3umIvqjeSgIeIZ0/mPfg9Q,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
linux-arch-u79uwXL29TY76Z2rM5mHXA
From: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Date: Mon, 23 Jun 2014 06:41:28 -0700
> Adding the helper reduces object code size as well as overall
> source size line count.
>
> It's also consistent with all the various zalloc mechanisms
> in the kernel.
>
> Done with a simple cocci script and some typing.
For networking bits:
Acked-by: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
2014-06-23 19:13 ` Joe Perches
@ 2014-06-23 23:27 ` Julian Calaby
2014-06-24 11:32 ` Johannes Berg
0 siblings, 1 reply; 8+ messages in thread
From: Julian Calaby @ 2014-06-23 23:27 UTC (permalink / raw)
To: Joe Perches
Cc: Luis R. Rodriguez, Arnd Bergmann, linux-kernel@vger.kernel.org,
devel@driverdev.osuosl.org, linux-arch, linux-scsi,
iss_storagedev, linux-rdma, netdev, linux-atm-general,
linux-wireless, dri-devel, linux-crypto, linux-eata, linux-media
Hi Joe,
On Tue, Jun 24, 2014 at 5:13 AM, Joe Perches <joe@perches.com> wrote:
> On Mon, 2014-06-23 at 10:25 -0700, Luis R. Rodriguez wrote:
>> On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
>> > Adding the helper reduces object code size as well as overall
>> > source size line count.
>> >
>> > It's also consistent with all the various zalloc mechanisms
>> > in the kernel.
>> >
>> > Done with a simple cocci script and some typing.
>>
>> Awesome, any chance you can paste in the SmPL? Also any chance
>> we can get this added to a make coccicheck so that maintainers
>> moving forward can use that to ensure that no new code is
>> added that uses the old school API?
>
> Not many of these are recent.
>
> Arnd Bergmann reasonably suggested that the pci_alloc_consistent
> api be converted the the more widely used dma_alloc_coherent.
>
> https://lkml.org/lkml/2014/6/23/513
>
>> Shouldn't these drivers just use the normal dma-mapping API now?
>
> and I replied:
>
> https://lkml.org/lkml/2014/6/23/525
>
>> Maybe. I wouldn't mind.
>> They do seem to have a trivial bit of unnecessary overhead for
>> hwdev == NULL ? NULL : &hwdev->dev
>
> Anyway, here's the little script.
> I'm not sure it's worthwhile to add it though.
>
> $ cat ./scripts/coccinelle/api/alloc/pci_zalloc_consistent.cocci
> ///
> /// Use pci_zalloc_consistent rather than
> /// pci_alloc_consistent followed by memset with 0
> ///
> /// This considers some simple cases that are common and easy to validate
> /// Note in particular that there are no ...s in the rule, so all of the
> /// matched code has to be contiguous
> ///
> /// Blatantly cribbed from: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
>
> @@
> type T, T2;
> expression x;
> expression E1,E2,E3;
> statement S;
> @@
>
> - x = (T)pci_alloc_consistent(E1,E2,E3);
> + x = pci_zalloc_consistent(E1,E2,E3);
> if ((x==NULL) || ...) S
> - memset((T2)x,0,E2);
I don't know much about SmPL, but wouldn't having that if statement
there reduce your matches?
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
2014-06-23 23:27 ` Julian Calaby
@ 2014-06-24 11:32 ` Johannes Berg
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2014-06-24 11:32 UTC (permalink / raw)
To: Julian Calaby
Cc: Joe Perches, Luis R. Rodriguez, Arnd Bergmann,
linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
linux-arch, linux-scsi, iss_storagedev, linux-rdma, netdev,
linux-atm-general, linux-wireless, dri-devel, linux-crypto,
linux-eata, linux-media
On Tue, 2014-06-24 at 09:27 +1000, Julian Calaby wrote:
> > - x = (T)pci_alloc_consistent(E1,E2,E3);
> > + x = pci_zalloc_consistent(E1,E2,E3);
> > if ((x==NULL) || ...) S
> > - memset((T2)x,0,E2);
>
> I don't know much about SmPL, but wouldn't having that if statement
> there reduce your matches?
Code that matched without the if statement would be buggy, since it
wouldn't be checking the pci_zalloc_consistent return value properly.l
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/22] Add and use pci_zalloc_consistent
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
` (2 preceding siblings ...)
[not found] ` <cover.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
@ 2014-06-25 19:41 ` John W. Linville
3 siblings, 0 replies; 8+ messages in thread
From: John W. Linville @ 2014-06-25 19:41 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, linux-atm-general, netdev, iss_storagedev,
linux-crypto, dri-devel, linux-rdma, linux-media, linux-wireless,
linux-scsi, linux-eata, devel, linux-arch
On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
> Adding the helper reduces object code size as well as overall
> source size line count.
>
> It's also consistent with all the various zalloc mechanisms
> in the kernel.
>
> Done with a simple cocci script and some typing.
>
> Joe Perches (22):
> ipw2100: Use pci_zalloc_consistent
> mwl8k: Use pci_zalloc_consistent
> rtl818x: Use pci_zalloc_consistent
> rtlwifi: Use pci_zalloc_consistent
Sure, fine by me.
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-06-25 19:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` [PATCH 19/22] scsi: Use pci_zalloc_consistent Joe Perches
2014-06-23 17:25 ` [PATCH 00/22] Add and use pci_zalloc_consistent Luis R. Rodriguez
2014-06-23 19:13 ` Joe Perches
2014-06-23 23:27 ` Julian Calaby
2014-06-24 11:32 ` Johannes Berg
[not found] ` <cover.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2014-06-23 21:49 ` David Miller
2014-06-25 19:41 ` John W. Linville
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).