Re: [PATCH] scsi: fix dma_unmap_sg() parameter in some drivers

2018-01-02 Thread John Garry

On 21/12/2017 08:15, chenxiang wrote:

For function dma_unmap_sg(), the  parameter should be number of
elements in the scatterlist prior to the mapping, not after the mapping.
So fix this usage in ibmvscsi_tgt/isci/mvsas/pm8001.



Hi chenxiang,

I think that it may be better to rewrite the series with a patch per 
driver, so that we can add specific "fixes" ID tag. Please also include 
"CC:" tag per patch, cc'ing the respective driver maintainer (if any).


BTW, I guess that there are many more instances of this issue throughout 
the kernel...


Much appreciated,
John


Signed-off-by: Xiang Chen 
---
 drivers/scsi/ibmvscsi_tgt/libsrp.c | 6 --
 drivers/scsi/isci/request.c| 2 +-
 drivers/scsi/mvsas/mv_sas.c| 4 ++--
 drivers/scsi/pm8001/pm8001_sas.c   | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ibmvscsi_tgt/libsrp.c 
b/drivers/scsi/ibmvscsi_tgt/libsrp.c
index 5a4cc28..16054c0 100644
--- a/drivers/scsi/ibmvscsi_tgt/libsrp.c
+++ b/drivers/scsi/ibmvscsi_tgt/libsrp.c
@@ -193,7 +193,8 @@ static int srp_direct_data(struct ibmvscsis_cmd *cmd, 
struct srp_direct_buf *md,
err = rdma_io(cmd, sg, nsg, md, 1, dir, len);

if (dma_map)
-   dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+   dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+   DMA_BIDIRECTIONAL);

return err;
 }
@@ -265,7 +266,8 @@ static int srp_indirect_data(struct ibmvscsis_cmd *cmd, 
struct srp_cmd *srp_cmd,
err = rdma_io(cmd, sg, nsg, md, nmd, dir, len);

if (dma_map)
-   dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+   dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+   DMA_BIDIRECTIONAL);

 free_mem:
