Re: [PATCH 21/29] scsi: nsp32: constify pci_device_id.

2017-08-06 Thread Masanori Goto
2017-07-30 17:43 GMT+09:00 Arvind Yadav :
>
> pci_device_id are not supposed to change at runtime. All functions
> working with pci_device_id provided by  work with
> const pci_device_id. So mark the non-const structs as const.
>
> Signed-off-by: Arvind Yadav 

Thank you!  (resending it twice due to an error)

Acked-by: Masanori Goto 


> ---
>  drivers/scsi/nsp32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
> index 53c8477..1430b3c 100644
> --- a/drivers/scsi/nsp32.c
> +++ b/drivers/scsi/nsp32.c
> @@ -76,7 +76,7 @@ static const char *nsp32_release_version = "1.2";
>  /
>   * Supported hardware
>   */
> -static struct pci_device_id nsp32_pci_table[] = {
> +static const struct pci_device_id nsp32_pci_table[] = {
> {
> .vendor  = PCI_VENDOR_ID_IODATA,
> .device  = PCI_DEVICE_ID_NINJASCSI_32BI_CBSC_II,
> --
> 2.7.4


Re: [PATCH] tcmu: Oops in unmap_thread_fn()

2017-08-06 Thread Nicholas A. Bellinger
On Tue, 2017-08-01 at 23:09 +0300, Dan Carpenter wrote:
> Calling list_del() on the iterator pointer in list_for_each_entry() will
> cause an oops.  We need to user the _safe() version for that.
> 
> Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid 
> starvation")
> Signed-off-by: Dan Carpenter 
> 

Applied to target-pending/for-next.

Thanks DanC.



[PATCH] scsi: mpt3sas: Fix memory allocation failure test in 'mpt3sas_base_attach()'

2017-08-06 Thread Christophe JAILLET
In the lines above this test, 8 'kzalloc' are performed, but only 7 results
are tested.

Add the missing one (i.e. '!ioc->port_enable_cmds.reply').

Signed-off-by: Christophe JAILLET 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 1a5b6e40fb5c..8a44636ab0b5 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5494,10 +5494,10 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
mutex_init(>ctl_cmds.mutex);
 
-   if (!ioc->base_cmds.reply || !ioc->transport_cmds.reply ||
-   !ioc->scsih_cmds.reply || !ioc->tm_cmds.reply ||
-   !ioc->config_cmds.reply || !ioc->ctl_cmds.reply ||
-   !ioc->ctl_cmds.sense) {
+   if (!ioc->base_cmds.reply || !ioc->port_enable_cmds.reply ||
+   !ioc->transport_cmds.reply || !ioc->scsih_cmds.reply ||
+   !ioc->tm_cmds.reply || !ioc->config_cmds.reply ||
+   !ioc->ctl_cmds.reply || !ioc->ctl_cmds.sense) {
r = -ENOMEM;
goto out_free_resources;
}
-- 
2.11.0



[PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups

2017-08-06 Thread Christophe JAILLET
This patch series improves 'charger_manager_probe()'. The first patch is
about a missing memory allocation failure test.
The 2 others are just things spotted in this function:
   - a comment that is no more up to date
   - a style issue (which saves 1 line)

Christophe JAILLET (3):
  power: supply: charger-manager: Fix a NULL pointer dereference in
'charger_manager_probe()'
  power: supply: charger-manager: Fix a comment
  power: supply: charger-manager: Slighly simplify code

 drivers/power/supply/charger-manager.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

-- 
2.11.0



Re: [PATCH v06 04/36] uapi scsi/scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h

2017-08-06 Thread James Bottomley
On Sun, 2017-08-06 at 23:42 +0300, Mikko Rapeli wrote:
> Hi,
> 
> On Sun, Aug 06, 2017 at 11:22:53AM -0700, James Bottomley wrote:
> > 
> > On Sun, 2017-08-06 at 18:43 +0200, Mikko Rapeli wrote:
> > > 
> > > Fixes userspace compilation errors like:
> > > 
> > > scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-
> > > list  before ‘uint64_t’
> > 
> > Rather than patching the kernel, why not #include  in
> > your userspace programme?
> 
> The userspace program is actually a test which checks that uapi
> headers compile alone because several headers are not compiling at
> all and/or require special tricks. The test is available here:
> 
> http://marc.info/?l=linux-kernel=150203944104544=2

But you don't seem to be detecting or fixing an existing problem.
 These types are width unambiguous and all current consumers of these
headers include stdint.h so you're churning the kernel for a problem
which doesn't currently exist for any consumer of this header.

I can agree not adding any more external uint_t types for newly
exported headers so new consumers don't depend on an external standard
is reasonable, so checkpatch should warn if someone tries to add them;
I just don't see the benefit of going over the whole kernel changing
stuff that has worked fine for years.  Now if you can tell me there's
an actual bug somewhere, that's different ...

James



[PATCH] iscsi-target: Fix iscsi_np reset hung task during parallel delete

2017-08-06 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch fixes a bug associated with iscsit_reset_np_thread()
that can occur during parallel configfs rmdir of a single iscsi_np
used across multiple iscsi-target instances, that would result in
hung task(s) similar to below where configfs rmdir process context
was blocked indefinately waiting for iscsi_np->np_restart_comp
to finish:

[ 6726.112076] INFO: task dcp_proxy_node_:15550 blocked for more than 120 
seconds.
[ 6726.119440]   Tainted: GW  O 4.1.26-3321 #2
[ 6726.125045] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
message.
[ 6726.132927] dcp_proxy_node_ D 8803f202bc88 0 15550  1 0x
[ 6726.140058]  8803f202bc88 88085c64d960 88083b3b1ad0 
88087fffeb08
[ 6726.147593]  8803f202c000 7fff 88083f459c28 
88083b3b1ad0
[ 6726.155132]  88035373c100 8803f202bca8 8168ced2 
8803f202bcb8
[ 6726.162667] Call Trace:
[ 6726.165150]  [] schedule+0x32/0x80
[ 6726.170156]  [] schedule_timeout+0x214/0x290
[ 6726.176030]  [] ? __send_signal+0x52/0x4a0
[ 6726.181728]  [] wait_for_completion+0x96/0x100
[ 6726.187774]  [] ? wake_up_state+0x10/0x10
[ 6726.193395]  [] iscsit_reset_np_thread+0x62/0xe0 
[iscsi_target_mod]
[ 6726.201278]  [] iscsit_tpg_disable_portal_group+0x96/0x190 
[iscsi_target_mod]
[ 6726.210033]  [] lio_target_tpg_store_enable+0x4f/0xc0 
[iscsi_target_mod]
[ 6726.218351]  [] configfs_write_file+0xaa/0x110
[ 6726.224392]  [] vfs_write+0xa4/0x1b0
[ 6726.229576]  [] SyS_write+0x41/0xb0
[ 6726.234659]  [] system_call_fastpath+0x12/0x71

It would happen because each iscsit_reset_np_thread() sets state
to ISCSI_NP_THREAD_RESET, sends SIGINT, and then blocks waiting
for completion on iscsi_np->np_restart_comp.

However, if iscsi_np was active processing a login request and
more than a single iscsit_reset_np_thread() caller to the same
iscsi_np was blocked on iscsi_np->np_restart_comp, iscsi_np
kthread process context in __iscsi_target_login_thread() would
flush pending signals and only perform a single completion of
np->np_restart_comp before going back to sleep within transport
specific iscsit_transport->iscsi_accept_np code.

To address this bug, add a iscsi_np->np_reset_count and update
__iscsi_target_login_thread() to keep completing np->np_restart_comp
until ->np_reset_count has reached zero.

Reported-by: Gary Guo 
Tested-by: Gary Guo 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Signed-off-by: Nicholas Bellinger 
---
 drivers/target/iscsi/iscsi_target.c   | 1 +
 drivers/target/iscsi/iscsi_target_login.c | 7 +--
 include/target/iscsi/iscsi_target_core.h  | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 12803de..5001261 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -418,6 +418,7 @@ int iscsit_reset_np_thread(
return 0;
}
np->np_thread_state = ISCSI_NP_THREAD_RESET;
+   atomic_inc(>np_reset_count);
 
if (np->np_thread) {
spin_unlock_bh(>np_thread_lock);
diff --git a/drivers/target/iscsi/iscsi_target_login.c 
b/drivers/target/iscsi/iscsi_target_login.c
index e9bdc8b..dc13afb 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -1243,9 +1243,11 @@ static int __iscsi_target_login_thread(struct iscsi_np 
*np)
flush_signals(current);
 
spin_lock_bh(>np_thread_lock);
-   if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+   if (atomic_dec_if_positive(>np_reset_count) >= 0) {
np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
+   spin_unlock_bh(>np_thread_lock);
complete(>np_restart_comp);
+   return 1;
} else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) {
spin_unlock_bh(>np_thread_lock);
goto exit;
@@ -1278,7 +1280,8 @@ static int __iscsi_target_login_thread(struct iscsi_np 
*np)
goto exit;
} else if (rc < 0) {
spin_lock_bh(>np_thread_lock);
-   if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+   if (atomic_dec_if_positive(>np_reset_count) >= 0) {
+   np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
spin_unlock_bh(>np_thread_lock);
complete(>np_restart_comp);
iscsit_put_transport(conn->conn_transport);
diff --git a/include/target/iscsi/iscsi_target_core.h 
b/include/target/iscsi/iscsi_target_core.h
index 0ca1fb0..fb87d32 100644
--- a/include/target/iscsi/iscsi_target_core.h
+++ b/include/target/iscsi/iscsi_target_core.h
@@ -786,6 +786,7 @@ struct iscsi_np {
int np_sock_type;
enum 

Re: [PATCH v06 04/36] uapi scsi/scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h

2017-08-06 Thread Mikko Rapeli
Hi,

On Sun, Aug 06, 2017 at 11:22:53AM -0700, James Bottomley wrote:
> On Sun, 2017-08-06 at 18:43 +0200, Mikko Rapeli wrote:
> > Fixes userspace compilation errors like:
> > 
> > scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list 
> > before ‘uint64_t’
> 
> Rather than patching the kernel, why not #include  in your
> userspace programme?

The userspace program is actually a test which checks that uapi headers
compile alone because several headers are not compiling at all and/or
require special tricks. The test is available here:

http://marc.info/?l=linux-kernel=150203944104544=2

I have tried that approach before but then:

https://lkml.org/lkml/2015/6/1/160

For some subsystems like fuse the above message was not enough and they
are including stdint.h in userspace. What shall we do with this old
scsi header file?

-Mikko


Re: [PATCH v06 04/36] uapi scsi/scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h

2017-08-06 Thread James Bottomley
On Sun, 2017-08-06 at 18:43 +0200, Mikko Rapeli wrote:
> Fixes userspace compilation errors like:
> 
> scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list 
> before ‘uint64_t’

Rather than patching the kernel, why not #include  in your
userspace programme?

James



Re: [Regression 4.13-rc1] Resume does not work on Lenovo X60t

2017-08-06 Thread Paul Menzel

Dear Christoph,


On 2017-08-05 11:30, Christoph Hellwig wrote:

On Thu, Aug 03, 2017 at 07:42:15PM +0200, Paul Menzel wrote:


Since the merge windows opened for Linux 4.13, I am unable to resume 
from
ACPI S3 suspend on a Lenovo X60t. The graphics comes back, but I am 
unable
to enter anything, and the system seems to be hung. Magic SysRq keys 
still
work though, but powering the system of doesn’t work. The power button 
also

does not work.

Please find the stack trace with Linux 4.13-rc3 captured over the 
serial

console below.


Is this really -rc3?  rc3 has a commit to disable block runtime pm
for blk-mq, which is now the default for scsi.  So with -rc1 we've
seen similar reports, but rc3 would be odd and suggest we have further
problems.


Yes, this was 4.13-rc3. Rebuilding the Linux kernel from commit 0fdd951c 
(Merge tag 'media/v4.13-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media) shows 
the same behavior.



Kind regards,

Paul



[PATCH v06 02/36] uapi scsi/scsi_bsg_fc.h: use __u8, __u32 and __u64 from linux/types.h

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation errors like:

scsi/scsi_bsg_fc.h:83:2: error: unknown type name ‘uint8_t’

Signed-off-by: Mikko Rapeli 
Cc: linux-scsi@vger.kernel.org
---
 include/uapi/scsi/scsi_bsg_fc.h | 54 +
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
index 3031b900b087..1a2044755636 100644
--- a/include/uapi/scsi/scsi_bsg_fc.h
+++ b/include/uapi/scsi/scsi_bsg_fc.h
@@ -22,6 +22,8 @@
 #ifndef SCSI_BSG_FC_H
 #define SCSI_BSG_FC_H
 
+#include 
+
 /*
  * This file intended to be included by both kernel and user space
  */
@@ -80,10 +82,10 @@
  * with the transport upon completion of the login.
  */
 struct fc_bsg_host_add_rport {
-   uint8_t reserved;
+   __u8reserved;
 
/* FC Address Identier of the remote port to login to */
-   uint8_t port_id[3];
+   __u8port_id[3];
 };
 
 /* Response:
@@ -101,10 +103,10 @@ struct fc_bsg_host_add_rport {
  * remain logged in with the remote port.
  */
 struct fc_bsg_host_del_rport {
-   uint8_t reserved;
+   __u8reserved;
 
/* FC Address Identier of the remote port to logout of */
-   uint8_t port_id[3];
+   __u8port_id[3];
 };
 
 /* Response:
@@ -125,10 +127,10 @@ struct fc_bsg_host_els {
 * ELS Command Code being sent (must be the same as byte 0
 * of the payload)
 */
-   uint8_t command_code;
+   __u8command_code;
 
/* FC Address Identier of the remote port to send the ELS to */
-   uint8_t port_id[3];
+   __u8port_id[3];
 };
 
 /* Response:
@@ -165,14 +167,14 @@ struct fc_bsg_ctels_reply {
 * Note: x_RJT/BSY status will indicae that the rjt_data field
 *   is valid and contains the reason/explanation values.
 */
-   uint32_tstatus; /* See FC_CTELS_STATUS_xxx */
+   __u32   status; /* See FC_CTELS_STATUS_xxx */
 
/* valid if status is not FC_CTELS_STATUS_OK */
struct  {
-   uint8_t action; /* fragment_id for CT REJECT */
-   uint8_t reason_code;
-   uint8_t reason_explanation;
-   uint8_t vendor_unique;
+   __u8action; /* fragment_id for CT REJECT */
+   __u8reason_code;
+   __u8reason_explanation;
+   __u8vendor_unique;
} rjt_data;
 };
 
@@ -188,17 +190,17 @@ struct fc_bsg_ctels_reply {
  * and whether to tear it down after the request.
  */
 struct fc_bsg_host_ct {
-   uint8_t reserved;
+   __u8reserved;
 
/* FC Address Identier of the remote port to send the ELS to */
-   uint8_t port_id[3];
+   __u8port_id[3];
 
/*
 * We need words 0-2 of the generic preamble for the LLD's
 */
-   uint32_tpreamble_word0; /* revision & IN_ID */
-   uint32_tpreamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
-   uint32_tpreamble_word2; /* Cmd Code, Max Size */
+   __u32   preamble_word0; /* revision & IN_ID */
+   __u32   preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
+   __u32   preamble_word2; /* Cmd Code, Max Size */
 
 };
 /* Response:
@@ -218,17 +220,17 @@ struct fc_bsg_host_vendor {
 * Identifies the vendor that the message is formatted for. This
 * should be the recipient of the message.
 */
-   uint64_t vendor_id;
+   __u64 vendor_id;
 
/* start of vendor command area */
-   uint32_t vendor_cmd[0];
+   __u32 vendor_cmd[0];
 };
 
 /* Response:
  */
 struct fc_bsg_host_vendor_reply {
/* start of vendor response area */
-   uint32_t vendor_rsp[0];
+   __u32 vendor_rsp[0];
 };
 
 
@@ -247,7 +249,7 @@ struct fc_bsg_rport_els {
 * ELS Command Code being sent (must be the same as
 * byte 0 of the payload)
 */
-   uint8_t els_code;
+   __u8 els_code;
 };
 
 /* Response:
@@ -265,9 +267,9 @@ struct fc_bsg_rport_ct {
/*
 * We need words 0-2 of the generic preamble for the LLD's
 */
-   uint32_tpreamble_word0; /* revision & IN_ID */
-   uint32_tpreamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
-   uint32_tpreamble_word2; /* Cmd Code, Max Size */
+   __u32   preamble_word0; /* revision & IN_ID */
+   __u32   preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
+   __u32   preamble_word2; /* Cmd Code, Max Size */
 };
 /* Response:
  *
@@ -279,7 +281,7 @@ struct fc_bsg_rport_ct {
 
 /* request (CDB) structure of the sg_io_v4 */
 struct fc_bsg_request {
-   uint32_t msgcode;
+   __u32 msgcode;
union {
struct fc_bsg_host_add_rporth_addrport;
struct 

[PATCH v06 03/36] uapi scsi/scsi_netlink.h: use __u8, __u16 and __u64 from linux/types.h

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation errors like:

scsi/scsi_netlink.h:43:2: error: unknown type name ‘uint8_t’

Signed-off-by: Mikko Rapeli 
Cc: linux-scsi@vger.kernel.org
---
 include/uapi/scsi/scsi_netlink.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/uapi/scsi/scsi_netlink.h b/include/uapi/scsi/scsi_netlink.h
index 62b4edab15d3..36b53a769a04 100644
--- a/include/uapi/scsi/scsi_netlink.h
+++ b/include/uapi/scsi/scsi_netlink.h
@@ -22,8 +22,8 @@
 #ifndef SCSI_NETLINK_H
 #define SCSI_NETLINK_H
 
-#include 
 #include 
+#include 
 
 /*
  * This file intended to be included by both kernel and user space
@@ -40,12 +40,12 @@
 
 /* SCSI_TRANSPORT_MSG event message header */
 struct scsi_nl_hdr {
-   uint8_t version;
-   uint8_t transport;
-   uint16_t magic;
-   uint16_t msgtype;
-   uint16_t msglen;
-} __attribute__((aligned(sizeof(uint64_t;
+   __u8 version;
+   __u8 transport;
+   __u16 magic;
+   __u16 msgtype;
+   __u16 msglen;
+} __attribute__((aligned(sizeof(__u64;
 
 /* scsi_nl_hdr->version value */
 #define SCSI_NL_VERSION1
@@ -89,10 +89,10 @@ struct scsi_nl_hdr {
  */
 struct scsi_nl_host_vendor_msg {
struct scsi_nl_hdr snlh;/* must be 1st element ! */
-   uint64_t vendor_id;
-   uint16_t host_no;
-   uint16_t vmsg_datalen;
-} __attribute__((aligned(sizeof(uint64_t;
+   __u64 vendor_id;
+   __u16 host_no;
+   __u16 vmsg_datalen;
+} __attribute__((aligned(sizeof(__u64;
 
 
 /*
-- 
2.13.3



[PATCH v06 04/36] uapi scsi/scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h

2017-08-06 Thread Mikko Rapeli
Fixes userspace compilation errors like:

scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list before 
‘uint64_t’

Signed-off-by: Mikko Rapeli 
Cc: linux-scsi@vger.kernel.org
---
 include/uapi/scsi/scsi_netlink_fc.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/uapi/scsi/scsi_netlink_fc.h 
b/include/uapi/scsi/scsi_netlink_fc.h
index cbf76e479761..2493a0f533dc 100644
--- a/include/uapi/scsi/scsi_netlink_fc.h
+++ b/include/uapi/scsi/scsi_netlink_fc.h
@@ -57,14 +57,14 @@
  */
 struct fc_nl_event {
struct scsi_nl_hdr snlh;/* must be 1st element ! */
-   uint64_t seconds;
-   uint64_t vendor_id;
-   uint16_t host_no;
-   uint16_t event_datalen;
-   uint32_t event_num;
-   uint32_t event_code;
-   uint32_t event_data;
-} __attribute__((aligned(sizeof(uint64_t;
+   __u64 seconds;
+   __u64 vendor_id;
+   __u16 host_no;
+   __u16 event_datalen;
+   __u32 event_num;
+   __u32 event_code;
+   __u32 event_data;
+} __attribute__((aligned(sizeof(__u64;
 
 
 #endif /* SCSI_NETLINK_FC_H */
-- 
2.13.3



Re: [PATCH 0/5] block-cciss: Fine-tuning for two function implementations

2017-08-06 Thread SF Markus Elfring
> Date: Thu, 18 Aug 2016 11:40:04 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (5):
>   Use memdup_user()
>   Less function calls after error detection
>   Delete unnecessary initialisations
>   Move an assignment for the variable "sg_used"
>   Replace three kzalloc() calls by kcalloc()
> 
>  drivers/block/cciss.c | 66 
> ---
>  1 file changed, 31 insertions(+), 35 deletions(-)

How will the clarification be continued for the shown change possibilities?

Regards,
Markus