if (token && dma_map) {
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index ed197bc..225d947 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2914,7 +2914,7 @@ static void isci_request_io_request_complete(struct 
isci_host *ihost,
 task->total_xfer_len, task->data_dir);
else  /* unmap the sgl dma addresses */
dma_unmap_sg(&ihost->pdev->dev, task->scatter,
-request->num_sg_entries, task->data_dir);
+task->num_scatter, task->data_dir);
break;
case SAS_PROTOCOL_SMP: {
struct scatterlist *sg = &task->smp_task.smp_req;
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index cff43bd..4b2cf36 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -848,7 +848,7 @@ static int mvs_task_prep(struct sas_task *task, struct 
mvs_info *mvi, int is_tmf
dev_printk(KERN_ERR, mvi->dev, "mvsas prep failed[%d]!\n", rc);
if (!sas_protocol_ata(task->task_proto))
if (n_elem)
-   dma_unmap_sg(mvi->dev, task->scatter, n_elem,
+   dma_unmap_sg(mvi->dev, task->scatter, task->num_scatter,
 task->data_dir);
 prep_out:
return rc;
@@ -899,7 +899,7 @@ static void mvs_slot_task_free(struct mvs_info *mvi, struct 
sas_task *task,
if (!sas_protocol_ata(task->task_proto))
if (slot->n_elem)
dma_unmap_sg(mvi->dev, task->scatter,
-slot->n_elem, task->data_dir);
+task->num_scatter, task->data_dir);

switch (task->task_proto) {
case SAS_PROTOCOL_SMP:
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 947d601..576a0f0 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -466,7 +466,7 @@ static int pm8001_task_exec(struct sas_task *task,
dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc);
if (!sas_protocol_ata(t->task_proto))
if (n_elem)
-   dma_unmap_sg(pm8001_ha->dev, t->scatter, n_elem,
+   dma_unmap_sg(pm8001_ha->dev, t->scatter, t->num_scatter,
t->data_dir);
 out_done:
spin_unlock_irqrestore(&pm8001_ha->lock, flags);






Re: [PATCH] scsi: fix dma_unmap_sg() parameter in some drivers

2018-01-02 Thread chenxiang (M)

在 2018/1/2 18:51, John Garry 写道:

On 21/12/2017 08:15, chenxiang wrote:

For function dma_unmap_sg(), the  parameter should be number of
elements in the scatterlist prior to the mapping, not after the mapping.
So fix this usage in ibmvscsi_tgt/isci/mvsas/pm8001.



Hi chenxiang,

I think that it may be better to rewrite the series with a patch per 
driver, so that we can add specific "fixes" ID tag. Please also 
include "CC:" tag per patch, cc'ing the respective driver maintainer 
(if any).


Ok, i will split it with a patch per driver.



BTW, I guess that there are many more instances of this issue 
throughout the kernel...


Much appreciated,
John


Signed-off-by: Xiang Chen 
---
 drivers/scsi/ibmvscsi_tgt/libsrp.c | 6 --
 drivers/scsi/isci/request.c| 2 +-
 drivers/scsi/mvsas/mv_sas.c| 4 ++--
 drivers/scsi/pm8001/pm8001_sas.c   | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ibmvscsi_tgt/libsrp.c 
b/drivers/scsi/ibmvscsi_tgt/libsrp.c

index 5a4cc28..16054c0 100644
--- a/drivers/scsi/ibmvscsi_tgt/libsrp.c
+++ b/drivers/scsi/ibmvscsi_tgt/libsrp.c
@@ -193,7 +193,8 @@ static int srp_direct_data(struct ibmvscsis_cmd 
*cmd, struct srp_direct_buf *md,

 err = rdma_io(cmd, sg, nsg, md, 1, dir, len);

 if (dma_map)
-dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+DMA_BIDIRECTIONAL);

 return err;
 }
@@ -265,7 +266,8 @@ static int srp_indirect_data(struct ibmvscsis_cmd 
*cmd, struct srp_cmd *srp_cmd,

 err = rdma_io(cmd, sg, nsg, md, nmd, dir, len);

 if (dma_map)
-dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+DMA_BIDIRECTIONAL);

 free_mem:
 if (token && dma_map) {
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index ed197bc..225d947 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2914,7 +2914,7 @@ static void 
isci_request_io_request_complete(struct isci_host *ihost,

  task->total_xfer_len, task->data_dir);
 else  /* unmap the sgl dma addresses */
 dma_unmap_sg(&ihost->pdev->dev, task->scatter,
- request->num_sg_entries, task->data_dir);
+ task->num_scatter, task->data_dir);
 break;
 case SAS_PROTOCOL_SMP: {
 struct scatterlist *sg = &task->smp_task.smp_req;
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index cff43bd..4b2cf36 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -848,7 +848,7 @@ static int mvs_task_prep(struct sas_task *task, 
struct mvs_info *mvi, int is_tmf

 dev_printk(KERN_ERR, mvi->dev, "mvsas prep failed[%d]!\n", rc);
 if (!sas_protocol_ata(task->task_proto))
 if (n_elem)
-dma_unmap_sg(mvi->dev, task->scatter, n_elem,
+dma_unmap_sg(mvi->dev, task->scatter, task->num_scatter,
  task->data_dir);
 prep_out:
 return rc;
@@ -899,7 +899,7 @@ static void mvs_slot_task_free(struct mvs_info 
*mvi, struct sas_task *task,

 if (!sas_protocol_ata(task->task_proto))
 if (slot->n_elem)
 dma_unmap_sg(mvi->dev, task->scatter,
- slot->n_elem, task->data_dir);
+ task->num_scatter, task->data_dir);

 switch (task->task_proto) {
 case SAS_PROTOCOL_SMP:
diff --git a/drivers/scsi/pm8001/pm8001_sas.c 
b/drivers/scsi/pm8001/pm8001_sas.c

index 947d601..576a0f0 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -466,7 +466,7 @@ static int pm8001_task_exec(struct sas_task *task,
 dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec 
failed[%d]!\n", rc);

 if (!sas_protocol_ata(t->task_proto))
 if (n_elem)
-dma_unmap_sg(pm8001_ha->dev, t->scatter, n_elem,
+dma_unmap_sg(pm8001_ha->dev, t->scatter, t->num_scatter,
 t->data_dir);
 out_done:
 spin_unlock_irqrestore(&pm8001_ha->lock, flags);





.






Re: [PATCH v5 0/7] Enhance libsas hotplug feature

2018-01-02 Thread John Garry

On 08/12/2017 09:42, Jason Yan wrote:

Now the libsas hotplug has some issues, Dan Williams report
a similar bug here before
https://www.mail-archive.com/linux-scsi@vger.kernel.org/msg39187.html



Hi Martin, James,

At this point we feel that we have a decent solution to the 
long-standing libsas hotplug issues.


Hannes has kindly reviewed the series.

Can you let us know what else you require for acceptance? More 
independent review or testing?


Thanks,
John


The issues we have found
1. if LLDD burst reports lots of phy-up/phy-down sas events, some events
   may lost because a same sas events is pending now, finally libsas topo
   may different the hardware.
2. receive a phy down sas event, libsas call sas_deform_port to remove
   devices, it would first delete the sas port, then put a destruction
   discovery event in a new work, and queue it at the tail of workqueue,
   once the sas port be deleted, its children device will be deleted too,
   when the destruction work start, it will found the target device has
   been removed, and report a sysfs warnning.
3. since a hotplug process will be devided into several works, if a phy up
   sas event insert into phydown works, like
   destruction work  ---> PORTE_BYTES_DMAED (sas_form_port) 
>PHYE_LOSS_OF_SIGNAL
   the hot remove flow would broken by PORTE_BYTES_DMAED event, it's not
   we expected, and issues would occur.

v4->v5: -process only one expander's revalidation in sas_ex_revalidate_domain()
-notify event PORTE_BROADCAST_RCVD in sas_enable_revalidation()
v3->v4: -use dynamic alloced work and support shutting down the phy if active 
event reached the threshold
-use flush_workqueue instead of wait-completion to process discover 
events synchronously
-direct call probe and destruct function
v2->v3: some code improvements suggested by Johannes and John,
split v2 patch 2 into several small pathes.
v1->v2: some code improvements suggested by John Garry

Jason Yan (7):
  scsi: libsas: Use dynamic alloced work to avoid sas event lost
  scsi: libsas: shut down the PHY if events reached the threshold
  scsi: libsas: make the event threshold configurable
  scsi: libsas: Use new workqueue to run sas event and disco event
  scsi: libsas: use flush_workqueue to process disco events
synchronously
  scsi: libsas: direct call probe and destruct
  scsi: libsas: notify event PORTE_BROADCAST_RCVD in
sas_enable_revalidation()

 drivers/scsi/hisi_sas/hisi_sas_main.c |   6 ++
 drivers/scsi/libsas/sas_ata.c |   1 -
 drivers/scsi/libsas/sas_discover.c|  34 ++-
 drivers/scsi/libsas/sas_event.c   |  86 ---
 drivers/scsi/libsas/sas_expander.c|   8 +--
 drivers/scsi/libsas/sas_init.c| 107 +-
 drivers/scsi/libsas/sas_internal.h|   7 +++
 drivers/scsi/libsas/sas_phy.c |  69 +++---
 drivers/scsi/libsas/sas_port.c|  25 
 include/scsi/libsas.h |  30 +++---
 include/scsi/scsi_transport_sas.h |   1 +
 11 files changed, 277 insertions(+), 97 deletions(-)






Re: [PATCH v1] libsas: remove private hex2bin() implementation

2018-01-02 Thread chenxiang (M)

在 2017/12/20 1:37, Andy Shevchenko 写道:

The function sas_parse_addr() could be easily substituted by hex2bin() which is
in kernel library code.

Cc: Christoph Hellwig 
Signed-off-by: Andy Shevchenko 


Tested-by: Xiang Chen 


---
  drivers/scsi/libsas/sas_scsi_host.c | 20 
  1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 58476b728c57..626727207889 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
  
  #include "sas_internal.h"
  
@@ -946,21 +947,6 @@ void sas_target_destroy(struct scsi_target *starget)

sas_put_device(found_dev);
  }
  
-static void sas_parse_addr(u8 *sas_addr, const char *p)

-{
-   int i;
-   for (i = 0; i < SAS_ADDR_SIZE; i++) {
-   u8 h, l;
-   if (!*p)
-   break;
-   h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   sas_addr[i] = (h<<4) | l;
-   }
-}
-
  #define SAS_STRING_ADDR_SIZE  16
  
  int sas_request_addr(struct Scsi_Host *shost, u8 *addr)

@@ -977,7 +963,9 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
goto out;
}
  
-	sas_parse_addr(addr, fw->data);

+   res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
+   if (res)
+   goto out;
  
  out:

release_firmware(fw);





[PATCH 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER

2018-01-02 Thread Jason Yan
From: chenxiang 

The status of SAS PHY is in sas_phy->enabled. There is an issue that the
status of a remote SAS PHY may be initialized incorrectly: if disable remote
SAS PHY through sysfs interface (such as echo 0 > 
/sys/class/sas_phy/phy-1:0:0/enable),
then reboot the system, and we will find the status of remote SAS PHY which is
disabled before is 1 (cat /sys/class/sas_phy/phy-1:0:0/enable). But actually
the status of remote SAS PHY is disabled and the device attached is not found.

In SAS protocol, NEGOTIATED LOGICAL LINK RATE field of DISCOVER response is 0x1
when remote SAS PHY is disabled. So initialize sas_phy->enabled according to
the value of NEGOTIATED LOGICAL LINK RATE field.

Signed-off-by: chenxiang 
Reviewed-by: John Garry 
Signed-off-by: Jason Yan 
---
 drivers/scsi/libsas/sas_expander.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 6eab487..c79cfd1 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -293,6 +293,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int 
phy_id, void *rsp)
phy->phy->minimum_linkrate = dr->pmin_linkrate;
phy->phy->maximum_linkrate = dr->pmax_linkrate;
phy->phy->negotiated_linkrate = phy->linkrate;
+   phy->phy->enabled = (phy->linkrate == SAS_PHY_DISABLED) ? 0:1;
 
  skip:
if (new_phy)
-- 
2.9.5



[PATCH 2/3] scsi: libsas: fix error when getting phy events

2018-01-02 Thread Jason Yan
The intend purpose here was to goto out if smp_execute_task() returned
error. Obviously something got screwed up. We will never get these link
error statistics below:

~:/sys/class/sas_phy/phy-1:0:12 # cat invalid_dword_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat running_disparity_error_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat loss_of_dword_sync_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat phy_reset_problem_count
0

Obviously we should goto error handler if smp_execute_task() returns
non-zero.

Signed-off-by: Jason Yan 
CC: John Garry 
CC: chenqilin 
CC: chenxiang 
---
 drivers/scsi/libsas/sas_expander.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 4b0c67f..6eab487 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -686,7 +686,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
resp, RPEL_RESP_SIZE);
 
-   if (!res)
+   if (res)
goto out;
 
phy->invalid_dword_count = scsi_to_u32(&resp[12]);
-- 
2.9.5



[PATCH 0/3] Three small fixes for libsas

2018-01-02 Thread Jason Yan
We've found three small bugs. Please consider including them for 4.15.

Jason Yan (2):
  scsi: libsas: fix memory leak in sas_smp_get_phy_events()
  scsi: libsas: fix error when getting phy events

chenxiang (1):
  scsi: libsas: initialize sas_phy status according to response of
DISCOVER

 drivers/scsi/libsas/sas_expander.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.9.5



[PATCH 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events()

2018-01-02 Thread Jason Yan
We've got a memory leak with the following producer:

while true;
do cat /sys/class/sas_phy/phy-1:0:12/invalid_dword_count >/dev/null;
done

The buffer req is allocated and not freed after we return. Fix it.

Signed-off-by: Jason Yan 
CC: John Garry 
CC: chenqilin 
CC: chenxiang 
---
 drivers/scsi/libsas/sas_expander.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 3183d63..4b0c67f 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -695,6 +695,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
phy->phy_reset_problem_count = scsi_to_u32(&resp[24]);
 
  out:
+   kfree(req);
kfree(resp);
return res;
 
-- 
2.9.5



Re: [PATCH 2/3] scsi: libsas: fix error when getting phy events

2018-01-02 Thread John Garry

On 02/01/2018 12:15, Jason Yan wrote:

The intend purpose here was to goto out if smp_execute_task() returned
error. Obviously something got screwed up. We will never get these link
error statistics below:

~:/sys/class/sas_phy/phy-1:0:12 # cat invalid_dword_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat running_disparity_error_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat loss_of_dword_sync_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat phy_reset_problem_count
0

Obviously we should goto error handler if smp_execute_task() returns
non-zero.

Signed-off-by: Jason Yan 
CC: John Garry 
CC: chenqilin 
CC: chenxiang 
---
 drivers/scsi/libsas/sas_expander.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 4b0c67f..6eab487 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -686,7 +686,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
resp, RPEL_RESP_SIZE);

-   if (!res)
+   if (res)
goto out;


This seems to have been broken for some time.

Could you inject some errors on the link to verify that this function 
actually works properly with this change, i.e. non-zero reading?


Thanks,
John



phy->invalid_dword_count = scsi_to_u32(&resp[12]);






Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Bob Peterson
- Original Message -
| Drop newline at the end of a message string when the printing function adds
| a newline.

Hi Julia,

NACK.

As much as it's a pain when searching the source code for output strings,
this patch set goes against the accepted Linux coding style document. See:

https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings

Regards,

Bob Peterson


RE: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Stanislav Nijnikov


> -Original Message-
> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> Sent: Thursday, December 28, 2017 9:37 PM
> To: Stanislav Nijnikov 
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> gre...@linuxfoundation.org; Alex Lemberg 
> Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> 
> On 12/28, Stanislav Nijnikov wrote:
> > This patch introduces a sysfs group entry for the UFS device
> > descriptor parameters. The group adds "device_descriptor" folder under
> > the UFS driver sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The
> > parameters are shown as hexadecimal numbers. The full information
> > about the parameters could be found at UFS specifications 2.1.
> >
> > Signed-off-by: Stanislav Nijnikov 
> > ---
> >  Documentation/ABI/testing/sysfs-driver-ufs | 223
> +
> >  drivers/scsi/ufs/Makefile  |   3 +-
> >  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
> >  drivers/scsi/ufs/ufs-sysfs.h   |  25 
> >  drivers/scsi/ufs/ufs.h |   8 ++
> >  drivers/scsi/ufs/ufshcd.c  |  12 +-
> >  drivers/scsi/ufs/ufshcd.h  |   4 +
> >  7 files changed, 439 insertions(+), 6 deletions(-)  create mode
> > 100644 Documentation/ABI/testing/sysfs-driver-ufs
> >  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode 100644
> > drivers/scsi/ufs/ufs-sysfs.h
> >
> > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> > b/Documentation/ABI/testing/sysfs-driver-ufs
> > new file mode 100644
> > index 000..17cc4aa
> > --- /dev/null
> > +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> 
> [snip]
> 
> > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> > index 9310c6c..918f579 100644
> > --- a/drivers/scsi/ufs/Makefile
> > +++ b/drivers/scsi/ufs/Makefile
> > @@ -3,6 +3,7 @@
> >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-
> dwc.o
> > tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> > ufshcd-dwc.o tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > +ufshcd.o ufs-sysfs.o
> 
> Why not just adding ufs-sysfs.o in the existing configuration?

The kernel build robot compiles the UFS driver as a separate module. 
The existing configuration doesn't allow to add a new file to be compiled 
as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
This was the reason why I used EXPORT_SYMBOL in the first version.

> 
> >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file
> > mode 100644 index 000..1c685f3
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -0,0 +1,170 @@
> > +/*
> > +* UFS Device Management sysfs
> > +*
> > +* Copyright (C) 2017 Western Digital Corporation
> > +*
> > +* This program is free software; you can redistribute it and/or
> > +* modify it under the terms of the GNU General Public License version
> > +* 2 as published by the Free Software Foundation.
> > +*
> > +* This program is distributed in the hope that it will be useful, but
> > +* WITHOUT ANY WARRANTY; without even the implied warranty of
> > +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU
> > +* General Public License for more details.
> > +*
> > +*/
> > +
> > +#include 
> > +#include 
> > +
> > +#include "ufs.h"
> > +#include "ufs-sysfs.h"
> > +/* collision between the device descriptor parameter and the
> > +definition */ #undef DEVICE_CLASS
> 
> Does this make sense? How about attaching "_" for all the macro like
> _DEVICE_CLASS below?
> 

It's not just changing the one line that uses "DEVICE_CLASS" to use 
"_DEVICE_CLASS". It's will be necessary to add "_" to all descriptor
parameters macros in all patches.

> > +
> > +enum ufs_desc_param_size {
> > +   UFS_PARAM_BYTE_SIZE = 1,
> > +   UFS_PARAM_WORD_SIZE = 2,
> > +   UFS_PARAM_DWORD_SIZE= 4,
> > +   UFS_PARAM_QWORD_SIZE= 8,
> > +};
> > +
> > +static inline ssize_t ufs_sysfs_read_desc_param(
> > +   struct ufs_hba *hba, u8 desc_idn, u8 index, char *buf, u8 off,
> > +   enum ufs_desc_param_size param_size) {
> > +   int desc_len;
> > +   int ret;
> > +   u8 *desc_buf;
> > +
> > +   if (ufshcd_map_desc_id_to_length(hba, desc_idn, &desc_len) ||
> > +   off >= desc_len)
> > +   return -EINVAL;
> > +   desc_buf = kzalloc(desc_len, GFP_ATOMIC);
> > +   if (!desc_buf)
> > +   return -ENOMEM;
> > +   ret = ufshcd_query_descriptor_retry(hba,
> UPIU_QUERY_OPCODE_READ_DESC,
> > +   desc_idn, index, 0, desc_buf, &desc_len);
> > +   if (ret)
> 
> Should free desc_buf here.
> 
> > +   return -EINVAL;
> > +   switch (param_size) 

Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Julia Lawall


On Tue, 2 Jan 2018, Bob Peterson wrote:

> - Original Message -
> | Drop newline at the end of a message string when the printing function adds
> | a newline.
>
> Hi Julia,
>
> NACK.
>
> As much as it's a pain when searching the source code for output strings,
> this patch set goes against the accepted Linux coding style document. See:
>
> https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings

I don't think that's the case:

"However, never break user-visible strings such as printk messages,
because that breaks the ability to grep for them."

julia

>
> Regards,
>
> Bob Peterson
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Bob Peterson
- Original Message -
| - Original Message -
| | Drop newline at the end of a message string when the printing function adds
| | a newline.
| 
| Hi Julia,
| 
| NACK.
| 
| As much as it's a pain when searching the source code for output strings,
| this patch set goes against the accepted Linux coding style document. See:
| 
| 
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
| 
| Regards,
| 
| Bob Peterson
| 
| 
Hm. I guess I stand corrected. The document reads:

"However, never break user-visible strings such as printk messages, because 
that breaks the ability to grep for them."

Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
and I don't like the thought of re-combining them all.

Regards,

Bob Peterson


Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Julia Lawall


On Tue, 2 Jan 2018, Bob Peterson wrote:

> - Original Message -
> | - Original Message -
> | | Drop newline at the end of a message string when the printing function 
> adds
> | | a newline.
> |
> | Hi Julia,
> |
> | NACK.
> |
> | As much as it's a pain when searching the source code for output strings,
> | this patch set goes against the accepted Linux coding style document. See:
> |
> | 
> https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings
> |
> | Regards,
> |
> | Bob Peterson
> |
> |
> Hm. I guess I stand corrected. The document reads:
>
> "However, never break user-visible strings such as printk messages, because 
> that breaks the ability to grep for them."
>
> Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> and I don't like the thought of re-combining them all.

Actually, the point of the patch was to remove the unnecessary \n at the
end of the string, because log_print will add another one.  If you prefer
to keep the string broken up, I can resend the patch in that form, but
without the unnecessary \n.

julia


RE: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Stanislav Nijnikov


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Friday, December 29, 2017 11:23 AM
> To: Stanislav Nijnikov 
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org; Alex Lemberg
> 
> Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> 
> On Thu, Dec 28, 2017 at 03:29:06PM +0200, Stanislav Nijnikov wrote:
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -0,0 +1,170 @@
> > +/*
> > +* UFS Device Management sysfs
> > +*
> > +* Copyright (C) 2017 Western Digital Corporation
> > +*
> > +* This program is free software; you can redistribute it and/or
> > +* modify it under the terms of the GNU General Public License version
> > +* 2 as published by the Free Software Foundation.
> > +*
> > +* This program is distributed in the hope that it will be useful, but
> > +* WITHOUT ANY WARRANTY; without even the implied warranty of
> > +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU
> > +* General Public License for more details.
> 
> Please use the SPDX format for all of this, like I asked last time :(
> 
> thanks,
> 
> greg k-h
 
Hi Greg.
Sorry about this.
Is this the proper legal header?

/*
* UFS Device Management sysfs
*
*Copyright (C) 2018 Western Digital Corporation
*This program is free software; you can redistribute it and/or modify it
*under the terms of the GNU General Public License as published by the
*Free Software Foundation; version 2.
*
*This program is distributed in the hope that it will be useful, but 
*WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*General Public License for more details.
*
*You should have received a copy of the GNU General Public License along
*with this program; if not, write to the Free Software Foundation, Inc.,
*51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA.
*/

It was taken from 

Thanks and Happy New Year!




Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Greg KH
On Tue, Jan 02, 2018 at 02:04:39PM +, Stanislav Nijnikov wrote:
> 
> 
> > -Original Message-
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Friday, December 29, 2017 11:23 AM
> > To: Stanislav Nijnikov 
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org; Alex Lemberg
> > 
> > Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> > 
> > On Thu, Dec 28, 2017 at 03:29:06PM +0200, Stanislav Nijnikov wrote:
> > > --- /dev/null
> > > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > > @@ -0,0 +1,170 @@
> > > +/*
> > > +* UFS Device Management sysfs
> > > +*
> > > +* Copyright (C) 2017 Western Digital Corporation
> > > +*
> > > +* This program is free software; you can redistribute it and/or
> > > +* modify it under the terms of the GNU General Public License version
> > > +* 2 as published by the Free Software Foundation.
> > > +*
> > > +* This program is distributed in the hope that it will be useful, but
> > > +* WITHOUT ANY WARRANTY; without even the implied warranty of
> > > +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > GNU
> > > +* General Public License for more details.
> > 
> > Please use the SPDX format for all of this, like I asked last time :(
> > 
> > thanks,
> > 
> > greg k-h
>  
> Hi Greg.
> Sorry about this.
> Is this the proper legal header?

First off, don't as a developer legal questions, ask your lawyers :)

> 
> /*
> * UFS Device Management sysfs
> *
> *Copyright (C) 2018 Western Digital Corporation
> *This program is free software; you can redistribute it and/or modify it
> *under the terms of the GNU General Public License as published by the
> *Free Software Foundation; version 2.
> *
> *This program is distributed in the hope that it will be useful, but 
> *WITHOUT ANY WARRANTY; without even the implied warranty of
> *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> *General Public License for more details.
> *
> *You should have received a copy of the GNU General Public License along
> *with this program; if not, write to the Free Software Foundation, Inc.,
> *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA.
> */
> 
> It was taken from 
> 
> Thanks and Happy New Year!

Nope, sorry, see the email thread on lkml from Thomas where he documents
how to properly set the SPDX line and why you don't want any of the
"boiler plate" text in there at all.

thanks,

greg k-h


Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Bart Van Assche
On Tue, 2018-01-02 at 13:54 +, Stanislav Nijnikov wrote:
> The existing configuration doesn't allow to add a new file to be compiled 
> as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
> ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
> This was the reason why I used EXPORT_SYMBOL in the first version.

There are plenty of kernel modules that consist of multiple source files, e.g.
the SCSI core. Please make yourself familiar with how to do this.

Thanks,

Bart.

Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Bart Van Assche
On Tue, 2018-01-02 at 15:00 +0100, Julia Lawall wrote:
> On Tue, 2 Jan 2018, Bob Peterson wrote:
> > - Original Message -
> > > - Original Message -
> > >
> > Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> > and I don't like the thought of re-combining them all.
> 
> Actually, the point of the patch was to remove the unnecessary \n at the
> end of the string, because log_print will add another one.  If you prefer
> to keep the string broken up, I can resend the patch in that form, but
> without the unnecessary \n.

Please combine any user-visible strings into a single line for which the
unneeded newline is dropped since these strings are modified anyway by
your patch.

Thanks,

Bart.

Re: [Cluster-devel] [PATCH 00/12] drop unneeded newline

2018-01-02 Thread Julia Lawall


On Tue, 2 Jan 2018, Bart Van Assche wrote:

> On Tue, 2018-01-02 at 15:00 +0100, Julia Lawall wrote:
> > On Tue, 2 Jan 2018, Bob Peterson wrote:
> > > - Original Message -
> > > > - Original Message -
> > > >
> > > Still, the GFS2 and DLM code has a plethora of broken-up printk messages,
> > > and I don't like the thought of re-combining them all.
> >
> > Actually, the point of the patch was to remove the unnecessary \n at the
> > end of the string, because log_print will add another one.  If you prefer
> > to keep the string broken up, I can resend the patch in that form, but
> > without the unnecessary \n.
>
> Please combine any user-visible strings into a single line for which the
> unneeded newline is dropped since these strings are modified anyway by
> your patch.

That is what the submitted patch (2/12 specifically) did.

julia


Re: [RFC] sg3_utils: sgp_dd: work around on pthread_cancel for android

2018-01-02 Thread Bart Van Assche

On 12/26/17 14:21, Bean Huo (beanhuo) wrote:

My changes are below:

Configure.ac:
+# check for pthread_cancel
+AC_SEARCH_LIBS(pthread_cancel, pthread,
+ [AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [have pthread_cancel])], [], [])

Src/Makefile.am
-sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread
+sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ @LIBS@

In the Src/sgp_dd.c, I can use macro definition " HAVE_PTHREAD_CANCEL" to 
differentiate
pthread_cancel supports or not.

It works.
But I got one warning below while run autoreconf , do you know what is wrong 
with that?
configure.ac:15: warning: AC_PROG_LIBTOOL was called before AM_PROG_AR
configure.ac:15: warning: LT_INIT was called before AM_PROG_AR


Hello Bean,

Even if these warnings would get addressed, we still would need 
something like the following change for src/sgp_dd.c:


diff --git a/src/sgp_dd.c b/src/sgp_dd.c
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -181,6 +181,7 @@ static int sg_finish_io(bool wr, Rq_elem * rep,

 static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER;

+static bool shutting_down = false;
 static bool do_sync = false;
 static bool do_time = false;
 static Rq_coll rcoll;
@@ -470,6 +471,8 @@ sig_listen_thread(void * v_clp)

 while (1) {
 sigwait(&signal_set, &sig_number);
+if (shutting_down)
+break;
 if (SIGINT == sig_number) {
 pr2serr(ME "interrupted by SIGINT\n");
 guarded_stop_both(clp);
@@ -1629,8 +1632,10 @@ main(int argc, char * argv[])
 }
 }

-status = pthread_cancel(sig_listen_thread_id);
-if (0 != status) err_exit(status, "pthread_cancel");
+shutting_down = true;
+
+status = pthread_kill(sig_listen_thread_id, SIGINT);
+if (0 != status) err_exit(status, "pthread_kill");
 if (STDIN_FILENO != rcoll.infd)
 close(rcoll.infd);

My proposal is to leave out any ifdef HAVE_PTHREAD_CANCEL tests and to 
use pthread_kill() on all platforms. Since sgp_dd is the only tool that 
uses pthread_cancel() this approach will allow to leave out the 
pthread_cancel() configure test. I'm proposing this approach because it 
will make it easier to maintain and to test the sgp_dd tool.


Thanks,

Bart.


Re: [PATCH 2/9] scsi: qla2xxx: Use zeroing allocator rather than allocator/memset

2018-01-02 Thread Madhani, Himanshu

> On Dec 30, 2017, at 7:28 AM, Himanshu Jha  wrote:
> 
> Use dma_zalloc_coherent and vzalloc instead of dma_alloc_coherent and
> vmalloc respectively, followed by memset 0.
> 
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 
> Suggested-by: Luis R. Rodriguez 
> Signed-off-by: Himanshu Jha 
> ---
> drivers/scsi/qla2xxx/qla_attr.c| 5 ++---
> drivers/scsi/qla2xxx/qla_bsg.c | 9 +++--
> drivers/scsi/qla2xxx/tcm_qla2xxx.c | 5 +
> 3 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
> index 9ce28c4..f46b015 100644
> --- a/drivers/scsi/qla2xxx/qla_attr.c
> +++ b/drivers/scsi/qla2xxx/qla_attr.c
> @@ -1843,14 +1843,13 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
>   if (qla2x00_reset_active(vha))
>   goto done;
> 
> - stats = dma_alloc_coherent(&ha->pdev->dev,
> - sizeof(*stats), &stats_dma, GFP_KERNEL);
> + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats),
> + &stats_dma, GFP_KERNEL);
>   if (!stats) {
>   ql_log(ql_log_warn, vha, 0x707d,
>   "Failed to allocate memory for stats.\n");
>   goto done;
>   }
> - memset(stats, 0, sizeof(*stats));
> 
>   rval = QLA_FUNCTION_FAILED;
>   if (IS_FWI2_CAPABLE(ha)) {
> diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
> index e3ac707..e2d5d3c 100644
> --- a/drivers/scsi/qla2xxx/qla_bsg.c
> +++ b/drivers/scsi/qla2xxx/qla_bsg.c
> @@ -1435,7 +1435,7 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, 
> scsi_qla_host_t *vha,
>   ha->optrom_state = QLA_SREADING;
>   }
> 
> - ha->optrom_buffer = vmalloc(ha->optrom_region_size);
> + ha->optrom_buffer = vzalloc(ha->optrom_region_size);
>   if (!ha->optrom_buffer) {
>   ql_log(ql_log_warn, vha, 0x7059,
>   "Read: Unable to allocate memory for optrom retrieval "
> @@ -1445,7 +1445,6 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, 
> scsi_qla_host_t *vha,
>   return -ENOMEM;
>   }
> 
> - memset(ha->optrom_buffer, 0, ha->optrom_region_size);
>   return 0;
> }
> 
> @@ -2314,16 +2313,14 @@ qla2x00_get_priv_stats(struct bsg_job *bsg_job)
>   if (!IS_FWI2_CAPABLE(ha))
>   return -EPERM;
> 
> - stats = dma_alloc_coherent(&ha->pdev->dev,
> - sizeof(*stats), &stats_dma, GFP_KERNEL);
> + stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats),
> + &stats_dma, GFP_KERNEL);
>   if (!stats) {
>   ql_log(ql_log_warn, vha, 0x70e2,
>   "Failed to allocate memory for stats.\n");
>   return -ENOMEM;
>   }
> 
> - memset(stats, 0, sizeof(*stats));
> -
>   rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options);
> 
>   if (rval == QLA_SUCCESS) {
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
> b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 3f82ea1..aadfeaa 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -1635,16 +1635,13 @@ static int tcm_qla2xxx_init_lport(struct 
> tcm_qla2xxx_lport *lport)
>   return rc;
>   }
> 
> - lport->lport_loopid_map = vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid) *
> - 65536);
> + lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) 
> * 65536);
>   if (!lport->lport_loopid_map) {
>   pr_err("Unable to allocate lport->lport_loopid_map of %zu 
> bytes\n",
>   sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
>   btree_destroy32(&lport->lport_fcport_map);
>   return -ENOMEM;
>   }
> - memset(lport->lport_loopid_map, 0, sizeof(struct tcm_qla2xxx_fc_loopid)
> -* 65536);
>   pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n",
>  sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
>   return 0;
> -- 
> 2.7.4
> 

Looks good

Acked-by: Himanshu Madhani 

[PATCH v17 4/4] PCI: Remove PCI pool macro functions

2018-01-02 Thread Romain Perier
From: Romain Perier 

Now that all the drivers use dma pool API, we can remove the macro
functions for PCI pool.

Signed-off-by: Romain Perier 
Reviewed-by: Peter Senna Tschudin 
Acked-by: Bjorn Helgaas 
---
 include/linux/pci.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 66cca1c6f742..c5dd05021b14 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1314,15 +1314,6 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode,
 #include 
 #include 
 
-#definepci_pool dma_pool
-#define pci_pool_create(name, pdev, size, align, allocation) \
-   dma_pool_create(name, &pdev->dev, size, align, allocation)
-#definepci_pool_destroy(pool) dma_pool_destroy(pool)
-#definepci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, 
handle)
-#definepci_pool_zalloc(pool, flags, handle) \
-   dma_pool_zalloc(pool, flags, handle)
-#definepci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, 
addr)
-
 struct msix_entry {
u32 vector; /* Kernel uses to write allocated vector */
u16 entry;  /* Driver uses to specify entry, OS writes */
-- 
2.14.1



[PATCH v17 0/4] Replace PCI pool by DMA pool API

2018-01-02 Thread Romain Perier
The current PCI pool API are simple macro functions direct expanded to
the appropriate dma pool functions. The prototypes are almost the same
and semantically, they are very similar. I propose to use the DMA pool
API directly and get rid of the old API.

This set of patches, replaces the old API by the dma pool API
and remove the defines.

Changes in v17:
- Rebased series onto next-20180102
- Added Acked-by tags by David S. Miller on patches 02/04
  and 03/04

Changes in v16:
- Rebased series onto next-20171215
- I have fixed patch 04/04, so it can be applied
- Added Acked-by for Bjorn Helgaas on patch 04/04

Changes in v15:
- Rebased series onto next-20171120
- Added patch 04/05 for mpt3sas scsi driver

Changes in v14:
- Rebased series onto next-20171018
- Rebased patch 03/05 on latest driver

Changes in v13:
- Rebased series onto next-20170906
- Added a new commit for the hinic ethernet driver
- Remove previously merged patches

Changes in v12:
- Rebased series onto next-20170822

Changes in v11:
- Rebased series onto next-20170809
- Removed patches 08-14, these have been merged.

Changes in v10:
- Rebased series onto next-20170706
- I have fixed and improved patch "scsi: megaraid: Replace PCI pool old API"

Changes in v9:
- Rebased series onto next-20170522
- I have fixed and improved the patch for lpfc driver

Changes in v8:
- Rebased series onto next-20170428

Changes in v7:
- Rebased series onto next-20170416
- Added Acked-by, Tested-by and Reviwed-by tags

Changes in v6:
- Fixed an issue reported by kbuild test robot about changes in DAC960
- Removed patches 15/19,16/19,17/19,18/19. They have been merged by Greg
- Added Acked-by Tags

Changes in v5:
- Re-worded the cover letter (remove sentence about checkpatch.pl)
- Rebased series onto next-20170308
- Fix typos in commit message
- Added Acked-by Tags

Changes in v4:
- Rebased series onto next-20170301
- Removed patch 20/20: checks done by checkpath.pl, no longer required.
  Thanks to Peter and Joe for their feedbacks.
- Added Reviewed-by tags

Changes in v3:
- Rebased series onto next-20170224
- Fix checkpath.pl reports for patch 11/20 and patch 12/20
- Remove prefix RFC
Changes in v2:
- Introduced patch 18/20
- Fixed cosmetic changes: spaces before brace, live over 80 characters
- Removed some of the check for NULL pointers before calling dma_pool_destroy
- Improved the regexp in checkpatch for pci_pool, thanks to Joe Perches
- Added Tested-by and Acked-by tags

Romain Perier (4):
  block: DAC960: Replace PCI pool old API
  net: e100: Replace PCI pool old API
  hinic: Replace PCI pool old API
  PCI: Remove PCI pool macro functions

 drivers/block/DAC960.c| 38 +++
 drivers/block/DAC960.h|  4 +--
 drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c | 10 +++---
 drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h |  2 +-
 drivers/net/ethernet/intel/e100.c | 12 +++
 include/linux/pci.h   |  9 --
 6 files changed, 32 insertions(+), 43 deletions(-)

-- 
2.14.1



[PATCH v17 3/4] hinic: Replace PCI pool old API

2018-01-02 Thread Romain Perier
From: Romain Perier 

The PCI pool API is deprecated. This commit replaces the PCI pool old
API by the appropriate function with the DMA pool API.

Signed-off-by: Romain Perier 
Acked-by: David S. Miller 
---
 drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c | 10 +-
 drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c 
b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
index 7d95f0866fb0..28a81ac97af5 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
@@ -143,7 +143,7 @@ int hinic_alloc_cmdq_buf(struct hinic_cmdqs *cmdqs,
struct hinic_hwif *hwif = cmdqs->hwif;
struct pci_dev *pdev = hwif->pdev;
 
-   cmdq_buf->buf = pci_pool_alloc(cmdqs->cmdq_buf_pool, GFP_KERNEL,
+   cmdq_buf->buf = dma_pool_alloc(cmdqs->cmdq_buf_pool, GFP_KERNEL,
   &cmdq_buf->dma_addr);
if (!cmdq_buf->buf) {
dev_err(&pdev->dev, "Failed to allocate cmd from the pool\n");
@@ -161,7 +161,7 @@ int hinic_alloc_cmdq_buf(struct hinic_cmdqs *cmdqs,
 void hinic_free_cmdq_buf(struct hinic_cmdqs *cmdqs,
 struct hinic_cmdq_buf *cmdq_buf)
 {
-   pci_pool_free(cmdqs->cmdq_buf_pool, cmdq_buf->buf, cmdq_buf->dma_addr);
+   dma_pool_free(cmdqs->cmdq_buf_pool, cmdq_buf->buf, cmdq_buf->dma_addr);
 }
 
 static unsigned int cmdq_wqe_size_from_bdlen(enum bufdesc_len len)
@@ -875,7 +875,7 @@ int hinic_init_cmdqs(struct hinic_cmdqs *cmdqs, struct 
hinic_hwif *hwif,
int err;
 
cmdqs->hwif = hwif;
-   cmdqs->cmdq_buf_pool = pci_pool_create("hinic_cmdq", pdev,
+   cmdqs->cmdq_buf_pool = dma_pool_create("hinic_cmdq", &pdev->dev,
   HINIC_CMDQ_BUF_SIZE,
   HINIC_CMDQ_BUF_SIZE, 0);
if (!cmdqs->cmdq_buf_pool)
@@ -916,7 +916,7 @@ int hinic_init_cmdqs(struct hinic_cmdqs *cmdqs, struct 
hinic_hwif *hwif,
devm_kfree(&pdev->dev, cmdqs->saved_wqs);
 
 err_saved_wqs:
-   pci_pool_destroy(cmdqs->cmdq_buf_pool);
+   dma_pool_destroy(cmdqs->cmdq_buf_pool);
return err;
 }
 
@@ -942,5 +942,5 @@ void hinic_free_cmdqs(struct hinic_cmdqs *cmdqs)
 
devm_kfree(&pdev->dev, cmdqs->saved_wqs);
 
-   pci_pool_destroy(cmdqs->cmdq_buf_pool);
+   dma_pool_destroy(cmdqs->cmdq_buf_pool);
 }
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h 
b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h
index b35583400cb6..23f8d39eab68 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h
@@ -157,7 +157,7 @@ struct hinic_cmdq {
 struct hinic_cmdqs {
struct hinic_hwif   *hwif;
 
-   struct pci_pool *cmdq_buf_pool;
+   struct dma_pool *cmdq_buf_pool;
 
struct hinic_wq *saved_wqs;
 
-- 
2.14.1



[PATCH v17 1/4] block: DAC960: Replace PCI pool old API

2018-01-02 Thread Romain Perier
From: Romain Perier 

The PCI pool API is deprecated. This commit replaces the PCI pool old
API by the appropriate function with the DMA pool API.

Signed-off-by: Romain Perier 
Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 
---
 drivers/block/DAC960.c | 38 ++
 drivers/block/DAC960.h |  4 ++--
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 442e777bdfb2..df8e3a8f63ec 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -268,17 +268,17 @@ static bool 
DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
   void *AllocationPointer = NULL;
   void *ScatterGatherCPU = NULL;
   dma_addr_t ScatterGatherDMA;
-  struct pci_pool *ScatterGatherPool;
+  struct dma_pool *ScatterGatherPool;
   void *RequestSenseCPU = NULL;
   dma_addr_t RequestSenseDMA;
-  struct pci_pool *RequestSensePool = NULL;
+  struct dma_pool *RequestSensePool = NULL;
 
   if (Controller->FirmwareType == DAC960_V1_Controller)
 {
   CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker);
   CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
-  ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather",
-   Controller->PCIDevice,
+  ScatterGatherPool = dma_pool_create("DAC960_V1_ScatterGather",
+   &Controller->PCIDevice->dev,
DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T),
sizeof(DAC960_V1_ScatterGatherSegment_T), 0);
   if (ScatterGatherPool == NULL)
@@ -290,18 +290,18 @@ static bool 
DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
 {
   CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker);
   CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
-  ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather",
-   Controller->PCIDevice,
+  ScatterGatherPool = dma_pool_create("DAC960_V2_ScatterGather",
+   &Controller->PCIDevice->dev,
DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
   if (ScatterGatherPool == NULL)
return DAC960_Failure(Controller,
"AUXILIARY STRUCTURE CREATION (SG)");
-  RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
-   Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
+  RequestSensePool = dma_pool_create("DAC960_V2_RequestSense",
+   &Controller->PCIDevice->dev, sizeof(DAC960_SCSI_RequestSense_T),
sizeof(int), 0);
   if (RequestSensePool == NULL) {
-   pci_pool_destroy(ScatterGatherPool);
+   dma_pool_destroy(ScatterGatherPool);
return DAC960_Failure(Controller,
"AUXILIARY STRUCTURE CREATION (SG)");
   }
@@ -335,16 +335,16 @@ static bool 
DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
   Command->Next = Controller->FreeCommands;
   Controller->FreeCommands = Command;
   Controller->Commands[CommandIdentifier-1] = Command;
-  ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
+  ScatterGatherCPU = dma_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
&ScatterGatherDMA);
   if (ScatterGatherCPU == NULL)
  return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
 
   if (RequestSensePool != NULL) {
- RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
+ RequestSenseCPU = dma_pool_alloc(RequestSensePool, GFP_ATOMIC,
&RequestSenseDMA);
  if (RequestSenseCPU == NULL) {
-pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
+dma_pool_free(ScatterGatherPool, ScatterGatherCPU,
 ScatterGatherDMA);
return DAC960_Failure(Controller,
"AUXILIARY STRUCTURE CREATION");
@@ -379,8 +379,8 @@ static bool 
DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
 {
   int i;
-  struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
-  struct pci_pool *RequestSensePool = NULL;
+  struct dma_pool *ScatterGatherPool = Controller->ScatterGatherPool;
+  struct dma_pool *RequestSensePool = NULL;
   void *ScatterGatherCPU;
   dma_addr_t ScatterGatherDMA;
   void *RequestSenseCPU;
@@ -411,9 +411,9 @@ static void 
DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
  RequestSenseDMA = Command->V2.RequestSenseDMA;
   }
   if (ScatterGatherCPU != NULL)
-  pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA);
+  dma_pool_free(ScatterGatherPool, ScatterGatherCPU, Sca

[PATCH v17 2/4] net: e100: Replace PCI pool old API

2018-01-02 Thread Romain Perier
From: Romain Perier 

The PCI pool API is deprecated. This commit replaces the PCI pool old
API by the appropriate function with the DMA pool API.

Signed-off-by: Romain Perier 
Acked-by: Peter Senna Tschudin 
Acked-by: Jeff Kirsher 
Acked-by: David S. Miller 
Tested-by: Peter Senna Tschudin 
---
 drivers/net/ethernet/intel/e100.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c 
b/drivers/net/ethernet/intel/e100.c
index 44b3937f7e81..29486478836e 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -607,7 +607,7 @@ struct nic {
struct mem *mem;
dma_addr_t dma_addr;
 
-   struct pci_pool *cbs_pool;
+   struct dma_pool *cbs_pool;
dma_addr_t cbs_dma_addr;
u8 adaptive_ifs;
u8 tx_threshold;
@@ -1892,7 +1892,7 @@ static void e100_clean_cbs(struct nic *nic)
nic->cb_to_clean = nic->cb_to_clean->next;
nic->cbs_avail++;
}
-   pci_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr);
+   dma_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr);
nic->cbs = NULL;
nic->cbs_avail = 0;
}
@@ -1910,7 +1910,7 @@ static int e100_alloc_cbs(struct nic *nic)
nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL;
nic->cbs_avail = 0;
 
-   nic->cbs = pci_pool_zalloc(nic->cbs_pool, GFP_KERNEL,
+   nic->cbs = dma_pool_zalloc(nic->cbs_pool, GFP_KERNEL,
   &nic->cbs_dma_addr);
if (!nic->cbs)
return -ENOMEM;
@@ -2960,8 +2960,8 @@ static int e100_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
netif_err(nic, probe, nic->netdev, "Cannot register net device, 
aborting\n");
goto err_out_free;
}
-   nic->cbs_pool = pci_pool_create(netdev->name,
-  nic->pdev,
+   nic->cbs_pool = dma_pool_create(netdev->name,
+  &nic->pdev->dev,
   nic->params.cbs.max * sizeof(struct cb),
   sizeof(u32),
   0);
@@ -3001,7 +3001,7 @@ static void e100_remove(struct pci_dev *pdev)
unregister_netdev(netdev);
e100_free(nic);
pci_iounmap(pdev, nic->csr);
-   pci_pool_destroy(nic->cbs_pool);
+   dma_pool_destroy(nic->cbs_pool);
free_netdev(netdev);
pci_release_regions(pdev);
pci_disable_device(pdev);
-- 
2.14.1



[PATCH for sg3_utils 1/4] configure.ac: Suppress an autoconf warning

2018-01-02 Thread Bart Van Assche
Avoid that autoconf reports the following warning:

configure.ac:15: warning: LT_INIT was called before AM_PROG_AR

Signed-off-by: Bart Van Assche 
---
 configure| 352 +--
 configure.ac |   6 +-
 2 files changed, 179 insertions(+), 179 deletions(-)

diff --git a/configure b/configure
index 4a664c1bc343..5fe9a187a373 100755
--- a/configure
+++ b/configure
@@ -661,8 +661,6 @@ NMEDIT
 DSYMUTIL
 MANIFEST_TOOL
 RANLIB
-ac_ct_AR
-AR
 DLLTOOL
 OBJDUMP
 LN_S
@@ -683,6 +681,8 @@ build_vendor
 build_cpu
 build
 LIBTOOL
+ac_ct_AR
+AR
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
@@ -3920,6 +3920,180 @@ fi
 # AC_PROG_CXX
 
 
+# AM_PROG_AR is supported and needed since automake v1.12+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar lib "link -lib"
+  do
+# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a 
program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar lib "link -lib"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with 
args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ac_cv_prog_ac_ct_AR="$ac_prog"
+$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+AR="false"
+  else
+case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not 
prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" 
>&2;}
+ac_tool_warned=yes ;;
+esac
+AR=$ac_ct_AR
+  fi
+fi
+
+: ${AR=ar}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) 
interface" >&5
+$as_echo_n "checking the archiver ($AR) interface... " >&6; }
+if ${am_cv_ar_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+   am_cv_ar_interface=ar
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int some_variable = 0;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if test "$ac_status" -eq 0; then
+am_cv_ar_interface=ar
+  else
+am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'
+{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
+  (eval $am_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+if test "$ac_status" -eq 0; then
+  am_cv_ar_interface=lib
+else
+  am_cv_ar_interface=unknown
+fi
+  fi
+  rm -f conftest.lib libconftest.a
+
+fi
+rm 

[PATCH for sg3_utils 4/4] configure.ac, Makefile.am: Use CFLAGS and LIBS instead of os_cflags and os_libs

2018-01-02 Thread Bart Van Assche
Instead of introducing variables for system-specific flags and libraries,
use CFLAGS and LIBS. This simplifies the Makefiles since automake appends
these automatically.

Signed-off-by: Bart Van Assche 
---
 Makefile.in |   2 -
 configure   |  36 ++---
 configure.ac|  22 ++--
 doc/Makefile.in |   2 -
 include/Makefile.in |   2 -
 lib/Makefile.am |   2 +-
 lib/Makefile.in |   4 +-
 scripts/Makefile.in |   2 -
 src/Makefile.am | 140 +-
 src/Makefile.in | 144 +---
 10 files changed, 149 insertions(+), 207 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 4e2b06453f28..2b88c81c2615 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -308,8 +308,6 @@ localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-os_cflags = @os_cflags@
-os_libs = @os_libs@
 pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
diff --git a/configure b/configure
index ce82b6d23236..af2f7d07e70c 100755
--- a/configure
+++ b/configure
@@ -649,8 +649,6 @@ OS_LINUX_FALSE
 OS_LINUX_TRUE
 OS_FREEBSD_FALSE
 OS_FREEBSD_TRUE
-os_libs
-os_cflags
 GETOPT_O_FILES
 PTHREAD_LIB
 CPP
@@ -12464,10 +12462,6 @@ cat >>confdefs.h <<_ACEOF
 #define SG_LIB_LINUX 1
 _ACEOF
 
-os_cflags=''
-
-os_libs=''
-
check_for_linux_nvme_headers;;
 *-*-freebsd*|*-*-kfreebsd*-gnu*)
 
@@ -12478,40 +12472,26 @@ _ACEOF
 
 $as_echo "#define HAVE_NVME 1" >>confdefs.h
 
-os_cflags=''
-
-os_libs='-lcam'
-;;
+LIBS="$LIBS -lcam";;
 *-*-solaris*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_SOLARIS 1
 _ACEOF
-
-os_cflags=''
-
-os_libs=''
 ;;
 *-*-osf*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_OSF1 1
 _ACEOF
-
-os_cflags=''
-
-os_libs=''
- ;;
+;;
 *-*-cygwin*)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_WIN32 1
 _ACEOF
 
-os_cflags='-Wno-char-subscripts'
-
-os_libs=''
- ;;
+CFLAGS="$CFLAGS -Wno-char-subscripts";;
 *-*-mingw*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12522,21 +12502,13 @@ _ACEOF
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_MINGW 1
 _ACEOF
-
-os_cflags=''
-
-os_libs=''
- ;;
+;;
 *-*-linux-gnu* | *-*-linux* | *)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_LINUX 1
 _ACEOF
 
-os_cflags=''
-
-os_libs=''
-
 check_for_linux_nvme_headers;;
 esac
 
diff --git a/configure.ac b/configure.ac
index 70cf98456339..8dffdc51c437 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,35 +52,23 @@ case "${host}" in
*-*-android*)
AC_DEFINE_UNQUOTED(SG_LIB_ANDROID, 1, [sg3_utils on android])
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], [''])
check_for_linux_nvme_headers;;
 *-*-freebsd*|*-*-kfreebsd*-gnu*)
AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sg3_utils on FreeBSD])
AC_DEFINE(HAVE_NVME, 1, [Found NVMe])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], ['-lcam']);;
+LIBS="$LIBS -lcam";;
 *-*-solaris*)
-   AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], ['']);;
+   AC_DEFINE_UNQUOTED(SG_LIB_SOLARIS, 1, [sg3_utils on Solaris]);;
 *-*-osf*)
-   AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sg3_utils on Tru64 UNIX])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], ['']) ;;
+   AC_DEFINE_UNQUOTED(SG_LIB_OSF1, 1, [sg3_utils on Tru64 UNIX]);;
 *-*-cygwin*)
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
-AC_SUBST([os_cflags], ['-Wno-char-subscripts'])
-AC_SUBST([os_libs], ['']) ;;
+CFLAGS="$CFLAGS -Wno-char-subscripts";;
 *-*-mingw*)
AC_DEFINE_UNQUOTED(SG_LIB_WIN32, 1, [sg3_utils on Win32])
-   AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], ['']) ;;
+   AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment]);;
 *-*-linux-gnu* | *-*-linux* | *)
 AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux])
-AC_SUBST([os_cflags], [''])
-AC_SUBST([os_libs], [''])
 check_for_linux_nvme_headers;;
 esac
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 5b3f009554af..e4605ac68e45 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@

[PATCH for sg3_utils 0/4] Simplify the sg3_utils configure script

2018-01-02 Thread Bart Van Assche
Hello Doug,

The four patches in this series is what I came up with after having reviewed
the sg3_utils configure script. Please consider to apply these patches on the
sg3_utils trunk.

Thanks,

Bart.

Bart Van Assche (4):
  configure.ac: Suppress an autoconf warning
  configure.ac: Only link with the pthread library if required
  configure.ac: Avoid code duplication
  configure.ac, Makefile.am: Use CFLAGS and LIBS instead of os_cflags
and os_libs

 Makefile.in |   3 +-
 config.h.in |   6 +-
 configure   | 672 +++-
 configure.ac|  83 +++
 doc/Makefile.in |   3 +-
 include/Makefile.in |   3 +-
 lib/Makefile.am |   2 +-
 lib/Makefile.in |   5 +-
 scripts/Makefile.in |   3 +-
 src/Makefile.am | 140 ++-
 src/Makefile.in | 145 ++--
 11 files changed, 425 insertions(+), 640 deletions(-)

-- 
2.15.1



[PATCH for sg3_utils 3/4] configure.ac: Avoid code duplication

2018-01-02 Thread Bart Van Assche
Ensure that the code for checking the Linux NVMe headers occurs once.

Signed-off-by: Bart Van Assche 
---
 config.h.in  |   2 +-
 configure| 124 ---
 configure.ac |  45 ++
 3 files changed, 21 insertions(+), 150 deletions(-)

diff --git a/config.h.in b/config.h.in
index b5c6715ade05..6050d85dfc1c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -105,7 +105,7 @@
 /* sg3_utils on FreeBSD */
 #undef SG_LIB_FREEBSD
 
-/* assume sg3_utils on linux */
+/* sg3_utils on linux */
 #undef SG_LIB_LINUX
 
 /* also MinGW environment */
diff --git a/configure b/configure
index 59b01f4fdf5b..ce82b6d23236 100755
--- a/configure
+++ b/configure
@@ -12418,18 +12418,8 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-case "${host}" in
-*-*-linux-gnu*)
-
-cat >>confdefs.h <<_ACEOF
-#define SG_LIB_LINUX 1
-_ACEOF
-
-os_cflags=''
-
-os_libs=''
-
-   for ac_header in linux/nvme_ioctl.h
+check_for_linux_nvme_headers() {
+   for ac_header in linux/nvme_ioctl.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" 
"ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
 if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
@@ -12443,7 +12433,7 @@ fi
 
 done
 
-   for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
+   for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef 
HAVE_LINUX_TYPES_H
@@ -12459,48 +12449,10 @@ _ACEOF
 fi
 
 done
- ;;
-*-*-linux*)
-
-cat >>confdefs.h <<_ACEOF
-#define SG_LIB_LINUX 1
-_ACEOF
-
-os_cflags=''
-
-os_libs=''
-
-   for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" 
"ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-   for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef 
HAVE_LINUX_TYPES_H
-# include 
-#endif
 
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
+}
 
-done
- ;;
+case "${host}" in
*-*-android*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12516,37 +12468,7 @@ _ACEOF
 
 os_libs=''
 
-   for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" 
"ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-   for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef 
HAVE_LINUX_TYPES_H
-# include 
-#endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
+   check_for_linux_nvme_headers;;
 *-*-freebsd*|*-*-kfreebsd*-gnu*)
 
 cat >>confdefs.h <<_ACEOF
@@ -12605,7 +12527,7 @@ _ACEOF
 
 os_libs=''
  ;;
-*)
+*-*-linux-gnu* | *-*-linux* | *)
 
 cat >>confdefs.h <<_ACEOF
 #define SG_LIB_LINUX 1
@@ -12615,37 +12537,7 @@ _ACEOF
 
 os_libs=''
 
-   for ac_header in linux/nvme_ioctl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" 
"ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LINUX_NVME_IOCTL_H 1
-_ACEOF
-
-$as_echo "#define HAVE_NVME 1" >>confdefs.h
-
-fi
-
-done
-
-   for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef 
HAVE_LINUX_TYPES_H
-# include 
-#endif
-
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
- ;;
+check_for_linux_nvme_headers;;
 esac
 
 # Define platform-specific symbol.
diff --git a/configure.ac b/configure.ac
index 6164850d0aa3..70cf98456339 10064

[PATCH for sg3_utils 2/4] configure.ac: Only link with the pthread library if required

2018-01-02 Thread Bart Van Assche
Let the configure script detect whether pthread functions occur in the
pthread library (all platforms except Android) or in the C library
(Android). From the autoconf manual:

  action-if-found is a list of shell commands to run if the link with the
  library succeeds; action-if-not-found is a list of shell commands to run
  if the link fails. If action-if-found is not specified, the default action
  prepends -llibrary to LIBS and defines 'HAVE_LIBlibrary' (in all capitals).

Signed-off-by: Bart Van Assche 
---
 Makefile.in |  1 +
 config.h.in |  4 +--
 configure   | 94 +++--
 configure.ac| 10 --
 doc/Makefile.in |  1 +
 include/Makefile.in |  1 +
 lib/Makefile.in |  1 +
 scripts/Makefile.in |  1 +
 src/Makefile.am |  2 +-
 src/Makefile.in |  3 +-
 10 files changed, 45 insertions(+), 73 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 0054cfe62bd6..4e2b06453f28 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -261,6 +261,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_LIB = @PTHREAD_LIB@
 RANLIB = @RANLIB@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
diff --git a/config.h.in b/config.h.in
index b33212f47d27..b5c6715ade05 100644
--- a/config.h.in
+++ b/config.h.in
@@ -36,10 +36,10 @@
 /* Define to 1 if you have the `posix_memalign' function. */
 #undef HAVE_POSIX_MEMALIGN
 
-/* Found pthread_cancel */
+/* Define to 1 if you have the `pthread_cancel' function. */
 #undef HAVE_PTHREAD_CANCEL
 
-/* Found pthread_kill */
+/* Define to 1 if you have the `pthread_kill' function. */
 #undef HAVE_PTHREAD_KILL
 
 /* Define to 1 if you have the  header file. */
diff --git a/configure b/configure
index 5fe9a187a373..59b01f4fdf5b 100755
--- a/configure
+++ b/configure
@@ -652,6 +652,7 @@ OS_FREEBSD_TRUE
 os_libs
 os_cflags
 GETOPT_O_FILES
+PTHREAD_LIB
 CPP
 LT_SYS_LIBRARY_PATH
 OTOOL64
@@ -12332,9 +12333,10 @@ _ACEOF
 fi
 done
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing 
pthread_cancel" >&5
-$as_echo_n "checking for library containing pthread_cancel... " >&6; }
-if ${ac_cv_search_pthread_cancel+:} false; then :
+SAVED_LIBS=$LIBS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing 
pthread_create" >&5
+$as_echo_n "checking for library containing pthread_create... " >&6; }
+if ${ac_cv_search_pthread_create+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -12347,11 +12349,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char pthread_cancel ();
+char pthread_create ();
 int
 main ()
 {
-return pthread_cancel ();
+return pthread_create ();
   ;
   return 0;
 }
@@ -12364,89 +12366,47 @@ for ac_lib in '' pthread; do
 LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
   if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_pthread_cancel=$ac_res
+  ac_cv_search_pthread_create=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
 conftest$ac_exeext
-  if ${ac_cv_search_pthread_cancel+:} false; then :
+  if ${ac_cv_search_pthread_create+:} false; then :
   break
 fi
 done
-if ${ac_cv_search_pthread_cancel+:} false; then :
+if ${ac_cv_search_pthread_create+:} false; then :
 
 else
-  ac_cv_search_pthread_cancel=no
+  ac_cv_search_pthread_create=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_cancel" 
>&5
-$as_echo "$ac_cv_search_pthread_cancel" >&6; }
-ac_res=$ac_cv_search_pthread_cancel
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" 
>&5
+$as_echo "$ac_cv_search_pthread_create" >&6; }
+ac_res=$ac_cv_search_pthread_create
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-$as_echo "#define HAVE_PTHREAD_CANCEL 1" >>confdefs.h
-
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing 
pthread_kill" >&5
-$as_echo_n "checking for library containing pthread_kill... " >&6; }
-if ${ac_cv_search_pthread_kill+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_kill ();
-int
-main ()
-{
-return pthread_kill ();
-  ;
-  return 0;
-}
+# AC_SEARCH_LIBS adds libraries at the start of $LIBS so remove $SAVED_LIBS
+# from the end of $LIBS.
+pthread_lib=${LIBS%${SAVED_LIBS}}
+for ac_func in pthread_cancel pthread_kill
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes

Re: [PATCH] scsi: smartpqi: allow static build ("built-in")

2018-01-02 Thread Steffen Weber
If CONFIG_SCSI_SMARTPQI=y then don't build this driver as a module.

Signed-off-by: Steffen Weber 
---
 drivers/scsi/smartpqi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/smartpqi/Makefile b/drivers/scsi/smartpqi/Makefile
index 0f42a225a..e6b779930 100644
--- a/drivers/scsi/smartpqi/Makefile
+++ b/drivers/scsi/smartpqi/Makefile
@@ -1,3 +1,3 @@
 ccflags-y += -I.
-obj-m  += smartpqi.o
+obj-$(CONFIG_SCSI_SMARTPQI) += smartpqi.o
 smartpqi-objs := smartpqi_init.o smartpqi_sis.o smartpqi_sas_transport.o
-- 
2.15.1



Re: [PATCH v4 net-next 0/4] qed*: Advance to FW 8.33.1.0

2018-01-02 Thread David Miller
From: Tomer Tayar 
Date: Wed, 27 Dec 2017 19:30:04 +0200

> This series advances all qed* drivers to use firmware 8.33.1.0 which brings
> new capabilities and initial support of new HW. The changes are mostly in
> qed, and include changes in the FW interface files, as well as updating the
> FW initialization and debug collection code. The protocol drivers have
> minor functional changes for this firmware.
> 
> Patch 1 Rearranges and refactors the FW interface files in preparation of
> the new FW (no functional change).
> Patch 2 Prepares the code for support of new HW (no functional change).
> Patch 3 Actual utilization of the new FW.
> Patch 4 Advances drivers' version.
> 
> v3->v4:
> Fix a compilation issue which was reported by krobot (dependency on CRC8).
> 
> v2->v3:
> Resend the series with a fixed title in the cover letter.
> 
> v1->v2:
> - Break the previous single patch into several patches.
> - Fix compilation issues which were reported by krobot.

I'm going to apply this, however

These firmware update changes are rediculously invasive.

Backporting patches through these updates will be a giant task if not
impossible for anyone who tries to do something like this.

Who reviewed these changes outside of Cavium to look for clerical
and typographical errors?  I be nobody did.  I personally scanned
them for about 20 minutes.

Therefore, it is my judgment that the way firmware support updates are
done in the QED driver is detrimental to it's long term
maintainability.

Thank you.


Re: [PATCH 7/9] scsi: bnx2fc: Use zeroing allocator rather than allocator/memset

2018-01-02 Thread Chad Dupuis

On Sat, 30 Dec 2017, 10:28am, Himanshu Jha wrote:

> Use dma_zalloc_coherent instead of dma_alloc_coherent followed by
> memset 0.
> 
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 
> Suggested-by: Luis R. Rodriguez 
> Signed-off-by: Himanshu Jha 
> ---
>  drivers/scsi/bnx2fc/bnx2fc_hwi.c | 60 
> +---
>  drivers/scsi/bnx2fc/bnx2fc_tgt.c | 51 +++---
>  2 files changed, 47 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c 
> b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> index 26de61d..e8ae4d6 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> @@ -1857,16 +1857,15 @@ int bnx2fc_setup_task_ctx(struct bnx2fc_hba *hba)
>* entries. Hence the limit with one page is 8192 task context
>* entries.
>*/
> - hba->task_ctx_bd_tbl = dma_alloc_coherent(&hba->pcidev->dev,
> -   PAGE_SIZE,
> -   &hba->task_ctx_bd_dma,
> -   GFP_KERNEL);
> + hba->task_ctx_bd_tbl = dma_zalloc_coherent(&hba->pcidev->dev,
> +PAGE_SIZE,
> +&hba->task_ctx_bd_dma,
> +GFP_KERNEL);
>   if (!hba->task_ctx_bd_tbl) {
>   printk(KERN_ERR PFX "unable to allocate task context BDT\n");
>   rc = -1;
>   goto out;
>   }
> - memset(hba->task_ctx_bd_tbl, 0, PAGE_SIZE);
>  
>   /*
>* Allocate task_ctx which is an array of pointers pointing to
> @@ -1895,16 +1894,15 @@ int bnx2fc_setup_task_ctx(struct bnx2fc_hba *hba)
>   task_ctx_bdt = (struct regpair *)hba->task_ctx_bd_tbl;
>   for (i = 0; i < task_ctx_arr_sz; i++) {
>  
> - hba->task_ctx[i] = dma_alloc_coherent(&hba->pcidev->dev,
> -   PAGE_SIZE,
> -   &hba->task_ctx_dma[i],
> -   GFP_KERNEL);
> + hba->task_ctx[i] = dma_zalloc_coherent(&hba->pcidev->dev,
> +PAGE_SIZE,
> +&hba->task_ctx_dma[i],
> +GFP_KERNEL);
>   if (!hba->task_ctx[i]) {
>   printk(KERN_ERR PFX "unable to alloc task context\n");
>   rc = -1;
>   goto out3;
>   }
> - memset(hba->task_ctx[i], 0, PAGE_SIZE);
>   addr = (u64)hba->task_ctx_dma[i];
>   task_ctx_bdt->hi = cpu_to_le32((u64)addr >> 32);
>   task_ctx_bdt->lo = cpu_to_le32((u32)addr);
> @@ -2033,28 +2031,23 @@ static int bnx2fc_allocate_hash_table(struct 
> bnx2fc_hba *hba)
>   }
>  
>   for (i = 0; i < segment_count; ++i) {
> - hba->hash_tbl_segments[i] =
> - dma_alloc_coherent(&hba->pcidev->dev,
> -BNX2FC_HASH_TBL_CHUNK_SIZE,
> -&dma_segment_array[i],
> -GFP_KERNEL);
> + hba->hash_tbl_segments[i] =
> +  dma_zalloc_coherent(&hba->pcidev->dev,
> + BNX2FC_HASH_TBL_CHUNK_SIZE,
> + &dma_segment_array[i],
> + GFP_KERNEL);
>   if (!hba->hash_tbl_segments[i]) {
>   printk(KERN_ERR PFX "hash segment alloc failed\n");
>   goto cleanup_dma;
>   }
> - memset(hba->hash_tbl_segments[i], 0,
> -BNX2FC_HASH_TBL_CHUNK_SIZE);
>   }
>  
> - hba->hash_tbl_pbl = dma_alloc_coherent(&hba->pcidev->dev,
> -PAGE_SIZE,
> -&hba->hash_tbl_pbl_dma,
> -GFP_KERNEL);
> + hba->hash_tbl_pbl = dma_zalloc_coherent(&hba->pcidev->dev, PAGE_SIZE,
> + &hba->hash_tbl_pbl_dma,
> + GFP_KERNEL);
>   if (!hba->hash_tbl_pbl) {
>   printk(KERN_ERR PFX "hash table pbl alloc failed\n");
>   goto cleanup_dma;
>   }
> - memset(hba->hash_tbl_pbl, 0, PAGE_SIZE);
>  
>   pbl = hba->hash_tbl_pbl;
>   for (i = 0; i < segment_count; ++i) {
> @@ -2111,27 +2104,26 @@ int bnx2fc_setup_fw_resc(struct bnx2fc_hba *hba)
>   return -ENOMEM;
>  
>   mem_size = BNX2FC_NUM_MAX_SESS * sizeof(struct regpair);
> - hba->t2_hash_tbl_ptr = dma_alloc_coherent(&hba->pcidev->dev, mem_size,
> -  

Re: [PATCH v17 0/4] Replace PCI pool by DMA pool API

2018-01-02 Thread Bjorn Helgaas
On Tue, Jan 02, 2018 at 06:53:52PM +0100, Romain Perier wrote:
> The current PCI pool API are simple macro functions direct expanded to
> the appropriate dma pool functions. The prototypes are almost the same
> and semantically, they are very similar. I propose to use the DMA pool
> API directly and get rid of the old API.
> 
> This set of patches, replaces the old API by the dma pool API
> and remove the defines.
> ...

> Romain Perier (4):
>   block: DAC960: Replace PCI pool old API
>   net: e100: Replace PCI pool old API
>   hinic: Replace PCI pool old API
>   PCI: Remove PCI pool macro functions
> 
>  drivers/block/DAC960.c| 38 
> +++
>  drivers/block/DAC960.h|  4 +--
>  drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c | 10 +++---
>  drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.h |  2 +-
>  drivers/net/ethernet/intel/e100.c | 12 +++
>  include/linux/pci.h   |  9 --
>  6 files changed, 32 insertions(+), 43 deletions(-)

Applied to pci/misc for v4.16, thanks!


Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Jaegeuk Kim
On 01/02, Stanislav Nijnikov wrote:
> 
> 
> > -Original Message-
> > From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> > Sent: Thursday, December 28, 2017 9:37 PM
> > To: Stanislav Nijnikov 
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> > gre...@linuxfoundation.org; Alex Lemberg 
> > Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> > 
> > On 12/28, Stanislav Nijnikov wrote:
> > > This patch introduces a sysfs group entry for the UFS device
> > > descriptor parameters. The group adds "device_descriptor" folder under
> > > the UFS driver sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The
> > > parameters are shown as hexadecimal numbers. The full information
> > > about the parameters could be found at UFS specifications 2.1.
> > >
> > > Signed-off-by: Stanislav Nijnikov 
> > > ---
> > >  Documentation/ABI/testing/sysfs-driver-ufs | 223
> > +
> > >  drivers/scsi/ufs/Makefile  |   3 +-
> > >  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
> > >  drivers/scsi/ufs/ufs-sysfs.h   |  25 
> > >  drivers/scsi/ufs/ufs.h |   8 ++
> > >  drivers/scsi/ufs/ufshcd.c  |  12 +-
> > >  drivers/scsi/ufs/ufshcd.h  |   4 +
> > >  7 files changed, 439 insertions(+), 6 deletions(-)  create mode
> > > 100644 Documentation/ABI/testing/sysfs-driver-ufs
> > >  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode 100644
> > > drivers/scsi/ufs/ufs-sysfs.h
> > >
> > > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> > > b/Documentation/ABI/testing/sysfs-driver-ufs
> > > new file mode 100644
> > > index 000..17cc4aa
> > > --- /dev/null
> > > +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> > 
> > [snip]
> > 
> > > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> > > index 9310c6c..918f579 100644
> > > --- a/drivers/scsi/ufs/Makefile
> > > +++ b/drivers/scsi/ufs/Makefile
> > > @@ -3,6 +3,7 @@
> > >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-
> > dwc.o
> > > tc-dwc-g210.o
> > >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> > > ufshcd-dwc.o tc-dwc-g210.o
> > >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > > +ufshcd.o ufs-sysfs.o
> > 
> > Why not just adding ufs-sysfs.o in the existing configuration?
> 
> The kernel build robot compiles the UFS driver as a separate module. 
> The existing configuration doesn't allow to add a new file to be compiled 
> as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
> ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
> This was the reason why I used EXPORT_SYMBOL in the first version.

Is there a reason to drop the first version?

> 
> > 
> > >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> > >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file
> > > mode 100644 index 000..1c685f3
> > > --- /dev/null
> > > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > > @@ -0,0 +1,170 @@
> > > +/*
> > > +* UFS Device Management sysfs
> > > +*
> > > +* Copyright (C) 2017 Western Digital Corporation
> > > +*
> > > +* This program is free software; you can redistribute it and/or
> > > +* modify it under the terms of the GNU General Public License version
> > > +* 2 as published by the Free Software Foundation.
> > > +*
> > > +* This program is distributed in the hope that it will be useful, but
> > > +* WITHOUT ANY WARRANTY; without even the implied warranty of
> > > +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > GNU
> > > +* General Public License for more details.
> > > +*
> > > +*/
> > > +
> > > +#include 
> > > +#include 
> > > +
> > > +#include "ufs.h"
> > > +#include "ufs-sysfs.h"
> > > +/* collision between the device descriptor parameter and the
> > > +definition */ #undef DEVICE_CLASS
> > 
> > Does this make sense? How about attaching "_" for all the macro like
> > _DEVICE_CLASS below?
> > 
> 
> It's not just changing the one line that uses "DEVICE_CLASS" to use 
> "_DEVICE_CLASS". It's will be necessary to add "_" to all descriptor
> parameters macros in all patches.

You should be able to do that by moving ufs_sysfs_read_desc_param() into
ufshcd.c, and remaining only the necessary header files for sysfs stuffs.

> 
> > > +
> > > +enum ufs_desc_param_size {
> > > + UFS_PARAM_BYTE_SIZE = 1,
> > > + UFS_PARAM_WORD_SIZE = 2,
> > > + UFS_PARAM_DWORD_SIZE= 4,
> > > + UFS_PARAM_QWORD_SIZE= 8,
> > > +};

Must be in header file.

> > > +
> > > +static inline ssize_t ufs_sysfs_read_desc_param(
> > > + struct ufs_hba *hba, u8 desc_idn, u8 index, char *buf, u8 off,
> > > + enum ufs_desc_param_size param_size) {
> > > + int desc_len;
> > > + int ret;
> > > + u8 *desc_buf;
> > > +
> > > + if

Re: [PATCH 2/3] scsi: libsas: fix error when getting phy events

2018-01-02 Thread Jason Yan


On 2018/1/2 21:50, John Garry wrote:

On 02/01/2018 12:15, Jason Yan wrote:

The intend purpose here was to goto out if smp_execute_task() returned
error. Obviously something got screwed up. We will never get these link
error statistics below:

~:/sys/class/sas_phy/phy-1:0:12 # cat invalid_dword_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat running_disparity_error_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat loss_of_dword_sync_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat phy_reset_problem_count
0

Obviously we should goto error handler if smp_execute_task() returns
non-zero.

Signed-off-by: Jason Yan 
CC: John Garry 
CC: chenqilin 
CC: chenxiang 
---
 drivers/scsi/libsas/sas_expander.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_expander.c
b/drivers/scsi/libsas/sas_expander.c
index 4b0c67f..6eab487 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -686,7 +686,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
 res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
 resp, RPEL_RESP_SIZE);

-if (!res)
+if (res)
 goto out;


This seems to have been broken for some time.

Could you inject some errors on the link to verify that this function
actually works properly with this change, i.e. non-zero reading?

Thanks,
John



Yes, I have tested it. Before we fix, they are all zero. After we fix
it and do some test:

localhost:/sys/class/sas_phy/phy-1:0:1 #
localhost:/sys/class/sas_phy/phy-1:0:1 # cat invalid_dword_count
22
localhost:/sys/class/sas_phy/phy-1:0:1 # cat phy_reset_problem_count
1
localhost:/sys/class/sas_phy/phy-1:0:1 # cat running_disparity_error_count
23
localhost:/sys/class/sas_phy/phy-1:0:1 # cat loss_of_dword_sync_count
1
localhost:/sys/class/sas_phy/phy-1:0:1 #




 phy->invalid_dword_count = scsi_to_u32(&resp[12]);





.





Re: [PATCH] scsi: libiscsi: Allow sd_shutdown on bad transport

2018-01-02 Thread Lee Duncan


On 12/07/2017 01:59 PM, Rafael David Tinoco wrote:
> If, for any reason, userland shuts down iscsi transport interfaces
> before proper logouts - like when logging in to LUNs manually,
> without logging out on server shutdown, or when automated scripts
> can't umount/logout from logged LUNs - kernel will hang forever on
> its sd_sync_cache() logic, after issuing the SYNCHRONIZE_CACHE cmd
> to all still existent paths.
> 
> PID: 1 TASK: 8801a69b8000 CPU: 1 COMMAND: "systemd-shutdow"
>  #0 [8801a69c3a30] __schedule at 8183e9ee
>  #1 [8801a69c3a80] schedule at 8183f0d5
>  #2 [8801a69c3a98] schedule_timeout at 81842199
>  #3 [8801a69c3b40] io_schedule_timeout at 8183e604
>  #4 [8801a69c3b70] wait_for_completion_io_timeout at 8183fc6c
>  #5 [8801a69c3bd0] blk_execute_rq at 813cfe10
>  #6 [8801a69c3c88] scsi_execute at 815c3fc7
>  #7 [8801a69c3cc8] scsi_execute_req_flags at 815c60fe
>  #8 [8801a69c3d30] sd_sync_cache at 815d37d7
>  #9 [8801a69c3da8] sd_shutdown at 815d3c3c
> 
> This happens because iscsi_eh_cmd_timed_out(), the transport layer
> timeout helper, would tell the queue timeout function (scsi_times_out)
> to reset the request timer over and over, until the session state is
> back to logged in state. Unfortunately, during server shutdown, this
> might never happen again.
> 
> Other option would be "not to handle" the issue in the transport
> layer. That would trigger the error handler logic, which would also
> need the session state to be logged in again.
> 
> Best option, for such case, is to tell upper layers that the command
> was handled during the transport layer error handler helper, marking
> it as DID_NO_CONNECT, which will allow completion and inform about
> the problem.
> 
> After the session was marked as ISCSI_STATE_FAILED, due to the first
> timeout during the server shutdown phase, all subsequent cmds will
> fail to be queued, allowing upper logic to fail faster.
> 
> Signed-off-by: Rafael David Tinoco 
> ---
>  drivers/scsi/libiscsi.c | 24 +++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 9c50d2d9f27c..785d1c55d152 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -1696,6 +1696,15 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct 
> scsi_cmnd *sc)
>*/
>   switch (session->state) {
>   case ISCSI_STATE_FAILED:
> + /*
> +  * cmds should fail during shutdown, if the session
> +  * state is bad, allowing completion to happen
> +  */
> + if (unlikely(system_state != SYSTEM_RUNNING)) {
> + reason = FAILURE_SESSION_FAILED;
> + sc->result = DID_NO_CONNECT << 16;
> + break;
> + }
>   case ISCSI_STATE_IN_RECOVERY:
>   reason = FAILURE_SESSION_IN_RECOVERY;
>   sc->result = DID_IMM_RETRY << 16;
> @@ -1978,6 +1987,19 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct 
> scsi_cmnd *sc)
>   }
>  
>   if (session->state != ISCSI_STATE_LOGGED_IN) {
> + /*
> +  * During shutdown, if session is prematurely disconnected,
> +  * recovery won't happen and there will be hung cmds. Not
> +  * handling cmds would trigger EH, also bad in this case.
> +  * Instead, handle cmd, allow completion to happen and let
> +  * upper layer to deal with the result.
> +  */
> + if (unlikely(system_state != SYSTEM_RUNNING)) {
> + sc->result = DID_NO_CONNECT << 16;
> + ISCSI_DBG_EH(session, "sc on shutdown, handled\n");
> + rc = BLK_EH_HANDLED;
> + goto done;
> + }
>   /*
>* We are probably in the middle of iscsi recovery so let
>* that complete and handle the error.
> @@ -2082,7 +2104,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct 
> scsi_cmnd *sc)
>   task->last_timeout = jiffies;
>   spin_unlock(&session->frwd_lock);
>   ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
> -  "timer reset" : "nh");
> +  "timer reset" : "shutdown or nh");
>   return rc;
>  }
>  EXPORT_SYMBOL_GPL(iscsi_eh_cmd_timed_out);
> 

Reviewed-by: Lee Duncan 

-- 
Lee


RE: [PATCH v4 net-next 0/4] qed*: Advance to FW 8.33.1.0

2018-01-02 Thread Elior, Ariel
> From: Tomer Tayar 
> Date: Wed, 27 Dec 2017 19:30:04 +0200
> 
> > This series advances all qed* drivers to use firmware 8.33.1.0 which brings
> > new capabilities and initial support of new HW. The changes are mostly in
> > qed, and include changes in the FW interface files, as well as updating the
> > FW initialization and debug collection code. The protocol drivers have
> > minor functional changes for this firmware.
> >
> > Patch 1 Rearranges and refactors the FW interface files in preparation of
> > the new FW (no functional change).
> > Patch 2 Prepares the code for support of new HW (no functional change).
> > Patch 3 Actual utilization of the new FW.
> > Patch 4 Advances drivers' version.
> >
> > v3->v4:
> > Fix a compilation issue which was reported by krobot (dependency on CRC8).
> >
> > v2->v3:
> > Resend the series with a fixed title in the cover letter.
> >
> > v1->v2:
> > - Break the previous single patch into several patches.
> > - Fix compilation issues which were reported by krobot.
> 
> I'm going to apply this, however
> 
> These firmware update changes are rediculously invasive.
> 
> Backporting patches through these updates will be a giant task if not
> impossible for anyone who tries to do something like this.
> 
> Who reviewed these changes outside of Cavium to look for clerical
> and typographical errors?  I be nobody did.  I personally scanned
> them for about 20 minutes.
> 
> Therefore, it is my judgment that the way firmware support updates are
> done in the QED driver is detrimental to it's long term
> maintainability.
> 
> Thank you.

Hi Dave,
We fully understand the concern regarding the size/depth of these changes,
and the difficulty of getting them reviewed, etc. Hopefully, this is the last 
time
you will see such massive changes. Future FW upgrades are expected to be far
lighter in their impact on the code. We also plan to make them more
frequent, which will further reduce the size/invasiveness of each change.
Thanks, and appreciate your time spent on reviewing this.
Ariel